var NBP=function(){var Gr={},Sn=function(){function Ai(st,vt){if(!Mi[st]){Mi[st]={};for(var Gt=0;Gtqt;qt++){var Nt=vt.charCodeAt(qt);Gt[2*qt]=Nt>>>8,Gt[2*qt+1]=Nt%256}return Gt},decompressFromUint8Array:function(st){if(null==st)return vi.decompress(st);for(var vt=new Array(st.length/2),Gt=0,qt=vt.length;qt>Gt;Gt++)vt[Gt]=256*st[2*Gt]+st[2*Gt+1];var ft=[];return vt.forEach(function(Nt){ft.push(si(Nt))}),vi.decompress(ft.join(""))},compressToEncodedURIComponent:function(st){return null==st?"":vi._compress(st,6,function(vt){return s.charAt(vt)})},decompressFromEncodedURIComponent:function(st){return null==st?"":""==st?null:(st=st.replace(/ /g,"+"),vi._decompress(st.length,32,function(vt){return Ai(s,st.charAt(vt))}))},compress:function(st){return vi._compress(st,16,function(vt){return si(vt)})},_compress:function(st,vt,Gt){if(null==st)return"";var qt,ft,Nt,ni={},kt={},Ri="",_i="",gt="",Oi=2,tr=3,lt=2,zi=[],Pt=0,tt=0;for(Nt=0;Ntqt;qt++)Pt<<=1,tt==vt-1?(tt=0,zi.push(Gt(Pt)),Pt=0):tt++;for(ft=gt.charCodeAt(0),qt=0;8>qt;qt++)Pt=Pt<<1|1&ft,tt==vt-1?(tt=0,zi.push(Gt(Pt)),Pt=0):tt++,ft>>=1}else{for(ft=1,qt=0;lt>qt;qt++)Pt=Pt<<1|ft,tt==vt-1?(tt=0,zi.push(Gt(Pt)),Pt=0):tt++,ft=0;for(ft=gt.charCodeAt(0),qt=0;16>qt;qt++)Pt=Pt<<1|1&ft,tt==vt-1?(tt=0,zi.push(Gt(Pt)),Pt=0):tt++,ft>>=1}0==--Oi&&(Oi=Math.pow(2,lt),lt++),delete kt[gt]}else for(ft=ni[gt],qt=0;lt>qt;qt++)Pt=Pt<<1|1&ft,tt==vt-1?(tt=0,zi.push(Gt(Pt)),Pt=0):tt++,ft>>=1;0==--Oi&&(Oi=Math.pow(2,lt),lt++),ni[_i]=tr++,gt=String(Ri)}if(""!==gt){if(Object.prototype.hasOwnProperty.call(kt,gt)){if(gt.charCodeAt(0)<256){for(qt=0;lt>qt;qt++)Pt<<=1,tt==vt-1?(tt=0,zi.push(Gt(Pt)),Pt=0):tt++;for(ft=gt.charCodeAt(0),qt=0;8>qt;qt++)Pt=Pt<<1|1&ft,tt==vt-1?(tt=0,zi.push(Gt(Pt)),Pt=0):tt++,ft>>=1}else{for(ft=1,qt=0;lt>qt;qt++)Pt=Pt<<1|ft,tt==vt-1?(tt=0,zi.push(Gt(Pt)),Pt=0):tt++,ft=0;for(ft=gt.charCodeAt(0),qt=0;16>qt;qt++)Pt=Pt<<1|1&ft,tt==vt-1?(tt=0,zi.push(Gt(Pt)),Pt=0):tt++,ft>>=1}0==--Oi&&(Oi=Math.pow(2,lt),lt++),delete kt[gt]}else for(ft=ni[gt],qt=0;lt>qt;qt++)Pt=Pt<<1|1&ft,tt==vt-1?(tt=0,zi.push(Gt(Pt)),Pt=0):tt++,ft>>=1;0==--Oi&&(Oi=Math.pow(2,lt),lt++)}for(ft=2,qt=0;lt>qt;qt++)Pt=Pt<<1|1&ft,tt==vt-1?(tt=0,zi.push(Gt(Pt)),Pt=0):tt++,ft>>=1;for(;;){if(Pt<<=1,tt==vt-1){zi.push(Gt(Pt));break}tt++}return zi.join("")},decompress:function(st){return null==st?"":""==st?null:vi._decompress(st.length,32768,function(vt){return st.charCodeAt(vt)})},_decompress:function(st,vt,Gt){var ft,Nt,ni,kt,Ri,_i,gt,Oi=[],tr=4,lt=4,zi=3,Pt="",tt=[],Je={val:Gt(0),position:vt,index:1};for(ft=0;3>ft;ft+=1)Oi[ft]=ft;for(ni=0,Ri=Math.pow(2,2),_i=1;_i!=Ri;)kt=Je.val&Je.position,Je.position>>=1,0==Je.position&&(Je.position=vt,Je.val=Gt(Je.index++)),ni|=(kt>0?1:0)*_i,_i<<=1;switch(ni){case 0:for(ni=0,Ri=Math.pow(2,8),_i=1;_i!=Ri;)kt=Je.val&Je.position,Je.position>>=1,0==Je.position&&(Je.position=vt,Je.val=Gt(Je.index++)),ni|=(kt>0?1:0)*_i,_i<<=1;gt=si(ni);break;case 1:for(ni=0,Ri=Math.pow(2,16),_i=1;_i!=Ri;)kt=Je.val&Je.position,Je.position>>=1,0==Je.position&&(Je.position=vt,Je.val=Gt(Je.index++)),ni|=(kt>0?1:0)*_i,_i<<=1;gt=si(ni);break;case 2:return""}for(Oi[3]=gt,Nt=gt,tt.push(gt);;){if(Je.index>st)return"";for(ni=0,Ri=Math.pow(2,zi),_i=1;_i!=Ri;)kt=Je.val&Je.position,Je.position>>=1,0==Je.position&&(Je.position=vt,Je.val=Gt(Je.index++)),ni|=(kt>0?1:0)*_i,_i<<=1;switch(gt=ni){case 0:for(ni=0,Ri=Math.pow(2,8),_i=1;_i!=Ri;)kt=Je.val&Je.position,Je.position>>=1,0==Je.position&&(Je.position=vt,Je.val=Gt(Je.index++)),ni|=(kt>0?1:0)*_i,_i<<=1;Oi[lt++]=si(ni),gt=lt-1,tr--;break;case 1:for(ni=0,Ri=Math.pow(2,16),_i=1;_i!=Ri;)kt=Je.val&Je.position,Je.position>>=1,0==Je.position&&(Je.position=vt,Je.val=Gt(Je.index++)),ni|=(kt>0?1:0)*_i,_i<<=1;Oi[lt++]=si(ni),gt=lt-1,tr--;break;case 2:return tt.join("")}if(0==tr&&(tr=Math.pow(2,zi),zi++),Oi[gt])Pt=Oi[gt];else{if(gt!==lt)return null;Pt=Nt+Nt.charAt(0)}tt.push(Pt),Oi[lt++]=Nt+Pt.charAt(0),Nt=Pt,0==--tr&&(tr=Math.pow(2,zi),zi++)}}};return vi}();return"function"==typeof define&&define.amd?define(function(){return Sn}):typeof module<"u"&&null!=module&&(module.exports=Sn),bloom={initalized:!1,hashRounds:null,bitArray:null,bitArrayLength:null},initState=!1,bloom.hashes={djb2:function(Ai){for(var si=5381,Gi=Ai.length,s=0;Gi>s;s++)si=33*si^Ai.charCodeAt(s);return(si>>>0)%bloom.bitArrayLength},sdbm:function(Ai){for(var si=0,Gi=Ai.length,s=0;Gi>s;s++)si=Ai.charCodeAt(s)+(si<<6)+(si<<16)-si;return(si>>>0)%bloom.bitArrayLength},getIndices:function(Ai){var si=[];si.push(this.djb2(Ai)),si.push(this.sdbm(Ai));for(var Gi=2;Gi<=bloom.hashRounds;Gi++){var s=(si[0]+Gi*si[1]+(2^Gi))%bloom.bitArrayLength;si.push(s)}return si}},bloom.init=function(Ai,si){var s=Sn.decompressFromUTF16(Ai).split(",");bloom.bitArrayLength=8*s.length,bloom.hashRounds=Math.round(Math.log(2)*bloom.bitArrayLength/si),bloom.bitArray=new Uint8Array(s),bloom.initalized=!0},bloom.checkEntry=function(Ai){if(!bloom.initalized)throw new Error("[NBP] Bloom filter has not been initalized, cannot run.");for(var si=bloom.hashes.getIndices(Ai),Gi=si.length-1;Gi>=0;Gi--){var s=si[Gi]%8,Mi=(si[Gi]-s)/8;if(0!=s&&!(bloom.bitArray[Mi]&128>>s-1)||0==s&&!(1&bloom.bitArray[Mi]))return!1}return!0},Gr.debug={bloom},Gr.init=function(){var Ai=void 0!==arguments[0]?arguments[0]:"mostcommon_10000",si=void 0!==arguments[1]?arguments[1]:"collections/",Gi=void 0===arguments[2]||arguments[2],s=Ai.split("_"),Mi=s[s.length-1];if("number"==typeof Mi)return console.error("[NBP] Provided wordlist file must match the format [list description]_[list length]"),console.error("i.e. mostcommon_10000"),!1;if("/"!==si.slice(-1)&&(si+="/"),typeof localStorage<"u"&&typeof localStorage["NBP_"+Ai]<"u"&&Gi)bloom.init(localStorage["NBP_"+Ai],Mi);else{var vi=new XMLHttpRequest,st="";vi.onreadystatechange=function(){vi.readyState===XMLHttpRequest.DONE&&(200===vi.status?(st=vi.responseText,Gi&&(localStorage["NBP_"+Ai]=st),bloom.init(st,Mi),initState=!0):(console.error("[NBP] Error retrieving bloom contents. Error code: "+vi.status),console.error("[NBP] Ensure that the word list is located at "+si+Ai),console.error("[NBP] Additionally, file must match the format [list description]_[list length]")))},vi.open("GET",""+si+Ai,!0),vi.send(null)}},Gr.isCommonPassword=function(Ai){return""!=Ai&&(bloom.checkEntry(Ai)||bloom.checkEntry(Ai.toLowerCase()))},Gr.testInit=function(){var Ai=void 0!==arguments[0]?arguments[0]:"mostcommon_100000",si=require("fs"),Gi=Ai.split("_"),s=Gi[Gi.length-1],Mi=si.readFileSync("collections/"+Ai,"utf8");bloom.init(Mi,s)},Gr}();typeof module<"u"&&(module.exports=NBP),function(Gr,Sn){"object"==typeof exports&&typeof module<"u"?module.exports=Sn():"function"==typeof define&&define.amd?define(Sn):(Gr=typeof globalThis<"u"?globalThis:Gr||self).mapboxgl=Sn()}(this,function(){"use strict";var Gr,Sn,Ai;function si(s,Mi){if(Gr)if(Sn){var vi="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 = {}; ("+Gr+")(sharedChunk); ("+Sn+")(sharedChunk); self.onerror = null;",st={};Gr(st),Ai=Mi(st),typeof window<"u"&&window&&window.URL&&window.URL.createObjectURL&&(Ai.workerUrl=window.URL.createObjectURL(new Blob([vi],{type:"text/javascript"})))}else Sn=Mi;else Gr=Mi}return si(0,function(s){function Mi(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var vi,st={},vt={};function Gt(){if(vi)return vt;vi=1,Object.defineProperty(vt,"__esModule",{value:!0}),vt.setMatrixArrayType=function(h){vt.ARRAY_TYPE=e=h},vt.toRadian=function(h){return h*o},vt.equals=function(h,a){return Math.abs(h-a)<=n*Math.max(1,Math.abs(h),Math.abs(a))},vt.RANDOM=vt.ARRAY_TYPE=vt.EPSILON=void 0;var n=1e-6;vt.EPSILON=n;var e=typeof Float32Array<"u"?Float32Array:Array;vt.ARRAY_TYPE=e;var i=Math.random;vt.RANDOM=i;var o=Math.PI/180;return Math.hypot||(Math.hypot=function(){for(var h=0,a=arguments.length;a--;)h+=arguments[a]*arguments[a];return Math.sqrt(h)}),vt}var qt,ft={};function Nt(){if(qt)return ft;function n(a){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(u){return typeof u}:function(u){return u&&"function"==typeof Symbol&&u.constructor===Symbol&&u!==Symbol.prototype?"symbol":typeof u})(a)}qt=1,Object.defineProperty(ft,"__esModule",{value:!0}),ft.create=function(){var a=new e.ARRAY_TYPE(4);return e.ARRAY_TYPE!=Float32Array&&(a[1]=0,a[2]=0),a[0]=1,a[3]=1,a},ft.clone=function(a){var u=new e.ARRAY_TYPE(4);return u[0]=a[0],u[1]=a[1],u[2]=a[2],u[3]=a[3],u},ft.copy=function(a,u){return a[0]=u[0],a[1]=u[1],a[2]=u[2],a[3]=u[3],a},ft.identity=function(a){return a[0]=1,a[1]=0,a[2]=0,a[3]=1,a},ft.fromValues=function(a,u,m,x){var w=new e.ARRAY_TYPE(4);return w[0]=a,w[1]=u,w[2]=m,w[3]=x,w},ft.set=function(a,u,m,x,w){return a[0]=u,a[1]=m,a[2]=x,a[3]=w,a},ft.transpose=function(a,u){if(a===u){var m=u[1];a[1]=u[2],a[2]=m}else a[0]=u[0],a[1]=u[2],a[2]=u[1],a[3]=u[3];return a},ft.invert=function(a,u){var m=u[0],x=u[1],w=u[2],p=u[3],g=m*p-w*x;return g?(a[0]=p*(g=1/g),a[1]=-x*g,a[2]=-w*g,a[3]=m*g,a):null},ft.adjoint=function(a,u){var m=u[0];return a[0]=u[3],a[1]=-u[1],a[2]=-u[2],a[3]=m,a},ft.determinant=function(a){return a[0]*a[3]-a[2]*a[1]},ft.multiply=o,ft.rotate=function(a,u,m){var x=u[0],w=u[1],p=u[2],g=u[3],b=Math.sin(m),y=Math.cos(m);return a[0]=x*y+p*b,a[1]=w*y+g*b,a[2]=x*-b+p*y,a[3]=w*-b+g*y,a},ft.scale=function(a,u,m){var x=u[1],w=u[2],p=u[3],g=m[0],b=m[1];return a[0]=u[0]*g,a[1]=x*g,a[2]=w*b,a[3]=p*b,a},ft.fromRotation=function(a,u){var m=Math.sin(u),x=Math.cos(u);return a[0]=x,a[1]=m,a[2]=-m,a[3]=x,a},ft.fromScaling=function(a,u){return a[0]=u[0],a[1]=0,a[2]=0,a[3]=u[1],a},ft.str=function(a){return"mat2("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+")"},ft.frob=function(a){return Math.hypot(a[0],a[1],a[2],a[3])},ft.LDU=function(a,u,m,x){return a[2]=x[2]/x[0],m[0]=x[0],m[1]=x[1],m[3]=x[3]-a[2]*m[1],[a,u,m]},ft.add=function(a,u,m){return a[0]=u[0]+m[0],a[1]=u[1]+m[1],a[2]=u[2]+m[2],a[3]=u[3]+m[3],a},ft.subtract=h,ft.exactEquals=function(a,u){return a[0]===u[0]&&a[1]===u[1]&&a[2]===u[2]&&a[3]===u[3]},ft.equals=function(a,u){var m=a[0],x=a[1],w=a[2],p=a[3],g=u[0],b=u[1],y=u[2],v=u[3];return Math.abs(m-g)<=e.EPSILON*Math.max(1,Math.abs(m),Math.abs(g))&&Math.abs(x-b)<=e.EPSILON*Math.max(1,Math.abs(x),Math.abs(b))&&Math.abs(w-y)<=e.EPSILON*Math.max(1,Math.abs(w),Math.abs(y))&&Math.abs(p-v)<=e.EPSILON*Math.max(1,Math.abs(p),Math.abs(v))},ft.multiplyScalar=function(a,u,m){return a[0]=u[0]*m,a[1]=u[1]*m,a[2]=u[2]*m,a[3]=u[3]*m,a},ft.multiplyScalarAndAdd=function(a,u,m,x){return a[0]=u[0]+m[0]*x,a[1]=u[1]+m[1]*x,a[2]=u[2]+m[2]*x,a[3]=u[3]+m[3]*x,a},ft.sub=ft.mul=void 0;var e=function(a){if(a&&a.__esModule)return a;if(null===a||"object"!==n(a)&&"function"!=typeof a)return{default:a};var m=i(void 0);if(m&&m.has(a))return m.get(a);var x={},w=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var p in a)if("default"!==p&&Object.prototype.hasOwnProperty.call(a,p)){var g=w?Object.getOwnPropertyDescriptor(a,p):null;g&&(g.get||g.set)?Object.defineProperty(x,p,g):x[p]=a[p]}return x.default=a,m&&m.set(a,x),x}(Gt());function i(a){if("function"!=typeof WeakMap)return null;var u=new WeakMap,m=new WeakMap;return(i=function(x){return x?m:u})(a)}function o(a,u,m){var x=u[0],w=u[1],p=u[2],g=u[3],b=m[0],y=m[1],v=m[2],M=m[3];return a[0]=x*b+p*y,a[1]=w*b+g*y,a[2]=x*v+p*M,a[3]=w*v+g*M,a}function h(a,u,m){return a[0]=u[0]-m[0],a[1]=u[1]-m[1],a[2]=u[2]-m[2],a[3]=u[3]-m[3],a}return ft.mul=o,ft.sub=h,ft}var ni,kt={};function Ri(){if(ni)return kt;function n(a){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(u){return typeof u}:function(u){return u&&"function"==typeof Symbol&&u.constructor===Symbol&&u!==Symbol.prototype?"symbol":typeof u})(a)}ni=1,Object.defineProperty(kt,"__esModule",{value:!0}),kt.create=function(){var a=new e.ARRAY_TYPE(6);return e.ARRAY_TYPE!=Float32Array&&(a[1]=0,a[2]=0,a[4]=0,a[5]=0),a[0]=1,a[3]=1,a},kt.clone=function(a){var u=new e.ARRAY_TYPE(6);return u[0]=a[0],u[1]=a[1],u[2]=a[2],u[3]=a[3],u[4]=a[4],u[5]=a[5],u},kt.copy=function(a,u){return a[0]=u[0],a[1]=u[1],a[2]=u[2],a[3]=u[3],a[4]=u[4],a[5]=u[5],a},kt.identity=function(a){return a[0]=1,a[1]=0,a[2]=0,a[3]=1,a[4]=0,a[5]=0,a},kt.fromValues=function(a,u,m,x,w,p){var g=new e.ARRAY_TYPE(6);return g[0]=a,g[1]=u,g[2]=m,g[3]=x,g[4]=w,g[5]=p,g},kt.set=function(a,u,m,x,w,p,g){return a[0]=u,a[1]=m,a[2]=x,a[3]=w,a[4]=p,a[5]=g,a},kt.invert=function(a,u){var m=u[0],x=u[1],w=u[2],p=u[3],g=u[4],b=u[5],y=m*p-x*w;return y?(a[0]=p*(y=1/y),a[1]=-x*y,a[2]=-w*y,a[3]=m*y,a[4]=(w*b-p*g)*y,a[5]=(x*g-m*b)*y,a):null},kt.determinant=function(a){return a[0]*a[3]-a[1]*a[2]},kt.multiply=o,kt.rotate=function(a,u,m){var x=u[0],w=u[1],p=u[2],g=u[3],b=u[4],y=u[5],v=Math.sin(m),M=Math.cos(m);return a[0]=x*M+p*v,a[1]=w*M+g*v,a[2]=x*-v+p*M,a[3]=w*-v+g*M,a[4]=b,a[5]=y,a},kt.scale=function(a,u,m){var x=u[1],w=u[2],p=u[3],g=u[4],b=u[5],y=m[0],v=m[1];return a[0]=u[0]*y,a[1]=x*y,a[2]=w*v,a[3]=p*v,a[4]=g,a[5]=b,a},kt.translate=function(a,u,m){var x=u[0],w=u[1],p=u[2],g=u[3],b=u[4],y=u[5],v=m[0],M=m[1];return a[0]=x,a[1]=w,a[2]=p,a[3]=g,a[4]=x*v+p*M+b,a[5]=w*v+g*M+y,a},kt.fromRotation=function(a,u){var m=Math.sin(u),x=Math.cos(u);return a[0]=x,a[1]=m,a[2]=-m,a[3]=x,a[4]=0,a[5]=0,a},kt.fromScaling=function(a,u){return a[0]=u[0],a[1]=0,a[2]=0,a[3]=u[1],a[4]=0,a[5]=0,a},kt.fromTranslation=function(a,u){return a[0]=1,a[1]=0,a[2]=0,a[3]=1,a[4]=u[0],a[5]=u[1],a},kt.str=function(a){return"mat2d("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+", "+a[4]+", "+a[5]+")"},kt.frob=function(a){return Math.hypot(a[0],a[1],a[2],a[3],a[4],a[5],1)},kt.add=function(a,u,m){return a[0]=u[0]+m[0],a[1]=u[1]+m[1],a[2]=u[2]+m[2],a[3]=u[3]+m[3],a[4]=u[4]+m[4],a[5]=u[5]+m[5],a},kt.subtract=h,kt.multiplyScalar=function(a,u,m){return a[0]=u[0]*m,a[1]=u[1]*m,a[2]=u[2]*m,a[3]=u[3]*m,a[4]=u[4]*m,a[5]=u[5]*m,a},kt.multiplyScalarAndAdd=function(a,u,m,x){return a[0]=u[0]+m[0]*x,a[1]=u[1]+m[1]*x,a[2]=u[2]+m[2]*x,a[3]=u[3]+m[3]*x,a[4]=u[4]+m[4]*x,a[5]=u[5]+m[5]*x,a},kt.exactEquals=function(a,u){return a[0]===u[0]&&a[1]===u[1]&&a[2]===u[2]&&a[3]===u[3]&&a[4]===u[4]&&a[5]===u[5]},kt.equals=function(a,u){var m=a[0],x=a[1],w=a[2],p=a[3],g=a[4],b=a[5],y=u[0],v=u[1],M=u[2],E=u[3],C=u[4],R=u[5];return Math.abs(m-y)<=e.EPSILON*Math.max(1,Math.abs(m),Math.abs(y))&&Math.abs(x-v)<=e.EPSILON*Math.max(1,Math.abs(x),Math.abs(v))&&Math.abs(w-M)<=e.EPSILON*Math.max(1,Math.abs(w),Math.abs(M))&&Math.abs(p-E)<=e.EPSILON*Math.max(1,Math.abs(p),Math.abs(E))&&Math.abs(g-C)<=e.EPSILON*Math.max(1,Math.abs(g),Math.abs(C))&&Math.abs(b-R)<=e.EPSILON*Math.max(1,Math.abs(b),Math.abs(R))},kt.sub=kt.mul=void 0;var e=function(a){if(a&&a.__esModule)return a;if(null===a||"object"!==n(a)&&"function"!=typeof a)return{default:a};var m=i(void 0);if(m&&m.has(a))return m.get(a);var x={},w=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var p in a)if("default"!==p&&Object.prototype.hasOwnProperty.call(a,p)){var g=w?Object.getOwnPropertyDescriptor(a,p):null;g&&(g.get||g.set)?Object.defineProperty(x,p,g):x[p]=a[p]}return x.default=a,m&&m.set(a,x),x}(Gt());function i(a){if("function"!=typeof WeakMap)return null;var u=new WeakMap,m=new WeakMap;return(i=function(x){return x?m:u})(a)}function o(a,u,m){var x=u[0],w=u[1],p=u[2],g=u[3],b=u[4],y=u[5],v=m[0],M=m[1],E=m[2],C=m[3],R=m[4],k=m[5];return a[0]=x*v+p*M,a[1]=w*v+g*M,a[2]=x*E+p*C,a[3]=w*E+g*C,a[4]=x*R+p*k+b,a[5]=w*R+g*k+y,a}function h(a,u,m){return a[0]=u[0]-m[0],a[1]=u[1]-m[1],a[2]=u[2]-m[2],a[3]=u[3]-m[3],a[4]=u[4]-m[4],a[5]=u[5]-m[5],a}return kt.mul=o,kt.sub=h,kt}var _i,gt={};function Oi(){if(_i)return gt;function n(a){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(u){return typeof u}:function(u){return u&&"function"==typeof Symbol&&u.constructor===Symbol&&u!==Symbol.prototype?"symbol":typeof u})(a)}_i=1,Object.defineProperty(gt,"__esModule",{value:!0}),gt.create=function(){var a=new e.ARRAY_TYPE(9);return e.ARRAY_TYPE!=Float32Array&&(a[1]=0,a[2]=0,a[3]=0,a[5]=0,a[6]=0,a[7]=0),a[0]=1,a[4]=1,a[8]=1,a},gt.fromMat4=function(a,u){return a[0]=u[0],a[1]=u[1],a[2]=u[2],a[3]=u[4],a[4]=u[5],a[5]=u[6],a[6]=u[8],a[7]=u[9],a[8]=u[10],a},gt.clone=function(a){var u=new e.ARRAY_TYPE(9);return u[0]=a[0],u[1]=a[1],u[2]=a[2],u[3]=a[3],u[4]=a[4],u[5]=a[5],u[6]=a[6],u[7]=a[7],u[8]=a[8],u},gt.copy=function(a,u){return a[0]=u[0],a[1]=u[1],a[2]=u[2],a[3]=u[3],a[4]=u[4],a[5]=u[5],a[6]=u[6],a[7]=u[7],a[8]=u[8],a},gt.fromValues=function(a,u,m,x,w,p,g,b,y){var v=new e.ARRAY_TYPE(9);return v[0]=a,v[1]=u,v[2]=m,v[3]=x,v[4]=w,v[5]=p,v[6]=g,v[7]=b,v[8]=y,v},gt.set=function(a,u,m,x,w,p,g,b,y,v){return a[0]=u,a[1]=m,a[2]=x,a[3]=w,a[4]=p,a[5]=g,a[6]=b,a[7]=y,a[8]=v,a},gt.identity=function(a){return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=1,a[5]=0,a[6]=0,a[7]=0,a[8]=1,a},gt.transpose=function(a,u){if(a===u){var m=u[1],x=u[2],w=u[5];a[1]=u[3],a[2]=u[6],a[3]=m,a[5]=u[7],a[6]=x,a[7]=w}else a[0]=u[0],a[1]=u[3],a[2]=u[6],a[3]=u[1],a[4]=u[4],a[5]=u[7],a[6]=u[2],a[7]=u[5],a[8]=u[8];return a},gt.invert=function(a,u){var m=u[0],x=u[1],w=u[2],p=u[3],g=u[4],b=u[5],y=u[6],v=u[7],M=u[8],E=M*g-b*v,C=-M*p+b*y,R=v*p-g*y,k=m*E+x*C+w*R;return k?(a[0]=E*(k=1/k),a[1]=(-M*x+w*v)*k,a[2]=(b*x-w*g)*k,a[3]=C*k,a[4]=(M*m-w*y)*k,a[5]=(-b*m+w*p)*k,a[6]=R*k,a[7]=(-v*m+x*y)*k,a[8]=(g*m-x*p)*k,a):null},gt.adjoint=function(a,u){var m=u[0],x=u[1],w=u[2],p=u[3],g=u[4],b=u[5],y=u[6],v=u[7],M=u[8];return a[0]=g*M-b*v,a[1]=w*v-x*M,a[2]=x*b-w*g,a[3]=b*y-p*M,a[4]=m*M-w*y,a[5]=w*p-m*b,a[6]=p*v-g*y,a[7]=x*y-m*v,a[8]=m*g-x*p,a},gt.determinant=function(a){var u=a[3],m=a[4],x=a[5],w=a[6],p=a[7],g=a[8];return a[0]*(g*m-x*p)+a[1]*(-g*u+x*w)+a[2]*(p*u-m*w)},gt.multiply=o,gt.translate=function(a,u,m){var x=u[0],w=u[1],p=u[2],g=u[3],b=u[4],y=u[5],v=u[6],M=u[7],E=u[8],C=m[0],R=m[1];return a[0]=x,a[1]=w,a[2]=p,a[3]=g,a[4]=b,a[5]=y,a[6]=C*x+R*g+v,a[7]=C*w+R*b+M,a[8]=C*p+R*y+E,a},gt.rotate=function(a,u,m){var x=u[0],w=u[1],p=u[2],g=u[3],b=u[4],y=u[5],v=u[6],M=u[7],E=u[8],C=Math.sin(m),R=Math.cos(m);return a[0]=R*x+C*g,a[1]=R*w+C*b,a[2]=R*p+C*y,a[3]=R*g-C*x,a[4]=R*b-C*w,a[5]=R*y-C*p,a[6]=v,a[7]=M,a[8]=E,a},gt.scale=function(a,u,m){var x=m[0],w=m[1];return a[0]=x*u[0],a[1]=x*u[1],a[2]=x*u[2],a[3]=w*u[3],a[4]=w*u[4],a[5]=w*u[5],a[6]=u[6],a[7]=u[7],a[8]=u[8],a},gt.fromTranslation=function(a,u){return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=1,a[5]=0,a[6]=u[0],a[7]=u[1],a[8]=1,a},gt.fromRotation=function(a,u){var m=Math.sin(u),x=Math.cos(u);return a[0]=x,a[1]=m,a[2]=0,a[3]=-m,a[4]=x,a[5]=0,a[6]=0,a[7]=0,a[8]=1,a},gt.fromScaling=function(a,u){return a[0]=u[0],a[1]=0,a[2]=0,a[3]=0,a[4]=u[1],a[5]=0,a[6]=0,a[7]=0,a[8]=1,a},gt.fromMat2d=function(a,u){return a[0]=u[0],a[1]=u[1],a[2]=0,a[3]=u[2],a[4]=u[3],a[5]=0,a[6]=u[4],a[7]=u[5],a[8]=1,a},gt.fromQuat=function(a,u){var m=u[0],x=u[1],w=u[2],p=u[3],g=m+m,b=x+x,y=w+w,v=m*g,M=x*g,E=x*b,C=w*g,R=w*b,k=w*y,P=p*g,O=p*b,B=p*y;return a[0]=1-E-k,a[3]=M-B,a[6]=C+O,a[1]=M+B,a[4]=1-v-k,a[7]=R-P,a[2]=C-O,a[5]=R+P,a[8]=1-v-E,a},gt.normalFromMat4=function(a,u){var m=u[0],x=u[1],w=u[2],p=u[3],g=u[4],b=u[5],y=u[6],v=u[7],M=u[8],E=u[9],C=u[10],R=u[11],k=u[12],P=u[13],O=u[14],B=u[15],G=m*b-x*g,H=m*y-w*g,X=m*v-p*g,Z=x*y-w*b,te=x*v-p*b,K=w*v-p*y,re=M*P-E*k,he=M*O-C*k,pe=M*B-R*k,fe=E*O-C*P,me=E*B-R*P,we=C*B-R*O,ge=G*we-H*me+X*fe+Z*pe-te*he+K*re;return ge?(a[0]=(b*we-y*me+v*fe)*(ge=1/ge),a[1]=(y*pe-g*we-v*he)*ge,a[2]=(g*me-b*pe+v*re)*ge,a[3]=(w*me-x*we-p*fe)*ge,a[4]=(m*we-w*pe+p*he)*ge,a[5]=(x*pe-m*me-p*re)*ge,a[6]=(P*K-O*te+B*Z)*ge,a[7]=(O*X-k*K-B*H)*ge,a[8]=(k*te-P*X+B*G)*ge,a):null},gt.projection=function(a,u,m){return a[0]=2/u,a[1]=0,a[2]=0,a[3]=0,a[4]=-2/m,a[5]=0,a[6]=-1,a[7]=1,a[8]=1,a},gt.str=function(a){return"mat3("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+", "+a[4]+", "+a[5]+", "+a[6]+", "+a[7]+", "+a[8]+")"},gt.frob=function(a){return Math.hypot(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8])},gt.add=function(a,u,m){return a[0]=u[0]+m[0],a[1]=u[1]+m[1],a[2]=u[2]+m[2],a[3]=u[3]+m[3],a[4]=u[4]+m[4],a[5]=u[5]+m[5],a[6]=u[6]+m[6],a[7]=u[7]+m[7],a[8]=u[8]+m[8],a},gt.subtract=h,gt.multiplyScalar=function(a,u,m){return a[0]=u[0]*m,a[1]=u[1]*m,a[2]=u[2]*m,a[3]=u[3]*m,a[4]=u[4]*m,a[5]=u[5]*m,a[6]=u[6]*m,a[7]=u[7]*m,a[8]=u[8]*m,a},gt.multiplyScalarAndAdd=function(a,u,m,x){return a[0]=u[0]+m[0]*x,a[1]=u[1]+m[1]*x,a[2]=u[2]+m[2]*x,a[3]=u[3]+m[3]*x,a[4]=u[4]+m[4]*x,a[5]=u[5]+m[5]*x,a[6]=u[6]+m[6]*x,a[7]=u[7]+m[7]*x,a[8]=u[8]+m[8]*x,a},gt.exactEquals=function(a,u){return a[0]===u[0]&&a[1]===u[1]&&a[2]===u[2]&&a[3]===u[3]&&a[4]===u[4]&&a[5]===u[5]&&a[6]===u[6]&&a[7]===u[7]&&a[8]===u[8]},gt.equals=function(a,u){var m=a[0],x=a[1],w=a[2],p=a[3],g=a[4],b=a[5],y=a[6],v=a[7],M=a[8],E=u[0],C=u[1],R=u[2],k=u[3],P=u[4],O=u[5],B=u[6],G=u[7],H=u[8];return Math.abs(m-E)<=e.EPSILON*Math.max(1,Math.abs(m),Math.abs(E))&&Math.abs(x-C)<=e.EPSILON*Math.max(1,Math.abs(x),Math.abs(C))&&Math.abs(w-R)<=e.EPSILON*Math.max(1,Math.abs(w),Math.abs(R))&&Math.abs(p-k)<=e.EPSILON*Math.max(1,Math.abs(p),Math.abs(k))&&Math.abs(g-P)<=e.EPSILON*Math.max(1,Math.abs(g),Math.abs(P))&&Math.abs(b-O)<=e.EPSILON*Math.max(1,Math.abs(b),Math.abs(O))&&Math.abs(y-B)<=e.EPSILON*Math.max(1,Math.abs(y),Math.abs(B))&&Math.abs(v-G)<=e.EPSILON*Math.max(1,Math.abs(v),Math.abs(G))&&Math.abs(M-H)<=e.EPSILON*Math.max(1,Math.abs(M),Math.abs(H))},gt.sub=gt.mul=void 0;var e=function(a){if(a&&a.__esModule)return a;if(null===a||"object"!==n(a)&&"function"!=typeof a)return{default:a};var m=i(void 0);if(m&&m.has(a))return m.get(a);var x={},w=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var p in a)if("default"!==p&&Object.prototype.hasOwnProperty.call(a,p)){var g=w?Object.getOwnPropertyDescriptor(a,p):null;g&&(g.get||g.set)?Object.defineProperty(x,p,g):x[p]=a[p]}return x.default=a,m&&m.set(a,x),x}(Gt());function i(a){if("function"!=typeof WeakMap)return null;var u=new WeakMap,m=new WeakMap;return(i=function(x){return x?m:u})(a)}function o(a,u,m){var x=u[0],w=u[1],p=u[2],g=u[3],b=u[4],y=u[5],v=u[6],M=u[7],E=u[8],C=m[0],R=m[1],k=m[2],P=m[3],O=m[4],B=m[5],G=m[6],H=m[7],X=m[8];return a[0]=C*x+R*g+k*v,a[1]=C*w+R*b+k*M,a[2]=C*p+R*y+k*E,a[3]=P*x+O*g+B*v,a[4]=P*w+O*b+B*M,a[5]=P*p+O*y+B*E,a[6]=G*x+H*g+X*v,a[7]=G*w+H*b+X*M,a[8]=G*p+H*y+X*E,a}function h(a,u,m){return a[0]=u[0]-m[0],a[1]=u[1]-m[1],a[2]=u[2]-m[2],a[3]=u[3]-m[3],a[4]=u[4]-m[4],a[5]=u[5]-m[5],a[6]=u[6]-m[6],a[7]=u[7]-m[7],a[8]=u[8]-m[8],a}return gt.mul=o,gt.sub=h,gt}var tr,lt={};function zi(){if(tr)return lt;function n(p){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(g){return typeof g}:function(g){return g&&"function"==typeof Symbol&&g.constructor===Symbol&&g!==Symbol.prototype?"symbol":typeof g})(p)}tr=1,Object.defineProperty(lt,"__esModule",{value:!0}),lt.create=function(){var p=new e.ARRAY_TYPE(16);return e.ARRAY_TYPE!=Float32Array&&(p[1]=0,p[2]=0,p[3]=0,p[4]=0,p[6]=0,p[7]=0,p[8]=0,p[9]=0,p[11]=0,p[12]=0,p[13]=0,p[14]=0),p[0]=1,p[5]=1,p[10]=1,p[15]=1,p},lt.clone=function(p){var g=new e.ARRAY_TYPE(16);return g[0]=p[0],g[1]=p[1],g[2]=p[2],g[3]=p[3],g[4]=p[4],g[5]=p[5],g[6]=p[6],g[7]=p[7],g[8]=p[8],g[9]=p[9],g[10]=p[10],g[11]=p[11],g[12]=p[12],g[13]=p[13],g[14]=p[14],g[15]=p[15],g},lt.copy=function(p,g){return p[0]=g[0],p[1]=g[1],p[2]=g[2],p[3]=g[3],p[4]=g[4],p[5]=g[5],p[6]=g[6],p[7]=g[7],p[8]=g[8],p[9]=g[9],p[10]=g[10],p[11]=g[11],p[12]=g[12],p[13]=g[13],p[14]=g[14],p[15]=g[15],p},lt.fromValues=function(p,g,b,y,v,M,E,C,R,k,P,O,B,G,H,X){var Z=new e.ARRAY_TYPE(16);return Z[0]=p,Z[1]=g,Z[2]=b,Z[3]=y,Z[4]=v,Z[5]=M,Z[6]=E,Z[7]=C,Z[8]=R,Z[9]=k,Z[10]=P,Z[11]=O,Z[12]=B,Z[13]=G,Z[14]=H,Z[15]=X,Z},lt.set=function(p,g,b,y,v,M,E,C,R,k,P,O,B,G,H,X,Z){return p[0]=g,p[1]=b,p[2]=y,p[3]=v,p[4]=M,p[5]=E,p[6]=C,p[7]=R,p[8]=k,p[9]=P,p[10]=O,p[11]=B,p[12]=G,p[13]=H,p[14]=X,p[15]=Z,p},lt.identity=o,lt.transpose=function(p,g){if(p===g){var b=g[1],y=g[2],v=g[3],M=g[6],E=g[7],C=g[11];p[1]=g[4],p[2]=g[8],p[3]=g[12],p[4]=b,p[6]=g[9],p[7]=g[13],p[8]=y,p[9]=M,p[11]=g[14],p[12]=v,p[13]=E,p[14]=C}else p[0]=g[0],p[1]=g[4],p[2]=g[8],p[3]=g[12],p[4]=g[1],p[5]=g[5],p[6]=g[9],p[7]=g[13],p[8]=g[2],p[9]=g[6],p[10]=g[10],p[11]=g[14],p[12]=g[3],p[13]=g[7],p[14]=g[11],p[15]=g[15];return p},lt.invert=function(p,g){var b=g[0],y=g[1],v=g[2],M=g[3],E=g[4],C=g[5],R=g[6],k=g[7],P=g[8],O=g[9],B=g[10],G=g[11],H=g[12],X=g[13],Z=g[14],te=g[15],K=b*C-y*E,re=b*R-v*E,he=b*k-M*E,pe=y*R-v*C,fe=y*k-M*C,me=v*k-M*R,we=P*X-O*H,ge=P*Z-B*H,Pe=P*te-G*H,Oe=O*Z-B*X,Ee=O*te-G*X,Ye=B*te-G*Z,$e=K*Ye-re*Ee+he*Oe+pe*Pe-fe*ge+me*we;return $e?(p[0]=(C*Ye-R*Ee+k*Oe)*($e=1/$e),p[1]=(v*Ee-y*Ye-M*Oe)*$e,p[2]=(X*me-Z*fe+te*pe)*$e,p[3]=(B*fe-O*me-G*pe)*$e,p[4]=(R*Pe-E*Ye-k*ge)*$e,p[5]=(b*Ye-v*Pe+M*ge)*$e,p[6]=(Z*he-H*me-te*re)*$e,p[7]=(P*me-B*he+G*re)*$e,p[8]=(E*Ee-C*Pe+k*we)*$e,p[9]=(y*Pe-b*Ee-M*we)*$e,p[10]=(H*fe-X*he+te*K)*$e,p[11]=(O*he-P*fe-G*K)*$e,p[12]=(C*ge-E*Oe-R*we)*$e,p[13]=(b*Oe-y*ge+v*we)*$e,p[14]=(X*re-H*pe-Z*K)*$e,p[15]=(P*pe-O*re+B*K)*$e,p):null},lt.adjoint=function(p,g){var b=g[0],y=g[1],v=g[2],M=g[3],E=g[4],C=g[5],R=g[6],k=g[7],P=g[8],O=g[9],B=g[10],G=g[11],H=g[12],X=g[13],Z=g[14],te=g[15];return p[0]=C*(B*te-G*Z)-O*(R*te-k*Z)+X*(R*G-k*B),p[1]=-(y*(B*te-G*Z)-O*(v*te-M*Z)+X*(v*G-M*B)),p[2]=y*(R*te-k*Z)-C*(v*te-M*Z)+X*(v*k-M*R),p[3]=-(y*(R*G-k*B)-C*(v*G-M*B)+O*(v*k-M*R)),p[4]=-(E*(B*te-G*Z)-P*(R*te-k*Z)+H*(R*G-k*B)),p[5]=b*(B*te-G*Z)-P*(v*te-M*Z)+H*(v*G-M*B),p[6]=-(b*(R*te-k*Z)-E*(v*te-M*Z)+H*(v*k-M*R)),p[7]=b*(R*G-k*B)-E*(v*G-M*B)+P*(v*k-M*R),p[8]=E*(O*te-G*X)-P*(C*te-k*X)+H*(C*G-k*O),p[9]=-(b*(O*te-G*X)-P*(y*te-M*X)+H*(y*G-M*O)),p[10]=b*(C*te-k*X)-E*(y*te-M*X)+H*(y*k-M*C),p[11]=-(b*(C*G-k*O)-E*(y*G-M*O)+P*(y*k-M*C)),p[12]=-(E*(O*Z-B*X)-P*(C*Z-R*X)+H*(C*B-R*O)),p[13]=b*(O*Z-B*X)-P*(y*Z-v*X)+H*(y*B-v*O),p[14]=-(b*(C*Z-R*X)-E*(y*Z-v*X)+H*(y*R-v*C)),p[15]=b*(C*B-R*O)-E*(y*B-v*O)+P*(y*R-v*C),p},lt.determinant=function(p){var g=p[0],b=p[1],y=p[2],v=p[3],M=p[4],E=p[5],C=p[6],R=p[7],k=p[8],P=p[9],O=p[10],B=p[11],G=p[12],H=p[13],X=p[14],Z=p[15];return(g*E-b*M)*(O*Z-B*X)-(g*C-y*M)*(P*Z-B*H)+(g*R-v*M)*(P*X-O*H)+(b*C-y*E)*(k*Z-B*G)-(b*R-v*E)*(k*X-O*G)+(y*R-v*C)*(k*H-P*G)},lt.multiply=h,lt.translate=function(p,g,b){var y,v,M,E,C,R,k,P,O,B,G,H,X=b[0],Z=b[1],te=b[2];return g===p?(p[12]=g[0]*X+g[4]*Z+g[8]*te+g[12],p[13]=g[1]*X+g[5]*Z+g[9]*te+g[13],p[14]=g[2]*X+g[6]*Z+g[10]*te+g[14],p[15]=g[3]*X+g[7]*Z+g[11]*te+g[15]):(v=g[1],M=g[2],E=g[3],C=g[4],R=g[5],k=g[6],P=g[7],O=g[8],B=g[9],G=g[10],H=g[11],p[0]=y=g[0],p[1]=v,p[2]=M,p[3]=E,p[4]=C,p[5]=R,p[6]=k,p[7]=P,p[8]=O,p[9]=B,p[10]=G,p[11]=H,p[12]=y*X+C*Z+O*te+g[12],p[13]=v*X+R*Z+B*te+g[13],p[14]=M*X+k*Z+G*te+g[14],p[15]=E*X+P*Z+H*te+g[15]),p},lt.scale=function(p,g,b){var y=b[0],v=b[1],M=b[2];return p[0]=g[0]*y,p[1]=g[1]*y,p[2]=g[2]*y,p[3]=g[3]*y,p[4]=g[4]*v,p[5]=g[5]*v,p[6]=g[6]*v,p[7]=g[7]*v,p[8]=g[8]*M,p[9]=g[9]*M,p[10]=g[10]*M,p[11]=g[11]*M,p[12]=g[12],p[13]=g[13],p[14]=g[14],p[15]=g[15],p},lt.rotate=function(p,g,b,y){var v,M,E,C,R,k,P,O,B,G,H,X,Z,te,K,re,he,pe,fe,me,we,ge,Pe,Oe,Ee=y[0],Ye=y[1],$e=y[2],je=Math.hypot(Ee,Ye,$e);return je0?(b[0]=2*(C*E+P*y+R*M-k*v)/O,b[1]=2*(R*E+P*v+k*y-C*M)/O,b[2]=2*(k*E+P*M+C*v-R*y)/O):(b[0]=2*(C*E+P*y+R*M-k*v),b[1]=2*(R*E+P*v+k*y-C*M),b[2]=2*(k*E+P*M+C*v-R*y)),a(p,g,b),p},lt.getTranslation=function(p,g){return p[0]=g[12],p[1]=g[13],p[2]=g[14],p},lt.getScaling=u,lt.getRotation=function(p,g){var b=new e.ARRAY_TYPE(3);u(b,g);var y=1/b[0],v=1/b[1],M=1/b[2],E=g[0]*y,C=g[1]*v,R=g[2]*M,k=g[4]*y,P=g[5]*v,O=g[6]*M,B=g[8]*y,G=g[9]*v,H=g[10]*M,X=E+P+H,Z=0;return X>0?(Z=2*Math.sqrt(X+1),p[3]=.25*Z,p[0]=(O-G)/Z,p[1]=(B-R)/Z,p[2]=(C-k)/Z):E>P&&E>H?(Z=2*Math.sqrt(1+E-P-H),p[3]=(O-G)/Z,p[0]=.25*Z,p[1]=(C+k)/Z,p[2]=(B+R)/Z):P>H?(Z=2*Math.sqrt(1+P-E-H),p[3]=(B-R)/Z,p[0]=(C+k)/Z,p[1]=.25*Z,p[2]=(O+G)/Z):(Z=2*Math.sqrt(1+H-E-P),p[3]=(C-k)/Z,p[0]=(B+R)/Z,p[1]=(O+G)/Z,p[2]=.25*Z),p},lt.fromRotationTranslationScale=function(p,g,b,y){var v=g[0],M=g[1],E=g[2],C=g[3],R=v+v,k=M+M,P=E+E,O=v*R,B=v*k,G=v*P,H=M*k,X=M*P,Z=E*P,te=C*R,K=C*k,re=C*P,he=y[0],pe=y[1],fe=y[2];return p[0]=(1-(H+Z))*he,p[1]=(B+re)*he,p[2]=(G-K)*he,p[3]=0,p[4]=(B-re)*pe,p[5]=(1-(O+Z))*pe,p[6]=(X+te)*pe,p[7]=0,p[8]=(G+K)*fe,p[9]=(X-te)*fe,p[10]=(1-(O+H))*fe,p[11]=0,p[12]=b[0],p[13]=b[1],p[14]=b[2],p[15]=1,p},lt.fromRotationTranslationScaleOrigin=function(p,g,b,y,v){var M=g[0],E=g[1],C=g[2],R=g[3],k=M+M,P=E+E,O=C+C,B=M*k,G=M*P,H=M*O,X=E*P,Z=E*O,te=C*O,K=R*k,re=R*P,he=R*O,pe=y[0],fe=y[1],me=y[2],we=v[0],ge=v[1],Pe=v[2],Oe=(1-(X+te))*pe,Ee=(G+he)*pe,Ye=(H-re)*pe,$e=(G-he)*fe,je=(1-(B+te))*fe,Fe=(Z+K)*fe,ut=(H+re)*me,Xe=(Z-K)*me,it=(1-(B+X))*me;return p[0]=Oe,p[1]=Ee,p[2]=Ye,p[3]=0,p[4]=$e,p[5]=je,p[6]=Fe,p[7]=0,p[8]=ut,p[9]=Xe,p[10]=it,p[11]=0,p[12]=b[0]+we-(Oe*we+$e*ge+ut*Pe),p[13]=b[1]+ge-(Ee*we+je*ge+Xe*Pe),p[14]=b[2]+Pe-(Ye*we+Fe*ge+it*Pe),p[15]=1,p},lt.fromQuat=function(p,g){var b=g[0],y=g[1],v=g[2],M=g[3],E=b+b,C=y+y,R=v+v,k=b*E,P=y*E,O=y*C,B=v*E,G=v*C,H=v*R,X=M*E,Z=M*C,te=M*R;return p[0]=1-O-H,p[1]=P+te,p[2]=B-Z,p[3]=0,p[4]=P-te,p[5]=1-k-H,p[6]=G+X,p[7]=0,p[8]=B+Z,p[9]=G-X,p[10]=1-k-O,p[11]=0,p[12]=0,p[13]=0,p[14]=0,p[15]=1,p},lt.frustum=function(p,g,b,y,v,M,E){var C=1/(b-g),R=1/(v-y),k=1/(M-E);return p[0]=2*M*C,p[1]=0,p[2]=0,p[3]=0,p[4]=0,p[5]=2*M*R,p[6]=0,p[7]=0,p[8]=(b+g)*C,p[9]=(v+y)*R,p[10]=(E+M)*k,p[11]=-1,p[12]=0,p[13]=0,p[14]=E*M*2*k,p[15]=0,p},lt.perspectiveNO=m,lt.perspectiveZO=function(p,g,b,y,v){var M,E=1/Math.tan(g/2);return p[0]=E/b,p[1]=0,p[2]=0,p[3]=0,p[4]=0,p[5]=E,p[6]=0,p[7]=0,p[8]=0,p[9]=0,p[11]=-1,p[12]=0,p[13]=0,p[15]=0,null!=v&&v!==1/0?(p[10]=v*(M=1/(y-v)),p[14]=v*y*M):(p[10]=-1,p[14]=-y),p},lt.perspectiveFromFieldOfView=function(p,g,b,y){var v=Math.tan(g.upDegrees*Math.PI/180),M=Math.tan(g.downDegrees*Math.PI/180),E=Math.tan(g.leftDegrees*Math.PI/180),C=Math.tan(g.rightDegrees*Math.PI/180),R=2/(E+C),k=2/(v+M);return p[0]=R,p[1]=0,p[2]=0,p[3]=0,p[4]=0,p[5]=k,p[6]=0,p[7]=0,p[8]=-(E-C)*R*.5,p[9]=(v-M)*k*.5,p[10]=y/(b-y),p[11]=-1,p[12]=0,p[13]=0,p[14]=y*b/(b-y),p[15]=0,p},lt.orthoNO=x,lt.orthoZO=function(p,g,b,y,v,M,E){var C=1/(g-b),R=1/(y-v),k=1/(M-E);return p[0]=-2*C,p[1]=0,p[2]=0,p[3]=0,p[4]=0,p[5]=-2*R,p[6]=0,p[7]=0,p[8]=0,p[9]=0,p[10]=k,p[11]=0,p[12]=(g+b)*C,p[13]=(v+y)*R,p[14]=M*k,p[15]=1,p},lt.lookAt=function(p,g,b,y){var v,M,E,C,R,k,P,O,B,G,H=g[0],X=g[1],Z=g[2],te=y[0],K=y[1],re=y[2],he=b[0],pe=b[1],fe=b[2];return Math.abs(H-he)0&&(P*=G=1/Math.sqrt(G),O*=G,B*=G);var H=R*B-k*O,X=k*P-C*B,Z=C*O-R*P;return(G=H*H+X*X+Z*Z)>0&&(H*=G=1/Math.sqrt(G),X*=G,Z*=G),p[0]=H,p[1]=X,p[2]=Z,p[3]=0,p[4]=O*Z-B*X,p[5]=B*H-P*Z,p[6]=P*X-O*H,p[7]=0,p[8]=P,p[9]=O,p[10]=B,p[11]=0,p[12]=v,p[13]=M,p[14]=E,p[15]=1,p},lt.str=function(p){return"mat4("+p[0]+", "+p[1]+", "+p[2]+", "+p[3]+", "+p[4]+", "+p[5]+", "+p[6]+", "+p[7]+", "+p[8]+", "+p[9]+", "+p[10]+", "+p[11]+", "+p[12]+", "+p[13]+", "+p[14]+", "+p[15]+")"},lt.frob=function(p){return Math.hypot(p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15])},lt.add=function(p,g,b){return p[0]=g[0]+b[0],p[1]=g[1]+b[1],p[2]=g[2]+b[2],p[3]=g[3]+b[3],p[4]=g[4]+b[4],p[5]=g[5]+b[5],p[6]=g[6]+b[6],p[7]=g[7]+b[7],p[8]=g[8]+b[8],p[9]=g[9]+b[9],p[10]=g[10]+b[10],p[11]=g[11]+b[11],p[12]=g[12]+b[12],p[13]=g[13]+b[13],p[14]=g[14]+b[14],p[15]=g[15]+b[15],p},lt.subtract=w,lt.multiplyScalar=function(p,g,b){return p[0]=g[0]*b,p[1]=g[1]*b,p[2]=g[2]*b,p[3]=g[3]*b,p[4]=g[4]*b,p[5]=g[5]*b,p[6]=g[6]*b,p[7]=g[7]*b,p[8]=g[8]*b,p[9]=g[9]*b,p[10]=g[10]*b,p[11]=g[11]*b,p[12]=g[12]*b,p[13]=g[13]*b,p[14]=g[14]*b,p[15]=g[15]*b,p},lt.multiplyScalarAndAdd=function(p,g,b,y){return p[0]=g[0]+b[0]*y,p[1]=g[1]+b[1]*y,p[2]=g[2]+b[2]*y,p[3]=g[3]+b[3]*y,p[4]=g[4]+b[4]*y,p[5]=g[5]+b[5]*y,p[6]=g[6]+b[6]*y,p[7]=g[7]+b[7]*y,p[8]=g[8]+b[8]*y,p[9]=g[9]+b[9]*y,p[10]=g[10]+b[10]*y,p[11]=g[11]+b[11]*y,p[12]=g[12]+b[12]*y,p[13]=g[13]+b[13]*y,p[14]=g[14]+b[14]*y,p[15]=g[15]+b[15]*y,p},lt.exactEquals=function(p,g){return p[0]===g[0]&&p[1]===g[1]&&p[2]===g[2]&&p[3]===g[3]&&p[4]===g[4]&&p[5]===g[5]&&p[6]===g[6]&&p[7]===g[7]&&p[8]===g[8]&&p[9]===g[9]&&p[10]===g[10]&&p[11]===g[11]&&p[12]===g[12]&&p[13]===g[13]&&p[14]===g[14]&&p[15]===g[15]},lt.equals=function(p,g){var b=p[0],y=p[1],v=p[2],M=p[3],E=p[4],C=p[5],R=p[6],k=p[7],P=p[8],O=p[9],B=p[10],G=p[11],H=p[12],X=p[13],Z=p[14],te=p[15],K=g[0],re=g[1],he=g[2],pe=g[3],fe=g[4],me=g[5],we=g[6],ge=g[7],Pe=g[8],Oe=g[9],Ee=g[10],Ye=g[11],$e=g[12],je=g[13],Fe=g[14],ut=g[15];return Math.abs(b-K)<=e.EPSILON*Math.max(1,Math.abs(b),Math.abs(K))&&Math.abs(y-re)<=e.EPSILON*Math.max(1,Math.abs(y),Math.abs(re))&&Math.abs(v-he)<=e.EPSILON*Math.max(1,Math.abs(v),Math.abs(he))&&Math.abs(M-pe)<=e.EPSILON*Math.max(1,Math.abs(M),Math.abs(pe))&&Math.abs(E-fe)<=e.EPSILON*Math.max(1,Math.abs(E),Math.abs(fe))&&Math.abs(C-me)<=e.EPSILON*Math.max(1,Math.abs(C),Math.abs(me))&&Math.abs(R-we)<=e.EPSILON*Math.max(1,Math.abs(R),Math.abs(we))&&Math.abs(k-ge)<=e.EPSILON*Math.max(1,Math.abs(k),Math.abs(ge))&&Math.abs(P-Pe)<=e.EPSILON*Math.max(1,Math.abs(P),Math.abs(Pe))&&Math.abs(O-Oe)<=e.EPSILON*Math.max(1,Math.abs(O),Math.abs(Oe))&&Math.abs(B-Ee)<=e.EPSILON*Math.max(1,Math.abs(B),Math.abs(Ee))&&Math.abs(G-Ye)<=e.EPSILON*Math.max(1,Math.abs(G),Math.abs(Ye))&&Math.abs(H-$e)<=e.EPSILON*Math.max(1,Math.abs(H),Math.abs($e))&&Math.abs(X-je)<=e.EPSILON*Math.max(1,Math.abs(X),Math.abs(je))&&Math.abs(Z-Fe)<=e.EPSILON*Math.max(1,Math.abs(Z),Math.abs(Fe))&&Math.abs(te-ut)<=e.EPSILON*Math.max(1,Math.abs(te),Math.abs(ut))},lt.sub=lt.mul=lt.ortho=lt.perspective=void 0;var e=function(p){if(p&&p.__esModule)return p;if(null===p||"object"!==n(p)&&"function"!=typeof p)return{default:p};var b=i(void 0);if(b&&b.has(p))return b.get(p);var y={},v=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var M in p)if("default"!==M&&Object.prototype.hasOwnProperty.call(p,M)){var E=v?Object.getOwnPropertyDescriptor(p,M):null;E&&(E.get||E.set)?Object.defineProperty(y,M,E):y[M]=p[M]}return y.default=p,b&&b.set(p,y),y}(Gt());function i(p){if("function"!=typeof WeakMap)return null;var g=new WeakMap,b=new WeakMap;return(i=function(y){return y?b:g})(p)}function o(p){return p[0]=1,p[1]=0,p[2]=0,p[3]=0,p[4]=0,p[5]=1,p[6]=0,p[7]=0,p[8]=0,p[9]=0,p[10]=1,p[11]=0,p[12]=0,p[13]=0,p[14]=0,p[15]=1,p}function h(p,g,b){var y=g[0],v=g[1],M=g[2],E=g[3],C=g[4],R=g[5],k=g[6],P=g[7],O=g[8],B=g[9],G=g[10],H=g[11],X=g[12],Z=g[13],te=g[14],K=g[15],re=b[0],he=b[1],pe=b[2],fe=b[3];return p[0]=re*y+he*C+pe*O+fe*X,p[1]=re*v+he*R+pe*B+fe*Z,p[2]=re*M+he*k+pe*G+fe*te,p[3]=re*E+he*P+pe*H+fe*K,p[4]=(re=b[4])*y+(he=b[5])*C+(pe=b[6])*O+(fe=b[7])*X,p[5]=re*v+he*R+pe*B+fe*Z,p[6]=re*M+he*k+pe*G+fe*te,p[7]=re*E+he*P+pe*H+fe*K,p[8]=(re=b[8])*y+(he=b[9])*C+(pe=b[10])*O+(fe=b[11])*X,p[9]=re*v+he*R+pe*B+fe*Z,p[10]=re*M+he*k+pe*G+fe*te,p[11]=re*E+he*P+pe*H+fe*K,p[12]=(re=b[12])*y+(he=b[13])*C+(pe=b[14])*O+(fe=b[15])*X,p[13]=re*v+he*R+pe*B+fe*Z,p[14]=re*M+he*k+pe*G+fe*te,p[15]=re*E+he*P+pe*H+fe*K,p}function a(p,g,b){var y=g[0],v=g[1],M=g[2],E=g[3],C=y+y,R=v+v,k=M+M,P=y*C,O=y*R,B=y*k,G=v*R,H=v*k,X=M*k,Z=E*C,te=E*R,K=E*k;return p[0]=1-(G+X),p[1]=O+K,p[2]=B-te,p[3]=0,p[4]=O-K,p[5]=1-(P+X),p[6]=H+Z,p[7]=0,p[8]=B+te,p[9]=H-Z,p[10]=1-(P+G),p[11]=0,p[12]=b[0],p[13]=b[1],p[14]=b[2],p[15]=1,p}function u(p,g){var b=g[4],y=g[5],v=g[6],M=g[8],E=g[9],C=g[10];return p[0]=Math.hypot(g[0],g[1],g[2]),p[1]=Math.hypot(b,y,v),p[2]=Math.hypot(M,E,C),p}function m(p,g,b,y,v){var M,E=1/Math.tan(g/2);return p[0]=E/b,p[1]=0,p[2]=0,p[3]=0,p[4]=0,p[5]=E,p[6]=0,p[7]=0,p[8]=0,p[9]=0,p[11]=-1,p[12]=0,p[13]=0,p[15]=0,null!=v&&v!==1/0?(p[10]=(v+y)*(M=1/(y-v)),p[14]=2*v*y*M):(p[10]=-1,p[14]=-2*y),p}function x(p,g,b,y,v,M,E){var C=1/(g-b),R=1/(y-v),k=1/(M-E);return p[0]=-2*C,p[1]=0,p[2]=0,p[3]=0,p[4]=0,p[5]=-2*R,p[6]=0,p[7]=0,p[8]=0,p[9]=0,p[10]=2*k,p[11]=0,p[12]=(g+b)*C,p[13]=(v+y)*R,p[14]=(E+M)*k,p[15]=1,p}function w(p,g,b){return p[0]=g[0]-b[0],p[1]=g[1]-b[1],p[2]=g[2]-b[2],p[3]=g[3]-b[3],p[4]=g[4]-b[4],p[5]=g[5]-b[5],p[6]=g[6]-b[6],p[7]=g[7]-b[7],p[8]=g[8]-b[8],p[9]=g[9]-b[9],p[10]=g[10]-b[10],p[11]=g[11]-b[11],p[12]=g[12]-b[12],p[13]=g[13]-b[13],p[14]=g[14]-b[14],p[15]=g[15]-b[15],p}return lt.perspective=m,lt.ortho=x,lt.mul=h,lt.sub=w,lt}var Pt,tt={},Je={};function uo(){if(Pt)return Je;function n(v){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(M){return typeof M}:function(M){return M&&"function"==typeof Symbol&&M.constructor===Symbol&&M!==Symbol.prototype?"symbol":typeof M})(v)}Pt=1,Object.defineProperty(Je,"__esModule",{value:!0}),Je.create=o,Je.clone=function(v){var M=new e.ARRAY_TYPE(3);return M[0]=v[0],M[1]=v[1],M[2]=v[2],M},Je.length=h,Je.fromValues=function(v,M,E){var C=new e.ARRAY_TYPE(3);return C[0]=v,C[1]=M,C[2]=E,C},Je.copy=function(v,M){return v[0]=M[0],v[1]=M[1],v[2]=M[2],v},Je.set=function(v,M,E,C){return v[0]=M,v[1]=E,v[2]=C,v},Je.add=function(v,M,E){return v[0]=M[0]+E[0],v[1]=M[1]+E[1],v[2]=M[2]+E[2],v},Je.subtract=a,Je.multiply=u,Je.divide=m,Je.ceil=function(v,M){return v[0]=Math.ceil(M[0]),v[1]=Math.ceil(M[1]),v[2]=Math.ceil(M[2]),v},Je.floor=function(v,M){return v[0]=Math.floor(M[0]),v[1]=Math.floor(M[1]),v[2]=Math.floor(M[2]),v},Je.min=function(v,M,E){return v[0]=Math.min(M[0],E[0]),v[1]=Math.min(M[1],E[1]),v[2]=Math.min(M[2],E[2]),v},Je.max=function(v,M,E){return v[0]=Math.max(M[0],E[0]),v[1]=Math.max(M[1],E[1]),v[2]=Math.max(M[2],E[2]),v},Je.round=function(v,M){return v[0]=Math.round(M[0]),v[1]=Math.round(M[1]),v[2]=Math.round(M[2]),v},Je.scale=function(v,M,E){return v[0]=M[0]*E,v[1]=M[1]*E,v[2]=M[2]*E,v},Je.scaleAndAdd=function(v,M,E,C){return v[0]=M[0]+E[0]*C,v[1]=M[1]+E[1]*C,v[2]=M[2]+E[2]*C,v},Je.distance=x,Je.squaredDistance=w,Je.squaredLength=p,Je.negate=function(v,M){return v[0]=-M[0],v[1]=-M[1],v[2]=-M[2],v},Je.inverse=function(v,M){return v[0]=1/M[0],v[1]=1/M[1],v[2]=1/M[2],v},Je.normalize=function(v,M){var E=M[0],C=M[1],R=M[2],k=E*E+C*C+R*R;return k>0&&(k=1/Math.sqrt(k)),v[0]=M[0]*k,v[1]=M[1]*k,v[2]=M[2]*k,v},Je.dot=g,Je.cross=function(v,M,E){var C=M[0],R=M[1],k=M[2],P=E[0],O=E[1],B=E[2];return v[0]=R*B-k*O,v[1]=k*P-C*B,v[2]=C*O-R*P,v},Je.lerp=function(v,M,E,C){var R=M[0],k=M[1],P=M[2];return v[0]=R+C*(E[0]-R),v[1]=k+C*(E[1]-k),v[2]=P+C*(E[2]-P),v},Je.hermite=function(v,M,E,C,R,k){var P=k*k,O=P*(2*k-3)+1,B=P*(k-2)+k,G=P*(k-1),H=P*(3-2*k);return v[0]=M[0]*O+E[0]*B+C[0]*G+R[0]*H,v[1]=M[1]*O+E[1]*B+C[1]*G+R[1]*H,v[2]=M[2]*O+E[2]*B+C[2]*G+R[2]*H,v},Je.bezier=function(v,M,E,C,R,k){var P=1-k,O=P*P,B=k*k,G=O*P,H=3*k*O,X=3*B*P,Z=B*k;return v[0]=M[0]*G+E[0]*H+C[0]*X+R[0]*Z,v[1]=M[1]*G+E[1]*H+C[1]*X+R[1]*Z,v[2]=M[2]*G+E[2]*H+C[2]*X+R[2]*Z,v},Je.random=function(v,M){M=M||1;var E=2*e.RANDOM()*Math.PI,C=2*e.RANDOM()-1,R=Math.sqrt(1-C*C)*M;return v[0]=Math.cos(E)*R,v[1]=Math.sin(E)*R,v[2]=C*M,v},Je.transformMat4=function(v,M,E){var C=M[0],R=M[1],k=M[2],P=E[3]*C+E[7]*R+E[11]*k+E[15];return v[0]=(E[0]*C+E[4]*R+E[8]*k+E[12])/(P=P||1),v[1]=(E[1]*C+E[5]*R+E[9]*k+E[13])/P,v[2]=(E[2]*C+E[6]*R+E[10]*k+E[14])/P,v},Je.transformMat3=function(v,M,E){var C=M[0],R=M[1],k=M[2];return v[0]=C*E[0]+R*E[3]+k*E[6],v[1]=C*E[1]+R*E[4]+k*E[7],v[2]=C*E[2]+R*E[5]+k*E[8],v},Je.transformQuat=function(v,M,E){var C=E[0],R=E[1],k=E[2],P=M[0],O=M[1],B=M[2],G=R*B-k*O,H=k*P-C*B,X=C*O-R*P,Z=R*X-k*H,te=k*G-C*X,K=C*H-R*G,re=2*E[3];return H*=re,X*=re,te*=2,K*=2,v[0]=P+(G*=re)+(Z*=2),v[1]=O+H+te,v[2]=B+X+K,v},Je.rotateX=function(v,M,E,C){var R=[],k=[];return R[0]=M[0]-E[0],R[1]=M[1]-E[1],R[2]=M[2]-E[2],k[0]=R[0],k[1]=R[1]*Math.cos(C)-R[2]*Math.sin(C),k[2]=R[1]*Math.sin(C)+R[2]*Math.cos(C),v[0]=k[0]+E[0],v[1]=k[1]+E[1],v[2]=k[2]+E[2],v},Je.rotateY=function(v,M,E,C){var R=[],k=[];return R[0]=M[0]-E[0],R[1]=M[1]-E[1],R[2]=M[2]-E[2],k[0]=R[2]*Math.sin(C)+R[0]*Math.cos(C),k[1]=R[1],k[2]=R[2]*Math.cos(C)-R[0]*Math.sin(C),v[0]=k[0]+E[0],v[1]=k[1]+E[1],v[2]=k[2]+E[2],v},Je.rotateZ=function(v,M,E,C){var R=[],k=[];return R[0]=M[0]-E[0],R[1]=M[1]-E[1],R[2]=M[2]-E[2],k[0]=R[0]*Math.cos(C)-R[1]*Math.sin(C),k[1]=R[0]*Math.sin(C)+R[1]*Math.cos(C),k[2]=R[2],v[0]=k[0]+E[0],v[1]=k[1]+E[1],v[2]=k[2]+E[2],v},Je.angle=function(v,M){var E=v[0],C=v[1],R=v[2],k=M[0],P=M[1],O=M[2],B=Math.sqrt(E*E+C*C+R*R)*Math.sqrt(k*k+P*P+O*O),G=B&&g(v,M)/B;return Math.acos(Math.min(Math.max(G,-1),1))},Je.zero=function(v){return v[0]=0,v[1]=0,v[2]=0,v},Je.str=function(v){return"vec3("+v[0]+", "+v[1]+", "+v[2]+")"},Je.exactEquals=function(v,M){return v[0]===M[0]&&v[1]===M[1]&&v[2]===M[2]},Je.equals=function(v,M){var E=v[0],C=v[1],R=v[2],k=M[0],P=M[1],O=M[2];return Math.abs(E-k)<=e.EPSILON*Math.max(1,Math.abs(E),Math.abs(k))&&Math.abs(C-P)<=e.EPSILON*Math.max(1,Math.abs(C),Math.abs(P))&&Math.abs(R-O)<=e.EPSILON*Math.max(1,Math.abs(R),Math.abs(O))},Je.forEach=Je.sqrLen=Je.len=Je.sqrDist=Je.dist=Je.div=Je.mul=Je.sub=void 0;var e=function(v){if(v&&v.__esModule)return v;if(null===v||"object"!==n(v)&&"function"!=typeof v)return{default:v};var E=i(void 0);if(E&&E.has(v))return E.get(v);var C={},R=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var k in v)if("default"!==k&&Object.prototype.hasOwnProperty.call(v,k)){var P=R?Object.getOwnPropertyDescriptor(v,k):null;P&&(P.get||P.set)?Object.defineProperty(C,k,P):C[k]=v[k]}return C.default=v,E&&E.set(v,C),C}(Gt());function i(v){if("function"!=typeof WeakMap)return null;var M=new WeakMap,E=new WeakMap;return(i=function(C){return C?E:M})(v)}function o(){var v=new e.ARRAY_TYPE(3);return e.ARRAY_TYPE!=Float32Array&&(v[0]=0,v[1]=0,v[2]=0),v}function h(v){return Math.hypot(v[0],v[1],v[2])}function a(v,M,E){return v[0]=M[0]-E[0],v[1]=M[1]-E[1],v[2]=M[2]-E[2],v}function u(v,M,E){return v[0]=M[0]*E[0],v[1]=M[1]*E[1],v[2]=M[2]*E[2],v}function m(v,M,E){return v[0]=M[0]/E[0],v[1]=M[1]/E[1],v[2]=M[2]/E[2],v}function x(v,M){return Math.hypot(M[0]-v[0],M[1]-v[1],M[2]-v[2])}function w(v,M){var E=M[0]-v[0],C=M[1]-v[1],R=M[2]-v[2];return E*E+C*C+R*R}function p(v){var M=v[0],E=v[1],C=v[2];return M*M+E*E+C*C}function g(v,M){return v[0]*M[0]+v[1]*M[1]+v[2]*M[2]}Je.sub=a,Je.mul=u,Je.div=m,Je.dist=x,Je.sqrDist=w,Je.len=h,Je.sqrLen=p;var b,y=(b=o(),function(v,M,E,C,R,k){var P,O;for(M||(M=3),E||(E=0),O=C?Math.min(C*M+E,v.length):v.length,P=E;P0&&(k=1/Math.sqrt(k)),y[0]=M*k,y[1]=E*k,y[2]=C*k,y[3]=R*k,y},Vt.dot=function(y,v){return y[0]*v[0]+y[1]*v[1]+y[2]*v[2]+y[3]*v[3]},Vt.cross=function(y,v,M,E){var C=M[0]*E[1]-M[1]*E[0],R=M[0]*E[2]-M[2]*E[0],k=M[0]*E[3]-M[3]*E[0],P=M[1]*E[2]-M[2]*E[1],O=M[1]*E[3]-M[3]*E[1],B=M[2]*E[3]-M[3]*E[2],G=v[0],H=v[1],X=v[2],Z=v[3];return y[0]=H*B-X*O+Z*P,y[1]=-G*B+X*k-Z*R,y[2]=G*O-H*k+Z*C,y[3]=-G*P+H*R-X*C,y},Vt.lerp=function(y,v,M,E){var C=v[0],R=v[1],k=v[2],P=v[3];return y[0]=C+E*(M[0]-C),y[1]=R+E*(M[1]-R),y[2]=k+E*(M[2]-k),y[3]=P+E*(M[3]-P),y},Vt.random=function(y,v){var M,E,C,R,k,P;v=v||1;do{k=(M=2*e.RANDOM()-1)*M+(E=2*e.RANDOM()-1)*E}while(k>=1);do{P=(C=2*e.RANDOM()-1)*C+(R=2*e.RANDOM()-1)*R}while(P>=1);var O=Math.sqrt((1-k)/P);return y[0]=v*M,y[1]=v*E,y[2]=v*C*O,y[3]=v*R*O,y},Vt.transformMat4=function(y,v,M){var E=v[0],C=v[1],R=v[2],k=v[3];return y[0]=M[0]*E+M[4]*C+M[8]*R+M[12]*k,y[1]=M[1]*E+M[5]*C+M[9]*R+M[13]*k,y[2]=M[2]*E+M[6]*C+M[10]*R+M[14]*k,y[3]=M[3]*E+M[7]*C+M[11]*R+M[15]*k,y},Vt.transformQuat=function(y,v,M){var E=v[0],C=v[1],R=v[2],k=M[0],P=M[1],O=M[2],B=M[3],G=B*E+P*R-O*C,H=B*C+O*E-k*R,X=B*R+k*C-P*E,Z=-k*E-P*C-O*R;return y[0]=G*B+Z*-k+H*-O-X*-P,y[1]=H*B+Z*-P+X*-k-G*-O,y[2]=X*B+Z*-O+G*-P-H*-k,y[3]=v[3],y},Vt.zero=function(y){return y[0]=0,y[1]=0,y[2]=0,y[3]=0,y},Vt.str=function(y){return"vec4("+y[0]+", "+y[1]+", "+y[2]+", "+y[3]+")"},Vt.exactEquals=function(y,v){return y[0]===v[0]&&y[1]===v[1]&&y[2]===v[2]&&y[3]===v[3]},Vt.equals=function(y,v){var M=y[0],E=y[1],C=y[2],R=y[3],k=v[0],P=v[1],O=v[2],B=v[3];return Math.abs(M-k)<=e.EPSILON*Math.max(1,Math.abs(M),Math.abs(k))&&Math.abs(E-P)<=e.EPSILON*Math.max(1,Math.abs(E),Math.abs(P))&&Math.abs(C-O)<=e.EPSILON*Math.max(1,Math.abs(C),Math.abs(O))&&Math.abs(R-B)<=e.EPSILON*Math.max(1,Math.abs(R),Math.abs(B))},Vt.forEach=Vt.sqrLen=Vt.len=Vt.sqrDist=Vt.dist=Vt.div=Vt.mul=Vt.sub=void 0;var e=function(y){if(y&&y.__esModule)return y;if(null===y||"object"!==n(y)&&"function"!=typeof y)return{default:y};var M=i(void 0);if(M&&M.has(y))return M.get(y);var E={},C=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var R in y)if("default"!==R&&Object.prototype.hasOwnProperty.call(y,R)){var k=C?Object.getOwnPropertyDescriptor(y,R):null;k&&(k.get||k.set)?Object.defineProperty(E,R,k):E[R]=y[R]}return E.default=y,M&&M.set(y,E),E}(Gt());function i(y){if("function"!=typeof WeakMap)return null;var v=new WeakMap,M=new WeakMap;return(i=function(E){return E?M:v})(y)}function o(){var y=new e.ARRAY_TYPE(4);return e.ARRAY_TYPE!=Float32Array&&(y[0]=0,y[1]=0,y[2]=0,y[3]=0),y}function h(y,v,M){return y[0]=v[0]-M[0],y[1]=v[1]-M[1],y[2]=v[2]-M[2],y[3]=v[3]-M[3],y}function a(y,v,M){return y[0]=v[0]*M[0],y[1]=v[1]*M[1],y[2]=v[2]*M[2],y[3]=v[3]*M[3],y}function u(y,v,M){return y[0]=v[0]/M[0],y[1]=v[1]/M[1],y[2]=v[2]/M[2],y[3]=v[3]/M[3],y}function m(y,v){return Math.hypot(v[0]-y[0],v[1]-y[1],v[2]-y[2],v[3]-y[3])}function x(y,v){var M=v[0]-y[0],E=v[1]-y[1],C=v[2]-y[2],R=v[3]-y[3];return M*M+E*E+C*C+R*R}function w(y){return Math.hypot(y[0],y[1],y[2],y[3])}function p(y){var v=y[0],M=y[1],E=y[2],C=y[3];return v*v+M*M+E*E+C*C}Vt.sub=h,Vt.mul=a,Vt.div=u,Vt.dist=m,Vt.sqrDist=x,Vt.len=w,Vt.sqrLen=p;var g,b=(g=o(),function(y,v,M,E,C,R){var k,P;for(v||(v=4),M||(M=0),P=E?Math.min(E*v+M,y.length):y.length,k=M;ke.EPSILON?(K[0]=re[0]/pe,K[1]=re[1]/pe,K[2]=re[2]/pe):(K[0]=1,K[1]=0,K[2]=0),he},tt.getAngle=function(K,re){var he=M(K,re);return Math.acos(2*he*he-1)},tt.multiply=w,tt.rotateX=function(K,re,he){he*=.5;var pe=re[0],fe=re[1],me=re[2],we=re[3],ge=Math.sin(he),Pe=Math.cos(he);return K[0]=pe*Pe+we*ge,K[1]=fe*Pe+me*ge,K[2]=me*Pe-fe*ge,K[3]=we*Pe-pe*ge,K},tt.rotateY=function(K,re,he){he*=.5;var pe=re[0],fe=re[1],me=re[2],we=re[3],ge=Math.sin(he),Pe=Math.cos(he);return K[0]=pe*Pe-me*ge,K[1]=fe*Pe+we*ge,K[2]=me*Pe+pe*ge,K[3]=we*Pe-fe*ge,K},tt.rotateZ=function(K,re,he){he*=.5;var pe=re[0],fe=re[1],me=re[2],we=re[3],ge=Math.sin(he),Pe=Math.cos(he);return K[0]=pe*Pe+fe*ge,K[1]=fe*Pe-pe*ge,K[2]=me*Pe+we*ge,K[3]=we*Pe-me*ge,K},tt.calculateW=function(K,re){var he=re[0],pe=re[1],fe=re[2];return K[0]=he,K[1]=pe,K[2]=fe,K[3]=Math.sqrt(Math.abs(1-he*he-pe*pe-fe*fe)),K},tt.exp=p,tt.ln=g,tt.pow=function(K,re,he){return g(K,re),v(K,K,he),p(K,K),K},tt.slerp=b,tt.random=function(K){var re=e.RANDOM(),he=e.RANDOM(),pe=e.RANDOM(),fe=Math.sqrt(1-re),me=Math.sqrt(re);return K[0]=fe*Math.sin(2*Math.PI*he),K[1]=fe*Math.cos(2*Math.PI*he),K[2]=me*Math.sin(2*Math.PI*pe),K[3]=me*Math.cos(2*Math.PI*pe),K},tt.invert=function(K,re){var he=re[0],pe=re[1],fe=re[2],me=re[3],we=he*he+pe*pe+fe*fe+me*me,ge=we?1/we:0;return K[0]=-he*ge,K[1]=-pe*ge,K[2]=-fe*ge,K[3]=me*ge,K},tt.conjugate=function(K,re){return K[0]=-re[0],K[1]=-re[1],K[2]=-re[2],K[3]=re[3],K},tt.fromMat3=y,tt.fromEuler=function(K,re,he,pe){var fe=.5*Math.PI/180;re*=fe,he*=fe,pe*=fe;var me=Math.sin(re),we=Math.cos(re),ge=Math.sin(he),Pe=Math.cos(he),Oe=Math.sin(pe),Ee=Math.cos(pe);return K[0]=me*Pe*Ee-we*ge*Oe,K[1]=we*ge*Ee+me*Pe*Oe,K[2]=we*Pe*Oe-me*ge*Ee,K[3]=we*Pe*Ee+me*ge*Oe,K},tt.str=function(K){return"quat("+K[0]+", "+K[1]+", "+K[2]+", "+K[3]+")"},tt.setAxes=tt.sqlerp=tt.rotationTo=tt.equals=tt.exactEquals=tt.normalize=tt.sqrLen=tt.squaredLength=tt.len=tt.length=tt.lerp=tt.dot=tt.scale=tt.mul=tt.add=tt.set=tt.copy=tt.fromValues=tt.clone=void 0;var e=u(Gt()),i=u(Oi()),o=u(uo()),h=u(yr());function a(K){if("function"!=typeof WeakMap)return null;var re=new WeakMap,he=new WeakMap;return(a=function(pe){return pe?he:re})(K)}function u(K,re){if(K&&K.__esModule)return K;if(null===K||"object"!==n(K)&&"function"!=typeof K)return{default:K};var he=a(re);if(he&&he.has(K))return he.get(K);var pe={},fe=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var me in K)if("default"!==me&&Object.prototype.hasOwnProperty.call(K,me)){var we=fe?Object.getOwnPropertyDescriptor(K,me):null;we&&(we.get||we.set)?Object.defineProperty(pe,me,we):pe[me]=K[me]}return pe.default=K,he&&he.set(K,pe),pe}function m(){var K=new e.ARRAY_TYPE(4);return e.ARRAY_TYPE!=Float32Array&&(K[0]=0,K[1]=0,K[2]=0),K[3]=1,K}function x(K,re,he){he*=.5;var pe=Math.sin(he);return K[0]=pe*re[0],K[1]=pe*re[1],K[2]=pe*re[2],K[3]=Math.cos(he),K}function w(K,re,he){var pe=re[0],fe=re[1],me=re[2],we=re[3],ge=he[0],Pe=he[1],Oe=he[2],Ee=he[3];return K[0]=pe*Ee+we*ge+fe*Oe-me*Pe,K[1]=fe*Ee+we*Pe+me*ge-pe*Oe,K[2]=me*Ee+we*Oe+pe*Pe-fe*ge,K[3]=we*Ee-pe*ge-fe*Pe-me*Oe,K}function p(K,re){var he=re[0],pe=re[1],fe=re[2],me=re[3],we=Math.sqrt(he*he+pe*pe+fe*fe),ge=Math.exp(me),Pe=we>0?ge*Math.sin(we)/we:0;return K[0]=he*Pe,K[1]=pe*Pe,K[2]=fe*Pe,K[3]=ge*Math.cos(we),K}function g(K,re){var he=re[0],pe=re[1],fe=re[2],me=re[3],we=Math.sqrt(he*he+pe*pe+fe*fe),ge=we>0?Math.atan2(we,me)/we:0;return K[0]=he*ge,K[1]=pe*ge,K[2]=fe*ge,K[3]=.5*Math.log(he*he+pe*pe+fe*fe+me*me),K}function b(K,re,he,pe){var fe,me,we,ge,Pe,Oe=re[0],Ee=re[1],Ye=re[2],$e=re[3],je=he[0],Fe=he[1],ut=he[2],Xe=he[3];return(me=Oe*je+Ee*Fe+Ye*ut+$e*Xe)<0&&(me=-me,je=-je,Fe=-Fe,ut=-ut,Xe=-Xe),1-me>e.EPSILON?(fe=Math.acos(me),we=Math.sin(fe),ge=Math.sin((1-pe)*fe)/we,Pe=Math.sin(pe*fe)/we):(ge=1-pe,Pe=pe),K[0]=ge*Oe+Pe*je,K[1]=ge*Ee+Pe*Fe,K[2]=ge*Ye+Pe*ut,K[3]=ge*$e+Pe*Xe,K}function y(K,re){var he,pe=re[0]+re[4]+re[8];if(pe>0)he=Math.sqrt(pe+1),K[3]=.5*he,K[0]=(re[5]-re[7])*(he=.5/he),K[1]=(re[6]-re[2])*he,K[2]=(re[1]-re[3])*he;else{var fe=0;re[4]>re[0]&&(fe=1),re[8]>re[3*fe+fe]&&(fe=2);var me=(fe+1)%3,we=(fe+2)%3;he=Math.sqrt(re[3*fe+fe]-re[3*me+me]-re[3*we+we]+1),K[fe]=.5*he,K[3]=(re[3*me+we]-re[3*we+me])*(he=.5/he),K[me]=(re[3*me+fe]+re[3*fe+me])*he,K[we]=(re[3*we+fe]+re[3*fe+we])*he}return K}tt.clone=h.clone,tt.fromValues=h.fromValues,tt.copy=h.copy,tt.set=h.set,tt.add=h.add,tt.mul=w;var v=h.scale;tt.scale=v;var M=h.dot;tt.dot=M,tt.lerp=h.lerp;var E=h.length;tt.length=E,tt.len=E;var C=h.squaredLength;tt.squaredLength=C,tt.sqrLen=C;var R=h.normalize;tt.normalize=R,tt.exactEquals=h.exactEquals,tt.equals=h.equals;var k,P,O,B=(k=o.create(),P=o.fromValues(1,0,0),O=o.fromValues(0,1,0),function(K,re,he){var pe=o.dot(re,he);return pe<-.999999?(o.cross(k,P,re),o.len(k)<1e-6&&o.cross(k,O,re),o.normalize(k,k),x(K,k,Math.PI),K):pe>.999999?(K[0]=0,K[1]=0,K[2]=0,K[3]=1,K):(o.cross(k,re,he),K[0]=k[0],K[1]=k[1],K[2]=k[2],K[3]=1+pe,R(K,K))});tt.rotationTo=B;var G,H,X=(G=m(),H=m(),function(K,re,he,pe,fe,me){return b(G,re,fe,me),b(H,he,pe,me),b(K,G,H,2*me*(1-me)),K});tt.sqlerp=X;var Z,te=(Z=i.create(),function(K,re,he,pe){return Z[0]=he[0],Z[3]=he[1],Z[6]=he[2],Z[1]=pe[0],Z[4]=pe[1],Z[7]=pe[2],Z[2]=-re[0],Z[5]=-re[1],Z[8]=-re[2],R(K,y(K,Z))});return tt.setAxes=te,tt}var Bo,Ns,Fo,Dt={},At={};function Vs(){if(Ns)return At;function n(y){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(v){return typeof v}:function(v){return v&&"function"==typeof Symbol&&v.constructor===Symbol&&v!==Symbol.prototype?"symbol":typeof v})(y)}Ns=1,Object.defineProperty(At,"__esModule",{value:!0}),At.create=o,At.clone=function(y){var v=new e.ARRAY_TYPE(2);return v[0]=y[0],v[1]=y[1],v},At.fromValues=function(y,v){var M=new e.ARRAY_TYPE(2);return M[0]=y,M[1]=v,M},At.copy=function(y,v){return y[0]=v[0],y[1]=v[1],y},At.set=function(y,v,M){return y[0]=v,y[1]=M,y},At.add=function(y,v,M){return y[0]=v[0]+M[0],y[1]=v[1]+M[1],y},At.subtract=h,At.multiply=a,At.divide=u,At.ceil=function(y,v){return y[0]=Math.ceil(v[0]),y[1]=Math.ceil(v[1]),y},At.floor=function(y,v){return y[0]=Math.floor(v[0]),y[1]=Math.floor(v[1]),y},At.min=function(y,v,M){return y[0]=Math.min(v[0],M[0]),y[1]=Math.min(v[1],M[1]),y},At.max=function(y,v,M){return y[0]=Math.max(v[0],M[0]),y[1]=Math.max(v[1],M[1]),y},At.round=function(y,v){return y[0]=Math.round(v[0]),y[1]=Math.round(v[1]),y},At.scale=function(y,v,M){return y[0]=v[0]*M,y[1]=v[1]*M,y},At.scaleAndAdd=function(y,v,M,E){return y[0]=v[0]+M[0]*E,y[1]=v[1]+M[1]*E,y},At.distance=m,At.squaredDistance=x,At.length=w,At.squaredLength=p,At.negate=function(y,v){return y[0]=-v[0],y[1]=-v[1],y},At.inverse=function(y,v){return y[0]=1/v[0],y[1]=1/v[1],y},At.normalize=function(y,v){var M=v[0],E=v[1],C=M*M+E*E;return C>0&&(C=1/Math.sqrt(C)),y[0]=v[0]*C,y[1]=v[1]*C,y},At.dot=function(y,v){return y[0]*v[0]+y[1]*v[1]},At.cross=function(y,v,M){var E=v[0]*M[1]-v[1]*M[0];return y[0]=y[1]=0,y[2]=E,y},At.lerp=function(y,v,M,E){var C=v[0],R=v[1];return y[0]=C+E*(M[0]-C),y[1]=R+E*(M[1]-R),y},At.random=function(y,v){v=v||1;var M=2*e.RANDOM()*Math.PI;return y[0]=Math.cos(M)*v,y[1]=Math.sin(M)*v,y},At.transformMat2=function(y,v,M){var E=v[0],C=v[1];return y[0]=M[0]*E+M[2]*C,y[1]=M[1]*E+M[3]*C,y},At.transformMat2d=function(y,v,M){var E=v[0],C=v[1];return y[0]=M[0]*E+M[2]*C+M[4],y[1]=M[1]*E+M[3]*C+M[5],y},At.transformMat3=function(y,v,M){var E=v[0],C=v[1];return y[0]=M[0]*E+M[3]*C+M[6],y[1]=M[1]*E+M[4]*C+M[7],y},At.transformMat4=function(y,v,M){var E=v[0],C=v[1];return y[0]=M[0]*E+M[4]*C+M[12],y[1]=M[1]*E+M[5]*C+M[13],y},At.rotate=function(y,v,M,E){var C=v[0]-M[0],R=v[1]-M[1],k=Math.sin(E),P=Math.cos(E);return y[0]=C*P-R*k+M[0],y[1]=C*k+R*P+M[1],y},At.angle=function(y,v){var M=y[0],E=y[1],C=v[0],R=v[1],k=Math.sqrt(M*M+E*E)*Math.sqrt(C*C+R*R);return Math.acos(Math.min(Math.max(k&&(M*C+E*R)/k,-1),1))},At.zero=function(y){return y[0]=0,y[1]=0,y},At.str=function(y){return"vec2("+y[0]+", "+y[1]+")"},At.exactEquals=function(y,v){return y[0]===v[0]&&y[1]===v[1]},At.equals=function(y,v){var M=y[0],E=y[1],C=v[0],R=v[1];return Math.abs(M-C)<=e.EPSILON*Math.max(1,Math.abs(M),Math.abs(C))&&Math.abs(E-R)<=e.EPSILON*Math.max(1,Math.abs(E),Math.abs(R))},At.forEach=At.sqrLen=At.sqrDist=At.dist=At.div=At.mul=At.sub=At.len=void 0;var e=function(y){if(y&&y.__esModule)return y;if(null===y||"object"!==n(y)&&"function"!=typeof y)return{default:y};var M=i(void 0);if(M&&M.has(y))return M.get(y);var E={},C=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var R in y)if("default"!==R&&Object.prototype.hasOwnProperty.call(y,R)){var k=C?Object.getOwnPropertyDescriptor(y,R):null;k&&(k.get||k.set)?Object.defineProperty(E,R,k):E[R]=y[R]}return E.default=y,M&&M.set(y,E),E}(Gt());function i(y){if("function"!=typeof WeakMap)return null;var v=new WeakMap,M=new WeakMap;return(i=function(E){return E?M:v})(y)}function o(){var y=new e.ARRAY_TYPE(2);return e.ARRAY_TYPE!=Float32Array&&(y[0]=0,y[1]=0),y}function h(y,v,M){return y[0]=v[0]-M[0],y[1]=v[1]-M[1],y}function a(y,v,M){return y[0]=v[0]*M[0],y[1]=v[1]*M[1],y}function u(y,v,M){return y[0]=v[0]/M[0],y[1]=v[1]/M[1],y}function m(y,v){return Math.hypot(v[0]-y[0],v[1]-y[1])}function x(y,v){var M=v[0]-y[0],E=v[1]-y[1];return M*M+E*E}function w(y){return Math.hypot(y[0],y[1])}function p(y){var v=y[0],M=y[1];return v*v+M*M}At.len=w,At.sub=h,At.mul=a,At.div=u,At.dist=m,At.sqrDist=x,At.sqrLen=p;var g,b=(g=o(),function(y,v,M,E,C,R){var k,P;for(v||(v=2),M||(M=0),P=E?Math.min(E*v+M,y.length):y.length,k=M;k0){v=Math.sqrt(v);var M=y[0]/v,E=y[1]/v,C=y[2]/v,R=y[3]/v,k=y[4],P=y[5],O=y[6],B=y[7],G=M*k+E*P+C*O+R*B;b[0]=M,b[1]=E,b[2]=C,b[3]=R,b[4]=(k-M*G)/v,b[5]=(P-E*G)/v,b[6]=(O-C*G)/v,b[7]=(B-R*G)/v}return b},Dt.str=function(b){return"quat2("+b[0]+", "+b[1]+", "+b[2]+", "+b[3]+", "+b[4]+", "+b[5]+", "+b[6]+", "+b[7]+")"},Dt.exactEquals=function(b,y){return b[0]===y[0]&&b[1]===y[1]&&b[2]===y[2]&&b[3]===y[3]&&b[4]===y[4]&&b[5]===y[5]&&b[6]===y[6]&&b[7]===y[7]},Dt.equals=function(b,y){var v=b[0],M=b[1],E=b[2],C=b[3],R=b[4],k=b[5],P=b[6],O=b[7],B=y[0],G=y[1],H=y[2],X=y[3],Z=y[4],te=y[5],K=y[6],re=y[7];return Math.abs(v-B)<=e.EPSILON*Math.max(1,Math.abs(v),Math.abs(B))&&Math.abs(M-G)<=e.EPSILON*Math.max(1,Math.abs(M),Math.abs(G))&&Math.abs(E-H)<=e.EPSILON*Math.max(1,Math.abs(E),Math.abs(H))&&Math.abs(C-X)<=e.EPSILON*Math.max(1,Math.abs(C),Math.abs(X))&&Math.abs(R-Z)<=e.EPSILON*Math.max(1,Math.abs(R),Math.abs(Z))&&Math.abs(k-te)<=e.EPSILON*Math.max(1,Math.abs(k),Math.abs(te))&&Math.abs(P-K)<=e.EPSILON*Math.max(1,Math.abs(P),Math.abs(K))&&Math.abs(O-re)<=e.EPSILON*Math.max(1,Math.abs(O),Math.abs(re))},Dt.sqrLen=Dt.squaredLength=Dt.len=Dt.length=Dt.dot=Dt.mul=Dt.setReal=Dt.getReal=void 0;var e=a(Gt()),i=a(En()),o=a(zi());function h(b){if("function"!=typeof WeakMap)return null;var y=new WeakMap,v=new WeakMap;return(h=function(M){return M?v:y})(b)}function a(b,y){if(b&&b.__esModule)return b;if(null===b||"object"!==n(b)&&"function"!=typeof b)return{default:b};var v=h(y);if(v&&v.has(b))return v.get(b);var M={},E=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var C in b)if("default"!==C&&Object.prototype.hasOwnProperty.call(b,C)){var R=E?Object.getOwnPropertyDescriptor(b,C):null;R&&(R.get||R.set)?Object.defineProperty(M,C,R):M[C]=b[C]}return M.default=b,v&&v.set(b,M),M}function u(b,y,v){var M=.5*v[0],E=.5*v[1],C=.5*v[2],R=y[0],k=y[1],P=y[2],O=y[3];return b[0]=R,b[1]=k,b[2]=P,b[3]=O,b[4]=M*O+E*P-C*k,b[5]=E*O+C*R-M*P,b[6]=C*O+M*k-E*R,b[7]=-M*R-E*k-C*P,b}function m(b,y){return b[0]=y[0],b[1]=y[1],b[2]=y[2],b[3]=y[3],b[4]=y[4],b[5]=y[5],b[6]=y[6],b[7]=y[7],b}function x(b,y,v){var M=y[0],E=y[1],C=y[2],R=y[3],k=v[4],P=v[5],O=v[6],B=v[7],G=y[4],H=y[5],X=y[6],Z=y[7],te=v[0],K=v[1],re=v[2],he=v[3];return b[0]=M*he+R*te+E*re-C*K,b[1]=E*he+R*K+C*te-M*re,b[2]=C*he+R*re+M*K-E*te,b[3]=R*he-M*te-E*K-C*re,b[4]=M*B+R*k+E*O-C*P+G*he+Z*te+H*re-X*K,b[5]=E*B+R*P+C*k-M*O+H*he+Z*K+X*te-G*re,b[6]=C*B+R*O+M*P-E*k+X*he+Z*re+G*K-H*te,b[7]=R*B-M*k-E*P-C*O+Z*he-G*te-H*K-X*re,b}Dt.getReal=i.copy,Dt.setReal=i.copy,Dt.mul=x;var w=i.dot;Dt.dot=w;var p=i.length;Dt.length=p,Dt.len=p;var g=i.squaredLength;return Dt.squaredLength=g,Dt.sqrLen=g,Dt}());st.quat2=m;var x=b(Vs());st.vec2=x;var w=b(uo());st.vec3=w;var p=b(yr());function g(y){if("function"!=typeof WeakMap)return null;var v=new WeakMap,M=new WeakMap;return(g=function(E){return E?M:v})(y)}function b(y,v){if(y&&y.__esModule)return y;if(null===y||"object"!==n(y)&&"function"!=typeof y)return{default:y};var M=g(v);if(M&&M.has(y))return M.get(y);var E={},C=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var R in y)if("default"!==R&&Object.prototype.hasOwnProperty.call(y,R)){var k=C?Object.getOwnPropertyDescriptor(y,R):null;k&&(k.get||k.set)?Object.defineProperty(E,R,k):E[R]=y[R]}return E.default=y,M&&M.set(y,E),E}return st.vec4=p,st}(),Hn=Mi(function(){if(No)return qr;function n(e,i,o,h){this.cx=3*e,this.bx=3*(o-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*i,this.by=3*(h-i)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=i,this.p2x=o,this.p2y=h}return No=1,qr=n,n.prototype={sampleCurveX:function(e){return((this.ax*e+this.bx)*e+this.cx)*e},sampleCurveY:function(e){return((this.ay*e+this.by)*e+this.cy)*e},sampleCurveDerivativeX:function(e){return(3*this.ax*e+2*this.bx)*e+this.cx},solveCurveX:function(e,i){if(void 0===i&&(i=1e-6),e<0)return 0;if(e>1)return 1;for(var o=e,h=0;h<8;h++){var a=this.sampleCurveX(o)-e;if(Math.abs(a)a?m=o:x=o,o=.5*(x-m)+m;return o},solve:function(e,i){return this.sampleCurveY(this.solveCurveX(e,i))}},qr}());function js(){if(fo)return Us;function n(e,i){this.x=e,this.y=i}return fo=1,Us=n,n.prototype={clone:function(){return new n(this.x,this.y)},add:function(e){return this.clone()._add(e)},sub:function(e){return this.clone()._sub(e)},multByPoint:function(e){return this.clone()._multByPoint(e)},divByPoint:function(e){return this.clone()._divByPoint(e)},mult:function(e){return this.clone()._mult(e)},div:function(e){return this.clone()._div(e)},rotate:function(e){return this.clone()._rotate(e)},rotateAround:function(e,i){return this.clone()._rotateAround(e,i)},matMult:function(e){return this.clone()._matMult(e)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(e){return this.x===e.x&&this.y===e.y},dist:function(e){return Math.sqrt(this.distSqr(e))},distSqr:function(e){var i=e.x-this.x,o=e.y-this.y;return i*i+o*o},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith:function(e){return this.angleWithSep(e.x,e.y)},angleWithSep:function(e,i){return Math.atan2(this.x*i-this.y*e,this.x*e+this.y*i)},_matMult:function(e){var i=e[2]*this.x+e[3]*this.y;return this.x=e[0]*this.x+e[1]*this.y,this.y=i,this},_add:function(e){return this.x+=e.x,this.y+=e.y,this},_sub:function(e){return this.x-=e.x,this.y-=e.y,this},_mult:function(e){return this.x*=e,this.y*=e,this},_div:function(e){return this.x/=e,this.y/=e,this},_multByPoint:function(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint:function(e){return this.x/=e.x,this.y/=e.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var e=this.y;return this.y=this.x,this.x=-e,this},_rotate:function(e){var i=Math.cos(e),o=Math.sin(e),h=o*this.x+i*this.y;return this.x=i*this.x-o*this.y,this.y=h,this},_rotateAround:function(e,i){var o=Math.cos(e),h=Math.sin(e),a=i.y+h*(this.x-i.x)+o*(this.y-i.y);return this.x=i.x+o*(this.x-i.x)-h*(this.y-i.y),this.y=a,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},n.convert=function(e){return e instanceof n?e:Array.isArray(e)?new n(e[0],e[1]):e},Us}var He=Mi(js());function mo(n,e){if(Array.isArray(n)){if(!Array.isArray(e)||n.length!==e.length)return!1;for(let i=0;i=1)return 1;const e=n*n,i=e*n;return 4*(n<.5?i:3*(n-e)+i-.75)}function Wn(n,e,i,o){const h=new Hn(n,e,i,o);return function(a){return h.solve(a)}}const Vo=Wn(.25,.1,.25,1);function zt(n,e,i){return Math.min(i,Math.max(e,n))}function Uo(n,e,i){return(i=zt((i-n)/(e-n),0,1))*i*(3-2*i)}function Cn(n,e,i){const o=i-e,h=((n-e)%o+o)%o+e;return h===e?i:h}function go(n,e,i){if(!n.length)return i(null,[]);let o=n.length;const h=new Array(n.length);let a=null;n.forEach((u,m)=>{e(u,(x,w)=>{x&&(a=x),h[m]=w,0==--o&&i(a,h)})})}function pr(n,...e){for(const i of e)for(const o in i)n[o]=i[o];return n}let Rr=1;function Gs(){return Rr++}function qs(n){return n<=1?1:Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function jo(n,e){n.forEach(i=>{e[i]&&(e[i]=e[i].bind(e))})}function Pn(n,e){return-1!==n.indexOf(e,n.length-e.length)}function yo(n,e,i){const o={};for(const h in n)o[h]=e.call(this,n[h],h,n);return o}function Go(n,e,i){const o={};for(const h in n)e.call(this,n[h],h,n)&&(o[h]=n[h]);return o}function Zr(n){return Array.isArray(n)?n.map(Zr):"object"==typeof n&&n?yo(n,Zr):n}const Zs={};function Qt(n){Zs[n]||(typeof console<"u"&&console.warn(n),Zs[n]=!0)}function dn(n,e,i){return(i.y-n.y)*(e.x-n.x)>(e.y-n.y)*(i.x-n.x)}function Ba(n){let e=0;for(let i,o,h=0,a=n.length,u=a-1;h@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(i,o,h,a)=>{const u=h||a;return e[o]=!u||u.toLowerCase(),""}),e["max-age"]){const i=parseInt(e["max-age"],10);isNaN(i)?delete e["max-age"]:e["max-age"]=i}return e}let qo,Hs=null;function vo(n,e){return[n[4*e],n[4*e+1],n[4*e+2],n[4*e+3]]}function Se(n,e,i,o){for(;e>1;n[h]>1;n[h]<=o?e=h+1:i=h}return e}function q(n){return n>0?1/(1.001-n):1+n}function ee(n){return n>0?1-1/(1.001-n):-n}const le={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(null==qo){const n=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{qo=null!=process.env.API_URL_REGEX?new RegExp(process.env.API_URL_REGEX):n}catch{qo=n}}return qo},get API_TILEJSON_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/v[0-9]*\/.*\.json.*$)/i},get API_SPRITE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*\/sprite.*\..*$)/i},get API_FONTS_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/fonts\/v[0-9]*\/)(.*\.pbf.*$)/i},get API_STYLE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*$)/i},get API_CDN_URL_REGEX(){return/^((https?:)?\/\/)?api\.mapbox\.c(n|om)(\/mapbox-gl-js\/)(.*$)/i},get EVENTS_URL(){if(!le.API_URL)return null;try{const n=new URL(le.API_URL);return"api.mapbox.cn"===n.hostname?"https://events.mapbox.cn/events/v2":"api.mapbox.com"===n.hostname?"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:"https://api.mapbox.com/mapbox-gl-js/draco_decoder_gltf_v1.5.6.wasm",MESHOPT_URL:"https://api.mapbox.com/mapbox-gl-js/meshopt_base_v0.20.wasm",MESHOPT_SIMD_URL:"https://api.mapbox.com/mapbox-gl-js/meshopt_simd_v0.20.wasm",GLYPHS_URL:"mapbox://fonts/mapbox/{fontstack}/{range}.pbf",TILES3D_URL_PREFIX:"3dtiles/v1"};function se(n){return le.API_URL_REGEX.test(n)}function _e(n){return le.API_SPRITE_REGEX.test(n)}let Te,ve,Me,De,Ce,Ve;function Ke(){return null==Te&&(Te=self.OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof self.createImageBitmap),Te}const Qe={now:()=>void 0!==De?De:performance.now(),setNow(n){De=n},restoreNow(){De=void 0},frame(n){const e=requestAnimationFrame(n);return{cancel:()=>cancelAnimationFrame(e)}},getImageData(n,e=0){const{width:i,height:o}=n;Ce||(Ce=document.createElement("canvas"));const h=Ce.getContext("2d",{willReadFrequently:!0});if(!h)throw new Error("failed to create canvas 2d context");return(i>Ce.width||o>Ce.height)&&(Ce.width=i,Ce.height=o),h.clearRect(-e,-e,i+2*e,o+2*e),h.drawImage(n,0,0,i,o),h.getImageData(-e,-e,i+2*e,o+2*e)},resolveURL:n=>(ve||(ve=document.createElement("a")),ve.href=n,ve.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return!!window.matchMedia&&(null==Me&&(Me=window.matchMedia("(prefers-reduced-motion: reduce)")),Me.matches)},hasCanvasFingerprintNoise(){if(void 0!==Ve)return Ve;if(!Ke())return Ve=!1,!1;const n=new OffscreenCanvas(85,1),e=n.getContext("2d",{willReadFrequently:!0});let i=0;for(let h=0;h0?`?${a}`:""}`}const St="mapbox-tiles";let Mt=500,ai=50;const pi=["language","worldview","jobid"];let Rt,ui;function Di(){try{return caches}catch{}}function Xi(){const n=Di();n&&null==Rt&&(Rt=n.open(St))}let Ki=1/0;const lr={supported:!1,testSupport:function(n){!Fa&&zn&&(Ws?Na(n):en=n)}};let en,zn,Fa=!1,Ws=!1;const Zo=typeof self<"u"?self:{};function Na(n){const e=n.createTexture();n.bindTexture(n.TEXTURE_2D,e);try{if(n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,zn),n.isContextLost())return;lr.supported=!0}catch{}n.deleteTexture(e),Fa=!0}Zo.document&&(zn=Zo.document.createElement("img"),zn.onload=function(){en&&Na(en),en=null,Ws=!0},zn.onerror=function(){Fa=!0,en=null},zn.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const $o={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image",Model:"Model"};"function"==typeof Object.freeze&&Object.freeze($o);class Jl extends Error{constructor(e,i,o){401===i&&se(o)&&(e+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),super(e),this.status=i,this.url=o}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const Ql=xo()?()=>self.worker&&self.worker.referrer:()=>("blob:"===location.protocol?parent:self).location.href,Xs=function(n,e){if(!(/^file:/.test(i=n.url)||/^file:/.test(Ql())&&!/^\w+:/.test(i))){if(self.fetch&&self.Request&&self.AbortController&&Request.prototype.hasOwnProperty("signal"))return function(o,h){const a=new AbortController,u=new Request(o.url,{method:o.method||"GET",body:o.body,credentials:o.credentials,headers:o.headers,referrer:Ql(),referrerPolicy:o.referrerPolicy,signal:a.signal});let m=!1,x=!1;const w=(p=u.url).indexOf("sku=")>0&&se(p);var p;"json"===o.type&&u.headers.set("Accept","application/json");const g=(y,v,M)=>{if(x)return;if(y&&"SecurityError"!==y.message&&Qt(y.toString()),v&&M)return b(v);const E=Date.now();fetch(u).then(C=>{if(C.ok){const R=w?C.clone():null;return b(C,R,E)}return h(new Jl(C.statusText,C.status,o.url))}).catch(C=>{"AbortError"!==C.name&&h(new Error(`${C.message} ${o.url}`))})},b=(y,v,M)=>{("arrayBuffer"===o.type?y.arrayBuffer():"json"===o.type?y.json():y.text()).then(E=>{x||(v&&M&&function(C,R,k){if(Xi(),null==Rt)return;const P=$s(R.headers.get("Cache-Control")||"");if(P["no-store"])return;const O={status:R.status,statusText:R.statusText,headers:new Headers};R.headers.forEach((H,X)=>O.headers.set(X,H)),P["max-age"]&&O.headers.set("Expires",new Date(k+1e3*P["max-age"]).toUTCString());const B=O.headers.get("Expires");if(!B||new Date(B).getTime()-k<42e4)return;let G=Tt(C.url,{persistentParams:pi});if(206===R.status){const H=C.headers.get("Range");if(!H)return;O.status=200,G=bt(G,{range:H})}!function(H,X){if(void 0===ui)try{new Response(new ReadableStream),ui=!0}catch{ui=!1}ui?X(H.body):H.blob().then(X)}(R,H=>{const X=new Response(200!==(Z=R.status)&&404!==Z&&[101,103,204,205,304].includes(Z)?null:H,O);var Z;Xi(),Rt?.then(te=>te.put(G,X)).catch(te=>Qt(te.message))})}(u,v,M),m=!0,h(null,E,y.headers.get("Cache-Control"),y.headers.get("Expires")))}).catch(E=>{x||h(new Error(E.message))})};return w?function(y,v){if(Xi(),null==Rt)return v(null);Rt.then(M=>{let E=Tt(y.url,{persistentParams:pi});const C=y.headers.get("Range");C&&(E=bt(E,{range:C})),M.match(E).then(R=>{const k=function(P){if(!P)return!1;const O=new Date(P.headers.get("Expires")||0),B=$s(P.headers.get("Cache-Control")||"");return O>Date.now()&&!B["no-cache"]}(R);M.delete(E),k&&M.put(E,R.clone()),v(null,R,k)}).catch(v)}).catch(v)}(u,g):g(null,null),{cancel:()=>{x=!0,m||a.abort()}}}(n,e);if(xo()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",n,e,void 0,!0)}var i;return function(o,h){const a=new XMLHttpRequest;a.open(o.method||"GET",o.url,!0),"arrayBuffer"===o.type&&(a.responseType="arraybuffer");for(const u in o.headers)a.setRequestHeader(u,o.headers[u]);return"json"===o.type&&(a.responseType="text",a.setRequestHeader("Accept","application/json")),a.withCredentials="include"===o.credentials,a.onerror=()=>{h(new Error(a.statusText))},a.onload=()=>{if((a.status>=200&&a.status<300||0===a.status)&&null!==a.response){let u=a.response;if("json"===o.type)try{u=JSON.parse(a.response)}catch(m){return h(m)}h(null,u,a.getResponseHeader("Cache-Control"),a.getResponseHeader("Expires"))}else h(new Jl(a.statusText,a.status,o.url))},a.send(o.body),{cancel:()=>a.abort()}}(n,e)},Ho=function(n,e){return Xs(pr(n,{type:"arrayBuffer"}),e)};function $r(n){const e=document.createElement("a");return e.href=n,e.protocol===location.protocol&&e.host===location.host}const tn="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let rn,Er;rn=[],Er=0;const pn=function(n,e){if(lr.supported&&(n.headers||(n.headers={}),n.headers.accept="image/webp,*/*"),Er>=le.MAX_PARALLEL_IMAGE_REQUESTS){const a={requestParameters:n,callback:e,cancelled:!1,cancel(){this.cancelled=!0}};return rn.push(a),a}Er++;let i=!1;const o=()=>{if(!i)for(i=!0,Er--;rn.length&&Er{o(),a?e(a):u&&(self.createImageBitmap?function(w,p){const g=new Blob([new Uint8Array(w)],{type:"image/png"});createImageBitmap(g).then(b=>{p(null,b)}).catch(b=>{p(new Error(`Could not load image because of ${b.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(u,(w,p)=>e(w,p,m,x)):function(w,p){const g=new Image;g.onload=()=>{p(null,g),URL.revokeObjectURL(g.src),g.onload=null,requestAnimationFrame(()=>{g.src=tn})},g.onerror=()=>p(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const b=new Blob([new Uint8Array(w)],{type:"image/png"});g.src=w.byteLength?URL.createObjectURL(b):tn}(u,(w,p)=>e(w,p,m,x)))});return{cancel:()=>{h.cancel(),o()}}};var Ys,ec,tc,fn={exports:{}},Va={exports:{}},Fh={exports:{}},Ar=Mi(function(){if(tc)return fn.exports;tc=1;var n=(Ys||(Ys=1,Va.exports=function(i,o){var h,a,u,m,x,w,p,g;for(a=i.length-(h=3&i.length),u=o,x=3432918353,w=461845907,g=0;g>>16)*x&65535)<<16)&4294967295)<<15|p>>>17))*w+(((p>>>16)*w&65535)<<16)&4294967295)<<13|u>>>19))+((5*(u>>>16)&65535)<<16)&4294967295))+((58964+(m>>>16)&65535)<<16);switch(p=0,h){case 3:p^=(255&i.charCodeAt(g+2))<<16;case 2:p^=(255&i.charCodeAt(g+1))<<8;case 1:u^=p=(65535&(p=(p=(65535&(p^=255&i.charCodeAt(g)))*x+(((p>>>16)*x&65535)<<16)&4294967295)<<15|p>>>17))*w+(((p>>>16)*w&65535)<<16)&4294967295}return u^=i.length,u=2246822507*(65535&(u^=u>>>16))+((2246822507*(u>>>16)&65535)<<16)&4294967295,u=3266489909*(65535&(u^=u>>>13))+((3266489909*(u>>>16)&65535)<<16)&4294967295,(u^=u>>>16)>>>0}),Va.exports),e=(ec||(ec=1,Fh.exports=function(i,o){for(var h,a=i.length,u=o^a,m=0;a>=4;)h=1540483477*(65535&(h=255&i.charCodeAt(m)|(255&i.charCodeAt(++m))<<8|(255&i.charCodeAt(++m))<<16|(255&i.charCodeAt(++m))<<24))+((1540483477*(h>>>16)&65535)<<16),u=1540483477*(65535&u)+((1540483477*(u>>>16)&65535)<<16)^(h=1540483477*(65535&(h^=h>>>24))+((1540483477*(h>>>16)&65535)<<16)),a-=4,++m;switch(a){case 3:u^=(255&i.charCodeAt(m+2))<<16;case 2:u^=(255&i.charCodeAt(m+1))<<8;case 1:u=1540483477*(65535&(u^=255&i.charCodeAt(m)))+((1540483477*(u>>>16)&65535)<<16)}return u=1540483477*(65535&(u^=u>>>13))+((1540483477*(u>>>16)&65535)<<16),(u^=u>>>15)>>>0}),Fh.exports);return fn.exports=n,fn.exports.murmur3=n,fn.exports.murmur2=e,fn.exports}());class Xn{constructor(e,...i){pr(this,i[0]||{}),this.type=e}}class Ks extends Xn{constructor(e,i={}){super("error",pr({error:e},i))}}function Wo(n,e,i){i[n]&&-1!==i[n].indexOf(e)||(i[n]=i[n]||[],i[n].push(e))}function ic(n,e,i){if(i&&i[n]){const o=i[n].indexOf(e);-1!==o&&i[n].splice(o,1)}}class Xo{on(e,i){return this._listeners=this._listeners||{},Wo(e,i,this._listeners),this}off(e,i){return ic(e,i,this._listeners),ic(e,i,this._oneTimeListeners),this}once(e,i){return i?(this._oneTimeListeners=this._oneTimeListeners||{},Wo(e,i,this._oneTimeListeners),this):new Promise(o=>this.once(e,o))}fire(e,i){const o="string"==typeof e?new Xn(e,i):e,h=o.type;if(this.listens(h)){o.target=this;const a=this._listeners&&this._listeners[h]?this._listeners[h].slice():[];for(const x of a)x.call(this,o);const u=this._oneTimeListeners&&this._oneTimeListeners[h]?this._oneTimeListeners[h].slice():[];for(const x of u)ic(h,x,this._oneTimeListeners),x.call(this,o);const m=this._eventedParent;m&&(pr(o,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),m.fire(o))}else o instanceof Ks&&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}}var rc,ei={},nc=function(){if(rc)return ei;rc=1;var n={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(a){return(a=Math.round(a))<0?0:a>255?255:a}function i(a){return e("%"===a[a.length-1]?parseFloat(a)/100*255:parseInt(a))}function o(a){return(u="%"===a[a.length-1]?parseFloat(a)/100:parseFloat(a))<0?0:u>1?1:u;var u}function h(a,u,m){return m<0?m+=1:m>1&&(m-=1),6*m<1?a+(u-a)*m*6:2*m<1?u:3*m<2?a+(u-a)*(2/3-m)*6:a}try{ei.parseCSSColor=function(a){var u,m=a.replace(/ /g,"").toLowerCase();if(m in n)return n[m].slice();if("#"===m[0])return 4===m.length?(u=parseInt(m.substr(1),16))>=0&&u<=4095?[(3840&u)>>4|(3840&u)>>8,240&u|(240&u)>>4,15&u|(15&u)<<4,1]:null:7===m.length&&(u=parseInt(m.substr(1),16))>=0&&u<=16777215?[(16711680&u)>>16,(65280&u)>>8,255&u,1]:null;var x=m.indexOf("("),w=m.indexOf(")");if(-1!==x&&w+1===m.length){var p=m.substr(0,x),g=m.substr(x+1,w-(x+1)).split(","),b=1;switch(p){case"rgba":if(4!==g.length)return null;b=o(g.pop());case"rgb":return 3!==g.length?null:[i(g[0]),i(g[1]),i(g[2]),b];case"hsla":if(4!==g.length)return null;b=o(g.pop());case"hsl":if(3!==g.length)return null;var y=(parseFloat(g[0])%360+360)%360/360,v=o(g[1]),M=o(g[2]),E=M<=.5?M*(v+1):M+v-M*v,C=2*M-E;return[e(255*h(C,E,y+1/3)),e(255*h(C,E,y)),e(255*h(C,E,y-1/3)),b];default:return null}}return null}}catch{}return ei}();class li{constructor(e,i,o,h=1){this.r=e,this.g=i,this.b=o,this.a=h}static parse(e){if(!e)return;if(e instanceof li)return e;if("string"!=typeof e)return;const i=nc.parseCSSColor(e);return i?new li(i[0]/255*i[3],i[1]/255*i[3],i[2]/255*i[3],i[3]):void 0}toString(){const[e,i,o,h]=0===this.a?[0,0,0,0]:[255*this.r/this.a,255*this.g/this.a,255*this.b/this.a,this.a];return`rgba(${Math.round(e)},${Math.round(i)},${Math.round(o)},${h})`}toRenderColor(e){const{r:i,g:o,b:h,a}=this;return new Id(e,i,o,h,a)}}class Id{constructor(e,i,o,h,a){if(e){const u=e.image.height,m=u*u;i=0===a?0:i/a*(u-1),o=0===a?0:o/a*(u-1),h=0===a?0:h/a*(u-1);const x=Math.floor(i),w=Math.floor(o),p=Math.floor(h),g=Math.ceil(i),b=Math.ceil(o),y=Math.ceil(h),v=i-x,M=o-w,E=h-p,C=e.image.data,R=4*(x+w*m+p*u),k=4*(x+w*m+y*u),P=4*(x+b*m+p*u),O=4*(x+b*m+y*u),B=4*(g+w*m+p*u),G=4*(g+w*m+y*u),H=4*(g+b*m+p*u),X=4*(g+b*m+y*u);if(R<0||X>=C.length)throw new Error("out of range");this.r=mt(mt(mt(C[R],C[k],E),mt(C[P],C[O],E),M),mt(mt(C[B],C[G],E),mt(C[H],C[X],E),M),v)/255*a,this.g=mt(mt(mt(C[R+1],C[k+1],E),mt(C[P+1],C[O+1],E),M),mt(mt(C[B+1],C[G+1],E),mt(C[H+1],C[X+1],E),M),v)/255*a,this.b=mt(mt(mt(C[R+2],C[k+2],E),mt(C[P+2],C[O+2],E),M),mt(mt(C[B+2],C[G+2],E),mt(C[H+2],C[X+2],E),M),v)/255*a,this.a=a}else this.r=i,this.g=o,this.b=h,this.a=a}toArray(){const{r:e,g:i,b:o,a:h}=this;return 0===h?[0,0,0,0]:[255*e/h,255*i/h,255*o/h,h]}toArray01(){const{r:e,g:i,b:o,a:h}=this;return 0===h?[0,0,0,0]:[e/h,i/h,o/h,h]}toArray01Scaled(e){const{r:i,g:o,b:h,a}=this;return 0===a?[0,0,0]:[i/a*e,o/a*e,h/a*e]}toArray01PremultipliedAlpha(){const{r:e,g:i,b:o,a:h}=this;return[e,i,o,h]}toArray01Linear(){const{r:e,g:i,b:o,a:h}=this;return 0===h?[0,0,0,0]:[Math.pow(e/h,2.2),Math.pow(i/h,2.2),Math.pow(o/h,2.2),h]}}function mt(n,e,i){return n*(1-i)+e*i}function Js(n,e,i){return n.map((o,h)=>mt(o,e[h],i))}li.black=new li(0,0,0,1),li.white=new li(1,1,1,1),li.transparent=new li(0,0,0,0),li.red=new li(1,0,0,1),li.blue=new li(0,0,1,1);var bo=Object.freeze({__proto__:null,array:Js,color:function(n,e,i){return new li(mt(n.r,e.r,i),mt(n.g,e.g,i),mt(n.b,e.b,i),mt(n.a,e.a,i))},number:mt});function Yo(n,...e){for(const i of e)for(const o in i)n[o]=i[o];return n}class mn extends Error{constructor(e,i){super(i),this.message=i,this.key=e}}class Ua{constructor(e,i=[]){this.parent=e,this.bindings={};for(const[o,h]of i)this.bindings[o]=h}concat(e){return new Ua(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 nn={kind:"null"},nt={kind:"number"},Wt={kind:"string"},Xt={kind:"boolean"},Ir={kind:"color"},fr={kind:"object"},Jt={kind:"value"},ja={kind:"collator"},Ko={kind:"formatted"},Jo={kind:"resolvedImage"};function xr(n,e){return{kind:"array",itemType:n,N:e}}function Vi(n){if("array"===n.kind){const e=Vi(n.itemType);return"number"==typeof n.N?`array<${e}, ${n.N}>`:"value"===n.itemType.kind?"array":`array<${e}>`}return n.kind}const Nh=[nn,nt,Wt,Xt,Ir,Ko,fr,xr(Jt),Jo];function Qo(n,e){if("error"===e.kind)return null;if("array"===n.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!Qo(n.itemType,e.itemType))&&("number"!=typeof n.N||n.N===e.N))return null}else{if(n.kind===e.kind)return null;if("value"===n.kind)for(const i of Nh)if(!Qo(i,e))return null}return`Expected ${Vi(n)} but found ${Vi(e)} instead.`}function es(n,e){return e.some(i=>i.kind===n.kind)}function _n(n,e){return e.some(i=>"null"===i?null===n:"array"===i?Array.isArray(n):"object"===i?n&&!Array.isArray(n)&&"object"==typeof n:i===typeof n)}class Ga{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 kr{constructor(e,i,o,h,a){this.text=e.normalize?e.normalize():e,this.image=i,this.scale=o,this.fontStack=h,this.textColor=a}}class mr{constructor(e){this.sections=e}static fromString(e){return new mr([new kr(e,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some(e=>0!==e.text.length||e.image&&0!==e.image.namePrimary.length)}static factory(e){return e instanceof mr?e:mr.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map(e=>e.text).join("")}serialize(){const e=["format"];for(const i of this.sections){if(i.image){e.push(["image",i.image.namePrimary]);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.toRenderColor(null).toArray())),e.push(o)}return e}}class vr{constructor(e){this.namePrimary=e.namePrimary,e.nameSecondary&&(this.nameSecondary=e.nameSecondary),this.available=e.available}toString(){return this.nameSecondary?`[${this.namePrimary},${this.nameSecondary}]`:this.namePrimary}static fromString(e,i){return e?new vr({namePrimary:e,nameSecondary:i,available:!1}):null}serialize(){return this.nameSecondary?["image",this.namePrimary,this.nameSecondary]:["image",this.namePrimary]}}function Vh(n,e,i,o){return"number"==typeof n&&n>=0&&n<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof i&&i>=0&&i<=255?void 0===o||"number"==typeof o&&o>=0&&o<=1?null:`Invalid rgba value [${[n,e,i,o].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof o?[n,e,i,o]:[n,e,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Yn(n){if(null===n||"string"==typeof n||"boolean"==typeof n||"number"==typeof n||n instanceof li||n instanceof Ga||n instanceof mr||n instanceof vr)return!0;if(Array.isArray(n)){for(const e of n)if(!Yn(e))return!1;return!0}if("object"==typeof n){for(const e in n)if(!Yn(n[e]))return!1;return!0}return!1}function $i(n){if(null===n)return nn;if("string"==typeof n)return Wt;if("boolean"==typeof n)return Xt;if("number"==typeof n)return nt;if(n instanceof li)return Ir;if(n instanceof Ga)return ja;if(n instanceof mr)return Ko;if(n instanceof vr)return Jo;if(Array.isArray(n)){const e=n.length;let i;for(const o of n){const h=$i(o);if(i){if(i===h)continue;i=Jt;break}i=h}return xr(i||Jt,e)}return fr}function br(n){const e=typeof n;return null===n?"":"string"===e||"number"===e||"boolean"===e?String(n):n instanceof li||n instanceof mr||n instanceof vr?n.toString():JSON.stringify(n)}class on{constructor(e,i){this.type=e,this.value=i}static parse(e,i){if(2!==e.length)return i.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!Yn(e[1]))return i.error("invalid value");const o=e[1];let h=$i(o);const a=i.expectedType;return"array"!==h.kind||0!==h.N||!a||"array"!==a.kind||"number"==typeof a.N&&0!==a.N||(h=a),new on(h,o)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof li?["rgba"].concat(this.value.toRenderColor(null).toArray()):this.value instanceof mr?this.value.serialize():this.value}}class ir{constructor(e){this.name="ExpressionEvaluationError",this.message=e}toJSON(){return this.message}}const oc={string:Wt,number:nt,boolean:Xt,object:fr};class sn{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,h=1;const a=e[0];if("array"===a){let m,x;if(e.length>2){const w=e[1];if("string"!=typeof w||!(w in oc)||"object"===w)return i.error('The item type argument of "array" must be one of string, number, boolean',1);m=oc[w],h++}else m=Jt;if(e.length>3){if(null!==e[2]&&("number"!=typeof e[2]||e[2]<0||e[2]!==Math.floor(e[2])))return i.error('The length argument to "array" must be a positive integer literal',2);x=e[2],h++}o=xr(m,x)}else o=oc[a];const u=[];for(;he.outputDefined())}serialize(){const e=this.type,i=[e.kind];if("array"===e.kind){const o=e.itemType;if("string"===o.kind||"number"===o.kind||"boolean"===o.kind){i.push(o.kind);const h=e.N;("number"==typeof h||this.args.length>1)&&i.push(h)}}return i.concat(this.args.map(o=>o.serialize()))}}class ts{constructor(e){this.type=Ko,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)&&"object"==typeof o)return i.error("First argument must be an image or text section.");const h=[];let a=!1;for(let u=1;u<=e.length-1;++u){const m=e[u];if(a&&"object"==typeof m&&!Array.isArray(m)){a=!1;let x=null;if(m["font-scale"]&&(x=i.parseObjectValue(m["font-scale"],u,"font-scale",nt),!x))return null;let w=null;if(m["text-font"]&&(w=i.parseObjectValue(m["text-font"],u,"text-font",xr(Wt)),!w))return null;let p=null;if(m["text-color"]&&(p=i.parseObjectValue(m["text-color"],u,"text-color",Ir),!p))return null;const g=h[h.length-1];g.scale=x,g.font=w,g.textColor=p}else{const x=i.parse(e[u],u,Jt);if(!x)return null;const w=x.type.kind;if("string"!==w&&"value"!==w&&"null"!==w&&"resolvedImage"!==w)return i.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");a=!0,h.push({content:x,scale:null,font:null,textColor:null})}}return new ts(h)}evaluate(e){return new mr(this.sections.map(i=>{const o=i.content.evaluate(e);return $i(o)===Jo?new kr("",o,null,null,null):new kr(br(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 wo{constructor(e,i){this.type=Jo,this.inputPrimary=e,this.inputSecondary=i}static parse(e,i){if(e.length<2)return i.error("Expected two or more arguments.");const o=i.parse(e[1],1,Wt);if(!o)return i.error("No image name provided.");if(2===e.length)return new wo(o);const h=i.parse(e[2],1,Wt);return h?new wo(o,h):i.error("Secondary image variant is not a string.")}evaluate(e){const i=vr.fromString(this.inputPrimary.evaluate(e),this.inputSecondary?this.inputSecondary.evaluate(e):void 0);return i&&e.availableImages&&(i.available=e.availableImages.indexOf(i.namePrimary)>-1,i.nameSecondary&&i.available&&e.availableImages&&(i.available=e.availableImages.indexOf(i.nameSecondary)>-1)),i}eachChild(e){e(this.inputPrimary),this.inputSecondary&&e(this.inputSecondary)}outputDefined(){return!1}serialize(){return this.inputSecondary?["image",this.inputPrimary.serialize(),this.inputSecondary.serialize()]:["image",this.inputPrimary.serialize()]}}function To(n){return n instanceof Number?"number":n instanceof String?"string":n instanceof Boolean?"boolean":Array.isArray(n)?"array":null===n?"null":typeof n}const qa={"to-boolean":Xt,"to-color":Ir,"to-number":nt,"to-string":Wt};class Dn{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],h=[];let a=nn;if("to-array"===o){if(!Array.isArray(e[1]))return null;const u=e[1].length;if(i.expectedType){if("array"!==i.expectedType.kind)return i.error(`Expected ${i.expectedType.kind} but found array.`);a=xr(i.expectedType.itemType,u)}else{if(!(u>0&&Yn(e[1][0])))return null;a=xr($i(e[1][0]),u)}for(let m=0;m4?`Invalid rbga value ${JSON.stringify(i)}: expected an array containing either three or four numeric values.`:Vh(i[0],i[1],i[2],i[3]),!o))return new li(i[0]/255,i[1]/255,i[2]/255,i[3])}throw new ir(o||`Could not parse color from value '${"string"==typeof i?i:String(JSON.stringify(i))}'`)}if("number"===this.type.kind){let i=null;for(const o of this.args){if(i=o.evaluate(e),null===i)return 0;const h=Number(i);if(!isNaN(h))return h}throw new ir(`Could not convert ${JSON.stringify(i)} to number.`)}return"formatted"===this.type.kind?mr.fromString(br(this.args[0].evaluate(e))):"resolvedImage"===this.type.kind?vr.fromString(br(this.args[0].evaluate(e))):"array"===this.type.kind?this.args.map(i=>i.evaluate(e)):br(this.args[0].evaluate(e))}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){if("formatted"===this.type.kind)return new ts([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new wo(this.args[0]).serialize();const e="array"===this.type.kind?[]:[`to-${this.type.kind}`];return this.eachChild(i=>{e.push(i.serialize())}),e}}const Cd=["Unknown","Point","LineString","Polygon"];class Uh{constructor(e,i){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null,this.scope=e,this.options=i}id(){return this.feature&&void 0!==this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Cd[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:h}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(o*i-e[0])+this.featureDistanceData.bearing[1]*(h*i-e[1])}return 0}parseColor(e){let i=this._parseColorCache[e];return i||(i=this._parseColorCache[e]=li.parse(e)),i}getConfig(e){return this.options?this.options.get(e):null}}class Cr{constructor(e,i,o,h,a){this.name=e,this.type=i,this._evaluate=o,this.args=h,this._overloadIndex=a}evaluate(e){if(!this._evaluate){const i=Cr.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],h=Cr.definitions[o];if(!h)return i.error(`Unknown expression "${o}". If you wanted a literal array, use ["literal", [...]].`,0);const a=Array.isArray(h)?h[0]:h.type,u=Array.isArray(h)?[[h[1],h[2]]]:h.overloads,m=[];let x=null,w=-1;for(const[p,g]of u){if(Array.isArray(p)&&p.length!==e.length-1)continue;m.push(p),w++,x=new Qh(i.registry,i.path,null,i.scope,void 0,i._scope,i.options);const b=[];let y=!1;for(let v=1;vb)).map(Pd).join(" | "),g=[];for(let b=1;bi;){if(o-i>600){const x=o-i+1,w=e-i+1,p=Math.log(x),g=.5*Math.exp(2*p/3),b=.5*Math.sqrt(p*g*(x-g)/x)*(w-x/2<0?-1:1);jh(n,e,Math.max(i,Math.floor(e-w*g/x+b)),Math.min(o,Math.floor(e+(x-w)*g/x+b)),h)}const a=n[e];let u=i,m=o;for(is(n,i,e),h(n[o],a)>0&&is(n,i,o);u0;)m--}0===h(n[i],a)?is(n,i,m):(m++,is(n,m,o)),m<=e&&(i=m+1),e<=m&&(o=m-1)}}function is(n,e,i){const o=n[e];n[e]=n[i],n[i]=o}function rs(n,e){return ne?1:0}function zd(n){let e=0;for(let i,o,h=0,a=n.length,u=a-1;h=e[2]||n[1]<=e[1]||n[3]>=e[3])}function Dd(n,e,i){const o=n[0]-e[0],h=n[1]-e[1],a=n[0]-i[0],u=n[1]-i[1];return o*u-a*h==0&&o*a<=0&&h*u<=0}function ns(n,e,i=!1){let o=!1;for(let m=0,x=e.length;m(h=n)[1]!=(u=v)[1]>h[1]&&h[0]<(u[0]-a[0])*(h[1]-a[1])/(u[1]-a[1])+a[0]&&(o=!o)}}var h,a,u;return o}function Gh(n,e,i,o){const h=o[0]-i[0],a=o[1]-i[1],u=(n[0]-i[0])*a-h*(n[1]-i[1]),m=(e[0]-i[0])*a-h*(e[1]-i[1]);return u>0&&m<0||u<0&&m>0}function $a(n,e,i,o){return(h=[o[0]-i[0],o[1]-i[1]])[0]*(a=[e[0]-n[0],e[1]-n[1]])[1]-h[1]*a[0]!=0&&!(!Gh(n,e,i,o)||!Gh(i,o,n,e));var h,a}const Or=8192;function Zt(n,e){const i=(180+n[0])/360,o=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+n[1]*Math.PI/360)))/360,h=Math.pow(2,e.z);return[Math.round(i*h*Or),Math.round(o*h*Or)]}function dt(n,e){for(let i=0;ii[2]){const h=.5*o;let a=n[0]-i[0]>h?-o:i[0]-n[0]>h?o:0;0===a&&(a=n[0]-i[2]>h?-o:i[2]-n[0]>h?o:0),n[0]+=a}Qs(e,n)}function Ha(n,e,i,o){const h=Math.pow(2,o.z)*Or,a=[o.x*Or,o.y*Or],u=[];if(!n)return u;for(const m of n)for(const x of m){const w=[x.x+a[0],x.y+a[1]];lc(w,e,i,h),u.push(w)}return u}function cc(n,e,i,o){const h=Math.pow(2,o.z)*Or,a=[o.x*Or,o.y*Or],u=[];if(!n)return u;for(const x of n){const w=[];for(const p of x){const g=[p.x+a[0],p.y+a[1]];Qs(e,g),w.push(g)}u.push(w)}if(e[2]-e[0]<=h/2){(m=e)[0]=m[1]=1/0,m[2]=m[3]=-1/0;for(const x of u)for(const w of x)lc(w,e,i,h)}var m;return u}class Kn{constructor(e,i){this.type=Xt,this.geojson=e,this.geometries=i}static parse(e,i){if(2!==e.length)return i.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Yn(e[1])){const o=e[1];if("FeatureCollection"===o.type)for(let h=0;hi)return Rn(a,u,(i-(o-m))/m)}return e[e.length-1]}pointToSegmentDistance(e,i,o){let[h,a]=i,u=Li(o[0]-h)*this.kx,m=(o[1]-a)*this.ky;if(0!==u||0!==m){const x=(Li(e[0]-h)*this.kx*u+(e[1]-a)*this.ky*m)/(u*u+m*m);x>1?(h=o[0],a=o[1]):x>0&&(h+=u/this.kx*x,a+=m/this.ky*x)}return u=Li(e[0]-h)*this.kx,m=(e[1]-a)*this.ky,Math.sqrt(u*u+m*m)}pointOnLine(e,i){let o=1/0,h=e[0][0],a=e[0][1],u=0,m=0;for(let x=0;x1?(w=e[x+1][0],p=e[x+1][1]):y>0&&(w+=g/this.kx*y,p+=b/this.ky*y)),g=Li(i[0]-w)*this.kx,b=(i[1]-p)*this.ky;const v=g*g+b*b;va.index||h.index===a.index&&h.t>a.t){const w=h;h=a,a=w}const u=[h.point],m=h.index+1,x=a.index;!Xa(o[m],u[0])&&m<=x&&u.push(o[m]);for(let w=m+1;w<=x;w++)u.push(o[w]);return Xa(o[x],a.point)||u.push(a.point),u}lineSliceAlong(e,i,o){let h=0;const a=[];for(let u=0;ue&&0===a.length&&a.push(Rn(m,x,(e-(h-w))/w)),h>=i)return a.push(Rn(m,x,(i-(h-w))/w)),a;h>e&&a.push(x)}return a}bufferPoint(e,i){const o=i/this.ky,h=i/this.kx;return[e[0]-h,e[1]-o,e[0]+h,e[1]+o]}bufferBBox(e,i){const o=i/this.ky,h=i/this.kx;return[e[0]-h,e[1]-o,e[2]+h,e[3]+o]}insideBBox(e,i){return Li(e[0]-i[0])>=0&&Li(e[0]-i[2])<=0&&e[1]>=i[1]&&e[1]<=i[3]}}function Xa(n,e){return n[0]===e[0]&&n[1]===e[1]}function Rn(n,e,i){const o=Li(e[0]-n[0]);return[n[0]+o*i,n[1]+(e[1]-n[1])*i]}function Li(n){for(;n<-180;)n+=360;for(;n>180;)n-=360;return n}class hc{constructor(e=[],i=(o,h)=>oh?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(0===this.length)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,h=i[e];for(;e>0;){const a=e-1>>1,u=i[a];if(o(h,u)>=0)break;i[e]=u,e=a}i[e]=h}_down(e){const{data:i,compare:o}=this,h=this.length>>1,a=i[e];for(;e=0)break;i[e]=i[u],e=u}i[e]=a}}var We=8192;function qh(n,e){return e.dist-n.dist}function Ka(n){const e=[1/0,1/0,-1/0,-1/0];if(e.length!==n.length)return!1;for(let i=0;i=n[0]&&n[1]n[1])return[null,null];const i=Ja(n);if(e){if(2===i)return[n,null];const o=Math.floor(i/2);return[[n[0],n[0]+o],[n[0]+o,n[1]]]}{if(1===i)return[n,null];const o=Math.floor(i/2)-1;return[[n[0],n[0]+o],[n[0]+o+1,n[1]]]}}function Br(n,e){const i=[1/0,1/0,-1/0,-1/0];if(!Ln(e,n.length))return i;for(let o=e[0];o<=e[1];++o)Qs(i,n[o]);return i}function Qa(n){const e=[1/0,1/0,-1/0,-1/0];for(let i=0;ie[2]&&(o=n[0]-e[2]),n[1]>e[3]&&(h=n[1]-e[3]),n[3]=o)return o;if(Mo(h,a)){if(fc(n,e))return 0}else if(fc(e,n))return 0;let u=o;for(const m of n)for(let x=0,w=m.length,p=w-1;x=a)continue;const p=w.range1;if(Ja(p)<=m){if(!Ln(p,n.length))return NaN;if(e){const g=Kh(n,p,i,o);if(0===(a=Math.min(a,g)))return a}else for(let g=p[0];g<=p[1];++g){const b=Yh(n[g],i,o);if(0===(a=Math.min(a,b)))return a}}else{const g=uc(p,e);if(null!==g[0]){const b=ls(Br(n,g[0]),x,o);b=u)continue;const g=p.range1,b=p.range2;if(Ja(g)<=x&&Ja(b)<=w){if(!Ln(g,n.length)||!Ln(b,i.length))return NaN;if(e&&o?u=Math.min(u,Wh(n,g,i,b,h)):e||o?e&&!o?u=Math.min(u,pc(i,b,n,g,h)):!e&&o&&(u=Math.min(u,pc(n,g,i,b,h))):u=Math.min(u,Xh(n,g,i,b,h)),0===u)return u}else{const y=uc(g,e),v=uc(b,o);ta(m,u,h,n,i,y[0],v[0]),ta(m,u,h,n,i,y[0],v[1]),ta(m,u,h,n,i,y[1],v[0]),ta(m,u,h,n,i,y[1],v[1])}}return u}function cs(n,e,i,o,h=1/0){let a=h;const u=Br(n,[0,n.length-1]);for(const m of i)if(!(a!==1/0&&ls(u,Br(m,[0,m.length-1]),o)>=a)&&(a=Math.min(a,ia(n,e,m,!0,o,a)),0===a))return a;return a}function ra(n,e,i,o,h=1/0){let a=h;const u=Br(n,[0,n.length-1]);for(const m of i){if(a!==1/0&&ls(u,Qa(m),o)>=a)continue;const x=tl(n,e,m,o,a);if(isNaN(x))return x;if(0===(a=Math.min(a,x)))return a}return a}function il(n){return"Point"===n||"MultiPoint"===n||"LineString"===n||"MultiLineString"===n||"Polygon"===n||"MultiPolygon"===n}class Jn{constructor(e,i){this.type=nt,this.geojson=e,this.geometries=i}static parse(e,i){if(2!==e.length)return i.error(`'distance' expression requires either one argument, but found ' ${e.length-1} instead.`);if(Yn(e[1])){const o=e[1];if("FeatureCollection"===o.type){for(let h=0;hi&&(n=i),n}class hs{constructor(e,i,o){this.type=e,this.key=i,this.scope=o}static parse(e,i){let o=i.expectedType;if(null==o&&(o=Jt),e.length<2||e.length>3)return i.error("Invalid number of arguments for 'config' expression.");const h=i.parse(e[1],1);if(!(h instanceof on))return i.error("Key name of 'config' expression must be a string literal.");if(e.length>=3){const a=i.parse(e[2],2);return a instanceof on?new hs(o,br(h.value),br(a.value)):i.error("Scope of 'config' expression must be a string literal.")}return new hs(o,br(h.value))}evaluate(e){const i=[this.key,this.scope,e.scope].filter(Boolean).join("\x1f"),o=e.getConfig(i);if(!o)return null;const{type:h,value:a,values:u,minValue:m,maxValue:x,stepValue:w}=o,p=o.default.evaluate(e);let g=p;if(a){const b=e.scope;e.scope=(b||"").split("\x1f").slice(1).join("\x1f"),g=a.evaluate(e),e.scope=b}return h&&(g=Qn(h,g)),void 0===g||void 0===m&&void 0===x&&void 0===w||("number"==typeof g?g=Yt(g,m,x,w):Array.isArray(g)&&(g=g.map(b=>"number"==typeof b?Yt(b,m,x,w):b))),void 0!==a&&void 0!==g&&u&&!u.includes(g)&&(g=p,h&&(g=Qn(h,g))),(h&&h!==this.type||void 0!==g&&$i(g)!==this.type)&&(g=Qn(this.type.kind,g)),g}eachChild(){}outputDefined(){return!1}serialize(){const e=["config",this.key];return this.scope&&e.concat(this.key),e}}function na(n){if(n instanceof Cr&&("get"===n.name&&1===n.args.length||"feature-state"===n.name||"has"===n.name&&1===n.args.length||"properties"===n.name||"geometry-type"===n.name||"id"===n.name||/^filter-/.test(n.name))||n instanceof Kn||n instanceof Jn)return!1;let e=!0;return n.eachChild(i=>{e&&!na(i)&&(e=!1)}),e}function rl(n){if(n instanceof Cr&&"feature-state"===n.name)return!1;let e=!0;return n.eachChild(i=>{e&&!rl(i)&&(e=!1)}),e}function nl(n){if(n instanceof hs)return new Set([n.key]);let e=new Set;return n.eachChild(i=>{e=new Set([...e,...nl(i)])}),e}function oa(n,e){if(n instanceof Cr&&e.indexOf(n.name)>=0)return!1;let i=!0;return n.eachChild(o=>{i&&!oa(o,e)&&(i=!1)}),i}class gi{constructor(e,i){this.type=i.type,this.name=e,this.boundExpression=i}static parse(e,i){if(2!==e.length||"string"!=typeof e[1])return i.error("'var' expression requires exactly one string literal argument.");const o=e[1];return i.scope.has(o)?new gi(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 mc{constructor(e,i=[],o,h=new Ua,a=[],u,m){this.registry=e,this.path=i,this.key=i.map(x=>"string"==typeof x?`['${x}']`:`[${x}]`).join(""),this.scope=h,this.errors=a,this.expectedType=o,this._scope=u,this.options=m}parse(e,i,o,h,a={}){return i||o?this.concat(i,null,o,h)._parse(e,a):this._parse(e,a)}parseObjectValue(e,i,o,h,a,u={}){return this.concat(i,o,h,a)._parse(e,u)}_parse(e,i){function o(h,a,u){return"assert"===u?new sn(a,[h]):"coerce"===u?new Dn(a,[h]):h}if(null!==e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e||(e=["literal",e]),Array.isArray(e)){if(0===e.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const h="string"==typeof e[0]?this.registry[e[0]]:void 0;if(h){let a=h.parse(e,this);if(!a)return null;if(this.expectedType){const u=this.expectedType,m=a.type;if("string"!==u.kind&&"number"!==u.kind&&"boolean"!==u.kind&&"object"!==u.kind&&"array"!==u.kind||"value"!==m.kind)if("color"!==u.kind&&"formatted"!==u.kind&&"resolvedImage"!==u.kind||"value"!==m.kind&&"string"!==m.kind){if(this.checkSubtype(u,m))return null}else a=o(a,u,i.typeAnnotation||"coerce");else a=o(a,u,i.typeAnnotation||"assert")}if(!(a instanceof on)&&"resolvedImage"!==a.type.kind&&_c(a)){const u=new Uh(this._scope,this.options);try{a=new on(a.type,a.evaluate(u))}catch(m){return this.error(m.message),null}}return a}return Dn.parse(["to-array",e],this)}return this.error(void 0===e?"'undefined' value invalid. Use null instead.":"object"==typeof e?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,i,o,h){let a="number"==typeof e?this.path.concat(e):this.path;a="string"==typeof i?a.concat(i):a;const u=h?this.scope.concat(h):this.scope;return new mc(this.registry,a,o||null,u,this.errors,this._scope,this.options)}error(e,...i){const o=`${this.key}${i.map(h=>`[${h}]`).join("")}`;this.errors.push(new mn(o,e))}checkSubtype(e,i){const o=Qo(e,i);return o&&this.error(o),o}}var Qh=mc;function _c(n){if(n instanceof gi)return _c(n.boundExpression);if(n instanceof Cr&&"error"===n.name||n instanceof Za||n instanceof Kn||n instanceof Jn||n instanceof hs)return!1;const e=n instanceof Dn||n instanceof sn;let i=!0;return n.eachChild(o=>{i=e?i&&_c(o):i&&o instanceof on}),!!i&&na(n)&&oa(n,["zoom","heatmap-density","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed"])}function ol(n,e){const i=n.length-1;let o,h,a=0,u=i,m=0;for(;a<=u;)if(m=Math.floor((a+u)/2),o=n[m],h=n[m+1],o<=e){if(m===i||ee))throw new ir("Input is not a number.");u=m-1}return 0}class sa{constructor(e,i,o){this.type=e,this.input=i,this.labels=[],this.outputs=[];for(const[h,a]of o)this.labels.push(h),this.outputs.push(a)}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,nt);if(!o)return null;const h=[];let a=null;i.expectedType&&"value"!==i.expectedType.kind&&(a=i.expectedType);for(let u=1;u=m)return i.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',w);const g=i.parse(x,p,a);if(!g)return null;a=a||g.type,h.push([m,g])}return new sa(a,o,h)}evaluate(e){const i=this.labels,o=this.outputs;if(1===i.length)return o[0].evaluate(e);const h=this.input.evaluate(e);if(h<=i[0])return o[0].evaluate(e);const a=i.length;return h>=i[a-1]?o[a-1].evaluate(e):o[ol(i,h)].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;i0&&e.push(this.labels[i]),e.push(this.outputs[i].serialize());return e}}const iu=4/29,us=6/29,ru=3*us*us,Rd=us*us*us,Ld=Math.PI/180,kd=180/Math.PI;function gc(n){return n>Rd?Math.pow(n,1/3):n/ru+iu}function yc(n){return n>us?n*n*n:ru*(n-iu)}function xc(n){return 255*(n<=.0031308?12.92*n:1.055*Math.pow(n,1/2.4)-.055)}function vc(n){return(n/=255)<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)}function nu(n){const e=vc(n.r),i=vc(n.g),o=vc(n.b),h=gc((.4124564*e+.3575761*i+.1804375*o)/.95047),a=gc((.2126729*e+.7151522*i+.072175*o)/1);return{l:116*a-16,a:500*(h-a),b:200*(a-gc((.0193339*e+.119192*i+.9503041*o)/1.08883)),alpha:n.a}}function ou(n){let e=(n.l+16)/116,i=isNaN(n.a)?e:e+n.a/500,o=isNaN(n.b)?e:e-n.b/200;return e=1*yc(e),i=.95047*yc(i),o=1.08883*yc(o),new li(xc(3.2404542*i-1.5371385*e-.4985314*o),xc(-.969266*i+1.8760108*e+.041556*o),xc(.0556434*i-.2040259*e+1.0572252*o),n.alpha)}function Od(n,e,i){const o=e-n;return n+i*(o>180||o<-180?o-360*Math.round(o/360):o)}const aa={forward:nu,reverse:ou,interpolate:function(n,e,i){return{l:mt(n.l,e.l,i),a:mt(n.a,e.a,i),b:mt(n.b,e.b,i),alpha:mt(n.alpha,e.alpha,i)}}},la={forward:function(n){const{l:e,a:i,b:o}=nu(n),h=Math.atan2(o,i)*kd;return{h:h<0?h+360:h,c:Math.sqrt(i*i+o*o),l:e,alpha:n.a}},reverse:function(n){const e=n.h*Ld,i=n.c;return ou({l:n.l,a:Math.cos(e)*i,b:Math.sin(e)*i,alpha:n.alpha})},interpolate:function(n,e,i){return{h:Od(n.h,e.h,i),c:mt(n.c,e.c,i),l:mt(n.l,e.l,i),alpha:mt(n.alpha,e.alpha,i)}}};var su=Object.freeze({__proto__:null,hcl:la,lab:aa});class Nr{constructor(e,i,o,h,a){this.type=e,this.operator=i,this.interpolation=o,this.input=h,this.labels=[],this.outputs=[];for(const[u,m]of a)this.labels.push(u),this.outputs.push(m)}static interpolationFactor(e,i,o,h){let a=0;if("exponential"===e.name)a=bc(i,e.base,o,h);else if("linear"===e.name)a=bc(i,1,o,h);else if("cubic-bezier"===e.name){const u=e.controlPoints;a=new Hn(u[0],u[1],u[2],u[3]).solve(bc(i,1,o,h))}return a}static parse(e,i){let[o,h,a,...u]=e;if(!Array.isArray(h)||0===h.length)return i.error("Expected an interpolation type expression.",1);if("linear"===h[0])h={name:"linear"};else if("exponential"===h[0]){const w=h[1];if("number"!=typeof w)return i.error("Exponential interpolation requires a numeric base.",1,1);h={name:"exponential",base:w}}else{if("cubic-bezier"!==h[0])return i.error(`Unknown interpolation type ${String(h[0])}`,1,0);{const w=h.slice(1);if(4!==w.length||w.some(p=>"number"!=typeof p||p<0||p>1))return i.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);h={name:"cubic-bezier",controlPoints:w}}}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.");if(a=i.parse(a,2,nt),!a)return null;const m=[];let x=null;"interpolate-hcl"===o||"interpolate-lab"===o?x=Ir:i.expectedType&&"value"!==i.expectedType.kind&&(x=i.expectedType);for(let w=0;w=p)return i.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',b);const v=i.parse(g,y,x);if(!v)return null;x=x||v.type,m.push([p,v])}return"number"===x.kind||"color"===x.kind||"array"===x.kind&&"number"===x.itemType.kind&&"number"==typeof x.N?new Nr(x,o,h,a,m):i.error(`Type ${Vi(x)} is not interpolatable.`)}evaluate(e){const i=this.labels,o=this.outputs;if(1===i.length)return o[0].evaluate(e);const h=this.input.evaluate(e);if(h<=i[0])return o[0].evaluate(e);const a=i.length;if(h>=i[a-1])return o[a-1].evaluate(e);const u=ol(i,h),m=Nr.interpolationFactor(this.interpolation,h,i[u],i[u+1]),x=o[u].evaluate(e),w=o[u+1].evaluate(e);return"interpolate"===this.operator?bo[this.type.kind.toLowerCase()](x,w,m):"interpolate-hcl"===this.operator?la.reverse(la.interpolate(la.forward(x),la.forward(w),m)):aa.reverse(aa.interpolate(aa.forward(x),aa.forward(w),m))}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="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const i=[this.operator,e,this.input.serialize()];for(let o=0;oQo(h,m.type));return new sl(u?Jt:o,a)}evaluate(e){let i,o=null,h=0;for(const a of this.args){if(h++,o=a.evaluate(e),o&&o instanceof vr&&!o.available&&(i||(i=o),o=null,h===this.args.length))return i;if(null!==o)break}return o}eachChild(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}}class al{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 a=1;a=o.length)throw new ir(`Array index out of bounds: ${i} > ${o.length-1}.`);if(i!==Math.floor(i))throw new ir(`Array index must be an integer, but found ${i} instead.`);return o[i]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class Tc{constructor(e,i){this.type=Xt,this.needle=e,this.haystack=i}static parse(e,i){if(3!==e.length)return i.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const o=i.parse(e[1],1,Jt),h=i.parse(e[2],2,Jt);return o&&h?es(o.type,[Xt,Wt,nt,nn,Jt])?new Tc(o,h):i.error(`Expected first argument to be of type boolean, string, number or null, but found ${Vi(o.type)} instead`):null}evaluate(e){const i=this.needle.evaluate(e),o=this.haystack.evaluate(e);if(null==o)return!1;if(!_n(i,["boolean","string","number","null"]))throw new ir(`Expected first argument to be of type boolean, string, number or null, but found ${Vi($i(i))} instead.`);if(!_n(o,["string","array"]))throw new ir(`Expected second argument to be of type array or string, but found ${Vi($i(o))} instead.`);return o.indexOf(i)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class ll{constructor(e,i,o){this.type=nt,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.`);const o=i.parse(e[1],1,Jt),h=i.parse(e[2],2,Jt);if(!o||!h)return null;if(!es(o.type,[Xt,Wt,nt,nn,Jt]))return i.error(`Expected first argument to be of type boolean, string, number or null, but found ${Vi(o.type)} instead`);if(4===e.length){const a=i.parse(e[3],3,nt);return a?new ll(o,h,a):null}return new ll(o,h)}evaluate(e){const i=this.needle.evaluate(e),o=this.haystack.evaluate(e);if(!_n(i,["boolean","string","number","null"]))throw new ir(`Expected first argument to be of type boolean, string, number or null, but found ${Vi($i(i))} instead.`);if(!_n(o,["string","array"]))throw new ir(`Expected second argument to be of type array or string, but found ${Vi($i(o))} instead.`);if(this.fromIndex){const h=this.fromIndex.evaluate(e);return o.indexOf(i,h)}return o.indexOf(i)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){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 Mc{constructor(e,i,o,h,a,u){this.inputType=e,this.type=i,this.input=o,this.cases=h,this.outputs=a,this.otherwise=u}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,h;i.expectedType&&"value"!==i.expectedType.kind&&(h=i.expectedType);const a={},u=[];for(let w=2;wNumber.MAX_SAFE_INTEGER)return b.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof v&&Math.floor(v)!==v)return b.error("Numeric branch labels must be integer values.");if(o){if(b.checkSubtype(o,$i(v)))return null}else o=$i(v);if(void 0!==a[String(v)])return b.error("Branch labels must be unique.");a[String(v)]=u.length}const y=i.parse(g,w,h);if(!y)return null;h=h||y.type,u.push(y)}const m=i.parse(e[1],1,Jt);if(!m)return null;const x=i.parse(e[e.length-1],e.length-1,h);return x?"value"!==m.type.kind&&i.concat(1).checkSubtype(o,m.type)?null:new Mc(o,h,m,a,u,x):null}evaluate(e){const i=this.input.evaluate(e);return($i(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=[],h={};for(const u of i){const m=h[this.cases[u]];void 0===m?(h[this.cases[u]]=o.length,o.push([this.cases[u],[u]])):o[m][1].push(u)}const a=u=>"number"===this.inputType.kind?Number(u):u;for(const[u,m]of o)e.push(1===m.length?a(m[0]):m.map(a)),e.push(this.outputs[u].serialize());return e.push(this.otherwise.serialize()),e}}class ca{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}.`);if(e.length%2!=0)return i.error("Expected an odd number of arguments.");let o;i.expectedType&&"value"!==i.expectedType.kind&&(o=i.expectedType);const h=[];for(let u=1;ui.outputDefined())&&this.otherwise.outputDefined()}serialize(){const e=["case"];return this.eachChild(i=>{e.push(i.serialize())}),e}}class cl{constructor(e,i,o,h){this.type=e,this.input=i,this.beginIndex=o,this.endIndex=h}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.`);const o=i.parse(e[1],1,Jt),h=i.parse(e[2],2,nt);if(!o||!h)return null;if(!es(o.type,[xr(Jt),Wt,Jt]))return i.error(`Expected first argument to be of type array or string, but found ${Vi(o.type)} instead`);if(4===e.length){const a=i.parse(e[3],3,nt);return a?new cl(o.type,o,h,a):null}return new cl(o.type,o,h)}evaluate(e){const i=this.input.evaluate(e),o=this.beginIndex.evaluate(e);if(!_n(i,["string","array"]))throw new ir(`Expected first argument to be of type array or string, but found ${Vi($i(i))} instead.`);if(this.endIndex){const h=this.endIndex.evaluate(e);return i.slice(o,h)}return i.slice(o)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const e=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),e]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}function Sc(n,e){return"=="===n||"!="===n?"boolean"===e.kind||"string"===e.kind||"number"===e.kind||"null"===e.kind||"value"===e.kind:"string"===e.kind||"number"===e.kind||"value"===e.kind}function au(n,e,i,o){return 0===o.compare(e,i)}function ds(n,e,i){const o="=="!==n&&"!="!==n;return class Og{constructor(a,u,m){this.type=Xt,this.lhs=a,this.rhs=u,this.collator=m,this.hasUntypedArgument="value"===a.type.kind||"value"===u.type.kind}static parse(a,u){if(3!==a.length&&4!==a.length)return u.error("Expected two or three arguments.");const m=a[0];let x=u.parse(a[1],1,Jt);if(!x)return null;if(!Sc(m,x.type))return u.concat(1).error(`"${m}" comparisons are not supported for type '${Vi(x.type)}'.`);let w=u.parse(a[2],2,Jt);if(!w)return null;if(!Sc(m,w.type))return u.concat(2).error(`"${m}" comparisons are not supported for type '${Vi(w.type)}'.`);if(x.type.kind!==w.type.kind&&"value"!==x.type.kind&&"value"!==w.type.kind)return u.error(`Cannot compare types '${Vi(x.type)}' and '${Vi(w.type)}'.`);o&&("value"===x.type.kind&&"value"!==w.type.kind?x=new sn(w.type,[x]):"value"!==x.type.kind&&"value"===w.type.kind&&(w=new sn(x.type,[w])));let p=null;if(4===a.length){if("string"!==x.type.kind&&"string"!==w.type.kind&&"value"!==x.type.kind&&"value"!==w.type.kind)return u.error("Cannot use collator to compare non-string types.");if(p=u.parse(a[3],3,ja),!p)return null}return new Og(x,w,p)}evaluate(a){const u=this.lhs.evaluate(a),m=this.rhs.evaluate(a);if(o&&this.hasUntypedArgument){const x=$i(u),w=$i(m);if(x.kind!==w.kind||"string"!==x.kind&&"number"!==x.kind)throw new ir(`Expected arguments for "${n}" to be (string, string) or (number, number), but found (${x.kind}, ${w.kind}) instead.`)}if(this.collator&&!o&&this.hasUntypedArgument){const x=$i(u),w=$i(m);if("string"!==x.kind||"string"!==w.kind)return e(a,u,m)}return this.collator?i(a,u,m,this.collator.evaluate(a)):e(a,u,m)}eachChild(a){a(this.lhs),a(this.rhs),this.collator&&a(this.collator)}outputDefined(){return!0}serialize(){const a=[n];return this.eachChild(u=>{a.push(u.serialize())}),a}}}const Bd=ds("==",function(n,e,i){return e===i},au),lu=ds("!=",function(n,e,i){return e!==i},function(n,e,i,o){return!au(0,e,i,o)}),cu=ds("<",function(n,e,i){return e",function(n,e,i){return e>i},function(n,e,i,o){return o.compare(e,i)>0}),hu=ds("<=",function(n,e,i){return e<=i},function(n,e,i,o){return o.compare(e,i)<=0}),uu=ds(">=",function(n,e,i){return e>=i},function(n,e,i,o){return o.compare(e,i)>=0});class Ec{constructor(e,i,o,h,a,u){this.type=Wt,this.number=e,this.locale=i,this.currency=o,this.unit=h,this.minFractionDigits=a,this.maxFractionDigits=u}static parse(e,i){if(3!==e.length)return i.error("Expected two arguments.");const o=i.parse(e[1],1,nt);if(!o)return null;const h=e[2];if("object"!=typeof h||Array.isArray(h))return i.error("NumberFormat options argument must be an object.");let a=null;if(h.locale&&(a=i.parseObjectValue(h.locale,2,"locale",Wt),!a))return null;let u=null;if(h.currency&&(u=i.parseObjectValue(h.currency,2,"currency",Wt),!u))return null;let m=null;if(h.unit&&(m=i.parseObjectValue(h.unit,2,"unit",Wt),!m))return null;let x=null;if(h["min-fraction-digits"]&&(x=i.parseObjectValue(h["min-fraction-digits"],2,"min-fraction-digits",nt),!x))return null;let w=null;return h["max-fraction-digits"]&&(w=i.parseObjectValue(h["max-fraction-digits"],2,"max-fraction-digits",nt),!w)?null:new Ec(o,a,u,m,x,w)}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 ha{constructor(e){this.type=nt,this.input=e}static parse(e,i){if(2!==e.length)return i.error(`Expected 1 argument, but found ${e.length-1} instead.`);const o=i.parse(e[1],1);return o?"array"!==o.type.kind&&"string"!==o.type.kind&&"value"!==o.type.kind?i.error(`Expected argument of type string or array, but found ${Vi(o.type)} instead.`):new ha(o):null}evaluate(e){const i=this.input.evaluate(e);if("string"==typeof i||Array.isArray(i))return i.length;throw new ir(`Expected value to be of type string or array, but found ${Vi($i(i))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){const e=["length"];return this.eachChild(i=>{e.push(i.serialize())}),e}}function hl(n){return function(){n=1831565813+(n|=0)|0;let e=Math.imul(n^n>>>15,1|n);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}const fs={"==":Bd,"!=":lu,">":ps,"<":cu,">=":uu,"<=":hu,array:sn,at:wc,boolean:sn,case:ca,coalesce:sl,collator:Za,format:ts,image:wo,in:Tc,"index-of":ll,interpolate:Nr,"interpolate-hcl":Nr,"interpolate-lab":Nr,length:ha,let:al,literal:on,match:Mc,number:sn,"number-format":Ec,object:sn,slice:cl,step:sa,string:sn,"to-boolean":Dn,"to-color":Dn,"to-number":Dn,"to-string":Dn,var:gi,within:Kn,distance:Jn,config:hs};function du(n,[e,i,o,h]){e=e.evaluate(n),i=i.evaluate(n),o=o.evaluate(n);const a=h?h.evaluate(n):1,u=Vh(e,i,o,a);if(u)throw new ir(u);return new li(e/255*a,i/255*a,o/255*a,a)}function Ac(n,[e,i,o,h]){e=e.evaluate(n),i=i.evaluate(n),o=o.evaluate(n);const a=h?h.evaluate(n):1,u=(p=i,g=o,b=a,"number"==typeof(w=e)&&w>=0&&w<=360?"number"==typeof p&&p>=0&&p<=100&&"number"==typeof g&&g>=0&&g<=100?void 0===b||"number"==typeof b&&b>=0&&b<=1?null:`Invalid hsla value [${[w,p,g,b].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${("number"==typeof b?[w,p,g,b]:[w,p,g]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${("number"==typeof b?[w,p,g,b]:[w,p,g]).join(", ")}]: 'h' must be between 0 and 360.`);var w,p,g,b;if(u)throw new ir(u);const m=`hsla(${e}, ${i}%, ${o}%, ${a})`,x=li.parse(m);if(!x)throw new ir(`Failed to parse HSLA color: ${m}`);return x}function Ic(n,e){return n in e}function Cc(n,e){const i=e[n];return void 0===i?null:i}function Eo(n){return{type:n}}function pu(n){return{result:"success",value:n}}function eo(n){return{result:"error",value:n}}function Pc(n,e){return!!n&&!!n.parameters&&n.parameters.indexOf(e)>-1}function ul(n){return"data-driven"===n["property-type"]}function zc(n){return Pc(n.expression,"measure-light")}function fu(n){return Pc(n.expression,"zoom")}function Dc(n){return!!n.expression&&n.expression.interpolated}function dl(n){return"object"==typeof n&&null!==n&&!Array.isArray(n)}function mu(n){return n}function _u(n,e){const i="color"===e.type,o=n.stops&&"object"==typeof n.stops[0][0],h=o||!(o||void 0!==n.property),a=n.type||(Dc(e)?"exponential":"interval");if(i&&((n=Yo({},n)).stops&&(n.stops=n.stops.map(w=>[w[0],li.parse(w[1])])),n.default=li.parse(n.default?n.default:e.default)),n.colorSpace&&"rgb"!==n.colorSpace&&!su[n.colorSpace])throw new Error(`Unknown color space: ${n.colorSpace}`);let u,m,x;if("exponential"===a)u=yu;else if("interval"===a)u=gu;else if("categorical"===a){u=Fd,m=Object.create(null);for(const w of n.stops)m[w[0]]=w[1];x=typeof n.stops[0][0]}else{if("identity"!==a)throw new Error(`Unknown function type "${a}"`);u=Nd}if(o){const w={},p=[];for(let y=0;yy[0]),evaluate:({zoom:y},v)=>yu({stops:g,base:n.base},e,y).evaluate(y,v)}}if(h){const w="exponential"===a?{name:"exponential",base:void 0!==n.base?n.base:1}:null;return{kind:"camera",interpolationType:w,interpolationFactor:Nr.interpolationFactor.bind(void 0,w),zoomStops:n.stops.map(p=>p[0]),evaluate:({zoom:p})=>u(n,e,p,m,x)}}return{kind:"source",evaluate(w,p){const g=p&&p.properties?p.properties[n.property]:void 0;return void 0===g?ua(n.default,e.default):u(n,e,g,m,x)}}}function ua(n,e,i){return void 0!==n?n:void 0!==e?e:void 0!==i?i:void 0}function Fd(n,e,i,o,h){return ua(typeof i===h?o[i]:void 0,n.default,e.default)}function gu(n,e,i){if("number"!==To(i))return ua(n.default,e.default);const o=n.stops.length;if(1===o||i<=n.stops[0][0])return n.stops[0][1];if(i>=n.stops[o-1][0])return n.stops[o-1][1];const h=ol(n.stops.map(a=>a[0]),i);return n.stops[h][1]}function yu(n,e,i){const o=void 0!==n.base?n.base:1;if("number"!==To(i))return ua(n.default,e.default);const h=n.stops.length;if(1===h||i<=n.stops[0][0])return n.stops[0][1];if(i>=n.stops[h-1][0])return n.stops[h-1][1];const a=ol(n.stops.map(p=>p[0]),i),u=function(p,g,b,y){const v=y-b,M=p-b;return 0===v?0:1===g?M/v:(Math.pow(g,M)-1)/(Math.pow(g,v)-1)}(i,o,n.stops[a][0],n.stops[a+1][0]),m=n.stops[a][1],x=n.stops[a+1][1];let w=bo[e.type]||mu;if(n.colorSpace&&"rgb"!==n.colorSpace){const p=su[n.colorSpace];w=(g,b)=>p.reverse(p.interpolate(p.forward(g),p.forward(b),u))}return"function"==typeof m.evaluate?{evaluate(...p){const g=m.evaluate.apply(void 0,p),b=x.evaluate.apply(void 0,p);if(void 0!==g&&void 0!==b)return w(g,b,u)}}:w(m,x,u)}function Nd(n,e,i){return"color"===e.type?i=li.parse(i):"formatted"===e.type?i=mr.fromString(i.toString()):"resolvedImage"===e.type?i=vr.fromString(i.toString()):To(i)===e.type||"enum"===e.type&&e.values[i]||(i=void 0),ua(i,n.default,e.default)}Cr.register(fs,{error:[{kind:"error"},[Wt],(n,[e])=>{throw new ir(e.evaluate(n))}],typeof:[Wt,[Jt],(n,[e])=>Vi($i(e.evaluate(n)))],"to-rgba":[xr(nt,4),[Ir],(n,[e])=>e.evaluate(n).toRenderColor(null).toArray()],rgb:[Ir,[nt,nt,nt],du],rgba:[Ir,[nt,nt,nt,nt],du],hsl:[Ir,[nt,nt,nt],Ac],hsla:[Ir,[nt,nt,nt,nt],Ac],has:{type:Xt,overloads:[[[Wt],(n,[e])=>Ic(e.evaluate(n),n.properties())],[[Wt,fr],(n,[e,i])=>Ic(e.evaluate(n),i.evaluate(n))]]},get:{type:Jt,overloads:[[[Wt],(n,[e])=>Cc(e.evaluate(n),n.properties())],[[Wt,fr],(n,[e,i])=>Cc(e.evaluate(n),i.evaluate(n))]]},"feature-state":[Jt,[Wt],(n,[e])=>Cc(e.evaluate(n),n.featureState||{})],properties:[fr,[],n=>n.properties()],"geometry-type":[Wt,[],n=>n.geometryType()],id:[Jt,[],n=>n.id()],zoom:[nt,[],n=>n.globals.zoom],pitch:[nt,[],n=>n.globals.pitch||0],"distance-from-center":[nt,[],n=>n.distanceFromCenter()],"measure-light":[nt,[Wt],(n,[e])=>n.measureLight(e.evaluate(n))],"heatmap-density":[nt,[],n=>n.globals.heatmapDensity||0],"line-progress":[nt,[],n=>n.globals.lineProgress||0],"raster-value":[nt,[],n=>n.globals.rasterValue||0],"raster-particle-speed":[nt,[],n=>n.globals.rasterParticleSpeed||0],"sky-radial-progress":[nt,[],n=>n.globals.skyRadialProgress||0],accumulated:[Jt,[],n=>void 0===n.globals.accumulated?null:n.globals.accumulated],"+":[nt,Eo(nt),(n,e)=>{let i=0;for(const o of e)i+=o.evaluate(n);return i}],"*":[nt,Eo(nt),(n,e)=>{let i=1;for(const o of e)i*=o.evaluate(n);return i}],"-":{type:nt,overloads:[[[nt,nt],(n,[e,i])=>e.evaluate(n)-i.evaluate(n)],[[nt],(n,[e])=>-e.evaluate(n)]]},"/":[nt,[nt,nt],(n,[e,i])=>e.evaluate(n)/i.evaluate(n)],"%":[nt,[nt,nt],(n,[e,i])=>e.evaluate(n)%i.evaluate(n)],ln2:[nt,[],()=>Math.LN2],pi:[nt,[],()=>Math.PI],e:[nt,[],()=>Math.E],"^":[nt,[nt,nt],(n,[e,i])=>Math.pow(e.evaluate(n),i.evaluate(n))],sqrt:[nt,[nt],(n,[e])=>Math.sqrt(e.evaluate(n))],log10:[nt,[nt],(n,[e])=>Math.log(e.evaluate(n))/Math.LN10],ln:[nt,[nt],(n,[e])=>Math.log(e.evaluate(n))],log2:[nt,[nt],(n,[e])=>Math.log(e.evaluate(n))/Math.LN2],sin:[nt,[nt],(n,[e])=>Math.sin(e.evaluate(n))],cos:[nt,[nt],(n,[e])=>Math.cos(e.evaluate(n))],tan:[nt,[nt],(n,[e])=>Math.tan(e.evaluate(n))],asin:[nt,[nt],(n,[e])=>Math.asin(e.evaluate(n))],acos:[nt,[nt],(n,[e])=>Math.acos(e.evaluate(n))],atan:[nt,[nt],(n,[e])=>Math.atan(e.evaluate(n))],min:[nt,Eo(nt),(n,e)=>Math.min(...e.map(i=>i.evaluate(n)))],max:[nt,Eo(nt),(n,e)=>Math.max(...e.map(i=>i.evaluate(n)))],abs:[nt,[nt],(n,[e])=>Math.abs(e.evaluate(n))],round:[nt,[nt],(n,[e])=>{const i=e.evaluate(n);return i<0?-Math.round(-i):Math.round(i)}],floor:[nt,[nt],(n,[e])=>Math.floor(e.evaluate(n))],ceil:[nt,[nt],(n,[e])=>Math.ceil(e.evaluate(n))],"filter-==":[Xt,[Wt,Jt],(n,[e,i])=>n.properties()[e.value]===i.value],"filter-id-==":[Xt,[Jt],(n,[e])=>n.id()===e.value],"filter-type-==":[Xt,[Wt],(n,[e])=>n.geometryType()===e.value],"filter-<":[Xt,[Wt,Jt],(n,[e,i])=>{const o=n.properties()[e.value],h=i.value;return typeof o==typeof h&&o{const i=n.id(),o=e.value;return typeof i==typeof o&&i":[Xt,[Wt,Jt],(n,[e,i])=>{const o=n.properties()[e.value],h=i.value;return typeof o==typeof h&&o>h}],"filter-id->":[Xt,[Jt],(n,[e])=>{const i=n.id(),o=e.value;return typeof i==typeof o&&i>o}],"filter-<=":[Xt,[Wt,Jt],(n,[e,i])=>{const o=n.properties()[e.value],h=i.value;return typeof o==typeof h&&o<=h}],"filter-id-<=":[Xt,[Jt],(n,[e])=>{const i=n.id(),o=e.value;return typeof i==typeof o&&i<=o}],"filter->=":[Xt,[Wt,Jt],(n,[e,i])=>{const o=n.properties()[e.value],h=i.value;return typeof o==typeof h&&o>=h}],"filter-id->=":[Xt,[Jt],(n,[e])=>{const i=n.id(),o=e.value;return typeof i==typeof o&&i>=o}],"filter-has":[Xt,[Jt],(n,[e])=>e.value in n.properties()],"filter-has-id":[Xt,[],n=>null!==n.id()&&void 0!==n.id()],"filter-type-in":[Xt,[xr(Wt)],(n,[e])=>e.value.indexOf(n.geometryType())>=0],"filter-id-in":[Xt,[xr(Jt)],(n,[e])=>e.value.indexOf(n.id())>=0],"filter-in-small":[Xt,[Wt,xr(Jt)],(n,[e,i])=>i.value.indexOf(n.properties()[e.value])>=0],"filter-in-large":[Xt,[Wt,xr(Jt)],(n,[e,i])=>function(o,h,a,u){for(;a<=u;){const m=a+u>>1;if(h[m]===o)return!0;h[m]>o?u=m-1:a=m+1}return!1}(n.properties()[e.value],i.value,0,i.value.length-1)],all:{type:Xt,overloads:[[[Xt,Xt],(n,[e,i])=>e.evaluate(n)&&i.evaluate(n)],[Eo(Xt),(n,e)=>{for(const i of e)if(!i.evaluate(n))return!1;return!0}]]},any:{type:Xt,overloads:[[[Xt,Xt],(n,[e,i])=>e.evaluate(n)||i.evaluate(n)],[Eo(Xt),(n,e)=>{for(const i of e)if(i.evaluate(n))return!0;return!1}]]},"!":[Xt,[Xt],(n,[e])=>!e.evaluate(n)],"is-supported-script":[Xt,[Wt],(n,[e])=>{const i=n.globals&&n.globals.isSupportedScript;return!i||i(e.evaluate(n))}],upcase:[Wt,[Wt],(n,[e])=>e.evaluate(n).toUpperCase()],downcase:[Wt,[Wt],(n,[e])=>e.evaluate(n).toLowerCase()],concat:[Wt,Eo(Jt),(n,e)=>e.map(i=>br(i.evaluate(n))).join("")],"resolved-locale":[Wt,[ja],(n,[e])=>e.evaluate(n).resolvedLocale()],random:[nt,[nt,nt,Jt],(n,e)=>{const[i,o,h]=e.map(u=>u.evaluate(n));if(i>o||i===o)return i;let a;if("string"==typeof h)a=function(u){let m=0;if(0===u.length)return m;for(let x=0;xJSON.stringify(p)).join(", ")}, but found ${JSON.stringify(w)} instead.`);return w}catch(w){return this._warningHistory[w.message]||(this._warningHistory[w.message]=!0,typeof console<"u"&&console.warn(`Failed to evaluate expression "${JSON.stringify(this.expression.serialize())}". ${w.message}`)),this._defaultValue}}}function fl(n){return Array.isArray(n)&&n.length>0&&"string"==typeof n[0]&&n[0]in fs}function da(n,e,i,o){const h=new Qh(fs,[],e?function(u){const m={color:Ir,string:Wt,number:nt,enum:Wt,boolean:Xt,formatted:Ko,resolvedImage:Jo};return"array"===u.type?xr(m[u.value]||Jt,u.length):m[u.type]}(e):void 0,void 0,void 0,i,o),a=h.parse(n,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return a?pu(new pl(a,e,i,o)):eo(h.errors)}class Rc{constructor(e,i,o){this.kind=e,this._styleExpression=i,this.isLightConstant=o,this.isStateDependent="constant"!==e&&!rl(i.expression),this.configDependencies=nl(i.expression)}evaluateWithoutErrorHandling(e,i,o,h,a,u){return this._styleExpression.evaluateWithoutErrorHandling(e,i,o,h,a,u)}evaluate(e,i,o,h,a,u){return this._styleExpression.evaluate(e,i,o,h,a,u)}}class gn{constructor(e,i,o,h,a){this.kind=e,this.zoomStops=o,this._styleExpression=i,this.isStateDependent="camera"!==e&&!rl(i.expression),this.isLightConstant=a,this.configDependencies=nl(i.expression),this.interpolationType=h}evaluateWithoutErrorHandling(e,i,o,h,a,u){return this._styleExpression.evaluateWithoutErrorHandling(e,i,o,h,a,u)}evaluate(e,i,o,h,a,u){return this._styleExpression.evaluate(e,i,o,h,a,u)}interpolationFactor(e,i,o){return this.interpolationType?Nr.interpolationFactor(this.interpolationType,e,i,o):0}}function xu(n,e,i,o){if("error"===(n=da(n,e,i,o)).result)return n;const h=n.value.expression,a=na(h);if(!a&&!ul(e))return eo([new mn("","data expressions not supported")]);const u=oa(h,["zoom","pitch","distance-from-center"]);if(!u&&!fu(e))return eo([new mn("","zoom expressions not supported")]);const m=oa(h,["measure-light"]);if(!m&&!zc(e))return eo([new mn("","measure-light expression not supported")]);const x=e.expression&&e.expression.relaxZoomRestriction,w=_l(h);return w||u||x?w instanceof mn?eo([w]):w instanceof Nr&&!Dc(e)?eo([new mn("",'"interpolate" expressions cannot be used with this property')]):pu(w?new gn(a?"camera":"composite",n.value,w.labels,w instanceof Nr?w.interpolation:void 0,m):new Rc(a?"constant":"source",n.value,m)):eo([new mn("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class ml{constructor(e,i){this._parameters=e,this._specification=i,Yo(this,_u(this._parameters,this._specification))}static deserialize(e){return new ml(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function _l(n){let e=null;if(n instanceof al)e=_l(n.result);else if(n instanceof sl){for(const i of n.args)if(e=_l(i),e)break}else(n instanceof sa||n instanceof Nr)&&n.input instanceof Cr&&"zoom"===n.input.name&&(e=n);return e instanceof mn||n.eachChild(i=>{const o=_l(i);o instanceof mn?e=o:e&&o&&e!==o&&(e=new mn("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),e}var gl,Lc,Ao=Mi(function(){if(Lc)return gl;Lc=1,gl=e;var n=3;function e(i,o,h){var a=this.cells=[];if(i instanceof ArrayBuffer){this.arrayBuffer=i;var u=new Int32Array(this.arrayBuffer);i=u[0],this.d=(o=u[1])+2*(h=u[2]);for(var m=0;m=b[M+0]&&a>=b[M+1])?(x[v]=!0,m.push(g[v])):x[v]=!1}}},e.prototype._forEachCell=function(i,o,h,a,u,m,x,w){for(var p=this._convertToCellCoord(i),g=this._convertToCellCoord(o),b=this._convertToCellCoord(h),y=this._convertToCellCoord(a),v=p;v<=b;v++)for(var M=g;M<=y;M++){var E=this.d*M+v;if((!w||w(this._convertFromCellCoord(v),this._convertFromCellCoord(M),this._convertFromCellCoord(v+1),this._convertFromCellCoord(M+1)))&&u.call(this,i,o,h,a,E,m,x,w))return}},e.prototype._convertFromCellCoord=function(i){return(i-this.padding)/this.scale},e.prototype._convertToCellCoord=function(i){return Math.max(0,Math.min(this.d-1,Math.floor(i*this.scale)+this.padding))},e.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var i=this.cells,o=n+this.cells.length+1+1,h=0,a=0;a=0||(h[a]=Pr(n[a],e)));n instanceof Error&&(h.message=n.message)}if(h.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==o&&(h.$name=o),h}throw new Error("can't serialize object of type "+typeof n)}function Io(n){if(null==n||"boolean"==typeof n||"number"==typeof n||"string"==typeof n||n instanceof Boolean||n instanceof Number||n instanceof String||n instanceof Date||n instanceof RegExp||kc(n)||bu(n)||ArrayBuffer.isView(n)||n instanceof ImageData)return n;if(Array.isArray(n))return n.map(Io);if("object"==typeof n){const e=n.$name||"Object";if("Map"===e){const h=new Map;for(const a of Object.keys(n))"$name"!==a&&h.set(a,Io(n[a]));return h}if("Set"===e){const h=new Set;for(const a of Object.keys(n))"$name"!==a&&h.add(Io(n[a]));return h}const{klass:i}=ms[e];if(!i)throw new Error(`can't deserialize unregistered class ${e}`);if(i.deserialize)return i.deserialize(n);const o=Object.create(i.prototype);for(const h of Object.keys(n))"$name"!==h&&(o[h]=Io(n[h]));return o}throw new Error("can't deserialize object of type "+typeof n)}const at_Arabic=n=>n>=1536&&n<=1791,at_Arabic_Supplement=n=>n>=1872&&n<=1919,at_Arabic_Extended_A=n=>n>=2208&&n<=2303,at_CJK_Radicals_Supplement=n=>n>=11904&&n<=12031,at_Kangxi_Radicals=n=>n>=12032&&n<=12255,at_Ideographic_Description_Characters=n=>n>=12272&&n<=12287,at_CJK_Symbols_and_Punctuation=n=>n>=12288&&n<=12351,at_Hiragana=n=>n>=12352&&n<=12447,at_Katakana=n=>n>=12448&&n<=12543,at_Bopomofo=n=>n>=12544&&n<=12591,at_Bopomofo_Extended=n=>n>=12704&&n<=12735,at_CJK_Strokes=n=>n>=12736&&n<=12783,at_Katakana_Phonetic_Extensions=n=>n>=12784&&n<=12799,at_Enclosed_CJK_Letters_and_Months=n=>n>=12800&&n<=13055,at_CJK_Compatibility=n=>n>=13056&&n<=13311,at_CJK_Unified_Ideographs_Extension_A=n=>n>=13312&&n<=19903,at_CJK_Unified_Ideographs=n=>n>=19968&&n<=40959,at_Yi_Syllables=n=>n>=40960&&n<=42127,at_Yi_Radicals=n=>n>=42128&&n<=42191,at_Hangul_Syllables=n=>n>=44032&&n<=55215,at_CJK_Compatibility_Ideographs=n=>n>=63744&&n<=64255,at_Arabic_Presentation_Forms_A=n=>n>=64336&&n<=65023,at_Vertical_Forms=n=>n>=65040&&n<=65055,at_CJK_Compatibility_Forms=n=>n>=65072&&n<=65103,at_Small_Form_Variants=n=>n>=65104&&n<=65135,at_Arabic_Presentation_Forms_B=n=>n>=65136&&n<=65279,at_Halfwidth_and_Fullwidth_Forms=n=>n>=65280&&n<=65519;function yl(n){for(const e of n)if(vl(e.charCodeAt(0)))return!0;return!1}function Vd(n){for(const e of n)if(!xl(e.charCodeAt(0)))return!1;return!0}function xl(n){return!(at_Arabic(n)||at_Arabic_Supplement(n)||at_Arabic_Extended_A(n)||at_Arabic_Presentation_Forms_A(n)||at_Arabic_Presentation_Forms_B(n))}function vl(n){return!(746!==n&&747!==n&&(n<4352||!(at_Bopomofo_Extended(n)||at_Bopomofo(n)||at_CJK_Compatibility_Forms(n)&&!(n>=65097&&n<=65103)||at_CJK_Compatibility_Ideographs(n)||at_CJK_Compatibility(n)||at_CJK_Radicals_Supplement(n)||at_CJK_Strokes(n)||!(!at_CJK_Symbols_and_Punctuation(n)||n>=12296&&n<=12305||n>=12308&&n<=12319||12336===n)||at_CJK_Unified_Ideographs_Extension_A(n)||at_CJK_Unified_Ideographs(n)||at_Enclosed_CJK_Letters_and_Months(n)||(n=>n>=12592&&n<=12687)(n)||(n=>n>=43360&&n<=43391)(n)||(n=>n>=55216&&n<=55295)(n)||(n=>n>=4352&&n<=4607)(n)||at_Hangul_Syllables(n)||at_Hiragana(n)||at_Ideographic_Description_Characters(n)||(n=>n>=12688&&n<=12703)(n)||at_Kangxi_Radicals(n)||at_Katakana_Phonetic_Extensions(n)||at_Katakana(n)&&12540!==n||!(!at_Halfwidth_and_Fullwidth_Forms(n)||65288===n||65289===n||65293===n||n>=65306&&n<=65310||65339===n||65341===n||65343===n||n>=65371&&n<=65503||65507===n||n>=65512&&n<=65519)||!(!at_Small_Form_Variants(n)||n>=65112&&n<=65118||n>=65123&&n<=65126)||(n=>n>=5120&&n<=5759)(n)||(n=>n>=6320&&n<=6399)(n)||at_Vertical_Forms(n)||(n=>n>=19904&&n<=19967)(n)||at_Yi_Syllables(n)||at_Yi_Radicals(n))))}function pa(n){return!(vl(n)||(e=n,(n=>n>=128&&n<=255)(e)&&(167===e||169===e||174===e||177===e||188===e||189===e||190===e||215===e||247===e)||(n=>n>=8192&&n<=8303)(e)&&(8214===e||8224===e||8225===e||8240===e||8241===e||8251===e||8252===e||8258===e||8263===e||8264===e||8265===e||8273===e)||(n=>n>=8448&&n<=8527)(e)||(n=>n>=8528&&n<=8591)(e)||(n=>n>=8960&&n<=9215)(e)&&(e>=8960&&e<=8967||e>=8972&&e<=8991||e>=8996&&e<=9e3||9003===e||e>=9085&&e<=9114||e>=9150&&e<=9165||9167===e||e>=9169&&e<=9179||e>=9186&&e<=9215)||(n=>n>=9216&&n<=9279)(e)&&9251!==e||(n=>n>=9280&&n<=9311)(e)||(n=>n>=9312&&n<=9471)(e)||(n=>n>=9632&&n<=9727)(e)||(n=>n>=9728&&n<=9983)(e)&&!(e>=9754&&e<=9759)||(n=>n>=11008&&n<=11263)(e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||at_CJK_Symbols_and_Punctuation(e)||at_Katakana(e)||(n=>n>=57344&&n<=63743)(e)||at_CJK_Compatibility_Forms(e)||at_Small_Form_Variants(e)||at_Halfwidth_and_Fullwidth_Forms(e)||8734===e||8756===e||8757===e||e>=9984&&e<=10087||e>=10102&&e<=10131||65532===e||65533===e));var e}function Oc(n){return n>=1424&&n<=2303||at_Arabic_Presentation_Forms_A(n)||at_Arabic_Presentation_Forms_B(n)}function Ud(n,e){return!(!e&&Oc(n)||n>=2304&&n<=3583||n>=3840&&n<=4255||(n=>n>=6016&&n<=6143)(n))}function jd(n){for(const e of n)if(Oc(e.charCodeAt(0)))return!0;return!1}const fa="deferred",ma="loading",bl="loaded";let _s=null,or="unavailable",to=null;const wu=function(n){n&&"string"==typeof n&&n.indexOf("NetworkError")>-1&&(or="error"),_s&&_s(n)};function Bc(){Fc.fire(new Xn("pluginStateChange",{pluginStatus:or,pluginURL:to}))}const Fc=new Xo,Nc=function(){return or},Vc=function(){if(or!==fa||!to)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");or=ma,Bc(),to&&Ho({url:to},n=>{n?wu(n):(or=bl,Bc())})},zr={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>or===bl||null!=zr.applyArabicShaping,isLoading:()=>or===ma,setState(n){or=n.pluginStatus,to=n.pluginURL},isParsed:()=>null!=zr.applyArabicShaping&&null!=zr.processBidirectionalText&&null!=zr.processStyledBidirectionalText,getPluginURL:()=>to};class Bi{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.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0)}isSupportedScript(e){return function(i,o){for(const h of i)if(!Ud(h.charCodeAt(0),o))return!1;return!0}(e,zr.isLoaded())}}class wl{constructor(e,i,o,h){this.property=e,this.value=i,this.expression=function(a,u,m,x){if(dl(a))return new ml(a,u);if(fl(a)||Array.isArray(a)&&a.length>0){const w=xu(a,u,m,x);if("error"===w.result)throw new Error(w.value.map(p=>`${p.key}: ${p.message}`).join(", "));return w.value}{let w=a;return"string"==typeof a&&"color"===u.type&&(w=li.parse(a)),{kind:"constant",configDependencies:new Set,evaluate:()=>w}}}(void 0===i?e.specification.default:i,e.specification,o,h)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(e,i,o){return this.property.possiblyEvaluate(this,e,i,o)}}class Uc{constructor(e,i,o){this.property=e,this.value=new wl(e,void 0,i,o)}transitioned(e,i){return new Mu(this.property,this.value,i,pr({},e.transition,this.transition),e.now)}untransitioned(){return new Mu(this.property,this.value,null,{},0)}}class Tu{constructor(e,i,o){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._scope=i,this._options=o,this.configDependencies=new Set}getValue(e){return Zr(this._values[e].value.value)}setValue(e,i){this._values.hasOwnProperty(e)||(this._values[e]=new Uc(this._values[e].property,this._scope,this._options)),this._values[e].value=new wl(this._values[e].property,null===i?void 0:Zr(i),this._scope,this._options),this._values[e].value.expression.configDependencies&&(this.configDependencies=new Set([...this.configDependencies,...this._values[e].value.expression.configDependencies]))}setTransitionOrValue(e,i){i&&(this._options=i);const o=this._properties.properties;if(e)for(const h in e){const a=e[h];if(Pn(h,"-transition")){const u=h.slice(0,-11);o[u]&&this.setTransition(u,a)}else o.hasOwnProperty(h)&&this.setValue(h,a)}}getTransition(e){return Zr(this._values[e].transition)}setTransition(e,i){this._values.hasOwnProperty(e)||(this._values[e]=new Uc(this._values[e].property)),this._values[e].transition=Zr(i)||void 0}serialize(){const e={};for(const i of Object.keys(this._values)){const o=this.getValue(i);void 0!==o&&(e[i]=o);const h=this.getTransition(i);void 0!==h&&(e[`${i}-transition`]=h)}return e}transitioned(e,i){const o=new Su(this._properties);for(const h of Object.keys(this._values))o._values[h]=this._values[h].transitioned(e,i._values[h]);return o}untransitioned(){const e=new Su(this._properties);for(const i of Object.keys(this._values))e._values[i]=this._values[i].untransitioned();return e}}class Mu{constructor(e,i,o,h,a){const u=h.delay||0,m=h.duration||0;a=a||0,this.property=e,this.value=i,this.begin=a+u,this.end=this.begin+m,e.specification.transition&&(h.delay||h.duration)&&(this.prior=o)}possiblyEvaluate(e,i,o){const h=e.now||0,a=this.value.possiblyEvaluate(e,i,o),u=this.prior;if(u){if(h>this.end)return this.prior=null,a;if(this.value.isDataDriven())return this.prior=null,a;if(h":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":{"expression":{"type":"expression"},"stops":{"type":"array","value":"function_stop"},"base":{"type":"number","default":1,"minimum":0},"property":{"type":"string","default":"$zoom"},"type":{"type":"enum","values":{"identity":1,"exponential":1,"interval":1,"categorical":1},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":1,"lab":1,"hcl":1},"default":"rgb"},"default":{"type":"*","required":false}},"function_stop":{"type":"array","minimum":0,"maximum":24,"value":["number","color"],"length":2},"expression":{"type":"array","value":"*","minimum":1},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"high-color":{"type":"color","property-type":"data-constant","default":"#245cdf","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"space-color":{"type":"color","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"horizon-blend":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,0.2,7,0.1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"star-intensity":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],5,0.35,6,0],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vertical-range":{"type":"array","default":[0,0],"minimum":0,"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}}},"camera":{"camera-projection":{"type":"enum","values":{"perspective":1,"orthographic":1},"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"default":"perspective","property-type":"data-constant"}},"colorTheme":{"data":{"type":"string","property-type":"data-constant","expression":{}}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"property-type":"data-constant","expression":{"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":1,"equalEarth":1,"equirectangular":1,"lambertConformalConic":1,"mercator":1,"naturalEarth":1,"winkelTripel":1,"globe":1},"default":"mercator","required":true},"center":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-180,-90],"maximum":[180,90]},"parallels":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-90,-90],"maximum":[90,90]}},"terrain":{"source":{"type":"string","required":true},"exaggeration":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","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"]},"property-type":"data-constant"},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"fill-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"fill-z-offset":{"type":"number","default":0,"minimum":0,"transition":true,"experimental":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-ambient-occlusion-intensity":{"property-type":"data-constant","type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-radius":{"property-type":"data-constant","type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-wall-radius":{"property-type":"data-constant","type":"number","experimental":true,"default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-radius":{"property-type":"data-constant","type":"number","experimental":true,"default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-attenuation":{"property-type":"data-constant","type":"number","experimental":true,"default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-flood-light-color":{"property-type":"data-constant","type":"color","experimental":true,"default":"#ffffff","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-intensity":{"property-type":"data-constant","type":"number","experimental":true,"default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-wall-radius":{"property-type":"data-driven","type":"number","experimental":true,"default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-radius":{"property-type":"data-driven","type":"number","experimental":true,"default":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-attenuation":{"property-type":"data-constant","type":"number","experimental":true,"default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-vertical-scale":{"property-type":"data-constant","type":"number","experimental":true,"default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-rounded-roof":{"property-type":"data-constant","type":"boolean","default":true,"experimental":true,"expression":{"parameters":["zoom"]}},"fill-extrusion-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{},"property-type":"data-constant"},"fill-extrusion-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"property-type":"data-driven"},"fill-extrusion-line-width":{"type":"number","default":0,"minimum":0,"transition":true,"experimental":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-extrusion-cast-shadows":{"type":"boolean","default":true,"property-type":"data-constant"}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-gradient":{"type":"color","expression":{"interpolated":true,"parameters":["line-progress"]},"property-type":"color-ramp"},"line-trim-offset":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1],"property-type":"constant"},"line-trim-fade-range":{"type":"array","value":"number","experimental":true,"length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1],"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"line-trim-color":{"type":"color","experimental":true,"default":"transparent","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"line-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"line-border-width":{"type":"number","private":true,"default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-border-color":{"type":"color","private":true,"default":"rgba(0, 0, 0, 0)","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-occlusion-opacity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true,"property-type":"data-constant"}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"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":true,"parameters":["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-occlusion-opacity":{"type":"number","minimum":0,"maximum":1,"default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"property-type":"data-driven"},"text-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-image-cross-fade":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"transition":true},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-occlusion-opacity":{"type":"number","minimum":0,"maximum":1,"default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","transition":true,"overridable":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-color-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{},"property-type":"data-constant"},"icon-color-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{},"property-type":"data-constant"},"icon-color-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{},"property-type":"data-constant"},"icon-color-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{},"property-type":"data-constant"},"symbol-z-offset":{"type":"number","default":0,"minimum":0,"transition":true,"experimental":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"symbol-elevation-reference":{"type":"enum","values":{"sea":1,"ground":1},"default":"ground","experimental":true,"expression":{"parameters":["zoom"]},"property-type":"data-constant"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-color":{"type":"color","expression":{"interpolated":true,"parameters":["raster-value"]},"property-type":"color-ramp"},"raster-color-mix":{"type":"array","default":[0.2126,0.7152,0.0722,0],"length":4,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-color-range":{"type":"array","length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-resampling":{"type":"enum","values":{"linear":1,"nearest":1},"default":"linear","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"raster-array-band":{"type":"string","required":false,"experimental":true,"property-type":"data-constant"},"raster-elevation":{"type":"number","default":0,"minimum":0,"transition":true,"experimental":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_raster-particle":{"raster-particle-array-band":{"type":"string","required":false,"property-type":"data-constant"},"raster-particle-count":{"type":"number","default":512,"minimum":1,"property-type":"data-constant"},"raster-particle-color":{"type":"color","expression":{"interpolated":true,"parameters":["raster-particle-speed"]},"property-type":"color-ramp"},"raster-particle-max-speed":{"type":"number","default":1,"minimum":1,"property-type":"data-constant"},"raster-particle-speed-factor":{"type":"number","default":0.2,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-particle-fade-opacity-factor":{"type":"number","default":0.98,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-particle-reset-rate-factor":{"type":"number","default":0.8,"minimum":0,"maximum":1,"property-type":"data-constant"},"raster-particle-elevation":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"hillshade-accent-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"hillshade-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"}},"paint_background":{"background-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":[]},"property-type":"data-constant"},"background-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":1,"atmosphere":1},"default":"atmosphere","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun-intensity":{"type":"number","default":10,"minimum":0,"maximum":100,"property-type":"data-constant"},"sky-gradient-center":{"type":"array","value":"number","default":[0,0],"length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient-radius":{"type":"number","default":90,"minimum":0,"maximum":180,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"expression":{"interpolated":true,"parameters":["sky-radial-progress"]},"property-type":"color-ramp"},"sky-atmosphere-halo-color":{"type":"color","default":"white","property-type":"data-constant"},"sky-atmosphere-color":{"type":"color","default":"white","property-type":"data-constant"},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_model":{"model-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"model-rotation":{"type":"array","value":"number","length":3,"default":[0,0,0],"period":360,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-scale":{"type":"array","value":"number","length":3,"default":[1,1,1],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-translation":{"type":"array","value":"number","length":3,"default":[0,0,0],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-color":{"type":"color","default":"#ffffff","property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":true},"model-color-mix-intensity":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-type":{"type":"enum","values":{"common-3d":1,"location-indicator":1},"default":"common-3d","property-type":"data-constant"},"model-cast-shadows":{"type":"boolean","default":true,"property-type":"data-constant"},"model-receive-shadows":{"type":"boolean","default":true,"property-type":"data-constant"},"model-ambient-occlusion-intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant","transition":true},"model-emissive-strength":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-roughness":{"type":"number","default":1,"minimum":0,"maximum":1,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state"]},"transition":true},"model-height-based-emissive-strength-multiplier":{"type":"array","default":[1,1,1,1,0],"length":5,"value":"number","property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{},"property-type":"data-constant"},"model-front-cutoff":{"type":"array","private":true,"value":"number","property-type":"data-constant","expression":{"interpolated":true,"parameters":["zoom"]},"length":3,"default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1]}},"transition":{"duration":{"type":"number","default":300,"minimum":0},"delay":{"type":"number","default":0,"minimum":0}},"property-type":{"data-driven":{"type":"property-type"},"color-ramp":{"type":"property-type"},"data-constant":{"type":"property-type"},"constant":{"type":"property-type"}},"promoteId":{"*":{"type":"string"}}}');function _a(n){return n instanceof Number||n instanceof String||n instanceof Boolean?n.valueOf():n}function Tl(n){if(Array.isArray(n))return n.map(Tl);if(n instanceof Object&&!(n instanceof Number||n instanceof String||n instanceof Boolean)){const e={};for(const i in n)e[i]=Tl(n[i]);return e}return _a(n)}function jc(n){if(!0===n||!1===n)return!0;if(!Array.isArray(n)||0===n.length)return!1;switch(n[0]){case"has":return n.length>=2&&"$id"!==n[1]&&"$type"!==n[1];case"in":return n.length>=3&&("string"!=typeof n[1]||Array.isArray(n[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==n.length||Array.isArray(n[1])||Array.isArray(n[2]);case"any":case"all":for(const e of n.slice(1))if(!jc(e)&&"boolean"!=typeof e)return!1;return!0;default:return!0}}function ln(n,e="",i=null,o="fill"){if(null==n)return{filter:()=>!0,needGeometry:!1,needFeature:!1};jc(n)||(n=Ml(n));const h=n;let a=!0;try{a=function(g){if(!xs(g))return g;let b=Tl(g);return Co(b),b=Gc(b),b}(h)}catch{console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.\nThis is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md\nand paste the contents of this message in the report.\nThank you!\nFilter Expression:\n${JSON.stringify(h,null,2)}\n `)}const u=be[`filter_${o}`],m=da(a,u,e,i);let x=null;if("error"===m.result)throw new Error(m.value.map(g=>`${g.key}: ${g.message}`).join(", "));x=(g,b,y)=>m.value.evaluate(g,b,{},y);let w=null,p=null;if(a!==h){const g=da(h,u,e,i);if("error"===g.result)throw new Error(g.value.map(b=>`${b.key}: ${b.message}`).join(", "));w=(b,y,v,M,E)=>g.value.evaluate(b,y,{},v,void 0,void 0,M,E),p=!na(g.value.expression)}return{filter:x,dynamicFilter:w||void 0,needGeometry:Eu(a),needFeature:!!p}}function Gc(n){if(!Array.isArray(n))return n;const e=function(i){if(qd.has(i[0]))for(let o=1;oGc(i))}function Co(n){let e=!1;const i=[];if("case"===n[0]){for(let o=1;o",">=","<","<=","to-boolean"]);function Zd(n,e){return ne?1:0}function Eu(n){if(!Array.isArray(n))return!1;if("within"===n[0]||"distance"===n[0])return!0;for(let e=1;e"===e||"<="===e||">="===e?Sl(n[1],n[2],e):"any"===e?(i=n.slice(1),["any"].concat(i.map(Ml))):"all"===e?["all"].concat(n.slice(1).map(Ml)):"none"===e?["all"].concat(n.slice(1).map(Ml).map(ya)):"in"===e?El(n[1],n.slice(2)):"!in"===e?ya(El(n[1],n.slice(2))):"has"===e?ga(n[1]):"!has"!==e||ya(ga(n[1]));var i}function Sl(n,e,i){switch(n){case"$type":return[`filter-type-${i}`,e];case"$id":return[`filter-id-${i}`,e];default:return[`filter-${i}`,n,e]}}function El(n,e){if(0===e.length)return!1;switch(n){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",n,["literal",e.sort(Zd)]]:["filter-in-small",n,["literal",e]]}}function ga(n){switch(n){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",n]}}function ya(n){return["!",n]}function Au(n,e){return e?`${n}\x1f${e}`:n}const cn="-transition",$d=new Set(["fill","line","background","hillshade","raster"]);class _r extends Xo{constructor(e,i,o,h,a){if(super(),this.id=e.id,this.fqid=Au(this.id,o),this.type=e.type,this.scope=o,this.lut=h,this.options=a,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,this.configDependencies=new Set,"custom"!==e.type&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,"background"!==e.type&&"sky"!==e.type&&"slot"!==e.type&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter),e.slot&&(this.slot=e.slot),i.layout&&(this._unevaluatedLayout=new Gd(i.layout,this.scope,a),this.configDependencies=new Set([...this.configDependencies,...this._unevaluatedLayout.configDependencies])),i.paint)){this._transitionablePaint=new Tu(i.paint,this.scope,a);for(const u in e.paint)this.setPaintProperty(u,e.paint[u]);for(const u in e.layout)this.setLayoutProperty(u,e.layout[u]);this.configDependencies=new Set([...this.configDependencies,...this._transitionablePaint.configDependencies]),this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new ys(i.paint)}}onAdd(e){}onRemove(e){}isDraped(e){return!this.is3D()&&$d.has(this.type)}getLayoutProperty(e){return"visibility"===e?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,i){if("custom"===this.type&&"visibility"===e)return void(this.visibility=i);const o=this._unevaluatedLayout;o._properties.properties[e]&&(o.setValue(e,i),this.configDependencies=new Set([...this.configDependencies,...o.configDependencies]),"visibility"===e&&this.possiblyEvaluateVisibility())}possiblyEvaluateVisibility(){this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0})}getPaintProperty(e){return Pn(e,cn)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,i){const o=this._transitionablePaint,h=o._properties.properties;if(Pn(e,cn)){const g=e.slice(0,-11);return h[g]&&o.setTransition(g,i||void 0),!1}if(!h[e])return!1;const a=o._values[e],u=a.value.isDataDriven(),m=a.value;o.setValue(e,i),this.configDependencies=new Set([...this.configDependencies,...o.configDependencies]),this._handleSpecialPaintPropertyUpdate(e);const x=o._values[e].value,w=x.isDataDriven(),p=Pn(e,"pattern")||"line-dasharray"===e;return w||u||p||this._handleOverridablePaintPropertyUpdate(e,m,x)}_handleSpecialPaintPropertyUpdate(e){}getProgramIds(){return null}getDefaultProgramParams(e,i,o){return null}_handleOverridablePaintPropertyUpdate(e,i,o){return!1}isHidden(e){return!!(this.minzoom&&e=this.maxzoom)||"none"===this.visibility}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.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,i)}serialize(){return Go({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()},(e,i)=>!(void 0===e||"layout"===i&&!Object.keys(e).length||"paint"===i&&!Object.keys(e).length))}is3D(){return!1}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(){}isStateDependent(){for(const e in this.paint._values){const i=this.paint.get(e);if(i instanceof gs&&ul(i.property.specification)&&("source"===i.value.kind||"composite"===i.value.kind)&&i.value.isStateDependent)return!0}return!1}compileFilter(e){this._filterCompiled||(this._featureFilter=ln(this.filter,this.scope,e),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}getLayerRenderingStats(){return this._stats}resetLayerRenderingStats(e){this._stats&&("shadow"===e.renderPass?this._stats.numRenderedVerticesInShadowPass=0:this._stats.numRenderedVerticesInTransparentPass=0)}queryRadius(e){}queryIntersectsFeature(e,i,o,h,a,u,m,x,w){}queryIntersectsMatchingFeature(e,i,o,h){}}const Hd={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class xa{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}}class Ii{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,i){return e._trim(),i&&(e.isTransferred=!0,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,i.capacity=e.arrayBuffer.byteLength/i.bytesPerElement,i._refreshViews(),i}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const i=this.uint8;this._refreshViews(),i&&this.uint8.set(i)}}_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 ti(n,e=1){let i=0,o=0;return{members:n.map(h=>{const a=Hd[h.type].BYTES_PER_ELEMENT,u=i=Iu(i,Math.max(e,a)),m=h.components||1;return o=Math.max(o,a),i+=a*m,{name:h.name,type:h.type,components:m,offset:u}}),size:Iu(i,Math.max(o,e)),alignment:e}}function Iu(n,e){return Math.ceil(n/e)*e}class io extends Ii{_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 h=2*e;return this.int16[h+0]=i,this.int16[h+1]=o,e}}io.prototype.bytesPerElement=4,rt(io,"StructArrayLayout2i4");class Al extends Ii{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,o){const h=this.length;return this.resize(h+1),this.emplace(h,e,i,o)}emplace(e,i,o,h){const a=3*e;return this.int16[a+0]=i,this.int16[a+1]=o,this.int16[a+2]=h,e}}Al.prototype.bytesPerElement=6,rt(Al,"StructArrayLayout3i6");class ro extends Ii{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,o,h){const a=this.length;return this.resize(a+1),this.emplace(a,e,i,o,h)}emplace(e,i,o,h,a){const u=4*e;return this.int16[u+0]=i,this.int16[u+1]=o,this.int16[u+2]=h,this.int16[u+3]=a,e}}ro.prototype.bytesPerElement=8,rt(ro,"StructArrayLayout4i8");class Il extends Ii{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,o,h,a){const u=this.length;return this.resize(u+1),this.emplace(u,e,i,o,h,a)}emplace(e,i,o,h,a,u){const m=5*e;return this.int16[m+0]=i,this.int16[m+1]=o,this.int16[m+2]=h,this.int16[m+3]=a,this.int16[m+4]=u,e}}Il.prototype.bytesPerElement=10,rt(Il,"StructArrayLayout5i10");class qc extends Ii{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,o,h,a,u,m){const x=this.length;return this.resize(x+1),this.emplace(x,e,i,o,h,a,u,m)}emplace(e,i,o,h,a,u,m,x){const w=6*e,p=12*e,g=3*e;return this.int16[w+0]=i,this.int16[w+1]=o,this.uint8[p+4]=h,this.uint8[p+5]=a,this.uint8[p+6]=u,this.uint8[p+7]=m,this.float32[g+2]=x,e}}qc.prototype.bytesPerElement=12,rt(qc,"StructArrayLayout2i4ub1f12");class kn extends Ii{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,o,h){const a=this.length;return this.resize(a+1),this.emplace(a,e,i,o,h)}emplace(e,i,o,h,a){const u=4*e;return this.float32[u+0]=i,this.float32[u+1]=o,this.float32[u+2]=h,this.float32[u+3]=a,e}}kn.prototype.bytesPerElement=16,rt(kn,"StructArrayLayout4f16");class no extends Ii{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,o){const h=this.length;return this.resize(h+1),this.emplace(h,e,i,o)}emplace(e,i,o,h){const a=3*e;return this.float32[a+0]=i,this.float32[a+1]=o,this.float32[a+2]=h,e}}no.prototype.bytesPerElement=12,rt(no,"StructArrayLayout3f12");class On extends Ii{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,o,h,a){const u=this.length;return this.resize(u+1),this.emplace(u,e,i,o,h,a)}emplace(e,i,o,h,a,u){const m=6*e,x=3*e;return this.uint16[m+0]=i,this.uint16[m+1]=o,this.uint16[m+2]=h,this.uint16[m+3]=a,this.float32[x+2]=u,e}}On.prototype.bytesPerElement=12,rt(On,"StructArrayLayout4ui1f12");class Po extends Ii{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,o,h){const a=this.length;return this.resize(a+1),this.emplace(a,e,i,o,h)}emplace(e,i,o,h,a){const u=4*e;return this.uint16[u+0]=i,this.uint16[u+1]=o,this.uint16[u+2]=h,this.uint16[u+3]=a,e}}Po.prototype.bytesPerElement=8,rt(Po,"StructArrayLayout4ui8");class Cl extends Ii{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,o,h,a,u){const m=this.length;return this.resize(m+1),this.emplace(m,e,i,o,h,a,u)}emplace(e,i,o,h,a,u,m){const x=6*e;return this.int16[x+0]=i,this.int16[x+1]=o,this.int16[x+2]=h,this.int16[x+3]=a,this.int16[x+4]=u,this.int16[x+5]=m,e}}Cl.prototype.bytesPerElement=12,rt(Cl,"StructArrayLayout6i12");class Zc extends Ii{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,o,h,a,u,m,x,w,p,g,b){const y=this.length;return this.resize(y+1),this.emplace(y,e,i,o,h,a,u,m,x,w,p,g,b)}emplace(e,i,o,h,a,u,m,x,w,p,g,b,y){const v=12*e;return this.int16[v+0]=i,this.int16[v+1]=o,this.int16[v+2]=h,this.int16[v+3]=a,this.uint16[v+4]=u,this.uint16[v+5]=m,this.uint16[v+6]=x,this.uint16[v+7]=w,this.int16[v+8]=p,this.int16[v+9]=g,this.int16[v+10]=b,this.int16[v+11]=y,e}}Zc.prototype.bytesPerElement=24,rt(Zc,"StructArrayLayout4i4ui4i24");class $c extends Ii{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,o,h,a,u){const m=this.length;return this.resize(m+1),this.emplace(m,e,i,o,h,a,u)}emplace(e,i,o,h,a,u,m){const x=10*e,w=5*e;return this.int16[x+0]=i,this.int16[x+1]=o,this.int16[x+2]=h,this.float32[w+2]=a,this.float32[w+3]=u,this.float32[w+4]=m,e}}$c.prototype.bytesPerElement=20,rt($c,"StructArrayLayout3i3f20");class Hc extends Ii{_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}}Hc.prototype.bytesPerElement=4,rt(Hc,"StructArrayLayout1ul4");class oo extends Ii{_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 h=2*e;return this.uint16[h+0]=i,this.uint16[h+1]=o,e}}oo.prototype.bytesPerElement=4,rt(oo,"StructArrayLayout2ui4");class bs extends Ii{_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,h,a,u,m,x,w,p,g,b,y){const v=this.length;return this.resize(v+1),this.emplace(v,e,i,o,h,a,u,m,x,w,p,g,b,y)}emplace(e,i,o,h,a,u,m,x,w,p,g,b,y,v){const M=20*e,E=10*e;return this.int16[M+0]=i,this.int16[M+1]=o,this.int16[M+2]=h,this.int16[M+3]=a,this.int16[M+4]=u,this.float32[E+3]=m,this.float32[E+4]=x,this.float32[E+5]=w,this.float32[E+6]=p,this.int16[M+14]=g,this.uint32[E+8]=b,this.uint16[M+18]=y,this.uint16[M+19]=v,e}}bs.prototype.bytesPerElement=40,rt(bs,"StructArrayLayout5i4f1i1ul2ui40");class zo extends Ii{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,o,h,a,u,m){const x=this.length;return this.resize(x+1),this.emplace(x,e,i,o,h,a,u,m)}emplace(e,i,o,h,a,u,m,x){const w=8*e;return this.int16[w+0]=i,this.int16[w+1]=o,this.int16[w+2]=h,this.int16[w+4]=a,this.int16[w+5]=u,this.int16[w+6]=m,this.int16[w+7]=x,e}}zo.prototype.bytesPerElement=16,rt(zo,"StructArrayLayout3i2i2i16");class wr extends Ii{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,o,h,a){const u=this.length;return this.resize(u+1),this.emplace(u,e,i,o,h,a)}emplace(e,i,o,h,a,u){const m=4*e,x=8*e;return this.float32[m+0]=i,this.float32[m+1]=o,this.float32[m+2]=h,this.int16[x+6]=a,this.int16[x+7]=u,e}}wr.prototype.bytesPerElement=16,rt(wr,"StructArrayLayout2f1f2i16");class ws extends Ii{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,o,h,a,u){const m=this.length;return this.resize(m+1),this.emplace(m,e,i,o,h,a,u)}emplace(e,i,o,h,a,u,m){const x=20*e,w=5*e;return this.uint8[x+0]=i,this.uint8[x+1]=o,this.float32[w+1]=h,this.float32[w+2]=a,this.float32[w+3]=u,this.float32[w+4]=m,e}}ws.prototype.bytesPerElement=20,rt(ws,"StructArrayLayout2ub4f20");class cr extends Ii{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,o){const h=this.length;return this.resize(h+1),this.emplace(h,e,i,o)}emplace(e,i,o,h){const a=3*e;return this.uint16[a+0]=i,this.uint16[a+1]=o,this.uint16[a+2]=h,e}}cr.prototype.bytesPerElement=6,rt(cr,"StructArrayLayout3ui6");class Wc extends Ii{_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,h,a,u,m,x,w,p,g,b,y,v,M,E,C,R,k,P,O){const B=this.length;return this.resize(B+1),this.emplace(B,e,i,o,h,a,u,m,x,w,p,g,b,y,v,M,E,C,R,k,P,O)}emplace(e,i,o,h,a,u,m,x,w,p,g,b,y,v,M,E,C,R,k,P,O,B){const G=30*e,H=15*e,X=60*e;return this.int16[G+0]=i,this.int16[G+1]=o,this.int16[G+2]=h,this.float32[H+2]=a,this.float32[H+3]=u,this.uint16[G+8]=m,this.uint16[G+9]=x,this.uint32[H+5]=w,this.uint32[H+6]=p,this.uint32[H+7]=g,this.uint16[G+16]=b,this.uint16[G+17]=y,this.uint16[G+18]=v,this.float32[H+10]=M,this.float32[H+11]=E,this.uint8[X+48]=C,this.uint8[X+49]=R,this.uint8[X+50]=k,this.uint32[H+13]=P,this.int16[G+28]=O,this.uint8[X+58]=B,e}}Wc.prototype.bytesPerElement=60,rt(Wc,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class Xc extends Ii{_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,h,a,u,m,x,w,p,g,b,y,v,M,E,C,R,k,P,O,B,G,H,X,Z,te,K,re,he,pe,fe){const me=this.length;return this.resize(me+1),this.emplace(me,e,i,o,h,a,u,m,x,w,p,g,b,y,v,M,E,C,R,k,P,O,B,G,H,X,Z,te,K,re,he,pe,fe)}emplace(e,i,o,h,a,u,m,x,w,p,g,b,y,v,M,E,C,R,k,P,O,B,G,H,X,Z,te,K,re,he,pe,fe,me){const we=20*e,ge=40*e,Pe=80*e;return this.float32[we+0]=i,this.float32[we+1]=o,this.int16[ge+4]=h,this.int16[ge+5]=a,this.int16[ge+6]=u,this.int16[ge+7]=m,this.int16[ge+8]=x,this.int16[ge+9]=w,this.int16[ge+10]=p,this.int16[ge+11]=g,this.int16[ge+12]=b,this.uint16[ge+13]=y,this.uint16[ge+14]=v,this.uint16[ge+15]=M,this.uint16[ge+16]=E,this.uint16[ge+17]=C,this.uint16[ge+18]=R,this.uint16[ge+19]=k,this.uint16[ge+20]=P,this.uint16[ge+21]=O,this.uint16[ge+22]=B,this.uint16[ge+23]=G,this.uint16[ge+24]=H,this.uint16[ge+25]=X,this.uint16[ge+26]=Z,this.uint16[ge+27]=te,this.uint32[we+14]=K,this.float32[we+15]=re,this.float32[we+16]=he,this.float32[we+17]=pe,this.float32[we+18]=fe,this.uint8[Pe+76]=me,e}}Xc.prototype.bytesPerElement=80,rt(Xc,"StructArrayLayout2f9i15ui1ul4f1ub80");class Ts extends Ii{_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}}Ts.prototype.bytesPerElement=4,rt(Ts,"StructArrayLayout1f4");class Bn extends Ii{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,o,h,a){const u=this.length;return this.resize(u+1),this.emplace(u,e,i,o,h,a)}emplace(e,i,o,h,a,u){const m=5*e;return this.float32[m+0]=i,this.float32[m+1]=o,this.float32[m+2]=h,this.float32[m+3]=a,this.float32[m+4]=u,e}}Bn.prototype.bytesPerElement=20,rt(Bn,"StructArrayLayout5f20");class Yc extends Ii{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,o,h,a,u,m){const x=this.length;return this.resize(x+1),this.emplace(x,e,i,o,h,a,u,m)}emplace(e,i,o,h,a,u,m,x){const w=7*e;return this.float32[w+0]=i,this.float32[w+1]=o,this.float32[w+2]=h,this.float32[w+3]=a,this.float32[w+4]=u,this.float32[w+5]=m,this.float32[w+6]=x,e}}Yc.prototype.bytesPerElement=28,rt(Yc,"StructArrayLayout7f28");class va extends Ii{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,o,h){const a=this.length;return this.resize(a+1),this.emplace(a,e,i,o,h)}emplace(e,i,o,h,a){const u=6*e;return this.uint32[3*e+0]=i,this.uint16[u+2]=o,this.uint16[u+3]=h,this.uint16[u+4]=a,e}}va.prototype.bytesPerElement=12,rt(va,"StructArrayLayout1ul3ui12");class Kc extends Ii{_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}}Kc.prototype.bytesPerElement=2,rt(Kc,"StructArrayLayout1ui2");class ba extends Ii{_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 h=2*e;return this.float32[h+0]=i,this.float32[h+1]=o,e}}ba.prototype.bytesPerElement=8,rt(ba,"StructArrayLayout2f8");class wa extends Ii{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,o,h,a,u,m,x,w,p,g,b,y,v,M,E){const C=this.length;return this.resize(C+1),this.emplace(C,e,i,o,h,a,u,m,x,w,p,g,b,y,v,M,E)}emplace(e,i,o,h,a,u,m,x,w,p,g,b,y,v,M,E,C){const R=16*e;return this.float32[R+0]=i,this.float32[R+1]=o,this.float32[R+2]=h,this.float32[R+3]=a,this.float32[R+4]=u,this.float32[R+5]=m,this.float32[R+6]=x,this.float32[R+7]=w,this.float32[R+8]=p,this.float32[R+9]=g,this.float32[R+10]=b,this.float32[R+11]=y,this.float32[R+12]=v,this.float32[R+13]=M,this.float32[R+14]=E,this.float32[R+15]=C,e}}wa.prototype.bytesPerElement=64,rt(wa,"StructArrayLayout16f64");class Pl extends Ii{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,o,h,a,u,m){const x=this.length;return this.resize(x+1),this.emplace(x,e,i,o,h,a,u,m)}emplace(e,i,o,h,a,u,m,x){const w=10*e,p=5*e;return this.uint16[w+0]=i,this.uint16[w+1]=o,this.uint16[w+2]=h,this.uint16[w+3]=a,this.float32[p+2]=u,this.float32[p+3]=m,this.float32[p+4]=x,e}}Pl.prototype.bytesPerElement=20,rt(Pl,"StructArrayLayout4ui3f20");class zl extends Ii{_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}}zl.prototype.bytesPerElement=2,rt(zl,"StructArrayLayout1i2");class Dl extends Ii{_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}}Dl.prototype.bytesPerElement=1,rt(Dl,"StructArrayLayout1ub1");class Cu extends xa{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]}}Cu.prototype.size=40;class Rl extends bs{get(e){return new Cu(this,e)}}rt(Rl,"CollisionBoxArray");class Ta extends xa{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}}Ta.prototype.size=60;class Jc extends Wc{get(e){return new Ta(this,e)}}rt(Jc,"PlacedSymbolArray");class Pu extends xa{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]}get 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]}}Pu.prototype.size=80;class Qc extends Xc{get(e){return new Pu(this,e)}}rt(Qc,"SymbolInstanceArray");class zu extends Ts{getoffsetX(e){return this.float32[1*e+0]}}rt(zu,"GlyphOffsetArray");class Ll extends io{getx(e){return this.int16[2*e+0]}gety(e){return this.int16[2*e+1]}}rt(Ll,"SymbolLineVertexArray");class Du extends xa{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]}}Du.prototype.size=12;class Ru extends va{get(e){return new Du(this,e)}}rt(Ru,"FeatureIndexArray");class Lu extends oo{geta_centroid_pos0(e){return this.uint16[2*e+0]}geta_centroid_pos1(e){return this.uint16[2*e+1]}}rt(Lu,"FillExtrusionCentroidArray");class ku extends xa{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]}}ku.prototype.size=6;class eh extends Al{get(e){return new ku(this,e)}}rt(eh,"FillExtrusionWallArray");const Wd=ti([{name:"a_pos",components:2,type:"Int16"}],4),Xd=ti([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class Fi{constructor(e=[]){this.segments=e}_prepareSegment(e,i,o,h){let a=this.segments[this.segments.length-1];return e>Fi.MAX_VERTEX_ARRAY_LENGTH&&Qt(`Max vertices per segment is ${Fi.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!a||a.vertexLength+e>Fi.MAX_VERTEX_ARRAY_LENGTH||a.sortKey!==h)&&(a={vertexOffset:i,primitiveOffset:o,vertexLength:0,primitiveLength:0},void 0!==h&&(a.sortKey=h),this.segments.push(a)),a}prepareSegment(e,i,o,h){return this._prepareSegment(e,i.length,o.length,h)}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,h){return new Fi([{vertexOffset:e,primitiveOffset:i,vertexLength:o,primitiveLength:h,vaos:{},sortKey:0}])}}function Ou(n,e){return 256*(n=zt(Math.floor(n),0,255))+zt(Math.floor(e),0,255)}Fi.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,rt(Fi,"SegmentVector");const Yd=ti([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),Kd=ti([{name:"a_dash",components:4,type:"Uint16"}]);class Ma{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}add(e,i,o,h){this.ids.push(Bu(e)),this.positions.push(i,o,h)}eachPosition(e,i){const o=Bu(e);let h=0,a=this.ids.length-1;for(;h>1;this.ids[u]>=o?a=u:h=u+1}for(;this.ids[h]===o;)i(this.positions[3*h],this.positions[3*h+1],this.positions[3*h+2]),h++}static serialize(e,i){const o=new Float64Array(e.ids),h=new Uint32Array(e.positions);return Ms(o,h,0,o.length-1),i&&(i.add(o.buffer),i.add(h.buffer)),{ids:o,positions:h}}static deserialize(e){const i=new Ma;let o;i.ids=e.ids,i.positions=e.positions;for(const h of i.ids)h!==o&&i.uniqueIds.push(h),o=h;return i.indexed=!0,i}}function Bu(n){const e=+n;return!isNaN(e)&&Number.MIN_SAFE_INTEGER<=e&&e<=Number.MAX_SAFE_INTEGER?e:Ar(String(n))}function Ms(n,e,i,o){for(;i>1];let a=i-1,u=o+1;for(;;){do{a++}while(n[a]h);if(a>=u)break;kl(n,a,u),kl(e,3*a,3*u),kl(e,3*a+1,3*u+1),kl(e,3*a+2,3*u+2)}u-i`u_${a}`),this.type=o,this.context=h}setUniform(e,i,o,h,a){const u=h.constantOr(this.value);i.set(e,a,u instanceof li?u.toRenderColor(this.context.lut):u)}getBinding(e,i){return"color"===this.type?new ih(e):new gr(e)}}class Ss{constructor(e,i){this.uniformNames=i.map(o=>`u_${o}`),this.pattern=null,this.pixelRatio=1}setConstantPatternPositions(e){this.pixelRatio=e.pixelRatio||1,this.pattern=e.tl.concat(e.br)}setUniform(e,i,o,h,a){const u="u_pattern"===a||"u_dash"===a?this.pattern:"u_pixel_ratio"===a?this.pixelRatio:null;u&&i.set(e,a,u)}getBinding(e,i){return"u_pattern"===i||"u_dash"===i?new Ol(e):new gr(e)}}class xn{constructor(e,i,o,h){this.expression=e,this.type=o,this.maxValue=0,this.paintVertexAttributes=i.map(a=>({name:`a_${a}`,type:"Float32",components:"color"===o?2:1,offset:0})),this.paintVertexArray=new h}populatePaintArray(e,i,o,h,a,u,m){const x=this.paintVertexArray.length,w=this.expression.evaluate(new Bi(0,{brightness:u}),i,{},a,h,m);this.paintVertexArray.resize(e),this._setPaintValue(x,e,w,this.context)}updatePaintArray(e,i,o,h,a,u,m){const x=this.expression.evaluate({zoom:0,brightness:m},o,h,void 0,a);this._setPaintValue(e,i,x,this.context)}_setPaintValue(e,i,o,h){if("color"===this.type){const a=nh(o.toRenderColor(h.lut));for(let u=e;u`u_${m}_t`),this.type=o,this.useIntegerZoom=h,this.context=a,this.maxValue=0,this.paintVertexAttributes=i.map(m=>({name:`a_${m}`,type:"Float32",components:"color"===o?4:2,offset:0})),this.paintVertexArray=new u}populatePaintArray(e,i,o,h,a,u,m){const x=this.expression.evaluate(new Bi(this.context.zoom,{brightness:u}),i,{},a,h,m),w=this.expression.evaluate(new Bi(this.context.zoom+1,{brightness:u}),i,{},a,h,m),p=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(p,e,x,w,this.context)}updatePaintArray(e,i,o,h,a,u,m){const x=this.expression.evaluate({zoom:this.context.zoom,brightness:m},o,h,void 0,a),w=this.expression.evaluate({zoom:this.context.zoom+1,brightness:m},o,h,void 0,a);this._setPaintValue(e,i,x,w,this.context)}_setPaintValue(e,i,o,h,a){if("color"===this.type){const u=nh(o.toRenderColor(a.lut)),m=nh(o.toRenderColor(a.lut));for(let x=e;x!0){this.binders={},this._buffers=[],this.context=i;const h=[];for(const a in e.paint._values){const u=e.paint.get(a);if(!o(a)||!(u instanceof gs&&ul(u.property.specification)))continue;const m=tp(a,e.type),x=u.value,w=u.property.specification.type,p=!!u.property.useIntegerZoom,g="line-dasharray"===a||a.endsWith("pattern"),b="line-dasharray"===a&&"constant"!==e.layout.get("line-cap").value.kind;if("constant"!==x.kind||b)if("source"===x.kind||b||g){const y=l(a,w,"source");this.binders[a]=g?new vn(x,m,w,y,e.id):new xn(x,m,w,y),h.push(`/a_${a}`)}else{const y=l(a,w,"composite");this.binders[a]=new Vr(x,m,w,p,i,y),h.push(`/z_${a}`)}else this.binders[a]=g?new Ss(x.value,m):new Ea(x.value,m,w,i),h.push(`/u_${a}`)}this.cacheKey=h.sort().join("")}getMaxValue(e){const i=this.binders[e];return i instanceof xn||i instanceof Vr?i.maxValue:0}populatePaintArrays(e,i,o,h,a,u,m){for(const x in this.binders){const w=this.binders[x];w.context=this.context,(w instanceof xn||w instanceof Vr||w instanceof vn)&&w.populatePaintArray(e,i,o,h,a,u,m)}}setConstantPatternPositions(e){for(const i in this.binders){const o=this.binders[i];o instanceof Ss&&o.setConstantPatternPositions(e)}}updatePaintArrays(e,i,o,h,a,u,m,x){let w=!1;const p=Object.keys(e),g=0!==p.length,b=g?p:i.uniqueIds;this.context.lut=a.lut;for(const y in this.binders){const v=this.binders[y];if(v.context=this.context,(v instanceof xn||v instanceof Vr||v instanceof vn)&&(!0===v.expression.isStateDependent||!1===v.expression.isLightConstant)){const M=a.paint.get(y);v.expression=M.value;for(const E of b){const C=e[E.toString()];i.eachPosition(E,(R,k,P)=>{const O=h.feature(R);v.updatePaintArray(k,P,O,C,u,m,x)})}if(!g)for(const E of o.uniqueIds){const C=e[E.toString()];o.eachPosition(E,(R,k,P)=>{const O=h.feature(R);v.updatePaintArray(k,P,O,C,u,m,x)})}w=!0}}return w}defines(){const e=[];for(const i in this.binders){const o=this.binders[i];(o instanceof Ea||o instanceof Ss)&&e.push(...o.uniformNames.map(h=>`#define HAS_UNIFORM_${h}`))}return e}getBinderAttributes(){const e=[];for(const i in this.binders){const o=this.binders[i];if(o instanceof xn||o instanceof Vr||o instanceof vn)for(let h=0;h!0){this.programConfigurations={};for(const h of e)this.programConfigurations[h.id]=new Ro(h,i,o);this.needsUpload=!1,this._featureMap=new Ma,this._featureMapWithoutIds=new Ma,this._bufferOffset=0,this._idlessCounter=0}populatePaintArrays(e,i,o,h,a,u,m,x){for(const w in this.programConfigurations)this.programConfigurations[w].populatePaintArrays(e,i,h,a,u,m,x);void 0!==i.id?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,h,a,u){for(const m of o)this.needsUpload=this.programConfigurations[m.id].updatePaintArrays(e,this._featureMap,this._featureMapWithoutIds,i,m,h,a,u||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()}}const ep={"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":["gapwidth"],"line-pattern":["pattern","pixel_ratio"],"fill-pattern":["pattern","pixel_ratio"],"fill-extrusion-pattern":["pattern","pixel_ratio"],"line-dasharray":["dash"]};function tp(n,e){return ep[n]||[n.replace(`${e}-`,"").replace(/-/g,"_")]}const ip={"line-pattern":{source:On,composite:On},"fill-pattern":{source:On,composite:On},"fill-extrusion-pattern":{source:On,composite:On},"line-dasharray":{source:Po,composite:Po}},Nu={color:{source:ba,composite:kn},number:{source:Ts,composite:ba}};function l(n,e,i){const o=ip[n];return o&&o[i]||Nu[e][i]}rt(Ea,"ConstantBinder"),rt(Ss,"PatternConstantBinder"),rt(xn,"SourceExpressionBinder"),rt(vn,"PatternCompositeBinder"),rt(Vr,"CompositeExpressionBinder"),rt(Ro,"ProgramConfiguration",{omit:["_buffers"]}),rt(so,"ProgramConfigurationSet");const t=We/Math.PI/2,f=64,_=[f,32,16],T=-t,S=t;function A(n,e,i,o=t){return i=Ht(i),[n*Math.sin(i)*o,-e*o,n*Math.cos(i)*o]}function I(n,e,i){return A(Math.cos(Ht(n)),Math.sin(Ht(n)),e,i)}const z=6371008.8,D=2*Math.PI*z;class L{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 L(Cn(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,h=e.lat*i,a=Math.sin(o)*Math.sin(h)+Math.cos(o)*Math.cos(h)*Math.cos((e.lng-this.lng)*i);return z*Math.acos(Math.min(a,1))}toBounds(e=0){const i=360*e/40075017,o=i/Math.cos(Math.PI/180*this.lat);return new F({lng:this.lng-o,lat:this.lat-i},{lng:this.lng+o,lat:this.lat+i})}toEcef(e){return I(this.lat,this.lng,t+e*t/z)}static convert(e){if(e instanceof L)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new L(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new L(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: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}class F{constructor(e,i){if(e)if(i)this.setSouthWest(e).setNorthEast(i);else if(4===e.length){const o=e;this.setSouthWest([o[0],o[1]]).setNorthEast([o[2],o[3]])}else{const o=e;this.setSouthWest(o[0]).setNorthEast(o[1])}}setNorthEast(e){return this._ne=e instanceof L?new L(e.lng,e.lat):L.convert(e),this}setSouthWest(e){return this._sw=e instanceof L?new L(e.lng,e.lat):L.convert(e),this}extend(e){const i=this._sw,o=this._ne;let h,a;if(e instanceof L)h=e,a=e;else{if(!(e instanceof F))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(F.convert(e)):this.extend(L.convert(e)):"object"==typeof e&&null!==e&&e.hasOwnProperty("lat")&&(e.hasOwnProperty("lon")||e.hasOwnProperty("lng"))?this.extend(L.convert(e)):this;if(h=e._sw,a=e._ne,!h||!a)return this}return i||o?(i.lng=Math.min(h.lng,i.lng),i.lat=Math.min(h.lat,i.lat),o.lng=Math.max(a.lng,o.lng),o.lat=Math.max(a.lat,o.lat)):(this._sw=new L(h.lng,h.lat),this._ne=new L(a.lng,a.lat)),this}getCenter(){return new L((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 L(this.getWest(),this.getNorth())}getSouthEast(){return new L(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}=L.convert(e);let h=this._sw.lng<=i&&i<=this._ne.lng;return this._sw.lng>this._ne.lng&&(h=this._sw.lng>=i&&i>=this._ne.lng),this._sw.lat<=o&&o<=this._ne.lat&&h}static convert(e){if(e)return e instanceof F?e:new F(e)}}function U(n){return D*Math.cos(n*Math.PI/180)}function W(n){return(180+n)/360}function Y(n){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+n*Math.PI/360)))/360}function $(n,e){return n/U(e)}function Q(n){return 360*n-180}function J(n){return 360/Math.PI*Math.atan(Math.exp((180-360*n)*Math.PI/180))-90}function ne(n,e){return n*U(J(e))}const ie=85.051129;function oe(n){return Math.cos(Ht(zt(n,-ie,ie)))}function de(n,e){const i=zt(e,0,25.5),o=Math.pow(2,i);return oe(n)*D/(512*o)}function ce(n){return 1/Math.cos(n*Math.PI/180)}function ae(n,e=0){const i=Math.exp(Math.PI*(1-(n.y+e/We)/(1<=x?(Ie(n,e,i,w,p,a,g,m,x),Ie(n,w,p,o,h,g,u,m,x)):n.push(u)}function ke(n,e,i){let o=n[0],h=o.x,a=o.y;e(o);const u=[o];for(let m=1;mn.x+1||on.y+1)&&Qt("Geometry exceeds allowed extent, reduce your vector tile buffer size"),n}function Ue(n,e,i){const o=n.loadGeometry(),h=n.extent,a=We/h;if(e&&i&&i.projection.isReprojectedInTileSpace){const u=1<{const y=Q((e.x+b.x/h)/u),v=J((e.y+b.y/h)/u),M=p.project(y,v);b.x=(M.x*m-x)*h,b.y=(M.y*m-w)*h};for(let b=0;b=h||v.y<0||v.y>=h||(g(v),y.push(v));o[b]=y}}for(const u of o)for(const m of u)ze(m,a);return o}function Ge(n,e){return{type:n.type,id:n.id,properties:n.properties,geometry:e?Ue(n):[]}}function Le(n,e,i,o,h){n.emplaceBack(2*e+(o+1)/2,2*i+(h+1)/2)}function Be(n,e,i){n.emplaceBack(e.x,e.y,e.z,16384*i[0],16384*i[1],16384*i[2])}class ht{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 io,this.indexArray=new cr,this.segments=new Fi,this.programConfigurations=new so(e.layers,{zoom:e.zoom,lut:e.lut}),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}updateFootprints(e,i){}populate(e,i,o,h){const a=this.layers[0],u=[];let m=null;"circle"===a.type&&(m=a.layout.get("circle-sort-key"));for(const{feature:w,id:p,index:g,sourceLayerIndex:b}of e){const y=this.layers[0]._featureFilter.needGeometry,v=Ge(w,y);if(!this.layers[0]._featureFilter.filter(new Bi(this.zoom),v,o))continue;const M=m?m.evaluate(v,{},o):void 0,E={id:p,properties:w.properties,type:w.type,sourceLayerIndex:b,index:g,geometry:y?v.geometry:Ue(w,o,h),patterns:{},sortKey:M};u.push(E)}m&&u.sort((w,p)=>w.sortKey-p.sortKey);let x=null;"globe"===h.projection.name&&(this.globeExtVertexArray=new Cl,x=h.projection);for(const w of u){const{geometry:p,index:g,sourceLayerIndex:b}=w,y=e[g].feature;this.addFeature(w,p,g,i.availableImages,o,x,i.brightness),i.featureIndex.insert(y,p,g,b,this.index)}}update(e,i,o,h,a){const u=0!==Object.keys(e).length;u&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(e,i,u?this.stateDependentLayers:this.layers,o,h,a)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Wd.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,Xd.members))),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())}addFeature(e,i,o,h,a,u,m){for(const x of i)for(const w of x){const p=w.x,g=w.y;if(p<0||p>=We||g<0||g>=We)continue;if(u){const v=u.projectTilePoint(p,g,a),M=u.upVector(a,p,g),E=this.globeExtVertexArray;Be(E,v,M),Be(E,v,M),Be(E,v,M),Be(E,v,M)}const b=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),y=b.vertexLength;Le(this.layoutVertexArray,p,g,-1,-1),Le(this.layoutVertexArray,p,g,1,-1),Le(this.layoutVertexArray,p,g,1,1),Le(this.layoutVertexArray,p,g,-1,1),this.indexArray.emplaceBack(y,y+1,y+2),this.indexArray.emplaceBack(y,y+2,y+3),b.vertexLength+=4,b.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,o,{},h,a,m)}}function Ze(n,e){for(let i=0;i1){if(pt(n,e))return!0;for(let o=0;o1?i:i.sub(e)._mult(h)._add(e))}function yi(n,e){let i,o,h,a=!1;for(let u=0;ue.y!=h.y>e.y&&e.x<(h.x-o.x)*(e.y-o.y)/(h.y-o.y)+o.x&&(a=!a)}return a}function Si(n,e){let i=!1;for(let o=0,h=n.length-1;oe.y!=u.y>e.y&&e.x<(u.x-a.x)*(e.y-a.y)/(u.y-a.y)+a.x&&(i=!i)}return i}function Hr(n,e,i,o,h){for(const u of n)if(e<=u.x&&i<=u.y&&o>=u.x&&h>=u.y)return!0;const a=[new He(e,i),new He(e,h),new He(o,h),new He(o,i)];if(n.length>2)for(const u of a)if(Si(n,u))return!0;for(let u=0;uh.x&&e.x>h.x||n.yh.y&&e.y>h.y)return!1;const a=dn(n,e,i[0]);return a!==dn(n,e,i[1])||a!==dn(n,e,i[2])||a!==dn(n,e,i[3])}function $t(n,e,i,o,h,a){let u=e.y-n.y,m=n.x-e.x;if(a=a||0){const x=u*u+m*m;if(0===x)return!0;const w=Math.sqrt(x);u/=w,m/=w}return!((i.x-n.x)*u+(i.y-n.y)*m-a<0||(o.x-n.x)*u+(o.y-n.y)*m-a<0||(h.x-n.x)*u+(h.y-n.y)*m-a<0)}function mi(n,e,i,o,h,a,u){return!($t(n,e,o,h,a,u)||$t(e,i,o,h,a,u)||$t(i,n,o,h,a,u)||$t(o,h,n,e,i,u)||$t(h,a,n,e,i,u)||$t(a,o,n,e,i,u))}function Pi(n,e,i){const o=e.paint.get(n).value;return"constant"===o.kind?o.value:i.programConfigurations.get(e.id).getMaxValue(n)}function fi(n){return Math.sqrt(n[0]*n[0]+n[1]*n[1])}function Ot(n,e,i,o,h){if(!e[0]&&!e[1])return n;const a=He.convert(e)._mult(h);"viewport"===i&&a._rotate(-o);const u=[];for(let m=0;m0;p--)x=1<this.canonical.z?new bi(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new bi(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 Tr(this.wrap*+i,e,this.canonical.z,this.canonical.x,this.canonical.y);{const o=this.canonical.z-e;return Tr(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 0===e.overscaledZ||e.overscaledZ>i&&e.canonical.y===this.canonical.y>>i}children(e){if(this.overscaledZ>=e)return[new bi(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,h=2*this.canonical.y;return[new bi(i,this.wrap,i,o,h),new bi(i,this.wrap,i,o+1,h),new bi(i,this.wrap,i,o,h+1),new bi(i,this.wrap,i,o+1,h+1)]}isLessThan(e){return this.wrape.wrap)&&(this.overscaledZe.overscaledZ)&&(this.canonical.xe.canonical.x)&&this.canonical.y{let e=n.canonical.x-1,i=n.wrap;return e<0&&(e=(1<{let e=n.canonical.x+1,i=n.wrap;return e===1<new bi(n.overscaledZ,n.wrap,n.canonical.z,n.canonical.x,(0===n.canonical.y?1<new bi(n.overscaledZ,n.wrap,n.canonical.z,n.canonical.x,n.canonical.y===(1<=0;if(0===a)return 0;a!==e.length&&(i=!1)}return i?2:1}function As(n,e){for(const i of n.projections){const o=bn(e,n.points[0],i.axis);if(i.projection[1]o[1])return 0}return 1}function Bl(n,e){let i=0;const o=[0,0,0,0];for(let h=0;h=0&&i++;return i}class Is{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=wi.fromPoints(this.points),this.projections=[],this.frustumEdges=[ue.vec3.sub([],this.points[2],this.points[3]),ue.vec3.sub([],this.points[0],this.points[3]),ue.vec3.sub([],this.points[4],this.points[0]),ue.vec3.sub([],this.points[5],this.points[1]),ue.vec3.sub([],this.points[6],this.points[2]),ue.vec3.sub([],this.points[7],this.points[3])];for(const o of this.frustumEdges){const h=[0,-o[2],o[1]],a=[o[2],0,-o[0]];this.projections.push({axis:h,projection:bn(this.points,this.points[0],h)}),this.projections.push({axis:a,projection:bn(this.points,this.points[0],a)})}}static fromInvProjectionMatrix(e,i,o,h){const a=Math.pow(2,o),u=[[-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(w=>{const p=ue.vec4.transformMat4([],w,e),g=1/p[3]/i*a;return ue.vec4.mul(p,p,[g,g,h?1/p[3]:g,g])}),m=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(w=>{const p=ue.vec3.sub([],u[w[0]],u[w[1]]),g=ue.vec3.sub([],u[w[2]],u[w[1]]),b=ue.vec3.normalize([],ue.vec3.cross([],p,g)),y=-ue.vec3.dot(b,u[w[1]]);return b.concat(y)}),x=[];for(let w=0;ww[1]||w[0]>x[1])return 0}return 1}containsPoint(e){for(const i of this.planes){const o=i[3];if(ue.vec3.dot([i[0],i[1],i[2]],e)+o<0)return!1}return!0}}class wi{static fromPoints(e){const i=[1/0,1/0,1/0],o=[-1/0,-1/0,-1/0];for(const h of e)ue.vec3.min(i,i,h),ue.vec3.max(o,o,h);return new wi(i,o)}static fromTileIdAndHeight(e,i,o){const h=1<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 Lo(n){return n*t/z}rt(wi,"Aabb");const rp=[new wi([T,T,T],[S,S,S]),new wi([T,T,T],[0,0,S]),new wi([0,T,T],[S,0,S]),new wi([T,0,T],[0,S,S]),new wi([0,0,T],[S,S,S])];function Vu(n,e,i,o=!0){const h=ue.vec3.scale([],n._camera.position,n.worldSize),a=[e,i,1,1];ue.vec4.transformMat4(a,a,n.pixelMatrixInverse),ue.vec4.scale(a,a,1/a[3]);const u=ue.vec3.sub([],a,h),m=ue.vec3.normalize([],u),x=n.globeMatrix,w=[x[12],x[13],x[14]],p=ue.vec3.sub([],w,h),g=ue.vec3.length(p),b=ue.vec3.normalize([],p),y=n.worldSize/(2*Math.PI),v=ue.vec3.dot(b,m),M=Math.asin(y/g);if(M1?null:function(o,h,a,u){const m=Math.sin(a);return o*(Math.sin((1-u)*a)/m)+h*(Math.sin(u*a)/m)}(n.a[e],n.b[e],n.angle,zt(i,0,1))+n.center[e]}function lo(n){if(n.z<=1)return rp[n.z+2*n.y+n.x];const e=op(Uu(n));return wi.fromPoints(e)}function ko(n,e,i){return ue.vec3.scale(n,n,1-i),ue.vec3.scaleAndAdd(n,n,e,i)}function gf(n,e,i){for(const o of n)ue.vec3.transformMat4(o,o,e),ue.vec3.scale(o,o,i)}function yf(n,e,i,o){const h=e/n.worldSize,a=n.globeMatrix;if(i.z<=1){const X=lo(i).getCorners();return gf(X,a,h),wi.fromPoints(X)}const u=Uu(i,o),m=op(u,t+Lo(n._tileCoverLift));gf(m,a,h);const x=Number.MAX_VALUE,w=[-x,-x,-x],p=[x,x,x];if(u.contains(n.center)){for(const te of m)ue.vec3.min(p,p,te),ue.vec3.max(w,w,te);w[2]=0;const X=n.point,Z=[X.x*h,X.y*h,0];return ue.vec3.min(p,p,Z),ue.vec3.max(w,w,Z),new wi(p,w)}if(n._tileCoverLift>0){for(const X of m)ue.vec3.min(p,p,X),ue.vec3.max(w,w,X);return new wi(p,w)}const g=[a[12]*h,a[13]*h,a[14]*h],b=u.getCenter(),y=zt(n.center.lat,-ie,ie),v=zt(b.lat,-ie,ie),M=W(n.center.lng),E=Y(y);let C=M-W(b.lng);const R=E-Y(v);C>.5?C-=1:C<-.5&&(C+=1);let k=0;if(Math.abs(C)>Math.abs(R))k=C>=0?1:3;else{k=R>=0?0:2;const X=[a[4]*h,a[5]*h,a[6]*h],Z=-Math.sin(Ht(R>=0?u.getSouth():u.getNorth()))*t;ue.vec3.scaleAndAdd(g,g,X,Z)}const P=m[k],O=m[(k+1)%4],B=new Bg(P,O,g),G=[np(B,0)||P[0],np(B,1)||P[1],np(B,2)||P[2]],H=Cs(n.zoom);if(H>0){const X=function({x:te,y:K,z:re},he,pe,fe,me){const we=1/(1<.5?Ye=-1:$e<-.5&&(Ye=1),ge=((ge+Ye)*he-(fe*=he))*pe+fe,Pe=((Pe+Ye)*he-fe)*pe+fe,Oe=(Oe*he-(me*=he))*pe+me,Ee=(Ee*he-me)*pe+me,[[ge,Ee,0],[Pe,Ee,0],[Pe,Oe,0],[ge,Oe,0]]}(i,e,n._pixelsPerMercatorPixel,M,E);for(let te=0;teMath.PI/2*1.01}const Tf=Ht(85),Fg=Math.cos(Tf),Ng=Math.sin(Tf),Vg=ue.mat4.create(),Mf=n=>{const e=[];return"map"===n.paint.get("circle-pitch-alignment")&&e.push("PITCH_WITH_MAP"),"map"===n.paint.get("circle-pitch-scale")&&e.push("SCALE_WITH_MAP"),e};function Sf(n,e,i,o,h,a,u,m,x){if(a&&n.queryGeometry.isAboveHorizon)return!1;a&&(x*=n.pixelToTileUnitsFactor);const w=n.tileID.canonical,p=i.projection.upVectorScale(w,i.center.lat,i.worldSize).metersToTile;for(const g of e)for(const b of g){const y=b.add(m),v=h&&i.elevation?i.elevation.exaggeration()*h.getElevationAt(y.x,y.y,!0):0,M=i.projection.projectTilePoint(y.x,y.y,w);if(v>0){const k=i.projection.upVector(w,y.x,y.y);M.x+=k[0]*p*v,M.y+=k[1]*p*v,M.z+=k[2]*p*v}const E=a?y:Ug(M.x,M.y,M.z,o),C=a?n.tilespaceRays.map(k=>Gg(k,v)):n.queryGeometry.screenGeometry,R=ue.vec4.transformMat4([],[M.x,M.y,M.z,1],o);if(!u&&a?x*=R[3]/i.cameraToCenterDistance:u&&!a&&(x*=i.cameraToCenterDistance/R[3]),a){const k=J((b.y/We+w.y)/(1<n.width||h.height>n.height||i.x>n.width-h.width||i.y>n.height-h.height)throw new RangeError("out of range source coordinates for image copy");if(h.width>e.width||h.height>e.height||o.x>e.width-h.width||o.y>e.height-h.height)throw new RangeError("out of range destination coordinates for image copy");const x=n.data,w=e.data,p=4===a&&m;for(let g=0;g{e[n.evaluationKey]=x;const w=n.expression.evaluate(e);w&&(h.data[u+m+0]=Math.floor(255*w.r/w.a),h.data[u+m+1]=Math.floor(255*w.g/w.a),h.data[u+m+2]=Math.floor(255*w.b/w.a),h.data[u+m+3]=Math.floor(255*w.a))};if(n.clips)for(let u=0,m=0;u80*i){m=1/0,x=1/0;let p=-1/0,g=-1/0;for(let b=i;bp&&(p=y),v>g&&(g=v)}w=Math.max(p-m,g-x),w=0!==w?32767/w:0}return lh(a,u,i,m,x,w,0),u}function kf(n,e,i,o,h){let a;if(h===function(u,m,x,w){let p=0;for(let g=m,b=x-w;g0)for(let u=e;u=e;u-=o)a=Ff(u/o|0,n[u],n[u+1],a);return a&&qu(a,a.next)&&(hh(a),a=a.next),a}function Aa(n,e){if(!n)return n;e||(e=n);let i,o=n;do{if(i=!1,o.steiner||!qu(o,o.next)&&0!==er(o.prev,o,o.next))o=o.next;else{if(hh(o),o=e=o.prev,o===o.next)break;i=!0}}while(i||o!==e);return e}function lh(n,e,i,o,h,a,u){if(!n)return;!u&&a&&function(x,w,p,g){let b=x;do{0===b.z&&(b.z=hp(b.x,b.y,w,p,g)),b.prevZ=b.prev,b.nextZ=b.next,b=b.next}while(b!==x);b.prevZ.nextZ=null,b.prevZ=null,function(y){let v,M=1;do{let E,C=y;y=null;let R=null;for(v=0;C;){v++;let k=C,P=0;for(let B=0;B0||O>0&&k;)0!==P&&(0===O||!k||C.z<=k.z)?(E=C,C=C.nextZ,P--):(E=k,k=k.nextZ,O--),R?R.nextZ=E:y=E,E.prevZ=R,R=E;C=k}R.nextZ=null,M*=2}while(v>1)}(b)}(n,o,h,a);let m=n;for(;n.prev!==n.next;){const x=n.prev,w=n.next;if(a?Hg(n,o,h,a):$g(n))e.push(x.i,n.i,w.i),hh(n),n=w.next,m=w.next;else if((n=w)===m){u?1===u?lh(n=Wg(Aa(n),e),e,i,o,h,a,2):2===u&&Xg(n,e,i,o,h,a):lh(Aa(n),e,i,o,h,a,1);break}}}function $g(n){const e=n.prev,i=n,o=n.next;if(er(e,i,o)>=0)return!1;const h=e.x,a=i.x,u=o.x,m=e.y,x=i.y,w=o.y,p=ha?h>u?h:u:a>u?a:u,y=m>x?m>w?m:w:x>w?x:w;let v=o.next;for(;v!==e;){if(v.x>=p&&v.x<=b&&v.y>=g&&v.y<=y&&Fl(h,m,a,x,u,w,v.x,v.y)&&er(v.prev,v,v.next)>=0)return!1;v=v.next}return!0}function Hg(n,e,i,o){const h=n.prev,a=n,u=n.next;if(er(h,a,u)>=0)return!1;const m=h.x,x=a.x,w=u.x,p=h.y,g=a.y,b=u.y,y=mx?m>w?m:w:x>w?x:w,E=p>g?p>b?p:b:g>b?g:b,C=hp(y,v,e,i,o),R=hp(M,E,e,i,o);let k=n.prevZ,P=n.nextZ;for(;k&&k.z>=C&&P&&P.z<=R;){if(k.x>=y&&k.x<=M&&k.y>=v&&k.y<=E&&k!==h&&k!==u&&Fl(m,p,x,g,w,b,k.x,k.y)&&er(k.prev,k,k.next)>=0||(k=k.prevZ,P.x>=y&&P.x<=M&&P.y>=v&&P.y<=E&&P!==h&&P!==u&&Fl(m,p,x,g,w,b,P.x,P.y)&&er(P.prev,P,P.next)>=0))return!1;P=P.nextZ}for(;k&&k.z>=C;){if(k.x>=y&&k.x<=M&&k.y>=v&&k.y<=E&&k!==h&&k!==u&&Fl(m,p,x,g,w,b,k.x,k.y)&&er(k.prev,k,k.next)>=0)return!1;k=k.prevZ}for(;P&&P.z<=R;){if(P.x>=y&&P.x<=M&&P.y>=v&&P.y<=E&&P!==h&&P!==u&&Fl(m,p,x,g,w,b,P.x,P.y)&&er(P.prev,P,P.next)>=0)return!1;P=P.nextZ}return!0}function Wg(n,e){let i=n;do{const o=i.prev,h=i.next.next;!qu(o,h)&&Of(o,i,i.next,h)&&ch(o,h)&&ch(h,o)&&(e.push(o.i,i.i,h.i),hh(i),hh(i.next),i=n=h),i=i.next}while(i!==n);return Aa(i)}function Xg(n,e,i,o,h,a){let u=n;do{let m=u.next.next;for(;m!==u.prev;){if(u.i!==m.i&&ey(u,m)){let x=Bf(u,m);return u=Aa(u,u.next),x=Aa(x,x.next),lh(u,e,i,o,h,a,0),void lh(x,e,i,o,h,a,0)}m=m.next}u=u.next}while(u!==n)}function Yg(n,e){return n.x-e.x}function Kg(n,e){const i=function(h,a){let u=a;const m=h.x,x=h.y;let w,p=-1/0;do{if(x<=u.y&&x>=u.next.y&&u.next.y!==u.y){const M=u.x+(x-u.y)*(u.next.x-u.x)/(u.next.y-u.y);if(M<=m&&M>p&&(p=M,w=u.x=u.x&&u.x>=b&&m!==u.x&&Fl(xw.x||u.x===w.x&&Jg(w,u)))&&(w=u,v=M)}u=u.next}while(u!==g);return w}(n,e);if(!i)return e;const o=Bf(i,n);return Aa(o,o.next),Aa(i,i.next)}function Jg(n,e){return er(n.prev,n,e.prev)<0&&er(e.next,n,n.next)<0}function hp(n,e,i,o,h){return(n=1431655765&((n=858993459&((n=252645135&((n=16711935&((n=(n-i)*h|0)|n<<8))|n<<4))|n<<2))|n<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-o)*h|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Qg(n){let e=n,i=n;do{(e.x=(n-u)*(a-m)&&(n-u)*(o-m)>=(i-u)*(e-m)&&(i-u)*(a-m)>=(h-u)*(o-m)}function ey(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!function(i,o){let h=i;do{if(h.i!==i.i&&h.next.i!==i.i&&h.i!==o.i&&h.next.i!==o.i&&Of(h,h.next,i,o))return!0;h=h.next}while(h!==i);return!1}(n,e)&&(ch(n,e)&&ch(e,n)&&function(i,o){let h=i,a=!1;const u=(i.x+o.x)/2,m=(i.y+o.y)/2;do{h.y>m!=h.next.y>m&&h.next.y!==h.y&&u<(h.next.x-h.x)*(m-h.y)/(h.next.y-h.y)+h.x&&(a=!a),h=h.next}while(h!==i);return a}(n,e)&&(er(n.prev,n,e.prev)||er(n,e.prev,e))||qu(n,e)&&er(n.prev,n,n.next)>0&&er(e.prev,e,e.next)>0)}function er(n,e,i){return(e.y-n.y)*(i.x-e.x)-(e.x-n.x)*(i.y-e.y)}function qu(n,e){return n.x===e.x&&n.y===e.y}function Of(n,e,i,o){const h=$u(er(n,e,i)),a=$u(er(n,e,o)),u=$u(er(i,o,n)),m=$u(er(i,o,e));return h!==a&&u!==m||!(0!==h||!Zu(n,i,e))||!(0!==a||!Zu(n,o,e))||!(0!==u||!Zu(i,n,o))||!(0!==m||!Zu(i,e,o))}function Zu(n,e,i){return e.x<=Math.max(n.x,i.x)&&e.x>=Math.min(n.x,i.x)&&e.y<=Math.max(n.y,i.y)&&e.y>=Math.min(n.y,i.y)}function $u(n){return n>0?1:n<0?-1:0}function ch(n,e){return er(n.prev,n,n.next)<0?er(n,e,n.next)>=0&&er(n,n.prev,e)>=0:er(n,e,n.prev)<0||er(n,n.next,e)<0}function Bf(n,e){const i=up(n.i,n.x,n.y),o=up(e.i,e.x,e.y),h=n.next,a=e.prev;return n.next=e,e.prev=n,i.next=h,h.prev=i,o.next=i,i.prev=o,a.next=o,o.prev=a,o}function Ff(n,e,i,o){const h=up(n,e,i);return o?(h.next=o.next,h.prev=o,o.next.prev=h,o.next=h):(h.prev=h,h.next=h),h}function hh(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function up(n,e,i){return{i:n,x:e,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Hu(n,e){const i=n.length;if(i<=1)return[n];const o=[];let h,a;for(let u=0;u1)for(let u=0;ui.fqid),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new io,this.indexArray=new cr,this.indexArray2=new oo,this.programConfigurations=new so(e.layers,{zoom:e.zoom,lut:e.lut}),this.segments=new Fi,this.segments2=new Fi,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.projection=e.projection}updateFootprints(e,i){}populate(e,i,o,h){this.hasPattern=dp("fill",this.layers,i);const a=this.layers[0].layout.get("fill-sort-key"),u=[];for(const{feature:m,id:x,index:w,sourceLayerIndex:p}of e){const g=this.layers[0]._featureFilter.needGeometry,b=Ge(m,g);if(!this.layers[0]._featureFilter.filter(new Bi(this.zoom),b,o))continue;const y=a?a.evaluate(b,{},o,i.availableImages):void 0,v={id:x,properties:m.properties,type:m.type,sourceLayerIndex:p,index:w,geometry:g?b.geometry:Ue(m,o,h),patterns:{},sortKey:y};u.push(v)}a&&u.sort((m,x)=>m.sortKey-x.sortKey);for(const m of u){const{geometry:x,index:w,sourceLayerIndex:p}=m;if(this.hasPattern){const g=pp("fill",this.layers,m,this.zoom,i);this.patternFeatures.push(g)}else this.addFeature(m,x,w,o,{},i.availableImages,i.brightness);i.featureIndex.insert(e[w].feature,x,w,p,this.index)}}update(e,i,o,h,a){const u=0!==Object.keys(e).length;u&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(e,i,u?this.stateDependentLayers:this.layers,o,h,a)}addFeatures(e,i,o,h,a,u){for(const m of this.patternFeatures)this.addFeature(m,m.geometry,m.index,i,o,h,u)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Zg),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(e,i,o,h,a,u=[],m){for(const x of Hu(i,500)){let w=0;for(const M of x)w+=M.length;const p=this.segments.prepareSegment(w,this.layoutVertexArray,this.indexArray),g=p.vertexLength,b=[],y=[];for(const M of x){if(0===M.length)continue;M!==x[0]&&y.push(b.length/2);const E=this.segments2.prepareSegment(M.length,this.layoutVertexArray,this.indexArray2),C=E.vertexLength;this.layoutVertexArray.emplaceBack(M[0].x,M[0].y),this.indexArray2.emplaceBack(C+M.length-1,C),b.push(M[0].x),b.push(M[0].y);for(let R=1;Rg.cellIdx-b.cellIdx||g.triIdx-b.triIdx);let p=0;for(;pthis.max.x||this.min.x>e.x||e.y>this.max.y||this.min.y>e.y)return;const o=co(e.x-this.min.x,this.xScale,this.cellsX),h=co(e.y-this.min.y,this.yScale,this.cellsY),a=this.cells[h*this.cellsX+o];if(a){this._lazyInitLookup();for(let u=0;uthis.max.x||this.min.x>i.x||e.y>this.max.y||this.min.y>i.y)return;this._lazyInitLookup();const h=co(e.x-this.min.x,this.xScale,this.cellsX),a=co(i.x-this.min.x,this.xScale,this.cellsX),u=co(e.y-this.min.y,this.yScale,this.cellsY),m=co(i.y-this.min.y,this.yScale,this.cellsY);for(let x=u;x<=m;x++)for(let w=h;w<=a;w++){const p=this.cells[x*this.cellsX+w];if(p)for(let g=0;gi.fqid),this.index=e.index,this.hasPattern=!1,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.footprints=[]}updateFootprints(e,i){for(const o of this.footprints)i.push({footprint:o,id:e})}populate(e,i,o,h){const a=[];for(const{feature:u,id:m,index:x,sourceLayerIndex:w}of e){const p=this.layers[0]._featureFilter.needGeometry,g=Ge(u,p);if(!this.layers[0]._featureFilter.filter(new Bi(this.zoom),g,o))continue;const b={id:m,properties:u.properties,type:u.type,sourceLayerIndex:w,index:x,geometry:p?g.geometry:Ue(u,o,h),patterns:{}};a.push(b)}for(const u of a){const{geometry:m,index:x,sourceLayerIndex:w}=u;this.addFeature(u,m,x,o,{},i.availableImages,i.brightness),i.featureIndex.insert(e[x].feature,m,x,w,this.index)}}isEmpty(){return 0===this.footprints.length}uploadPending(){return!1}upload(e){}update(e,i,o,h,a){}destroy(){}addFeature(e,i,o,h,a,u=[],m){for(const x of Hu(i,2)){const w=[],p=[],g=[],b=new He(1/0,1/0),y=new He(-1/0,-1/0);for(const E of x)if(0!==E.length){E!==x[0]&&g.push(p.length/2);for(let C=0;C>3}if(x--,1===m||2===m)w+=h.readSVarint(),p+=h.readSVarint(),1===m&&(a&&g.push(a),a=[]),a.push(new n(w,p));else{if(7!==m)throw new Error("unknown command "+m);a&&a.push(a[0].clone())}}return a&&g.push(a),g},e.prototype.bbox=function(){var h=this._pbf;h.pos=this._geometry;for(var a=h.readVarint()+h.pos,u=1,m=0,x=0,w=0,p=1/0,g=-1/0,b=1/0,y=-1/0;h.pos>3}if(m--,1===u||2===u)(x+=h.readSVarint())g&&(g=x),(w+=h.readSVarint())y&&(y=w);else if(7!==u)throw new Error("unknown command "+u)}return[p,b,g,y]},e.prototype.toGeoJSON=function(h,a,u){var m,x,w=this.extent*Math.pow(2,u),p=this.extent*h,g=this.extent*a,b=this.loadGeometry(),y=e.types[this.type];function v(C){for(var R=0;R>3;m=1===w?u.readString():2===w?u.readFloat():3===w?u.readDouble():4===w?u.readVarint64():5===w?u.readVarint():6===w?u.readSVarint():7===w?u.readBoolean():null}return m}(a))}return gp=e,e.prototype.feature=function(o){if(o<0||o>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[o];var h=this._pbf.readVarint()+this._pbf.pos;return new n(this._pbf,h,this.extent,this._keys,this._values)},gp}function Yf(){return Hf||(Hf=1,Wu.VectorTile=function(){if($f)return yp;$f=1;var n=Xf();function e(i,o,h){if(3===i){var a=new n(h,h.readVarint()+h.pos);a.length&&(o[a.name]=a)}}return yp=function(i,o){this.layers=i.readFields(e,{},o)}}(),Wu.VectorTileFeature=Wf(),Wu.VectorTileLayer=Xf()),Wu}var Nl=Yf();class Ia extends He{constructor(e,i,o){super(e,i),this.z=o}}class Kf extends Ia{constructor(e,i,o,h){super(e,i,o),this.w=h}}function Xu(n,e,i,o){const h=[],a=0===o?(u,m,x,w,p,g)=>{u.push(new He(g,x+(g-m)/(w-m)*(p-x)))}:(u,m,x,w,p,g)=>{u.push(new He(m+(g-x)/(p-x)*(w-m),g))};for(const u of n){const m=[];for(const x of u){if(x.length<=2)continue;const w=[];for(let b=0;be&&a(w,y,v,M,E,e):C>i?R=e&&a(w,y,v,M,E,e),R>i&&C<=i&&a(w,y,v,M,E,i)}let p=x[x.length-1];const g=0===o?p.x:p.y;g>=e&&g<=i&&w.push(p),w.length&&(p=w[w.length-1],w[0].x===p.x&&w[0].y===p.y||w.push(w[0]),m.push(w))}m.length&&h.push(m)}return h}function Jf(n,e,i,o){const h="x"===i?"y":"x",a=(o-n[i])/(e[i]-n[i]);n[h]=n[h]+(e[h]-n[h])*a,n[i]=o,n.hasOwnProperty("z")&&(n.z=mt(n.z,e.z,a)),n.hasOwnProperty("w")&&(n.w=mt(n.w,e.w,a))}function Qf(n,e,i,o){const h=i,a=o;for(const u of["x","y"]){let m=n,x=e;m[u]>=x[u]&&(m=e,x=n),m[u]h&&Jf(m,x,u,h),m[u]a&&Jf(x,m,u,a)}}const Yu=Number.MAX_SAFE_INTEGER;function em(n,e,i,o){return n.orderu===h));var h,a}function Ku(n,e){return n.x-e.x||n.y-e.y}function tm(n,e){return 0===Ku(n.min,e.min)&&0===Ku(n.max,e.max)}function xp(n,e){return!(n.min.x>e.max.x||n.max.xe.max.y||n.max.ynew He((x.x+a.x*We)*m-u.x*We,(x.y+a.y*We)*m-u.y*We))}return rm(i,h,n.indices,0,n.indices.length,0,0)}function om(n,e,i,o){const h=Math.pow(2,o.z-i.z);return new He((n+i.x*We)*h-o.x*We,(e+i.y*We)*h-o.y*We)}function sm(n,e){const i=[];e.grid.queryPoint(n,i);const o=e.indices,h=e.vertices;for(let a=0;a0&&(o.length>1&&i.push(o),o=[])}return o.length>1&&i.push(o),i}const wp=Nl.VectorTileFeature.types,hy=["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"],uy=["fill-extrusion-flood-light-ground-radius"],dy=Math.pow(2,13),py=Math.pow(2,15)-1,lm=new He(0,1),zs=2147483648;function uh(n,e,i,o,h,a,u,m){n.emplaceBack((e<<1)+u,(i<<1)+a,(Math.floor(o*dy)<<1)+h,Math.round(m))}function dh(n,e,i){n.emplaceBack(e.x*We,e.y*We,i?1:0)}function Ju(n,e,i,o,h,a){n.emplaceBack(e.x,e.y,(i.x<<1)+o,(i.y<<1)+h,a)}function ph(n,e,i){n.emplaceBack(e.x,e.y,e.z,16384*i[0],16384*i[1],16384*i[2])}class cm{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0}}class hm{constructor(){this.centroidXY=new He(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 He(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new He(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0}span(){return new He(this.max.x-this.min.x,this.max.y-this.min.y)}}class um{constructor(){this.acc=new He(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 h=!!this.borders;i.xe.max.x&&(e.max.x=i.x,h=!0),i.ye.max.y&&(e.max.y=i.y,h=!0),((0===i.x||i.x===We)&&i.x===o.x)!=((0===i.y||i.y===We)&&i.y===o.y)&&this.processBorderOverlap(i,o),h&&this.checkBorderIntersection(i,o)}checkBorderIntersection(e,i){i.x<0!=e.x<0&&this.addBorderIntersection(0,mt(i.y,e.y,(0-i.x)/(e.x-i.x))),i.x>We!=e.x>We&&this.addBorderIntersection(1,mt(i.y,e.y,(We-i.x)/(e.x-i.x))),i.y<0!=e.y<0&&this.addBorderIntersection(2,mt(i.x,e.x,(0-i.y)/(e.y-i.y))),i.y>We!=e.y>We&&this.addBorderIntersection(3,mt(i.x,e.x,(We-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];io[1]&&(o[1]=i)}processBorderOverlap(e,i){if(e.x===i.x){if(e.y===i.y)return;const o=0===e.x?0:1;this.addBorderIntersection(o,i.y),this.addBorderIntersection(o,e.y)}else{const o=0===e.y?2:3;this.addBorderIntersection(o,i.x),this.addBorderIntersection(o,e.x)}}centroid(){return 0===this.accCount?new He(0,0):new He(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 dm(n,e){const i=n.add(e)._unit(),o=zt(n.x*i.x+n.y*i.y,-1,1);var h,a,u;return u=Math.acos(o),Math.min(4,Math.max(-4,Math.tan(u)))/4*py*((h=n).x*(a=e).y-h.y*a.x<0?-1:1)}const fy=[n=>n.x<0,n=>n.x>We,n=>n.y<0,n=>n.y>We];function my(n,e,i,o){const h=[4];if(0===o)return h;i._mult(o);const a=n.sub(i),u=e.sub(i),m=[n,e,a,u];for(let x=0;x<4;x++)for(const w of m)if(fy[x](w)){h.push(x);break}return h}class pm{constructor(e){this.vertexArray=new Il,this.indexArray=new cr,this.programConfigurations=new so(e.layers,{zoom:e.zoom,lut:e.lut},i=>uy.includes(i)),this._segments=new Fi,this.hiddenByLandmarkVertexArray=new Dl,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 0!==this.vertexArray.length}addData(e,i,o,h=!1){const a=e.length;if(a>2){let u=Math.max(0,this._segments.get().length-1);const m=this._segments._prepareSegment(4*a,this.vertexArray.length,2*this._segmentToGroundQuads[u].length);let x;u!==this._segments.get().length-1&&(u++,this._segmentToGroundQuads[u]=[],this._segmentToRegionTriCounts[u]=[0,0,0,0,0]);{const w=e[0],p=e[1];x=dm(w.sub(e[a-1])._perp()._unit(),p.sub(w)._perp()._unit())}for(let w=0;wh.region-a.region);for(let o=0;ox+w,0);let m=0;for(let x=0;x<=4;x++){const w=u[x];if(0!==w){let p=this.regionSegments[x];p||(p=this.regionSegments[x]=new Fi);const g={vertexOffset:a.vertexOffset,primitiveOffset:a.primitiveOffset+m,vertexLength:a.vertexLength,primitiveLength:w};p.get().push(g)}m+=w}for(let x=0;x0?this.hiddenByLandmarkVertexBuffer=e.createVertexBuffer(this.hiddenByLandmarkVertexArray,sy.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._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let e=0;e<=4;e++){const i=this.regionSegments[e];i&&i.destroy()}}}}class Qu{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.overscaling=e.overscaling,this.layers=e.layers,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=[],this.footprintIndices=new cr,this.footprintVertices=new io,this.footprintSegments=[],this.layoutVertexArray=new ro,this.centroidVertexArray=new Lu,this.wallVertexArray=new eh,this.indexArray=new cr,this.programConfigurations=new so(e.layers,{zoom:e.zoom,lut:e.lut},i=>hy.includes(i)),this.segments=new Fi,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.groundEffect=new pm(e),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[]}updateFootprints(e,i){}populate(e,i,o,h){this.features=[],this.hasPattern=dp("fill-extrusion",this.layers,i),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=ae(o),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter,this.wallMode=0!==this.layers[0].paint.get("fill-extrusion-line-width").constantOr(1);for(const{feature:a,id:u,index:m,sourceLayerIndex:x}of e){const w=this.layers[0]._featureFilter.needGeometry,p=Ge(a,w);if(!this.layers[0]._featureFilter.filter(new Bi(this.zoom),p,o))continue;const g={id:u,sourceLayerIndex:x,index:m,geometry:w?p.geometry:Ue(a,o,h),properties:a.properties,type:a.type,patterns:{}},b=this.layoutVertexArray.length,y="Polygon"===wp[g.type];if(this.hasPattern)this.features.push(pp("fill-extrusion",this.layers,g,this.zoom,i));else if(this.wallMode)for(const v of g.geometry)for(const M of am(v,y))this.addFeature(g,[M],m,o,{},i.availableImages,h,i.brightness);else this.addFeature(g,g.geometry,m,o,{},i.availableImages,h,i.brightness);i.featureIndex.insert(a,g.geometry,m,x,this.index,b)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(e,i,o,h,a,u){for(const m of this.features){const x="Polygon"===wp[m.type],{geometry:w}=m;if(this.wallMode)for(const p of w)for(const g of am(p,x))this.addFeature(m,[g],m.index,i,o,h,a,u);else this.addFeature(m,w,m.index,i,o,h,a,u)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles()}update(e,i,o,h,a){const u=0!==Object.keys(e).length;if(u&&!this.stateDependentLayers.length)return;const m=u?this.stateDependentLayers:this.layers;this.programConfigurations.updatePaintArrays(e,i,m,o,h,a),this.groundEffect.update(e,i,m,o,h,a)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,ly),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.wallVertexBuffer=e.createVertexBuffer(this.wallVertexArray,oy.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=e.createVertexBuffer(this.layoutVertexExtArray,ay.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,ny.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,h,a,u,m,x){const w=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(e,{})/this.tileToMeter,p=[new He(0,0),new He(We,We)],g=m.projection,b="globe"===g.name,y=this.wallMode||"Polygon"===wp[e.type],v=new um;v.centroidDataIndex=this.centroidData.length;const M=new hm,E=this.layers[0].paint.get("fill-extrusion-base").evaluate(e,{},h)<=0,C=this.layers[0].paint.get("fill-extrusion-height").evaluate(e,{},h);let R;if(M.height=C,M.vertexArrayOffset=this.layoutVertexArray.length,M.groundVertexArrayOffset=this.groundEffect.vertexArray.length,b&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new Cl),this.wallMode){if(b)return void Qt("Non zero fill-extrusion-line-width is not yet supported on globe.");if(1!==i.length)return;R=function(Z){const te=Z[0].x===Z[Z.length-1].x&&Z[0].y===Z[Z.length-1].y;(function(je){let Fe=0;const ut=je.length;for(let Xe=0;Xe=0})(Z)||(Z=Z.reverse());const re={geometry:[],joinNormals:[],indices:[]},he=[],pe=[],fe=[];let me=Z.length;if(me<(te?3:2))return re;for(;me>=2&&Z[me-1].equals(Z[me-2]);)me--;let we,ge,Pe,Oe,Ee,Ye=0;for(;Ye0;let xt="miter";const Bt=2;"miter"===xt&&Xe>Bt&&(xt="bevel"),"bevel"===xt&&(Xe>100&&(xt="flipbevel"),Xe{const hi=new He(Ct.x,Ct.y),wt=new He(Ct.x,Ct.y);hi.x+=Ut.x*xi,hi.y+=Ut.y*xi,wt.x-=Ut.x*Math.max(jt,1),wt.y-=Ut.y*Math.max(jt,1),fe.push(Ut),he.push(hi),pe.push(wt)};if("miter"===xt)Fe._mult(Xe),It(we,Fe,0,0);else if("flipbevel"===xt)Fe=Ee.mult(-1),It(we,Fe,0,0),It(we,Fe.mult(-1),0,0);else{const Ct=-Math.sqrt(Xe*Xe-1),Ut=it?Ct:0,jt=it?0:Ct;ge&&It(we,Oe,Ut,jt),Pe&&It(we,Ee,Ut,jt)}}re.geometry=[...he,...pe.reverse(),he[0]],re.joinNormals=[...fe,...fe.reverse(),fe[fe.length-1]];const $e=re.geometry.length-1;for(let je=0;je<$e/2;je++)if(je+1<$e/2){let Fe=je,ut=je+1,Xe=$e-1-je,it=$e-2-je;Fe=0===Fe?$e-1:Fe-1,ut=0===ut?$e-1:ut-1,Xe=0===Xe?$e-1:Xe-1,it=0===it?$e-1:it-1,re.indices.push(Xe),re.indices.push(ut),re.indices.push(Fe),re.indices.push(Xe),re.indices.push(it),re.indices.push(ut)}return re}(i[0]),i=[R.geometry]}const k=(Z,te)=>Z<(te.length-1)/2||Z===te.length-1,P=this.wallMode?[i]:Hu(i,500);for(let Z=P.length-1;Z>=0;Z--){const te=P[Z];(0===te.length||(O=te[0]).every(K=>K.x<=0)||O.every(K=>K.x>=We)||O.every(K=>K.y<=0)||O.every(K=>K.y>=We))&&P.splice(Z,1)}var O;let B;if(b)B=vm(P,p,h);else{B=[];for(const Z of P)B.push({polygon:Z,bounds:p})}const G=y?this.edgeRadius:0,H=G>0&&this.zoom<17,X=(Z,te)=>{if(0===Z.length)return!1;const K=Z[Z.length-1];return te.x===K.x&&te.y===K.y};for(const{polygon:Z,bounds:te}of B){let K=0,re=0;for(const me of Z)y&&!me[0].equals(me[me.length-1])&&me.push(me[0]),re+=y?me.length-1:me.length;const he=this.segments.prepareSegment((y?5:4)*re,this.layoutVertexArray,this.indexArray);M.footprintSegIdx<0&&(M.footprintSegIdx=this.footprintSegments.length),M.polygonSegIdx<0&&(M.polygonSegIdx=this.polygonSegments.length);const pe={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},fe=new cm;if(fe.vertexOffset=this.footprintVertices.length,fe.indexOffset=3*this.footprintIndices.length,fe.ringIndices=[],y){const me=[],we=[];K=he.vertexLength;for(let Pe=0;Pe4&&gm(we[we.length-2],we[0],we[1]),Pe=G?_y(we[we.length-2],we[0],we[1],G):0;const Oe=[];let Ee,Ye,$e;Ye=we[1].sub(we[0])._perp()._unit();let je=!0;for(let Fe=1,ut=0;Fe0?1:0,Ut=Xe.dist(it);if(ut+Ut>32768&&(ut=0),G){$e=xt.sub(it)._perp()._unit();let wt=mm(Xe,it,xt,fm(Ye,$e),G);isNaN(wt)&&(wt=0);const ri=it.sub(Xe)._unit();Xe=Xe.add(ri.mult(Pe))._round(),it=it.add(ri.mult(-wt))._round(),Pe=wt,Ye=$e,E&&this.zoom>=17&&(X(Oe,Xe)||Oe.push(Xe),X(Oe,it)||Oe.push(it))}const jt=he.vertexLength,xi=we.length>4&&gm(Xe,it,xt);let hi=ym(ut,ge,je);if(uh(this.layoutVertexArray,Xe.x,Xe.y,It,Ct,0,0,hi),uh(this.layoutVertexArray,Xe.x,Xe.y,It,Ct,0,1,hi),this.wallMode){const wt=k(Fe-1,we),ri=R.joinNormals[Fe-1];dh(this.wallVertexArray,ri,wt),dh(this.wallVertexArray,ri,wt)}if(ut+=Ut,hi=ym(ut,xi,!je),ge=xi,uh(this.layoutVertexArray,it.x,it.y,It,Ct,0,0,hi),uh(this.layoutVertexArray,it.x,it.y,It,Ct,0,1,hi),this.wallMode){const wt=k(Fe,we),ri=R.joinNormals[Fe];dh(this.wallVertexArray,ri,wt),dh(this.wallVertexArray,ri,wt)}if(he.vertexLength+=4,this.indexArray.emplaceBack(jt+0,jt+1,jt+2),this.indexArray.emplaceBack(jt+1,jt+3,jt+2),he.primitiveLength+=2,G){const wt=K+(1===Fe?we.length-2:Fe-2),ri=1===Fe?K:wt+1;if(this.indexArray.emplaceBack(jt+1,wt,jt+3),this.indexArray.emplaceBack(wt,ri,jt+3),he.primitiveLength+=2,void 0===Ee&&(Ee=jt),!Tp(xt,we[Fe],te)){const oi=Fe===we.length-1?Ee:he.vertexLength;this.indexArray.emplaceBack(jt+2,jt+3,oi),this.indexArray.emplaceBack(jt+3,oi+1,oi),this.indexArray.emplaceBack(jt+3,ri,oi+1),he.primitiveLength+=3}je=!je}if(b){const wt=this.layoutVertexExtArray,ri=g.projectTilePoint(Xe.x,Xe.y,h),oi=g.projectTilePoint(it.x,it.y,h),Ei=g.upVector(h,Xe.x,Xe.y),Ui=g.upVector(h,it.x,it.y);ph(wt,ri,Ei),ph(wt,ri,Ei),ph(wt,oi,Ui),ph(wt,oi,Ui)}}y&&(K+=we.length-1),E&&G&&this.zoom>=17&&(0!==Oe.length&&X(Oe,Oe[0])&&Oe.pop(),this.groundEffect.addData(Oe,te,w,G>0))}this.footprintSegments.push(fe),pe.triangleCount=this.indexArray.length-pe.triangleArrayOffset,this.polygonSegments.push(pe),++M.footprintSegLen,++M.polygonSegLen}if(M.vertexCount=this.layoutVertexArray.length-M.vertexArrayOffset,M.groundVertexCount=this.groundEffect.vertexArray.length-M.groundVertexArrayOffset,0!==M.vertexCount){if(M.centroidXY=v.borders?lm:this.encodeCentroid(v,M),this.centroidData.push(M),v.borders){this.featuresOnBorder.push(v);const Z=this.featuresOnBorder.length-1;for(let te=0;tethis.featuresOnBorder[i].borders[e][0]-this.featuresOnBorder[o].borders[e][0])}splitToSubtiles(){const e=[];for(let m=0;mWe),p=2*w+(+(x.min.x+x.max.x>We)^w);for(let g=0;gm.triangleSegmentIdx===x.triangleSegmentIdx?m.subtile-x.subtile:m.triangleSegmentIdx-x.triangleSegmentIdx);let o=0,h=0,a=0;for(const m of e){if(m.triangleSegmentIdx!==o)break;a++}const u=e.length;for(;h!==e.length;){o=e[h].triangleSegmentIdx;let m=0,x=h,w=h;for(let p=x;p0&&this.triangleSubSegments.push({segment:y,min:g,max:b}),x=w;for(let v=x;v[M[0]*(1-C[0])+E[0]*C[0],M[1]*(1-C[1])+E[1]*C[1]],y=[],v=[];for(const M of this.triangleSubSegments){y[0]=M.min.x/We,y[1]=M.min.y/We,v[0]=M.max.x/We,v[1]=M.max.y/We;const E=b(p,g,y),C=b(p,g,v);if(0===new wi([E[0],E[1],a],[C[0],C[1],u]).intersectsPrecise(o)){w&&(h.segments.push(w),w=void 0);continue}const R=M.segment;w&&w.vertexOffset!==R.vertexOffset&&(h.segments.push(w),w=void 0),w?(w.vertexLength+=R.vertexLength,w.primitiveLength+=R.primitiveLength):w={vertexOffset:R.vertexOffset,primitiveLength:R.primitiveLength,vertexLength:R.vertexLength,primitiveOffset:R.primitiveOffset,sortKey:void 0,vaos:{}}}return w&&h.segments.push(w),h}encodeCentroid(e,i){const o=e.centroid(),h=i.span(),a=Math.min(7,Math.round(h.x*this.tileToMeter/10)),u=Math.min(7,Math.round(h.y*this.tileToMeter/10));return new He(zt(o.x,1,8191)<<3|a,zt(o.y,1,8191)<<3|u)}encodeBorderCentroid(e){if(!e.borders)return new He(0,0);const i=e.borders,o=Number.MAX_VALUE;if(i[0][0]!==o||i[1][0]!==o){const h=i[0][0]!==o?0:1;return new He(6|(i[0][0]!==o?0:65528),(i[h][0]+i[h][1])/2<<3|6)}{const h=i[2][0]!==o?2:3;return new He((i[h][0]+i[h][1])/2<<3|6,6|(i[2][0]!==o?0:65528))}}showCentroid(e){const i=this.centroidData[e.centroidDataIndex];i.flags&=zs,i.centroidXY.x=0,i.centroidXY.y=0,this.writeCentroidToBuffer(i)}writeCentroidToBuffer(e){this.groundEffect.updateHiddenByLandmark(e);const i=e.vertexArrayOffset,o=e.vertexCount+e.vertexArrayOffset,h=e.flags&zs?lm:e.centroidXY,a=this.centroidVertexArray.geta_centroid_pos0(i);if(this.centroidVertexArray.geta_centroid_pos1(i)!==h.y||a!==h.x){for(let u=i;ux.max.x||x.min.x>u.max.x||u.min.y>x.max.y||x.min.y>u.max.y))for(let w=0;wi!=y>i&&e<(this.footprintVertices.int16[2*(p+u.vertexOffset)+0]-g)*(i-b)/(y-b)+g&&(h=!h)}m=x}}return h}getHeightAtTileCoord(e,i){let o=Number.NEGATIVE_INFINITY,h=!0;const a=4*(e+We)*We+(i+We);if(this.partLookup.hasOwnProperty(a)){const u=this.partLookup[a];return u?{height:u.height,hidden:!!(u.flags&zs)}:void 0}for(const u of this.centroidData)e>u.max.x||u.min.x>e||i>u.max.y||u.min.y>i||this.footprintContainsPoint(e,i,u)&&u&&u.height>o&&(o=u.height,this.partLookup[a]=u,h=!!(u.flags&zs));if(o!==Number.NEGATIVE_INFINITY)return{height:o,hidden:h};this.partLookup[a]=void 0}}function fm(n,e){const i=n.add(e)._unit();return n.x*i.x+n.y*i.y}function _y(n,e,i,o){const h=e.sub(n)._perp()._unit(),a=i.sub(e)._perp()._unit();return mm(n,e,i,fm(h,a),o)}function mm(n,e,i,o,h){const a=Math.sqrt(1-o*o);return Math.min(n.dist(e)/3,e.dist(i)/3,h*a/o)}function Tp(n,e,i){return n.xi[1].x&&e.x>i[1].x||n.yi[1].y&&e.y>i[1].y}function _m(n,e){return n.xe[1].x||n.ye[1].y}function gm(n,e,i){if(n.x<0||n.x>=We||e.x<0||e.x>=We||i.x<0||i.x>=We)return!1;const o=i.sub(e),h=o.perp(),a=n.sub(e);return(o.x*a.x+o.y*a.y)/Math.sqrt((o.x*o.x+o.y*o.y)*(a.x*a.x+a.y*a.y))>-.866&&h.x*a.x+h.y*a.y<0}function ym(n,e,i){const o=e?2|n:-3&n;return i?1|o:-2&o}function xm(){const n=Math.PI/32,e=Math.tan(n),i=z;return i*Math.sqrt(1+2*e*e)-i}function vm(n,e,i){const o=1<{for(const H of B)v.push({polygon:H,bounds:G})},E=Math.ceil(Math.log2(p)),C=Math.ceil(Math.log2(g)),R=E-C,k=[];for(let B=0;B0?0:1);for(let B=0;BG+1?O.push({polygons:he,bounds:fe,depth:G+1}):M(he,fe)}if(pe.length){const fe=[new He(0===H?re:X.x,1===H?re:X.y),Z];k.length>G+1?O.push({polygons:pe,bounds:fe,depth:G+1}):M(pe,fe)}}return v}(n,e,Math.ceil((a-h)/11.25),Math.ceil((u-m)/11.25),1,(x,w,p)=>{if(0===x)return.5*(w+p);{const g=J((i.y+w/We)/o);return(Y(.5*(J((i.y+p/We)/o)+g))*o-i.y)*We}})}function gy(n,e,i,o,h,a){const u=Math.pow(2,o.z-h.z);for(let m=0;m1&&(x=e[++m]);const p=Math.abs(w-x.left),g=Math.abs(w-x.right),b=Math.min(p,g);let y;const v=a/o*(h+1);if(x.isDash){const M=h-Math.abs(v);y=Math.sqrt(b*b+M*M)}else y=h-Math.sqrt(b*b+v*v);this.image.data[u+w]=Math.max(0,Math.min(255,y+128))}}}addRegularDash(e,i){for(let x=e.length-1;x>=0;--x){const w=e[x],p=e[x+1];w.zeroLength?e.splice(x,1):p&&p.isDash===w.isDash&&(p.left=w.left,e.splice(x,1))}const o=e[0],h=e[e.length-1];o.isDash===h.isDash&&(o.left=h.left-this.width,h.right=o.right+this.width);const a=this.width*this.nextRow;let u=0,m=e[u];for(let x=0;x1&&(m=e[++u]);const w=Math.abs(x-m.left),p=Math.abs(x-m.right),g=Math.min(w,p);this.image.data[a+x]=Math.max(0,Math.min(255,(m.isDash?g:-g)+i+128))}}addDash(e,i){const o=this.getKey(e,i);if(this.positions[o])return this.positions[o];const h="round"===i,a=h?7:0,u=2*a+1;if(this.nextRow+u>this.height)return Qt("LineAtlas out of space"),null;0===e.length&&e.push(1);let m=0;for(let p=0;pi.fqid),this.index=e.index,this.projection=e.projection,this.hasPattern=!1,this.hasZOffset=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(i=>{this.gradients[i.id]={}}),this.layoutVertexArray=new qc,this.layoutVertexArray2=new kn,this.patternVertexArray=new no,this.indexArray=new cr,this.programConfigurations=new so(e.layers,{zoom:e.zoom,lut:e.lut}),this.segments=new Fi,this.maxLineLength=0,this.zOffsetVertexArray=new Ts,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.tessellationStep=e.tessellationStep?e.tessellationStep:128}updateFootprints(e,i){}populate(e,i,o,h){this.hasPattern=dp("line",this.layers,i);const a=this.layers[0].layout.get("line-sort-key"),u=this.layers[0].layout.get("line-z-offset");this.hasZOffset=!u.isConstant()||!!u.constantOr(0);const m=[];for(const{feature:g,id:b,index:y,sourceLayerIndex:v}of e){const M=this.layers[0]._featureFilter.needGeometry,E=Ge(g,M);if(!this.layers[0]._featureFilter.filter(new Bi(this.zoom),E,o))continue;const C=a?a.evaluate(E,{},o):void 0,R={id:b,properties:g.properties,type:g.type,sourceLayerIndex:v,index:y,geometry:M?E.geometry:Ue(g,o,h),patterns:{},sortKey:C};m.push(R)}a&&m.sort((g,b)=>g.sortKey-b.sortKey);const{lineAtlas:x,featureIndex:w}=i,p=this.addConstantDashes(x);for(const g of m){const{geometry:b,index:y,sourceLayerIndex:v}=g;if(p&&this.addFeatureDashes(g,x),this.hasPattern){const M=pp("line",this.layers,g,this.zoom,i);this.patternFeatures.push(M)}else this.addFeature(g,b,y,o,x.positions,i.availableImages,i.brightness);w.insert(e[y].feature,b,y,v,this.index)}}addConstantDashes(e){let i=!1;for(const o of this.layers){const h=o.paint.get("line-dasharray").value,a=o.layout.get("line-cap").value;if("constant"!==h.kind||"constant"!==a.kind)i=!0;else{const u=a.value,m=h.value;if(!m)continue;e.addDash(m,u)}}return i}addFeatureDashes(e,i){const o=this.zoom;for(const h of this.layers){const a=h.paint.get("line-dasharray").value,u=h.layout.get("line-cap").value;if("constant"===a.kind&&"constant"===u.kind)continue;let m,x;if("constant"===a.kind){if(m=a.value,!m)continue}else m=a.evaluate({zoom:o},e);x="constant"===u.kind?u.value:u.evaluate({zoom:o},e),i.addDash(m,x),e.patterns[h.id]=i.getKey(m,x)}}update(e,i,o,h,a){const u=0!==Object.keys(e).length;u&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(e,i,u?this.stateDependentLayers:this.layers,o,h,a)}addFeatures(e,i,o,h,a,u){for(const m of this.patternFeatures)this.addFeature(m,m.geometry,m.index,i,o,h,u)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,wy)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=e.createVertexBuffer(this.patternVertexArray,My)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,xy.members,!0)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,vy),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&e.properties.hasOwnProperty("mapbox_clip_start")&&e.properties.hasOwnProperty("mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,i,o,h,a,u,m){const x=this.layers[0].layout,w=x.get("line-join").evaluate(e,{}),p=x.get("line-cap").evaluate(e,{}),g=x.get("line-miter-limit"),b=x.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const y of i)this.addLine(y,e,h,w,p,g,b);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,o,a,u,h,m)}addLine(e,i,o,h,a,u,m){this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.currentVertex=void 0;const x={zoom:this.zoom,lineProgress:void 0},w=this.layers[0].layout,p="none"===h;if(this.patternJoinNone=this.hasPattern&&p,this.segmentStart=0,this.segmentStartf32=0,this.segmentPoints=[],this.lineClips){this.lineClipsArray.push(this.lineClips);for(let B=0;B=2&&e[b-1].equals(e[b-2]);)b--;let y=0;for(;y0;if(he&&B>y){const fe=E.dist(C);if(fe>2*v){const me=E.sub(E.sub(C)._mult(v/fe)._round());this.updateDistance(C,me),this.addCurrentVertex(me,k,0,0,M,O),C=me}}if(G&&"round"===H&&(Ku&&(H="bevel"),"bevel"===H&&(K>2&&(H="flipbevel"),K100)Z=P.mult(-1);else{const fe=K*k.add(P).mag()/k.sub(P).mag();Z._perp()._mult(fe*(pe?-1:1))}this.addCurrentVertex(E,Z,0,0,M,O),this.addCurrentVertex(E,Z.mult(-1),0,0,M,O)}else if("bevel"===H||"fakeround"===H){const fe=-Math.sqrt(K*K-1),me=pe?fe:0,we=pe?0:fe;if(C&&this.addCurrentVertex(E,k,me,we,M,O),"fakeround"===H){const ge=Math.round(180*re/Math.PI/20);for(let Pe=1;Pe2*v){const me=E.add(R.sub(E)._mult(v/fe)._round());this.updateDistance(E,me),this.addCurrentVertex(me,P,0,0,M,O),E=me}}}}addVerticesTo(e,i,o,h,a,u,m,x,w,p){const g=(i.w-e.w)/this.tessellationStep|0;if(g>1){this.lineSoFar=e.w;const b=(i.x-e.x)/g,y=(i.y-e.y)/g,v=(i.z-e.z)/g,M=(i.w-e.w)/g;for(let E=1;E=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,p),x.primitiveLength++),u?this.e2=p:this.e1=p,null!=w&&this.zOffsetVertexArray.emplaceBack(w)}updateScaledDistance(){if(this.lineClips){const e=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=e*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(e,i){this.distance+=e.dist(i),this.updateScaledDistance()}}function Em(n,e,i){return n.xi||n.yi}let Am,Im;function Cm(n,e,i){return e*(We/(n.tileSize*Math.pow(2,i-n.tileID.overscaledZ)))}function Pm(n,e){return 1/Cm(n,1,e.tileZoom)}function zm(n,e,i,o){return n.translatePosMatrix(o||e.tileID.projMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}rt(Mp,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const Dm=n=>{const e=[];Rm(n)&&e.push("RENDER_LINE_DASH"),n.paint.get("line-gradient")&&e.push("RENDER_LINE_GRADIENT");const i=n.paint.get("line-trim-offset");0===i[0]&&0===i[1]||e.push("RENDER_LINE_TRIM_OFFSET"),0!==n.paint.get("line-border-width").constantOr(1)&&e.push("RENDER_LINE_BORDER");const o="none"===n.layout.get("line-join").constantOr("miter"),h=!!n.paint.get("line-pattern").constantOr(1);return o&&h&&e.push("LINE_JOIN_NONE"),e};function Rm(n){const e=n.paint.get("line-dasharray").value;return e.value||"constant"!==e.kind}let Sp;const Lm=()=>Sp||(Sp={layout:Am||(Am=new Ci({"line-cap":new ct(be.layout_line["line-cap"]),"line-join":new ct(be.layout_line["line-join"]),"line-miter-limit":new qe(be.layout_line["line-miter-limit"]),"line-round-limit":new qe(be.layout_line["line-round-limit"]),"line-sort-key":new ct(be.layout_line["line-sort-key"]),"line-z-offset":new ct(be.layout_line["line-z-offset"]),visibility:new qe(be.layout_line.visibility)})),paint:Im||(Im=new Ci({"line-opacity":new ct(be.paint_line["line-opacity"]),"line-color":new ct(be.paint_line["line-color"]),"line-translate":new qe(be.paint_line["line-translate"]),"line-translate-anchor":new qe(be.paint_line["line-translate-anchor"]),"line-width":new ct(be.paint_line["line-width"]),"line-gap-width":new ct(be.paint_line["line-gap-width"]),"line-offset":new ct(be.paint_line["line-offset"]),"line-blur":new ct(be.paint_line["line-blur"]),"line-dasharray":new ct(be.paint_line["line-dasharray"]),"line-pattern":new ct(be.paint_line["line-pattern"]),"line-gradient":new an(be.paint_line["line-gradient"]),"line-trim-offset":new qe(be.paint_line["line-trim-offset"]),"line-trim-fade-range":new qe(be.paint_line["line-trim-fade-range"]),"line-trim-color":new qe(be.paint_line["line-trim-color"]),"line-emissive-strength":new qe(be.paint_line["line-emissive-strength"]),"line-border-width":new ct(be.paint_line["line-border-width"]),"line-border-color":new ct(be.paint_line["line-border-color"]),"line-occlusion-opacity":new qe(be.paint_line["line-occlusion-opacity"])}))},Sp);class Iy extends ct{possiblyEvaluate(e,i){return i=new Bi(Math.floor(i.zoom),{now:i.now,fadeDuration:i.fadeDuration,transition:i.transition}),super.possiblyEvaluate(e,i)}evaluate(e,i,o,h){return i=pr({},i,{zoom:Math.floor(i.zoom)}),super.evaluate(e,i,o,h)}}let mh;function km(n,e){return e>0?e+2*n:n}const Cy=ti([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Py=ti([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),zy=ti([{name:"a_projected_pos",components:4,type:"Float32"}],4);ti([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Dy=ti([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),Ry=ti([{name:"a_texb",components:2,type:"Uint16"}]),Ly=ti([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),ky=ti([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);ti([{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 Om=ti([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Oy=ti([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);ti([{name:"triangle",components:3,type:"Uint16"}]),ti([{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"}]),ti([{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"}]),ti([{type:"Float32",name:"offsetX"}]),ti([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);const Vn=128;function Ep(n,e){const{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new Bi(n+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:o,interpolationType:h}=i;let a=0;for(;a{o.text=function(h,a,u){const m=a.layout.get("text-transform").evaluate(u,{});return"uppercase"===m?h=h.toLocaleUpperCase():"lowercase"===m&&(h=h.toLocaleLowerCase()),zr.applyArabicShaping&&(h=zr.applyArabicShaping(h)),h}(o.text,e,i)}),n}const _h={"!":"\ufe15","#":"\uff03",$:"\uff04","%":"\uff05","&":"\uff06","(":"\ufe35",")":"\ufe36","*":"\uff0a","+":"\uff0b",",":"\ufe10","-":"\ufe32",".":"\u30fb","/":"\uff0f",":":"\ufe13",";":"\ufe14","<":"\ufe3f","=":"\uff1d",">":"\ufe40","?":"\ufe16","@":"\uff20","[":"\ufe47","\\":"\uff3c","]":"\ufe48","^":"\uff3e",_:"\ufe33","`":"\uff40","{":"\ufe37","|":"\u2015","}":"\ufe38","~":"\uff5e","\xa2":"\uffe0","\xa3":"\uffe1","\xa5":"\uffe5","\xa6":"\uffe4","\xac":"\uffe2","\xaf":"\uffe3","\u2013":"\ufe32","\u2014":"\ufe31","\u2018":"\ufe43","\u2019":"\ufe44","\u201c":"\ufe41","\u201d":"\ufe42","\u2026":"\ufe19","\u2027":"\u30fb","\u20a9":"\uffe6","\u3001":"\ufe11","\u3002":"\ufe12","\u3008":"\ufe3f","\u3009":"\ufe40","\u300a":"\ufe3d","\u300b":"\ufe3e","\u300c":"\ufe41","\u300d":"\ufe42","\u300e":"\ufe43","\u300f":"\ufe44","\u3010":"\ufe3b","\u3011":"\ufe3c","\u3014":"\ufe39","\u3015":"\ufe3a","\u3016":"\ufe17","\u3017":"\ufe18","\uff01":"\ufe15","\uff08":"\ufe35","\uff09":"\ufe36","\uff0c":"\ufe10","\uff0d":"\ufe32","\uff0e":"\u30fb","\uff1a":"\ufe13","\uff1b":"\ufe14","\uff1c":"\ufe3f","\uff1e":"\ufe40","\uff1f":"\ufe16","\uff3b":"\ufe47","\uff3d":"\ufe48","\uff3f":"\ufe33","\uff5b":"\ufe37","\uff5c":"\u2015","\uff5d":"\ufe38","\uff5f":"\ufe35","\uff60":"\ufe36","\uff61":"\ufe12","\uff62":"\ufe41","\uff63":"\ufe42","\u2190":"\u2191","\u2192":"\u2193"};function Ny(n){return"\ufe36"===n||"\ufe48"===n||"\ufe38"===n||"\ufe44"===n||"\ufe42"===n||"\ufe3e"===n||"\ufe3c"===n||"\ufe3a"===n||"\ufe18"===n||"\ufe40"===n||"\ufe10"===n||"\ufe13"===n||"\ufe14"===n||"\uff40"===n||"\uffe3"===n||"\ufe11"===n||"\ufe12"===n}function Vy(n){return"\ufe35"===n||"\ufe47"===n||"\ufe37"===n||"\ufe43"===n||"\ufe41"===n||"\ufe3d"===n||"\ufe3b"===n||"\ufe39"===n||"\ufe17"===n||"\ufe3f"===n}var Bm,Ap,Fm,Ip={};function Nm(){if(Fm)return Ap;Fm=1,Ap=e;var n=function Uy(){return Bm||(Bm=1,Ip.read=function(n,e,i,o,h){var a,u,m=8*h-o-1,x=(1<>1,p=-7,g=i?h-1:0,b=i?-1:1,y=n[e+g];for(g+=b,a=y&(1<<-p)-1,y>>=-p,p+=m;p>0;a=256*a+n[e+g],g+=b,p-=8);for(u=a&(1<<-p)-1,a>>=-p,p+=o;p>0;u=256*u+n[e+g],g+=b,p-=8);if(0===a)a=1-w;else{if(a===x)return u?NaN:1/0*(y?-1:1);u+=Math.pow(2,o),a-=w}return(y?-1:1)*u*Math.pow(2,a-o)},Ip.write=function(n,e,i,o,h,a){var u,m,x,w=8*a-h-1,p=(1<>1,b=23===h?Math.pow(2,-24)-Math.pow(2,-77):0,y=o?0:a-1,v=o?1:-1,M=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(m=isNaN(e)?1:0,u=p):(u=Math.floor(Math.log(e)/Math.LN2),e*(x=Math.pow(2,-u))<1&&(u--,x*=2),(e+=u+g>=1?b/x:b*Math.pow(2,1-g))*x>=2&&(u++,x/=2),u+g>=p?(m=0,u=p):u+g>=1?(m=(e*x-1)*Math.pow(2,h),u+=g):(m=e*Math.pow(2,g-1)*Math.pow(2,h),u=0));h>=8;n[i+y]=255&m,y+=v,m/=256,h-=8);for(u=u<0;n[i+y]=255&u,y+=v,u/=256,w-=8);n[i+y-v]|=128*M}),Ip}();function e(P){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(P)?P:new Uint8Array(P||0),this.pos=0,this.type=0,this.length=this.buf.length}e.Varint=0,e.Fixed64=1,e.Bytes=2,e.Fixed32=5;var i=4294967296,o=1/i,h=typeof TextDecoder>"u"?null:new TextDecoder("utf8");function a(P){return P.type===e.Bytes?P.readVarint()+P.pos:P.pos+1}function m(P,O,B){var G=O<=16383?1:O<=2097151?2:O<=268435455?3:Math.floor(Math.log(O)/(7*Math.LN2));B.realloc(G);for(var H=B.pos-1;H>=P;H--)B.buf[H+G]=B.buf[H]}function x(P,O){for(var B=0;B>>8,P[B+2]=O>>>16,P[B+3]=O>>>24}function k(P,O){return(P[O]|P[O+1]<<8|P[O+2]<<16)+(P[O+3]<<24)}return e.prototype={destroy:function(){this.buf=null},readFields:function(P,O,B){for(B=B||this.length;this.pos>3,X=this.pos;this.type=7&G,P(H,O,this),this.pos===X&&this.skip(G)}return O},readMessage:function(P,O){return this.readFields(P,O,this.readVarint()+this.pos)},readFixed32:function(){var P=C(this.buf,this.pos);return this.pos+=4,P},readSFixed32:function(){var P=k(this.buf,this.pos);return this.pos+=4,P},readFixed64:function(){var P=C(this.buf,this.pos)+C(this.buf,this.pos+4)*i;return this.pos+=8,P},readSFixed64:function(){var P=C(this.buf,this.pos)+k(this.buf,this.pos+4)*i;return this.pos+=8,P},readFloat:function(){var P=n.read(this.buf,this.pos,!0,23,4);return this.pos+=4,P},readDouble:function(){var P=n.read(this.buf,this.pos,!0,52,8);return this.pos+=8,P},readVarint:function(P){var O,B,G=this.buf;return O=127&(B=G[this.pos++]),B<128?O:(O|=(127&(B=G[this.pos++]))<<7,B<128?O:(O|=(127&(B=G[this.pos++]))<<14,B<128?O:(O|=(127&(B=G[this.pos++]))<<21,B<128?O:function(H,X,Z){var te,K,re=Z.buf;if(te=(112&(K=re[Z.pos++]))>>4,K<128||(te|=(127&(K=re[Z.pos++]))<<3,K<128)||(te|=(127&(K=re[Z.pos++]))<<10,K<128)||(te|=(127&(K=re[Z.pos++]))<<17,K<128)||(te|=(127&(K=re[Z.pos++]))<<24,K<128)||(te|=(1&(K=re[Z.pos++]))<<31,K<128))return function u(P,O,B){return B?4294967296*O+(P>>>0):4294967296*(O>>>0)+(P>>>0)}(H,te,X);throw new Error("Expected varint not more than 10 bytes")}(O|=(15&(B=G[this.pos]))<<28,P,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var P=this.readVarint();return P%2==1?(P+1)/-2:P/2},readBoolean:function(){return!!this.readVarint()},readString:function(){var P=this.readVarint()+this.pos,O=this.pos;return this.pos=P,P-O>=12&&h?h.decode(this.buf.subarray(O,P)):function(B,G,H){for(var X="",Z=G;Z239?4:he>223?3:he>191?2:1;if(Z+fe>H)break;1===fe?he<128&&(pe=he):2===fe?128==(192&(te=B[Z+1]))&&(pe=(31&he)<<6|63&te)<=127&&(pe=null):3===fe?(K=B[Z+2],128==(192&(te=B[Z+1]))&&128==(192&K)&&((pe=(15&he)<<12|(63&te)<<6|63&K)<=2047||pe>=55296&&pe<=57343)&&(pe=null)):4===fe&&(K=B[Z+2],re=B[Z+3],128==(192&(te=B[Z+1]))&&128==(192&K)&&128==(192&re)&&((pe=(15&he)<<18|(63&te)<<12|(63&K)<<6|63&re)<=65535||pe>=1114112)&&(pe=null)),null===pe?(pe=65533,fe=1):pe>65535&&(pe-=65536,X+=String.fromCharCode(pe>>>10&1023|55296),pe=56320|1023&pe),X+=String.fromCharCode(pe),Z+=fe}return X}(this.buf,O,P)},readBytes:function(){var P=this.readVarint()+this.pos,O=this.buf.subarray(this.pos,P);return this.pos=P,O},readPackedVarint:function(P,O){if(this.type!==e.Bytes)return P.push(this.readVarint(O));var B=a(this);for(P=P||[];this.pos127;);else if(O===e.Bytes)this.pos=this.readVarint()+this.pos;else if(O===e.Fixed32)this.pos+=4;else{if(O!==e.Fixed64)throw new Error("Unimplemented type: "+O);this.pos+=8}},writeTag:function(P,O){this.writeVarint(P<<3|O)},realloc:function(P){for(var O=this.length||16;O268435455||P<0?function(O,B){var G,H,X,te;if(O>=0?(G=O%4294967296|0,H=O/4294967296|0):(H=~(-O/4294967296),4294967295^(G=~(-O%4294967296))?G=G+1|0:(G=0,H=H+1|0)),O>=0x10000000000000000||O<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");B.realloc(10),X=G,(te=B).buf[te.pos++]=127&X|128,X>>>=7,te.buf[te.pos++]=127&X|128,X>>>=7,te.buf[te.pos++]=127&X|128,X>>>=7,te.buf[te.pos++]=127&X|128,te.buf[te.pos]=127&(X>>>=7),function(X,Z){var te=(7&X)<<4;Z.buf[Z.pos++]|=te|((X>>>=3)?128:0),X&&(Z.buf[Z.pos++]=127&X|((X>>>=7)?128:0),X&&(Z.buf[Z.pos++]=127&X|((X>>>=7)?128:0),X&&(Z.buf[Z.pos++]=127&X|((X>>>=7)?128:0),X&&(Z.buf[Z.pos++]=127&X|((X>>>=7)?128:0),X&&(Z.buf[Z.pos++]=127&X)))))}(H,B)}(P,this):(this.realloc(4),this.buf[this.pos++]=127&P|(P>127?128:0),P<=127||(this.buf[this.pos++]=127&(P>>>=7)|(P>127?128:0),P<=127||(this.buf[this.pos++]=127&(P>>>=7)|(P>127?128:0),P<=127||(this.buf[this.pos++]=P>>>7&127))))},writeSVarint:function(P){this.writeVarint(P<0?2*-P-1:2*P)},writeBoolean:function(P){this.writeVarint(!!P)},writeString:function(P){P=String(P),this.realloc(4*P.length),this.pos++;var O=this.pos;this.pos=function(G,H,X){for(var Z,te,K=0;K55295&&Z<57344){if(!te){Z>56319||K+1===H.length?(G[X++]=239,G[X++]=191,G[X++]=189):te=Z;continue}if(Z<56320){G[X++]=239,G[X++]=191,G[X++]=189,te=Z;continue}Z=te-55296<<10|Z-56320|65536,te=null}else te&&(G[X++]=239,G[X++]=191,G[X++]=189,te=null);Z<128?G[X++]=Z:(Z<2048?G[X++]=Z>>6|192:(Z<65536?G[X++]=Z>>12|224:(G[X++]=Z>>18|240,G[X++]=Z>>12&63|128),G[X++]=Z>>6&63|128),G[X++]=63&Z|128)}return X}(this.buf,P,this.pos);var B=this.pos-O;B>=128&&m(O,B,this),this.pos=O-1,this.writeVarint(B),this.pos+=B},writeFloat:function(P){this.realloc(4),n.write(this.buf,P,this.pos,!0,23,4),this.pos+=4},writeDouble:function(P){this.realloc(8),n.write(this.buf,P,this.pos,!0,52,8),this.pos+=8},writeBytes:function(P){var O=P.length;this.writeVarint(O),this.realloc(O);for(var B=0;B=128&&m(B,G,this),this.pos=B-1,this.writeVarint(G),this.pos+=G},writeMessage:function(P,O,B){this.writeTag(P,e.Bytes),this.writeRawMessage(O,B)},writePackedVarint:function(P,O){O.length&&this.writeMessage(P,x,O)},writePackedSVarint:function(P,O){O.length&&this.writeMessage(P,w,O)},writePackedBoolean:function(P,O){O.length&&this.writeMessage(P,b,O)},writePackedFloat:function(P,O){O.length&&this.writeMessage(P,p,O)},writePackedDouble:function(P,O){O.length&&this.writeMessage(P,g,O)},writePackedFixed32:function(P,O){O.length&&this.writeMessage(P,y,O)},writePackedSFixed32:function(P,O){O.length&&this.writeMessage(P,v,O)},writePackedFixed64:function(P,O){O.length&&this.writeMessage(P,M,O)},writePackedSFixed64:function(P,O){O.length&&this.writeMessage(P,E,O)},writeBytesField:function(P,O){this.writeTag(P,e.Bytes),this.writeBytes(O)},writeFixed32Field:function(P,O){this.writeTag(P,e.Fixed32),this.writeFixed32(O)},writeSFixed32Field:function(P,O){this.writeTag(P,e.Fixed32),this.writeSFixed32(O)},writeFixed64Field:function(P,O){this.writeTag(P,e.Fixed64),this.writeFixed64(O)},writeSFixed64Field:function(P,O){this.writeTag(P,e.Fixed64),this.writeSFixed64(O)},writeVarintField:function(P,O){this.writeTag(P,e.Varint),this.writeVarint(O)},writeSVarintField:function(P,O){this.writeTag(P,e.Varint),this.writeSVarint(O)},writeStringField:function(P,O){this.writeTag(P,e.Bytes),this.writeString(O)},writeFloatField:function(P,O){this.writeTag(P,e.Fixed32),this.writeFloat(O)},writeDoubleField:function(P,O){this.writeTag(P,e.Fixed64),this.writeDouble(O)},writeBooleanField:function(P,O){this.writeVarintField(P,!!O)}},Ap}var td=Mi(Nm());function jy(n,e,i){e.glyphs=[],1===n&&i.readMessage(Gy,e)}function Gy(n,e,i){if(3===n){const{id:o,bitmap:h,width:a,height:u,left:m,top:x,advance:w}=i.readMessage(qy,{});e.glyphs.push({id:o,bitmap:new Ps({width:a+6,height:u+6},h),metrics:{width:a,height:u,left:m,top:x,advance:w}})}else 4===n?e.ascender=i.readSVarint():5===n&&(e.descender=i.readSVarint())}function qy(n,e,i){1===n?e.id=i.readVarint():2===n?e.bitmap=i.readBytes():3===n?e.width=i.readVarint():4===n?e.height=i.readVarint():5===n?e.left=i.readSVarint():6===n?e.top=i.readSVarint():7===n&&(e.advance=i.readVarint())}const hn={horizontal:1,vertical:2,horizontalOnly:3};class gh{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(e,i){const o=new gh;return o.scale=e||1,o.fontStack=i,o}static forImage(e){const i=new gh;return i.imageName=e,i}}class Ul{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(e,i){const o=new Ul;for(let h=0;h=0&&o>=e&&id[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 Ul;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(gh.forText(e.scale,e.fontStack||i));const o=this.sections.length-1;for(let h=0;h=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Pp(n,e,i,o,h,a,u,m,x,w,p,g,b,y,v){const M=Ul.fromFeature(n,h);g===hn.vertical&&M.verticalizePunctuation(b);let E=[];const C=function(B,G,H,X,Z,te){if(!B)return[];const K=[],re=function(me,we,ge,Pe,Oe,Ee){let Ye=0;for(let $e=0;$e=0;let pe=0;for(let me=0;me0&&jr>Ct&&(Ct=jr)}else{const dr=H[wt.fontStack];if(!dr)continue;dr[oi]&&(Wi=dr[oi]);const Ti=G[wt.fontStack];if(!Ti)continue;const jr=Ti.glyphs[oi];if(!jr)continue;if(Ui=jr.metrics,ki=8203!==oi?24:0,Ee){const Zn=void 0!==Ti.ascender?Math.abs(Ti.ascender):0,Tn=void 0!==Ti.descender?Math.abs(Ti.descender):0,Mn=(Zn+Tn)*Ei;Ut-i/2;){if(u--,u<0)return!1;m-=n[u].dist(a),a=n[u]}m+=n[u].dist(n[u+1]),u++;const x=[];let w=0;for(;mo;)w-=x.shift().angleDelta;if(w>h)return!1;u++,m+=p.dist(g)}return!0}function Wm(n){let e=0;for(let i=0;iw){const v=(w-x)/y,M=mt(g.x,b.x,v),E=mt(g.y,b.y,v),C=new Oo(M,E,0,b.angleTo(g),p);return!u||Hm(n,C,m,u,e)?C:void 0}x+=y}}function Xy(n,e,i,o,h,a,u,m,x){const w=Xm(o,a,u),p=Ym(o,h),g=p*u,b=0===n[0].x||n[0].x===x||0===n[0].y||n[0].y===x;return e-g=0&&P=0&&O=0&&b+w<=p){const B=new Oo(P,O,0,R,v);o&&!Hm(n,B,a,o,h)||y.push(B)}}g+=C}return m||y.length||u||(y=Km(n,g/2,i,o,h,a,u,!0,x)),y}function Jm(n,e,i,o,h){const a=[];for(let u=0;u=o&&g.x>=o||(p.x>=o?p=new He(o,p.y+(o-p.x)/(g.x-p.x)*(g.y-p.y))._round():g.x>=o&&(g=new He(o,p.y+(o-p.x)/(g.x-p.x)*(g.y-p.y))._round()),p.y>=h&&g.y>=h||(p.y>=h?p=new He(p.x+(h-p.y)/(g.y-p.y)*(g.x-p.x),h)._round():g.y>=h&&(g=new He(p.x+(h-p.y)/(g.y-p.y)*(g.x-p.x),h)._round()),x&&p.equals(x[x.length-1])||(x=[p],a.push(x)),x.push(g)))))}}return a}function Qm(n){let e=0,i=0;for(const u of n)e+=u.w*u.h,i=Math.max(i,u.w);n.sort((u,m)=>m.h-u.h);const o=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let h=0,a=0;for(const u of n)for(let m=o.length-1;m>=0;m--){const x=o[m];if(!(u.w>x.w||u.h>x.h)){if(u.x=x.x,u.y=x.y,a=Math.max(a,u.y+u.h),h=Math.max(h,u.x+u.w),u.w===x.w&&u.h===x.h){const w=o.pop();m1?y-1:y,Sr.copy(g.data,w,{x:0,y:0},{x:v,y:M},g.data,o),Sr.copy(g.data,w,{x:0,y:C-y},{x:v,y:M-y},{width:E,height:y},o),Sr.copy(g.data,w,{x:0,y:0},{x:v,y:M+C},{width:E,height:y},o),Sr.copy(g.data,w,{x:E-y,y:0},{x:v-y,y:M},{width:y,height:C},o),Sr.copy(g.data,w,{x:0,y:0},{x:v+E,y:M},{width:y,height:C},o),Sr.copy(g.data,w,{x:E-y,y:C-y},{x:v-y,y:M-y},{width:y,height:y},o),Sr.copy(g.data,w,{x:0,y:C-y},{x:v+E,y:M-y},{width:y,height:y},o),Sr.copy(g.data,w,{x:0,y:0},{x:v+E,y:M+C},{width:y,height:y},o),Sr.copy(g.data,w,{x:E-y,y:0},{x:v-y,y:M+C},{width:y,height:y},o)}this.image=w,this.iconPositions=h,this.patternPositions=a}addImages(e,i,o,h){for(const a in e){const u=e[a],m={x:0,y:0,w:u.data.width+2*o,h:u.data.height+2*o};h.push(m),i[a]=new Dp(m,u,o),u.hasRenderCallback&&this.haveRenderCallbacks.push(a)}}patchUpdatedImages(e,i,o){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(h=>e.hasImage(h,o)),e.dispatchRenderCallbacks(this.haveRenderCallbacks,o);for(const h in e.getUpdatedImages(o))this.patchUpdatedImage(this.iconPositions[h],e.getImage(h,o),i),this.patchUpdatedImage(this.patternPositions[h],e.getImage(h,o),i)}patchUpdatedImage(e,i,o){if(!e||!i||e.version===i.version)return;e.version=i.version;const[h,a]=e.tl;o.update(i.data,{position:{x:h,y:a}})}}rt(Dp,"ImagePosition"),rt(e_,"ImageAtlas");const xh=1e20;function t_(n,e,i,o,h,a,u,m,x){for(let w=e;w-1);x++,a[x]=m,u[x]=w,u[x+1]=xh}for(let m=0,x=0;m{let w=this.entries[u];w||(w=this.entries[u]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let p=w.glyphs[m];if(void 0!==p)return void x(null,{stack:u,id:m,glyph:p});if(p=this._tinySDF(w,u,m),p)return w.glyphs[m]=p,void x(null,{stack:u,id:m,glyph:p});const g=Math.floor(m/256);if(256*g>65535)return void x(new Error("glyphs > 65535 not supported"));if(w.ranges[g])return void x(null,{stack:u,id:m,glyph:p});let b=w.requests[g];b||(b=w.requests[g]=[],jl.loadGlyphRange(u,g,a,this.requestManager,(y,v)=>{if(v){w.ascender=v.ascender,w.descender=v.descender;for(const M in v.glyphs)this._doesCharSupportLocalGlyph(+M)||(w.glyphs[+M]=v.glyphs[+M]);w.ranges[g]=!0}for(const M of b)M(y,v);delete w.requests[g]})),b.push((y,v)=>{y?x(y):v&&x(null,{stack:u,id:m,glyph:v.glyphs[m]||null})})},(u,m)=>{if(u)o(u);else if(m){const x={};for(const{stack:w,id:p,glyph:g}of m)void 0===x[w]&&(x[w]={}),void 0===x[w].glyphs&&(x[w].glyphs={}),x[w].glyphs[p]=g&&{id:g.id,bitmap:g.bitmap.clone(),metrics:g.metrics},x[w].ascender=this.entries[w].ascender,x[w].descender=this.entries[w].descender;o(null,x)}})}_doesCharSupportLocalGlyph(e){return this.localGlyphMode!==Rp.none&&(this.localGlyphMode===Rp.all?!!this.localFontFamily:!!this.localFontFamily&&(at_CJK_Unified_Ideographs(e)||at_Hangul_Syllables(e)||at_Hiragana(e)||at_Katakana(e)||at_CJK_Symbols_and_Punctuation(e)||at_CJK_Unified_Ideographs_Extension_A(e)||(n=e)>=131072&&n<=173791));var n}_tinySDF(e,i,o){const h=this.localFontFamily;if(!h||!this._doesCharSupportLocalGlyph(o))return;let a=e.tinySDF;if(!a){let M="400";/bold/i.test(i)?M="900":/medium/i.test(i)?M="500":/light/i.test(i)&&(M="200"),a=e.tinySDF=new jl.TinySDF({fontFamily:h,fontWeight:M,fontSize:48,buffer:6,radius:16}),a.fontWeight=M}if(this.localGlyphs[a.fontWeight][o])return this.localGlyphs[a.fontWeight][o];const u=String.fromCodePoint(o),{data:m,width:x,height:w,glyphWidth:p,glyphHeight:g,glyphLeft:b,glyphTop:y,glyphAdvance:v}=a.draw(u);return this.localGlyphs[a.fontWeight][o]={id:o,bitmap:new Ps({width:x,height:w},m),metrics:{width:p/2,height:g/2,left:b/2,top:y/2-27,advance:v/2,localGlyph:!0}}}}function r_(n,e,i,o){const h=[],a=n.imagePrimary,u=a.pixelRatio,m=a.paddedRect.w-2,x=a.paddedRect.h-2,w=n.right-n.left,p=n.bottom-n.top,g=a.stretchX||[[0,m]],b=a.stretchY||[[0,x]],y=(te,K)=>te+K[1]-K[0],v=g.reduce(y,0),M=b.reduce(y,0),E=m-v,C=x-M;let R=0,k=v,P=0,O=M,B=0,G=E,H=0,X=C;if(a.content&&o){const te=a.content;R=rd(g,0,te[0]),P=rd(b,0,te[1]),k=rd(g,te[0],te[2]),O=rd(b,te[1],te[3]),B=te[0]-R,H=te[1]-P,G=te[2]-te[0]-k,X=te[3]-te[1]-O}const Z=(te,K,re,he)=>{const pe=nd(te.stretch-R,k,w,n.left),fe=od(te.fixed-B,G,te.stretch,v),me=nd(K.stretch-P,O,p,n.top),we=od(K.fixed-H,X,K.stretch,M),ge=nd(re.stretch-R,k,w,n.left),Pe=od(re.fixed-B,G,re.stretch,v),Oe=nd(he.stretch-P,O,p,n.top),Ee=od(he.fixed-H,X,he.stretch,M),Ye=new He(pe,me),$e=new He(ge,me),je=new He(ge,Oe),Fe=new He(pe,Oe),ut=new He(fe/u,we/u),Xe=new He(Pe/u,Ee/u),it=e*Math.PI/180;if(it){const jt=Math.sin(it),xi=Math.cos(it),hi=[xi,-jt,jt,xi];Ye._matMult(hi),$e._matMult(hi),Fe._matMult(hi),je._matMult(hi)}const xt=te.stretch+te.fixed,Bt=re.stretch+re.fixed,It=K.stretch+K.fixed,Ct=he.stretch+he.fixed,Ut=n.imageSecondary;return{tl:Ye,tr:$e,bl:Fe,br:je,texPrimary:{x:a.paddedRect.x+1+xt,y:a.paddedRect.y+1+It,w:Bt-xt,h:Ct-It},texSecondary:Ut?{x:Ut.paddedRect.x+1+xt,y:Ut.paddedRect.y+1+It,w:Bt-xt,h:Ct-It}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:ut,pixelOffsetBR:Xe,minFontScaleX:G/u/w,minFontScaleY:X/u/p,isSDF:i}};if(o&&(a.stretchX||a.stretchY)){const te=n_(g,E,v),K=n_(b,C,M);for(let re=0;rea)&&(a=v.x),(!y||v.y>u)&&(u=v.y)}const x=Math.min(a-o,u-h);let w=x/2;const p=new hc([],Jy);if(0===x)return new He(o,h);for(let y=o;yg.d||!g.d)&&(g=y,i&&console.log("found best %d after %d probes",Math.round(1e4*y.d)/1e4,b)),y.max-g.d<=e||(w=y.h/2,p.push(new Gl(y.p.x-w,y.p.y-w,w,n)),p.push(new Gl(y.p.x+w,y.p.y-w,w,n)),p.push(new Gl(y.p.x-w,y.p.y+w,w,n)),p.push(new Gl(y.p.x+w,y.p.y+w,w,n)),b+=4)}return i&&(console.log(`num probes: ${b}`),console.log(`best distance: ${g.d}`)),g.p}function Jy(n,e){return e.max-n.max}jl.loadGlyphRange=function(n,e,i,o,h){const a=256*e,u=a+255,m=o.transformRequest(o.normalizeGlyphsURL(i).replace("{fontstack}",n).replace("{range}",`${a}-${u}`),$o.Glyphs);Ho(m,(x,w)=>{if(x)h(x);else if(w){const p={},g=new td(w).readFields(jy,{});for(const b of g.glyphs)p[b.id]=b;h(null,{glyphs:p,ascender:g.ascender,descender:g.descender})}})},jl.TinySDF=class{constructor({fontSize:n=24,buffer:e=3,radius:i=8,cutoff:o=.25,fontFamily:h="sans-serif",fontWeight:a="normal",fontStyle:u="normal"}={}){this.buffer=e,this.cutoff=o,this.radius=i;const m=this.size=n+4*e,x=this._createCanvas(m),w=this.ctx=x.getContext("2d",{willReadFrequently:!0});w.font=`${u} ${a} ${n}px ${h}`,w.textBaseline="alphabetic",w.textAlign="left",w.fillStyle="black",this.gridOuter=new Float64Array(m*m),this.gridInner=new Float64Array(m*m),this.f=new Float64Array(m),this.z=new Float64Array(m+1),this.v=new Uint16Array(m)}_createCanvas(n){const e=document.createElement("canvas");return e.width=e.height=n,e}draw(n){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:o,actualBoundingBoxLeft:h,actualBoundingBoxRight:a}=this.ctx.measureText(n),u=Math.ceil(i),m=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(a-h))),x=Math.min(this.size-this.buffer,u+Math.ceil(o)),w=m+2*this.buffer,p=x+2*this.buffer,g=Math.max(w*p,0),b=new Uint8ClampedArray(g),y={data:b,width:w,height:p,glyphWidth:m,glyphHeight:x,glyphTop:u,glyphLeft:0,glyphAdvance:e};if(0===m||0===x)return y;const{ctx:v,buffer:M,gridInner:E,gridOuter:C}=this;v.clearRect(M,M,m,x),v.fillText(n,M,M+u);const R=v.getImageData(M,M,m,x);C.fill(xh,0,g),E.fill(0,0,g);for(let k=0;k0?G*G:0,E[B]=G<0?G*G:0}}t_(C,0,0,w,p,w,this.f,this.v,this.z),t_(E,M,M,m,x,w,this.f,this.v,this.z);for(let k=0;ka.y!=M.y>a.y&&a.x<(M.x-v.x)*(a.y-v.y)/(M.y-v.y)+v.x&&(m=!m),x=Math.min(x,di(a,v,M))}}return(m?1:-1)*Math.sqrt(x)}(this.p,h),this.max=this.d+this.h*Math.SQRT2}}const Lp=Number.POSITIVE_INFINITY,Qy=Math.sqrt(2);function o_(n,[e,i]){let o=0,h=0;if(i===Lp){e<0&&(e=0);const a=e/Qy;switch(n){case"top-right":case"top-left":h=a-7;break;case"bottom-right":case"bottom-left":h=7-a;break;case"bottom":h=7-e;break;case"top":h=e-7}switch(n){case"top-right":case"bottom-right":o=-a;break;case"top-left":case"bottom-left":o=a;break;case"left":o=e;break;case"right":o=-e}}else{switch(e=Math.abs(e),i=Math.abs(i),n){case"top-right":case"top-left":case"top":h=i-7;break;case"bottom-right":case"bottom-left":case"bottom":h=7-i}switch(n){case"top-right":case"bottom-right":case"right":o=-e;break;case"top-left":case"bottom-left":case"left":o=e}}return[o,h]}function kp(n){switch(n){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function e0(n,e,i,o,h,a,u,m,x,w,p,g,b,y,v){let M=a.textMaxSize.evaluate(e,{},g);void 0===M&&(M=u);const E=n.layers[0].layout,C=E.get("icon-offset").evaluate(e,{},g),R=a_(i.horizontal)||i.vertical,k="globe"===b.name,O=u/24,B=n.tilePixelRatio*M/24,G=(pe=n.overscaling,n.zoom>18&&pe>2&&(pe>>=1),Math.max(We/(512*pe),1)*E.get("symbol-spacing")),H=E.get("text-padding")*n.tilePixelRatio,X=E.get("icon-padding")*n.tilePixelRatio,Z=Ht(E.get("text-max-angle")),te="map"===E.get("text-rotation-alignment")&&"point"!==E.get("symbol-placement"),K="map"===E.get("icon-rotation-alignment")&&"point"!==E.get("symbol-placement"),re=E.get("symbol-placement"),he=G/2;var pe;const fe=E.get("icon-text-fit").evaluate(e,{},g),me=E.get("icon-text-fit-padding").evaluate(e,{},g),we="none"!==fe;let ge;!1===n.hasAnyIconTextFit&&we&&(n.hasAnyIconTextFit=!0),o&&we&&(n.allowVerticalPlacement&&i.vertical&&(ge=$m(o,i.vertical,fe,me,C,O)),R&&(o=$m(o,R,fe,me,C,O)));const Pe=(Oe,Ee,Ye)=>{if(Ee.x<0||Ee.x>=We||Ee.y<0||Ee.y>=We)return;let $e=null;if(k){const{x:je,y:Fe,z:ut}=b.projectTilePoint(Ee.x,Ee.y,Ye);$e={anchor:new Oo(je,Fe,ut,0,void 0),up:b.upVector(Ye,Ee.x,Ee.y)}}!function(je,Fe,ut,Xe,it,xt,Bt,It,Ct,Ut,jt,xi,hi,wt,ri,oi,Ei,Ui,Wi,ji,ki,sr,Yi,dr,Ti,jr,Zn){const Tn=je.addToLineVertexArray(Fe,Xe);let Mn,Da,Bs,Ra,Bh,Ig,Cg,Pg=0,zg=0,Dg=0,Rg=0,uf=-1,df=-1;const ho={};let Lg=Ar("");const La=ut?ut.anchor:Fe,pf="none"!==Ct.layout.get("icon-text-fit").evaluate(ki,{},Ti);let ff=0,mf=0;if(void 0===Ct._unevaluatedLayout.getValue("text-radial-offset")?[ff,mf]=Ct.layout.get("text-offset").evaluate(ki,{},Ti).map(Yr=>24*Yr):(ff=24*Ct.layout.get("text-radial-offset").evaluate(ki,{},Ti),mf=Lp),je.allowVerticalPlacement&&it.vertical){const Yr=it.vertical;if(ri)Ig=Op(Yr),It&&(Cg=Op(It));else{const Kr=Ct.layout.get("text-rotate").evaluate(ki,{},Ti)+90;Bs=sd(Ut,La,Fe,jt,xi,hi,Yr,wt,Kr,oi),It&&(Ra=sd(Ut,La,Fe,jt,xi,hi,It,Ui,Kr))}}if(xt){const Yr=Ct.layout.get("icon-rotate").evaluate(ki,{},Ti),Kr=r_(xt,Yr,Yi,pf),Kl=It?r_(It,Yr,Yi,pf):void 0;Da=sd(Ut,La,Fe,jt,xi,hi,xt,Ui,Yr),Pg=4*Kr.length;const kg=je.iconSizeData;let ka=null;"source"===kg.kind?(ka=[Vn*Ct.layout.get("icon-size").evaluate(ki,{},Ti)],ka[0]>Rs&&Qt(`${je.layerIds[0]}: Value for "icon-size" is >= ${vh}. Reduce your "icon-size".`)):"composite"===kg.kind&&(ka=[Vn*sr.compositeIconSizes[0].evaluate(ki,{},Ti),Vn*sr.compositeIconSizes[1].evaluate(ki,{},Ti)],(ka[0]>Rs||ka[1]>Rs)&&Qt(`${je.layerIds[0]}: Value for "icon-size" is >= ${vh}. Reduce your "icon-size".`)),je.addSymbols(je.icon,Kr,ka,ji,Wi,ki,!1,ut,Fe,Tn.lineStartIndex,Tn.lineLength,-1,dr,Ti,jr,Zn),uf=je.icon.placedSymbolArray.length-1,Kl&&(zg=4*Kl.length,je.addSymbols(je.icon,Kl,ka,ji,Wi,ki,hn.vertical,ut,Fe,Tn.lineStartIndex,Tn.lineLength,-1,dr,Ti,jr,Zn),df=je.icon.placedSymbolArray.length-1)}for(const Yr in it.horizontal){const Kr=it.horizontal[Yr];Mn||(Lg=Ar(Kr.text),ri?Bh=Op(Kr):Mn=sd(Ut,La,Fe,jt,xi,hi,Kr,wt,Ct.layout.get("text-rotate").evaluate(ki,{},Ti),oi));const Kl=1===Kr.positionedLines.length;if(Dg+=s_(je,ut,Fe,Kr,Bt,Ct,ri,ki,oi,Tn,it.vertical?hn.horizontal:hn.horizontalOnly,Kl?Object.keys(it.horizontal):[Yr],ho,uf,sr,dr,Ti,jr),Kl)break}it.vertical&&(Rg+=s_(je,ut,Fe,it.vertical,Bt,Ct,ri,ki,oi,Tn,hn.vertical,["vertical"],ho,df,sr,dr,Ti,jr));let Fs=-1;const _f=(Yr,Kr)=>Yr?Math.max(Yr,Kr):Kr;Fs=_f(Bh,Fs),Fs=_f(Ig,Fs),Fs=_f(Cg,Fs);const mx=Fs>-1?1:0;je.glyphOffsetArray.length>=65535&&Qt("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==ki.sortKey&&je.addToSortKeyRanges(je.symbolInstances.length,ki.sortKey),je.symbolInstances.emplaceBack(Fe.x,Fe.y,La.x,La.y,La.z,ho.right>=0?ho.right:-1,ho.center>=0?ho.center:-1,ho.left>=0?ho.left:-1,ho.vertical>=0?ho.vertical:-1,uf,df,Lg,void 0!==Mn?Mn:je.collisionBoxArray.length,void 0!==Mn?Mn+1:je.collisionBoxArray.length,void 0!==Bs?Bs:je.collisionBoxArray.length,void 0!==Bs?Bs+1:je.collisionBoxArray.length,void 0!==Da?Da:je.collisionBoxArray.length,void 0!==Da?Da+1:je.collisionBoxArray.length,Ra||je.collisionBoxArray.length,Ra?Ra+1:je.collisionBoxArray.length,jt,Dg,Rg,Pg,zg,mx,0,ff,mf,Fs,0,pf?1:0)}(n,Ee,$e,Oe,i,o,h,ge,n.layers[0],n.collisionBoxArray,e.index,e.sourceLayerIndex,n.index,H,te,x,0,X,K,C,e,a,w,p,g,y,v)};if("line"===re)for(const Oe of Jm(e.geometry,0,0,We,We)){const Ee=Xy(Oe,G,Z,i.vertical||R,o,24,B,n.overscaling,We);for(const Ye of Ee)R&&t0(n,R.text,he,Ye)||Pe(Oe,Ye,g)}else if("line-center"===re){for(const Oe of e.geometry)if(Oe.length>1){const Ee=Wy(Oe,Z,i.vertical||R,o,24,B);Ee&&Pe(Oe,Ee,g)}}else if("Polygon"===e.type)for(const Oe of Hu(e.geometry,0)){const Ee=Ky(Oe,16);Pe(Oe[0],new Oo(Ee.x,Ee.y,0,0,void 0),g)}else if("LineString"===e.type)for(const Oe of e.geometry)Pe(Oe,new Oo(Oe[0].x,Oe[0].y,0,0,void 0),g);else if("Point"===e.type)for(const Oe of e.geometry)for(const Ee of Oe)Pe([Ee],new Oo(Ee.x,Ee.y,0,0,void 0),g)}const vh=255,Rs=vh*Vn;function s_(n,e,i,o,h,a,u,m,x,w,p,g,b,y,v,M,E,C){const R=function(O,B,G,H,X,Z,te,K){const re=[];if(0===B.positionedLines.length)return re;const he=H.layout.get("text-rotate").evaluate(Z,{})*Math.PI/180,pe=function(Pe){const Oe=Pe[0],Ee=Pe[1],Ye=Oe*Ee;return Ye>0?[Oe,-Ee]:Ye<0?[-Oe,Ee]:0===Oe?[Ee,Oe]:[Ee,-Oe]}(G);let fe=Math.abs(B.top-B.bottom);for(const Pe of B.positionedLines)fe-=Pe.lineOffset;const me=B.positionedLines.length,we=fe/me;let ge=B.top-G[1];for(let Pe=0;PeRs&&Qt(`${n.layerIds[0]}: Value for "text-size" is >= ${vh}. Reduce your "text-size".`)):"composite"===k.kind&&(P=[Vn*v.compositeTextSizes[0].evaluate(m,{},E),Vn*v.compositeTextSizes[1].evaluate(m,{},E)],(P[0]>Rs||P[1]>Rs)&&Qt(`${n.layerIds[0]}: Value for "text-size" is >= ${vh}. Reduce your "text-size".`)),n.addSymbols(n.text,R,P,x,u,m,p,e,i,w.lineStartIndex,w.lineLength,y,M,E,C,!1);for(const O of g)b[O]=n.text.placedSymbolArray.length-1;return 4*R.length}function a_(n){for(const e in n)return n[e];return null}function sd(n,e,i,o,h,a,u,m,x,w){let p=u.top,g=u.bottom,b=u.left,y=u.right;const v=u.collisionPadding;if(v&&(b-=v[0],p-=v[1],y+=v[2],g+=v[3]),x){const M=new He(b,p),E=new He(y,p),C=new He(b,g),R=new He(y,g),k=Ht(x);let P=new He(0,0);w&&(P=new He(w[0],w[1])),M._rotateAround(k,P),E._rotateAround(k,P),C._rotateAround(k,P),R._rotateAround(k,P),b=Math.min(M.x,E.x,C.x,R.x),y=Math.max(M.x,E.x,C.x,R.x),p=Math.min(M.y,E.y,C.y,R.y),g=Math.max(M.y,E.y,C.y,R.y)}return n.emplaceBack(e.x,e.y,e.z,i.x,i.y,b,p,y,g,m,o,h,a),n.length-1}function Op(n){n.collisionPadding&&(n.top-=n.collisionPadding[1],n.bottom+=n.collisionPadding[3]);const e=n.bottom-n.top;return e>0?Math.max(10,e):null}function t0(n,e,i,o){const h=n.compareText;if(e in h){const a=h[e];for(let u=a.length-1;u>=0;u--)if(o.dist(a[u])k&&(P(B,he,H,X,K,re),P(he,G,K,re,Z,te))}P(g,b,o,a,h,a),P(b,y,h,a,h,u),P(y,v,h,u,o,u),P(v,g,o,u,o,a),M-=k,E-=k,C+=k,R+=k;const O=1/Math.max(C-M,R-E);return{scale:O,x:M*O,y:E*O,x2:C*O,y2:R*O,projection:e}}function c_(n,{x:e,y:i},o=0){return new He(((e-o)*n.scale-n.x)*We,(i*n.scale-n.y)*We)}const i0=ue.mat4.identity(new Float32Array(16));class Ls{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 L(0,0)}projectTilePoint(e,i,o){return{x:e,y:i,z:0}}locationPoint(e,i,o=!0){return e._coordinatePoint(e.locationCoordinate(i),o)}pixelsPerMeter(e,i){return $(1,e)*i}pixelSpaceConversion(e,i,o){return 1}farthestPixelDistance(e){return l_(e,e.pixelsPerMeter)}pointCoordinate(e,i,o,h){const a=e.horizonLineFromTop(!1),u=new He(i,Math.max(a,o));return e.rayIntersectionCoordinate(e.pointRayIntersection(u,h))}pointCoordinate3D(e,i,o){const h=new He(i,o);if(e.elevation)return e.elevation.pointCoordinate(h);{const a=this.pointCoordinate(e,h.x,h.y,0);return[a.x,a.y,a.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.y0?i<-ql+o&&(i=-ql+o):i>ql-o&&(i=ql-o);const u=a/Math.pow(ld(i),h);let m=u*Math.sin(h*e),x=a-u*Math.cos(h*e);return m=.5*(m/Math.PI+.5),x=.5*(x/Math.PI+.5),{x:m,y:this.southernCenter?x:1-x,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:h}=this,a=h-i,u=Math.sign(a),m=Math.sign(o)*Math.sqrt(e*e+a*a);let x=Math.atan2(e,Math.abs(a))*u;a*o<0&&(x-=Math.PI*Math.sign(e)*u);const w=zt(nr(x/o)+this.center[0],-180,180),p=zt(nr(2*Math.atan(Math.pow(h/m,1/o))-ql),-ie,ie);return new L(w,this.southernCenter?-p:p)}}class h_ extends Ls{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:W(e),y:Y(i),z:0}}unproject(e,i){const o=Q(e),h=J(i);return new L(o,h)}}const u_=Ht(ie);class a0 extends Ls{project(e,i){const o=(i=Ht(i))*i,h=o*o;return{x:.5*((e=Ht(e))*(.8707-.131979*o+h*(h*(.003971*o-.001529*h)-.013791))/Math.PI+.5),y:1-.5*(i*(1.007226+o*(.015085+h*(.028874*o-.044475-.005916*h)))/Math.PI+1),z:0}}unproject(e,i){e=(2*e-.5)*Math.PI;let o=i=(2*(1-i)-1)*Math.PI,h=25,a=0,u=o*o;do{u=o*o;const w=u*u;a=(o*(1.007226+u*(.015085+w*(.028874*u-.044475-.005916*w)))-i)/(1.007226+u*(.045255+w*(.259866*u-.311325-.005916*11*w))),o=zt(o-a,-u_,u_)}while(Math.abs(a)>1e-6&&--h>0);u=o*o;const m=zt(nr(e/(.8707+u*(u*(u*u*u*(.003971-.001529*u)-.013791)-.131979))),-180,180),x=nr(o);return new L(m,x)}}const d_=Ht(ie);class l0 extends Ls{project(e,i){i=Ht(i),e=Ht(e);const o=Math.cos(i),h=2/Math.PI,a=Math.acos(o*Math.cos(e/2)),u=Math.sin(a)/a,m=.5*(e*h+2*o*Math.sin(e/2)/u)||0,x=.5*(i+Math.sin(i)/u)||0;return{x:.5*(m/Math.PI+.5),y:1-.5*(x/Math.PI+1),z:0}}unproject(e,i){let o=e=(2*e-.5)*Math.PI,h=i=(2*(1-i)-1)*Math.PI,a=25;const u=1e-6;let m=0,x=0;do{const w=Math.cos(h),p=Math.sin(h),g=2*p*w,b=p*p,y=w*w,v=Math.cos(o/2),M=Math.sin(o/2),E=2*v*M,C=M*M,R=1-y*v*v,k=R?1/R:0,P=R?Math.acos(w*v)*Math.sqrt(1/R):0,O=.5*(2*P*w*M+2*o/Math.PI)-e,B=.5*(P*p+h)-i,G=.5*k*(y*C+P*w*v*b)+1/Math.PI,H=k*(E*g/4-P*p*M),X=.125*k*(g*M-P*p*y*E),Z=.5*k*(b*v+P*C*w)+.5,te=H*X-Z*G;m=(B*H-O*Z)/te,x=(O*X-B*G)/te,o=zt(o-m,-Math.PI,Math.PI),h=zt(h-x,-d_,d_)}while((Math.abs(m)>u||Math.abs(x)>u)&&--a>0);return new L(nr(o),nr(h))}}class p_ extends Ls{constructor(e){super(e),this.center=e.center||[0,0],this.parallels=e.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Ht(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:h}=this;return{x:Ht(e)*h*o+.5,y:-Math.sin(Ht(i))/h*o+.5,z:0}}unproject(e,i){const{scale:o,cosPhi:h}=this,a=-(i-.5)/o,u=zt(nr((e-.5)/o)/h,-180,180),m=Math.asin(zt(a*h,-1,1)),x=zt(nr(m),-ie,ie);return new L(u,x)}}class c0 extends h_{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 h=oh(e,i,o),a=Gu(lo(o));return ue.vec3.transformMat4(h,h,a),{x:h[0],y:h[1],z:h[2]}}locationPoint(e,i){const o=I(i.lat,i.lng),h=ue.vec3.normalize([],o),a=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(i),e._centerAltitude):e._centerAltitude,u=$(1,0)*We*a;ue.vec3.scaleAndAdd(o,o,h,u);const m=ue.mat4.identity(new Float64Array(16));return ue.mat4.multiply(m,e.pixelMatrix,e.globeMatrix),ue.vec3.transformMat4(o,o,m),new He(o[0],o[1])}pixelsPerMeter(e,i){return $(1,0)*i}pixelSpaceConversion(e,i,o){const h=$(1,e)*i,a=mt($(1,45)*i,h,o);return this.pixelsPerMeter(e,i)/a}createTileMatrix(e,i,o){const h=sp(lo(o.canonical));return ue.mat4.multiply(new Float64Array(16),e.globeMatrix,h)}createInversionMatrix(e,i){const{center:o}=e,h=Gu(lo(i));return ue.mat4.rotateY(h,h,Ht(o.lng)),ue.mat4.rotateX(h,h,Ht(o.lat)),ue.mat4.scale(h,h,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(h)}pointCoordinate(e,i,o,h){return Vu(e,i,o,!0)||new ye(0,0)}pointCoordinate3D(e,i,o){const h=this.pointCoordinate(e,i,o,0);return[h.x,h.y,h.z]}isPointAboveHorizon(e,i){return!Vu(e,i.x,i.y,!1)}farthestPixelDistance(e){const i=function(h,a){const u=h.cameraToCenterDistance,m=h._centerAltitude*a,x=h._camera,w=h._camera.forward(),p=ue.vec3.add([],ue.vec3.scale([],w,-u),[0,0,m]),g=h.worldSize/(2*Math.PI),b=[0,0,-g],y=h.width/h.height,v=Math.tan(h.fovAboveCenter),M=ue.vec3.scale([],x.up(),v),E=ue.vec3.scale([],x.right(),v*y),C=ue.vec3.normalize([],ue.vec3.add([],ue.vec3.add([],w,M),E)),R=[];let k;if(new Nn(p,C).closestPointOnSphere(b,g,R)){const P=ue.vec3.add([],R,b),O=ue.vec3.sub([],P,p);k=Math.cos(h.fovAboveCenter)*ue.vec3.length(O)}else{const P=ue.vec3.sub([],p,b),O=ue.vec3.sub([],b,p);ue.vec3.normalize(O,O);const B=ue.vec3.length(P)-g;k=Math.sqrt(B*(B+2*g));const G=Math.acos(k/(g+B))-Math.acos(ue.vec3.dot(w,O));k*=Math.cos(G)}return 1.01*k}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),o=Cs(e.zoom);if(o>0){const h=l_(e,$(1,e.center.lat)*e.worldSize),a=e.worldSize/(2*Math.PI),u=Math.max(e.width,e.height)/e.worldSize*Math.PI;return mt(i,h+a*(1-Math.cos(u)),Math.pow(o,10))}return i}upVector(e,i,o){return oh(i,o,e,1)}upVectorScale(e){return{metersToTile:Lo(ju(lo(e)))}}}function f_(n){const e=n.parallels,i=!!e&&Math.abs(e[0]+e[1])<.01;switch(n.name){case"mercator":return new h_(n);case"equirectangular":return new o0(n);case"naturalEarth":return new a0(n);case"equalEarth":return new n0(n);case"winkelTripel":return new l0(n);case"albers":return i?new p_(n):new r0(n);case"lambertConformalConic":return i?new p_(n):new s0(n);case"globe":return new c0(n)}throw new Error(`Invalid projection name: ${n.name}`)}const h0=Nl.VectorTileFeature.types,u0=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function cd(n,e,i,o,h,a,u,m,x,w,p,g,b){const y=m?Math.min(Rs,Math.round(m[0])):0,v=m?Math.min(Rs,Math.round(m[1])):0;n.emplaceBack(e,i,Math.round(32*o),Math.round(32*h),a,u,(y<<1)+(x?1:0),v,16*w,16*p,256*g,256*b)}function hd(n,e,i){n.emplaceBack(e,i)}function ud(n,e,i,o,h,a,u){n.emplaceBack(e,i,o,h,a,u)}function dd(n,e,i,o,h){n.emplaceBack(e,i,o,h),n.emplaceBack(e,i,o,h),n.emplaceBack(e,i,o,h),n.emplaceBack(e,i,o,h)}function d0(n){for(const e of n.sections)if(jd(e.text))return!0;return!1}class Bp{constructor(e){this.layoutVertexArray=new Zc,this.indexArray=new cr,this.programConfigurations=e,this.segments=new Fi,this.dynamicLayoutVertexArray=new kn,this.opacityVertexArray=new Hc,this.placedSymbolArray=new Jc,this.iconTransitioningVertexArray=new oo,this.globeExtVertexArray=new $c,this.zOffsetVertexArray=new Ts}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length&&0===this.iconTransitioningVertexArray.length}upload(e,i,o,h,a){this.isEmpty()||(o&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Cy.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,i),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,zy.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,u0,!0),this.iconTransitioningVertexArray.length>0&&(this.iconTransitioningVertexBuffer=e.createVertexBuffer(this.iconTransitioningVertexArray,Ry.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,Py.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||a)&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,Dy.members,!0)),this.opacityVertexBuffer.itemSize=1),(o||h)&&this.programConfigurations.upload(e))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy())}}rt(Bp,"SymbolBuffers");class Fp{constructor(e,i,o){this.layoutVertexArray=new e,this.layoutAttributes=i,this.indexArray=new o,this.segments=new Fi,this.collisionVertexArray=new ws,this.collisionVertexArrayExt=new kn}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,Ly.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())}}rt(Fp,"CollisionBuffers");class pd{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.lut=e.lut,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(u=>u.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=ue.mat4.identity([]),this.placementViewportMatrix=ue.mat4.identity([]);const i=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Ep(this.zoom,i["text-size"]),this.iconSizeData=Ep(this.zoom,i["icon-size"]);const o=this.layers[0].layout,h=o.get("symbol-sort-key"),a=o.get("symbol-z-order");this.canOverlap=o.get("text-allow-overlap")||o.get("icon-allow-overlap")||o.get("text-ignore-placement")||o.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==a&&void 0!==h.constantOr(1),this.sortFeaturesByY=("viewport-y"===a||"auto"===a&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=o.get("text-writing-mode").map(u=>hn[u]),this.stateDependentLayerIds=this.layers.filter(u=>u.isStateDependent()).map(u=>u.id),this.sourceID=e.sourceID,this.projection=e.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=o.get("symbol-z-elevate"),this.activeReplacements=[],this.replacementUpdateTime=0}createArrays(){this.text=new Bp(new so(this.layers,{zoom:this.zoom,lut:this.lut},e=>e.startsWith("text")||e.startsWith("symbol"))),this.icon=new Bp(new so(this.layers,{zoom:this.zoom,lut:this.lut},e=>e.startsWith("icon")||e.startsWith("symbol"))),this.glyphOffsetArray=new zu,this.lineVertexArray=new Ll,this.symbolInstances=new Qc}calculateGlyphDependencies(e,i,o,h,a){for(let u=0;u0)&&("constant"!==x.value.kind||x.value.value.length>0),b="constant"!==p.value.kind||!!p.value.value||Object.keys(p.parameters).length>0,y=u.get("symbol-sort-key");if(this.features=[],!g&&!b)return;const v=i.iconDependencies,M=i.glyphDependencies,E=i.availableImages,C=new Bi(this.zoom);for(const{feature:R,id:k,index:P,sourceLayerIndex:O}of e){const B=a._featureFilter.needGeometry,G=Ge(R,B);if(!a._featureFilter.filter(C,G,o))continue;if(B||(G.geometry=Ue(R,o,h)),m&&1!==R.type&&o.z<=5){const te=G.geometry,K=.98078528056,re=(he,pe)=>{const fe=oh(he.x,he.y,o,1),me=oh(pe.x,pe.y,o,1);return ue.vec3.dot(fe,me)=0;for(const re of H.sections)if(re.image)v[re.image.namePrimary]=!0;else{const he=yl(H.toString()),pe=re.fontStack||te,fe=M[pe]=M[pe]||{};this.calculateGlyphDependencies(re.text,fe,K,this.allowVerticalPlacement,he)}}}"line"===u.get("symbol-placement")&&(this.features=function(R){const k={},P={},O=[];let B=0;function G(te){O.push(R[te]),B++}function H(te,K,re){const he=P[te];return delete P[te],P[K]=he,O[he].geometry[0].pop(),O[he].geometry[0]=O[he].geometry[0].concat(re[0]),he}function X(te,K,re){const he=k[K];return delete k[K],k[te]=he,O[he].geometry[0].shift(),O[he].geometry[0]=re[0].concat(O[he].geometry[0]),he}function Z(te,K,re){const he=re?K[0][K[0].length-1]:K[0][0];return`${te}:${he.x}:${he.y}`}for(let te=0;tete.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((R,k)=>R.sortKey-k.sortKey)}update(e,i,o,h,a){const u=0!==Object.keys(e).length;if(u&&!this.stateDependentLayers.length)return;const m=u?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(e,i,m,o,h,a),this.icon.programConfigurations.updatePaintArrays(e,i,m,o,h,a)}updateZOffset(){const e=(a,u,m)=>{o+=u,o>a.length&&a.resize(o);for(let x=-u;x<0;x++)a.emplace(x+o,m)},i=(a,u,m)=>{h+=u,h>a.length&&a.resize(h);for(let x=-u;x<0;x++)a.emplace(x+h,m)};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let o=0,h=0;for(let a=0;a0;if((m>0||x>0)&&(e(this.text.zOffsetVertexArray,m,p),e(this.text.zOffsetVertexArray,x,p)),g){const{placedIconSymbolIndex:b,verticalPlacedIconSymbolIndex:y}=u;b>=0&&i(this.icon.zOffsetVertexArray,w,p),y>=0&&i(this.icon.zOffsetVertexArray,u.numVerticalIconVertices,p)}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray)}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=f_(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,i){const o=this.lineVertexArray.length;if(void 0!==e.segment)for(const{x:h,y:a}of i)this.lineVertexArray.emplaceBack(h,a);return{lineStartIndex:o,lineLength:this.lineVertexArray.length-o}}addSymbols(e,i,o,h,a,u,m,x,w,p,g,b,y,v,M,E){const C=e.indexArray,R=e.layoutVertexArray,k=e.globeExtVertexArray,P=e.segments.prepareSegment(4*i.length,R,C,this.canOverlap?u.sortKey:void 0),O=this.glyphOffsetArray.length,B=P.vertexLength,G=this.allowVerticalPlacement&&m===hn.vertical?Math.PI/2:0,H=u.text&&u.text.sections;for(let Z=0;Z=0?i.rightJustifiedTextSymbolIndex:i.centerJustifiedTextSymbolIndex>=0?i.centerJustifiedTextSymbolIndex:i.leftJustifiedTextSymbolIndex>=0?i.leftJustifiedTextSymbolIndex:i.verticalPlacedTextSymbolIndex>=0?i.verticalPlacedTextSymbolIndex:h),u=ed(this.textSizeData,e,a)/24;return this.tilePixelRatio*u}getSymbolInstanceIconSize(e,i,o){const h=this.icon.placedSymbolArray.get(o),a=ed(this.iconSizeData,e,h);return this.tilePixelRatio*a}_commitDebugCollisionVertexUpdate(e,i,o,h){e.emplaceBack(i,-o,-o,h),e.emplaceBack(i,o,-o,h),e.emplaceBack(i,o,o,h),e.emplaceBack(i,-o,o,h)}_updateTextDebugCollisionBoxes(e,i,o,h,a,u){for(let m=h;m0}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),h=o.vertexStartIndex+4*o.numGlyphs;for(let a=o.vertexStartIndex;ah[m]-h[x]||a[x]-a[m]),u}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let e=0;ethis.symbolInstances.get(i).zOffset-this.symbolInstances.get(e).zOffset)}addToSortKeyRanges(e,i){const o=this.sortKeyRanges[this.sortKeyRanges.length-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&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const i of this.symbolInstanceIndexes){const o=this.symbolInstances.get(i);this.featureSortOrder.push(o.featureIndex);const{rightJustifiedTextSymbolIndex:h,centerJustifiedTextSymbolIndex:a,leftJustifiedTextSymbolIndex:u,verticalPlacedTextSymbolIndex:m,placedIconSymbolIndex:x,verticalPlacedIconSymbolIndex:w}=o;h>=0&&this.addIndicesForPlacedSymbol(this.text,h),a>=0&&a!==h&&this.addIndicesForPlacedSymbol(this.text,a),u>=0&&u!==a&&u!==h&&this.addIndicesForPlacedSymbol(this.text,u),m>=0&&this.addIndicesForPlacedSymbol(this.text,m),x>=0&&this.addIndicesForPlacedSymbol(this.icon,x),w>=0&&this.addIndicesForPlacedSymbol(this.icon,w)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let m_,__,Np;rt(pd,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),pd.addDynamicAttributes=dd;class g_{constructor(e){this.type=e.property.overrides?e.property.overrides.runtimeType:nn,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}}rt(g_,"FormatSectionOverride",{omit:["defaultValue"]});const Vp=()=>Np||(Np={layout:m_||(m_=new Ci({"symbol-placement":new qe(be.layout_symbol["symbol-placement"]),"symbol-spacing":new qe(be.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new qe(be.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new ct(be.layout_symbol["symbol-sort-key"]),"symbol-z-order":new qe(be.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new qe(be.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new qe(be.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new qe(be.layout_symbol["icon-ignore-placement"]),"icon-optional":new qe(be.layout_symbol["icon-optional"]),"icon-rotation-alignment":new qe(be.layout_symbol["icon-rotation-alignment"]),"icon-size":new ct(be.layout_symbol["icon-size"]),"icon-text-fit":new ct(be.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new ct(be.layout_symbol["icon-text-fit-padding"]),"icon-image":new ct(be.layout_symbol["icon-image"]),"icon-rotate":new ct(be.layout_symbol["icon-rotate"]),"icon-padding":new qe(be.layout_symbol["icon-padding"]),"icon-keep-upright":new qe(be.layout_symbol["icon-keep-upright"]),"icon-offset":new ct(be.layout_symbol["icon-offset"]),"icon-anchor":new ct(be.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new qe(be.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new qe(be.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new qe(be.layout_symbol["text-rotation-alignment"]),"text-field":new ct(be.layout_symbol["text-field"]),"text-font":new ct(be.layout_symbol["text-font"]),"text-size":new ct(be.layout_symbol["text-size"]),"text-max-width":new ct(be.layout_symbol["text-max-width"]),"text-line-height":new ct(be.layout_symbol["text-line-height"]),"text-letter-spacing":new ct(be.layout_symbol["text-letter-spacing"]),"text-justify":new ct(be.layout_symbol["text-justify"]),"text-radial-offset":new ct(be.layout_symbol["text-radial-offset"]),"text-variable-anchor":new qe(be.layout_symbol["text-variable-anchor"]),"text-anchor":new ct(be.layout_symbol["text-anchor"]),"text-max-angle":new qe(be.layout_symbol["text-max-angle"]),"text-writing-mode":new qe(be.layout_symbol["text-writing-mode"]),"text-rotate":new ct(be.layout_symbol["text-rotate"]),"text-padding":new qe(be.layout_symbol["text-padding"]),"text-keep-upright":new qe(be.layout_symbol["text-keep-upright"]),"text-transform":new ct(be.layout_symbol["text-transform"]),"text-offset":new ct(be.layout_symbol["text-offset"]),"text-allow-overlap":new qe(be.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new qe(be.layout_symbol["text-ignore-placement"]),"text-optional":new qe(be.layout_symbol["text-optional"]),visibility:new qe(be.layout_symbol.visibility)})),paint:__||(__=new Ci({"icon-opacity":new ct(be.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new ct(be.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new ct(be.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new ct(be.paint_symbol["text-emissive-strength"]),"icon-color":new ct(be.paint_symbol["icon-color"]),"icon-halo-color":new ct(be.paint_symbol["icon-halo-color"]),"icon-halo-width":new ct(be.paint_symbol["icon-halo-width"]),"icon-halo-blur":new ct(be.paint_symbol["icon-halo-blur"]),"icon-translate":new qe(be.paint_symbol["icon-translate"]),"icon-translate-anchor":new qe(be.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new ct(be.paint_symbol["icon-image-cross-fade"]),"text-opacity":new ct(be.paint_symbol["text-opacity"]),"text-occlusion-opacity":new ct(be.paint_symbol["text-occlusion-opacity"]),"text-color":new ct(be.paint_symbol["text-color"],{runtimeType:Ir,getOverride:n=>n.textColor,hasOverride:n=>!!n.textColor}),"text-halo-color":new ct(be.paint_symbol["text-halo-color"]),"text-halo-width":new ct(be.paint_symbol["text-halo-width"]),"text-halo-blur":new ct(be.paint_symbol["text-halo-blur"]),"text-translate":new qe(be.paint_symbol["text-translate"]),"text-translate-anchor":new qe(be.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new qe(be.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new qe(be.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new qe(be.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new qe(be.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new ct(be.paint_symbol["symbol-z-offset"]),"symbol-elevation-reference":new qe(be.paint_symbol["symbol-elevation-reference"])}))},Np);class fd extends _r{constructor(e,i,o,h){super(e,Vp(),i,o,h),this._colorAdjustmentMatrix=ue.mat4.identity([]),this.hasInitialOcclusionOpacityProperties=void 0!==e.paint&&("icon-occlusion-opacity"in e.paint||"text-occlusion-opacity"in e.paint)}recalculate(e,i){super.recalculate(e,i),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const o=this.layout.get("text-writing-mode");if(o){const h=[];for(const a of o)h.indexOf(a)<0&&h.push(a);this.layout._values["text-writing-mode"]=h}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getColorAdjustmentMatrix(e,i,o,h){return this._saturation===e&&this._contrast===i&&this._brightnessMin===o&&this._brightnessMax===h||(this._colorAdjustmentMatrix=function(a,u,m,x){a=ee(a),u=q(u);const w=ue.mat4.create(),p=a/3,g=1-2*p,b=[g,p,p,0,p,g,p,0,p,p,g,0,0,0,0,1],y=.5-.5*u,v=x-m;return ue.mat4.multiply(w,[v,0,0,0,0,v,0,0,0,0,v,0,m,m,m,1],[u,0,0,0,0,u,0,0,0,0,u,0,y,y,y,1]),ue.mat4.multiply(w,w,b),w}(e,i,o,h),this._saturation=e,this._contrast=i,this._brightnessMin=o,this._brightnessMax=h),this._colorAdjustmentMatrix}getValueAndResolveTokens(e,i,o,h){const a=this.layout.get(e).evaluate(i,{},o,h),u=this._unevaluatedLayout._values[e];return u.isDataDriven()||fl(u.value)||!a?a:(m=i.properties,a.replace(/{([^{}]+)}/g,(w,p)=>p in m?String(m[p]):""));var m}createBucket(e){return new pd(e)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const e of Vp().paint.overridableProperties){if(!fd.hasPaintOverride(this.layout,e))continue;const i=this.paint.get(e),o=new g_(i),h=new pl(o,i.property.specification,this.scope,this.options);let a=null;a="constant"===i.value.kind||"source"===i.value.kind?new Rc("source",h):new gn("composite",h,i.value.zoomStops,i.value._interpolationType),this.paint._values[e]=new gs(i.property,a,i.parameters)}}_handleOverridablePaintPropertyUpdate(e,i,o){return!(!this.layout||i.isDataDriven()||o.isDataDriven())&&fd.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,i){const o=e.get("text-field"),h=Vp().paint.properties[i];let a=!1;const u=m=>{for(const x of m)if(h.overrides&&h.overrides.hasOverride(x))return void(a=!0)};if("constant"===o.value.kind&&o.value.value instanceof mr)u(o.value.value.sections);else if("source"===o.value.kind){const m=w=>{a||(w instanceof on&&$i(w.value)===Ko?u(w.value.sections):w instanceof ts?u(w.sections):w.eachChild(m))},x=o.value;x._styleExpression&&m(x._styleExpression.expression)}return a}getProgramIds(){return["symbol"]}getDefaultProgramParams(e,i,o){return{config:new Ro(this,{zoom:i,lut:o}),overrideFog:!1}}}let y_,x_,v_,b_;var Up=ti([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);function jp(n){switch(n){case WebGL2RenderingContext.RGBA8: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 Gp(n){switch(n){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.UNSIGNED_BYTE;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}}class qp{constructor(e,i,o,h){this.context=e,this.format=o,this.useMipmap=h&&h.useMipmap,this.texture=e.gl.createTexture(),this.update(i,{premultiply:h&&h.premultiply})}update(e,i){const o=e&&e instanceof HTMLVideoElement&&0===e.width?e.videoWidth:e.width,h=e&&e instanceof HTMLVideoElement&&0===e.height?e.videoHeight:e.height,{context:a}=this,{gl:u}=a,{x:m,y:x}=i&&i.position?i.position:{x:0,y:0},w=Math.max(m+o,this.size?this.size[0]:0),p=Math.max(x+h,this.size?this.size[1]:0);!this.size||this.size[0]===w&&this.size[1]===p||(u.bindTexture(u.TEXTURE_2D,null),u.deleteTexture(this.texture),this.texture=u.createTexture(),this.size=null),u.bindTexture(u.TEXTURE_2D,this.texture),a.pixelStoreUnpackFlipY.set(!1),a.pixelStoreUnpack.set(1),a.pixelStoreUnpackPremultiplyAlpha.set(this.format===u.RGBA8&&(!i||!1!==i.premultiply));const g=e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||ImageBitmap&&e instanceof ImageBitmap;if(!this.size&&w>0&&p>0){const b=this.useMipmap?Math.floor(Math.log2(Math.max(w,p)))+1:1;u.texStorage2D(u.TEXTURE_2D,b,this.format,w,p),this.size=[w,p]}if(this.size)if(g)u.texSubImage2D(u.TEXTURE_2D,0,m,x,jp(this.format),Gp(this.format),e);else{const b=e.data;b&&u.texSubImage2D(u.TEXTURE_2D,0,m,x,o,h,jp(this.format),Gp(this.format),b)}this.useMipmap&&u.generateMipmap(u.TEXTURE_2D)}bind(e,i,o=!1){const{context:h}=this,{gl:a}=h;a.bindTexture(a.TEXTURE_2D,this.texture),e!==this.minFilter&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,e),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,this.useMipmap&&!o?e===a.NEAREST?a.NEAREST_MIPMAP_NEAREST:a.LINEAR_MIPMAP_LINEAR:e),this.minFilter=e),i!==this.wrapS&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,i),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,i),this.wrapS=i)}bindExtraParam(e,i,o,h){const{context:a}=this,{gl:u}=a;u.bindTexture(u.TEXTURE_2D,this.texture),i!==this.magFilter&&(u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MAG_FILTER,i),this.magFilter=i),e!==this.minFilter&&(u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MIN_FILTER,this.useMipmap?e===u.NEAREST?u.NEAREST_MIPMAP_NEAREST:u.LINEAR_MIPMAP_LINEAR:e),this.minFilter=e),o!==this.wrapS&&(u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_S,o),this.wrapS=o),h!==this.wrapT&&(u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_T,h),this.wrapT=h)}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}}class md{constructor(e,i){this.context=e,this.texture=i}bind(e,i){const{context:o}=this,{gl:h}=o;h.bindTexture(h.TEXTURE_2D,this.texture),e!==this.minFilter&&(h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MAG_FILTER,e),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MIN_FILTER,e),this.minFilter=e),i!==this.wrapS&&(h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_S,i),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_T,i),this.wrapS=i)}}function _d(n,e,i,o,h,a,u,m){const x=[n,e,1,i,o,1,h,a,1],w=[u,m,1],p=ue.mat3.adjoint([],x),[g,b,y]=ue.vec3.transformMat3(w,w,p);return ue.mat3.multiply(x,x,[g,0,0,0,b,0,0,0,y])}function w_(n,e,i,o,h,a,u,m){const x=function(w,p,g,b,y,v,M,E){const C=_d(0,0,1,0,1,1,0,1),R=_d(w,p,g,b,y,v,M,E),k=ue.mat3.adjoint([],C);return ue.mat3.multiply(R,R,k)}(n,e,i,o,h,a,u,m);return[x[2]/x[8]/We,x[5]/x[8]/We]}function gd(n){return[n[0],Math.min(Math.max(n[1],-ie),ie)]}class T_ extends Xo{constructor(e,i,o,h){super(),this.id=e,this.dispatcher=o,this.coordinates=i.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(h),this.options=i,this._dirty=!1}load(e,i){if(this._loaded=i||!1,this.fire(new Xn("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return e&&(this.coordinates=e),this._loaded=!0,void this._finishLoading();this._imageRequest=pn(this.map._requestManager.transformRequest(this.url,$o.Image),(o,h)=>{this._imageRequest=null,this._loaded=!0,o?this.fire(new Ks(o)):h&&(this.image=h instanceof HTMLImageElement?Qe.getImageData(h):h,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,e&&(this.coordinates=e),this._finishLoading())})}loaded(){return this._loaded}updateImage(e){return e.url?(this._imageRequest&&e.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=e.url,this.load(e.coordinates,this._loaded),this):this}setTexture(e){if(!(e.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new md(this.map.painter.context,e.handle),this.width=e.dimensions[0],this.height=e.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new Xn("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(e){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof md||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy())}setCoordinates(e){if(this.coordinates=e,this._boundsArray=void 0,this._unsupportedCoords=!1,!e.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let i=e[0][1],o=e[0][1];for(const a of e)a[1]>o&&(o=a[1]),a[1]ie?this.onNorthPole=!0:h<-ie&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const a=e.map(ye.fromLngLat);this.tileID=function(u){let m=1/0,x=1/0,w=-1/0,p=-1/0;for(const M of u)m=Math.min(m,M.x),x=Math.min(x,M.y),w=Math.max(w,M.x),p=Math.max(p,M.y);const g=Math.max(w-m,p-x),b=Math.max(0,Math.floor(-Math.log(g)/Math.LN2)),y=Math.pow(2,b);let v=Math.floor((m+w)/2*y);return v>1&&(v-=1),new rr(b,v,Math.floor((x+p)/2*y))}(a),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new Xn("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(e){for(const C in this.tiles){const R=this.tiles[C];"loaded"!==R.state&&(R.state="loaded",R.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const i=bh(new rr(0,0,0),this.map.transform.projection),o=[i.projection.project(this.coordinates[0][0],this.coordinates[0][1]),i.projection.project(this.coordinates[1][0],this.coordinates[1][1]),i.projection.project(this.coordinates[2][0],this.coordinates[2][1]),i.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(C){const R=C[1].x-C[0].x,k=C[1].y-C[0].y,P=C[2].x-C[1].x,O=C[2].y-C[1].y,B=C[3].x-C[2].x,G=C[3].y-C[2].y,H=C[0].x-C[3].x,X=C[0].y-C[3].y,Z=R*O-P*k,te=P*G-B*O,K=B*X-H*G,re=H*k-R*X;return Z>0&&te>0&&K>0&&re>0||Z<0&&te<0&&K<0&&re<0}(o))return console.warn("Image source coordinates are defining non-convex area in the Mercator projection"),void(this._unsupportedCoords=!0);const h=bh(this.tileID,this.map.transform.projection),[a,u,m,x]=this.coordinates.map(C=>{const R=h.projection.project(C[0],C[1]);return c_(h,R)._round()});this.perspectiveTransform=w_(a.x,a.y,u.x,u.y,m.x,m.y,x.x,x.y);const w=this._boundsArray=new ro;w.emplaceBack(a.x,a.y,0,0),w.emplaceBack(u.x,u.y,We,0),w.emplaceBack(x.x,x.y,0,We),w.emplaceBack(m.x,m.y,We,We),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=e.createVertexBuffer(w,Up.members),this.boundsSegments=Fi.simpleSegment(0,0,4,2);const p=[],g=[gd((b=this.coordinates)[0]),gd(b[1]),gd(b[2]),gd(b[3])];var b;const[y,v,M,E]=function(C){let R=C[0][0],k=R,P=C[0][1],O=P;for(let B=1;Bk&&(k=C[B][0]),C[B][1]O&&(O=C[B][1]);return[R,P,k-R,O-P]}(g);{const C=new ro,[R,k,P,O]=function(me){let we=me[0].x,ge=we,Pe=me[0].y,Oe=Pe;for(let Ee=1;Eege&&(ge=me[Ee].x),me[Ee].yOe&&(Oe=me[Ee].y);return[we,Pe,ge-we,Oe-Pe]}(o),B=me=>[(me.x-R)/P,(me.y-k)/O],[G,H,X,Z]=o.map(B),te=function(me,we,ge,Pe,Oe,Ee,Ye,$e){const je=_d(0,0,1,0,1,1,0,1),Fe=_d(me,we,ge,Pe,Oe,Ee,Ye,$e),ut=ue.mat3.adjoint([],Fe);return ue.mat3.multiply(je,je,ut)}(G[0],G[1],H[0],H[1],X[0],X[1],Z[0],Z[1]);this.elevatedGlobePerspectiveTransform=w_(G[0],G[1],H[0],H[1],X[0],X[1],Z[0],Z[1]);const K=(me,we)=>{p.push(me.lng);const ge=Math.round((me.lng-y)/M*We),Pe=Math.round((me.lat-v)/E*We),Oe=B(we),Ee=ue.vec3.transformMat3([],[Oe[0],Oe[1],1],te),Ye=Math.round(Ee[0]/Ee[2]*We),$e=Math.round(Ee[1]/Ee[2]*We);C.emplaceBack(ge,Pe,Ye,$e)},re=o[3].x-o[0].x,he=o[3].y-o[0].y,pe=o[2].x-o[1].x,fe=o[2].y-o[1].y;for(let me=0;me<65;me++){const we=me/64,ge=[o[0].x+we*re,o[0].y+we*he],Pe=[o[1].x+we*pe,o[1].y+we*fe],Oe=Pe[0]-ge[0],Ee=Pe[1]-ge[1];for(let Ye=0;Ye<65;Ye++){const $e=Ye/64,je={x:ge[0]+Oe*$e,y:ge[1]+Ee*$e,z:0};K(i.projection.unproject(je.x,je.y),je)}}this.elevatedGlobeVertexBuffer=e.createVertexBuffer(C,Up.members)}{this.maxLongitudeTriangleSize=0;let C=[],R=new cr;const k=(P,O,B)=>{R.emplaceBack(P,O,B);const G=p[P],H=p[O],X=p[B],Z=Math.min(Math.min(G,H),X),te=Math.max(Math.max(G,H),X)-Z;te>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=te),C.push(Z+te/2)};for(let P=0;P<64;P++)for(let O=0;O<64;O++){const B=65*P+O,G=B+1,H=B+65,X=H+1;k(B,H,G),k(G,H,X)}[C,R]=function(P,O){const B=Array.from({length:P.length},(X,Z)=>Z);B.sort((X,Z)=>P[X]-P[Z]);const G=[],H=new cr;for(let X=0;X{u.segments.push({vertexOffset:0,primitiveOffset:g,vertexLength:i.segments[0].vertexLength,primitiveLength:b,sortKey:void 0,vaos:{}})},x=.51*this.maxLongitudeTriangleSize;if(Math.abs(o[0]-h)<=x){const g=j(o,0,o.length,h+x);return g===o.length||m(g,Se(o,g+1,o.length,h+360-x)-g),u}h0?function(u,m,x){const w=(v,M,E)=>{const C=ue.vec3.length(v),R=ue.vec3.length(M),k=ko(v,M,E);return ue.vec3.scale(k,k,1/ue.vec3.length(k)*mt(C,R,E))},p=w([u[0],u[1],u[2]],[m[0],m[1],m[2]],x),g=w([u[4],u[5],u[6]],[m[4],m[5],m[6]],x),b=w([u[8],u[9],u[10]],[m[8],m[9],m[10]],x),y=ko([u[12],u[13],u[14]],[m[12],m[13],m[14]],x);return[p[0],p[1],p[2],0,g[0],g[1],g[2],0,b[0],b[1],b[2],0,y[0],y[1],y[2],1]}(h,function(u,m){const x=m.worldSize,w=$(1,0)*x*de(m.center.lat,m.zoom)/ap(x),p=$(1,m.center.lat)*x,g=ue.mat4.identity([]);return ue.mat4.rotateY(g,g,Ht(m.center.lng)),ue.mat4.rotateX(g,g,Ht(m.center.lat)),ue.mat4.translate(g,g,[0,0,t]),ue.mat4.scale(g,g,[w,w,w*p]),ue.mat4.translate(g,g,[m.point.x-.5*x,m.point.y-.5*x,0]),ue.mat4.multiply(g,g,u),ue.mat4.multiply(g,m.globeMatrix,g)}(n,e),o):h}function k_(n,e,i,o){const h=wi.projectAabbCorners(o,i);let a=Number.MAX_VALUE,u=-1;for(let w=0;wnew He(h[w][0],h[w][1]);let x;switch(u){case 0:case 6:x=[m(1),m(5),m(4),m(7),m(3),m(2),m(1)];break;case 1:case 7:x=[m(0),m(4),m(5),m(6),m(2),m(3),m(0)];break;case 3:case 5:x=[m(1),m(0),m(4),m(7),m(6),m(2),m(1)];break;default:x=[m(1),m(5),m(6),m(7),m(3),m(0),m(1)]}if(Ze(n,x))return a}const m0=ti([{name:"a_pos_3f",components:3,type:"Float32"}]),_0=ti([{name:"a_color_3f",components:3,type:"Float32"}]),g0=ti([{name:"a_color_4f",components:4,type:"Float32"}]),y0=ti([{name:"a_uv_2f",components:2,type:"Float32"}]),x0=ti([{name:"a_normal_3f",components:3,type:"Float32"}]),v0=ti([{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"}]),b0=ti([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]),O_={None:0,Model:1,Symbol:2,FillExtrusion:4,All:7};class vd{constructor(e,i,o,h){this.message=(e?`${e}: `:"")+o,h&&(this.identifier=h),null!=i&&i.__line__&&(this.line=i.__line__)}}function B_(n,e){const i=-1===n.indexOf("://");try{return new URL(n,i&&e?"http://example.com":void 0),!0}catch{return!1}}class F_{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 N_{constructor(){this.instancedDataArray=new wa,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class Wp{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.layers=e.layers,this.layerIds=this.layers.map(i=>i.fqid),this.projection=e.projection,this.index=e.index,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?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}updateFootprints(e,i){}populate(e,i,o,h){this.tileToMeter=ae(o);const a=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:u,id:m,index:x,sourceLayerIndex:w}of e){const p=m??(u.properties&&u.properties.hasOwnProperty("id")?u.properties.id:void 0),g=Ge(u,a);if(!this.layers[0]._featureFilter.filter(new Bi(this.zoom),g,o))continue;const b={id:p,sourceLayerIndex:w,index:x,geometry:a?g.geometry:Ue(u,o,h),properties:u.properties,type:u.type,patterns:{}},y=this.addFeature(b,b.geometry,g);y&&i.featureIndex.insert(u,b.geometry,x,w,this.index,this.instancesPerModel[y].instancedDataArray.length,256)}this.lookup=null}update(e,i,o,h){for(const a in this.instancesPerModel){const u=this.instancesPerModel[a];for(const m in e)u.idToFeaturesIndex.hasOwnProperty(m)&&(this.evaluate(u.features[u.idToFeaturesIndex[m]],e[m],u,!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 h of o.features){const a=this.layers[0],u=h.feature,m=this.canonical,x=a.paint.get("model-rotation").evaluate(u,{},m),w=a.paint.get("model-scale").evaluate(u,{},m),p=a.paint.get("model-translation").evaluate(u,{},m);ue.vec3.exactEquals(h.rotation,x)&&ue.vec3.exactEquals(h.scale,w)&&ue.vec3.exactEquals(h.translation,p)||(this.evaluate(h,h.featureStates,o,!0),e=!0)}}return e}updateReplacement(e,i,o,h){if(i.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=i.updateTime;const a=i.getReplacementRegionsForTile(e.toUnwrapped(),!0);if(vp(this.activeReplacements,a))return!1;this.activeReplacements=a;let u=!1;for(const m in this.instancesPerModel){const x=this.instancesPerModel[m],w=x.instancedDataArray;for(const p of x.features){const g=p.instancedDataOffset,b=p.instancedDataCount;for(let y=0;yWe;M=E?M-We:M;const C=Math.floor(M),R=w.float32[v+1];let k=!1;for(const P of this.activeReplacements)if(!em(P,o,O_.Model,h)&&!(P.min.x>C||C>P.max.x||P.min.y>R||R>P.max.y)&&(k=sm(om(C,R,e.canonical,P.footprintTileId.canonical),P.footprint),k))break;w.float32[v]=k?M+We:M,u=u||k!==E}}}return u}isEmpty(){for(const e in this.instancesPerModel)if(0!==this.instancesPerModel[e].instancedDataArray.length)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||0===o.instancedDataArray.length||(o.instancedDataBuffer?o.instancedDataBuffer.updateData(o.instancedDataArray):o.instancedDataBuffer=e.createVertexBuffer(o.instancedDataArray,v0.members,!0,void 0,this.instanceCount))}this.uploaded=!0}destroy(){for(const i in this.instancesPerModel){const o=this.instancesPerModel[i];0!==o.instancedDataArray.length&&o.instancedDataBuffer&&o.instancedDataBuffer.destroy()}const e=this.layers[0].modelManager;if(e&&this.modelUris)for(const i of this.modelUris)e.removeModel(i,"")}addFeature(e,i,o){const h=this.layers[0],a=h.layout.get("model-id").evaluate(o,{},this.canonical);if(!a)return Qt(`modelId is not evaluated for layer ${h.id} and it is not going to get rendered.`),a;B_(a,!1)&&(this.modelUris.includes(a)||this.modelUris.push(a)),this.instancesPerModel[a]||(this.instancesPerModel[a]=new N_);const u=this.instancesPerModel[a],m=u.instancedDataArray,x=new F_(o,m.length);for(const w of i)for(const p of w){if(p.x<0||p.x>=We||p.y<0||p.y>=We)continue;const g=(this.lookupDim-1)/We,b=this.lookupDim*(p.y*g|0)+p.x*g|0;if(this.lookup){if(0!==this.lookup[b])continue;this.lookup[b]=1}this.instanceCount++;const y=m.length;m.resize(y+1),u.instancesEvaluatedElevation.push(0),m.float32[16*y]=p.x,m.float32[16*y+1]=p.y}return x.instancedDataCount=u.instancedDataArray.length-x.instancedDataOffset,x.instancedDataCount>0&&(e.id&&(u.idToFeaturesIndex[e.id]=u.features.length),u.features.push(x),this.evaluate(x,{},u,!1)),a}getModelUris(){return this.modelUris}evaluate(e,i,o,h){const a=this.layers[0],u=e.feature,m=this.canonical,x=e.rotation=a.paint.get("model-rotation").evaluate(u,i,m),w=e.scale=a.paint.get("model-scale").evaluate(u,i,m),p=e.translation=a.paint.get("model-translation").evaluate(u,i,m),g=a.paint.get("model-color").evaluate(u,i,m);g.a=a.paint.get("model-color-mix-intensity").evaluate(u,i,m);const b=[];this.maxVerticalOffset10?this.tileToMeter:ae(m,k)),C[E+4]=p[0],C[E+5]=p[1],C[E+6]=p[2]+R,C[E+7]=b[0],C[E+8]=b[1],C[E+9]=b[2],C[E+10]=b[4],C[E+11]=b[5],C[E+12]=b[6],C[E+13]=b[8],C[E+14]=b[9],C[E+15]=b[10],o.instancesEvaluatedElevation[M]=p[2]}}}let V_,U_;rt(Wp,"ModelBucket",{omit:["layers"]}),rt(N_,"PerModelAttributes"),rt(F_,"ModelFeature");const Zl={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function j_(n,e,i,o,h,a,u,m,x,w=!1){const p=i.zoom,g=i.project(o),b=de(o.lat,p),y=1/b;ue.mat4.identity(n),ue.mat4.translate(n,n,[g.x+u[0]*y,g.y+u[1]*y,u[2]]);let v=1,M=1;const E=i.worldSize;if(w){if("mercator"===i.projection.name){let P=0;i.elevation&&(P=i.elevation.getAtPointOrZero(new ye(g.x/E,g.y/E),0));const O=ue.vec4.transformMat4([],[g.x,g.y,P,1],i.projMatrix)[3]/i.cameraToCenterDistance;v=O,M=O*de(i.center.lat,p)}else if("globe"===i.projection.name){const P=Hp(n,i),O=ue.mat4.multiply([],i.projMatrix,P),B=[0,0,0,1];ue.vec4.transformMat4(B,B,O);const G=B[3]/i.cameraToCenterDistance,H=Cs(p),X=i.projection.pixelsPerMeter(o.lat,E)*de(o.lat,p),Z=i.projection.pixelsPerMeter(i.center.lat,E)*de(i.center.lat,p);v=G/mt(X,oe(i.center.lat),H),M=G*b/X,v*=Z,M*=Z}}else v=y;ue.mat4.scale(n,n,[v,v,M]);const C=[...n],R=e.orientation,k=[];if(L_(k,[R[0]+h[0],R[1]+h[1],R[2]+h[2]],a),ue.mat4.multiply(n,C,k),m&&i.elevation){let P=0;const O=[];if(x&&i.elevation){P=function(H,X,Z,te,K){const re=X.elevation;if(!re)return 0;const he=wi.projectAabbCorners(Z,te),pe=$(1,K.lat)*X.worldSize,fe=function(ut,Xe){const it=[0,0,1],xt=[{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 Bt of xt){const It=ut[Bt.corners[0]],Ct=ut[Bt.corners[1]],Ut=ut[Bt.corners[2]],jt=[Ct[0]-It[0],Ct[1]-It[1],Xe*(Ct[2]-It[2])],xi=ue.vec3.cross(jt,jt,[Ut[0]-It[0],Ut[1]-It[1],Xe*(Ut[2]-It[2])]);ue.vec3.normalize(xi,xi),Bt.dotProductWithUp=ue.vec3.dot(xi,it)}return xt.sort((Bt,It)=>Bt.dotProductWithUp-It.dotProductWithUp),xt[0].corners}(he,pe),me=he[fe[0]],we=he[fe[1]],ge=he[fe[2]],Pe=he[fe[3]],Oe=re.getAtPointOrZero(new ye(me[0]/X.worldSize,me[1]/X.worldSize),0),Ee=re.getAtPointOrZero(new ye(we[0]/X.worldSize,we[1]/X.worldSize),0),Ye=re.getAtPointOrZero(new ye(ge[0]/X.worldSize,ge[1]/X.worldSize),0),$e=re.getAtPointOrZero(new ye(Pe[0]/X.worldSize,Pe[1]/X.worldSize),0),je=(Oe+$e)/2,Fe=(Ee+Ye)/2;return je>Fe?Ee=e.gl.NEAREST_MIPMAP_NEAREST}),n.uploaded=!0,n.image=null)}function w0(n,e,i){n.indexBuffer=e.createIndexBuffer(n.indexArray,!1,!0),n.vertexBuffer=e.createVertexBuffer(n.vertexArray,m0.members,!1,!0),n.normalArray&&(n.normalBuffer=e.createVertexBuffer(n.normalArray,x0.members,!1,!0)),n.texcoordArray&&(n.texcoordBuffer=e.createVertexBuffer(n.texcoordArray,y0.members,!1,!0)),n.colorArray&&(n.colorBuffer=e.createVertexBuffer(n.colorArray,(12===n.colorArray.bytesPerElement?_0:g0).members,!1,!0)),n.featureArray&&(n.pbrBuffer=e.createVertexBuffer(n.featureArray,b0.members,!0)),n.segments=Fi.simpleSegment(0,0,n.vertexArray.length,n.indexArray.length);const o=n.material;o.pbrMetallicRoughness.baseColorTexture&&Eh(o.pbrMetallicRoughness.baseColorTexture,e),o.pbrMetallicRoughness.metallicRoughnessTexture&&Eh(o.pbrMetallicRoughness.metallicRoughnessTexture,e),o.normalTexture&&Eh(o.normalTexture,e),o.occlusionTexture&&Eh(o.occlusionTexture,e,i),o.emissionTexture&&Eh(o.emissionTexture,e)}function Xp(n,e,i){if(n.meshes)for(const o of n.meshes)w0(o,e,i);if(n.children)for(const o of n.children)Xp(o,e,i)}function bd(n){if(n.meshes)for(const e of n.meshes)e.indexArray.destroy(),e.vertexArray.destroy(),e.colorArray&&e.colorArray.destroy(),e.normalArray&&e.normalArray.destroy(),e.texcoordArray&&e.texcoordArray.destroy(),e.featureArray&&e.featureArray.destroy();if(n.children)for(const e of n.children)bd(e)}function Yp(n){if(n.meshes)for(const i of n.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((e=i.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()));var e;if(n.children)for(const i of n.children)Yp(i)}class $l{constructor(e,i,o){this._demTile=e,this._dem=this._demTile.dem,this._scale=i,this._offset=o}static create(e,i,o){const h=o||e.findDEMTileFor(i);if(!h||!h.dem)return;const a=h.dem,u=h.tileID,m=1<=B)continue;const me=Kp[fe],we=Math.abs(me);we>te&&(Z=me,te=we,K=pe,re=he)}if(te>.1){const he=1-(B+.5*Math.abs(K*re))/v;let pe=i._dem.get(H,G)+Z*he;const fe=i._dem.get(H+K,G+re),me=i._dem.get(H-K,G-re,!0);(pe-fe)*(pe-me)>0&&(pe=(fe+me)/2),Kp[X]=i._dem.set(H,G,pe),Pa[X]=B}}}}}m&&(i._demTile.needsDEMTextureUpload=!0,i._dem._timestamp=Qe.now())}getNodesInfo(){return this.nodesInfo}destroy(){const e=this.getNodesInfo();for(const i of e)bd(i.node),Yp(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()),h=this.getNodesInfo();for(let a=0;am.footprint===u.footprint)}}getHeightAtTileCoord(e,i){const o=this.getNodesInfo(),h=[],a=[0,0,0],u=ue.mat4.identity([]);for(let m=0;mp.max[0]||i>p.max[1])continue;if(!0===x.node.hidden)return{height:1/0,maxHeight:x.feature.properties.height,hidden:!1,verticalScale:x.evaluatedScale[2]};ue.mat4.invert(u,x.node.matrix),a[0]=e,a[1]=i,ue.vec3.transformMat4(a,a,u);const g=(a[0]-w.aabb.min[0])/(w.aabb.max[0]-w.aabb.min[0])*64|0,b=64*Math.min(63,(a[1]-w.aabb.min[1])/(w.aabb.max[1]-w.aabb.min[1])*64|0)+Math.min(63,g),y=w.heightmap[b];if(!(y<0&&x.node.footprint))return x.hiddenByReplacement?void 0:{height:y,maxHeight:x.feature.properties.height,hidden:!1,verticalScale:x.evaluatedScale[2]};if(x.node.footprint.grid.query(new He(e,i),new He(e,i),h),h.length>0)return{height:void 0,maxHeight:x.feature.properties.height,hidden:x.hiddenByReplacement,verticalScale:x.evaluatedScale[2]}}}}function Ah(n,e){return!n.isLightConstant&&e}function T0(n,e,i,o,h,a,u,m){let x=(61440&e|(61440&e)>>4)>>8,w=(3840&e|(3840&e)>>4)>>4,p=240&e|(240&e)>>4;i[3]>0&&(x=mt(x,255*i[0],i[3]),w=mt(w,255*i[1],i[3]),p=mt(p,255*i[2],i[3]));const g=x<<8|w,b=p<<8|Math.floor(255*o[3]),y=function(B){const G=zt(B,0,2);return Math.min(Math.round(.5*G*255),255)}(o[2])<<8|15*o[0]<<4|15*o[1],v=zt(h[0],0,1),M=zt(h[1],0,1),E=zt(h[2],0,1),C=zt(h[3],0,1);let R,k,P,O;if(v!==M&&u!==a&&M!==v){const B=u-a;k=1/(B*(M-v)),P=-(a+B*v)/(B*(M-v));const G=zt(h[4],-1,1);O=Math.pow(10,G),R=255*E<<8|255*C}else R=65535,k=0,P=1,O=1;if(n.emplaceBack(g,b,y,R,k,P,O),m){const B=m.length;m.clear();for(let G=0;G>16&65535,p=a?x>>16&65535:65535&x,g=(15&p)<8?15&p:0,b=n.evaluatedRMEA[g],y=n.evaluatedColor[g],v=n.emissionHeightBasedParams[g];let M;if(m&&2===g&&o.lights&&(M=new Pl,M.resize(10*o.lights.length)),T0(u.featureArray,w,y,b,v,u.aabb.min[2],u.aabb.max[2],M),M&&m){m=!1;const E=o.meshes[o.lightMeshIndex];E.featureArray=M,E.featureArray._trim()}}u.featureArray._trim(),h++}}function H_(n,e,i,o){const h=1<P.polygon).flat());const E=y?m:null,[C,R]=(O=o,B=g,G=p,H=w,X=u,Z=E,te=b,K=v,re=a.center.lat,"globe"===(P=a).projection.name?function(pe,fe,me,we,ge,Pe,Oe,Ee,Ye,$e,je){const Fe=[],ut=[],Xe=pe.projection.upVectorScale(je,pe.center.lat,pe.worldSize).metersToTile,it=[0,0,0,1],xt=[0,0,0,1],Bt=(Ct,Ut,jt,xi)=>{Ct[0]=Ut,Ct[1]=jt,Ct[2]=xi,Ct[3]=1},It=xm();me>0&&(me+=It),we+=It;for(const Ct of fe){const Ut=[],jt=[];for(const xi of Ct){const hi=xi.x+ge.x,wt=xi.y+ge.y,ri=pe.projection.projectTilePoint(hi,wt,je),oi=pe.projection.upVector(je,xi.x,xi.y);let Ei=me,Ui=we;if(Oe){const Wi=Mm(hi,wt,me,we,Oe,Ee,Ye,$e);Ei+=Wi.base,Ui+=Wi.top}0!==me?Bt(it,ri.x+oi[0]*Xe*Ei,ri.y+oi[1]*Xe*Ei,ri.z+oi[2]*Xe*Ei):Bt(it,ri.x,ri.y,ri.z),Bt(xt,ri.x+oi[0]*Xe*Ui,ri.y+oi[1]*Xe*Ui,ri.z+oi[2]*Xe*Ui),ue.vec3.transformMat4(it,it,Pe),ue.vec3.transformMat4(xt,xt,Pe),Ut.push(new Ia(it[0],it[1],it[2])),jt.push(new Ia(xt[0],xt[1],xt[2]))}Fe.push(Ut),ut.push(jt)}return[Fe,ut]}(P,O,B,G,H,X,Z,te,K,re,n.tileID.canonical):Z?function(pe,fe,me,we,ge,Pe,Oe,Ee,Ye){const $e=[],je=[],Fe=[0,0,0,1];for(const ut of pe){const Xe=[],it=[];for(const xt of ut){const Bt=xt.x+we.x,It=xt.y+we.y,Ct=Mm(Bt,It,fe,me,Pe,Oe,Ee,Ye);Fe[0]=Bt,Fe[1]=It,Fe[2]=Ct.base,Fe[3]=1,ue.vec4.transformMat4(Fe,Fe,ge),Fe[3]=Math.max(Fe[3],1e-5);const Ut=new Ia(Fe[0]/Fe[3],Fe[1]/Fe[3],Fe[2]/Fe[3]);Fe[0]=Bt,Fe[1]=It,Fe[2]=Ct.top,Fe[3]=1,ue.vec4.transformMat4(Fe,Fe,ge),Fe[3]=Math.max(Fe[3],1e-5);const jt=new Ia(Fe[0]/Fe[3],Fe[1]/Fe[3],Fe[2]/Fe[3]);Xe.push(Ut),it.push(jt)}$e.push(Xe),je.push(it)}return[$e,je]}(O,B,G,H,X,Z,te,K,re):function(pe,fe,me,we,ge){const Pe=[],Oe=[],Ee=ge[8]*fe,Ye=ge[9]*fe,$e=ge[10]*fe,je=ge[11]*fe,Fe=ge[8]*me,ut=ge[9]*me,Xe=ge[10]*me,it=ge[11]*me;for(const xt of pe){const Bt=[],It=[];for(const Ct of xt){const Ut=Ct.x+we.x,jt=Ct.y+we.y,xi=ge[0]*Ut+ge[4]*jt+ge[12],hi=ge[1]*Ut+ge[5]*jt+ge[13],wt=ge[2]*Ut+ge[6]*jt+ge[14],ri=ge[3]*Ut+ge[7]*jt+ge[15],oi=xi+Ee,Ei=hi+Ye,Ui=wt+$e,Wi=Math.max(ri+je,1e-5),ji=xi+Fe,ki=hi+ut,sr=wt+Xe,Yi=Math.max(ri+it,1e-5);Bt.push(new Ia(oi/Wi,Ei/Wi,Ui/Wi)),It.push(new Ia(ji/Yi,ki/Yi,sr/Yi))}Pe.push(Bt),Oe.push(It)}return[Pe,Oe]}(O,B,G,H,X)),k=n.queryGeometry;var P,O,B,G,H,X,Z,te,K,re;return function(P,O,B){let G=1/0;_t(B,O)&&(G=Tm(B,O[0]));for(let H=0;H{if(mh)return mh;const i=Lm();return mh=new Iy(i.paint.properties["line-width"].specification),mh.useIntegerZoom=!0,mh})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,n)}createBucket(n){return new Mp(n)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getDefaultProgramParams(n,e,i){const o=Dm(this);return{config:new Ro(this,{zoom:e,lut:i}),defines:o,overrideFog:!1}}queryRadius(n){const e=n,i=km(Pi("line-width",this,e),Pi("line-gap-width",this,e)),o=Pi("line-offset",this,e);return i/2+Math.abs(o)+fi(this.paint.get("line-translate"))}queryIntersectsFeature(n,e,i,o,h,a){if(n.queryGeometry.isAboveHorizon)return!1;const u=Ot(n.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),a.angle,n.pixelToTileUnitsFactor),m=n.pixelToTileUnitsFactor/2*km(this.paint.get("line-width").evaluate(e,i),this.paint.get("line-gap-width").evaluate(e,i)),x=this.paint.get("line-offset").evaluate(e,i);return x&&(o=function(w,p){const g=[],b=new He(0,0);for(let y=0;y=3)for(let v=0;v{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._callback()},0))}remove(){this._channel=void 0,this._callback=()=>{}}}class A0{constructor(){this.tasks={},this.taskQueue=[],jo(["process"],this),this.invoker=new E0(this.process),this.nextId=0}add(e,i){const o=this.nextId++,h=function({type:a,isSymbolTile:u,zoom:m}){return m=m||0,"message"===a?0:"maybePrepare"!==a||u?"parseTile"!==a||u?"parseTile"===a&&u?300-m:"maybePrepare"===a&&u?400-m:500:200-m:100-m}(i);if(0===h){try{e()}finally{}return null}return this.tasks[o]={fn:e,metadata:i,priority:h,id:o},this.taskQueue.push(o),this.invoker.trigger(),{cancel:()=>{delete this.tasks[o]}}}process(){try{if(this.taskQueue=this.taskQueue.filter(o=>!!this.tasks[o]),!this.taskQueue.length)return;const e=this.pick();if(null===e)return;const i=this.tasks[e];if(delete this.tasks[e],this.taskQueue.length&&this.invoker.trigger(),!i)return;i.fn()}finally{}}pick(){let e=null,i=1/0;for(let h=0;h{o&&delete this.callbacks[m],this.target.postMessage({id:m,type:"",targetMapId:h,sourceMapId:this.mapId})}}}receive(e){const i=e.data,o=i.id;if(o&&(!i.targetMapId||this.mapId===i.targetMapId))if(""===i.type){const h=this.cancelCallbacks[o];delete this.cancelCallbacks[o],h&&h.cancel()}else if(i.mustQueue||xo()){const h=this.callbacks[o],a=this.scheduler.add(()=>this.processTask(o,i),h&&h.metadata||{type:"message"});a&&(this.cancelCallbacks[o]=a)}else this.processTask(o,i)}processTask(e,i){if(delete this.cancelCallbacks[e],""===i.type){const o=this.callbacks[e];delete this.callbacks[e],o&&(i.error?o(Io(i.error)):o(null,Io(i.data)))}else{const o=new Set,h=i.hasCallback?(u,m)=>{this.target.postMessage({id:e,type:"",sourceMapId:this.mapId,error:u?Pr(u):null,data:Pr(m,o)},o)}:u=>{},a=Io(i.data);if(this.parent[i.type])this.parent[i.type](i.sourceMapId,a,h);else if(this.parent.getWorkerSource){const u=i.type.split(".");this.parent.getWorkerSource(i.sourceMapId,u[0],a.source,a.scope)[u[1]](a,h)}else h(new Error(`Could not find function ${i.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}class Hl{constructor(e,i){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=Gs();const o=this.workerPool.acquire(this.id);for(let h=0;h{this.ready=!0})}broadcast(e,i,o){go(this.actors,(h,a)=>{h.send(e,i,a)},o=o||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(e=>{e.remove()}),this.actors=[],this.workerPool.release(this.id)}}Hl.Actor=W_;class X_{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 Y_(n,e,i,o){let h=0,a=Number.MAX_VALUE;for(let u=0;u<3;u++)if(Math.abs(o[u])<1e-15){if(i[u]e[u])return null}else{const m=1/o[u];let x=(n[u]-i[u])*m,w=(e[u]-i[u])*m;if(x>w){const p=x;x=w,w=p}if(x>h&&(h=x),wa)return null}return h}function K_(n,e,i,o,h,a,u,m,x,w,p){const g=o-n,b=h-e,y=a-i,v=u-n,M=m-e,E=x-i,C=p[1]*E-p[2]*M,R=p[2]*v-p[0]*E,k=p[0]*M-p[1]*v,P=g*C+b*R+y*k;if(Math.abs(P)<1e-15)return null;const O=1/P,B=w[0]-n,G=w[1]-e,H=w[2]-i,X=(B*C+G*R+H*k)*O;if(X<0||X>1)return null;const Z=G*y-H*b,te=H*g-B*y,K=B*b-G*g,re=(p[0]*Z+p[1]*te+p[2]*K)*O;return re<0||X+re>1?null:(v*Z+M*te+E*K)*O}function J_(n,e,i){return(n-e)/(i-e)}function Q_(n,e,i,o,h,a,u,m,x){const w=1<{const R=E?1:0,k=(y+1)*M-R,P=v*M,O=(v+1)*M-R;C[0]=y*M,C[1]=P,C[2]=k,C[3]=O};let g=new X_(x);const b=[];for(let y=0;y=1;x/=2){const y=m[m.length-1];g=new X_(x);for(let v=0;v0;){const{idx:v,t:M,nodex:E,nodey:C,depth:R}=y.pop();if(this.leaves[v]){Q_(E,C,R,e,i,o,h,g,b);const P=1<=fe[2])return M}continue}let k=0;for(let P=0;P=w[p[H]]&&(p.splice(H,0,P),G=!0);G||(p[k]=P),k++}}for(let P=0;P=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],h=Td.getUnpackVector(i);let a=Math.floor((e+h[3])/h[2]);return o[2]=a%256,a=Math.floor(a/256),o[1]=a%256,a=Math.floor(a/256),o[0]=a,o}getPixels(){return new Lf({width:this.stride,height:this.stride},this.pixels)}backfillBorder(e,i,o){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let h=i*this.dim,a=i*this.dim+this.dim,u=o*this.dim,m=o*this.dim+this.dim;switch(i){case-1:h=a-1;break;case 1:a=h+1}switch(o){case-1:u=m-1;break;case 1:m=u+1}const x=-i*this.dim,w=-o*this.dim;for(let p=u;p=1;o--){const h=1===o?1:0,a=2===o?1:0;for(let u=0;u>>1^-(1&n[e]);return n}function j0(n,e){switch(e){case"uint32":return n;case"uint16":for(let i=0;i>4|(61440&o)>>8|(240&h)<<4|61440&h,n[i+1]=15&o|(3840&o)>>4|(15&h)<<8|(3840&h)<<4}return n;case"uint8":for(let i=0;i>6|(192&h)>>4|(192&a)>>2|192&u,n[i+1]=(48&o)>>4|(48&h)>>2|48&a|(48&u)<<2,n[i+2]=(12&o)>>2|12&h|(12&a)<<2|(12&u)<<4,n[i+3]=3&o|(3&h)<<2|(3&a)<<4|(3&u)<<6}return n;default:throw new Error(`Invalid pixel format, "${e}"`)}}var un=Uint8Array,Ih=Uint16Array,G0=Int32Array,ig=new un([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]),rg=new un([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]),q0=new un([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ng=function(n,e){for(var i=new Ih(31),o=0;o<31;++o)i[o]=e+=1<>1|(21845&Hi)<<1;ag[Hi]=((65280&(Wl=(61680&(Wl=(52428&Wl)>>2|(13107&Wl)<<2))>>4|(3855&Wl)<<4))>>8|(255&Wl)<<8)>>1}var Ch=function(n,e,i){for(var o=n.length,h=0,a=new Ih(e);h>x]=w;return u},Ph=new un(288);for(Hi=0;Hi<144;++Hi)Ph[Hi]=8;for(Hi=144;Hi<256;++Hi)Ph[Hi]=9;for(Hi=256;Hi<280;++Hi)Ph[Hi]=7;for(Hi=280;Hi<288;++Hi)Ph[Hi]=8;var lg=new un(32);for(Hi=0;Hi<32;++Hi)lg[Hi]=5;var H0=Ch(Ph,9),W0=Ch(lg,5),Jp=function(n){for(var e=n[0],i=1;ie&&(e=n[i]);return e},jn=function(n,e,i){var o=e/8|0;return(n[o]|n[o+1]<<8)>>(7&e)&i},Qp=function(n,e){var i=e/8|0;return(n[i]|n[i+1]<<8|n[i+2]<<16)>>(7&e)},X0=["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"],Gn=function(n,e,i){var o=new Error(e||X0[n]);if(o.code=n,Error.captureStackTrace&&Error.captureStackTrace(o,Gn),!i)throw o;return o},Y0=new un(0),K0=typeof TextDecoder<"u"&&new TextDecoder;try{K0.decode(Y0,{stream:!0})}catch{}const J0={gzip_data:"gzip"};class wn extends Error{constructor(e){super(e),this.name="MRTError"}}const Q0={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},cg={uint32:1,uint16:2,uint8:4},ex={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let ef;class tf{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 wn(`Layer '${e}' not found`);return i}getHeaderLength(e){const i=new Uint8Array(e),o=new DataView(e);if(13!==i[0])throw new wn("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} but got buffer of length ${i.length}`);const h=new ef(i.subarray(0,o)).readFields(z0,{header_length:0,x:0,y:0,z:0,layers:[]},void 0);if(!isNaN(this.x)&&(this.x!==h.x||this.y!==h.y||this.z!==h.z))throw new wn(`Invalid attempt to parse header ${h.z}/${h.x}/${h.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=h.x,this.y=h.y,this.z=h.z;for(const a of h.layers)this.layers[a.name]=new tx(a,{cacheSize:this._cacheSize});return this}createDecodingTask(e){const i=[],o=this.getLayer(e.layerName);for(let h of e.blockIndices){const a=o.dataIndex[h],u=a.first_byte-e.firstByte,m=a.last_byte-e.firstByte;if(o._blocksInProgress.has(h))continue;const x={layerName:o.name,firstByte:u,lastByte:m,pixelFormat:o.pixelFormat,blockIndex:h,blockShape:[a.bands.length].concat(o.bandShape),buffer:o.buffer,codec:a.codec.codec,filters:a.filters.map(w=>w.filter)};o._blocksInProgress.add(h),i.push(x)}return new hg(i,()=>{i.forEach(h=>o._blocksInProgress.delete(h.blockIndex))},(h,a)=>{if(i.forEach(u=>o._blocksInProgress.delete(u.blockIndex)),h)throw h;a.forEach(u=>{this.getLayer(u.layerName).processDecodedData(u)})})}}class tx{constructor({version:e,name:i,units:o,tilesize:h,pixel_format:a,buffer:u,data_index:m},x){if(this.version=e,1!==this.version)throw new wn(`Cannot parse raster layer encoded with MRT version ${e}`);this.name=i,this.units=o,this.tileSize=h,this.buffer=u,this.pixelFormat=Q0[a],this.dataIndex=m,this.bandShape=[h+2*u,h+2*u,cg[this.pixelFormat]],this._decodedBlocks=new N0(x?x.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return cg[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,h]of this.dataIndex.entries()){for(const[a,u]of h.bands.entries())if(u===e)return{bandIndex:i+a,blockIndex:o,blockBandIndex:a};i+=h.bands.length}break;case"number":for(const[o,h]of this.dataIndex.entries()){if(e>=i&&ethis.cacheSize)throw new wn(`Number of blocks to decode (${a.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:i,lastByte:o,blockIndices:h}}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),h=this._decodedBlocks.get(i.toString());if(!h)throw new wn(`Data for band ${JSON.stringify(e)} of layer "${this.name}" not decoded.`);const a=this.dataIndex[i],u=this.bandShape.reduce((w,p)=>w*p,1),m=o*u,x=h.subarray(m,m+u);return{data:x,bytes:new Uint8Array(x.buffer).subarray(x.byteOffset,x.byteOffset+x.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:0!==a.offset?a.offset:a.deprecated_offset,scale:0!==a.scale?a.scale:a.deprecated_scale}}}tf.setPbf=function(n){ef=n};class hg{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)}}tf.performDecoding=function(n,e){const i=new Uint8Array(n);return Promise.all(e.tasks.map(o=>{const{layerName:h,firstByte:a,lastByte:u,pixelFormat:m,blockShape:x,blockIndex:w,filters:p,codec:g}=o,b=i.subarray(a,u+1),y=new Uint32Array(x[0]*x[1]*x[2]);let v;if("gzip_data"!==g)throw new wn(`Unhandled codec: ${g}`);return v=function(M,E){if(!globalThis.DecompressionStream&&"gzip_data"===E)return Promise.resolve(((P=function(G){31==G[0]&&139==G[1]&&8==G[2]||Gn(6,"invalid gzip data");var H=G[3],X=10;4&H&&(X+=2+(G[10]|G[11]<<8));for(var Z=(H>>3&1)+(H>>4&1);Z>0;Z-=!G[X++]);return X+(2&H)}(k=M))+8>k.length&&Gn(6,"invalid gzip data"),function(G,H,X){var te=G.length;if(!te||H.f&&!H.l)return X||new un(0);var K=!X,re=K||2!=H.i,he=H.i;K&&(X=new un(3*te));var pe,fe,me=function(Bs){var Ra=X.length;if(Bs>Ra){var Bh=new un(Math.max(2*Ra,Bs));Bh.set(X),X=Bh}},we=H.f||0,ge=H.p||0,Pe=H.b||0,Oe=H.l,Ee=H.d,Ye=H.m,$e=H.n,je=8*te;do{if(!Oe){we=jn(G,ge,1);var Fe=jn(G,ge+1,3);if(ge+=3,!Fe){var ut=G[(wt=4+((ge+7)/8|0))-4]|G[wt-3]<<8,Xe=wt+ut;if(Xe>te){he&&Gn(0);break}re&&me(Pe+ut),X.set(G.subarray(wt,Xe),Pe),H.b=Pe+=ut,H.p=ge=8*Xe,H.f=we;continue}if(1==Fe)Oe=H0,Ee=W0,Ye=9,$e=5;else if(2==Fe){var it=jn(G,ge,31)+257,xt=jn(G,ge+10,15)+4,Bt=it+jn(G,ge+5,31)+1;ge+=14;for(var It=new un(Bt),Ct=new un(19),Ut=0;Ut>4)<16)It[Ut++]=wt;else{var oi=0,Ei=0;for(16==wt?(Ei=3+jn(G,ge,3),ge+=2,oi=It[Ut-1]):17==wt?(Ei=3+jn(G,ge,7),ge+=3):18==wt&&(Ei=11+jn(G,ge,127),ge+=7);Ei--;)It[Ut++]=oi}}var Ui=It.subarray(0,it),Wi=It.subarray(it);Ye=Jp(Ui),$e=Jp(Wi),Oe=Ch(Ui,Ye),Ee=Ch(Wi,$e)}else Gn(1);if(ge>je){he&&Gn(0);break}}re&&me(Pe+131072);for(var ji=(1<>4;if((ge+=15&oi)>je){he&&Gn(0);break}if(oi||Gn(2),Yi<256)X[Pe++]=Yi;else{if(256==Yi){sr=ge,Oe=null;break}var dr=Yi-254;Yi>264&&(dr=jn(G,ge,(1<<(Zn=ig[Ut=Yi-257]))-1)+sg[Ut],ge+=Zn);var Ti=Ee[Qp(G,ge)&ki],jr=Ti>>4;if(Ti||Gn(3),ge+=15&Ti,Wi=$0[jr],jr>3){var Zn=rg[jr];Wi+=Qp(G,ge)&(1<je){he&&Gn(0);break}re&&me(Pe+131072);var Tn=Pe+dr;if(Pepe.length)&&(fe=pe.length),new un(pe.subarray(0,fe))):X.subarray(0,Pe)}(k.subarray(P,-8),{i:2},new un(((C=k)[(R=C.length)-4]|C[R-3]<<8|C[R-2]<<16|C[R-1]<<24)>>>0))));var C,R,k,P;const O=J0[E];if(!O)throw new Error(`Unhandled codec: ${E}`);const B=new globalThis.DecompressionStream(O);return new Response(new Blob([M]).stream().pipeThrough(B)).arrayBuffer().then(G=>new Uint8Array(G))}(b,g).then(M=>(new ef(M).readFields(B0,y),new ex[m](y.buffer))),v.then(M=>{for(let E=p.length-1;E>=0;E--)switch(p[E]){case"delta_filter":V0(M,x);break;case"zigzag_filter":U0(M);break;case"bitshuffle_filter":j0(M,m);break;default:throw new wn(`Unhandled filter "${p[E]}"`)}return{layerName:h,blockIndex:w,data:M}}).catch(M=>{throw M})}))},rt(hg,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]});var zh={workerUrl:"",workerClass:null,workerParams:void 0};const rf="mapboxgl_preloaded_worker_pool";class Dh{constructor(){this.active={}}acquire(e){if(!this.workers)for(this.workers=[];this.workers.length{i.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[rf]}numActive(){return Object.keys(this.active).length}}let Rh;function Md(){return Rh||(Rh=new Dh),Rh}Dh.workerCount=2;let Lh,nf,qn,Xl,of,Yl=null;function ug(){return xo()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:nf||le.DRACO_URL}function dg(){if(xo()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(Xl)return Xl;const n=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]);if("object"!=typeof WebAssembly)throw new Error("WebAssembly not supported, cannot instantiate meshoptimizer");return Xl=WebAssembly.validate(n)?le.MESHOPT_SIMD_URL:le.MESHOPT_URL,Xl}const Sd={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},ix={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},kh={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function pg(n,e,i){const o=i.json.bufferViews.length,h=i.buffers.length;e.bufferView=o,i.json.bufferViews[o]={buffer:h,byteLength:n.byteLength},i.buffers[h]=n}const sf="KHR_draco_mesh_compression";function rx(n,e){const i=n.extensions&&n.extensions[sf];if(!i)return;const o=new qn.Decoder,h=gg(e,i.bufferView),a=new qn.Mesh;if(!o.DecodeArrayToMesh(h,h.byteLength,a))throw new Error("Failed to decode Draco mesh");const u=e.json.accessors[n.indices],m=Sd[u.componentType],x=u.count*m.BYTES_PER_ELEMENT,w=qn._malloc(x);m===Uint16Array?o.GetTrianglesUInt16Array(a,x,w):o.GetTrianglesUInt32Array(a,x,w),pg(qn.memory.buffer.slice(w,w+x),u,e),qn._free(w);for(const p of Object.keys(i.attributes)){const g=o.GetAttributeByUniqueId(a,i.attributes[p]),b=e.json.accessors[n.attributes[p]],y=ix[b.componentType],v=b.count*kh[b.type]*Sd[b.componentType].BYTES_PER_ELEMENT,M=qn._malloc(v);o.GetAttributeDataArrayForAllPoints(a,g,qn[y],v,M),pg(qn.memory.buffer.slice(M,M+v),b,e),qn._free(M)}o.destroy(),a.destroy(),delete n.extensions[sf]}const Ed="EXT_meshopt_compression";function nx(n,e){if(!n.extensions||!n.extensions[Ed])return;const i=n.extensions[Ed],o=new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength||0),h=new Uint8Array(i.count*i.byteStride);of.decodeGltfBuffer(h,i.count,i.byteStride,o,i.mode,i.filter),n.buffer=e.buffers.length,n.byteOffset=0,e.buffers[n.buffer]=h.buffer,delete n.extensions[Ed]}const fg=1179937895,mg=new TextDecoder("utf8");function _g(n,e){return new URL(n,e).href}function ox(n,e,i,o){return fetch(_g(n.uri,o)).then(h=>h.arrayBuffer()).then(h=>{e.buffers[i]=h})}function gg(n,e){const i=n.json.bufferViews[e];return new Uint8Array(n.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function sx(n,e,i,o){if(n.uri){const h=_g(n.uri,o);return fetch(h).then(a=>a.blob()).then(a=>createImageBitmap(a)).then(a=>{e.images[i]=a})}if(void 0!==n.bufferView){const h=gg(e,n.bufferView),a=new Blob([h],{type:n.mimeType});return createImageBitmap(a).then(u=>{e.images[i]=u})}}function yg(n,e=0,i){const o={json:null,images:[],buffers:[]};if(new Uint32Array(n,e,1)[0]===fg){const p=new Uint32Array(n,e);let g=2;const b=(p[g++]>>2)-3,y=p[g++]>>2;if(g++,o.json=JSON.parse(mg.decode(p.subarray(g,g+y))),g+=y,g{const p=[],g=m&&m.includes(sf),b=m&&m.includes(Ed);if(g&&p.push(function(){if(!qn)return Lh??(Lh=function(y){let v,M=null;function E(){v=new Uint8Array(M.buffer)}function C(){throw new Error("Unexpected Draco error.")}const R={a:{a:C,d:function(k,P,O){return v.copyWithin(k,P,P+O)},c:function(k){const P=v.length,O=Math.max(k>>>0,Math.ceil(1.2*P)),B=Math.ceil((O-P)/65536);try{return M.grow(B),E(),!0}catch{return!1}},b:C}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(y,R):y.then(k=>k.arrayBuffer()).then(k=>WebAssembly.instantiate(k,R))).then(k=>{const{Rb:P,Qb:O,P:B,T:G,X:H,Ja:X,La:Z,Qa:te,Va:K,Wa:re,eb:he,jb:pe,f:fe,e:me,yb:we,zb:ge,Ab:Pe,Bb:Oe,Db:Ee,Gb:Ye}=k.instance.exports;M=me;const $e=(()=>{let je=0,Fe=0,ut=0,Xe=0;return it=>{ut&&(P(Xe),P(je),Fe+=ut,ut=je=0),je||(Fe+=128,je=O(Fe));const xt=it.length+7&-8;let Bt=je;xt>=Fe&&(ut=xt,Bt=Xe=O(xt));for(let It=0;It{qn=y,Lh=void 0}))}()),b&&p.push(function(){if(of)return;const y=function(v){let M;const E=WebAssembly.instantiateStreaming(v,{}).then(k=>{M=k.instance,M.exports.__wasm_call_ctors()}),C={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},R={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:E,supported:!0,decodeGltfBuffer(k,P,O,B,G,H){!function(X,Z,te,K,re,he,pe){const fe=X.exports.sbrk,me=K+3&-4,we=fe(me*re),ge=fe(he.length),Pe=new Uint8Array(X.exports.memory.buffer);Pe.set(he,ge);const Oe=Z(we,K,re,ge,he.length);if(0===Oe&&pe&&pe(we,me,re),te.set(Pe.subarray(we,we+K*re)),fe(we-fe(0)),0!==Oe)throw new Error(`Malformed buffer data: ${Oe}`)}(M,M.exports[R[G]],k,P,O,B,M.exports[C[H]])}}}(fetch(dg()));return y.ready.then(()=>{of=y})}()),a)for(let y=0;y{if(g&&u)for(const{primitives:y}of u)for(const v of y)rx(v,o);if(b&&u&&x)for(const y of x)nx(y,o);return o})})}function za(n,e){const i=n.json.bufferViews[e.bufferView],o=Sd[e.componentType];return new o(n.buffers[i.buffer],(e.byteOffset||0)+(i.byteOffset||0),e.count*(i.byteStride&&i.byteStride!==kh[e.type]*o.BYTES_PER_ELEMENT?i.byteStride/o.BYTES_PER_ELEMENT:kh[e.type]))}function af(n,e,i,o){const h=Sd[e.componentType],a=function(p){switch(p){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(h),u=n.json.bufferViews[e.bufferView],m=u.byteStride?u.byteStride/h.BYTES_PER_ELEMENT:kh[e.type],x=i.float32,w=x.length/i.capacity;for(let p=0,g=0;p0){for(let E=0;E0){a.texcoordArray=new ba;const b=e.json.accessors[h.TEXCOORD_0];a.texcoordArray.resize(b.count);const y=za(e,b);af(e,b,a.texcoordArray,y)}if(void 0!==h._FEATURE_ID_RGBA4444){const b=e.json.accessors[h._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(a.featureData=za(e,b))}void 0!==h._FEATURE_RGBA4444&&(a.featureData=new Uint32Array(za(e,e.json.accessors[h._FEATURE_RGBA4444]).buffer));const g=n.material;return a.material=function(b,y){const{emissiveFactor:v=[0,0,0],alphaMode:M="OPAQUE",alphaCutoff:E=.5,normalTexture:C,occlusionTexture:R,emissiveTexture:k,doubleSided:P}=b,{baseColorFactor:O=[1,1,1,1],metallicFactor:B=1,roughnessFactor:G=1,baseColorTexture:H,metallicRoughnessTexture:X}=b.pbrMetallicRoughness||{},Z=R?y[R.index]:void 0;if(R&&R.extensions&&R.extensions.KHR_texture_transform&&Z){const te=R.extensions.KHR_texture_transform;Z.offsetScale=[te.offset[0],te.offset[1],te.scale[0],te.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:new li(...O),metallicFactor:B,roughnessFactor:G,baseColorTexture:H?y[H.index]:void 0,metallicRoughnessTexture:X?y[X.index]:void 0},doubleSided:P,emissiveFactor:v,alphaMode:M,alphaCutoff:E,normalTexture:C?y[C.index]:void 0,occlusionTexture:Z,emissionTexture:k?y[k.index]:void 0,defined:void 0===b.defined}}(void 0!==g?e.json.materials[g]:{defined:!1},i),a}function xg(n,e,i){const{matrix:o,rotation:h,translation:a,scale:u,mesh:m,extras:x,children:w}=n,p={};if(p.matrix=o||ue.mat4.fromRotationTranslationScale([],h||[0,0,0,1],a||[0,0,0],u||[1,1,1]),void 0!==m){p.meshes=i[m];const g=p.anchor=[0,0];for(const b of p.meshes){const{min:y,max:v}=b.aabb;g[0]+=y[0]+v[0],g[1]+=y[1]+v[1]}g[0]=Math.floor(g[0]/p.meshes.length/2),g[1]=Math.floor(g[1]/p.meshes.length/2)}if(x&&(x.id&&(p.id=x.id),x.lights&&(p.lights=function(g){if(!g.length)return[];const b=function(C){const R=atob(C),k=new Uint8Array(R.length);for(let P=0;P1&&o[o.length-1].equals(o[0])&&o.pop();let h=0;for(let u=0;u0&&o.reverse();const a=ah(o.flatMap(u=>[u.x,u.y]),[]);return 0===a.length?null:{vertices:o,indices:a}}function hx(n,e){const i=[],o=[];let h=0;const a=[];for(const u of n){h=i.length;const m=u.vertexArray.float32,x=u.indexArray.uint16;for(let w=0;w0&&([o[u+1],o[u+2]]=[o[u+2],o[u+1]])}return{vertices:i,indices:o}}function vg(n){const i=function(x,w){const p=[];for(const g of x.json.meshes){const b=[];for(const y of g.primitives)b.push(ax(y,x,w));p.push(b)}return p}(n,function(x,w){const p=[],g=WebGL2RenderingContext;if(x.json.textures)for(const b of x.json.textures){const y={magFilter:g.LINEAR,minFilter:g.NEAREST,wrapS:g.REPEAT,wrapT:g.REPEAT};void 0!==b.sampler&&Object.assign(y,x.json.samplers[b.sampler]),p.push({image:w[b.source],sampler:y,uploaded:!1})}return p}(n,n.images)),{scenes:o,scene:h,nodes:a}=n.json,u=o?o[h||0].nodes:a,m=[];for(const x of u)m.push(xg(a[x],n,i));return function(x,w,p){const g={},b=new Set;for(let y=0;y0){const y=Array.from(b.values()).sort((v,M)=>v-M);for(let v=y.length-1;v>=0;v--)x.splice(y[v],1)}}(m,u,n.json.nodes),m}function ux(n){n.heightmap=new Float32Array(4096),n.heightmap.fill(-1);const e=n.vertexArray.float32,i=n.aabb.min[0]-1,o=n.aabb.min[1]-1,h=64/(n.aabb.max[0]-i+2),a=64/(n.aabb.max[1]-o+2);for(let u=0;un.heightmap[64*w+x]&&(n.heightmap[64*w+x]=m)}}function dx(n,e){const i={};i.indexArray=new cr,i.indexArray.reserve(4*n.length),i.vertexArray=new no,i.vertexArray.reserve(10*n.length),i.colorArray=new kn,i.vertexArray.reserve(10*n.length);let o=0;for(const u of n){const m=Math.min(10,Math.max(4,1.3*u.height))*e,x=[-u.normal[1],u.normal[0],0],w=Math.min(.29,.1*u.width/u.depth),p=u.width-2*u.depth*e*(w+.01),g=ue.vec3.scaleAndAdd([],u.pos,x,p/2),b=ue.vec3.scaleAndAdd([],u.pos,x,-p/2),y=[g[0],g[1],g[2]+u.height],v=[b[0],b[1],b[2]+u.height],M=ue.vec3.scaleAndAdd([],u.normal,x,w);ue.vec3.scale(M,M,m);const E=ue.vec3.scaleAndAdd([],u.normal,x,-w);ue.vec3.scale(E,E,m),ue.vec3.add(M,g,M),ue.vec3.add(E,b,E),g[2]+=.1,b[2]+=.1,i.vertexArray.emplaceBack(M[0],M[1],M[2]),i.vertexArray.emplaceBack(E[0],E[1],E[2]),i.vertexArray.emplaceBack(g[0],g[1],g[2]),i.vertexArray.emplaceBack(b[0],b[1],b[2]),i.vertexArray.emplaceBack(y[0],y[1],y[2]),i.vertexArray.emplaceBack(v[0],v[1],v[2]),i.vertexArray.emplaceBack(g[0],g[1],g[2]),i.vertexArray.emplaceBack(b[0],b[1],b[2]),i.vertexArray.emplaceBack(M[0],M[1],M[2]),i.vertexArray.emplaceBack(E[0],E[1],E[2]);const C=p/m/2;i.colorArray.emplaceBack(-C-w,-1,C,.8),i.colorArray.emplaceBack(C+w,-1,C,.8),i.colorArray.emplaceBack(-C,0,C,1.3),i.colorArray.emplaceBack(C,0,C,1.3),i.colorArray.emplaceBack(C+w,-.8,C,.7),i.colorArray.emplaceBack(C+w,-.8,C,.7),i.colorArray.emplaceBack(0,0,C,1.3),i.colorArray.emplaceBack(0,0,C,1.3),i.colorArray.emplaceBack(C+w,-1.2,C,.8),i.colorArray.emplaceBack(C+w,-1.2,C,.8),i.indexArray.emplaceBack(6+o,4+o,8+o),i.indexArray.emplaceBack(7+o,9+o,5+o),i.indexArray.emplaceBack(0+o,1+o,2+o),i.indexArray.emplaceBack(1+o,3+o,2+o),o+=10}const h={defined:!0,emissiveFactor:[0,0,0]},a={};return a.baseColorFactor=li.white,h.pbrMetallicRoughness=a,i.material=h,i.aabb=new wi([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),i}class bg{constructor(e){this._stringToNumber={},this._numberToString=[];for(let i=0;i=0&&b[3]>=0&&w.insert(x,b[0],b[1],b[2],b[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Nl.VectorTile(new td(this.rawTileData)).layers,this.sourceLayerCoder=new bg(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,o,h){this.loadVTLayers();const a=e.params||{},u=ln(a.filter),m=e.tileResult,x=e.transform,w=m.bufferedTilespaceBounds,p=this.grid.query(w.min.x,w.min.y,w.max.x,w.max.y,(v,M,E,C)=>Hr(m.bufferedTilespaceGeometry,v,M,E,C));p.sort(fx);let g=null;x.elevation&&p.length>0&&(g=$l.create(x.elevation,this.tileID));const b={};let y;for(let v=0;v(C||(C=Ue(R,this.tileID.canonical,e.tileTransform)),k.queryIntersectsFeature(m,R,P,C,this.z,e.transform,e.pixelPosMatrix,g,O)))}return b}loadMatchingFeature(e,i,o,h,a,u,m,x,w){const{featureIndex:p,bucketIndex:g,sourceLayerIndex:b,layoutVertexArrayOffset:y}=i,v=this.bucketLayerIDs[g];if(h&&!function(R,k){for(let P=0;P=0)return!0;return!1}(h,v))return;const M=this.sourceLayerCoder.decode(b),E=this.vtLayers[M].feature(p);if(o.needGeometry){const R=Ge(E,!0);if(!o.filter(new Bi(this.tileID.overscaledZ),R,this.tileID.canonical))return}else if(!o.filter(new Bi(this.tileID.overscaledZ),E))return;const C=this.getId(E,M);for(let R=0;R{const m=e instanceof ys?e.get(u):null;return m&&m.evaluate?m.evaluate(i,o,h):m})}function fx(n,e){return e-n}rt(Tg,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const Sg=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class lf{static from(e){if(!(e instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[i,o]=new Uint8Array(e,0,2);if(219!==i)throw new Error("Data does not appear to be in a KDBush format.");const h=o>>4;if(1!==h)throw new Error(`Got v${h} data when expected v1.`);const a=Sg[15&o];if(!a)throw new Error("Unrecognized array type.");const[u]=new Uint16Array(e,2,1),[m]=new Uint32Array(e,4,1);return new lf(m,u,a,e)}constructor(e,i=64,o=Float64Array,h){if(isNaN(e)||e<0)throw new Error(`Unpexpected 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 a=Sg.indexOf(this.ArrayType),u=2*e*this.ArrayType.BYTES_PER_ELEMENT,m=e*this.IndexArrayType.BYTES_PER_ELEMENT,x=(8-m%8)%8;if(a<0)throw new Error(`Unexpected typed array class: ${o}.`);h&&h instanceof ArrayBuffer?(this.data=h,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+m+x,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+u+m+x),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+m+x,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+a]),new Uint16Array(this.data,2,1)[0]=i,new Uint32Array(this.data,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 cf(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,i,o,h){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:a,coords:u,nodeSize:m}=this,x=[0,a.length-1,0],w=[];for(;x.length;){const p=x.pop()||0,g=x.pop()||0,b=x.pop()||0;if(g-b<=m){for(let E=b;E<=g;E++){const C=u[2*E],R=u[2*E+1];C>=e&&C<=o&&R>=i&&R<=h&&w.push(a[E])}continue}const y=b+g>>1,v=u[2*y],M=u[2*y+1];v>=e&&v<=o&&M>=i&&M<=h&&w.push(a[y]),(0===p?e<=v:i<=M)&&(x.push(b),x.push(y-1),x.push(1-p)),(0===p?o>=v:h>=M)&&(x.push(y+1),x.push(g),x.push(1-p))}return w}within(e,i,o){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:h,coords:a,nodeSize:u}=this,m=[0,h.length-1,0],x=[],w=o*o;for(;m.length;){const p=m.pop()||0,g=m.pop()||0,b=m.pop()||0;if(g-b<=u){for(let E=b;E<=g;E++)Ag(a[2*E],a[2*E+1],e,i)<=w&&x.push(h[E]);continue}const y=b+g>>1,v=a[2*y],M=a[2*y+1];Ag(v,M,e,i)<=w&&x.push(h[y]),(0===p?e-o<=v:i-o<=M)&&(m.push(b),m.push(y-1),m.push(1-p)),(0===p?e+o>=v:i+o>=M)&&(m.push(y+1),m.push(g),m.push(1-p))}return x}}function cf(n,e,i,o,h,a){if(h-o<=i)return;const u=o+h>>1;Eg(n,e,u,o,h,a),cf(n,e,i,o,u-1,1-a),cf(n,e,i,u+1,h,1-a)}function Eg(n,e,i,o,h,a){for(;h>o;){if(h-o>600){const w=h-o+1,p=i-o+1,g=Math.log(w),b=.5*Math.exp(2*g/3),y=.5*Math.sqrt(g*b*(w-b)/w)*(p-w/2<0?-1:1);Eg(n,e,i,Math.max(o,Math.floor(i-p*b/w+y)),Math.min(h,Math.floor(i+(w-p)*b/w+y)),a)}const u=e[2*i+a];let m=o,x=h;for(Oh(n,e,o,i),e[2*h+a]>u&&Oh(n,e,o,h);mu;)x--}e[2*o+a]===u?Oh(n,e,o,x):(x++,Oh(n,e,x,h)),x<=i&&(o=x+1),i<=x&&(h=x-1)}}function Oh(n,e,i,o){hf(n,i,o),hf(e,2*i,2*o),hf(e,2*i+1,2*o+1)}function hf(n,e,i){const o=n[e];n[e]=n[i],n[i]=o}function Ag(n,e,i,o){const h=n-i,a=e-o;return h*h+a*a}s.$=Tu,s.A=class extends vd{},s.B=To,s.C=Yo,s.D=_a,s.E=Xo,s.F=Dc,s.G=ul,s.H=fu,s.I=Dp,s.J=fl,s.K=Tl,s.L=xu,s.M=da,s.N=rl,s.O=oa,s.P=He,s.Q=na,s.R=$o,s.S=Cr,s.T=qp,s.U=nc,s.V=vd,s.W=jc,s.X=dl,s.Y=zc,s.Z=function(n){const e=n.value;let i=[];if(!e)return i;const o=To(e);return"string"!==o?(i=i.concat([new vd(n.key,e,`string expected, "${o}" found`)]),i):(B_(e,!0)||(i=i.concat([new vd(n.key,e,`invalid url "${e}"`)])),i)},s._=be,s.a=function(n){return le.API_CDN_URL_REGEX.test(n)},s.a$=Kc,s.a0=Ci,s.a1=qe,s.a2=class{constructor(n){this.specification=n}possiblyEvaluate(n,e){return Lr(n.expression.evaluate(e))}interpolate(n,e,i){return{x:mt(n.x,e.x,i),y:mt(n.y,e.y,i),z:mt(n.z,e.z,i),azimuthal:mt(n.azimuthal,e.azimuthal,i),polar:mt(n.polar,e.polar,i)}}},s.a3=Bi,s.a4=gn,s.a5=ye,s.a6=ue,s.a7=Uo,s.a8=ys,s.a9=Cs,s.aA=bi,s.aB=M_,s.aC=P_,s.aD=T_,s.aE=function(n,e){const i=document.createElement("video");i.muted=!0,i.onloadstart=function(){e(null,i)};for(let o=0;o{}}},s.aF=md,s.aG=function(n){return fetch(n).then(e=>e.arrayBuffer()).then(e=>yg(e,0,n))},s.aH=vg,s.aI=class{constructor(n,e,i,o){this.id=n,this.position=null!=e?new L(e[0],e[1]):new L(0,0),this.orientation=i??[0,0,0],this.nodes=o,this.uploaded=!1,this.aabb=new wi([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[]}_applyTransformations(n,e){if(ue.mat4.multiply(n.matrix,e,n.matrix),n.meshes)for(const i of n.meshes){const o=wi.applyTransformFast(i.aabb,n.matrix);this.aabb.encapsulate(o)}if(n.children)for(const i of n.children)this._applyTransformations(i,n.matrix)}computeBoundsAndApplyParent(){const n=ue.mat4.identity([]);for(const e of this.nodes)this._applyTransformations(e,n)}computeModelMatrix(n,e,i,o,h,a,u=!1){j_(this.matrix,this,n.transform,this.position,e,i,o,h,a,u)}upload(n){if(!this.uploaded){for(const e of this.nodes)Xp(e,n);for(const e of this.nodes)bd(e);this.uploaded=!0}}destroy(){for(const n of this.nodes)Yp(n)}},s.aJ=jo,s.aK=bh,s.aL=Q,s.aM=J,s.aN=ro,s.aO=cr,s.aP=Gs,s.aQ=Rl,s.aR=pd,s.aS=function(){zr.isLoading()||zr.isLoaded()||"deferred"!==Nc()||Vc()},s.aT=ln,s.aU=Ge,s.aV=wg,s.aW=$s,s.aX=Mp,s.aY=fp,s.aZ=Ue,s.a_=io,s.aa=mt,s.ab=We,s.ac=Js,s.ad=class{constructor(n){this.specification=n}possiblyEvaluate(n,e){return function([i,o]){const h=Lr([1,i,o]);return{x:h.x,y:h.y,z:h.z}}(n.expression.evaluate(e))}interpolate(n,e,i){return{x:mt(n.x,e.x,i),y:mt(n.y,e.y,i),z:mt(n.z,e.z,i)}}},s.ae=function(n,e,i=0,o=!0){const h=new He(i,i),a=n.sub(h),u=e.add(h),m=[a,new He(u.x,a.y),u,new He(a.x,u.y)];return o&&m.push(a.clone()),m},s.af=function(n,e){const i=[];for(let o=0;o{o(a,u)},e):o(a,u),()=>{}}return h.callbacks.push(o),h.cancel||(h.cancel=i((a,u)=>{h.result=[a,u];for(const m of h.callbacks)this.scheduler?this.scheduler.add(()=>{m(a,u)},e):m(a,u);setTimeout(()=>delete this.entries[n],3e3)})),()=>{h.result||(h.callbacks=h.callbacks.filter(a=>a!==o),h.callbacks.length||(h.cancel(),delete this.entries[n]))}}},s.av=Au,s.aw=function(n,e,i){const o=JSON.stringify(n.request);return n.data&&(this.deduped.entries[o]={result:[null,n.data]}),this.deduped.request(o,{type:"parseTile",isSymbolTile:n.isSymbolTile,zoom:n.tileZoom},h=>{const a=Ho(n.request,(u,m,x,w)=>{u?h(u):m&&h(null,{vectorTile:i?void 0:new Nl.VectorTile(new td(m)),rawData:m,cacheControl:x,expires:w})});return()=>{a.cancel(),h()}},e)},s.ax=function(n){Ki++,Ki>ai&&(n.getActor().send("enforceCacheSizeLimit",Mt),Ki=0)},s.ay=Ke,s.az=function(n){return n<=1?1:Math.pow(2,Math.floor(Math.log(n)/Math.LN2))},s.b=function(n){return le.API_FONTS_REGEX.test(n)},s.b$=function(n){const{x:e,y:i}=n.point,{lng:o,lat:h}=n._center;return bf(e,i,n.worldSize,o,h)},s.b0=Xr,s.b1=Fi,s.b2=ah,s.b3=Up,s.b4=function(n,e){const i=Cs(e.zoom);if(0===i)return lo(n);const o=Uu(n),h=op(o),a=W(o.getWest())*e.worldSize,u=W(o.getEast())*e.worldSize,m=Y(o.getNorth())*e.worldSize,x=Y(o.getSouth())*e.worldSize,w=[a,m,0],p=[u,m,0],g=[a,x,0],b=[u,x,0],y=ue.mat4.invert([],e.globeMatrix);return ue.vec3.transformMat4(w,w,y),ue.vec3.transformMat4(p,p,y),ue.vec3.transformMat4(g,g,y),ue.vec3.transformMat4(b,b,y),h[0]=ko(h[0],g,i),h[1]=ko(h[1],b,i),h[2]=ko(h[2],p,i),h[3]=ko(h[3],w,i),wi.fromPoints(h)},s.b5=Gu,s.b6=oh,s.b7=ko,s.b8=Al,s.b9=Dr,s.bA=Cn,s.bB=Ht,s.bC=vo,s.bD=$,s.bE=function(n,e,i){n[4*e+0]=i[0],n[4*e+1]=i[1],n[4*e+2]=i[2],n[4*e+3]=i[3]},s.bF=Sa,s.bG=yn,s.bH=th,s.bI=gr,s.bJ=Do,s.bK=L,s.bL=f_,s.bM=Qi,s.bN=Is,s.bO=D_,s.bP=rr,s.bQ=yf,s.bR=function(n,e,i,o,h,a,u,m,x){if("globe"===x.name)return yf(n,e,new rr(i,o,h),!1);const w=bh({z:i,x:o,y:h},x);return new wi([(a+w.x/w.scale)*e,e*(w.y/w.scale),u],[(a+w.x2/w.scale)*e,e*(w.y2/w.scale),m])},s.bS=function(n,e,i){let o=0;for(let h=0;h<2;++h)n[h]>0&&(o+=(n[h]-0)*(n[h]-0)),e[h]<0&&(o+=(0-e[h])*(0-e[h]));return o},s.bT=ie,s.bU=6,s.bV=function(n){const e=ue.mat4.identity(new Float64Array(16));ue.mat4.multiply(e,n.pixelMatrix,n.globeMatrix);const i=[0,T,0],o=[0,S,0];return ue.vec3.transformMat4(i,i,e),ue.vec3.transformMat4(o,o,e),[i[0]>0&&i[0]<=n.width&&i[1]>0&&i[1]<=n.height&&!lp(n,new L(n.center.lat,90)),o[0]>0&&o[0]<=n.width&&o[1]>0&&o[1]<=n.height&&!lp(n,new L(n.center.lat,-90))]},s.bW=function(n,e){const{scale:i}=n.tileTransform,o=i*We/(n.tileSize*Math.pow(2,e.zoom-n.tileID.overscaledZ+n.tileID.canonical.z));return ue.mat2.scale(new Float32Array(4),e.inverseAdjustmentMatrix,[o,o])},s.bX=yd,s.bY=z_,s.bZ=function(n){const e=z_(n,!0);return ue.mat2.invert([],[e[0],e[1],e[4],e[5]])},s.b_=ao,s.ba=tf,s.bb=td,s.bc=Ho,s.bd=function(n){const e=[];for(const i in n)e.push(n[i]);return e},s.be=function(n,e){const i=[];for(const o in n)o in e||i.push(o);return i},s.bf=go,s.bg=["type","source","source-layer","minzoom","maxzoom","filter","layout"],s.bh=mo,s.bi=function(n,e){const{x:i,y:o}=n.point,h=bf(i,o,n.worldSize/n._pixelsPerMercatorPixel,0,0);return ue.mat4.multiply(h,h,sp(lo(e)))},s.bj=Vl,s.bk=hn,s.bl=ed,s.bm=function(n,e,i,o,h){const a=5*e+2;n.float32[a+0]=i,n.float32[a+1]=o,n.float32[a+2]=h},s.bn=dd,s.bo=Jm,s.bp=Ze,s.bq=24,s.br=em,s.bs=O_,s.bt=om,s.bu=sm,s.bv=kp,s.bw=o_,s.bx=zp,s.by=lf,s.bz=li,s.c=_e,s.c$=Mr,s.c0=nr,s.c1=Tr,s.c2=5,s.c3=function(n){const e=Math.round((n+45+360)%360/90)%4;return Qr[e]},s.c4=45,s.c5=U,s.c6=Ol,s.c7=function(n,e,i){const o=Math.sqrt(n*n+e*e+i*i),h=o>0?Math.acos(i/o)*In:0;let a=0!==n||0!==e?Math.atan2(-e,-n)*In+90:0;return a<0&&(a+=360),[o,a,h]},s.c8=ae,s.c9=wi,s.cA=function(n){const e=ie-5;n=zt(n,-e,e)/e*90;const i=Math.pow(Math.abs(Math.sin(Ht(n))),3);return Math.round(i*(_.length-1))},s.cB=function(n,e,i,o){const h=e.getNorth(),a=e.getSouth(),u=e.getWest(),m=e.getEast(),x=1<0){const v=180/o;ue.mat3.multiply(y,y,[v/w+1,0,0,0,v/p+1,0,-.5*v/g,.5*v/b,1])}return y[2]=x,y[5]=n.x,y[8]=n.y,y},s.cC=lo,s.cD=function(n,e,i){const o=ue.mat4.identity(new Float64Array(16)),h=(e/(1<1)return!1;const i=e.getSource().maxzoom,o=1<1)return e;const h=o.getSource().maxzoom,a=1<{const a=this.getAtTileOffset(n,h.x,h.y),u=o.upVector(n.canonical,h.x,h.y),m=o.upVectorScale(n.canonical,e,i).metersToTile;return ue.vec3.scale(u,u,a*m),u}}getForTilePoints(n,e,i,o){if(this.isUsingMockSource())return!1;const h=$l.create(this,n,o);return!!h&&(e.forEach(a=>{a[2]=this.exaggeration()*h.getElevationAt(a[0],a[1],i)}),!0)}getMinMaxForTile(n){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(n);if(!e||!e.dem)return null;const i=e.dem.tree,o=e.tileID,h=1<({u_camera_to_center_distance:new gr(n),u_extrude_scale:new rh(n),u_device_pixel_ratio:new gr(n),u_matrix:new Sa(n),u_inv_rot_matrix:new Sa(n),u_merc_center:new yn(n),u_tile_id:new th(n),u_zoom_transition:new gr(n),u_up_dir:new th(n),u_emissive_strength:new gr(n)}),s.cO=n=>({u_matrix:new Sa(n),u_pixels_to_tile_units:new rh(n),u_device_pixel_ratio:new gr(n),u_units_to_pixels:new yn(n),u_dash_image:new Do(n),u_gradient_image:new Do(n),u_image_height:new gr(n),u_texsize:new yn(n),u_tile_units_to_pixels:new gr(n),u_alpha_discard_threshold:new gr(n),u_trim_offset:new yn(n),u_trim_fade_range:new yn(n),u_trim_color:new Ol(n),u_emissive_strength:new gr(n)}),s.cP=n=>({u_matrix:new Sa(n),u_texsize:new yn(n),u_pixels_to_tile_units:new rh(n),u_device_pixel_ratio:new gr(n),u_image:new Do(n),u_units_to_pixels:new yn(n),u_tile_units_to_pixels:new gr(n),u_alpha_discard_threshold:new gr(n),u_trim_offset:new yn(n)}),s.cQ=wr,s.cR=Oy,s.cS=By,s.cT=Mf,s.cU=(n,e,i,o,h,a)=>{const u=n.transform,m="globe"===u.projection.name;let x;if("map"===a.paint.get("circle-pitch-alignment"))if(m){const p=vf(u.zoom,e.canonical)*u._pixelsPerMercatorPixel;x=Float32Array.from([p,0,0,p])}else x=u.calculatePixelsToTileUnitsMatrix(i);else x=new Float32Array([u.pixelsToGLUnits[0],0,0,u.pixelsToGLUnits[1]]);const w={u_camera_to_center_distance:n.transform.getCameraToCenterDistance(u.projection),u_matrix:n.translatePosMatrix(e.projMatrix,i,a.paint.get("circle-translate"),a.paint.get("circle-translate-anchor")),u_device_pixel_ratio:Qe.devicePixelRatio,u_extrude_scale:x,u_inv_rot_matrix:Vg,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:a.paint.get("circle-emissive-strength")};if(m){w.u_inv_rot_matrix=o,w.u_merc_center=h,w.u_tile_id=[e.canonical.x,e.canonical.y,1<{const u=n.transform;return{u_matrix:zm(n,e,i,o),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:u.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:h,u_image:0,u_tile_units_to_pixels:Pm(e,u),u_units_to_pixels:[1/u.pixelsToGLUnits[0],1/u.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:a}},s.cX=(n,e,i,o,h,a,u)=>{const m=n.transform,x=m.calculatePixelsToTileUnitsMatrix(e);return{u_matrix:zm(n,e,i,o),u_pixels_to_tile_units:x,u_device_pixel_ratio:a,u_units_to_pixels:[1/m.pixelsToGLUnits[0],1/m.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:h,u_texsize:Rm(i)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:Pm(e,n.transform),u_alpha_discard_threshold:0,u_trim_offset:u,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toRenderColor(i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength")}},s.cY=qs,s.cZ=sh,s.c_=xm,s.ca=Lr,s.cb=function(n){return[Math.pow(n[0],1/2.2),Math.pow(n[1],1/2.2),Math.pow(n[2],1/2.2)]},s.cc=function(n){return n({pluginStatus:or,pluginURL:to}),Fc.on("pluginStateChange",n),n},s.cd=Hl,s.ce=Md,s.cf=jl,s.cg=Rp,s.ch=Ql,s.ci=wu,s.cj=Tt,s.ck=Ar,s.cl=Zr,s.cm=function(n){const e=n.indexOf("\x1f");return e>=0?n.slice(0,e):n},s.cn=function(n){return n.indexOf("\x1f")>=0},s.co=function(n){const e=n.indexOf("\x1f");return e>=0?n.slice(e+1):""},s.cp=function(n){const e=[],i=n.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===n.render&&e.push({message:`layers.${i}: missing required method "render"`}),n.renderingMode&&"2d"!==n.renderingMode&&"3d"!==n.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},s.cq=function(n,e,i,o){return"custom"===n.type?new f0(n,e):new S0[n.type](n,e,i,o)},s.cr=Go,s.cs=Fc,s.ct=Xs,s.cu=ih,s.cv=class extends Fn{constructor(n){super(n),this.current=Jd}set(n,e,i){if(this.fetchUniformLocation(n,e))for(let o=0;o<9;o++)if(i[o]!==this.current[o]){this.current=i,this.gl.uniformMatrix3fv(this.location,!1,i);break}}},s.cw=_o,s.cx=function(n,e,i){const o=Cs(i.zoom),h=n.style.map._antialias,a=e.options.extStandardDerivativesForceOff||n.terrain&&n.terrain.exaggeration()>0;return 0===o&&!h&&!a},s.cy=function(n){const e=n.pixelsPerMeter,i=e/$(1,n.center.lat),o=ue.mat4.identity(new Float64Array(16));return ue.mat4.translate(o,o,[n.point.x,n.point.y,0]),ue.mat4.scale(o,o,[i,i,e]),Float32Array.from(o)},s.cz=Uu,s.d=function(n){return le.API_TILEJSON_REGEX.test(n)},s.d$=Mi,s.d0=Qu,s.d1=zs,s.d2=450,s.d3=7,s.d4=p0,s.d5=ti,s.d6=zl,s.d7=256,s.d8=sp,s.d9=no,s.dA=wf,s.dB=function(n){const e=[0,0,0],i=ue.mat4.identity(new Float64Array(16));return ue.mat4.multiply(i,n.pixelMatrix,n.globeMatrix),ue.vec3.transformMat4(e,e,i),new He(e[0],e[1])},s.dC=function(n,e,i=!1){if(or===fa||or===ma||or===bl)throw new Error("setRTLTextPlugin cannot be called multiple times.");to=Qe.resolveURL(n),or=fa,_s=e,Bc(),i||Vc()},s.dD=Nc,s.dE=function(){Md().acquire(rf)},s.dF=function(){const n=Rh;n&&(n.isPreloaded()&&1===n.numActive()?(n.release(rf),Rh=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()"))},s.dG=Dh,s.dH=function(n){const e=Di();if(!e)return;const i=e.delete(St);n&&i.catch(n).then(()=>n())},s.dI=zh,s.dJ=ug,s.dK=function(n){nf=Qe.resolveURL(n),Yl||(Yl=new Hl(Md(),new Xo)),Yl.broadcast("setDracoUrl",nf)},s.dL=dg,s.dM=function(n){Xl=Qe.resolveURL(n),Yl||(Yl=new Hl(Md(),new Xo)),Yl.broadcast("setMeshoptUrl",Xl)},s.dN=rt,s.dO=Ps,s.dP=2,s.dQ=bg,s.dR=Tg,s.dS=Sm,s.dT=yo,s.dU=e_,s.dV=function(n,e,i,o,h,a,u,m,x,w,p){n.createArrays(),n.tilePixelRatio=We/(512*n.overscaling),n.compareText={},n.iconsNeedLinear=!1;const g=n.layers[0].layout,b=n.layers[0]._unevaluatedLayout._values,y={};if("composite"===n.textSizeData.kind){const{minZoom:C,maxZoom:R}=n.textSizeData;y.compositeTextSizes=[b["text-size"].possiblyEvaluate(new Bi(C),m),b["text-size"].possiblyEvaluate(new Bi(R),m)]}if("composite"===n.iconSizeData.kind){const{minZoom:C,maxZoom:R}=n.iconSizeData;y.compositeIconSizes=[b["icon-size"].possiblyEvaluate(new Bi(C),m),b["icon-size"].possiblyEvaluate(new Bi(R),m)]}y.layoutTextSize=b["text-size"].possiblyEvaluate(new Bi(x+1),m),y.layoutIconSize=b["icon-size"].possiblyEvaluate(new Bi(x+1),m),y.textMaxSize=b["text-size"].possiblyEvaluate(new Bi(18),m);const v="map"===g.get("text-rotation-alignment")&&"point"!==g.get("symbol-placement"),M=g.get("text-size");let E=!1;for(const C of n.features)if(C.icon&&C.icon.nameSecondary){E=!0;break}for(const C of n.features){const R=g.get("text-font").evaluate(C,{},m).join(","),k=M.evaluate(C,{},m),P=y.layoutTextSize.evaluate(C,{},m),O=(y.layoutIconSize.evaluate(C,{},m),{horizontal:{},vertical:void 0}),B=C.text;let G,H=[0,0];if(B){const te=B.toString(),K=24*g.get("text-letter-spacing").evaluate(C,{},m),re=24*g.get("text-line-height").evaluate(C,{},m),he=Vd(te)?K:0,pe=g.get("text-anchor").evaluate(C,{},m),fe=g.get("text-variable-anchor");if(!fe){const Oe=g.get("text-radial-offset").evaluate(C,{},m);H=Oe?o_(pe,[24*Oe,Lp]):g.get("text-offset").evaluate(C,{},m).map(Ee=>24*Ee)}let me=v?"center":g.get("text-justify").evaluate(C,{},m);const we="point"===g.get("symbol-placement"),ge=we?24*g.get("text-max-width").evaluate(C,{},m):1/0,Pe=Oe=>{n.allowVerticalPlacement&&yl(te)&&(O.vertical=Pp(B,e,i,h,R,ge,re,pe,Oe,he,H,hn.vertical,!0,P,k))};if(!v&&fe){const Oe="auto"===me?fe.map(Ye=>kp(Ye)):[me];let Ee=!1;for(let Ye=0;Ye=0||!yl(te)){const Oe=Pp(B,e,i,h,R,ge,re,pe,me,he,H,hn.horizontal,!1,P,k);Oe&&(O.horizontal[me]=Oe)}Pe(we?"left":me)}}let X=!1;if(C.icon&&C.icon.namePrimary){const te=o[C.icon.namePrimary];te&&(G=Hy(h[C.icon.namePrimary],C.icon.nameSecondary?h[C.icon.nameSecondary]:void 0,g.get("icon-offset").evaluate(C,{},m),g.get("icon-anchor").evaluate(C,{},m)),X=te.sdf,void 0===n.sdfIcons?n.sdfIcons=te.sdf:n.sdfIcons!==te.sdf&&Qt("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(te.pixelRatio!==n.pixelRatio||0!==g.get("icon-rotate").constantOr(1))&&(n.iconsNeedLinear=!0))}const Z=a_(O.horizontal)||O.vertical;n.iconsInText||(n.iconsInText=!!Z&&Z.iconsInText),(Z||G)&&e0(n,C,O,G,o,y,P,0,H,X,u,m,w,p,E)}a&&n.generateCollisionDebugBuffers(x,n.collisionBoxArray)},s.dW=Nl,s.dX=Td,s.dY=js,s.dZ=Yf,s.d_=Nm,s.da=Bn,s.db=Yc,s.dc=function(n,e,i,o,h){return zt((n-e)/(i-e)*(h-o)+o,o,h)},s.dd=hl,s.de=de,s.df=class{constructor(n,e,i,o){this.context=n,this.format=o,this.size=i,this.texture=n.gl.createTexture();const[h,a,u]=this.size,{gl:m}=n;m.bindTexture(m.TEXTURE_3D,this.texture),n.pixelStoreUnpackFlipY.set(!1),n.pixelStoreUnpack.set(1),n.pixelStoreUnpackPremultiplyAlpha.set(!1),m.texImage3D(m.TEXTURE_3D,0,this.format,h,a,u,0,jp(this.format),Gp(this.format),e.data)}bind(n,e){const{context:i}=this,{gl:o}=i;o.bindTexture(o.TEXTURE_3D,this.texture),n!==this.minFilter&&(o.texParameteri(o.TEXTURE_3D,o.TEXTURE_MAG_FILTER,n),o.texParameteri(o.TEXTURE_3D,o.TEXTURE_MIN_FILTER,n),this.minFilter=n),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:n}=this.context;n.deleteTexture(this.texture),this.texture=null}},s.dg=Hp,s.dh=[1,1,1],s.di=$l,s.dj=Zl,s.dk=oo,s.dl=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new He(1/0,1/0),max:new He(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(n,e=!1){const i=im(new He(0,0),new He(We,We),n),o=[];if(e&&!xp(i,this._globalClipBounds))return o;for(const h of this._activeRegions){if(h.hiddenByOverlap||!xp(i,h))continue;const a=cy(h.min,h.max,n);o.push({min:a.min,max:a.max,sourceId:this._sourceIds[h.priority],footprint:h.footprint,footprintTileId:h.tileId,order:h.order,clipMask:h.clipMask,clipScope:h.clipScope})}return o}setSources(n){this._setSources(n.map(e=>({getSourceId:()=>e.cache.id,getFootprints:()=>{const i=[];for(const o of e.cache.getVisibleCoordinates()){const h=e.cache.getTile(o).buckets[e.layer];h&&h.updateFootprints(o.toUnwrapped(),i)}return i},getOrder:()=>e.order,getClipMask:()=>e.clipMask,getClipScope:()=>e.clipScope})))}_addSource(n){const e=n.getFootprints();if(0===e.length)return;const i=n.getOrder(),o=n.getClipMask(),h=n.getClipScope();for(const a of e){if(!a.footprint)continue;const u=im(a.footprint.min,a.footprint.max,a.id);this._activeRegions.push({min:u.min,max:u.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:a.id,footprint:a.footprint,order:i,clipMask:o,clipScope:h})}this._sourceIds.push(n.getSourceId())}_computeReplacement(){this._activeRegions.sort((e,i)=>e.priority-i.priority||Ku(e.min,i.min)||Ku(e.max,i.max)||e.order-i.order||e.clipMask-i.clipMask||function(o,h){const a=(u,m)=>u+m;return o.length-h.length||o.reduce(a,"").localeCompare(h.reduce(a,""))}(e.clipScope,i.clipScope));let n=this._activeRegions.length!==this._prevRegions.length;if(!n){let e=0;for(;!n&&e!==this._activeRegions.length;){const i=this._activeRegions[e],o=this._prevRegions[e];n=i.priority!==o.priority||!tm(i,o)||i.order!==o.order||i.clipMask!==o.clipMask||!mo(i.clipScope,o.clipScope),++e}}if(n){++this._updateTime;for(const i of this._activeRegions)i.order!==Yu&&(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 h=o[i].priority;for(;i1){let i=0,o=e(i);for(;i!==o;){let h=i;const a=i;for(;h!==o;){const u=this._activeRegions[h];u.hiddenByOverlap=!1;for(let m=0;m=0;e--)this._addSource(n[e]);this._computeReplacement()}},s.dm=class{constructor(n){this._createGrid(n),this._createPoles(n)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const n of this._poleSegments)n.destroy();for(const n of this._gridSegments)n.withSkirts.destroy(),n.withoutSkirts.destroy()}_fillGridMeshWithLods(n,e){const i=new io,o=new cr,h=[],a=n+1+2,u=e[0]+1,m=e[0]+1+(1+e.length),x=(w,p,g)=>{let b=w===a-1?w-2:0===w?w:w-1;return b+=g?24575:0,[b,p]};for(let w=0;w=n.byteLength)&&Qt("Invalid b3dm header information.")}return yg(n,e)},s.e1=function(n,e){const i=vg(n);for(const o of i){for(const h of o.meshes)ux(h);o.lights&&(o.lightMeshIndex=o.meshes.length,o.meshes.push(dx(o.lights,e)))}return i},s.e2=wd,s.e3=W_,s.e4=zr,s.e5=function(n){Xi(),Rt?.then(e=>{e.keys().then(i=>{for(let o=0;o"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""))},s.k=function(n){return btoa(encodeURIComponent(n).replace(/%([0-9A-F]{2})/g,(e,i)=>String.fromCharCode(+("0x"+i))))},s.l=pr,s.m=lr,s.n=function(n,e){return Xs(pr(n,{type:"json"}),e)},s.o=pn,s.p=function(n,e){return Xs(pr(n,{method:"POST"}),e)},s.q=Qe,s.r=Sr,s.s=function(n){try{const e=self[n];return e.setItem("_mapbox_test_",1),e.removeItem("_mapbox_test_"),!0}catch{return!1}},s.t=Ks,s.u=function(){return function n(e){return e?(e^Math.random()*(16>>e/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,n)}()},s.v=function(n){return!!n&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(n)},s.w=Qt,s.x=Xn,s.y=2,s.z=Qm}),si(0,function(s){function Mi(Se){const j=Se?Se.url.toString():void 0;return j?performance.getEntriesByName(j):[]}function vi(Se){if("number"==typeof Se||"boolean"==typeof Se||"string"==typeof Se||null==Se)return JSON.stringify(Se);if(Array.isArray(Se)){let q="[";for(const ee of Se)q+=`${vi(ee)},`;return`${q}]`}let j="{";for(const q of Object.keys(Se).sort())j+=`${q}:${vi(Se[q])},`;return`${j}}`}function st(Se){let j="";for(const q of s.bg)j+=`/${vi(Se[q])}`;return j}class vt{constructor(j){this.keyCache={},this._layers={},this._layerConfigs={},j&&this.replace(j)}replace(j,q){this._layerConfigs={},this._layers={},this.update(j,[],q)}update(j,q,ee){this._options=ee;for(const se of j)this._layerConfigs[se.id]=se,(this._layers[se.id]=s.cq(se,this.scope,null,this._options)).compileFilter(ee),this.keyCache[se.id]&&delete this.keyCache[se.id];for(const se of q)delete this.keyCache[se],delete this._layerConfigs[se],delete this._layers[se];this.familiesBySource={};const le=function(se,_e){const Te={};for(let Me=0;Methis._layers[Ve.id]),Te=_e[0];if("none"===Te.visibility)continue;const ve=Te.source||"";let Me=this.familiesBySource[ve];Me||(Me=this.familiesBySource[ve]={});const De=Te.sourceLayer||"_geojsonTileLayer";let Ce=Me[De];Ce||(Ce=Me[De]=[]),Ce.push(_e)}}}const Gt=1*s.dP;class qt{constructor(j){const q={},ee=[];for(const Te in j){const ve=j[Te],Me=q[Te]={};for(const De in ve.glyphs){const Ce=ve.glyphs[+De];if(!Ce||0===Ce.bitmap.width||0===Ce.bitmap.height)continue;const Ve=Ce.metrics.localGlyph?Gt:1,Ke={x:0,y:0,w:Ce.bitmap.width+2*Ve,h:Ce.bitmap.height+2*Ve};ee.push(Ke),Me[De]=Ke}}const{w:le,h:se}=s.z(ee),_e=new s.dO({width:le||1,height:se||1});for(const Te in j){const ve=j[Te];for(const Me in ve.glyphs){const De=ve.glyphs[+Me];if(!De||0===De.bitmap.width||0===De.bitmap.height)continue;const Ce=q[Te][Me],Ve=De.metrics.localGlyph?Gt:1;s.dO.copy(De.bitmap,_e,{x:0,y:0},{x:Ce.x+Ve,y:Ce.y+Ve},De.bitmap)}}this.image=_e,this.positions=q}}s.dN(qt,"GlyphAtlas");class ft{constructor(j){this.tileID=new s.aA(j.tileID.overscaledZ,j.tileID.wrap,j.tileID.canonical.z,j.tileID.canonical.x,j.tileID.canonical.y),this.tileZoom=j.tileZoom,this.uid=j.uid,this.zoom=j.zoom,this.lut=j.lut,this.canonical=j.tileID.canonical,this.pixelRatio=j.pixelRatio,this.tileSize=j.tileSize,this.source=j.source,this.scope=j.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=j.showCollisionBoxes,this.collectResourceTiming=!!j.collectResourceTiming,this.promoteId=j.promoteId,this.isSymbolTile=j.isSymbolTile,this.tileTransform=s.aK(j.tileID.canonical,j.projection),this.projection=j.projection,this.brightness=j.brightness,this.extraShadowCaster=!!j.extraShadowCaster,this.tessellationStep=j.tessellationStep}parse(j,q,ee,le,se){this.status="parsing",this.data=j,this.collisionBoxArray=new s.aQ;const _e=new s.dQ(Object.keys(j.layers).sort()),Te=new s.dR(this.tileID,this.promoteId);Te.bucketLayerIDs=[];const ve={},Me=new s.dS(256,256),De={featureIndex:Te,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:Me,availableImages:ee,brightness:this.brightness},Ce=q.familiesBySource[this.source];for(const Mt in Ce){const ai=j.layers[Mt];if(!ai)continue;let pi=!1,Rt=!1,ui=!1;for(const Ki of Ce[Mt])"symbol"===Ki[0].type?pi=!0:Rt=!0,Ki[0].is3D()&&"model"!==Ki[0].type&&(ui=!0);if(this.extraShadowCaster&&!ui||!0===this.isSymbolTile&&!pi||!1===this.isSymbolTile&&!Rt)continue;1===ai.version&&s.w(`Vector tile source "${this.source}" layer "${Mt}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const Di=_e.encode(Mt),Xi=[];for(let Ki=0;Ki=lr.maxzoom||"none"!==lr.visibility&&(Nt(Ki,this.zoom,De.brightness,ee),(ve[lr.id]=lr.createBucket({index:Te.bucketLayerIDs.length,layers:Ki,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:Di,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep})).populate(Xi,De,this.tileID.canonical,this.tileTransform),Te.bucketLayerIDs.push(Ki.map(en=>en.id))))}}let Ve,Ke,Qe,bt;Me.trim();const Tt={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},St=()=>{if(Ve)return this.status="done",se(Ve);if(this.extraShadowCaster)this.status="done",se(null,{buckets:s.bd(ve).filter(Mt=>!Mt.isEmpty()),featureIndex:Te,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:De.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(Ke&&Qe&&bt){const Mt=new qt(Ke),ai=new s.dU(Qe,bt,this.lut);for(const pi in ve){const Rt=ve[pi];Rt instanceof s.aR?(Nt(Rt.layers,this.zoom,De.brightness,ee),s.dV(Rt,Ke,Mt.positions,Qe,ai.iconPositions,this.showCollisionBoxes,ee,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):Rt.hasPattern&&(Rt instanceof s.aX||Rt instanceof s.aY||Rt instanceof s.d0)&&(Nt(Rt.layers,this.zoom,De.brightness,ee),Rt.addFeatures(De,this.tileID.canonical,ai.patternPositions,ee,this.tileTransform,this.brightness))}this.status="done",se(null,{buckets:s.bd(ve).filter(pi=>!pi.isEmpty()),featureIndex:Te,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:Mt.image,lineAtlas:Me,imageAtlas:ai,brightness:De.brightness})}};if(!this.extraShadowCaster){const Mt=s.dT(De.glyphDependencies,Rt=>Object.keys(Rt).map(Number));Object.keys(Mt).length?le.send("getGlyphs",{uid:this.uid,stacks:Mt,scope:this.scope},(Rt,ui)=>{Ve||(Ve=Rt,Ke=ui,St())},void 0,!1,Tt):Ke={};const ai=Object.keys(De.iconDependencies);ai.length?le.send("getImages",{icons:ai,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},(Rt,ui)=>{Ve||(Ve=Rt,Qe=ui,St())},void 0,!1,Tt):Qe={};const pi=Object.keys(De.patternDependencies);pi.length?le.send("getImages",{icons:pi,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},(Rt,ui)=>{Ve||(Ve=Rt,bt=ui,St())},void 0,!1,Tt):bt={}}St()}}function Nt(Se,j,q,ee){const le=new s.a3(j,{brightness:q});for(const se of Se)se.recalculate(le,ee)}class ni extends s.E{constructor(j,q,ee,le,se,_e){super(),this.actor=j,this.layerIndex=q,this.availableImages=ee,this.loadVectorData=se||s.aw,this.loading={},this.loaded={},this.deduped=new s.au(j.scheduler),this.isSpriteLoaded=le,this.scheduler=j.scheduler,this.brightness=_e}loadTile(j,q){const ee=j.uid,le=j&&j.request,se=le&&le.collectResourceTiming,_e=this.loading[ee]=new ft(j);_e.abort=this.loadVectorData(j,(Te,ve)=>{const Me=!this.loading[ee];if(delete this.loading[ee],Me||Te||!ve)return _e.status="done",Me||(this.loaded[ee]=_e),q(Te);const De=ve.rawData,Ce={};ve.expires&&(Ce.expires=ve.expires),ve.cacheControl&&(Ce.cacheControl=ve.cacheControl),_e.vectorTile=ve.vectorTile||new s.dW.VectorTile(new s.bb(De));const Ve=()=>{_e.parse(_e.vectorTile,this.layerIndex,this.availableImages,this.actor,(Ke,Qe)=>{if(Ke||!Qe)return q(Ke);const bt={};if(se){const Tt=Mi(le);Tt.length>0&&(bt.resourceTiming=JSON.parse(JSON.stringify(Tt)))}q(null,s.l({rawTileData:De.slice(0)},Qe,Ce,bt))})};this.isSpriteLoaded?Ve():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(Ve,{type:"parseTile",isSymbolTile:j.isSymbolTile,zoom:j.tileZoom}):Ve()}),this.loaded=this.loaded||{},this.loaded[ee]=_e})}reloadTile(j,q){const ee=this.loaded,le=j.uid;if(ee&&ee[le]){const se=ee[le];se.showCollisionBoxes=j.showCollisionBoxes,se.projection=j.projection,se.brightness=j.brightness,se.tileTransform=s.aK(j.tileID.canonical,j.projection),se.extraShadowCaster=j.extraShadowCaster,se.lut=j.lut;const _e=(Te,ve)=>{const Me=se.reloadCallback;Me&&(delete se.reloadCallback,se.parse(se.vectorTile,this.layerIndex,this.availableImages,this.actor,Me)),q(Te,ve)};"parsing"===se.status?se.reloadCallback=_e:"done"===se.status&&(se.vectorTile?se.parse(se.vectorTile,this.layerIndex,this.availableImages,this.actor,_e):_e())}else q(null,void 0)}abortTile(j,q){const ee=j.uid,le=this.loading[ee];le&&(le.abort&&le.abort(),delete this.loading[ee]),q()}removeTile(j,q){const ee=this.loaded,le=j.uid;ee&&ee[le]&&delete ee[le],q()}}class kt{loadTile(j,q){const{uid:ee,encoding:le,rawImageData:se,padding:_e}=j,Te=ImageBitmap&&se instanceof ImageBitmap?this.getImageData(se,_e):se;q(null,new s.dX(ee,Te,le,_e<1))}getImageData(j,q){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(j.width,j.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=j.width,this.offscreenCanvas.height=j.height,this.offscreenCanvasContext.drawImage(j,0,0,j.width,j.height);const ee=this.offscreenCanvasContext.getImageData(-q,-q,j.width+2*q,j.height+2*q);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),ee}}s.ba.setPbf(s.bb);class Ri{decodeRasterArray({task:j,buffer:q},ee){s.ba.performDecoding(q,j).then(le=>{ee(null,le)},le=>{ee(le)})}}const _i=s.dW.VectorTileFeature.prototype.toGeoJSON;class gt{constructor(j){this._feature=j,this.extent=s.ab,this.type=j.type,this.properties=j.tags,"id"in j&&!isNaN(j.id)&&(this.id=parseInt(j.id,10))}loadGeometry(){if(1===this._feature.type){const j=[];for(const q of this._feature.geometry)j.push([new s.P(q[0],q[1])]);return j}{const j=[];for(const q of this._feature.geometry){const ee=[];for(const le of q)ee.push(new s.P(le[0],le[1]));j.push(ee)}return j}}toGeoJSON(j,q,ee){return _i.call(this,j,q,ee)}}class Oi{constructor(j){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=s.ab,this.length=j.length,this._features=j}feature(j){return new gt(this._features[j])}}const tr=64/4096;class zi{constructor(){this.features=new Map}clear(){this.features.clear()}load(j=[],q){for(const ee of j){const le=ee.id;if(null==le)continue;let se=this.features.get(le);se&&this.updateCache(se,q),ee.geometry?(se=tt(ee),this.updateCache(se,q),this.features.set(le,se)):this.features.delete(le),this.updateCache(se,q)}}updateCache(j,q){for(const{canonical:ee,uid:le}of Object.values(q)){const{z:se,x:_e,y:Te}=ee;Pt(j,Math.pow(2,se),_e,Te)&&delete q[le]}}getTile(j,q,ee){const le=Math.pow(2,j),se=[];for(const _e of this.features.values())Pt(_e,le,q,ee)&&se.push(Oa(_e,le,q,ee));return{features:se}}getFeatures(){return[...this.features.values()]}}function Pt({minX:Se,minY:j,maxX:q,maxY:ee},le,se,_e){return Se<(se+1+tr)/le&&j<(_e+1+tr)/le&&q>(se-tr)/le&&ee>(_e-tr)/le}function tt(Se){const{id:j,geometry:q,properties:ee}=Se;if(!q)return;if("GeometryCollection"===q.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:le,coordinates:se}=q,_e={id:j,type:1,geometry:[],tags:ee,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},Te=_e.geometry;if("Point"===le)Je(se,Te,_e);else if("MultiPoint"===le)for(const ve of se)Je(ve,Te,_e);else if("LineString"===le)_e.type=2,uo(se,Te,_e);else if("MultiLineString"===le)_e.type=2,$n(se,Te,_e);else if("Polygon"===le)_e.type=3,$n(se,Te,_e,!0);else{if("MultiPolygon"!==le)throw new Error("Input data is not a valid GeoJSON object.");_e.type=3;for(const ve of se)$n(ve,Te,_e,!0)}return _e}function Je([Se,j],q,ee){const le=s.am(Se);let se=s.at(j);se=se<0?0:se>1?1:se,q.push(le,se),ee.minX=Math.min(ee.minX,le),ee.minY=Math.min(ee.minY,se),ee.maxX=Math.max(ee.maxX,le),ee.maxY=Math.max(ee.maxY,se)}function uo(Se,j,q,ee=!1,le=!1){const se=[];for(const _e of Se)Je(_e,se,q);j.push(se),ee&&function(_e,Te){let ve=0;for(let Me=0,De=_e.length,Ce=De-2;Me0===Te)for(let Me=0,De=_e.length;Me=_e&&Ce>=_e||(Me>=_e?(De+=Math.round(Qe*((_e-Me)/Ke)),Me=_e):Ce>=_e&&(Ve=De+Math.round(Qe*((_e-Me)/Ke)),Ce=_e),De>=_e&&Ve>=_e||(De>=_e?(Me+=Math.round(Ke*((_e-De)/Qe)),De=_e):Ve>=_e&&(Ce=Me+Math.round(Ke*((_e-De)/Qe)),Ve=_e),Te&&Me===Te[Te.length-1][0]&&De===Te[Te.length-1][1]||(Te=[[Me,De]],le.push(Te)),Te.push([Ce,Ve])))))}}var yr,En,Bo,Dt={exports:{}},po=function(){if(Bo)return Dt.exports;Bo=1;var Se=s.d_(),j=function(){if(En)return yr;En=1;var De=s.dY(),Ce=s.dZ().VectorTileFeature;function Ve(Qe,bt){this.options=bt||{},this.features=Qe,this.length=Qe.length}function Ke(Qe,bt){this.id="number"==typeof Qe.id?Qe.id:void 0,this.type=Qe.type,this.rawGeometry=1===Qe.type?[Qe.geometry]:Qe.geometry,this.properties=Qe.tags,this.extent=bt||4096}return yr=Ve,Ve.prototype.feature=function(Qe){return new Ke(this.features[Qe],this.options.extent)},Ke.prototype.loadGeometry=function(){var Qe=this.rawGeometry;this.geometry=[];for(var bt=0;bt>31}function ve(De,Ce){for(var Ve=De.loadGeometry(),Ke=De.type,Qe=0,bt=0,Tt=Ve.length,St=0;StSe},At=Math.fround||(Vs=new Float32Array(1),Se=>(Vs[0]=+Se,Vs[0]));var Vs;class Us{constructor(j){this.options=Object.assign(Object.create(Fo),j),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(j){const{log:q,minZoom:ee,maxZoom:le}=this.options;q&&console.time("total time");const se=`prepare ${j.length} points`;q&&console.time(se),this.points=j;const _e=[];for(let ve=0;ve=ee;ve--){const Me=+Date.now();Te=this.trees[ve]=this._createTree(this._cluster(Te,ve)),q&&console.log("z%d: %d clusters in %dms",ve,Te.numItems,+Date.now()-Me)}return q&&console.timeEnd("total time"),this}getClusters(j,q){let ee=((j[0]+180)%360+360)%360-180;const le=Math.max(-90,Math.min(90,j[1]));let se=180===j[2]?180:((j[2]+180)%360+360)%360-180;const _e=Math.max(-90,Math.min(90,j[3]));if(j[2]-j[0]>=360)ee=-180,se=180;else if(ee>se){const Ce=this.getClusters([ee,le,180,_e],q),Ve=this.getClusters([-180,le,se,_e],q);return Ce.concat(Ve)}const Te=this.trees[this._limitZoom(q)],ve=Te.range(An(ee),Hn(_e),An(se),Hn(le)),Me=Te.data,De=[];for(const Ce of ve){const Ve=this.stride*Ce;De.push(Me[Ve+5]>1?fo(Me,Ve,this.clusterProps):this.points[Me[Ve+3]])}return De}getChildren(j){const q=this._getOriginId(j),ee=this._getOriginZoom(j),le="No cluster with the specified id.",se=this.trees[ee];if(!se)throw new Error(le);const _e=se.data;if(q*this.stride>=_e.length)throw new Error(le);const Te=this.options.radius/(this.options.extent*Math.pow(2,ee-1)),ve=se.within(_e[q*this.stride],_e[q*this.stride+1],Te),Me=[];for(const De of ve){const Ce=De*this.stride;_e[Ce+4]===j&&Me.push(_e[Ce+5]>1?fo(_e,Ce,this.clusterProps):this.points[_e[Ce+3]])}if(0===Me.length)throw new Error(le);return Me}getLeaves(j,q,ee){const le=[];return this._appendLeaves(le,j,q=q||10,ee=ee||0,0),le}getTile(j,q,ee){const le=this.trees[this._limitZoom(j)],se=Math.pow(2,j),{extent:_e,radius:Te}=this.options,ve=Te/_e,Me=(ee-ve)/se,De=(ee+1+ve)/se,Ce={features:[]};return this._addTileFeatures(le.range((q-ve)/se,Me,(q+1+ve)/se,De),le.data,q,ee,se,Ce),0===q&&this._addTileFeatures(le.range(1-ve/se,Me,1,De),le.data,se,ee,se,Ce),q===se-1&&this._addTileFeatures(le.range(0,Me,ve/se,De),le.data,-1,ee,se,Ce),Ce.features.length?Ce:null}getClusterExpansionZoom(j){let q=this._getOriginZoom(j)-1;for(;q<=this.options.maxZoom;){const ee=this.getChildren(j);if(q++,1!==ee.length)break;j=ee[0].properties.cluster_id}return q}_appendLeaves(j,q,ee,le,se){const _e=this.getChildren(q);for(const Te of _e){const ve=Te.properties;if(ve&&ve.cluster?se+ve.point_count<=le?se+=ve.point_count:se=this._appendLeaves(j,ve.cluster_id,ee,le,se):se1;let De,Ce,Ve;if(Me)De=ue(q,ve,this.clusterProps),Ce=q[ve],Ve=q[ve+1];else{const bt=this.points[q[ve+3]];De=bt.properties;const[Tt,St]=bt.geometry.coordinates;Ce=An(Tt),Ve=Hn(St)}const Ke={type:1,geometry:[[Math.round(this.options.extent*(Ce*se-ee)),Math.round(this.options.extent*(Ve*se-le))]],tags:De};let Qe;Qe=Me||this.options.generateId?q[ve+3]:this.points[q[ve+3]].id,void 0!==Qe&&(Ke.id=Qe),_e.features.push(Ke)}}_limitZoom(j){return Math.max(this.options.minZoom,Math.min(Math.floor(+j),this.options.maxZoom+1))}_cluster(j,q){const{radius:ee,extent:le,reduce:se,minPoints:_e}=this.options,Te=ee/(le*Math.pow(2,q)),ve=j.data,Me=[],De=this.stride;for(let Ce=0;Ceq&&(Tt+=ve[Mt+5])}if(Tt>bt&&Tt>=_e){let St,Mt=Ve*bt,ai=Ke*bt,pi=-1;const Rt=(Ce/De<<5)+(q+1)+this.points.length;for(const ui of Qe){const Di=ui*De;if(ve[Di+2]<=q)continue;ve[Di+2]=q;const Xi=ve[Di+5];Mt+=ve[Di]*Xi,ai+=ve[Di+1]*Xi,ve[Di+4]=Rt,se&&(St||(St=this._map(ve,Ce,!0),pi=this.clusterProps.length,this.clusterProps.push(St)),se(St,this._map(ve,Di)))}ve[Ce+4]=Rt,Me.push(Mt/Tt,ai/Tt,1/0,Rt,-1,Tt),se&&Me.push(pi)}else{for(let St=0;St1)for(const St of Qe){const Mt=St*De;if(!(ve[Mt+2]<=q)){ve[Mt+2]=q;for(let ai=0;ai>5}_getOriginZoom(j){return(j-this.points.length)%32}_map(j,q,ee){if(j[q+5]>1){const _e=this.clusterProps[j[q+6]];return ee?Object.assign({},_e):_e}const le=this.points[j[q+3]].properties,se=this.options.map(le);return ee&&se===le?Object.assign({},se):se}}function fo(Se,j,q){return{type:"Feature",id:Se[j+3],properties:ue(Se,j,q),geometry:{type:"Point",coordinates:[(ee=Se[j],360*(ee-.5)),js(Se[j+1])]}};var ee}function ue(Se,j,q){const ee=Se[j+5],le=ee>=1e4?`${Math.round(ee/1e3)}k`:ee>=1e3?Math.round(ee/100)/10+"k":ee,se=Se[j+6],_e=-1===se?{}:Object.assign({},q[se]);return Object.assign(_e,{cluster:!0,cluster_id:Se[j+3],point_count:ee,point_count_abbreviated:le})}function An(Se){return Se/360+.5}function Hn(Se){const j=Math.sin(Se*Math.PI/180),q=.5-.25*Math.log((1+j)/(1-j))/Math.PI;return q<0?0:q>1?1:q}function js(Se){const j=(180-360*Se)*Math.PI/180;return 360*Math.atan(Math.exp(j))/Math.PI-90}function He(Se,j,q,ee){let le=ee;const se=j+(q-j>>1);let _e,Te=q-j;const ve=Se[j],Me=Se[j+1],De=Se[q],Ce=Se[q+1];for(let Ve=j+3;Vele)_e=Ve,le=Ke;else if(Ke===le){const Qe=Math.abs(Ve-se);Qeee&&(_e-j>3&&He(Se,j,_e,ee),Se[_e+2]=le,q-_e>3&&He(Se,_e,q,ee))}function mo(Se,j,q,ee,le,se){let _e=le-q,Te=se-ee;if(0!==_e||0!==Te){const ve=((Se-q)*_e+(j-ee)*Te)/(_e*_e+Te*Te);ve>1?(q=le,ee=se):ve>0&&(q+=_e*ve,ee+=Te*ve)}return _e=Se-q,Te=j-ee,_e*_e+Te*Te}function ar(Se,j,q,ee){const le={id:Se??null,type:j,geometry:q,tags:ee,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===j||"MultiPoint"===j||"LineString"===j)In(le,q);else if("Polygon"===j)In(le,q[0]);else if("MultiLineString"===j)for(const se of q)In(le,se);else if("MultiPolygon"===j)for(const se of q)In(le,se[0]);return le}function In(Se,j){for(let q=0;q0&&(_e+=ee?(le*De-Me*se)/2:Math.sqrt(Math.pow(Me-le,2)+Math.pow(De-se,2))),le=Me,se=De}const Te=j.length-3;j[2]=1,He(j,0,Te,q),j[Te+2]=1,j.size=Math.abs(_e),j.start=0,j.end=j.size}function _o(Se,j,q,ee){for(let le=0;le1?1:q}function zt(Se,j,q,ee,le,se,_e,Te){if(ee/=j,se>=(q/=j)&&_e=ee)return null;const ve=[];for(const Me of Se){const De=Me.geometry;let Ce=Me.type;const Ve=0===le?Me.minX:Me.minY,Ke=0===le?Me.maxX:Me.maxY;if(Ve>=q&&Ke=ee)continue;let Qe=[];if("Point"===Ce||"MultiPoint"===Ce)Uo(De,Qe,q,ee,le);else if("LineString"===Ce)Cn(De,Qe,q,ee,le,!1,Te.lineMetrics);else if("MultiLineString"===Ce)pr(De,Qe,q,ee,le,!1);else if("Polygon"===Ce)pr(De,Qe,q,ee,le,!0);else if("MultiPolygon"===Ce)for(const bt of De){const Tt=[];pr(bt,Tt,q,ee,le,!0),Tt.length&&Qe.push(Tt)}if(Qe.length){if(Te.lineMetrics&&"LineString"===Ce){for(const bt of Qe)ve.push(ar(Me.id,Ce,bt,Me.tags));continue}"LineString"!==Ce&&"MultiLineString"!==Ce||(1===Qe.length?(Ce="LineString",Qe=Qe[0]):Ce="MultiLineString"),"Point"!==Ce&&"MultiPoint"!==Ce||(Ce=3===Qe.length?"Point":"MultiPoint"),ve.push(ar(Me.id,Ce,Qe,Me.tags))}}return ve.length?ve:null}function Uo(Se,j,q,ee,le){for(let se=0;se=q&&_e<=ee&&Rr(j,Se[se],Se[se+1],Se[se+2])}}function Cn(Se,j,q,ee,le,se,_e){let Te=go(Se);const ve=0===le?Gs:qs;let Me,De,Ce=Se.start;for(let Tt=0;Ttq&&(De=ve(Te,St,Mt,pi,Rt,q),_e&&(Te.start=Ce+Me*De)):ui>ee?Di=q&&(De=ve(Te,St,Mt,pi,Rt,q),Xi=!0),Di>ee&&ui<=ee&&(De=ve(Te,St,Mt,pi,Rt,ee),Xi=!0),!se&&Xi&&(_e&&(Te.end=Ce+Me*De),j.push(Te),Te=go(Se)),_e&&(Ce+=Me)}let Ve=Se.length-3;const Ke=Se[Ve],Qe=Se[Ve+1],bt=0===le?Ke:Qe;bt>=q&&bt<=ee&&Rr(Te,Ke,Qe,Se[Ve+2]),Ve=Te.length-3,se&&Ve>=3&&(Te[Ve]!==Te[0]||Te[Ve+1]!==Te[1])&&Rr(Te,Te[0],Te[1],Te[2]),Te.length&&j.push(Te)}function go(Se){const j=[];return j.size=Se.size,j.start=Se.start,j.end=Se.end,j}function pr(Se,j,q,ee,le,se){for(const _e of Se)Cn(_e,j,q,ee,le,se,!1)}function Rr(Se,j,q,ee){Se.push(j,q,ee)}function Gs(Se,j,q,ee,le,se){const _e=(se-j)/(ee-j);return Rr(Se,se,q+(le-q)*_e,1),_e}function qs(Se,j,q,ee,le,se){const _e=(se-q)/(le-q);return Rr(Se,j+(ee-j)*_e,se,1),_e}function jo(Se,j){const q=[];for(let ee=0;ee0&&j.size<(le?_e:ee))return void(q.numPoints+=j.length/3);const Te=[];for(let ve=0;ve_e)&&(q.numSimplified++,Te.push(j[ve],j[ve+1])),q.numPoints++;le&&function(ve,Me){let De=0;for(let Ce=0,Ve=ve.length,Ke=Ve-2;Ce0===Me)for(let Ce=0,Ve=ve.length;Ce24)throw new Error("maxZoom should be in the 0-24 range");if(q.promoteId&&q.generateId)throw new Error("promoteId and generateId cannot be used together.");let le=function(se,_e){const Te=[];if("FeatureCollection"===se.type)for(let ve=0;ve1&&console.time("creation"),Ke=this.tiles[Ve]=Zr(j,q,ee,le,Me),this.tileCoords.push({z:q,x:ee,y:le}),De)){De>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",q,ee,le,Ke.numFeatures,Ke.numPoints,Ke.numSimplified),console.timeEnd("creation"));const Xi=`z${q}`;this.stats[Xi]=(this.stats[Xi]||0)+1,this.total++}if(Ke.source=j,null==se){if(q===Me.indexMaxZoom||Ke.numPoints<=Me.indexMaxPoints)continue}else{if(q===Me.maxZoom||q===se)continue;if(null!=se){const Xi=se-q;if(ee!==_e>>Xi||le!==Te>>Xi)continue}}if(Ke.source=null,0===j.length)continue;De>1&&console.time("clipping");const Qe=.5*Me.buffer/Me.extent,bt=.5-Qe,Tt=.5+Qe,St=1+Qe;let Mt=null,ai=null,pi=null,Rt=null,ui=zt(j,Ce,ee-Qe,ee+Tt,0,Ke.minX,Ke.maxX,Me),Di=zt(j,Ce,ee+bt,ee+St,0,Ke.minX,Ke.maxX,Me);j=null,ui&&(Mt=zt(ui,Ce,le-Qe,le+Tt,1,Ke.minY,Ke.maxY,Me),ai=zt(ui,Ce,le+bt,le+St,1,Ke.minY,Ke.maxY,Me),ui=null),Di&&(pi=zt(Di,Ce,le-Qe,le+Tt,1,Ke.minY,Ke.maxY,Me),Rt=zt(Di,Ce,le+bt,le+St,1,Ke.minY,Ke.maxY,Me),Di=null),De>1&&console.timeEnd("clipping"),ve.push(Mt||[],q+1,2*ee,2*le),ve.push(ai||[],q+1,2*ee,2*le+1),ve.push(pi||[],q+1,2*ee+1,2*le),ve.push(Rt||[],q+1,2*ee+1,2*le+1)}}getTile(j,q,ee){j=+j,q=+q,ee=+ee;const le=this.options,{extent:se,debug:_e}=le;if(j<0||j>24)return null;const Te=1<1&&console.log("drilling down to z%d-%d-%d",j,q,ee);let Me,De=j,Ce=q,Ve=ee;for(;!Me&&De>0;)De--,Ce>>=1,Ve>>=1,Me=this.tiles[Lr(De,Ce,Ve)];return Me&&Me.source?(_e>1&&(console.log("found parent tile z%d-%d-%d",De,Ce,Ve),console.time("drilling down")),this.splitTile(Me.source,De,Ce,Ve,j,q,ee),_e>1&&console.timeEnd("drilling down"),this.tiles[ve]?yo(this.tiles[ve],se):null):null}}function Lr(Se,j,q){return 32*((1<{if(se||!_e)return q(se);if("object"!=typeof _e)return q(new Error(`Input data given to '${j.source}' is not a valid GeoJSON object.`));{try{if(j.filter){const ve=s.M(j.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===ve.result)throw new Error(ve.value.map(Me=>`${Me.key}: ${Me.message}`).join(", "));_e.features=_e.features.filter(Me=>ve.value.evaluate({zoom:0},Me))}j.dynamic?("Feature"===_e.type&&(_e={type:"FeatureCollection",features:[_e]}),j.append||(this._dynamicIndex.clear(),this.loaded={}),this._dynamicIndex.load(_e.features,this.loaded),j.cluster&&(_e.features=this._dynamicIndex.getFeatures())):this.loaded={},this._geoJSONIndex=j.cluster?new Us(function({superclusterOptions:ve,clusterProperties:Me}){if(!Me||!ve)return ve;const De={},Ce={},Ve={accumulated:null,zoom:0},Ke={properties:null},Qe=Object.keys(Me);for(const bt of Qe){const[Tt,St]=Me[bt],Mt=s.M(St),ai=s.M("string"==typeof Tt?[Tt,["accumulated"],["get",bt]]:Tt);De[bt]=Mt.value,Ce[bt]=ai.value}return ve.map=bt=>{Ke.properties=bt;const Tt={};for(const St of Qe)Tt[St]=De[St].evaluate(Ve,Ke);return Tt},ve.reduce=(bt,Tt)=>{Ke.properties=Tt;for(const St of Qe)Ve.accumulated=bt[St],bt[St]=Ce[St].evaluate(Ve,Ke)},ve}(j)).load(_e.features):j.dynamic?this._dynamicIndex:new Ba(ve=_e,j.geojsonVtOptions)}catch(ve){return q(ve)}const Te={};if(le){const ve=Mi(ee);ve&&(Te.resourceTiming={},Te.resourceTiming[j.source]=JSON.parse(JSON.stringify(ve)))}q(null,Te)}var ve})}reloadTile(j,q){const ee=this.loaded;return ee&&ee[j.uid]?j.partial?q(null,void 0):super.reloadTile(j,q):this.loadTile(j,q)}loadGeoJSON(j,q){if(j.request)s.n(j.request,q);else{if("string"!=typeof j.data)return q(new Error(`Input data given to '${j.source}' is not a valid GeoJSON object.`));try{return q(null,JSON.parse(j.data))}catch{return q(new Error(`Input data given to '${j.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(j,q){try{q(null,this._geoJSONIndex.getClusterExpansionZoom(j.clusterId))}catch(ee){q(ee)}}getClusterChildren(j,q){try{q(null,this._geoJSONIndex.getChildren(j.clusterId))}catch(ee){q(ee)}}getClusterLeaves(j,q){try{q(null,this._geoJSONIndex.getLeaves(j.clusterId,j.limit,j.offset))}catch(ee){q(ee)}}}class qo{constructor(j,q){this.tileID=new s.aA(j.tileID.overscaledZ,j.tileID.wrap,j.tileID.canonical.z,j.tileID.canonical.x,j.tileID.canonical.y),this.tileZoom=j.tileZoom,this.uid=j.uid,this.zoom=j.zoom,this.canonical=j.tileID.canonical,this.pixelRatio=j.pixelRatio,this.tileSize=j.tileSize,this.source=j.source,this.overscaling=this.tileID.overscaleFactor(),this.projection=j.projection,this.brightness=q}parse(j,q,ee,le){this.status="parsing";const se=new s.aA(ee.tileID.overscaledZ,ee.tileID.wrap,ee.tileID.canonical.z,ee.tileID.canonical.x,ee.tileID.canonical.y),_e={},Te=q.familiesBySource[ee.source],ve=new s.dR(se,ee.promoteId);return ve.bucketLayerIDs=[],ve.is3DTile=!0,s.e0(j).then(Me=>{if(!Me)return le(new Error("Could not parse tile"));const De=s.e1(Me,1/s.c8(ee.tileID.canonical)),Ce=Me.json.extensionsUsed&&Me.json.extensionsUsed.includes("MAPBOX_mesh_features")||Me.json.asset.extras&&Me.json.asset.extras.MAPBOX_mesh_features,Ve=Me.json.extensionsUsed&&Me.json.extensionsUsed.includes("EXT_meshopt_compression"),Ke=new s.a3(this.zoom,{brightness:this.brightness});for(const Qe in Te)for(const bt of Te[Qe]){const Tt=bt[0];ve.bucketLayerIDs.push(bt.map(Mt=>Mt.id)),Tt.recalculate(Ke,[]);const St=new s.e2(De,se,Ce,Ve,this.brightness,ve);Ce||(St.needsUpload=!0),_e[Tt.fqid]=St,St.evaluate(Tt)}this.status="done",le(null,{buckets:_e,featureIndex:ve})}).catch(Me=>le(new Error(Me.message)))}}class Hs{constructor(j,q,ee,le,se,_e){this.actor=j,this.layerIndex=q,this.brightness=_e,this.loading={},this.loaded={}}loadTile(j,q){const ee=j.uid,le=this.loading[ee]=new qo(j,this.brightness);s.bc(j.request,(se,_e)=>{const Te=!this.loading[ee];return delete this.loading[ee],Te||se?(le.status="done",Te||(this.loaded[ee]=le),q(se)):_e&&0!==_e.byteLength?void le.parse(_e,this.layerIndex,j,(ve,Me)=>{le.status="done",this.loaded=this.loaded||{},this.loaded[ee]=le,ve||!Me?q(ve):q(null,Me)}):(le.status="done",this.loaded[ee]=le,q())})}reloadTile(j,q){const ee=this.loaded,le=j.uid;if(ee&&ee[le]){const se=ee[le];se.projection=j.projection,se.brightness=j.brightness;const _e=(Te,ve)=>{se.reloadCallback&&(delete se.reloadCallback,this.loadTile(j,q)),q(Te,ve)};"parsing"===se.status?se.reloadCallback=_e:"done"===se.status&&this.loadTile(j,q)}}abortTile(j,q){const ee=j.uid;this.loading[ee]&&delete this.loading[ee],q()}removeTile(j,q){const ee=this.loaded,le=j.uid;ee&&ee[le]&&delete ee[le],q()}}class vo{constructor(j){this.self=j,this.actor=new s.e3(j,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=s.bL({name:"mercator"}),this.workerSourceTypes={vector:ni,geojson:$s,"batched-model":Hs},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(q,ee)=>{if(this.workerSourceTypes[q])throw new Error(`Worker source with name "${q}" already registered.`);this.workerSourceTypes[q]=ee},this.self.registerRTLTextPlugin=q=>{if(s.e4.isParsed())throw new Error("RTL text plugin already registered.");s.e4.applyArabicShaping=q.applyArabicShaping,s.e4.processBidirectionalText=q.processBidirectionalText,s.e4.processStyledBidirectionalText=q.processStyledBidirectionalText}}clearCaches(j,q,ee){delete this.layerIndexes[j],delete this.availableImages[j],delete this.workerSources[j],delete this.demWorkerSources[j],delete this.rasterArrayWorkerSource,ee()}checkIfReady(j,q,ee){ee()}setReferrer(j,q){this.referrer=q}spriteLoaded(j,{scope:q,isLoaded:ee}){if(this.isSpriteLoaded[j]||(this.isSpriteLoaded[j]={}),this.isSpriteLoaded[j][q]=ee,this.workerSources[j]&&this.workerSources[j][q])for(const le in this.workerSources[j][q]){const se=this.workerSources[j][q][le];for(const _e in se){const Te=se[_e];Te instanceof ni&&(Te.isSpriteLoaded=ee,Te.fire(new s.x("isSpriteLoaded")))}}}setImages(j,{scope:q,images:ee},le){if(this.availableImages[j]||(this.availableImages[j]={}),this.availableImages[j][q]=ee,this.workerSources[j]&&this.workerSources[j][q]){for(const se in this.workerSources[j][q]){const _e=this.workerSources[j][q][se];for(const Te in _e)_e[Te].availableImages=ee}le()}else le()}setProjection(j,q){this.projections[j]=s.bL(q)}setBrightness(j,q,ee){this.brightness=q,ee()}setLayers(j,q,ee){this.getLayerIndex(j,q.scope).replace(q.layers,q.options),ee()}updateLayers(j,q,ee){this.getLayerIndex(j,q.scope).update(q.layers,q.removedIds,q.options),ee()}loadTile(j,q,ee){q.projection=this.projections[j]||this.defaultProjection,this.getWorkerSource(j,q.type,q.source,q.scope).loadTile(q,ee)}loadDEMTile(j,q,ee){this.getDEMWorkerSource(j,q.source,q.scope).loadTile(q,ee)}decodeRasterArray(j,q,ee){this.getRasterArrayWorkerSource().decodeRasterArray(q,ee)}reloadTile(j,q,ee){q.projection=this.projections[j]||this.defaultProjection,this.getWorkerSource(j,q.type,q.source,q.scope).reloadTile(q,ee)}abortTile(j,q,ee){this.getWorkerSource(j,q.type,q.source,q.scope).abortTile(q,ee)}removeTile(j,q,ee){this.getWorkerSource(j,q.type,q.source,q.scope).removeTile(q,ee)}removeSource(j,q,ee){if(!(this.workerSources[j]&&this.workerSources[j][q.scope]&&this.workerSources[j][q.scope][q.type]&&this.workerSources[j][q.scope][q.type][q.source]))return;const le=this.workerSources[j][q.scope][q.type][q.source];delete this.workerSources[j][q.scope][q.type][q.source],void 0!==le.removeSource?le.removeSource(q,ee):ee()}loadWorkerSource(j,q,ee){try{this.self.importScripts(q.url),ee()}catch(le){ee(le.toString())}}syncRTLPluginState(j,q,ee){try{s.e4.setState(q);const le=s.e4.getPluginURL();if(s.e4.isLoaded()&&!s.e4.isParsed()&&null!=le){this.self.importScripts(le);const se=s.e4.isParsed();ee(se?void 0:new Error(`RTL Text Plugin failed to import scripts from ${le}`),se)}}catch(le){ee(le.toString())}}setDracoUrl(j,q){this.dracoUrl=q}getAvailableImages(j,q){this.availableImages[j]||(this.availableImages[j]={});let ee=this.availableImages[j][q];return ee||(ee=[]),ee}getLayerIndex(j,q){this.layerIndexes[j]||(this.layerIndexes[j]={});let ee=this.layerIndexes[j][q];return ee||(ee=this.layerIndexes[j][q]=new vt,ee.scope=q),ee}getWorkerSource(j,q,ee,le){return this.workerSources[j]||(this.workerSources[j]={}),this.workerSources[j][le]||(this.workerSources[j][le]={}),this.workerSources[j][le][q]||(this.workerSources[j][le][q]={}),this.isSpriteLoaded[j]||(this.isSpriteLoaded[j]={}),this.workerSources[j][le][q][ee]||(this.workerSources[j][le][q][ee]=new this.workerSourceTypes[q]({send:(se,_e,Te,ve,Me,De)=>{this.actor.send(se,_e,Te,j,Me,De)},scheduler:this.actor.scheduler},this.getLayerIndex(j,le),this.getAvailableImages(j,le),this.isSpriteLoaded[j][le],void 0,this.brightness)),this.workerSources[j][le][q][ee]}getDEMWorkerSource(j,q,ee){return this.demWorkerSources[j]||(this.demWorkerSources[j]={}),this.demWorkerSources[j][ee]||(this.demWorkerSources[j][ee]={}),this.demWorkerSources[j][ee][q]||(this.demWorkerSources[j][ee][q]=new kt),this.demWorkerSources[j][ee][q]}getRasterArrayWorkerSource(){return this.rasterArrayWorkerSource||(this.rasterArrayWorkerSource=new Ri),this.rasterArrayWorkerSource}enforceCacheSizeLimit(j,q){s.e5(q)}getWorkerPerformanceMetrics(j,q,ee){ee(void 0,void 0)}}return typeof WorkerGlobalScope<"u"&&typeof self<"u"&&self instanceof WorkerGlobalScope&&(self.worker=new vo(self)),vo}),si(0,function(s){var Mi="3.7.0";const vi={create:"create",load:"load",fullLoad:"fullLoad"},st={mark(l){performance.mark(l)},measure(l,t,r){performance.measure(l,t,r)}};function vt(l){const t=l.name.split("?")[0];return s.a(t)&&t.includes("mapbox-gl.js")?"javascript":s.a(t)&&t.includes("mapbox-gl.css")?"css":s.b(t)?"fontRange":s.c(t)?"sprite":s.i(t)?"style":s.d(t)?"tilejson":"other"}var Gt,qt={},ft=function(){if(Gt)return qt;function l(c){return!t(c)}function t(c){return typeof window>"u"||typeof document>"u"?"not a browser":function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var f,_,T=new Blob([""],{type:"text/javascript"}),S=URL.createObjectURL(T);try{_=new Worker(S),f=!0}catch{f=!1}return _&&_.terminate(),URL.revokeObjectURL(S),f}()?function(){var f=document.createElement("canvas");f.width=f.height=1;var _=f.getContext("2d");if(!_)return!1;var T=_.getImageData(0,0,1,1);return T&&T.width===f.width}()?(void 0===r[d=c&&c.failIfMajorPerformanceCaveat]&&(r[d]=function(f){var _,S,A,I,T=(S=f,A=document.createElement("canvas"),(I=Object.create(l.webGLContextAttributes)).failIfMajorPerformanceCaveat=S,A.getContext("webgl2",I));if(!T)return!1;try{_=T.createShader(T.VERTEX_SHADER)}catch{return!1}return!(!_||T.isContextLost())&&(T.shaderSource(_,"void main() {}"),T.compileShader(_),!0===T.getShaderParameter(_,T.COMPILE_STATUS))}(d)),r[d]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL2 support"):"insufficient Canvas/getImageData support":"insufficient worker support";var d}Gt=1,qt.supported=l,qt.notSupportedReason=t;var r={};return l.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0},qt}();function Nt(l,t,r){const c=document.createElement(l);return null!=t&&(c.className=t),r&&r.appendChild(c),c}function ni(l,t,r){const c=document.createElementNS("http://www.w3.org/2000/svg",l);for(const d of Object.keys(t))c.setAttributeNS(null,d,String(t[d]));return r&&r.appendChild(c),c}const kt=typeof document<"u"?document.documentElement&&document.documentElement.style:null,Ri=kt&&void 0!==kt.userSelect?"userSelect":"WebkitUserSelect";let _i;function gt(){kt&&Ri&&(_i=kt[Ri],kt[Ri]="none")}function Oi(){kt&&Ri&&(kt[Ri]=_i)}function tr(l){l.preventDefault(),l.stopPropagation(),window.removeEventListener("click",tr,!0)}function lt(){window.addEventListener("click",tr,!0),window.setTimeout(()=>{window.removeEventListener("click",tr,!0)},0)}function zi(l,t){const r=l.getBoundingClientRect();return Je(l,r,t)}function Pt(l,t){const r=l.getBoundingClientRect(),c=[];for(let d=0;d=0?0:l.button}function Je(l,t,r){const c=l.offsetWidth===t.width?1:l.offsetWidth/t.width;return new s.P((r.clientX-t.left)*c,(r.clientY-t.top)*c)}const uo="01",$n="NO_ACCESS_TOKEN";class Oa{constructor(t,r,c){this._transformRequestFn=t,this._customAccessToken=r,this._silenceAuthErrors=!!c,this._createSkuToken()}_createSkuToken(){const t=function(){let r="";for(let c=0;c<10;c++)r+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1",uo,r].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=t.token,this._skuTokenExpiresAt=t.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(t,r){return this._transformRequestFn&&this._transformRequestFn(t,r)||{url:t}}normalizeStyleURL(t,r){if(!s.f(t))return t;const c=yr(t);return c.params.push(`sdk=js-${Mi}`),c.path=`/styles/v1${c.path}`,this._makeAPIURL(c,this._customAccessToken||r)}normalizeGlyphsURL(t,r){if(!s.f(t))return t;const c=yr(t);return c.path=`/fonts/v1${c.path}`,this._makeAPIURL(c,this._customAccessToken||r)}normalizeModelURL(t,r){if(!s.f(t))return t;const c=yr(t);return c.path=`/models/v1${c.path}`,this._makeAPIURL(c,this._customAccessToken||r)}normalizeSourceURL(t,r,c,d){if(!s.f(t))return t;const f=yr(t);return f.path=`/v4/${f.authority}.json`,f.params.push("secure"),c&&f.params.push(`language=${c}`),d&&f.params.push(`worldview=${d}`),this._makeAPIURL(f,this._customAccessToken||r)}normalizeSpriteURL(t,r,c,d){const f=yr(t);return s.f(t)?(f.path=`/styles/v1${f.path}/sprite${r}${c}`,this._makeAPIURL(f,this._customAccessToken||d)):(f.path+=`${r}${c}`,En(f))}normalizeTileURL(t,r,c){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!s.f(t))return t;const d=yr(t);d.path=d.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${r||c&&"raster"!==d.authority&&512===c?"@2x":""}${s.m.supported?".webp":"$1"}`),"raster"===d.authority?d.path=`/${s.e.RASTER_URL_PREFIX}${d.path}`:"rasterarrays"===d.authority?d.path=`/${s.e.RASTERARRAYS_URL_PREFIX}${d.path}`:"3dtiles"===d.authority?d.path=`/${s.e.TILES3D_URL_PREFIX}${d.path}`:(d.path=d.path.replace(/^.+\/v4\//,"/"),d.path=`/${s.e.TILE_URL_VERSION}${d.path}`);const f=this._customAccessToken||function(_){for(const T of _){const S=T.match(/^access_token=(.*)$/);if(S)return S[1]}return null}(d.params)||s.e.ACCESS_TOKEN;return s.e.REQUIRE_ACCESS_TOKEN&&f&&this._skuToken&&d.params.push(`sku=${this._skuToken}`),this._makeAPIURL(d,f)}canonicalizeTileURL(t,r){const c=yr(t);if(!c.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!c.path.match(/\.[\w]+$/))return t;let d="mapbox://";c.path.match(/^\/raster\/v1\//)?d+=`raster/${c.path.replace(`/${s.e.RASTER_URL_PREFIX}/`,"")}`:c.path.match(/^\/rasterarrays\/v1\//)?d+=`rasterarrays/${c.path.replace(`/${s.e.RASTERARRAYS_URL_PREFIX}/`,"")}`:d+=`tiles/${c.path.replace(`/${s.e.TILE_URL_VERSION}/`,"")}`;let f=c.params;return r&&(f=f.filter(_=>!_.match(/^access_token=/))),f.length&&(d+=`?${f.join("&")}`),d}canonicalizeTileset(t,r){const c=!!r&&s.f(r),d=[];for(const f of t.tiles||[])s.h(f)?d.push(this.canonicalizeTileURL(f,c)):d.push(f);return d}_makeAPIURL(t,r){const c="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",d=yr(s.e.API_URL);if(t.protocol=d.protocol,t.authority=d.authority,"http"===t.protocol){const f=t.params.indexOf("secure");f>=0&&t.params.splice(f,1)}if("/"!==d.path&&(t.path=`${d.path}${t.path}`),!s.e.REQUIRE_ACCESS_TOKEN)return En(t);if(r=r||s.e.ACCESS_TOKEN,!this._silenceAuthErrors){if(!r)throw new Error(`An API access token is required to use Mapbox GL. ${c}`);if("s"===r[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${c}`)}return t.params=t.params.filter(f=>-1===f.indexOf("access_token")),t.params.push(`access_token=${r||""}`),En(t)}}const Vt=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function yr(l){const t=l.match(Vt);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 En(l){const t=l.params.length?`?${l.params.join("&")}`:"";return`${l.protocol}://${l.authority}${l.path}${t}`}const Bo="mapbox.eventData";function Dt(l){if(!l)return null;const t=l.split(".");if(!t||3!==t.length)return null;try{return JSON.parse(s.j(t[1]))}catch{return null}}class po{constructor(t){this.type=t,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(t){const r=Dt(s.e.ACCESS_TOKEN);let c="";return c=r&&r.u?s.k(r.u):s.e.ACCESS_TOKEN||"",t?`${Bo}.${t}:${c}`:`${Bo}:${c}`}fetchEventData(){const t=s.s("localStorage"),r=this.getStorageKey(),c=this.getStorageKey("uuid");if(t)try{const d=localStorage.getItem(r);d&&(this.eventData=JSON.parse(d));const f=localStorage.getItem(c);f&&(this.anonId=f)}catch{s.w("Unable to read from LocalStorage")}}saveEventData(){const t=s.s("localStorage"),r=this.getStorageKey(),c=this.getStorageKey("uuid"),d=this.anonId;if(t&&d)try{localStorage.setItem(c,d),Object.keys(this.eventData).length>=1&&localStorage.setItem(r,JSON.stringify(this.eventData))}catch{s.w("Unable to write to LocalStorage")}}processRequests(t){}postEvent(t,r,c,d){if(!s.e.EVENTS_URL)return;const f=yr(s.e.EVENTS_URL);f.params.push(`access_token=${d||s.e.ACCESS_TOKEN||""}`);const _={event:this.type,created:new Date(t).toISOString()},T=r?s.l(_,r):_,S={url:En(f),headers:{"Content-Type":"text/plain"},body:JSON.stringify([T])};this.pendingRequest=s.p(S,A=>{this.pendingRequest=null,c(A),this.saveEventData(),this.processRequests(d)})}queueRequest(t,r){this.queue.push(t),this.processRequests(r)}}const Ns=new class extends po{constructor(l){super("appUserTurnstile"),this._customAccessToken=l}postTurnstileEvent(l,t){s.e.EVENTS_URL&&s.e.ACCESS_TOKEN&&Array.isArray(l)&&l.some(r=>s.f(r)||s.h(r))&&this.queueRequest(Date.now(),t)}processRequests(l){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const t=Dt(s.e.ACCESS_TOKEN),r=t?t.u:s.e.ACCESS_TOKEN;let c=r!==this.eventData.tokenU;s.v(this.anonId)||(this.anonId=s.u(),c=!0);const d=this.queue.shift();if(this.eventData.lastSuccess){const f=new Date(this.eventData.lastSuccess),_=new Date(d),T=(d-this.eventData.lastSuccess)/864e5;c=c||T>=1||T<-1||f.getDate()!==_.getDate()}else c=!0;c?this.postEvent(d,{sdkIdentifier:"mapbox-gl-js",sdkVersion:Mi,skuId:uo,"enabled.telemetry":!1,userId:this.anonId},f=>{f||(this.eventData.lastSuccess=d,this.eventData.tokenU=r)},l):this.processRequests()}},Fo=Ns.postTurnstileEvent.bind(Ns),At=new class extends po{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(l,t,r,c){this.skuToken=t,this.errorCb=c,s.e.EVENTS_URL&&(r||s.e.ACCESS_TOKEN?this.queueRequest({id:l,timestamp:Date.now()},r):this.errorCb(new Error($n)))}processRequests(l){if(this.pendingRequest||0===this.queue.length)return;const{id:t,timestamp:r}=this.queue.shift();t&&this.success[t]||(this.anonId||this.fetchEventData(),s.v(this.anonId)||(this.anonId=s.u()),this.postEvent(r,{sdkIdentifier:"mapbox-gl-js",sdkVersion:Mi,skuId:uo,skuToken:this.skuToken,userId:this.anonId},c=>{c?this.errorCb(c):t&&(this.success[t]=!0)},l))}remove(){this.errorCb=null}},Vs=At.postMapLoadEvent.bind(At),Jr=new class extends po{constructor(){super("style.load"),this.eventIdPerMapInstanceMap=new Map,this.mapInstanceIdMap=new WeakMap}getMapInstanceId(l){let t=this.mapInstanceIdMap.get(l);return t||(t=s.u(),this.mapInstanceIdMap.set(l,t)),t}getEventId(l){const t=this.eventIdPerMapInstanceMap.get(l)||0;return this.eventIdPerMapInstanceMap.set(l,t+1),t}postStyleLoadEvent(l,t){const{map:r,style:c,importedStyles:d}=t;if(!s.e.EVENTS_URL||!l&&!s.e.ACCESS_TOKEN)return;const f=this.getMapInstanceId(r),_={mapInstanceId:f,eventId:this.getEventId(f),style:c};d.length&&(_.importedStyles=d),this.queueRequest({timestamp:Date.now(),payload:_},l)}processRequests(l){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:t,payload:r}=this.queue.shift();this.postEvent(t,r,()=>{},l)}},qr=Jr.postStyleLoadEvent.bind(Jr),No=new class extends po{constructor(){super("gljs.performance")}postPerformanceEvent(l,t){s.e.EVENTS_URL&&(l||s.e.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:t},l)}processRequests(l){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:t,performanceData:r}=this.queue.shift(),c=function(d){const f=performance.getEntriesByType("resource"),_=performance.getEntriesByType("mark"),T=function(L){const F={};if(L)for(const N in L)if("other"!==N)for(const V of L[N]){const U=`${N}ResolveRangeMin`,W=`${N}ResolveRangeMax`,Y=`${N}RequestCount`,$=`${N}RequestCachedCount`;F[U]=Math.min(F[U]||1/0,V.startTime),F[W]=Math.max(F[W]||-1/0,V.responseEnd);const Q=J=>{void 0===F[J]&&(F[J]=0),++F[J]};void 0!==V.transferSize&&0===V.transferSize&&Q($),Q(Y)}return F}(function(L,F){const N={};if(L)for(const V of L){const U=F(V);void 0===N[U]&&(N[U]=[]),N[U].push(V)}return N}(f,vt)),S=window.devicePixelRatio,A=navigator.connection||navigator.mozConnection||navigator.webkitConnection,I=A?A.effectiveType:void 0,z={counters:[],metadata:[],attributes:[]},D=(L,F,N)=>{null!=N&&L.push({name:F,value:N.toString()})};for(const L in T)D(z.counters,L,T[L]);if(d.interactionRange[0]!==1/0&&d.interactionRange[1]!==-1/0&&(D(z.counters,"interactionRangeMin",d.interactionRange[0]),D(z.counters,"interactionRangeMax",d.interactionRange[1])),_)for(const L of Object.keys(vi)){const F=vi[L],N=_.find(V=>V.name===F);N&&D(z.counters,F,N.startTime)}return D(z.counters,"visibilityHidden",d.visibilityHidden),D(z.attributes,"style",function(L){if(L)for(const F of L){const N=F.name.split("?")[0];if(s.i(N)){const V=N.split("/").slice(-2);if(2===V.length)return`mapbox://styles/${V[0]}/${V[1]}`}}}(f)),D(z.attributes,"terrainEnabled",d.terrainEnabled?"true":"false"),D(z.attributes,"fogEnabled",d.fogEnabled?"true":"false"),D(z.attributes,"projection",d.projection),D(z.attributes,"zoom",d.zoom),D(z.metadata,"devicePixelRatio",S),D(z.metadata,"connectionEffectiveType",I),D(z.metadata,"navigatorUserAgent",navigator.userAgent),D(z.metadata,"screenWidth",window.screen.width),D(z.metadata,"screenHeight",window.screen.height),D(z.metadata,"windowWidth",window.innerWidth),D(z.metadata,"windowHeight",window.innerHeight),D(z.metadata,"mapWidth",d.width/S),D(z.metadata,"mapHeight",d.height/S),D(z.metadata,"webglRenderer",d.renderer),D(z.metadata,"webglVendor",d.vendor),D(z.metadata,"sdkVersion",Mi),D(z.metadata,"sdkIdentifier","mapbox-gl-js"),z}(r);for(const d of c.metadata);for(const d of c.counters);for(const d of c.attributes);this.postEvent(t,c,()=>{},l)}},Us=No.postPerformanceEvent.bind(No),fo=new class extends po{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(l,t,r,c){if(!s.e.API_URL||!s.e.SESSION_PATH)return;const d=yr(s.e.API_URL+s.e.SESSION_PATH);d.params.push(`sku=${t||""}`),d.params.push(`access_token=${c||s.e.ACCESS_TOKEN||""}`);const f={url:En(d),headers:{"Content-Type":"text/plain"}};this.pendingRequest=s.g(f,_=>{this.pendingRequest=null,r(_),this.saveEventData(),this.processRequests(c)})}getSessionAPI(l,t,r,c){this.skuToken=t,this.errorCb=c,s.e.SESSION_PATH&&s.e.API_URL&&(r||s.e.ACCESS_TOKEN?this.queueRequest({id:l,timestamp:Date.now()},r):this.errorCb(new Error($n)))}processRequests(l){if(this.pendingRequest||0===this.queue.length)return;const{id:t,timestamp:r}=this.queue.shift();t&&this.success[t]||this.getSession(r,this.skuToken,c=>{c?this.errorCb(c):t&&(this.success[t]=!0)},l)}remove(){this.errorCb=null}},ue=fo.getSessionAPI.bind(fo),An=new Set;function Hn(l,t){t?An.add(l):An.delete(l)}class js{constructor(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps=new Set,this._updatedImages=new Set}isDirty(){return this._changed}setDirty(){this._changed=!0}getUpdatedSourceCaches(){return this._updatedSourceCaches}updateSourceCache(t,r){this._updatedSourceCaches[t]=r,this.setDirty()}discardSourceCacheUpdate(t){delete this._updatedSourceCaches[t]}updateLayer(t){const r=t.scope;this._updatedLayers[r]=this._updatedLayers[r]||new Set,this._updatedLayers[r].add(t.id),this.setDirty()}removeLayer(t){const r=t.scope;this._removedLayers[r]=this._removedLayers[r]||{},this._updatedLayers[r]=this._updatedLayers[r]||new Set,this._removedLayers[r][t.id]=t,this._updatedLayers[r].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 r in this._updatedLayers)t[r]=t[r]||{},t[r].updatedIds=Array.from(this._updatedLayers[r].values());for(const r in this._removedLayers)t[r]=t[r]||{},t[r].removedIds=Object.keys(this._removedLayers[r]);return t}getUpdatedPaintProperties(){return this._updatedPaintProps}updatePaintProperties(t){this._updatedPaintProps.add(t.fqid),this.setDirty()}getUpdatedImages(){return Array.from(this._updatedImages.values())}updateImage(t){this._updatedImages.add(t),this.setDirty()}resetUpdatedImages(){this._updatedImages.clear()}reset(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps.clear(),this._updatedImages.clear()}}function He(l){const{userImage:t}=l;return!!(t&&t.render&&t.render())&&(l.data.replace(new Uint8Array(t.data.buffer)),!0)}class mo extends s.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded={},this.requestors=[],this.patterns={},this.atlasImage={},this.atlasTexture={},this.dirty=!0}createScope(t){this.images[t]={},this.loaded[t]=!1,this.updatedImages[t]={},this.patterns[t]={},this.callbackDispatchedThisFrame[t]={},this.atlasImage[t]=new s.r({width:1,height:1})}isLoaded(){for(const t in this.loaded)if(!this.loaded[t])return!1;return!0}setLoaded(t,r){if(this.loaded[r]!==t&&(this.loaded[r]=t,t)){for(const{ids:c,callback:d}of this.requestors)this._notify(c,r,d);this.requestors=[]}}hasImage(t,r){return!!this.getImage(t,r)}getImage(t,r){return this.images[r][t]}addImage(t,r,c){this._validate(t,c)&&(this.images[r][t]=c)}_validate(t,r){let c=!0;return this._validateStretch(r.stretchX,r.data&&r.data.width)||(this.fire(new s.t(new Error(`Image "${t}" has invalid "stretchX" value`))),c=!1),this._validateStretch(r.stretchY,r.data&&r.data.height)||(this.fire(new s.t(new Error(`Image "${t}" has invalid "stretchY" value`))),c=!1),this._validateContent(r.content,r)||(this.fire(new s.t(new Error(`Image "${t}" has invalid "content" value`))),c=!1),c}_validateStretch(t,r){if(!t)return!0;let c=0;for(const d of t){if(d[0]1?I-1:I,s.r.copy(L,_,{x:0,y:0},{x:z,y:D},{width:F,height:N},r),s.r.copy(L,_,{x:0,y:N-I},{x:z,y:D-I},{width:F,height:I},r),s.r.copy(L,_,{x:0,y:0},{x:z,y:D+N},{width:F,height:I},r),s.r.copy(L,_,{x:F-I,y:0},{x:z-I,y:D},{width:I,height:N},r),s.r.copy(L,_,{x:0,y:0},{x:z+F,y:D},{width:I,height:N},r),s.r.copy(L,_,{x:F-I,y:N-I},{x:z-I,y:D-I},{width:I,height:I},r),s.r.copy(L,_,{x:0,y:N-I},{x:z+F,y:D-I},{width:I,height:I},r),s.r.copy(L,_,{x:0,y:0},{x:z+F,y:D+N},{width:I,height:I},r),s.r.copy(L,_,{x:F-I,y:0},{x:z-I,y:D+N},{width:I,height:I},r)}this.dirty=!0}beginFrame(){for(const t in this.images)this.callbackDispatchedThisFrame[t]={}}dispatchRenderCallbacks(t,r){for(const c of t){if(this.callbackDispatchedThisFrame[r][c])continue;this.callbackDispatchedThisFrame[r][c]=!0;const d=this.images[r][c];He(d)&&this.updateImage(c,r,d)}}}function ar(l){const t=l.key,r=l.value,c=l.valueSpec||{},d=l.objectElementValidators||{},f=l.style,_=l.styleSpec;let T=[];const S=s.B(r);if("object"!==S)return[new s.V(t,r,`object expected, ${S} found`)];for(const A in r){const I=A.split(".")[0];let z;d[I]?z=d[I]:c[I]?z=Qt:d["*"]?z=d["*"]:c["*"]&&(z=Qt),z?T=T.concat(z({key:(t&&`${t}.`)+A,value:r[A],valueSpec:c[I]||c["*"],style:f,styleSpec:_,object:r,objectKey:A},r)):T.push(new s.A(t,r[A],`unknown property "${A}"`))}for(const A in c)d[A]||c[A].required&&void 0===c[A].default&&void 0===r[A]&&T.push(new s.V(t,r,`missing required property "${A}"`));return T}function In(l){const t=l.value,r=l.valueSpec,c=l.style,d=l.styleSpec,f=l.key,_=l.arrayElementValidator||Qt;if("array"!==s.B(t))return[new s.V(f,t,`array expected, ${s.B(t)} found`)];if(r.length&&t.length!==r.length)return[new s.V(f,t,`array length ${r.length} expected, length ${t.length} found`)];if(r["min-length"]&&t.lengthf)return[new s.V(t,r,`${r} is greater than the maximum value ${f}`)]}return[]}function nr(l){const t=l.valueSpec,r=s.D(l.value.type);let c,d,f,_={};const T="categorical"!==r&&void 0===l.value.property,S=!T,A="array"===s.B(l.value.stops)&&"array"===s.B(l.value.stops[0])&&"object"===s.B(l.value.stops[0][0]),I=ar({key:l.key,value:l.value,valueSpec:l.styleSpec.function,style:l.style,styleSpec:l.styleSpec,objectElementValidators:{stops:function(L){if("identity"===r)return[new s.V(L.key,L.value,'identity function may not have a "stops" property')];let F=[];const N=L.value;return F=F.concat(In({key:L.key,value:N,valueSpec:L.valueSpec,style:L.style,styleSpec:L.styleSpec,arrayElementValidator:z})),"array"===s.B(N)&&0===N.length&&F.push(new s.V(L.key,N,"array must have at least one stop")),F},default:function(L){return Qt({key:L.key,value:L.value,valueSpec:t,style:L.style,styleSpec:L.styleSpec})}}});return"identity"===r&&T&&I.push(new s.V(l.key,l.value,'missing required property "property"')),"identity"===r||l.value.stops||I.push(new s.V(l.key,l.value,'missing required property "stops"')),"exponential"===r&&l.valueSpec.expression&&!s.F(l.valueSpec)&&I.push(new s.V(l.key,l.value,"exponential functions not supported")),l.styleSpec.$version>=8&&(S&&!s.G(l.valueSpec)?I.push(new s.V(l.key,l.value,"property functions not supported")):T&&!s.H(l.valueSpec)&&I.push(new s.V(l.key,l.value,"zoom functions not supported"))),"categorical"!==r&&!A||void 0!==l.value.property||I.push(new s.V(l.key,l.value,'"property" property is required')),I;function z(L){let F=[];const N=L.value,V=L.key;if("array"!==s.B(N))return[new s.V(V,N,`array expected, ${s.B(N)} found`)];if(2!==N.length)return[new s.V(V,N,`array length 2 expected, length ${N.length} found`)];if(A){if("object"!==s.B(N[0]))return[new s.V(V,N,`object expected, ${s.B(N[0])} found`)];if(void 0===N[0].zoom)return[new s.V(V,N,"object stop key must have zoom")];if(void 0===N[0].value)return[new s.V(V,N,"object stop key must have value")];const U=s.D(N[0].zoom);if("number"!=typeof U)return[new s.V(V,N[0].zoom,"stop zoom values must be numbers")];if(f&&f>U)return[new s.V(V,N[0].zoom,"stop zoom values must appear in ascending order")];U!==f&&(f=U,d=void 0,_={}),F=F.concat(ar({key:`${V}[0]`,value:N[0],valueSpec:{zoom:{}},style:L.style,styleSpec:L.styleSpec,objectElementValidators:{zoom:Ht,value:D}}))}else F=F.concat(D({key:`${V}[0]`,value:N[0],valueSpec:{},style:L.style,styleSpec:L.styleSpec},N));return s.J(s.K(N[1]))?F.concat([new s.V(`${V}[1]`,N[1],"expressions are not allowed in function stops.")]):F.concat(Qt({key:`${V}[1]`,value:N[1],valueSpec:t,style:L.style,styleSpec:L.styleSpec}))}function D(L,F){const N=s.B(L.value),V=s.D(L.value),U=null!==L.value?L.value:F;if(c){if(N!==c)return[new s.V(L.key,U,`${N} stop domain type must match previous stop domain type ${c}`)]}else c=N;if("number"!==N&&"string"!==N&&"boolean"!==N&&"number"!=typeof V&&"string"!=typeof V&&"boolean"!=typeof V)return[new s.V(L.key,U,"stop domain value must be a number, string, or boolean")];if("number"!==N&&"categorical"!==r){let W=`number expected, ${N} found`;return s.G(t)&&void 0===r&&(W+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new s.V(L.key,U,W)]}return"categorical"!==r||"number"!==N||"number"==typeof V&&isFinite(V)&&Math.floor(V)===V?"categorical"!==r&&"number"===N&&"number"==typeof V&&"number"==typeof d&&void 0!==d&&Vnew s.V(`${l.key}${c.key}`,l.value,c.message));const r=t.value.expression||t.value._styleExpression.expression;if("property"===l.expressionContext&&"text-font"===l.propertyKey&&!r.outputDefined())return[new s.V(l.key,l.value,`Invalid data expression for "${l.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===l.expressionContext&&"layout"===l.propertyType&&!s.N(r))return[new s.V(l.key,l.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===l.expressionContext)return _o(r,l);if(l.expressionContext&&0===l.expressionContext.indexOf("cluster")){if(!s.O(r,["zoom","feature-state"]))return[new s.V(l.key,l.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===l.expressionContext&&!s.Q(r))return[new s.V(l.key,l.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function _o(l,t){const r=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(t.valueSpec&&t.valueSpec.expression)for(const d of t.valueSpec.expression.parameters)r.delete(d);if(0===r.size)return[];const c=[];return l instanceof s.S&&r.has(l.name)?[new s.V(t.key,t.value,`["${l.name}"] expression is not supported in a filter for a ${t.object.type} layer with id: ${t.object.id}`)]:(l.eachChild(d=>{c.push(..._o(d,t))}),c)}function Wn(l){const t=l.key,r=l.value,c=l.valueSpec,d=[];return Array.isArray(c.values)?-1===c.values.indexOf(s.D(r))&&d.push(new s.V(t,r,`expected one of [${c.values.join(", ")}], ${JSON.stringify(r)} found`)):-1===Object.keys(c.values).indexOf(s.D(r))&&d.push(new s.V(t,r,`expected one of [${Object.keys(c.values).join(", ")}], ${JSON.stringify(r)} found`)),d}function Vo(l){return s.W(s.K(l.value))?Qr(s.C({},l,{expressionContext:"filter",valueSpec:l.styleSpec[`filter_${l.layerType||"fill"}`]})):zt(l)}function zt(l){const t=l.value,r=l.key;if("array"!==s.B(t))return[new s.V(r,t,`array expected, ${s.B(t)} found`)];const c=l.styleSpec;let d,f=[];if(t.length<1)return[new s.V(r,t,"filter array must have at least 1 element")];switch(f=f.concat(Wn({key:`${r}[0]`,value:t[0],valueSpec:c.filter_operator,style:l.style,styleSpec:l.styleSpec})),s.D(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&"$type"===s.D(t[1])&&f.push(new s.V(r,t,`"$type" cannot be use with operator "${t[0]}"`));case"==":case"!=":3!==t.length&&f.push(new s.V(r,t,`filter array for operator "${t[0]}" must have 3 elements`));case"in":case"!in":t.length>=2&&(d=s.B(t[1]),"string"!==d&&f.push(new s.V(`${r}[1]`,t[1],`string expected, ${d} found`)));for(let _=2;_{A in r&&t.push(new s.V(c,r[A],`"${A}" is prohibited for ref layers`))}),d.layers.forEach(A=>{s.D(A.id)===T&&(S=A)}),S?S.ref?t.push(new s.V(c,r.ref,"ref cannot reference another ref layer")):_=s.D(S.type):"string"==typeof T&&t.push(new s.V(c,r.ref,`ref layer "${T}" not found`))}else if("background"!==_&&"sky"!==_&&"slot"!==_)if(r.source){const S=d.sources&&d.sources[r.source],A=S&&s.D(S.type);S?"vector"===A&&"raster"===_?t.push(new s.V(c,r.source,`layer "${r.id}" requires a raster source`)):"raster"===A&&"raster"!==_?t.push(new s.V(c,r.source,`layer "${r.id}" requires a vector source`)):"vector"!==A||r["source-layer"]?"raster-dem"===A&&"hillshade"!==_?t.push(new s.V(c,r.source,"raster-dem source can only be used with layer type 'hillshade'.")):"raster-array"!==A||["raster","raster-particle"].includes(_)?"line"!==_||!r.paint||!r.paint["line-gradient"]&&!r.paint["line-trim-offset"]||"geojson"===A&&S.lineMetrics?"raster-particle"===_&&"raster-array"!==A&&t.push(new s.V(c,r.source,`layer "${r.id}" requires a 'raster-array' source.`)):t.push(new s.V(c,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new s.V(c,r.source,"raster-array source can only be used with layer type 'raster'.")):t.push(new s.V(c,r,`layer "${r.id}" must specify a "source-layer"`)):t.push(new s.V(c,r.source,`source "${r.source}" not found`))}else t.push(new s.V(c,r,'missing required property "source"'));return t=t.concat(ar({key:c,value:r,valueSpec:f.layer,style:l.style,styleSpec:l.styleSpec,objectElementValidators:{"*":()=>[],type:()=>Qt({key:`${c}.type`,value:r.type,valueSpec:f.layer.type,style:l.style,styleSpec:l.styleSpec,object:r,objectKey:"type"}),filter:S=>Vo(s.C({layerType:_},S)),layout:S=>ar({layer:r,key:S.key,value:S.value,valueSpec:{},style:S.style,styleSpec:S.styleSpec,objectElementValidators:{"*":A=>go(s.C({layerType:_},A))}}),paint:S=>ar({layer:r,key:S.key,value:S.value,valueSpec:{},style:S.style,styleSpec:S.styleSpec,objectElementValidators:{"*":A=>Cn(s.C({layerType:_,layer:r},A))}})}})),t}function Rr(l){const t=l.value,r=l.key,c=s.B(t);return"string"!==c?[new s.V(r,t,`string expected, ${c} found`)]:[]}const Gs={promoteId:function({key:l,value:t}){if("string"===s.B(t))return Rr({key:l,value:t});{const r=[];for(const c in t)r.push(...Rr({key:`${l}.${c}`,value:t[c]}));return r}}};function qs(l){const t=l.value,r=l.key,c=l.styleSpec,d=l.style;if(!t.type)return[new s.V(r,t,'"type" is required')];const f=s.D(t.type);let _=[];switch(["vector","raster","raster-dem","raster-array"].includes(f)&&(t.url||t.tiles||_.push(new s.A(r,t,'Either "url" or "tiles" is required.'))),f){case"vector":case"raster":case"raster-dem":case"raster-array":return _=_.concat(ar({key:r,value:t,valueSpec:c[`source_${f.replace("-","_")}`],style:l.style,styleSpec:c,objectElementValidators:Gs})),_;case"geojson":if(_=ar({key:r,value:t,valueSpec:c.source_geojson,style:d,styleSpec:c,objectElementValidators:Gs}),t.cluster)for(const T in t.clusterProperties){const[S,A]=t.clusterProperties[T],I="string"==typeof S?[S,["accumulated"],["get",T]]:S;_.push(...Qr({key:`${r}.${T}.map`,value:A,expressionContext:"cluster-map"})),_.push(...Qr({key:`${r}.${T}.reduce`,value:I,expressionContext:"cluster-reduce"}))}return _;case"video":return ar({key:r,value:t,valueSpec:c.source_video,style:d,styleSpec:c});case"image":return ar({key:r,value:t,valueSpec:c.source_image,style:d,styleSpec:c});case"canvas":return[new s.V(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Wn({key:`${r}.type`,value:t.type,valueSpec:{values:jo(c)},style:d,styleSpec:c})}}function jo(l){return l.source.reduce((t,r)=>{const c=l[r];return"enum"===c.type.type&&(t=t.concat(Object.keys(c.type.values))),t},[])}function Pn(l){const t=l.value,r=l.styleSpec,c=r.light,d=l.style;let f=[];const _=s.B(t);if(void 0===t)return f;if("object"!==_)return f=f.concat([new s.V("light",t,`object expected, ${_} found`)]),f;for(const T in t){const S=T.match(/^(.*)-transition$/);f=f.concat(S&&c[S[1]]&&c[S[1]].transition?Qt({key:T,value:t[T],valueSpec:r.transition,style:d,styleSpec:r}):c[T]?Qt({key:T,value:t[T],valueSpec:c[T],style:d,styleSpec:r}):[new s.V(T,t[T],`unknown property "${T}"`)])}return f}function yo(l){const t=l.value;let r=[];if(!t)return r;const c=s.B(t);if("object"!==c)return r=r.concat([new s.V("light-3d",t,`object expected, ${c} found`)]),r;const d=l.styleSpec,f=d["light-3d"],_=l.key,T=l.style,S=l.style.lights;for(const z of["type","id"])if(!(z in t))return r=r.concat([new s.V("light-3d",t,`missing property ${z} on light`)]),r;if(t.type&&S)for(let z=0;z[],array:In,boolean:function(l){const t=l.value,r=l.key,c=s.B(t);return"boolean"!==c?[new s.V(r,t,`boolean expected, ${c} found`)]:[]},number:Ht,color:function(l){const t=l.key,r=l.value,c=s.B(r);return"string"!==c?[new s.V(t,r,`color expected, ${c} found`)]:null===s.U.parseCSSColor(r)?[new s.V(t,r,`color expected, "${r}" found`)]:[]},enum:Wn,filter:Vo,function:nr,layer:pr,object:ar,source:qs,model:s.Z,light:Pn,"light-3d":yo,terrain:Go,fog:Zr,string:Rr,formatted:function(l){return 0===Rr(l).length?[]:Qr(l)},resolvedImage:function(l){return 0===Rr(l).length?[]:Qr(l)},projection:function(l){const t=l.value,r=l.styleSpec,c=r.projection,d=l.style;let f=[];const _=s.B(t);if("object"===_)for(const T in t)f=f.concat(Qt({key:T,value:t[T],valueSpec:c[T],style:d,styleSpec:r}));else"string"!==_&&(f=f.concat([new s.V("projection",t,`object or string expected, ${_} found`)]));return f},import:function(l){const{value:t,styleSpec:r}=l,{data:c,...d}=t;Object.defineProperty(d,"__line__",{value:t.__line__,enumerable:!1});let f=ar(s.C({},l,{value:d,valueSpec:r.import}));return""===s.D(d.id)&&f.push(new s.V(`${l.key}.id`,d,"import id can't be an empty string")),c&&(f=f.concat(Ba(c,r,{key:`${l.key}.data`}))),f}};function Qt(l,t=!1){const r=l.value,c=l.valueSpec,d=l.styleSpec;if(c.expression&&s.X(s.D(r)))return nr(l);if(c.expression&&s.J(s.K(r)))return Qr(l);if(c.type&&Zs[c.type]){const f=Zs[c.type](l);return!0===t&&f.length>0&&"array"===s.B(l.value)?Qr(l):f}return ar(s.C({},l,{valueSpec:c.type?d[c.type]:c}))}function dn(l){const t=l.value,r=l.key,c=Rr(l);return c.length||(-1===t.indexOf("{fontstack}")&&c.push(new s.V(r,t,'"glyphs" url must include a "{fontstack}" token')),-1===t.indexOf("{range}")&&c.push(new s.V(r,t,'"glyphs" url must include a "{range}" token'))),c}function Ba(l,t=s._,r={}){return Qt({key:r.key||"",value:l,valueSpec:t.$root,styleSpec:t,style:l,objectElementValidators:{glyphs:dn,"*":()=>[]}})}function Lr(l,t=s._){return se(Ba(l,t))}const xo=l=>se(qs(l)),$s=l=>se(Pn(l)),qo=l=>se(yo(l)),Hs=l=>se(Go(l)),vo=l=>se(Zr(l)),Se=l=>se(pr(l)),j=l=>se(Vo(l)),q=l=>se(Cn(l)),ee=l=>se(go(l)),le=l=>se(s.Z(l));function se(l){return l.slice().sort((t,r)=>t.line&&r.line?t.line-r.line:0)}function _e(l,t){let r=!1;if(t&&t.length)for(const c of t)c instanceof s.A?s.w(c.message):(l.fire(new s.t(new Error(c.message))),r=!0);return r}let Te;class ve extends s.E{constructor(t,r="flat"){super(),this._transitionable=new s.$(Te||(Te=new s.a0({anchor:new s.a1(s._.light.anchor),position:new s.a2(s._.light.position),color:new s.a1(s._.light.color),intensity:new s.a1(s._.light.intensity)}))),this.setLight(t,r),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(t,r,c={}){this._validate($s,t,c)||(this._transitionable.setTransitionOrValue(t),this.id=r)}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,r,c){return(!c||!1!==c.validate)&&_e(this,t.call(Lr,s.l({value:r,style:{glyphs:!0,sprite:!0},styleSpec:s._})))}}const Me=new s.a0({source:new s.a1(s._.terrain.source),exaggeration:new s.a1(s._.terrain.exaggeration)});let De=class extends s.E{constructor(l,t,r,c){super(),this.scope=r,this._transitionable=new s.$(Me,r,c),this._transitionable.setTransitionOrValue(l,c),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=t}get(){return this._transitionable.serialize()}set(l,t){this._transitionable.setTransitionOrValue(l,t)}updateTransitions(l){this._transitioning=this._transitionable.transitioned(l,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(l){this.properties=this._transitioning.possiblyEvaluate(l)}getExaggeration(l){return this._transitioning.possiblyEvaluate(new s.a3(l)).get("exaggeration")}isZoomDependent(){const l=this._transitionable._values.exaggeration;return null!=l&&null!=l.value&&null!=l.value.expression&&l.value.expression instanceof s.a4}};const Ke=.05;function Qe(l,t,r,c){const d=s.a7(45,65,r),[f,_]=bt(l,c);let T=1-Math.min(1,Math.exp((t-f)/(_-f)*-6));return T*=T*T,T=Math.min(1,1.00747*T),T*d*l.alpha}function bt(l,t){const r=.5/Math.tan(.5*t);return[l.range[0]+r,l.range[1]+r]}function Tt(l,t,r,c,d){const f=s.a6.vec3.transformMat4([],[t,r,c],d.mercatorFogMatrix);return Qe(l,s.a6.vec3.length(f),d.pitch,d._fov)}function St(l,t,r,c,d,f,_){const T=[[r,c,0],[d,c,0],[d,f,0],[r,f,0]];let S=Number.MAX_VALUE,A=-Number.MAX_VALUE;for(const I of T){const z=s.a6.vec3.transformMat4([],I,t),D=s.a6.vec3.length(z);S=Math.min(S,D),A=Math.max(A,D)}return[Qe(l,S,_.pitch,_._fov),Qe(l,A,_.pitch,_._fov)]}const Mt=new s.a0({range:new s.a1(s._.fog.range),color:new s.a1(s._.fog.color),"high-color":new s.a1(s._.fog["high-color"]),"space-color":new s.a1(s._.fog["space-color"]),"horizon-blend":new s.a1(s._.fog["horizon-blend"]),"star-intensity":new s.a1(s._.fog["star-intensity"]),"vertical-range":new s.a1(s._.fog["vertical-range"])});class ai extends s.E{constructor(t,r,c,d){super(),this._transitionable=new s.$(Mt,c,new Map(d)),this.set(t,d),this._transitioning=this._transitionable.untransitioned(),this._transform=r,this.properties=new s.a8(Mt),this.scope=c}get state(){const t=this._transform,r="globe"===t.projection.name,c=s.a9(t.zoom),d=this.properties.get("range"),f=[.5,3];return{range:r?[s.aa(f[0],d[0],c),s.aa(f[1],d[1],c)]:d,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(t,r,c={}){if(this._validate(vo,t,c))return;const d=s.l({},t);for(const f of Object.keys(s._.fog))void 0===d[f]&&(d[f]=s._.fog[f].default);this._options=d,this._transitionable.setTransitionOrValue(this._options,r)}getOpacity(t){if(!this._transform.projection.supportsFog)return 0;const r=this.properties&&this.properties.get("color")||1;return("globe"===this._transform.projection.name?1:s.a7(45,65,t))*r.a}getOpacityAtLatLng(t,r){return this._transform.projection.supportsFog?function(c,d,f){const _=s.a5.fromLngLat(d),T=f.elevation?f.elevation.getAtPointOrZero(_):0;return Tt(c,_.x,_.y,T,f)}(this.state,t,r):0}getOpacityForTile(t){if(!this._transform.projection.supportsFog)return[1,1];const r=this._transform.calculateFogTileMatrix(t.toUnwrapped());return St(this.state,r,0,0,s.ab,s.ab,this._transform)}getOpacityForBounds(t,r,c,d,f){return this._transform.projection.supportsFog?St(this.state,t,r,c,d,f,this._transform):[1,1]}getFovAdjustedRange(t){return this._transform.projection.supportsFog?bt(this.state,t):[0,1]}isVisibleOnFrustum(t){if(!this._transform.projection.supportsFog)return!1;const r=[4,5,6,7];for(const c of r){const d=t.points[c];let f;if(d[2]>=0)f=d;else{const _=t.points[c-4];f=s.ac(_,d,_[2]/(_[2]-d[2]))}if(Tt(this.state,f[0],f[1],0,this._transform)>=Ke)return!0}return!1}updateConfig(t){this._transitionable.setTransitionOrValue(this._options,new Map(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,r,c){return(!c||!1!==c.validate)&&_e(this,t.call(Lr,s.l({value:r,style:{glyphs:!0,sprite:!0},styleSpec:s._})))}}class pi extends s.E{constructor(t,r,c,d){super(),this.scope=c,this._options=t,this.properties=new s.a8(r),this._transitionable=new s.$(r,c,new Map(d)),this._transitionable.setTransitionOrValue(t.properties),this._transitioning=this._transitionable.untransitioned()}updateConfig(t){this._transitionable.setTransitionOrValue(this._options.properties,new Map(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,r){this._options=t,this._transitionable.setTransitionOrValue(t.properties,r)}shadowsEnabled(){return!!this.properties&&!0===this.properties.get("cast-shadows")}}let Rt,ui;class Di{constructor(t,r,c,d){this.screenBounds=t,this.cameraPoint=r,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=c,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,d)}static createFromScreenPoints(t,r){let c,d;if(t instanceof s.P||"number"==typeof t[0]){const f=s.P.convert(t);c=[f],d=r.isPointAboveHorizon(f)}else{const f=s.P.convert(t[0]),_=s.P.convert(t[1]);c=[f,_],d=s.ae(f,_).every(T=>r.isPointAboveHorizon(T))}return new Di(c,r.getCameraPoint(),d,r)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(t){return s.ae(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],t)}bufferedCameraGeometry(t){const r=this.screenBounds[0],c=1===this.screenBounds.length?this.screenBounds[0].add(new s.P(1,1)):this.screenBounds[1],d=s.ae(r,c,0,!1);return this.cameraPoint.y>c.y&&(this.cameraPoint.x>r.x&&this.cameraPoint.x=c.x?d[2]=this.cameraPoint:this.cameraPoint.x<=r.x&&(d[3]=this.cameraPoint)),s.af(d,t)}bufferedCameraGeometryGlobe(t){const r=this.screenBounds[0],c=1===this.screenBounds.length?this.screenBounds[0].add(new s.P(1,1)):this.screenBounds[1],d=s.ae(r,c,t),f=this.cameraPoint.clone();switch(3*((f.y>r.y)+(f.y>c.y))+((f.x>r.x)+(f.x>c.x))){case 0:d[0]=f,d[4]=f.clone();break;case 1:d.splice(1,0,f);break;case 2:d[1]=f;break;case 3:d.splice(4,0,f);break;case 5:d.splice(2,0,f);break;case 6:d[3]=f;break;case 7:d.splice(3,0,f);break;case 8:d[2]=f}return d}containsTile(t,r,c,d=0){const f=t.queryPadding/r._pixelsPerMercatorPixel+1,_=c?this._bufferedCameraMercator(f,r):this._bufferedScreenMercator(f,r);let T=t.tileID.wrap+(_.unwrapped?d:0);const S=_.polygon.map(V=>s.ag(t.tileTransform,V,T));if(!s.ah(S,0,0,s.ab,s.ab))return;T=t.tileID.wrap+(this.screenGeometryMercator.unwrapped?d:0);const A=this.screenGeometryMercator.polygon.map(V=>s.ai(t.tileTransform,V,T)),I=A.map(V=>new s.P(V[0],V[1])),z=r.getFreeCameraOptions().position||new s.a5(0,0,0),D=s.ai(t.tileTransform,z,T),L=A.map(V=>{const U=s.a6.vec3.sub(V,V,D);return s.a6.vec3.normalize(U,U),new s.aj(D,U)}),F=s.ak(t,1,r.zoom)*r._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:I,tilespaceRays:L,bufferedTilespaceGeometry:S,bufferedTilespaceBounds:(N=s.al(S),N.min.x=s.ap(N.min.x,0,s.ab),N.min.y=s.ap(N.min.y,0,s.ab),N.max.x=s.ap(N.max.x,0,s.ab),N.max.y=s.ap(N.max.y,0,s.ab),N),tile:t,tileID:t.tileID,pixelToTileUnitsFactor:F};var N}_bufferedScreenMercator(t,r){const c=lr(t);if(this._screenRaycastCache[c])return this._screenRaycastCache[c];{let d;return d="globe"===r.projection.name?this._projectAndResample(this.bufferedScreenGeometry(t),r):{polygon:this.bufferedScreenGeometry(t).map(f=>r.pointCoordinate3D(f)),unwrapped:!0},this._screenRaycastCache[c]=d,d}}_bufferedCameraMercator(t,r){const c=lr(t);if(this._cameraRaycastCache[c])return this._cameraRaycastCache[c];{let d;return d="globe"===r.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(t),r):{polygon:this.bufferedCameraGeometry(t).map(f=>r.pointCoordinate3D(f)),unwrapped:!0},this._cameraRaycastCache[c]=d,d}}_projectAndResample(t,r){const c=function(f,_){const T=s.a6.mat4.multiply([],_.pixelMatrix,_.globeMatrix),S=[0,-s.aq,0,1],A=[0,s.aq,0,1],I=[0,0,0,1];s.a6.vec4.transformMat4(S,S,T),s.a6.vec4.transformMat4(A,A,T),s.a6.vec4.transformMat4(I,I,T);const z=new s.P(S[0]/S[3],S[1]/S[3]),D=new s.P(A[0]/A[3],A[1]/A[3]),L=s.an(f,z)&&S[3]1?Xi(f.slice(0,V),_):[],Y=Vnew s.P(Ki(ne.x),ne.y)),Y=Y.map(ne=>new s.P(Ki(ne.x),ne.y));const $=[...W];0===$.length&&$.push(Y[Y.length-1]);const Q=s.aa($[$.length-1].y,(0===Y.length?W[0]:Y[0]).y,U);let J;return J=L?[new s.P(0,Q),new s.P(0,0),new s.P(1,0),new s.P(1,Q)]:[new s.P(1,Q),new s.P(1,1),new s.P(0,1),new s.P(0,Q)],$.push(...J),0===Y.length?$.push(W[0]):$.push(...Y),{polygon:$.map(ne=>new s.a5(ne.x,ne.y)),unwrapped:!1}}(t,r);if(c)return c;const d=function(f,_){let T=!1,S=-1/0,A=0;for(let z=0;zS&&(S=f[z].x,A=z);for(let z=0;z.5&&(L.x{z.x-=1}),{polygon:f,unwrapped:T}}(Xi(t,r).map(f=>new s.P(Ki(f.x),f.y)),r);return{polygon:d.polygon.map(f=>new s.a5(f.x,f.y)),unwrapped:d.unwrapped}}}function Xi(l,t){return s.ao(l,r=>{const c=t.pointCoordinate3D(r);r.x=c.x,r.y=c.y},1/256)}function Ki(l){return l<0?1+l%1:l%1}function lr(l){return 100*l|0}function en(l,t,r,c,d){const f=function(T,S){if(T)return d(T);if(S){if(l.url&&S.tiles&&l.tiles&&delete l.tiles,S.variants){if(!Array.isArray(S.variants))return d(new Error("variants must be an array"));for(const I of S.variants){if(null==I||"object"!=typeof I||I.constructor!==Object)return d(new Error("variant must be an object"));if(!Array.isArray(I.capabilities))return d(new Error("capabilities must be an array"));if(1===I.capabilities.length&&"meshopt"===I.capabilities[0]){S=s.l(S,I);break}}}const A=s.ar(s.l(S,l),["tilejson","tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);S.vector_layers&&(A.vectorLayers=S.vector_layers,A.vectorLayerIds=A.vectorLayers.map(I=>I.id)),S.raster_layers&&(A.rasterLayers=S.raster_layers,A.rasterLayerIds=A.rasterLayers.map(I=>I.id)),A.tiles=t.canonicalizeTileset(A,l.url),d(null,A)}},_=function(T,S,A){if(!T)return null;if(!S&&!A)return T;A=A||T.worldview_default;const I=Object.values(T.language||{});if(0===I.length)return null;const z=Object.values(T.worldview||{});if(0===z.length)return null;const D=I.every(F=>F===S),L=z.every(F=>F===A);return D&&L?T:S in(T.language_options||{})||A in(T.worldview_options||{})?null:T.language_options&&T.worldview_options?T:null}(l.data,r,c);return _?s.q.frame(()=>f(null,_)):l.url?s.n(t.transformRequest(t.normalizeSourceURL(l.url,null,r,c),s.R.Source),f):s.q.frame(()=>{const{data:T,...S}=l;f(null,S)})}class zn{constructor(t,r,c){this.bounds=s.as.convert(this.validateBounds(t)),this.minzoom=r||0,this.maxzoom=c||24}validateBounds(t){return Array.isArray(t)&&4===t.length?[Math.max(-180,t[0]),Math.max(-90,t[1]),Math.min(180,t[2]),Math.min(90,t[3])]:[-180,-90,180,90]}contains(t){const r=Math.pow(2,t.z),c=Math.floor(s.am(this.bounds.getWest())*r),d=Math.floor(s.at(this.bounds.getNorth())*r),f=Math.ceil(s.am(this.bounds.getEast())*r),_=Math.ceil(s.at(this.bounds.getSouth())*r);return t.x>=c&&t.x=d&&t.y<_}}class Fa extends s.E{constructor(t,r,c,d){if(super(),this.id=t,this.dispatcher=c,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,s.l(this,s.ar(r,["url","scheme","tileSize","promoteId"])),this._options=s.l({type:"vector"},r),this._collectResourceTiming=!!r.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(d),this._tileWorkers={},this._deduped=new s.au}load(t){this._loaded=!1,this.fire(new s.x("dataloading",{dataType:"source"}));const r=Array.isArray(this.map._language)?this.map._language.join():this.map._language,c=this.map._worldview;this._tileJSONRequest=en(this._options,this.map._requestManager,r,c,(d,f)=>{this._tileJSONRequest=null,this._loaded=!0,d?(r&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${r}`),c&&2!==c.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${c}`),this.fire(new s.t(d))):f&&(s.l(this,f),f.bounds&&(this.tileBounds=new zn(f.bounds,this.minzoom,this.maxzoom)),Fo(f.tiles,this.map._requestManager._customAccessToken),this.fire(new s.x("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new s.x("data",{dataType:"source",sourceDataType:"content"}))),t&&t(d)})}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=s.av(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 s.l({},this._options)}loadTile(t,r){const c=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme)),d=this.map._requestManager.transformRequest(c,s.R.Tile),f=this.map.style?this.map.style.getLut(this.scope):null,_={request:d,data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,lut:f?{image:f.image.clone()}:null,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,pixelRatio:s.q.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:t.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:t.isExtraShadowCaster,tessellationStep:this.map._tessellationStep};if(_.request.collectResourceTiming=this._collectResourceTiming,t.actor&&"expired"!==t.state)"loading"===t.state?t.reloadCallback=r:t.request=t.actor.send("reloadTile",_,T.bind(this));else if(t.actor=this._tileWorkers[c]=this._tileWorkers[c]||this.dispatcher.getActor(),this.dispatcher.ready)t.request=t.actor.send("loadTile",_,T.bind(this),void 0,!0);else{const S=s.aw.call({deduped:this._deduped},_,(A,I)=>{A||!I?T.call(this,A):(_.data={cacheControl:I.cacheControl,expires:I.expires,rawData:I.rawData.slice(0)},t.actor&&t.actor.send("loadTile",_,T.bind(this),void 0,!0))},!0);t.request={cancel:S}}function T(S,A){return delete t.request,t.aborted?r(null):S&&404!==S.status?r(S):(A&&A.resourceTiming&&(t.resourceTiming=A.resourceTiming),this.map._refreshExpiredTiles&&A&&t.setExpiryData(A),t.loadVectorData(A,this.map.painter),s.ax(this.dispatcher),r(null),void(t.reloadCallback&&(this.loadTile(t,t.reloadCallback),t.reloadCallback=null)))}}abortTile(t){t.request&&(t.request.cancel(),delete t.request),t.actor&&t.actor.send("abortTile",{uid:t.uid,type:this.type,source:this.id,scope:this.scope})}unloadTile(t,r){t.actor&&t.actor.send("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)}}class Ws extends s.E{constructor(t,r,c,d){super(),this.id=t,this.dispatcher=c,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=s.l({type:"raster"},r),s.l(this,s.ar(r,["url","scheme","tileSize"]))}load(t){this._loaded=!1,this.fire(new s.x("dataloading",{dataType:"source"})),this._tileJSONRequest=en(this._options,this.map._requestManager,null,null,(r,c)=>{this._tileJSONRequest=null,this._loaded=!0,r?this.fire(new s.t(r)):c&&(s.l(this,c),c.bounds&&(this.tileBounds=new zn(c.bounds,this.minzoom,this.maxzoom)),Fo(c.tiles),this.fire(new s.x("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new s.x("data",{dataType:"source",sourceDataType:"content"}))),t&&t(r)})}loaded(){return this._loaded}onAdd(t){this.map=t,this.load()}reload(){this.cancelTileJSONRequest();const t=s.av(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 s.l({},this._options)}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}loadTile(t,r){const c=s.q.devicePixelRatio>=2,d=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),c,this.tileSize);t.request=s.o(this.map._requestManager.transformRequest(d,s.R.Tile),(f,_,T,S)=>(delete t.request,t.aborted?(t.state="unloaded",r(null)):f?(t.state="errored",r(f)):_?(this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:T,expires:S}),t.setTexture(_,this.map.painter),t.state="loaded",s.ax(this.dispatcher),void r(null)):r(null)))}abortTile(t,r){t.request&&(t.request.cancel(),delete t.request),r&&r()}unloadTile(t,r){t.texture&&t.texture instanceof s.T?(t.destroy(!0),t.texture&&t.texture instanceof s.T&&this.map.painter.saveTileTexture(t.texture)):t.destroy(),r&&r()}hasTransition(){return!1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}class Zo extends Ws{constructor(t,r,c,d){super(t,r,c,d),this.type="raster-array",this.maxzoom=22,this._options=s.l({type:"raster-array"},r)}triggerRepaint(t){const r=this.map.painter._terrain,c=this.map.style.getSourceCache(this.id);r&&r.enabled&&c&&r._clearRenderCacheForTile(c.id,t.tileID),this.map.triggerRepaint()}loadTile(t,r){const c=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),d=this.map._requestManager.transformRequest(c,s.R.Tile);t.requestParams=d,t.actor||(t.actor=this.dispatcher.getActor()),t.request=t.fetchHeader(void 0,(f,_,T,S)=>(delete t.request,t.aborted?(t.state="unloaded",r(null)):f?20===f.code?void 0:(t.state="errored",r(f)):(this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:T,expires:S}),t.state="empty",void r(null))))}unloadTile(t,r){const c=t.texture;c&&c instanceof s.T?(t.destroy(!0),this.map.painter.saveTileTexture(c)):(t.destroy(),t.flushQueues(),t._isHeaderLoaded=!1,delete t._mrt,delete t.textureDescriptor),t.fbo&&(t.fbo.destroy(),delete t.fbo),delete t.request,delete t.requestParams,delete t.neighboringTiles,t.state="unloaded"}prepareTile(t,r,c){t._isHeaderLoaded&&("empty"!==t.state&&(t.state="reloading"),t.fetchBand(r,c,(d,f)=>{if(d)return t.state="errored",this.fire(new s.t(d)),void this.triggerRepaint(t);f&&(t.setTexture(f,this.map.painter),t.state="loaded",this.triggerRepaint(t))}))}getInitialBand(t){if(!this.rasterLayers)return 0;const r=this.rasterLayers.find(({id:f})=>f===t),c=r&&r.fields,d=c&&c.bands&&c.bands;return d?d[0]:0}getTextureDescriptor(t,r,c){if(!t)return;const d=r.sourceLayer||this.rasterLayerIds&&this.rasterLayerIds[0];if(!d)return;let f=null;r instanceof s.aB?f=r.paint.get("raster-array-band"):r instanceof s.aC&&(f=r.paint.get("raster-particle-array-band"));const _=f||this.getInitialBand(d);if(null!=_)if(t.textureDescriptor){if(!t.updateNeeded(d,_)||c)return Object.assign({},t.textureDescriptor,{texture:t.texture})}else this.prepareTile(t,d,_)}}const Na={vector:Fa,raster:Ws,"raster-dem":class extends Ws{constructor(l,t,r,c){super(l,t,r,c),this.type="raster-dem",this.maxzoom=22,this._options=s.l({type:"raster-dem"},t),this.encoding=t.encoding||"mapbox"}loadTile(l,t){const r=this.map._requestManager.normalizeTileURL(l.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function c(d,f){d&&(l.state="errored",t(d)),f&&(l.dem=f,l.dem.onDeserialize(),l.needsHillshadePrepare=!0,l.needsDEMTextureUpload=!0,l.state="loaded",t(null))}l.request=s.o(this.map._requestManager.transformRequest(r,s.R.Tile),function(d,f,_,T){if(delete l.request,l.aborted)l.state="unloaded",t(null);else if(d)l.state="errored",t(d);else if(f){this.map._refreshExpiredTiles&&l.setExpiryData({cacheControl:_,expires:T});const S=ImageBitmap&&f instanceof ImageBitmap&&s.ay(),A=1-(f.width-s.az(f.width))/2;A<1||l.neighboringTiles||(l.neighboringTiles=this._getNeighboringTiles(l.tileID));const I=S?f:s.q.getImageData(f,A),z={uid:l.uid,coord:l.tileID,source:this.id,scope:this.scope,rawImageData:I,encoding:this.encoding,padding:A};l.actor&&"expired"!==l.state||(l.actor=this.dispatcher.getActor(),l.actor.send("loadDEMTile",z,c.bind(this),void 0,!0))}}.bind(this))}_getNeighboringTiles(l){const t=l.canonical,r=Math.pow(2,t.z),c=(t.x-1+r)%r,d=0===t.x?l.wrap-1:l.wrap,f=(t.x+1+r)%r,_=t.x+1===r?l.wrap+1:l.wrap,T={};return T[new s.aA(l.overscaledZ,d,t.z,c,t.y).key]={backfilled:!1},T[new s.aA(l.overscaledZ,_,t.z,f,t.y).key]={backfilled:!1},t.y>0&&(T[new s.aA(l.overscaledZ,d,t.z,c,t.y-1).key]={backfilled:!1},T[new s.aA(l.overscaledZ,l.wrap,t.z,t.x,t.y-1).key]={backfilled:!1},T[new s.aA(l.overscaledZ,_,t.z,f,t.y-1).key]={backfilled:!1}),t.y+1{if(this._loaded=!0,this._pendingLoad=null,c)this.fire(new s.t(c));else{const f={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&d&&d.resourceTiming&&d.resourceTiming[this.id]&&(f.resourceTiming=d.resourceTiming[this.id]),l&&(this._partialReload=!0),this.fire(new s.x("data",f)),this._partialReload=!1,this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(l),this._coalesce=!1)})}loaded(){return this._loaded}loadTile(l,t){const r=l.actor?"reloadTile":"loadTile";l.actor=this.actor;const c=this.map.style?this.map.style.getLut(this.scope):null,d=this._partialReload,f={type:this.type,uid:l.uid,tileID:l.tileID,tileZoom:l.tileZoom,zoom:l.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,lut:c?{image:c.image.clone()}:null,scope:this.scope,pixelRatio:s.q.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,brightness:this.map.style&&this.map.style.getBrightness()||0,partial:d};l.request=this.actor.send(r,f,(_,T)=>d&&!T?(l.state="loaded",t(null)):(delete l.request,l.destroy(),l.aborted?t(null):_?t(_):(l.loadVectorData(T,this.map.painter,"reloadTile"===r),t(null))),void 0,"loadTile"===r)}abortTile(l){l.request&&(l.request.cancel(),delete l.request),l.aborted=!0}unloadTile(l,t){this.actor.send("removeTile",{uid:l.uid,type:this.type,source:this.id,scope:this.scope}),l.destroy()}onRemove(l){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return s.l({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends s.aD{constructor(l,t,r,c){super(l,t,r,c),this.roundZoom=!0,this.type="video",this.options=t}load(){this._loaded=!1;const l=this.options;this.urls=[];for(const t of l.urls)this.urls.push(this.map._requestManager.transformRequest(t,s.R.Source).url);s.aE(this.urls,(t,r)=>{this._loaded=!0,t?this.fire(new s.t(t)):r&&(this.video=r,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading())})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(l){if(this.video){const t=this.video.seekable;lt.end(0)?this.fire(new s.t(new s.V(`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=l}}getVideo(){return this.video}onAdd(l){this.map||(this.map=l,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const l=this.map.painter.context,t=l.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 s.T(l,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(l)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:s.aD,model:class extends s.E{constructor(l,t,r,c){super(),this.id=l,this.type="model",this.models=[],this._loaded=!1,this._options=t}load(){const l=[];for(const t in this._options.models){const r=this._options.models[t],c=s.aG(this.map._requestManager.transformRequest(r.uri,s.R.Model).url).then(d=>{if(!d)return;const f=s.aH(d),_=new s.aI(t,r.position,r.orientation,f);_.computeBoundsAndApplyParent(),this.models.push(_)}).catch(d=>{this.fire(new s.t(new Error(`Could not load model ${t} from ${r.uri}: ${d.message}`)))});l.push(c)}return Promise.allSettled(l).then(()=>{this._loaded=!0,this.fire(new s.x("data",{dataType:"source",sourceDataType:"metadata"}))}).catch(t=>{this.fire(new s.t(new Error(`Could not load models: ${t.message}`)))})}onAdd(l){this.map=l,this.load()}hasTransition(){return!1}loaded(){return this._loaded}getModels(){return this.models}loadTile(l,t){}serialize(){return{type:"model"}}},"batched-model":class extends s.E{constructor(l,t,r,c){super(),this.type="batched-model",this.id=l,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=r,this.reparseOverscaled=!1,this.scheme="xyz",this._loaded=!1,this.setEventedParent(c)}onAdd(l){this.map=l,this.load()}load(l){this._loaded=!1,this.fire(new s.x("dataloading",{dataType:"source"}));const t=Array.isArray(this.map._language)?this.map._language.join():this.map._language,r=this.map._worldview;this._tileJSONRequest=en(this._options,this.map._requestManager,t,r,(c,d)=>{this._tileJSONRequest=null,this._loaded=!0,c?(t&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${t}`),r&&2!==r.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${r}`),this.fire(new s.t(c))):d&&(s.l(this,d),d.bounds&&(this.tileBounds=new zn(d.bounds,this.minzoom,this.maxzoom)),Fo(d.tiles,this.map._requestManager._customAccessToken),this.fire(new s.x("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new s.x("data",{dataType:"source",sourceDataType:"content"}))),l&&l(c)})}hasTransition(){return!1}hasTile(l){return!this.tileBounds||this.tileBounds.contains(l.canonical)}loaded(){return this._loaded}loadTile(l,t){const r=this.map._requestManager.normalizeTileURL(l.tileID.canonical.url(this.tiles,this.scheme)),c={request:this.map._requestManager.transformRequest(r,s.R.Tile),data:void 0,uid:l.uid,tileID:l.tileID,tileZoom:l.tileZoom,zoom:l.tileID.overscaledZ,tileSize:this.tileSize*l.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,showCollisionBoxes:this.map.showCollisionBoxes,isSymbolTile:l.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0};if(l.actor&&"expired"!==l.state)if("loading"===l.state)l.reloadCallback=t;else{if(l.buckets){const f=Object.values(l.buckets);for(const _ of f)_.dirty=!0;return void(l.state="loaded")}l.request=l.actor.send("reloadTile",c,d.bind(this))}else l.actor=this.dispatcher.getActor(),l.request=l.actor.send("loadTile",c,d.bind(this),void 0,!0);function d(f,_){return l.aborted?t(null):f&&404!==f.status?t(f):(_&&(_.resourceTiming&&(l.resourceTiming=_.resourceTiming),this.map._refreshExpiredTiles&&l.setExpiryData(_),l.buckets={...l.buckets,..._.buckets},_.featureIndex&&(l.latestFeatureIndex=_.featureIndex)),l.state="loaded",void t(null))}}serialize(){return s.l({},this._options)}},canvas:class extends s.aD{constructor(l,t,r,c){super(l,t,r,c),t.coordinates?Array.isArray(t.coordinates)&&4===t.coordinates.length&&!t.coordinates.some(d=>!Array.isArray(d)||2!==d.length||d.some(f=>"number"!=typeof f))||this.fire(new s.t(new s.V(`sources.${l}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new s.t(new s.V(`sources.${l}`,null,'missing required property "coordinates"'))),t.animate&&"boolean"!=typeof t.animate&&this.fire(new s.t(new s.V(`sources.${l}`,null,'optional "animate" property must be a boolean value'))),t.canvas?"string"==typeof t.canvas||t.canvas instanceof HTMLCanvasElement||this.fire(new s.t(new s.V(`sources.${l}`,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 s.t(new s.V(`sources.${l}`,null,'missing required property "canvas"'))),this.options=t,this.animate=void 0===t.animate||t.animate}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 s.t(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(l){this.map=l,this.load(),this.canvas&&this.animate&&this.play()}onRemove(l){this.pause()}prepare(){let l=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,l=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,l=!0),this._hasInvalidDimensions()||0===Object.keys(this.tiles).length)return;const t=this.map.painter.context;this.texture?!l&&!this._playing||this.texture instanceof s.aF||this.texture.update(this.canvas,{premultiply:!0}):this.texture=new s.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 l of[this.canvas.width,this.canvas.height])if(isNaN(l)||l<=0)return!0;return!1}},custom:class extends s.E{constructor(l,t,r,c){super(),this.id=l,this.type="custom",this._dataType="raster",this._dispatcher=r,this._implementation=t,this.setEventedParent(c),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new s.t(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new s.t(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new zn(this._implementation.bounds,this.minzoom,this.maxzoom)),t.update=this._update.bind(this),t.clearTiles=this._clearTiles.bind(this),t.coveringTiles=this._coveringTiles.bind(this),s.l(this,s.ar(t,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return s.ar(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new s.x("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new s.x("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(l){this.map=l,this._loaded=!1,this.fire(new s.x("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(l),this.load()}onRemove(l){this._implementation.onRemove&&this._implementation.onRemove(l)}hasTile(l){if(this._implementation.hasTile){const{x:t,y:r,z:c}=l.canonical;return this._implementation.hasTile({x:t,y:r,z:c})}return!this.tileBounds||this.tileBounds.contains(l.canonical)}loadTile(l,t){const{x:r,y:c,z:d}=l.tileID.canonical,f=new AbortController;l.request=Promise.resolve(this._implementation.loadTile({x:r,y:c,z:d},{signal:f.signal})).then(function(_){return delete l.request,l.aborted?(l.state="unloaded",t(null)):void 0===_?(l.state="errored",t(null)):null===_?(this.loadTileData(l,{width:this.tileSize,height:this.tileSize,data:null}),l.state="loaded",t(null)):(T=_)instanceof ImageData||T instanceof HTMLCanvasElement||T instanceof ImageBitmap||T instanceof HTMLImageElement?(this.loadTileData(l,_),l.state="loaded",void t(null)):(l.state="errored",t(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)));var T}.bind(this)).catch(_=>{20!==_.code&&(l.state="errored",t(_))}),l.request.cancel=()=>f.abort()}loadTileData(l,t){l.setTexture(t,this.map.painter)}unloadTile(l,t){if(l.texture&&l.texture instanceof s.T?(l.destroy(!0),l.texture&&l.texture instanceof s.T&&this.map.painter.saveTileTexture(l.texture)):l.destroy(),this._implementation.unloadTile){const{x:r,y:c,z:d}=l.tileID.canonical;this._implementation.unloadTile({x:r,y:c,z:d})}t&&t()}abortTile(l,t){l.request&&l.request.cancel&&(l.request.cancel(),delete l.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(l=>({x:l.canonical.x,y:l.canonical.y,z:l.canonical.z}))}_clearTiles(){const l=s.av(this.id,this.scope);this.map.style.clearSource(l)}_update(){this.fire(new s.x("data",{dataType:"source",sourceDataType:"content"}))}}},$o=function(l,t,r,c){const d=new Na[t.type](l,t,r,c);if(d.id!==l)throw new Error(`Expected Source id to be ${l} instead of ${d.id}`);return s.aJ(["load","abort","unload","serialize","prepare"],d),d};function Jl(l,t){const r=s.a6.mat4.identity([]);return s.a6.mat4.scale(r,r,[.5*l.width,.5*-l.height,1]),s.a6.mat4.translate(r,r,[1,-1,0]),s.a6.mat4.multiply(r,r,l.calculateProjMatrix(t.toUnwrapped())),Float32Array.from(r)}function Ql(l,t,r,c,d,f,_,T=!1){const S=l.tilesIn(c,_,T);S.sort(Ho);const A=[];for(const z of S)A.push({wrappedTileID:z.tile.tileID.wrapped().key,queryResults:z.tile.queryRenderedFeatures(t,r,l._state,z,d,f,Jl(l.transform,z.tile.tileID),T)});const I=function(z){const D={},L={};for(const F of z){const N=F.queryResults,V=F.wrappedTileID,U=L[V]=L[V]||{};for(const W in N){const Y=N[W],$=U[W]=U[W]||{},Q=D[W]=D[W]||[];for(const J of Y)$[J.featureIndex]||($[J.featureIndex]=!0,Q.push(J))}}return D}(A);for(const z in I)I[z].forEach(D=>{const L=D.feature,F=L.layer;F&&"background"!==F.type&&"sky"!==F.type&&"slot"!==F.type&&(L.source=F.source,F["source-layer"]&&(L.sourceLayer=F["source-layer"]),L.state=void 0!==L.id?l.getFeatureState(F["source-layer"],L.id):{})});return I}function Xs(l,t){const r=l.getRenderableIds().map(f=>l.getTileByID(f)),c=[],d={};for(let f=0;f>=1)>1;){const A=r+d>>1,I=c+f>>1;1&t?(d=r,f=c,r=_,c=T):(r=d,c=f,d=_,f=T),_=A,T=I}const S=4*l;rn[S+0]=r,rn[S+1]=c,rn[S+2]=d,rn[S+3]=f}const Er=new Uint16Array(2178),pn=new Uint8Array(1089),Ys=new Uint16Array(1089);function ec(l){return 0===l?-.03125:32===l?.03125:0}const tc={type:2,extent:s.ab,loadGeometry:()=>[[new s.P(0,0),new s.P(s.ab+1,0),new s.P(s.ab+1,s.ab+1),new s.P(0,s.ab+1),new s.P(0,0)]]};class fn{constructor(t,r,c,d,f){this.tileID=t,this.uid=s.aP(),this.uses=0,this.tileSize=r,this.tileZoom=c,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=f,d&&d.style&&(this._lastUpdatedBrightness=d.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",d&&d.transform&&(this.projection=d.transform.projection)}registerFadeDuration(t){const r=t+this.timeAdded;rf.getLayer(A)).filter(Boolean);if(0!==S.length){T.layers=S,T.stateDependentLayerIds&&(T.stateDependentLayers=T.stateDependentLayerIds.map(A=>S.filter(I=>I.id===A)[0]));for(const A of S)_[A.fqid]=T}}return _}(t.buckets,r.style),this.hasSymbolBuckets=!1;for(const d in this.buckets){const f=this.buckets[d];if(f instanceof s.aR){if(this.hasSymbolBuckets=!0,!c)break;f.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const d in this.buckets){const f=this.buckets[d];if(f instanceof s.aR&&f.hasRTLText){this.hasRTLText=!0,s.aS();break}}this.queryPadding=0;for(const d in this.buckets){const f=this.buckets[d],_=r.style.getOwnLayer(d);if(!_)continue;const T=_.queryRadius(f);this.queryPadding=Math.max(this.queryPadding,T)}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),t.lineAtlas&&(this.lineAtlas=t.lineAtlas),this._lastUpdatedBrightness=t.brightness}else this.collisionBoxArray=new s.aQ}unloadVectorData(){if(this.hasData()){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(t){return this.buckets[t.fqid]}upload(t){for(const d in this.buckets){const f=this.buckets[d];f.uploadPending()&&f.upload(t)}const r=t.gl,c=this.imageAtlas;if(c&&!c.uploaded){const d=!!Object.keys(c.patternPositions).length;this.imageAtlasTexture=new s.T(t,c.image,r.RGBA8,{useMipmap:d}),this.imageAtlas.uploaded=!0}this.glyphAtlasImage&&(this.glyphAtlasTexture=new s.T(t,this.glyphAtlasImage,r.R8),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new s.T(t,this.lineAtlas.image,r.R8),this.lineAtlas.uploaded=!0)}prepare(t,r,c){if(this.imageAtlas&&this.imageAtlasTexture&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture,c),!r||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;const d=r.style.getBrightness();(this._lastUpdatedBrightness||d)&&(this._lastUpdatedBrightness&&d&&Math.abs(this._lastUpdatedBrightness-d)<.001||(this._lastUpdatedBrightness=d,this.updateBuckets(r)))}queryRenderedFeatures(t,r,c,d,f,_,T,S){return this.latestFeatureIndex&&(this.latestFeatureIndex.rawTileData||this.latestFeatureIndex.is3DTile)?this.latestFeatureIndex.query({tileResult:d,pixelPosMatrix:T,transform:_,params:f,tileTransform:this.tileTransform},t,r,c):{}}querySourceFeatures(t,r){const c=this.latestFeatureIndex;if(!c||!c.rawTileData)return;const d=c.loadVTLayers(),f=r?r.sourceLayer:"",_=d._geojsonTileLayer||d[f];if(!_)return;const T=s.aT(r&&r.filter),{z:S,x:A,y:I}=this.tileID.canonical,z={z:S,x:A,y:I};for(let D=0;D<_.length;D++){const L=_.feature(D);if(T.needGeometry){const V=s.aU(L,!0);if(!T.filter(new s.a3(this.tileID.overscaledZ),V,this.tileID.canonical))continue}else if(!T.filter(new s.a3(this.tileID.overscaledZ),L))continue;const F=c.getId(L,f),N=new s.aV(L,S,A,I,F);N.tile=z,t.push(N)}}hasData(){return"loaded"===this.state||"reloading"===this.state||"expired"===this.state}patternsLoaded(){return!!this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(t){const r=this.expirationTime;if(t.cacheControl){const c=s.aW(t.cacheControl);c["max-age"]&&(this.expirationTime=Date.now()+1e3*c["max-age"])}else t.expires&&(this.expirationTime=new Date(t.expires).getTime());if(this.expirationTime){const c=Date.now();let d=!1;if(this.expirationTime>c)d=!1;else if(r)if(this.expirationTime=0;V--){const U=4*V,W=rn[U+0],Y=rn[U+1],$=rn[U+2],Q=rn[U+3],J=W+$>>1,ne=Y+Q>>1,ie=J+ne-Y,oe=ne+W-J,de=33*Y+W,ce=33*Q+$,ae=33*ne+J,ye=Math.hypot((Er[2*de+0]+Er[2*ce+0])/2-Er[2*ae+0],(Er[2*de+1]+Er[2*ce+1])/2-Er[2*ae+1])>=16;pn[ae]=pn[ae]||(ye?1:0),V<1022&&(pn[ae]=pn[ae]||pn[33*(Y+oe>>1)+(W+ie>>1)]||pn[33*(Q+oe>>1)+($+ie>>1)])}const z=new s.aN,D=new s.aO;let L=0;function F(V,U){const W=33*U+V;return 0===Ys[W]&&(z.emplaceBack(Er[2*W+0],Er[2*W+1],V*s.ab/32,U*s.ab/32),Ys[W]=++L),Ys[W]-1}function N(V,U,W,Y,$,Q){const J=V+W>>1,ne=U+Y>>1;if(Math.abs(V-$)+Math.abs(U-Q)>1&&pn[33*ne+J])N($,Q,V,U,J,ne),N(W,Y,$,Q,J,ne);else{const ie=F(V,U),oe=F(W,Y),de=F($,Q);D.emplaceBack(ie,oe,de)}}return N(0,0,32,32,32,0),N(32,32,0,0,0,32),{vertices:z,indices:D}}(this.tileID.canonical,r);d=_.vertices,f=_.indices}else{d=new s.aN,f=new s.aO;for(const{x:T,y:S}of c)d.emplaceBack(T,S,0,0);const _=s.b2(d.int16,void 0,4);for(let T=0;T<_.length;T+=3)f.emplaceBack(_[T],_[T+1],_[T+2])}this._tileBoundsBuffer=t.createVertexBuffer(d,s.b3.members),this._tileBoundsIndexBuffer=t.createIndexBuffer(f),this._tileBoundsSegments=s.b1.simpleSegment(0,0,d.length,f.length)}_makeGlobeTileDebugBuffers(t,r){const c=r.projection;if(!c||"globe"!==c.name||r.freezeTileCoverage)return;const d=this.tileID.canonical,f=s.b4(d,r),_=s.b5(f),T=s.a9(r.zoom);let S;T>0&&(S=s.a6.mat4.invert(new Float64Array(16),r.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(t,d,r,_,S,T),this._makeGlobeTileDebugTextBuffer(t,d,r,_,S,T)}_globePoint(t,r,c,d,f,_,T){let S=s.b6(t,r,c);if(_){const A=1<.5?L=-1:D<-.5&&(L=1);let F=(t/s.ab+c.x)/A+L,N=(r/s.ab+c.y)/A;F=(F-I)*d._pixelsPerMercatorPixel+I,N=(N-z)*d._pixelsPerMercatorPixel+z;const V=[F*d.worldSize,N*d.worldSize,0];s.a6.vec3.transformMat4(V,V,_),S=s.b7(S,V,T)}return s.a6.vec3.transformMat4(S,S,f)}_makeGlobeTileDebugBorderBuffer(t,r,c,d,f,_){const T=new s.a_,S=new s.a$,A=new s.b8,I=(D,L,F,N,V)=>{const U=(F-D)/(V-1),W=(N-L)/(V-1),Y=T.length;for(let $=0;$z*L+F;for(let L=0;L{if(f)r(f);else try{const A=c.getHeaderLength(_);if(A>t)return void(this.request=this.fetchHeader(A,r));c.parseHeader(_),this._isHeaderLoaded=!0;let I=0;for(const z of Object.values(c.layers))I=Math.max(I,z.dataIndex[z.dataIndex.length-1].last_byte);_.byteLength>=I&&(this.entireBuffer=_),r(null,this.entireBuffer||_,T,S)}catch(A){r(A)}}),this.request}fetchBand(t,r,c){const d=this._mrt;if(!this._isHeaderLoaded||!d)return void c(new Error("Tile header is not ready"));const f=this.actor;if(!f)return void c(new Error("Can't fetch tile band without an actor"));let _;const T=(z,D)=>{_.complete(z,D),z?c(z):(this.updateTextureDescriptor(t,r),c(null,this.textureDescriptor&&this.textureDescriptor.img))},S=(z,D)=>{if(z)return c(z);const L=f.send("decodeRasterArray",{buffer:D,task:_},T,void 0,!0);this._workQueue.push(()=>{L&&L.cancel(),_.cancel()})},A=d.getLayer(t);if(!A)return void c(new Error(`Unknown sourceLayer "${t}"`));if(A.hasDataForBand(r))return this.updateTextureDescriptor(t,r),void c(null,this.textureDescriptor?this.textureDescriptor.img:null);const I=A.getDataRange([r]);if(_=d.createDecodingTask(I),!_||_.tasks.length)if(this.flushQueues(),this.entireBuffer)S(null,this.entireBuffer.slice(I.firstByte,I.lastByte+1));else{const z=Object.assign({},this.requestParams,{headers:{Range:`bytes=${I.firstByte}-${I.lastByte}`}}),D=s.bc(z,S);this._fetchQueue.push(()=>{D.cancel(),_.cancel()})}else c(null)}updateNeeded(t,r){return(!this.textureDescriptor||this.textureDescriptor.band!==r||this.textureDescriptor.layer!==t)&&"errored"!==this.state}updateTextureDescriptor(t,r){if(!this._mrt)return;const c=this._mrt.getLayer(t);if(!c||!c.hasBand(r)||!c.hasDataForBand(r))return;const{bytes:d,tileSize:f,buffer:_,offset:T,scale:S}=c.getBandView(r),A=f+2*_,I={data:d,width:A,height:A},z=this.texture;z&&z instanceof s.T&&z.update(I,{premultiply:!1}),this.textureDescriptor={layer:t,band:r,img:I,buffer:_,offset:T,tileSize:f,format:c.pixelFormat,mix:[S,256*S,65536*S,16777216*S]}}}class Fh{constructor(t,r){this.max=t,this.onRemove=r,this.reset()}reset(){for(const t in this.data)for(const r of this.data[t])r.timeout&&clearTimeout(r.timeout),this.onRemove(r.value);return this.data={},this.order=[],this}add(t,r,c){const d=t.wrapped().key;void 0===this.data[d]&&(this.data[d]=[]);const f={value:r,timeout:void 0};if(void 0!==c&&(f.timeout=setTimeout(()=>{this.remove(t,f)},c)),this.data[d].push(f),this.order.push(d),this.order.length>this.max){const _=this._getAndRemoveByKey(this.order[0]);_&&this.onRemove(_)}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 r=this.data[t].shift();return r.timeout&&clearTimeout(r.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),r.value}getByKey(t){const r=this.data[t];return r?r[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,r){if(!this.has(t))return this;const c=t.wrapped().key,d=void 0===r?0:this.data[c].indexOf(r),f=this.data[c][d];return this.data[c].splice(d,1),f.timeout&&clearTimeout(f.timeout),0===this.data[c].length&&delete this.data[c],this.onRemove(f.value),this.order.splice(this.order.indexOf(c),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const r=this._getAndRemoveByKey(this.order[0]);r&&this.onRemove(r)}return this}filter(t){const r=[];for(const c in this.data)for(const d of this.data[c])t(d.value)||r.push(d);for(const c of r)this.remove(c.value.tileID,c)}}class Ad{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,r,c){const d=String(r);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][d]=this.stateChanges[t][d]||{},s.l(this.stateChanges[t][d],c),null===this.deletedStates[t]){this.deletedStates[t]={};for(const f in this.state[t])f!==d&&(this.deletedStates[t][f]=null)}else if(this.deletedStates[t]&&null===this.deletedStates[t][d]){this.deletedStates[t][d]={};for(const f in this.state[t][d])c[f]||(this.deletedStates[t][d][f]=null)}else for(const f in c)this.deletedStates[t]&&this.deletedStates[t][d]&&null===this.deletedStates[t][d][f]&&delete this.deletedStates[t][d][f]}removeFeatureState(t,r,c){if(null===this.deletedStates[t])return;const d=String(r);if(this.deletedStates[t]=this.deletedStates[t]||{},c&&void 0!==r)null!==this.deletedStates[t][d]&&(this.deletedStates[t][d]=this.deletedStates[t][d]||{},this.deletedStates[t][d][c]=null);else if(void 0!==r)if(this.stateChanges[t]&&this.stateChanges[t][d])for(c in this.deletedStates[t][d]={},this.stateChanges[t][d])this.deletedStates[t][d][c]=null;else this.deletedStates[t][d]=null;else this.deletedStates[t]=null}getState(t,r){const c=this.state[t]||{},d=this.stateChanges[t]||{},f=this.deletedStates[t];if(null===f)return{};if(void 0!==r){const T=String(r),S=s.l({},c[T],d[T]);if(f){const A=f[r];if(null===A)return{};for(const I in A)delete S[I]}return S}const _=s.l({},c,d);if(f)for(const T in f)delete _[T];return _}initializeTileState(t,r){t.setFeatureState(this.state,r)}coalesceChanges(t,r){const c={};for(const d in this.stateChanges){this.state[d]=this.state[d]||{};const f={};for(const _ in this.stateChanges[d])this.state[d][_]||(this.state[d][_]={}),s.l(this.state[d][_],this.stateChanges[d][_]),f[_]=this.state[d][_];c[d]=f}for(const d in this.deletedStates){this.state[d]=this.state[d]||{};const f={};if(null===this.deletedStates[d])for(const _ in this.state[d])f[_]={},this.state[d][_]={};else for(const _ in this.deletedStates[d]){if(null===this.deletedStates[d][_])this.state[d][_]={};else if(this.state[d][_])for(const T of Object.keys(this.deletedStates[d][_]))delete this.state[d][_][T];f[_]=this.state[d][_]}c[d]=c[d]||{},s.l(c[d],f)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(c).length)for(const d in t)t[d].setFeatureState(c,r)}}class Ar extends s.E{constructor(t,r,c){super(),this.id=t,this._onlySymbols=c,r.on("data",d=>{"source"===d.dataType&&"metadata"===d.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===d.dataType&&"content"===d.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))}),r.on("error",()=>{this._sourceErrored=!0}),this._source=r,this._tiles={},this._cache=new Fh(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=r.minTileCacheSize,this._maxTileCacheSize=r.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new Ad,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"raster-array"===this._source.type||"custom"===this._source.type&&"raster"===this._source._dataType}onAdd(t){this.map=t,this._minTileCacheSize=void 0===this._minTileCacheSize&&t?t._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&t?t._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const t in this._tiles){const r=this._tiles[t];if("loaded"!==r.state&&"errored"!==r.state)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(t,r){return t.isSymbolTile=this._onlySymbols,t.isExtraShadowCaster=this._shadowCasterTiles[t.tileID.key],this._source.loadTile(t,r)}_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 r in this._tiles){const c=this._tiles[r];c.upload(t),c.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return s.bd(this._tiles).map(t=>t.tileID).sort(Xn).map(t=>t.key)}getRenderableIds(t,r){const c=[];for(const d in this._tiles)this._isIdRenderable(+d,t,r)&&c.push(this._tiles[d]);return t?c.sort((d,f)=>{const _=d.tileID,T=f.tileID,S=new s.P(_.canonical.x,_.canonical.y)._rotate(this.transform.angle),A=new s.P(T.canonical.x,T.canonical.y)._rotate(this.transform.angle);return _.overscaledZ-T.overscaledZ||A.y-S.y||A.x-S.x}).map(d=>d.tileID.key):c.map(d=>d.tileID).sort(Xn).map(d=>d.key)}hasRenderableParent(t){const r=this.findLoadedParent(t,0);return!!r&&this._isIdRenderable(r.tileID.key)}_isIdRenderable(t,r,c){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(r||!this._tiles[t].holdingForFade())&&(c||!this._shadowCasterTiles[t])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)"errored"!==this._tiles[t].state&&this._reloadTile(+t,"reloading")}}_reloadTile(t,r){const c=this._tiles[t];c&&("loading"!==c.state&&(c.state=r),this._loadTile(c,this._tileLoaded.bind(this,c,t,r)))}_tileLoaded(t,r,c,d){if(d)if(t.state="errored",404!==d.status)this._source.fire(new s.t(d,{tile:t}));else{if(this._source.fire(new s.x("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id,tile:t})),!(t.tileID.key in this._loadedParentTiles))return;if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const f=this.map.painter.terrain;this.update(this.transform,f.getScaledDemTileSize(),!0),f.resetTileLookupCache(this.id)}else this.update(this.transform)}else t.timeAdded=s.q.now(),"expired"===c&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(r,t),"raster-dem"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),this._source.fire(new s.x("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id}))}_backfillDEM(t){const r=this.getRenderableIds();for(let d=0;d1||(Math.abs(_)>1&&(1===Math.abs(_+S)?_+=S:1===Math.abs(_-S)&&(_-=S)),f.dem&&d.dem&&(d.dem.backfillBorder(f.dem,_,T),d.neighboringTiles&&d.neighboringTiles[A]&&(d.neighboringTiles[A].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,r,c,d){for(const f in this._tiles){let _=this._tiles[f];if(d[f]||!_.hasData()||_.tileID.overscaledZ<=r||_.tileID.overscaledZ>c)continue;let T=_.tileID;for(;_&&_.tileID.overscaledZ>r+1;){const A=_.tileID.scaledTo(_.tileID.overscaledZ-1);_=this._tiles[A.key],_&&_.hasData()&&(T=A)}let S=T;for(;S.overscaledZ>r;)if(S=S.scaledTo(S.overscaledZ-1),t[S.key]){d[T.key]=T;break}}}findLoadedParent(t,r){if(t.key in this._loadedParentTiles){const c=this._loadedParentTiles[t.key];return c&&c.tileID.overscaledZ>=r?c:null}for(let c=t.overscaledZ-1;c>=r;c--){const d=t.scaledTo(c),f=this._getLoadedTile(d);if(f)return f}}_getLoadedTile(t){const r=this._tiles[t.key];return r&&r.hasData()?r:this._cache.getByKey(this._source.reparseOverscaled?t.wrapped().key:t.canonical.key)}updateCacheSize(t,r){r=r||this._source.tileSize;const c=Math.ceil(t.width/r)+1,d=Math.ceil(t.height/r)+1,f=Math.floor(c*d*5),_="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,f):f,T="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,_):_;this._cache.setMaxSize(T)}handleWrapJump(t){const r=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);if(this._prevLng=t,r){const c={};for(const d in this._tiles){const f=this._tiles[d];f.tileID=f.tileID.unwrapTo(f.tileID.wrap+r),c[f.tileID.key]=f}this._tiles=c;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,r,c,d){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!c)return;this.updateCacheSize(t,r),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={};const f="batched-model"===this._source.type;let _;if(this.used||this.usedForTerrain){if(this._source.tileID)_=t.getVisibleUnwrappedCoordinates(this._source.tileID).map(A=>new s.aA(A.canonical.z,A.wrap,A.canonical.z,A.canonical.x,A.canonical.y));else if(0!==this.tileCoverLift){const A=t.clone();A.tileCoverLift=this.tileCoverLift,_=A.coveringTiles({tileSize:r||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!c,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:f}),this._source.minzoom<=1&&"globe"===t.projection.name&&(_.push(new s.aA(1,0,1,0,0)),_.push(new s.aA(1,0,1,1,0)),_.push(new s.aA(1,0,1,0,1)),_.push(new s.aA(1,0,1,1,1)))}else if(_=t.coveringTiles({tileSize:r||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!c,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:f}),this._source.hasTile){const A=this._source.hasTile.bind(this._source);_=_.filter(I=>A(I))}}else _=[];if(_.length>0&&this.castsShadows&&d&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!Ks(this._source.type)){const A=t.coveringZoomLevel({tileSize:r||this._source.tileSize,roundZoom:this._source.roundZoom&&!c}),I=Math.min(A,this._source.maxzoom);if(f){const z=t.extendTileCover(_,I);for(const D of z)_.push(D)}else{const z=t.extendTileCover(_,I,d);for(const D of z)this._shadowCasterTiles[D.key]=!0,_.push(D)}}const T=this._updateRetainedTiles(_);if(Ks(this._source.type)&&0!==_.length){const A={},I={},z=Object.keys(T);for(const L of z){const F=T[L],N=this._tiles[L];if(!N||N.fadeEndTime&&N.fadeEndTime<=s.q.now())continue;const V=this.findLoadedParent(F,Math.max(F.overscaledZ-Ar.maxOverzooming,this._source.minzoom));V&&(this._addTile(V.tileID),A[V.tileID.key]=V.tileID),I[L]=F}const D=_[_.length-1].overscaledZ;for(const L in this._tiles){const F=this._tiles[L];if(T[L]||!F.hasData())continue;let N=F.tileID;for(;N.overscaledZ>D;){N=N.scaledTo(N.overscaledZ-1);const V=this._tiles[N.key];if(V&&V.hasData()&&I[N.key]){T[L]=F.tileID;break}}}for(const L in A)T[L]||(this._coveredTiles[L]=!0,T[L]=A[L])}for(const A in T)this._tiles[A].clearFadeHold();const S=s.be(this._tiles,T);for(const A of S){const I=this._tiles[A];I.hasSymbolBuckets&&!I.holdingForFade()?I.setHoldDuration(this.map._fadeDuration):I.hasSymbolBuckets&&!I.symbolFadeFinished()||this._removeTile(+A)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(+t)}_updateRetainedTiles(t){const r={};if(0===t.length)return r;const c={},d=t.reduce((A,I)=>Math.min(A,I.overscaledZ),1/0),f=t[0].overscaledZ,_=Math.max(f-Ar.maxOverzooming,this._source.minzoom),T=Math.max(f+Ar.maxUnderzooming,this._source.minzoom),S={};for(const A of t){const I=this._addTile(A);r[A.key]=A,I.hasData()||d=this._source.maxzoom){const D=A.children(this._source.maxzoom)[0],L=this.getTile(D);if(L&&L.hasData()){r[D.key]=D;continue}}else{const D=A.children(this._source.maxzoom);if(r[D[0].key]&&r[D[1].key]&&r[D[2].key]&&r[D[3].key])continue}let z=I.wasRequested();for(let D=A.overscaledZ-1;D>=_;--D){const L=A.scaledTo(D);if(c[L.key]||(c[L.key]=!0,I=this.getTile(L),!I&&z&&(I=this._addTile(L)),I&&(r[L.key]=L,z=I.wasRequested(),I.hasData())))break}}return r}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const r=[];let c,d=this._tiles[t].tileID;for(;d.overscaledZ>0;){if(d.key in this._loadedParentTiles){c=this._loadedParentTiles[d.key];break}r.push(d.key);const f=d.scaledTo(d.overscaledZ-1);if(c=this._getLoadedTile(f),c)break;d=f}for(const f of r)this._loadedParentTiles[f]=c}}_addTile(t){let r=this._tiles[t.key];if(r)return!0!==r.isExtraShadowCaster||this._shadowCasterTiles[t.key]||this._reloadTile(t.key,"reloading"),r;r=this._cache.getAndRemove(t),r&&(this._setTileReloadTimer(t.key,r),r.tileID=t,this._state.initializeTileState(r,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,r)));const c=!!r;if(!c){const d=this.map?this.map.painter:null,f=this._source.tileSize*t.overscaleFactor();r="raster-array"===this._source.type?new Va(t,f,this.transform.tileZoom,d,this._isRaster):new fn(t,f,this.transform.tileZoom,d,this._isRaster),this._loadTile(r,this._tileLoaded.bind(this,r,t.key,r.state))}return r?(r.uses++,this._tiles[t.key]=r,c||this._source.fire(new s.x("dataloading",{tile:r,coord:r.tileID,dataType:"source"})),r):null}_setTileReloadTimer(t,r){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const c=r.getExpiryTimeout();c&&(this._timers[t]=setTimeout(()=>{this._reloadTile(t,"expired"),delete this._timers[t]},c))}_removeTile(t){const r=this._tiles[t];r&&(r.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),r.uses>0||(r.hasData()&&"reloading"!==r.state||"empty"===r.state?this._cache.add(r.tileID,r,r.getExpiryTimeout()):(r.aborted=!0,this._abortTile(r),this._unloadTile(r))))}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,r,c){const d=[],f=this.transform;if(!f)return d;const _="globe"===f.projection.name,T=s.am(f.center.lng);for(const S in this._tiles){const A=this._tiles[S];if(c&&A.clearQueryDebugViz(),A.holdingForFade())continue;let I;if(_){const z=A.tileID.canonical;if(0===z.z){const D=[Math.abs(s.ap(T,...Wo(z,-1))-T),Math.abs(s.ap(T,...Wo(z,1))-T)];I=[0,2*D.indexOf(Math.min(...D))-1]}else{const D=[Math.abs(s.ap(T,...Wo(z,-1))-T),Math.abs(s.ap(T,...Wo(z,0))-T),Math.abs(s.ap(T,...Wo(z,1))-T)];I=[D.indexOf(Math.min(...D))-1]}}else I=[0];for(const z of I){const D=t.containsTile(A,f,r,z);D&&d.push(D)}}return d}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(t){return this._getRenderableCoordinates(t)}_getRenderableCoordinates(t,r){const c=this.getRenderableIds(t,r).map(f=>this._tiles[f].tileID),d="globe"===this.transform.projection.name;for(const f of c)f.projMatrix=this.transform.calculateProjMatrix(f.toUnwrapped()),f.expandedProjMatrix=d?this.transform.calculateProjMatrix(f.toUnwrapped(),!1,!0):f.projMatrix;return c}sortCoordinatesByDistance(t){const r=t.slice(),c=this.transform._camera.position,d=this.transform._camera.forward(),f={};for(const _ of r){const T=1/(1<<_.canonical.z);f[_.key]=((_.canonical.x+.5)*T+_.wrap-c[0])*d[0]+((_.canonical.y+.5)*T-c[1])*d[1]-c[2]*d[2]}return r.sort((_,T)=>f[_.key]-f[T.key]),r}hasTransition(){if(this._source.hasTransition())return!0;if(Ks(this._source.type))for(const t in this._tiles){const r=this._tiles[t];if(void 0!==r.fadeEndTime&&r.fadeEndTime>=s.q.now())return!0}return!1}setFeatureState(t,r,c){this._state.updateState(t=t||"_geojsonTileLayer",r,c)}removeFeatureState(t,r,c){this._state.removeFeatureState(t=t||"_geojsonTileLayer",r,c)}getFeatureState(t,r){return this._state.getState(t=t||"_geojsonTileLayer",r)}setDependencies(t,r,c){const d=this._tiles[t];d&&d.setDependencies(r,c)}reloadTilesForDependencies(t,r){for(const c in this._tiles)this._tiles[c].hasDependency(t,r)&&this._reloadTile(+c,"reloading");this._cache.filter(c=>!c.hasDependency(t,r))}_preloadTiles(t,r){if(!this._sourceLoaded){const S=()=>{this._sourceLoaded&&(this._source.off("data",S),this._preloadTiles(t,r))};return void this._source.on("data",S)}const c=new Map,d=Array.isArray(t)?t:[t],f=this.map.painter.terrain,_=this.usedForTerrain&&f?f.getScaledDemTileSize():this._source.tileSize;for(const S of d){const A=S.coveringTiles({tileSize:_,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const I of A)c.set(I.key,I);this.usedForTerrain&&S.updateElevation(!1)}const T=Array.from(c.values());s.bf(T,(S,A)=>{const I=new fn(S,this._source.tileSize*S.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(I,z=>{"raster-dem"===this._source.type&&I.dem&&this._backfillDEM(I),A(z,I)})},r)}}function Xn(l,t){const r=Math.abs(2*l.wrap)-+(l.wrap<0),c=Math.abs(2*t.wrap)-+(t.wrap<0);return l.overscaledZ-t.overscaledZ||c-r||t.canonical.y-l.canonical.y||t.canonical.x-l.canonical.x}function Ks(l){return"raster"===l||"image"===l||"video"===l||"custom"===l}function Wo(l,t){const r=1<0:"model"===c.type&&(d=!c.isHidden(t)&&c.paint.get("model-opacity")>0),this.layersGotHidden=this.layersGotHidden||!d&&r.visible,r.visible=d}}updateZOffset(t,r){this.currentBuildingBuckets=[];for(const d of this.layers){const f=d.layer,_=this.style.getLayerSourceCache(f);let T=1;"fill-extrusion"===f.type&&(T=d.visible?f.paint.get("fill-extrusion-vertical-scale"):0);let S=_?_.getTile(r):null;if(!S&&_&&r.canonical.z>_.getSource().minzoom){let A=r.scaledTo(Math.min(_.getSource().maxzoom,r.overscaledZ-1));for(;A.overscaledZ>=_.getSource().minzoom&&(S=_.getTile(A),!S&&0!==A.overscaledZ);)A=A.scaledTo(A.overscaledZ-1)}this.currentBuildingBuckets.push({bucket:S?S.getBucket(f):null,tileID:S?S.tileID:r,verticalScale:T})}t.hasAnyZOffset=!1;let c=!1;for(let d=0;d{c in t&&(r[c]=t[c])}),r}function rc(l){l=l.slice();const t=Object.create(null);for(let r=0;r0?(d-_)/T:0;return this.points[f].mult(1-S).add(this.points[r].mult(S))}}class Ua{constructor(t,r,c){const d=this.boxCells=[],f=this.circleCells=[];this.xCellCount=Math.ceil(t/c),this.yCellCount=Math.ceil(r/c);for(let _=0;_this.width||d<0||r>this.height)return!f&&[];const T=[];if(t<=0&&r<=0&&this.width<=c&&this.height<=d){if(f)return!0;for(let S=0;S0:T}_queryCircle(t,r,c,d,f){const _=t-c,T=t+c,S=r-c,A=r+c;if(T<0||_>this.width||A<0||S>this.height)return!d&&[];const I=[];return this._forEachCell(_,S,T,A,this._queryCellCircle,I,{hitTest:d,circle:{x:t,y:r,radius:c},seenUids:{box:{},circle:{}}},f),d?I.length>0:I}query(t,r,c,d,f){return this._query(t,r,c,d,!1,f)}hitTest(t,r,c,d,f){return this._query(t,r,c,d,!0,f)}hitTestCircle(t,r,c,d){return this._queryCircle(t,r,c,!0,d)}_queryCell(t,r,c,d,f,_,T,S){const A=T.seenUids,I=this.boxCells[f];if(null!==I){const D=this.bboxes;for(const L of I)if(!A.box[L]){A.box[L]=!0;const F=4*L;if(t<=D[F+2]&&r<=D[F+3]&&c>=D[F+0]&&d>=D[F+1]&&(!S||S(this.boxKeys[L]))){if(T.hitTest)return _.push(!0),!0;_.push({key:this.boxKeys[L],x1:D[F],y1:D[F+1],x2:D[F+2],y2:D[F+3]})}}}const z=this.circleCells[f];if(null!==z){const D=this.circles;for(const L of z)if(!A.circle[L]){A.circle[L]=!0;const F=3*L;if(this._circleAndRectCollide(D[F],D[F+1],D[F+2],t,r,c,d)&&(!S||S(this.circleKeys[L]))){if(T.hitTest)return _.push(!0),!0;{const N=D[F],V=D[F+1],U=D[F+2];_.push({key:this.circleKeys[L],x1:N-U,y1:V-U,x2:N+U,y2:V+U})}}}}}_queryCellCircle(t,r,c,d,f,_,T,S){const A=T.circle,I=T.seenUids,z=this.boxCells[f];if(null!==z){const L=this.bboxes;for(const F of z)if(!I.box[F]){I.box[F]=!0;const N=4*F;if(this._circleAndRectCollide(A.x,A.y,A.radius,L[N+0],L[N+1],L[N+2],L[N+3])&&(!S||S(this.boxKeys[F])))return _.push(!0),!0}}const D=this.circleCells[f];if(null!==D){const L=this.circles;for(const F of D)if(!I.circle[F]){I.circle[F]=!0;const N=3*F;if(this._circlesCollide(L[N],L[N+1],L[N+2],A.x,A.y,A.radius)&&(!S||S(this.circleKeys[F])))return _.push(!0),!0}}}_forEachCell(t,r,c,d,f,_,T,S){const A=this._convertToXCellCoord(t),I=this._convertToYCellCoord(r),z=this._convertToXCellCoord(c),D=this._convertToYCellCoord(d);for(let L=A;L<=z;L++)for(let F=I;F<=D;F++)if(f.call(this,t,r,c,d,this.xCellCount*F+L,_,T,S))return}_convertToXCellCoord(t){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(t*this.xScale)))}_convertToYCellCoord(t){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(t*this.yScale)))}_circlesCollide(t,r,c,d,f,_){const T=d-t,S=f-r,A=c+_;return A*A>T*T+S*S}_circleAndRectCollide(t,r,c,d,f,_,T){const S=(_-d)/2,A=Math.abs(t-(d+S));if(A>S+c)return!1;const I=(T-f)/2,z=Math.abs(r-(f+I));if(z>I+c)return!1;if(A<=S||z<=I)return!0;const D=A-S,L=z-I;return D*D+L*L<=c*c}}const nt=Math.tan(85*Math.PI/180);function Wt(l,t,r,c,d,f,_){const T=s.a6.mat4.create();if(r)if("globe"===f.name){const S=s.bi(d,t);s.a6.mat4.multiply(T,T,S)}else{const S=s.a6.mat2.invert([],_);T[0]=S[0],T[1]=S[1],T[4]=S[2],T[5]=S[3],c||s.a6.mat4.rotateZ(T,T,d.angle)}else s.a6.mat4.multiply(T,d.labelPlaneMatrix,l);return T}function Xt(l,t,r,c,d,f,_){const T=Wt(l,t,r,c,d,f,_);return"globe"===f.name&&r||(T[2]=T[6]=T[10]=T[14]=0),T}function Ir(l,t,r,c,d,f,_){if(r){if("globe"===f.name){const T=Wt(l,t,r,c,d,f,_);return s.a6.mat4.invert(T,T),s.a6.mat4.multiply(T,l,T),T}{const T=s.a6.mat4.clone(l),S=s.a6.mat4.identity([]);return S[0]=_[0],S[1]=_[1],S[4]=_[2],S[5]=_[3],s.a6.mat4.multiply(T,T,S),c||s.a6.mat4.rotateZ(T,T,-d.angle),T}}return d.glCoordMatrix}function fr(l,t,r,c){const d=[l,t,r,1];r?s.a6.vec4.transformMat4(d,d,c):Ga(d,d,c);const f=d[3];return d[0]/=f,d[1]/=f,d[2]/=f,d}function Jt(l,t){return Math.min(.5+l/t*.5,1.5)}function ja(l,t){const r=l[0]/l[3],c=l[1]/l[3];return r>=-t[0]&&r<=t[0]&&c>=-t[1]&&c<=t[1]}function Ko(l,t,r,c,d,f,_,T,S,A){const I=r.transform,z=c?l.textSizeData:l.iconSizeData,D=s.bj(z,r.transform.zoom),L="globe"===I.projection.name,F=[256/r.width*2+1,256/r.height*2+1],N=c?l.text.dynamicLayoutVertexArray:l.icon.dynamicLayoutVertexArray;N.clear();let V=null;L&&(V=c?l.text.globeExtVertexArray:l.icon.globeExtVertexArray);const U=l.lineVertexArray,W=c?l.text.placedSymbolArray:l.icon.placedSymbolArray,Y=r.transform.width/r.transform.height;let $,Q=!1;for(let J=0;JMath.abs(r)?{useVertical:!0}:l===s.bk.vertical?c>0?{needsFlipping:!0}:null:0!==t&&(0===(d=r)||Math.abs(c/d)>nt)?1===t?{needsFlipping:!0}:null:r<0?{needsFlipping:!0}:null;var d}function Vi(l,t,r,c,d,f,_,T,S,A,I,z,D,L,F,N,V,U,W){const Y=t/24,$=l.lineOffsetX*Y,Q=l.lineOffsetY*Y,{lineStartIndex:J,glyphStartIndex:ne,numGlyphs:ie,segment:oe,writingMode:de,flipState:ce}=l,ae=J+l.lineLength,ye=Ie=>{if(I){const[xe,Re,ze]=Ie.up,Ue=A.length;s.bm(I,Ue+0,xe,Re,ze),s.bm(I,Ue+1,xe,Re,ze),s.bm(I,Ue+2,xe,Re,ze),s.bm(I,Ue+3,xe,Re,ze)}const[ke,Ae,Ne]=Ie.point;s.bn(A,ke,Ae,Ne,Ie.angle)};if(ie>1){const Ie=Jo(Y,T,$,Q,r,z,D,l,S,f,L,N,!1,V,U,W);if(!Ie)return{notEnoughRoom:!0};if(c&&!r){let[ke,Ae,Ne]=Ie.first.point,[xe,Re,ze]=Ie.last.point;[ke,Ae]=fr(ke,Ae,Ne,_),[xe,Re]=fr(xe,Re,ze,_);const Ue=xr(de,ce,(xe-ke)*F,Re-Ae);if(l.flipState=Ue&&Ue.needsFlipping?1:2,Ue)return Ue}ye(Ie.first);for(let ke=ne+1;ke0?xe:Qo(D,Ne,ke,1,d,void 0,V,U.canonical),ze=xr(de,ce,(Re[0]-ke[0])*F,Re[1]-ke[1]);if(l.flipState=ze&&ze.needsFlipping?1:2,ze)return ze}const Ie=es(Y*T.getoffsetX(ne),$,Q,r,z,D,oe,J,ae,S,f,L,N,!1,!1,V,U,W);if(!Ie)return{notEnoughRoom:!0};ye(Ie)}return{}}function Nh(l,t,r,c,d){const{x:f,y:_,z:T}=c.projectTilePoint(l.x,l.y,t);if(!d)return fr(f,_,T,r);const[S,A,I]=d(l);return fr(f+S,_+A,T+I,r)}function Qo(l,t,r,c,d,f,_,T){const S=Nh(l.sub(t)._unit()._add(l),T,d,_,f);return s.a6.vec3.sub(S,r,S),s.a6.vec3.normalize(S,S),s.a6.vec3.scaleAndAdd(S,r,S,c)}function es(l,t,r,c,d,f,_,T,S,A,I,z,D,L,F,N,V,U){const W=c?l-t:l+t;let Y=W>0?1:-1,$=0;c&&(Y*=-1,$=Math.PI),Y<0&&($+=Math.PI);let Q=T+_+(Y>0?0:1)|0,J=d,ne=d,ie=0,oe=0;const de=Math.abs(W),ce=[],ae=[];let ye=f,Ie=ye;const ke=()=>Qo(Ie,ye,ne,de-ie+1,I,D,N,V.canonical);for(;ie+oe<=de;){if(Q+=Y,Q=S)return null;if(ne=J,Ie=ye,ce.push(ne),L&&ae.push(Ie),ye=new s.P(A.getx(Q),A.gety(Q)),J=z[Q],!J){const Be=Nh(ye,V.canonical,I,N,D);J=Be[3]>0?z[Q]=Be:ke()}ie+=oe,oe=s.a6.vec3.distance(ne,J)}F&&D&&(z[Q]&&(J=ke(),oe=s.a6.vec3.distance(ne,J)),z[Q]=J);const Ae=(de-ie)/oe,Ne=ye.sub(Ie)._mult(Ae)._add(Ie),xe=s.a6.vec3.sub([],J,ne),Re=s.a6.vec3.scaleAndAdd([],ne,xe,Ae);let ze=[0,0,1],Ue=xe[0],Ge=xe[1];if(U&&(ze=N.upVector(V.canonical,Ne.x,Ne.y),0!==ze[0]||0!==ze[1]||1!==ze[2])){const Be=[ze[2],0,-ze[0]],ht=s.a6.vec3.cross([],ze,Be);s.a6.vec3.normalize(Be,Be),s.a6.vec3.normalize(ht,ht),Ue=s.a6.vec3.dot(xe,Be),Ge=s.a6.vec3.dot(xe,ht)}if(r){const Be=s.a6.vec3.cross([],ze,xe);s.a6.vec3.normalize(Be,Be),s.a6.vec3.scaleAndAdd(Re,Re,Be,r*Y)}const Le=$+Math.atan2(Ge,Ue);return ce.push(Re),L&&ae.push(Ne),{point:Re,angle:Le,path:ce,tilePath:ae,up:ze}}function _n(l,t){const r=t.length,c=r+4*l;t.resize(c),t.float32.fill(-1/0,4*r,4*c)}function Ga(l,t,r){const c=t[0],d=t[1];return l[0]=r[0]*c+r[4]*d+r[12],l[1]=r[1]*c+r[5]*d+r[13],l[3]=r[3]*c+r[7]*d+r[15],l}const kr=100;class mr{constructor(t,r,c=new Ua(t.width+200,t.height+200,25),d=new Ua(t.width+200,t.height+200,25)){this.transform=t,this.grid=c,this.ignoredGrid=d,this.pitchfactor=Math.cos(t._pitch)*t.cameraToCenterDistance,this.screenRightBoundary=t.width+kr,this.screenBottomBoundary=t.height+kr,this.gridRightBoundary=t.width+200,this.gridBottomBoundary=t.height+200,this.fogState=r}placeCollisionBox(t,r,c,d,f,_,T,S){let A=c.projectedAnchorX,I=c.projectedAnchorY,z=c.projectedAnchorZ;const D=c.elevation,L=c.tileID,F=t.getProjection();if(D&&L){const[J,ne,ie]=F.upVector(L.canonical,c.tileAnchorX,c.tileAnchorY),oe=F.upVectorScale(L.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;A+=J*D*oe,I+=ne*D*oe,z+=ie*D*oe}const N=this.projectAndGetPerspectiveRatio(T,A,I,z,c.tileID,"globe"===F.name||!!D||this.transform.pitch>0,F),V=_*N.perspectiveRatio,U=(c.x1*r+d.x-c.padding)*V+N.point.x,W=(c.y1*r+d.y-c.padding)*V+N.point.y,Y=(c.x2*r+d.x+c.padding)*V+N.point.x,$=(c.y2*r+d.y+c.padding)*V+N.point.y,Q=N.perspectiveRatio<=.55||N.occluded;return!this.isInsideGrid(U,W,Y,$)||!f&&this.grid.hitTest(U,W,Y,$,S)||Q?{box:[],offscreen:!1,occluded:N.occluded}:{box:[U,W,Y,$],offscreen:this.isOffscreen(U,W,Y,$),occluded:!1}}placeCollisionCircles(t,r,c,d,f,_,T,S,A,I,z,D,L,F,N){const V=[],U=this.transform.elevation,W=t.getProjection(),Y=U?U.getAtTileOffsetFunc(N,this.transform.center.lat,this.transform.worldSize,W):null,$=new s.P(c.tileAnchorX,c.tileAnchorY);let{x:Q,y:J,z:ne}=W.projectTilePoint($.x,$.y,N.canonical);if(Y){const[Ne,xe,Re]=Y($);Q+=Ne,J+=xe,ne+=Re}const ie="globe"===W.name,oe=this.projectAndGetPerspectiveRatio(T,Q,J,ne,N,ie||!!U||this.transform.pitch>0,W),{perspectiveRatio:de}=oe,ce=(z?_/de:_*de)/s.bq,ae=fr(Q,J,ne,S),ye=oe.signedDistanceFromCamera>0?Jo(ce,f,c.lineOffsetX*ce,c.lineOffsetY*ce,!1,ae,$,c,d,S,{},U&&!z?Y:null,z&&!!U,W,N,z):null;let Ie=!1,ke=!1,Ae=!0;if(ye&&!oe.occluded){const Ne=.5*L*de+F,xe=new s.P(-100,-100),Re=new s.P(this.screenRightBoundary,this.screenBottomBoundary),ze=new mn,{first:Ue,last:Ge}=ye,Le=Ue.path.length;let Be=[];for(let et=Le-1;et>=1;et--)Be.push(Ue.path[et]);for(let et=1;et(Y&&!ie&&(ot=Y(ptet[3]<=0)&&(Be=[]));let Ze=[];if(Be.length>0){let et=1/0,_t=-1/0,ot=1/0,pt=-1/0;for(const Ft of Be)et=Math.min(et,Ft[0]),ot=Math.min(ot,Ft[1]),_t=Math.max(_t,Ft[0]),pt=Math.max(pt,Ft[1]);_t>=xe.x&&et<=Re.x&&pt>=xe.y&&ot<=Re.y&&(Ze=[Be.map(Ft=>new s.P(Ft[0],Ft[1]))],(etRe.x||otRe.y)&&(Ze=s.bo(Ze,xe.x,xe.y,Re.x,Re.y)))}for(const et of Ze){ze.reset(et,.25*Ne);let _t=0;_t=ze.length<=.5*Ne?1:Math.ceil(ze.paddedLength/ht)+1;for(let ot=0;ot<_t;ot++){const pt=ot/Math.max(_t-1,1),Ft=ze.lerp(pt),Lt=Ft.x+kr,di=Ft.y+kr;V.push(Lt,di,Ne,0);const yi=Lt-Ne,Si=di-Ne,Hr=Lt+Ne,qi=di+Ne;if(Ae=Ae&&this.isOffscreen(yi,Si,Hr,qi),ke=ke||this.isInsideGrid(yi,Si,Hr,qi),!r&&this.grid.hitTestCircle(Lt,di,Ne,D)&&(Ie=!0,!I))return{circles:[],offscreen:!1,collisionDetected:Ie,occluded:!1}}}}return{circles:!I&&Ie||!ke?[]:V,offscreen:Ae,collisionDetected:Ie,occluded:oe.occluded}}queryRenderedSymbols(t){if(0===t.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const r=[];let c=1/0,d=1/0,f=-1/0,_=-1/0;for(const I of t){const z=new s.P(I.x+kr,I.y+kr);c=Math.min(c,z.x),d=Math.min(d,z.y),f=Math.max(f,z.x),_=Math.max(_,z.y),r.push(z)}const T=this.grid.query(c,d,f,_).concat(this.ignoredGrid.query(c,d,f,_)),S={},A={};for(const I of T){const z=I.key;if(void 0===S[z.bucketInstanceId]&&(S[z.bucketInstanceId]={}),S[z.bucketInstanceId][z.featureIndex])continue;const D=[new s.P(I.x1,I.y1),new s.P(I.x2,I.y1),new s.P(I.x2,I.y2),new s.P(I.x1,I.y2)];s.bp(r,D)&&(S[z.bucketInstanceId][z.featureIndex]=!0,void 0===A[z.bucketInstanceId]&&(A[z.bucketInstanceId]=[]),A[z.bucketInstanceId].push(z.featureIndex))}return A}insertCollisionBox(t,r,c,d,f){(r?this.ignoredGrid:this.grid).insert({bucketInstanceId:c,featureIndex:d,collisionGroupID:f},t[0],t[1],t[2],t[3])}insertCollisionCircles(t,r,c,d,f){const _=r?this.ignoredGrid:this.grid,T={bucketInstanceId:c,featureIndex:d,collisionGroupID:f};for(let S=0;S0?(s.a6.vec4.transformMat4(S,S,t),this.fogState&&f&&"globe"!==T.name&&(A=function(D,L,F,N,V,U){const W=U.calculateFogTileMatrix(V),Y=[L,F,N];return s.a6.vec3.transformMat4(Y,Y,W),Qe(D,s.a6.vec3.length(Y),U.pitch,U._fov)}(this.fogState,r,c,d,f.toUnwrapped(),this.transform)>.9)):Ga(S,S,t);const I=S[3];return{point:new s.P((S[0]/I+1)/2*this.transform.width+kr,(-S[1]/I+1)/2*this.transform.height+kr),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(T)/I*.5,1.5),signedDistanceFromCamera:I,occluded:_&&S[2]>I||A}}isOffscreen(t,r,c,d){return c=this.screenRightBoundary||dthis.screenBottomBoundary}isInsideGrid(t,r,c,d){return c>=0&&t=0&&rc.collisionGroupID===r}}return this.collisionGroups[t]}}function ts(l,t,r,c,d){const{horizontalAlign:f,verticalAlign:_}=s.bx(l),T=-(f-.5)*t,S=-(_-.5)*r,A=s.bw(l,c);return new s.P(T+A[0]*d,S+A[1]*d)}function wo(l,t,r,c,d){const f=new s.P(l,t);return r&&f._rotate(c?d:-d),f}class To{constructor(t,r,c,d,f,_){this.transform=t.clone(),this.projection=t.projection.name,this.collisionIndex=new mr(this.transform,f),this.buildingIndex=_,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=r,this.retainedQueryData={},this.collisionGroups=new sn(c),this.collisionCircleArrays={},this.prevPlacement=d,d&&(d.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(t,r,c,d){const f=c.getBucket(r),_=c.latestFeatureIndex;if(!f||!_||r.fqid!==f.layerIds[0])return;const T=f.layers[0].layout,S=f.layers[0].paint,A=c.collisionBoxArray,I=Math.pow(2,this.transform.zoom-c.tileID.overscaledZ),z=c.tileSize/s.ab,D=c.tileID.toUnwrapped();this.transform.setProjection(f.projection);const L=(F=c.tileID,N=f.getProjection(),V=this.transform,N.name===this.projection?V.calculateProjMatrix(F.toUnwrapped()):vr(V,N,F));var F,N,V;const U="map"===T.get("text-pitch-alignment"),W="map"===T.get("text-rotation-alignment");r.compileFilter();const Y=r.dynamicFilter(),$=r.dynamicFilterNeedsFeature(),Q=this.transform.calculatePixelsToTileUnitsMatrix(c),J=Xt(L,c.tileID.canonical,U,W,this.transform,f.getProjection(),Q);let ne=null;if(U){const de=Ir(L,c.tileID.canonical,U,W,this.transform,f.getProjection(),Q);ne=s.a6.mat4.multiply([],this.transform.labelPlaneMatrix,de)}let ie=null;Y&&c.latestFeatureIndex&&(ie={unwrappedTileID:D,dynamicFilter:Y,dynamicFilterNeedsFeature:$}),this.retainedQueryData[f.bucketInstanceId]=new oc(f.bucketInstanceId,_,f.sourceLayerIndex,f.index,c.tileID);const oe={bucket:f,layout:T,paint:S,posMatrix:L,textLabelPlaneMatrix:J,labelToScreenMatrix:ne,clippingData:ie,scale:I,textPixelRatio:z,holdingForFade:c.holdingForFade(),collisionBoxArray:A,partiallyEvaluatedTextSize:s.bj(f.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:s.bj(f.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(f.sourceID),latestFeatureIndex:c.latestFeatureIndex};if(d)for(const de of f.sortKeyRanges){const{sortKey:ce,symbolInstanceStart:ae,symbolInstanceEnd:ye}=de;t.push({sortKey:ce,symbolInstanceStart:ae,symbolInstanceEnd:ye,parameters:oe})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:f.symbolInstances.length,parameters:oe})}attemptAnchorPlacement(t,r,c,d,f,_,T,S,A,I,z,D,L,F,N,V,U,W){const{textOffset0:Y,textOffset1:$,crossTileID:Q}=D,J=[Y,$],ne=ts(t,c,d,J,f),ie=this.collisionIndex.placeCollisionBox(F,f,r,wo(ne.x,ne.y,_,T,this.transform.angle),z,S,A,I.predicate);if(V){const oe=F.getSymbolInstanceIconSize(W,this.transform.zoom,D.placedIconSymbolIndex);if(0===this.collisionIndex.placeCollisionBox(F,oe,V,wo(ne.x,ne.y,_,T,this.transform.angle),z,S,A,I.predicate).box.length)return}if(ie.box.length>0){let oe;return this.prevPlacement&&this.prevPlacement.variableOffsets[Q]&&this.prevPlacement.placements[Q]&&this.prevPlacement.placements[Q].text&&(oe=this.prevPlacement.variableOffsets[Q].anchor),this.variableOffsets[Q]={textOffset:J,width:c,height:d,anchor:t,textScale:f,prevAnchor:oe},this.markUsedJustification(F,t,D,N),F.allowVerticalPlacement&&(this.markUsedOrientation(F,N,D),this.placedOrientations[Q]=N),{shift:ne,placedGlyphBoxes:ie}}}placeLayerBucketPart(t,r,c,d){const{bucket:f,layout:_,paint:T,posMatrix:S,textLabelPlaneMatrix:A,labelToScreenMatrix:I,clippingData:z,textPixelRatio:D,holdingForFade:L,collisionBoxArray:F,partiallyEvaluatedTextSize:N,partiallyEvaluatedIconSize:V,collisionGroup:U,latestFeatureIndex:W}=t.parameters,Y=_.get("text-optional"),$=_.get("icon-optional"),Q=_.get("text-allow-overlap"),J=_.get("icon-allow-overlap"),ne="map"===_.get("text-rotation-alignment"),ie="map"===_.get("text-pitch-alignment"),oe=_.get("symbol-z-elevate"),de=T.get("symbol-z-offset"),ce="sea"===T.get("symbol-elevation-reference");this.transform.setProjection(f.projection);let ae=Q&&(J||!f.hasIconData()||$),ye=J&&(Q||!f.hasTextData()||Y);const Ie=!de.isConstant();!f.collisionArrays&&F&&f.deserializeCollisionBoxes(F),c&&d&&f.updateCollisionDebugBuffers(this.transform.zoom,F);const ke=(Ae,Ne,xe)=>{const{crossTileID:Re,numVerticalGlyphVertices:ze}=Ae;let Ue=null;if(z&&z.dynamicFilterNeedsFeature||Ie){const Ot=this.retainedQueryData[f.bucketInstanceId];Ue=W.loadFeature({featureIndex:Ae.featureIndex,bucketIndex:Ot.bucketIndex,sourceLayerIndex:Ot.sourceLayerIndex,layoutVertexArrayOffset:0})}if(z&&!(0,z.dynamicFilter)({zoom:this.transform.zoom,pitch:this.transform.pitch},Ue,this.retainedQueryData[f.bucketInstanceId].tileID.canonical,new s.P(Ae.tileAnchorX,Ae.tileAnchorY),this.transform.calculateDistanceTileData(z.unwrappedTileID)))return this.placements[Re]=new on(!1,!1,!1,!0),void r.add(Re);const Ge=de.evaluate(Ue,{});if(r.has(Re))return;if(L)return void(this.placements[Re]=new on(!1,!1,!1));let Le=!1,Be=!1,ht=!0,Ze=!1,et=!1,_t=null,ot={box:null,offscreen:null,occluded:null},pt={box:null,offscreen:null,occluded:null},Ft=null,Lt=null,di=null,yi=0,Si=0,Hr=0;xe.textFeatureIndex?yi=xe.textFeatureIndex:Ae.useRuntimeCollisionCircles&&(yi=Ae.featureIndex),xe.verticalTextFeatureIndex&&(Si=xe.verticalTextFeatureIndex);const qi=Ot=>{Ot.tileID=this.retainedQueryData[f.bucketInstanceId].tileID;const ii=this.transform.elevation;Ot.elevation=ce?Ge:Ge+(ii?ii.getAtTileOffset(Ot.tileID,Ot.tileAnchorX,Ot.tileAnchorY):0),Ot.elevation+=Ae.zOffset},$t=xe.textBox;if($t){qi($t);const Ot=ci=>{let Ni=s.bk.horizontal;if(f.allowVerticalPlacement&&!ci&&this.prevPlacement){const Zi=this.prevPlacement.placedOrientations[Re];Zi&&(this.placedOrientations[Re]=Zi,Ni=Zi,this.markUsedOrientation(f,Ni,Ae))}return Ni},ii=(ci,Ni)=>{if(f.allowVerticalPlacement&&ze>0&&xe.verticalTextBox){for(const Zi of f.writingModes)if(Zi===s.bk.vertical?(ot=Ni(),pt=ot):ot=ci(),ot&&ot.box&&ot.box.length)break}else ot=ci()};if(_.get("text-variable-anchor")){let ci=_.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[Re]){const Kt=this.prevPlacement.variableOffsets[Re];ci.indexOf(Kt.anchor)>0&&(ci=ci.filter(Ji=>Ji!==Kt.anchor),ci.unshift(Kt.anchor))}const Ni=(Kt,Ji,rr)=>{const Qi=f.getSymbolInstanceTextSize(N,Ae,this.transform.zoom,Ne),bi=(Kt.x2-Kt.x1)*Qi+2*Kt.padding,Tr=(Kt.y2-Kt.y1)*Qi+2*Kt.padding,Mr=Ae.hasIconTextFit&&!J?Ji:null;Mr&&qi(Mr);let Wr={box:[],offscreen:!1,occluded:!1};const Ur=Q?2*ci.length:ci.length;for(let Dr=0;Dr=ci.length,Ae,Ne,f,rr,Mr,N,V);if(Xr&&(Wr=Xr.placedGlyphBoxes,Wr&&Wr.box&&Wr.box.length)){Le=!0,_t=Xr.shift;break}}return Wr};ii(()=>Ni($t,xe.iconBox,s.bk.horizontal),()=>{const Kt=xe.verticalTextBox;return Kt&&qi(Kt),f.allowVerticalPlacement&&!(ot&&ot.box&&ot.box.length)&&ze>0&&Kt?Ni(Kt,xe.verticalIconBox,s.bk.vertical):{box:null,offscreen:null,occluded:null}}),ot&&(Le=ot.box,ht=ot.offscreen,Ze=ot.occluded);const Zi=Ot(!(!ot||!ot.box));if(!Le&&this.prevPlacement){const Kt=this.prevPlacement.variableOffsets[Re];Kt&&(this.variableOffsets[Re]=Kt,this.markUsedJustification(f,Kt.anchor,Ae,Zi))}}else{const ci=(Ni,Zi)=>{const Kt=f.getSymbolInstanceTextSize(N,Ae,this.transform.zoom,Ne),Ji=this.collisionIndex.placeCollisionBox(f,Kt,Ni,new s.P(0,0),Q,D,S,U.predicate);return Ji&&Ji.box&&Ji.box.length&&(this.markUsedOrientation(f,Zi,Ae),this.placedOrientations[Re]=Zi),Ji};ii(()=>ci($t,s.bk.horizontal),()=>{const Ni=xe.verticalTextBox;return f.allowVerticalPlacement&&ze>0&&Ni?(qi(Ni),ci(Ni,s.bk.vertical)):{box:null,offscreen:null,occluded:null}}),Ot(!!(ot&&ot.box&&ot.box.length))}}if(Ft=ot,Le=Ft&&Ft.box&&Ft.box.length>0,ht=Ft&&Ft.offscreen,Ze=Ft&&Ft.occluded,Ae.useRuntimeCollisionCircles){const Ot=f.text.placedSymbolArray.get(Ae.centerJustifiedTextSymbolIndex>=0?Ae.centerJustifiedTextSymbolIndex:Ae.verticalPlacedTextSymbolIndex),ii=s.bl(f.textSizeData,N,Ot),ci=_.get("text-padding");Lt=this.collisionIndex.placeCollisionCircles(f,Q,Ot,f.lineVertexArray,f.glyphOffsetArray,ii,S,A,I,c,ie,U.predicate,Ae.collisionCircleDiameter*ii/s.bq,ci,this.retainedQueryData[f.bucketInstanceId].tileID),Le=Q||Lt.circles.length>0&&!Lt.collisionDetected,ht=ht&&Lt.offscreen,Ze=Lt.occluded}if(xe.iconFeatureIndex&&(Hr=xe.iconFeatureIndex),xe.iconBox){const Ot=ii=>{qi(ii);const ci=Ae.hasIconTextFit&&_t?wo(_t.x,_t.y,ne,ie,this.transform.angle):new s.P(0,0),Ni=f.getSymbolInstanceIconSize(V,this.transform.zoom,Ae.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(f,Ni,ii,ci,J,D,S,U.predicate)};pt&&pt.box&&pt.box.length&&xe.verticalIconBox?(di=Ot(xe.verticalIconBox),Be=di.box.length>0):(di=Ot(xe.iconBox),Be=di.box.length>0),ht=ht&&di.offscreen,et=di.occluded}const mi=Y||0===Ae.numHorizontalGlyphVertices&&0===ze,Pi=$||0===Ae.numIconVertices;if(mi||Pi?Pi?mi||(Be=Be&&Le):Le=Be&&Le:Be=Le=Be&&Le,Le&&Ft&&Ft.box&&this.collisionIndex.insertCollisionBox(Ft.box,_.get("text-ignore-placement"),f.bucketInstanceId,pt&&pt.box&&Si?Si:yi,U.ID),Be&&di&&this.collisionIndex.insertCollisionBox(di.box,_.get("icon-ignore-placement"),f.bucketInstanceId,Hr,U.ID),Lt&&(Le&&this.collisionIndex.insertCollisionCircles(Lt.circles,_.get("text-ignore-placement"),f.bucketInstanceId,yi,U.ID),c)){const Ot=f.bucketInstanceId;let ii=this.collisionCircleArrays[Ot];void 0===ii&&(ii=this.collisionCircleArrays[Ot]=new ir);for(let ci=0;ci=0;--Ne){const xe=Ae[Ne];ke(f.symbolInstances.get(xe),xe,f.collisionArrays[xe])}f.hasAnyZOffset&&s.w(`${f.layerIds[0]} layer symbol-z-elevate: symbols are not sorted by elevation if symbol-z-order is evaluated to viewport-y`)}else if(f.hasAnyZOffset){const Ae=f.getSortedIndexesByZOffset();for(let Ne=0;Ne=0&&(t.text.placedSymbolArray.get(f).crossTileID=z>=0&&f!==z?0:A),_>=0&&(t.text.placedSymbolArray.get(_).crossTileID=z>=0&&_!==z?0:A),T>=0&&(t.text.placedSymbolArray.get(T).crossTileID=z>=0&&T!==z?0:A),S>=0&&(t.text.placedSymbolArray.get(S).crossTileID=z>=0&&S!==z?0:A)}markUsedOrientation(t,r,c){const d=r===s.bk.horizontal||r===s.bk.horizontalOnly?r:0,f=r===s.bk.vertical?r:0,{leftJustifiedTextSymbolIndex:_,centerJustifiedTextSymbolIndex:T,rightJustifiedTextSymbolIndex:S,verticalPlacedTextSymbolIndex:A}=c,I=t.text.placedSymbolArray;_>=0&&(I.get(_).placedOrientation=d),T>=0&&(I.get(T).placedOrientation=d),S>=0&&(I.get(S).placedOrientation=d),A>=0&&(I.get(A).placedOrientation=f)}commit(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;const r=this.prevPlacement;let c=!1;this.prevZoomAdjustment=r?r.zoomAdjustment(this.transform.zoom):0;const d=r?r.symbolFadeChange(t):1,f=r?r.opacities:{},_=r?r.variableOffsets:{},T=r?r.placedOrientations:{};for(const S in this.placements){const A=this.placements[S],I=f[S];I?(this.opacities[S]=new br(I,d,A.text,A.icon,null,A.clipped),c=c||A.text!==I.text.placed||A.icon!==I.icon.placed):(this.opacities[S]=new br(null,d,A.text,A.icon,A.skipFade,A.clipped),c=c||A.text||A.icon)}for(const S in f){const A=f[S];if(!this.opacities[S]){const I=new br(A,d,!1,!1);I.isHidden()||(this.opacities[S]=I,c=c||A.text.placed||A.icon.placed)}}for(const S in _)this.variableOffsets[S]||!this.opacities[S]||this.opacities[S].isHidden()||(this.variableOffsets[S]=_[S]);for(const S in T)this.placedOrientations[S]||!this.opacities[S]||this.opacities[S].isHidden()||(this.placedOrientations[S]=T[S]);c?this.lastPlacementChangeTime=t:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=r?r.lastPlacementChangeTime:t)}updateLayerOpacities(t,r,c,d){const f=new Set;for(const _ of r){const T=_.getBucket(t);T&&_.latestFeatureIndex&&t.fqid===T.layerIds[0]&&(this.updateBucketOpacities(T,f,_,_.collisionBoxArray,c,d,_.tileID,t.scope),T.layers[0].layout.get("symbol-z-elevate")&&this.buildingIndex&&(this.buildingIndex.updateZOffset(T,_.tileID),T.updateZOffset()))}}updateBucketOpacities(t,r,c,d,f,_,T,S){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 A=t.layers[0].layout,I=t.layers[0].paint,z=!!t.layers[0].dynamicFilter(),D=new br(null,0,!1,!1,!0),L=A.get("text-allow-overlap"),F=A.get("icon-allow-overlap"),N=A.get("text-variable-anchor"),V="map"===A.get("text-rotation-alignment"),U="map"===A.get("text-pitch-alignment"),W=I.get("symbol-z-offset"),Y="sea"===I.get("symbol-elevation-reference"),$=!W.isConstant(),Q=new br(null,0,L&&(F||!t.hasIconData()||A.get("icon-optional")),F&&(L||!t.hasTextData()||A.get("text-optional")),!0);!t.collisionArrays&&d&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(d);const J=(ie,oe,de)=>{for(let ce=0;ce0||ce>0,Ue=ye>0,Ge=this.placedOrientations[ae],Le=Ge===s.bk.vertical,Be=Ge===s.bk.horizontal||Ge===s.bk.horizontalOnly;!ze&&!Ue||Re.isHidden()||ne++;let ht=!1;if((ze||Ue)&&_)for(const Ze of t.activeReplacements){if(s.br(Ze,f,s.bs.Symbol,S)||Ze.min.x>Ie||Ie>Ze.max.x||Ze.min.y>ke||ke>Ze.max.y)continue;const et=s.bt(Ie,ke,T.canonical,Ze.footprintTileId.canonical);if(ht=s.bu(et,Ze.footprint),ht)break}if(ze){const Ze=ht?rs:is(Re.text);J(t.text,de,Le?rs:Ze),J(t.text,ce,Be?rs:Ze);const et=Re.text.isHidden(),{leftJustifiedTextSymbolIndex:_t,centerJustifiedTextSymbolIndex:ot,rightJustifiedTextSymbolIndex:pt,verticalPlacedTextSymbolIndex:Ft}=oe,Lt=t.text.placedSymbolArray,di=et||Le?1:0;_t>=0&&(Lt.get(_t).hidden=di),ot>=0&&(Lt.get(ot).hidden=di),pt>=0&&(Lt.get(pt).hidden=di),Ft>=0&&(Lt.get(Ft).hidden=et||Be?1:0);const yi=this.variableOffsets[ae];yi&&this.markUsedJustification(t,yi.anchor,oe,Ge);const Si=this.placedOrientations[ae];Si&&(this.markUsedJustification(t,"left",oe,Si),this.markUsedOrientation(t,Si,oe))}if(Ue){const Ze=ht?rs:is(Re.icon),{placedIconSymbolIndex:et,verticalPlacedIconSymbolIndex:_t}=oe,ot=t.icon.placedSymbolArray,pt=Re.icon.isHidden()?1:0;et>=0&&(J(t.icon,ye,Le?rs:Ze),ot.get(et).hidden=pt),_t>=0&&(J(t.icon,oe.numVerticalIconVertices,Be?rs:Ze),ot.get(_t).hidden=pt)}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const Ze=t.collisionArrays[ie];if(Ze){let et=new s.P(0,0),_t=!0;if(Ze.textBox||Ze.verticalTextBox){if(N){const pt=this.variableOffsets[ae];pt?(et=ts(pt.anchor,pt.width,pt.height,pt.textOffset,pt.textScale),V&&et._rotate(U?this.transform.angle:-this.transform.angle)):_t=!1}z&&(_t=!Re.clipped),Ze.textBox&&qa(t.textCollisionBox.collisionVertexArray,Re.text.placed,!_t||Le,Ne,Y,et.x,et.y),Ze.verticalTextBox&&qa(t.textCollisionBox.collisionVertexArray,Re.text.placed,!_t||Be,Ne,Y,et.x,et.y)}const ot=_t&&!(Be||!Ze.verticalIconBox);Ze.iconBox&&qa(t.iconCollisionBox.collisionVertexArray,Re.icon.placed,ot,Ne,Y,oe.hasIconTextFit?et.x:0,oe.hasIconTextFit?et.y:0),Ze.verticalIconBox&&qa(t.iconCollisionBox.collisionVertexArray,Re.icon.placed,!ot,Ne,Y,oe.hasIconTextFit?et.x:0,oe.hasIconTextFit?et.y:0)}}}if(t.fullyClipped=0===ne,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 ie=this.collisionCircleArrays[t.bucketInstanceId];t.placementInvProjMatrix=ie.invProjMatrix,t.placementViewportMatrix=ie.viewportMatrix,t.collisionCircleArray=ie.circles,delete this.collisionCircleArrays[t.bucketInstanceId]}}symbolFadeChange(t){return 0===this.fadeDuration?1:(t-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(t){return Math.max(0,(this.transform.zoom-t)/1.5)}hasTransitions(t){return this.stale||t-this.lastPlacementChangeTimet}setStale(){this.stale=!0}}function qa(l,t,r,c,d,f,_){l.emplaceBack(t?1:0,r?1:0,f||0,_||0,c,d?1:0),l.emplaceBack(t?1:0,r?1:0,f||0,_||0,c,d?1:0),l.emplaceBack(t?1:0,r?1:0,f||0,_||0,c,d?1:0),l.emplaceBack(t?1:0,r?1:0,f||0,_||0,c,d?1:0)}const Dn=Math.pow(2,25),Cd=Math.pow(2,24),Uh=Math.pow(2,17),Cr=Math.pow(2,16),Pd=Math.pow(2,9),Za=Math.pow(2,8),jh=Math.pow(2,1);function is(l){if(0===l.opacity&&!l.placed)return 0;if(1===l.opacity&&l.placed)return 4294967295;const t=l.placed?1:0,r=Math.floor(127*l.opacity);return r*Dn+t*Cd+r*Uh+t*Cr+r*Pd+t*Za+r*jh+t}const rs=0;class zd{constructor(t){this._sortAcrossTiles="viewport-y"!==t.layout.get("symbol-z-order")&&void 0!==t.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs=new Set,this._bucketParts=[]}continuePlacement(t,r,c,d,f){const _=this._bucketParts;for(;this._currentTileIndexT.sortKey-S.sortKey));this._currentPartIndex<_.length;){const T=_[this._currentPartIndex];if(r.placeLayerBucketPart(T,this._seenCrossTileIDs,c,0===T.symbolInstanceStart),this._currentPartIndex++,f())return!0}return!1}}class Qs{constructor(t,r,c,d,f,_,T,S,A){this.placement=new To(t,f,_,T,S,A),this._currentPlacementIndex=r.length-1,this._forceFullPlacement=c,this._showCollisionBoxes=d,this._done=!1}isDone(){return this._done}continuePlacement(t,r,c,d){const f=s.q.now(),_=()=>{const T=s.q.now()-f;return!this._forceFullPlacement&&T>2};for(;this._currentPlacementIndex>=0;){const T=r[t[this._currentPlacementIndex]],S=this.placement.collisionIndex.transform.zoom;if("symbol"===T.type&&(!T.minzoom||T.minzoom<=S)&&(!T.maxzoom||T.maxzoom>S)){const A=T,I=A.layout.get("symbol-z-elevate"),z=void 0!==A.layout.get("symbol-sort-key").constantOr(1),D=A.layout.get("symbol-z-order"),L="viewport-y"===D||"auto"===D&&!("viewport-y"!==D&&z),F=A.layout.get("text-allow-overlap")||A.layout.get("icon-allow-overlap")||A.layout.get("text-ignore-placement")||A.layout.get("icon-ignore-placement"),N=L&&F,V=this._inProgressLayer=this._inProgressLayer||new zd(A),U=s.av(T.source,T.scope);if(V.continuePlacement(I||N?d[U]:c[U],this.placement,this._showCollisionBoxes,T,_))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(t){return this.placement.commit(t),this.placement}}const Mo=512/s.ab/2;class Dd{constructor(t,r,c){this.tileID=t,this.bucketInstanceId=c,this.index=new s.by(r.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const d=t.canonical.x*s.ab,f=t.canonical.y*s.ab;for(let _=0;_t.overscaledZ)for(const T in _){const S=_[T];S.tileID.isChildOf(t)&&S.findMatches(r.symbolInstances,t,d)}else{const T=_[t.scaledTo(Number(f)).key];T&&T.findMatches(r.symbolInstances,t,d)}}for(let f=0;f{r[c]=!0});for(const c in this.layerIndexes)r[c]||delete this.layerIndexes[c]}}class Zt{constructor(t,r,c,d){this.blendFunction=t,this.blendColor=r,this.mask=c,this.blendEquation=d}}Zt.Replace=[1,0,1,0],Zt.disabled=new Zt(Zt.Replace,s.bz.transparent,[!1,!1,!1,!1]),Zt.unblended=new Zt(Zt.Replace,s.bz.transparent,[!0,!0,!0,!0]),Zt.alphaBlended=new Zt([1,771,1,771],s.bz.transparent,[!0,!0,!0,!0]),Zt.alphaBlendedNonPremultiplied=new Zt([770,771,770,771],s.bz.transparent,[!0,!0,!0,!0]),Zt.multiply=new Zt([774,0,774,0],s.bz.transparent,[!0,!0,!0,!0]);class dt{constructor(t,r,c){this.func=t,this.mask=r,this.range=c}}dt.ReadOnly=!1,dt.ReadWrite=!0,dt.disabled=new dt(519,dt.ReadOnly,[0,1]);class Et{constructor(t,r,c,d,f,_){this.test=t,this.ref=r,this.mask=c,this.fail=d,this.depthFail=f,this.pass=_}}Et.disabled=new Et({func:519,mask:0},0,0,7680,7680,7680);class yt{constructor(t,r,c){this.enable=t,this.mode=r,this.frontFace=c}}function lc(l,t){const r=s.bC(l,3);s.a6.mat4.fromQuat(l,t),s.bE(l,3,r)}function Ha(l,t){const r=s.a6.quat.identity([]);return s.a6.quat.rotateZ(r,r,-t),s.a6.quat.rotateX(r,r,-l),r}function cc(l,t){const r=[l[0],l[1],0],c=[t[0],t[1],0];if(s.a6.vec3.length(r)>=1e-15){const _=s.a6.vec3.normalize([],r);s.a6.vec3.scale(c,_,s.a6.vec3.dot(c,_)),t[0]=c[0],t[1]=c[1]}const d=s.a6.vec3.cross([],t,l);if(s.a6.vec3.len(d)<1e-15)return null;const f=Math.atan2(-d[1],d[0]);return Ha(Math.atan2(Math.sqrt(l[0]*l[0]+l[1]*l[1]),-l[2]),f)}yt.disabled=new yt(!1,1029,2305),yt.backCCW=new yt(!0,1029,2305),yt.backCW=new yt(!0,1029,2304),yt.frontCW=new yt(!0,1028,2304),yt.frontCCW=new yt(!0,1028,2305);class Kn{constructor(t,r){this.position=t,this.orientation=r}get position(){return this._position}set position(t){if(t){const r=t instanceof s.a5?t:new s.a5(t[0],t[1],t[2]);this._renderWorldCopies&&(r.x=s.bA(r.x,0,1)),this._position=r}else this._position=null}lookAtPoint(t,r){if(this.orientation=null,!this.position)return;const c=this.position,d=this._elevation?this._elevation.getAtPointOrZero(s.a5.fromLngLat(t)):0,f=s.a5.fromLngLat(t,d),_=[f.x-c.x,f.y-c.y,f.z-c.z];r||(r=[0,0,1]),r[2]=Math.abs(r[2]),this.orientation=cc(_,r)}setPitchBearing(t,r){this.orientation=Ha(s.bB(t),s.bB(-r))}}class So{constructor(t,r){this._transform=s.a6.mat4.identity([]),this.orientation=r,this.position=t}get mercatorPosition(){const t=this.position;return new s.a5(t[0],t[1],t[2])}get position(){const t=s.bC(this._transform,3);return[t[0],t[1],t[2]]}set position(t){var r;t&&s.bE(this._transform,3,[(r=t)[0],r[1],r[2],1])}get orientation(){return this._orientation}set orientation(t){this._orientation=t||s.a6.quat.identity([]),t&&lc(this._transform,this._orientation)}getPitchBearing(){const t=this.forward(),r=this.right();return{bearing:Math.atan2(-r[1],r[0]),pitch:Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2])}}setPitchBearing(t,r){this._orientation=Ha(t,r),lc(this._transform,this._orientation)}forward(){const t=s.bC(this._transform,2);return[-t[0],-t[1],-t[2]]}up(){const t=s.bC(this._transform,1);return[-t[0],-t[1],-t[2]]}right(){const t=s.bC(this._transform,0);return[t[0],t[1],t[2]]}getCameraToWorld(t,r){const c=new Float64Array(16);return s.a6.mat4.invert(c,this.getWorldToCamera(t,r)),c}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(t,r,c){const d=this.position;s.a6.vec3.scale(d,d,-t);const f=new Float64Array(16);return s.a6.mat4.fromScaling(f,[c,c,c]),s.a6.mat4.translate(f,f,d),f[10]*=r,f}getWorldToCamera(t,r){const c=new Float64Array(16),d=new Float64Array(4),f=this.position;return s.a6.quat.conjugate(d,this._orientation),s.a6.vec3.scale(f,f,-t),s.a6.mat4.fromQuat(c,d),s.a6.mat4.translate(c,c,f),c[1]*=-1,c[5]*=-1,c[9]*=-1,c[13]*=-1,c[8]*=r,c[9]*=r,c[10]*=r,c[11]*=r,c}getCameraToClipPerspective(t,r,c,d){const f=new Float64Array(16);return s.a6.mat4.perspective(f,t,r,c,d),f}getCameraToClipOrthographic(t,r,c,d,f,_){const T=new Float64Array(16);return s.a6.mat4.ortho(T,t,r,c,d,f,_),T}getDistanceToElevation(t,r=!1){const c=0===t?0:s.bD(t,r?s.aM(this.position[1]):this.position[1]),d=this.forward();return(c-this.position[2])/d[2]}clone(){return new So([...this.position],[...this.orientation])}}class Wa{constructor(t=0,r=0,c=0,d=0){if(isNaN(t)||t<0||isNaN(r)||r<0||isNaN(c)||c<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=r,this.left=c,this.right=d}interpolate(t,r,c){return null!=r.top&&null!=t.top&&(this.top=s.aa(t.top,r.top,c)),null!=r.bottom&&null!=t.bottom&&(this.bottom=s.aa(t.bottom,r.bottom,c)),null!=r.left&&null!=t.left&&(this.left=s.aa(t.left,r.left,c)),null!=r.right&&null!=t.right&&(this.right=s.aa(t.right,r.right,c)),this}getCenter(t,r){const c=s.ap((this.left+t-this.right)/2,0,t),d=s.ap((this.top+r-this.bottom)/2,0,r);return new s.P(c,d)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new Wa(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const os=(l,t,r)=>(1-r)*l+r*t,ss=l=>l*l*l*l*l;class Xa{constructor(t,r,c,d,f,_,T){this.tileSize=512,this._renderWorldCopies=void 0===f||f,this._minZoom=t||0,this._maxZoom=r||22,this._minPitch=c??0,this._maxPitch=d??60,this.setProjection(_),this.setMaxBounds(T),this.width=0,this.height=0,this._center=new s.bK(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._unmodified=!0,this._edgeInsets=new Wa,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new So,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}clone(){const t=new Xa(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection());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._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}get isOrthographic(){return"globe"!==this.projection.name&&this._orthographicProjectionAtLowPitch&&this.pitch<15}get elevation(){return this._elevation}set elevation(t){this._elevation!==t&&(this._elevation=t,this._updateCameraOnTerrain(),this._calcMatrices())}get depthOcclusionForSymbolsAndCircles(){return"globe"!==this.projection.name&&!this.isOrthographic}updateElevation(t,r=!1){const c=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(null==this._seaLevelZoom||c)&&this._updateCameraOnTerrain(),(t||c)&&this._constrainCamera(r),this._calcMatrices()}getProjection(){return s.ar(this.projection,["name","center","parallels"])}setProjection(t){this.projectionOptions=t||{name:"mercator"};const r=this.projection?this.getProjection():void 0;this.projection=s.bL(this.projectionOptions);const c=this.getProjection(),d=!s.bh(r,c);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=s.bL({name:"mercator"});const r=t!==this.projection.name;return r&&this._calcMatrices(),r}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&&!0===this.projection.supportsWorldCopies}set renderWorldCopies(t){void 0===t?t=!0:null===t&&(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 s.bD(1,this.center.lat)*this.cameraWorldSizeForFog}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new s.P(this.width,this.height)}get bearing(){return s.bA(this.rotation,-180,180)}set bearing(t){this.rotation=t}get rotation(){return-this.angle/Math.PI*180}set rotation(t){const r=-t*Math.PI/180;this.angle!==r&&(this._unmodified=!1,this.angle=r,this._calcMatrices(),this.rotationMatrix=s.a6.mat2.create(),s.a6.mat2.rotate(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(t){const r=s.ap(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==r&&(this._unmodified=!1,this._pitch=r,this._calcMatrices())}get aspect(){return this.width/this.height}get fov(){return this._fov/Math.PI*180}get fovX(){return this._fov}get fovY(){const t=1/Math.tan(.5*this.fovX);return 2*Math.atan(1/this.aspect/t)}set fov(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=s.bB(t),this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(t){this._averageElevation=t,this._calcFogMatrices(),this._distanceTileDataCache={}}get zoom(){return this._zoom}set zoom(t){const r=Math.min(Math.max(t,this.minZoom),this.maxZoom);this._zoom!==r&&(this._unmodified=!1,this._setZoom(r),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,r=this.elevation&&t===Number.NEGATIVE_INFINITY&&this.elevation.visibleDemTiles.length>0&&this.elevation.exaggeration()>0&&this._centerAltitudeValidForExaggeration;if(!this._elevation||t===Number.NEGATIVE_INFINITY&&(!r||!this._centerAltitude))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const c=this._elevation;r||this._centerAltitude&&this._centerAltitudeValidForExaggeration&&c.exaggeration()&&this._centerAltitudeValidForExaggeration!==c.exaggeration()?(this._centerAltitude=this._centerAltitude/this._centerAltitudeValidForExaggeration*c.exaggeration(),this._centerAltitudeValidForExaggeration=c.exaggeration()):(this._centerAltitude=t||0,this._centerAltitudeValidForExaggeration=c.exaggeration()),this._updateSeaLevelZoom()}_updateSeaLevelZoom(){void 0!==this._centerAltitudeValidForExaggeration&&(this._seaLevelZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize))}sampleAverageElevation(){if(!this._elevation)return 0;const t=this._elevation,r=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],c=this.horizonLineFromTop();let d=0,f=0;for(let _=0;_{const N=s.c1(z,I,D,L,F);T.has(N)||(d.push(new s.aA(I,z,D,L,F)),T.add(N))};for(let I=0;I0,W=D.y+10,$=z.wrap-(U?0:1),Q=z.wrap+(V?0:1),J=U?D.x-1:N-1,ne=V?D.x+1:0;if(f)c[0]<0?(S(L,Q,D.z,ne,D.y),c[1]<0&&W&&(S(L,F,D.z,D.x,D.y+1),S(L,Q,D.z,ne,D.y+1)),c[1]>0&&Y&&(S(L,F,D.z,D.x,D.y-1),S(L,Q,D.z,ne,D.y-1))):c[0]>0?(S(L,$,D.z,J,D.y),c[1]<0&&W&&(S(L,F,D.z,D.x,D.y+1),S(L,$,D.z,J,D.y+1)),c[1]>0&&Y&&(S(L,F,D.z,D.x,D.y-1),S(L,$,D.z,J,D.y-1))):c[1]<0&&W?S(L,F,D.z,D.x,D.y+1):Y&&S(L,F,D.z,D.x,D.y-1);else{const ie=z.visibleQuadrants;1&ie&&(S(L,$,D.z,J,D.y),Y&&(S(L,F,D.z,D.x,D.y-1),S(L,$,D.z,J,D.y-1))),2&ie&&(S(L,Q,D.z,ne,D.y),Y&&(S(L,F,D.z,D.x,D.y-1),S(L,Q,D.z,ne,D.y-1))),4&ie&&(S(L,$,D.z,J,D.y),W&&(S(L,F,D.z,D.x,D.y+1),S(L,$,D.z,J,D.y+1))),8&ie&&(S(L,Q,D.z,ne,D.y),W&&(S(L,F,D.z,D.x,D.y+1),S(L,Q,D.z,ne,D.y+1)))}}const A=[];for(const I of d)d.some(z=>I.isChildOf(z))||A.push(I);if(d=A.filter(I=>!t.some(z=>!!(I.overscaledZ{const V=N.canonical.x+.5-D[0],U=N.canonical.y+.5-D[1];return V*V+U*Ut.maxzoom&&(r=t.maxzoom);const T=this.locationCoordinate(this.center),S=this.center.lat,A=1<{const ze=new s.a5(xe.x+25e-6,xe.y,xe.z),Ue=new s.a5(xe.x,xe.y+25e-6,xe.z),Ge=xe.toLngLat(),Le=ze.toLngLat(),Be=Ue.toLngLat(),ht=this.locationCoordinate(Ge),Ze=this.locationCoordinate(Le),et=this.locationCoordinate(Be),_t=Math.hypot(Ze.x-ht.x,Ze.y-ht.y),ot=Math.hypot(et.x-ht.x,et.y-ht.y);return Math.sqrt(_t*ot)*ne/25e-6},oe=xe=>{const Re=Q,ze=J;return{aabb:s.bR(this,A,0,0,0,xe,ze,Re,this.projection),zoom:0,x:0,y:0,minZ:ze,maxZ:Re,wrap:xe,fullyVisible:!1}},de=[];let ce=[];const ae=r,ye=t.reparseOverscaled?c:r,Ie=(V-this._centerAltitude)*N,ke=xe=>{if(!this._elevation||!xe.tileID||!_)return;const Re=this._elevation.getMinMaxForTile(xe.tileID),ze=xe.aabb;Re?(ze.min[2]=Re.min,ze.max[2]=Re.max,ze.center[2]=(ze.min[2]+ze.max[2])/2):(xe.shouldSplit=Ne(xe),xe.shouldSplit||(ze.min[2]=ze.max[2]=ze.center[2]=this._centerAltitude))},Ae=(xe,Re)=>{if(.707*Re{if(xe.zoom<$)return!0;if(xe.zoom===ae)return!1;if(null!=xe.shouldSplit)return xe.shouldSplit;const Re=xe.aabb.distanceX(U),ze=xe.aabb.distanceY(U);let Ue=Ie,Ge=1;if(z){Ue=xe.aabb.distanceZ(U);const ot=Math.pow(2,xe.zoom),pt=s.aM((xe.y+1)/ot),Ft=s.aM(xe.y/ot),Lt=Math.min(Math.max(S,pt),Ft),di=s.c5(Lt)/s.c5(S);if(Ge=Lt===S?1/Math.max(1,this._mercatorScaleRatio-.3):Math.min(1,di/this._mercatorScaleRatio),this.zoom<=s.c2&&xe.zoom===ae-1&&di>=.9)return!0}else if(f&&(Ue=xe.aabb.distanceZ(U)*N),this.projection.isReprojectedInTileSpace&&c<=5){const ot=Math.pow(2,xe.zoom),pt=ie(new s.a5((xe.x+.5)/ot,(xe.y+.5)/ot));Ge=pt>.85?1:pt}if(!_){const ot=Math.sqrt(Re*Re+ze*ze+Ue*Ue);let pt=(1<0;){const xe=de.pop(),Re=xe.x,ze=xe.y;let Ue=xe.fullyVisible;const Ge=()=>"globe"===this.projection.name&&(0===xe.y||xe.y===(1<>1),Ze={aabb:_?xe.aabb.quadrant(Le):s.bR(this,A,xe.zoom+1,Be,ht,xe.wrap,xe.minZ,xe.maxZ,this.projection),zoom:xe.zoom+1,x:Be,y:ht,wrap:xe.wrap,fullyVisible:Ue,tileID:void 0,shouldSplit:void 0,minZ:xe.minZ,maxZ:xe.maxZ};f&&!z&&(Ze.tileID=new s.aA(xe.zoom+1===ae?ye:xe.zoom+1,xe.wrap,xe.zoom+1,Be,ht),ke(Ze)),de.push(Ze)}else{const Le=xe.zoom===ae?ye:xe.zoom;if(t.minzoom&&t.minzoom>Le)continue;let Be=0;if(!Ue){let _t=W?xe.aabb.intersectsPrecise(L):xe.aabb.intersectsPreciseFlat(L);if(0===_t&&Ge()){const ot=new s.bP(xe.zoom,Re,ze);_t=s.bQ(this,A,ot,!0).intersectsPrecise(L)}if(0===_t)continue;if(t.calculateQuadrantVisibility)if(L.containsPoint(xe.aabb.center))Be=15;else for(let ot=0;ot<4;ot++)0!==xe.aabb.quadrant(ot).intersects(L)&&(Be|=1<{const Ue=[0,0,0,1],Ge=[s.ab,s.ab,0,1],Le=this.calculateFogTileMatrix(ze.tileID.toUnwrapped());s.a6.vec4.transformMat4(Ue,Ue,Le),s.a6.vec4.transformMat4(Ge,Ge,Le);const Be=s.a6.vec4.min([],Ue,Ge),ht=s.a6.vec4.max([],Ue,Ge),Ze=s.bS(Be,ht);if(0===Ze)return!0;let et=!1;const _t=this._elevation;if(_t&&Ze>xe&&0!==Re){const ot=this.calculateProjMatrix(ze.tileID.toUnwrapped());let pt;t.isTerrainDEM||(pt=_t.getMinMaxForTile(ze.tileID)),pt||(pt={min:J,max:Q});const Ft=s.c3(this.rotation),Lt=[Ft[0]*s.ab,Ft[1]*s.ab,pt.max];s.a6.vec3.transformMat4(Lt,Lt,ot),et=(1-Lt[1])*this.height*.5xe.distanceSq-Re.distanceSq).map(xe=>xe.tileID)}resize(t,r){this.width=t,this.height=r,this.pixelsToGLUnits=[2/t,-2/r],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(t){return Math.pow(2,t)}scaleZoom(t){return Math.log(t)/Math.LN2}project(t){const r=s.ap(t.lat,-s.bT,s.bT),c=this.projection.project(t.lng,r);return new s.P(c.x*this.worldSize,c.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/s.bD(1,this.center.lat)/this.worldSize}setLocationAtPoint(t,r){let c,d;const f=this.centerPoint;if("globe"===this.projection.name){const T=this.worldSize;c=(r.x-f.x)/T,d=(r.y-f.y)/T}else{const T=this.pointCoordinate(r),S=this.pointCoordinate(f);c=T.x-S.x,d=T.y-S.y}const _=this.locationCoordinate(t);this.setLocation(new s.a5(_.x-c,_.y-d))}setLocation(t){this.center=this.coordinateLocation(t),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(t){return this.projection.locationPoint(this,t)}locationPoint3D(t){return this.projection.locationPoint(this,t,!0)}pointLocation(t){return this.coordinateLocation(this.pointCoordinate(t))}pointLocation3D(t){return this.coordinateLocation(this.pointCoordinate3D(t))}locationCoordinate(t,r){const c=r?s.bD(r,t.lat):void 0,d=this.projection.project(t.lng,t.lat);return new s.a5(d.x,d.y,c)}coordinateLocation(t){return this.projection.unproject(t.x,t.y)}pointRayIntersection(t,r){const c=r??this._centerAltitude,d=[t.x,t.y,0,1],f=[t.x,t.y,1,1];s.a6.vec4.transformMat4(d,d,this.pixelMatrixInverse),s.a6.vec4.transformMat4(f,f,this.pixelMatrixInverse);const _=f[3];s.a6.vec4.scale(d,d,1/d[3]),s.a6.vec4.scale(f,f,1/_);const T=d[2],S=f[2];return{p0:d,p1:f,t:T===S?0:(c-T)/(S-T)}}screenPointToMercatorRay(t){const r=[t.x,t.y,0,1],c=[t.x,t.y,1,1];return s.a6.vec4.transformMat4(r,r,this.pixelMatrixInverse),s.a6.vec4.transformMat4(c,c,this.pixelMatrixInverse),s.a6.vec4.scale(r,r,1/r[3]),s.a6.vec4.scale(c,c,1/c[3]),r[2]=s.bD(r[2],this._center.lat)*this.worldSize,c[2]=s.bD(c[2],this._center.lat)*this.worldSize,s.a6.vec4.scale(r,r,1/this.worldSize),s.a6.vec4.scale(c,c,1/this.worldSize),new s.aj([r[0],r[1],r[2]],s.a6.vec3.normalize([],s.a6.vec3.sub([],c,r)))}rayIntersectionCoordinate(t){const{p0:r,p1:c,t:d}=t,f=s.bD(r[2],this._center.lat),_=s.bD(c[2],this._center.lat);return new s.a5(s.aa(r[0],c[0],d)/this.worldSize,s.aa(r[1],c[1],d)/this.worldSize,s.aa(f,_,d))}pointCoordinate(t,r=this._centerAltitude){return this.projection.pointCoordinate(this,t.x,t.y,r)}pointCoordinate3D(t){if(!this.elevation)return this.pointCoordinate(t);let r=this.projection.pointCoordinate3D(this,t.x,t.y);if(r)return new s.a5(r[0],r[1],r[2]);let c=0,d=this.horizonLineFromTop();if(t.y>d)return this.pointCoordinate(t);const f=.02*d,_=t.clone();for(let T=0;T<10&&d-c>f;T++){_.y=s.aa(c,d,.66);const S=this.projection.pointCoordinate3D(this,_.x,_.y);S?(d=_.y,r=S):c=_.y}return r?new s.a5(r[0],r[1],r[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>=s.bU)return!this.isPointAboveHorizon(t);const r=this.pointCoordinate(t);return r.y>=0&&r.y<=1}_coordinatePoint(t,r){const c=r&&this.elevation?this.elevation.getAtPointOrZero(t,this._centerAltitude):this._centerAltitude,d=[t.x*this.worldSize,t.y*this.worldSize,c+t.toAltitude(),1];return s.a6.vec4.transformMat4(d,d,this.pixelMatrix),d[3]>0?new s.P(d[0]/d[3],d[1]/d[3]):new s.P(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){const{top:t,left:r}=this._edgeInsets,c=this.height-this._edgeInsets.bottom,d=this.width-this._edgeInsets.right,f=this.pointLocation3D(new s.P(r,t)),_=this.pointLocation3D(new s.P(d,t)),T=this.pointLocation3D(new s.P(d,c)),S=this.pointLocation3D(new s.P(r,c));let A=Math.min(f.lng,_.lng,T.lng,S.lng),I=Math.max(f.lng,_.lng,T.lng,S.lng),z=Math.min(f.lat,_.lat,T.lat,S.lat),D=Math.max(f.lat,_.lat,T.lat,S.lat);const L=Math.pow(2,-this.zoom)/16*270,F="globe"===this.projection.name?1:4,N=(V,U,W,Y,$)=>{const Q=(V+W)/2,J=(U+Y)/2,ne=new s.P(Q,J),{lng:ie,lat:oe}=this.pointLocation3D(ne),de=Math.max(0,A-ie,z-oe,ie-I,oe-D);A=Math.min(A,ie),I=Math.max(I,ie),z=Math.min(z,oe),D=Math.max(D,oe),($L)&&(N(V,U,Q,J,$+1),N(Q,J,W,Y,$+1))};if(N(r,t,d,t,1),N(d,t,d,c,1),N(d,c,r,c,1),N(r,c,r,t,1),"globe"===this.projection.name){const[V,U]=s.bV(this);V?(D=90,I=180,A=-180):U&&(z=-90,I=180,A=-180)}return new s.as(new s.bK(A,z),new s.bK(I,D))}_getBoundsRectangular(t,r){const{top:c,left:d}=this._edgeInsets,f=this.height-this._edgeInsets.bottom,_=this.width-this._edgeInsets.right,T=new s.P(d,c),S=new s.P(_,c),A=new s.P(_,f),I=new s.P(d,f);let z=this.pointCoordinate(T,t),D=this.pointCoordinate(S,t);const L=this.pointCoordinate(A,r),F=this.pointCoordinate(I,r),N=(V,U)=>(U.y-V.y)/(U.x-V.x);return z.y>1&&D.y>=0?z=new s.a5((1-F.y)/N(F,z)+F.x,1):z.y<0&&D.y<=1&&(z=new s.a5(-F.y/N(F,z)+F.x,0)),D.y>1&&z.y>=0?D=new s.a5((1-L.y)/N(L,D)+L.x,1):D.y<0&&z.y<=1&&(D=new s.a5(-L.y/N(L,D)+L.x,0)),(new s.as).extend(this.coordinateLocation(z)).extend(this.coordinateLocation(D)).extend(this.coordinateLocation(F)).extend(this.coordinateLocation(L))}_getBoundsRectangularTerrain(){const t=this.elevation;if(!t.visibleDemTiles.length||t.isUsingMockSource())return this._getBoundsRectangular(0,0);const r=t.visibleDemTiles.reduce((c,d)=>{if(d.dem){const f=d.dem.tree;c.min=Math.min(c.min,f.minimums[0]),c.max=Math.max(c.max,f.maximums[0])}return c},{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(r.min*t.exaggeration(),r.max*t.exaggeration())}getBounds(){return"mercator"===this.projection.name||"equirectangular"===this.projection.name?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}horizonLineFromTop(t=!0){const r=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))-this.centerOffset.y,c=this.height/2-r*(1-this._horizonShift);return t?Math.max(0,c):c}getMaxBounds(){return this.maxBounds}setMaxBounds(t){this.maxBounds=t,this.minLat=-s.bT,this.maxLat=s.bT,this.minLng=-180,this.maxLng=180,t&&(this.minLat=t.getSouth(),this.maxLat=t.getNorth(),this.minLng=t.getWest(),this.maxLng=t.getEast(),this.maxLngz&&(T=z-A),z-IL&&(_=L-S),L-D{for(let Ne=0;Ne<16;Ne++)ye[Ne]=os(Ie[Ne],ke[Ne],Ae)})(T,T,S,ss(this.pitch>=15?1:this.pitch/15))}else T=S;const A=s.a6.mat4.mul([],S,_);let I=s.a6.mat4.mul([],T,_);if(this.projection.isReprojectedInTileSpace){const oe=this.locationCoordinate(this.center),de=s.a6.mat4.identity([]);s.a6.mat4.translate(de,de,[oe.x*this.worldSize,oe.y*this.worldSize,0]),s.a6.mat4.multiply(de,de,s.bY(this)),s.a6.mat4.translate(de,de,[-oe.x*this.worldSize,-oe.y*this.worldSize,0]),s.a6.mat4.multiply(I,I,de),s.a6.mat4.multiply(A,A,de),this.inverseAdjustmentMatrix=s.bZ(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];if(this.mercatorMatrix=s.a6.mat4.scale([],I,[this.worldSize,this.worldSize,this.worldSize/f,1]),this.projMatrix=I,this.invProjMatrix=s.a6.mat4.invert(new Float64Array(16),this.projMatrix),r){const oe=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);oe[8]=2*-t.x/this.width,oe[9]=2*t.y/this.height,this.expandedFarZProjMatrix=s.a6.mat4.mul([],oe,_)}else this.expandedFarZProjMatrix=this.projMatrix;const z=s.a6.mat4.invert([],T);this.frustumCorners=s.b_.fromInvProjectionMatrix(z,this.horizonLineFromTop(),this.height),this.cameraFrustum=s.bN.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!r);const D=new Float32Array(16);s.a6.mat4.identity(D),s.a6.mat4.scale(D,D,[1,-1,1]),s.a6.mat4.rotateX(D,D,this._pitch),s.a6.mat4.rotateZ(D,D,this.angle);const L=s.a6.mat4.perspective(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ);this.starsProjMatrix=s.a6.mat4.clone(L);const F=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;L[8]=2*-t.x/this.width,L[9]=2*(t.y+F)/this.height,this.skyboxMatrix=s.a6.mat4.multiply(D,L,D);const N=this.point,V=N.x,U=N.y,W=this.width%2/2,Y=this.height%2/2,$=Math.cos(this.angle),Q=Math.sin(this.angle),J=V-Math.round(V)+$*W+Q*Y,ne=U-Math.round(U)+$*Y+Q*W,ie=new Float64Array(I);if(s.a6.mat4.translate(ie,ie,[J>.5?J-1:J,ne>.5?ne-1:ne,0]),this.alignedProjMatrix=ie,I=s.a6.mat4.create(),s.a6.mat4.scale(I,I,[this.width/2,-this.height/2,1]),s.a6.mat4.translate(I,I,[1,-1,0]),this.labelPlaneMatrix=I,I=s.a6.mat4.create(),s.a6.mat4.scale(I,I,[1,-1,1]),s.a6.mat4.translate(I,I,[-1,-1,0]),s.a6.mat4.scale(I,I,[2/this.width,2/this.height,1]),this.glCoordMatrix=I,this.pixelMatrix=s.a6.mat4.multiply(new Float64Array(16),this.labelPlaneMatrix,A),this._calcFogMatrices(),this._distanceTileDataCache={},I=s.a6.mat4.invert(new Float64Array(16),this.pixelMatrix),!I)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=I,"globe"===this.projection.name||this.mercatorFromTransition){this.globeMatrix=s.b$(this);const oe=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=s.a6.vec3.transformMat4(oe,oe,_),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=I;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const t=this.cameraWorldSizeForFog,r=this.cameraPixelsPerMeter,c=this._camera.position,d=1/this.height/this._pixelsPerMercatorPixel,f=[t,t,r];s.a6.vec3.scale(f,f,d),s.a6.vec3.scale(c,c,-1),s.a6.vec3.multiply(c,c,f);const _=s.a6.mat4.create();s.a6.mat4.translate(_,_,c),s.a6.mat4.scale(_,_,f),this.mercatorFogMatrix=_,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(t,r,d)}_computeCameraPosition(t){const r=(t=t||this.pixelsPerMeter)/this.pixelsPerMeter,c=this._camera.forward(),d=this.point,f=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*r-t/this.worldSize*this._centerAltitude;return[d.x/this.worldSize-c[0]*f,d.y/this.worldSize-c[1]*f,t/this.worldSize*this._centerAltitude-c[2]*f]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(t){const r=this._maxCameraBoundsDistance()*Math.cos(this._pitch),c=this._camera.position[2],d=t[2];let f=1;this.projection.wrap&&(this.center=this.center.wrap()),d>0&&(f=Math.min((r-c)/d,1)),this._camera.position=s.a6.vec3.scaleAndAdd([],this._camera.position,t,f),this._updateStateFromCamera()}_updateStateFromCamera(){const t=this._camera.position,r=this._camera.forward(),{pitch:c,bearing:d}=this._camera.getPitchBearing(),f=s.bD(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,_=this._mercatorZfromZoom(this._maxZoom)*Math.cos(s.bB(this._maxPitch)),T=Math.max((t[2]-f)/Math.cos(c),_),S=this._zoomFromMercatorZ(T);s.a6.vec3.scaleAndAdd(t,t,r,T),this._pitch=s.ap(c,s.bB(this.minPitch),s.bB(this.maxPitch)),this.angle=s.bA(d,-Math.PI,Math.PI),this._setZoom(s.ap(S,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new s.a5(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(null!=this._seaLevelZoom?this._seaLevelZoom:this._zoom,this._maxZoom)+4;return this._mercatorZfromZoom(t)}_zoomFromMercatorZ(t){return this.scaleZoom(this.cameraToCenterDistance/(t*this.tileSize))}zoomFromMercatorZAdjusted(t){let r=0,c=s.bU,d=0,f=1/0;for(;c-r>1e-6&&c>r;){const _=r+.5*(c-r),T=this.tileSize*Math.pow(2,_),S=this.getCameraToCenterDistance(this.projection,_,T),A=this.scaleZoom(S/(t*this.tileSize)),I=Math.abs(_-A);IA||D.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+s.c0(this.fovAboveCenter)>88||this.anyCornerOffEdge(new s.P(0,0),new s.P(this.width,this.height))}zoomDeltaToMovement(t,r){const c=s.a6.vec3.length(s.a6.vec3.sub([],this._camera.position,t)),d=this._zoomFromMercatorZ(c)+r;return c-this._mercatorZfromZoom(d)}getCameraPoint(){if("globe"===this.projection.name){const t=function([r,c,d],f){const _=[r,c,d,1];s.a6.vec4.transformMat4(_,_,f);const T=_[3]=Math.max(_[3],1e-6);return _[0]/=T,_[1]/=T,_[2]/=T,_}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new s.P(t[0],t[1])}{const t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new s.P(0,t))}}getCameraToCenterDistance(t,r=this.zoom,c=this.worldSize){const d=s.bX(t,r,this.width,this.height,1024),f=t.pixelSpaceConversion(this.center.lat,c,d);let _=.5/Math.tan(.5*this._fov)*this.height*f;return this.isOrthographic&&(_=os(1,_,ss(this.pitch>=15?1:this.pitch/15))),_}getWorldToCameraMatrix(){const t=this._camera.getWorldToCamera(this.worldSize,"meters"===this.projection.zAxisUnit?this.pixelsPerMeter:1);return"globe"===this.projection.name&&s.a6.mat4.multiply(t,t,this.globeMatrix),t}getFrustum(t){return s.bN.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,t,"meters"===this.projection.zAxisUnit)}}const Rn=(l,t)=>{if(t>0&&l.terrain&&s.w("Cutoff is currently disabled on terrain"),t<=0||l.terrain)return{shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};const r=l.transform,c=Math.max(Math.abs(r._zoom-(l.minCutoffZoom-1)),1),d=r.isLODDisabled(!1)?s.a7(60,45,r.pitch):s.a7(30,15,r.pitch),f=r._farZ-r._nearZ,_=t*r.height,T=((1-(S=d))*r.cameraToCenterDistance+S*(r._farZ+_))*c;var S;return{shouldRenderCutoff:d<1,uniformValues:{u_cutoff_params:[r._nearZ,r._farZ,(T-r._nearZ)/f,(T-_-r._nearZ)/f]}}},Li={cascadeCount:2,normalOffset:3,shadowMapResolution:2048};class hc{constructor(t,r){this.aabb=t,this.lastCascade=r}}class We{add(t,r){const c=this.receivers[t.key];void 0!==c?(c.aabb.min[0]=Math.min(c.aabb.min[0],r.min[0]),c.aabb.min[1]=Math.min(c.aabb.min[1],r.min[1]),c.aabb.min[2]=Math.min(c.aabb.min[2],r.min[2]),c.aabb.max[0]=Math.max(c.aabb.max[0],r.max[0]),c.aabb.max[1]=Math.max(c.aabb.max[1],r.max[1]),c.aabb.max[2]=Math.max(c.aabb.max[2],r.max[2])):this.receivers[t.key]=new hc(r,null)}clear(){this.receivers={}}get(t){return this.receivers[t.key]}computeRequiredCascades(t,r,c){const d=s.c9.fromPoints(t.points);let f=0;for(const _ in this.receivers){const T=this.receivers[_];if(!T||!d.intersectsAabb(T.aabb))continue;T.aabb.min=d.closestPoint(T.aabb.min),T.aabb.max=d.closestPoint(T.aabb.max);const S=T.aabb.getCorners();for(let A=0;A1||D[1]<-1||D[1]>1){I=!1;break}}if(T.lastCascade=A,f=Math.max(f,A),I)break}}return f+1}}class qh{constructor(t){this.painter=t,this._enabled=!1,this._shadowLayerCount=0,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new We,this._depthMode=new dt(t.context.gl.LEQUAL,dt.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.useNormalOffset=!1,t.tp.registerParameter(this,["Shadows"],"_forceDisable",{label:"forceDisable"},()=>{this.painter.style.map.triggerRepaint()}),t.tp.registerParameter(Li,["Shadows"],"cascadeCount",{min:1,max:2,step:1}),t.tp.registerParameter(Li,["Shadows"],"normalOffset",{min:0,max:10,step:.05}),t.tp.registerParameter(Li,["Shadows"],"shadowMapResolution",{min:32,max:2048,step:32}),t.tp.registerBinding(this,["Shadows"],"_numCascadesToRender",{readonly:!0,label:"numCascadesToRender"})}destroy(){for(const t of this._cascades)t.texture.destroy(),t.framebuffer.destroy();this._cascades=[]}updateShadowParameters(t,r){const c=this.painter;if(this._enabled=!1,this._shadowLayerCount=0,this._receivers.clear(),!r||!r.properties)return;const d=r.properties.get("shadow-intensity");if(!r.shadowsEnabled()||d<=0||(this._shadowLayerCount=c.style.order.reduce((F,N)=>{const V=c.style._mergedLayers[N];return F+(V.hasShadowPass()&&!V.isHidden(t.zoom)?1:0)},0),this._enabled=this._shadowLayerCount>0,!this.enabled))return;const f=c.context,_=Li.shadowMapResolution,T=Li.shadowMapResolution;if(0===this._cascades.length||Li.shadowMapResolution!==this._cascades[0].texture.size[0]){this._cascades=[];for(let F=0;FV.dem).forEach(V=>{const U=V.dem.tree;N[0]=Math.min(N[0],U.minimums[0]),N[1]=Math.max(N[1],U.maximums[0])}),1e4!==N[0]&&(S=(N[1]-N[0])*F.exaggeration())}const A=1.5*t.cameraToCenterDistance,I=3*A,z=new Float64Array(16);for(let F=0;F=0)return{};const f=function(S,A,I){const z=I/(1<0&&(s.a6.vec3.add(f[1],f[1],[d[0]*_,0,0]),s.a6.vec3.add(f[2],f[2],[d[0]*_,0,0])),d[1]<0?(s.a6.vec3.add(f[0],f[0],[0,d[1]*_,0]),s.a6.vec3.add(f[1],f[1],[0,d[1]*_,0])):d[1]>0&&(s.a6.vec3.add(f[2],f[2],[0,d[1]*_,0]),s.a6.vec3.add(f[3],f[3],[0,d[1]*_,0]));const T={};return T.vertices=f,T.planes=[as(f[1],f[0],f[4]),as(f[2],f[1],f[5]),as(f[3],f[2],f[6]),as(f[0],f[3],f[7])],T}addShadowReceiver(t,r,c){this._receivers.add(t,s.c9.fromTileIdAndHeight(t,r,c))}getMaxCascadeForTile(t){const r=this._receivers.get(t);return r&&r.lastCascade?r.lastCascade:0}}function as(l,t,r){const c=s.a6.vec3.sub([],r,t),d=s.a6.vec3.sub([],l,t),f=s.a6.vec3.cross([],c,d),_=s.a6.vec3.length(f);return 0===_?[0,0,1,0]:(s.a6.vec3.scale(f,f,1/_),[f[0],f[1],f[2],-s.a6.vec3.dot(f,t)])}function Ya(l){const t=l.properties.get("direction"),r=s.c7(t.x,t.y,t.z);r[2]=s.ap(r[2],0,75);const c=s.ca([r[0],r[1],r[2]]);return s.a6.vec3.fromValues(c.x,c.y,c.z)}function Ka(l,t,r){const c=t.properties.get("color"),d=t.properties.get("intensity"),f=t.properties.get("direction"),_=[f.x,f.y,f.z],T=r.properties.get("color"),S=r.properties.get("intensity"),A=Math.max(s.a6.vec3.dot([0,0,1],_),0),I=[0,0,0];s.a6.vec3.scale(I,T.toRenderColor(l.getLut(t.scope)).toArray01Linear().slice(0,3),S);const z=[0,0,0];return s.a6.vec3.scale(z,c.toRenderColor(l.getLut(r.scope)).toArray01Linear().slice(0,3),A*d),s.cb([I[0]>0?I[0]/(I[0]+z[0]):0,I[1]>0?I[1]/(I[1]+z[1]):0,I[2]>0?I[2]/(I[2]+z[2]):0])}function Ja(l,t,r,c,d,f){const _=l.zoom,T=l.scale,S=l.worldSize,A=1/S,I=l.aspect,z=Math.sqrt(1+I*I)*Math.tan(.5*l.fovX),D=z*z,L=c-r,F=c+r;let N,V;D>L/F?(N=c,V=c*z):(N=.5*F*(1+D),V=.5*Math.sqrt(L*L+2*(c*c+r*r)*D+F*F*D*D));const U=l.projection.pixelsPerMeter(l.center.lat,S),W=l._camera.getCameraToWorldMercator(),Y=[0,0,-N*A];s.a6.vec3.transformMat4(Y,Y,W);let $=V*A;const Q=l._edgeInsets;if(!(0===Q.left&&0===Q.top&&0===Q.right&&0===Q.bottom||Q.left===Q.right&&Q.top===Q.bottom)){const Ue=l._camera.getWorldToCamera(l.worldSize,"meters"===l.projection.zAxisUnit?U:1),Ge=l._camera.getCameraToClipPerspective(l._fov,l.width/l.height,r,c);Ge[8]=2*-l.centerOffset.x/l.width,Ge[9]=2*l.centerOffset.y/l.height;const Le=new Float64Array(16);s.a6.mat4.mul(Le,Ge,Ue);const Be=new Float64Array(16);s.a6.mat4.invert(Be,Le);const ht=s.bN.fromInvProjectionMatrix(Be,S,_,!0);for(const Ze of ht.points){const et=((J=Ze)[0]/=T,J[1]/=T,J[2]=s.bD(J[2],l._center.lat),J);$=Math.max($,s.a6.vec3.len(s.a6.vec3.subtract([],Y,et)))}}var J;$*=d/(d-1);const ne=Math.acos(t[2]),ie=Math.atan2(-t[0],-t[1]),oe=new So;oe.position=Y,oe.setPitchBearing(ne,ie);const de=oe.getWorldToCamera(S,U),ce=$*S,ae=Math.min(l._mercatorZfromZoom(17)*S*-2,-2*ce),ye=oe.getCameraToClipOrthographic(-ce,ce,-ce,ce,ae,(ce+f*U)/t[2]),Ie=new Float64Array(16);s.a6.mat4.multiply(Ie,ye,de);const ke=s.a6.vec3.fromValues(Math.floor(1e6*Y[0])/1e6*S,Math.floor(1e6*Y[1])/1e6*S,0),Ae=.5*d,Ne=[0,0,0];s.a6.vec3.transformMat4(Ne,ke,Ie),s.a6.vec3.scale(Ne,Ne,Ae);const xe=[Math.floor(Ne[0]),Math.floor(Ne[1]),Math.floor(Ne[2])],Re=[0,0,0];s.a6.vec3.sub(Re,Ne,xe),s.a6.vec3.scale(Re,Re,-1/Ae);const ze=new Float64Array(16);return s.a6.mat4.identity(ze),s.a6.mat4.translate(ze,ze,Re),s.a6.mat4.multiply(Ie,ze,Ie),[Ie,ce]}class Ln extends s.E{constructor(t){super(),this.requestManager=t,this.models={"":{}},this.numModelsLoading={}}loadModel(t,r){return s.aG(this.requestManager.transformRequest(r,s.R.Model).url).then(c=>{if(!c)return;const d=s.aH(c),f=new s.aI(t,void 0,void 0,d);return f.computeBoundsAndApplyParent(),f}).catch(c=>{if(c&&404===c.status)return null;this.fire(new s.t(new Error(`Could not load model ${t} from ${r}: ${c.message}`)))})}load(t,r){this.models[r]||(this.models[r]={});const c=Object.keys(t);this.numModelsLoading[r]=(this.numModelsLoading[r]||0)+c.length;const d=[];for(const f of c)d.push(this.loadModel(f,t[f]));Promise.allSettled(d).then(f=>{for(let _=0;_{this.fire(new s.t(new Error(`Could not load models: ${f.message}`)))})}isLoaded(){for(const t in this.numModelsLoading)if(this.numModelsLoading[t]>0)return!1;return!0}hasModel(t,r){return!!this.getModel(t,r)}getModel(t,r){return this.models[r]||(this.models[r]={}),this.models[r][t]?this.models[r][t].model:void 0}addModel(t,r,c){this.models[c]||(this.models[c]={}),this.hasModel(t,c)&&this.models[c][t].numReferences++,this.load({[t]:this.requestManager.normalizeModelURL(r)},c)}addModels(t,r){this.models[r]||(this.models[r]={});const c={};for(const d in t)this.models[r][d]={},c[d]=this.requestManager.normalizeModelURL(t[d]);this.load(c,r)}addModelsFromBucket(t,r){this.models[r]||(this.models[r]={});const c={};for(const d of t)this.hasModel(d,r)?this.models[r][d].numReferences++:c[d]=this.requestManager.normalizeModelURL(d);this.load(c,r)}removeModel(t,r){if(this.models[r]&&this.models[r][t]&&(this.models[r][t].numReferences--,0===this.models[r][t].numReferences)){const c=this.models[r][t].model;delete this.models[r][t],c.destroy()}}listModels(t){return this.models[t]||(this.models[t]={}),Object.keys(this.models[t])}upload(t,r){this.models[r]||(this.models[r]={});for(const c in this.models[r])this.models[r][c].model&&this.models[r][c].model.upload(t.context)}}const uc=new s.a0({data:new s.a1(s._.colorTheme.data)}),Br=(l,t)=>_e(l,t&&t.filter(r=>"source.canvas"!==r.identifier)),Qa=s.ar(ei,["addLayer","removeLayer","setLights","setPaintProperty","setLayoutProperty","setSlot","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection","setCamera","addImport","removeImport","updateImport"]),ls=s.ar(ei,["setCenter","setZoom","setBearing","setPitch"]),Zh={version:8,layers:[],sources:{}},$h={duration:300,delay:0};class Fr extends s.E{constructor(t,r={}){super(),this.map=t,this.scope=r.scope||"",this.globalId=null,this.fragments=[],this.importDepth=r.importDepth||0,this.importsCache=r.importsCache||new Map,this.resolvedImports=r.resolvedImports||new Set,this.transition=s.l({},$h),this._buildingIndex=new ic(this),this.crossTileSymbolIndex=new $a,this._mergedOrder=[],this._drapedFirstOrder=[],this._mergedLayers={},this._mergedSourceCaches={},this._mergedOtherSourceCaches={},this._mergedSymbolSourceCaches={},this._clipLayerPresent=!1,this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this._changes=r.styleChanges||new js,this.dispatcher=r.dispatcher?r.dispatcher:new s.cd(s.ce(),this),r.imageManager?this.imageManager=r.imageManager:(this.imageManager=new mo,this.imageManager.setEventedParent(this)),this.imageManager.createScope(this.scope),this.glyphManager=r.glyphManager?r.glyphManager:new s.cf(t._requestManager,r.localFontFamily?s.cg.all:r.localIdeographFontFamily?s.cg.ideographs:s.cg.none,r.localFontFamily||r.localIdeographFontFamily),r.modelManager?this.modelManager=r.modelManager:(this.modelManager=new Ln(t._requestManager),this.modelManager.setEventedParent(this)),this._layers={},this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this._loaded=!1,this._precompileDone=!1,this._shouldPrecompile=!1,this._availableImages=[],this._order=[],this._markersNeedUpdate=!1,this._styleColorTheme={lut:null,lutLoading:!1,lutLoadingCorrelationID:0,colorTheme:null},this._styleColorThemeForScope={},this.options=r.configOptions?r.configOptions:new Map,this._configDependentLayers=r.configDependentLayers?r.configDependentLayers:new Set,this._config=r.config,this._initialConfig=r.initialConfig,this.dispatcher.broadcast("setReferrer",s.ch());const c=this;this._rtlTextPluginCallback=Fr.registerForPluginStateChange(d=>{c.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:d.pluginStatus,pluginURL:d.pluginURL},(f,_)=>{if(s.ci(f),_&&_.every(T=>T))for(const T in c._sourceCaches){const S=c._sourceCaches[T],A=S.getSource().type;"vector"!==A&&"geojson"!==A||S.reload()}})}),this.on("data",d=>{if("source"!==d.dataType||"metadata"!==d.sourceDataType)return;const f=this.getOwnSource(d.sourceId);if(f&&f.vectorLayerIds)for(const _ in this._layers){const T=this._layers[_];T.source===f.id&&this._validateLayer(T)}})}load(t){return t?("string"==typeof t?this.loadURL(t):this.loadJSON(t),this):this}_getGlobalId(t){if(!t)return null;if("string"==typeof t){if(s.f(t))return t;const r=s.cj(t);if(!r.startsWith("http"))try{return new URL(r,location.href).toString()}catch{return r}return r}return`json://${s.ck(JSON.stringify(t))}`}_diffStyle(t,r,c){this.globalId=this._getGlobalId(t);const d=(f,_)=>{try{_(null,this.setState(f,c))}catch(T){_(T,!1)}};if("string"==typeof t){const f=this.map._requestManager.normalizeStyleURL(t),_=this.map._requestManager.transformRequest(f,s.R.Style);s.n(_,(T,S)=>{T?this.fire(new s.t(T)):S&&d(S,r)})}else"object"==typeof t&&d(t,r)}loadURL(t,r={}){this.fire(new s.x("dataloading",{dataType:"style"}));const c="boolean"==typeof r.validate?r.validate:!s.f(t);this.globalId=this._getGlobalId(t),t=this.map._requestManager.normalizeStyleURL(t,r.accessToken),this.resolvedImports.add(t);const d=this.importsCache.get(t);if(d)return this._load(d,c);const f=this.map._requestManager.transformRequest(t,s.R.Style);this._request=s.n(f,(_,T)=>{if(this._request=null,_)this.fire(new s.t(_));else if(T)return this.importsCache.set(t,T),this._load(T,c)})}loadJSON(t,r={}){this.fire(new s.x("dataloading",{dataType:"style"})),this.globalId=this._getGlobalId(t),this._request=s.q.frame(()=>{this._request=null,this._load(t,!1!==r.validate)})}loadEmpty(){this.fire(new s.x("dataloading",{dataType:"style"})),this._load(Zh,!1)}_loadImports(t,r,c){if(this.importDepth>=4)return s.w("Style doesn't support nesting deeper than 5"),Promise.resolve();const d=[];for(const f of t){const _=this._createFragmentStyle(f),T=new Promise(I=>{_.once("style.import.load",I),_.once("error",I)}).then(()=>this.mergeAll());if(d.push(T),this.resolvedImports.has(f.url)){_.loadEmpty();continue}const S=f.data||this.importsCache.get(f.url);S?(_.loadJSON(S,{validate:r}),this._isInternalStyle(S)&&(_.globalId=null)):f.url?_.loadURL(f.url,{validate:r}):_.loadEmpty();const A={style:_,id:f.id,config:f.config};if(c){const I=this.fragments.findIndex(({id:z})=>z===c);this.fragments=this.fragments.slice(0,I).concat(A).concat(this.fragments.slice(I))}else this.fragments.push(A)}return Promise.allSettled(d)}getImportGlobalIds(t=this,r=new Set){for(const c of t.fragments)c.style.globalId&&r.add(c.style.globalId),this.getImportGlobalIds(c.style,r);return[...r.values()]}_createFragmentStyle(t){const r=this.scope?s.av(t.id,this.scope):t.id;let c;const d=this._initialConfig&&this._initialConfig[r];(t.config||d)&&(c=s.l({},t.config,d));const f=new Fr(this.map,{scope:r,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:c,configOptions:this.options,configDependentLayers:this._configDependentLayers});return f.setEventedParent(this.map,{style:f}),f}_reloadImports(){this.mergeAll(),this._updateMapProjection(),this.updateConfigDependencies(),this.map._triggerCameraUpdate(this.camera),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),this._shouldPrecompile=this.map._precompilePrograms&&this.isRootStyle()}_isInternalStyle(t){return this.isRootStyle()&&(t.fragment||!!t.schema&&!1!==t.fragment)}_load(t,r){const c=t.schema;if(this._isInternalStyle(t)){const _=s.l({},Zh,{imports:[{id:"basemap",data:t,url:""}]});return void this._load(_,r)}if(this.updateConfig(this._config,c),r&&Br(this,Lr(t)))return;this._loaded=!0,this.stylesheet=s.cl(t);const d=()=>{for(const A in t.sources)this.addSource(A,t.sources[A],{validate:!1,isInitialLoad:!0});t.sprite?this._loadSprite(t.sprite):(this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0})),this.glyphManager.setURL(t.glyphs,this.scope);const _=rc(this.stylesheet.layers);if(this._order=_.map(A=>A.id),this.stylesheet.light&&s.w("The `light` root property is deprecated, prefer using `lights` with `flat` light type instead."),this.stylesheet.lights)if(1===this.stylesheet.lights.length&&"flat"===this.stylesheet.lights[0].type){const A=this.stylesheet.lights[0];this.light=new ve(A.properties,A.id)}else this.setLights(this.stylesheet.lights);this.light||(this.light=new ve(this.stylesheet.light)),this._layers={},this._serializedLayers={};for(const A of _){const I=s.cq(A,this.scope,this._styleColorTheme.lut,this.options);0!==I.configDependencies.size&&this._configDependentLayers.add(I.fqid),I.setEventedParent(this,{layer:{id:I.id}}),this._layers[I.id]=I,this._serializedLayers[I.id]=I.serialize();const z=this.getOwnLayerSourceCache(I),D=!!this.directionalLight&&this.directionalLight.shadowsEnabled();z&&I.canCastShadows()&&D&&(z.castsShadows=!0)}this.stylesheet.models&&this.modelManager.addModels(this.stylesheet.models,this.scope);const T=this.stylesheet.terrain;T&&(this.checkCanvasFingerprintNoise(),this.disableElevatedTerrain||this.terrainSetForDrapingOnly()||this._createTerrain(T,1)),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this.stylesheet.transition&&this.setTransition(this.stylesheet.transition),this.fire(new s.x("data",{dataType:"style"}));const S=this.isRootStyle();t.imports?this._loadImports(t.imports,r).then(()=>{this._reloadImports(),this.fire(new s.x(S?"style.load":"style.import.load"))}):(this._reloadImports(),this.fire(new s.x(S?"style.load":"style.import.load")))},f=this.stylesheet["color-theme"];if(this._styleColorTheme.colorTheme=f,f){const _=this._evaluateColorThemeData(f);this._loadColorTheme(_).then(()=>{d()}).catch(T=>{s.w(`Couldn't load color theme from the stylesheet: ${T}`),d()})}else this._styleColorTheme.lut=null,d()}isRootStyle(){return 0===this.importDepth}mergeAll(){let t,r,c,d,f,_,T,S;const A={};this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(I=>{if(I.stylesheet){if(null!=I.light&&(t=I.light),I.stylesheet.lights)for(const z of I.stylesheet.lights)"ambient"===z.type&&null!=I.ambientLight&&(r=I.ambientLight),"directional"===z.type&&null!=I.directionalLight&&(c=I.directionalLight);d=this._prioritizeTerrain(d,I.terrain,I.stylesheet.terrain),I.stylesheet.fog&&null!=I.fog&&(f=I.fog),null!=I.stylesheet.camera&&(S=I.stylesheet.camera),null!=I.stylesheet.projection&&(_=I.stylesheet.projection),null!=I.stylesheet.transition&&(T=I.stylesheet.transition),A[I.scope]=I._styleColorTheme}}),this.light=t,this.ambientLight=r,this.directionalLight=c,this.fog=f,this._styleColorThemeForScope=A,null===d?delete this.terrain:this.terrain=d,this.camera=S||{"camera-projection":"perspective"},this.projection=_||{name:"mercator"},this.transition=s.l({},$h,T),this.mergeSources(),this.mergeLayers()}forEachFragmentStyle(t){const r=c=>{for(const d of c.fragments)r(d.style);t(c)};r(this)}_prioritizeTerrain(t,r,c){const d=t&&0===t.drapeRenderMode;return null===c?r&&0===r.drapeRenderMode?r:d?t:null:null!=r&&(!t||d||r&&1===r.drapeRenderMode)?r:t}mergeTerrain(){let t;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(r=>{t=this._prioritizeTerrain(t,r.terrain,r.stylesheet.terrain)}),null===t?delete this.terrain:this.terrain=t}mergeProjection(){let t;this.forEachFragmentStyle(r=>{null!=r.stylesheet.projection&&(t=r.stylesheet.projection)}),this.projection=t||{name:"mercator"}}mergeSources(){const t={},r={},c={};this.forEachFragmentStyle(d=>{for(const f in d._sourceCaches){const _=s.av(f,d.scope);t[_]=d._sourceCaches[f]}for(const f in d._otherSourceCaches){const _=s.av(f,d.scope);r[_]=d._otherSourceCaches[f]}for(const f in d._symbolSourceCaches){const _=s.av(f,d.scope);c[_]=d._symbolSourceCaches[f]}}),this._mergedSourceCaches=t,this._mergedOtherSourceCaches=r,this._mergedSymbolSourceCaches=c}mergeLayers(){const t={},r=[],c={};this._mergedSlots=[],this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle(f=>{for(const _ of f._order){const T=f._layers[_];if("slot"===T.type){const S=s.cm(_);if(t[S])continue;t[S]=[]}T.slot&&t[T.slot]?t[T.slot].push(T):r.push(T)}}),this._mergedOrder=[];const d=(f=[])=>{for(const _ of f)if("slot"===_.type){const T=s.cm(_.id);t[T]&&d(t[T]),this._mergedSlots.push(T)}else{const T=s.av(_.id,_.scope);this._mergedOrder.push(T),c[T]=_,_.is3D()&&(this._has3DLayers=!0),"circle"===_.type&&(this._hasCircleLayers=!0),"symbol"===_.type&&(this._hasSymbolLayers=!0),"clip"===_.type&&(this._clipLayerPresent=!0)}};d(r),this._mergedOrder.sort((f,_)=>{const T=c[f],S=c[_];return T.hasInitialOcclusionOpacityProperties?S.is3D()?1:0:T.is3D()&&S.hasInitialOcclusionOpacityProperties?-1:0}),this._mergedLayers=c,this.updateDrapeFirstLayers(),this._buildingIndex.processLayersChanged()}terrainSetForDrapingOnly(){return!!this.terrain&&0===this.terrain.drapeRenderMode}getCamera(){return this.stylesheet.camera}setCamera(t){return this.stylesheet.camera=s.l({},this.stylesheet.camera,t),this.camera=this.stylesheet.camera,this}_evaluateColorThemeData(t){return t.data?function(r,c,d){const f=s.l({},c);for(const T of Object.keys(s._.colorTheme))void 0===f[T]&&(f[T]=s._.colorTheme[T].default);const _=new s.$(uc,r,new Map(d));return _.setTransitionOrValue(f,d),_.untransitioned().possiblyEvaluate(new s.a3(0))}(this.scope,t,this.options).get("data"):null}_loadColorTheme(t){this._styleColorTheme.lutLoading=!0,this._styleColorTheme.lutLoadingCorrelationID+=1;const r=this._styleColorTheme.lutLoadingCorrelationID;return new Promise((c,d)=>{const f="data:image/png;base64,";if(!t||0===t.length)return this._styleColorTheme.lut=null,this._styleColorTheme.lutLoading=!1,void c();let _=t;_.startsWith(f)||(_=f+_);const T="mapbox-reserved-lut",S=new Image;S.src=_,S.onerror=()=>{this._styleColorTheme.lutLoading=!1,d(new Error("Failed to load image data"))},S.onload=()=>{if(this._styleColorTheme.lutLoadingCorrelationID!==r)return void c();this._styleColorTheme.lutLoading=!1;const{width:A,height:I,data:z}=s.q.getImageData(S);if(I>32)return void d(new Error("The height of the image must be less than or equal to 32 pixels."));if(A!==I*I)return void d(new Error("The width of the image must be equal to the height squared."));this.getImage(T)&&this.removeImage(T),this.addImage(T,{data:new s.r({width:A,height:I},z),pixelRatio:1,sdf:!1,version:0});const D=this.imageManager.getImage(T,this.scope);D?(this._styleColorTheme.lut={image:D.data,data:t},c()):d(new Error("Missing LUT image."))}})}getLut(t){const r=this._styleColorThemeForScope[t];return r?r.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.getTerrain()||this.stylesheet.terrain)&&!this.disableElevatedTerrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null,0))}_updateMapProjection(){this.isRootStyle()&&(this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.projection))}_loadSprite(t){this._spriteRequest=function(r,c,d){let f,_,T;const S=s.q.devicePixelRatio>1?"@2x":"";let A=s.n(c.transformRequest(c.normalizeSpriteURL(r,S,".json"),s.R.SpriteJSON),(D,L)=>{A=null,T||(T=D,f=L,z())}),I=s.o(c.transformRequest(c.normalizeSpriteURL(r,S,".png"),s.R.SpriteImage),(D,L)=>{I=null,T||(T=D,_=L,z())});function z(){if(T)d(T);else if(f&&_){const D=s.q.getImageData(_),L={};for(const F in f){const{width:N,height:V,x:U,y:W,sdf:Y,pixelRatio:$,stretchX:Q,stretchY:J,content:ne}=f[F],ie=new s.r({width:N,height:V});s.r.copy(D,ie,{x:U,y:W},{x:0,y:0},{width:N,height:V},null),L[F]={data:ie,pixelRatio:$,sdf:Y,stretchX:Q,stretchY:J,content:ne}}d(null,L)}}return{cancel(){A&&(A.cancel(),A=null),I&&(I.cancel(),I=null)}}}(t,this.map._requestManager,(r,c)=>{if(this._spriteRequest=null,r)this.fire(new s.t(r));else if(c)for(const d in c)this.imageManager.addImage(d,this.scope,c[d]);this.imageManager.setLoaded(!0,this.scope),this._availableImages=this.imageManager.listImages(this.scope),this.dispatcher.broadcast("setImages",{scope:this.scope,images:this._availableImages}),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new s.x("data",{dataType:"style"}))})}_validateLayer(t){const r=this.getOwnSource(t.source);if(!r)return;const c=t.sourceLayer;c&&("geojson"===r.type||r.vectorLayerIds&&-1===r.vectorLayerIds.indexOf(c))&&this.fire(new s.t(new Error(`Source layer "${c}" does not exist on source "${r.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.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,r)=>{const c=this.fragments[r];return c&&c.style&&(t.data=c.style.serialize()),t})}_serializeSources(){const t={};for(const r in this._sourceCaches){const c=this._sourceCaches[r].getSource();t[c.id]||(t[c.id]=c.serialize())}return t}_serializeLayers(t){const r=[];for(const c of t){const d=this._layers[c];d&&"custom"!==d.type&&r.push(d.serialize())}return r}hasLightTransitions(){return!(!this.light||!this.light.hasTransition())||!(!this.ambientLight||!this.ambientLight.hasTransition())||!(!this.directionalLight||!this.directionalLight.hasTransition())}hasFogTransition(){return!!this.fog&&this.fog.hasTransition()}hasTransitions(){if(this.hasLightTransitions()||this.hasFogTransition())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}get order(){return this.terrain?this._drapedFirstOrder: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 r=this.getOwnLayer(t);if(r)return r;this.fire(new s.t(new Error(`The layer '${t}' does not exist in the map's style.`)))}_checkSource(t){const r=this.getOwnSource(t);if(r)return r;this.fire(new s.t(new Error(`The source '${t}' does not exist in the map's style.`)))}precompilePrograms(t,r){const c=this.map.painter;if(c)for(let d=t.minzoom||0;d<(t.maxzoom||25.5);d++){const f=t.getProgramIds();if(f)for(const _ of f){const T=t.getDefaultProgramParams(_,r.zoom,this._styleColorTheme.lut);T&&(c.style=this,this.fog&&(c._fogVisible=!0,T.overrideFog=!0,c.getOrCreateProgram(_,T)),c._fogVisible=!1,T.overrideFog=!1,c.getOrCreateProgram(_,T),(this.stylesheet.terrain||this.stylesheet.projection&&"globe"===this.stylesheet.projection.name)&&(T.overrideRtt=!0,c.getOrCreateProgram(_,T)))}}}update(t){if(!this._loaded)return;this.ambientLight&&this.ambientLight.recalculate(t),this.directionalLight&&this.directionalLight.recalculate(t);const r=this.calculateLightsBrightness();t.brightness=r||0,r!==this._brightness&&(this._brightness=r,this.dispatcher.broadcast("setBrightness",r));const c=this._changes.isDirty();let d=!1;if(this._changes.isDirty()){const _=this._changes.getLayerUpdatesByScope();for(const T in _){const{updatedIds:S,removedIds:A}=_[T];(S||A)&&(this._updateWorkerLayers(T,S,A),d=!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._changes.reset()}const f={};for(const _ in this._mergedSourceCaches){const T=this._mergedSourceCaches[_];f[_]=T.used,T.used=!1,T.tileCoverLift=0}for(const _ of this._mergedOrder){const T=this._mergedLayers[_];if(T.recalculate(t,this._availableImages),!T.isHidden(t.zoom)){const S=this.getLayerSourceCache(T);S&&(S.used=!0,S.tileCoverLift=Math.max(S.tileCoverLift,T.tileCoverLift()))}!this._precompileDone&&this._shouldPrecompile&&("requestIdleCallback"in window?requestIdleCallback(()=>{this.precompilePrograms(T,t)}):this.precompilePrograms(T,t))}this._shouldPrecompile&&(this._precompileDone=!0),this.terrain&&d&&this.mergeLayers();for(const _ in f){const T=this._mergedSourceCaches[_];f[_]!==T.used&&T.getSource().fire(new s.x("data",{sourceDataType:"visibility",dataType:"source",sourceId:T.getSource().id}))}this.light&&this.light.recalculate(t),this.terrain&&this.terrain.recalculate(t),this.fog&&this.fog.recalculate(t),this.z=t.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),c&&this.fire(new s.x("data",{dataType:"style"}))}_updateTilesForChangedImages(){const t=this._changes.getUpdatedImages();if(t.length){for(const r in this._sourceCaches)this._sourceCaches[r].reloadTilesForDependencies(["icons","patterns"],t);this._changes.resetUpdatedImages()}}_updateWorkerLayers(t,r,c){const d=this.getFragmentStyle(t);d&&this.dispatcher.broadcast("updateLayers",{layers:r?d._serializeLayers(r):[],scope:t,removedIds:c||[],options:d.options})}setState(t,r){if(this._checkLoaded(),Br(this,Lr(t)))return!1;(t=s.cl(t)).layers=rc(t.layers);const c=function(_,T){if(!_)return[{command:ei.setStyle,args:[T]}];let S=[];try{if(!s.bh(_.version,T.version))return[{command:ei.setStyle,args:[T]}];if(s.bh(_.center,T.center)||S.push({command:ei.setCenter,args:[T.center]}),s.bh(_.zoom,T.zoom)||S.push({command:ei.setZoom,args:[T.zoom]}),s.bh(_.bearing,T.bearing)||S.push({command:ei.setBearing,args:[T.bearing]}),s.bh(_.pitch,T.pitch)||S.push({command:ei.setPitch,args:[T.pitch]}),s.bh(_.sprite,T.sprite)||S.push({command:ei.setSprite,args:[T.sprite]}),s.bh(_.glyphs,T.glyphs)||S.push({command:ei.setGlyphs,args:[T.glyphs]}),s.bh(_.imports,T.imports)||function(L=[],F=[],N){F=F||[];const V=(L=L||[]).map(bo),U=F.map(bo),W=L.reduce(Yo,{}),Y=F.reduce(Yo,{}),$=V.slice();let Q,J,ne,ie;for(Q=0,J=0;Q{L.source&&A[L.source]?S.push({command:ei.removeLayer,args:[L.id]}):z.push(L)});let D=_.terrain;D&&A[D.source]&&(S.push({command:ei.setTerrain,args:[void 0]}),D=void 0),S=S.concat(I),s.bh(D,T.terrain)||S.push({command:ei.setTerrain,args:[T.terrain]}),function(L,F,N){F=F||[];const V=(L=L||[]).map(bo),U=F.map(bo),W=L.reduce(Yo,{}),Y=F.reduce(Yo,{}),$=V.slice(),Q=Object.create(null);let J,ne,ie,oe,de,ce,ae;for(J=0,ne=0;J!(_.command in ls));if(0===c.length)return!1;const d=c.filter(_=>!(_.command in Qa));if(d.length>0)throw new Error(`Unimplemented: ${d.map(_=>_.command).join(", ")}.`);const f=[];return c.forEach(_=>{f.push(this[_.command].apply(this,_.args))}),r&&Promise.all(f).then(r),this.stylesheet=t,this.mergeAll(),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),!0}addImage(t,r){return this.getImage(t)?this.fire(new s.t(new Error("An image with this name already exists."))):(this.imageManager.addImage(t,this.scope,r),this._afterImageUpdated(t),this)}updateImage(t,r){this.imageManager.updateImage(t,this.scope,r)}getImage(t){return this.imageManager.getImage(t,this.scope)}removeImage(t){return this.getImage(t)?(this.imageManager.removeImage(t,this.scope),this._afterImageUpdated(t),this):this.fire(new s.t(new Error("No image with this name exists.")))}_afterImageUpdated(t){this._availableImages=this.imageManager.listImages(this.scope),this._changes.updateImage(t),this.dispatcher.broadcast("setImages",{scope:this.scope,images:this._availableImages}),this.fire(new s.x("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addModel(t,r,c={}){return this._checkLoaded(),this._validate(le,`models.${t}`,r,null,c)||(this.modelManager.addModel(t,r,this.scope),this._changes.setDirty()),this}hasModel(t){return this.modelManager.hasModel(t,this.scope)}removeModel(t){return this.hasModel(t)?(this.modelManager.removeModel(t,this.scope),this):this.fire(new s.t(new Error("No model with this ID exists.")))}listModels(){return this._checkLoaded(),this.modelManager.listModels(this.scope)}addSource(t,r,c={}){if(this._checkLoaded(),void 0!==this.getOwnSource(t))throw new Error(`There is already a source with ID "${t}".`);if(!r.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(r).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(r.type)>=0&&this._validate(xo,`sources.${t}`,r,null,c))return;this.map&&this.map._collectResourceTiming&&(r.collectResourceTiming=!0);const d=$o(t,r,this.dispatcher,this);d.scope=this.scope,d.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(d.id),source:d.serialize(),sourceId:d.id}));const f=_=>{const T=(_?"symbol:":"other:")+d.id,S=s.av(T,this.scope),A=this._sourceCaches[T]=new Ar(S,d,_);(_?this._symbolSourceCaches:this._otherSourceCaches)[d.id]=A,A.onAdd(this.map)};f(!1),"vector"!==r.type&&"geojson"!==r.type||f(!0),d.onAdd&&d.onAdd(this.map),c.isInitialLoad||(this.mergeSources(),this._changes.setDirty())}removeSource(t){this._checkLoaded();const r=this.getOwnSource(t);if(!r)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 s.t(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 s.t(new Error(`Source "${t}" cannot be removed while terrain is using it.`)));const c=this.getOwnSourceCaches(t);for(const d of c){const f=s.cm(d.id);delete this._sourceCaches[f],this._changes.discardSourceCacheUpdate(d.id),d.fire(new s.x("data",{sourceDataType:"metadata",dataType:"source",sourceId:d.getSource().id})),d.setEventedParent(null),d.clearTiles()}return delete this._otherSourceCaches[t],delete this._symbolSourceCaches[t],this.mergeSources(),r.setEventedParent(null),r.onRemove&&r.onRemove(this.map),this._changes.setDirty(),this}setGeoJSONSourceData(t,r){this._checkLoaded(),this.getOwnSource(t).setData(r),this._changes.setDirty()}getOwnSource(t){const r=this.getOwnSourceCache(t);return r&&r.getSource()}getOwnSources(){const t=[];for(const r in this._otherSourceCaches){const c=this.getOwnSourceCache(r);c&&t.push(c.getSource())}return t}areTilesLoaded(){const t=this._mergedSourceCaches;for(const r in t){const c=t[r]._tiles;for(const d in c){const f=c[d];if("loaded"!==f.state&&"errored"!==f.state)return!1}}return!0}setLights(t){if(this._checkLoaded(),!t)return delete this.ambientLight,void delete this.directionalLight;const r=this._getTransitionParameters();for(const d of t){if(this._validate(qo,"lights",d))return;switch(d.type){case"ambient":if(this.ambientLight){const f=this.ambientLight;f.set(d),f.updateTransitions(r)}else this.ambientLight=new pi(d,Rt||(Rt=new s.a0({color:new s.a1(s._.properties_light_ambient.color),intensity:new s.a1(s._.properties_light_ambient.intensity)})),this.scope,this.options);break;case"directional":if(this.directionalLight){const f=this.directionalLight;f.set(d),f.updateTransitions(r)}else this.directionalLight=new pi(d,ui||(ui=new s.a0({direction:new s.ad(s._.properties_light_directional.direction),color:new s.a1(s._.properties_light_directional.color),intensity:new s.a1(s._.properties_light_directional.intensity),"cast-shadows":new s.a1(s._.properties_light_directional["cast-shadows"]),"shadow-intensity":new s.a1(s._.properties_light_directional["shadow-intensity"])})),this.scope,this.options)}}const c=new s.a3(this.z||0,r);this.ambientLight&&this.ambientLight.recalculate(c),this.directionalLight&&this.directionalLight.recalculate(c),this._brightness=this.calculateLightsBrightness(),this.dispatcher.broadcast("setBrightness",this._brightness)}calculateLightsBrightness(){const t=this.directionalLight,r=this.ambientLight;if(!t||!r)return;const c=z=>.2126*(z[0]<=.03928?z[0]/12.92:Math.pow((z[0]+.055)/1.055,2.4))+.7152*(z[1]<=.03928?z[1]/12.92:Math.pow((z[1]+.055)/1.055,2.4))+.0722*(z[2]<=.03928?z[2]/12.92:Math.pow((z[2]+.055)/1.055,2.4)),d=t.properties.get("color").toRenderColor(null).toArray01(),f=t.properties.get("intensity"),_=t.properties.get("direction"),T=1-s.c7(_.x,_.y,_.z)[2]/90,S=c(d)*f*T,A=r.properties.get("color").toRenderColor(null).toArray01(),I=r.properties.get("intensity");return(S+c(A)*I)/2}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)return this;if(s.cn(t)){const r=s.co(t),c=this.fragments.find(({id:f})=>f===r);if(!c)throw new Error(`Style import not found: ${t}`);const d=s.cm(t);return c.style.getFragmentStyle(d)}{const r=this.fragments.find(({id:c})=>c===t);if(!r)throw new Error(`Style import not found: ${t}`);return r.style}}getConfigProperty(t,r){const c=this.getFragmentStyle(t);if(!c)return null;const d=s.av(r,c.scope),f=c.options.get(d),_=f?f.value||f.default:null;return _?_.serialize():null}setConfigProperty(t,r,c){const d=this.getFragmentStyle(t);if(!d)return;const f=d.stylesheet.schema;if(!f||!f[r])return;const _=s.M(c);if("success"!==_.result)return void Br(this,_.value);const T=_.value.expression,S=s.av(r,d.scope),A=d.options.get(S);if(!A)return;let I;const{minValue:z,maxValue:D,stepValue:L,type:F,values:N}=f[r],V=s.M(f[r].default);"success"===V.result&&(I=V.value.expression),I?(this.options.set(S,{...A,value:T,default:I,minValue:z,maxValue:D,stepValue:L,type:F,values:N}),this.updateConfigDependencies(r)):this.fire(new s.t(new Error(`No schema defined for the config option "${r}" in the "${t}" fragment.`)))}getConfig(t){const r=this.getFragmentStyle(t);if(!r)return null;const c=r.stylesheet.schema;if(!c)return null;const d={};for(const f in c){const _=s.av(f,r.scope),T=r.options.get(_),S=T?T.value||T.default:null;d[f]=S?S.serialize():null}return d}setConfig(t,r){const c=this.getFragmentStyle(t);c&&(c.updateConfig(r,c.stylesheet.schema),this.updateConfigDependencies())}getSchema(t){const r=this.getFragmentStyle(t);return r?r.stylesheet.schema:null}setSchema(t,r){const c=this.getFragmentStyle(t);c&&(c.stylesheet.schema=r,c.updateConfig(c._config,r),this.updateConfigDependencies())}updateConfig(t,r){if(this._config=t,t||r)if(r)for(const c in r){let d,f;const _=s.M(r[c].default);if("success"===_.result&&(d=_.value.expression),t&&void 0!==t[c]){const D=s.M(t[c]);"success"===D.result&&(f=D.value.expression)}const{minValue:T,maxValue:S,stepValue:A,type:I,values:z}=r[c];if(d){const D=s.av(c,this.scope);this.options.set(D,{default:d,value:f,minValue:T,maxValue:S,stepValue:A,type:I,values:z})}else this.fire(new s.t(new Error(`No schema defined for config option "${c}".`)))}else this.fire(new s.t(new Error("Attempting to set config for a style without schema.")))}updateConfigDependencies(t){for(const r of this._configDependentLayers){const c=this.getLayer(r);if(c){if(t&&!c.configDependencies.has(t))continue;c.possiblyEvaluateVisibility(),this._updateLayer(c)}}this.ambientLight&&this.ambientLight.updateConfig(this.options),this.directionalLight&&this.directionalLight.updateConfig(this.options),this.fog&&this.fog.updateConfig(this.options),this.forEachFragmentStyle(r=>{if(r._styleColorTheme.colorTheme){const c=r._evaluateColorThemeData(r._styleColorTheme.colorTheme);(!r._styleColorTheme.lut&&""!==c||r._styleColorTheme.lut&&c!==r._styleColorTheme.lut.data)&&r.setColorTheme(r._styleColorTheme.colorTheme)}}),this._changes.setDirty()}addLayer(t,r,c={}){this._checkLoaded();const d=t.id;if(this._layers[d])return void this.fire(new s.t(new Error(`Layer with id "${d}" already exists on this map`)));let f;if("custom"===t.type){if(Br(this,s.cp(t)))return;f=s.cq(t,this.scope,this._styleColorTheme.lut,this.options)}else{if("object"==typeof t.source&&(this.addSource(d,t.source),t=s.cl(t),t=s.l(t,{source:d})),this._validate(Se,`layers.${d}`,t,{arrayIndex:-1},c))return;f=s.cq(t,this.scope,this._styleColorTheme.lut,this.options),this._validateLayer(f),f.setEventedParent(this,{layer:{id:d}}),this._serializedLayers[f.id]=f.serialize()}0!==f.configDependencies.size&&this._configDependentLayers.add(f.fqid);let _=this._order.length;if(r){const I=this._order.indexOf(r);if(-1===I)return void this.fire(new s.t(new Error(`Layer with id "${r}" does not exist on this map.`)));f.slot===this._layers[r].slot?_=I:s.w(`Layer with id "${r}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(_,0,d),this._layerOrderChanged=!0,this._layers[d]=f;const T=this.getOwnLayerSourceCache(f),S=!!this.directionalLight&&this.directionalLight.shadowsEnabled();T&&f.canCastShadows()&&S&&(T.castsShadows=!0);const A=this._changes.getRemovedLayer(f);if(A&&f.source&&T&&"custom"!==f.type){this._changes.discardLayerRemoval(f);const I=s.av(f.source,f.scope);A.type!==f.type?this._changes.updateSourceCache(I,"clear"):(this._changes.updateSourceCache(I,"reload"),T.pause())}this._updateLayer(f),f.onAdd&&f.onAdd(this.map),f.scope=this.scope,this.mergeLayers()}moveLayer(t,r){this._checkLoaded();const c=this._checkLayer(t);if(!c||t===r)return;const d=this._order.indexOf(t);this._order.splice(d,1);let f=this._order.length;if(r){const _=this._order.indexOf(r);if(-1===_)return void this.fire(new s.t(new Error(`Layer with id "${r}" does not exist on this map.`)));c.slot===this._layers[r].slot?f=_:s.w(`Layer with id "${r}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(f,0,t),this._changes.setDirty(),this._layerOrderChanged=!0,this.mergeLayers()}removeLayer(t){this._checkLoaded();const r=this._checkLayer(t);if(!r)return;r.setEventedParent(null);const c=this._order.indexOf(t);this._order.splice(c,1),delete this._layers[t],delete this._serializedLayers[t],this._changes.setDirty(),this._layerOrderChanged=!0,this._configDependentLayers.delete(r.fqid),this._changes.removeLayer(r);const d=this.getOwnLayerSourceCache(r);if(d&&d.castsShadows){let f=!1;for(const _ in this._layers)if(this._layers[_].source===r.source&&this._layers[_].canCastShadows()){f=!0;break}d.castsShadows=f}r.onRemove&&r.onRemove(this.map),this.mergeLayers()}getOwnLayer(t){return this._layers[t]}hasLayer(t){return t in this._mergedLayers}hasLayerType(t){for(const r in this._layers)if(this._layers[r].type===t)return!0;return!1}setLayerZoomRange(t,r,c){this._checkLoaded();const d=this._checkLayer(t);d&&(d.minzoom===r&&d.maxzoom===c||(null!=r&&(d.minzoom=r),null!=c&&(d.maxzoom=c),this._updateLayer(d)))}getSlots(){return this._checkLoaded(),this._mergedSlots}setSlot(t,r){this._checkLoaded();const c=this._checkLayer(t);c&&c.slot!==r&&(c.slot=r,this._updateLayer(c))}setFilter(t,r,c={}){this._checkLoaded();const d=this._checkLayer(t);if(d&&!s.bh(d.filter,r))return null==r?(d.filter=void 0,void this._updateLayer(d)):void(this._validate(j,`layers.${d.id}.filter`,r,{layerType:d.type},c)||(d.filter=s.cl(r),this._updateLayer(d)))}getFilter(t){const r=this._checkLayer(t);if(r)return s.cl(r.filter)}setLayoutProperty(t,r,c,d={}){this._checkLoaded();const f=this._checkLayer(t);if(f&&!s.bh(f.getLayoutProperty(r),c)){if(null!=c&&(!d||!1!==d.validate)&&Br(f,ee.call(Lr,{key:`layers.${t}.layout.${r}`,layerType:f.type,objectKey:r,value:c,styleSpec:s._,style:{glyphs:!0,sprite:!0}})))return;f.setLayoutProperty(r,c),0!==f.configDependencies.size&&this._configDependentLayers.add(f.fqid),this._updateLayer(f)}}getLayoutProperty(t,r){const c=this._checkLayer(t);if(c)return c.getLayoutProperty(r)}setPaintProperty(t,r,c,d={}){this._checkLoaded();const f=this._checkLayer(t);if(!f||s.bh(f.getPaintProperty(r),c)||null!=c&&(!d||!1!==d.validate)&&Br(f,q.call(Lr,{key:`layers.${t}.paint.${r}`,layerType:f.type,objectKey:r,value:c,styleSpec:s._})))return;const _=f.setPaintProperty(r,c);0!==f.configDependencies.size&&this._configDependentLayers.add(f.fqid),_&&this._updateLayer(f),this._changes.updatePaintProperties(f)}getPaintProperty(t,r){const c=this._checkLayer(t);if(c)return c.getPaintProperty(r)}setFeatureState(t,r){this._checkLoaded();const c=t.source,d=t.sourceLayer,f=this._checkSource(c);if(!f)return;const _=f.type;if("geojson"===_&&d)return void this.fire(new s.t(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===_&&!d)return void this.fire(new s.t(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===t.id&&this.fire(new s.t(new Error("The feature id parameter must be provided.")));const T=this.getOwnSourceCaches(c);for(const S of T)S.setFeatureState(d,t.id,r)}removeFeatureState(t,r){this._checkLoaded();const c=t.source,d=this._checkSource(c);if(!d)return;const f=d.type,_="vector"===f?t.sourceLayer:void 0;if("vector"===f&&!_)return void this.fire(new s.t(new Error("The sourceLayer parameter must be provided for vector source types.")));if(r&&"string"!=typeof t.id&&"number"!=typeof t.id)return void this.fire(new s.t(new Error("A feature id is required to remove its specific state property.")));const T=this.getOwnSourceCaches(c);for(const S of T)S.removeFeatureState(_,t.id,r)}getFeatureState(t){this._checkLoaded();const r=t.source,c=t.sourceLayer,d=this._checkSource(r);if(d){if("vector"!==d.type||c)return void 0===t.id&&this.fire(new s.t(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(r)[0].getFeatureState(c,t.id);this.fire(new s.t(new Error("The sourceLayer parameter must be provided for vector source types.")))}}setTransition(t){return this.stylesheet.transition=s.l({},this.stylesheet.transition,t),this.transition=this.stylesheet.transition,this}getTransition(){return s.l({},this.stylesheet.transition)}serialize(){this._checkLoaded();const t=this.getTerrain(),r=t&&this.terrain&&this.terrain.scope===this.scope?t:this.stylesheet.terrain;return s.cr({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,fragment:this.stylesheet.fragment,imports:this._serializeImports(),schema:this.stylesheet.schema,camera:this.stylesheet.camera,light:this.stylesheet.light,lights:this.stylesheet.lights,terrain:r,fog:this.stylesheet.fog,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)},c=>void 0!==c)}_updateLayer(t){this._changes.updateLayer(t);const r=this.getLayerSourceCache(t),c=s.av(t.source,t.scope),d=this._changes.getUpdatedSourceCaches();t.source&&!d[c]&&r&&"raster"!==r.getSource().type&&(this._changes.updateSourceCache(c,"reload"),r.pause()),t.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(t){const r=T=>this._mergedLayers[T].is3D(),c=this.order,d={},f=[];for(let T=c.length-1;T>=0;T--){const S=c[T];if(r(S)){d[S]=T;for(const A of t){const I=A[S];if(I)for(const z of I)f.push(z)}}}f.sort((T,S)=>S.intersectionZ-T.intersectionZ);const _=[];for(let T=c.length-1;T>=0;T--){const S=c[T];if(r(S))for(let A=f.length-1;A>=0;A--){const I=f[A].feature;if(I.layer&&d[I.layer.id]{const I=this.getLayer(A);return I&&I.is3D()}):this.has3DLayers(),S=Di.createFromScreenPoints(t,c);for(const A in this._mergedSourceCaches){const I=this._mergedSourceCaches[A].getSource();if(!I||I.scope!==r.scope)continue;const z=this._mergedSourceCaches[A].getSource().id;r.layers&&!d[z]||f.push(Ql(this._mergedSourceCaches[A],this._mergedLayers,_,S,r,c,T,!!this.map._showQueryGeometry))}return this.placement&&f.push(function(A,I,z,D,L,F,N){const V={},U=F.queryRenderedSymbols(D),W=[];for(const Y of Object.keys(U).map(Number))W.push(N[Y]);W.sort(Ho);for(const Y of W){const $=Y.featureIndex.lookupSymbolFeatures(U[Y.bucketInstanceId],I,Y.bucketIndex,Y.sourceLayerIndex,L.filter,L.layers,L.availableImages,A);for(const Q in $){const J=V[Q]=V[Q]||[],ne=$[Q];ne.sort((ie,oe)=>{const de=Y.featureSortOrder;if(de){const ce=de.indexOf(ie.featureIndex);return de.indexOf(oe.featureIndex)-ce}return oe.featureIndex-ie.featureIndex});for(const ie of ne)J.push(ie)}}for(const Y in V)V[Y].forEach($=>{const Q=$.feature,J=z(A[Y]);if(!J)return;const ne=J.getFeatureState(Q.layer["source-layer"],Q.id);Q.source=Q.layer.source,Q.layer["source-layer"]&&(Q.sourceLayer=Q.layer["source-layer"]),Q.state=ne});return V}(this._mergedLayers,_,this.getLayerSourceCache.bind(this),S.screenGeometry,r,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(f)}querySourceFeatures(t,r){r&&r.filter&&this._validate(j,"querySourceFeatures.filter",r.filter,null,r);const c=this.getOwnSourceCaches(t);let d=[];for(const f of c)d=d.concat(Xs(f,r));return d}addSourceType(t,r,c){return Fr.getSourceType(t)?c(new Error(`A source type called "${t}" already exists.`)):(Fr.setSourceType(t,r),r.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:t,url:r.workerSourceURL},c):c(null,null))}getFlatLight(){return this.light.getLight()}setFlatLight(t,r,c={}){this._checkLoaded();const d=this.light.getLight();let f=!1;for(const T in t)if(!s.bh(t[T],d[T])){f=!0;break}if(!f)return;const _=this._getTransitionParameters();this.light.setLight(t,r,c),this.light.updateTransitions(_)}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}checkCanvasFingerprintNoise(){void 0===this.disableElevatedTerrain&&(this.disableElevatedTerrain=s.q.hasCanvasFingerprintNoise(),this.disableElevatedTerrain&&s.w("Terrain and hillshade are disabled because of Canvas2D limitations when fingerprinting protection is enabled (e.g. in private browsing mode)."))}setTerrain(t,r=1){if(this._checkLoaded(),!t)return this.terrainSetForDrapingOnly()||(delete this.terrain,this.map.transform.projection.requiresDraping&&this.setTerrainForDraping()),0===r&&delete this.terrain,null===t?this.stylesheet.terrain=null:delete this.stylesheet.terrain,this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);this.checkCanvasFingerprintNoise();let c=t;const d=null==t.source;if(1===r){if(this.disableElevatedTerrain)return;if("object"==typeof c.source){const T="terrain-dem-src";this.addSource(T,c.source),c=s.cl(c),c=s.l(c,{source:T})}const f=s.l({},c),_={};if(this.terrain&&d){f.source=this.terrain.get().source;const T=this.terrain?this.getFragmentStyle(this.terrain.scope):null;T&&(_.style=T.serialize())}if(this._validate(Hs,"terrain",f,_))return}if(!this.terrain||this.terrain.scope!==this.scope&&!d||this.terrain&&r!==this.terrain.drapeRenderMode){if(!c)return;this._createTerrain(c,r),this.fire(new s.x("data",{dataType:"style"}))}else{const f=this.terrain,_=f.get();for(const T of Object.keys(s._.terrain))!c.hasOwnProperty(T)&&s._.terrain[T].default&&(c[T]=s._.terrain[T].default);for(const T in t)if(!s.bh(t[T],_[T])){f.set(t,this.options),this.stylesheet.terrain=t;const S=this._getTransitionParameters({duration:0});f.updateTransitions(S),this.fire(new s.x("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(t){const r=this.fog=new ai(t,this.map.transform,this.scope,this.options);this.stylesheet.fog=r.get();const c=this._getTransitionParameters({duration:0});r.updateTransitions(c)}_updateMarkersOpacity(){0!==this.map._markers.length&&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)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const r=this.fog;if(!s.bh(r.get(),t)){r.set(t,this.options),this.stylesheet.fog=r.get();const c=this._getTransitionParameters({duration:0});r.updateTransitions(c)}}else this._createFog(t);this._markersNeedUpdate=!0}setColorTheme(t){this._checkLoaded();const r=()=>{for(const d in this._layers)this._layers[d].lut=this._styleColorTheme.lut;for(const d in this._sourceCaches)this._sourceCaches[d].clearTiles()};if(this._styleColorTheme.colorTheme=t,!t)return this._styleColorTheme.lut=null,void r();const c=this._evaluateColorThemeData(t);this._loadColorTheme(c).then(()=>{this.fire(new s.x("colorthemeset")),r()}).catch(d=>{s.w(`Couldn't set color theme: ${d}`)})}_getTransitionParameters(t){return{now:s.q.now(),transition:s.l(this.transition,t)}}updateDrapeFirstLayers(){if(!this.terrain)return;const t=[],r=[];for(const c of this._mergedOrder)this.isLayerDraped(this._mergedLayers[c])?t.push(c):r.push(c);this._drapedFirstOrder=[],this._drapedFirstOrder.push(...t),this._drapedFirstOrder.push(...r)}_createTerrain(t,r){const c=this.terrain=new De(t,r,this.scope,this.options);1===r&&(this.stylesheet.terrain=t),this.mergeTerrain(),this.updateDrapeFirstLayers(),this._force3DLayerUpdate();const d=this._getTransitionParameters({duration:0});c.updateTransitions(d)}_force3DLayerUpdate(){for(const t in this._layers){const r=this._layers[t];"fill-extrusion"===r.type&&this._updateLayer(r)}}_forceSymbolLayerUpdate(){for(const t in this._layers){const r=this._layers[t];"symbol"===r.type&&this._updateLayer(r)}}_validate(t,r,c,d,f={}){if(f&&!1===f.validate)return!1;const _=s.l({},this.serialize());return Br(this,t.call(Lr,s.l({key:r,style:_,value:c,styleSpec:s._},d)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),s.cs.off("pluginStateChange",this._rtlTextPluginCallback);for(const t in this._mergedLayers)this._mergedLayers[t].setEventedParent(null);for(const t in this._mergedSourceCaches)this._mergedSourceCaches[t].clearTiles(),this._mergedSourceCaches[t].setEventedParent(null);this.setEventedParent(null),delete this.fog,delete this.terrain,delete this.ambientLight,delete this.directionalLight,this.isRootStyle()&&(this.imageManager.setEventedParent(null),this.modelManager.setEventedParent(null),this.dispatcher.remove())}clearSource(t){const r=this.getSourceCaches(t);for(const c of r)c.clearTiles()}clearSources(){for(const t in this._mergedSourceCaches)this._mergedSourceCaches[t].clearTiles()}reloadSource(t){const r=this.getSourceCaches(t);for(const c of r)c.resume(),c.reload()}reloadSources(){for(const t of this.getSources())t.reload&&t.reload()}updateSources(t){let r;this.directionalLight&&(r=Ya(this.directionalLight));for(const c in this._mergedSourceCaches)this._mergedSourceCaches[c].update(t,void 0,void 0,r)}_generateCollisionBoxes(){for(const t in this._sourceCaches){const r=this._sourceCaches[t];r.resume(),r.reload()}}_updatePlacement(t,r,c,d,f,_,T=!1){let S=!1,A=!1;const I={},z={};for(const D of this._mergedOrder){const L=this._mergedLayers[D];if("symbol"!==L.type)continue;const F=s.av(L.source,L.scope);let N=I[F];if(!N){const U=this.getLayerSourceCache(L);if(!U)continue;const W=U.getRenderableIds(!0).map(Y=>U.getTileByID(Y));z[F]=W.slice(),N=I[F]=W.sort((Y,$)=>$.tileID.overscaledZ-Y.tileID.overscaledZ||(Y.tileID.isLessThan($.tileID)?-1:1))}const V=this.crossTileSymbolIndex.addLayer(L,N,r.center.lng,r.projection);S=S||V}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder),T=T||this._layerOrderChanged||0===d,this._layerOrderChanged&&this.fire(new s.x("neworder")),(T||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(s.q.now(),r.zoom))&&(this.pauseablePlacement=new Qs(r,this._mergedOrder,T,c,d,f,this.placement,this.fog&&r.projection.supportsFog?this.fog.state:null,this._buildingIndex),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._mergedOrder,this._mergedLayers,I,z),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(s.q.now()),A=!0),S&&this.pauseablePlacement.placement.setStale()),A||S){this._buildingIndex.onNewFrame(r.zoom);for(let D=0;Df===t.id))return void this.fire(new s.t(new Error(`Import with id '${t.id}' already exists in the map's style.`)));if(!r)return c.push(t),this._loadImports([t],!0);const d=c.findIndex(({id:f})=>f===r);return-1===d&&this.fire(new s.t(new Error(`Import with id "${r}" does not exist on this map.`))),this.stylesheet.imports=c.slice(0,d).concat(t).concat(c.slice(d)),this._loadImports([t],!0,r)}updateImport(t,r){this._checkLoaded();const c=this.stylesheet.imports||[],d=this.getImportIndex(t);return-1===d?this:"string"==typeof r?(this.setImportUrl(t,r),this):(r.url&&r.url!==c[d].url&&this.setImportUrl(t,r.url),s.bh(r.config,c[d].config)||this.setImportConfig(t,r.config),s.bh(r.data,c[d].data)||this.setImportData(t,r.data),this)}moveImport(t,r){this._checkLoaded();let c=this.stylesheet.imports||[];const d=this.getImportIndex(t);if(-1===d)return this;const f=this.getImportIndex(r);if(-1===f)return this;const _=c[d],T=this.fragments[d];return c=c.filter(({id:S})=>S!==t),this.fragments=this.fragments.filter(({id:S})=>S!==t),this.stylesheet.imports=c.slice(0,f).concat(_).concat(c.slice(f)),this.fragments=this.fragments.slice(0,f).concat(T).concat(this.fragments.slice(f)),this.mergeLayers(),this}setImportUrl(t,r){this._checkLoaded();const c=this.stylesheet.imports||[],d=this.getImportIndex(t);if(-1===d)return this;c[d].url=r;const f=this.fragments[d];return f.style=this._createFragmentStyle(c[d]),f.style.on("style.import.load",()=>this.mergeAll()),f.style.loadURL(r),this}setImportData(t,r){this._checkLoaded();const c=this.getImportIndex(t),d=this.stylesheet.imports||[];return-1===c?this:r?(this.fragments[c].style.setState(r),this._reloadImports(),this):(delete d[c].data,this.setImportUrl(t,d[c].url))}setImportConfig(t,r){this._checkLoaded();const c=this.getImportIndex(t),d=this.stylesheet.imports||[];if(-1===c)return this;r?d[c].config=r:delete d[c].config;const f=this.fragments[c],_=f.style.stylesheet&&f.style.stylesheet.schema;return f.config=r,f.style.updateConfig(r,_),this.updateConfigDependencies(),this}removeImport(t){this._checkLoaded();const r=this.stylesheet.imports||[],c=this.getImportIndex(t);-1!==c&&(r.splice(c,1),this.fragments[c].style._remove(),this.fragments.splice(c,1),this._reloadImports())}getImportIndex(t){const r=(this.stylesheet.imports||[]).findIndex(c=>c.id===t);return-1===r&&this.fire(new s.t(new Error(`Import '${t}' does not exist in the map's style and cannot be updated.`))),r}getLayer(t){return this._mergedLayers[t]}getSources(){const t=[];for(const r in this._mergedOtherSourceCaches){const c=this._mergedOtherSourceCaches[r];c&&t.push(c.getSource())}return t}getSource(t,r){const c=this.getSourceCache(t,r);return c&&c.getSource()}getLayerSource(t){const r=this.getLayerSourceCache(t);return r&&r.getSource()}getSourceCache(t,r){const c=s.av(t,r);return this._mergedOtherSourceCaches[c]}getLayerSourceCache(t){const r=s.av(t.source,t.scope);return"symbol"===t.type?this._mergedSymbolSourceCaches[r]:this._mergedOtherSourceCaches[r]}getSourceCaches(t){if(null==t)return Object.values(this._mergedSourceCaches);const r=[];return this._mergedOtherSourceCaches[t]&&r.push(this._mergedOtherSourceCaches[t]),this._mergedSymbolSourceCaches[t]&&r.push(this._mergedSymbolSourceCaches[t]),r}updateSourceCaches(){const t=this._changes.getUpdatedSourceCaches();for(const r in t){const c=t[r];"reload"===c?this.reloadSource(r):"clear"===c&&this.clearSource(r)}}updateLayers(t){const r=this._changes.getUpdatedPaintProperties();for(const c of r){const d=this.getLayer(c);d&&d.updateTransitions(t)}}getImages(t,r,c){this.imageManager.getImages(r.icons,r.scope,c),this._updateTilesForChangedImages();const d=f=>{f&&f.setDependencies(r.tileID.key,r.type,r.icons)};d(this._otherSourceCaches[r.source]),d(this._symbolSourceCaches[r.source])}getGlyphs(t,r,c){this.glyphManager.getGlyphs(r.stacks,r.scope,c)}getResource(t,r,c){return s.ct(r,c)}getOwnSourceCache(t){return this._otherSourceCaches[t]}getOwnLayerSourceCache(t){return"symbol"===t.type?this._symbolSourceCaches[t.source]:this._otherSourceCaches[t.source]}getOwnSourceCaches(t){const r=[];return this._otherSourceCaches[t]&&r.push(this._otherSourceCaches[t]),this._symbolSourceCaches[t]&&r.push(this._symbolSourceCaches[t]),r}_isSourceCacheLoaded(t){const r=this.getOwnSourceCaches(t);return 0===r.length?(this.fire(new s.t(new Error(`There is no source with ID '${t}'`))),!1):r.every(c=>c.loaded())}has3DLayers(){return this._has3DLayers}hasSymbolLayers(){return this._hasSymbolLayers}hasCircleLayers(){return this._hasCircleLayers}isLayerClipped(t,r){if(!this._clipLayerPresent&&"fill-extrusion"!==t.type)return!1;const c="fill-extrusion"===t.type&&"building"===t.sourceLayer;if(t.is3D()){if(c||r&&"batched-model"===r.type||"model"===t.type)return!0}else if("symbol"===t.type)return!0;return!1}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}destroy(){this._clearWorkerCaches(),this.fragments.forEach(t=>{t.style._remove()}),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}Fr.getSourceType=function(l){return Na[l]},Fr.setSourceType=function(l,t){Na[l]=t},Fr.registerForPluginStateChange=s.cc;var Hh="\n#define EPSILON 0.0000001\n#define PI 3.141592653589793\n#ifdef RENDER_CUTOFF\nfloat 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);}\n#endif",dc="\nout vec4 glFragColor;highp float unpack_depth(highp vec4 rgba_depth)\n{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) {highp float depth=ndc_z*0.5+0.5;const 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;}\n#ifdef INDICATOR_CUTOUT\nuniform vec2 u_indicator_cutout_centers;uniform vec4 u_indicator_cutout_params;\n#endif\nvec4 applyCutout(vec4 color) {\n#ifdef INDICATOR_CUTOUT\nfloat holeMinOpacity=u_indicator_cutout_params.x;float holeRadius=max(u_indicator_cutout_params.y,0.0);float holeAspectRatio=u_indicator_cutout_params.z;float 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);\n#else\nreturn color;\n#endif\n}\n#ifdef DEBUG_WIREFRAME\n#define HANDLE_WIREFRAME_DEBUG \\\nglFragColor=vec4(0.7,0.0,0.0,0.7); \\\ngl_FragDepth=gl_FragCoord.z-0.0001;\n#else\n#define HANDLE_WIREFRAME_DEBUG\n#endif\n#ifdef RENDER_CUTOFF\nuniform highp vec4 u_cutoff_params;in float v_cutoff_opacity;\n#endif\nvec4 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 applyLUT(highp sampler3D lut,vec4 col) {vec3 size=vec3(textureSize(lut,0));vec3 uvw=(col.rbg*float(size-1.0)+0.5)/size;return vec4(texture(lut,uvw).rgb,col.a);}vec3 applyLUT(highp sampler3D lut,vec3 col) {return applyLUT(lut,vec4(col,1.0)).rgb;}",pc="\n#define EXTENT 8192.0\n#define RAD_TO_DEG 180.0/PI\n#define DEG_TO_RAD PI/180.0\n#define GLOBE_RADIUS EXTENT/PI/2.0\nfloat 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;}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {\n#ifndef PROJECTED_POS_ON_VIEWPORT\nfloat 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;\n#else\nreturn vec3(0.0);\n#endif\n}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);}\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(\nunpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}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);return (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);}\n#ifdef RENDER_CUTOFF\nuniform vec4 u_cutoff_params;out float v_cutoff_opacity;\n#endif\nconst vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);const float skirtOffset=24575.0;vec3 decomposeToPosAndSkirt(vec2 posWithComposedSkirt)\n{float skirt=float(posWithComposedSkirt.x >=skirtOffset);vec2 pos=posWithComposedSkirt-vec2(skirt*skirtOffset,0.0);return vec3(pos,skirt);}",el="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;}",Wh="\n#define ELEVATION_SCALE 7.0\n#define ELEVATION_OFFSET 450.0\n#ifdef PROJECTION_GLOBE_VIEW\nuniform 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;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix(\nmix(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;}\n#else\nvec3 elevationVector(vec2 pos) { return vec3(0,0,1); }\n#endif\n#ifdef TERRAIN\nuniform 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) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 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;\n#else\nfloat 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);\n#endif\n}float prevElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 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;\n#else\nfloat 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);\n#endif\n}\n#ifdef TERRAIN_VERTEX_MORPHING\nfloat elevation(vec2 apos) {\n#ifdef ZERO_EXAGGERATION\nreturn 0.0;\n#endif\nfloat nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}\n#else\nfloat elevation(vec2 apos) {\n#ifdef ZERO_EXAGGERATION\nreturn 0.0;\n#endif\nreturn currentElevation(apos);}\n#endif\nvec4 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);}\n#else\nfloat elevation(vec2 pos) { return 0.0; }\n#endif\n#ifdef DEPTH_OCCLUSION\nuniform 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;\n#ifdef DEPTH_D24\nfloat 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);}\n#else\nhighp float unpack_depth_rgba(vec4 rgba_depth)\n{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;}\n#endif\nbool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;\n#ifdef DEPTH_D24\nfloat depth=unpack_depth(texture(u_depth,(coord.xy+1.0)*0.5).r);\n#else\nfloat depth=unpack_depth_rgba(texture(u_depth,(coord.xy+1.0)*0.5));\n#endif\nreturn coord.z+u_occlusion_depth_offset > depth;}highp vec4 getCornerDepths(vec2 coord) {highp vec3 df=vec3(u_occluder_half_size*u_depth_size_inv,0.0);highp vec2 uv=0.5*coord.xy+0.5;\n#ifdef DEPTH_D24\nhighp vec4 depth=vec4(\ntexture(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\n);depth=unpack_depth4(depth);\n#else\nhighp vec4 depth=vec4(\nunpack_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))\n);\n#endif\nreturn depth;}highp float occlusionFadeMultiSample(vec4 frag) {highp vec3 coord=frag.xyz/frag.w;highp vec2 uv=0.5*coord.xy+0.5;int 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) {\n#ifdef DEPTH_D24\nhighp float depth=unpack_depth(texture(u_depth,uv-df+vec2(float(x)*oneStep.x,float(y)*oneStep.y)).r);\n#else\nhighp float depth=unpack_depth_rgba(texture(u_depth,uv-df+vec2(float(x)*oneStep.x,float(y)*oneStep.y)));\n#endif\nres+=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;highp 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));}\n#else\nbool isOccluded(vec4 frag) { return false; }highp float occlusionFade(vec4 frag) { return 1.0; }highp float occlusionFadeMultiSample(vec4 frag) { return 1.0; }\n#endif//DEPTH_OCCLUSION",Xh="#ifdef FOG\nuniform 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);}\n#endif",Yh="highp vec3 hash(highp vec2 p) {highp vec3 p3=fract(p.xyx*vec3(443.8975,397.2973,491.1871));p3+=dot(p3,p3.yxz+19.19);return fract((p3.xxy+p3.yzz)*p3.zyx);}vec3 dither(vec3 color,highp vec2 seed) {vec3 rnd=hash(seed)+hash(seed+0.59374)-0.5;return color+rnd/255.0;}\n#ifdef FOG\nuniform 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;highp vec3 ray_dir=mix(\nmix(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;}vec3 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) {\n#ifdef FOG_DITHERING\nvec2 dither_seed=gl_FragCoord.xy+u_fog_temporal_offset;return dither(color,dither_seed);\n#else\nreturn color;\n#endif\n}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}\n#endif",Kh="#ifdef RASTER_ARRAY\nuniform 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);}vec2 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)\n);}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)\n);}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);}\n#endif",fc="#ifdef RASTER_ARRAY\nuniform 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;}\n#endif\nuniform 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;}",Jh="#ifdef RENDER_SHADOWS\nuniform 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];}\n#endif//RENDER_SHADOWS",ta="#ifdef RENDER_SHADOWS\n#ifdef DEPTH_TEXTURE\nuniform highp sampler2D u_shadowmap_0;uniform highp sampler2D u_shadowmap_1;\n#else\nuniform sampler2D u_shadowmap_0;uniform sampler2D u_shadowmap_1;\n#endif\nuniform 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 float shadow_sample_1(highp vec2 uv,highp float compare) {highp float shadow_depth;\n#ifdef DEPTH_TEXTURE\nshadow_depth=texture(u_shadowmap_1,uv).r;\n#else\nshadow_depth=unpack_depth(texture(u_shadowmap_1,uv))*0.5+0.5;\n#endif\nreturn step(shadow_depth,compare);}highp float shadow_sample_0(highp vec2 uv,highp float compare) {highp float shadow_depth;\n#ifdef DEPTH_TEXTURE\nshadow_depth=texture(u_shadowmap_0,uv).r;\n#else\nshadow_depth=unpack_depth(texture(u_shadowmap_0,uv))*0.5+0.5;\n#endif\nreturn step(shadow_depth,compare);}float shadow_occlusion_1(highp vec4 pos,highp float bias) {highp vec2 uv=pos.xy;return shadow_sample_1(uv,pos.z-bias);}float shadow_occlusion_0(highp vec4 pos,highp float bias) {highp float compare0=pos.z-bias;\n#ifdef NATIVE\nhighp vec2 uv=pos.xy;highp vec4 samples=textureGather(u_shadowmap_0,uv,0);lowp vec4 stepSamples=step(samples,vec4(compare0));\n#else\nhighp vec2 uv00=pos.xy-vec2(0.5*u_shadow_texel_size);highp vec2 uv10=uv00+vec2(u_shadow_texel_size,0.0);highp vec2 uv01=uv00+vec2(0.0,u_shadow_texel_size);highp vec2 uv11=uv01+vec2(u_shadow_texel_size,0.0);lowp vec4 stepSamples=vec4(\nshadow_sample_0(uv01,compare0),shadow_sample_0(uv11,compare0),shadow_sample_0(uv10,compare0),shadow_sample_0(uv00,compare0)\n);\n#endif\nvec2 f=fract(pos.xy*u_shadow_map_resolution-vec2(0.5));lowp vec2 lerpx=mix(stepSamples.wx,stepSamples.zy,f.xx);return mix(lerpx.x,lerpx.y,f.y);}float shadow_occlusion(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,highp float bias) {\n#ifdef SHADOWS_SINGLE_CASCADE\nlight_view_pos0.xyz=light_view_pos0.xyz/light_view_pos0.w*0.5+0.5;return shadow_occlusion_0(light_view_pos0,bias);\n#else\nlight_view_pos0.xyz/=light_view_pos0.w;light_view_pos1.xyz/=light_view_pos1.w;vec4 uv=vec4(light_view_pos0.xy,light_view_pos1.xy);vec4 abs_bounds=abs(uv);if (abs_bounds.x < 1.0 && abs_bounds.y < 1.0) {light_view_pos0.xyz=light_view_pos0.xyz*0.5+0.5;return shadow_occlusion_0(light_view_pos0,bias);}if (abs_bounds.z >=1.0 || abs_bounds.w >=1.0) {return 0.0;}light_view_pos1.xyz=light_view_pos1.xyz*0.5+0.5;float occlusion1=shadow_occlusion_1(light_view_pos1,bias);return mix(occlusion1,0.0,smoothstep(u_fade_range.x,u_fade_range.y,view_depth));\n#endif\n}highp float calculate_shadow_bias(float NDotL) {\n#ifdef NORMAL_OFFSET\nreturn 0.5*u_shadow_bias.x;\n#else\nreturn 0.5*(u_shadow_bias.x+clamp(u_shadow_bias.y*tan(acos(NDotL)),0.0,u_shadow_bias.z));\n#endif\n}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));}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);}\n#endif";const tl=[];Qn(Hh,tl),Qn(pc,tl),Qn(dc,tl);const ia={"_prelude_fog.vertex.glsl":Xh,"_prelude_terrain.vertex.glsl":Wh,"_prelude_shadow.vertex.glsl":Jh,"_prelude_fog.fragment.glsl":Yh,"_prelude_shadow.fragment.glsl":ta,"_prelude_lighting.glsl":"\n#ifdef LIGHTING_3D_MODE\nuniform 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);}\n#endif//LIGHTING_3D_MODE","_prelude_raster_array.glsl":Kh,"_prelude_raster_particle.glsl":fc},cs={};Yt("",Wh),Yt(Yh,Xh),Yt(ta,Jh),Yt(Kh,""),Yt(fc,"");const ra=Yt(dc,pc),il=Hh;var Jn={background:Yt('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec4 u_color;uniform float u_opacity;\n#ifdef LIGHTING_3D_MODE\nin vec4 v_color;\n#endif\nvoid main() {vec4 out_color;\n#ifdef LIGHTING_3D_MODE\nout_color=v_color;\n#else\nout_color=u_color;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_lighting.glsl"\nin vec2 a_pos;uniform mat4 u_matrix;\n#ifdef LIGHTING_3D_MODE\nuniform mediump vec4 u_color;out vec4 v_color;uniform float u_emissive_strength;\n#endif\nvoid main() {gl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef LIGHTING_3D_MODE\nv_color=apply_lighting_with_emission_ground(u_color,u_emissive_strength);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),backgroundPattern:Yt('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform 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);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform 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 vec2 a_pos;out highp vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_pattern_size,u_pattern_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),circle:Yt('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nin vec3 v_data;in float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nuniform float u_emissive_strength;void main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 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 opacity_t=smoothstep((1.0-blur_positive)*antialiased_blur,blur_positive*antialiased_blur,extrude_length-1.0)-smoothstep(0.0,antialiasblur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(\nantialiased_blur,0.0,extrude_length-radius/(radius+stroke_width)\n);vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_apply_premultiplied(out_color,v_fog_pos);\n#endif\nglFragColor=out_color*(v_visibility*opacity_t);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#define NUM_VISIBILITY_RINGS 2\n#define INV_SQRT2 0.70710678\n#define ELEVATION_BIAS 0.0001\n#define NUM_SAMPLES_PER_RING 16\nuniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;in vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in vec3 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;\n#endif\nout vec3 v_data;out float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvec2 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,-1),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1,-1),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1,1),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1,1),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) {\n#if defined(TERRAIN)\nreturn elevation(pos)+ELEVATION_BIAS;\n#else\nreturn 0.0;\n#endif\n}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);\n#ifdef PITCH_WITH_MAP\n#ifdef PROJECTION_GLOBE_VIEW\nreturn u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) );\n#else\nreturn u_matrix*( world_center+vec4(sample_offset,0,0) );\n#endif\n#else\nreturn projected_center+vec4(sample_offset,0,0);\n#endif\n}float get_sample_step() {\n#ifdef PITCH_WITH_MAP\nreturn 2.0*PI/float(NUM_SAMPLES_PER_RING);\n#else\nreturn PI/float(NUM_SAMPLES_PER_RING);\n#endif\n}void main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);vec4 world_center;mat3 surface_vectors;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=a_pos_normal_3/16384.0;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(circle_center)*circle_elevation(circle_center);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*circle_elevation(circle_center);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);\n#else \nsurface_vectors=mat3(1.0);float height=circle_elevation(circle_center);world_center=vec4(circle_center,height,1);\n#endif\nvec4 projected_center=u_matrix*world_center;float view_scale=0.0;\n#ifdef PITCH_WITH_MAP\n#ifdef SCALE_WITH_MAP\nview_scale=1.0;\n#else\nview_scale=projected_center.w/u_camera_to_center_distance;\n#endif\n#else\n#ifdef SCALE_WITH_MAP\nview_scale=u_camera_to_center_distance;\n#else\nview_scale=projected_center.w;\n#endif\n#endif\ngl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0;\n#ifdef TERRAIN\nfloat step=get_sample_step();vec4 occlusion_world_center;vec4 occlusion_projected_center;\n#ifdef PITCH_WITH_MAP\nfloat 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;\n#else\nocclusion_world_center=world_center;occlusion_projected_center=projected_center;\n#endif\nfor(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);\n#else\nvisibility=1.0;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nvisibility=1.0;\n#endif\nv_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);\n#ifdef FOG\nv_fog_pos=fog_position(world_center.xyz);\n#endif\n}'),clippingMask:Yt("void main() {glFragColor=vec4(1.0);}","in vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:Yt('#include "_prelude_fog.fragment.glsl"\nuniform highp float u_intensity;in vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat 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);\n#ifdef FOG\nif (u_is_globe==0) {glFragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;in vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in vec3 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;\n#endif\nout vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 unscaled_extrude=vec2(mod(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(a_pos*0.5);vec3 pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=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=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);\n#else\npos=vec3(tilePos+extrude,elevation(tilePos));\n#endif\ngl_Position=u_matrix*vec4(pos,1);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),heatmapTexture:Yt("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;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(0.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}","in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=a_pos*0.5+0.5;}"),collisionBox:Yt("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"\nin vec3 a_pos;in vec2 a_anchor_pos;in vec2 a_extrude;in vec2 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;out float v_placed;out float v_notUsed;void main() {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(a_anchor_pos));vec4 projectedPoint=u_matrix*vec4(a_pos+elevationVector(a_anchor_pos)*(feature_elevation+terrain_elevation),1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,1.5);gl_Position=projectedPoint;gl_Position.xy+=(a_extrude*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}'),collisionCircle:Yt("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 vec2 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;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(\nmix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));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(\n0.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=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:Yt("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"\nin vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;\n#endif\nout vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {float h=elevation(a_pos);v_uv=a_pos/8192.0;\n#ifdef PROJECTION_GLOBE_VIEW\ngl_Position=u_matrix*vec4(a_pos_3+elevationVector(a_pos)*h,1);\n#else\ngl_Position=u_matrix*vec4(a_pos*u_overlay_scale,h,1);\n#endif\n}'),fill:Yt('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nuniform float u_emissive_strength;void main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nvec4 out_color=color;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nin vec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;\n#endif\nuniform mat4 u_matrix;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp float z_offset\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;\n#endif\nfloat hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillOutline:Yt('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nin highp vec2 v_pos;uniform float u_emissive_strength;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nin vec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;\n#endif\nuniform mat4 u_matrix;uniform vec2 u_world;out highp vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp float z_offset\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;\n#endif\nfloat hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillOutlinePattern:Yt('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_emissive_strength;in highp vec2 v_pos;in highp vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=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);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in vec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;\n#endif\nout highp vec2 v_pos;out highp vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\n#pragma mapbox: initialize highp float z_offset\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;\n#endif\nfloat hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_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,a_pos);v_pos_world=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillPattern:Yt('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;in highp vec2 v_pos;uniform float u_emissive_strength;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=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);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in vec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;\n#endif\nout highp vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\n#pragma mapbox: initialize highp float z_offset\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;\n#endif\nfloat hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_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,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillExtrusion:Yt('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nin vec4 v_color;in vec4 v_flat;\n#ifdef RENDER_SHADOWS\nin highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;\n#endif\nuniform lowp float u_opacity;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;in vec2 v_ao;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nin vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nin highp vec3 v_normal;\n#endif\nuniform vec3 u_flood_light_color;uniform highp float u_vertical_scale;uniform float u_flood_light_intensity;uniform vec3 u_ground_shadow_factor;\n#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)\nin float v_flood_radius;in float v_has_floodlight;\n#endif\nin float v_height;\n#pragma mapbox: define highp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize highp float emissive_strength\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nvec3 normal=normalize(v_normal);\n#endif\nfloat z;vec4 color=v_color;\n#ifdef ZERO_ROOF_RADIUS\nz=float(normal.z > 0.00001);\n#ifdef LIGHTING_3D_MODE\nnormal=mix(normal,vec3(0.0,0.0,1.0),z);\n#else\ncolor=mix(v_color,v_roof_color,z);\n#endif\n#endif\nfloat h=max(0.0,v_height);float ao_shade=1.0;\n#ifdef FAUX_AO\nfloat 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;\n#ifdef ZERO_ROOF_RADIUS\nconcave*=(1.0-z);\n#endif\nfloat 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);\n#ifdef LIGHTING_3D_MODE\n#ifdef FLOOD_LIGHT\ncolor.rgb*=mix(ao_shade,1.0,v_has_floodlight);\n#else\ncolor.rgb*=ao_shade;\n#endif\n#else\ncolor.rgb*=ao_shade;\n#endif\n#endif\n#ifdef LIGHTING_3D_MODE\nfloat flood_radiance=0.0;\n#ifdef FLOOD_LIGHT\nflood_radiance=(1.0-min(h/v_flood_radius,1.0))*u_flood_light_intensity*v_has_floodlight;\n#endif\n#ifdef RENDER_SHADOWS\n#ifdef FLOOD_LIGHT\nfloat 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);\n#else\nfloat shadowed_lighting_factor;\n#ifdef RENDER_CUTOFF\nshadowed_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;}\n#else\nshadowed_lighting_factor=shadowed_light_factor_normal(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);\n#endif\ncolor.rgb=apply_lighting(color.rgb,normal,shadowed_lighting_factor);\n#endif\n#else\ncolor.rgb=apply_lighting(color.rgb,normal);\n#ifdef FLOOD_LIGHT\ncolor.rgb=mix(color.rgb,u_flood_light_color*u_opacity,flood_radiance);\n#endif\n#endif\ncolor.rgb=mix(color.rgb,v_flat.rgb,emissive_strength);color*=u_opacity;\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos,h));\n#endif\n#ifdef INDICATOR_CUTOUT\ncolor=applyCutout(color);\n#endif\nglFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\n#include "_prelude_lighting.glsl"\nuniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_edge_radius;uniform float u_width_scale;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#ifdef RENDER_WALL_MODE\nin vec3 a_join_normal_inside;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in vec3 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;\n#endif\nuniform highp float u_vertical_scale;out vec4 v_color;out vec4 v_flat;\n#ifdef RENDER_SHADOWS\nuniform 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;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nout vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nout highp vec3 v_normal;\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;out vec2 v_ao;\n#endif\n#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)\nout float v_flood_radius;out float v_has_floodlight;\n#endif\nout float v_height;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define highp float flood_light_wall_radius\n#pragma mapbox: define highp float line_width\n#pragma mapbox: define highp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize highp float flood_light_wall_radius\n#pragma mapbox: initialize highp float line_width\n#pragma mapbox: initialize highp float emissive_strength\nbase*=u_vertical_scale;height*=u_vertical_scale;vec4 pos_nx=floor(a_pos_normal_ed*0.5);vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nv_normal=normal;\n#endif\nbase=max(0.0,base);float attr_height=height;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);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\nfloat ele=0.0;float h=0.0;float c_ele=0.0;vec3 pos;\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);pos=vec3(pos_nx.xy,h);\n#else\nh=t > 0.0 ? height : base;pos=vec3(pos_nx.xy,h);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=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);\n#endif\nfloat cutoff=1.0;vec3 scaled_pos=pos;\n#ifdef RENDER_CUTOFF\nvec3 centroid_random=vec3(centroid_pos.xy,centroid_pos.x+centroid_pos.y+1.0);vec3 ground_pos=centroid_pos.x==0.0 ? pos.xyz : (centroid_random/8.0);vec4 ground=u_matrix*vec4(ground_pos.xy,ele,1.0);cutoff=cutoff_opacity(u_cutoff_params,ground.z);if (centroid_pos.y !=0.0 && centroid_pos.x !=0.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);\n#endif\nfloat hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (cutoff==0.0 && centroid_pos.x !=0.0) || (color.a==0.0));\n#ifdef RENDER_WALL_MODE\nvec2 wall_offset=u_width_scale*line_width*(a_join_normal_inside.xy/EXTENT);scaled_pos.xy+=(1.0-a_join_normal_inside.z)*wall_offset*0.5;scaled_pos.xy-=a_join_normal_inside.z*wall_offset*0.5;\n#endif\ngl_Position=mix(u_matrix*vec4(scaled_pos,1),AWAY,hidden);h=h-ele;v_height=h;\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=pos;vec3 shd_pos1=pos;\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(normal);shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_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);\n#endif\nfloat NdotL=0.0;float colorvalue=0.0;\n#ifndef LIGHTING_3D_MODE\ncolorvalue=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*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}\n#endif\n#ifdef FAUX_AO\nfloat 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;\n#ifdef TERRAIN\ntop_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);\n#endif\nv_ao=vec2(mix(concave,-concave,start),y_ground);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\n#ifdef LIGHTING_3D_MODE\n#ifdef FLOOD_LIGHT\nfloat is_wall=1.0-float(t > 0.0 && top_up_ny.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;\n#endif\nv_color=vec4(color.rgb,1.0);v_flat=vec4(linearProduct(color.rgb,vec3(calculate_NdotL(normal))),1.0);\n#else\nv_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;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nfloat 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;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),fillExtrusionDepth:Yt("in highp float v_depth;void main() {\n#ifndef DEPTH_TEXTURE\nglFragColor=pack_depth(v_depth);\n#endif\n}",'#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_edge_radius;uniform float u_width_scale;uniform float u_vertical_scale;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#ifdef RENDER_WALL_MODE\nin vec3 a_join_normal_inside;\n#endif\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp float line_width\n#pragma mapbox: define highp vec4 color\nout highp float v_depth;void main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp float line_width\n#pragma mapbox: initialize highp vec4 color\nbase*=u_vertical_scale;height*=u_vertical_scale;vec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;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);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\nvec3 pos;\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base);pos=vec3(pos_nx.xy,h);\n#else\npos=vec3(pos_nx.xy,t > 0.0 ? height : base);\n#endif\n#ifdef RENDER_WALL_MODE\nvec2 wall_offset=u_width_scale*line_width*(a_join_normal_inside.xy/EXTENT);pos.xy+=(1.0-a_join_normal_inside.z)*wall_offset*0.5;pos.xy-=a_join_normal_inside.z*wall_offset*0.5;\n#endif\nfloat 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);v_depth=gl_Position.z/gl_Position.w;}'),fillExtrusionPattern:Yt('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;in vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nin vec3 v_normal;\n#endif\nin highp vec2 v_pos;in vec4 v_lighting;uniform lowp float u_opacity;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define mediump vec4 pattern\n#pragma mapbox: define highp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize highp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=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);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color,normalize(v_normal))*u_opacity;\n#else\nout_color=out_color*v_lighting;\n#endif\n#ifdef FAUX_AO\nfloat 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;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_lighting.glsl"\nuniform 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;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#ifdef RENDER_WALL_MODE\nin vec3 a_join_normal_inside;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in vec3 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;\n#endif\nout highp vec2 v_pos;out vec4 v_lighting;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;out vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nout vec3 v_normal;\n#endif\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define mediump vec4 pattern\n#pragma mapbox: define highp float pixel_ratio\n#pragma mapbox: define highp float line_width\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize highp float pixel_ratio\n#pragma mapbox: initialize highp float line_width\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec4 pos_nx=floor(a_pos_normal_ed*0.5);mediump vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;mediump vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=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.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\nfloat ele=0.0;float h=z;vec3 p;float c_ele;\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);p=vec3(pos_nx.xy,h);\n#else\np=vec3(pos_nx.xy,z);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=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);\n#endif\n#ifdef RENDER_WALL_MODE\nvec2 wall_offset=u_width_scale*line_width*(a_join_normal_inside.xy/EXTENT);p.xy+=(1.0-a_join_normal_inside.z)*wall_offset*0.5;p.xy-=a_join_normal_inside.z*wall_offset*0.5;\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(p,1),AWAY,hidden);vec2 pos=normal.z==1.0\n? pos_nx.xy\n: 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;\n#ifdef LIGHTING_3D_MODE\nNdotL=calculate_NdotL(normal);\n#else\nNdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),NdotL);\n#endif\nif (normal.y !=0.0) {float r=0.84;\n#ifndef LIGHTING_3D_MODE\nr=mix(0.7,0.98,1.0-u_lightintensity);\n#endif\nNdotL*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}\n#ifdef FAUX_AO\nfloat 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;\n#ifdef TERRAIN\ntop_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);\n#endif\nv_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\n#ifdef LIGHTING_3D_MODE\nv_normal=normal;\n#else\nv_lighting.rgb+=clamp(NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;\n#endif \n#ifdef FOG\nv_fog_pos=fog_position(p);\n#endif\n}'),groundShadow:Yt('#include "_prelude_shadow.fragment.glsl"\nprecision highp float;uniform vec3 u_ground_shadow_factor;in vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;\n#ifdef FOG\nin float v_fog_opacity;\n#endif\nvoid main() {float light=shadowed_light_factor(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);\n#ifdef RENDER_CUTOFF\nshadow=mix(vec3(1.0),shadow,cutoff_opacity(u_cutoff_params,1.0/gl_FragCoord.w));\n#endif\n#ifdef FOG\nshadow=mix(shadow,vec3(1.0),v_fog_opacity);\n#endif\n#ifdef INDICATOR_CUTOUT\nshadow=mix(shadow,vec3(1.0),1.0-applyCutout(vec4(1.0)).r);\n#endif\nglFragColor=vec4(shadow,1.0);}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;in vec2 a_pos;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1;\n#ifdef FOG\nout float v_fog_opacity;\n#endif\nvoid 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);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);v_fog_opacity=fog(v_fog_pos);\n#endif\n}'),fillExtrusionGroundEffect:Yt("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;\n#ifdef SDF_SUBPASS\nin 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);}\n#ifdef FOG\nin highp float v_fog;\n#endif\n#endif\nvoid main() {\n#ifdef CLEAR_SUBPASS\nvec4 color=vec4(1.0);\n#ifdef CLEAR_FROM_TEXTURE\ncolor=texture(u_fb,gl_FragCoord.xy/vec2(u_fb_size));\n#endif\nglFragColor=color;\n#else\n#ifdef SDF_SUBPASS\nhighp 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;\n#ifdef FOG\nfog=v_fog;\n#endif\n#ifdef RENDER_CUTOFF\nfog*=v_cutoff_opacity;\n#endif\nglFragColor=vec4(vec3(0.0),mix(1.0,d,effect_intensity*u_opacity*fog));\n#else\nvec4 color=mix(vec4(u_flood_light_color,1.0),vec4(vec3(0.0),1.0),u_ao_pass);\n#ifdef OVERDRAW_INSPECTOR\ncolor=vec4(1.0);\n#endif\nglFragColor=color;\n#endif\nHANDLE_WIREFRAME_DEBUG;\n#endif\n}",'#include "_prelude_fog.vertex.glsl"\nin highp vec4 a_pos_end;in highp float a_angular_offset_factor;in highp float a_hidden_by_landmark;\n#ifdef SDF_SUBPASS\nout highp vec2 v_pos;out highp vec4 v_line_segment;out highp float v_flood_light_radius_tile;out highp vec2 v_ao;\n#ifdef FOG\nout highp float v_fog;\n#endif\n#endif\nuniform 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;\n#pragma mapbox: define highp float flood_light_ground_radius\nconst float TANGENT_CUTOFF=4.0;const float NORM=32767.0;void main() {\n#pragma mapbox: initialize highp float flood_light_ground_radius\nvec2 p=a_pos_end.xy;vec2 q=floor(a_pos_end.zw*0.5);vec2 start_bottom=a_pos_end.zw-q*2.0;float fl_ground_radius=flood_light_ground_radius;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=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;\n#ifdef SDF_SUBPASS\nv_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);\n#ifdef FOG\nv_fog_pos=fog_position(pos);v_fog=1.0-fog(v_fog_pos);\n#endif\n#endif\nfloat hidden_by_landmark=0.0;\n#ifdef HAS_CENTROID\nhidden_by_landmark=a_hidden_by_landmark;\n#endif\nfloat 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));\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n}'),hillshadePrepare:Yt("precision highp float;uniform 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(\n(c+e+e+h)-(a+d+d+f),(f+g+g+h)-(a+b+b+c)\n)/pow(2.0,exaggeration+(19.2562-u_zoom));glFragColor=clamp(vec4(\nderiv.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 vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:Yt('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform 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;\n#ifdef LIGHTING_3D_MODE\nglFragColor=apply_lighting_with_emission_ground(glFragColor,u_emissive_strength);\n#endif\n#ifdef FOG\nglFragColor=fog_dither(fog_apply_premultiplied(glFragColor,v_fog_pos));\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;in vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),line:Yt('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform lowp float u_device_pixel_ratio;uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;uniform highp vec2 u_trim_fade_range;uniform lowp vec4 u_trim_color;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec4 v_uv;\n#ifdef RENDER_LINE_DASH\nuniform sampler2D u_dash_image;in vec2 v_tex;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform sampler2D u_gradient_image;\n#endif\nfloat luminance(vec3 c) {return (c.r+c.r+c.b+c.g+c.g+c.g)*0.1667;}uniform float u_emissive_strength;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float border_width\n#pragma mapbox: define lowp vec4 border_color\nfloat linearstep(float edge0,float edge1,float x) {return clamp((x-edge0)/(edge1-edge0),0.0,1.0);}void main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float border_width\n#pragma mapbox: initialize lowp vec4 border_color\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);\n#ifdef RENDER_LINE_DASH\nfloat sdfdist=texture(u_dash_image,v_tex).r;float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/dash.z;alpha*=linearstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);\n#endif\nhighp vec4 out_color;\n#ifdef RENDER_LINE_GRADIENT\nout_color=texture(u_gradient_image,v_uv.xy);\n#else\nout_color=color;\n#endif\nfloat trim_alpha=1.0;\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float start=v_uv[2];highp float end=v_uv[3];highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=(start+(v_uv.x)*(end-start));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);out_color=mix(out_color,u_trim_color,transition_factor);trim_alpha=out_color.a;}\n#endif\nif (u_alpha_discard_threshold !=0.0) {if (alpha < u_alpha_discard_threshold) {discard;}}\n#ifdef RENDER_LINE_BORDER\nfloat edgeBlur=(border_width+1.0/u_device_pixel_ratio);float alpha2=clamp(min(dist-(v_width2.t-edgeBlur),v_width2.s-dist)/edgeBlur,0.0,1.0);if (alpha2 < 1.) {float smoothAlpha=smoothstep(0.6,1.0,alpha2);if (border_color.a==0.0) {float 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-smoothAlpha));} else {out_color.rgb*=(0.6 +0.4*smoothAlpha);}} else {out_color.rgb=mix(border_color.rgb*border_color.a*trim_alpha,out_color.rgb,smoothAlpha);}}\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nout_color*=(alpha*opacity);\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#define EXTRUDE_SCALE 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS)\nin float a_z_offset;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nin highp vec4 a_packed;\n#endif\n#ifdef RENDER_LINE_DASH\nin float a_linesofar;\n#endif\nuniform mat4 u_matrix;uniform mat2 u_pixels_to_tile_units;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec4 v_uv;\n#ifdef RENDER_LINE_DASH\nuniform vec2 u_texsize;uniform float u_tile_units_to_pixels;out vec2 v_tex;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform float u_image_height;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float border_width\n#pragma mapbox: define lowp vec4 border_color\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float border_width\n#pragma mapbox: initialize lowp vec4 border_color\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*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);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);\n#ifdef ELEVATED_ROADS\ngl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,a_z_offset+0.01*step(0.01,a_z_offset),1.0)+projected_extrude;\n#else\n#ifdef ELEVATED\nvec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 halfCellProgress=normal.yx*32.0;float ele0=elevation(pos);float ele_line=max(ele0,max(elevation(pos+halfCellProgress),elevation(pos-halfCellProgress)));float ele1=elevation(pos+offsetTile);float ele2=elevation(pos-offsetTile);float ele_max=max(ele_line,0.5*(ele1+ele2));float ele=ele_max-ele0+ele1+a_z_offset ;gl_Position=u_matrix*vec4(pos+offsetTile,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)*0.1*u_exaggeration);gl_Position.z-=(gl_Position.w*zbias);gl_Position=mix(gl_Position,AWAY,hidden);\n#else\ngl_Position=mix(u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude,AWAY,hidden);\n#endif\n#endif\n#ifndef RENDER_TO_TEXTURE\nfloat 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=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nfloat a_uv_x=a_packed[0];float a_split_index=a_packed[1];highp float a_clip_start=a_packed[2];highp float a_clip_end=a_packed[3];\n#ifdef RENDER_LINE_GRADIENT\nhighp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec4(a_uv_x,a_split_index*texel_height-half_texel_height,a_clip_start,a_clip_end);\n#else\nv_uv=vec4(a_uv_x,0.0,a_clip_start,a_clip_end);\n#endif\n#endif\n#ifdef RENDER_LINE_DASH\nfloat scale=dash.z==0.0 ? 0.0 : u_tile_units_to_pixels/dash.z;float height=dash.y;v_tex=vec2(a_linesofar*scale/floorwidth,(-normal.y*height+dash.x+0.5)/u_texsize.y);\n#endif\nv_width2=vec2(outset,inset);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),linePattern:Yt('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform highp float u_device_pixel_ratio;uniform highp float u_alpha_discard_threshold;uniform highp vec2 u_texsize;uniform highp float u_tile_units_to_pixels;uniform highp vec2 u_trim_offset;uniform sampler2D u_image;in vec2 v_normal;in vec2 v_width2;in highp float v_linesofar;in float v_gamma_scale;in float v_width;\n#ifdef RENDER_LINE_TRIM_OFFSET\nin highp vec4 v_uv;\n#endif\n#ifdef LINE_JOIN_NONE\nin vec2 v_pattern_data;\n#endif\n#pragma mapbox: define mediump vec4 pattern\n#pragma mapbox: define mediump float pixel_ratio\n#pragma mapbox: define mediump float blur\n#pragma mapbox: define mediump float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize mediump float pixel_ratio\n#pragma mapbox: initialize mediump float blur\n#pragma mapbox: initialize mediump float opacity\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;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=(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);\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float start=v_uv[2];highp float end=v_uv[3];highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=(start+(v_uv.x)*(end-start));if (trim_end > trim_start) {if (line_progress <=trim_end && line_progress >=trim_start) {color=vec4(0,0,0,0);}}\n#endif\n#ifdef LINE_JOIN_NONE\nfloat pattern_len=pattern_size/aspect;float segment_phase=pattern_len-mod(v_linesofar-v_pattern_data.x+pattern_len,pattern_len);float visible_start=segment_phase-step(pattern_len*0.5,segment_phase)*pattern_len;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);}\n#endif\n#ifdef LIGHTING_3D_MODE\ncolor=apply_lighting_ground(color);\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ncolor*=(alpha*opacity);if (u_alpha_discard_threshold !=0.0) {if (color.a < u_alpha_discard_threshold) {discard;}}\n#ifdef INDICATOR_CUTOUT\ncolor=applyCutout(color);\n#endif\nglFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS)\nin float a_z_offset;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nin highp vec4 a_packed;\n#endif\nin highp float a_linesofar;\n#ifdef LINE_JOIN_NONE\nin highp vec3 a_pattern_data;out vec2 v_pattern_data;\n#endif\nuniform 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;out vec2 v_normal;out vec2 v_width2;out highp float v_linesofar;out float v_gamma_scale;out float v_width;\n#ifdef RENDER_LINE_TRIM_OFFSET\nout highp vec4 v_uv;\n#endif\n#pragma mapbox: define mediump float blur\n#pragma mapbox: define mediump float opacity\n#pragma mapbox: define mediump float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define mediump float floorwidth\n#pragma mapbox: define mediump vec4 pattern\n#pragma mapbox: define mediump float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize mediump float blur\n#pragma mapbox: initialize mediump float opacity\n#pragma mapbox: initialize mediump float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize mediump float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize mediump float pixel_ratio\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);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);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);\n#ifdef ELEVATED_ROADS\ngl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,a_z_offset+0.01*step(0.01,a_z_offset),1.0)+projected_extrude;\n#else\n#ifdef ELEVATED\nvec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 halfCellProgress=normal.yx*32.0;float ele0=elevation(pos);float ele_line=max(ele0,max(elevation(pos+halfCellProgress),elevation(pos-halfCellProgress)));float ele1=elevation(pos+offsetTile);float ele2=elevation(pos-offsetTile);float ele_max=max(ele_line,0.5*(ele1+ele2));float ele=ele_max-ele0+ele1+a_z_offset ;gl_Position=u_matrix*vec4(pos+offsetTile,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)*0.1*u_exaggeration);gl_Position.z-=(gl_Position.w*zbias);gl_Position=mix(gl_Position,AWAY,hidden);\n#else\ngl_Position=mix(u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude,AWAY,hidden);\n#endif\n#endif\n#ifndef RENDER_TO_TEXTURE\nfloat 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=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nfloat a_uv_x=a_packed[0];highp float a_clip_start=a_packed[2];highp float a_clip_end=a_packed[3];v_uv=vec4(a_uv_x,0.0,a_clip_start,a_clip_end);\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;\n#ifdef LINE_JOIN_NONE\nv_width=floorwidth+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/((pattern.w-pattern.y)*pixel_ratio_inverse);highp float subt_multiple=(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);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),raster:Yt('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_raster_array.glsl"\nuniform 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;\n#ifdef PROJECTION_GLOBE_VIEW\nin float v_split_fade;\n#endif\nuniform 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;\n#ifndef RASTER_ARRAY\nuniform sampler2D u_image0;uniform sampler2D u_image1;\n#endif\n#ifdef RASTER_COLOR\nuniform sampler2D u_color_ramp;uniform highp vec4 u_colorization_mix;uniform highp float u_colorization_offset;uniform vec2 u_texture_res;\n#endif\nvoid main() {vec4 color0,color1,color;vec2 value;\n#ifdef RASTER_COLOR\n#ifdef RASTER_ARRAY\n#ifdef RASTER_ARRAY_LINEAR\nvalue=mix(\nraTexture2D_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\n);\n#else\nvalue=mix(\nraTexture2D_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\n);\n#endif\nif (value.y > 0.0) value.x/=value.y;\n#else\ncolor=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);\n#endif\ncolor=texture(u_color_ramp,vec2(value.x,0.5));if (color.a > 0.0) color.rgb/=color.a;color.a*=value.y;\n#else\ncolor0=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);\n#endif\ncolor.a*=u_opacity;\n#ifdef GLOBE_POLES\ncolor.a*=1.0-smoothstep(0.0,0.05,u_zoom_transition);\n#endif\nvec3 rgb=color.rgb;rgb=vec3(\ndot(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);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),u_emissive_strength).rgb;\n#endif\n#ifdef FOG\nhighp 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));\n#endif\nglFragColor=vec4(out_color*color.a,color.a);\n#ifdef PROJECTION_GLOBE_VIEW\nglFragColor*=mix(1.0,1.0-smoothstep(0.0,0.05,u_zoom_transition),smoothstep(0.8,0.9,v_split_fade));\n#endif\n#ifdef RENDER_CUTOFF\nglFragColor=glFragColor*cutoff_opacity(u_cutoff_params,v_depth);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform 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;\n#define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8\n#ifdef GLOBE_POLES\nin vec3 a_globe_pos;in vec2 a_uv;\n#else\nin vec2 a_pos;in vec2 a_texture_pos;\n#endif\nout vec2 v_pos0;out vec2 v_pos1;out float v_depth;\n#ifdef PROJECTION_GLOBE_VIEW\nout float v_split_fade;\n#endif\nvoid main() {vec2 uv;\n#ifdef GLOBE_POLES\nvec3 globe_pos=a_globe_pos;globe_pos+=normalize(globe_pos)*u_raster_elevation*GLOBE_UPSCALE;gl_Position=u_matrix*u_globe_matrix*vec4(globe_pos ,1.0);uv=a_uv;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(a_globe_pos,1.0)).xyz);\n#endif\n#else\nfloat w=1.0+dot(a_texture_pos,u_perspective_transform);uv=a_texture_pos/8192.0;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);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);float mercatorY=mercatorYfromLat(latLng[0]);float mercatorX=mercatorXfromLng(latLng[1]); \nv_split_fade=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;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)));}float tiles=u_grid_matrix[0][2];if (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);}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition)*w,w);gl_Position=u_matrix*interpolated_pos;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n#else\ngl_Position=u_matrix*vec4(a_pos*w,u_raster_elevation*w,w);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n#endif\n#endif\nv_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;\n#ifdef RENDER_CUTOFF\nv_depth=gl_Position.z;\n#endif\n}'),rasterParticle:Yt('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform 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;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),0.0).rgb;\n#endif\n#ifdef FOG\nhighp 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));\n#endif\nglFragColor=vec4(out_color*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform 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;\n#define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8\nin vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {float w=1.0;vec2 uv;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 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;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n#else\nuv=a_texture_pos/8192.0;gl_Position=u_matrix*vec4(a_pos*w,u_raster_elevation*w,w);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n#endif\nv_pos0=uv;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}'),rasterParticleDraw:Yt("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"\nin float 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(\nmod(a_index,u_particle_texture_side_len),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:Yt("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 vec2 a_pos;out vec2 v_tex_pos;void main() {vec2 uv=0.5*a_pos+vec2(0.5);v_tex_pos=uv;gl_Position=vec4(a_pos,0.0,1.0);}"),rasterParticleUpdate:Yt('#include "_prelude_raster_particle.glsl"\nuniform 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(\nlinearstep(vec2(-u_particle_pos_offset),vec2(0),pos)*linearstep(vec2(1.0+u_particle_pos_offset),vec2(1),pos),vec2(4)\n);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 vec2 a_pos;out vec2 v_tex_coord;void main() {v_tex_coord=0.5*(a_pos+vec2(1.0));gl_Position=vec4(a_pos,0.0,1.0);}"),symbol:Yt('#include "_prelude_lighting.glsl"\n#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;uniform bool u_is_halo;\n#ifdef ICON_TRANSITION\nuniform float u_icon_transition;\n#endif\n#ifdef COLOR_ADJUSTMENT\nuniform mat4 u_color_adj_mat;\n#endif\nin vec2 v_tex_a;\n#ifdef ICON_TRANSITION\nin vec2 v_tex_b;\n#endif\nin float v_draw_halo;in vec3 v_gamma_scale_size_fade_opacity;\n#ifdef RENDER_TEXT_AND_SYMBOL\nin float is_sdf;in vec2 v_tex_a_icon;\n#endif\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\n#pragma mapbox: initialize lowp float emissive_strength\nvec4 out_color;float fade_opacity=v_gamma_scale_size_fade_opacity[2];\n#ifdef RENDER_TEXT_AND_SYMBOL\nif (is_sdf==ICON) {vec2 tex_icon=v_tex_a_icon;lowp float alpha=opacity*fade_opacity;glFragColor=texture(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nreturn;}\n#endif\n#ifdef RENDER_SDF\nfloat 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*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/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;\n#else\n#ifdef ICON_TRANSITION\nvec4 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);\n#else\nout_color=texture(u_texture,v_tex_a);\n#endif\n#ifdef COLOR_ADJUSTMENT\nout_color=u_color_adj_mat*out_color;\n#endif\n#endif\nout_color*=opacity*fade_opacity;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\nin vec4 a_pos_offset;in vec4 a_tex_size;in vec4 a_pixeloffset;in vec4 a_projected_pos;in float a_fade_opacity;\n#ifdef Z_OFFSET\nin float a_auto_z_offset;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_globe_anchor;in vec3 a_globe_normal;\n#endif\n#ifdef ICON_TRANSITION\nin vec2 a_texb;\n#endif\n#ifdef OCCLUSION_QUERIES\nin float a_occlusion_query_opacity;\n#endif\nuniform 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;uniform 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;uniform vec3 u_up_vector;uniform vec2 u_texsize_icon;uniform bool u_is_halo;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform 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;\n#endif\nout vec2 v_tex_a;\n#ifdef ICON_TRANSITION\nout vec2 v_tex_b;\n#endif\nout float v_draw_halo;out vec3 v_gamma_scale_size_fade_opacity;\n#ifdef RENDER_TEXT_AND_SYMBOL\nout float is_sdf;out vec2 v_tex_a_icon;\n#endif\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n#pragma mapbox: define lowp float emissive_strength\n#pragma mapbox: define lowp float occlusion_opacity\n#pragma mapbox: define lowp float z_offset\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\n#pragma mapbox: initialize lowp float emissive_strength\n#pragma mapbox: initialize lowp float occlusion_opacity\n#pragma mapbox: initialize lowp float z_offset\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_min_font_scale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;float e=u_elevation_from_sea ? z_offset : z_offset+elevation(tile_anchor);\n#ifdef Z_OFFSET\ne+=a_auto_z_offset;\n#endif\nvec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;vec3 world_pos_globe;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos_globe=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;\n#else\nworld_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;\n#endif\nvec4 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 ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.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;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetprojected_point=u_matrix*vec4(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;\n#else\noffsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);a=projected_point.xy/projected_point.w;\n#endif\nvec2 b=offsetprojected_point.xy/offsetprojected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp 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);\n#ifdef TERRAIN\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\n#endif\n#ifdef Z_OFFSET\nz+=u_pitch_with_map ? a_auto_z_offset+(u_elevation_from_sea ? z_offset : z_offset) : 0.0;\n#else\nz+=u_pitch_with_map ? (u_elevation_from_sea ? z_offset : z_offset) : 0.0;\n#endif\nfloat occlusion_fade=globe_occlusion_fade;float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nvec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));float out_fade_opacity=interpolated_fade_opacity*projection_transition_fade;\n#ifdef DEPTH_OCCLUSION\nfloat depth_occlusion=occlusionFadeMultiSample(projected_point);float depth_occlusion_multplier=mix(occlusion_opacity,1.0,depth_occlusion);out_fade_opacity*=depth_occlusion_multplier;\n#endif\n#ifdef OCCLUSION_QUERIES\nfloat occludedFadeMultiplier=mix(occlusion_opacity,1.0,a_occlusion_query_opacity);out_fade_opacity*=occludedFadeMultiplier;\n#endif\nfloat alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 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);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,hidden);\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,hidden);\n#endif\nfloat 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;\n#ifdef RENDER_TEXT_AND_SYMBOL\nis_sdf=a_size[0]-2.0*a_size_min;v_tex_a_icon=a_tex/u_texsize_icon;\n#endif\n#ifdef ICON_TRANSITION\nv_tex_b=a_texb/u_texsize;\n#endif\n}'),terrainRaster:Yt('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image0;in vec2 v_pos0;\n#ifdef FOG\nin float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nin vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;\n#endif\nuniform vec3 u_ground_shadow_factor;void main() {vec4 image_color=texture(u_image0,v_pos0);vec4 color;\n#ifdef LIGHTING_3D_MODE\nconst vec3 normal=vec3(0.0,0.0,1.0);\n#ifdef RENDER_SHADOWS\nfloat cutoffOpacity=1.0;\n#ifdef RENDER_CUTOFF\ncutoffOpacity=cutoff_opacity(u_cutoff_params,1.0/gl_FragCoord.w);\n#endif\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nvec3 unlit_base=image_color.rgb*(1.0-image_color.a);vec3 emissive_base=image_color.rgb*image_color.a;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;\n#else\nfloat 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));\n#endif\n#else\nfloat lighting_factor=u_lighting_directional_dir.z;color=apply_lighting(image_color,normal,lighting_factor);\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\ncolor.rgb=mix(color.rgb,image_color.rgb,image_color.a);color.a=1.0;\n#endif\n#endif\n#else\ncolor=image_color;\n#endif\n#ifdef FOG\n#ifdef ZERO_EXAGGERATION\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#else\ncolor=fog_dither(fog_apply_from_vert(color,v_fog_opacity));\n#endif\n#endif\nglFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_skirt_height;in vec2 a_pos;out vec2 v_pos0;\n#ifdef FOG\nout float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nuniform 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;out float v_depth;\n#endif\nvoid 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;gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);\n#ifdef FOG\n#ifdef ZERO_EXAGGERATION\nv_fog_pos=fog_position(decodedPos);\n#else\nv_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));\n#endif\n#endif\n#ifdef RENDER_SHADOWS\nvec3 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.);\n#endif\n}'),terrainDepth:Yt("precision highp float;in float v_depth;void main() {glFragColor=pack_depth(v_depth);}",'#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;in vec2 a_pos;out float v_depth;void main() {float elevation=elevation(a_pos);gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}'),skybox:Yt('#include "_prelude_fog.fragment.glsl"\nin 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(\ncos_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))/(end-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;\n#ifdef FOG\nsky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color);\n#endif\nsky_color.rgb=dither(sky_color.rgb,gl_FragCoord.xy+u_temporal_offset);sky_color+=0.1*sun_disk(v_uv,u_sun_direction);glFragColor=vec4(sky_color*u_opacity,u_opacity);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}',el),skyboxGradient:Yt('#include "_prelude_fog.fragment.glsl"\nin 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));\n#ifdef FOG\ncolor.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a;\n#endif\ncolor*=u_opacity;color.rgb=dither(color.rgb,gl_FragCoord.xy+u_temporal_offset);glFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}',el),skyboxCapture:Yt("\nin 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;\n#define BETA_R vec3(5.5e-6,13.0e-6,22.4e-6)\n#define BETA_M vec3(21e-6,21e-6,21e-6)\n#define MIE_G 0.76\n#define DENSITY_HEIGHT_SCALE_R 8000.0\n#define DENSITY_HEIGHT_SCALE_M 1200.0\n#define PLANET_RADIUS 6360e3\n#define ATMOSPHERE_RADIUS 6420e3\n#define SAMPLE_STEPS 10\n#define DENSITY_STEPS 4\nfloat 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);}float 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))/(end-start)+new_start;}void main() {vec4 pos=vec4(u_matrix_3f*a_pos_3f,1.0);v_position=pos.xyz;v_position.y*=-1.0;v_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:Yt('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image0;uniform float u_far_z_cutoff;in vec2 v_pos0;\n#ifndef FOG\nuniform 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;\n#endif\nvoid main() {vec4 color;\n#ifdef CUSTOM_ANTIALIASING\nvec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);vec3 dir=normalize(ray_dir);vec3 closest_point=dot(u_globe_pos,dir)*dir;float norm_dist_from_center=1.0-length(closest_point-u_globe_pos)/u_globe_radius;const float antialias_pixel=2.0;float antialias_factor=antialias_pixel*fwidth(norm_dist_from_center);float antialias=smoothstep(0.0,antialias_factor,norm_dist_from_center);vec4 raster=texture(u_image0,v_pos0);\n#ifdef LIGHTING_3D_MODE\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nraster=apply_lighting_with_emission_ground(raster,raster.a);color=vec4(raster.rgb*antialias,antialias);\n#else\nraster=apply_lighting_ground(raster);color=vec4(raster.rgb*antialias,raster.a*antialias);\n#endif\n#else\ncolor=vec4(raster.rgb*antialias,raster.a*antialias);\n#endif\n#else\ncolor=texture(u_image0,v_pos0);\n#ifdef LIGHTING_3D_MODE\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\ncolor=apply_lighting_with_emission_ground(color,color.a);color.a=1.0;\n#else\ncolor=apply_lighting_ground(color);\n#endif\n#endif\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ncolor*=1.0-step(u_far_z_cutoff,1.0/gl_FragCoord.w);glFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_proj_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;uniform mat3 u_grid_matrix;uniform float u_skirt_height;\n#ifdef GLOBE_POLES\nin vec3 a_globe_pos;in vec2 a_uv;\n#else\nin vec2 a_pos;\n#endif\nout vec2 v_pos0;void main() {\n#ifdef GLOBE_POLES\nvec3 globe_pos=a_globe_pos;vec2 uv=a_uv;\n#else\nfloat 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);\n#endif\nv_pos0=uv;vec2 tile_pos=uv*EXTENT;vec3 globe_derived_up_vector=normalize(globe_pos)*u_tile_up_scale;\n#ifdef GLOBE_POLES\nvec3 up_vector=globe_derived_up_vector;\n#else\nvec3 up_vector=elevationVector(tile_pos);\n#endif\nfloat height=elevation(tile_pos);globe_pos+=up_vector*height;\n#ifndef GLOBE_POLES\nglobe_pos-=globe_derived_up_vector*u_skirt_height*decomposed_pos_and_skirt.z;\n#endif\n#ifdef GLOBE_POLES\nvec4 interpolated_pos=u_globe_matrix*vec4(globe_pos,1.0);\n#else\nvec4 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);\n#endif\ngl_Position=u_proj_matrix*interpolated_pos;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n}'),globeAtmosphere:Yt('#include "_prelude_fog.fragment.glsl"\nuniform float u_transition;uniform highp float u_fadeout_range;uniform highp float u_temporal_offset;uniform vec4 u_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;\n#ifdef PROJECTION_GLOBE_VIEW\nglobe_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) {\n#ifdef ALPHA_PASS\nglFragColor=vec4(0,0,0,0);return;\n#else\n#ifdef NATIVE\nglFragColor=vec4(1,1,1,1);\n#else\nglFragColor=vec4(0,0,0,1);\n#endif\nreturn;\n#endif\n}\n#endif\nhighp vec3 horizon_dir=normalize(v_horizon_dir);float horizon_angle_mercator=dir.y < horizon_dir.y ?\n0.0 : max(acos(clamp(dot(dir,horizon_dir),-1.0,1.0)),0.0);float horizon_angle;\n#ifdef PROJECTION_GLOBE_VIEW\nhighp 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 ?\nPI-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);\n#else\nhorizon_angle=horizon_angle_mercator;\n#endif\nhorizon_angle/=PI;float t=exp(-horizon_angle/u_fadeout_range);float alpha_0=u_color.a;float alpha_1=u_high_color.a;float alpha_2=u_space_color.a;vec3 color_stop_0=u_color.rgb;vec3 color_stop_1=u_high_color.rgb;vec3 color_stop_2=u_space_color.rgb;\n#ifdef ALPHA_PASS\nfloat 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);\n#else\nvec3 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;\n#ifndef NATIVE\nc=dither(c,gl_FragCoord.xy+u_temporal_offset);\n#endif\nglFragColor=vec4(c*t,t);\n#endif\n}',"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(\nmix(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(\nmix(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);}"),model:Yt('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform float u_opacity;uniform vec3 u_lightcolor;uniform vec3 u_lightpos;uniform float u_lightintensity;uniform 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;\n#ifdef RENDER_SHADOWS\nin highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in float v_depth_shadows;\n#endif\n#ifdef OCCLUSION_TEXTURE_TRANSFORM\nuniform vec4 u_occlusionTextureTransform;\n#endif\n#pragma mapbox: define-attribute highp vec3 normal_3f\n#pragma mapbox: define-attribute highp vec3 color_3f\n#pragma mapbox: define-attribute highp vec4 color_4f\n#pragma mapbox: define-attribute highp vec2 uv_2f\n#pragma mapbox: initialize-attribute highp vec3 normal_3f\n#pragma mapbox: initialize-attribute highp vec3 color_3f\n#pragma mapbox: initialize-attribute highp vec4 color_4f\n#pragma mapbox: initialize-attribute highp vec2 uv_2f\n#ifdef HAS_ATTRIBUTE_a_pbr\nin lowp vec4 v_roughness_metallic_emissive_alpha;in mediump vec4 v_height_based_emission_params;\n#endif\n#ifdef HAS_TEXTURE_u_baseColorTexture\nuniform sampler2D u_baseColorTexture;uniform bool u_baseTextureIsAlpha;uniform bool u_alphaMask;uniform float u_alphaCutoff;\n#endif\n#ifdef HAS_TEXTURE_u_metallicRoughnessTexture\nuniform sampler2D u_metallicRoughnessTexture;\n#endif\n#ifdef HAS_TEXTURE_u_occlusionTexture\nuniform sampler2D u_occlusionTexture;uniform float u_aoIntensity;\n#endif\n#ifdef HAS_TEXTURE_u_normalTexture\nuniform sampler2D u_normalTexture;\n#endif\n#ifdef HAS_TEXTURE_u_emissionTexture\nuniform sampler2D u_emissionTexture;\n#endif\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nin highp float v_depth;uniform highp sampler2D u_depthTexture;uniform highp vec2 u_inv_depth_size;uniform highp vec2 u_depth_range_unpack;\n#ifdef DEPTH_D24\nhighp float unpack_depth(highp float depth) {return depth*u_depth_range_unpack.x+u_depth_range_unpack.y;}\n#else\nhighp float unpack_depth_rgba(highp vec4 rgba_depth)\n{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;}\n#endif\nbool isOccluded() {highp vec2 coord=gl_FragCoord.xy*u_inv_depth_size;\n#ifdef DEPTH_D24\nhighp float depth=unpack_depth(texture(u_depthTexture,coord).r);\n#else\nhighp float depth=unpack_depth_rgba(texture(u_depthTexture,coord));\n#endif\nreturn v_depth > depth+0.0005;}\n#endif\n#define saturate(_x) clamp(_x,0.,1.)\nvec3 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)\n{\n#ifdef LIGHTING_3D_MODE\nvec3 transformed_normal=vec3(-normal.xy,normal.z);float lighting_factor;\n#ifdef RENDER_SHADOWS\nlighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);\n#else\nlighting_factor=saturate(dot(transformed_normal,u_lighting_directional_dir));\n#endif\nreturn apply_lighting(albedo,transformed_normal,lighting_factor);\n#else\nvec3 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;\n#endif\n}vec4 getBaseColor() {vec4 albedo=u_baseColorFactor;\n#ifdef HAS_ATTRIBUTE_a_color_3f\nalbedo*=vec4(color_3f,1.0);\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\n#else\n#ifdef HAS_ATTRIBUTE_a_color_4f\nalbedo*=color_4f;\n#endif\n#endif\n#if defined (HAS_TEXTURE_u_baseColorTexture) && defined (HAS_ATTRIBUTE_a_uv_2f)\nvec4 texColor=texture(u_baseColorTexture,uv_2f);if(u_alphaMask) {if (texColor.w < u_alphaCutoff) {discard;}}\n#ifdef UNPREMULT_TEXTURE_IN_SHADER\nif(texColor.w > 0.0) {texColor.rgb/=texColor.w;}texColor.w=1.0;\n#endif\nif(u_baseTextureIsAlpha) {if (texColor.r < 0.5) {discard;}} else {texColor.rgb=sRGBToLinear(texColor.rgb);albedo*=texColor;}\n#endif\nvec4 color=vec4(mix(albedo.rgb,v_color_mix.rgb,v_color_mix.a),albedo.a);\n#ifdef APPLY_LUT_ON_GPU\ncolor=applyLUT(u_lutTexture,color);\n#endif\nreturn color;}highp mat3 cotangentFrame(highp vec3 N,highp vec3 p,highp vec2 uv ) {\n#ifdef HAS_TEXTURE_u_normalTexture\nhighp 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;highp 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;\n#else\nreturn mat3(1.0);\n#endif\n}highp vec3 getNormal(){highp vec3 n;\n#ifdef HAS_ATTRIBUTE_a_normal_3f\nn=normalize(normal_3f);\n#else\nhighp 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));n=normalize(cross(fdx,fdy))*-1.0;\n#endif\n#if defined(HAS_TEXTURE_u_normalTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\nvec3 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);\n#endif\nreturn 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;\n#ifdef HAS_ATTRIBUTE_a_pbr\nmat.perceptualRoughness=v_roughness_metallic_emissive_alpha.x;mat.metallic=v_roughness_metallic_emissive_alpha.y;mat.baseColor.w*=v_roughness_metallic_emissive_alpha.w;\n#endif\n#if defined(HAS_TEXTURE_u_metallicRoughnessTexture) && defined(HAS_ATTRIBUTE_a_uv_2f) \nvec4 mrSample=texture(u_metallicRoughnessTexture,uv_2f);mat.perceptualRoughness*=mrSample.g;mat.metallic*=mrSample.b;\n#endif\nconst 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)\n{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)\n{return specularColor+(f90-specularColor)*pow(clamp(1.0-VdotH,0.0,1.0),5.0);}vec3 F_SchlickFast(vec3 specularColor,float VdotH)\n{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)\n{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)\n{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)\n{\n#ifdef LIGHTING_3D_MODE\nreturn mat.diffuseColor;\n#else\nreturn mat.diffuseColor/PI;\n#endif\n}vec3 EnvBRDFApprox(vec3 specularColor,float roughness,highp float NdotV)\n{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)\n{vec3 env_light=vec3(0.65,0.65,0.65);\n#ifdef LIGHTING_3D_MODE\nfloat ambient_factor=calculate_ambient_directional_factor(normal);env_light=u_lighting_ambient_color*ambient_factor;\n#endif\nvec3 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)\n{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;\n#ifdef RENDER_SHADOWS\nlighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);\n#else\nlighting_factor=NdotL;\n#endif\nvec3 directLightColor=(specularTerm+diffuseTerm)*lighting_factor*lightColor;vec3 indirectLightColor=computeIndirectLightContribution(mat,NdotV,transformed_normal);vec3 color=(saturate(directLightColor)+indirectLightColor);float intensityFactor=1.0;\n#if !defined(LIGHTING_3D_MODE)\nconst 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);\n#endif\ncolor*=intensityFactor;return color;}void main() {\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nif (isOccluded()) {discard;}\n#endif\nvec3 lightDir=u_lightpos;vec3 lightColor=u_lightcolor;\n#ifdef LIGHTING_3D_MODE\nlightDir=u_lighting_directional_dir;lightDir.xy=-lightDir.xy;lightColor=u_lighting_directional_color;\n#endif\nvec4 finalColor;\n#ifdef DIFFUSE_SHADED\nvec3 N=getNormal();vec3 baseColor=getBaseColor().rgb;vec3 diffuse=getDiffuseShadedColor(baseColor,N,lightDir,lightColor);\n#ifdef HAS_TEXTURE_u_occlusionTexture\nfloat ao=(texture(u_occlusionTexture,uv_2f).r-1.0)*u_aoIntensity+1.0;diffuse*=ao;\n#endif\nfinalColor=vec4(mix(diffuse,baseColor,u_emissive_strength),1.0)*u_opacity;\n#else\nMaterial mat=getPBRMaterial();vec3 color=computeLightContribution(mat,lightDir,lightColor);float ao=1.0;\n#if defined (HAS_TEXTURE_u_occlusionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\n#ifdef OCCLUSION_TEXTURE_TRANSFORM\nvec2 uv=uv_2f.xy*u_occlusionTextureTransform.zw+u_occlusionTextureTransform.xy;\n#else\nvec2 uv=uv_2f;\n#endif\nao=(texture(u_occlusionTexture,uv).x-1.0)*u_aoIntensity+1.0;color*=ao;\n#endif\nvec4 emissive=u_emissiveFactor;\n#if defined(HAS_TEXTURE_u_emissionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\nemissive.rgb*=sRGBToLinear(texture(u_emissionTexture,uv_2f).rgb);\n#endif\n#ifdef APPLY_LUT_ON_GPU\nfloat emissiveFactorLength=max(length(u_emissiveFactor.rgb),0.001);emissive.rgb=sRGBToLinear(applyLUT(u_lutTexture,linearTosRGB(emissive.rgb/emissiveFactorLength).rbg))*emissiveFactorLength;\n#endif\ncolor+=emissive.rgb;float opacity=mat.baseColor.w*u_opacity;\n#ifdef HAS_ATTRIBUTE_a_pbr\nfloat 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;\n#ifdef APPLY_LUT_ON_GPU\ncolor_mix=applyLUT(u_lutTexture,color_mix);\n#endif\ncolor=mix(color,color_mix,min(1.0,resEmission));\n#ifdef HAS_ATTRIBUTE_a_color_4f\nfloat distance=length(vec2(1.3*max(0.0,abs(color_4f.x)-color_4f.z),color_4f.y));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);\n#endif\n#endif\nvec3 unlitColor=mat.baseColor.rgb*ao+emissive.rgb;color=mix(color,unlitColor,u_emissive_strength);color=linearTosRGB(color);color*=opacity;finalColor=vec4(color,opacity);\n#endif\n#ifdef FOG\nfinalColor=fog_dither(fog_apply_premultiplied(finalColor,v_fog_pos,v_position_height.w));\n#endif\n#ifdef RENDER_CUTOFF\nfinalColor*=v_cutoff_opacity;\n#endif\n#ifdef INDICATOR_CUTOUT\nfinalColor=applyCutout(finalColor);\n#endif\nglFragColor=finalColor;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin vec3 a_pos_3f;\n#pragma mapbox: define-attribute highp vec3 normal_3f\n#pragma mapbox: define-attribute highp vec2 uv_2f\n#pragma mapbox: define-attribute highp vec3 color_3f\n#pragma mapbox: define-attribute highp vec4 color_4f\n#pragma mapbox: define-attribute-vertex-shader-only highp vec4 pbr\n#pragma mapbox: define-attribute-vertex-shader-only highp vec3 heightBasedEmissiveStrength\nuniform mat4 u_matrix;uniform mat4 u_node_matrix;uniform mat4 u_lighting_matrix;uniform vec3 u_camera_pos;uniform vec4 u_color_mix;\n#ifdef INSTANCED_ARRAYS\nin vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3;\n#else\nuniform highp mat4 u_normal_matrix;\n#endif\n#ifdef RENDER_SHADOWS\nuniform 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;\n#endif\nout vec4 v_position_height;out lowp vec4 v_color_mix;\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nout highp float v_depth;\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\nout lowp vec4 v_roughness_metallic_emissive_alpha;out mediump vec4 v_height_based_emission_params;\n#endif\nvec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() {\n#pragma mapbox: initialize-attribute highp vec3 normal_3f\n#pragma mapbox: initialize-attribute highp vec2 uv_2f\n#pragma mapbox: initialize-attribute highp vec3 color_3f\n#pragma mapbox: initialize-attribute highp vec4 color_4f\n#pragma mapbox: initialize-attribute-custom highp vec4 pbr\n#pragma mapbox: initialize-attribute-custom highp vec3 heightBasedEmissiveStrength\nhighp mat4 normal_matrix;\n#ifdef INSTANCED_ARRAYS\nnormal_matrix=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3);\n#else\nnormal_matrix=u_normal_matrix;\n#endif\nvec3 local_pos;mat3 rs;\n#ifdef MODEL_POSITION_ON_GPU\nvec3 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;\n#else\nlocal_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);\n#endif\nv_position_height.w=a_pos_3f.z;\n#ifdef HAS_ATTRIBUTE_a_pbr\nvec4 albedo_c=decode_color(pbr.xy);vec2 e_r_m=unpack_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(pbr.w)/256.0;v_height_based_emission_params.z=emissionMultiplierValues.x;v_height_based_emission_params.w=emissionMultiplierValues.y-emissionMultiplierValues.x;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(local_pos);\n#endif\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef HAS_ATTRIBUTE_a_normal_3f\n#ifdef MODEL_POSITION_ON_GPU\nfloat 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);\n#else\nnormal_3f=vec3(normal_matrix*vec4(normal_3f,0));\n#endif\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\n#ifdef HAS_ATTRIBUTE_a_color_4f\nv_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);\n#endif\n#endif\n#ifdef RENDER_SHADOWS\nvec4 shadow_pos=u_node_matrix*vec4(local_pos,1.0);\n#ifdef NORMAL_OFFSET\n#ifdef HAS_ATTRIBUTE_a_normal_3f\n#ifdef MODEL_POSITION_ON_GPU\nvec3 offset=shadow_normal_offset(vec3(-normal_3f.xy,normal_3f.z));shadow_pos.xyz+=offset*shadow_normal_offset_multiplier0();\n#else\nvec3 offset=shadow_normal_offset_model(normal_3f);shadow_pos.xyz+=offset*shadow_normal_offset_multiplier0();\n#endif\n#endif\n#endif\nv_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;\n#endif\n}'),modelDepth:Yt("in highp float v_depth;void main() {\n#ifndef DEPTH_TEXTURE\nglFragColor=pack_depth(v_depth);\n#endif\n}","in vec3 a_pos_3f;uniform mat4 u_matrix;out highp float v_depth;\n#ifdef MODEL_POSITION_ON_GPU\n#ifdef INSTANCED_ARRAYS\nin vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3;\n#else\nuniform highp mat4 u_instance;\n#endif\nuniform highp mat4 u_node_matrix;\n#endif\nvoid main() {\n#ifdef MODEL_POSITION_ON_GPU\nhighp mat4 instance;\n#ifdef INSTANCED_ARRAYS\ninstance=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3);\n#else\ninstance=u_instance;\n#endif\nvec3 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;rs[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);\n#else\ngl_Position=u_matrix*vec4(a_pos_3f,1);\n#endif\nv_depth=gl_Position.z/gl_Position.w;}"),stars:Yt("in highp vec2 v_uv;in mediump float v_intensity;float shapeCircle(in vec2 uv)\n{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;}","\nin vec3 a_pos_3f;in vec2 a_uv;in float a_size_scale;in float a_fade_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_fade_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:Yt("uniform vec4 u_color;void main() {glFragColor=u_color;}",'#include "_prelude_terrain.vertex.glsl"\nin 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;\n#ifdef TERRAIN\nfloat e=elevation(world_pos.xy);world_pos.z+=e;\n#endif\nvec4 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 Qn(l,t){const r=l.replace(/\s*\/\/[^\n]*\n/g,"\n").split("\n");for(let c of r)if(c=c.trim(),"#"===c[0]&&c.includes("if")&&!c.includes("endif")){c=c.replace("#","").replace(/ifdef|ifndef|elif|if/g,"").replace(/!|defined|\(|\)|\|\||&&/g,"").replace(/\s+/g," ").trim();const d=c.split(" ");for(const f of d)t.includes(f)||t.push(f)}}function Yt(l,t){const r=/#include\s+"([^"]+)"/g,c=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g;let d=t.match(/(attribute(\S*)|(^\s*|;)in) (highp |mediump |lowp )?([\w]+) ([\w]+)/gm);d&&(d=d.map(A=>{const I=A.split(" ");return I[I.length-1]}),d=[...new Set(d)]);const f={},_=[],T=[];if(l=l.replace(r,(A,I)=>(T.push(I),"")),(t=t.replace(r,(A,I)=>(_.push(I),""))).includes("flat out"))return void console.error('The usage of "flat" qualifier is disallowed, see: https://bugs.webkit.org/show_bug.cgi?id=268071');let S=[...tl];Qn(l,S),Qn(t,S);for(const A of[..._,...T])ia[A]||console.error(`Undefined include: ${A}`),cs[A]||(cs[A]=[],Qn(ia[A],cs[A])),S=[...S,...cs[A]];return{fragmentSource:l=l.replace(c,(A,I,z,D,L)=>(f[L]=!0,"define"===I?`\n#ifndef HAS_UNIFORM_u_${L}\nin ${z} ${D} ${L};\n#else\nuniform ${z} ${D} u_${L};\n#endif\n`:"initialize"===I?`\n#ifdef HAS_UNIFORM_u_${L}\n ${z} ${D} ${L} = u_${L};\n#endif\n`:"define-attribute"===I?`\n#ifdef HAS_ATTRIBUTE_a_${L}\n in ${z} ${D} ${L};\n#endif\n`:"initialize-attribute"===I?"":void 0)),vertexSource:t=t.replace(c,(A,I,z,D,L)=>{const F="float"===D?"vec2":D,N=L.match(/color/)?"color":F;return"define-attribute-vertex-shader-only"===I?`\n#ifdef HAS_ATTRIBUTE_a_${L}\nin ${z} ${D} a_${L};\n#endif\n`:f[L]?"define"===I?`\n#ifndef HAS_UNIFORM_u_${L}\nuniform lowp float u_${L}_t;\nin ${z} ${F} a_${L};\nout ${z} ${D} ${L};\n#else\nuniform ${z} ${D} u_${L};\n#endif\n`:"initialize"===I?"vec4"===N?`\n#ifndef HAS_UNIFORM_u_${L}\n ${L} = a_${L};\n#else\n ${z} ${D} ${L} = u_${L};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${L}\n ${L} = unpack_mix_${N}(a_${L}, u_${L}_t);\n#else\n ${z} ${D} ${L} = u_${L};\n#endif\n`:"define-attribute"===I?`\n#ifdef HAS_ATTRIBUTE_a_${L}\n in ${z} ${D} a_${L};\n out ${z} ${D} ${L};\n#endif\n`:"initialize-attribute"===I?`\n#ifdef HAS_ATTRIBUTE_a_${L}\n ${L} = a_${L};\n#endif\n`:void 0:"define"===I?`\n#ifndef HAS_UNIFORM_u_${L}\nuniform lowp float u_${L}_t;\nin ${z} ${F} a_${L};\n#else\nuniform ${z} ${D} u_${L};\n#endif\n`:"define-instanced"===I?"mat4"===N?`\n#ifdef INSTANCED_ARRAYS\nin vec4 a_${L}0;\nin vec4 a_${L}1;\nin vec4 a_${L}2;\nin vec4 a_${L}3;\n#else\nuniform ${z} ${D} u_${L};\n#endif\n`:`\n#ifdef INSTANCED_ARRAYS\nin ${z} ${F} a_${L};\n#else\nuniform ${z} ${D} u_${L};\n#endif\n`:"initialize-attribute-custom"===I?`\n#ifdef HAS_ATTRIBUTE_a_${L}\n ${z} ${D} ${L} = a_${L};\n#endif\n`:"vec4"===N?`\n#ifndef HAS_UNIFORM_u_${L}\n ${z} ${D} ${L} = a_${L};\n#else\n ${z} ${D} ${L} = u_${L};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${L}\n ${z} ${D} ${L} = unpack_mix_${N}(a_${L}, u_${L}_t);\n#else\n ${z} ${D} ${L} = u_${L};\n#endif\n`}),staticAttributes:d,usedDefines:S,vertexIncludes:_,fragmentIncludes:T}}class hs{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(t,r,c,d,f,_,T,S){this.context=t;let A=this.boundPaintVertexBuffers.length!==d.length;for(let z=0;!A&&z{const $=W.paint.get("hillshade-shadow-color"),Q=W.paint.get("hillshade-highlight-color"),J=W.paint.get("hillshade-accent-color"),ne=W.paint.get("hillshade-emissive-strength");let ie=s.bB(W.paint.get("hillshade-illumination-direction"));if("viewport"===W.paint.get("hillshade-illumination-anchor"))ie-=V.transform.angle;else if(V.style&&V.style.enable3dLights()&&V.style.directionalLight){const de=V.style.directionalLight.properties.get("direction"),ce=s.c7(de.x,de.y,de.z);ie=s.bB(ce[1])}const oe=!V.options.moving;return{u_matrix:Y||V.transform.calculateProjMatrix(U.tileID.toUnwrapped(),oe),u_image:0,u_latrange:na(0,U.tileID),u_light:[W.paint.get("hillshade-exaggeration"),ie],u_shadow:$.toRenderColor(W.lut),u_highlight:Q.toRenderColor(W.lut),u_emissive_strength:ne,u_accent:J.toRenderColor(W.lut)}})(l,r,c,l.terrain?t.projMatrix:null);l.uploadCommonUniforms(T,z,t.toUnwrapped());const{tileBoundsBuffer:L,tileBoundsIndexBuffer:F,tileBoundsSegments:N}=l.getTileBoundsBuffers(r);z.draw(l,S.TRIANGLES,d,f,_,yt.disabled,D,c.id,L,F,N)}function nl(l,t,r){if(!t.needsDEMTextureUpload)return;const c=l.context,d=c.gl;c.pixelStoreUnpackPremultiplyAlpha.set(!1),t.demTexture=t.demTexture||l.getTileTexture(r.stride);const f=r.getPixels();t.demTexture?t.demTexture.update(f,{premultiply:!1}):t.demTexture=new s.T(c,f,d.R32F,{premultiply:!1}),t.needsDEMTextureUpload=!1}function oa(l,t,r){const c=l.context,d=c.gl;if(!t.dem)return;const f=t.dem;if(c.activeTexture.set(d.TEXTURE1),nl(l,t,f),!t.demTexture)return;t.demTexture.bind(d.NEAREST,d.CLAMP_TO_EDGE);const _=f.dim;c.activeTexture.set(d.TEXTURE0);let T=t.hillshadeFBO;if(!T){const D=new s.T(c,{width:_,height:_,data:null},d.RGBA8);D.bind(d.LINEAR,d.CLAMP_TO_EDGE),T=t.hillshadeFBO=c.createFramebuffer(_,_,!0,"renderbuffer"),T.colorAttachment.set(D.texture)}c.bindFramebuffer.set(T.framebuffer),c.viewport.set([0,0,_,_]);const{tileBoundsBuffer:S,tileBoundsIndexBuffer:A,tileBoundsSegments:I}=l.getMercatorTileBoundsBuffers(),z=[];l.linearFloatFilteringSupported()&&z.push("TERRAIN_DEM_FLOAT_FORMAT"),l.getOrCreateProgram("hillshadePrepare",{defines:z}).draw(l,d.TRIANGLES,dt.disabled,Et.disabled,Zt.unblended,yt.disabled,((D,L)=>{const F=L.stride,N=s.a6.mat4.create();return s.a6.mat4.ortho(N,0,s.ab,-s.ab,0,0,1),s.a6.mat4.translate(N,N,[0,-s.ab,0]),{u_matrix:N,u_image:1,u_dimension:[F,F],u_zoom:D.overscaledZ}})(t.tileID,f),r.id,S,A,I),t.needsHillshadePrepare=!1}class gi{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 mc extends gi{getDefault(){return s.bz.transparent}set(t){const r=this.current;(t.r!==r.r||t.g!==r.g||t.b!==r.b||t.a!==r.a||this.dirty)&&(this.gl.clearColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class Qh extends gi{getDefault(){return 1}set(t){(t!==this.current||this.dirty)&&(this.gl.clearDepth(t),this.current=t,this.dirty=!1)}}class _c extends gi{getDefault(){return 0}set(t){(t!==this.current||this.dirty)&&(this.gl.clearStencil(t),this.current=t,this.dirty=!1)}}class ol extends gi{getDefault(){return[!0,!0,!0,!0]}set(t){const r=this.current;(t[0]!==r[0]||t[1]!==r[1]||t[2]!==r[2]||t[3]!==r[3]||this.dirty)&&(this.gl.colorMask(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class sa extends gi{getDefault(){return!0}set(t){(t!==this.current||this.dirty)&&(this.gl.depthMask(t),this.current=t,this.dirty=!1)}}class eu extends gi{getDefault(){return 255}set(t){(t!==this.current||this.dirty)&&(this.gl.stencilMask(t),this.current=t,this.dirty=!1)}}class tu extends gi{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(t){const r=this.current;(t.func!==r.func||t.ref!==r.ref||t.mask!==r.mask||this.dirty)&&(this.gl.stencilFunc(t.func,t.ref,t.mask),this.current=t,this.dirty=!1)}}class iu extends gi{getDefault(){const t=this.gl;return[t.KEEP,t.KEEP,t.KEEP]}set(t){const r=this.current;(t[0]!==r[0]||t[1]!==r[1]||t[2]!==r[2]||this.dirty)&&(this.gl.stencilOp(t[0],t[1],t[2]),this.current=t,this.dirty=!1)}}class us extends gi{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const r=this.gl;t?r.enable(r.STENCIL_TEST):r.disable(r.STENCIL_TEST),this.current=t,this.dirty=!1}}class ru extends gi{getDefault(){return[0,1]}set(t){const r=this.current;(t[0]!==r[0]||t[1]!==r[1]||this.dirty)&&(this.gl.depthRange(t[0],t[1]),this.current=t,this.dirty=!1)}}class Rd extends gi{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const r=this.gl;t?r.enable(r.DEPTH_TEST):r.disable(r.DEPTH_TEST),this.current=t,this.dirty=!1}}class Ld extends gi{getDefault(){return this.gl.LESS}set(t){(t!==this.current||this.dirty)&&(this.gl.depthFunc(t),this.current=t,this.dirty=!1)}}class kd extends gi{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const r=this.gl;t?r.enable(r.BLEND):r.disable(r.BLEND),this.current=t,this.dirty=!1}}class gc extends gi{getDefault(){const t=this.gl;return[t.ONE,t.ZERO,t.ONE,t.ZERO]}set(t){const r=this.current;(t[0]!==r[0]||t[1]!==r[1]||t[2]!==r[2]||t[3]!==r[3]||this.dirty)&&(this.gl.blendFuncSeparate(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class yc extends gi{getDefault(){return s.bz.transparent}set(t){const r=this.current;(t.r!==r.r||t.g!==r.g||t.b!==r.b||t.a!==r.a||this.dirty)&&(this.gl.blendColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class xc extends gi{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 vc extends gi{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const r=this.gl;t?r.enable(r.CULL_FACE):r.disable(r.CULL_FACE),this.current=t,this.dirty=!1}}class nu extends gi{getDefault(){return this.gl.BACK}set(t){(t!==this.current||this.dirty)&&(this.gl.cullFace(t),this.current=t,this.dirty=!1)}}class ou extends gi{getDefault(){return this.gl.CCW}set(t){(t!==this.current||this.dirty)&&(this.gl.frontFace(t),this.current=t,this.dirty=!1)}}let Od=class extends gi{getDefault(){return null}set(l){(l!==this.current||this.dirty)&&(this.gl.useProgram(l),this.current=l,this.dirty=!1)}};class aa extends gi{getDefault(){return this.gl.TEXTURE0}set(t){(t!==this.current||this.dirty)&&(this.gl.activeTexture(t),this.current=t,this.dirty=!1)}}class la extends gi{getDefault(){const t=this.gl;return[0,0,t.drawingBufferWidth,t.drawingBufferHeight]}set(t){const r=this.current;(t[0]!==r[0]||t[1]!==r[1]||t[2]!==r[2]||t[3]!==r[3]||this.dirty)&&(this.gl.viewport(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class su extends gi{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const r=this.gl;r.bindFramebuffer(r.FRAMEBUFFER,t),this.current=t,this.dirty=!1}}class Nr extends gi{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const r=this.gl;r.bindRenderbuffer(r.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class bc extends gi{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const r=this.gl;r.bindTexture(r.TEXTURE_2D,t),this.current=t,this.dirty=!1}}class sl extends gi{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const r=this.gl;r.bindBuffer(r.ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class al extends gi{getDefault(){return null}set(t){const r=this.gl;r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class wc extends gi{getDefault(){return null}set(t){this.gl&&(t!==this.current||this.dirty)&&(this.gl.bindVertexArray(t),this.current=t,this.dirty=!1)}}class Tc extends gi{getDefault(){return 4}set(t){if(t===this.current&&!this.dirty)return;const r=this.gl;r.pixelStorei(r.UNPACK_ALIGNMENT,t),this.current=t,this.dirty=!1}}class ll extends gi{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const r=this.gl;r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t),this.current=t,this.dirty=!1}}class Mc extends gi{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const r=this.gl;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,t),this.current=t,this.dirty=!1}}class ca extends gi{constructor(t,r){super(t),this.context=t,this.parent=r}getDefault(){return null}}class cl extends ca{setDirty(){this.dirty=!0}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const r=this.gl;r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,t,0),this.current=t,this.dirty=!1}}class Sc extends ca{attachment(){return this.gl.DEPTH_ATTACHMENT}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const r=this.gl;r.framebufferRenderbuffer(r.FRAMEBUFFER,this.attachment(),r.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class au extends ca{attachment(){return this.gl.DEPTH_ATTACHMENT}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const r=this.gl;r.framebufferTexture2D(r.FRAMEBUFFER,this.attachment(),r.TEXTURE_2D,t,0),this.current=t,this.dirty=!1}}class ds extends Sc{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}const Bd=(l,t,r)=>({u_matrix:l,u_image0:0,u_skirt_height:t,u_ground_shadow_factor:r}),lu=(l,t,r,c,d,f,_,T,S,A,I,z,D,L,F,N)=>({u_proj_matrix:Float32Array.from(l),u_globe_matrix:t,u_normalize_matrix:Float32Array.from(c),u_merc_matrix:r,u_zoom_transition:d,u_merc_center:f,u_image0:0,u_frustum_tl:_,u_frustum_tr:T,u_frustum_br:S,u_frustum_bl:A,u_globe_pos:I,u_globe_radius:z,u_viewport:D,u_grid_matrix:N?Float32Array.from(N):new Float32Array(9),u_skirt_height:L,u_far_z_cutoff:F});function cu(l,t){return null!=l&&null!=t&&!(!l.hasData()||!t.hasData())&&null!=l.demTexture&&null!=t.demTexture&&l.tileID.key!==t.tileID.key}const ps=new class{constructor(){this.operations={}}newMorphing(l,t,r,c,d){if(l in this.operations){const f=this.operations[l];f.to.tileID.key!==r.tileID.key&&(f.queued=r)}else this.operations[l]={startTime:c,phase:0,duration:d,from:t,to:r,queued:null}}getMorphValuesForProxy(l){if(!(l in this.operations))return null;const t=this.operations[l];return{from:t.from,to:t.to,phase:t.phase}}update(l){for(const t in this.operations){const r=this.operations[t];for(r.phase=(l-r.startTime)/r.duration;r.phase>=1||!this._validOp(r);)if(!this._nextOp(r,l)){delete this.operations[t];break}}}_nextOp(l,t){return!!l.queued&&(l.from=l.to,l.to=l.queued,l.queued=null,l.phase=0,l.startTime=t,!0)}_validOp(l){return l.from.hasData()&&l.to.hasData()}},hu={0:null,1:"TERRAIN_VERTEX_MORPHING"};function uu(l,t,r){if(0===t)return 0;const c=t<1&&514===r?.25/t:1;return 6*Math.pow(1.5,22-l)*Math.max(t,1)*c}function Ec(l,t){const r=1<({u_matrix:l});function hl(l,t,r,c,d){if(d>0){const f=s.q.now(),_=(f-l.timeAdded)/d,T=t?(f-t.timeAdded)/d:-1,S=r.getSource(),A=c.coveringZoomLevel({tileSize:S.tileSize,roundZoom:S.roundZoom}),I=!t||Math.abs(t.tileID.overscaledZ-A)>Math.abs(l.tileID.overscaledZ-A),z=I&&l.refreshedUponExpiration?1:s.ap(I?_:1-T,0,1);return l.refreshedUponExpiration&&_>=1&&(l.refreshedUponExpiration=!1),t?{opacity:1,mix:1-z}:{opacity:z,mix:0}}return{opacity:1,mix:0}}class fs extends Ar{constructor(t){const r={type:"raster-dem",maxzoom:t.transform.maxZoom},c=new s.cd(s.ce(),null),d=$o("mock-dem",r,c,t.style);super("mock-dem",d,!1),d.setEventedParent(this),this._sourceLoaded=!0}_loadTile(t,r){t.state="loaded",r(null)}}class du extends Ar{constructor(t){const r=$o("proxy",{type:"geojson",maxzoom:t.transform.maxZoom},new s.cd(s.ce(),null),t.style);super("proxy",r,!1),r.setEventedParent(this),this.map=this.getSource().map=t,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(t,r,c){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((f,_)=>{if(f[_.key]="",!this._tiles[_.key]){const T=new fn(_,this._source.tileSize*_.overscaleFactor(),t.tileZoom);T.state="loaded",this._tiles[_.key]=T}return f},{});for(const f in this._tiles)f in d||(this.freeFBO(f),this._tiles[f].unloadVectorData(),delete this._tiles[f])}freeFBO(t){const r=this.proxyCachedFBO[t];if(void 0!==r){const c=Object.values(r);this.renderCachePool.push(...c),delete this.proxyCachedFBO[t]}}deallocRenderCache(){this.renderCache.forEach(t=>t.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class Ac extends s.aA{constructor(t,r,c){super(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y),this.proxyTileKey=r,this.projMatrix=c}}class Ic extends s.cE{constructor(t,r){super(),this._debugParams={sortTilesHiZFirst:!0,disableRenderCache:!1},t.tp.registerParameter(this._debugParams,["Terrain"],"sortTilesHiZFirst",{},()=>{this._style.map.triggerRepaint()}),t.tp.registerParameter(this._debugParams,["Terrain"],"disableRenderCache",{},()=>{this._style.map.triggerRepaint()}),t.tp.registerButton(["Terrain"],"Invalidate Render Cache",()=>{this.invalidateRenderCache=!0,this._style.map.triggerRepaint()}),this.painter=t,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[c,d,f]=function(){const A=new s.a_,I=new s.aO,z=131;A.reserve(17161),I.reserve(33800);const D=s.ab/128,L=s.ab+D/2,F=L+D;for(let V=-D;VL||V<0||V>L?24575:0,Y=s.ap(Math.round(U),0,s.ab),$=s.ap(Math.round(V),0,s.ab);A.emplaceBack(Y+W,$)}const N=(V,U)=>{const W=U*z+V;I.emplaceBack(W+1,W,W+z),I.emplaceBack(W+z,W+z+1,W+1)};for(let V=1;V<129;V++)for(let U=1;U<129;U++)N(U,V);return[0,129].forEach(V=>{for(let U=0;U<130;U++)N(U,V),N(V,U)}),[A,I,32768]}(),_=t.context;this.gridBuffer=_.createVertexBuffer(c,s.b0.members),this.gridIndexBuffer=_.createIndexBuffer(d),this.gridSegments=s.b1.simpleSegment(0,0,c.length,d.length),this.gridNoSkirtSegments=s.b1.simpleSegment(0,0,c.length,f),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new du(r.map),this.orthoMatrix=s.a6.mat4.create(),s.a6.mat4.ortho(this.orthoMatrix,"globe"===this.painter.transform.projection.name?.015:0,s.ab,0,s.ab,0,1);const T=_.gl;this._overlapStencilMode=new Et({func:T.GEQUAL,mask:255},0,255,T.KEEP,T.KEEP,T.REPLACE),this._previousZoom=t.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=r,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new fs(r.map),this._pendingGroundEffectLayers=[]}set style(t){t.on("data",this._onStyleDataEvent.bind(this)),this._style=t,this._style.map.on("moveend",()=>{this._clearLineLayersFromRenderCache()})}update(t,r,c){if(t&&t.terrain){this._style!==t&&(this.style=t,this._evaluationZoom=void 0);const d=t.terrain.properties,f=0===t.terrain.drapeRenderMode,_=t.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=s.q.now();const T=t.terrain&&t.terrain.scope,S=d.get("source"),A=f?this._mockSourceCache:t.getSourceCache(S,T);if(!A)return void s.w(`Couldn't find terrain source "${S}".`);if(this.sourceCache=A,this._exaggeration=_?this.calculateExaggeration(r):d.get("exaggeration"),!r.projection.requiresDraping&&_&&0===this._exaggeration)return void this._disable();this.enabled=!0;const I=()=>{this.sourceCache.used&&s.w(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source.\nThis leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const z=this.getScaledDemTileSize();this.sourceCache.update(r,z,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,I(),this._initializing=!0),I(),r.updateElevation(!0,c),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(r),this._emptyDEMTextureDirty=!0,this._previousZoom=r.zoom}else this._disable()}calculateExaggeration(t){const r=this._previousCameraAltitude,c=t.getFreeCameraOptions().position.z/t.pixelsPerMeter*t.worldSize;this._previousCameraAltitude=c;const d=null!=r?c-r:Number.MAX_VALUE;if(Math.abs(d)<2)return this._exaggeration;const f=t.zoom,_=this._style.terrain;if(!this._previousUpdateTimestamp)return _.getExaggeration(f);let T=f-this._previousZoom;const S=this._previousUpdateTimestamp;let A=f;null!=this._evaluationZoom&&(A=this._evaluationZoom,Math.abs(f-A)>.5&&(T=.5*(f-A+T)),T*d<0&&(A+=T)),this._evaluationZoom=A;const I=_.getExaggeration(A),z=I===_.getExaggeration(Math.max(0,A-.1));if(z&&Math.abs(I-this._exaggeration)<.01)return I;let D=Math.min(.1,.00375*(this._updateTimestamp-S));return(z||I<.1||Math.abs(T)<1e-4)&&(D=Math.min(.2,4*D)),s.aa(this._exaggeration,I,D)}resetTileLookupCache(t){this._findCoveringTileCache[t]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_onStyleDataEvent(t){t.coord&&"source"===t.dataType?this._clearRenderCacheForTile(t.sourceCacheId,t.coord):"style"===t.dataType&&(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 r=this.proxySourceCache,c=this.painter.transform;this._initializing&&(this._initializing=0===c._centerAltitude&&-1===this.getAtPointOrZero(s.a5.fromLngLat(c.center),-1),this._emptyDEMTextureDirty=!this._initializing);const d=this.proxyCoords=r.getIds().map(S=>{const A=r.getTileByID(S).tileID;return A.projMatrix=c.calculateProjMatrix(A.toUnwrapped()),A});!function(S,A){const I=A.transform.pointCoordinate(A.transform.getCameraPoint()),z=new s.P(I.x,I.y);S.sort((D,L)=>{if(L.overscaledZ-D.overscaledZ)return L.overscaledZ-D.overscaledZ;const F=new s.P(D.canonical.x+(1<{this.proxyToSource[S.key]={}}),this.terrainTileForTile={};const _=this._style._mergedSourceCaches;for(const S in _){const A=_[S];if(!A.used||(A!==this.sourceCache&&this.resetTileLookupCache(A.id),this._setupProxiedCoordsForOrtho(A,t[S],f),A.usedForTerrain))continue;const I=t[S];A.getSource().reparseOverscaled&&this._assignTerrainTiles(I)}this.proxiedCoords[r.id]=d.map(S=>new Ac(S,S.key,this.orthoMatrix)),this._assignTerrainTiles(d),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(f),this.renderingToTexture=!1;const T={};this._visibleDemTiles=[];for(const S of this.proxyCoords){const A=this.terrainTileForTile[S.key];if(!A)continue;const I=A.tileID.key;I in T||(this._visibleDemTiles.push(A),T[I]=I)}}_assignTerrainTiles(t){this._initializing||t.forEach(r=>{if(this.terrainTileForTile[r.key])return;const c=this._findTileCoveringTileID(r,this.sourceCache);c&&(this.terrainTileForTile[r.key]=c)})}_prepareDEMTextures(){const t=this.painter.context,r=t.gl;for(const c in this.terrainTileForTile){const d=this.terrainTileForTile[c],f=d.dem;!f||d.demTexture&&!d.needsDEMTextureUpload||(t.activeTexture.set(r.TEXTURE1),nl(this.painter,d,f))}}_prepareDemTileUniforms(t,r,c,d){if(!r||null==r.demTexture)return!1;const f=t.tileID.canonical,_=Math.pow(2,r.tileID.canonical.z-f.z),T=d||"";return c[`u_dem_tl${T}`]=[f.x*_%1,f.y*_%1],c[`u_dem_scale${T}`]=_,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}_getLoadedAreaMinimum(){if(!this.enabled)return 0;let t=0;const r=this._visibleDemTiles.reduce((c,d)=>{if(!d.dem)return c;const f=d.dem.tree.minimums[0];return f>0&&t++,c+f},0);return t?r/t:0}_updateEmptyDEMTexture(){const t=this.painter.context,r=t.gl;t.activeTexture.set(r.TEXTURE2);const c=this._getLoadedAreaMinimum(),d=new s.cF({width:1,height:1},new Float32Array([c]));this._emptyDEMTextureDirty=!1;let f=this._emptyDEMTexture;return f?f.update(d,{premultiply:!1}):f=this._emptyDEMTexture=new s.T(t,d,r.R32F,{premultiply:!1}),f}setupElevationDraw(t,r,c){const d=this.painter.context,f=d.gl,_={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};_.u_exaggeration=this.exaggeration();let T=null,S=null,A=1;if(c&&c.morphing&&this._useVertexMorphing){const L=c.morphing.srcDemTile,F=c.morphing.dstDemTile;A=c.morphing.phase,L&&F&&(this._prepareDemTileUniforms(t,L,_,"_prev")&&(S=L),this._prepareDemTileUniforms(t,F,_)&&(T=F))}const I=L=>L&&L.demTexture&&this.painter.linearFloatFilteringSupported()?f.LINEAR:f.NEAREST;let z=null;var D;if(this.enabled?S&&T?(z=T.demTexture,d.activeTexture.set(f.TEXTURE4),S.demTexture.bind(I(S),f.CLAMP_TO_EDGE),_.u_dem_lerp=A):(T=this.terrainTileForTile[t.tileID.key],z=this._prepareDemTileUniforms(t,T,_)?T.demTexture:this.emptyDEMTexture):z=this.emptyDEMTexture,d.activeTexture.set(f.TEXTURE2),z&&(_.u_dem_size=1===(D=z).size[0]?1:D.size[0]-2,z.bind(I(T),f.CLAMP_TO_EDGE)),this.painter.setupDepthForOcclusion(c&&c.useDepthForOcclusion,r,_),c&&c.useMeterToDem&&T){const L=(1<{if(U===Ie)return;const ke=[hu[Ie],"PROJECTION_GLOBE_VIEW"];Y&&ke.push("CUSTOM_ANTIALIASING");const Ae=A.isTileAffectedByFog(ye);V=A.getOrCreateProgram("globeRaster",{defines:ke,overrideFog:Ae}),U=Ie},Q=A.colorModeForRenderPass(),J=new dt(N.LEQUAL,dt.ReadWrite,A.depthRangeFor3D);ps.update(L);const ne=s.cy(W),ie=[s.am(W.center.lng),s.at(W.center.lat)],oe=A.globeSharedBuffers,de=[W.width*s.q.devicePixelRatio,W.height*s.q.devicePixelRatio],ce=Float32Array.from(W.globeMatrix),ae={useDenormalizedUpVectorScale:!0};{const ye=A.transform,Ie=uu(ye.zoom,I.exaggeration(),I.sourceCache._source.tileSize);U=-1;const ke=N.TRIANGLES;for(const Ae of D){const Ne=z.getTile(Ae),xe=Et.disabled,Re=I.prevTerrainTileForTile[Ae.key],ze=I.terrainTileForTile[Ae.key];cu(Re,ze)&&ps.newMorphing(Ae.key,Re,ze,L,250),F.activeTexture.set(N.TEXTURE0),Ne.texture&&Ne.texture.bind(N.LINEAR,N.CLAMP_TO_EDGE);const Ue=ps.getMorphValuesForProxy(Ae.key),Ge=Ue?1:0;Ue&&s.C(ae,{morphing:{srcDemTile:Ue.from,dstDemTile:Ue.to,phase:s.cw(Ue.phase)}});const Le=s.cz(Ae.canonical),Be=s.cA(Le.getCenter().lat),ht=s.cB(Ae.canonical,Le,Be,ye.worldSize/ye._pixelsPerMercatorPixel),Ze=s.b5(s.cC(Ae.canonical)),et=lu(ye.expandedFarZProjMatrix,ce,ne,Ze,s.a9(ye.zoom),ie,ye.frustumCorners.TL,ye.frustumCorners.TR,ye.frustumCorners.BR,ye.frustumCorners.BL,ye.globeCenterInViewSpace,ye.globeRadius,de,Ie,ye._farZ,ht);if($(Ae,Ge),V&&(I.setupElevationDraw(Ne,V,ae),A.uploadCommonUniforms(F,V,Ae.toUnwrapped()),oe)){const[_t,ot,pt]=oe.getGridBuffers(Be,0!==Ie);V.draw(A,ke,J,xe,Q,yt.backCCW,et,"globe_raster",_t,ot,pt)}}}if(oe&&(A.renderDefaultNorthPole||A.renderDefaultSouthPole)){const ye=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];Y&&ye.push("CUSTOM_ANTIALIASING"),V=A.getOrCreateProgram("globeRaster",{defines:ye});for(const Ie of D){const{x:ke,y:Ae,z:Ne}=Ie.canonical,xe=0===Ae,Re=Ae===(1<_t.draw(A,N.TRIANGLES,J,Et.disabled,Q,yt.disabled,lu(W.expandedFarZProjMatrix,ht,ht,Ze,0,ie,W.frustumCorners.TL,W.frustumCorners.TR,W.frustumCorners.BR,W.frustumCorners.BL,W.globeCenterInViewSpace,W.globeRadius,de,0,W._farZ),"globe_pole_raster",ot,Ge,Le);I.setupElevationDraw(Be,V,ae),A.uploadCommonUniforms(F,V,Ie.toUnwrapped()),xe&&A.renderDefaultNorthPole&&et(V,ze),Re&&A.renderDefaultSouthPole&&(ht=s.a6.mat4.scale(s.a6.mat4.create(),ht,[1,-1,1]),et(V,Ue))}}}}(d,f,_,T,S);else{const A=d.context,I=A.gl;let z,D;const L=d.shadowRenderer,F=Rn(d,d.longestCutoffRange),N=Q=>{if(D===Q)return;const J=[];J.push(hu[Q]),F.shouldRenderCutoff&&J.push("RENDER_CUTOFF"),z=d.getOrCreateProgram("terrainRaster",{defines:J}),D=Q},V=d.colorModeForRenderPass(),U=new dt(I.LEQUAL,dt.ReadWrite,d.depthRangeFor3D);ps.update(S);const W=d.transform,Y=uu(W.zoom,f.exaggeration(),f.sourceCache._source.tileSize);let $=[0,0,0];if(L){const Q=d.style.directionalLight,J=d.style.ambientLight;Q&&J&&($=Ka(d.style,Q,J))}{D=-1;const Q=I.TRIANGLES,[J,ne]=[f.gridIndexBuffer,f.gridSegments];for(const ie of T){const oe=_.getTile(ie),de=Et.disabled,ce=f.prevTerrainTileForTile[ie.key],ae=f.terrainTileForTile[ie.key];cu(ce,ae)&&ps.newMorphing(ie.key,ce,ae,S,250),A.activeTexture.set(I.TEXTURE0),oe.texture&&oe.texture.bind(I.LINEAR,I.CLAMP_TO_EDGE);const ye=ps.getMorphValuesForProxy(ie.key),Ie=ye?1:0;let ke;ye&&(ke={morphing:{srcDemTile:ye.from,dstDemTile:ye.to,phase:s.cw(ye.phase)}});const Ae=Bd(ie.projMatrix,Ec(ie.canonical,W.renderWorldCopies)?Y/10:Y,$);if(N(Ie),!z)continue;f.setupElevationDraw(oe,z,ke);const Ne=ie.toUnwrapped();L&&L.setupShadows(Ne,z),d.uploadCommonUniforms(A,z,Ne,null,F),z.draw(d,Q,U,de,V,yt.backCCW,Ae,"terrain_raster",f.gridBuffer,J,ne)}}}}(r,this,this.proxySourceCache,t,this._updateTimestamp),this.renderingToTexture=!0,r.gpuTimingDeferredRenderEnd(),t.splice(0,t.length))}renderBatch(t){if(0===this._drapedRenderBatches.length)return t+1;this.renderingToTexture=!0;const r=this.painter,c=this.painter.context,d=this.proxySourceCache,f=this.proxiedCoords[d.id],_=this._drapedRenderBatches.shift(),T=r.style.order,S=[];let A=0;for(const I of f){const z=d.getTileByID(I.proxyTileKey),D=d.proxyCachedFBO[I.key]?d.proxyCachedFBO[I.key][t]:void 0,L=void 0!==D?d.renderCache[D]:this.pool[A++],F=void 0!==D;if(z.texture=L.tex,F&&!L.dirty){S.push(z.tileID);continue}let N;c.bindFramebuffer.set(L.fb.framebuffer),this.renderedToTile=!1,L.dirty&&(c.clear({color:s.bz.transparent,stencil:0}),L.dirty=!1);for(let V=_.start;V<=_.end;++V){const U=r.style._mergedLayers[T[V]];if(U.isHidden(r.transform.zoom))continue;const W=r.style.getLayerSourceCache(U),Y=W?this.proxyToSource[I.key][W.id]:[I];if(!Y)continue;const $=Y;c.viewport.set([0,0,L.fb.width,L.fb.height]),N!==(W?W.id:null)&&(this._setupStencil(L,Y,U,W),N=W?W.id:null),r.renderLayer(r,W,U,$)}if(0===this._drapedRenderBatches.length)for(const V of this._pendingGroundEffectLayers){const U=r.style._mergedLayers[T[V]];if(U.isHidden(r.transform.zoom))continue;const W=r.style.getLayerSourceCache(U),Y=W?this.proxyToSource[I.key][W.id]:[I];if(!Y)continue;const $=Y;c.viewport.set([0,0,L.fb.width,L.fb.height]),N!==(W?W.id:null)&&(this._setupStencil(L,Y,U,W),N=W?W.id:null),r.renderLayer(r,W,U,$)}this.renderedToTile?(L.dirty=!0,S.push(z.tileID)):F||--A,5===A&&(A=0,this.renderToBackBuffer(S))}return this.renderToBackBuffer(S),this.renderingToTexture=!1,c.bindFramebuffer.set(null),c.viewport.set([0,0,r.width,r.height]),_.end+1}postRender(){}isLayerOrderingCorrect(t){const r=t.order.length;let c=-1,d=r;for(let f=0;fc}getMinElevationBelowMSL(){let t=0;return this._visibleDemTiles.filter(r=>r.dem).forEach(r=>{t=Math.min(t,r.dem.tree.minimums[0])}),0===t?t:(t-30)*this._exaggeration}raycast(t,r,c){if(!this._visibleDemTiles)return null;const d=this._visibleDemTiles.filter(f=>f.dem).map(f=>{const _=f.tileID,T=1<<_.overscaledZ,{x:S,y:A}=_.canonical,I=S/T,z=(S+1)/T,D=A/T,L=(A+1)/T;return{minx:I,miny:D,maxx:z,maxy:L,t:f.dem.tree.raycastRoot(I,D,z,L,t,r,c),tile:f}});d.sort((f,_)=>(null!==f.t?f.t:Number.MAX_VALUE)-(null!==_.t?_.t:Number.MAX_VALUE));for(const f of d){if(null==f.t)return null;const _=f.tile.dem.tree.raycast(f.minx,f.miny,f.maxx,f.maxy,t,r,c);if(null!=_)return _}return null}_createFBO(){const t=this.painter.context,r=t.gl,c=this.drapeBufferSize;t.activeTexture.set(r.TEXTURE0);const d=new s.T(t,{width:c[0],height:c[1],data:null},r.RGBA8);d.bind(r.LINEAR,r.CLAMP_TO_EDGE);const f=t.createFramebuffer(c[0],c[1],!0,null);return f.colorAttachment.set(d.texture),f.depthAttachment=new ds(t,f.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=t.createRenderbuffer(t.gl.DEPTH_STENCIL,c[0],c[1]),this._stencilRef=0,f.depthAttachment.set(this._sharedDepthStencil),t.clear({stencil:0})):f.depthAttachment.set(this._sharedDepthStencil),t.extTextureFilterAnisotropic&&r.texParameterf(r.TEXTURE_2D,t.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,t.extTextureFilterAnisotropicMax),{fb:f,tex:d,dirty:!1}}_initFBOPool(){for(;this.pool.length{const r=this._style._mergedLayers[t],c=r.isHidden(this.painter.transform.zoom);return"hillshade"===r.type||"custom"===r.type?!c&&r.shouldRedrape():!c&&r.hasTransition()})}_clearLineLayersFromRenderCache(){let t=!1;for(const c of this._style.getSources())if(c instanceof Fa){t=!0;break}if(!t)return;const r={};for(let c=0;cS>T.end)||s.w("fill-extrusion with flood lighting and/or ground ambient occlusion should be moved to be on top of all draped layers.")}this._drapedRenderBatches=c}_setupRenderCache(t){const r=this.proxySourceCache;if(this._shouldDisableRenderCache()||this.invalidateRenderCache){if(this.invalidateRenderCache=!1,r.renderCache.length>r.renderCachePool.length){const _=Object.values(r.proxyCachedFBO);r.proxyCachedFBO={};for(let T=0;T<_.length;++T){const S=Object.values(_[T]);r.renderCachePool.push(...S)}}return}this._clearRasterLayersFromRenderCache();const c=this.proxyCoords,d=this._tilesDirty;for(let _=c.length-1;_>=0;_--){const T=c[_];if(r.getTileByID(T.key),void 0!==r.proxyCachedFBO[T.key]){const S=t[T.key],A=this.proxyToSource[T.key];let I=0;for(const z in A){const D=A[z],L=S[z];if(!L||L.length!==D.length||D.some((F,N)=>F!==L[N]||d[z]&&d[z].hasOwnProperty(F.key))){I=-1;break}++I}for(const z in r.proxyCachedFBO[T.key])r.renderCache[r.proxyCachedFBO[T.key][z]].dirty=I<0||I!==Object.values(S).length}}const f=[...this._drapedRenderBatches];f.sort((_,T)=>T.end-T.start-(_.end-_.start));for(const _ of f)for(const T of c){if(r.proxyCachedFBO[T.key])continue;let S=r.renderCachePool.pop();void 0===S&&r.renderCache.length<50&&(S=r.renderCache.length,r.renderCache.push(this._createFBO())),void 0!==S&&(r.proxyCachedFBO[T.key]={},r.proxyCachedFBO[T.key][_.start]=S,r.renderCache[S].dirty=!0)}this._tilesDirty={}}_setupStencil(t,r,c,d){if(!d||!this._sourceTilesOverlap[d.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const f=this.painter.context,_=f.gl;if(r.length<=1)return void(this._overlapStencilType=!1);let T;if(c.isTileClipped())T=r.length,this._overlapStencilMode.test={func:_.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(r[0].overscaledZ>r[r.length-1].overscaledZ))return void(this._overlapStencilType=!1);T=1,this._overlapStencilMode.test={func:_.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+T>255&&(f.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=T,this._overlapStencilMode.ref=this._stencilRef,c.isTileClipped()&&this._renderTileClippingMasks(r,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return"Clip"===this._overlapStencilType||"Mask"===this._overlapStencilType}stencilModeForRTTOverlap(t){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[t.key]),this._overlapStencilMode):Et.disabled}_renderTileClippingMasks(t,r){const c=this.painter,d=this.painter.context,f=d.gl;c._tileClippingMaskIDs={},d.setColorMode(Zt.disabled),d.setDepthMode(dt.disabled);const _=c.getOrCreateProgram("clippingMask");for(const T of t){const S=c._tileClippingMaskIDs[T.key]=--r;_.draw(c,f.TRIANGLES,dt.disabled,new Et({func:f.ALWAYS,mask:0},S,255,f.KEEP,f.KEEP,f.REPLACE),Zt.disabled,yt.disabled,ha(T.projMatrix),"$clipping",c.tileExtentBuffer,c.quadTriangleIndexBuffer,c.tileExtentSegments)}}pointCoordinate(t){const r=this.painter.transform;if(t.x<0||t.x>r.width||t.y<0||t.y>r.height)return null;const c=[t.x,t.y,1,1];s.a6.vec4.transformMat4(c,c,r.pixelMatrixInverse),s.a6.vec4.scale(c,c,1/c[3]),c[0]/=r.worldSize,c[1]/=r.worldSize;const d=r._camera.position,f=s.bD(1,r.center.lat),_=[d[0],d[1],d[2]/f,0],T=s.a6.vec3.subtract([],c.slice(0,3),_);s.a6.vec3.normalize(T,T);const S=this.raycast(_,T,this._exaggeration);return null!==S&&S?(s.a6.vec3.scaleAndAdd(_,_,T,S),_[3]=_[2],_[2]*=f,_):null}_setupProxiedCoordsForOrtho(t,r,c){if(t.getSource()instanceof s.aD)return this._setupProxiedCoordsForImageSource(t,r,c);this._findCoveringTileCache[t.id]=this._findCoveringTileCache[t.id]||{};const d=this.proxiedCoords[t.id]=[],f=this.proxyCoords;for(let S=0;SI.overscaledZ-A.overscaledZ)}_setupProxiedCoordsForImageSource(t,r,c){if(!t.getSource().loaded())return;const d=this.proxiedCoords[t.id]=[],f=this.proxyCoords,_=t.getSource(),T=_.tileID;if(!T)return;const S=new s.P(T.x,T.y)._div(1<(z.min.x=Math.min(z.min.x,D.x-S.x),z.min.y=Math.min(z.min.y,D.y-S.y),z.max.x=Math.max(z.max.x,D.x-S.x),z.max.y=Math.max(z.max.y,D.y-S.y),z),{min:new s.P(Number.MAX_VALUE,Number.MAX_VALUE),max:new s.P(-Number.MAX_VALUE,-Number.MAX_VALUE)}),I=(z,D)=>{const L=z.wrap+z.canonical.x/(1<V+A.max.x||F+NU+A.max.y};for(let z=0;z_.key===r.tileID.key);if(f)return f}if(r.tileID.key!==t.key){const f=t.canonical.z-r.tileID.canonical.z;let _,T,S;d=s.a6.mat4.create();const A=r.tileID.wrap-t.wrap<0?(_=s.ab>>f,T=_*((r.tileID.canonical.x<=z){const D=t.canonical.z-z;r.getSource().reparseOverscaled?(T=Math.max(t.canonical.z+2,r.transform.tileZoom),_=new s.aA(T,t.wrap,z,t.canonical.x>>D,t.canonical.y>>D)):0!==D&&(T=z,_=new s.aA(T,t.wrap,z,t.canonical.x>>D,t.canonical.y>>D))}_.key!==t.key&&(A.push(_.key),c=r.getTile(_))}const I=z=>{A.forEach(D=>{d[D]=z}),A.length=0};for(T-=1;T>=S&&(!c||!c.hasData());T--){c&&I(c.tileID.key);const z=_.calculateScaledKey(T);if(c=r.getTileByID(z),c&&c.hasData())break;const D=d[z];if(null===D)break;void 0===D?A.push(z):c=r.getTileByID(D)}return I(c?c.tileID.key:null),c&&c.hasData()?c:null}findDEMTileFor(t){return this.enabled?this._findTileCoveringTileID(t,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(t,r){let c=this._tilesDirty[t];c||(c=this._tilesDirty[t]={}),c[r.key]=!0}}function Cc(l,t,r){const c=function(T,S,A){const I=s.a6.vec3.dot(S,T),z=s.a6.vec3.dot(A,[.2126,.7152,.0722]),D=(F,N,V)=>(1-V)*F+V*N,L=D(1-.3*Math.min(z,1),1,Math.min(I+1,1));return D(.92,1,Math.asin(s.ap(S[2],-1,1))/Math.PI+.5)*L}(l,[0,0,1],t),d=[0,0,0];s.a6.vec3.scale(d,r.slice(0,3),c);const f=[0,0,0];s.a6.vec3.scale(f,t.slice(0,3),l[2]);const _=[0,0,0];return s.a6.vec3.add(_,d,f),s.cb(_)}const Eo=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],pu=["stars","fillExtrusion","fillExtrusionGroundEffect","model","symbol"];class eo{static cacheKey(t,r,c,d){let f=`${r}${d?d.cacheKey:""}`;for(const _ of c)t.usedDefines.includes(_)&&(f+=`/${_}`);return f}constructor(t,r,c,d,f,_){const T=t.gl;this.program=T.createProgram(),this.configuration=d,this.name=r,this.fixedDefines=[..._];const S=d?d.getBinderAttributes():[],A=(c.staticAttributes||[]).concat(S);let I=d?d.defines():[];I=I.concat(_.map(V=>`#define ${V}`));const z="#version 300 es\n";let D=z+I.concat("precision mediump float;",il,ra.fragmentSource).join("\n");for(const V of c.fragmentIncludes)D+=`\n${ia[V]}`;D+=`\n${c.fragmentSource}`;let L=z+I.concat("precision highp float;",il,ra.vertexSource).join("\n");for(const V of c.vertexIncludes)L+=`\n${ia[V]}`;L+=`\n${c.vertexSource}`;const F=T.createShader(T.FRAGMENT_SHADER);if(T.isContextLost())return void(this.failedToCreate=!0);T.shaderSource(F,D),T.compileShader(F),T.attachShader(this.program,F);const N=T.createShader(T.VERTEX_SHADER);if(T.isContextLost())this.failedToCreate=!0;else{T.shaderSource(N,L),T.compileShader(N),T.attachShader(this.program,N),this.attributes={},this.numAttributes=A.length;for(let V=0;V({u_tile_tl_up:new s.bH(V),u_tile_tr_up:new s.bH(V),u_tile_br_up:new s.bH(V),u_tile_bl_up:new s.bH(V),u_tile_up_scale:new s.bI(V)}))(t)),_.includes("FOG")&&(this.fogUniforms=(V=>({u_fog_matrix:new s.bF(V),u_fog_range:new s.bG(V),u_fog_color:new s.c6(V),u_fog_horizon_blend:new s.bI(V),u_fog_vertical_limit:new s.bG(V),u_fog_temporal_offset:new s.bI(V),u_frustum_tl:new s.bH(V),u_frustum_tr:new s.bH(V),u_frustum_br:new s.bH(V),u_frustum_bl:new s.bH(V),u_globe_pos:new s.bH(V),u_globe_radius:new s.bI(V),u_globe_transition:new s.bI(V),u_is_globe:new s.bJ(V),u_viewport:new s.bG(V)}))(t)),_.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(V=>({u_cutoff_params:new s.c6(V)}))(t)),_.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(V=>({u_lighting_ambient_color:new s.bH(V),u_lighting_directional_dir:new s.bH(V),u_lighting_directional_color:new s.bH(V),u_ground_radiance:new s.bH(V)}))(t)),_.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(V=>({u_light_matrix_0:new s.bF(V),u_light_matrix_1:new s.bF(V),u_fade_range:new s.bG(V),u_shadow_normal_offset:new s.bH(V),u_shadow_intensity:new s.bI(V),u_shadow_texel_size:new s.bI(V),u_shadow_map_resolution:new s.bI(V),u_shadow_direction:new s.bH(V),u_shadow_bias:new s.bH(V),u_shadowmap_0:new s.bJ(V),u_shadowmap_1:new s.bJ(V)}))(t))}var V}setTerrainUniformValues(t,r){if(!this.terrainUniforms)return;const c=this.terrainUniforms;if(!this.failedToCreate){t.program.set(this.program);for(const d in r)c[d]&&c[d].set(this.program,d,r[d])}}setGlobeUniformValues(t,r){if(!this.globeUniforms)return;const c=this.globeUniforms;if(!this.failedToCreate){t.program.set(this.program);for(const d in r)c[d]&&c[d].set(this.program,d,r[d])}}setFogUniformValues(t,r){if(!this.fogUniforms)return;const c=this.fogUniforms;if(!this.failedToCreate){t.program.set(this.program);for(const d in r)c[d].set(this.program,d,r[d])}}setCutoffUniformValues(t,r){if(!this.cutoffUniforms)return;const c=this.cutoffUniforms;if(!this.failedToCreate){t.program.set(this.program);for(const d in r)c[d].set(this.program,d,r[d])}}setLightsUniformValues(t,r){if(!this.lightsUniforms)return;const c=this.lightsUniforms;if(!this.failedToCreate){t.program.set(this.program);for(const d in r)c[d].set(this.program,d,r[d])}}setShadowUniformValues(t,r){if(this.failedToCreate||!this.shadowUniforms)return;const c=this.shadowUniforms;t.program.set(this.program);for(const d in r)c[d].set(this.program,d,r[d])}_drawDebugWireframe(t,r,c,d,f,_,T,S,A,I){const z=t.options.wireframe;if(!1===z.terrain&&!1===z.layers2D&&!1===z.layers3D)return;const D=t.context;if(!(z.terrain&&("terrainRaster"===this.name||"globeRaster"===this.name)||!(!z.layers2D||t._terrain&&t._terrain.renderingToTexture)&&Eo.includes(this.name)||z.layers3D&&pu.includes(this.name)))return;const L=D.gl,F=t.wireframeDebugCache.getLinesFromTrianglesBuffer(t.frameCounter,f,D);if(!F)return;const N=[...this.fixedDefines];N.push("DEBUG_WIREFRAME");const V=t.getOrCreateProgram(this.name,{config:this.configuration,defines:N});D.program.set(V.program);const U=($,Q,J)=>{if(Q[$]&&J[$])for(const ne in Q[$])J[$][ne]&&J[$][ne].set(J.program,ne,Q[$][ne].current)};A&&A.setUniforms(V.program,D,V.binderUniforms,T,{zoom:S}),U("fixedUniforms",this,V),U("terrainUniforms",this,V),U("globeUniforms",this,V),U("fogUniforms",this,V),U("lightsUniforms",this,V),U("shadowUniforms",this,V),F.bind(),D.setColorMode(new Zt([L.ONE,L.ONE_MINUS_SRC_ALPHA,L.ZERO,L.ONE],s.bz.transparent,[!0,!0,!0,!1])),D.setDepthMode(new dt(r.func===L.LESS?L.LEQUAL:r.func,dt.ReadOnly,r.range)),D.setStencilMode(Et.disabled);const W=3*_.primitiveLength*2,Y=3*_.primitiveOffset*2*2;I&&I>1?L.drawElementsInstanced(L.LINES,W,L.UNSIGNED_SHORT,Y,I):L.drawElements(L.LINES,W,L.UNSIGNED_SHORT,Y),f.bind(),D.program.set(this.program),D.setDepthMode(r),D.setStencilMode(c),D.setColorMode(d)}draw(t,r,c,d,f,_,T,S,A,I,z,D,L,F,N,V){const U=t.context,W=U.gl;if(this.failedToCreate)return;U.program.set(this.program),U.setDepthMode(c),U.setStencilMode(d),U.setColorMode(f),U.setCullFace(_);for(const Q of Object.keys(this.fixedUniforms))this.fixedUniforms[Q].set(this.program,Q,T[Q]);F&&F.setUniforms(this.program,U,this.binderUniforms,D,{zoom:L});const Y={[W.POINTS]:1,[W.LINES]:2,[W.TRIANGLES]:3,[W.LINE_STRIP]:1}[r],$=V&&V>0?1:void 0;for(const Q of z.get()){const J=Q.vaos||(Q.vaos={});(J[S]||(J[S]=new hs)).bind(U,this,A,F?F.getPaintVertexBuffers():[],I,Q.vertexOffset,N||[],$),V&&V>1?W.drawElementsInstanced(r,Q.primitiveLength*Y,W.UNSIGNED_SHORT,Q.primitiveOffset*Y*2,V):I?W.drawElements(r,Q.primitiveLength*Y,W.UNSIGNED_SHORT,Q.primitiveOffset*Y*2):W.drawArrays(r,Q.vertexOffset,Q.vertexLength),r===W.TRIANGLES&&I&&this._drawDebugWireframe(t,c,d,f,I,Q,D,L,F,V)}}}function Pc(l,t){const r=Math.pow(2,t.tileID.overscaledZ),c=t.tileSize*Math.pow(2,l.transform.tileZoom)/r,d=c*(t.tileID.canonical.x+t.tileID.wrap*r),f=c*t.tileID.canonical.y;return{u_image:0,u_texsize:t.imageAtlasTexture?t.imageAtlasTexture.size:[0,0],u_tile_units_to_pixels:1/s.ak(t,1,l.transform.tileZoom),u_pixel_coord_upper:[d>>16,f>>16],u_pixel_coord_lower:[65535&d,65535&f]}}const ul=s.a6.mat4.create(),zc=(l,t,r,c,d,f,_,T,S,A,I,z,D,L,F,N)=>{const V=t.style.light,U=V.properties.get("position"),W=[U.x,U.y,U.z],Y=s.a6.mat3.create();"viewport"===V.properties.get("anchor")&&(s.a6.mat3.fromRotation(Y,-t.transform.angle),s.a6.vec3.transformMat3(W,W,Y));const $=V.properties.get("color"),Q=t.transform,J={u_matrix:l,u_lightpos:W,u_lightintensity:V.properties.get("intensity"),u_lightcolor:[$.r,$.g,$.b],u_vertical_gradient:+r,u_opacity:c,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:ul,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_ao:d,u_edge_radius:f,u_width_scale:_,u_flood_light_color:D,u_vertical_scale:L,u_flood_light_intensity:F,u_ground_shadow_factor:N};return"globe"===Q.projection.name&&(J.u_tile_id=[T.canonical.x,T.canonical.y,1<({u_matrix:l,u_edge_radius:t,u_width_scale:r,u_vertical_scale:c}),Dc=(l,t,r,c,d,f,_,T,S,A,I,z,D,L,F)=>{const N=zc(l,t,r,c,d,f,_,T,A,I,z,D,L,F,1,[0,0,0]),V={u_height_factor:-Math.pow(2,T.overscaledZ)/S.tileSize/8};return s.l(N,Pc(t,S),V)},dl=(l,t)=>({u_matrix:l,u_emissive_strength:t}),mu=(l,t,r,c)=>s.l(dl(l,t),Pc(r,c)),_u=(l,t,r)=>({u_matrix:l,u_world:r,u_emissive_strength:t}),ua=(l,t,r,c,d)=>s.l(mu(l,t,r,c),{u_world:d}),Fd=(l,t,r,c)=>{const d=s.ab/r.tileSize;return{u_matrix:l,u_camera_to_center_distance:t.getCameraToCenterDistance(c),u_extrude_scale:[t.pixelsToGLUnits[0]/d,t.pixelsToGLUnits[1]/d]}},gu=(l,t,r=1)=>({u_matrix:l,u_color:t.toRenderColor(null),u_overlay:0,u_overlay_scale:r}),yu=s.a6.mat4.create(),Nd=(l,t,r,c,d,f,_)=>{const T=l.transform,S="globe"===T.projection.name,A=S?s.cI(T.zoom,t.canonical)*T._pixelsPerMercatorPixel:s.ak(r,1,f),I={u_matrix:t.projMatrix,u_extrude_scale:A,u_intensity:_,u_inv_rot_matrix:yu,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(S){I.u_inv_rot_matrix=c,I.u_merc_center=d,I.u_tile_id=[t.canonical.x,t.canonical.y,1<({u_matrix:l,u_normalize_matrix:t,u_globe_matrix:r,u_merc_matrix:c,u_grid_matrix:d,u_tl_parent:f,u_scale_parent:A,u_fade_t:I.mix,u_opacity:I.opacity*z.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:z.paint.get("raster-brightness-min"),u_brightness_high:z.paint.get("raster-brightness-max"),u_saturation_factor:s.cJ(z.paint.get("raster-saturation")),u_contrast_factor:s.cK(z.paint.get("raster-contrast")),u_spin_weights:Rc(z.paint.get("raster-hue-rotate")),u_perspective_transform:D,u_raster_elevation:L,u_zoom_transition:_,u_merc_center:T,u_cutoff_params:S,u_colorization_mix:pl(s.cL,N,U),u_colorization_offset:fl(s.cL,V,U),u_color_ramp:F,u_texture_offset:[Y/(W+2*Y),W/(W+2*Y)],u_texture_res:[W+2*Y,W+2*Y],u_emissive_strength:$});function Rc(l){l*=Math.PI/180;const t=Math.sin(l),r=Math.cos(l);return[(2*r+1)/3,(-Math.sqrt(3)*t-r+1)/3,(Math.sqrt(3)*t-r+1)/3]}const gn=.05,xu=(l,t,r,c,d,f,_,T,S,A,I,z)=>({u_matrix:l,u_normalize_matrix:t,u_globe_matrix:r,u_merc_matrix:c,u_grid_matrix:d,u_tl_parent:f,u_scale_parent:A,u_fade_t:I.mix,u_opacity:I.opacity,u_image0:0,u_image1:1,u_raster_elevation:z,u_zoom_transition:_,u_merc_center:T,u_cutoff_params:S}),ml=(l,t,r,c,d,f,_,T,S,A)=>({u_particle_texture:l,u_particle_texture_side_len:t,u_tile_offset:r,u_velocity:c,u_color_ramp:f,u_velocity_res:d,u_max_speed:_,u_uv_offset:T,u_data_scale:[255*S[0],255*S[1]],u_data_offset:A,u_particle_pos_scale:1.1,u_particle_pos_offset:[gn,gn]}),_l=(l,t,r,c,d,f,_,T,S,A)=>({u_particle_texture:l,u_particle_texture_side_len:t,u_velocity:r,u_velocity_res:c,u_max_speed:d,u_speed_factor:f,u_reset_rate:_,u_rand_seed:Math.random(),u_uv_offset:T,u_data_scale:[255*S[0],255*S[1]],u_data_offset:A,u_particle_pos_scale:1.1,u_particle_pos_offset:[gn,gn]}),gl=s.a6.mat4.create(),Lc=(l,t,r,c,d,f,_,T,S,A,I,z,D,L,F,N,V,U,W,Y,$)=>{const Q=d.transform,J={u_is_size_zoom_constant:+("constant"===l||"source"===l),u_is_size_feature_constant:+("constant"===l||"camera"===l),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:Q.getCameraToCenterDistance(W),u_rotate_symbol:+r,u_aspect_ratio:Q.width/Q.height,u_fade_change:d.options.fadeDuration?d.symbolFadeChange:1,u_matrix:f,u_label_plane_matrix:_,u_coord_matrix:T,u_is_text:+A,u_elevation_from_sea:S?1:0,u_pitch_with_map:+c,u_texsize:I,u_texsize_icon:z,u_texture:0,u_texture_icon:1,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:gl,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:gl,u_up_vector:[0,-1,0],u_color_adj_mat:Y,u_icon_transition:$||0,u_gamma_scale:c?d.transform.getCameraToCenterDistance(W)*Math.cos(d.terrain?0:d.transform._pitch):1,u_device_pixel_ratio:s.q.devicePixelRatio,u_is_halo:+D};return"globe"===W.name&&(J.u_tile_id=[L.canonical.x,L.canonical.y,1<({u_matrix:l,u_emissive_strength:t,u_opacity:r,u_color:c}),Ao=(l,t,r,c,d,f,_,T,S)=>s.l(function(A,I,z,D,L,F){const{width:N,height:V}=D.imageManager.getPixelSize(I),U=Math.pow(2,F.tileID.overscaledZ),W=F.tileSize*Math.pow(2,D.transform.tileZoom)/U,Y=W*(F.tileID.canonical.x+F.tileID.wrap*U),$=W*F.tileID.canonical.y;return{u_image:0,u_pattern_tl:z.tl,u_pattern_br:z.br,u_texsize:[N,V],u_pattern_size:z.displaySize,u_pattern_units_to_pixels:L?[D.transform.width,-1*D.transform.height]:[1/s.ak(F,1,D.transform.tileZoom),1/s.ak(F,1,D.transform.tileZoom)],u_pixel_coord_upper:[Y>>16,$>>16],u_pixel_coord_lower:[65535&Y,65535&$]}}(0,f,_,c,T,S),{u_matrix:l,u_emissive_strength:t,u_opacity:r}),ms=new Float32Array(s.a6.mat4.identity([])),rt=(l,t,r,c,d,f,_,T,S,A,I,z,D,L=[0,0,0],F)=>{const N=d.style.light,V=N.properties.get("position"),U=[-V.x,-V.y,V.z],W=s.a6.mat3.create();"viewport"===N.properties.get("anchor")&&(s.a6.mat3.fromRotation(W,-d.transform.angle),s.a6.vec3.transformMat3(U,U,W));const Y="MASK"===I.alphaMode,$=N.properties.get("color").toRenderColor(null),Q=D.paint.get("model-ambient-occlusion-intensity"),J=D.paint.get("model-color").constantOr(s.bz.white).toRenderColor(null),ne=D.paint.get("model-color-mix-intensity").constantOr(0);return{u_matrix:l,u_lighting_matrix:t,u_normal_matrix:r,u_node_matrix:c||ms,u_lightpos:U,u_lightintensity:N.properties.get("intensity"),u_lightcolor:[$.r,$.g,$.b],u_camera_pos:L,u_opacity:f,u_baseTextureIsAlpha:0,u_alphaMask:+Y,u_alphaCutoff:I.alphaCutoff,u_baseColorFactor:[_.r,_.g,_.b,_.a],u_emissiveFactor:[T[0],T[1],T[2],1],u_metallicFactor:S,u_roughnessFactor:A,u_baseColorTexture:5,u_metallicRoughnessTexture:6,u_normalTexture:7,u_occlusionTexture:8,u_emissionTexture:9,u_lutTexture:10,u_color_mix:[J.r,J.g,J.b,ne],u_aoIntensity:Q,u_emissive_strength:z,u_occlusionTextureTransform:F||[0,0,0,0]}},kc=(l,t=ms,r=ms)=>({u_matrix:l,u_instance:t,u_node_matrix:r}),bu={fillExtrusion:l=>({u_matrix:new s.bF(l),u_lightpos:new s.bH(l),u_lightintensity:new s.bI(l),u_lightcolor:new s.bH(l),u_vertical_gradient:new s.bI(l),u_opacity:new s.bI(l),u_edge_radius:new s.bI(l),u_width_scale:new s.bI(l),u_ao:new s.bG(l),u_tile_id:new s.bH(l),u_zoom_transition:new s.bI(l),u_inv_rot_matrix:new s.bF(l),u_merc_center:new s.bG(l),u_up_dir:new s.bH(l),u_height_lift:new s.bI(l),u_flood_light_color:new s.bH(l),u_vertical_scale:new s.bI(l),u_flood_light_intensity:new s.bI(l),u_ground_shadow_factor:new s.bH(l)}),fillExtrusionDepth:l=>({u_matrix:new s.bF(l),u_edge_radius:new s.bI(l),u_width_scale:new s.bI(l),u_vertical_scale:new s.bI(l)}),fillExtrusionPattern:l=>({u_matrix:new s.bF(l),u_lightpos:new s.bH(l),u_lightintensity:new s.bI(l),u_lightcolor:new s.bH(l),u_vertical_gradient:new s.bI(l),u_height_factor:new s.bI(l),u_edge_radius:new s.bI(l),u_width_scale:new s.bI(l),u_ao:new s.bG(l),u_tile_id:new s.bH(l),u_zoom_transition:new s.bI(l),u_inv_rot_matrix:new s.bF(l),u_merc_center:new s.bG(l),u_up_dir:new s.bH(l),u_height_lift:new s.bI(l),u_image:new s.bJ(l),u_texsize:new s.bG(l),u_pixel_coord_upper:new s.bG(l),u_pixel_coord_lower:new s.bG(l),u_tile_units_to_pixels:new s.bI(l),u_opacity:new s.bI(l)}),fillExtrusionGroundEffect:l=>({u_matrix:new s.bF(l),u_opacity:new s.bI(l),u_ao_pass:new s.bI(l),u_meter_to_tile:new s.bI(l),u_ao:new s.bG(l),u_flood_light_intensity:new s.bI(l),u_flood_light_color:new s.bH(l),u_attenuation:new s.bI(l),u_edge_radius:new s.bI(l),u_fb:new s.bJ(l),u_fb_size:new s.bI(l),u_dynamic_offset:new s.bI(l)}),fill:l=>({u_matrix:new s.bF(l),u_emissive_strength:new s.bI(l)}),fillPattern:l=>({u_matrix:new s.bF(l),u_emissive_strength:new s.bI(l),u_image:new s.bJ(l),u_texsize:new s.bG(l),u_pixel_coord_upper:new s.bG(l),u_pixel_coord_lower:new s.bG(l),u_tile_units_to_pixels:new s.bI(l)}),fillOutline:l=>({u_matrix:new s.bF(l),u_emissive_strength:new s.bI(l),u_world:new s.bG(l)}),fillOutlinePattern:l=>({u_matrix:new s.bF(l),u_emissive_strength:new s.bI(l),u_world:new s.bG(l),u_image:new s.bJ(l),u_texsize:new s.bG(l),u_pixel_coord_upper:new s.bG(l),u_pixel_coord_lower:new s.bG(l),u_tile_units_to_pixels:new s.bI(l)}),circle:s.cN,collisionBox:l=>({u_matrix:new s.bF(l),u_camera_to_center_distance:new s.bI(l),u_extrude_scale:new s.bG(l)}),collisionCircle:l=>({u_matrix:new s.bF(l),u_inv_matrix:new s.bF(l),u_camera_to_center_distance:new s.bI(l),u_viewport_size:new s.bG(l)}),debug:l=>({u_color:new s.cu(l),u_matrix:new s.bF(l),u_overlay:new s.bJ(l),u_overlay_scale:new s.bI(l)}),clippingMask:l=>({u_matrix:new s.bF(l)}),heatmap:l=>({u_extrude_scale:new s.bI(l),u_intensity:new s.bI(l),u_matrix:new s.bF(l),u_inv_rot_matrix:new s.bF(l),u_merc_center:new s.bG(l),u_tile_id:new s.bH(l),u_zoom_transition:new s.bI(l),u_up_dir:new s.bH(l)}),heatmapTexture:l=>({u_image:new s.bJ(l),u_color_ramp:new s.bJ(l),u_opacity:new s.bI(l)}),hillshade:l=>({u_matrix:new s.bF(l),u_image:new s.bJ(l),u_latrange:new s.bG(l),u_light:new s.bG(l),u_shadow:new s.cu(l),u_highlight:new s.cu(l),u_emissive_strength:new s.bI(l),u_accent:new s.cu(l)}),hillshadePrepare:l=>({u_matrix:new s.bF(l),u_image:new s.bJ(l),u_dimension:new s.bG(l),u_zoom:new s.bI(l)}),line:s.cO,linePattern:s.cP,raster:l=>({u_matrix:new s.bF(l),u_normalize_matrix:new s.bF(l),u_globe_matrix:new s.bF(l),u_merc_matrix:new s.bF(l),u_grid_matrix:new s.cv(l),u_tl_parent:new s.bG(l),u_scale_parent:new s.bI(l),u_fade_t:new s.bI(l),u_opacity:new s.bI(l),u_image0:new s.bJ(l),u_image1:new s.bJ(l),u_brightness_low:new s.bI(l),u_brightness_high:new s.bI(l),u_saturation_factor:new s.bI(l),u_contrast_factor:new s.bI(l),u_spin_weights:new s.bH(l),u_perspective_transform:new s.bG(l),u_raster_elevation:new s.bI(l),u_zoom_transition:new s.bI(l),u_merc_center:new s.bG(l),u_cutoff_params:new s.c6(l),u_colorization_mix:new s.c6(l),u_colorization_offset:new s.bI(l),u_color_ramp:new s.bJ(l),u_texture_offset:new s.bG(l),u_texture_res:new s.bG(l),u_emissive_strength:new s.bI(l)}),rasterParticle:l=>({u_matrix:new s.bF(l),u_normalize_matrix:new s.bF(l),u_globe_matrix:new s.bF(l),u_merc_matrix:new s.bF(l),u_grid_matrix:new s.cv(l),u_tl_parent:new s.bG(l),u_scale_parent:new s.bI(l),u_fade_t:new s.bI(l),u_opacity:new s.bI(l),u_image0:new s.bJ(l),u_image1:new s.bJ(l),u_raster_elevation:new s.bI(l),u_zoom_transition:new s.bI(l),u_merc_center:new s.bG(l),u_cutoff_params:new s.c6(l)}),rasterParticleTexture:l=>({u_texture:new s.bJ(l),u_opacity:new s.bI(l)}),rasterParticleDraw:l=>({u_particle_texture:new s.bJ(l),u_particle_texture_side_len:new s.bI(l),u_tile_offset:new s.bG(l),u_velocity:new s.bJ(l),u_color_ramp:new s.bJ(l),u_velocity_res:new s.bG(l),u_max_speed:new s.bI(l),u_uv_offset:new s.bG(l),u_data_scale:new s.bG(l),u_data_offset:new s.bI(l),u_particle_pos_scale:new s.bI(l),u_particle_pos_offset:new s.bG(l)}),rasterParticleUpdate:l=>({u_particle_texture:new s.bJ(l),u_particle_texture_side_len:new s.bI(l),u_velocity:new s.bJ(l),u_velocity_res:new s.bG(l),u_max_speed:new s.bI(l),u_speed_factor:new s.bI(l),u_reset_rate:new s.bI(l),u_rand_seed:new s.bI(l),u_uv_offset:new s.bG(l),u_data_scale:new s.bG(l),u_data_offset:new s.bI(l),u_particle_pos_scale:new s.bI(l),u_particle_pos_offset:new s.bG(l)}),symbol:l=>({u_is_size_zoom_constant:new s.bJ(l),u_is_size_feature_constant:new s.bJ(l),u_size_t:new s.bI(l),u_size:new s.bI(l),u_camera_to_center_distance:new s.bI(l),u_rotate_symbol:new s.bJ(l),u_aspect_ratio:new s.bI(l),u_fade_change:new s.bI(l),u_matrix:new s.bF(l),u_label_plane_matrix:new s.bF(l),u_coord_matrix:new s.bF(l),u_is_text:new s.bJ(l),u_elevation_from_sea:new s.bJ(l),u_pitch_with_map:new s.bJ(l),u_texsize:new s.bG(l),u_texsize_icon:new s.bG(l),u_texture:new s.bJ(l),u_texture_icon:new s.bJ(l),u_gamma_scale:new s.bI(l),u_device_pixel_ratio:new s.bI(l),u_tile_id:new s.bH(l),u_zoom_transition:new s.bI(l),u_inv_rot_matrix:new s.bF(l),u_merc_center:new s.bG(l),u_camera_forward:new s.bH(l),u_tile_matrix:new s.bF(l),u_up_vector:new s.bH(l),u_ecef_origin:new s.bH(l),u_is_halo:new s.bJ(l),u_icon_transition:new s.bI(l),u_color_adj_mat:new s.bF(l)}),background:l=>({u_matrix:new s.bF(l),u_emissive_strength:new s.bI(l),u_opacity:new s.bI(l),u_color:new s.cu(l)}),backgroundPattern:l=>({u_matrix:new s.bF(l),u_emissive_strength:new s.bI(l),u_opacity:new s.bI(l),u_image:new s.bJ(l),u_pattern_tl:new s.bG(l),u_pattern_br:new s.bG(l),u_texsize:new s.bG(l),u_pattern_size:new s.bG(l),u_pixel_coord_upper:new s.bG(l),u_pixel_coord_lower:new s.bG(l),u_pattern_units_to_pixels:new s.bG(l)}),terrainRaster:l=>({u_matrix:new s.bF(l),u_image0:new s.bJ(l),u_skirt_height:new s.bI(l),u_ground_shadow_factor:new s.bH(l)}),skybox:l=>({u_matrix:new s.bF(l),u_sun_direction:new s.bH(l),u_cubemap:new s.bJ(l),u_opacity:new s.bI(l),u_temporal_offset:new s.bI(l)}),skyboxGradient:l=>({u_matrix:new s.bF(l),u_color_ramp:new s.bJ(l),u_center_direction:new s.bH(l),u_radius:new s.bI(l),u_opacity:new s.bI(l),u_temporal_offset:new s.bI(l)}),skyboxCapture:l=>({u_matrix_3f:new s.cv(l),u_sun_direction:new s.bH(l),u_sun_intensity:new s.bI(l),u_color_tint_r:new s.c6(l),u_color_tint_m:new s.c6(l),u_luminance:new s.bI(l)}),globeRaster:l=>({u_proj_matrix:new s.bF(l),u_globe_matrix:new s.bF(l),u_normalize_matrix:new s.bF(l),u_merc_matrix:new s.bF(l),u_zoom_transition:new s.bI(l),u_merc_center:new s.bG(l),u_image0:new s.bJ(l),u_grid_matrix:new s.cv(l),u_skirt_height:new s.bI(l),u_far_z_cutoff:new s.bI(l),u_frustum_tl:new s.bH(l),u_frustum_tr:new s.bH(l),u_frustum_br:new s.bH(l),u_frustum_bl:new s.bH(l),u_globe_pos:new s.bH(l),u_globe_radius:new s.bI(l),u_viewport:new s.bG(l)}),globeAtmosphere:l=>({u_frustum_tl:new s.bH(l),u_frustum_tr:new s.bH(l),u_frustum_br:new s.bH(l),u_frustum_bl:new s.bH(l),u_horizon:new s.bI(l),u_transition:new s.bI(l),u_fadeout_range:new s.bI(l),u_color:new s.c6(l),u_high_color:new s.c6(l),u_space_color:new s.c6(l),u_temporal_offset:new s.bI(l),u_horizon_angle:new s.bI(l)}),model:l=>({u_matrix:new s.bF(l),u_lighting_matrix:new s.bF(l),u_normal_matrix:new s.bF(l),u_node_matrix:new s.bF(l),u_lightpos:new s.bH(l),u_lightintensity:new s.bI(l),u_lightcolor:new s.bH(l),u_camera_pos:new s.bH(l),u_opacity:new s.bI(l),u_baseColorFactor:new s.c6(l),u_emissiveFactor:new s.c6(l),u_metallicFactor:new s.bI(l),u_roughnessFactor:new s.bI(l),u_baseTextureIsAlpha:new s.bJ(l),u_alphaMask:new s.bJ(l),u_alphaCutoff:new s.bI(l),u_baseColorTexture:new s.bJ(l),u_metallicRoughnessTexture:new s.bJ(l),u_normalTexture:new s.bJ(l),u_occlusionTexture:new s.bJ(l),u_emissionTexture:new s.bJ(l),u_lutTexture:new s.bJ(l),u_color_mix:new s.c6(l),u_aoIntensity:new s.bI(l),u_emissive_strength:new s.bI(l),u_occlusionTextureTransform:new s.c6(l)}),modelDepth:l=>({u_matrix:new s.bF(l),u_instance:new s.bF(l),u_node_matrix:new s.bF(l)}),groundShadow:l=>({u_matrix:new s.bF(l),u_ground_shadow_factor:new s.bH(l)}),stars:l=>({u_matrix:new s.bF(l),u_up:new s.bH(l),u_right:new s.bH(l),u_intensity_multiplier:new s.bI(l)}),occlusion:l=>({u_matrix:new s.bF(l),u_anchorPos:new s.bH(l),u_screenSizePx:new s.bG(l),u_occluderSizePx:new s.bG(l),u_color:new s.c6(l)})};class Pr{constructor(t,r,c,d){this.id=Pr.uniqueIdxCounter,Pr.uniqueIdxCounter++,this.context=t;const f=t.gl;this.buffer=f.createBuffer(),this.dynamicDraw=!!c,this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),f.bufferData(f.ELEMENT_ARRAY_BUFFER,r.arrayBuffer,this.dynamicDraw?f.DYNAMIC_DRAW:f.STATIC_DRAW),this.dynamicDraw||d||r.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(t){this.id=Pr.uniqueIdxCounter,Pr.uniqueIdxCounter++;const r=this.context.gl;this.context.unbindVAO(),this.bind(),r.bufferSubData(r.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}Pr.uniqueIdxCounter=0;const Io={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class at{constructor(t,r,c,d,f,_){this.length=r.length,this.attributes=c,this.itemSize=r.bytesPerElement,this.dynamicDraw=d,this.instanceCount=_,this.context=t;const T=t.gl;this.buffer=T.createBuffer(),t.bindVertexBuffer.set(this.buffer),T.bufferData(T.ARRAY_BUFFER,r.arrayBuffer,this.dynamicDraw?T.DYNAMIC_DRAW:T.STATIC_DRAW),this.dynamicDraw||f||r.destroy()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(t){const r=this.context.gl;this.bind(),r.bufferSubData(r.ARRAY_BUFFER,0,t.arrayBuffer)}enableAttributes(t,r){for(let c=0;c0&&t.vertexAttribDivisor(f,c)}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class yl{constructor(t,r,c,d,f){this.context=t,this.width=r,this.height=c;const _=this.framebuffer=t.gl.createFramebuffer();d&&(this.colorAttachment=new cl(t,_)),f&&(this.depthAttachmentType=f,this.depthAttachment="renderbuffer"===f?new Sc(t,_):new au(t,_))}destroy(){const t=this.context.gl;if(this.colorAttachment){const r=this.colorAttachment.get();r&&t.deleteTexture(r)}if(this.depthAttachment&&this.depthAttachmentType)if("renderbuffer"===this.depthAttachmentType){const r=this.depthAttachment.get();r&&t.deleteRenderbuffer(r)}else{const r=this.depthAttachment.get();r&&t.deleteTexture(r)}t.deleteFramebuffer(this.framebuffer)}}class Vd{constructor(t,r){this.gl=t,this.clearColor=new mc(this),this.clearDepth=new Qh(this),this.clearStencil=new _c(this),this.colorMask=new ol(this),this.depthMask=new sa(this),this.stencilMask=new eu(this),this.stencilFunc=new tu(this),this.stencilOp=new iu(this),this.stencilTest=new us(this),this.depthRange=new ru(this),this.depthTest=new Rd(this),this.depthFunc=new Ld(this),this.blend=new kd(this),this.blendFunc=new gc(this),this.blendColor=new yc(this),this.blendEquation=new xc(this),this.cullFace=new vc(this),this.cullFaceSide=new nu(this),this.frontFace=new ou(this),this.program=new Od(this),this.activeTexture=new aa(this),this.viewport=new la(this),this.bindFramebuffer=new su(this),this.bindRenderbuffer=new Nr(this),this.bindTexture=new bc(this),this.bindVertexBuffer=new sl(this),this.bindElementBuffer=new al(this),this.bindVertexArrayOES=new wc(this),this.pixelStoreUnpack=new Tc(this),this.pixelStoreUnpackPremultiplyAlpha=new ll(this),this.pixelStoreUnpackFlipY=new Mc(this),this.options=r?{...r}:{},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.options.extTextureFloatLinearForceOff||(this.extTextureFloatLinear=t.getExtension("OES_texture_float_linear")),this.extRenderToTextureHalfFloat=t.getExtension("EXT_color_buffer_half_float"),this.extTimerQuery=t.getExtension("EXT_disjoint_timer_query_webgl2"),this.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE),this.maxPointSize=t.getParameter(t.ALIASED_POINT_SIZE_RANGE)[1]}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,r,c){return new Pr(this,t,r,c)}createVertexBuffer(t,r,c,d,f){return new at(this,t,r,c,d,f)}createRenderbuffer(t,r,c){const d=this.gl,f=d.createRenderbuffer();return this.bindRenderbuffer.set(f),d.renderbufferStorage(d.RENDERBUFFER,t,r,c),this.bindRenderbuffer.set(null),f}createFramebuffer(t,r,c,d){return new yl(this,t,r,c,d)}clear({color:t,depth:r,stencil:c,colorMask:d}){const f=this.gl;let _=0;t&&(_|=f.COLOR_BUFFER_BIT,this.clearColor.set(t),this.colorMask.set(d||[!0,!0,!0,!0])),void 0!==r&&(_|=f.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(r),this.depthMask.set(!0)),void 0!==c&&(_|=f.STENCIL_BUFFER_BIT,this.clearStencil.set(c),this.stencilMask.set(255)),f.clear(_)}setCullFace(t){!1===t.enable?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){s.bh(t.blendFunction,Zt.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 xl;function vl(l,t,r,c,d,f,_){const T=l.context,S=T.gl,A=l.transform,I=l.getOrCreateProgram("collisionBox"),z=[];let D=0,L=0;for(let $=0;$0){const ae=s.a6.mat4.create(),ye=oe;s.a6.mat4.mul(ae,ne.placementInvProjMatrix,A.glCoordMatrix),s.a6.mat4.mul(ae,ae,ne.placementViewportMatrix),z.push({circleArray:ce,circleOffset:L,transform:ye,invTransform:ae,projection:ne.getProjection()}),D+=ce.length/4,L=D}de&&(l.terrain&&l.terrain.setupElevationDraw(J,I),I.draw(l,S.LINES,dt.disabled,Et.disabled,l.colorModeForRenderPass(),yt.disabled,Fd(oe,A,J,ne.getProjection()),r.id,de.layoutVertexBuffer,de.indexBuffer,de.segments,null,A.zoom,null,[de.collisionVertexBuffer,de.collisionVertexBufferExt]))}if(!_||!z.length)return;const F=l.getOrCreateProgram("collisionCircle"),N=new s.cQ;N.resize(4*D),N._trim();let V=0;for(const $ of z)for(let Q=0;Q<$.circleArray.length/4;Q++){const J=4*Q,ne=$.circleArray[J+0],ie=$.circleArray[J+1],oe=$.circleArray[J+2],de=$.circleArray[J+3];N.emplace(V++,ne,ie,oe,de,0),N.emplace(V++,ne,ie,oe,de,1),N.emplace(V++,ne,ie,oe,de,2),N.emplace(V++,ne,ie,oe,de,3)}(!xl||xl.length<2*D)&&(xl=function($){const Q=2*$,J=new s.aO;J.resize(Q),J._trim();for(let ne=0;ne=0&&(F[$.associatedIconIndex]={x:ae,y:ye,z:Ie,angle:Re})}else _n(ne,D)}if(I){L.clear();const Y=l.icon.placedSymbolArray;for(let $=0;${oe.depthOcclusionForSymbolsAndCircles&&(r.hasInitialOcclusionOpacityProperties||l.terrain)&&(fi.push("DEPTH_D24"),fi.push("DEPTH_OCCLUSION"))},di=()=>{const fi=de&&"point"!==r.layout.get("symbol-placement"),Ot=[];Lt(Ot);const ii=fi||pt,ci=r.paint.get("icon-image-cross-fade").constantOr(0);l.terrainRenderModeElevated()&&ae&&Ot.push("PITCH_WITH_MAP_TERRAIN"),ht&&(Ot.push("PROJECTION_GLOBE_VIEW"),ii&&Ot.push("PROJECTED_POS_ON_VIEWPORT")),ci>0&&Ot.push("ICON_TRANSITION"),Be.icon.zOffsetVertexBuffer&&Ot.push("Z_OFFSET"),0===U&&0===W&&0===Y&&1===$||Ot.push("COLOR_ADJUSTMENT"),Be.sdfIcons&&Ot.push("RENDER_SDF");const Ni=Be.icon.programConfigurations.get(r.id),Zi=l.getOrCreateProgram("symbol",{config:Ni,defines:Ot}),Kt=Le.imageAtlasTexture?Le.imageAtlasTexture.size:[0,0],Ji=Be.iconSizeData,rr=s.bj(Ji,oe.zoom),Qi=ae||0!==oe.pitch,bi=Wt(et,Le.tileID.canonical,ae,de,oe,Be.getProjection(),_t),Tr=Ir(et,Le.tileID.canonical,ae,de,oe,Be.getProjection(),_t),Mr=l.translatePosMatrix(Tr,Le,T,A,!0),Wr=l.translatePosMatrix(et,Le,T,A),Ur=ii?pa:bi,Dr=de&&!ae&&!fi;let Xr=Ue;!Re&&!oe.mercatorFromTransition||de||(Xr=Oc(oe));const Nn=ht?Xr:Ue,ao=r.getColorAdjustmentMatrix(U,W,Y,$),bn=Lc(Ji.kind,rr,Dr,ae,l,Wr,Ur,Mr,Q,!1,Kt,[0,0],!0,Ge,Ze,Ne,Ft,Nn,Be.getProjection(),ao,ci),Es=Le.imageAtlasTexture?Le.imageAtlasTexture:null,As=1!==r.layout.get("icon-size").constantOr(0)||Be.iconsNeedLinear,Bl=Be.sdfIcons||l.options.rotating||l.options.zooming||As||Qi?ie.LINEAR:ie.NEAREST,Is=Be.sdfIcons&&0!==r.paint.get("icon-halo-width").constantOr(1),wi=l.terrain&&ae&&fi?s.a6.mat4.invert(s.a6.mat4.create(),bi):pa;if(fi&&Be.icon){const Lo=oe.elevation,rp=Lo?Lo.getAtTileOffsetFunc(Ge,oe.center.lat,oe.worldSize,Be.getProjection()):null,Vu=Xt(et,Le.tileID.canonical,ae,de,oe,Be.getProjection(),_t);Ko(Be,et,l,!1,Vu,Tr,ae,N,rp,Ge)}return{program:Zi,buffers:Be.icon,uniformValues:bn,atlasTexture:Es,atlasTextureIcon:null,atlasInterpolation:Bl,atlasInterpolationIcon:null,isSDF:Be.sdfIcons,hasHalo:Is,tile:Le,labelPlaneMatrixInv:wi}},yi=()=>{const fi=ce&&"point"!==r.layout.get("symbol-placement"),Ot=[],ii=fi||xe||pt;l.terrainRenderModeElevated()&&ye&&Ot.push("PITCH_WITH_MAP_TERRAIN"),ht&&(Ot.push("PROJECTION_GLOBE_VIEW"),ii&&Ot.push("PROJECTED_POS_ON_VIEWPORT")),Be.text.zOffsetVertexBuffer&&Ot.push("Z_OFFSET"),Be.iconsInText&&Ot.push("RENDER_TEXT_AND_SYMBOL"),Ot.push("RENDER_SDF"),Lt(Ot);const ci=Be.text.programConfigurations.get(r.id),Ni=l.getOrCreateProgram("symbol",{config:ci,defines:Ot});let Zi,Kt=[0,0],Ji=null;const rr=Be.textSizeData;Be.iconsInText&&(Kt=Le.imageAtlasTexture?Le.imageAtlasTexture.size:[0,0],Ji=Le.imageAtlasTexture?Le.imageAtlasTexture:null,Zi=ye||0!==oe.pitch||l.options.rotating||l.options.zooming||"composite"===rr.kind||"camera"===rr.kind?ie.LINEAR:ie.NEAREST);const Qi=Le.glyphAtlasTexture?Le.glyphAtlasTexture.size:[0,0],bi=s.bj(rr,oe.zoom),Tr=Wt(et,Le.tileID.canonical,ye,ce,oe,Be.getProjection(),_t),Mr=Ir(et,Le.tileID.canonical,ye,ce,oe,Be.getProjection(),_t),Wr=l.translatePosMatrix(Mr,Le,S,I,!0),Ur=l.translatePosMatrix(et,Le,S,I),Dr=ii?pa:Tr,Xr=ce&&!ye&&!fi;let Nn=Ue;!Re&&!oe.mercatorFromTransition||ce||(Nn=Oc(oe));const ao=Lc(rr.kind,bi,Xr,ye,l,Ur,Dr,Wr,Q,!0,Qi,Kt,!0,Ge,Ze,Ne,Ft,ht?Nn:Ue,Be.getProjection(),J),bn=Le.glyphAtlasTexture?Le.glyphAtlasTexture:null,Es=ie.LINEAR,As=0!==r.paint.get("text-halo-width").constantOr(1),Bl=l.terrain&&ye&&fi?s.a6.mat4.invert(s.a6.mat4.create(),Tr):pa;if(fi&&Be.text){const Is=oe.elevation,wi=Is?Is.getAtTileOffsetFunc(Ge,oe.center.lat,oe.worldSize,Be.getProjection()):null,Lo=Xt(et,Le.tileID.canonical,ye,ce,oe,Be.getProjection(),_t);Ko(Be,et,l,!0,Lo,Mr,ye,V,wi,Ge)}return{program:Ni,buffers:Be.text,uniformValues:ao,atlasTexture:bn,atlasTextureIcon:Ji,atlasInterpolation:Es,atlasInterpolationIcon:Zi,isSDF:!0,hasHalo:As,tile:Le,labelPlaneMatrixInv:Bl}},Si=Be.icon.segments.get().length,Hr=Be.text.segments.get().length,qi=Si&&!_.onlyText?di():null,$t=Hr&&!_.onlyIcons?yi():null,mi=r.paint.get("icon-opacity").constantOr(1),Pi=r.paint.get("text-opacity").constantOr(1);if(Ie&&Be.canOverlap){ke=!0;const fi=mi&&!_.onlyText?Be.icon.segments.get():[],Ot=Pi&&!_.onlyIcons?Be.text.segments.get():[];for(const ii of fi)ze.push({segments:new s.b1([ii]),sortKey:ii.sortKey,state:qi});for(const ii of Ot)ze.push({segments:new s.b1([ii]),sortKey:ii.sortKey,state:$t})}else _.onlyText||ze.push({segments:mi?Be.icon.segments:new s.b1([]),sortKey:0,state:qi}),_.onlyIcons||ze.push({segments:Pi?Be.text.segments:new s.b1([]),sortKey:0,state:$t})}ke&&ze.sort((Ge,Le)=>Ge.sortKey-Le.sortKey);for(const Ge of ze){const Le=Ge.state;if(Le)if(l.terrain?l.terrain.setupElevationDraw(Le.tile,Le.program,{useDepthForOcclusion:oe.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:Le.labelPlaneMatrixInv}):l.setupDepthForOcclusion(oe.depthOcclusionForSymbolsAndCircles,Le.program),ne.activeTexture.set(ie.TEXTURE0),Le.atlasTexture&&Le.atlasTexture.bind(Le.atlasInterpolation,ie.CLAMP_TO_EDGE,!0),Le.atlasTextureIcon&&(ne.activeTexture.set(ie.TEXTURE1),Le.atlasTextureIcon&&Le.atlasTextureIcon.bind(Le.atlasInterpolationIcon,ie.CLAMP_TO_EDGE,!0)),l.uploadCommonLightUniforms(l.context,Le.program),Le.hasHalo){const Be=Le.uniformValues;Be.u_is_halo=1,ma(Le.buffers,Ge.segments,r,l,Le.program,Ae,d,f,Be,2),Be.u_is_halo=0}else{if(Le.isSDF){const Be=Le.uniformValues;Le.hasHalo&&(Be.u_is_halo=1,ma(Le.buffers,Ge.segments,r,l,Le.program,Ae,d,f,Be,1)),Be.u_is_halo=0}ma(Le.buffers,Ge.segments,r,l,Le.program,Ae,d,f,Le.uniformValues,1)}}}function ma(l,t,r,c,d,f,_,T,S,A){const I=[l.dynamicLayoutVertexBuffer,l.opacityVertexBuffer,l.iconTransitioningVertexBuffer,l.globeExtVertexBuffer,l.zOffsetVertexBuffer];d.draw(c,c.context.gl.TRIANGLES,f,_,T,yt.disabled,S,r.id,l.layoutVertexBuffer,l.indexBuffer,t,r.paint,c.transform.zoom,l.programConfigurations.get(r.id),I,A)}function bl(l,t,r,c,d,f,_){const T=l.context.gl,S=r.paint.get("fill-pattern"),A=r.is3D(),I=A?l.stencilModeFor3D():Et.disabled,z=S&&S.constantOr(1);let D,L,F,N,V;_?(L=z&&!r.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",D=T.LINES):(L=z?"fillPattern":"fill",D=T.TRIANGLES);for(const U of c){const W=t.getTile(U);if(z&&!W.patternsLoaded())continue;const Y=W.getBucket(r);if(!Y)continue;l.prepareDrawTile();const $=Y.programConfigurations.get(r.id),Q=l.isTileAffectedByFog(U),J=l.getOrCreateProgram(L,{config:$,overrideFog:Q});z&&(l.context.activeTexture.set(T.TEXTURE0),W.imageAtlasTexture&&W.imageAtlasTexture.bind(T.LINEAR,T.CLAMP_TO_EDGE),$.updatePaintBuffers());const ne=S.constantOr(null);if(ne&&W.imageAtlas){const de=W.imageAtlas.patternPositions[ne.toString()];de&&$.setConstantPatternPositions(de)}const ie=l.translatePosMatrix(U.projMatrix,W,r.paint.get("fill-translate"),r.paint.get("fill-translate-anchor")),oe=r.paint.get("fill-emissive-strength");if(_){N=Y.indexBuffer2,V=Y.segments2;const de=l.terrain&&l.terrain.renderingToTexture?l.terrain.drapeBufferSize:[T.drawingBufferWidth,T.drawingBufferHeight];F="fillOutlinePattern"===L&&z?ua(ie,oe,l,W,de):_u(ie,oe,de)}else N=Y.indexBuffer,V=Y.segments,F=z?mu(ie,oe,l,W):dl(ie,oe);l.uploadCommonUniforms(l.context,J,U.toUnwrapped()),J.draw(l,D,d,A?I:l.stencilModeForClipping(U),f,yt.disabled,F,r.id,Y.layoutVertexBuffer,N,V,r.paint,l.transform.zoom,$,void 0)}}function _s(l,t,r,c,d,f,_,T){r.resetLayerRenderingStats(l);const S=l.context,A=S.gl,I=l.transform,z=r.paint.get("fill-extrusion-pattern"),D=z.constantOr(1),L=r.paint.get("fill-extrusion-opacity"),F=l.style.enable3dLights(),N=r.paint.get(F&&!D?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),V=[r.paint.get("fill-extrusion-ambient-occlusion-intensity"),N],U=r.layout.get("fill-extrusion-edge-radius"),W=U>0&&!r.paint.get("fill-extrusion-rounded-roof"),Y=W?0:U,$="globe"===I.projection.name?s.c_():0,Q="globe"===I.projection.name,J=Q?s.a9(I.zoom):0,ne=[s.am(I.center.lng),s.at(I.center.lat)],ie=r.paint.get("fill-extrusion-flood-light-color").toRenderColor(r.lut).toArray01().slice(0,3),oe=r.paint.get("fill-extrusion-flood-light-intensity"),de=r.paint.get("fill-extrusion-vertical-scale"),ce=0!==r.paint.get("fill-extrusion-line-width").constantOr(1),ae=Rn(l,r.paint.get("fill-extrusion-cutoff-fade-range")),ye=[];let Ie;Q&&ye.push("PROJECTION_GLOBE_VIEW"),V[0]>0&&ye.push("FAUX_AO"),W&&ye.push("ZERO_ROOF_RADIUS"),T&&ye.push("HAS_CENTROID"),oe>0&&ye.push("FLOOD_LIGHT"),ae.shouldRenderCutoff&&ye.push("RENDER_CUTOFF"),ce&&ye.push("RENDER_WALL_MODE");const ke="shadow"===l.renderPass,Ae=l.shadowRenderer,Ne=ke&&!!Ae;l.shadowRenderer&&(l.shadowRenderer.useNormalOffset=!0);let xe=[0,0,0];if(Ae){const Ue=l.style.directionalLight,Ge=l.style.ambientLight;Ue&&Ge&&(xe=Ka(l.style,Ue,Ge)),Ie=ye.concat(["SHADOWS_SINGLE_CASCADE"])}const Re=Ne?"fillExtrusionDepth":D?"fillExtrusionPattern":"fillExtrusion",ze=r.getLayerRenderingStats();for(const Ue of c){const Ge=t.getTile(Ue),Le=Ge.getBucket(r);if(!Le||Le.projection.name!==I.projection.name)continue;let Be=!1;Ae&&(Be=0===Ae.getMaxCascadeForTile(Ue.toUnwrapped()));const ht=l.isTileAffectedByFog(Ue),Ze=Le.programConfigurations.get(r.id),et=l.getOrCreateProgram(Re,{config:Ze,defines:Be?Ie:ye,overrideFog:ht});if(l.terrain&&l.terrain.setupElevationDraw(Ge,et,{useMeterToDem:!0}),!Le.centroidVertexBuffer){const yi=et.attributes.a_centroid_pos;void 0!==yi&&A.vertexAttrib2f(yi,0,0)}!ke&&Ae&&Ae.setupShadows(Ge.tileID.toUnwrapped(),et,"vector-tile",Ge.tileID.overscaledZ),D&&(l.context.activeTexture.set(A.TEXTURE0),Ge.imageAtlasTexture&&Ge.imageAtlasTexture.bind(A.LINEAR,A.CLAMP_TO_EDGE),Ze.updatePaintBuffers());const _t=z.constantOr(null);if(_t&&Ge.imageAtlas){const yi=Ge.imageAtlas.patternPositions[_t.toString()];yi&&Ze.setConstantPatternPositions(yi)}const ot=r.paint.get("fill-extrusion-vertical-gradient"),pt=1/Le.tileToMeter;let Ft;if(ke&&Ae){if(Nc(Ge.tileID,Le,l))continue;const yi=Ae.calculateShadowPassMatrixFromTile(Ge.tileID.toUnwrapped());Ft=fu(yi,Y,pt,de)}else{const yi=l.translatePosMatrix(Ue.expandedProjMatrix,Ge,r.paint.get("fill-extrusion-translate"),r.paint.get("fill-extrusion-translate-anchor")),Si=I.projection.createInversionMatrix(I,Ue.canonical);Ft=D?Dc(yi,l,ot,L,V,Y,pt,Ue,Ge,$,J,ne,Si,ie,de):zc(yi,l,ot,L,V,Y,pt,Ue,$,J,ne,Si,ie,de,oe,xe)}l.uploadCommonUniforms(S,et,Ue.toUnwrapped(),null,ae);let Lt=Le.segments;if("mercator"===I.projection.name&&!ke&&(Lt=Le.getVisibleSegments(Ge.tileID,l.terrain,l.transform.getFrustum(0)),!Lt.get().length))continue;if(ze)if(ke)for(const yi of Lt.get())ze.numRenderedVerticesInShadowPass+=yi.primitiveLength;else for(const yi of Lt.get())ze.numRenderedVerticesInTransparentPass+=yi.primitiveLength;const di=[];(l.terrain||T)&&di.push(Le.centroidVertexBuffer),Q&&di.push(Le.layoutVertexExtBuffer),ce&&di.push(Le.wallVertexBuffer),et.draw(l,S.gl.TRIANGLES,d,f,_,yt.backCCW,Ft,r.id,Le.layoutVertexBuffer,Le.indexBuffer,Lt,r.paint,l.transform.zoom,Ze,di)}l.shadowRenderer&&(l.shadowRenderer.useNormalOffset=!1)}function or(l,t,r,c,d,f,_,T,S,A,I,z,D,L,F,N,V,U,W){const Y=l.context,$=Y.gl,Q=l.transform,J=l.transform.zoom,ne=[],ie=Rn(l,r.paint.get("fill-extrusion-cutoff-fade-range"));"clear"===A?(ne.push("CLEAR_SUBPASS"),W&&(ne.push("CLEAR_FROM_TEXTURE"),Y.activeTexture.set($.TEXTURE0),W.bind($.LINEAR,$.CLAMP_TO_EDGE))):"sdf"===A&&ne.push("SDF_SUBPASS"),V&&ne.push("HAS_CENTROID"),ie.shouldRenderCutoff&&ne.push("RENDER_CUTOFF");const oe=r.layout.get("fill-extrusion-edge-radius"),de=(ce,ae,ye,Ie,ke)=>{const Ae=ae.programConfigurations.get(r.id),Ne=l.isTileAffectedByFog(ce),xe=l.getOrCreateProgram("fillExtrusionGroundEffect",{config:Ae,defines:ne,overrideFog:Ne}),Re=((Ue,Ge,Le,Be,ht,Ze,et,_t,ot,pt,Ft)=>({u_matrix:Ge,u_opacity:Le,u_ao_pass:Be?1:0,u_meter_to_tile:ht,u_ao:Ze,u_flood_light_intensity:et,u_flood_light_color:_t,u_attenuation:ot,u_edge_radius:pt,u_fb:0,u_fb_size:Ft,u_dynamic_offset:1}))(0,Ie,I,S,ke,[z,D*ke],L,F,N,J>=17?0:oe*ke,W?W.size[0]:0),ze=[];V&&ze.push(ae.hiddenByLandmarkVertexBuffer),l.uploadCommonUniforms(Y,xe,ce.toUnwrapped(),null,ie),xe.draw(l,Y.gl.TRIANGLES,d,f,_,T,Re,r.id,ae.vertexBuffer,ae.indexBuffer,ye,r.paint,J,Ae,ze)};for(const ce of c){const ae=t.getTile(ce),ye=ae.getBucket(r);if(!ye||ye.projection.name!==Q.projection.name||!ye.groundEffect||ye.groundEffect&&!ye.groundEffect.hasData())continue;const Ie=ye.groundEffect,ke=1/ye.tileToMeter;{const Ae=l.translatePosMatrix(ce.projMatrix,ae,r.paint.get("fill-extrusion-translate"),r.paint.get("fill-extrusion-translate-anchor")),Ne=Ie.getDefaultSegment();de(ce,Ie,Ne,Ae,ke)}if(U)for(let Ae=0;Ae<4;Ae++){const Ne=s.c$[Ae](ce),xe=t.getTile(Ne);if(!xe)continue;const Re=xe.getBucket(r);if(!Re||Re.projection.name!==Q.projection.name||!Re.groundEffect||Re.groundEffect&&!Re.groundEffect.hasData())continue;const ze=Re.groundEffect;let Ue,Ge;0===Ae?(Ue=[-s.ab,0,0],Ge=1):1===Ae?(Ue=[s.ab,0,0],Ge=0):2===Ae?(Ue=[0,-s.ab,0],Ge=3):(Ue=[0,s.ab,0],Ge=2);const Le=ze.regionSegments[Ge];if(!Le)continue;const Be=new Float32Array(16);s.a6.mat4.translate(Be,ce.projMatrix,Ue),de(ce,ze,Le,l.translatePosMatrix(Be,ae,r.paint.get("fill-extrusion-translate"),r.paint.get("fill-extrusion-translate-anchor")),ke)}}}function to(l,t,r,c,d,f,_){0===c.centroidVertexArray.length&&c.createCentroidsBuffer();const T=f?f.findDEMTileFor(r):null;if(!(T&&T.dem||_))return;const S=U=>new s.P(Math.ceil((U+s.d2)*s.d3),0),A=U=>{const W=t.getSource().minzoom,Y=Q=>{const J=t.getTileByID(Q);if(J&&J.hasData())return J.getBucket(d)},$=[0,-1,1];for(const Q of $){if(U.overscaledZ+Q(I[0]=Math.min(U.min.y,W.min.y),I[1]=Math.max(U.max.y,W.max.y),I[2]=s.ab-W.min.x>U.max.x?W.min.x-s.ab:U.max.x,I),D=(U,W)=>(I[0]=Math.min(U.min.x,W.min.x),I[1]=Math.max(U.max.x,W.max.x),I[2]=s.ab-W.min.y>U.max.y?W.min.y-s.ab:U.max.y,I),L=[(U,W)=>z(U,W),(U,W)=>z(W,U),(U,W)=>D(U,W),(U,W)=>D(W,U)],F=(U,W,Y,$,Q,J,ne)=>{if(!f)return 0;const ie=[[J?Y:U,J?U:Y,0],[J?Y:W,J?W:Y,0]],oe=ne<0?s.ab+ne:ne,de=[J?oe:(U+W)/2,J?(U+W)/2:oe,0];return 0===Y&&ne<0||0!==Y&&ne>0?f.getForTilePoints(Q,[de],!0,$):ie.push(de),f.getForTilePoints(r,ie,!0,T),Math.max(ie[0][2],ie[1][2],de[2])/f.exaggeration()};for(let U=0;U<4;U++){const W=c.borderFeatureIndices[U];if(0===W.length)continue;const Y=s.c$[U](r),$=A(Y);if(!($&&$ instanceof s.d0)||c.borderDoneWithNeighborZ[U]===$.canonical.z)continue;0===$.centroidVertexArray.length&&$.createCentroidsBuffer();const Q=f?f.findDEMTileFor(Y):null;if(!(Q&&Q.dem||_))continue;const J=(U<2?1:5)-U,ne=$.borderDoneWithNeighborZ[J]!==c.canonical.z,ie=$.borderFeatureIndices[J];let oe=0;if(c.canonical.z!==$.canonical.z){for(const de of W)c.showCentroid(c.featuresOnBorder[de]);if(ne)for(const de of ie)$.showCentroid($.featuresOnBorder[de]);c.borderDoneWithNeighborZ[U]=$.canonical.z,$.borderDoneWithNeighborZ[J]=c.canonical.z}for(const de of W){const ce=c.featuresOnBorder[de],ae=c.centroidData[ce.centroidDataIndex],ye=ce.borders[U];let Ie;for(;oeye[0]+3||ke[0]>ye[0]-3)break;$.showCentroid(Ie),oe++}if(Ie&&oeye[1]-3)&&(Ae++,++oe!==ie.length);)Ie=$.featuresOnBorder[ie[oe]];Ie=$.featuresOnBorder[ie[ke]];let Ne=!1;if(Ae>=1){const ze=Ie.borders[J];Math.abs(ye[0]-ze[0])<3&&Math.abs(ye[1]-ze[1])<3&&(Ae=1,Ne=!0,oe=ke+1)}else if(0===Ae){c.showCentroid(ce);continue}const xe=$.centroidData[Ie.centroidDataIndex];_&&Ne&&(((N=ae).flags|(V=xe).flags)&s.d1?(N.flags|=s.d1,V.flags|=s.d1):(N.flags&=~s.d1,V.flags&=~s.d1));const Re=ce.intersectsCount()>1||Ie.intersectsCount()>1;if(Ae>1)oe=ke,ae.centroidXY=xe.centroidXY=new s.P(0,0);else if(Q&&Q.dem&&!Re){const ze=L[U](ae,xe),Ue=U%2?s.ab-1:0,Ge=F(ze[0],Math.min(s.ab-1,ze[1]),Ue,Q,Y,U<2,ze[2]);ae.centroidXY=xe.centroidXY=S(Ge)}else Re?ae.centroidXY=xe.centroidXY=new s.P(0,0):(ae.centroidXY=c.encodeBorderCentroid(ce),xe.centroidXY=$.encodeBorderCentroid(Ie));c.writeCentroidToBuffer(ae),$.writeCentroidToBuffer(xe)}else c.showCentroid(ce)}c.borderDoneWithNeighborZ[U]=$.canonical.z,$.borderDoneWithNeighborZ[J]=c.canonical.z}var N,V;(c.needsCentroidUpdate||!c.centroidVertexBuffer&&0!==c.centroidVertexArray.length)&&c.uploadCentroid(l)}const wu=[1,0,0],Bc=[0,1,0],Fc=[0,0,1];function Nc(l,t,r){const c=r.transform,d=r.shadowRenderer;if(!d)return!0;const f=l.toUnwrapped(),_=c.tileSize*d._cascades[r.currentShadowCascade].scale;let T=t.maxHeight;if(c.elevation){const N=c.elevation.getMinMaxForTile(l);N&&(T+=N.max)}const S=[...d.shadowDirection];S[2]=-S[2];const A=d.computeSimplifiedTileShadowVolume(f,T,_,S);if(!A)return!1;const I=[wu,Bc,Fc,S,[S[0],0,S[2]],[0,S[1],S[2]]],z="globe"===c.projection.name,D=c.scaleZoom(_),L=s.bN.fromInvProjectionMatrix(c.invProjMatrix,c.worldSize,D,!z),F=d.getCurrentCascadeFrustum();return 0===L.intersectsPrecise(A.vertices,A.planes,I)||0===F.intersectsPrecise(A.vertices,A.planes,I)}function Vc(l){return[l[0]*s.d4,l[1]*s.d4,l[2]*s.d4,0]}function zr(l,t,r,c,d,f,_,T,S){const A=c.getSource(),I=r.globeSharedBuffers;if(!I)return;let z,D,L;if(t&&(z=c.getTile(t)),A instanceof s.aD?(D=A.texture,L=s.cD(0,0,r.transform)):z&&t&&(D=z.texture,L=s.cD(t.canonical.z,t.canonical.x,r.transform)),!D||!L)return;l||(L=s.a6.mat4.scale(s.a6.mat4.create(),L,[1,-1,1]));const F=r.context,N=F.gl,V="nearest"===d.paint.get("raster-resampling")?N.NEAREST:N.LINEAR,U=r.colorModeForDrapableLayerRenderPass(f),W=_.defines;W.push("GLOBE_POLES");const Y=new dt(N.LEQUAL,dt.ReadWrite,r.depthRangeFor3D),$=Float32Array.from(r.transform.expandedFarZProjMatrix),Q=Float32Array.from(s.b5(s.cC(new s.bP(0,0,0))));r.terrain&&r.terrain.prepareDrawTile(),F.activeTexture.set(N.TEXTURE0),D.bind(V,N.CLAMP_TO_EDGE),F.activeTexture.set(N.TEXTURE1),D.bind(V,N.CLAMP_TO_EDGE),D.useMipmap&&F.extTextureFilterAnisotropic&&r.transform.pitch>20&&N.texParameterf(N.TEXTURE_2D,F.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,F.extTextureFilterAnisotropicMax);const[J,ne,ie,oe]=t?I.getPoleBuffers(t.canonical.z,!1):I.getPoleBuffers(0,!0),de=d.paint.get("raster-elevation");let ce;l?(ce=J,r.renderDefaultNorthPole=0!==de):(ce=ne,r.renderDefaultSouthPole=0!==de);const ae=Vc(_.mix),ye=(ke=$,Ae=Q,Ne=L,xe=s.a9(r.transform.zoom),ze=d,Ge=de,Be=ae,ht=_.offset,Ze=_.range,et=f,da(ke,Ae,Ne,new Float32Array(16),new Float32Array(9),[0,0],xe,[0,0],[0,0,0,0],1,{opacity:1,mix:0},ze,[0,0],Ge,2,Be,ht,Ze,1,0,et)),Ie=r.getOrCreateProgram("raster",{defines:W});var ke,Ae,Ne,xe,ze,Ge,Be,ht,Ze,et;r.uploadCommonUniforms(F,Ie,null),Ie.draw(r,N.TRIANGLES,Y,S,U,T,ye,d.id,ce,ie,oe)}function Bi(l){const t=l._nearZ,r=l.projection.farthestPixelDistance(l),c=r-t,d=.2*l.height,f=t+d;return[t,r,(f-d-t)/c,(f-t)/c]}function wl(l,t,r,c){if(l)return t instanceof Zo&&l instanceof Va?t.getTextureDescriptor(l,r,!0):{texture:l.texture,mix:Vc(c.mix),offset:c.offset,buffer:0,tileSize:1}}var Uc=s.d5([{name:"a_index",type:"Int16",components:1}]);class Tu{constructor(t,r,c,d){const f={width:c[0],height:c[1],data:null},_=t.gl;this.targetColorTexture=new s.T(t,f,_.RGBA8,{useMipmap:!1}),this.backgroundColorTexture=new s.T(t,f,_.RGBA8,{useMipmap:!1}),this.context=t,this.updateParticleTexture(r,d),this.lastInvalidatedAt=0}updateParticleTexture(t,r){if(this.particleTextureDimension===r.width)return;(this.particleTexture0||this.particleTexture1||this.particleIndexBuffer||this.particleSegment)&&(this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleIndexBuffer.destroy(),this.particleSegment.destroy());const c=this.context.gl,d=r.width*r.height;this.particleTexture0=new s.T(this.context,r,c.RGBA8,{premultiply:!1,useMipmap:!1}),this.particleTexture1=new s.T(this.context,r,c.RGBA8,{premultiply:!1,useMipmap:!1});const f=new s.d6;f.reserve(d);for(let _=0;_0){const ae=s.b4(r.canonical,S),ye=s.d8(ae);D=s.a6.mat4.multiply(new Float32Array(16),S.globeMatrix,ye),s.a6.mat4.multiply(D,S.projMatrix,D)}const L=s.a6.mat4.create();L[12]+=2*d/(s.q.devicePixelRatio*S.width),L[13]+=2*f/(s.q.devicePixelRatio*S.height),s.a6.mat4.multiply(D,L,D);const F=l.getOrCreateProgram("debug",{defines:z}),N=t.getTileByID(r.key);l.terrain&&l.terrain.setupElevationDraw(N,F);const V=dt.disabled,U=Et.disabled,W=l.colorModeForRenderPass(),Y="$debug";T.activeTexture.set(A.TEXTURE0),l.emptyTexture.bind(A.LINEAR,A.CLAMP_TO_EDGE),I?N._makeGlobeTileDebugBuffers(l.context,S):N._makeDebugTileBoundsBuffers(l.context,S.projection);const $=N._tileDebugBuffer||l.debugBuffer,Q=N._tileDebugIndexBuffer||l.debugIndexBuffer,J=N._tileDebugSegments||l.debugSegments;if(F.draw(l,A.LINE_STRIP,V,U,W,yt.disabled,gu(D,c),Y,$,Q,J,null,null,null,[N._globeTileDebugBorderBuffer]),_){const ae=N.latestRawTileData,ye=Math.floor((ae&&ae.byteLength||0)/1024);let Ie=r.canonical.toString();r.overscaledZ!==r.canonical.z&&(Ie+=` => ${r.overscaledZ}`),Ie+=` ${N.state}`,Ie+=` ${ye}kb`,function(ke,Ae){ke.initDebugOverlayCanvas();const Ne=ke.debugOverlayCanvas,xe=ke.context.gl,Re=ke.debugOverlayCanvas.getContext("2d");Re.clearRect(0,0,Ne.width,Ne.height),Re.shadowColor="white",Re.shadowBlur=2,Re.lineWidth=1.5,Re.strokeStyle="white",Re.textBaseline="top",Re.font="bold 36px Open Sans, sans-serif",Re.fillText(Ae,5,5),Re.strokeText(Ae,5,5),ke.debugOverlayTexture.update(Ne),ke.debugOverlayTexture.bind(xe.LINEAR,xe.CLAMP_TO_EDGE)}(l,Ie)}const ne=t.getTile(r).tileSize,ie=512/Math.min(ne,512)*(r.overscaledZ/S.zoom)*.5,oe=N._tileDebugTextBuffer||l.debugBuffer,de=N._tileDebugTextIndexBuffer||l.quadTriangleIndexBuffer,ce=N._tileDebugTextSegments||l.debugSegments;F.draw(l,A.TRIANGLES,V,U,Zt.alphaBlended,yt.disabled,gu(D,s.bz.transparent,ie),Y,oe,de,ce,null,null,null,[N._globeTileDebugTextBuffer])}function Ci(l,t,r,c){_a(l,0,t+r/2,l.transform.width,r,c)}function be(l,t,r,c){_a(l,t-r/2,0,r,l.transform.height,c)}function _a(l,t,r,c,d,f){const _=l.context,T=_.gl;T.enable(T.SCISSOR_TEST),T.scissor(t*s.q.devicePixelRatio,r*s.q.devicePixelRatio,c*s.q.devicePixelRatio,d*s.q.devicePixelRatio),_.clear({color:f}),T.disable(T.SCISSOR_TEST)}const Tl=s.d5([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:jc}=Tl;function ln(l,t,r,c){l.emplaceBack(t,r,c)}class Gc{constructor(t){this.vertexArray=new s.d9,this.indices=new s.aO,ln(this.vertexArray,-1,-1,1),ln(this.vertexArray,1,-1,1),ln(this.vertexArray,-1,1,1),ln(this.vertexArray,1,1,1),ln(this.vertexArray,-1,-1,-1),ln(this.vertexArray,1,-1,-1),ln(this.vertexArray,-1,1,-1),ln(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,jc),this.indexBuffer=t.createIndexBuffer(this.indices),this.segment=s.b1.simpleSegment(0,0,36,12)}}function Co(l,t,r,c,d,f){const _=l.context.gl,T=t.paint.get("sky-atmosphere-color"),S=t.paint.get("sky-atmosphere-halo-color"),A=t.paint.get("sky-atmosphere-sun-intensity"),I={u_matrix_3f:s.a6.mat3.fromMat4(s.a6.mat3.create(),c),u_sun_direction:d,u_sun_intensity:A,u_color_tint_r:[(F=T).r,F.g,F.b,F.a],u_color_tint_m:[(N=S).r,N.g,N.b,N.a],u_luminance:5e-5};var F,N;_.framebufferTexture2D(_.FRAMEBUFFER,_.COLOR_ATTACHMENT0,_.TEXTURE_CUBE_MAP_POSITIVE_X+f,t.skyboxTexture,0),r.draw(l,_.TRIANGLES,dt.disabled,Et.disabled,Zt.unblended,yt.frontCW,I,"skyboxCapture",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment)}const xs=s.d5([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class qd{constructor(t){const r=new s.da;r.emplaceBack(-1,1,1,0,0),r.emplaceBack(1,1,1,1,0),r.emplaceBack(1,-1,1,1,1),r.emplaceBack(-1,-1,1,0,1);const c=new s.aO;c.emplaceBack(0,1,2),c.emplaceBack(2,3,0),this.vertexBuffer=t.createVertexBuffer(r,xs.members),this.indexBuffer=t.createIndexBuffer(c),this.segments=s.b1.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const Zd=s.d5([{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_fade_opacity",components:1}]);class Eu{constructor(){this.starsCount=16e3,this.sizeMultiplier=.15,this.sizeRange=100,this.intensityRange=200}}class Ml{constructor(t){this.colorModeAlphaBlendedWriteRGB=new Zt([1,771,1,771],s.bz.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new Zt([1,0,1,0],s.bz.transparent,[!1,!1,!1,!0]),this.params=new Eu,this.updateNeeded=!0,t.tp.registerParameter(this.params,["Stars"],"starsCount",{min:100,max:16e3,step:1},()=>{this.updateNeeded=!0}),t.tp.registerParameter(this.params,["Stars"],"sizeMultiplier",{min:.01,max:2,step:.01}),t.tp.registerParameter(this.params,["Stars"],"sizeRange",{min:0,max:200,step:1},()=>{this.updateNeeded=!0}),t.tp.registerParameter(this.params,["Stars"],"intensityRange",{min:0,max:200,step:1},()=>{this.updateNeeded=!0})}update(t){const r=t.context;if(!this.atmosphereBuffer||this.updateNeeded){this.updateNeeded=!1,this.atmosphereBuffer=new qd(r);const c=this.params.sizeRange,d=this.params.intensityRange,f=function(I){const z=s.dd(30),D=[];for(let L=0;L{const Q="globe"===f.projection.name?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];$&&Q.push("ALPHA_PASS");const J=t.getOrCreateProgram("globeAtmosphere",{defines:Q}),ne=((oe,de,ce,ae,ye,Ie,ke,Ae,Ne,xe,Re,ze)=>({u_frustum_tl:oe,u_frustum_tr:de,u_frustum_br:ce,u_frustum_bl:ae,u_horizon:ye,u_transition:Ie,u_fadeout_range:ke,u_color:Ae,u_high_color:Ne,u_space_color:xe,u_temporal_offset:Re,u_horizon_angle:ze}))(f.frustumCorners.TL,f.frustumCorners.TR,f.frustumCorners.BR,f.frustumCorners.BL,f.frustumCorners.horizon,T,L,A,I,z,N,W);t.uploadCommonUniforms(c,J);const ie=this.atmosphereBuffer;ie&&J.draw(t,d.TRIANGLES,_,Et.disabled,$?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,yt.backCW,ne,$?"atmosphere_glow_alpha":"atmosphere_glow",ie.vertexBuffer,ie.indexBuffer,ie.segments)};Y(!1),Y(!0)}drawStars(t,r){const c=s.ap(r.properties.get("star-intensity"),0,1);if(0===c)return;const d=t.context,f=d.gl,_=t.transform,T=t.getOrCreateProgram("stars"),S=s.a6.quat.identity([]);s.a6.quat.rotateX(S,S,-_._pitch),s.a6.quat.rotateZ(S,S,-_.angle),s.a6.quat.rotateX(S,S,s.bB(_._center.lat)),s.a6.quat.rotateY(S,S,-s.bB(_._center.lng));const A=s.a6.mat4.fromQuat(new Float32Array(16),S),I=s.a6.mat4.multiply([],_.starsProjMatrix,A),z=s.a6.mat3.fromMat4([],A),D=s.a6.mat3.invert([],z),L=[0,1,0];s.a6.vec3.transformMat3(L,L,D),s.a6.vec3.scale(L,L,this.params.sizeMultiplier);const F=[1,0,0];s.a6.vec3.transformMat3(F,F,D),s.a6.vec3.scale(F,F,this.params.sizeMultiplier);const N=(V=L,U=F,W=c,{u_matrix:Float32Array.from(I),u_up:V,u_right:U,u_intensity_multiplier:W});var V,U,W;t.uploadCommonUniforms(d,T),this.starsVx&&this.starsIdx&&T.draw(t,f.TRIANGLES,dt.disabled,Et.disabled,this.colorModeAlphaBlendedWriteRGB,yt.disabled,N,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments)}}function Sl(l,t){const r=[...l],c=t.cameraWorldSizeForFog/t.worldSize,d=s.a6.mat4.identity([]);return s.a6.mat4.scale(d,d,[c,c,1]),s.a6.mat4.multiply(r,d,r),s.a6.mat4.multiply(r,t.worldToFogMatrix,r),r}function El(l,t,r,c,d){const f=r.material,_=c.context,{baseColorTexture:T,metallicRoughnessTexture:S}=f.pbrMetallicRoughness,{normalTexture:A,occlusionTexture:I,emissionTexture:z}=f;function D(L,F,N){if(L&&(l.push(F),_.activeTexture.set(_.gl.TEXTURE0+N),L.gfxTexture)){const{minFilter:V,magFilter:U,wrapS:W,wrapT:Y}=L.sampler;L.gfxTexture.bindExtraParam(V,U,W,Y)}}D(T,"HAS_TEXTURE_u_baseColorTexture",5),D(S,"HAS_TEXTURE_u_metallicRoughnessTexture",6),D(A,"HAS_TEXTURE_u_normalTexture",7),D(I,"HAS_TEXTURE_u_occlusionTexture",8),D(z,"HAS_TEXTURE_u_emissionTexture",9),d&&(d.texture||(d.texture=new s.df(c.context,d.image,[d.image.height,d.image.height,d.image.height],_.gl.RGBA8)),_.activeTexture.set(_.gl.TEXTURE0+10),d.texture&&d.texture.bind(_.gl.LINEAR,_.gl.CLAMP_TO_EDGE),l.push("APPLY_LUT_ON_GPU")),r.texcoordBuffer&&(l.push("HAS_ATTRIBUTE_a_uv_2f"),t.push(r.texcoordBuffer)),r.colorBuffer&&(l.push(12===r.colorBuffer.itemSize?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),t.push(r.colorBuffer)),r.normalBuffer&&(l.push("HAS_ATTRIBUTE_a_normal_3f"),t.push(r.normalBuffer)),r.pbrBuffer&&(l.push("HAS_ATTRIBUTE_a_pbr"),l.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),t.push(r.pbrBuffer)),"OPAQUE"!==f.alphaMode&&"MASK"!==f.alphaMode||l.push("UNPREMULT_TEXTURE_IN_SHADER"),f.defined||l.push("DIFFUSE_SHADED"),l.push("USE_STANDARD_DERIVATIVES")}function ga(l,t,r,c,d,f){const _=r.paint.get("model-opacity"),T=t.context,S=new dt(t.context.gl.LEQUAL,dt.ReadWrite,t.depthRangeFor3D),A=t.transform,I=l.mesh,z=I.material,D=z.pbrMetallicRoughness,L=t.style.fog;let F;F="pixels"===t.transform.projection.zAxisUnit?[...l.nodeModelMatrix]:s.a6.mat4.multiply([],c.zScaleMatrix,l.nodeModelMatrix),s.a6.mat4.multiply(F,c.negCameraPosMatrix,F);const N=s.a6.mat4.invert([],F);s.a6.mat4.transpose(N,N);const V=r.paint.get("model-emissive-strength").constantOr(0),U=rt(new Float32Array(l.worldViewProjection),new Float32Array(F),new Float32Array(N),null,t,_,D.baseColorFactor.toRenderColor(null),z.emissiveFactor,D.metallicFactor,D.roughnessFactor,z,V,r),W={defines:[]},Y=[];El(W.defines,Y,I,t,r.lut);const $=t.shadowRenderer;$&&($.useNormalOffset=!1);let Q=null;if(L){const ie=Sl(l.nodeModelMatrix,t.transform);if(Q=new Float32Array(ie),"globe"!==A.projection.name){const oe=I.aabb.min,de=I.aabb.max,[ce,ae]=L.getOpacityForBounds(ie,oe[0],oe[1],de[0],de[1]);W.overrideFog=ce>=Ke||ae>=Ke}}const J=Rn(t,r.paint.get("model-cutoff-fade-range"));J.shouldRenderCutoff&&W.defines.push("RENDER_CUTOFF");const ne=t.getOrCreateProgram("model",W);t.uploadCommonUniforms(T,ne,null,Q,J),"shadow"!==t.renderPass&&$&&$.setupShadowsFromMatrix(l.nodeModelMatrix,ne),ne.draw(t,T.gl.TRIANGLES,S,d,f,I.material.doubleSided?yt.disabled:yt.backCCW,U,r.id,I.vertexBuffer,I.indexBuffer,I.segments,r.paint,t.transform.zoom,void 0,Y)}function ya(l,t,r,c,d,f,_){let T;T="globe"===l.projection.name?s.dg(r,l):[...r],s.a6.mat4.multiply(T,T,t.matrix);const S=s.a6.mat4.multiply([],c,T);if(t.meshes)for(const A of t.meshes){if("BLEND"!==A.material.alphaMode){_.push({mesh:A,depth:0,modelIndex:d,worldViewProjection:S,nodeModelMatrix:T});continue}const I=s.a6.vec3.transformMat4([],A.centroid,S);I[2]>0&&f.push({mesh:A,depth:I[2],modelIndex:d,worldViewProjection:S,nodeModelMatrix:T})}if(t.children)for(const A of t.children)ya(l,A,r,c,d,f,_)}function vs(l,t,r,c){const d=r.shadowRenderer;if(!d)return;const f=d.getShadowPassDepthMode(),_=d.getShadowPassColorMode(),T=d.calculateShadowPassMatrixFromMatrix(t),S=kc(T);r.getOrCreateProgram("modelDepth",{defines:r._shadowMapDebug?[]:["DEPTH_TEXTURE"]}).draw(r,r.context.gl.TRIANGLES,f,Et.disabled,_,yt.backCCW,S,c.id,l.vertexBuffer,l.indexBuffer,l.segments,c.paint,r.transform.zoom,void 0,void 0)}function Au(l,t,r){const c=t.updateZoomBasedPaintProperties(),d=function(f,_,T){let S,A,I,z=f.terrain?f.terrain.exaggeration():0;if(f.terrain&&z>0){const D=f.terrain,L=D.findDEMTileFor(T);L&&L.dem?S=s.di.create(D,T,L):z=0}if(0===z&&(_.terrainElevationMin=0,_.terrainElevationMax=0),z===_.validForExaggeration&&(0===z||S&&S._demTile&&S._demTile.tileID===_.validForDEMTile.id&&S._dem._timestamp===_.validForDEMTile.timestamp))return!1;for(const D in _.instancesPerModel){const L=_.instancesPerModel[D];for(let F=0;FA&&(A=L.max)}const I=s.ap(c.x,f,_)-c.x,z=s.ap(c.y,T,S)-c.y,D=s.bD(A,t.center.lat)-c.z;return t._zoomFromMercatorZ(Math.sqrt(I*I+z*z+D*D))}function _r(l,t,r,c,d,f,_){const T=l.context,S="shadow"===l.renderPass,A=l.shadowRenderer,I=S&&A?A.getShadowPassDepthMode():new dt(T.gl.LEQUAL,dt.ReadWrite,l.depthRangeFor3D),z=l.isTileAffectedByFog(f);if(r.meshes)for(const D of r.meshes){const L=["MODEL_POSITION_ON_GPU"],F=[];let N,V,U;c.instancedDataArray.length>20&&L.push("INSTANCED_ARRAYS");const W=Rn(l,t.paint.get("model-cutoff-fade-range"));if(W.shouldRenderCutoff&&L.push("RENDER_CUTOFF"),S&&A)N=l.getOrCreateProgram("modelDepth",{defines:L}),V=kc(_.shadowTileMatrix,_.shadowTileMatrix,Float32Array.from(r.matrix)),U=A.getShadowPassColorMode();else{El(L,F,D,l,t.lut),N=l.getOrCreateProgram("model",{defines:L,overrideFog:z});const $=D.material,Q=$.pbrMetallicRoughness,J=t.paint.get("model-opacity"),ne=t.paint.get("model-emissive-strength").constantOr(0);V=rt(f.expandedProjMatrix,Float32Array.from(r.matrix),new Float32Array(16),null,l,J,Q.baseColorFactor.toRenderColor(null),$.emissiveFactor,Q.metallicFactor,Q.roughnessFactor,$,ne,t,d),A&&(_.shadowUniformsInitialized?N.setShadowUniformValues(T,A.getShadowUniformValues()):(A.setupShadows(f.toUnwrapped(),N,"model-tile",f.overscaledZ),_.shadowUniformsInitialized=!0)),U=W.shouldRenderCutoff||J<1||"OPAQUE"!==$.alphaMode?Zt.alphaBlended:Zt.unblended}l.uploadCommonUniforms(T,N,f.toUnwrapped(),null,W);const Y=D.material.doubleSided?yt.disabled:yt.backCCW;if(c.instancedDataArray.length>20)F.push(c.instancedDataBuffer),N.draw(l,T.gl.TRIANGLES,I,Et.disabled,U,Y,V,t.id,D.vertexBuffer,D.indexBuffer,D.segments,t.paint,l.transform.zoom,void 0,F,c.instancedDataArray.length);else{const $=S?"u_instance":"u_normal_matrix";for(let Q=0;QS[1]?_:S,f[0]=r.max[0],_=s.a6.vec4.transformMat4(s.a6.vec4.create(),f,d),T=_[1]S[1]?_:S,f[1]=r.min[1],_=s.a6.vec4.transformMat4(s.a6.vec4.create(),f,d),T=_[1]S[1]?_:S;const A=s.ap(c[0],0,1),I=100*t.pixelsPerMeter*s.ap(c[1],0,1),z=s.ap(c[2],0,1),D=s.a6.vec4.lerp(s.a6.vec4.create(),T,S,A),L=Math.tan(.5*t.fovX),F=-D[2]*L;if(0===I)return D[1]<-Math.abs(F)?z:1;const N=(-Math.abs(F)-D[1])/I,V=(W,Y,$)=>(1-$)*W+$*Y,U=s.ap(V(1,z,N),z,1);return V(1,U,s.ap((t.pitch-20)/20,0,1))}class Iu{}class io{constructor(){this._storage=new Map}getLinesFromTrianglesBuffer(t,r,c){{const z=this._storage.get(r.id);if(z)return z.lastUsedFrameIdx=t,z.buf}const d=c.gl,f=d.getBufferParameter(d.ELEMENT_ARRAY_BUFFER,d.BUFFER_SIZE),_=new ArrayBuffer(f),T=new Int16Array(_);d.getBufferSubData(d.ELEMENT_ARRAY_BUFFER,0,new Int16Array(_));const S=new s.dk;for(let z=0;z30&&(c.buf.destroy(),this._storage.delete(r))}destroy(){for(const[t,r]of this._storage)r.buf.destroy(),this._storage.delete(t)}}class Al{constructor(t){this.occluderSize=30,this.depthOffset=-1e-4,t.registerParameter(this,["Occlusion"],"occluderSize",{min:1,max:100,step:1}),t.registerParameter(this,["Occlusion"],"depthOffset",{min:-.05,max:0,step:1e-5})}}const ro={symbol:function(l,t,r,c,d){if("translucent"!==l.renderPass)return;const f=Et.disabled,_=l.colorModeForRenderPass();r.layout.get("text-variable-anchor")&&function(A,I,z,D,L,F,N){const V=I.transform,U="map"===L,W="map"===F;for(const Y of A){const $=D.getTile(Y),Q=$.getBucket(z);if(!Q||!Q.text||!Q.text.segments.get().length)continue;const J=s.bj(Q.textSizeData,V.zoom),ne=Yn(Y,Q.getProjection(),V),ie=V.calculatePixelsToTileUnitsMatrix($),oe=Wt(ne,$.tileID.canonical,W,U,V,Q.getProjection(),ie),de=Q.hasIconTextFit()&&Q.hasIconData();if(J){const ce=Math.pow(2,V.zoom-$.tileID.overscaledZ);jd(Q,U,W,N,s.cS,V,oe,Y,ce,J,de)}}}(c,l,r,t,r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),d);const T=0!==r.paint.get("icon-opacity").constantOr(1),S=0!==r.paint.get("text-opacity").constantOr(1);void 0!==r.layout.get("symbol-sort-key").constantOr(1)&&(T||S)?fa(l,t,r,c,f,_):(T&&fa(l,t,r,c,f,_,{onlyIcons:!0}),S&&fa(l,t,r,c,f,_,{onlyText:!0})),t.map.showCollisionBoxes&&(vl(l,t,r,c,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),!0),vl(l,t,r,c,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),!1))},circle:function(l,t,r,c){if("translucent"!==l.renderPass)return;const d=r.paint.get("circle-opacity"),f=r.paint.get("circle-stroke-width"),_=r.paint.get("circle-stroke-opacity"),T=void 0!==r.layout.get("circle-sort-key").constantOr(1),S=r.paint.get("circle-emissive-strength");if(0===d.constantOr(1)&&(0===f.constantOr(1)||0===_.constantOr(1)))return;const A=l.context,I=A.gl,z=l.transform,D=l.depthModeForSublayer(0,dt.ReadOnly),L=Et.disabled,F=l.colorModeForDrapableLayerRenderPass(S),N="globe"===z.projection.name,V=[s.am(z.center.lng),s.at(z.center.lat)],U=[];for(let Y=0;YY.sortKey-$.sortKey);const W={useDepthForOcclusion:z.depthOcclusionForSymbolsAndCircles};for(const Y of U){const{programConfiguration:$,program:Q,layoutVertexBuffer:J,globeExtVertexBuffer:ne,indexBuffer:ie,uniformValues:oe,tile:de}=Y.state,ce=Y.segments;l.terrain&&l.terrain.setupElevationDraw(de,Q,W),l.uploadCommonUniforms(A,Q,de.tileID.toUnwrapped()),Q.draw(l,I.TRIANGLES,D,L,F,yt.disabled,oe,r.id,J,ie,ce,r.paint,z.zoom,$,[ne])}},heatmap:function(l,t,r,c){if(0!==r.paint.get("heatmap-opacity"))if("offscreen"===l.renderPass){const d=l.context,f=d.gl,_=Et.disabled,T=new Zt([f.ONE,f.ONE,f.ONE,f.ONE],s.bz.transparent,[!0,!0,!0,!0]);(function(L,F,N,V){const U=L.gl,W=F.width*V,Y=F.height*V;L.activeTexture.set(U.TEXTURE1),L.viewport.set([0,0,W,Y]);let $=N.heatmapFbo;if(!$||$&&($.width!==W||$.height!==Y)){$&&$.destroy();const Q=U.createTexture();U.bindTexture(U.TEXTURE_2D,Q),U.texParameteri(U.TEXTURE_2D,U.TEXTURE_WRAP_S,U.CLAMP_TO_EDGE),U.texParameteri(U.TEXTURE_2D,U.TEXTURE_WRAP_T,U.CLAMP_TO_EDGE),U.texParameteri(U.TEXTURE_2D,U.TEXTURE_MIN_FILTER,U.LINEAR),U.texParameteri(U.TEXTURE_2D,U.TEXTURE_MAG_FILTER,U.LINEAR),$=N.heatmapFbo=L.createFramebuffer(W,Y,!0,null),function(J,ne,ie,oe,de,ce){const ae=J.gl;ae.texImage2D(ae.TEXTURE_2D,0,J.extRenderToTextureHalfFloat?ae.RGBA16F:ae.RGBA,de,ce,0,ae.RGBA,J.extRenderToTextureHalfFloat?ae.HALF_FLOAT:ae.UNSIGNED_BYTE,null),oe.colorAttachment.set(ie)}(L,0,Q,$,W,Y)}else U.bindTexture(U.TEXTURE_2D,$.colorAttachment.get()),L.bindFramebuffer.set($.framebuffer)})(d,l,r,"globe"===l.transform.projection.name?.5:.25),d.clear({color:s.bz.transparent});const S=l.transform,A="globe"===S.projection.name,I=A?["PROJECTION_GLOBE_VIEW"]:[],z=A?yt.frontCCW:yt.disabled,D=[s.am(S.center.lng),s.at(S.center.lat)];for(let L=0;L0&&T<1;const de=r.paint.get("line-gradient"),ce=J?"linePattern":"line",ae=s.cV(r);let ye;if(F&&l.terrain&&l.terrain.clipOrMaskOverlapStencilType()&&(oe=!1),0!==T&&l.depthOcclusion){const ke=r.paint._values["line-opacity"];ke&&ke.value&&"constant"===ke.value.kind?ye=ke.value:s.w(`Occlusion opacity for layer ${r.id} is supported only when line-opacity isn't data-driven.`)}if(z&&(l.forceTerrainMode=!0),!z&&0!==T&&l.terrain&&!F)return void s.w(`Occlusion opacity for layer ${r.id} is supported on terrain only if the layer has non-zero line-z-offset.`);const Ie=oe&&z?l.stencilModeFor3D():Et.disabled;for(const ke of c){const Ae=t.getTile(ke);if(J&&!Ae.patternsLoaded())continue;const Ne=Ae.getBucket(r);if(!Ne)continue;l.prepareDrawTile();const xe=Ne.programConfigurations.get(r.id),Re=l.isTileAffectedByFog(ke),ze=l.getOrCreateProgram(ce,{config:xe,defines:z?[...ae,"ELEVATED"]:ae,overrideFog:Re});if(ne&&Ae.imageAtlas){const Ze=Ae.imageAtlas.patternPositions[ne.toString()];Ze&&xe.setConstantPatternPositions(Ze)}if(!J&&Y&&$&&Ae.lineAtlas){const Ze=Ae.lineAtlas.getDash(Y,$);Ze&&xe.setConstantPatternPositions(Ze)}let[Ue,Ge]=r.paint.get("line-trim-offset");("round"===$||"square"===$)&&Ue!==Ge&&(0===Ue&&(Ue-=1),1===Ge&&(Ge+=1));const Le=F?ke.projMatrix:null,Be=J?s.cW(l,Ae,r,Le,N,[Ue,Ge]):s.cX(l,Ae,r,Le,Ne.lineClipsArray.length,N,[Ue,Ge]);if(de){const Ze=Ne.gradients[r.id];let et=Ze.texture;if(r.gradientVersion!==Ze.version){let _t=256;if(r.stepInterpolant){const ot=t.getSource().maxzoom,pt=ke.canonical.z===ot?Math.ceil(1<{null!=ye&&(ye.value=ie*T),ze.draw(l,A.TRIANGLES,D,Ze,L,yt.disabled,Be,r.id,Ne.layoutVertexBuffer,Ne.indexBuffer,Ne.segments,r.paint,l.transform.zoom,xe,[Ne.layoutVertexBuffer2,Ne.patternVertexBuffer,Ne.zOffsetVertexBuffer]),null!=ye&&(ye.value=ie)};if(oe&&!z){const Ze=l.stencilModeForClipping(ke).ref;0===Ze&&F&&S.clear({stencil:0});const et={func:A.EQUAL,mask:255};Be.u_alpha_discard_threshold=.8,ht(new Et(et,Ze,255,A.KEEP,A.KEEP,A.INVERT)),Be.u_alpha_discard_threshold=0,ht(new Et(et,Ze,255,A.KEEP,A.KEEP,A.KEEP))}else oe&&z&&(Be.u_alpha_discard_threshold=.001),ht(z?Ie:l.stencilModeForClipping(ke))}oe&&(l.resetStencilClippingMasks(),F&&S.clear({stencil:0})),0===T||l.depthOcclusion||F||l.layersWithOcclusionOpacity.push(l.currentLayer),z&&(l.forceTerrainMode=!1)},fill:function(l,t,r,c){const d=r.paint.get("fill-color"),f=r.paint.get("fill-opacity"),_=r.is3D(),T=new dt(l.context.gl.LEQUAL,dt.ReadWrite,l.depthRangeFor3D);if(0===f.constantOr(1))return;const S=r.paint.get("fill-emissive-strength"),A=l.colorModeForDrapableLayerRenderPass(S),I=r.paint.get("fill-pattern"),z=l.opaquePassEnabledForLayer()&&!I.constantOr(1)&&1===d.constantOr(s.bz.transparent).a&&1===f.constantOr(0)?"opaque":"translucent";if(l.renderPass===z){const D=_?T:l.depthModeForSublayer(1,"opaque"===l.renderPass?dt.ReadWrite:dt.ReadOnly);bl(l,t,r,c,D,A,!1)}if(!_&&"translucent"===l.renderPass&&r.paint.get("fill-antialias")){const D=_?T:l.depthModeForSublayer(r.getPaintProperty("fill-outline-color")?2:0,dt.ReadOnly);bl(l,t,r,c,D,A,!0)}},"fill-extrusion":function(l,t,r,c){const d=r.paint.get("fill-extrusion-opacity"),f=l.context,_=f.gl,T=l.terrain,S=T&&T.renderingToTexture;if(0===d)return;const A=l.conflationActive&&l.style.isLayerClipped(r,t.getSource()),I=l.style.order.indexOf(r.fqid);if(A&&function(z,D,L,F,N){for(const V of F){const U=D.getTile(V).getBucket(L);U&&(U.updateReplacement(V,z.replacementSource,N),U.uploadCentroid(z.context))}}(l,t,r,c,I),T||A)for(const z of c){const D=t.getTile(z).getBucket(r);D&&to(l.context,t,z,D,r,T,A)}if("shadow"===l.renderPass&&l.shadowRenderer){const z=l.shadowRenderer;if(T&&d<.65&&r._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof s.a4)return;const D=z.getShadowPassDepthMode(),L=z.getShadowPassColorMode();_s(l,t,r,c,D,Et.disabled,L,A)}else if("translucent"===l.renderPass){const z=!r.paint.get("fill-extrusion-pattern").constantOr(1),D=r.paint.get("fill-extrusion-color").constantOr(s.bz.white);if(!S&&0!==D.a){const L=new dt(l.context.gl.LEQUAL,dt.ReadWrite,l.depthRangeFor3D);1===d&&z?_s(l,t,r,c,L,Et.disabled,Zt.unblended,A):(_s(l,t,r,c,L,Et.disabled,Zt.disabled,A),_s(l,t,r,c,L,l.stencilModeFor3D(),l.colorModeForRenderPass(),A),l.resetStencilClippingMasks())}if(l.style.enable3dLights()&&z&&(!T&&"globe"!==l.transform.projection.name||S)){const L=r.paint.get("fill-extrusion-opacity"),F=r.paint.get("fill-extrusion-ambient-occlusion-intensity"),N=r.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),V=r.paint.get("fill-extrusion-flood-light-intensity"),U=r.paint.get("fill-extrusion-flood-light-color").toRenderColor(r.lut).toArray01().slice(0,3),W=F>0&&N>0,Y=V>0,$=(J,ne,ie)=>(1-ie)*J+ie*ne,Q=J=>{const ne=l.depthModeForSublayer(1,dt.ReadOnly,_.LEQUAL,!0),ie=r.paint.get(J?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),oe=$(.1,3,ie),de=l._showOverdrawInspector;if(!de){const ce=new Et({func:_.ALWAYS,mask:255},255,255,_.KEEP,_.KEEP,_.REPLACE),ae=new Zt([_.ONE,_.ONE,_.ONE,_.ONE],s.bz.transparent,[!1,!1,!1,!0],_.MIN);or(l,t,r,c,ne,ce,ae,yt.disabled,J,"sdf",L,F,N,V,U,oe,A,!1)}{const ce=de?Et.disabled:new Et({func:_.EQUAL,mask:255},255,255,_.KEEP,_.DECR,_.DECR),ae=de?l.colorModeForRenderPass():new Zt([_.ONE_MINUS_DST_ALPHA,_.DST_ALPHA,_.ONE,_.ONE],s.bz.transparent,[!0,!0,!0,!0]);or(l,t,r,c,ne,ce,ae,yt.disabled,J,"color",L,F,N,V,U,oe,A,!1)}};if(S){const J=(ne,ie,oe)=>{const de=l.depthModeForSublayer(1,dt.ReadOnly,_.LEQUAL,!1),ce=r.paint.get(ne?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),ae=$(.1,3,ce);{const ye=new Zt([_.ONE,_.ONE,_.ONE,_.ONE],s.bz.transparent,[!1,!1,!1,!0]);or(l,t,r,c,de,Et.disabled,ye,yt.disabled,ne,"clear",L,F,N,V,U,ae,A,ie)}{const ye=new Et({func:_.ALWAYS,mask:255},255,255,_.KEEP,_.KEEP,_.REPLACE),Ie=new Zt([_.ONE,_.ONE,_.ONE,_.ONE],s.bz.transparent,[!1,!1,!1,!0],_.MIN);or(l,t,r,c,de,ye,Ie,yt.disabled,ne,"sdf",L,F,N,V,U,ae,A,ie)}{const ye=ne?_.ZERO:_.ONE_MINUS_DST_ALPHA,Ie=new Et({func:_.EQUAL,mask:255},255,255,_.KEEP,_.DECR,_.DECR),ke=new Zt([ye,_.DST_ALPHA,_.ONE_MINUS_DST_ALPHA,_.ZERO],s.bz.transparent,[!0,!0,!0,!0]);or(l,t,r,c,de,Ie,ke,yt.disabled,ne,"color",L,F,N,V,U,ae,A,ie)}{const ye=new Zt([_.ONE,_.ONE,_.ONE,ne?_.ZERO:_.ONE],s.bz.transparent,[!1,!1,!1,!0],ne?_.FUNC_ADD:_.MAX);or(l,t,r,c,de,Et.disabled,ye,yt.disabled,ne,"clear",L,F,N,V,U,ae,A,ie,oe)}};if(W||Y){let ne;if(l.prepareDrawTile(),T){const ie=T.drapeBufferSize[0],oe=T.drapeBufferSize[1];ne=T.framebufferCopyTexture,ne&&(!ne||ne.size[0]===ie&&ne.size[1]===oe)||(ne&&ne.destroy(),ne=T.framebufferCopyTexture=new s.T(f,new s.r({width:ie,height:oe}),_.RGBA8)),ne.bind(_.LINEAR,_.CLAMP_TO_EDGE),_.copyTexImage2D(_.TEXTURE_2D,0,_.RGBA,0,0,ie,oe,0)}W&&J(!0,!1,ne),Y&&J(!1,!0,ne)}}else W&&Q(!0),Y&&Q(!1),(W||Y)&&l.resetStencilClippingMasks()}}},hillshade:function(l,t,r,c){if("offscreen"!==l.renderPass&&"translucent"!==l.renderPass||l.style.disableElevatedTerrain)return;const d=l.context,f=l.terrain&&l.terrain.renderingToTexture,[_,T]="translucent"!==l.renderPass||f?[{},c]:l.stencilConfigForOverlap(c);for(const S of T){const A=t.getTile(S);if(A.needsHillshadePrepare&&"offscreen"===l.renderPass)oa(l,A,r);else if("translucent"===l.renderPass){const I=l.depthModeForSublayer(0,dt.ReadOnly),z=r.paint.get("hillshade-emissive-strength"),D=l.colorModeForDrapableLayerRenderPass(z),L=f&&l.terrain?l.terrain.stencilModeForRTTOverlap(S):_[S.overscaledZ];rl(l,S,A,r,I,L,D)}}d.viewport.set([0,0,l.width,l.height]),l.resetStencilClippingMasks()},raster:function(l,t,r,c,d,f){if("translucent"!==l.renderPass||0===r.paint.get("raster-opacity"))return;const _="globe"===l.transform.projection.name,T=0!==r.paint.get("raster-elevation"),S=T&&_;if(l.renderElevatedRasterBackface&&!S)return;const A=l.context,I=A.gl,z=t.getSource(),D=function(J,ne,ie,oe){const de=ne.paint.get("raster-color"),ce="raster-array"===J.type,ae=[],ye=ne.paint.get("raster-resampling"),Ie=ne.paint.get("raster-color-mix");let ke=ne.paint.get("raster-color-range");const Ae=[Ie[0],Ie[1],Ie[2],0],Ne=Ie[3];let xe="nearest"===ye?oe.NEAREST:oe.LINEAR;if(ce&&(ae.push("RASTER_ARRAY"),de||ae.push("RASTER_COLOR"),"linear"===ye&&ae.push("RASTER_ARRAY_LINEAR"),xe=oe.NEAREST,!ke&&J.rasterLayers)){const Re=J.rasterLayers.find(({id:ze})=>ze===ne.sourceLayer);Re&&Re.fields&&Re.fields.range&&(ke=Re.fields.range)}if(ke=ke||[0,1],de){ae.push("RASTER_COLOR"),ie.activeTexture.set(oe.TEXTURE2),ne.updateColorRamp(ke);let Re=ne.colorRampTexture;Re||(Re=ne.colorRampTexture=new s.T(ie,ne.colorRamp,oe.RGBA8)),Re.bind(oe.LINEAR,oe.CLAMP_TO_EDGE)}return{mix:Ae,range:ke,offset:Ne,defines:ae,resampling:xe}}(z,r,A,I);if(z instanceof s.aD&&!c.length&&!_)return;const L=r.paint.get("raster-emissive-strength"),F=l.colorModeForDrapableLayerRenderPass(L),N=l.terrain&&l.terrain.renderingToTexture,V=!l.options.moving,U="nearest"===r.paint.get("raster-resampling")?I.NEAREST:I.LINEAR;if(z instanceof s.aD&&!c.length&&(z.onNorthPole||z.onSouthPole)){const J=T?l.stencilModeFor3D():Et.disabled;return void zr(!!z.onNorthPole,null,l,t,r,L,D,yt.disabled,J)}if(!c.length)return;const[W,Y]=z instanceof s.aD||N?[{},c]:l.stencilConfigForOverlap(c),$=Y[Y.length-1].overscaledZ;S&&D.defines.push("PROJECTION_GLOBE_VIEW"),T&&D.defines.push("RENDER_CUTOFF");const Q=(J,ne,ie)=>{for(const oe of J){const de=oe.toUnwrapped(),ce=t.getTile(oe);if(N&&(!ce||!ce.hasData()))continue;A.activeTexture.set(I.TEXTURE0);const ae=wl(ce,z,r,D);if(!ae||!ae.texture)continue;const{texture:ye,mix:Ie,offset:ke,tileSize:Ae,buffer:Ne}=ae;let xe,Re;N?(xe=dt.disabled,Re=oe.projMatrix):T?(xe=new dt(I.LEQUAL,dt.ReadWrite,l.depthRangeFor3D),Re=_?Float32Array.from(l.transform.expandedFarZProjMatrix):l.transform.calculateProjMatrix(de,V)):(xe=l.depthModeForSublayer(oe.overscaledZ-$,1===r.paint.get("raster-opacity")?dt.ReadWrite:dt.ReadOnly,I.LESS),Re=l.transform.calculateProjMatrix(de,V));const ze=l.terrain&&N?l.terrain.stencilModeForRTTOverlap(oe):W[oe.overscaledZ],Ue=f?0:r.paint.get("raster-fade-duration");ce.registerFadeDuration(Ue);const Ge=t.findLoadedParent(oe,0),Le=hl(ce,Ge,t,l.transform,Ue);let Be,ht;l.terrain&&l.terrain.prepareDrawTile(),A.activeTexture.set(I.TEXTURE0),ye.bind(U,I.CLAMP_TO_EDGE),A.activeTexture.set(I.TEXTURE1),Ge?(Ge.texture&&Ge.texture.bind(U,I.CLAMP_TO_EDGE),Be=Math.pow(2,Ge.tileID.overscaledZ-ce.tileID.overscaledZ),ht=[ce.tileID.canonical.x*Be%1,ce.tileID.canonical.y*Be%1]):ye.bind(U,I.CLAMP_TO_EDGE),ye.useMipmap&&A.extTextureFilterAnisotropic&&l.transform.pitch>20&&I.texParameterf(I.TEXTURE_2D,A.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,A.extTextureFilterAnisotropicMax);const Ze=l.transform;let et;const _t=T?Bi(Ze):[0,0,0,0];let ot,pt,Ft,Lt,di,yi=0;if(S&&z instanceof s.aD&&z.coordinates.length>3)ot=Float32Array.from(s.b5(s.cC(new s.bP(0,0,0)))),pt=Float32Array.from(Ze.globeMatrix),Ft=Float32Array.from(s.cy(Ze)),Lt=[s.am(Ze.center.lng),s.at(Ze.center.lat)],et=z.elevatedGlobePerspectiveTransform,di=z.elevatedGlobeGridMatrix||new Float32Array(9);else if(S){const $t=s.cz(oe.canonical);yi=s.cA($t.getCenter().lat),ot=Float32Array.from(s.b5(s.cC(oe.canonical))),pt=Float32Array.from(Ze.globeMatrix),Ft=Float32Array.from(s.cy(Ze)),Lt=[s.am(Ze.center.lng),s.at(Ze.center.lat)],et=[0,0],di=Float32Array.from(s.cB(oe.canonical,$t,yi,Ze.worldSize/Ze._pixelsPerMercatorPixel))}else et=z instanceof s.aD?z.perspectiveTransform:[0,0],ot=new Float32Array(16),pt=new Float32Array(9),Ft=new Float32Array(16),Lt=[0,0],di=new Float32Array(9);const Si=da(Re,ot,pt,Ft,di,ht||[0,0],s.a9(l.transform.zoom),Lt,_t,Be||1,Le,r,et,T?r.paint.get("raster-elevation"):0,2,Ie,ke,D.range,Ae,Ne,L),Hr=l.isTileAffectedByFog(oe),qi=l.getOrCreateProgram("raster",{defines:D.defines,overrideFog:Hr});if(l.uploadCommonUniforms(A,qi,de),z instanceof s.aD){const $t=z.elevatedGlobeVertexBuffer,mi=z.elevatedGlobeIndexBuffer;if(N||!_)z.boundsBuffer&&z.boundsSegments&&qi.draw(l,I.TRIANGLES,xe,Et.disabled,F,yt.disabled,Si,r.id,z.boundsBuffer,l.quadTriangleIndexBuffer,z.boundsSegments);else if($t&&mi){const Pi=Ze.zoom<=s.c2?z.elevatedGlobeSegments:z.getSegmentsForLongitude(Ze.center.lng);Pi&&qi.draw(l,I.TRIANGLES,xe,Et.disabled,F,ne,Si,r.id,$t,mi,Pi)}}else if(S){xe=new dt(I.LEQUAL,dt.ReadOnly,l.depthRangeFor3D);const $t=l.globeSharedBuffers;if($t){const[mi,Pi,fi]=$t.getGridBuffers(yi,!1);qi.draw(l,I.TRIANGLES,xe,ie||ze,l.colorModeForRenderPass(),ne,Si,r.id,mi,Pi,fi)}}else{const{tileBoundsBuffer:$t,tileBoundsIndexBuffer:mi,tileBoundsSegments:Pi}=l.getTileBoundsBuffers(ce);qi.draw(l,I.TRIANGLES,xe,ze,F,yt.disabled,Si,r.id,$t,mi,Pi)}}if(!(z instanceof s.aD)&&S)for(const oe of J){const de=oe.canonical.y===(1<>>16,2654435769),((oe=Math.imul(oe^oe>>>16,2654435769))>>>0)/4294967296},ie=1/1.1;for(let oe=0;oes.c$[ze](ye));Ne.push(ye);const xe=ye.canonical.x,Re=ye.canonical.y;for(const ze of Ne){const Ue=$.getTile(de?ze.wrapped():ze);if(!Ue)continue;const Ge=Ue.rasterParticleState;if(!Ge)continue;const Le=ze.canonical.x+(1<Q.tileID)),D&&(S.activeTexture.set(A.TEXTURE0),l.imageManager.bind(l.context,r.scope)),T){const Q=l.getOrCreateProgram(W,{overrideFog:!1,overrideRtt:!0}),J=new Float32Array(s.a6.mat4.identity([])),ne=new s.aA(0,0,0,0,0),ie=D?Ao(J,_,f,l,0,r.scope,L,T,{tileID:ne,tileSize:z}):vu(J,_,f,d.toRenderColor(r.lut));Q.draw(l,A.TRIANGLES,V,N,U,yt.disabled,ie,r.id,l.viewportBuffer,l.quadTriangleIndexBuffer,l.viewportSegments)}else for(const Q of $){const J=l.isTileAffectedByFog(Q),ne=l.getOrCreateProgram(W,{overrideFog:J}),ie=Q.toUnwrapped(),oe=c?Q.projMatrix:l.transform.calculateProjMatrix(ie);l.prepareDrawTile();const de=t?t.getTile(Q):Y?Y[Q.key]:new fn(Q,z,I.zoom,l),ce=D?Ao(oe,_,f,l,0,r.scope,L,T,{tileID:Q,tileSize:z}):vu(oe,_,f,d.toRenderColor(r.lut));l.uploadCommonUniforms(S,ne,ie);const{tileBoundsBuffer:ae,tileBoundsIndexBuffer:ye,tileBoundsSegments:Ie}=l.getTileBoundsBuffers(de);ne.draw(l,A.TRIANGLES,V,N,U,yt.disabled,ce,r.id,ae,ye,Ie)}},sky:function(l,t,r){const c=l._atmosphere?s.a9(l.transform.zoom):1,d=r.paint.get("sky-opacity")*c;if(0===d)return;const f=l.context,_=r.paint.get("sky-type"),T=new dt(f.gl.LEQUAL,dt.ReadOnly,[0,1]),S=l.frameCounter/1e3%1;"atmosphere"===_?"offscreen"===l.renderPass?r.needsSkyboxCapture(l)&&(function(A,I){const L=A.context,F=L.gl;let N=I.skyboxFbo;if(!N){N=I.skyboxFbo=L.createFramebuffer(32,32,!0,null),I.skyboxGeometry=new Gc(L),I.skyboxTexture=L.gl.createTexture(),F.bindTexture(F.TEXTURE_CUBE_MAP,I.skyboxTexture),F.texParameteri(F.TEXTURE_CUBE_MAP,F.TEXTURE_WRAP_S,F.CLAMP_TO_EDGE),F.texParameteri(F.TEXTURE_CUBE_MAP,F.TEXTURE_WRAP_T,F.CLAMP_TO_EDGE),F.texParameteri(F.TEXTURE_CUBE_MAP,F.TEXTURE_MIN_FILTER,F.LINEAR),F.texParameteri(F.TEXTURE_CUBE_MAP,F.TEXTURE_MAG_FILTER,F.LINEAR);for(let Y=0;Y<6;++Y)F.texImage2D(F.TEXTURE_CUBE_MAP_POSITIVE_X+Y,0,F.RGBA,32,32,0,F.RGBA,F.UNSIGNED_BYTE,null)}L.bindFramebuffer.set(N.framebuffer),L.viewport.set([0,0,32,32]);const V=I.getCenter(A,!0),U=A.getOrCreateProgram("skyboxCapture"),W=new Float64Array(16);s.a6.mat4.identity(W),s.a6.mat4.rotateY(W,W,.5*-Math.PI),Co(A,I,U,W,V,0),s.a6.mat4.identity(W),s.a6.mat4.rotateY(W,W,.5*Math.PI),Co(A,I,U,W,V,1),s.a6.mat4.identity(W),s.a6.mat4.rotateX(W,W,.5*-Math.PI),Co(A,I,U,W,V,2),s.a6.mat4.identity(W),s.a6.mat4.rotateX(W,W,.5*Math.PI),Co(A,I,U,W,V,3),s.a6.mat4.identity(W),Co(A,I,U,W,V,4),s.a6.mat4.identity(W),s.a6.mat4.rotateY(W,W,Math.PI),Co(A,I,U,W,V,5),L.viewport.set([0,0,A.width,A.height])}(l,r),r.markSkyboxValid(l)):"sky"===l.renderPass&&function(A,I,z,D,L){const F=A.context,N=F.gl,V=A.transform,U=A.getOrCreateProgram("skybox");F.activeTexture.set(N.TEXTURE0),N.bindTexture(N.TEXTURE_CUBE_MAP,I.skyboxTexture);const W=((Y,$,Q,J,ne)=>({u_matrix:Y,u_sun_direction:$,u_cubemap:0,u_opacity:J,u_temporal_offset:ne}))(V.skyboxMatrix,I.getCenter(A,!1),0,D,L);A.uploadCommonUniforms(F,U),U.draw(A,N.TRIANGLES,z,Et.disabled,A.colorModeForRenderPass(),yt.backCW,W,"skybox",I.skyboxGeometry.vertexBuffer,I.skyboxGeometry.indexBuffer,I.skyboxGeometry.segment)}(l,r,T,d,S):"gradient"===_&&"sky"===l.renderPass&&function(A,I,z,D,L){const F=A.context,N=F.gl,V=A.transform,U=A.getOrCreateProgram("skyboxGradient");I.skyboxGeometry||(I.skyboxGeometry=new Gc(F)),F.activeTexture.set(N.TEXTURE0);let W=I.colorRampTexture;W||(W=I.colorRampTexture=new s.T(F,I.colorRamp,N.RGBA8)),W.bind(N.LINEAR,N.CLAMP_TO_EDGE);const Y=($=V.skyboxMatrix,Q=I.getCenter(A,!1),J=I.paint.get("sky-gradient-radius"),ne=D,ie=L,{u_matrix:$,u_color_ramp:0,u_center_direction:Q,u_radius:s.bB(J),u_opacity:ne,u_temporal_offset:ie});var $,Q,J,ne,ie;A.uploadCommonUniforms(F,U),U.draw(A,N.TRIANGLES,z,Et.disabled,A.colorModeForRenderPass(),yt.backCW,Y,"skyboxGradient",I.skyboxGeometry.vertexBuffer,I.skyboxGeometry.indexBuffer,I.skyboxGeometry.segment)}(l,r,T,d,S)},debug:function(l,t,r,c,d,f){for(let _=0;_{_&&(_.useNormalOffset=!0,T||(_.enabled=!0))},A=t.getSource();if("light-beam"===l.renderPass&&"batched-model"!==A.type)return;if("vector"===A.type||"geojson"===A.type)return function(U,W,Y,$,Q){const J=U.transform;if("mercator"!==J.projection.name)return void s.w(`Drawing 3D models for ${J.projection.name} projection is not yet implemented`);const ne=J.getFreeCameraOptions().position;if(!U.modelManager)return;const ie=U.modelManager;Y.modelManager=ie;const oe=U.shadowRenderer;if(!Y._unevaluatedLayout._values.hasOwnProperty("model-id"))return;const de=Y._unevaluatedLayout._values["model-id"],ce={...Y.layout.get("model-id").parameters},ae=U.style.order.indexOf(Y.fqid);for(const ye of $){const Ie=W.getTile(ye).getBucket(Y);if(!Ie||Ie.projection.name!==J.projection.name)continue;const ke=Ie.getModelUris();ke&&!Ie.modelsRequested&&(ie.addModelsFromBucket(ke,Q),Ie.modelsRequested=!0);const Ae=$d(ye,J);ce.zoom=Ae;const Ne=de.possiblyEvaluate(ce);if(Au(U,Ie,ye),cn.shadowUniformsInitialized=!1,cn.useSingleShadowCascade=!!oe&&0===oe.getMaxCascadeForTile(ye.toUnwrapped()),"shadow"===U.renderPass&&oe){if(1===U.currentShadowCascade&&Ie.isInsideFirstShadowMapFrustum)continue;const ze=J.calculatePosMatrix(ye.toUnwrapped(),J.worldSize);if(cn.tileMatrix.set(ze),cn.shadowTileMatrix=Float32Array.from(oe.calculateShadowPassMatrixFromMatrix(ze)),cn.aabb.min.fill(0),cn.aabb.max[0]=cn.aabb.max[1]=s.ab,cn.aabb.max[2]=0,xa(Ie,cn,U,Y.scope))continue}const xe=1<0&&U.style.isLayerClipped(Y,W.getSource())&&Ie.updateReplacement(ye,U.replacementSource,ae,Q)&&(Ie.uploaded=!1,Ie.upload(U.context));for(let ze in Ie.instancesPerModel){const Ue=Ie.instancesPerModel[ze];Ue.features.length>0&&(ze=Ne.evaluate(Ue.features[0].feature,{}));const Ge=ie.getModel(ze,Q);if(Ge&&Ge.uploaded)for(const Le of Ge.nodes)_r(U,Y,Le,Ue,Re,ye,cn)}}}(l,t,r,c,"vector"===A.type?r.scope:""),void S();if(!A.loaded())return;if("batched-model"===A.type)return function(U,W,Y,$){Y.resetLayerRenderingStats(U);const Q=U.context,J=U.transform,ne=U.style.fog,ie=U.shadowRenderer;if("mercator"!==J.projection.name)return void s.w(`Drawing 3D landmark models for ${J.projection.name} projection is not yet implemented`);const oe=U.transform.getFreeCameraOptions().position,de=s.a6.vec3.scale([],[oe.x,oe.y,oe.z],U.transform.worldSize),ce=s.a6.vec3.negate([],de),ae=s.a6.mat4.identity([]),ye=s.de(J.center.lat,J.zoom),Ie=s.a6.mat4.fromScaling([],[1,1,1/ye]);s.a6.mat4.translate(ae,ae,ce);const ke=Y.paint.get("model-opacity"),Ae=new dt(Q.gl.LEQUAL,dt.ReadWrite,U.depthRangeFor3D),Ne=new dt(Q.gl.LEQUAL,dt.ReadOnly,U.depthRangeFor3D),xe=new s.c9([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),Re="shadow"===U.renderPass,ze=Re&&ie?ie.getCurrentCascadeFrustum():J.getFrustum(J.scaleZoom(J.worldSize)),Ue=Y.paint.get("model-front-cutoff"),Ge=Ue[2]<1,Le=Rn(U,Y.paint.get("model-cutoff-fade-range")),Be=Y.getLayerRenderingStats();(function(ht,Ze,et,_t){const ot=ht.terrain?ht.terrain.exaggeration():0,pt=ht.transform.zoom;for(const Ft of _t){const Lt=Ze.getTile(Ft).getBucket(et);Lt&&(ht.conflationActive&&Lt.updateReplacement(Ft,ht.replacementSource),Lt.evaluateScale(ht,et),ht.terrain&&ot>0&&Lt.elevationUpdate(ht.terrain,ot,Ft,et.source),Lt.needsReEvaluation(ht,pt,et)&&Lt.evaluate(et))}})(U,W,Y,$),function(){let ht,Ze,et;Ge?(ht=$.length-1,Ze=-1,et=-1):(ht=0,Ze=$.length,et=1);const _t=new Float64Array(16),ot=s.a6.vec3.create(),pt=new s.P(0,0);for(let Ft=ht;Ft!==Ze;Ft+=et){const Lt=$[Ft],di=W.getTile(Lt).getBucket(Y);if(!di||!di.uploaded)continue;let yi=!1;ie&&(yi=0===ie.getMaxCascadeForTile(Lt.toUnwrapped()));const Si=J.calculatePosMatrix(Lt.toUnwrapped(),J.worldSize),Hr=di.modelTraits;!Re&&Ge&&(s.a6.mat4.invert(_t,Si),s.a6.vec3.transformMat4(ot,de,_t),pt.x=ot[0],pt.y=ot[1]);const qi=[];for(const $t of di.getNodesInfo()){if($t.hiddenByReplacement||!$t.node.meshes)continue;const mi=$t.node;let Pi=0;U.terrain&&mi.elevation&&(Pi=mi.elevation*U.terrain.exaggeration());const fi=(()=>{const bi=$t.aabb;return xe.min=[...bi.min],xe.max=[...bi.max],xe.min[2]+=Pi,xe.max[2]+=Pi,s.a6.vec3.transformMat4(xe.min,xe.min,Si),s.a6.vec3.transformMat4(xe.max,xe.max,Si),xe})(),Ot=$t.evaluatedScale;if(Ot[0]<=1&&Ot[1]<=1&&Ot[2]<=1&&0===fi.intersects(ze))continue;if(!Re&&Ge){const bi=.16666666666666666;$t.cameraCollisionOpacity=de[0]>fi.min[0]&&de[0]fi.min[1]&&de[1]!Ge||1===$t.opacity&&1===mi.opacity?$t.depthmi.depth?-1:1);for(const $t of qi){const mi=$t.nodeInfo,Pi=mi.node;let fi=s.a6.mat4.multiply([],Ie,$t.tileModelMatrix);s.a6.mat4.multiply(fi,ae,fi);const Ot=s.a6.mat4.invert([],fi);s.a6.mat4.transpose(Ot,Ot),s.a6.mat4.scale(Ot,Ot,Hd),fi=s.a6.mat4.multiply(fi,fi,Pi.matrix);const ii="light-beam"===U.renderPass,ci=Hr&s.dj.HasMapboxMeshFeatures,Ni=ci?0:mi.evaluatedRMEA[0][2];for(let Zi=0;Zi=Ke||As>=Ke}}const Mr=Kt.material;let Wr;Mr.occlusionTexture&&Mr.occlusionTexture.offsetScale&&(Wr=Mr.occlusionTexture.offsetScale,Qi.defines.push("OCCLUSION_TEXTURE_TRANSFORM")),!Re&&ie&&(ie.useNormalOffset=!!Kt.normalBuffer);const Ur=U.getOrCreateProgram("model",Qi);!Re&&ie&&ie.setupShadowsFromMatrix($t.tileModelMatrix,Ur,ie.useNormalOffset),U.uploadCommonUniforms(Q,Ur,null,Tr);const Dr=Mr.pbrMetallicRoughness;Dr.metallicFactor=.9,Dr.roughnessFactor=.5;const Xr=rt(new Float32Array(rr),new Float32Array(fi),new Float32Array(Ot),new Float32Array(Pi.matrix),U,$t.opacity,Dr.baseColorFactor.toRenderColor(null),Mr.emissiveFactor,Dr.metallicFactor,Dr.roughnessFactor,Mr,Ni,Y,[0,0,0],Wr);!Ji&&(mi.hasTranslucentParts||$t.opacity<1)&&Ur.draw(U,Q.gl.TRIANGLES,Ae,Et.disabled,Zt.disabled,yt.backCCW,Xr,Y.id,Kt.vertexBuffer,Kt.indexBuffer,Kt.segments,Y.paint,U.transform.zoom,void 0,bi),Ur.draw(U,Q.gl.TRIANGLES,Ji?Ne:Ae,Et.disabled,Ji||$t.opacity<1||mi.hasTranslucentParts?Zt.alphaBlended:Zt.unblended,yt.backCCW,Xr,Y.id,Kt.vertexBuffer,Kt.indexBuffer,Kt.segments,Y.paint,U.transform.zoom,void 0,bi)}}}}()}(l,t,r,c),void S();if("model"!==A.type)return;const I=A.getModels(),z=[],D=l.transform.getFreeCameraOptions().position,L=s.a6.vec3.scale([],[D.x,D.y,D.z],l.transform.worldSize);s.a6.vec3.negate(L,L);const F=[],N=[];let V=0;for(const U of I){const W=r.paint.get("model-rotation").constantOr(null),Y=r.paint.get("model-scale").constantOr(null),$=r.paint.get("model-translation").constantOr(null);U.computeModelMatrix(l,W,Y,$,!0,!0,!1);const Q=s.a6.mat4.identity([]),J=s.de(U.position.lat,l.transform.zoom),ne=s.a6.mat4.fromScaling([],[1,1,1/J]);s.a6.mat4.translate(Q,Q,L),z.push({zScaleMatrix:ne,negCameraPosMatrix:Q});for(const ie of U.nodes)ya(l.transform,ie,U.matrix,l.transform.expandedFarZProjMatrix,V,F,N);V++}if(F.sort((U,W)=>W.depth-U.depth),"shadow"!==l.renderPass){if(1===d)for(const U of N)ga(U,l,r,z[U.modelIndex],Et.disabled,l.colorModeForRenderPass());else{for(const U of N)ga(U,l,r,z[U.modelIndex],Et.disabled,Zt.disabled);for(const U of N)ga(U,l,r,z[U.modelIndex],l.stencilModeFor3D(),l.colorModeForRenderPass());l.resetStencilClippingMasks()}for(const U of F)ga(U,l,r,z[U.modelIndex],Et.disabled,l.colorModeForRenderPass());S()}else{for(const U of N)vs(U.mesh,U.nodeModelMatrix,l,r);for(const U of F)vs(U.mesh,U.nodeModelMatrix,l,r);S()}}},Il={model:function(l,t,r){const c=t.getSource();if(!c.loaded())return;if("vector"===c.type||"geojson"===c.type)return void(r.modelManager&&r.modelManager.upload(r,"vector"===c.type?l.scope:""));if("batched-model"===c.type||"model"!==c.type)return;const d=c.getModels();for(const f of d)f.upload(r.context)},raster:function(l,t,r){const c=t.getSource();if(!(c instanceof Zo&&c.loaded()))return;const d=l.sourceLayer||c.rasterLayerIds&&c.rasterLayerIds[0];if(!d)return;const f=l.paint.get("raster-array-band")||c.getInitialBand(d);if(null==f)return;const _=t.getIds().map(T=>t.getTileByID(T));for(const T of _)T.updateNeeded(d,f)&&c.prepareTile(T,d,f)},"raster-particle":function(l,t,r){const c=t.getSource();if(!(c instanceof Zo&&c.loaded()))return;const d=l.sourceLayer||c.rasterLayerIds&&c.rasterLayerIds[0];if(!d)return;const f=l.paint.get("raster-particle-array-band")||c.getInitialBand(d);if(null==f)return;const _=t.getIds().map(T=>t.getTileByID(T));for(const T of _)T.updateNeeded(d,f)&&c.prepareTile(T,d,f)}};class qc{constructor(t,r,c,d){this.context=new Vd(t,r),this.transform=c,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.tp=d,this._timeStamp=s.q.now(),this._averageFPS=0,this._fpsHistory=[],this._dt=0,this._debugParams={showTerrainProxyTiles:!1,fpsWindow:30,continousRedraw:!1,enabledLayers:{}};const f=["fill","line","symbol","circle","heatmap","fill-extrusion","raster","raster-particle","hillshade","model","background","sky"];for(const T of f)this._debugParams.enabledLayers[T]=!0;d.registerParameter(this._debugParams,["Terrain"],"showTerrainProxyTiles",{},()=>{this.style.map.triggerRepaint()}),d.registerParameter(this._debugParams,["FPS"],"fpsWindow",{min:1,max:100,step:1}),d.registerBinding(this._debugParams,["FPS"],"continousRedraw",{readonly:!0,label:"continuous redraw"}),d.registerBinding(this,["FPS"],"_averageFPS",{readonly:!0,label:"value"}),d.registerBinding(this,["FPS"],"_averageFPS",{readonly:!0,label:"graph",view:"graph",min:0,max:200});for(const T of f)d.registerParameter(this._debugParams.enabledLayers,["Debug","Layers"],T);this.occlusionParams=new Al(d),this.setup(),this.numSublayers=Ar.maxUnderzooming+Ar.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.deferredRenderGpuTimeQueries=[],this.gpuTimers={},this.frameCounter=0,this._backgroundTiles={},this.conflationActive=!1,this.replacementSource=new s.dl,this.longestCutoffRange=0,this.minCutoffZoom=0,this._fogVisible=!1,this._cachedTileFogOpacities={},this._shadowRenderer=new qh(this),this._wireframeDebugCache=new io,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0,this.layersWithOcclusionOpacity=[];const _=new s.r({width:1,height:1},Uint8Array.of(0,0,0,0));this.emptyDepthTexture=new s.T(this.context,_,t.RGBA8),this._clippingActiveLastFrame=!1}updateTerrain(t,r){const c=!!t&&!!t.terrain&&this.transform.projection.supportsTerrain;if(!(c||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new Ic(this,t));const d=this._terrain;this.transform.elevation=c?d:null,d.update(t,this.transform,r),this.transform.elevation&&!d.enabled&&(this.transform.elevation=null)}_updateFog(t){const r=t.fog;if(!r||"globe"===this.transform.projection.name||r.getOpacity(this.transform.pitch)<1||r.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);const[c,d]=r.getFovAdjustedRange(this.transform._fov);if(c>d)return void(this.transform.fogCullDistSq=null);const f=c+.78*(d-c);this.transform.fogCullDistSq=f*f}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 Ic(this,this.style)),this._forceTerrainMode=t}get shadowRenderer(){return this._shadowRenderer&&this._shadowRenderer.enabled?this._shadowRenderer:null}get wireframeDebugCache(){return this._wireframeDebugCache}resize(t,r){if(this.width=t*s.q.devicePixelRatio,this.height=r*s.q.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const c of this.style.order)this.style._mergedLayers[c].resize()}setup(){const t=this.context,r=new s.a_;r.emplaceBack(0,0),r.emplaceBack(s.ab,0),r.emplaceBack(0,s.ab),r.emplaceBack(s.ab,s.ab),this.tileExtentBuffer=t.createVertexBuffer(r,s.b0.members),this.tileExtentSegments=s.b1.simpleSegment(0,0,4,2);const c=new s.a_;c.emplaceBack(0,0),c.emplaceBack(s.ab,0),c.emplaceBack(0,s.ab),c.emplaceBack(s.ab,s.ab),this.debugBuffer=t.createVertexBuffer(c,s.b0.members),this.debugSegments=s.b1.simpleSegment(0,0,4,5);const d=new s.a_;d.emplaceBack(-1,-1),d.emplaceBack(1,-1),d.emplaceBack(-1,1),d.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(d,s.b0.members),this.viewportSegments=s.b1.simpleSegment(0,0,4,2);const f=new s.aN;f.emplaceBack(0,0,0,0),f.emplaceBack(s.ab,0,s.ab,0),f.emplaceBack(0,s.ab,0,s.ab),f.emplaceBack(s.ab,s.ab,s.ab,s.ab),this.mercatorBoundsBuffer=t.createVertexBuffer(f,s.b3.members),this.mercatorBoundsSegments=s.b1.simpleSegment(0,0,4,2);const _=new s.aO;_.emplaceBack(0,1,2),_.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(_);const T=new s.a$;for(const A of[0,1,3,2,0])T.emplaceBack(A);this.debugIndexBuffer=t.createIndexBuffer(T),this.emptyTexture=new s.T(t,new s.r({width:1,height:1},Uint8Array.of(0,0,0,0)),t.gl.RGBA8),this.identityMat=s.a6.mat4.create();const S=this.context.gl;this.stencilClearMode=new Et({func:S.ALWAYS,mask:0},0,255,S.ZERO,S.ZERO,S.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,dt.disabled,this.stencilClearMode,Zt.disabled,yt.disabled,ha(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(t,r,c){if(!r||this.currentStencilSource===r.id||!t.isTileClipped()||!c||0===c.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let T=!1;for(const S of c)if(void 0===this._tileClippingMaskIDs[S.key]){T=!0;break}if(!T)return}this.currentStencilSource=r.id;const d=this.context,f=d.gl;this.nextStencilID+c.length>256&&this.clearStencil(),d.setColorMode(Zt.disabled),d.setDepthMode(dt.disabled);const _=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const T of c){const S=r.getTile(T),A=this._tileClippingMaskIDs[T.key]=this.nextStencilID++,{tileBoundsBuffer:I,tileBoundsIndexBuffer:z,tileBoundsSegments:D}=this.getTileBoundsBuffers(S);_.draw(this,f.TRIANGLES,dt.disabled,new Et({func:f.ALWAYS,mask:0},A,255,f.KEEP,f.KEEP,f.REPLACE),Zt.disabled,yt.disabled,ha(T.projMatrix),"$clipping",I,z,D)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const t=this.nextStencilID++,r=this.context.gl;return new Et({func:r.NOTEQUAL,mask:255},t,255,r.KEEP,r.KEEP,r.REPLACE)}stencilModeForClipping(t){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(t);const r=this.context.gl;return new Et({func:r.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,r.KEEP,r.KEEP,r.REPLACE)}stencilConfigForOverlap(t){const r=this.context.gl,c=t.sort((_,T)=>T.overscaledZ-_.overscaledZ),d=c[c.length-1].overscaledZ,f=c[0].overscaledZ-d+1;if(f>1){this.currentStencilSource=void 0,this.nextStencilID+f>256&&this.clearStencil();const _={};for(let T=0;Tthis._debugParams.fpsWindow&&this._fpsHistory.splice(0,this._fpsHistory.length-this._debugParams.fpsWindow),this._averageFPS=Math.round(this._fpsHistory.reduce((t,r)=>t+r/this._fpsHistory.length,0))}render(t,r){const c=s.q.now();this._dt=c-this._timeStamp,this._timeStamp=c,this._wireframeDebugCache.update(this.frameCounter),this._debugParams.continousRedraw=t.map.repaint,this.style=t,this.options=r;const d=this.style._mergedLayers,f=this.style.order.filter(ce=>{const ae=d[ce];return!(ae.type in this._debugParams.enabledLayers)||this._debugParams.enabledLayers[ae.type]});let _=!1,T=!1;for(const ce of f){const ae=d[ce];"circle"===ae.type&&(_=!0),"symbol"===ae.type&&(ae.hasInitialOcclusionOpacityProperties?T=!0:_=!0)}const S=f.map(ce=>d[ce]),A=this.style._mergedSourceCaches;this.imageManager=t.imageManager,this.modelManager=t.modelManager,this.symbolFadeChange=t.placement.symbolFadeChange(s.q.now()),this.imageManager.beginFrame();let I=0,z=!1;for(const ce in A){const ae=A[ce];ae.used&&(ae.prepare(this.context),ae.getSource().usedInConflation&&++I)}let D=!1;for(const ce of S)ce.isHidden(this.transform.zoom)||("clip"===ce.type&&(D=!0),this.prepareLayer(ce));const L={},F={},N={},V={},U={};for(const ce in A){const ae=A[ce];L[ce]=ae.getVisibleCoordinates(),F[ce]=L[ce].slice().reverse(),N[ce]=ae.getVisibleCoordinates(!0).reverse(),V[ce]=ae.getShadowCasterCoordinates(),U[ce]=ae.sortCoordinatesByDistance(L[ce])}const W=ce=>{const ae=this.style.getLayerSourceCache(ce);return ae&&ae.used?ae.getSource():null};if(I||D||this._clippingActiveLastFrame){const ce=[],ae=[];let ye=0;for(const Ie of S)this.isSourceForClippingOrConflation(Ie,W(Ie))&&(ce.push(Ie),ae.push(ye)),ye++;if(ce&&(D||ce.length>1)||this._clippingActiveLastFrame){D=!1;const Ie=[];for(let ke=0;ke0){const Ie=W(ae);Ie&&(this.minCutoffZoom=Math.max(Ie.minzoom,this.minCutoffZoom)),ae.minzoom&&(this.minCutoffZoom=Math.max(ae.minzoom,this.minCutoffZoom))}ae.is3D()&&(this.opaquePassCutoff===1/0&&(this.opaquePassCutoff=ce),this._lastOcclusionLayer=ce)}const Y=this.style&&this.style.fog;Y?(this._fogVisible=0!==Y.getOpacity(this.transform.pitch),this._fogVisible&&"globe"!==this.transform.projection.name&&(this._fogVisible=Y.isVisibleOnFrustum(this.transform.cameraFrustum))):this._fogVisible=!1,this._cachedTileFogOpacities={},this.terrain&&(this.terrain.updateTileBinding(N),this.opaquePassCutoff=0);const $=this._shadowRenderer;if($){$.updateShadowParameters(this.transform,this.style.directionalLight);for(const ce in A)for(const ae of L[ce]){let ye={min:0,max:0};this.terrain&&(ye=this.terrain.getMinMaxForTile(ae)||ye),$.addShadowReceiver(ae.toUnwrapped(),ye.min,ye.max)}}if("globe"!==this.transform.projection.name||this.globeSharedBuffers||(this.globeSharedBuffers=new s.dm(this.context)),this.style.fog&&this.transform.projection.supportsFog?(this._atmosphere||(this._atmosphere=new Ml(this)),this._atmosphere.update(this)):this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0),!An.has(this.context.gl))return;this.renderPass="offscreen";for(const ce of S){const ae=t.getLayerSourceCache(ce);if(!ce.hasOffscreenPass()||ce.isHidden(this.transform.zoom))continue;const ye=ae?F[ae.id]:void 0;("custom"===ce.type||"raster"===ce.type||"raster-particle"===ce.type||ce.isSky()||ye&&ye.length)&&this.renderLayer(this,ae,ce,ye)}this.depthRangeFor3D=[0,1-(S.length+2)*this.numSublayers*this.depthEpsilon],this._shadowRenderer&&(this.renderPass="shadow",this._shadowRenderer.drawShadowPass(this.style,V)),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]);const Q="globe"===this.transform.projection.name||this.transform.isHorizonVisible(),J=(()=>{if(r.showOverdrawInspector)return s.bz.black;const ce=this.style.fog;if(ce&&this.transform.projection.supportsFog){const ae=this.style.getLut(ce.scope);if(!Q){const ye=ce.properties.get("color").toRenderColor(ae).toArray01();return new s.bz(...ye)}if(Q){const ye=ce.properties.get("space-color").toRenderColor(ae).toArray01();return new s.bz(...ye)}}return s.bz.transparent})();if(this.context.clear({color:J,depth:1}),this.clearStencil(),this._showOverdrawInspector=r.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=f.length-1;this.currentLayer>=0;this.currentLayer--){const ce=S[this.currentLayer],ae=t.getLayerSourceCache(ce);if(ce.isSky())continue;const ye=ae?(ce.is3D()?U:F)[ae.id]:void 0;this._renderTileClippingMasks(ce,ae,ye),this.renderLayer(this,ae,ce,ye)}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||s.a9(this.transform.zoom)>0)&&("globe"===this.transform.projection.name||this.transform.isHorizonVisible()))for(this.currentLayer=0;this.currentLayer0&&ce.hasShadowPass()&&0==--ie&&($.drawGroundShadows(),this.firstLightBeamLayer<=this.currentLayer)){const ye=this.currentLayer;for(this.renderPass="light-beam",this.currentLayer=this.firstLightBeamLayer;this.currentLayer<=ye;this.currentLayer++){const Ie=S[this.currentLayer];if(!Ie.hasLightBeamPass())continue;const ke=t.getLayerSourceCache(Ie);this.renderLayer(this,ke,Ie,ke?F[ke.id]:void 0)}this.currentLayer=ye,this.renderPass="translucent"}if(this.currentLayer>=this._lastOcclusionLayer&&this.layersWithOcclusionOpacity.length>0){const ye=this.currentLayer;this.depthOcclusion=!0;for(const Ie of this.layersWithOcclusionOpacity){this.currentLayer=Ie;const ke=S[this.currentLayer],Ae=t.getLayerSourceCache(ke),Ne=Ae?F[Ae.id]:void 0;ke.is3D()||this.terrain||this._renderTileClippingMasks(ke,Ae,Ae?L[Ae.id]:void 0),this.renderLayer(this,Ae,ke,Ne)}this.depthOcclusion=!1,this.currentLayer=ye,this.renderPass="translucent",this.layersWithOcclusionOpacity=[]}++this.currentLayer}}if(this.terrain&&this.terrain.postRender(),this.options.showTileBoundaries||this.options.showQueryGeometry||this.options.showTileAABBs){let ce=null;S.forEach(ae=>{const ye=t.getLayerSourceCache(ae);ye&&!ae.isHidden(this.transform.zoom)&&ye.getVisibleCoordinates().length&&(!ce||ce.getSource().maxzoom0?r.pop():null}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture||this.forceTerrainMode}linearFloatFilteringSupported(){return null!=this.context.extTextureFloatLinear}currentGlobalDefines(t,r,c){const d=void 0===c?this.terrain&&this.terrain.renderingToTexture:c,f=[];return this.style&&this.style.enable3dLights()&&("globeRaster"===t||"terrainRaster"===t?(f.push("LIGHTING_3D_MODE"),f.push("LIGHTING_3D_ALPHA_EMISSIVENESS")):d||f.push("LIGHTING_3D_MODE")),"shadow"===this.renderPass?this._shadowMapDebug||f.push("DEPTH_TEXTURE"):this.shadowRenderer&&(this.shadowRenderer.useNormalOffset?f.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"):f.push("RENDER_SHADOWS","DEPTH_TEXTURE")),this.terrainRenderModeElevated()&&(f.push("TERRAIN"),this.linearFloatFilteringSupported()&&f.push("TERRAIN_DEM_FLOAT_FORMAT")),"globe"===this.transform.projection.name&&f.push("GLOBE"),!this._fogVisible||d||void 0!==r&&!r||f.push("FOG","FOG_DITHERING"),d&&f.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&f.push("OVERDRAW_INSPECTOR"),f}getOrCreateProgram(t,r){this.cache=this.cache||{};const c=r&&r.defines||[],d=r&&r.config,f=this.currentGlobalDefines(t,r&&r.overrideFog,r&&r.overrideRtt).concat(c),_=eo.cacheKey(Jn[t],t,f,d);return this.cache[_]||(this.cache[_]=new eo(this.context,t,Jn[t],d,bu[t],f)),this.cache[_]}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(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new s.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,r){if(this.style.enable3dLights()){const c=this.style.directionalLight,d=this.style.ambientLight;if(c&&d){const f=((_,T,S)=>{const A=_.properties.get("direction"),I=_.properties.get("color").toRenderColor(S.getLut(_.scope)).toArray01(),z=_.properties.get("intensity"),D=T.properties.get("color").toRenderColor(S.getLut(T.scope)).toArray01(),L=T.properties.get("intensity"),F=[A.x,A.y,A.z],N=s.cH(D,L),V=s.cH(I,z);return{u_lighting_ambient_color:N,u_lighting_directional_dir:F,u_lighting_directional_color:V,u_ground_radiance:Cc(F,V,N)}})(c,d,this.style);r.setLightsUniformValues(t,f)}}}uploadCommonUniforms(t,r,c,d,f){if(this.uploadCommonLightUniforms(t,r),this.terrain&&this.terrain.renderingToTexture)return;const _=this.style.fog;if(_){const T=_.getOpacity(this.transform.pitch),S=((A,I,z,D,L,F,N,V,U,W,Y,$)=>{const Q=A.transform,J=I.properties.get("color").toRenderColor(A.style.getLut(I.scope)).toArray01();J[3]=D;const ne=A.frameCounter/1e3%1,[ie,oe]=I.properties.get("vertical-range");return{u_fog_matrix:z?Q.calculateFogTileMatrix(z):$||A.identityMat,u_fog_range:I.getFovAdjustedRange(Q._fov),u_fog_color:J,u_fog_horizon_blend:I.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(ie,oe),oe],u_fog_temporal_offset:ne,u_frustum_tl:L,u_frustum_tr:F,u_frustum_br:N,u_frustum_bl:V,u_globe_pos:U,u_globe_radius:W,u_viewport:Y,u_globe_transition:s.a9(Q.zoom),u_is_globe:+("globe"===Q.projection.name)}})(this,_,c,T,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*s.q.devicePixelRatio,this.transform.height*s.q.devicePixelRatio],d);r.setFogUniformValues(t,S)}f&&r.setCutoffUniformValues(t,f.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,r=t.createTexture();return t.bindTexture(t.TEXTURE_2D,r),t.copyTexImage2D(t.TEXTURE_2D,0,t.RGBA,0,0,t.drawingBufferWidth,t.drawingBufferHeight,0),r}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const t=this.style&&this.style.fog;return!!t&&0!==t.getOpacity(this.transform.pitch)}getBackgroundTiles(){const t=this._backgroundTiles,r=this._backgroundTiles={},c=this.transform.coveringTiles({tileSize:512});for(const d of c)r[d.key]=t[d.key]||new fn(d,512,this.transform.tileZoom,this);return r}clearBackgroundTiles(){this._backgroundTiles={}}isSourceForClippingOrConflation(t,r){return!(!t.is3D()||"clip"!==t.type&&(t.minzoom&&t.minzoom>this.transform.zoom||(this.style._clipLayerPresent||"building"!==t.sourceLayer)&&(!r||"batched-model"!==r.type)))}isTileAffectedByFog(t){if(!this.style||!this.style.fog)return!1;if("globe"===this.transform.projection.name)return!0;let r=this._cachedTileFogOpacities[t.key];return r||(this._cachedTileFogOpacities[t.key]=r=this.style.fog.getOpacityForTile(t)),r[0]>=Ke||r[1]>=Ke}setupDepthForOcclusion(t,r,c){const d=this.context,f=d.gl,_=!!c;var T;c||(c={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(f.TEXTURE3),t&&this.depthFBO&&this.depthTexture?(this.depthTexture.bind(f.NEAREST,f.CLAMP_TO_EDGE),c.u_depth_size_inv=[1/this.depthFBO.width,1/this.depthFBO.height],c.u_depth_range_unpack=[2/((T=this.depthRangeFor3D)[1]-T[0]),-1-2*T[0]/(T[1]-T[0])],c.u_occluder_half_size=.5*this.occlusionParams.occluderSize,c.u_occlusion_depth_offset=this.occlusionParams.depthOffset):this.emptyDepthTexture.bind(f.NEAREST,f.CLAMP_TO_EDGE),d.activeTexture.set(f.TEXTURE0),_||r.setTerrainUniformValues(d,c)}}function kn(l,t){let r=!1,c=null;const d=()=>{c=null,r&&(l(),c=setTimeout(d,t),r=!1)};return()=>(r=!0,c||d(),c)}class no{constructor(t){this._hashName=t&&encodeURIComponent(t),s.aJ(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=kn(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 r=On(t);if(this._hashName){const c=this._hashName;let d=!1;const f=location.hash.slice(1).split("&").map(_=>{const T=_.split("=")[0];return T===c?(d=!0,`${T}=${r}`):_}).filter(_=>_);return d||f.push(`${c}=${r}`),`#${f.join("&")}`}return`#${r}`}_getCurrentHash(){const t=location.hash.replace("#","");if(this._hashName){let r;return t.split("&").map(c=>c.split("=")).forEach(c=>{c[0]===this._hashName&&(r=c)}),(r&&r[1]||"").split("/")}return t.split("/")}_onHashChange(){const t=this._map;if(!t)return!1;const r=this._getCurrentHash();if(r.length>=3&&!r.some(c=>isNaN(c))){const c=t.dragRotate.isEnabled()&&t.touchZoomRotate.isEnabled()?+(r[3]||0):t.getBearing();return t.jumpTo({center:[+r[2],+r[1]],zoom:+r[0],bearing:c,pitch:+(r[4]||0)}),!0}return!1}_updateHashUnthrottled(){history.replaceState(history.state,"",location.href.replace(/(#.+)?$/,this.getHashString()))}}function On(l,t){const r=l.getCenter(),c=Math.round(100*l.getZoom())/100,d=Math.ceil((c*Math.LN2+Math.log(512/360/.5))/Math.LN10),f=Math.pow(10,d),_=Math.round(r.lng*f)/f,T=Math.round(r.lat*f)/f,S=l.getBearing(),A=l.getPitch();let I=t?`/${_}/${T}/${c}`:`${c}/${T}/${_}`;return(S||A)&&(I+="/"+Math.round(10*S)/10),A&&(I+=`/${Math.round(A)}`),I}const Po={linearity:.3,easing:s.dp(0,0,.3,1)},Cl=s.l({deceleration:2500,maxSpeed:1400},Po),Zc=s.l({deceleration:20,maxSpeed:1400},Po),$c=s.l({deceleration:1e3,maxSpeed:360},Po),Hc=s.l({deceleration:1e3,maxSpeed:90},Po);class oo{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:s.q.now(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,r=s.q.now();for(;t.length>0&&r-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._map._prefersReducedMotion()||(this._drainInertiaBuffer(),this._inertiaBuffer.length<2))return;const r={zoom:0,bearing:0,pitch:0,pan:new s.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:f}of this._inertiaBuffer)r.zoom+=f.zoomDelta||0,r.bearing+=f.bearingDelta||0,r.pitch+=f.pitchDelta||0,f.panDelta&&r.pan._add(f.panDelta),f.around&&(r.around=f.around),f.pinchAround&&(r.pinchAround=f.pinchAround);const c=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,d={};if(r.pan.mag()){const f=zo(r.pan.mag(),c,s.l({},Cl,t||{}));d.offset=r.pan.mult(f.amount/r.pan.mag()),d.center=this._map.transform.center,bs(d,f)}if(r.zoom){const f=zo(r.zoom,c,Zc);d.zoom=this._map.transform.zoom+f.amount,bs(d,f)}if(r.bearing){const f=zo(r.bearing,c,$c);d.bearing=this._map.transform.bearing+s.ap(f.amount,-179,179),bs(d,f)}if(r.pitch){const f=zo(r.pitch,c,Hc);d.pitch=this._map.transform.pitch+f.amount,bs(d,f)}if(d.zoom||d.bearing){const f=void 0===r.pinchAround?r.around:r.pinchAround;d.around=f?this._map.unproject(f):this._map.getCenter()}return this.clear(),d.noMoveStart=!0,d}}function bs(l,t){(!l.duration||l.durationr.unproject(S)),T=f.reduce((S,A,I,z)=>S.add(A.div(z.length)),new s.P(0,0));super(t,{points:f,point:T,lngLats:_,lngLat:r.unproject(T),originalEvent:c}),this._defaultPrevented=!1}}class cr extends s.x{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,r){super("wheel",{originalEvent:r}),this._defaultPrevented=!1}}class Wc{constructor(t,r){this._map=t,this._clickTolerance=r.clickTolerance}reset(){this._mousedownPos=void 0}wheel(t){return this._firePreventable(new cr(this._map,t))}mousedown(t,r){return this._mousedownPos=r,this._firePreventable(new wr(t.type,this._map,t))}mouseup(t){this._map.fire(new wr(t.type,this._map,t))}preclick(t){const r=s.l({},t);r.type="preclick",this._map.fire(new wr(r.type,this._map,r))}click(t,r){this._mousedownPos&&this._mousedownPos.dist(r)>=this._clickTolerance||(this.preclick(t),this._map.fire(new wr(t.type,this._map,t)))}dblclick(t){return this._firePreventable(new wr(t.type,this._map,t))}mouseover(t){this._map.fire(new wr(t.type,this._map,t))}mouseout(t){this._map.fire(new wr(t.type,this._map,t))}touchstart(t){return this._firePreventable(new ws(t.type,this._map,t))}touchmove(t){this._map.fire(new ws(t.type,this._map,t))}touchend(t){this._map.fire(new ws(t.type,this._map,t))}touchcancel(t){this._map.fire(new ws(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Xc{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(t){this._map.fire(new wr(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new wr("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._map.fire(new wr(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Ts{constructor(t,r){this._map=t,this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=r.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(t,r){this.isEnabled()&&t.shiftKey&&0===t.button&&(gt(),this._startPos=this._lastPos=r,this._active=!0)}mousemoveWindow(t,r){if(!this._active)return;const c=r,d=this._startPos,f=this._lastPos;if(!d||!f||f.equals(c)||!this._box&&c.dist(d){this._box&&(this._box.style.transform=`translate(${_}px,${S}px)`,this._box.style.width=T-_+"px",this._box.style.height=A-S+"px")})}mouseupWindow(t,r){if(!this._active)return;const c=this._startPos,d=r;if(c&&0===t.button){if(this.reset(),lt(),c.x!==d.x||c.y!==d.y)return this._map.fire(new s.x("boxzoomend",{originalEvent:t})),{cameraAnimation:f=>f.fitScreenCoordinates(c,d,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",t)}}keydown(t){this._active&&27===t.keyCode&&(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),Oi(),delete this._startPos,delete this._lastPos}_fireEvent(t,r){return this._map.fire(new s.x(t,{originalEvent:r}))}}function Bn(l,t){const r={};for(let c=0;cthis.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=t.timeStamp),c.length===this.numTouches&&(this.centroid=function(d){const f=new s.P(0,0);for(const _ of d)f._add(_);return f.div(d.length)}(r),this.touches=Bn(c,r)))}touchmove(t,r,c){if(this.aborted||!this.centroid)return;const d=Bn(c,r);for(const f in this.touches){const _=d[f];(!_||_.dist(this.touches[f])>30)&&(this.aborted=!0)}}touchend(t,r,c){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),0===c.length){const d=!this.aborted&&this.centroid;if(this.reset(),d)return d}}}class va{constructor(t){this.singleTap=new Yc(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(t,r,c){this.singleTap.touchstart(t,r,c)}touchmove(t,r,c){this.singleTap.touchmove(t,r,c)}touchend(t,r,c){const d=this.singleTap.touchend(t,r,c);if(d){const f=t.timeStamp-this.lastTime<500,_=!this.lastTap||this.lastTap.dist(d)<30;if(f&&_||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=d,this.count===this.numTaps)return this.reset(),d}}}class Kc{constructor(){this._zoomIn=new va({numTouches:1,numTaps:2}),this._zoomOut=new va({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,r,c){this._zoomIn.touchstart(t,r,c),this._zoomOut.touchstart(t,r,c)}touchmove(t,r,c){this._zoomIn.touchmove(t,r,c),this._zoomOut.touchmove(t,r,c)}touchend(t,r,c){const d=this._zoomIn.touchend(t,r,c),f=this._zoomOut.touchend(t,r,c);return d?(this._active=!0,t.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:_=>_.easeTo({duration:300,zoom:_.getZoom()+1,around:_.unproject(d)},{originalEvent:t})}):f?(this._active=!0,t.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:_=>_.easeTo({duration:300,zoom:_.getZoom()-1,around:_.unproject(f)},{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 ba={0:1,2:2};class wa{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,r){return!1}_move(t,r){return{}}mousedown(t,r){if(this._lastPoint)return;const c=tt(t);this._correctButton(t,c)&&(this._lastPoint=r,this._eventButton=c)}mousemoveWindow(t,r){const c=this._lastPoint;if(c)if(t.preventDefault(),null!=this._eventButton&&function(d,f){const _=ba[f];return void 0===d.buttons||(d.buttons&_)!==_}(t,this._eventButton))this.reset();else if(this._moved||!(r.dist(c)0&&(this._active=!0);const d=Bn(c,r),f=new s.P(0,0),_=new s.P(0,0);let T=0;for(const A in d){const I=d[A],z=this._touches[A];z&&(f._add(I),_._add(I.sub(z)),T++,d[A]=I)}if(this._touches=d,T{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.removeAttribute("role")},500)}}class Rl{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(t){}_move(t,r,c){return{}}touchstart(t,r,c){this._firstTwoTouches||c.length<2||(this._firstTwoTouches=[c[0].identifier,c[1].identifier],this._start([r[0],r[1]]))}touchmove(t,r,c){const d=this._firstTwoTouches;if(!d)return;t.preventDefault();const[f,_]=d,T=Ta(c,r,f),S=Ta(c,r,_);if(!T||!S)return;const A=this._aroundCenter?null:T.add(S).div(2);return this._move([T,S],A,t)}touchend(t,r,c){if(!this._firstTwoTouches)return;const[d,f]=this._firstTwoTouches,_=Ta(c,r,d),T=Ta(c,r,f);_&&T||(this._active&<(),this.reset())}touchcancel(){this.reset()}enable(t){this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function Ta(l,t,r){for(let c=0;cMath.abs(l.x)}class Du extends Rl{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,Ll(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,r,c){const d=this._lastPoints;if(!d)return;const f=t[0].sub(d[0]),_=t[1].sub(d[1]);return this._map._cooperativeGestures&&!s.dq()&&c.touches.length<3||(this._valid=this.gestureBeginsVertically(f,_,c.timeStamp),!this._valid)?void 0:(this._lastPoints=t,this._active=!0,{pitchDelta:(f.y+_.y)/2*-.5})}gestureBeginsVertically(t,r,c){if(void 0!==this._valid)return this._valid;const d=t.mag()>=2,f=r.mag()>=2;if(!d&&!f)return;if(!d||!f)return null==this._firstMove&&(this._firstMove=c),c-this._firstMove<100&&void 0;const _=t.y>0==r.y>0;return Ll(t)&&Ll(r)&&_}}const Ru={panStep:100,bearingStep:15,pitchStep:10};class Lu{constructor(){const t=Ru;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let r=0,c=0,d=0,f=0,_=0;switch(t.keyCode){case 61:case 107:case 171:case 187:r=1;break;case 189:case 109:case 173:r=-1;break;case 37:t.shiftKey?c=-1:(t.preventDefault(),f=-1);break;case 39:t.shiftKey?c=1:(t.preventDefault(),f=1);break;case 38:t.shiftKey?d=1:(t.preventDefault(),_=-1);break;case 40:t.shiftKey?d=-1:(t.preventDefault(),_=1);break;default:return}return this._rotationDisabled&&(c=0,d=0),{cameraAnimation:T=>{const S=T.getZoom();T.easeTo({duration:300,easeId:"keyboardHandler",easing:ku,zoom:r?Math.round(S)+r*(t.shiftKey?2:1):S,bearing:T.getBearing()+c*this._bearingStep,pitch:T.getPitch()+d*this._pitchStep,offset:[-f*this._panStep,-_*this._panStep],center:T.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}}function ku(l){return l*(2-l)}const eh=4.000244140625,Wd=1/450;class Xd{constructor(t,r){this._map=t,this._el=t.getCanvasContainer(),this._handler=r,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=Wd,s.aJ(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this)}setZoomRate(t){this._defaultZoomRate=t}setWheelZoomRate(t){this._wheelZoomRate=t}isEnabled(){return!!this._enabled}isActive(){return this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around,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()||s.dq()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let r=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const c=s.q.now(),d=c-(this._lastWheelEventTime||0);this._lastWheelEventTime=c,0!==r&&r%eh==0?this._type="wheel":0!==r&&Math.abs(r)<4?this._type="trackpad":d>400?(this._type=null,this._lastValue=r,this._timeout=window.setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(d*r)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,r+=this._lastValue)),t.shiftKey&&r&&(r/=4),this._type&&(this._lastWheelEvent=t,this._delta-=r,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 r=zi(this._el,t);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:r,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;"wheel"===this._type&&t.projection.wrap&&(t._center.lng>=180||t._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);const r=()=>t._terrainEnabled()&&this._aroundCoord?t.computeZoomRelativeTo(this._aroundCoord):t.zoom;if(0!==this._delta){const A="wheel"===this._type&&Math.abs(this._delta)>eh?this._wheelZoomRate:this._defaultZoomRate;let I=2/(1+Math.exp(-Math.abs(this._delta*A)));this._delta<0&&0!==I&&(I=1/I);const z=r(),D=Math.pow(2,z),L="number"==typeof this._targetZoom?t.zoomScale(this._targetZoom):D;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(L*I))),"wheel"===this._type&&(this._startZoom=z,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0}const c="number"==typeof this._targetZoom?this._targetZoom:r(),d=this._startZoom,f=this._easing;let _,T=!1;if("wheel"===this._type&&d&&f){const A=Math.min((s.q.now()-this._lastWheelEventTime)/200,1),I=f(A);_=s.aa(d,c,I),A<1?this._frameId||(this._frameId=!0):T=!0}else _=c,T=!0;this._active=!0,T&&(this._active=!1,this._finishTimeout=window.setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200));let S=_-r();return S*this._lastDelta<0&&(S=0),{noInertia:!0,needsRenderFrame:!T,zoomDelta:S,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let r=s.dr;if(this._prevEase){const c=this._prevEase,d=(s.q.now()-c.start)/c.duration,f=c.easing(d+.01)-c.easing(d),_=.27/Math.sqrt(f*f+1e-4)*.01,T=Math.sqrt(.0729-_*_);r=s.dp(_,T,.25,1)}return this._prevEase={start:s.q.now(),duration:t,easing:r},r}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=/(Mac|iPad)/i.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 Fi{constructor(t,r){this._clickZoom=t,this._tapZoom=r}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 Ou{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(t,r){return t.preventDefault(),{cameraAnimation:c=>{c.easeTo({duration:300,zoom:c.getZoom()+(t.shiftKey?-1:1),around:c.unproject(r)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Yd{constructor(){this._tap=new va({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,r,c){this._swipePoint||(this._tapTime&&t.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?c.length>0&&(this._swipePoint=r[0],this._swipeTouch=c[0].identifier):this._tap.touchstart(t,r,c))}touchmove(t,r,c){if(this._tapTime){if(this._swipePoint){if(c[0].identifier!==this._swipeTouch)return;const d=r[0],f=d.y-this._swipePoint.y;return this._swipePoint=d,t.preventDefault(),this._active=!0,{zoomDelta:f/128}}}else this._tap.touchmove(t,r,c)}touchend(t,r,c){this._tapTime?this._swipePoint&&0===c.length&&this.reset():this._tap.touchend(t,r,c)&&(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 Kd{constructor(t,r,c){this._el=t,this._mousePan=r,this._touchPan=c}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 Ma{constructor(t,r,c){this._pitchWithRotate=t.pitchWithRotate,this._mouseRotate=r,this._mousePitch=c}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class Bu{constructor(t,r,c,d){this._el=t,this._touchZoom=r,this._touchRotate=c,this._tapDragZoom=d,this._rotationDisabled=!1,this._enabled=!0}enable(t){this._touchZoom.enable(t),this._rotationDisabled||this._touchRotate.enable(t),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._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()}}const Ms=l=>l.zoom||l.drag||l.pitch||l.rotate;class kl extends s.x{}class Fn{constructor(){this.constants=[1,1,.01],this.radius=0}setup(t,r){const c=s.a6.vec3.sub([],r,t);this.radius=s.a6.vec3.length(c[2]<0?s.a6.vec3.div([],c,this.constants):[c[0],c[1],0])}projectRay(t){s.a6.vec3.div(t,t,this.constants),s.a6.vec3.normalize(t,t),s.a6.vec3.mul(t,t,this.constants);const r=s.a6.vec3.scale([],t,this.radius);if(r[2]>0){const c=s.a6.vec3.scale([],[0,0,1],s.a6.vec3.dot(r,[0,0,1])),d=s.a6.vec3.scale([],s.a6.vec3.normalize([],[r[0],r[1],0]),this.radius),f=s.a6.vec3.add([],r,s.a6.vec3.scale([],s.a6.vec3.sub([],s.a6.vec3.add([],d,c),r),2));r[0]=f[0],r[1]=f[1]}return r}}function Do(l){return l.panDelta&&l.panDelta.mag()||l.zoomDelta||l.bearingDelta||l.pitchDelta}class gr{constructor(t,r){this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new oo(t),this._bearingSnap=r.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new Fn,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(r),s.aJ(["handleEvent","handleWindowEvent"],this);const c=this._el;this._listeners=[[c,"touchstart",{passive:!0}],[c,"touchmove",{passive:!1}],[c,"touchend",void 0],[c,"touchcancel",void 0],[c,"mousedown",void 0],[c,"mousemove",void 0],[c,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[c,"mouseover",void 0],[c,"mouseout",void 0],[c,"dblclick",void 0],[c,"click",void 0],[c,"keydown",{capture:!1}],[c,"keyup",void 0],[c,"wheel",{passive:!1}],[c,"contextmenu",void 0],[window,"blur",void 0]];for(const[d,f,_]of this._listeners){const T=d===document?this.handleWindowEvent:this.handleEvent;d.addEventListener(f,T,_)}}destroy(){for(const[t,r,c]of this._listeners){const d=t===document?this.handleWindowEvent:this.handleEvent;t.removeEventListener(r,d,c)}}_addDefaultHandlers(t){const r=this._map,c=r.getCanvasContainer();this._add("mapEvent",new Wc(r,t));const d=r.boxZoom=new Ts(r,t);this._add("boxZoom",d);const f=new Kc,_=new Ou;r.doubleClickZoom=new Fi(_,f),this._add("tapZoom",f),this._add("clickZoom",_);const T=new Yd;this._add("tapDragZoom",T);const S=r.touchPitch=new Du(r);this._add("touchPitch",S);const A=new zl(t),I=new Dl(t);r.dragRotate=new Ma(t,A,I),this._add("mouseRotate",A,["mousePitch"]),this._add("mousePitch",I,["mouseRotate"]);const z=new Pl(t),D=new Cu(r,t);r.dragPan=new Kd(c,z,D),this._add("mousePan",z),this._add("touchPan",D,["touchZoom","touchRotate"]);const L=new zu,F=new Pu;r.touchZoomRotate=new Bu(c,F,L,T),this._add("touchRotate",L,["touchPan","touchZoom"]),this._add("touchZoom",F,["touchPan","touchRotate"]),this._add("blockableMapEvent",new Xc(r));const N=r.scrollZoom=new Xd(r,this);this._add("scrollZoom",N,["mousePan"]);const V=r.keyboard=new Lu;this._add("keyboard",V);for(const U of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])t.interactive&&t[U]&&r[U].enable(t[U])}_add(t,r,c){this._handlers.push({handlerName:t,handler:r,allowed:c}),this._handlersById[t]=r}stop(t){if(!this._updatingCamera){for(const{handler:r}of this._handlers)r.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!!Ms(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(t,r,c){for(const d in t)if(d!==c&&(!r||r.indexOf(d)<0))return!0;return!1}handleWindowEvent(t){this.handleEvent(t,`${t.type}Window`)}_getMapTouches(t){const r=[];for(const c of t)this._el.contains(c.target)&&r.push(c);return r}handleEvent(t,r){this._updatingCamera=!0;const c="renderFrame"===t.type,d=c?void 0:t,f={needsRenderFrame:!1},_={},T={},S=t.touches?this._getMapTouches(t.touches):void 0,A=S?Pt(this._el,S):c?void 0:zi(this._el,t);for(const{handlerName:D,handler:L,allowed:F}of this._handlers){if(!L.isEnabled())continue;let N;this._blockedByActive(T,F,D)?L.reset():L[r||t.type]&&(N=L[r||t.type](t,A,S),this.mergeHandlerResult(f,_,N,D,d),N&&N.needsRenderFrame&&this._triggerRenderFrame()),(N||L.isActive())&&(T[D]=L)}const I={};for(const D in this._previousActiveHandlers)T[D]||(I[D]=d);this._previousActiveHandlers=T,(Object.keys(I).length||Do(f))&&(this._changes.push([f,_,I]),this._triggerRenderFrame()),(Object.keys(T).length||Do(f))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:z}=f;z&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],z(this._map))}mergeHandlerResult(t,r,c,d,f){if(!c)return;s.l(t,c);const _={handlerName:d,originalEvent:c.originalEvent||f};void 0!==c.zoomDelta&&(r.zoom=_),void 0!==c.panDelta&&(r.drag=_),void 0!==c.pitchDelta&&(r.pitch=_),void 0!==c.bearingDelta&&(r.rotate=_)}_applyChanges(){const t={},r={},c={};for(const[d,f,_]of this._changes)d.panDelta&&(t.panDelta=(t.panDelta||new s.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),void 0!==d.around&&(t.around=d.around),void 0!==d.aroundCoord&&(t.aroundCoord=d.aroundCoord),void 0!==d.pinchAround&&(t.pinchAround=d.pinchAround),d.noInertia&&(t.noInertia=d.noInertia),s.l(r,f),s.l(c,_);this._updateMapTransform(t,r,c),this._changes=[]}_updateMapTransform(t,r,c){const d=this._map,f=d.transform,_=W=>[W.x,W.y,W.z];if((()=>{const Y=this._eventsInProgress.drag;return Y&&!this._handlersById[Y.handlerName].isActive()})()&&!Do(t)){const W=f.zoom;f.cameraElevationReference="sea",null!=this._originalZoom&&f._orthographicProjectionAtLowPitch&&"globe"!==f.projection.name&&0===f.pitch?(f.cameraElevationReference="ground",f.zoom=this._originalZoom):(f.recenterOnTerrain(),f.cameraElevationReference="ground"),W!==f.zoom&&this._map._update(!0)}if(f._isCameraConstrained&&d._stop(!0),!Do(t))return void this._fireEvents(r,c,!0);let{panDelta:T,zoomDelta:S,bearingDelta:A,pitchDelta:I,around:z,aroundCoord:D,pinchAround:L}=t;f._isCameraConstrained&&(S>0&&(S=0),f._isCameraConstrained=!1),void 0!==L&&(z=L),(S||(W=>r[W]&&!this._eventsInProgress[W])("drag"))&&z&&(this._dragOrigin=_(f.pointCoordinate3D(z)),this._originalZoom=f.zoom,this._trackingEllipsoid.setup(f._camera.position,this._dragOrigin)),f.cameraElevationReference="sea",d._stop(!0),z=z||d.transform.centerPoint,A&&(f.bearing+=A),I&&(f.pitch+=I),f._updateCameraState();const F=[0,0,0];if(T)if("mercator"===f.projection.name){const W=this._trackingEllipsoid.projectRay(f.screenPointToMercatorRay(z).dir),Y=this._trackingEllipsoid.projectRay(f.screenPointToMercatorRay(z.sub(T)).dir);F[0]=Y[0]-W[0],F[1]=Y[1]-W[1]}else{const W=f.pointCoordinate(z);if("globe"===f.projection.name){T=T.rotate(-f.angle);const Y=f._pixelsPerMercatorPixel/f.worldSize;F[0]=-T.x*s.ds(s.aM(W.y))*Y,F[1]=-T.y*s.ds(f.center.lat)*Y}else{const Y=f.pointCoordinate(z.sub(T));W&&Y&&(F[0]=Y.x-W.x,F[1]=Y.y-W.y)}}const N=f.zoom,V=[0,0,0];if(S){const W=_(D||f.pointCoordinate3D(z)),Y={dir:s.a6.vec3.normalize([],s.a6.vec3.sub([],W,f._camera.position))};if(Y.dir[2]<0){const $=f.zoomDeltaToMovement(W,S);s.a6.vec3.scale(V,Y.dir,$)}}const U=s.a6.vec3.add(F,F,V);f._translateCameraConstrained(U),S&&Math.abs(f.zoom-N)>1e-4&&f.recenterOnTerrain(),f.cameraElevationReference="ground",this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(r,c,!0)}_fireEvents(t,r,c){const d=Ms(this._eventsInProgress),f=Ms(t),_={};for(const I in t){const{originalEvent:z}=t[I];this._eventsInProgress[I]||(_[`${I}start`]=z),this._eventsInProgress[I]=t[I]}!d&&f&&this._fireEvent("movestart",f.originalEvent);for(const I in _)this._fireEvent(I,_[I]);f&&this._fireEvent("move",f.originalEvent);for(const I in t){const{originalEvent:z}=t[I];this._fireEvent(I,z)}const T={};let S;for(const I in this._eventsInProgress){const{handlerName:z,originalEvent:D}=this._eventsInProgress[I];this._handlersById[z].isActive()||(delete this._eventsInProgress[I],S=r[z]||D,T[`${I}end`]=S)}for(const I in T)this._fireEvent(I,T[I]);const A=Ms(this._eventsInProgress);if(c&&(d||f)&&!A){this._updatingCamera=!0;const I=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),z=D=>0!==D&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new kl("renderFrame",{timeStamp:t})),this._applyChanges()})}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}const yn="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class th extends s.E{constructor(t,r){super(),this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=r.bearingSnap,this._respectPrefersReducedMotion=!1!==r.respectPrefersReducedMotion,s.aJ(["_renderFrameCallback"],this)}getCenter(){return new s.bK(this.transform.center.lng,this.transform.center.lat)}setCenter(t,r){return this.jumpTo({center:t},r)}panBy(t,r,c){return t=s.P.convert(t).mult(-1),this.panTo(this.transform.center,s.l({offset:t},r),c)}panTo(t,r,c){return this.easeTo(s.l({center:t},r),c)}getZoom(){return this.transform.zoom}setZoom(t,r){return this.jumpTo({zoom:t},r),this}zoomTo(t,r,c){return this.easeTo(s.l({zoom:t},r),c)}zoomIn(t,r){return this.zoomTo(this.getZoom()+1,t,r),this}zoomOut(t,r){return this.zoomTo(this.getZoom()-1,t,r),this}getBearing(){return this.transform.bearing}setBearing(t,r){return this.jumpTo({bearing:t},r),this}getPadding(){return this.transform.padding}setPadding(t,r){return this.jumpTo({padding:t},r),this}rotateTo(t,r,c){return this.easeTo(s.l({bearing:t},r),c)}resetNorth(t,r){return this.rotateTo(0,s.l({duration:1e3},t),r),this}resetNorthPitch(t,r){return this.easeTo(s.l({bearing:0,pitch:0,duration:1e3},t),r),this}snapToNorth(t,r){return Math.abs(this.getBearing())t.aspect?c/(2*Math.tan(.5*t.fovX)*t.aspect):d/(2*Math.tan(.5*t.fovY)*t.aspect)}_cameraForBoundsOnGlobe(t,r,c,d,f,_){const T=t.clone(),S=this._extendCameraOptions(_);T.bearing=d,T.pitch=f;const A=s.bK.convert(r),I=s.bK.convert(c),z=.5*(A.lat+I.lat),D=.5*(A.lng+I.lng),L=s.dt(z,D),F=s.a6.vec3.normalize([],L),N=s.a6.vec3.normalize([],s.a6.vec3.cross([],F,[0,1,0])),V=s.a6.vec3.cross([],N,F),U=[N[0],N[1],N[2],0,V[0],V[1],V[2],0,F[0],F[1],F[2],0,0,0,0,1],W=[L,s.dt(A.lat,A.lng),s.dt(I.lat,A.lng),s.dt(I.lat,I.lng),s.dt(A.lat,I.lng),s.dt(z,A.lng),s.dt(z,I.lng),s.dt(A.lat,D),s.dt(I.lat,D)];let Y=s.c9.fromPoints(W.map(ze=>[s.a6.vec3.dot(N,ze),s.a6.vec3.dot(V,ze),s.a6.vec3.dot(F,ze)]));const $=s.a6.vec3.transformMat4([],Y.center,U);0===s.a6.vec3.squaredLength($)&&s.a6.vec3.set($,0,0,1),s.a6.vec3.normalize($,$),s.a6.vec3.scale($,$,s.aq),T.center=s.du($);const Q=T.getWorldToCameraMatrix(),J=s.a6.mat4.invert(new Float64Array(16),Q);Y=s.c9.applyTransform(Y,s.a6.mat4.multiply([],Q,U));const ne=this._extendAABB(Y,T,S,d);if(!ne)return void s.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");Y=ne,s.a6.vec3.transformMat4($,$,Q);const ie=.5*(Y.max[2]-Y.min[2]),oe=this._minimumAABBFrustumDistance(T,Y),de=s.a6.vec3.scale([],[0,0,1],ie),ce=s.a6.vec3.add(de,$,de),ae=oe+(0===T.pitch?0:s.a6.vec3.distance($,ce)),ye=T.globeCenterInViewSpace,Ie=s.a6.vec3.sub([],$,[ye[0],ye[1],ye[2]]);s.a6.vec3.normalize(Ie,Ie),s.a6.vec3.scale(Ie,Ie,ae);const ke=s.a6.vec3.add([],$,Ie);s.a6.vec3.transformMat4(ke,ke,J);const Ae=s.dw/s.aq,Ne=s.a6.vec3.length(ke),xe=s.bD(Math.max(Ne*Ae-s.dw,Number.EPSILON),0),Re=Math.min(T.zoomFromMercatorZAdjusted(xe),S.maxZoom);return Re>.5*(s.c2+s.bU)?(T.setProjection({name:"mercator"}),T.zoom=Re,this._cameraForBounds(T,r,c,d,f,_)):{center:T.center,zoom:Re,bearing:d,pitch:f}}_extendAABB(t,r,c,d){const f=.5*((c.padding.left||0)+(c.padding.right||0)),_=.5*((c.padding.top||0)+(c.padding.bottom||0)),T=_,S=f,A=f,I=_,z=r.width-(S+A),D=r.height-(T+I),L=s.a6.vec3.sub([],t.max,t.min),F=Math.min(z/L[0],D/L[1]),N=Math.min(r.scaleZoom(r.scale*F),c.maxZoom);if(isNaN(N))return null;const V=r.scale/r.zoomScale(N),U=new s.c9([t.min[0]-S*V,t.min[1]-I*V,t.min[2]],[t.max[0]+A*V,t.max[1]+T*V,t.max[2]]),W=("number"==typeof c.offset.x&&"number"==typeof c.offset.y?new s.P(c.offset.x,c.offset.y):s.P.convert(c.offset)).rotate(-s.bB(d));return U.center[0]-=W.x*V,U.center[1]+=W.y*V,U}queryTerrainElevation(t,r){const c=this.transform.elevation;return c?(r=s.l({},{exaggerated:!0},r),c.getAtPoint(s.a5.fromLngLat(t),null,r.exaggerated)):null}_cameraForBounds(t,r,c,d,f,_){if("globe"===t.projection.name)return this._cameraForBoundsOnGlobe(t,r,c,d,f,_);const T=t.clone(),S=this._extendCameraOptions(_);T.bearing=d,T.pitch=f;const A=s.bK.convert(r),I=s.bK.convert(c),z=new s.bK(A.lng,I.lat),D=new s.bK(I.lng,A.lat),L=T.project(A),F=T.project(I),N=this.queryTerrainElevation(A),V=this.queryTerrainElevation(I),U=this.queryTerrainElevation(z),W=this.queryTerrainElevation(D),Y=[[L.x,L.y,Math.min(N||0,V||0,U||0,W||0)],[F.x,F.y,Math.max(N||0,V||0,U||0,W||0)]];let $=s.c9.fromPoints(Y);const Q=T.getWorldToCameraMatrix(),J=s.a6.mat4.invert(new Float64Array(16),Q);$=s.c9.applyTransform($,Q);const ne=this._extendAABB($,T,S,d);if(!ne)return void s.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");$=ne;const ie=.5*s.a6.vec3.sub([],$.max,$.min)[2],oe=this._minimumAABBFrustumDistance(T,$),de=[0,0,1,0];s.a6.vec4.transformMat4(de,de,Q),s.a6.vec4.normalize(de,de);const ce=s.a6.vec3.scale([],de,oe+ie),ae=s.a6.vec3.add([],$.center,ce);s.a6.vec3.transformMat4($.center,$.center,J),s.a6.vec3.transformMat4(ae,ae,J);const ye=T.unproject(new s.P($.center[0],$.center[1])),Ie=s.dv(T.projection,ye),ke=Math.pow(2,Ie),Ae=Math.min(T._zoomFromMercatorZ(ae[2]*T.pixelsPerMeter*ke/T.worldSize),S.maxZoom);return T.mercatorFromTransition&&Ae<.5*(s.c2+s.bU)?(T.setProjection({name:"globe"}),T.zoom=Ae,this._cameraForBounds(T,r,c,d,f,_)):{center:ye,zoom:Ae,bearing:d,pitch:f}}fitBounds(t,r,c){const d=this.cameraForBounds(t,r);return this._fitInternal(d,r,c)}fitScreenCoordinates(t,r,c,d,f){const _=s.P.convert(t),T=s.P.convert(r),S=new s.P(Math.min(_.x,T.x),Math.min(_.y,T.y)),A=new s.P(Math.max(_.x,T.x),Math.max(_.y,T.y));if("mercator"===this.transform.projection.name&&this.transform.anyCornerOffEdge(_,T))return this;const I=this.transform.pointLocation3D(S),z=this.transform.pointLocation3D(A),D=this.transform.pointLocation3D(new s.P(S.x,A.y)),L=this.transform.pointLocation3D(new s.P(A.x,S.y)),F=[Math.min(I.lng,z.lng,D.lng,L.lng),Math.min(I.lat,z.lat,D.lat,L.lat)],N=[Math.max(I.lng,z.lng,D.lng,L.lng),Math.max(I.lat,z.lat,D.lat,L.lat)],V=d&&d.pitch?d.pitch:this.getPitch(),U=this._cameraForBounds(this.transform,F,N,c,V,d);return this._fitInternal(U,d,f)}_fitInternal(t,r,c){return t?(r=s.l(t,r)).linear?this.easeTo(r,c):this.flyTo(r,c):this}jumpTo(t,r){this.stop();const c=t.preloadOnly?this.transform.clone():this.transform;let d=!1,f=!1,_=!1;"zoom"in t&&c.zoom!==+t.zoom&&(d=!0,c.zoom=+t.zoom),void 0!==t.center&&(c.center=s.bK.convert(t.center)),"bearing"in t&&c.bearing!==+t.bearing&&(f=!0,c.bearing=+t.bearing),"pitch"in t&&c.pitch!==+t.pitch&&(_=!0,c.pitch=+t.pitch);const T="number"==typeof t.padding?this._extendPadding(t.padding):t.padding;if(null!=t.padding&&!c.isPaddingEqual(T))if(!1===t.retainPadding){const S=c.clone();S.padding=T,c.setLocationAtPoint(c.center,S.centerPoint)}else c.padding=T;return t.preloadOnly?(this._preloadTiles(c),this):(this.fire(new s.x("movestart",r)).fire(new s.x("move",r)),d&&this.fire(new s.x("zoomstart",r)).fire(new s.x("zoom",r)).fire(new s.x("zoomend",r)),f&&this.fire(new s.x("rotatestart",r)).fire(new s.x("rotate",r)).fire(new s.x("rotateend",r)),_&&this.fire(new s.x("pitchstart",r)).fire(new s.x("pitch",r)).fire(new s.x("pitchend",r)),this.fire(new s.x("moveend",r)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||s.w(yn),this.transform.getFreeCameraOptions()}setFreeCameraOptions(t,r){const c=this.transform;if(!c.projection.supportsFreeCamera)return s.w(yn),this;this.stop();const d=c.zoom,f=c.pitch,_=c.bearing;c.setFreeCameraOptions(t);const T=d!==c.zoom,S=f!==c.pitch,A=_!==c.bearing;return this.fire(new s.x("movestart",r)).fire(new s.x("move",r)),T&&this.fire(new s.x("zoomstart",r)).fire(new s.x("zoom",r)).fire(new s.x("zoomend",r)),A&&this.fire(new s.x("rotatestart",r)).fire(new s.x("rotate",r)).fire(new s.x("rotateend",r)),S&&this.fire(new s.x("pitchstart",r)).fire(new s.x("pitch",r)).fire(new s.x("pitchend",r)),this.fire(new s.x("moveend",r)),this}easeTo(t,r){this._stop(!1,t.easeId),(!1===(t=s.l({offset:[0,0],duration:500,easing:s.dr},t)).animate||this._prefersReducedMotion(t))&&(t.duration=0);const c=this.transform,d=this.getZoom(),f=this.getBearing(),_=this.getPitch(),T=this.getPadding(),S="zoom"in t?+t.zoom:d,A="bearing"in t?this._normalizeBearing(t.bearing,f):f,I="pitch"in t?+t.pitch:_,z=this._extendPadding(t.padding),D=s.P.convert(t.offset);let L,F,N;if("globe"===c.projection.name){const de=s.a5.fromLngLat(c.center),ce=D.rotate(-c.angle);de.x+=ce.x/c.worldSize,de.y+=ce.y/c.worldSize;const ae=de.toLngLat(),ye=s.bK.convert(t.center||ae);this._normalizeCenter(ye),L=c.centerPoint.add(ce),F=new s.P(de.x,de.y).mult(c.worldSize),N=new s.P(s.am(ye.lng),s.at(ye.lat)).mult(c.worldSize).sub(F)}else{L=c.centerPoint.add(D);const de=c.pointLocation(L),ce=s.bK.convert(t.center||de);this._normalizeCenter(ce),F=c.project(de),N=c.project(ce).sub(F)}const V=c.zoomScale(S-d);let U,W;t.around&&(U=s.bK.convert(t.around),W=c.locationPoint(U));const Y=this._zooming||S!==d,$=this._rotating||f!==A,Q=this._pitching||I!==_,J=!c.isPaddingEqual(z),ne=!1===t.retainPadding?c.clone():c,ie=de=>ce=>{if(Y&&(de.zoom=s.aa(d,S,ce)),$&&(de.bearing=s.aa(f,A,ce)),Q&&(de.pitch=s.aa(_,I,ce)),J&&(ne.interpolatePadding(T,z,ce),L=ne.centerPoint.add(D)),U)de.setLocationAtPoint(U,W);else{const ae=de.zoomScale(de.zoom-d),ye=S>d?Math.min(2,V):Math.max(.5,V),Ie=Math.pow(ye,1-ce),ke=de.unproject(F.add(N.mult(ce*Ie)).mult(ae));de.setLocationAtPoint(de.renderWorldCopies?ke.wrap():ke,L)}return t.preloadOnly||this._fireMoveEvents(r),de};if(t.preloadOnly){const de=this._emulate(ie,t.duration,c);return this._preloadTiles(de),this}const oe={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=Y,this._rotating=$,this._pitching=Q,this._padding=J,this._easeId=t.easeId,this._prepareEase(r,t.noMoveStart,oe),this._ease(ie(c),de=>{"sea"===c.cameraElevationReference&&c.recenterOnTerrain(),this._afterEase(r,de)},t),this}_prepareEase(t,r,c={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&0===this.transform.pitch&&"globe"!==this.transform.projection.name&&(this.transform.cameraElevationReference="ground"),r||c.moving||this.fire(new s.x("movestart",t)),this._zooming&&!c.zooming&&this.fire(new s.x("zoomstart",t)),this._rotating&&!c.rotating&&this.fire(new s.x("rotatestart",t)),this._pitching&&!c.pitching&&this.fire(new s.x("pitchstart",t))}_fireMoveEvents(t){this.fire(new s.x("move",t)),this._zooming&&this.fire(new s.x("zoom",t)),this._rotating&&this.fire(new s.x("rotate",t)),this._pitching&&this.fire(new s.x("pitch",t))}_afterEase(t,r){if(this._easeId&&r&&this._easeId===r)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const c=this._zooming,d=this._rotating,f=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,c&&this.fire(new s.x("zoomend",t)),d&&this.fire(new s.x("rotateend",t)),f&&this.fire(new s.x("pitchend",t)),this.fire(new s.x("moveend",t))}flyTo(t,r){if(this._prefersReducedMotion(t)){const ze=s.ar(t,["center","zoom","bearing","pitch","around","padding","retainPadding"]);return this.jumpTo(ze,r)}this.stop(),t=s.l({offset:[0,0],speed:1.2,curve:1.42,easing:s.dr},t);const c=this.transform,d=this.getZoom(),f=this.getBearing(),_=this.getPitch(),T=this.getPadding(),S="zoom"in t?s.ap(+t.zoom,c.minZoom,c.maxZoom):d,A="bearing"in t?this._normalizeBearing(t.bearing,f):f,I="pitch"in t?+t.pitch:_,z=this._extendPadding(t.padding),D=c.zoomScale(S-d),L=s.P.convert(t.offset);let F=c.centerPoint.add(L);const N=c.pointLocation(F),V=s.bK.convert(t.center||N);this._normalizeCenter(V);const U=c.project(N),W=c.project(V).sub(U);let Y=t.curve;const $=Math.max(c.width,c.height),Q=$/D,J=W.mag();if("minZoom"in t){const ze=s.ap(Math.min(t.minZoom,d,S),c.minZoom,c.maxZoom),Ue=$/c.zoomScale(ze-d);Y=Math.sqrt(Ue/J*2)}const ne=Y*Y;function ie(ze){const Ue=(Q*Q-$*$+(ze?-1:1)*ne*ne*J*J)/(2*(ze?Q:$)*ne*J);return Math.log(Math.sqrt(Ue*Ue+1)-Ue)}function oe(ze){return(Math.exp(ze)-Math.exp(-ze))/2}function de(ze){return(Math.exp(ze)+Math.exp(-ze))/2}const ce=ie(0);let ae=function(ze){return de(ce)/de(ce+Y*ze)},ye=function(ze){return $*((de(ce)*(oe(Ue=ce+Y*ze)/de(Ue))-oe(ce))/ne)/J;var Ue},Ie=(ie(1)-ce)/Y;if(Math.abs(J)<1e-6||!isFinite(Ie)){if(Math.abs($-Q)<1e-6)return this.easeTo(t,r);const ze=Q<$?-1:1;Ie=Math.abs(Math.log(Q/$))/Y,ye=function(){return 0},ae=function(Ue){return Math.exp(ze*Y*Ue)}}t.duration="duration"in t?+t.duration:1e3*Ie/("screenSpeed"in t?+t.screenSpeed/Y:+t.speed),t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0);const ke=f!==A,Ae=I!==_,Ne=!c.isPaddingEqual(z),xe=!1===t.retainPadding?c.clone():c,Re=ze=>Ue=>{const Ge=Ue*Ie,Le=1/ae(Ge);ze.zoom=1===Ue?S:d+ze.scaleZoom(Le),ke&&(ze.bearing=s.aa(f,A,Ue)),Ae&&(ze.pitch=s.aa(_,I,Ue)),Ne&&(xe.interpolatePadding(T,z,Ue),F=xe.centerPoint.add(L));const Be=1===Ue?V:ze.unproject(U.add(W.mult(ye(Ge))).mult(Le));return ze.setLocationAtPoint(ze.renderWorldCopies?Be.wrap():Be,F),ze._updateCameraOnTerrain(),t.preloadOnly||this._fireMoveEvents(r),ze};if(t.preloadOnly){const ze=this._emulate(Re,t.duration,c);return this._preloadTiles(ze),this}return this._zooming=!0,this._rotating=ke,this._pitching=Ae,this._padding=Ne,this._prepareEase(r,!1),this._ease(Re(c),()=>this._afterEase(r),t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_requestRenderFrame(t){}_cancelRenderFrame(t){}_stop(t,r){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const c=this._onEaseEnd;this._onEaseEnd=void 0,c.call(this,r)}if(!t){const c=this.handlers;c&&c.stop(!1)}return this}_ease(t,r,c){!1===c.animate||0===c.duration?(t(1),r()):(this._easeStart=s.q.now(),this._easeOptions=c,this._onEaseFrame=t,this._onEaseEnd=r,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const t=Math.min((s.q.now()-this._easeStart)/this._easeOptions.duration,1),r=this._onEaseFrame;r&&r(this._easeOptions.easing(t)),t<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(t,r){t=s.bA(t,-180,180);const c=Math.abs(t-r);return Math.abs(t-360-r)180?-360:c<-180?360:0}_prefersReducedMotion(t){return this._respectPrefersReducedMotion&&s.q.prefersReducedMotion&&!(t&&t.essential)}_emulate(t,r,c){const d=Math.ceil(15*r/1e3),f=[],_=t(c.clone());for(let T=0;T<=d;T++){const S=_(T/d);f.push(S.clone())}return f}_preloadTiles(t,r){}}class Ol{constructor(t={}){this.options=t,s.aJ(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(t){const r=this.options&&this.options.compact,c=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",c);const d=Nt("span","mapboxgl-ctrl-icon",this._compactButton);return d.setAttribute("aria-hidden","true"),d.setAttribute("title",c),this._innerContainer=Nt("div","mapboxgl-ctrl-attrib-inner",this._container),r&&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),void 0===r&&(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 r=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||s.e.ACCESS_TOKEN}];if(t){const c=r.reduce((d,f,_)=>(f.value&&(d+=`${f.key}=${f.value}${_d.length-f.length),t=t.filter((d,f)=>{for(let _=f+1;_=0)return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=[...this.options.customAttribution,...t]:t.unshift(this.options.customAttribution));const c=t.join(" | ");c!==this._attribHTML&&(this._attribHTML=c,t.length?(this._innerContainer.innerHTML=c,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 ih{constructor(){s.aJ(["_updateLogo","_updateCompact"],this)}onAdd(t){this._map=t,this._container=Nt("div","mapboxgl-ctrl");const r=Nt("a","mapboxgl-ctrl-logo");return r.target="_blank",r.rel="noopener nofollow",r.href="https://www.mapbox.com/",r.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),r.setAttribute("rel","noopener nofollow"),this._container.appendChild(r),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&&"metadata"!==t.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const t=this._map.style._sourceCaches;if(0===Object.entries(t).length)return!0;for(const r in t){const c=t[r].getSource();if(c.hasOwnProperty("mapbox_logo")&&!c.mapbox_logo)return!1}return!0}_updateCompact(){const t=this._container.children;if(t.length){const r=t[0];this._map.getCanvasContainer().offsetWidth<250?r.classList.add("mapboxgl-compact"):r.classList.remove("mapboxgl-compact")}}}class Fu{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){const r=++this._id;return this._queue.push({callback:t,id:r,cancelled:!1}),r}remove(t){const r=this._currentlyRunning,c=r?this._queue.concat(r):this._queue;for(const d of c)if(d.id===t)return void(d.cancelled=!0)}run(t=0){const r=this._currentlyRunning=this._queue;this._queue=[];for(const c of r)if(!c.cancelled&&(c.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}class Sa{constructor(t){this.jumpTo(t)}getValue(t){if(t<=this._startTime)return this._start;if(t>=this._endTime)return this._end;const r=s.cw((t-this._startTime)/(this._endTime-this._startTime));return this._start*(1-r)+this._end*r}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,r,c){this._start=this.getValue(r),this._end=t,this._startTime=r,this._endTime=r+c}}const Jd={"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 \u2318 + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"};class Qd{registerParameter(){}registerButton(){}registerBinding(){}refreshUI(){}}class rh{constructor(t){this.map=t,this.interactionsByType=new Map,this.typeById=new Map,this.filters=new Map,this.handleType=this.handleType.bind(this)}add(t,r){if(this.typeById.has(t))throw new Error(`Interaction id "${t}" already exists.`);const{type:c,filter:d}=r;if(d){const _=s.M(d,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===_.result)throw new Error(_.value.map(T=>`${T.key}: ${T.message}`).join(", "));this.filters.set(t,_.value)}const f=this.interactionsByType.get(c)||new Map;0===f.size&&(this.map.on(c,this.handleType),this.interactionsByType.set(c,f)),f.set(t,r),this.typeById.set(t,c)}remove(t){const r=this.typeById.get(t);if(!r)return;this.typeById.delete(t),this.filters.delete(t);const c=this.interactionsByType.get(r);c&&(c.delete(t),0===c.size&&this.map.off(r,this.handleType))}handleType(t){const r=t.features||this.map.queryRenderedFeatures(t.point);if(!r)return;const c=this.interactionsByType.get(t.type),d={zoom:0};for(const[f,_]of c){const T=this.filters.get(f),{handler:S,layers:A}=_;for(const I of r)if((!A||A.includes(I.layer.id))&&(!T||T.evaluate(d,I))&&!1!==S({id:f,feature:I,interaction:_}))break}}}const nh={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,transformRequest:null,accessToken:null,fadeDuration:300,respectPrefersReducedMotion:!0,crossSourceCollisions:!0,collectResourceTiming:!1,testMode:!1,precompilePrograms:!0},Ea={showCompass:!0,showZoom:!0,visualizePitch:!1};class Ss{constructor(t,r,c=!1){this._clickTolerance=10,this.element=r,this.mouseRotate=new zl({clickTolerance:t.dragRotate._mouseRotate._clickTolerance}),this.map=t,c&&(this.mousePitch=new Dl({clickTolerance:t.dragRotate._mousePitch._clickTolerance})),s.aJ(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),r.addEventListener("mousedown",this.mousedown),r.addEventListener("touchstart",this.touchstart,{passive:!1}),r.addEventListener("touchmove",this.touchmove),r.addEventListener("touchend",this.touchend),r.addEventListener("touchcancel",this.reset)}down(t,r){this.mouseRotate.mousedown(t,r),this.mousePitch&&this.mousePitch.mousedown(t,r),gt()}move(t,r){const c=this.map,d=this.mouseRotate.mousemoveWindow(t,r),f=d&&d.bearingDelta;if(f&&c.setBearing(c.getBearing()+f),this.mousePitch){const _=this.mousePitch.mousemoveWindow(t,r),T=_&&_.pitchDelta;T&&c.setPitch(c.getPitch()+T)}}off(){const t=this.element;t.removeEventListener("mousedown",this.mousedown),t.removeEventListener("touchstart",this.touchstart,{passive:!1}),t.removeEventListener("touchmove",this.touchmove),t.removeEventListener("touchend",this.touchend),t.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){Oi(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup)}mousedown(t){this.down(s.l({},t,{ctrlKey:!0,preventDefault:()=>t.preventDefault()}),zi(this.element,t)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)}mousemove(t){this.move(t,zi(this.element,t))}mouseup(t){this.mouseRotate.mouseupWindow(t),this.mousePitch&&this.mousePitch.mouseupWindow(t),this.offTemp()}touchstart(t){1!==t.targetTouches.length?this.reset():(this._startPos=this._lastPos=Pt(this.element,t.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>t.preventDefault()},this._startPos))}touchmove(t){1!==t.targetTouches.length?this.reset():(this._lastPos=Pt(this.element,t.targetTouches)[0],this.move({preventDefault:()=>t.preventDefault()},this._lastPos))}touchend(t){0===t.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)r.width||t.y>r.height;r.locationPoint(c).distSqr(t)<_&&(T||Math.abs(c.lng-r.center.lng)180;){const c=r.locationPoint(l);if(c.x>=0&&c.y>=0&&c.x<=r.width&&c.y<=r.height)break;l.lng>r.center.lng?l.lng-=360:l.lng+=360}return l}const Vr={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%)"};class vn extends s.E{constructor(t,r){if(super(),(t instanceof HTMLElement||r)&&(t=s.l({element:t},r)),s.aJ(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this),this._anchor=t&&t.anchor||"center",this._color=t&&t.color||"#3FB1CE",this._scale=t&&t.scale||1,this._draggable=t&&t.draggable||!1,this._clickTolerance=t&&t.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=t&&t.rotation||0,this._rotationAlignment=t&&t.rotationAlignment||"auto",this._pitchAlignment=t&&t.pitchAlignment&&t.pitchAlignment||"auto",this._updateMoving=()=>this._update(!0),this._occludedOpacity=t&&t.occludedOpacity||.2,t&&t.element)this._element=t.element,this._offset=s.P.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=Nt("div");const f=41,_=27,T=ni("svg",{display:"block",height:f*this._scale+"px",width:_*this._scale+"px",viewBox:`0 0 ${_} ${f}`},this._element),S=ni("radialGradient",{id:"shadowGradient"},ni("defs",{},T));ni("stop",{offset:"10%","stop-opacity":.4},S),ni("stop",{offset:"100%","stop-opacity":.05},S),ni("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},T),ni("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"},T),ni("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"},T),ni("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},T),this._offset=s.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",f=>{f.preventDefault()}),this._element.addEventListener("mousedown",f=>{f.preventDefault()});const c=this._element.classList;for(const f in Vr)c.remove(`mapboxgl-marker-anchor-${f}`);c.add(`mapboxgl-marker-anchor-${this._anchor}`);const d=t&&t.className?t.className.trim().split(/\s+/):[];c.add(...d),this._popup=null}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=s.bK.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}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*(24.6+d)],"bottom-right":[-d,-1*(24.6+d)],left:[13.5,-24.6],right:[-13.5,-24.6]}:this._offset}this._popup=t,t._marker=this,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 r=t.code,c=t.charCode||t.keyCode;"Space"!==r&&"Enter"!==r&&32!==c&&13!==c||this.togglePopup()}_onMapClick(t){const r=t.originalEvent.target,c=this._element;this._popup&&(r===c||c.contains(r))&&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,r=this._pos;if(!t||!r)return!1;const c=t.unproject(r),d=t.getFreeCameraOptions();if(!d.position)return!1;const f=d.position.toLngLat();return f.distanceTo(c)<.9*f.distanceTo(this._lngLat)}_evaluateOpacity(){const t=this._map;if(!t)return;const r=this._pos;if(!r||r.x<0||r.x>t.transform.width||r.y<0||r.y>t.transform.height)return void this._clearFadeTimer();const c=t.unproject(r);let d;t._showingGlobe()&&s.dz(t.transform,this._lngLat)?d=0:(d=1-t._queryFogOpacity(c),t.transform._terrainEnabled()&&t.getTerrain()&&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 r=this._offset.mult(this._scale);this._element.style.transform=`\n translate(${t.x}px,${t.y}px)\n ${Vr[this._anchor]}\n ${this._calculateXYTransform()} ${this._calculateZTransform()}\n translate(${r.x}px,${r.y}px)\n `}_calculateXYTransform(){const t=this._pos,r=this._map,c=this.getPitchAlignment();if(!r||!t||"map"!==c)return"";if(!r._showingGlobe()){const S=r.getPitch();return S?`rotateX(${S}deg)`:""}const d=s.c0(s.dA(r.transform,this._lngLat)),f=t.sub(s.dB(r.transform)),_=Math.abs(f.x)+Math.abs(f.y);if(0===_)return"";const T=d/_;return`rotateX(${-f.y*T}deg) rotateY(${f.x*T}deg)`}_calculateZTransform(){const t=this._pos,r=this._map;if(!r||!t)return"";let c=0;const d=this.getRotationAlignment();if("map"===d)if(r._showingGlobe()){const f=r.project(new s.bK(this._lngLat.lng,this._lngLat.lat+.001)),_=r.project(new s.bK(this._lngLat.lng,this._lngLat.lat-.001)).sub(f);c=s.c0(Math.atan2(_.y,_.x))-90}else c=-r.getBearing();else if("horizon"===d){const f=s.a7(4,6,r.getZoom()),_=s.dB(r.transform);_.y+=f*r.transform.height;const T=t.sub(_),S=s.c0(Math.atan2(T.y,T.x));c=(S>90?S-270:S+90)*(1-f)}return c+=this._rotation,c?`rotateZ(${c}deg)`:""}_update(t){cancelAnimationFrame(this._updateFrameId);const r=this._map;r&&(r.transform.renderWorldCopies&&(this._lngLat=xn(this._lngLat,this._pos,r.transform)),this._pos=r.project(this._lngLat),!0===t?this._updateFrameId=requestAnimationFrame(()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())}):this._pos=this._pos.round(),r._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(r._showingGlobe()||r.getTerrain()||r.getFog())&&!this._fadeTimer&&(this._fadeTimer=window.setTimeout(this._evaluateOpacity.bind(this),60)))}))}getOffset(){return this._offset}setOffset(t){return this._offset=s.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 r=this._map;if(!r)return;const c=this._pointerdownPos,d=this._positionDelta;if(c&&d){if(!this._isDragging){const f=this._clickTolerance||r._clickTolerance;if(t.point.dist(c)l.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=l.minPitch&&null!=l.maxPitch&&l.minPitch>l.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=l.minPitch&&l.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=l.maxPitch&&l.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(l.antialias&&s.dx(window)&&(l.antialias=!1,s.w("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new Xa(l.minZoom,l.maxZoom,l.minPitch,l.maxPitch,l.renderWorldCopies),l),this._repaint=!!l.repaint,this._interactive=l.interactive,this._minTileCacheSize=l.minTileCacheSize,this._maxTileCacheSize=l.maxTileCacheSize,this._failIfMajorPerformanceCaveat=l.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=l.preserveDrawingBuffer,this._antialias=l.antialias,this._trackResize=l.trackResize,this._bearingSnap=l.bearingSnap,this._refreshExpiredTiles=l.refreshExpiredTiles,this._fadeDuration=l.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=l.crossSourceCollisions,this._collectResourceTiming=l.collectResourceTiming,this._language=this._parseLanguage(l.language),this._worldview=l.worldview,this._renderTaskQueue=new Fu,this._domRenderTaskQueue=new Fu,this._controls=[],this._markers=[],this._popups=[],this._mapId=s.aP(),this._locale=s.l({},Jd,l.locale),this._clickTolerance=l.clickTolerance,this._cooperativeGestures=l.cooperativeGestures,this._performanceMetricsCollection=l.performanceMetricsCollection,this._tessellationStep=l.tessellationStep,this._containerWidth=0,this._containerHeight=0,this._showParseStatus=!0,this._precompilePrograms=l.precompilePrograms,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new Sa(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._frameId=0,this._requestManager=new Oa(l.transformRequest,l.accessToken,l.testMode),this._silenceAuthErrors=!!l.testMode,this._contextCreateOptions=l.contextCreateOptions?{...l.contextCreateOptions}:{},"string"==typeof l.container){const r=document.getElementById(l.container);if(!r)throw new Error(`Container '${l.container.toString()}' not found.`);this._container=r}else{if(!(l.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=l.container}if(this._container.childNodes.length>0&&s.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."),l.maxBounds&&this.setMaxBounds(l.maxBounds),s.aJ(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._tp||(this._tp=new Qd),this._tp.registerParameter(this,["Debug"],"showOverdrawInspector"),this._tp.registerParameter(this,["Debug"],"showTileBoundaries"),this._tp.registerParameter(this,["Debug"],"showParseStatus"),this._tp.registerParameter(this,["Debug"],"repaint"),this._tp.registerParameter(this,["Debug"],"showTileAABBs"),this._tp.registerParameter(this,["Debug"],"showPadding"),this._tp.registerParameter(this,["Debug"],"showCollisionBoxes",{noSave:!0}),this._tp.registerParameter(this.transform,["Debug"],"freezeTileCoverage",{noSave:!0},()=>{this._update()}),this._tp.registerParameter(this,["Debug","Wireframe"],"showTerrainWireframe"),this._tp.registerParameter(this,["Debug","Wireframe"],"showLayers2DWireframe"),this._tp.registerParameter(this,["Debug","Wireframe"],"showLayers3DWireframe"),this._setupPainter(),void 0===this.painter)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 gr(this,l),this._localFontFamily=l.localFontFamily,this._localIdeographFontFamily=l.localIdeographFontFamily,(l.style||!l.testMode)&&this.setStyle(l.style||s.e.DEFAULT_STYLE,{config:l.config,localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),l.projection&&this.setProjection(l.projection),l.hash&&(this._hash=new no("string"==typeof l.hash&&l.hash||void 0).addTo(this)),!this._hash||!this._hash._onHashChange()){null==t.center&&null==t.zoom||(this.transform._unmodified=!1),this.jumpTo({center:l.center,zoom:l.zoom,bearing:l.bearing,pitch:l.pitch});const r=l.bounds;r&&(this.resize(),this.fitBounds(r,s.l({},l.fitBoundsOptions,{duration:0})))}this.resize(),l.attributionControl&&this.addControl(new Ol({customAttribution:l.customAttribution})),this._logoControl=new ih,this.addControl(this._logoControl,l.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet),this._postStyleLoadEvent()}),this.on("data",r=>{this._update("style"===r.dataType),this.fire(new s.x(`${r.dataType}data`,r))}),this.on("dataloading",r=>{this.fire(new s.x(`${r.dataType}dataloading`,r))}),this._interactions=new rh(this)}_getMapId(){return this._mapId}addControl(l,t){if(void 0===t&&(t=l.getDefaultPosition?l.getDefaultPosition():"top-right"),!l||!l.onAdd)return this.fire(new s.t(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const r=l.onAdd(this);this._controls.push(l);const c=this._controlPositions[t];return-1!==t.indexOf("bottom")?c.insertBefore(r,c.firstChild):c.appendChild(r),this}removeControl(l){if(!l||!l.onRemove)return this.fire(new s.t(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const t=this._controls.indexOf(l);return t>-1&&this._controls.splice(t,1),l.onRemove(this),this}hasControl(l){return this._controls.indexOf(l)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(l){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 s.x("movestart",l)).fire(new s.x("move",l)),this.fire(new s.x("resize",l)),t&&this.fire(new s.x("moveend",l)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(l){return this.transform.setMaxBounds(s.as.convert(l)),this._update()}setMinZoom(l){if((l=l??-2)>=-2&&l<=this.transform.maxZoom)return this.transform.minZoom=l,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=l,this._update(),this.getZoom()>l?this.setZoom(l):this.fire(new s.x("zoomstart")).fire(new s.x("zoom")).fire(new s.x("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(l){if((l=l??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(l>=0&&l<=this.transform.maxPitch)return this.transform.minPitch=l,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(l>=this.transform.minPitch)return this.transform.maxPitch=l,this._update(),this.getPitch()>l?this.setPitch(l):this.fire(new s.x("pitchstart")).fire(new s.x("pitch")).fire(new s.x("pitchend")),this;throw new Error("maxPitch must be greater than or equal to minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(l){return this.transform.renderWorldCopies=l,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(l){return"auto"===l?navigator.language:Array.isArray(l)?0===l.length?void 0:l.map(t=>"auto"===t?navigator.language:t):l}setLanguage(l){const t=this._parseLanguage(l);if(!this.style||t===this._language)return this;this._language=t,this.style.reloadSources();for(const r of this._controls)r._setLanguage&&r._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(l){return this.style&&l!==this._worldview?(this._worldview=l,this.style.reloadSources(),this):this}getProjection(){return this.transform.mercatorFromTransition?{name:"globe",center:[0,0]}:this.transform.getProjection()}_showingGlobe(){return"globe"===this.transform.projection.name}setProjection(l){return this._lazyInitEmptyStyle(),l?"string"==typeof l&&(l={name:l}):l=null,this._useExplicitProjection=!!l,this._prioritizeAndUpdateProjection(l,this.style.projection)}_updateProjectionTransition(){if("globe"!==this.getProjection().name)return;const l=this.transform,t=l.projection.name;let r;"globe"===t&&l.zoom>=s.bU?(l.setMercatorFromTransition(),r=!0):"mercator"===t&&l.zoom=s.bU?this.transform.setMercatorFromTransition():this.transform.setProjection(l),this.style.applyProjectionUpdate(),t&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}project(l){return this.transform.locationPoint3D(s.bK.convert(l))}unproject(l){return this.transform.pointLocation3D(s.P.convert(l))}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(l,t,r){if("mouseenter"===l||"mouseover"===l){let c=!1;const d=_=>{const T=t.filter(A=>this.getLayer(A)),S=T.length?this.queryRenderedFeatures(_.point,{layers:T}):[];S.length?c||(c=!0,r.call(this,new wr(l,this,_.originalEvent,{features:S}))):c=!1},f=()=>{c=!1};return{layers:new Set(t),listener:r,delegates:{mousemove:d,mouseout:f}}}if("mouseleave"===l||"mouseout"===l){let c=!1;const d=_=>{const T=t.filter(S=>this.getLayer(S));(T.length?this.queryRenderedFeatures(_.point,{layers:T}):[]).length?c=!0:c&&(c=!1,r.call(this,new wr(l,this,_.originalEvent)))},f=_=>{c&&(c=!1,r.call(this,new wr(l,this,_.originalEvent)))};return{layers:new Set(t),listener:r,delegates:{mousemove:d,mouseout:f}}}{const c=d=>{const f=t.filter(T=>this.getLayer(T)),_=f.length?this.queryRenderedFeatures(d.point,{layers:f}):[];_.length&&(d.features=_,r.call(this,d),delete d.features)};return{layers:new Set(t),listener:r,delegates:{[l]:c}}}}on(l,t,r){if("function"==typeof t||void 0===r)return super.on(l,t);if(Array.isArray(t)||(t=[t]),t)for(const d of t)if(!this._isValidId(d))return this;const c=this._createDelegatedListener(l,t,r);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[l]=this._delegatedListeners[l]||[],this._delegatedListeners[l].push(c);for(const d in c.delegates)this.on(d,c.delegates[d]);return this}once(l,t,r){if("function"==typeof t||void 0===r)return super.once(l,t);if(Array.isArray(t)||(t=[t]),t)for(const d of t)if(!this._isValidId(d))return this;const c=this._createDelegatedListener(l,t,r);for(const d in c.delegates)this.once(d,c.delegates[d]);return this}off(l,t,r){if("function"==typeof t||void 0===r)return super.off(l,t);const c=new Set(Array.isArray(t)?t:[t]);for(const _ of c)if(!this._isValidId(_))return this;const d=(_,T)=>{if(_.size!==T.size)return!1;for(const S of _)if(!T.has(S))return!1;return!0},f=this._delegatedListeners?this._delegatedListeners[l]:void 0;return f&&(_=>{for(let T=0;T<_.length;T++){const S=_[T];if(S.listener===r&&d(S.layers,c)){for(const A in S.delegates)this.off(A,S.delegates[A]);return _.splice(T,1),this}}})(f),this}queryRenderedFeatures(l,t){if(!this.style)return[];if(void 0!==t||void 0===l||l instanceof s.P||Array.isArray(l)||(t=l,l=void 0),l=l||[[0,0],[this.transform.width,this.transform.height]],(t=t||{}).layers&&Array.isArray(t.layers))for(const r of t.layers)if(!this._isValidId(r))return[];return this.style.queryRenderedFeatures(l,t,this.transform)}querySourceFeatures(l,t){return this._isValidId(l)?this.style.querySourceFeatures(l,t):[]}isPointOnSurface(l){const{name:t}=this.transform.projection;return"globe"!==t&&"mercator"!==t&&s.w(`${t} projection does not support isPointOnSurface, this API may behave unexpectedly.`),this.transform.isPointOnSurface(s.P.convert(l))}addInteraction(l,t){return this._interactions.add(l,t),this}removeInteraction(l){return this._interactions.remove(l),this}setStyle(l,t){return t=s.l({},{localIdeographFontFamily:this._localIdeographFontFamily,localFontFamily:this._localFontFamily},t),this.style&&l&&!1!==t.diff&&t.localFontFamily===this._localFontFamily&&t.localIdeographFontFamily===this._localIdeographFontFamily&&!t.config?(this.style._diffStyle(l,(r,c)=>{r?(s.w(`Unable to perform style diff: ${String(r.message||r.error||r)}. Rebuilding the style from scratch.`),this._updateStyle(l,t)):c&&this._update(!0)},()=>{this._postStyleLoadEvent()}),this):(this._localIdeographFontFamily=t.localIdeographFontFamily,this._localFontFamily=t.localFontFamily,this._updateStyle(l,t))}_getUIString(l){const t=this._locale[l];if(null==t)throw new Error(`Missing UI string '${l}'`);return t}_updateStyle(l,t){if(this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),l){const r=s.l({},t);t&&t.config&&(r.initialConfig=t.config,delete r.config),this.style=new Fr(this,r).load(l),this.style.setEventedParent(this,{style:this.style})}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new Fr(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():(s.w("There is no style added to the map."),!1)}_isValidId(l){return null==l?(this.fire(new s.t(new Error("IDs can't be empty."))),!1):!s.cn(l)||(this.fire(new s.t(new Error(`IDs can't contain special symbols: "${l}".`))),!1)}addSource(l,t){return this._isValidId(l)?(this._lazyInitEmptyStyle(),this.style.addSource(l,t),this._update(!0)):this}isSourceLoaded(l){return!!this._isValidId(l)&&!!this.style&&this.style._isSourceCacheLoaded(l)}areTilesLoaded(){return this.style.areTilesLoaded()}addSourceType(l,t,r){this._lazyInitEmptyStyle(),this.style.addSourceType(l,t,r)}removeSource(l){return this._isValidId(l)?(this.style.removeSource(l),this._updateTerrain(),this._update(!0)):this}getSource(l){return this._isValidId(l)?this.style.getOwnSource(l):null}addImage(l,t,{pixelRatio:r=1,sdf:c=!1,stretchX:d,stretchY:f,content:_}={}){if(this._lazyInitEmptyStyle(),t instanceof HTMLImageElement||ImageBitmap&&t instanceof ImageBitmap){const{width:T,height:S,data:A}=s.q.getImageData(t);this.style.addImage(l,{data:new s.r({width:T,height:S},A),pixelRatio:r,stretchX:d,stretchY:f,content:_,sdf:c,version:0})}else if(void 0===t.width||void 0===t.height)this.fire(new s.t(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:T,height:S}=t,A=t;this.style.addImage(l,{data:new s.r({width:T,height:S},new Uint8Array(A.data)),pixelRatio:r,stretchX:d,stretchY:f,content:_,sdf:c,version:0,userImage:A}),A.onAdd&&A.onAdd(this,l)}}updateImage(l,t){this._lazyInitEmptyStyle();const r=this.style.getImage(l);if(!r)return void this.fire(new s.t(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const c=t instanceof HTMLImageElement||ImageBitmap&&t instanceof ImageBitmap?s.q.getImageData(t):t,{width:d,height:f,data:_}=c;if(void 0===d||void 0===f)return void this.fire(new s.t(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(d!==r.data.width||f!==r.data.height)return void this.fire(new s.t(new Error(`The width and height of the updated image (${d}, ${f})\n must be that same as the previous version of the image\n (${r.data.width}, ${r.data.height})`)));const T=!(t instanceof HTMLImageElement||ImageBitmap&&t instanceof ImageBitmap);r.data.replace(_,T),this.style.updateImage(l,r)}hasImage(l){return l?!!this.style&&!!this.style.getImage(l):(this.fire(new s.t(new Error("Missing required image id"))),!1)}removeImage(l){this.style.removeImage(l)}loadImage(l,t){s.o(this._requestManager.transformRequest(l,s.R.Image),(r,c)=>{t(r,c instanceof HTMLImageElement?s.q.getImageData(c):c)})}listImages(){return this.style.listImages()}addModel(l,t){this._lazyInitEmptyStyle(),this.style.addModel(l,t)}hasModel(l){return l?this.style.hasModel(l):(this.fire(new s.t(new Error("Missing required model id"))),!1)}removeModel(l){this.style.removeModel(l)}listModels(){return this.style.listModels()}addLayer(l,t){return this._isValidId(l.id)?(this._lazyInitEmptyStyle(),this.style.addLayer(l,t),this._update(!0)):this}getSlot(l){const t=this.getLayer(l);return t&&t.slot||null}setSlot(l,t){return this.style.setSlot(l,t),this.style.mergeLayers(),this._update(!0)}addImport(l,t){return this.style.addImport(l,t),this}updateImport(l,t){return"string"!=typeof t&&t.id!==l?(this.removeImport(l),this.addImport(t)):(this.style.updateImport(l,t),this._update(!0))}removeImport(l){return this.style.removeImport(l),this}moveImport(l,t){return this.style.moveImport(l,t),this._update(!0)}moveLayer(l,t){return this._isValidId(l)?(this.style.moveLayer(l,t),this._update(!0)):this}removeLayer(l){return this._isValidId(l)?(this.style.removeLayer(l),this._update(!0)):this}getLayer(l){if(!this._isValidId(l))return null;const t=this.style.getOwnLayer(l);return t?"custom"===t.type?t.implementation:t.serialize():void 0}getSlots(){return this.style.getSlots()}setLayerZoomRange(l,t,r){return this._isValidId(l)?(this.style.setLayerZoomRange(l,t,r),this._update(!0)):this}setFilter(l,t,r={}){return this._isValidId(l)?(this.style.setFilter(l,t,r),this._update(!0)):this}getFilter(l){return this._isValidId(l)?this.style.getFilter(l):null}setPaintProperty(l,t,r,c={}){return this._isValidId(l)?(this.style.setPaintProperty(l,t,r,c),this._update(!0)):this}getPaintProperty(l,t){return this._isValidId(l)?this.style.getPaintProperty(l,t):null}setLayoutProperty(l,t,r,c={}){return this._isValidId(l)?(this.style.setLayoutProperty(l,t,r,c),this._update(!0)):this}getLayoutProperty(l,t){return this._isValidId(l)?this.style.getLayoutProperty(l,t):null}getSchema(l){return this.style.getSchema(l)}setSchema(l,t){return this.style.setSchema(l,t),this._update(!0)}getConfig(l){return this.style.getConfig(l)}setConfig(l,t){return this.style.setConfig(l,t),this._update(!0)}getConfigProperty(l,t){return this.style.getConfigProperty(l,t)}setConfigProperty(l,t,r){return this.style.setConfigProperty(l,t,r),this._update(!0)}setLights(l){if(this._lazyInitEmptyStyle(),l&&1===l.length&&"flat"===l[0].type){const t=l[0];t.properties?this.style.setFlatLight(t.properties,t.id,{}):this.style.setFlatLight({},"flat")}else this.style.setLights(l),this.painter.terrain&&(this.painter.terrain.invalidateRenderCache=!0);return this._update(!0)}getLights(){const l=this.style.getLights()||[];return 0===l.length&&l.push({id:this.style.light.id,type:"flat",properties:this.style.getFlatLight()}),l}setLight(l,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:l}])}getLight(){return console.log("The `map.getLight` function is deprecated, prefer using `map.getLights` instead."),this.style.getFlatLight()}setTerrain(l){return this._lazyInitEmptyStyle(),!l&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(l),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(l){return this._lazyInitEmptyStyle(),this.style.setFog(l),this._update(!0)}getFog(){return this.style?this.style.getFog():null}setColorTheme(l){return this._lazyInitEmptyStyle(),this.style.setColorTheme(l),this._update(!0)}setCamera(l){return this.style.setCamera(l),this._triggerCameraUpdate(l)}_triggerCameraUpdate(l){return this._update(this.transform.setOrthographicProjectionAtLowPitch("orthographic"===l["camera-projection"]))}getCamera(){return this.style.camera}_queryFogOpacity(l){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(s.bK.convert(l),this.transform):0}setFeatureState(l,t){return this._isValidId(l.source)?(this.style.setFeatureState(l,t),this._update()):this}removeFeatureState(l,t){return this._isValidId(l.source)?(this.style.removeFeatureState(l,t),this._update()):this}getFeatureState(l){return this._isValidId(l.source)?this.style.getFeatureState(l):null}_updateContainerDimensions(){if(!this._container)return;const l=this._container.getBoundingClientRect().width||400,t=this._container.getBoundingClientRect().height||300;let r,c,d,f=this._container;for(;f&&(!c||!d);){const _=window.getComputedStyle(f).transform;_&&"none"!==_&&(r=_.match(/matrix.*\((.+)\)/)[1].split(", "),r[0]&&"0"!==r[0]&&"1"!==r[0]&&(c=r[0]),r[3]&&"0"!==r[3]&&"1"!==r[3]&&(d=r[3])),f=f.parentElement}this._containerWidth=c?Math.abs(l/c):l,this._containerHeight=d?Math.abs(t/d):t}_detectMissingCSS(){"rgb(250, 128, 114)"!==window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&s.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 l=this._container;l.classList.add("mapboxgl-map"),(this._missingCSSCanary=Nt("div","mapboxgl-canary",l)).style.visibility="hidden",this._detectMissingCSS();const t=this._canvasContainer=Nt("div","mapboxgl-canvas-container",l);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 r=this._controlContainer=Nt("div","mapboxgl-control-container",l),c=this._controlPositions={};["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"].forEach(d=>{c[d]=Nt("div",`mapboxgl-ctrl-${d}`,r)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(l,t){const r=s.q.devicePixelRatio||1;this._canvas.width=r*Math.ceil(l),this._canvas.height=r*Math.ceil(t),this._canvas.style.width=`${l}px`,this._canvas.style.height=`${t}px`}_addMarker(l){this._markers.push(l)}_removeMarker(l){const t=this._markers.indexOf(l);-1!==t&&this._markers.splice(t,1)}_addPopup(l){this._popups.push(l)}_removePopup(l){const t=this._popups.indexOf(l);-1!==t&&this._popups.splice(t,1)}_setupPainter(){const l=s.l({},ft.supported.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),t=this._canvas.getContext("webgl2",l);t?(Hn(t,!0),this.painter=new qc(t,this._contextCreateOptions,this.transform,this._tp),this.on("data",r=>{"source"===r.dataType&&this.painter.setTileLoadedFlag(!0)}),s.m.testSupport(t)):this.fire(new s.t(new Error("Failed to initialize WebGL")))}_contextLost(l){l.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new s.x("webglcontextlost",{originalEvent:l}))}_contextRestored(l){this._setupPainter(),this.resize(),this._update(),this.fire(new s.x("webglcontextrestored",{originalEvent:l}))}_onMapScroll(l){if(l.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(l){return this.style?(this._styleDirty=this._styleDirty||l,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(l){return this._update(),this._renderTaskQueue.add(l)}_cancelRenderFrame(l){this._renderTaskQueue.remove(l)}_requestDomTask(l){!this.loaded()||this.loaded()&&!this.isMoving()?l():this._domRenderTaskQueue.add(l)}_render(l){let t;this.fire(new s.x("renderstart")),++this._frameId;const r=this.painter.context.extTimerQuery,c=s.q.now(),d=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(t=d.createQuery(),d.beginQuery(r.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(l),this._domRenderTaskQueue.run(l),this._removed)return;this._updateProjectionTransition();const f=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const A=this.transform.zoom,I=this.transform.pitch,z=s.q.now(),D=new s.a3(A,{now:z,fadeDuration:f,pitch:I,transition:this.style.transition});this.style.update(D)}this.style&&this.style.hasFogTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let _=!1;this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),_=this._updateAverageElevation(c),this.style.updateSources(this.transform),this._forceMarkerAndPopupUpdate()):_=this._updateAverageElevation(c);const T=this.style&&this.style._updatePlacement(this.painter,this.painter.transform,this.showCollisionBoxes,f,this._crossSourceCollisions,this.painter.replacementSource);if(T&&(this._placementDirty=T.needsRerender),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:f,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),gpuTimingDeferredRender:!!this.listens("gpu-timing-deferred-render"),speedIndexTiming:this.speedIndexTiming}),this.fire(new s.x("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,st.mark(vi.load),this.fire(new s.x("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),t){const A=s.q.now()-c;d.endQuery(r.TIME_ELAPSED_EXT),setTimeout(()=>{const I=d.getQueryParameter(t,d.QUERY_RESULT)/1e6;d.deleteQuery(t),this.fire(new s.x("gpu-timing-frame",{cpuTime:A,gpuTime:I}))},50)}if(this.listens("gpu-timing-layer")){const A=this.painter.collectGpuTimers();setTimeout(()=>{const I=this.painter.queryGpuTimers(A);this.fire(new s.x("gpu-timing-layer",{layerTimes:I}))},50)}if(this.listens("gpu-timing-deferred-render")){const A=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{const I=this.painter.queryGpuTimeDeferredRender(A);this.fire(new s.x("gpu-timing-deferred-render",{gpuTime:I}))},50)}const S=this._sourcesDirty||this._styleDirty||this._placementDirty||_;if(S||this._repaint)this.triggerRepaint();else{const A=this.idle();if(A&&(_=this._updateAverageElevation(c,!0)),_)this.triggerRepaint();else if(this._triggerFrame(!1),A&&(this.fire(new s.x("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const I=this._calculateSpeedIndex();this.fire(new s.x("speedindexcompleted",{speedIndex:I})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||S||(this._fullyLoaded=!0,st.mark(vi.fullLoad),this._performanceMetricsCollection&&Us(this._requestManager._customAccessToken,{width:this.painter.width,height:this.painter.height,interactionRange:this._interactionRange,visibilityHidden:this._visibilityHidden,terrainEnabled:!!this.painter.style.getTerrain(),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(l){for(const t of this._markers)l&&!this.getRenderWorldCopies()&&(t._lngLat=t._lngLat.wrap()),t._update();for(const t of this._popups)!l||this.getRenderWorldCopies()||t._trackPointer||(t._lngLat=t._lngLat.wrap()),t._update()}_updateAverageElevation(l,t=!1){const r=d=>(this.transform.averageElevation=d,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&r(0);const c=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(c||(t||l-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(l)){const d=this.transform.averageElevation;let f=this.transform.sampleAverageElevation();null!=this.transform.elevation&&(this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(f)?f=0:this._averageElevationLastSampledAt=l;const _=Math.abs(d-f);if(_>1){if(this._isInitialLoad||c)return this._averageElevation.jumpTo(f),r(f);this._averageElevation.easeTo(f,l,300)}else if(_>1e-4)return this._averageElevation.jumpTo(f),r(f)}return!!this._averageElevation.isEasing(l)&&r(this._averageElevation.getValue(l))}_authenticate(){ue(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,l=>{if(l&&(l.message===$n||401===l.status)){const t=this.painter.context.gl;Hn(t,!1),this._logoControl instanceof ih&&this._logoControl._updateLogo(),t&&t.clear(t.DEPTH_BUFFER_BIT|t.COLOR_BUFFER_BIT|t.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new s.t(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/")))}}),Vs(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_postStyleLoadEvent(){this.style.globalId&&qr(this._requestManager._customAccessToken,{map:this,skuToken:this._requestManager._skuToken,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()})}_updateTerrain(){const l=this._isDragging();this.painter.updateTerrain(this.style,l)}_calculateSpeedIndex(){const l=this.painter.canvasCopy(),t=this.painter.getCanvasCopiesAndTimestamps();t.timeStamps.push(performance.now());const r=this.painter.context.gl,c=r.createFramebuffer();function d(f){r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,f,0);const _=new Uint8Array(r.drawingBufferWidth*r.drawingBufferHeight*4);return r.readPixels(0,0,r.drawingBufferWidth,r.drawingBufferHeight,r.RGBA,r.UNSIGNED_BYTE,_),_}return r.bindFramebuffer(r.FRAMEBUFFER,c),this._canvasPixelComparison(d(l),t.canvasCopies.map(d),t.timeStamps)}_canvasPixelComparison(l,t,r){let c=r[1]-r[0];const d=l.length/4;for(let f=0;f{const r=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,r&&this._render(t)}))}_preloadTiles(l){const t=this.style?this.style.getSourceCaches():[];return s.bf(t,(r,c)=>r._preloadTiles(l,c),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(l){this._trackResize&&this.resize({originalEvent:l})._update()}_onVisibilityChange(){"hidden"===document.visibilityState&&this._visibilityHidden++}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(l){this._showTileBoundaries!==l&&(this._showTileBoundaries=l,this._tp.refreshUI(),this._update())}get showParseStatus(){return!!this._showParseStatus}set showParseStatus(l){this._showParseStatus!==l&&(this._showParseStatus=l,this._tp.refreshUI(),this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(l){this._showTerrainWireframe!==l&&(this._showTerrainWireframe=l,this._tp.refreshUI(),this._update())}get showLayers2DWireframe(){return!!this._showLayers2DWireframe}set showLayers2DWireframe(l){this._showLayers2DWireframe!==l&&(this._showLayers2DWireframe=l,this._tp.refreshUI(),this._update())}get showLayers3DWireframe(){return!!this._showLayers3DWireframe}set showLayers3DWireframe(l){this._showLayers3DWireframe!==l&&(this._showLayers3DWireframe=l,this._tp.refreshUI(),this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(l){this._speedIndexTiming!==l&&(this._speedIndexTiming=l,this._update())}get showPadding(){return!!this._showPadding}set showPadding(l){this._showPadding!==l&&(this._showPadding=l,this._tp.refreshUI(),this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(l){this._showCollisionBoxes!==l&&(this._showCollisionBoxes=l,this._tp.refreshUI(),l?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(l){this._showOverdrawInspector!==l&&(this._showOverdrawInspector=l,this._tp.refreshUI(),this._update())}get repaint(){return!!this._repaint}set repaint(l){this._repaint!==l&&(this._repaint=l,this._tp.refreshUI(),this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(l){this._vertices=l,this._update()}get showTileAABBs(){return!!this._showTileAABBs}set showTileAABBs(l){this._showTileAABBs!==l&&(this._showTileAABBs=l,this._tp.refreshUI(),l&&this._update())}_setCacheLimits(l,t){s.dy(l,t)}get version(){return Mi}},NavigationControl:class{constructor(l={}){this.options=s.l({},Ea,l),this._container=Nt("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",t=>t.preventDefault()),this.options.showZoom&&(s.aJ(["_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&&(s.aJ(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",t=>{const r=this._map;r&&(this.options.visualizePitch?r.resetNorthPitch({},{originalEvent:t}):r.resetNorth({},{originalEvent:t}))}),this._compassIcon=Nt("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const l=this._map;if(!l)return;const t=l.getZoom(),r=t===l.getMaxZoom(),c=t===l.getMinZoom();this._zoomInButton.disabled=r,this._zoomOutButton.disabled=c,this._zoomInButton.setAttribute("aria-disabled",r.toString()),this._zoomOutButton.setAttribute("aria-disabled",c.toString())}_rotateCompassArrow(){const l=this._map;if(!l)return;const t=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(l.transform.pitch*(Math.PI/180)),.5)}) rotateX(${l.transform.pitch}deg) rotateZ(${l.transform.angle*(180/Math.PI)}deg)`:`rotate(${l.transform.angle*(180/Math.PI)}deg)`;l._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=t)})}onAdd(l){return this._map=l,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),l.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&l.on("pitch",this._rotateCompassArrow),l.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new Ss(l,this._compass,this.options.visualizePitch)),this._container}onRemove(){const l=this._map;l&&(this._container.remove(),this.options.showZoom&&l.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&l.off("pitch",this._rotateCompassArrow),l.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(l,t){const r=Nt("button",l,this._container);return r.type="button",r.addEventListener("click",t),r}_setButtonTitle(l,t){if(!this._map)return;const r=this._map._getUIString(`NavigationControl.${t}`);l.setAttribute("aria-label",r),l.firstElementChild&&l.firstElementChild.setAttribute("title",r)}},GeolocateControl:class extends s.E{constructor(l={}){super();const t=navigator.geolocation;this.options=s.l({geolocation:t},Ro,l),s.aJ(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=kn(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(l){return this._map=l,this._container=Nt("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){void 0!==this._geolocationWatchID&&(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(l){const t=(r=!!this.options.geolocation)=>{this._supportsGeolocation=r,l(r)};void 0!==this._supportsGeolocation?l(this._supportsGeolocation):void 0!==navigator.permissions?navigator.permissions.query({name:"geolocation"}).then(r=>t("denied"!==r.state)).catch(()=>t()):t()}_isOutOfMapMaxBounds(l){const t=this._map.getMaxBounds(),r=l.coords;return!!t&&(r.longitudet.getEast()||r.latitudet.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting")}}_onSuccess(l){if(this._map){if(this._isOutOfMapMaxBounds(l))return this._setErrorState(),this.fire(new s.x("outofmaxbounds",l)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=l,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background")}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(l),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(l),this.options.showUserLocation&&this._userLocationDotMarker.removeClassName("mapboxgl-user-location-dot-stale"),this.fire(new s.x("geolocate",l)),this._finish()}}_updateCamera(l){const t=new s.bK(l.coords.longitude,l.coords.latitude),r=l.coords.accuracy,c=this._map.getBearing(),d=s.l({bearing:c},this.options.fitBoundsOptions);this._map.fitBounds(t.toBounds(r),d,{geolocateSource:!0})}_updateMarker(l){if(l){const t=new s.bK(l.coords.longitude,l.coords.latitude);this._accuracyCircleMarker.setLngLat(t).addTo(this._map),this._userLocationDotMarker.setLngLat(t).addTo(this._map),this._accuracy=l.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const l=this._map.transform,t=s.bD(1,l._center.lat)*l.worldSize,r=Math.ceil(2*this._accuracy*t);this._circleElement.style.width=`${r}px`,this._circleElement.style.height=`${r}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&"number"==typeof this._heading?(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(l){if(this._map){if(this.options.trackUserLocation)if(1===l.code){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===l.code&&this._noTimeout)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._userLocationDotMarker.addClassName("mapboxgl-user-location-dot-stale"),this.fire(new s.x("error",l)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(l){if(void 0!==this._map){if(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",!1===l){s.w("Geolocation support is not available so the GeolocateControl will be disabled.");const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t)}else{const t=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(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 vn({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=Nt("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new vn({element:this._circleElement,pitchAlignment:"map"}),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.trackUserLocation&&this._map.on("movestart",t=>{t.geolocateSource||"ACTIVE_LOCK"!==this._watchState||t.originalEvent&&"resize"===t.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new s.x("trackuserlocationend")))})}}_onDeviceOrientation(l){this._userLocationDotMarker&&(l.webkitCompassHeading?this._heading=l.webkitCompassHeading:!0===l.absolute&&(this._heading=-1*l.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return s.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new s.x("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":this._numberOfWatches--,this._noTimeout=!1,this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this.fire(new s.x("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new s.x("trackuserlocationstart"))}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"BACKGROUND":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");break;case"BACKGROUND_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error")}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let l;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(l={maximumAge:6e5,timeout:0},this._noTimeout=!0):(l=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,l),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=window.setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const l=()=>{"ondeviceorientationabsolute"in window?window.addEventListener("deviceorientationabsolute",this._onDeviceOrientation):window.addEventListener("deviceorientation",this._onDeviceOrientation)};typeof DeviceMotionEvent<"u"&&"function"==typeof DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then(t=>{"granted"===t&&l()}).catch(console.error):l()}_clearWatch(){this.options.geolocation.clearWatch(this._geolocationWatchID),window.removeEventListener("deviceorientation",this._onDeviceOrientation),window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientation),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},AttributionControl:Ol,ScaleControl:class{constructor(l={}){this.options=s.l({},so,l),this._isNumberFormatSupported=function(){try{return new Intl.NumberFormat("en",{style:"unit",unitDisplay:"short",unit:"meter"}),!0}catch{return!1}}(),s.aJ(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const l=this.options.maxWidth||100,t=this._map,r=t._containerHeight/2,c=t._containerWidth/2-l/2,d=t.unproject([c,r]),f=t.unproject([c+l,r]),_=d.distanceTo(f);if("imperial"===this.options.unit){const T=3.2808*_;T>5280?this._setScale(l,T/5280,"mile"):this._setScale(l,T,"foot")}else"nautical"===this.options.unit?this._setScale(l,_/1852,"nautical-mile"):_>=1e3?this._setScale(l,_/1e3,"kilometer"):this._setScale(l,_,"meter")}_setScale(l,t,r){this._map._requestDomTask(()=>{const c=function(f){const _=Math.pow(10,`${Math.floor(f)}`.length-1);let T=f/_;return T=T>=10?10:T>=5?5:T>=3?3:T>=2?2:T>=1?1:function(S){const A=Math.pow(10,Math.ceil(-Math.log(S)/Math.LN10));return Math.round(S*A)/A}(T),_*T}(t),d=c/t;this._container.innerHTML=this._isNumberFormatSupported&&"nautical-mile"!==r?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:r}).format(c):`${c} ${ep[r]}`,this._container.style.width=l*d+"px"})}onAdd(l){return this._map=l,this._language=l.getLanguage(),this._container=Nt("div","mapboxgl-ctrl mapboxgl-ctrl-scale",l.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(l){this._language=l,this._update()}setUnit(l){this.options.unit=l,this._update()}},FullscreenControl:class{constructor(l={}){this._fullscreen=!1,l&&l.container&&(l.container instanceof HTMLElement?this._container=l.container:s.w("Full screen control 'container' must be a DOM element.")),s.aJ(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(l){return this._map=l,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",s.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 l=this._fullscreenButton=Nt("button","mapboxgl-ctrl-fullscreen",this._controlContainer);Nt("span","mapboxgl-ctrl-icon",l).setAttribute("aria-hidden","true"),l.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const l=this._getTitle();this._fullscreenButton.setAttribute("aria-label",l),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",l)}_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()}},Popup:class extends s.E{constructor(l){super(),this.options=s.l(Object.create(tp),l),s.aJ(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(l&&l.className?l.className.trim().split(/\s+/):[])}addTo(l){return this._map&&this.remove(),this._map=l,this.options.closeOnClick&&l.on("preclick",this._onClose),this.options.closeOnMove&&l.on("move",this._onClose),l.on("remove",this.remove),this._update(),l._addPopup(this),this._focusFirstElement(),this._trackPointer?(l.on("mousemove",this._onMouseEvent),l.on("mouseup",this._onMouseEvent),l._canvasContainer.classList.add("mapboxgl-track-pointer")):l.on("move",this._update),this.fire(new s.x("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const l=this._map;return l&&(l.off("move",this._update),l.off("move",this._onClose),l.off("preclick",this._onClose),l.off("click",this._onClose),l.off("remove",this.remove),l.off("mousemove",this._onMouseEvent),l.off("mouseup",this._onMouseEvent),l.off("drag",this._onMouseEvent),l._canvasContainer&&l._canvasContainer.classList.remove("mapboxgl-track-pointer"),l._removePopup(this),this._map=void 0),this.fire(new s.x("close")),this}getLngLat(){return this._lngLat}setLngLat(l){this._lngLat=s.bK.convert(l),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}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const l=this._map;return l&&(l.off("move",this._update),l.on("mousemove",this._onMouseEvent),l.on("drag",this._onMouseEvent),l._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(l){return this.setDOMContent(document.createTextNode(l))}setHTML(l){const t=document.createDocumentFragment(),r=document.createElement("body");let c;for(r.innerHTML=l;c=r.firstChild,c;)t.appendChild(c);return this.setDOMContent(t)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(l){return this.options.maxWidth=l,this._update(),this}setDOMContent(l){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(l),this.options.closeButton){const r=this._closeButton=Nt("button","mapboxgl-popup-close-button",t);r.type="button",r.setAttribute("aria-label","Close popup"),r.setAttribute("aria-hidden","true"),r.innerHTML="×",r.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(l){return this._classList.add(l),this._updateClassList(),this}removeClassName(l){return this._classList.delete(l),this._updateClassList(),this}setOffset(l){return this.options.offset=l,this._update(),this}toggleClassName(l){let t;return this._classList.delete(l)?t=!1:(this._classList.add(l),t=!0),this._updateClassList(),t}_onMouseEvent(l){this._update(l.point)}_getAnchor(l){if(this.options.anchor)return this.options.anchor;const t=this._map,r=this._container,c=this._pos;if(!t||!r||!c)return"bottom";const d=r.offsetWidth,f=r.offsetHeight,_=c.xt.transform.width-d/2;if(c.y+lt.transform.height-f){if(_)return"bottom-left";if(T)return"bottom-right"}return _?"left":T?"right":"bottom"}_updateClassList(){const l=this._container;if(!l)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"),l.className=t.join(" ")}_update(l){const t=this._map,r=this._content;if(!t||!this._lngLat&&!this._trackPointer||!r)return;let c=this._container;if(c||(c=this._container=Nt("div","mapboxgl-popup",t.getContainer()),this._tip=Nt("div","mapboxgl-popup-tip",c),c.appendChild(r)),this.options.maxWidth&&c.style.maxWidth!==this.options.maxWidth&&(c.style.maxWidth=this.options.maxWidth),t.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=xn(this._lngLat,this._pos,t.transform)),!this._trackPointer||l){const d=this._pos=this._trackPointer&&l instanceof s.P?l:t.project(this._lngLat),f=Nu(this.options.offset),_=this._anchor=this._getAnchor(f.y),T=Nu(this.options.offset,_),S=d.add(T).round();t._requestDomTask(()=>{this._container&&_&&(this._container.style.transform=`${Vr[_]} translate(${S.x}px,${S.y}px)`)})}if(!this._marker&&t._showingGlobe()){const d=s.dz(t.transform,this._lngLat)?0:1;this._setOpacity(d)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const l=this._container.querySelector(ip);l&&l.focus()}_onClose(){this.remove()}_setOpacity(l){this._container&&(this._container.style.opacity=`${l}`),this._content&&(this._content.style.pointerEvents=l?"auto":"none")}},Marker:vn,Style:Fr,LngLat:s.bK,LngLatBounds:s.as,Point:s.P,MercatorCoordinate:s.a5,FreeCameraOptions:Kn,Evented:s.E,config:s.e,prewarm:s.dE,clearPrewarmedResources:s.dF,get accessToken(){return s.e.ACCESS_TOKEN},set accessToken(l){s.e.ACCESS_TOKEN=l},get baseApiUrl(){return s.e.API_URL},set baseApiUrl(l){s.e.API_URL=l},get workerCount(){return s.dG.workerCount},set workerCount(l){s.dG.workerCount=l},get maxParallelImageRequests(){return s.e.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(l){s.e.MAX_PARALLEL_IMAGE_REQUESTS=l},clearStorage(l){s.dH(l)},get workerUrl(){return s.dI.workerUrl},set workerUrl(l){s.dI.workerUrl=l},get workerClass(){return s.dI.workerClass},set workerClass(l){s.dI.workerClass=l},get workerParams(){return s.dI.workerParams},set workerParams(l){s.dI.workerParams=l},get dracoUrl(){return s.dJ()},set dracoUrl(l){s.dK(l)},get meshoptUrl(){return s.dL()},set meshoptUrl(l){s.dM(l)},setNow:s.q.setNow,restoreNow:s.q.restoreNow}}),Ai});