searchsmartly-ui 0.0.103 → 0.0.104

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -40,5 +40,5 @@ read:function(e,t,r,i,n){var o,s,a=8*n-i-1,l=(1<<a)-1,c=l>>1,u=-7,h=r?n-1:0,d=r?
40
40
  * @license BSD-3-Clause
41
41
  * @version 11.2.6
42
42
  */
43
- class Cy{constructor(e=0,t=0,r=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=e,this.resetTtl=r,this.size=0,this.ttl=t}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(e){if(this.has(e)){const t=this.items[e];delete this.items[e],this.size--,null!==t.prev&&(t.prev.next=t.next),null!==t.next&&(t.next.prev=t.prev),this.first===t&&(this.first=t.next),this.last===t&&(this.last=t.prev)}return this}entries(e=this.keys()){return e.map((e=>[e,this.get(e)]))}evict(e=!1){if(e||this.size>0){const e=this.first;delete this.items[e.key],0==--this.size?(this.first=null,this.last=null):(this.first=e.next,this.first.prev=null)}return this}expiresAt(e){let t;return this.has(e)&&(t=this.items[e].expiry),t}get(e){let t;if(this.has(e)){const r=this.items[e];this.ttl>0&&r.expiry<=Date.now()?this.delete(e):(t=r.value,this.set(e,t,!0))}return t}has(e){return e in this.items}keys(){const e=[];let t=this.first;for(;null!==t;)e.push(t.key),t=t.next;return e}set(e,t,r=!1,i=this.resetTtl){let n;if(r||this.has(e)){if(n=this.items[e],n.value=t,!1===r&&i&&(n.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.last!==n){const e=this.last,t=n.next,r=n.prev;this.first===n&&(this.first=n.next),n.next=null,n.prev=this.last,e.next=n,null!==r&&(r.next=t),null!==t&&(t.prev=r)}}else this.max>0&&this.size===this.max&&this.evict(!0),n=this.items[e]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:e,prev:this.last,next:null,value:t},1==++this.size?this.first=n:this.last.next=n;return this.last=n,this}values(e=this.keys()){return e.map((e=>this.get(e)))}}function Ty(e,t){if(4!==t.length)throw new Error(`Expected data of dimension 4 but got ${t.length}.`);let r=t[3];for(let i=2;i>=1;i--){const n=1===i?1:0,o=2===i?1:0;for(let i=0;i<t[0];i++){const s=t[1]*i;for(let i=n;i<t[1];i++){const n=t[2]*(i+s);for(let i=o;i<t[2];i++){const o=t[3]*(i+n);for(let i=0;i<t[3];i++){const t=o+i;e[t]+=e[t-r]}}}}r*=t[i]}return e}function Ey(e){for(let t=0,r=e.length;t<r;t++)e[t]=e[t]>>>1^-(1&e[t]);return e}function My(e,t){switch(t){case"uint32":return e;case"uint16":for(let t=0;t<e.length;t+=2){const r=e[t],i=e[t+1];e[t]=(240&r)>>4|(61440&r)>>8|(240&i)<<4|61440&i,e[t+1]=15&r|(3840&r)>>4|(15&i)<<8|(3840&i)<<4}return e;case"uint8":for(let t=0;t<e.length;t+=4){const r=e[t],i=e[t+1],n=e[t+2],o=e[t+3];e[t+0]=(192&r)>>6|(192&i)>>4|(192&n)>>2|192&o,e[t+1]=(48&r)>>4|(48&i)>>2|48&n|(48&o)<<2,e[t+2]=(12&r)>>2|12&i|(12&n)<<2|(12&o)<<4,e[t+3]=3&r|(3&i)<<2|(3&n)<<4|(3&o)<<6}return e;default:throw new Error(`Invalid pixel format, "${t}"`)}}class Sy extends Error{constructor(e){super(e),this.name="MRTError"}}var Iy=Uint8Array,Py=Uint16Array,Dy=Int32Array,ky=new Iy([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]),Ly=new Iy([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]),zy=new Iy([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Oy=function(e,t){for(var r=new Py(31),i=0;i<31;++i)r[i]=t+=1<<e[i-1];var n=new Dy(r[30]);for(i=1;i<30;++i)for(var o=r[i];o<r[i+1];++o)n[o]=o-r[i]<<5|i;return{b:r,r:n}},By=Oy(ky,2),Ry=By.b,Fy=By.r;Ry[28]=258,Fy[258]=28;for(var jy=Oy(Ly,0).b,Vy=new Py(32768),Ny=0;Ny<32768;++Ny){var Uy=(43690&Ny)>>1|(21845&Ny)<<1;Vy[Ny]=((65280&(Uy=(61680&(Uy=(52428&Uy)>>2|(13107&Uy)<<2))>>4|(3855&Uy)<<4))>>8|(255&Uy)<<8)>>1}var Hy=function(e,t,r){for(var i=e.length,n=0,o=new Py(t);n<i;++n)e[n]&&++o[e[n]-1];var s,a=new Py(t);for(n=1;n<t;++n)a[n]=a[n-1]+o[n-1]<<1;s=new Py(1<<t);var l=15-t;for(n=0;n<i;++n)if(e[n])for(var c=n<<4|e[n],u=t-e[n],h=a[e[n]-1]++<<u,d=h|(1<<u)-1;h<=d;++h)s[Vy[h]>>l]=c;return s},Gy=new Iy(288);for(Ny=0;Ny<144;++Ny)Gy[Ny]=8;for(Ny=144;Ny<256;++Ny)Gy[Ny]=9;for(Ny=256;Ny<280;++Ny)Gy[Ny]=7;for(Ny=280;Ny<288;++Ny)Gy[Ny]=8;var Zy=new Iy(32);for(Ny=0;Ny<32;++Ny)Zy[Ny]=5;var Wy=Hy(Gy,9),Qy=Hy(Zy,5),qy=function(e){for(var t=e[0],r=1;r<e.length;++r)e[r]>t&&(t=e[r]);return t},Xy=function(e,t,r){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(7&t)&r},Yy=function(e,t){var r=t/8|0;return(e[r]|e[r+1]<<8|e[r+2]<<16)>>(7&t)},$y=["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"],Ky=function(e,t,r){var i=new Error(t||$y[e]);if(i.code=e,Error.captureStackTrace&&Error.captureStackTrace(i,Ky),!r)throw i;return i},Jy=new Iy(0),ex="undefined"!=typeof TextDecoder&&new TextDecoder;try{ex.decode(Jy,{stream:!0})}catch(e){}const tx={gzip_data:"gzip"},rx={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},ix={uint32:1,uint16:2,uint8:4},nx={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};class ox{constructor(e=1){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=e}getLayer(e){return this.layers[e]}getHeaderLength(e){const t=new Uint8Array(e),r=new DataView(e);if(13!==t[0])throw new Sy("File is not a valid MRT.");return r.getUint32(1,!0)}parseHeader(e){const t=new Uint8Array(e),r=this.getHeaderLength(e);if(t.length<r)throw new Sy(`Expected header with length >= ${r} but got buffer of length ${t.length}`);const i=new bm(t.subarray(0,r)),n=by.read(i);if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new Sy(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const e of n.layers)this.layers[e.name]=new sx(e,{cacheSize:this._cacheSize});return this}createDecodingTask(e){const t=[],r=this.getLayer(e.layerName);for(let i=0;i<r.dataIndex.length;i++){const n=r.dataIndex[i],o=n.first_byte-e.firstByte,s=n.last_byte+1-e.firstByte;if(i<e.firstBlock||i>e.lastBlock)continue;if(r._blocksInProgress.has(i))continue;const a={layerName:r.name,firstByte:o,lastByte:s,pixelFormat:r.pixelFormat,blockIndex:i,blockShape:[n.bands.length].concat(r.bandShape),buffer:r.buffer,codec:n.codec.codec,filters:n.filters.map((e=>e.filter))};r._blocksInProgress.add(i),t.push(a)}return new ax(t,(()=>{t.forEach((e=>r._blocksInProgress.delete(e.blockIndex)))}),((e,i)=>{if(t.forEach((e=>r._blocksInProgress.delete(e.blockIndex))),e)throw e;i.forEach((e=>{this.getLayer(e.layerName).processDecodedData(e)}))}))}}class sx{constructor({version:e,name:t,units:r,tilesize:i,pixel_format:n,buffer:o,data_index:s},a){if(this.version=e,1!==this.version)throw new Sy(`Cannot parse raster layer encoded with MRT version ${e}`);this.name=t,this.units=r,this.tileSize=i,this.buffer=o,this.pixelFormat=rx[n],this.dataIndex=s,this.bandShape=[i+2*o,i+2*o,ix[this.pixelFormat]],this._decodedBlocks=function(e=1e3,t=0,r=!1){if(isNaN(e)||e<0)throw new TypeError("Invalid max value");if(isNaN(t)||t<0)throw new TypeError("Invalid ttl value");if("boolean"!=typeof r)throw new TypeError("Invalid resetTtl value");return new Cy(e,t,r)}(a?a.cacheSize:5),this._blocksInProgress=new Set}processDecodedData(e){const t=e.blockIndex.toString();this._decodedBlocks.get(t)||this._decodedBlocks.set(t,e.data)}getBlockForBand(e){let t=0;switch(typeof e){case"string":for(const[r,i]of this.dataIndex.entries()){for(const[n,o]of i.bands.entries())if(o===e)return{bandIndex:t+n,blockIndex:r,blockBandIndex:n};t+=i.bands.length}break;case"number":for(const[r,i]of this.dataIndex.entries()){if(e>=t&&e<t+i.bands.length)return{bandIndex:e,blockIndex:r,blockBandIndex:e-t};t+=i.bands.length}break;default:throw new Sy(`Invalid band \`${JSON.stringify(e)}\`. Expected string or integer.`)}throw new Sy(`Band not found: ${JSON.stringify(e)}`)}getDataRange(e){let t=1/0,r=-1/0,i=1/0,n=-1/0;for(const o of e){const{blockIndex:e}=this.getBlockForBand(o);if(e<0)throw new Sy(`Invalid band: ${JSON.stringify(o)}`);const s=this.dataIndex[e];i=Math.min(i,e),n=Math.max(n,e),t=Math.min(t,s.first_byte),r=Math.max(r,s.last_byte)}return{layerName:this.name,firstByte:t,lastByte:r,firstBlock:i,lastBlock:n}}hasBand(e){const{blockIndex:t}=this.getBlockForBand(e);return t>=0}hasDataForBand(e){const{blockIndex:t}=this.getBlockForBand(e);return t>=0&&!!this._decodedBlocks.get(t.toString())}getBandView(e){const{blockIndex:t,blockBandIndex:r}=this.getBlockForBand(e),i=this._decodedBlocks.get(t.toString());if(!i)throw new Sy(`Data for band ${JSON.stringify(e)} of layer "${this.name}" not decoded.`);const n=this.dataIndex[t],o=this.bandShape.reduce(((e,t)=>e*t),1),s=r*o,a=i.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,offset:n.offset,scale:n.scale}}}class ax{constructor(e,t,r){this.tasks=e,this._onCancel=t,this._onComplete=r,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(e,t){this._finalized||(this._onComplete(e,t),this._finalized=!0)}}ox.performDecoding=function(e,t){return Promise.all(t.tasks.map((t=>{const{layerName:r,firstByte:i,lastByte:n,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:c}=t,u=new Uint8Array(e).subarray(i,n+1),h=new Uint32Array(s[0]*s[1]*s[2]);let d;if("gzip_data"!==c)throw new Error(`Unhandled codec: ${c}`);return d=function(e,t){if(!globalThis.DecompressionStream&&"gzip_data"===t)return Promise.resolve(((o=function(e){31==e[0]&&139==e[1]&&8==e[2]||Ky(6,"invalid gzip data");var t=e[3],r=10;4&t&&(r+=2+(e[10]|e[11]<<8));for(var i=(t>>3&1)+(t>>4&1);i>0;i-=!e[r++]);return r+(2&t)}(n=e))+8>n.length&&Ky(6,"invalid gzip data"),function(e,t,r,i){var n=e.length;if(!n||t.f&&!t.l)return r||new Iy(0);var o=!r,s=o||2!=t.i,a=t.i;o&&(r=new Iy(3*n));var l,c,u=function(e){var t=r.length;if(e>t){var i=new Iy(Math.max(2*t,e));i.set(r),r=i}},h=t.f||0,d=t.p||0,p=t.b||0,f=t.l,m=t.d,A=t.m,g=t.n,_=8*n;do{if(!f){h=Xy(e,d,1);var y=Xy(e,d+1,3);if(d+=3,!y){var x=e[(D=4+((d+7)/8|0))-4]|e[D-3]<<8,v=D+x;if(v>n){a&&Ky(0);break}s&&u(p+x),r.set(e.subarray(D,v),p),t.b=p+=x,t.p=d=8*v,t.f=h;continue}if(1==y)f=Wy,m=Qy,A=9,g=5;else if(2==y){var b=Xy(e,d,31)+257,w=Xy(e,d+10,15)+4,C=b+Xy(e,d+5,31)+1;d+=14;for(var T=new Iy(C),E=new Iy(19),M=0;M<w;++M)E[zy[M]]=Xy(e,d+3*M,7);d+=3*w;var S=qy(E),I=(1<<S)-1,P=Hy(E,S);for(M=0;M<C;){var D,k=P[Xy(e,d,I)];if(d+=15&k,(D=k>>4)<16)T[M++]=D;else{var L=0,z=0;for(16==D?(z=3+Xy(e,d,3),d+=2,L=T[M-1]):17==D?(z=3+Xy(e,d,7),d+=3):18==D&&(z=11+Xy(e,d,127),d+=7);z--;)T[M++]=L}}var O=T.subarray(0,b),B=T.subarray(b);A=qy(O),g=qy(B),f=Hy(O,A),m=Hy(B,g)}else Ky(1);if(d>_){a&&Ky(0);break}}s&&u(p+131072);for(var R=(1<<A)-1,F=(1<<g)-1,j=d;;j=d){var V=(L=f[Yy(e,d)&R])>>4;if((d+=15&L)>_){a&&Ky(0);break}if(L||Ky(2),V<256)r[p++]=V;else{if(256==V){j=d,f=null;break}var N=V-254;V>264&&(N=Xy(e,d,(1<<(G=ky[M=V-257]))-1)+Ry[M],d+=G);var U=m[Yy(e,d)&F],H=U>>4;if(U||Ky(3),d+=15&U,B=jy[H],H>3){var G=Ly[H];B+=Yy(e,d)&(1<<G)-1,d+=G}if(d>_){a&&Ky(0);break}s&&u(p+131072);var Z=p+N;if(p<B){var W=0-B,Q=Math.min(B,Z);for(W+p<0&&Ky(3);p<Q;++p)r[p]=(void 0)[W+p]}for(;p<Z;++p)r[p]=r[p-B]}}t.l=f,t.p=j,t.b=p,t.f=h,f&&(h=1,t.m=A,t.d=m,t.n=g)}while(!h);return p!=r.length&&o?(l=r,(null==(c=p)||c>l.length)&&(c=l.length),new Iy(l.subarray(0,c))):r.subarray(0,p)}(n.subarray(o,-8),{i:2},new Iy(((r=n)[(i=r.length)-4]|r[i-3]<<8|r[i-2]<<16|r[i-1]<<24)>>>0))));var r,i,n,o;const s=tx[t];if(!s)throw new Error(`Unhandled codec: ${t}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([e]).stream().pipeThrough(a)).arrayBuffer().then((e=>new Uint8Array(e)))}(u,c).then((e=>{const t=wy.read(new bm(e));if("uint32_values"===t.values)return t.uint32_values.readValuesInto(h),new nx[o](h.buffer);throw new Error(`Unhandled numeric data "${t.values}"`)})),d.then((e=>{for(let t=l.length-1;t>=0;t--)switch(l[t]){case"delta_filter":Ty(e,s);break;case"zigzag_filter":Ey(e);break;case"bitshuffle_filter":My(e,o);break;default:throw new Error(`Unhandled filter "${l[t]}"`)}return{layerName:r,blockIndex:a,data:e}})).catch((e=>{throw e}))})))},fa(ax,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]});const lx=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class cx{static from(e){if(!(e instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[t,r]=new Uint8Array(e,0,2);if(219!==t)throw new Error("Data does not appear to be in a KDBush format.");const i=r>>4;if(1!==i)throw new Error(`Got v${i} data when expected v1.`);const n=lx[15&r];if(!n)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(e,2,1),[s]=new Uint32Array(e,4,1);return new cx(s,o,n,e)}constructor(e,t=64,r=Float64Array,i){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=r,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const n=lx.indexOf(this.ArrayType),o=2*e*this.ArrayType.BYTES_PER_ELEMENT,s=e*this.IndexArrayType.BYTES_PER_ELEMENT,a=(8-s%8)%8;if(n<0)throw new Error(`Unexpected typed array class: ${r}.`);i&&i instanceof ArrayBuffer?(this.data=i,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+s+a,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+o+s+a),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+s+a,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+n]),new Uint16Array(this.data,2,1)[0]=t,new Uint32Array(this.data,4,1)[0]=e)}add(e,t){const r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=e,this.coords[this._pos++]=t,r}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return ux(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,r,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:o,nodeSize:s}=this,a=[0,n.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,u=a.pop()||0,h=a.pop()||0;if(u-h<=s){for(let s=h;s<=u;s++){const a=o[2*s],c=o[2*s+1];a>=e&&a<=r&&c>=t&&c<=i&&l.push(n[s])}continue}const d=h+u>>1,p=o[2*d],f=o[2*d+1];p>=e&&p<=r&&f>=t&&f<=i&&l.push(n[d]),(0===c?e<=p:t<=f)&&(a.push(h),a.push(d-1),a.push(1-c)),(0===c?r>=p:i>=f)&&(a.push(d+1),a.push(u),a.push(1-c))}return l}within(e,t,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:i,coords:n,nodeSize:o}=this,s=[0,i.length-1,0],a=[],l=r*r;for(;s.length;){const c=s.pop()||0,u=s.pop()||0,h=s.pop()||0;if(u-h<=o){for(let r=h;r<=u;r++)fx(n[2*r],n[2*r+1],e,t)<=l&&a.push(i[r]);continue}const d=h+u>>1,p=n[2*d],f=n[2*d+1];fx(p,f,e,t)<=l&&a.push(i[d]),(0===c?e-r<=p:t-r<=f)&&(s.push(h),s.push(d-1),s.push(1-c)),(0===c?e+r>=p:t+r>=f)&&(s.push(d+1),s.push(u),s.push(1-c))}return a}}function ux(e,t,r,i,n,o){if(n-i<=r)return;const s=i+n>>1;hx(e,t,s,i,n,o),ux(e,t,r,i,s-1,1-o),ux(e,t,r,s+1,n,1-o)}function hx(e,t,r,i,n,o){for(;n>i;){if(n-i>600){const s=n-i+1,a=r-i+1,l=Math.log(s),c=.5*Math.exp(2*l/3),u=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2<0?-1:1);hx(e,t,r,Math.max(i,Math.floor(r-a*c/s+u)),Math.min(n,Math.floor(r+(s-a)*c/s+u)),o)}const s=t[2*r+o];let a=i,l=n;for(dx(e,t,i,r),t[2*n+o]>s&&dx(e,t,i,n);a<l;){for(dx(e,t,a,l),a++,l--;t[2*a+o]<s;)a++;for(;t[2*l+o]>s;)l--}t[2*i+o]===s?dx(e,t,i,l):(l++,dx(e,t,l,n)),l<=r&&(i=l+1),r<=l&&(n=l-1)}}function dx(e,t,r,i){px(e,r,i),px(t,2*r,2*i),px(t,2*r+1,2*i+1)}function px(e,t,r){const i=e[t];e[t]=e[r],e[r]=i}function fx(e,t,r,i){const n=e-r,o=t-i;return n*n+o*o}e.$=class{constructor(e){this.specification=e}possiblyEvaluate(e,t){return function([e,t]){const r=fr([1,e,t]);return{x:r.x,y:r.y,z:r.z}}(e.expression.evaluate(t))}interpolate(e,t,r){return{x:Ui(e.x,t.x,r),y:Ui(e.y,t.y,r),z:Ui(e.z,t.z,r)}}},e.A=rl,e.B=Qs,e.C=Pn,e.D=Gs,e.E=Oi,e.F=function(e){const t=e.value;let r=[];if(!t)return r;const i=Tn(t);return"string"!==i?(r=r.concat([new Kg(e.key,t,`string expected, "${i}" found`)]),r):(Jg(t,!0)||(r=r.concat([new Kg(e.key,t,`invalid url "${t}"`)])),r)},e.G=tl,e.H=Ka,e.I=eA,e.J=Xa,e.K=class{constructor(e){this.specification=e}possiblyEvaluate(e,t){return fr(e.expression.evaluate(t))}interpolate(e,t,r){return{x:Ui(e.x,t.x,r),y:Ui(e.y,t.y,r),z:Ui(e.z,t.z,r),azimuthal:Ui(e.azimuthal,t.azimuthal,r),polar:Ui(e.polar,t.polar,r)}}},e.L=Ha,e.M=class{constructor(e,t,r,i){this.id=e,this.position=null!=t?new su(t[0],t[1]):new su(0,0),this.orientation=null!=r?r:[0,0,0],this.nodes=i,this.uploaded=!1,this.aabb=new mh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[]}_applyTransformations(t,r){if(e.a9.multiply(t.matrix,r,t.matrix),t.meshes)for(const e of t.meshes){const r=mh.applyTransform(e.aabb,t.matrix);this.aabb.encapsulate(r)}if(t.children)for(const e of t.children)this._applyTransformations(e,t.matrix)}computeBoundsAndApplyParent(){const t=e.a9.identity([]);for(const e of this.nodes)this._applyTransformations(e,t)}computeModelMatrix(e,t,r,i,n,o,s=!1){a_(this.matrix,this,e.transform,this.position,t,r,i,n,o,s)}upload(e){if(!this.uploaded){for(const t of this.nodes)u_(t,e);for(const e of this.nodes)h_(e);this.uploaded=!0}}destroy(){for(const e of this.nodes)d_(e)}},e.N=Va,e.O=Iu,e.P=Vt,e.R=Xr,e.S=Yt,e.T=yg,e.U=qa,e.V=Kg,e.W=jh,e.X=Ui,e.Y=no,e.Z=oa,e._=Hi,e.a=zi,e.a$=or,e.a0=function(e,t,r=0,i=!0){const n=new Vt(r,r),o=e.sub(n),s=t.add(n),a=[o,new Vt(s.x,o.y),s,new Vt(o.x,s.y)];return i&&a.push(o.clone()),a},e.a1=function(e,t){const r=[];for(let i=0;i<e.length;i++){const n=$t(i-1,-1,e.length-1),o=$t(i+1,-1,e.length-1),s=e[i],a=e[o],l=e[n].sub(s).unit(),c=a.sub(s).unit(),u=c.angleWithSep(l.x,l.y),h=l.add(c).unit().mult(-1*t/Math.sin(u/2));r.push(s.add(h))}return r},e.a2=kA,e.a3=Ku,e.a4=function(t,r,i=0){return e.Q.fromValues(((r.x-i)*t.scale-t.x)*no,(r.y*t.scale-t.y)*no,wu(r.z,r.y))},e.a5=lh,e.a6=Sf,e.a7=function(e){let t=1/0,r=1/0,i=-1/0,n=-1/0;for(const o of e)t=Math.min(t,o.x),r=Math.min(r,o.y),i=Math.max(i,o.x),n=Math.max(n,o.y);return{min:new Vt(t,r),max:new Vt(i,n)}},e.a8=_u,e.aA=Ni,e.aB=wl,e.aC=Ls,e.aD=ec,e.aE=mc,e.aF=tr,e.aG=ic,e.aH=cg,e.aI=function(){ja.isLoading()||ja.isLoaded()||"deferred"!==Ra()||Fa()},e.aJ=il,e.aK=Fu,e.aL=sy,e.aM=Ar,e.aN=Tf,e.aO=Gd,e.aP=Ru,e.aQ=Tl,e.aR=Yl,e.aS=yh,e.aT=jd,e.aU=_g,e.aV=function(t,r){const i=jh(r.zoom);if(0===i)return Th(t);const n=Ih(t),o=Ph(n),s=_u(n.getWest())*r.worldSize,a=_u(n.getEast())*r.worldSize,l=yu(n.getNorth())*r.worldSize,c=yu(n.getSouth())*r.worldSize,u=[s,l,0],h=[a,l,0],d=[s,c,0],p=[a,c,0],f=e.a9.invert([],r.globeMatrix);return e.Q.transformMat4(u,u,f),e.Q.transformMat4(h,h,f),e.Q.transformMat4(d,d,f),e.Q.transformMat4(p,p,f),o[0]=Eh(o[0],d,i),o[1]=Eh(o[1],p,i),o[2]=Eh(o[2],h,i),o[3]=Eh(o[3],u,i),mh.fromPoints(o)},e.aW=zh,e.aX=Dh,e.aY=Eh,e.aZ=El,e.a_=_h,e.ab=$u,e.ac=Du,e.ad=Xt,e.ae=qc,e.af=function(e,t){const r={};for(let i=0;i<t.length;i++){const n=t[i];n in e&&(r[n]=e[n])}return r},e.ag=au,e.ah=yu,e.ai=class{constructor(e){this.entries={},this.scheduler=e}request(e,t,r,i){const n=this.entries[e]=this.entries[e]||{callbacks:[]};if(n.result){const[e,r]=n.result;return this.scheduler?this.scheduler.add((()=>{i(e,r)}),t):i(e,r),()=>{}}return n.callbacks.push(i),n.cancel||(n.cancel=r(((r,i)=>{n.result=[r,i];for(const e of n.callbacks)this.scheduler?this.scheduler.add((()=>{e(r,i)}),t):e(r,i);setTimeout((()=>delete this.entries[e]),3e3)}))),()=>{n.result||(n.callbacks=n.callbacks.filter((e=>e!==i)),n.callbacks.length||(n.cancel(),delete this.entries[e]))}}},e.aj=Al,e.ak=function(e,t,r){const i=JSON.stringify(e.request);return e.data&&(this.deduped.entries[i]={result:[null,e.data]}),this.deduped.request(i,{type:"parseTile",isSymbolTile:e.isSymbolTile,zoom:e.tileZoom},(t=>{const i=Jr(e.request,((e,i,n,o)=>{e?t(e):i&&t(null,{vectorTile:r?void 0:new hp(new bm(i)),rawData:i,cacheControl:n,expires:o})}));return()=>{i.cancel(),t()}}),t)},e.al=function(e){Nr++,Nr>Fr&&(e.getActor().send("enforceCacheSizeLimit",Rr),Nr=0)},e.am=fi,e.an=Pr,e.ao=function(e){return e<=1?1:Math.pow(2,Math.floor(Math.log(e)/Math.LN2))},e.ap=du,e.aq=Eg,e.ar=Ig,e.as=Cg,e.at=function(e,t){const r=document.createElement("video");r.muted=!0,r.onloadstart=function(){t(null,r)};for(let t=0;t<e.length;t++){const i=document.createElement("source");ei(e[t])||(r.crossOrigin="Anonymous"),i.src=e[t],r.appendChild(i)}return{cancel:()=>{}}},e.au=xg,e.av=DA,e.aw=vu,e.ax=bu,e.ay=Ml,e.az=Hl,e.b=Li,e.b$=aA,e.b0=ox,e.b1=Jr,e.b2=function(e){const t=[];for(const r in e)t.push(e[r]);return t},e.b3=function(e,t){const r=[];for(const i in e)i in t||r.push(i);return r},e.b4=Kt,e.b5=["type","source","source-layer","minzoom","maxzoom","filter","layout"],e.b6=function(t,r){const{x:i,y:n}=t.point,o=Fh(i,n,t.worldSize/t._pixelsPerMercatorPixel,0,0);return e.a9.multiply(o,o,Oh(Th(r)))},e.b8=qf,e.b9=Sm,e.bA=Yc,e.bB=function(t){const r=e.a9.identity(new Float64Array(16));e.a9.multiply(r,t.pixelMatrix,t.globeMatrix);const i=[0,eu,0],n=[0,tu,0];return e.Q.transformMat4(i,i,r),e.Q.transformMat4(n,n,r),[i[0]>0&&i[0]<=t.width&&i[1]>0&&i[1]<=t.height&&!Nh(t,new su(t.center.lat,90)),n[0]>0&&n[0]<=t.width&&n[1]>0&&n[1]<=t.height&&!Nh(t,new su(t.center.lat,-90))]},e.bC=function(t,r){const{scale:i}=t.tileTransform,n=i*no/(t.tileSize*Math.pow(2,r.zoom-t.tileID.overscaledZ+t.tileID.canonical.z));return e.b7.scale(new Float32Array(4),r.inverseAdjustmentMatrix,[n,n])},e.bD=Rg,e.bE=Og,e.bF=function(t){const r=Og(t,!0);return e.b7.invert([],[r[0],r[1],r[4],r[5]])},e.bG=ch,e.bH=function(e){const{x:t,y:r}=e.point,{lng:i,lat:n}=e._center;return Fh(t,r,e.worldSize,i,n)},e.bI=Gt,e.bJ=Xc,e.bK=function(e){const t=Math.round((e+45+360)%360/90)%4;return Zt[t]},e.bL=45,e.bM=gu,e.bN=Dc,e.bO=Ec,e.bP=Mc,e.bQ=Tc,e.bR=Cc,e.bS=Sc,e.bT=function(e,t,r){const i=Math.sqrt(e*e+t*t+r*r),n=i>0?Math.acos(r/i)*Ut:0;let o=0!==e||0!==t?Math.atan2(-t,-e)*Ut+90:0;return o<0&&(o+=360),[i,o,n]},e.bU=Su,e.bV=mh,e.bW=fr,e.bX=function(e){return[Math.pow(e[0],1/2.2),Math.pow(e[1],1/2.2),Math.pow(e[2],1/2.2)]},e.bY=function(e){return e({pluginStatus:ka,pluginURL:La}),Ba.on("pluginStateChange",e),e},e.bZ=A_,e.b_=b_,e.ba=Qf,e.bb=function(e,t,r,i,n){const o=5*t+2;e.float32[o+0]=r,e.float32[o+1]=i,e.float32[o+2]=n},e.bc=og,e.bd=$m,e.be=Uu,e.bf=Gf,e.bg=vA,e.bh=xA,e.bi=jm,e.bj=cx,e.bk=$t,e.bm=Ht,e.bn=Tr,e.bo=xu,e.bp=function(e,t,r){e[4*t+0]=r[0],e[4*t+1]=r[1],e[4*t+2]=r[2],e[4*t+3]=r[3]},e.bq=su,e.br=JA,e.bs=hu,e.bt=fh,e.bu=Bg,e.bv=uu,e.bw=Sh,e.bx=function(e,t,r,i,n,o,s,a,l){if("globe"===l.name)return Sh(e,t,new uu(r,i,n),!1);const c=DA({z:r,x:i,y:n},l);return new mh([(o+c.x/c.scale)*t,t*(c.y/c.scale),s],[(o+c.x2/c.scale)*t,t*(c.y2/c.scale),a])},e.by=function(e,t,r){let i=0;for(let r=0;r<2;++r){const n=0;e[r]>n&&(i+=(e[r]-n)*(e[r]-n)),t[r]<n&&(i+=(n-t[r])*(n-t[r]))}return i},e.bz=Cu,e.c=ty,e.c$=[1,1,1],e.c0=sA,e.c1=$r,e.c2=za,e.c3=o,e.c4=Lr,e.c5=Pi,e.c6=cr,e.c7=function(e,t,r){return"custom"===e.type?new Pg(e,t):new vy[e.type](e,t,r)},e.c8=function(e){const t=e.indexOf(ml);return t>=0?e.slice(0,t):e},e.c9=function(e){return e.indexOf(ml)>=0},e.cA=e=>({u_matrix:new Dc(e),u_pixels_to_tile_units:new zc(e),u_device_pixel_ratio:new Tc(e),u_units_to_pixels:new Ec(e),u_dash_image:new Cc(e),u_gradient_image:new Cc(e),u_image_height:new Tc(e),u_texsize:new Ec(e),u_tile_units_to_pixels:new Tc(e),u_alpha_discard_threshold:new Tc(e),u_trim_offset:new Ec(e),u_emissive_strength:new Tc(e)}),e.cB=e=>({u_matrix:new Dc(e),u_texsize:new Ec(e),u_pixels_to_tile_units:new zc(e),u_device_pixel_ratio:new Tc(e),u_image:new Cc(e),u_units_to_pixels:new Ec(e),u_tile_units_to_pixels:new Tc(e),u_alpha_discard_threshold:new Tc(e),u_trim_offset:new Ec(e)}),e.cC=Nl,e.cD=Hf,e.cE=Xf,e.cF=Wh,e.cG=(e,t,r,i,n,o)=>{const s=e.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const e=Rh(s.zoom,t.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([e,0,0,e])}else l=s.calculatePixelsToTileUnitsMatrix(r);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:e.transform.getCameraToCenterDistance(s.projection),u_matrix:e.translatePosMatrix(t.projMatrix,r,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:Dr.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Zh,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=i,c.u_merc_center=n,c.u_tile_id=[t.canonical.x,t.canonical.y,1<<t.canonical.z],c.u_zoom_transition=jh(s.zoom);const e=n[0]*no,r=n[1]*no;c.u_up_dir=s.projection.upVector(new uu(0,0,0),e,r)}return c},e.cH=Df,e.cI=(e,t,r,i,n,o)=>{const s=e.transform;return{u_matrix:Pf(e,t,r,i),u_texsize:t.imageAtlasTexture?t.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(t),u_device_pixel_ratio:n,u_image:0,u_tile_units_to_pixels:If(t,s),u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:o}},e.cJ=(e,t,r,i,n,o,s)=>{const a=e.transform,l=a.calculatePixelsToTileUnitsMatrix(t);return{u_matrix:Pf(e,t,r,i),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:n,u_texsize:kf(r)&&t.lineAtlasTexture?t.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:If(t,e.transform),u_alpha_discard_threshold:0,u_trim_offset:s,u_emissive_strength:r.paint.get("line-emissive-strength")}},e.cK=ir,e.cL=ad,e.cM=sf,e.cN=fu,e.cO=$p,e.cP=Vp,e.cQ=450,e.cR=7,e.cS=Tg,e.cT=256,e.cU=Oh,e.cV=$l,e.cW=Ql,e.cX=ql,e.cY=function(e,t,r,i,n){return Xt((e-t)/(r-t)*(n-i)+i,i,n)},e.cZ=Eu,e.c_=Hg,e.ca=function(e){const t=e.indexOf(ml);return t>=0?e.slice(t+1):""},e.cb=function(e){const t=[],r=e.id;return void 0===r&&t.push({message:`layers.${r}: missing required property "id"`}),void 0===e.render&&t.push({message:`layers.${r}: missing required method "render"`}),e.renderingMode&&"2d"!==e.renderingMode&&"3d"!==e.renderingMode&&t.push({message:`layers.${r}: property "renderingMode" must be either "2d" or "3d"`}),t},e.cc=lr,e.cd=Ba,e.ce=Kr,e.cf=Ic,e.cg=class extends wc{constructor(e){super(e),this.current=kc}set(e,t,r){if(this.fetchUniformLocation(e,t))for(let e=0;e<9;e++)if(r[e]!==this.current[e]){this.current=r,this.gl.uniformMatrix3fv(this.location,!1,r);break}}},e.ch=Wt,e.ci=function(e,t,r){const i=jh(r.zoom),n=e.style.map._antialias,o=t.options.extStandardDerivativesForceOff||e.terrain&&e.terrain.exaggeration()>0;return 0===i&&!n&&!o},e.cj=function(t){const r=t.pixelsPerMeter,i=r/xu(1,t.center.lat),n=e.a9.identity(new Float64Array(16));return e.a9.translate(n,n,[t.point.x,t.point.y,0]),e.a9.scale(n,n,[i,i,r]),Float32Array.from(n)},e.ck=Ih,e.cl=function(e){const t=Cu-5;e=Xt(e,-t,t)/t*90;const r=Math.pow(Math.abs(Math.sin(Ht(e))),3);return Math.round(r*(Jc.length-1))},e.cm=function(t,r,i,n){const o=r.getNorth(),s=r.getSouth(),a=r.getWest(),l=r.getEast(),c=1<<t.z,u=l-a,h=o-s,d=u/Kc,p=-h/Jc[i],f=[0,d,0,p,0,0,o,a,0];if(t.z>0){const t=180/n;e.ct.multiply(f,f,[t/u+1,0,0,0,t/h+1,0,-.5*t/d,.5*t/p,1])}return f[2]=c,f[5]=t.x,f[8]=t.y,f},e.cn=Th,e.co=function(t,r,i){const n=e.a9.identity(new Float64Array(16)),o=(r/(1<<t)-.5)*Math.PI*2;return e.a9.rotateY(n,i.globeMatrix,o),Float32Array.from(n)},e.cp=class{isDataAvailableAtPoint(e){const t=this._source();if(this.isUsingMockSource()||!t||e.y<0||e.y>1)return!1;const r=t.getSource().maxzoom,i=1<<r,n=Math.floor(e.x),o=Math.floor((e.x-n)*i),s=Math.floor(e.y*i),a=this.findDEMTileFor(new du(r,n,r,o,s));return!(!a||!a.dem)}getAtPointOrZero(e,t=0){return this.getAtPoint(e,t)||0}getAtPoint(e,t,r=!0){if(this.isUsingMockSource())return null;null==t&&(t=null);const i=this._source();if(!i)return t;if(e.y<0||e.y>1)return t;const n=i.getSource().maxzoom,o=1<<n,s=Math.floor(e.x),a=e.x-s,l=new du(n,s,n,Math.floor(a*o),Math.floor(e.y*o)),c=this.findDEMTileFor(l);if(!c||!c.dem)return t;const u=c.dem,h=1<<c.tileID.canonical.z,d=(a*h-c.tileID.canonical.x)*u.dim,p=(e.y*h-c.tileID.canonical.y)*u.dim,f=Math.floor(d),m=Math.floor(p);return(r?this.exaggeration():1)*Ui(Ui(u.get(f,m),u.get(f,m+1),p-m),Ui(u.get(f+1,m),u.get(f+1,m+1),p-m),d-f)}getAtTileOffset(e,t,r){const i=1<<e.canonical.z;return this.getAtPointOrZero(new Iu(e.wrap+(e.canonical.x+t/no)/i,(e.canonical.y+r/no)/i))}getAtTileOffsetFunc(t,r,i,n){return o=>{const s=this.getAtTileOffset(t,o.x,o.y),a=n.upVector(t.canonical,o.x,o.y),l=n.upVectorScale(t.canonical,r,i).metersToTile;return e.Q.scale(a,a,s*l),a}}getForTilePoints(e,t,r,i){if(this.isUsingMockSource())return!1;const n=Lp.create(this,e,i);return!!n&&(t.forEach((e=>{e[2]=this.exaggeration()*n.getElevationAt(e[0],e[1],r)})),!0)}getMinMaxForTile(e){if(this.isUsingMockSource())return null;const t=this.findDEMTileFor(e);if(!t||!t.dem)return null;const r=t.dem.tree,i=t.tileID,n=1<<e.canonical.z-i.canonical.z;let o=e.canonical.x/n-i.canonical.x,s=e.canonical.y/n-i.canonical.y,a=0;for(let t=0;t<e.canonical.z-i.canonical.z&&!r.leaves[a];t++){o*=2,s*=2;const e=2*Math.floor(s)+Math.floor(o);a=r.childOffsets[a]+e,o%=1,s%=1}return{min:this.exaggeration()*r.minimums[a],max:this.exaggeration()*r.maximums[a]}}getMinElevationBelowMSL(){throw new Error("Pure virtual method called.")}raycast(e,t,r){throw new Error("Pure virtual method called.")}pointCoordinate(e){throw new Error("Pure virtual method called.")}_source(){throw new Error("Pure virtual method called.")}isUsingMockSource(){throw new Error("Pure virtual method called.")}exaggeration(){throw new Error("Pure virtual method called.")}findDEMTileFor(e){throw new Error("Pure virtual method called.")}get visibleDemTiles(){throw new Error("Getter must be implemented in subclass.")}getMinMaxForVisibleTiles(){const e=this.visibleDemTiles;if(0===e.length)return null;let t=!1,r=Number.MAX_VALUE,i=Number.MIN_VALUE;for(const n of e){const e=this.getMinMaxForTile(n.tileID);e&&(r=Math.min(r,e.min),i=Math.max(i,e.max),t=!0)}return t?{min:r,max:i}:null}},e.cq=xh,e.cr=nd,e.cs=function(e,t){return[Math.pow(e[0],2.2)*t,Math.pow(e[1],2.2)*t,Math.pow(e[2],2.2)*t]},e.cu=Rh,e.cv=Ir,e.cw=Sr,e.cx=256,e.cy=function(t,r){const i=[0,0,0],n=zh(Th(r.canonical));return e.Q.transformMat4(i,i,n),e.Q.transformMat4(i,i,t),i},e.cz=e=>({u_camera_to_center_distance:new Tc(e),u_extrude_scale:new zc(e),u_device_pixel_ratio:new Tc(e),u_matrix:new Dc(e),u_inv_rot_matrix:new Dc(e),u_merc_center:new Ec(e),u_tile_id:new Mc(e),u_zoom_transition:new Tc(e),u_up_dir:new Mc(e),u_emissive_strength:new Tc(e)}),e.d=ni,e.d$=m_,e.d0=Lp,e.d1=s_,e.d2=Fl,e.d3=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[]}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(e){const t=gp(new Vt(0,0),new Vt(no,no),e),r=[];for(const i of this._activeRegions){if(i.hiddenByOverlap)continue;if(!Ap(t,i))continue;const n=_p(i.min,i.max,e);r.push({min:n.min,max:n.max,sourceId:this._sourceIds[i.priority],footprint:i.footprint,footprintTileId:i.tileId})}return r}setSources(e){this._setSources(e.map((e=>({getSourceId:()=>e.cache.id,getFootprints:()=>{const t=[];for(const r of e.cache.getVisibleCoordinates()){const i=e.cache.getTile(r).buckets[e.layer];if(i)for(const e of i.getNodesInfo()){const i=e.node;i.footprint&&t.push({footprint:i.footprint,id:r.toUnwrapped()})}}return t}}))))}_addSource(e){const t=e.getFootprints();if(0!==t.length){for(const e of t){if(!e.footprint)continue;const t=gp(e.footprint.min,e.footprint.max,e.id);this._activeRegions.push({min:t.min,max:t.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:e.id,footprint:e.footprint})}this._sourceIds.push(e.getSourceId())}}_computeReplacement(){this._activeRegions.sort(((e,t)=>e.priority-t.priority||fp(e.min,t.min)||fp(e.max,t.max)));let e=this._activeRegions.length!==this._prevRegions.length;if(!e){let t=0,r=0;for(;!e&&t!==this._activeRegions.length;){const i=this._activeRegions[t],n=this._prevRegions[r];e=i.priority!==n.priority||!mp(i,n),++t,++r}}if(e){++this._updateTime;const e=e=>{const t=this._activeRegions;if(e>=t.length)return e;const r=t[e].priority;for(;e<t.length&&t[e].priority===r;)++e;return e};if(this._sourceIds.length>1){let t=0,r=e(t);for(;t!==r;){let i=t;const n=t;for(;i!==r;){const e=this._activeRegions[i];e.hiddenByOverlap=!1;for(let t=0;t<n;t++){const r=this._activeRegions[t];if(!r.hiddenByOverlap&&Ap(e,r)&&(e.hiddenByOverlap=xp(e.footprint,e.tileId,r.footprint,r.tileId),e.hiddenByOverlap))break}++i}t=r,r=e(t)}}}}_setSources(e){[this._prevRegions,this._activeRegions]=[this._activeRegions,[]],this._sourceIds=[];for(let t=e.length-1;t>=0;t--)this._addSource(e[t]);this._computeReplacement()}},e.d4=class{constructor(e){this._createGrid(e),this._createPoles(e)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const e of this._poleSegments)e.destroy();for(const e of this._gridSegments)e.withSkirts.destroy(),e.withoutSkirts.destroy()}_fillGridMeshWithLods(e,t){const r=new Tl,i=new Hl,n=[],o=e+1+2,s=t[0]+1,a=t[0]+1+(1+t.length),l=(e,t,r)=>{let i=e===o-1?e-2:0===e?e:e-1;return i+=r?24575:0,[i,t]};for(let e=0;e<o;++e)r.emplaceBack(...l(e,0,!0));for(let e=0;e<s;++e)for(let t=0;t<o;++t)r.emplaceBack(...l(t,e,(0===t||t===o-1)&&!0));for(let e=0;e<t.length;++e){const i=t[e];for(let e=0;e<o;++e)r.emplaceBack(...l(e,i,!0))}for(let e=0;e<t.length;++e){const s=i.length,l=t[e]+1+2,c=new Hl;for(let r=0;r<l-1;r++){const n=r===l-2,s=n?o*(a-t.length+e-r):o;for(let e=0;e<o-1;e++){const t=r*o+e;0===r||n||0===e||e===o-2?(c.emplaceBack(t+1,t,t+s),c.emplaceBack(t+s,t+s+1,t+1)):(i.emplaceBack(t+1,t,t+s),i.emplaceBack(t+s,t+s+1,t+1))}}const u=mc.simpleSegment(0,s,r.length,i.length-s);for(let e=0;e<c.uint16.length;e+=3)i.emplaceBack(c.uint16[e],c.uint16[e+1],c.uint16[e+2]);const h=mc.simpleSegment(0,s,r.length,i.length-s);n.push({withoutSkirts:u,withSkirts:h})}return{vertices:r,indices:i,segments:n}}_createGrid(e){const t=this._fillGridMeshWithLods(Kc,Jc);this._gridSegments=t.segments,this._gridBuffer=e.createVertexBuffer(t.vertices,yh.members),this._gridIndexBuffer=e.createIndexBuffer(t.indices,!0)}_createPoles(e){const t=new Hl;for(let e=0;e<=Kc;e++)t.emplaceBack(0,e+1,e+2);this._poleIndexBuffer=e.createIndexBuffer(t,!0);const r=new Ql,i=new Ql,n=new Ql,o=new Ql;this._poleSegments=[];for(let e=0,t=0;e<Xc;e++){const s=360/(1<<e);r.emplaceBack(0,-qc,0,.5,0),i.emplaceBack(0,-qc,0,.5,1),n.emplaceBack(0,-qc,0,.5,.5),o.emplaceBack(0,-qc,0,.5,.5);for(let e=0;e<=Kc;e++){let t=e/Kc,a=0;const l=Ui(0,s,t),[c,u,h]=ru(Hh,Gh,l,qc);r.emplaceBack(c,u,h,t,a),i.emplaceBack(c,u,h,t,1-a);const d=Ht(l);t=.5+.5*Math.sin(d),a=.5+.5*Math.cos(d),n.emplaceBack(c,u,h,t,a),o.emplaceBack(c,u,h,t,1-a)}this._poleSegments.push(mc.simpleSegment(t,0,66,64)),t+=66}this._poleNorthVertexBuffer=e.createVertexBuffer(r,gh,!1),this._poleSouthVertexBuffer=e.createVertexBuffer(i,gh,!1),this._texturedPoleNorthVertexBuffer=e.createVertexBuffer(n,gh,!1),this._texturedPoleSouthVertexBuffer=e.createVertexBuffer(o,gh,!1)}getGridBuffers(e,t){return[this._gridBuffer,this._gridIndexBuffer,t?this._gridSegments[e].withSkirts:this._gridSegments[e].withoutSkirts]}getPoleBuffers(e,t){return[t?this._texturedPoleNorthVertexBuffer:this._poleNorthVertexBuffer,t?this._texturedPoleSouthVertexBuffer:this._poleSouthVertexBuffer,this._poleIndexBuffer,this._poleSegments[e]]}},e.d5=function(e){return wi.has(e)},e.d6=Qt,e.d7=function(){return!!document.fullscreenElement||!!document.webkitFullscreenElement},e.d8=qt,e.d9=Mu,e.dA=x_,e.dB=function(e){const t=jr();if(!t)return;const r=t.delete(zr);e&&r.catch(e).then((()=>e()))},e.dC=g_,e.dD=I_,e.dE=function(e){C_=Dr.resolveURL(e),S_||(S_=new A_(b_(),new Oi)),S_.broadcast("setDracoUrl",C_)},e.dF=P_,e.dG=function(e){E_=Dr.resolveURL(e),S_||(S_=new A_(b_(),new Oi)),S_.broadcast("setMeshoptUrl",E_)},e.dH=fa,e.dI=rd,e.dJ=oA,e.dK=ny,e.dL=ay,e.dM=vf,e.dN=ar,e.dO=tA,e.dP=function(e,t,r,i,n,o,s,a,l,c,u){e.createArrays(),e.tilePixelRatio=no/(512*e.overscaling),e.compareText={},e.iconsNeedLinear=!1;const h=e.layers[0].layout,d=e.layers[0]._unevaluatedLayout._values,p={};if("composite"===e.textSizeData.kind){const{minZoom:t,maxZoom:r}=e.textSizeData;p.compositeTextSizes=[d["text-size"].possiblyEvaluate(new Va(t),a),d["text-size"].possiblyEvaluate(new Va(r),a)]}if("composite"===e.iconSizeData.kind){const{minZoom:t,maxZoom:r}=e.iconSizeData;p.compositeIconSizes=[d["icon-size"].possiblyEvaluate(new Va(t),a),d["icon-size"].possiblyEvaluate(new Va(r),a)]}p.layoutTextSize=d["text-size"].possiblyEvaluate(new Va(l+1),a),p.layoutIconSize=d["icon-size"].possiblyEvaluate(new Va(l+1),a),p.textMaxSize=d["text-size"].possiblyEvaluate(new Va(18),a);const f="map"===h.get("text-rotation-alignment")&&"point"!==h.get("symbol-placement"),m=h.get("text-size");let A=!1;for(const t of e.features)if(t.icon&&t.icon.nameSecondary){A=!0;break}for(const o of e.features){const l=h.get("text-font").evaluate(o,{},a).join(","),d=m.evaluate(o,{},a),g=p.layoutTextSize.evaluate(o,{},a),_=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),y=o.text;let x,v=[0,0];if(y){const i=y.toString(),s=h.get("text-letter-spacing").evaluate(o,{},a)*Gf,c=h.get("text-line-height").evaluate(o,{},a)*Gf,u=va(i)?s:0,p=h.get("text-anchor").evaluate(o,{},a),m=h.get("text-variable-anchor");if(!m){const e=h.get("text-radial-offset").evaluate(o,{},a);v=e?xA(p,[e*Gf,_A]):h.get("text-offset").evaluate(o,{},a).map((e=>e*Gf))}let A=f?"center":h.get("text-justify").evaluate(o,{},a);const x="point"===h.get("symbol-placement"),b=x?h.get("text-max-width").evaluate(o,{},a)*Gf:1/0,w=o=>{e.allowVerticalPlacement&&xa(i)&&(_.vertical=Dm(y,t,r,n,l,b,c,p,o,u,v,Sm.vertical,!0,g,d))};if(!f&&m){const e="auto"===A?m.map((e=>vA(e))):[A];let i=!1;for(let o=0;o<e.length;o++){const s=e[o];if(!_.horizontal[s])if(i)_.horizontal[s]=_.horizontal[0];else{const e=Dm(y,t,r,n,l,b,c,"center",s,u,v,Sm.horizontal,!1,g,d);e&&(_.horizontal[s]=e,i=1===e.positionedLines.length)}}w("left")}else{if("auto"===A&&(A=vA(p)),x||h.get("text-writing-mode").indexOf("horizontal")>=0||!xa(i)){const e=Dm(y,t,r,n,l,b,c,p,A,u,v,Sm.horizontal,!1,g,d);e&&(_.horizontal[A]=e)}w(x?"left":A)}}let b=!1;if(o.icon&&o.icon.namePrimary){const t=i[o.icon.namePrimary];t&&(x=Nm(n[o.icon.namePrimary],o.icon.nameSecondary?n[o.icon.nameSecondary]:void 0,h.get("icon-offset").evaluate(o,{},a),h.get("icon-anchor").evaluate(o,{},a)),b=t.sdf,void 0===e.sdfIcons?e.sdfIcons=t.sdf:e.sdfIcons!==t.sdf&&hr("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(t.pixelRatio!==e.pixelRatio||0!==h.get("icon-rotate").constantOr(1))&&(e.iconsNeedLinear=!0))}const w=EA(_.horizontal)||_.vertical;e.iconsInText||(e.iconsInText=!!w&&w.iconsInText),(w||x)&&bA(e,o,_,x,i,p,g,0,v,b,s,a,c,u,A)}o&&e.generateCollisionDebugBuffers(l,e.collisionBoxArray)},e.dQ=hp,e.dR=bm,e.dS=kp,e.dT=dp,e.dU=Jd,e.dV=Ft,e.dW=tm,e.dX=h,e.dY=function(e){let t=0;if(new Uint32Array(e,0,1)[0]!==j_){const r=new Uint32Array(e,0,7),[,,i,n,o,s]=r;t=r.byteLength+n+o+s+o,(i!==e.byteLength||t>=e.byteLength)&&hr("Invalid b3dm header information.")}return Z_(e,t)},e.dZ=function(e,t){const r=ty(e);for(const e of r){for(const t of e.meshes)ry(t);e.lights&&(e.lightMeshIndex=e.meshes.length,e.meshes.push(iy(e.lights,t)))}return r},e.d_=Ay,e.da=iu,e.db=function([e,t,r]){const i=Math.hypot(e,t,r),n=Math.atan2(e,r),o=.5*Math.PI-Math.acos(-t/i);return new su(Gt(n),Gt(o))},e.dc=nu,e.dd=i,e.de=Nh,e.df=Vh,e.dg=function(t){const r=[0,0,0],i=e.a9.identity(new Float64Array(16));return e.a9.multiply(i,t.pixelMatrix,t.globeMatrix),e.Q.transformMat4(r,r,i),new Vt(r[0],r[1])},e.dh=function(e){const t=e.navigator?e.navigator.userAgent:null;return!!function(e){if(null==wr){const t=e.navigator?e.navigator.userAgent:null;wr=!!e.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return wr}(e)&&t&&(t.match("Version/15.4")||t.match("Version/15.5")||t.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},e.di=class{constructor(e,t,r){this._transformRequestFn=e,this._customAccessToken=t,this._silenceAuthErrors=!!r,this._createSkuToken()}_createSkuToken(){const e=function(){let e="";for(let t=0;t<10;t++)e+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1",oi,e].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=e.token,this._skuTokenExpiresAt=e.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}normalizeStyleURL(e,r){if(!o(e))return e;const i=li(e);return i.params.push(`sdk=js-${t}`),i.path=`/styles/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||r)}normalizeGlyphsURL(e,t){if(!o(e))return e;const r=li(e);return r.path=`/fonts/v1${r.path}`,this._makeAPIURL(r,this._customAccessToken||t)}normalizeModelURL(e,t){if(!o(e))return e;const r=li(e);return r.path=`/models/v1${r.path}`,this._makeAPIURL(r,this._customAccessToken||t)}normalizeSourceURL(e,t,r,i){if(!o(e))return e;const n=li(e);return n.path=`/v4/${n.authority}.json`,n.params.push("secure"),r&&n.params.push(`language=${r}`),i&&n.params.push(`worldview=${i}`),this._makeAPIURL(n,this._customAccessToken||t)}normalizeSpriteURL(e,t,r,i){const n=li(e);return o(e)?(n.path=`/styles/v1${n.path}/sprite${t}${r}`,this._makeAPIURL(n,this._customAccessToken||i)):(n.path+=`${t}${r}`,ci(n))}normalizeTileURL(e,t,r){if(this._isSkuTokenExpired()&&this._createSkuToken(),e&&!o(e))return e;const n=li(e);n.path=n.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${t||r&&"raster"!==n.authority&&512===r?"@2x":""}${Ur.supported?".webp":"$1"}`),"raster"===n.authority?n.path=`/${i.RASTER_URL_PREFIX}${n.path}`:"rasterarrays"===n.authority?n.path=`/${i.RASTERARRAYS_URL_PREFIX}${n.path}`:(n.path=n.path.replace(/^.+\/v4\//,"/"),n.path=`/${i.TILE_URL_VERSION}${n.path}`);const s=this._customAccessToken||function(e){for(const t of e){const e=t.match(/^access_token=(.*)$/);if(e)return e[1]}return null}(n.params)||i.ACCESS_TOKEN;return i.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&n.params.push(`sku=${this._skuToken}`),this._makeAPIURL(n,s)}canonicalizeTileURL(e,t){const r=li(e);if(!r.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!r.path.match(/\.[\w]+$/))return e;let n="mapbox://";r.path.match(/^\/raster\/v1\//)?n+=`raster/${r.path.replace(`/${i.RASTER_URL_PREFIX}/`,"")}`:r.path.match(/^\/rasterarrays\/v1\//)?n+=`rasterarrays/${r.path.replace(`/${i.RASTERARRAYS_URL_PREFIX}/`,"")}`:n+=`tiles/${r.path.replace(`/${i.TILE_URL_VERSION}/`,"")}`;let o=r.params;return t&&(o=o.filter((e=>!e.match(/^access_token=/)))),o.length&&(n+=`?${o.join("&")}`),n}canonicalizeTileset(e,t){const r=!!t&&o(t),i=[];for(const t of e.tiles||[])n(t)?i.push(this.canonicalizeTileURL(t,r)):i.push(t);return i}_makeAPIURL(e,t){const r="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",n=li(i.API_URL);if(e.protocol=n.protocol,e.authority=n.authority,"http"===e.protocol){const t=e.params.indexOf("secure");t>=0&&e.params.splice(t,1)}if("/"!==n.path&&(e.path=`${n.path}${e.path}`),!i.REQUIRE_ACCESS_TOKEN)return ci(e);if(t=t||i.ACCESS_TOKEN,!this._silenceAuthErrors){if(!t)throw new Error(`An API access token is required to use Mapbox GL. ${r}`);if("s"===t[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${r}`)}return e.params=e.params.filter((e=>-1===e.indexOf("access_token"))),e.params.push(`access_token=${t||""}`),ci(e)}},e.dj=function(e,t){t?wi.add(e):wi.delete(e)},e.dk=Ur,e.dl=xi,e.dm=bi,e.dn=si,e.dp=Ai,e.dq=_i,e.dr=function(e){wi.delete(e)},e.ds=vi,e.dt=mi,e.du=t,e.dv=function(e,t){Rr=e,Fr=t},e.dw=function(e,t,r=!1){if(ka===Sa||ka===Ia||ka===Pa)throw new Error("setRTLTextPlugin cannot be called multiple times.");La=Dr.resolveURL(e),ka=Sa,Da=t,Oa(),r||Fa()},e.dx=Ra,e.dy=function(){b_().acquire(y_)},e.dz=function(){const e=v_;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(y_),v_=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()"))},e.e=Jt,e.e0=ja,e.e1=function(e){Vr(),Or&&Or.then((t=>{t.keys().then((r=>{for(let i=0;i<r.length-e;i++)t.delete(r[i])}))}))},e.f=Dr,e.g=function(e,t){return Kr(Jt(e,{type:"json"}),t)},e.h=id,e.i=class extends Kg{},e.j=Tn,e.k=Zi,e.l=function(e){return fetch(e).then((e=>e.arrayBuffer())).then((t=>Z_(t,0,e)))},e.m=Hs,e.n=Zs,e.o=ra,e.p=Km,e.q=el,e.r=sa,e.s=Ws,e.t=ia,e.u=Ja,e.v=Vo,e.w=hr,e.x=Uo,e.y=jo})),i(["./shared"],(function(e){function t(e){const t=e?e.url.toString():void 0;return t?performance.getEntriesByName(t):[]}function r(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e||null==e)return JSON.stringify(e);if(Array.isArray(e)){let t="[";for(const i of e)t+=`${r(i)},`;return`${t}]`}let t="{";for(const i of Object.keys(e).sort())t+=`${i}:${r(e[i])},`;return`${t}}`}function i(t){let i="";for(const n of e.b5)i+=`/${r(t[n])}`;return i}class n{constructor(e){this.keyCache={},this._layers={},this._layerConfigs={},e&&this.replace(e)}replace(e,t){this._layerConfigs={},this._layers={},this.update(e,[],t)}update(t,r,n){this._options=n;for(const r of t)this._layerConfigs[r.id]=r,(this._layers[r.id]=e.c7(r,this.scope,this._options)).compileFilter(),this.keyCache[r.id]&&delete this.keyCache[r.id];for(const e of r)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const o=function(e,t){const r={};for(let n=0;n<e.length;n++){const o=t&&t[e[n].id]||i(e[n]);t&&(t[e[n].id]=o);let s=r[o];s||(s=r[o]=[]),s.push(e[n])}const n=[];for(const e in r)n.push(r[e]);return n}(e.b2(this._layerConfigs),this.keyCache);for(const e of o){const t=e.map((e=>this._layers[e.id])),r=t[0];if("none"===r.visibility)continue;const i=r.source||"";let n=this.familiesBySource[i];n||(n=this.familiesBySource[i]={});const o=r.sourceLayer||"_geojsonTileLayer";let s=n[o];s||(s=n[o]=[]),s.push(t)}}}const o=1*e.dJ;class s{constructor(t){const r={},i=[];for(const e in t){const n=t[e],s=r[e]={};for(const e in n.glyphs){const t=n.glyphs[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const r=t.metrics.localGlyph?o:1,a={x:0,y:0,w:t.bitmap.width+2*r,h:t.bitmap.height+2*r};i.push(a),s[e]=a}}const{w:n,h:s}=e.p(i),a=new e.dI({width:n||1,height:s||1});for(const i in t){const n=t[i];for(const t in n.glyphs){const s=n.glyphs[+t];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=r[i][t],c=s.metrics.localGlyph?o:1;e.dI.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=r}}e.dH(s,"GlyphAtlas");class a{constructor(t){this.tileID=new e.ap(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.tileZoom=t.tileZoom,this.uid=t.uid,this.zoom=t.zoom,this.canonical=t.tileID.canonical,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.scope=t.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=t.showCollisionBoxes,this.collectResourceTiming=!!t.collectResourceTiming,this.promoteId=t.promoteId,this.isSymbolTile=t.isSymbolTile,this.tileTransform=e.av(t.tileID.canonical,t.projection),this.projection=t.projection,this.brightness=t.brightness,this.extraShadowCaster=!!t.extraShadowCaster}parse(t,r,i,n,o){this.status="parsing",this.data=t,this.collisionBoxArray=new e.aG;const a=new e.dK(Object.keys(t.layers).sort()),c=new e.dL(this.tileID,this.promoteId);c.bucketLayerIDs=[];const u={},h=new e.dM(256,256),d={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:h,availableImages:i,brightness:this.brightness},p=r.familiesBySource[this.source];for(const r in p){const n=t.layers[r];if(!n)continue;let o=!1,s=!1,h=!1;for(const e of p[r])"symbol"===e[0].type?o=!0:s=!0,e[0].is3D()&&"model"!==e[0].type&&(h=!0);if(this.extraShadowCaster&&!h)continue;if(!0===this.isSymbolTile&&!o)continue;if(!1===this.isSymbolTile&&!s)continue;1===n.version&&e.w(`Vector tile source "${this.source}" layer "${r}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=a.encode(r),m=[];for(let e=0;e<n.length;e++){const t=n.feature(e),i=c.getId(t,r);m.push({feature:t,id:i,index:e,sourceLayerIndex:f})}for(const e of p[r]){const t=e[0];(!this.extraShadowCaster||t.is3D()&&"model"!==t.type)&&(void 0!==this.isSymbolTile&&"symbol"===t.type!==this.isSymbolTile||t.minzoom&&this.zoom<Math.floor(t.minzoom)||t.maxzoom&&this.zoom>=t.maxzoom||"none"!==t.visibility&&(l(e,this.zoom,d.brightness,i),(u[t.id]=t.createBucket({index:c.bucketLayerIDs.length,layers:e,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:f,sourceID:this.source,projection:this.projection.spec})).populate(m,d,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(e.map((e=>e.id)))))}}let f,m,A,g;h.trim();const _={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},y=()=>{if(f)return this.status="done",o(f);if(this.extraShadowCaster)this.status="done",o(null,{buckets:e.b2(u).filter((e=>!e.isEmpty())),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:d.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(m&&A&&g){const t=new s(m),r=new e.dO(A,g);for(const n in u){const o=u[n];o instanceof e.aH?(l(o.layers,this.zoom,d.brightness,i),e.dP(o,m,t.positions,A,r.iconPositions,this.showCollisionBoxes,i,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):o.hasPattern&&(o instanceof e.aN||o instanceof e.aO||o instanceof e.cO)&&(l(o.layers,this.zoom,d.brightness,i),o.addFeatures(d,this.tileID.canonical,r.patternPositions,i,this.tileTransform,this.brightness))}this.status="done",o(null,{buckets:e.b2(u).filter((e=>!e.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:t.image,lineAtlas:h,imageAtlas:r,brightness:d.brightness})}};if(!this.extraShadowCaster){const t=e.dN(d.glyphDependencies,(e=>Object.keys(e).map(Number)));Object.keys(t).length?n.send("getGlyphs",{uid:this.uid,stacks:t,scope:this.scope},((e,t)=>{f||(f=e,m=t,y())}),void 0,!1,_):m={};const r=Object.keys(d.iconDependencies);r.length?n.send("getImages",{icons:r,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((e,t)=>{f||(f=e,A=t,y())}),void 0,!1,_):A={};const i=Object.keys(d.patternDependencies);i.length?n.send("getImages",{icons:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((e,t)=>{f||(f=e,g=t,y())}),void 0,!1,_):g={}}y()}}function l(t,r,i,n){const o=new e.N(r,{brightness:i});for(const e of t)e.recalculate(o,n)}class c extends e.E{constructor(t,r,i,n,o,s){super(),this.actor=t,this.layerIndex=r,this.availableImages=i,this.loadVectorData=o||e.ak,this.loading={},this.loaded={},this.deduped=new e.ai(t.scheduler),this.isSpriteLoaded=n,this.scheduler=t.scheduler,this.brightness=s}loadTile(r,i){const n=r.uid,o=r&&r.request,s=o&&o.collectResourceTiming,l=this.loading[n]=new a(r);l.abort=this.loadVectorData(r,((a,c)=>{const u=!this.loading[n];if(delete this.loading[n],u||a||!c)return l.status="done",u||(this.loaded[n]=l),i(a);const h=c.rawData,d={};c.expires&&(d.expires=c.expires),c.cacheControl&&(d.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new e.dQ(new e.dR(h));const p=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((r,n)=>{if(r||!n)return i(r);const a={};if(s){const e=t(o);e.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(e)))}i(null,e.e({rawTileData:h.slice(0)},n,d,a))}))};this.isSpriteLoaded?p():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:r.isSymbolTile,zoom:r.tileZoom}):p()})),this.loaded=this.loaded||{},this.loaded[n]=l}))}reloadTile(t,r){const i=this.loaded,n=t.uid,o=this;if(i&&i[n]){const s=i[n];s.showCollisionBoxes=t.showCollisionBoxes,s.projection=t.projection,s.brightness=t.brightness,s.tileTransform=e.av(t.tileID.canonical,t.projection),s.extraShadowCaster=t.extraShadowCaster;const a=(e,t)=>{const i=s.reloadCallback;i&&(delete s.reloadCallback,s.parse(s.vectorTile,o.layerIndex,this.availableImages,o.actor,i)),r(e,t)};"parsing"===s.status?s.reloadCallback=a:"done"===s.status&&(s.vectorTile?s.parse(s.vectorTile,this.layerIndex,this.availableImages,this.actor,a):a())}else r(null,void 0)}abortTile(e,t){const r=e.uid,i=this.loading[r];i&&(i.abort&&i.abort(),delete this.loading[r]),t()}removeTile(e,t){const r=this.loaded,i=e.uid;r&&r[i]&&delete r[i],t()}}class u{loadTile(t,r){const{uid:i,encoding:n,rawImageData:o,padding:s}=t,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;r(null,new e.dS(i,a,n,s<1))}getImageData(e,t){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(e.width,e.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=e.width,this.offscreenCanvas.height=e.height,this.offscreenCanvasContext.drawImage(e,0,0,e.width,e.height);const r=this.offscreenCanvasContext.getImageData(-t,-t,e.width+2*t,e.height+2*t);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),r}}class h{decodeRasterArray({task:t,buffer:r},i){e.b0.performDecoding(r,t).then((e=>{i(null,e)}),(e=>{i(e)}))}}const d=e.dT.prototype.toGeoJSON;let p=class{constructor(t){this._feature=t,this.extent=e.Y,this.type=t.type,this.properties=t.tags,"id"in t&&!isNaN(t.id)&&(this.id=parseInt(t.id,10))}loadGeometry(){if(1===this._feature.type){const t=[];for(const r of this._feature.geometry)t.push([new e.P(r[0],r[1])]);return t}{const t=[];for(const r of this._feature.geometry){const i=[];for(const t of r)i.push(new e.P(t[0],t[1]));t.push(i)}return t}}toGeoJSON(e,t,r){return d.call(this,e,t,r)}},f=class{constructor(t){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=e.Y,this.length=t.length,this._features=t}feature(e){return new p(this._features[e])}};var m={exports:{}},A=e.dV,g=e.dU.VectorTileFeature,_=y;function y(e,t){this.options=t||{},this.features=e,this.length=e.length}function x(e,t){this.id="number"==typeof e.id?e.id:void 0,this.type=e.type,this.rawGeometry=1===e.type?[e.geometry]:e.geometry,this.properties=e.tags,this.extent=t||4096}y.prototype.feature=function(e){return new x(this.features[e],this.options.extent)},x.prototype.loadGeometry=function(){var e=this.rawGeometry;this.geometry=[];for(var t=0;t<e.length;t++){for(var r=e[t],i=[],n=0;n<r.length;n++)i.push(new A(r[n][0],r[n][1]));this.geometry.push(i)}return this.geometry},x.prototype.bbox=function(){this.geometry||this.loadGeometry();for(var e=this.geometry,t=1/0,r=-1/0,i=1/0,n=-1/0,o=0;o<e.length;o++)for(var s=e[o],a=0;a<s.length;a++){var l=s[a];t=Math.min(t,l.x),r=Math.max(r,l.x),i=Math.min(i,l.y),n=Math.max(n,l.y)}return[t,i,r,n]},x.prototype.toGeoJSON=g.prototype.toGeoJSON;var v=e.dW,b=_;function w(e){var t=new v;return function(e,t){for(var r in e.layers)t.writeMessage(3,C,e.layers[r])}(e,t),t.finish()}function C(e,t){var r;t.writeVarintField(15,e.version||1),t.writeStringField(1,e.name||""),t.writeVarintField(5,e.extent||4096);var i={keys:[],values:[],keycache:{},valuecache:{}};for(r=0;r<e.length;r++)i.feature=e.feature(r),t.writeMessage(2,T,i);var n=i.keys;for(r=0;r<n.length;r++)t.writeStringField(3,n[r]);var o=i.values;for(r=0;r<o.length;r++)t.writeMessage(4,P,o[r])}function T(e,t){var r=e.feature;void 0!==r.id&&t.writeVarintField(1,r.id),t.writeMessage(2,E,e),t.writeVarintField(3,r.type),t.writeMessage(4,I,r)}function E(e,t){var r=e.feature,i=e.keys,n=e.values,o=e.keycache,s=e.valuecache;for(var a in r.properties){var l=r.properties[a],c=o[a];if(null!==l){void 0===c&&(i.push(a),o[a]=c=i.length-1),t.writeVarint(c);var u=typeof l;"string"!==u&&"boolean"!==u&&"number"!==u&&(l=JSON.stringify(l));var h=u+":"+l,d=s[h];void 0===d&&(n.push(l),s[h]=d=n.length-1),t.writeVarint(d)}}}function M(e,t){return(t<<3)+(7&e)}function S(e){return e<<1^e>>31}function I(e,t){for(var r=e.loadGeometry(),i=e.type,n=0,o=0,s=r.length,a=0;a<s;a++){var l=r[a],c=1;1===i&&(c=l.length),t.writeVarint(M(1,c));for(var u=3===i?l.length-1:l.length,h=0;h<u;h++){1===h&&1!==i&&t.writeVarint(M(2,u-1));var d=l[h].x-n,p=l[h].y-o;t.writeVarint(S(d)),t.writeVarint(S(p)),n+=d,o+=p}3===i&&t.writeVarint(M(7,1))}}function P(e,t){var r=typeof e;"string"===r?t.writeStringField(1,e):"boolean"===r?t.writeBooleanField(7,e):"number"===r&&(e%1!=0?t.writeDoubleField(3,e):e<0?t.writeSVarintField(6,e):t.writeVarintField(5,e))}m.exports=w,m.exports.fromVectorTileJs=w,m.exports.fromGeojsonVt=function(e,t){t=t||{};var r={};for(var i in e)r[i]=new b(e[i].features,t),r[i].name=i,r[i].version=t.version,r[i].extent=t.extent;return w({layers:r})},m.exports.GeoJSONWrapper=b;var D=e.dX(m.exports);const k={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:e=>e},L=Math.fround||(z=new Float32Array(1),e=>(z[0]=+e,z[0]));var z;const O=3,B=5,R=6;class F{constructor(e){this.options=Object.assign(Object.create(k),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(e){const{log:t,minZoom:r,maxZoom:i}=this.options;t&&console.time("total time");const n=`prepare ${e.length} points`;t&&console.time(n),this.points=e;const o=[];for(let t=0;t<e.length;t++){const r=e[t];if(!r.geometry)continue;const[i,n]=r.geometry.coordinates,s=L(N(i)),a=L(U(n));o.push(s,a,1/0,t,-1,1),this.options.reduce&&o.push(0)}let s=this.trees[i+1]=this._createTree(o);t&&console.timeEnd(n);for(let e=i;e>=r;e--){const r=+Date.now();s=this.trees[e]=this._createTree(this._cluster(s,e)),t&&console.log("z%d: %d clusters in %dms",e,s.numItems,+Date.now()-r)}return t&&console.timeEnd("total time"),this}getClusters(e,t){let r=((e[0]+180)%360+360)%360-180;const i=Math.max(-90,Math.min(90,e[1]));let n=180===e[2]?180:((e[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)r=-180,n=180;else if(r>n){const e=this.getClusters([r,i,180,o],t),s=this.getClusters([-180,i,n,o],t);return e.concat(s)}const s=this.trees[this._limitZoom(t)],a=s.range(N(r),U(o),N(n),U(i)),l=s.data,c=[];for(const e of a){const t=this.stride*e;c.push(l[t+B]>1?j(l,t,this.clusterProps):this.points[l[t+O]])}return c}getChildren(e){const t=this._getOriginId(e),r=this._getOriginZoom(e),i="No cluster with the specified id.",n=this.trees[r];if(!n)throw new Error(i);const o=n.data;if(t*this.stride>=o.length)throw new Error(i);const s=this.options.radius/(this.options.extent*Math.pow(2,r-1)),a=n.within(o[t*this.stride],o[t*this.stride+1],s),l=[];for(const t of a){const r=t*this.stride;o[r+4]===e&&l.push(o[r+B]>1?j(o,r,this.clusterProps):this.points[o[r+O]])}if(0===l.length)throw new Error(i);return l}getLeaves(e,t,r){const i=[];return this._appendLeaves(i,e,t=t||10,r=r||0,0),i}getTile(e,t,r){const i=this.trees[this._limitZoom(e)],n=Math.pow(2,e),{extent:o,radius:s}=this.options,a=s/o,l=(r-a)/n,c=(r+1+a)/n,u={features:[]};return this._addTileFeatures(i.range((t-a)/n,l,(t+1+a)/n,c),i.data,t,r,n,u),0===t&&this._addTileFeatures(i.range(1-a/n,l,1,c),i.data,n,r,n,u),t===n-1&&this._addTileFeatures(i.range(0,l,a/n,c),i.data,-1,r,n,u),u.features.length?u:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const r=this.getChildren(e);if(t++,1!==r.length)break;e=r[0].properties.cluster_id}return t}_appendLeaves(e,t,r,i,n){const o=this.getChildren(t);for(const t of o){const o=t.properties;if(o&&o.cluster?n+o.point_count<=i?n+=o.point_count:n=this._appendLeaves(e,o.cluster_id,r,i,n):n<i?n++:e.push(t),e.length===r)break}return n}_createTree(t){const r=new e.bj(t.length/this.stride|0,this.options.nodeSize,Float32Array);for(let e=0;e<t.length;e+=this.stride)r.add(t[e],t[e+1]);return r.finish(),r.data=t,r}_addTileFeatures(e,t,r,i,n,o){for(const s of e){const e=s*this.stride,a=t[e+B]>1;let l,c,u;if(a)l=V(t,e,this.clusterProps),c=t[e],u=t[e+1];else{const r=this.points[t[e+O]];l=r.properties;const[i,n]=r.geometry.coordinates;c=N(i),u=U(n)}const h={type:1,geometry:[[Math.round(this.options.extent*(c*n-r)),Math.round(this.options.extent*(u*n-i))]],tags:l};let d;d=a||this.options.generateId?t[e+O]:this.points[t[e+O]].id,void 0!==d&&(h.id=d),o.features.push(h)}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,t){const{radius:r,extent:i,reduce:n,minPoints:o}=this.options,s=r/(i*Math.pow(2,t)),a=e.data,l=[],c=this.stride;for(let r=0;r<a.length;r+=c){if(a[r+2]<=t)continue;a[r+2]=t;const i=a[r],u=a[r+1],h=e.within(a[r],a[r+1],s),d=a[r+B];let p=d;for(const e of h){const r=e*c;a[r+2]>t&&(p+=a[r+B])}if(p>d&&p>=o){let e,o=i*d,s=u*d,f=-1;const m=(r/c<<5)+(t+1)+this.points.length;for(const i of h){const l=i*c;if(a[l+2]<=t)continue;a[l+2]=t;const u=a[l+B];o+=a[l]*u,s+=a[l+1]*u,a[l+4]=m,n&&(e||(e=this._map(a,r,!0),f=this.clusterProps.length,this.clusterProps.push(e)),n(e,this._map(a,l)))}a[r+4]=m,l.push(o/p,s/p,1/0,m,-1,p),n&&l.push(f)}else{for(let e=0;e<c;e++)l.push(a[r+e]);if(p>1)for(const e of h){const r=e*c;if(!(a[r+2]<=t)){a[r+2]=t;for(let e=0;e<c;e++)l.push(a[r+e])}}}}return l}_getOriginId(e){return e-this.points.length>>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,t,r){if(e[t+B]>1){const i=this.clusterProps[e[t+R]];return r?Object.assign({},i):i}const i=this.points[e[t+O]].properties,n=this.options.map(i);return r&&n===i?Object.assign({},n):n}}function j(e,t,r){return{type:"Feature",id:e[t+O],properties:V(e,t,r),geometry:{type:"Point",coordinates:[(i=e[t],360*(i-.5)),H(e[t+1])]}};var i}function V(e,t,r){const i=e[t+B],n=i>=1e4?`${Math.round(i/1e3)}k`:i>=1e3?Math.round(i/100)/10+"k":i,o=e[t+R],s=-1===o?{}:Object.assign({},r[o]);return Object.assign(s,{cluster:!0,cluster_id:e[t+O],point_count:i,point_count_abbreviated:n})}function N(e){return e/360+.5}function U(e){const t=Math.sin(e*Math.PI/180),r=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return r<0?0:r>1?1:r}function H(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}var G={exports:{}};G.exports=function(){function e(r,i,n,o){for(var s,a=o,l=n-i>>1,c=n-i,u=r[i],h=r[i+1],d=r[n],p=r[n+1],f=i+3;f<n;f+=3){var m=t(r[f],r[f+1],u,h,d,p);if(m>a)s=f,a=m;else if(m===a){var A=Math.abs(f-l);A<c&&(s=f,c=A)}}a>o&&(s-i>3&&e(r,i,s,o),r[s+2]=a,n-s>3&&e(r,s,n,o))}function t(e,t,r,i,n,o){var s=n-r,a=o-i;if(0!==s||0!==a){var l=((e-r)*s+(t-i)*a)/(s*s+a*a);l>1?(r=n,i=o):l>0&&(r+=s*l,i+=a*l)}return(s=e-r)*s+(a=t-i)*a}function r(e,t,r,n){var o={id:void 0===e?null:e,type:t,geometry:r,tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(e){var t=e.geometry,r=e.type;if("Point"===r||"MultiPoint"===r||"LineString"===r)i(e,t);else if("Polygon"===r||"MultiLineString"===r)for(var n=0;n<t.length;n++)i(e,t[n]);else if("MultiPolygon"===r)for(n=0;n<t.length;n++)for(var o=0;o<t[n].length;o++)i(e,t[n][o])}(o),o}function i(e,t){for(var r=0;r<t.length;r+=3)e.minX=Math.min(e.minX,t[r]),e.minY=Math.min(e.minY,t[r+1]),e.maxX=Math.max(e.maxX,t[r]),e.maxY=Math.max(e.maxY,t[r+1])}function n(e,t,i,l){if(t.geometry){var c=t.geometry.coordinates,u=t.geometry.type,h=Math.pow(i.tolerance/((1<<i.maxZoom)*i.extent),2),d=[],p=t.id;if(i.promoteId?p=t.properties[i.promoteId]:i.generateId&&(p=l||0),"Point"===u)o(c,d);else if("MultiPoint"===u)for(var f=0;f<c.length;f++)o(c[f],d);else if("LineString"===u)s(c,d,h,!1);else if("MultiLineString"===u){if(i.lineMetrics){for(f=0;f<c.length;f++)s(c[f],d=[],h,!1),e.push(r(p,"LineString",d,t.properties));return}a(c,d,h,!1)}else if("Polygon"===u)a(c,d,h,!0);else{if("MultiPolygon"!==u){if("GeometryCollection"===u){for(f=0;f<t.geometry.geometries.length;f++)n(e,{id:p,geometry:t.geometry.geometries[f],properties:t.properties},i,l);return}throw new Error("Input data is not a valid GeoJSON object.")}for(f=0;f<c.length;f++){var m=[];a(c[f],m,h,!0),d.push(m)}}e.push(r(p,u,d,t.properties))}}function o(e,t){t.push(l(e[0])),t.push(c(e[1])),t.push(0)}function s(t,r,i,n){for(var o,s,a=0,u=0;u<t.length;u++){var h=l(t[u][0]),d=c(t[u][1]);r.push(h),r.push(d),r.push(0),u>0&&(a+=n?(o*d-h*s)/2:Math.sqrt(Math.pow(h-o,2)+Math.pow(d-s,2))),o=h,s=d}var p=r.length-3;r[2]=1,e(r,0,p,i),r[p+2]=1,r.size=Math.abs(a),r.start=0,r.end=r.size}function a(e,t,r,i){for(var n=0;n<e.length;n++){var o=[];s(e[n],o,r,i),t.push(o)}}function l(e){return e/360+.5}function c(e){var t=Math.sin(e*Math.PI/180),r=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return r<0?0:r>1?1:r}function u(e,t,i,n,o,s,a,l){if(n/=t,s>=(i/=t)&&a<n)return e;if(a<i||s>=n)return null;for(var c=[],u=0;u<e.length;u++){var p=e[u],m=p.geometry,A=p.type,g=0===o?p.minX:p.minY,_=0===o?p.maxX:p.maxY;if(g>=i&&_<n)c.push(p);else if(!(_<i||g>=n)){var y=[];if("Point"===A||"MultiPoint"===A)h(m,y,i,n,o);else if("LineString"===A)d(m,y,i,n,o,!1,l.lineMetrics);else if("MultiLineString"===A)f(m,y,i,n,o,!1);else if("Polygon"===A)f(m,y,i,n,o,!0);else if("MultiPolygon"===A)for(var x=0;x<m.length;x++){var v=[];f(m[x],v,i,n,o,!0),v.length&&y.push(v)}if(y.length){if(l.lineMetrics&&"LineString"===A){for(x=0;x<y.length;x++)c.push(r(p.id,A,y[x],p.tags));continue}"LineString"!==A&&"MultiLineString"!==A||(1===y.length?(A="LineString",y=y[0]):A="MultiLineString"),"Point"!==A&&"MultiPoint"!==A||(A=3===y.length?"Point":"MultiPoint"),c.push(r(p.id,A,y,p.tags))}}}return c.length?c:null}function h(e,t,r,i,n){for(var o=0;o<e.length;o+=3){var s=e[o+n];s>=r&&s<=i&&(t.push(e[o]),t.push(e[o+1]),t.push(e[o+2]))}}function d(e,t,r,i,n,o,s){for(var a,l,c=p(e),u=0===n?A:g,h=e.start,d=0;d<e.length-3;d+=3){var f=e[d],_=e[d+1],y=e[d+2],x=e[d+3],v=e[d+4],b=0===n?f:_,w=0===n?x:v,C=!1;s&&(a=Math.sqrt(Math.pow(f-x,2)+Math.pow(_-v,2))),b<r?w>r&&(l=u(c,f,_,x,v,r),s&&(c.start=h+a*l)):b>i?w<i&&(l=u(c,f,_,x,v,i),s&&(c.start=h+a*l)):m(c,f,_,y),w<r&&b>=r&&(l=u(c,f,_,x,v,r),C=!0),w>i&&b<=i&&(l=u(c,f,_,x,v,i),C=!0),!o&&C&&(s&&(c.end=h+a*l),t.push(c),c=p(e)),s&&(h+=a)}var T=e.length-3;f=e[T],_=e[T+1],y=e[T+2],(b=0===n?f:_)>=r&&b<=i&&m(c,f,_,y),T=c.length-3,o&&T>=3&&(c[T]!==c[0]||c[T+1]!==c[1])&&m(c,c[0],c[1],c[2]),c.length&&t.push(c)}function p(e){var t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function f(e,t,r,i,n,o){for(var s=0;s<e.length;s++)d(e[s],t,r,i,n,o,!1)}function m(e,t,r,i){e.push(t),e.push(r),e.push(i)}function A(e,t,r,i,n,o){var s=(o-t)/(i-t);return e.push(o),e.push(r+(n-r)*s),e.push(1),s}function g(e,t,r,i,n,o){var s=(o-r)/(n-r);return e.push(t+(i-t)*s),e.push(o),e.push(1),s}function _(e,t){for(var i=[],n=0;n<e.length;n++){var o,s=e[n],a=s.type;if("Point"===a||"MultiPoint"===a||"LineString"===a)o=y(s.geometry,t);else if("MultiLineString"===a||"Polygon"===a){o=[];for(var l=0;l<s.geometry.length;l++)o.push(y(s.geometry[l],t))}else if("MultiPolygon"===a)for(o=[],l=0;l<s.geometry.length;l++){for(var c=[],u=0;u<s.geometry[l].length;u++)c.push(y(s.geometry[l][u],t));o.push(c)}i.push(r(s.id,a,o,s.tags))}return i}function y(e,t){var r=[];r.size=e.size,void 0!==e.start&&(r.start=e.start,r.end=e.end);for(var i=0;i<e.length;i+=3)r.push(e[i]+t,e[i+1],e[i+2]);return r}function x(e,t){if(e.transformed)return e;var r,i,n,o=1<<e.z,s=e.x,a=e.y;for(r=0;r<e.features.length;r++){var l=e.features[r],c=l.geometry,u=l.type;if(l.geometry=[],1===u)for(i=0;i<c.length;i+=2)l.geometry.push(v(c[i],c[i+1],t,o,s,a));else for(i=0;i<c.length;i++){var h=[];for(n=0;n<c[i].length;n+=2)h.push(v(c[i][n],c[i][n+1],t,o,s,a));l.geometry.push(h)}}return e.transformed=!0,e}function v(e,t,r,i,n,o){return[Math.round(r*(e*i-n)),Math.round(r*(t*i-o))]}function b(e,t,r,i,n){for(var o=t===n.maxZoom?0:n.tolerance/((1<<t)*n.extent),s={features:[],numPoints:0,numSimplified:0,numFeatures:0,source:null,x:r,y:i,z:t,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0},a=0;a<e.length;a++){s.numFeatures++,w(s,e[a],o,n);var l=e[a].minX,c=e[a].minY,u=e[a].maxX,h=e[a].maxY;l<s.minX&&(s.minX=l),c<s.minY&&(s.minY=c),u>s.maxX&&(s.maxX=u),h>s.maxY&&(s.maxY=h)}return s}function w(e,t,r,i){var n=t.geometry,o=t.type,s=[];if("Point"===o||"MultiPoint"===o)for(var a=0;a<n.length;a+=3)s.push(n[a]),s.push(n[a+1]),e.numPoints++,e.numSimplified++;else if("LineString"===o)C(s,n,e,r,!1,!1);else if("MultiLineString"===o||"Polygon"===o)for(a=0;a<n.length;a++)C(s,n[a],e,r,"Polygon"===o,0===a);else if("MultiPolygon"===o)for(var l=0;l<n.length;l++){var c=n[l];for(a=0;a<c.length;a++)C(s,c[a],e,r,!0,0===a)}if(s.length){var u=t.tags||null;if("LineString"===o&&i.lineMetrics){for(var h in u={},t.tags)u[h]=t.tags[h];u.mapbox_clip_start=n.start/n.size,u.mapbox_clip_end=n.end/n.size}var d={geometry:s,type:"Polygon"===o||"MultiPolygon"===o?3:"LineString"===o||"MultiLineString"===o?2:1,tags:u};null!==t.id&&(d.id=t.id),e.features.push(d)}}function C(e,t,r,i,n,o){var s=i*i;if(i>0&&t.size<(n?s:i))r.numPoints+=t.length/3;else{for(var a=[],l=0;l<t.length;l+=3)(0===i||t[l+2]>s)&&(r.numSimplified++,a.push(t[l]),a.push(t[l+1])),r.numPoints++;n&&function(e,t){for(var r=0,i=0,n=e.length,o=n-2;i<n;o=i,i+=2)r+=(e[i]-e[o])*(e[i+1]+e[o+1]);if(r>0===t)for(i=0,n=e.length;i<n/2;i+=2){var s=e[i],a=e[i+1];e[i]=e[n-2-i],e[i+1]=e[n-1-i],e[n-2-i]=s,e[n-1-i]=a}}(a,o),e.push(a)}}function T(e,t){var r=(t=this.options=function(e,t){for(var r in t)e[r]=t[r];return e}(Object.create(this.options),t)).debug;if(r&&console.time("preprocess data"),t.maxZoom<0||t.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(t.promoteId&&t.generateId)throw new Error("promoteId and generateId cannot be used together.");var i=function(e,t){var r=[];if("FeatureCollection"===e.type)for(var i=0;i<e.features.length;i++)n(r,e.features[i],t,i);else n(r,"Feature"===e.type?e:{geometry:e},t);return r}(e,t);this.tiles={},this.tileCoords=[],r&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",t.indexMaxZoom,t.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),(i=function(e,t){var r=t.buffer/t.extent,i=e,n=u(e,1,-1-r,r,0,-1,2,t),o=u(e,1,1-r,2+r,0,-1,2,t);return(n||o)&&(i=u(e,1,-r,1+r,0,-1,2,t)||[],n&&(i=_(n,1).concat(i)),o&&(i=i.concat(_(o,-1)))),i}(i,t)).length&&this.splitTile(i,0,0,0),r&&(i.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}function E(e,t,r){return 32*((1<<e)*r+t)+e}return T.prototype.options={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0},T.prototype.splitTile=function(e,t,r,i,n,o,s){for(var a=[e,t,r,i],l=this.options,c=l.debug;a.length;){i=a.pop(),r=a.pop(),t=a.pop(),e=a.pop();var h=1<<t,d=E(t,r,i),p=this.tiles[d];if(!p&&(c>1&&console.time("creation"),p=this.tiles[d]=b(e,t,r,i,l),this.tileCoords.push({z:t,x:r,y:i}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,r,i,p.numFeatures,p.numPoints,p.numSimplified),console.timeEnd("creation"));var f="z"+t;this.stats[f]=(this.stats[f]||0)+1,this.total++}if(p.source=e,n){if(t===l.maxZoom||t===n)continue;var m=1<<n-t;if(r!==Math.floor(o/m)||i!==Math.floor(s/m))continue}else if(t===l.indexMaxZoom||p.numPoints<=l.indexMaxPoints)continue;if(p.source=null,0!==e.length){c>1&&console.time("clipping");var A,g,_,y,x,v,w=.5*l.buffer/l.extent,C=.5-w,T=.5+w,M=1+w;A=g=_=y=null,x=u(e,h,r-w,r+T,0,p.minX,p.maxX,l),v=u(e,h,r+C,r+M,0,p.minX,p.maxX,l),e=null,x&&(A=u(x,h,i-w,i+T,1,p.minY,p.maxY,l),g=u(x,h,i+C,i+M,1,p.minY,p.maxY,l),x=null),v&&(_=u(v,h,i-w,i+T,1,p.minY,p.maxY,l),y=u(v,h,i+C,i+M,1,p.minY,p.maxY,l),v=null),c>1&&console.timeEnd("clipping"),a.push(A||[],t+1,2*r,2*i),a.push(g||[],t+1,2*r,2*i+1),a.push(_||[],t+1,2*r+1,2*i),a.push(y||[],t+1,2*r+1,2*i+1)}}},T.prototype.getTile=function(e,t,r){var i=this.options,n=i.extent,o=i.debug;if(e<0||e>24)return null;var s=1<<e,a=E(e,t=(t%s+s)%s,r);if(this.tiles[a])return x(this.tiles[a],n);o>1&&console.log("drilling down to z%d-%d-%d",e,t,r);for(var l,c=e,u=t,h=r;!l&&c>0;)c--,u=Math.floor(u/2),h=Math.floor(h/2),l=this.tiles[E(c,u,h)];return l&&l.source?(o>1&&console.log("found parent tile z%d-%d-%d",c,u,h),o>1&&console.time("drilling down"),this.splitTile(l.source,c,u,h,e,t,r),o>1&&console.timeEnd("drilling down"),this.tiles[a]?x(this.tiles[a],n):null):null},function(e,t){return new T(e,t)}}();var Z=e.dX(G.exports);function W(e,t){const r=e.tileID.canonical;if(!this._geoJSONIndex)return t(null,null);const i=this._geoJSONIndex.getTile(r.z,r.x,r.y);if(!i)return t(null,null);const n=new f(i.features);let o=D(n);0===o.byteOffset&&o.byteLength===o.buffer.byteLength||(o=new Uint8Array(o)),t(null,{vectorTile:n,rawData:o.buffer})}class Q extends c{constructor(e,t,r,i,n,o){super(e,t,r,i,W,o),n&&(this.loadGeoJSON=n),this._featureMap=new Map}loadData(r,i){const n=r&&r.request,o=n&&n.collectResourceTiming;this.loadGeoJSON(r,((s,a)=>{if(s||!a)return i(s);if("object"!=typeof a)return i(new Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`));{try{if(r.filter){const t=e.t(r.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===t.result)throw new Error(t.value.map((e=>`${e.key}: ${e.message}`)).join(", "));a.features=a.features.filter((e=>t.value.evaluate({zoom:0},e)))}if(r.dynamic){"Feature"===a.type&&(a={type:"FeatureCollection",features:[a]}),r.append||this._featureMap.clear();for(const e of a.features||[]){const t=e.id;void 0!==t&&(e.geometry?this._featureMap.set(t,e):this._featureMap.delete(t))}a.features=[...this._featureMap.values()]}this._geoJSONIndex=r.cluster?new F(function({superclusterOptions:t,clusterProperties:r}){if(!r||!t)return t;const i={},n={},o={accumulated:null,zoom:0},s={properties:null},a=Object.keys(r);for(const t of a){const[o,s]=r[t],a=e.t(s),l=e.t("string"==typeof o?[o,["accumulated"],["get",t]]:o);i[t]=a.value,n[t]=l.value}return t.map=e=>{s.properties=e;const t={};for(const e of a)t[e]=i[e].evaluate(o,s);return t},t.reduce=(e,t)=>{s.properties=t;for(const t of a)o.accumulated=e[t],e[t]=n[t].evaluate(o,s)},t}(r)).load(a.features):Z(a,r.geojsonVtOptions)}catch(s){return i(s)}this.loaded={};const l={};if(o){const e=t(n);e&&(l.resourceTiming={},l.resourceTiming[r.source]=JSON.parse(JSON.stringify(e)))}i(null,l)}}))}reloadTile(e,t){const r=this.loaded;return r&&r[e.uid]?super.reloadTile(e,t):this.loadTile(e,t)}loadGeoJSON(t,r){if(t.request)e.g(t.request,r);else{if("string"!=typeof t.data)return r(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));try{return r(null,JSON.parse(t.data))}catch(e){return r(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(e,t){try{t(null,this._geoJSONIndex.getClusterExpansionZoom(e.clusterId))}catch(e){t(e)}}getClusterChildren(e,t){try{t(null,this._geoJSONIndex.getChildren(e.clusterId))}catch(e){t(e)}}getClusterLeaves(e,t){try{t(null,this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset))}catch(e){t(e)}}}class q{constructor(t,r){this.tileID=new e.ap(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.tileZoom=t.tileZoom,this.uid=t.uid,this.zoom=t.zoom,this.canonical=t.tileID.canonical,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.overscaling=this.tileID.overscaleFactor(),this.projection=t.projection,this.brightness=r}parse(t,r,i,n){this.status="parsing";const o=new e.ap(i.tileID.overscaledZ,i.tileID.wrap,i.tileID.canonical.z,i.tileID.canonical.x,i.tileID.canonical.y),s={},a=r.familiesBySource[i.source],l=new e.dL(o,i.promoteId);return l.bucketLayerIDs=[],l.is3DTile=!0,e.dY(t).then((t=>{if(!t)return n(new Error("Could not parse tile"));const r=e.dZ(t,1/e.bU(i.tileID.canonical)),c=t.json.extensionsUsed&&t.json.extensionsUsed.includes("MAPBOX_mesh_features")||t.json.asset.extras&&t.json.asset.extras.MAPBOX_mesh_features,u=t.json.extensionsUsed&&t.json.extensionsUsed.includes("EXT_meshopt_compression"),h=new e.N(this.zoom,{brightness:this.brightness});for(const t in a)for(const i of a[t]){const t=i[0];l.bucketLayerIDs.push(i.map((e=>e.id))),t.recalculate(h,[]);const n=new e.d_(r,o,c,u,this.brightness,l);c||(n.needsUpload=!0),s[t.fqid]=n,n.evaluate(t)}this.status="done",n(null,{buckets:s,featureIndex:l})})).catch((e=>n(new Error(e.message))))}}class X{constructor(e,t,r,i,n,o){this.actor=e,this.layerIndex=t,this.brightness=o,this.loading={},this.loaded={}}loadTile(t,r){const i=t.uid,n=this.loading[i]=new q(t,this.brightness);e.b1(t.request,((e,o)=>{const s=!this.loading[i];return delete this.loading[i],s||e?(n.status="done",s||(this.loaded[i]=n),r(e)):o&&0!==o.byteLength?void n.parse(o,this.layerIndex,t,((e,t)=>{n.status="done",this.loaded=this.loaded||{},this.loaded[i]=n,e||!t?r(e):r(null,t)})):(n.status="done",this.loaded[i]=n,r())}))}reloadTile(e,t){const r=this.loaded,i=e.uid;if(r&&r[i]){const n=r[i];n.projection=e.projection,n.brightness=e.brightness;const o=(r,i)=>{n.reloadCallback&&(delete n.reloadCallback,this.loadTile(e,t)),t(r,i)};"parsing"===n.status?n.reloadCallback=o:"done"===n.status&&this.loadTile(e,t)}}abortTile(e,t){const r=e.uid;this.loading[r]&&delete this.loading[r],t()}removeTile(e,t){const r=this.loaded,i=e.uid;r&&r[i]&&delete r[i],t()}}class Y{constructor(t){this.self=t,this.actor=new e.d$(t,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=e.br({name:"mercator"}),this.workerSourceTypes={vector:c,geojson:Q,"batched-model":X},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(e,t)=>{if(this.workerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.workerSourceTypes[e]=t},this.self.registerRTLTextPlugin=t=>{if(e.e0.isParsed())throw new Error("RTL text plugin already registered.");e.e0.applyArabicShaping=t.applyArabicShaping,e.e0.processBidirectionalText=t.processBidirectionalText,e.e0.processStyledBidirectionalText=t.processStyledBidirectionalText}}clearCaches(e,t,r){delete this.layerIndexes[e],delete this.availableImages[e],delete this.workerSources[e],delete this.demWorkerSources[e],delete this.rasterArrayWorkerSource,r()}checkIfReady(e,t,r){r()}setReferrer(e,t){this.referrer=t}spriteLoaded(t,{scope:r,isLoaded:i}){if(this.isSpriteLoaded[t]||(this.isSpriteLoaded[t]={}),this.isSpriteLoaded[t][r]=i,this.workerSources[t]&&this.workerSources[t][r])for(const n in this.workerSources[t][r]){const o=this.workerSources[t][r][n];for(const t in o)o[t]instanceof c&&(o[t].isSpriteLoaded=i,o[t].fire(new e.b("isSpriteLoaded")))}}setImages(e,{scope:t,images:r},i){if(this.availableImages[e]||(this.availableImages[e]={}),this.availableImages[e][t]=r,this.workerSources[e]&&this.workerSources[e][t]){for(const i in this.workerSources[e][t]){const n=this.workerSources[e][t][i];for(const e in n)n[e].availableImages=r}i()}else i()}setProjection(t,r){this.projections[t]=e.br(r)}setBrightness(e,t,r){this.brightness=t,r()}setLayers(e,t,r){this.getLayerIndex(e,t.scope).replace(t.layers,t.options),r()}updateLayers(e,t,r){this.getLayerIndex(e,t.scope).update(t.layers,t.removedIds,t.options),r()}loadTile(e,t,r){t.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t.type,t.source,t.scope).loadTile(t,r)}loadDEMTile(e,t,r){this.getDEMWorkerSource(e,t.source,t.scope).loadTile(t,r)}decodeRasterArray(e,t,r){this.getRasterArrayWorkerSource().decodeRasterArray(t,r)}reloadTile(e,t,r){t.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t.type,t.source,t.scope).reloadTile(t,r)}abortTile(e,t,r){this.getWorkerSource(e,t.type,t.source,t.scope).abortTile(t,r)}removeTile(e,t,r){this.getWorkerSource(e,t.type,t.source,t.scope).removeTile(t,r)}removeSource(e,t,r){if(!(this.workerSources[e]&&this.workerSources[e][t.scope]&&this.workerSources[e][t.scope][t.type]&&this.workerSources[e][t.scope][t.type][t.source]))return;const i=this.workerSources[e][t.scope][t.type][t.source];delete this.workerSources[e][t.scope][t.type][t.source],void 0!==i.removeSource?i.removeSource(t,r):r()}loadWorkerSource(e,t,r){try{this.self.importScripts(t.url),r()}catch(e){r(e.toString())}}syncRTLPluginState(t,r,i){try{e.e0.setState(r);const t=e.e0.getPluginURL();if(e.e0.isLoaded()&&!e.e0.isParsed()&&null!=t){this.self.importScripts(t);const r=e.e0.isParsed();i(r?void 0:new Error(`RTL Text Plugin failed to import scripts from ${t}`),r)}}catch(e){i(e.toString())}}setDracoUrl(e,t){this.dracoUrl=t}getAvailableImages(e,t){this.availableImages[e]||(this.availableImages[e]={});let r=this.availableImages[e][t];return r||(r=[]),r}getLayerIndex(e,t){this.layerIndexes[e]||(this.layerIndexes[e]={});let r=this.layerIndexes[e][t];return r||(r=this.layerIndexes[e][t]=new n,r.scope=t),r}getWorkerSource(e,t,r,i){if(this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][i]||(this.workerSources[e][i]={}),this.workerSources[e][i][t]||(this.workerSources[e][i][t]={}),this.isSpriteLoaded[e]||(this.isSpriteLoaded[e]={}),!this.workerSources[e][i][t][r]){const n={send:(t,r,i,n,o,s)=>{this.actor.send(t,r,i,e,o,s)},scheduler:this.actor.scheduler};this.workerSources[e][i][t][r]=new this.workerSourceTypes[t](n,this.getLayerIndex(e,i),this.getAvailableImages(e,i),this.isSpriteLoaded[e][i],void 0,this.brightness)}return this.workerSources[e][i][t][r]}getDEMWorkerSource(e,t,r){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][r]||(this.demWorkerSources[e][r]={}),this.demWorkerSources[e][r][t]||(this.demWorkerSources[e][r][t]=new u),this.demWorkerSources[e][r][t]}getRasterArrayWorkerSource(){return this.rasterArrayWorkerSource||(this.rasterArrayWorkerSource=new h),this.rasterArrayWorkerSource}enforceCacheSizeLimit(t,r){e.e1(r)}getWorkerPerformanceMetrics(e,t,r){r(void 0,void 0)}}return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new Y(self)),Y})),i(["./shared"],(function(e){function t(e,r){if(Array.isArray(e)){if(!Array.isArray(r)||e.length!==r.length)return!1;for(let i=0;i<e.length;i++)if(!t(e[i],r[i]))return!1;return!0}if("object"==typeof e&&null!==e&&null!==r){if("object"!=typeof r)return!1;if(Object.keys(e).length!==Object.keys(r).length)return!1;for(const i in e)if(!t(e[i],r[i]))return!1;return!0}return e===r}var r=i;function i(e){return!function(e){return"undefined"==typeof window||"undefined"==typeof document?"not a browser":function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var e,t,r=new Blob([""],{type:"text/javascript"}),i=URL.createObjectURL(r);try{t=new Worker(i),e=!0}catch(t){e=!1}return t&&t.terminate(),URL.revokeObjectURL(i),e}()?function(){var e=document.createElement("canvas");e.width=e.height=1;var t=e.getContext("2d");if(!t)return!1;var r=t.getImageData(0,0,1,1);return r&&r.width===e.width}()?(void 0===n[t=e&&e.failIfMajorPerformanceCaveat]&&(n[t]=function(e){var t,r=function(e){var t=document.createElement("canvas"),r=Object.create(i.webGLContextAttributes);return r.failIfMajorPerformanceCaveat=e,t.getContext("webgl2",r)}(e);if(!r)return!1;try{t=r.createShader(r.VERTEX_SHADER)}catch(e){return!1}return!(!t||r.isContextLost())&&(r.shaderSource(t,"void main() {}"),r.compileShader(t),!0===r.getShaderParameter(t,r.COMPILE_STATUS))}(t)),n[t]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL2 support"):"insufficient Canvas/getImageData support":"insufficient worker support";var t}(e)}var n={};function o(e,t,r){const i=document.createElement(e);return null!=t&&(i.className=t),r&&r.appendChild(i),i}function s(e,t,r){const i=document.createElementNS("http://www.w3.org/2000/svg",e);for(const e of Object.keys(t))i.setAttributeNS(null,e,String(t[e]));return r&&r.appendChild(i),i}i.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0};const a="undefined"!=typeof document?document.documentElement&&document.documentElement.style:null,l=a&&void 0!==a.userSelect?"userSelect":"WebkitUserSelect";let c;function u(){a&&l&&(c=a[l],a[l]="none")}function h(){a&&l&&(a[l]=c)}function d(e){e.preventDefault(),e.stopPropagation(),window.removeEventListener("click",d,!0)}function p(){window.addEventListener("click",d,!0),window.setTimeout((()=>{window.removeEventListener("click",d,!0)}),0)}function f(e,t){const r=e.getBoundingClientRect();return g(e,r,t)}function m(e,t){const r=e.getBoundingClientRect(),i=[];for(let n=0;n<t.length;n++)i.push(g(e,r,t[n]));return i}function A(e){return void 0!==window.InstallTrigger&&2===e.button&&e.ctrlKey&&window.navigator.platform.toUpperCase().indexOf("MAC")>=0?0:e.button}function g(t,r,i){const n=t.offsetWidth===r.width?1:t.offsetWidth/r.width;return new e.P((i.clientX-r.left)*n,(i.clientY-r.top)*n)}class _{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(e,t){this._updatedSourceCaches[e]=t,this.setDirty()}discardSourceCacheUpdate(e){delete this._updatedSourceCaches[e]}updateLayer(e){const t=e.scope;this._updatedLayers[t]=this._updatedLayers[t]||new Set,this._updatedLayers[t].add(e.id),this.setDirty()}removeLayer(e){const t=e.scope;this._removedLayers[t]=this._removedLayers[t]||{},this._updatedLayers[t]=this._updatedLayers[t]||new Set,this._removedLayers[t][e.id]=e,this._updatedLayers[t].delete(e.id),this._updatedPaintProps.delete(e.fqid),this.setDirty()}getRemovedLayer(e){return this._removedLayers[e.scope]?this._removedLayers[e.scope][e.id]:null}discardLayerRemoval(e){this._removedLayers[e.scope]&&delete this._removedLayers[e.scope][e.id]}getLayerUpdatesByScope(){const e={};for(const t in this._updatedLayers)e[t]=e[t]||{},e[t].updatedIds=Array.from(this._updatedLayers[t].values());for(const t in this._removedLayers)e[t]=e[t]||{},e[t].removedIds=Object.keys(this._removedLayers[t]);return e}getUpdatedPaintProperties(){return this._updatedPaintProps}updatePaintProperties(e){this._updatedPaintProps.add(e.fqid),this.setDirty()}getUpdatedImages(){return Array.from(this._updatedImages.values())}updateImage(e){this._updatedImages.add(e),this.setDirty()}resetUpdatedImages(){this._updatedImages.clear()}reset(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps.clear(),this._updatedImages.clear()}}class y extends e.E{constructor(e){super(),this.requestManager=e,this.models={"":{}},this.numModelsLoading={}}loadModel(t,r){return e.l(this.requestManager.transformRequest(r,e.R.Model).url).then((r=>{if(!r)return;const i=e.c(r),n=new e.M(t,void 0,void 0,i);return n.computeBoundsAndApplyParent(),n})).catch((i=>{if(i&&404===i.status)return null;this.fire(new e.a(new Error(`Could not load model ${t} from ${r}: ${i.message}`)))}))}load(t,r){this.models[r]||(this.models[r]={});const i=Object.keys(t);this.numModelsLoading[r]=(this.numModelsLoading[r]||0)+i.length;const n=[];for(const e of i)n.push(this.loadModel(e,t[e]));Promise.allSettled(n).then((t=>{for(let e=0;e<t.length;e++){const{status:n,value:o}=t[e];"fulfilled"===n&&o&&(this.models[r][i[e]]={model:o,numReferences:1})}this.numModelsLoading[r]-=i.length,this.fire(new e.b("data",{dataType:"style"}))})).catch((t=>{this.fire(new e.a(new Error(`Could not load models: ${t.message}`)))}))}isLoaded(){for(const e in this.numModelsLoading)if(this.numModelsLoading[e]>0)return!1;return!0}hasModel(e,t){return!!this.getModel(e,t)}getModel(e,t){return this.models[t]||(this.models[t]={}),this.models[t][e]?this.models[t][e].model:void 0}addModel(e,t,r){this.models[r]||(this.models[r]={}),this.hasModel(e,r)&&this.models[r][e].numReferences++,this.load({[e]:this.requestManager.normalizeModelURL(t)},r)}addModels(e,t){this.models[t]||(this.models[t]={});const r={};for(const i in e)this.models[t][i]={},r[i]=this.requestManager.normalizeModelURL(e[i]);this.load(r,t)}addModelsFromBucket(e,t){this.models[t]||(this.models[t]={});const r={};for(const i of e)this.hasModel(i,t)?this.models[t][i].numReferences++:r[i]=this.requestManager.normalizeModelURL(i);this.load(r,t)}removeModel(e,t){if(this.models[t]&&this.models[t][e]&&(this.models[t][e].numReferences--,0===this.models[t][e].numReferences)){const r=this.models[t][e].model;delete this.models[t][e],r.destroy()}}listModels(e){return this.models[e]||(this.models[e]={}),Object.keys(this.models[e])}upload(e,t){this.models[t]||(this.models[t]={});for(const r in this.models[t])this.models[t][r].model&&this.models[t][r].model.upload(e.context)}}class x{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,r,i){const n=String(r);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][n]=this.stateChanges[t][n]||{},e.e(this.stateChanges[t][n],i),null===this.deletedStates[t]){this.deletedStates[t]={};for(const e in this.state[t])e!==n&&(this.deletedStates[t][e]=null)}else if(this.deletedStates[t]&&null===this.deletedStates[t][n]){this.deletedStates[t][n]={};for(const e in this.state[t][n])i[e]||(this.deletedStates[t][n][e]=null)}else for(const e in i)this.deletedStates[t]&&this.deletedStates[t][n]&&null===this.deletedStates[t][n][e]&&delete this.deletedStates[t][n][e]}removeFeatureState(e,t,r){if(null===this.deletedStates[e])return;const i=String(t);if(this.deletedStates[e]=this.deletedStates[e]||{},r&&void 0!==t)null!==this.deletedStates[e][i]&&(this.deletedStates[e][i]=this.deletedStates[e][i]||{},this.deletedStates[e][i][r]=null);else if(void 0!==t)if(this.stateChanges[e]&&this.stateChanges[e][i])for(r in this.deletedStates[e][i]={},this.stateChanges[e][i])this.deletedStates[e][i][r]=null;else this.deletedStates[e][i]=null;else this.deletedStates[e]=null}getState(t,r){const i=String(r),n=e.e({},(this.state[t]||{})[i],(this.stateChanges[t]||{})[i]);if(null===this.deletedStates[t])return{};if(this.deletedStates[t]){const e=this.deletedStates[t][r];if(null===e)return{};for(const t in e)delete n[t]}return n}initializeTileState(e,t){e.setFeatureState(this.state,t)}coalesceChanges(t,r){const i={};for(const t in this.stateChanges){this.state[t]=this.state[t]||{};const r={};for(const i in this.stateChanges[t])this.state[t][i]||(this.state[t][i]={}),e.e(this.state[t][i],this.stateChanges[t][i]),r[i]=this.state[t][i];i[t]=r}for(const t in this.deletedStates){this.state[t]=this.state[t]||{};const r={};if(null===this.deletedStates[t])for(const e in this.state[t])r[e]={},this.state[t][e]={};else for(const e in this.deletedStates[t]){if(null===this.deletedStates[t][e])this.state[t][e]={};else if(this.state[t][e])for(const r of Object.keys(this.deletedStates[t][e]))delete this.state[t][e][r];r[e]=this.state[t][e]}i[t]=i[t]||{},e.e(i[t],r)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(i).length)for(const e in t)t[e].setFeatureState(i,r)}}function v(e){const{userImage:t}=e;return!!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}class b extends e.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 e.h({width:1,height:1})}isLoaded(){for(const e in this.loaded)if(!this.loaded[e])return!1;return!0}setLoaded(e,t){if(this.loaded[t]!==e&&(this.loaded[t]=e,e)){for(const{ids:e,callback:r}of this.requestors)this._notify(e,t,r);this.requestors=[]}}hasImage(e,t){return!!this.getImage(e,t)}getImage(e,t){return this.images[t][e]}addImage(e,t,r){this._validate(e,r)&&(this.images[t][e]=r)}_validate(t,r){let i=!0;return this._validateStretch(r.stretchX,r.data&&r.data.width)||(this.fire(new e.a(new Error(`Image "${t}" has invalid "stretchX" value`))),i=!1),this._validateStretch(r.stretchY,r.data&&r.data.height)||(this.fire(new e.a(new Error(`Image "${t}" has invalid "stretchY" value`))),i=!1),this._validateContent(r.content,r)||(this.fire(new e.a(new Error(`Image "${t}" has invalid "content" value`))),i=!1),i}_validateStretch(e,t){if(!e)return!0;let r=0;for(const i of e){if(i[0]<r||i[1]<i[0]||t<i[1])return!1;r=i[1]}return!0}_validateContent(e,t){return!(e&&(4!==e.length||e[0]<0||t.data.width<e[0]||e[1]<0||t.data.height<e[1]||e[2]<0||t.data.width<e[2]||e[3]<0||t.data.height<e[3]||e[2]<e[0]||e[3]<e[1]))}updateImage(e,t,r){r.version=this.images[t][e].version+1,this.images[t][e]=r,this.updatedImages[t][e]=!0}removeImage(e,t){const r=this.images[t][e];delete this.images[t][e],delete this.patterns[t][e],r.userImage&&r.userImage.onRemove&&r.userImage.onRemove()}listImages(e){return Object.keys(this.images[e])}getImages(e,t,r){let i=!0;const n=!!this.loaded[t];if(!n)for(const r of e)this.images[t][r]||(i=!1);n||i?this._notify(e,t,r):this.requestors.push({ids:e,scope:t,callback:r})}getUpdatedImages(e){return this.updatedImages[e]}_notify(t,r,i){const n={};for(const i of t){this.images[r][i]||this.fire(new e.b("styleimagemissing",{id:i}));const t=this.images[r][i];t?n[i]={data:t.data.clone(),pixelRatio:t.pixelRatio,sdf:t.sdf,version:t.version,stretchX:t.stretchX,stretchY:t.stretchY,content:t.content,hasRenderCallback:Boolean(t.userImage&&t.userImage.render)}:e.w(`Image "${i}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`)}i(null,n)}getPixelSize(e){const{width:t,height:r}=this.atlasImage[e];return{width:t,height:r}}getPattern(t,r){const i=this.patterns[r][t],n=this.getImage(t,r);if(!n)return null;if(i&&i.position.version===n.version)return i.position;if(i)i.position.version=n.version;else{const i={w:n.data.width+2,h:n.data.height+2,x:0,y:0},o=new e.I(i,n);this.patterns[r][t]={bin:i,position:o}}return this._updatePatternAtlas(r),this.patterns[r][t].position}bind(t,r){const i=t.gl;let n=this.atlasTexture[r];n?this.dirty&&(n.update(this.atlasImage[r]),this.dirty=!1):(n=new e.T(t,this.atlasImage[r],i.RGBA),this.atlasTexture[r]=n),n.bind(i.LINEAR,i.CLAMP_TO_EDGE)}_updatePatternAtlas(t){const r=[];for(const e in this.patterns[t])r.push(this.patterns[t][e].bin);const{w:i,h:n}=e.p(r),o=this.atlasImage[t];o.resize({width:i||1,height:n||1});for(const r in this.patterns[t]){const{bin:i}=this.patterns[t][r],n=i.x+1,s=i.y+1,a=this.images[t][r].data,l=a.width,c=a.height;e.h.copy(a,o,{x:0,y:0},{x:n,y:s},{width:l,height:c}),e.h.copy(a,o,{x:0,y:c-1},{x:n,y:s-1},{width:l,height:1}),e.h.copy(a,o,{x:0,y:0},{x:n,y:s+c},{width:l,height:1}),e.h.copy(a,o,{x:l-1,y:0},{x:n-1,y:s},{width:1,height:c}),e.h.copy(a,o,{x:0,y:0},{x:n+l,y:s},{width:1,height:c})}this.dirty=!0}beginFrame(){for(const e in this.images)this.callbackDispatchedThisFrame[e]={}}dispatchRenderCallbacks(e,t){for(const r of e){if(this.callbackDispatchedThisFrame[t][r])continue;this.callbackDispatchedThisFrame[t][r]=!0;const e=this.images[t][r];v(e)&&this.updateImage(r,t,e)}}}function w(t){const r=t.key,i=t.value,n=t.valueSpec||{},o=t.objectElementValidators||{},s=t.style,a=t.styleSpec;let l=[];const c=e.j(i);if("object"!==c)return[new e.V(r,i,`object expected, ${c} found`)];for(const t in i){const c=t.split(".")[0];let u;o[c]?u=o[c]:n[c]?u=Z:o["*"]?u=o["*"]:n["*"]&&(u=Z),u?l=l.concat(u({key:(r?`${r}.`:r)+t,value:i[t],valueSpec:n[c]||n["*"],style:s,styleSpec:a,object:i,objectKey:t},i)):l.push(new e.i(r,i[t],`unknown property "${t}"`))}for(const t in n)o[t]||n[t].required&&void 0===n[t].default&&void 0===i[t]&&l.push(new e.V(r,i,`missing required property "${t}"`));return l}function C(t){const r=t.value,i=t.valueSpec,n=t.style,o=t.styleSpec,s=t.key,a=t.arrayElementValidator||Z;if("array"!==e.j(r))return[new e.V(s,r,`array expected, ${e.j(r)} found`)];if(i.length&&r.length!==i.length)return[new e.V(s,r,`array length ${i.length} expected, length ${r.length} found`)];if(i["min-length"]&&r.length<i["min-length"])return[new e.V(s,r,`array length at least ${i["min-length"]} expected, length ${r.length} found`)];let l={type:i.value,values:i.values,minimum:i.minimum,maximum:i.maximum,function:void 0};o.$version<7&&(l.function=i.function),"object"===e.j(i.value)&&(l=i.value);let c=[];for(let e=0;e<r.length;e++)c=c.concat(a({array:r,arrayIndex:e,value:r[e],valueSpec:l,style:n,styleSpec:o,key:`${s}[${e}]`},!0));return c}function T(t){const r=t.key,i=t.value,n=t.valueSpec;let o=e.j(i);if("number"===o&&i!=i&&(o="NaN"),"number"!==o)return[new e.V(r,i,`number expected, ${o} found`)];if("minimum"in n){let o=n.minimum;if("array"===e.j(n.minimum)&&(o=n.minimum[t.arrayIndex]),i<o)return[new e.V(r,i,`${i} is less than the minimum value ${o}`)]}if("maximum"in n){let o=n.maximum;if("array"===e.j(n.maximum)&&(o=n.maximum[t.arrayIndex]),i>o)return[new e.V(r,i,`${i} is greater than the maximum value ${o}`)]}return[]}function E(t){const r=t.valueSpec,i=e.u(t.value.type);let n,o,s,a={};const l="categorical"!==i&&void 0===t.value.property,c=!l,u="array"===e.j(t.value.stops)&&"array"===e.j(t.value.stops[0])&&"object"===e.j(t.value.stops[0][0]),h=w({key:t.key,value:t.value,valueSpec:t.styleSpec.function,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===i)return[new e.V(t.key,t.value,'identity function may not have a "stops" property')];let r=[];const n=t.value;return r=r.concat(C({key:t.key,value:n,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:d})),"array"===e.j(n)&&0===n.length&&r.push(new e.V(t.key,n,"array must have at least one stop")),r},default:function(e){return Z({key:e.key,value:e.value,valueSpec:r,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===i&&l&&h.push(new e.V(t.key,t.value,'missing required property "property"')),"identity"===i||t.value.stops||h.push(new e.V(t.key,t.value,'missing required property "stops"')),"exponential"===i&&t.valueSpec.expression&&!e.s(t.valueSpec)&&h.push(new e.V(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(c&&!e.m(t.valueSpec)?h.push(new e.V(t.key,t.value,"property functions not supported")):l&&!e.n(t.valueSpec)&&h.push(new e.V(t.key,t.value,"zoom functions not supported"))),"categorical"!==i&&!u||void 0!==t.value.property||h.push(new e.V(t.key,t.value,'"property" property is required')),h;function d(t){let i=[];const n=t.value,l=t.key;if("array"!==e.j(n))return[new e.V(l,n,`array expected, ${e.j(n)} found`)];if(2!==n.length)return[new e.V(l,n,`array length 2 expected, length ${n.length} found`)];if(u){if("object"!==e.j(n[0]))return[new e.V(l,n,`object expected, ${e.j(n[0])} found`)];if(void 0===n[0].zoom)return[new e.V(l,n,"object stop key must have zoom")];if(void 0===n[0].value)return[new e.V(l,n,"object stop key must have value")];const r=e.u(n[0].zoom);if("number"!=typeof r)return[new e.V(l,n[0].zoom,"stop zoom values must be numbers")];if(s&&s>r)return[new e.V(l,n[0].zoom,"stop zoom values must appear in ascending order")];r!==s&&(s=r,o=void 0,a={}),i=i.concat(w({key:`${l}[0]`,value:n[0],valueSpec:{zoom:{}},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:T,value:p}}))}else i=i.concat(p({key:`${l}[0]`,value:n[0],valueSpec:{},style:t.style,styleSpec:t.styleSpec},n));return e.o(e.q(n[1]))?i.concat([new e.V(`${l}[1]`,n[1],"expressions are not allowed in function stops.")]):i.concat(Z({key:`${l}[1]`,value:n[1],valueSpec:r,style:t.style,styleSpec:t.styleSpec}))}function p(t,s){const l=e.j(t.value),c=e.u(t.value),u=null!==t.value?t.value:s;if(n){if(l!==n)return[new e.V(t.key,u,`${l} stop domain type must match previous stop domain type ${n}`)]}else n=l;if("number"!==l&&"string"!==l&&"boolean"!==l&&"number"!=typeof c&&"string"!=typeof c&&"boolean"!=typeof c)return[new e.V(t.key,u,"stop domain value must be a number, string, or boolean")];if("number"!==l&&"categorical"!==i){let n=`number expected, ${l} found`;return e.m(r)&&void 0===i&&(n+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new e.V(t.key,u,n)]}return"categorical"!==i||"number"!==l||"number"==typeof c&&isFinite(c)&&Math.floor(c)===c?"categorical"!==i&&"number"===l&&"number"==typeof c&&"number"==typeof o&&void 0!==o&&c<o?[new e.V(t.key,u,"stop domain values must appear in ascending order")]:(o=c,"categorical"===i&&c in a?[new e.V(t.key,u,"stop domain values must be unique")]:(a[c]=!0,[])):[new e.V(t.key,u,`integer expected, found ${String(c)}`)]}}function M(t){const r=("property"===t.expressionContext?e.r:e.t)(e.q(t.value),t.valueSpec);if("error"===r.result)return r.value.map((r=>new e.V(`${t.key}${r.key}`,t.value,r.message)));const i=r.value.expression||r.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!i.outputDefined())return[new e.V(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===t.expressionContext&&"layout"===t.propertyType&&!e.v(i))return[new e.V(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext)return S(i,t);if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!e.x(i,["zoom","feature-state"]))return[new e.V(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!e.y(i))return[new e.V(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function S(t,r){const i=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(r.valueSpec&&r.valueSpec.expression)for(const e of r.valueSpec.expression.parameters)i.delete(e);if(0===i.size)return[];const n=[];return t instanceof e.C&&i.has(t.name)?[new e.V(r.key,r.value,`["${t.name}"] expression is not supported in a filter for a ${r.object.type} layer with id: ${r.object.id}`)]:(t.eachChild((e=>{n.push(...S(e,r))})),n)}function I(t){const r=t.key,i=t.value,n=t.valueSpec,o=[];return Array.isArray(n.values)?-1===n.values.indexOf(e.u(i))&&o.push(new e.V(r,i,`expected one of [${n.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(n.values).indexOf(e.u(i))&&o.push(new e.V(r,i,`expected one of [${Object.keys(n.values).join(", ")}], ${JSON.stringify(i)} found`)),o}function P(t){return e.A(e.q(t.value))?M(e.k({},t,{expressionContext:"filter",valueSpec:t.styleSpec[`filter_${t.layerType||"fill"}`]})):D(t)}function D(t){const r=t.value,i=t.key;if("array"!==e.j(r))return[new e.V(i,r,`array expected, ${e.j(r)} found`)];const n=t.styleSpec;let o,s=[];if(r.length<1)return[new e.V(i,r,"filter array must have at least 1 element")];switch(s=s.concat(I({key:`${i}[0]`,value:r[0],valueSpec:n.filter_operator,style:t.style,styleSpec:t.styleSpec})),e.u(r[0])){case"<":case"<=":case">":case">=":r.length>=2&&"$type"===e.u(r[1])&&s.push(new e.V(i,r,`"$type" cannot be use with operator "${r[0]}"`));case"==":case"!=":3!==r.length&&s.push(new e.V(i,r,`filter array for operator "${r[0]}" must have 3 elements`));case"in":case"!in":r.length>=2&&(o=e.j(r[1]),"string"!==o&&s.push(new e.V(`${i}[1]`,r[1],`string expected, ${o} found`)));for(let a=2;a<r.length;a++)o=e.j(r[a]),"$type"===e.u(r[1])?s=s.concat(I({key:`${i}[${a}]`,value:r[a],valueSpec:n.geometry_type,style:t.style,styleSpec:t.styleSpec})):"string"!==o&&"number"!==o&&"boolean"!==o&&s.push(new e.V(`${i}[${a}]`,r[a],`string, number, or boolean expected, ${o} found`));break;case"any":case"all":case"none":for(let e=1;e<r.length;e++)s=s.concat(D({key:`${i}[${e}]`,value:r[e],style:t.style,styleSpec:t.styleSpec}));break;case"has":case"!has":o=e.j(r[1]),2!==r.length?s.push(new e.V(i,r,`filter array for "${r[0]}" operator must have 2 elements`)):"string"!==o&&s.push(new e.V(`${i}[1]`,r[1],`string expected, ${o} found`))}return s}function k(t,r){const i=t.key,n=t.style,o=t.layer,s=t.styleSpec,a=t.value,l=t.objectKey,c=s[`${r}_${t.layerType}`];if(!c)return[];const u=l.match(/^(.*)-transition$/);if("paint"===r&&u&&c[u[1]]&&c[u[1]].transition)return Z({key:i,value:a,valueSpec:s.transition,style:n,styleSpec:s});const h=t.valueSpec||c[l];if(!h)return[new e.i(i,a,`unknown property "${l}"`)];let d;if("string"===e.j(a)&&e.m(h)&&!h.tokens&&(d=/^{([^}]+)}$/.exec(a))){const t=`\`{ "type": "identity", "property": ${d?JSON.stringify(d[1]):'"_"'} }\``;return[new e.V(i,a,`"${l}" does not support interpolation syntax\nUse an identity property function instead: ${t}.`)]}const p=[];if("symbol"===t.layerType)"text-field"!==l||!n||n.glyphs||n.imports||p.push(new e.V(i,a,'use of "text-field" requires a style "glyphs" property')),"text-font"===l&&e.B(e.q(a))&&"identity"===e.u(a.type)&&p.push(new e.V(i,a,'"text-font" does not support identity functions'));else if("model"===t.layerType&&"paint"===r&&o&&o.layout&&o.layout.hasOwnProperty("model-id")&&e.m(h)&&(e.D(h)||e.n(h))){const t=e.r(e.q(a),h),r=t.value.expression||t.value._styleExpression.expression;r&&!e.x(r,["measure-light"])&&("model-emissive-strength"===l&&e.y(r)&&e.v(r)||p.push(new e.V(i,a,`${l} does not support measure-light expressions when the model layer source is vector tile or GeoJSON.`)))}return p.concat(Z({key:t.key,value:a,valueSpec:h,style:n,styleSpec:s,expressionContext:"property",propertyType:r,propertyKey:l}))}function L(e){return k(e,"paint")}function z(e){return k(e,"layout")}function O(t){let r=[];const i=t.value,n=t.key,o=t.style,s=t.styleSpec;i.type||i.ref||r.push(new e.V(n,i,'either "type" or "ref" is required'));let a=e.u(i.type);const l=e.u(i.ref);if(i.id){const s=e.u(i.id);for(let a=0;a<t.arrayIndex;a++){const t=o.layers[a];e.u(t.id)===s&&r.push(new e.V(n,i.id,`duplicate layer id "${i.id}", previously used at line ${t.id.__line__}`))}}if("ref"in i){let t;["type","source","source-layer","filter","layout"].forEach((t=>{t in i&&r.push(new e.V(n,i[t],`"${t}" is prohibited for ref layers`))})),o.layers.forEach((r=>{e.u(r.id)===l&&(t=r)})),t?t.ref?r.push(new e.V(n,i.ref,"ref cannot reference another ref layer")):a=e.u(t.type):"string"==typeof l&&r.push(new e.V(n,i.ref,`ref layer "${l}" not found`))}else if("background"!==a&&"sky"!==a&&"slot"!==a)if(i.source){const t=o.sources&&o.sources[i.source],s=t&&e.u(t.type);t?"vector"===s&&"raster"===a?r.push(new e.V(n,i.source,`layer "${i.id}" requires a raster source`)):"raster"===s&&"raster"!==a?r.push(new e.V(n,i.source,`layer "${i.id}" requires a vector source`)):"vector"!==s||i["source-layer"]?"raster-dem"===s&&"hillshade"!==a?r.push(new e.V(n,i.source,"raster-dem source can only be used with layer type 'hillshade'.")):"raster-array"!==s||["raster","raster-particle"].includes(a)?"line"!==a||!i.paint||!i.paint["line-gradient"]&&!i.paint["line-trim-offset"]||"geojson"===s&&t.lineMetrics?"raster-particle"===a&&"raster-array"!==s&&r.push(new e.V(n,i.source,`layer "${i.id}" requires a 'raster-array' source.`)):r.push(new e.V(n,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):r.push(new e.V(n,i.source,"raster-array source can only be used with layer type 'raster'.")):r.push(new e.V(n,i,`layer "${i.id}" must specify a "source-layer"`)):r.push(new e.V(n,i.source,`source "${i.source}" not found`))}else r.push(new e.V(n,i,'missing required property "source"'));return r=r.concat(w({key:n,value:i,valueSpec:s.layer,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":()=>[],type:()=>Z({key:`${n}.type`,value:i.type,valueSpec:s.layer.type,style:t.style,styleSpec:t.styleSpec,object:i,objectKey:"type"}),filter:t=>P(e.k({layerType:a},t)),layout:t=>w({layer:i,key:t.key,value:t.value,valueSpec:{},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":t=>z(e.k({layerType:a},t))}}),paint:t=>w({layer:i,key:t.key,value:t.value,valueSpec:{},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":t=>L(e.k({layerType:a,layer:i},t))}})}})),r}function B(t){const r=t.value,i=t.key,n=e.j(r);return"string"!==n?[new e.V(i,r,`string expected, ${n} found`)]:[]}const R={promoteId:function({key:t,value:r}){if("string"===e.j(r))return B({key:t,value:r});{const e=[];for(const i in r)e.push(...B({key:`${t}.${i}`,value:r[i]}));return e}}};function F(t){const r=t.value,i=t.key,n=t.styleSpec,o=t.style;if(!r.type)return[new e.V(i,r,'"type" is required')];const s=e.u(r.type);let a=[];switch(["vector","raster","raster-dem","raster-array"].includes(s)&&(r.url||r.tiles||a.push(new e.i(i,r,'Either "url" or "tiles" is required.'))),s){case"vector":case"raster":case"raster-dem":case"raster-array":return a=a.concat(w({key:i,value:r,valueSpec:n[`source_${s.replace("-","_")}`],style:t.style,styleSpec:n,objectElementValidators:R})),a;case"geojson":if(a=w({key:i,value:r,valueSpec:n.source_geojson,style:o,styleSpec:n,objectElementValidators:R}),r.cluster)for(const e in r.clusterProperties){const[t,n]=r.clusterProperties[e],o="string"==typeof t?[t,["accumulated"],["get",e]]:t;a.push(...M({key:`${i}.${e}.map`,value:n,expressionContext:"cluster-map"})),a.push(...M({key:`${i}.${e}.reduce`,value:o,expressionContext:"cluster-reduce"}))}return a;case"video":return w({key:i,value:r,valueSpec:n.source_video,style:o,styleSpec:n});case"image":return w({key:i,value:r,valueSpec:n.source_image,style:o,styleSpec:n});case"canvas":return[new e.V(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return I({key:`${i}.type`,value:r.type,valueSpec:{values:j(n)},style:o,styleSpec:n})}}function j(e){return e.source.reduce(((t,r)=>{const i=e[r];return"enum"===i.type.type&&(t=t.concat(Object.keys(i.type.values))),t}),[])}function V(t){const r=t.value,i=t.styleSpec,n=i.light,o=t.style;let s=[];const a=e.j(r);if(void 0===r)return s;if("object"!==a)return s=s.concat([new e.V("light",r,`object expected, ${a} found`)]),s;for(const t in r){const a=t.match(/^(.*)-transition$/);s=s.concat(a&&n[a[1]]&&n[a[1]].transition?Z({key:t,value:r[t],valueSpec:i.transition,style:o,styleSpec:i}):n[t]?Z({key:t,value:r[t],valueSpec:n[t],style:o,styleSpec:i}):[new e.V(t,r[t],`unknown property "${t}"`)])}return s}function N(t){const r=t.value;let i=[];if(!r)return i;const n=e.j(r);if("object"!==n)return i=i.concat([new e.V("light-3d",r,`object expected, ${n} found`)]),i;const o=t.styleSpec,s=o["light-3d"],a=t.key,l=t.style,c=t.style.lights;for(const t of["type","id"])if(!(t in r))return i=i.concat([new e.V("light-3d",r,`missing property ${t} on light`)]),i;if(r.type&&c)for(let n=0;n<t.arrayIndex;n++){const t=e.u(r.type),o=c[n];e.u(o.type)===t&&i.push(new e.V(a,r.id,`duplicate light type "${r.type}", previously defined at line ${o.id.__line__}`))}const u=`properties_light_${r.type}`;if(!(u in o))return i=i.concat([new e.V("light-3d",r,`Invalid light type ${r.type}`)]),i;const h=o[u];for(const n in r)if("properties"===n){const s=r[n],a=e.j(s);if("object"!==a)return i=i.concat([new e.V("properties",s,`object expected, ${a} found`)]),i;for(const r in s)i=i.concat(h[r]?Z({key:r,value:s[r],valueSpec:h[r],style:l,styleSpec:o}):[new e.i(t.key,s[r],`unknown property "${r}"`)])}else{const t=n.match(/^(.*)-transition$/);i=i.concat(t&&s[t[1]]&&s[t[1]].transition?Z({key:n,value:r[n],valueSpec:o.transition,style:l,styleSpec:o}):s[n]?Z({key:n,value:r[n],valueSpec:s[n],style:l,styleSpec:o}):[new e.i(n,r[n],`unknown property "${n}"`)])}return i}function U(t){const r=t.value,i=t.key,n=t.style,o=t.styleSpec,s=o.terrain;let a=[];const l=e.j(r);if(void 0===r)return a;if("null"===l)return a;if("object"!==l)return a=a.concat([new e.V("terrain",r,`object expected, ${l} found`)]),a;for(const t in r){const i=t.match(/^(.*)-transition$/);a=a.concat(i&&s[i[1]]&&s[i[1]].transition?Z({key:t,value:r[t],valueSpec:o.transition,style:n,styleSpec:o}):s[t]?Z({key:t,value:r[t],valueSpec:s[t],style:n,styleSpec:o}):[new e.i(t,r[t],`unknown property "${t}"`)])}if(r.source){const t=n.sources&&n.sources[r.source],o=t&&e.u(t.type);t?"raster-dem"!==o&&a.push(new e.V(i,r.source,`terrain cannot be used with a source of type ${String(o)}, it only be used with a "raster-dem" source type`)):a.push(new e.V(i,r.source,`source "${r.source}" not found`))}else a.push(new e.V(i,r,'terrain is missing required property "source"'));return a}function H(t){const r=t.value,i=t.style,n=t.styleSpec,o=n.fog;let s=[];const a=e.j(r);if(void 0===r)return s;if("object"!==a)return s=s.concat([new e.V("fog",r,`object expected, ${a} found`)]),s;for(const t in r){const a=t.match(/^(.*)-transition$/);s=s.concat(a&&o[a[1]]&&o[a[1]].transition?Z({key:t,value:r[t],valueSpec:n.transition,style:i,styleSpec:n}):o[t]?Z({key:t,value:r[t],valueSpec:o[t],style:i,styleSpec:n}):[new e.i(t,r[t],`unknown property "${t}"`)])}return s}const G={"*":()=>[],array:C,boolean:function(t){const r=t.value,i=t.key,n=e.j(r);return"boolean"!==n?[new e.V(i,r,`boolean expected, ${n} found`)]:[]},number:T,color:function(t){const r=t.key,i=t.value,n=e.j(i);return"string"!==n?[new e.V(r,i,`color expected, ${n} found`)]:null===e.z(i)?[new e.V(r,i,`color expected, "${i}" found`)]:[]},enum:I,filter:P,function:E,layer:O,object:w,source:F,model:e.F,light:V,"light-3d":N,terrain:U,fog:H,string:B,formatted:function(e){return 0===B(e).length?[]:M(e)},resolvedImage:function(e){return 0===B(e).length?[]:M(e)},projection:function(t){const r=t.value,i=t.styleSpec,n=i.projection,o=t.style;let s=[];const a=e.j(r);if("object"===a)for(const e in r)s=s.concat(Z({key:e,value:r[e],valueSpec:n[e],style:o,styleSpec:i}));else"string"!==a&&(s=s.concat([new e.V("projection",r,`object or string expected, ${a} found`)]));return s},import:function(t){const{value:r,styleSpec:i}=t,{data:n,...o}=r;Object.defineProperty(o,"__line__",{value:r.__line__,enumerable:!1});let s=w(e.k({},t,{value:o,valueSpec:i.import}));return""===e.u(o.id)&&s.push(new e.V(`${t.key}.id`,o,"import id can't be an empty string")),n&&(s=s.concat(Q(n,i,{key:`${t.key}.data`}))),s}};function Z(t,r=!1){const i=t.value,n=t.valueSpec,o=t.styleSpec;if(n.expression&&e.B(e.u(i)))return E(t);if(n.expression&&e.o(e.q(i)))return M(t);if(n.type&&G[n.type]){const i=G[n.type](t);return!0===r&&i.length>0&&"array"===e.j(t.value)?M(t):i}return w(e.k({},t,{valueSpec:n.type?o[n.type]:n}))}function W(t){const r=t.value,i=t.key,n=B(t);return n.length||(-1===r.indexOf("{fontstack}")&&n.push(new e.V(i,r,'"glyphs" url must include a "{fontstack}" token')),-1===r.indexOf("{range}")&&n.push(new e.V(i,r,'"glyphs" url must include a "{range}" token'))),n}function Q(t,r=e.G,i={}){return Z({key:i.key||"",value:t,valueSpec:r.$root,styleSpec:r,style:t,objectElementValidators:{glyphs:W,"*":()=>[]}})}function q(t,r=e.G){return oe(Q(t,r))}const X=e=>oe(F(e)),Y=e=>oe(V(e)),$=e=>oe(N(e)),K=e=>oe(U(e)),J=e=>oe(H(e)),ee=e=>oe(O(e)),te=e=>oe(P(e)),re=e=>oe(L(e)),ie=e=>oe(z(e)),ne=t=>oe(e.F(t));function oe(e){return e.slice().sort(((e,t)=>e.line&&t.line?e.line-t.line:0))}function se(t,r){let i=!1;if(r&&r.length)for(const n of r)n instanceof e.i?e.w(n.message):(t.fire(new e.a(new Error(n.message))),i=!0);return i}const ae=new e.H({anchor:new e.J(e.G.light.anchor),position:new e.K(e.G.light.position),color:new e.J(e.G.light.color),intensity:new e.J(e.G.light.intensity)});class le extends e.E{constructor(t,r="flat"){super(),this._transitionable=new e.L(ae),this.setLight(t,r),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(e,t,r={}){this._validate(Y,e,r)||(this._transitionable.setTransitionOrValue(e),this.id=t)}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(t,r,i){return(!i||!1!==i.validate)&&se(this,t.call(q,e.e({value:r,style:{glyphs:!0,sprite:!0},styleSpec:e.G})))}}const ce=new e.H({source:new e.J(e.G.terrain.source),exaggeration:new e.J(e.G.terrain.exaggeration)});let ue=class extends e.E{constructor(t,r,i,n){super(),this.scope=i,this._transitionable=new e.L(ce,i,n),this._transitionable.setTransitionOrValue(t,n),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=r}get(){return this._transitionable.serialize()}set(e,t){this._transitionable.setTransitionOrValue(e,t)}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}getExaggeration(t){return this._transitioning.possiblyEvaluate(new e.N(t)).get("exaggeration")}isZoomDependent(){const t=this._transitionable._values.exaggeration;return null!=t&&null!=t.value&&null!=t.value.expression&&t.value.expression instanceof e.Z}};const he=45,de=65,pe=.05;function fe(t,r,i,n){const o=e.S(he,de,i),[s,a]=me(t,n);let l=1-Math.min(1,Math.exp((r-s)/(a-s)*-6));return l*=l*l,l=Math.min(1,1.00747*l),l*o*t.alpha}function me(e,t){const r=.5/Math.tan(.5*t);return[e.range[0]+r,e.range[1]+r]}function Ae(t,r,i,n,o){const s=e.Q.transformMat4([],[r,i,n],o.mercatorFogMatrix);return fe(t,e.Q.length(s),o.pitch,o._fov)}function ge(t,r,i,n,o,s,a){const l=[[i,n,0],[o,n,0],[o,s,0],[i,s,0]];let c=Number.MAX_VALUE,u=-Number.MAX_VALUE;for(const t of l){const i=e.Q.transformMat4([],t,r),n=e.Q.length(i);c=Math.min(c,n),u=Math.max(u,n)}return[fe(t,c,a.pitch,a._fov),fe(t,u,a.pitch,a._fov)]}const _e=new e.H({range:new e.J(e.G.fog.range),color:new e.J(e.G.fog.color),"high-color":new e.J(e.G.fog["high-color"]),"space-color":new e.J(e.G.fog["space-color"]),"horizon-blend":new e.J(e.G.fog["horizon-blend"]),"star-intensity":new e.J(e.G.fog["star-intensity"]),"vertical-range":new e.J(e.G.fog["vertical-range"])});class ye extends e.E{constructor(t,r,i,n){super(),this._transitionable=new e.L(_e,i,new Map(n)),this.set(t,n),this._transitioning=this._transitionable.untransitioned(),this._transform=r,this.properties=new e.U(_e)}get state(){const t=this._transform,r="globe"===t.projection.name,i=e.W(t.zoom),n=this.properties.get("range"),o=[.5,3];return{range:r?[e.X(o[0],n[0],i),e.X(o[1],n[1],i)]:n,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(t,r,i={}){if(this._validate(J,t,i))return;const n=e.e({},t);for(const t of Object.keys(e.G.fog))void 0===n[t]&&(n[t]=e.G.fog[t].default);this._options=n,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:e.S(he,de,t))*r.a}getOpacityAtLatLng(t,r){return this._transform.projection.supportsFog?function(t,r,i){const n=e.O.fromLngLat(r),o=i.elevation?i.elevation.getAtPointOrZero(n):0;return Ae(t,n.x,n.y,o,i)}(this.state,t,r):0}getOpacityForTile(t){if(!this._transform.projection.supportsFog)return[1,1];const r=this._transform.calculateFogTileMatrix(t.toUnwrapped());return ge(this.state,r,0,0,e.Y,e.Y,this._transform)}getOpacityForBounds(e,t,r,i,n){return this._transform.projection.supportsFog?ge(this.state,e,t,r,i,n,this._transform):[1,1]}getFovAdjustedRange(e){return this._transform.projection.supportsFog?me(this.state,e):[0,1]}isVisibleOnFrustum(t){if(!this._transform.projection.supportsFog)return!1;const r=[4,5,6,7];for(const i of r){const r=t.points[i];let n;if(r[2]>=0)n=r;else{const o=t.points[i-4];n=e._(o,r,o[2]/(o[2]-r[2]))}if(Ae(this.state,n[0],n[1],0,this._transform)>=pe)return!0}return!1}updateConfig(e){this._transitionable.setTransitionOrValue(this._options,new Map(e))}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(t,r,i){return(!i||!1!==i.validate)&&se(this,t.call(q,e.e({value:r,style:{glyphs:!0,sprite:!0},styleSpec:e.G})))}}class xe extends e.E{constructor(t,r,i,n){super(),this.scope=i,this._options=t,this.properties=new e.U(r),this._transitionable=new e.L(r,i,new Map(n)),this._transitionable.setTransitionOrValue(t.properties),this._transitioning=this._transitionable.untransitioned()}updateConfig(e){this._transitionable.setTransitionOrValue(this._options.properties,new Map(e))}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}get(){return this._options.properties=this._transitionable.serialize(),this._options}set(e,t){this._options=e,this._transitionable.setTransitionOrValue(e.properties,t)}shadowsEnabled(){return!!this.properties&&!0===this.properties.get("cast-shadows")}}const ve=new e.H({color:new e.J(e.G.properties_light_ambient.color),intensity:new e.J(e.G.properties_light_ambient.intensity)}),be=new e.H({direction:new e.$(e.G.properties_light_directional.direction),color:new e.J(e.G.properties_light_directional.color),intensity:new e.J(e.G.properties_light_directional.intensity),"cast-shadows":new e.J(e.G.properties_light_directional["cast-shadows"]),"shadow-intensity":new e.J(e.G.properties_light_directional["shadow-intensity"])});class we{constructor(e,t,r,i){this.screenBounds=e,this.cameraPoint=t,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=r,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,i)}static createFromScreenPoints(t,r){let i,n;if(t instanceof e.P||"number"==typeof t[0]){const o=e.P.convert(t);i=[o],n=r.isPointAboveHorizon(o)}else{const o=e.P.convert(t[0]),s=e.P.convert(t[1]);i=[o,s],n=e.a0(o,s).every((e=>r.isPointAboveHorizon(e)))}return new we(i,r.getCameraPoint(),n,r)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(t){return e.a0(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],t)}bufferedCameraGeometry(t){const r=this.screenBounds[0],i=1===this.screenBounds.length?this.screenBounds[0].add(new e.P(1,1)):this.screenBounds[1],n=e.a0(r,i,0,!1);return this.cameraPoint.y>i.y&&(this.cameraPoint.x>r.x&&this.cameraPoint.x<i.x?n.splice(3,0,this.cameraPoint):this.cameraPoint.x>=i.x?n[2]=this.cameraPoint:this.cameraPoint.x<=r.x&&(n[3]=this.cameraPoint)),e.a1(n,t)}bufferedCameraGeometryGlobe(t){const r=this.screenBounds[0],i=1===this.screenBounds.length?this.screenBounds[0].add(new e.P(1,1)):this.screenBounds[1],n=e.a0(r,i,t),o=this.cameraPoint.clone();switch(3*((o.y>r.y)+(o.y>i.y))+((o.x>r.x)+(o.x>i.x))){case 0:n[0]=o,n[4]=o.clone();break;case 1:n.splice(1,0,o);break;case 2:n[1]=o;break;case 3:n.splice(4,0,o);break;case 5:n.splice(2,0,o);break;case 6:n[3]=o;break;case 7:n.splice(3,0,o);break;case 8:n[2]=o}return n}containsTile(t,r,i,n=0){const o=t.queryPadding/r._pixelsPerMercatorPixel+1,s=i?this._bufferedCameraMercator(o,r):this._bufferedScreenMercator(o,r);let a=t.tileID.wrap+(s.unwrapped?n:0);const l=s.polygon.map((r=>e.a2(t.tileTransform,r,a)));if(!e.a3(l,0,0,e.Y,e.Y))return;a=t.tileID.wrap+(this.screenGeometryMercator.unwrapped?n:0);const c=this.screenGeometryMercator.polygon.map((r=>e.a4(t.tileTransform,r,a))),u=c.map((t=>new e.P(t[0],t[1]))),h=r.getFreeCameraOptions().position||new e.O(0,0,0),d=e.a4(t.tileTransform,h,a),p=c.map((t=>{const r=e.Q.sub(t,t,d);return e.Q.normalize(r,r),new e.a5(d,r)})),f=e.a6(t,1,r.zoom)*r._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:u,tilespaceRays:p,bufferedTilespaceGeometry:l,bufferedTilespaceBounds:(m=e.a7(l),m.min.x=e.ad(m.min.x,0,e.Y),m.min.y=e.ad(m.min.y,0,e.Y),m.max.x=e.ad(m.max.x,0,e.Y),m.max.y=e.ad(m.max.y,0,e.Y),m),tile:t,tileID:t.tileID,pixelToTileUnitsFactor:f};var m}_bufferedScreenMercator(e,t){const r=Ee(e);if(this._screenRaycastCache[r])return this._screenRaycastCache[r];{let i;return i="globe"===t.projection.name?this._projectAndResample(this.bufferedScreenGeometry(e),t):{polygon:this.bufferedScreenGeometry(e).map((e=>t.pointCoordinate3D(e))),unwrapped:!0},this._screenRaycastCache[r]=i,i}}_bufferedCameraMercator(e,t){const r=Ee(e);if(this._cameraRaycastCache[r])return this._cameraRaycastCache[r];{let i;return i="globe"===t.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(e),t):{polygon:this.bufferedCameraGeometry(e).map((e=>t.pointCoordinate3D(e))),unwrapped:!0},this._cameraRaycastCache[r]=i,i}}_projectAndResample(t,r){const i=function(t,r){const i=e.a9.multiply([],r.pixelMatrix,r.globeMatrix),n=[0,-e.ae,0,1],o=[0,e.ae,0,1],s=[0,0,0,1];e.aa.transformMat4(n,n,i),e.aa.transformMat4(o,o,i),e.aa.transformMat4(s,s,i);const a=new e.P(n[0]/n[3],n[1]/n[3]),l=new e.P(o[0]/o[3],o[1]/o[3]),c=e.ab(t,a)&&n[3]<s[3],u=e.ab(t,l)&&o[3]<s[3];if(!c&&!u)return null;const h=function(e,t,r){for(let i=1;i<e.length;i++){const n=Te(t.pointCoordinate3D(e[i-1]).x),o=Te(t.pointCoordinate3D(e[i]).x);if(r<0){if(n<o)return{idx:i,t:-n/(o-1-n)}}else if(o<n)return{idx:i,t:(1-n)/(o+1-n)}}return null}(t,r,c?-1:1);if(!h)return null;const{idx:d,t:p}=h;let f=d>1?Ce(t.slice(0,d),r):[],m=d<t.length?Ce(t.slice(d),r):[];f=f.map((t=>new e.P(Te(t.x),t.y))),m=m.map((t=>new e.P(Te(t.x),t.y)));const A=[...f];0===A.length&&A.push(m[m.length-1]);const g=e.X(A[A.length-1].y,(0===m.length?f[0]:m[0]).y,p);let _;return _=c?[new e.P(0,g),new e.P(0,0),new e.P(1,0),new e.P(1,g)]:[new e.P(1,g),new e.P(1,1),new e.P(0,1),new e.P(0,g)],A.push(..._),0===m.length?A.push(f[0]):A.push(...m),{polygon:A.map((t=>new e.O(t.x,t.y))),unwrapped:!1}}(t,r);if(i)return i;const n=function(t,r){let i=!1,n=-1/0,o=0;for(let e=0;e<t.length-1;e++)t[e].x>n&&(n=t[e].x,o=e);for(let e=0;e<t.length-1;e++){const r=(o+e)%(t.length-1),n=t[r],s=t[r+1];Math.abs(n.x-s.x)>.5&&(n.x<s.x?(n.x+=1,0===r&&(t[t.length-1].x+=1)):(s.x+=1,r+1===t.length-1&&(t[0].x+=1)),i=!0)}const s=e.a8(r.center.lng);return i&&s<Math.abs(s-1)&&t.forEach((e=>{e.x-=1})),{polygon:t,unwrapped:i}}(Ce(t,r).map((t=>new e.P(Te(t.x),t.y))),r);return{polygon:n.polygon.map((t=>new e.O(t.x,t.y))),unwrapped:n.unwrapped}}}function Ce(t,r){return e.ac(t,(e=>{const t=r.pointCoordinate3D(e);e.x=t.x,e.y=t.y}),1/256)}function Te(e){return e<0?1+e%1:e%1}function Ee(e){return 100*e|0}function Me(t,r,i,n,o){const s=function(i,n){if(i)return o(i);if(n){t.url&&n.tiles&&t.tiles&&delete t.tiles;const i=e.af(e.e(n,t),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);n.vector_layers&&(i.vectorLayers=n.vector_layers,i.vectorLayerIds=i.vectorLayers.map((e=>e.id))),n.raster_layers&&(i.rasterLayers=n.raster_layers,i.rasterLayerIds=i.rasterLayers.map((e=>e.id))),i.tiles=r.canonicalizeTileset(i,t.url),o(null,i)}};return t.url?e.g(r.transformRequest(r.normalizeSourceURL(t.url,null,i,n),e.R.Source),s):e.f.frame((()=>s(null,t)))}class Se{constructor(t,r,i){this.bounds=e.ag.convert(this.validateBounds(t)),this.minzoom=r||0,this.maxzoom=i||24}validateBounds(e){return Array.isArray(e)&&4===e.length?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(t){const r=Math.pow(2,t.z),i=Math.floor(e.a8(this.bounds.getWest())*r),n=Math.floor(e.ah(this.bounds.getNorth())*r),o=Math.ceil(e.a8(this.bounds.getEast())*r),s=Math.ceil(e.ah(this.bounds.getSouth())*r);return t.x>=i&&t.x<o&&t.y>=n&&t.y<s}}class Ie extends e.E{constructor(t,r,i,n){if(super(),this.id=t,this.dispatcher=i,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,e.e(this,e.af(r,["url","scheme","tileSize","promoteId"])),this._options=e.e({type:"vector"},r),this._collectResourceTiming=!!r.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(n),this._tileWorkers={},this._deduped=new e.ai}load(t){this._loaded=!1,this.fire(new e.b("dataloading",{dataType:"source"}));const r=Array.isArray(this.map._language)?this.map._language.join():this.map._language,i=this.map._worldview;this._tileJSONRequest=Me(this._options,this.map._requestManager,r,i,((n,o)=>{this._tileJSONRequest=null,this._loaded=!0,n?(r&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${r}`),i&&2!==i.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${i}`),this.fire(new e.a(n))):o&&(e.e(this,o),o.bounds&&(this.tileBounds=new Se(o.bounds,this.minzoom,this.maxzoom)),e.am(o.tiles,this.map._requestManager._customAccessToken),this.fire(new e.b("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.b("data",{dataType:"source",sourceDataType:"content"}))),t&&t(n)}))}loaded(){return this._loaded}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load()}reload(){this.cancelTileJSONRequest();const t=e.aj(this.id,this.scope);this.load((()=>this.map.style.clearSource(t)))}setTiles(e){return this._options.tiles=e,this.reload(),this}setUrl(e){return this.url=e,this._options.url=e,this.reload(),this}onRemove(){this.cancelTileJSONRequest()}serialize(){return e.e({},this._options)}loadTile(t,r){const i=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme)),n={request:this.map._requestManager.transformRequest(i,e.R.Tile),data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,pixelRatio:e.f.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:t.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:t.isExtraShadowCaster};if(n.request.collectResourceTiming=this._collectResourceTiming,t.actor&&"expired"!==t.state)"loading"===t.state?t.reloadCallback=r:t.request=t.actor.send("reloadTile",n,o.bind(this));else if(t.actor=this._tileWorkers[i]=this._tileWorkers[i]||this.dispatcher.getActor(),this.dispatcher.ready)t.request=t.actor.send("loadTile",n,o.bind(this),void 0,!0);else{const r=e.ak.call({deduped:this._deduped},n,((e,r)=>{e||!r?o.call(this,e):(n.data={cacheControl:r.cacheControl,expires:r.expires,rawData:r.rawData.slice(0)},t.actor&&t.actor.send("loadTile",n,o.bind(this),void 0,!0))}),!0);t.request={cancel:r}}function o(i,n){return delete t.request,t.aborted?r(null):i&&404!==i.status?r(i):(n&&n.resourceTiming&&(t.resourceTiming=n.resourceTiming),this.map._refreshExpiredTiles&&n&&t.setExpiryData(n),t.loadVectorData(n,this.map.painter),e.al(this.dispatcher),r(null),void(t.reloadCallback&&(this.loadTile(t,t.reloadCallback),t.reloadCallback=null)))}}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.actor&&e.actor.send("abortTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope})}unloadTile(e){e.actor&&e.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope}),e.destroy()}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}class Pe extends e.E{constructor(t,r,i,n){super(),this.id=t,this.dispatcher=i,this.setEventedParent(n),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=e.e({type:"raster"},r),e.e(this,e.af(r,["url","scheme","tileSize"]))}load(t){this._loaded=!1,this.fire(new e.b("dataloading",{dataType:"source"})),this._tileJSONRequest=Me(this._options,this.map._requestManager,null,null,((r,i)=>{this._tileJSONRequest=null,this._loaded=!0,r?this.fire(new e.a(r)):i&&(e.e(this,i),i.bounds&&(this.tileBounds=new Se(i.bounds,this.minzoom,this.maxzoom)),e.am(i.tiles),this.fire(new e.b("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.b("data",{dataType:"source",sourceDataType:"content"}))),t&&t(r)}))}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}reload(){this.cancelTileJSONRequest();const t=e.aj(this.id,this.scope);this.load((()=>this.map.style.clearSource(t)))}setTiles(e){return this._options.tiles=e,this.reload(),this}setUrl(e){return this.url=e,this._options.url=e,this.reload(),this}onRemove(){this.cancelTileJSONRequest()}serialize(){return e.e({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(t,r){const i=e.f.devicePixelRatio>=2,n=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),i,this.tileSize);t.request=e.d(this.map._requestManager.transformRequest(n,e.R.Tile),((i,n,o,s)=>(delete t.request,t.aborted?(t.state="unloaded",r(null)):i?(t.state="errored",r(i)):n?(this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:o,expires:s}),t.setTexture(n,this.map.painter),t.state="loaded",e.al(this.dispatcher),void r(null)):r(null))))}abortTile(e,t){e.request&&(e.request.cancel(),delete e.request),t()}unloadTile(t,r){t.texture&&t.texture instanceof e.T?(t.destroy(!0),t.texture&&t.texture instanceof e.T&&this.map.painter.saveTileTexture(t.texture)):t.destroy(),r()}hasTransition(){return!1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}class De extends Pe{constructor(t,r,i,n){super(t,r,i,n),this.type="raster-array",this.maxzoom=22,this._options=e.e({type:"raster-array"},r)}triggerRepaint(e){const t=this.map.painter._terrain,r=this.map.style.getSourceCache(this.id);t&&t.enabled&&r&&t._clearRenderCacheForTile(r.id,e.tileID),this.map.triggerRepaint()}loadTile(t,r){const i=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),n=this.map._requestManager.transformRequest(i,e.R.Tile);t.requestParams=n,t.actor||(t.actor=this.dispatcher.getActor()),t.request=t.fetchHeader(void 0,((e,i,n,o)=>{if(delete t.request,t.aborted)return t.state="unloaded",r(null);if(e){if(20===e.code)return;return t.state="errored",r(e)}this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:n,expires:o}),t.state="empty",r(null)}))}unloadTile(t){const r=t.texture;r&&r instanceof e.T?(t.destroy(!0),this.map.painter.saveTileTexture(r)):(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,i){t._isHeaderLoaded&&("empty"!==t.state&&(t.state="reloading"),t.fetchBand(r,i,((r,i)=>{if(r)return t.state="errored",this.fire(new e.a(r)),void this.triggerRepaint(t);i&&(t.setTexture(i,this.map.painter),t.state="loaded",this.triggerRepaint(t))})))}getInitialBand(e){if(!this.rasterLayers)return 0;const t=this.rasterLayers.find((({id:t})=>t===e)),r=t&&t.fields,i=r&&r.bands&&r.bands;return i?i[0]:0}getTextureDescriptor(t,r,i){if(!t)return;const n=r.sourceLayer||this.rasterLayerIds&&this.rasterLayerIds[0];if(!n)return;let o=null;r instanceof e.aq?o=r.paint.get("raster-array-band"):r instanceof e.ar&&(o=r.paint.get("raster-particle-array-band"));const s=o||this.getInitialBand(n);if(null!=s)if(t.textureDescriptor){if(!t.updateNeeded(n,s)||i)return Object.assign({},t.textureDescriptor,{texture:t.texture})}else this.prepareTile(t,n,s)}}const ke=32,Le=33,ze=new Uint16Array(8184);for(let e=0;e<2046;e++){let t=e+2,r=0,i=0,n=0,o=0,s=0,a=0;for(1&t?n=o=s=ke:r=i=a=ke;(t>>=1)>1;){const e=r+n>>1,l=i+o>>1;1&t?(n=r,o=i,r=s,i=a):(r=n,i=o,n=s,o=a),s=e,a=l}const l=4*e;ze[l+0]=r,ze[l+1]=i,ze[l+2]=n,ze[l+3]=o}const Oe=new Uint16Array(2178),Be=new Uint8Array(1089),Re=new Uint16Array(1089);function Fe(e){return 0===e?-.03125:32===e?.03125:0}class je{constructor(e,t,r,i){this.id=je.uniqueIdxCounter,je.uniqueIdxCounter++,this.context=e;const n=e.gl;this.buffer=n.createBuffer(),this.dynamicDraw=Boolean(r),this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?n.DYNAMIC_DRAW:n.STATIC_DRAW),this.dynamicDraw||i||t.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){this.id=je.uniqueIdxCounter,je.uniqueIdxCounter++;const t=this.context.gl;this.context.unbindVAO(),this.bind(),t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}je.uniqueIdxCounter=0;const Ve={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Ne{constructor(e,t,r,i,n,o){this.length=t.length,this.attributes=r,this.itemSize=t.bytesPerElement,this.dynamicDraw=i,this.instanceCount=o,this.context=e;const s=e.gl;this.buffer=s.createBuffer(),e.bindVertexBuffer.set(this.buffer),s.bufferData(s.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?s.DYNAMIC_DRAW:s.STATIC_DRAW),this.dynamicDraw||n||t.destroy()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){const t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,t){for(let r=0;r<this.attributes.length;r++){const i=t.attributes[this.attributes[r].name];void 0!==i&&e.enableVertexAttribArray(i)}}setVertexAttribPointers(e,t,r){for(let i=0;i<this.attributes.length;i++){const n=this.attributes[i],o=t.attributes[n.name];void 0!==o&&e.vertexAttribPointer(o,n.components,e[Ve[n.type]],!1,this.itemSize,n.offset+this.itemSize*(r||0))}}setVertexAttribDivisor(e,t,r){for(let i=0;i<this.attributes.length;i++){const n=t.attributes[this.attributes[i].name];void 0!==n&&this.instanceCount&&this.instanceCount>0&&e.vertexAttribDivisor(n,r)}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class Ue{constructor(e){this.gl=e.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(e){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class He extends Ue{getDefault(){return e.aA.transparent}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.clearColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class Ge extends Ue{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}}class Ze extends Ue{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}}class We extends Ue{getDefault(){return[!0,!0,!0,!0]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.colorMask(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class Qe extends Ue{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}}class qe extends Ue{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}}class Xe extends Ue{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(e){const t=this.current;(e.func!==t.func||e.ref!==t.ref||e.mask!==t.mask||this.dirty)&&(this.gl.stencilFunc(e.func,e.ref,e.mask),this.current=e,this.dirty=!1)}}class Ye extends Ue{getDefault(){const e=this.gl;return[e.KEEP,e.KEEP,e.KEEP]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||this.dirty)&&(this.gl.stencilOp(e[0],e[1],e[2]),this.current=e,this.dirty=!1)}}class $e extends Ue{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST),this.current=e,this.dirty=!1}}class Ke extends Ue{getDefault(){return[0,1]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||this.dirty)&&(this.gl.depthRange(e[0],e[1]),this.current=e,this.dirty=!1)}}class Je extends Ue{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST),this.current=e,this.dirty=!1}}class et extends Ue{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}}class tt extends Ue{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.BLEND):t.disable(t.BLEND),this.current=e,this.dirty=!1}}class rt extends Ue{getDefault(){const e=this.gl;return[e.ONE,e.ZERO,e.ONE,e.ZERO]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.blendFuncSeparate(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class it extends Ue{getDefault(){return e.aA.transparent}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.blendColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class nt extends Ue{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquationSeparate(e,e),this.current=e,this.dirty=!1)}}class ot extends Ue{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.CULL_FACE):t.disable(t.CULL_FACE),this.current=e,this.dirty=!1}}class st extends Ue{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1)}}class at extends Ue{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1)}}let lt=class extends Ue{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}};class ct extends Ue{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}}class ut extends Ue{getDefault(){const e=this.gl;return[0,0,e.drawingBufferWidth,e.drawingBufferHeight]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.viewport(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class ht extends Ue{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,e),this.current=e,this.dirty=!1}}class dt extends Ue{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindRenderbuffer(t.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class pt extends Ue{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindTexture(t.TEXTURE_2D,e),this.current=e,this.dirty=!1}}class ft extends Ue{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindBuffer(t.ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class mt extends Ue{getDefault(){return null}set(e){const t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class At extends Ue{getDefault(){return null}set(e){this.gl&&(e!==this.current||this.dirty)&&(this.gl.bindVertexArray(e),this.current=e,this.dirty=!1)}}class gt extends Ue{getDefault(){return 4}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_ALIGNMENT,e),this.current=e,this.dirty=!1}}class _t extends Ue{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e),this.current=e,this.dirty=!1}}class yt extends Ue{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e),this.current=e,this.dirty=!1}}class xt extends Ue{constructor(e,t){super(e),this.context=e,this.parent=t}getDefault(){return null}}class vt extends xt{setDirty(){this.dirty=!0}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}}class bt extends xt{attachment(){return this.gl.DEPTH_ATTACHMENT}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,this.attachment(),t.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class wt extends xt{attachment(){return this.gl.DEPTH_ATTACHMENT}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,this.attachment(),t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}}class Ct extends bt{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}class Tt{constructor(e,t,r,i,n){this.context=e,this.width=t,this.height=r;const o=this.framebuffer=e.gl.createFramebuffer();i&&(this.colorAttachment=new vt(e,o)),n&&(this.depthAttachmentType=n,this.depthAttachment="renderbuffer"===n?new bt(e,o):new wt(e,o))}destroy(){const e=this.context.gl;if(this.colorAttachment){const t=this.colorAttachment.get();t&&e.deleteTexture(t)}if(this.depthAttachment&&this.depthAttachmentType)if("renderbuffer"===this.depthAttachmentType){const t=this.depthAttachment.get();t&&e.deleteRenderbuffer(t)}else{const t=this.depthAttachment.get();t&&e.deleteTexture(t)}e.deleteFramebuffer(this.framebuffer)}}class Et{constructor(e,t,r){this.func=e,this.mask=t,this.range=r}}Et.ReadOnly=!1,Et.ReadWrite=!0,Et.disabled=new Et(519,Et.ReadOnly,[0,1]);const Mt=7680;class St{constructor(e,t,r,i,n,o){this.test=e,this.ref=t,this.mask=r,this.fail=i,this.depthFail=n,this.pass=o}}St.disabled=new St({func:519,mask:0},0,0,Mt,Mt,Mt);const It=771;class Pt{constructor(e,t,r,i){this.blendFunction=e,this.blendColor=t,this.mask=r,this.blendEquation=i}}Pt.Replace=[1,0,1,0],Pt.disabled=new Pt(Pt.Replace,e.aA.transparent,[!1,!1,!1,!1]),Pt.unblended=new Pt(Pt.Replace,e.aA.transparent,[!0,!0,!0,!0]),Pt.alphaBlended=new Pt([1,It,1,It],e.aA.transparent,[!0,!0,!0,!0]),Pt.multiply=new Pt([774,0,774,0],e.aA.transparent,[!0,!0,!0,!0]);const Dt=1029,kt=2305;class Lt{constructor(e,t,r){this.enable=e,this.mode=t,this.frontFace=r}}Lt.disabled=new Lt(!1,Dt,kt),Lt.backCCW=new Lt(!0,Dt,kt),Lt.backCW=new Lt(!0,Dt,2304),Lt.frontCW=new Lt(!0,1028,2304),Lt.frontCCW=new Lt(!0,1028,kt);class zt{constructor(e,t){this.gl=e,this.clearColor=new He(this),this.clearDepth=new Ge(this),this.clearStencil=new Ze(this),this.colorMask=new We(this),this.depthMask=new Qe(this),this.stencilMask=new qe(this),this.stencilFunc=new Xe(this),this.stencilOp=new Ye(this),this.stencilTest=new $e(this),this.depthRange=new Ke(this),this.depthTest=new Je(this),this.depthFunc=new et(this),this.blend=new tt(this),this.blendFunc=new rt(this),this.blendColor=new it(this),this.blendEquation=new nt(this),this.cullFace=new ot(this),this.cullFaceSide=new st(this),this.frontFace=new at(this),this.program=new lt(this),this.activeTexture=new ct(this),this.viewport=new ut(this),this.bindFramebuffer=new ht(this),this.bindRenderbuffer=new dt(this),this.bindTexture=new pt(this),this.bindVertexBuffer=new ft(this),this.bindElementBuffer=new mt(this),this.bindVertexArrayOES=new At(this),this.pixelStoreUnpack=new gt(this),this.pixelStoreUnpackPremultiplyAlpha=new _t(this),this.pixelStoreUnpackFlipY=new yt(this),this.options=t?{...t}:{},this.options.extTextureFilterAnisotropicForceOff||(this.extTextureFilterAnisotropic=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=e.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT))),this.extDebugRendererInfo=e.getExtension("WEBGL_debug_renderer_info"),this.extDebugRendererInfo&&(this.renderer=e.getParameter(this.extDebugRendererInfo.UNMASKED_RENDERER_WEBGL),this.vendor=e.getParameter(this.extDebugRendererInfo.UNMASKED_VENDOR_WEBGL)),this.options.extTextureFloatLinearForceOff||(this.extTextureFloatLinear=e.getExtension("OES_texture_float_linear")),this.extRenderToTextureHalfFloat=e.getExtension("EXT_color_buffer_half_float"),this.extTimerQuery=e.getExtension("EXT_disjoint_timer_query_webgl2"),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),this.maxPointSize=e.getParameter(e.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(e,t,r){return new je(this,e,t,r)}createVertexBuffer(e,t,r,i,n){return new Ne(this,e,t,r,i,n)}createRenderbuffer(e,t,r){const i=this.gl,n=i.createRenderbuffer();return this.bindRenderbuffer.set(n),i.renderbufferStorage(i.RENDERBUFFER,e,t,r),this.bindRenderbuffer.set(null),n}createFramebuffer(e,t,r,i){return new Tt(this,e,t,r,i)}clear({color:e,depth:t,stencil:r,colorMask:i}){const n=this.gl;let o=0;e&&(o|=n.COLOR_BUFFER_BIT,this.clearColor.set(e),this.colorMask.set(i||[!0,!0,!0,!0])),void 0!==t&&(o|=n.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(t),this.depthMask.set(!0)),void 0!==r&&(o|=n.STENCIL_BUFFER_BIT,this.clearStencil.set(r),this.stencilMask.set(255)),n.clear(o)}setCullFace(e){!1===e.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(e.mode),this.frontFace.set(e.frontFace))}setDepthMode(e){e.func!==this.gl.ALWAYS||e.mask?(this.depthTest.set(!0),this.depthFunc.set(e.func),this.depthMask.set(e.mask),this.depthRange.set(e.range)):this.depthTest.set(!1)}setStencilMode(e){e.test.func!==this.gl.ALWAYS||e.mask?(this.stencilTest.set(!0),this.stencilMask.set(e.mask),this.stencilOp.set([e.fail,e.depthFail,e.pass]),this.stencilFunc.set({func:e.test.func,ref:e.ref,mask:e.test.mask})):this.stencilTest.set(!1)}setColorMode(e){t(e.blendFunction,Pt.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(e.blendFunction),this.blendColor.set(e.blendColor),e.blendEquation?this.blendEquation.set(e.blendEquation):this.blendEquation.setDefault()),this.colorMask.set(e.mask)}unbindVAO(){this.bindVertexArrayOES.set(null)}}var Ot=e.aB([{name:"a_index",type:"Int16",components:1}]);const Bt=.15000000000000002;class Rt{constructor(t,r,i,n){const o={width:i[0],height:i[1],data:null},s=t.gl;this.targetColorTexture=new e.T(t,o,s.RGBA,{useMipmap:!1}),this.backgroundColorTexture=new e.T(t,o,s.RGBA,{useMipmap:!1}),this.context=t,this.setParticleTextureDimension(r,n),this.lastInvalidatedAt=0}setParticleTextureDimension(t,r){if(this.particleTextureDimension===r)return;(this.particleTexture0||this.particleTexture1||this.particleIndexBuffer||this.particleSegment)&&(this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleIndexBuffer.destroy(),this.particleSegment.destroy());const i=this.context.gl,n=r*r,o=new Uint8Array(4*n),s=.7692307692307692,a=e.aC(t.key);for(let e=0;e<o.length;e+=4){const t=s*(a()+Bt),r=s*(a()+Bt),i=255*t%1,n=255*r%1,l=i,c=r-n/255,u=n;o[e+0]=Math.floor(255*(t-i/255)),o[e+1]=Math.floor(255*l),o[e+2]=Math.floor(255*c),o[e+3]=Math.floor(255*u)}const l=new e.h({width:r,height:r},o);this.particleTexture0=new e.T(this.context,l,i.RGBA,{premultiply:!1,useMipmap:!1}),this.particleTexture1=new e.T(this.context,l,i.RGBA,{premultiply:!1,useMipmap:!1});const c=new e.aD;c.reserve(n);for(let e=0;e<n;e++)c.emplaceBack(e);this.particleIndexBuffer=this.context.createVertexBuffer(c,Ot.members,!0),this.particleSegment=e.aE.simpleSegment(0,0,this.particleIndexBuffer.length,0),this.particleTextureDimension=r}update(t){return!(this.lastInvalidatedAt<t&&(this.lastInvalidatedAt=e.f.now(),1))}destroy(){this.targetColorTexture.destroy(),this.backgroundColorTexture.destroy(),this.particleIndexBuffer.destroy(),this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleSegment.destroy()}}const Ft={type:2,extent:e.Y,loadGeometry:()=>[[new e.P(0,0),new e.P(e.Y+1,0),new e.P(e.Y+1,e.Y+1),new e.P(0,e.Y+1),new e.P(0,0)]]};class jt{constructor(t,r,i,n,o){this.tileID=t,this.uid=e.aF(),this.uses=0,this.tileSize=r,this.tileZoom=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=o,n&&n.style&&(this._lastUpdatedBrightness=n.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",n&&n.transform&&(this.projection=n.transform.projection)}registerFadeDuration(t){const r=t+this.timeAdded;r<e.f.now()||this.fadeEndTime&&r<this.fadeEndTime||(this.fadeEndTime=r)}wasRequested(){return"errored"===this.state||"loaded"===this.state||"reloading"===this.state}get tileTransform(){return this._tileTransform||(this._tileTransform=e.av(this.tileID.canonical,this.projection)),this._tileTransform}loadVectorData(t,r,i){if(this.unloadVectorData(),this.state="loaded",t){t.featureIndex&&(this.latestFeatureIndex=t.featureIndex,t.rawTileData?(this.latestRawTileData=t.rawTileData,this.latestFeatureIndex.rawTileData=t.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=t.collisionBoxArray,this.buckets=function(e,t){const r={};if(!t)return r;for(const i of e){const e=i.layerIds.map((e=>t.getLayer(e))).filter(Boolean);if(0!==e.length){i.layers=e,i.stateDependentLayerIds&&(i.stateDependentLayers=i.stateDependentLayerIds.map((t=>e.filter((e=>e.id===t))[0])));for(const t of e)r[t.fqid]=i}}return r}(t.buckets,r.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const r=this.buckets[t];if(r instanceof e.aH){if(this.hasSymbolBuckets=!0,!i)break;r.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const r=this.buckets[t];if(r instanceof e.aH&&r.hasRTLText){this.hasRTLText=!0,e.aI();break}}this.queryPadding=0;for(const e in this.buckets){const t=this.buckets[e],i=r.style.getOwnLayer(e);if(!i)continue;const n=i.queryRadius(t);this.queryPadding=Math.max(this.queryPadding,n)}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 e.aG}unloadVectorData(){if(this.hasData()){for(const e in this.buckets)this.buckets[e].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(e){return this.buckets[e.fqid]}upload(t){for(const e in this.buckets){const r=this.buckets[e];r.uploadPending()&&r.upload(t)}const r=t.gl,i=this.imageAtlas;if(i&&!i.uploaded){const n=!!Object.keys(i.patternPositions).length;this.imageAtlasTexture=new e.T(t,i.image,r.RGBA,{useMipmap:n}),this.imageAtlas.uploaded=!0}this.glyphAtlasImage&&(this.glyphAtlasTexture=new e.T(t,this.glyphAtlasImage,r.R8),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new e.T(t,this.lineAtlas.image,r.R8),this.lineAtlas.uploaded=!0)}prepare(e,t,r){if(this.imageAtlas&&this.imageAtlasTexture&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture,r),!t||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;const i=t.style.getBrightness();(this._lastUpdatedBrightness||i)&&(this._lastUpdatedBrightness&&i&&Math.abs(this._lastUpdatedBrightness-i)<.001||(this._lastUpdatedBrightness=i,this.updateBuckets(void 0,t)))}queryRenderedFeatures(e,t,r,i,n,o,s,a){return this.latestFeatureIndex&&(this.latestFeatureIndex.rawTileData||this.latestFeatureIndex.is3DTile)?this.latestFeatureIndex.query({tileResult:i,pixelPosMatrix:s,transform:o,params:n,tileTransform:this.tileTransform},e,t,r):{}}querySourceFeatures(t,r){const i=this.latestFeatureIndex;if(!i||!i.rawTileData)return;const n=i.loadVTLayers(),o=r?r.sourceLayer:"",s=n._geojsonTileLayer||n[o];if(!s)return;const a=e.aJ(r&&r.filter),{z:l,x:c,y:u}=this.tileID.canonical,h={z:l,x:c,y:u};for(let r=0;r<s.length;r++){const n=s.feature(r);if(a.needGeometry){const t=e.aK(n,!0);if(!a.filter(new e.N(this.tileID.overscaledZ),t,this.tileID.canonical))continue}else if(!a.filter(new e.N(this.tileID.overscaledZ),n))continue;const d=i.getId(n,o),p=new e.aL(n,l,c,u,d);p.tile=h,t.push(p)}}hasData(){return"loaded"===this.state||"reloading"===this.state||"expired"===this.state}bucketsLoaded(){for(const e in this.buckets)if(this.buckets[e].uploadPending())return!1;return!0}patternsLoaded(){return!!this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(t){const r=this.expirationTime;if(t.cacheControl){const r=e.aM(t.cacheControl);r["max-age"]&&(this.expirationTime=Date.now()+1e3*r["max-age"])}else t.expires&&(this.expirationTime=new Date(t.expires).getTime());if(this.expirationTime){const e=Date.now();let t=!1;if(this.expirationTime>e)t=!1;else if(r)if(this.expirationTime<r)t=!0;else{const i=this.expirationTime-r;i?this.expirationTime=e+Math.max(i,3e4):t=!0}else t=!0;t?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-(new Date).getTime(),Math.pow(2,31)-1)}setFeatureState(e,t){this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData&&0!==Object.keys(e).length&&t&&this.updateBuckets(e,t)}updateBuckets(t,r){if(!this.latestFeatureIndex)return;const i=this.latestFeatureIndex.loadVTLayers(),n=r.style.listImages(),o=r.style.getBrightness();for(const s in this.buckets){if(!r.style.hasLayer(s))continue;const a=this.buckets[s],l=a.layers[0].sourceLayer||"_geojsonTileLayer",c=i[l];let u={};if(t&&(u=t[l],!c||!u||0===Object.keys(u).length))continue;if(a.update(u,c,n,this.imageAtlas&&this.imageAtlas.patternPositions||{},o),a instanceof e.aN||a instanceof e.aO){const e=r.style.getOwnSourceCache(a.layers[0].source);r._terrain&&r._terrain.enabled&&e&&a.programConfigurations.needsUpload&&r._terrain._clearRenderCacheForTile(e.id,this.tileID)}const h=r&&r.style&&r.style.getOwnLayer(s);h&&(this.queryPadding=Math.max(this.queryPadding,h.queryRadius(a)))}}holdingForFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<e.f.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(t){this.symbolFadeHoldUntil=e.f.now()+t}setTexture(t,r){const i=r.context,n=i.gl;this.texture=this.texture||r.getTileTexture(t.width),this.texture&&this.texture instanceof e.T?this.texture.update(t,{useMipmap:!0}):(this.texture=new e.T(i,t,n.RGBA,{useMipmap:!0}),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE))}setDependencies(e,t){const r={};for(const e of t)r[e]=!0;this.dependencies[e]=r}hasDependency(e,t){for(const r of e){const e=this.dependencies[r];if(e)for(const r of t)if(e[r])return!0}return!1}clearQueryDebugViz(){}_makeDebugTileBoundsBuffers(t,r){if(!r||"mercator"===r.name||this._tileDebugBuffer)return;const i=e.aP(Ft,this.tileID.canonical,this.tileTransform)[0],n=new e.aQ,o=new e.aR;for(let e=0;e<i.length;e++){const{x:t,y:r}=i[e];n.emplaceBack(t,r),o.emplaceBack(e)}o.emplaceBack(0),this._tileDebugIndexBuffer=t.createIndexBuffer(o),this._tileDebugBuffer=t.createVertexBuffer(n,e.aS.members),this._tileDebugSegments=e.aE.simpleSegment(0,0,n.length,o.length)}_makeTileBoundsBuffers(t,r){if(this._tileBoundsBuffer||!r||"mercator"===r.name)return;const i=e.aP(Ft,this.tileID.canonical,this.tileTransform)[0];let n,o;if(this.isRaster){const t=function(t,r){const i=e.av(t,r),n=Math.pow(2,t.z);for(let o=0;o<Le;o++)for(let s=0;s<Le;s++){const a=e.aw((t.x+(s+Fe(s))/ke)/n),l=e.ax((t.y+(o+Fe(o))/ke)/n),c=r.project(a,l),u=o*Le+s;Oe[2*u+0]=Math.round((c.x*i.scale-i.x)*e.Y),Oe[2*u+1]=Math.round((c.y*i.scale-i.y)*e.Y)}Be.fill(0),Re.fill(0);for(let e=2045;e>=0;e--){const t=4*e,r=ze[t+0],i=ze[t+1],n=ze[t+2],o=ze[t+3],s=r+n>>1,a=i+o>>1,l=s+a-i,c=a+r-s,u=i*Le+r,h=o*Le+n,d=a*Le+s,p=Math.hypot((Oe[2*u+0]+Oe[2*h+0])/2-Oe[2*d+0],(Oe[2*u+1]+Oe[2*h+1])/2-Oe[2*d+1])>=16;Be[d]=Be[d]||(p?1:0),e<1022&&(Be[d]=Be[d]||Be[(i+c>>1)*Le+(r+l>>1)]||Be[(o+c>>1)*Le+(n+l>>1)])}const o=new e.ay,s=new e.az;let a=0;function l(t,r){const i=r*Le+t;return 0===Re[i]&&(o.emplaceBack(Oe[2*i+0],Oe[2*i+1],t*e.Y/ke,r*e.Y/ke),Re[i]=++a),Re[i]-1}function c(e,t,r,i,n,o){const a=e+r>>1,u=t+i>>1;if(Math.abs(e-n)+Math.abs(t-o)>1&&Be[u*Le+a])c(n,o,e,t,a,u),c(r,i,n,o,a,u);else{const a=l(e,t),c=l(r,i),u=l(n,o);s.emplaceBack(a,c,u)}}return c(0,0,ke,ke,ke,0),c(ke,ke,0,0,0,ke),{vertices:o,indices:s}}(this.tileID.canonical,r);n=t.vertices,o=t.indices}else{n=new e.ay,o=new e.az;for(const{x:e,y:t}of i)n.emplaceBack(e,t,0,0);const t=e.aT(n.int16,void 0,4);for(let e=0;e<t.length;e+=3)o.emplaceBack(t[e],t[e+1],t[e+2])}this._tileBoundsBuffer=t.createVertexBuffer(n,e.aU.members),this._tileBoundsIndexBuffer=t.createIndexBuffer(o),this._tileBoundsSegments=e.aE.simpleSegment(0,0,n.length,o.length)}_makeGlobeTileDebugBuffers(t,r){const i=r.projection;if(!i||"globe"!==i.name||r.freezeTileCoverage)return;const n=this.tileID.canonical,o=e.aV(n,r),s=e.aW(o),a=e.W(r.zoom);let l;a>0&&(l=e.a9.invert(new Float64Array(16),r.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(t,n,r,s,l,a),this._makeGlobeTileDebugTextBuffer(t,n,r,s,l,a)}_globePoint(t,r,i,n,o,s,a){let l=e.aX(t,r,i);if(s){const o=1<<i.z,c=e.a8(n.center.lng),u=e.ah(n.center.lat),h=(i.x+.5)/o-c;let d=0;h>.5?d=-1:h<-.5&&(d=1);let p=(t/e.Y+i.x)/o+d,f=(r/e.Y+i.y)/o;p=(p-c)*n._pixelsPerMercatorPixel+c,f=(f-u)*n._pixelsPerMercatorPixel+u;const m=[p*n.worldSize,f*n.worldSize,0];e.Q.transformMat4(m,m,s),l=e.aY(l,m,a)}return e.Q.transformMat4(l,l,o)}_makeGlobeTileDebugBorderBuffer(t,r,i,n,o,s){const a=new e.aQ,l=new e.aR,c=new e.aZ,u=(e,t,u,h,d)=>{const p=(u-e)/(d-1),f=(h-t)/(d-1),m=a.length;for(let u=0;u<d;u++){const h=e+u*p,d=t+u*f;a.emplaceBack(h,d);const A=this._globePoint(h,d,r,i,n,o,s);c.emplaceBack(A[0],A[1],A[2]),l.emplaceBack(m+u)}},h=e.Y;u(0,0,h,0,16),u(h,0,h,h,16),u(h,h,0,h,16),u(0,h,0,0,16),this._tileDebugIndexBuffer=t.createIndexBuffer(l),this._tileDebugBuffer=t.createVertexBuffer(a,e.aS.members),this._globeTileDebugBorderBuffer=t.createVertexBuffer(c,e.a_.members),this._tileDebugSegments=e.aE.simpleSegment(0,0,a.length,l.length)}_makeGlobeTileDebugTextBuffer(t,r,i,n,o,s){const a=e.Y/4,l=new e.aQ,c=new e.az,u=new e.aZ,h=25;c.reserve(32),l.reserve(h),u.reserve(h);const d=(e,t)=>h*e+t;for(let e=0;e<h;e++){const t=e*a;for(let e=0;e<h;e++){const c=e*a;l.emplaceBack(c,t);const h=this._globePoint(c,t,r,i,n,o,s);u.emplaceBack(h[0],h[1],h[2])}}for(let e=0;e<4;e++)for(let t=0;t<4;t++){const r=d(e,t),i=d(e,t+1),n=d(e+1,t),o=d(e+1,t+1);c.emplaceBack(r,i,n),c.emplaceBack(n,i,o)}this._tileDebugTextIndexBuffer=t.createIndexBuffer(c),this._tileDebugTextBuffer=t.createVertexBuffer(l,e.aS.members),this._globeTileDebugTextBuffer=t.createVertexBuffer(u,e.a_.members),this._tileDebugTextSegments=e.aE.simpleSegment(0,0,h,32)}destroy(t=!1){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&(this.imageAtlasTexture.destroy(),delete this.imageAtlasTexture),this.glyphAtlasTexture&&(this.glyphAtlasTexture.destroy(),delete this.glyphAtlasTexture),this.lineAtlasTexture&&(this.lineAtlasTexture.destroy(),delete this.lineAtlasTexture),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),!t&&this.texture&&this.texture instanceof e.T&&(this.texture.destroy(),delete this.texture),this.hillshadeFBO&&(this.hillshadeFBO.destroy(),delete this.hillshadeFBO),this.dem&&delete this.dem,this.neighboringTiles&&delete this.neighboringTiles,this.demTexture&&(this.demTexture.destroy(),delete this.demTexture),this.rasterParticleState&&(this.rasterParticleState.destroy(),delete this.rasterParticleState),this.latestFeatureIndex=null,this.state="unloaded"}}const Vt={vector:Ie,raster:Pe,"raster-dem":class extends Pe{constructor(t,r,i,n){super(t,r,i,n),this.type="raster-dem",this.maxzoom=22,this._options=e.e({type:"raster-dem"},r),this.encoding=r.encoding||"mapbox"}loadTile(t,r){const i=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function n(e,i){e&&(t.state="errored",r(e)),i&&(t.dem=i,t.dem.onDeserialize(),t.needsHillshadePrepare=!0,t.needsDEMTextureUpload=!0,t.state="loaded",r(null))}t.request=e.d(this.map._requestManager.transformRequest(i,e.R.Tile),function(i,o,s,a){if(delete t.request,t.aborted)t.state="unloaded",r(null);else if(i)t.state="errored",r(i);else if(o){this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:s,expires:a});const r=ImageBitmap&&o instanceof ImageBitmap&&e.an(),i=1-(o.width-e.ao(o.width))/2;i<1||t.neighboringTiles||(t.neighboringTiles=this._getNeighboringTiles(t.tileID));const l=r?o:e.f.getImageData(o,i),c={uid:t.uid,coord:t.tileID,source:this.id,scope:this.scope,rawImageData:l,encoding:this.encoding,padding:i};t.actor&&"expired"!==t.state||(t.actor=this.dispatcher.getActor(),t.actor.send("loadDEMTile",c,n.bind(this),void 0,!0))}}.bind(this))}_getNeighboringTiles(t){const r=t.canonical,i=Math.pow(2,r.z),n=(r.x-1+i)%i,o=0===r.x?t.wrap-1:t.wrap,s=(r.x+1+i)%i,a=r.x+1===i?t.wrap+1:t.wrap,l={};return l[new e.ap(t.overscaledZ,o,r.z,n,r.y).key]={backfilled:!1},l[new e.ap(t.overscaledZ,a,r.z,s,r.y).key]={backfilled:!1},r.y>0&&(l[new e.ap(t.overscaledZ,o,r.z,n,r.y-1).key]={backfilled:!1},l[new e.ap(t.overscaledZ,t.wrap,r.z,r.x,r.y-1).key]={backfilled:!1},l[new e.ap(t.overscaledZ,a,r.z,s,r.y-1).key]={backfilled:!1}),r.y+1<i&&(l[new e.ap(t.overscaledZ,o,r.z,n,r.y+1).key]={backfilled:!1},l[new e.ap(t.overscaledZ,t.wrap,r.z,r.x,r.y+1).key]={backfilled:!1},l[new e.ap(t.overscaledZ,a,r.z,s,r.y+1).key]={backfilled:!1}),l}},"raster-array":De,geojson:class extends e.E{constructor(t,r,i,n){super(),this.id=t,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._loaded=!1,this.actor=i.getActor(),this.setEventedParent(n),this._data=r.data,this._options=e.e({},r),this._collectResourceTiming=r.collectResourceTiming,void 0!==r.maxzoom&&(this.maxzoom=r.maxzoom),void 0!==r.minzoom&&(this.minzoom=r.minzoom),r.type&&(this.type=r.type),r.attribution&&(this.attribution=r.attribution),this.promoteId=r.promoteId;const o=e.Y/this.tileSize;this.workerOptions=e.e({source:this.id,scope:this.scope,cluster:r.cluster||!1,geojsonVtOptions:{buffer:(void 0!==r.buffer?r.buffer:128)*o,tolerance:(void 0!==r.tolerance?r.tolerance:.375)*o,extent:e.Y,maxZoom:this.maxzoom,lineMetrics:r.lineMetrics||!1,generateId:r.generateId||!1},superclusterOptions:{maxZoom:void 0!==r.clusterMaxZoom?r.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,r.clusterMinPoints||2),extent:e.Y,radius:(void 0!==r.clusterRadius?r.clusterRadius:50)*o,log:!1,generateId:r.generateId||!1},clusterProperties:r.clusterProperties,filter:r.filter,dynamic:r.dynamic},r.workerOptions)}onAdd(e){this.map=e,this.setData(this._data)}setData(e){return this._data=e,this._updateWorkerData(),this}updateData(t){return this._options.dynamic?(this._data=t,this._updateWorkerData(!0),this):this.fire(new e.a(new Error("Can't call updateData on a GeoJSON source with dynamic set to false.")))}getClusterExpansionZoom(e,t){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:e,source:this.id,scope:this.scope},t),this}getClusterChildren(e,t){return this.actor.send("geojson.getClusterChildren",{clusterId:e,source:this.id,scope:this.scope},t),this}getClusterLeaves(e,t,r,i){return this.actor.send("geojson.getClusterLeaves",{source:this.id,scope:this.scope,clusterId:e,limit:t,offset:r},i),this}_updateWorkerData(t=!1){if(this._pendingLoad)return void(this._coalesce=!0);this.fire(new e.b("dataloading",{dataType:"source"})),this._loaded=!1;const r=e.e({append:t},this.workerOptions);r.scope=this.scope;const i=this._data;"string"==typeof i?(r.request=this.map._requestManager.transformRequest(e.f.resolveURL(i),e.R.Source),r.request.collectResourceTiming=this._collectResourceTiming):r.data=JSON.stringify(i),this._pendingLoad=this.actor.send(`${this.type}.loadData`,r,((r,i)=>{if(this._loaded=!0,this._pendingLoad=null,r)this.fire(new e.a(r));else{const t={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&i&&i.resourceTiming&&i.resourceTiming[this.id]&&(t.resourceTiming=i.resourceTiming[this.id]),this.fire(new e.b("data",t)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(t),this._coalesce=!1)}))}loaded(){return this._loaded}loadTile(t,r){const i=t.actor?"reloadTile":"loadTile";t.actor=this.actor;const n={type:this.type,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,scope:this.scope,pixelRatio:e.f.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,brightness:this.map.style&&this.map.style.getBrightness()||0};t.request=this.actor.send(i,n,((e,n)=>(delete t.request,t.destroy(),t.aborted?r(null):e?r(e):(t.loadVectorData(n,this.map.painter,"reloadTile"===i),r(null)))),void 0,"loadTile"===i)}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.aborted=!0}unloadTile(e){this.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope}),e.destroy()}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return e.e({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends e.as{constructor(e,t,r,i){super(e,t,r,i),this.roundZoom=!0,this.type="video",this.options=t}load(){this._loaded=!1;const t=this.options;this.urls=[];for(const r of t.urls)this.urls.push(this.map._requestManager.transformRequest(r,e.R.Source).url);e.at(this.urls,((t,r)=>{this._loaded=!0,t?this.fire(new e.a(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(t){if(this.video){const r=this.video.seekable;t<r.start(0)||t>r.end(0)?this.fire(new e.a(new e.V(`sources.${this.id}`,null,`Playback for this video can be set only between the ${r.start(0)} and ${r.end(0)}-second mark.`))):this.video.currentTime=t}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const t=this.map.painter.context,r=t.gl;this.texture?this.video.paused||(this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE),r.texSubImage2D(r.TEXTURE_2D,0,0,0,r.RGBA,r.UNSIGNED_BYTE,this.video)):(this.texture=new e.T(t,this.video,r.RGBA),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(t)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:e.as,model:class extends e.E{constructor(e,t,r,i){super(),this.id=e,this.type="model",this.models=[],this._loaded=!1,this._options=t}load(){const t=[];for(const r in this._options.models){const i=this._options.models[r],n=e.l(this.map._requestManager.transformRequest(i.uri,e.R.Model).url).then((t=>{if(!t)return;const n=e.c(t),o=new e.M(r,i.position,i.orientation,n);o.computeBoundsAndApplyParent(),this.models.push(o)})).catch((t=>{this.fire(new e.a(new Error(`Could not load model ${r} from ${i.uri}: ${t.message}`)))}));t.push(n)}return Promise.allSettled(t).then((()=>{this._loaded=!0,this.fire(new e.b("data",{dataType:"source",sourceDataType:"metadata"}))})).catch((t=>{this.fire(new e.a(new Error(`Could not load models: ${t.message}`)))}))}onAdd(e){this.map=e,this.load()}hasTransition(){return!1}loaded(){return this._loaded}getModels(){return this.models}loadTile(e,t){}serialize(){return{type:"model"}}},"batched-model":class extends e.E{constructor(e,t,r,i){super(),this.type="batched-model",this.id=e,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(i)}onAdd(e){this.map=e,this.load()}load(t){this._loaded=!1,this.fire(new e.b("dataloading",{dataType:"source"}));const r=Array.isArray(this.map._language)?this.map._language.join():this.map._language,i=this.map._worldview;this._tileJSONRequest=Me(this._options,this.map._requestManager,r,i,((n,o)=>{this._tileJSONRequest=null,this._loaded=!0,n?(r&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${r}`),i&&2!==i.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${i}`),this.fire(new e.a(n))):o&&(e.e(this,o),o.bounds&&(this.tileBounds=new Se(o.bounds,this.minzoom,this.maxzoom)),e.am(o.tiles,this.map._requestManager._customAccessToken),this.fire(new e.b("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.b("data",{dataType:"source",sourceDataType:"content"}))),t&&t(n)}))}hasTransition(){return!1}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loaded(){return this._loaded}loadTile(t,r){const i=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme)),n={request:this.map._requestManager.transformRequest(i,e.R.Tile),data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,showCollisionBoxes:this.map.showCollisionBoxes,isSymbolTile:t.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0};if(t.actor&&"expired"!==t.state)if("loading"===t.state)t.reloadCallback=r;else{if(t.buckets){const e=Object.values(t.buckets);for(const t of e)t.dirty=!0;return void(t.state="loaded")}t.request=t.actor.send("reloadTile",n,o.bind(this))}else t.actor=this.dispatcher.getActor(),t.request=t.actor.send("loadTile",n,o.bind(this),void 0,!0);function o(e,i){return t.aborted?r(null):e&&404!==e.status?r(e):(i&&(i.resourceTiming&&(t.resourceTiming=i.resourceTiming),this.map._refreshExpiredTiles&&t.setExpiryData(i),t.buckets={...t.buckets,...i.buckets},i.featureIndex&&(t.latestFeatureIndex=i.featureIndex)),t.state="loaded",void r(null))}}serialize(){return e.e({},this._options)}},canvas:class extends e.as{constructor(t,r,i,n){super(t,r,i,n),r.coordinates?Array.isArray(r.coordinates)&&4===r.coordinates.length&&!r.coordinates.some((e=>!Array.isArray(e)||2!==e.length||e.some((e=>"number"!=typeof e))))||this.fire(new e.a(new e.V(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new e.a(new e.V(`sources.${t}`,null,'missing required property "coordinates"'))),r.animate&&"boolean"!=typeof r.animate&&this.fire(new e.a(new e.V(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),r.canvas?"string"==typeof r.canvas||r.canvas instanceof HTMLCanvasElement||this.fire(new e.a(new e.V(`sources.${t}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new e.a(new e.V(`sources.${t}`,null,'missing required property "canvas"'))),this.options=r,this.animate=void 0===r.animate||r.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 e.a(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const r=this.map.painter.context;this.texture?!t&&!this._playing||this.texture instanceof e.au||this.texture.update(this.canvas,{premultiply:!0}):this.texture=new e.T(r,this.canvas,r.gl.RGBA,{premultiply:!0}),this._prepareData(r)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const e of[this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return!0;return!1}},custom:class extends e.E{constructor(t,r,i,n){super(),this.id=t,this.type="custom",this._dataType="raster",this._dispatcher=i,this._implementation=r,this.setEventedParent(n),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new e.a(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new e.a(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new Se(this._implementation.bounds,this.minzoom,this.maxzoom)),r.update=this._update.bind(this),r.clearTiles=this._clearTiles.bind(this),r.coveringTiles=this._coveringTiles.bind(this),e.e(this,e.af(r,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return e.af(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new e.b("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.b("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(t){this._map=t,this._loaded=!1,this.fire(new e.b("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(t),this.load()}onRemove(e){this._implementation.onRemove&&this._implementation.onRemove(e)}hasTile(e){if(this._implementation.hasTile){const{x:t,y:r,z:i}=e.canonical;return this._implementation.hasTile({x:t,y:r,z:i})}return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e,t){const{x:r,y:i,z:n}=e.tileID.canonical,o=new AbortController;e.request=Promise.resolve(this._implementation.loadTile({x:r,y:i,z:n},{signal:o.signal})).then(function(r){return delete e.request,e.aborted?(e.state="unloaded",t(null)):void 0===r?(e.state="errored",t(null)):null===r?(this.loadTileData(e,{width:this.tileSize,height:this.tileSize,data:null}),e.state="loaded",t(null)):function(e){return e instanceof ImageData||e instanceof HTMLCanvasElement||e instanceof ImageBitmap||e instanceof HTMLImageElement}(r)?(this.loadTileData(e,r),e.state="loaded",void t(null)):(e.state="errored",t(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}.bind(this)).catch((r=>{20!==r.code&&(e.state="errored",t(r))})),e.request.cancel=()=>o.abort()}loadTileData(e,t){e.setTexture(t,this._map.painter)}unloadTile(t,r){if(t.texture&&t.texture instanceof e.T?(t.destroy(!0),t.texture&&t.texture instanceof e.T&&this._map.painter.saveTileTexture(t.texture)):t.destroy(),this._implementation.unloadTile){const{x:e,y:r,z:i}=t.tileID.canonical;this._implementation.unloadTile({x:e,y:r,z:i})}r()}abortTile(e,t){e.request&&e.request.cancel&&(e.request.cancel(),delete e.request),t()}hasTransition(){return!1}_coveringTiles(){return this._map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map((e=>({x:e.canonical.x,y:e.canonical.y,z:e.canonical.z})))}_clearTiles(){const t=e.aj(this.id,this.scope);this._map.style.clearSource(t)}_update(){this.fire(new e.b("data",{dataType:"source",sourceDataType:"content"}))}}},Nt=function(t,r,i,n){const o=new Vt[r.type](t,r,i,n);if(o.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${o.id}`);return e.a$(["load","abort","unload","serialize","prepare"],o),o};function Ut(t,r){const i=e.a9.identity([]);return e.a9.scale(i,i,[.5*t.width,.5*-t.height,1]),e.a9.translate(i,i,[1,-1,0]),e.a9.multiply(i,i,t.calculateProjMatrix(r.toUnwrapped())),Float32Array.from(i)}function Ht(e,t,r,i,n,o,s,a=!1){const l=e.tilesIn(i,s,a);l.sort(Zt);const c=[];for(const i of l)c.push({wrappedTileID:i.tile.tileID.wrapped().key,queryResults:i.tile.queryRenderedFeatures(t,r,e._state,i,n,o,Ut(e.transform,i.tile.tileID),a)});const u=function(e){const t={},r={};for(const i of e){const e=i.queryResults,n=i.wrappedTileID,o=r[n]=r[n]||{};for(const r in e){const i=e[r],n=o[r]=o[r]||{},s=t[r]=t[r]||[];for(const e of i)n[e.featureIndex]||(n[e.featureIndex]=!0,s.push(e))}}return t}(c);for(const t in u)u[t].forEach((t=>{const r=t.feature,i=r.layer;i&&"background"!==i.type&&"sky"!==i.type&&"slot"!==i.type&&(r.source=i.source,i["source-layer"]&&(r.sourceLayer=i["source-layer"]),r.state=void 0!==r.id?e.getFeatureState(i["source-layer"],r.id):{})}));return u}function Gt(e,t){const r=e.getRenderableIds().map((t=>e.getTileByID(t))),i=[],n={};for(let e=0;e<r.length;e++){const o=r[e],s=o.tileID.canonical.key;n[s]||(n[s]=!0,o.querySourceFeatures(i,t))}return i}function Zt(e,t){const r=e.tileID,i=t.tileID;return r.overscaledZ-i.overscaledZ||r.canonical.y-i.canonical.y||r.wrap-i.wrap||r.canonical.x-i.canonical.x}class Wt extends jt{constructor(e,t,r,i,n){super(e,t,r,i,n),this._workQueue=[],this._fetchQueue=[],this._isHeaderLoaded=!1}setTexture(t,r){const i=r.context,n=i.gl;this.texture=this.texture||r.getTileTexture(t.width),this.texture&&this.texture instanceof e.T?this.texture.update(t,{useMipmap:!1,premultiply:!1}):this.texture=new e.T(i,t,n.RGBA,{useMipmap:!1,premultiply:!1})}flushQueues(){for(;this._workQueue.length;)this._workQueue.pop()();for(;this._fetchQueue.length;)this._fetchQueue.pop()()}fetchHeader(t=16384,r){const i=this._mrt=new e.b0(30),n=Object.assign({},this.requestParams,{headers:{Range:"bytes=0-"+(t-1)}});return this.entireBuffer=null,this.request=e.b1(n,((e,n,o,s)=>{if(e)r(e);else try{const e=i.getHeaderLength(n);if(e>t)return void(this.request=this.fetchHeader(e,r));i.parseHeader(n),this._isHeaderLoaded=!0;let a=0;for(const e of Object.values(i.layers))a=Math.max(a,e.dataIndex[e.dataIndex.length-1].last_byte);n.byteLength>=a&&(this.entireBuffer=n),r(null,this.entireBuffer||n,o,s)}catch(e){r(e)}})),this.request}fetchBand(t,r,i){const n=this._mrt;if(!this._isHeaderLoaded||!n)return void i(new Error("Tile header is not ready"));const o=this.actor;if(!o)return void i(new Error("Can't fetch tile band without an actor"));let s;const a=(e,n)=>{s.complete(e,n),e?i(e):(this.updateTextureDescriptor(t,r),i(null,this.textureDescriptor&&this.textureDescriptor.img))},l=(e,t)=>{if(e)return i(e);const r=o.send("decodeRasterArray",{buffer:t,task:s},a,void 0,!0);this._workQueue.push((()=>{r&&r.cancel(),s.cancel()}))},c=n.getLayer(t);if(!c)return void i(new Error(`Unknown sourceLayer "${t}"`));if(c.hasDataForBand(r))return this.updateTextureDescriptor(t,r),void i(null,this.textureDescriptor?this.textureDescriptor.img:null);const u=c.getDataRange([r]);if(s=n.createDecodingTask(u),!s||s.tasks.length)if(this.flushQueues(),this.entireBuffer)l(null,this.entireBuffer.slice(u.firstByte,u.lastByte+1));else{const t=Object.assign({},this.requestParams,{headers:{Range:`bytes=${u.firstByte}-${u.lastByte}`}}),r=e.b1(t,l);this._fetchQueue.push((()=>{r.cancel(),s.cancel()}))}else i(null)}updateNeeded(e,t){return(!this.textureDescriptor||this.textureDescriptor.band!==t||this.textureDescriptor.layer!==e)&&"errored"!==this.state}updateTextureDescriptor(t,r){if(!this._mrt)return;const i=this._mrt.getLayer(t);if(!i||!i.hasBand(r)||!i.hasDataForBand(r))return;const{bytes:n,tileSize:o,buffer:s,offset:a,scale:l}=i.getBandView(r),c=o+2*s,u={data:n,width:c,height:c},h=this.texture;h&&h instanceof e.T&&h.update(u,{useMipmap:!1,premultiply:!1}),this.textureDescriptor={layer:t,band:r,img:u,buffer:s,offset:a,tileSize:o,format:i.pixelFormat,mix:[l,256*l,65536*l,16777216*l]}}}class Qt{constructor(e,t){this.max=e,this.onRemove=t,this.reset()}reset(){for(const e in this.data)for(const t of this.data[e])t.timeout&&clearTimeout(t.timeout),this.onRemove(t.value);return this.data={},this.order=[],this}add(e,t,r){const i=e.wrapped().key;void 0===this.data[i]&&(this.data[i]=[]);const n={value:t,timeout:void 0};if(void 0!==r&&(n.timeout=setTimeout((()=>{this.remove(e,n)}),r)),this.data[i].push(n),this.order.push(i),this.order.length>this.max){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){const t=this.data[e].shift();return t.timeout&&clearTimeout(t.timeout),0===this.data[e].length&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),t.value}getByKey(e){const t=this.data[e];return t?t[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,t){if(!this.has(e))return this;const r=e.wrapped().key,i=void 0===t?0:this.data[r].indexOf(t),n=this.data[r][i];return this.data[r].splice(i,1),n.timeout&&clearTimeout(n.timeout),0===this.data[r].length&&delete this.data[r],this.onRemove(n.value),this.order.splice(this.order.indexOf(r),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}filter(e){const t=[];for(const r in this.data)for(const i of this.data[r])e(i.value)||t.push(i);for(const e of t)this.remove(e.value.tileID,e)}}class qt extends e.E{constructor(e,t,r){super(),this.id=e,this._onlySymbols=r,t.on("data",(e=>{"source"===e.dataType&&"metadata"===e.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===e.dataType&&"content"===e.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))})),t.on("error",(()=>{this._sourceErrored=!0})),this._source=t,this._tiles={},this._cache=new Qt(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new x,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(e){this.map=e,this._minTileCacheSize=void 0===this._minTileCacheSize&&e?e._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&e?e._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const e in this._tiles){const t=this._tiles[e];if("errored"!==t.state&&("loaded"!==t.state||!t.bucketsLoaded()))return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(e,t){return e.isSymbolTile=this._onlySymbols,e.isExtraShadowCaster=this._shadowCasterTiles[e.tileID.key],this._source.loadTile(e,t)}_unloadTile(e){if(this._source.unloadTile)return this._source.unloadTile(e,(()=>{}))}_abortTile(e){if(this._source.abortTile)return this._source.abortTile(e,(()=>{}))}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const t in this._tiles){const r=this._tiles[t];r.upload(e),r.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return e.b2(this._tiles).map((e=>e.tileID)).sort(Xt).map((e=>e.key))}getRenderableIds(t,r){const i=[];for(const e in this._tiles)this._isIdRenderable(+e,t,r)&&i.push(this._tiles[e]);return t?i.sort(((t,r)=>{const i=t.tileID,n=r.tileID,o=new e.P(i.canonical.x,i.canonical.y)._rotate(this.transform.angle),s=new e.P(n.canonical.x,n.canonical.y)._rotate(this.transform.angle);return i.overscaledZ-n.overscaledZ||s.y-o.y||s.x-o.x})).map((e=>e.tileID.key)):i.map((e=>e.tileID)).sort(Xt).map((e=>e.key))}hasRenderableParent(e){const t=this.findLoadedParent(e,0);return!!t&&this._isIdRenderable(t.tileID.key)}_isIdRenderable(e,t,r){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(t||!this._tiles[e].holdingForFade())&&(r||!this._shadowCasterTiles[e])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const e in this._tiles)"errored"!==this._tiles[e].state&&this._reloadTile(+e,"reloading")}}_reloadTile(e,t){const r=this._tiles[e];r&&("loading"!==r.state&&(r.state=t),this._loadTile(r,this._tileLoaded.bind(this,r,e,t)))}_tileLoaded(t,r,i,n){if(n)if(t.state="errored",404!==n.status)this._source.fire(new e.a(n,{tile:t}));else{if(!(t.tileID.key in this._loadedParentTiles))return void this._source.fire(new e.b("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id}));if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const e=this.map.painter.terrain;this.update(this.transform,e.getScaledDemTileSize(),!0),e.resetTileLookupCache(this.id)}else this.update(this.transform)}else t.timeAdded=e.f.now(),"expired"===i&&(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 e.b("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id}))}_backfillDEM(e){const t=this.getRenderableIds();for(let i=0;i<t.length;i++){const n=t[i];if(e.neighboringTiles&&e.neighboringTiles[n]){const t=this.getTileByID(n);r(e,t),r(t,e)}}function r(e,t){if(!e.dem||e.dem.borderReady)return;e.needsHillshadePrepare=!0,e.needsDEMTextureUpload=!0;let r=t.tileID.canonical.x-e.tileID.canonical.x;const i=t.tileID.canonical.y-e.tileID.canonical.y,n=Math.pow(2,e.tileID.canonical.z),o=t.tileID.key;0===r&&0===i||Math.abs(i)>1||(Math.abs(r)>1&&(1===Math.abs(r+n)?r+=n:1===Math.abs(r-n)&&(r-=n)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,r,i),e.neighboringTiles&&e.neighboringTiles[o]&&(e.neighboringTiles[o].backfilled=!0)))}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,t,r,i){for(const n in this._tiles){let o=this._tiles[n];if(i[n]||!o.hasData()||o.tileID.overscaledZ<=t||o.tileID.overscaledZ>r)continue;let s=o.tileID;for(;o&&o.tileID.overscaledZ>t+1;){const e=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[e.key],o&&o.hasData()&&(s=e)}let a=s;for(;a.overscaledZ>t;)if(a=a.scaledTo(a.overscaledZ-1),e[a.key]){i[s.key]=s;break}}}findLoadedParent(e,t){if(e.key in this._loadedParentTiles){const r=this._loadedParentTiles[e.key];return r&&r.tileID.overscaledZ>=t?r:null}for(let r=e.overscaledZ-1;r>=t;r--){const t=e.scaledTo(r),i=this._getLoadedTile(t);if(i)return i}}_getLoadedTile(e){const t=this._tiles[e.key];return t&&t.hasData()?t:this._cache.getByKey(this._source.reparseOverscaled?e.wrapped().key:e.canonical.key)}updateCacheSize(e,t){t=t||this._source.tileSize;const r=Math.ceil(e.width/t)+1,i=Math.ceil(e.height/t)+1,n=Math.floor(r*i*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,n):n,s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(s)}handleWrapJump(e){const t=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);if(this._prevLng=e,t){const e={};for(const r in this._tiles){const i=this._tiles[r];i.tileID=i.tileID.unwrapTo(i.tileID.wrap+t),e[i.tileID.key]=i}this._tiles=e;for(const e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const e in this._tiles)this._setTileReloadTimer(+e,this._tiles[e])}}update(t,r,i,n){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!i)return;let o;if(this.updateCacheSize(t,r),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={},this.used||this.usedForTerrain)if(this._source.tileID)o=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new e.ap(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y)));else if(0!==this.tileCoverLift){const n=t.clone();n.tileCoverLift=this.tileCoverLift,o=n.coveringTiles({tileSize:r||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!i,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.minzoom<=1&&"globe"===t.projection.name&&(o.push(new e.ap(1,0,1,0,0)),o.push(new e.ap(1,0,1,1,0)),o.push(new e.ap(1,0,1,0,1)),o.push(new e.ap(1,0,1,1,1)))}else o=t.coveringTiles({tileSize:r||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!i,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(o=o.filter((e=>this._source.hasTile(e))));else o=[];if(o.length>0&&this.castsShadows&&n&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!Yt(this._source.type)){const e=t.coveringZoomLevel({tileSize:r||this._source.tileSize,roundZoom:this._source.roundZoom&&!i}),s=Math.min(e,this._source.maxzoom),a=t.extendTileCoverForShadows(o,n,s);for(const e of a)this._shadowCasterTiles[e.key]=!0,o.push(e)}const s=this._updateRetainedTiles(o);if(Yt(this._source.type)&&0!==o.length){const t={},r={},i=Object.keys(s);for(const n of i){const i=s[n],o=this._tiles[n];if(!o||o.fadeEndTime&&o.fadeEndTime<=e.f.now())continue;const a=this.findLoadedParent(i,Math.max(i.overscaledZ-qt.maxOverzooming,this._source.minzoom));a&&(this._addTile(a.tileID),t[a.tileID.key]=a.tileID),r[n]=i}const n=o[o.length-1].overscaledZ;for(const e in this._tiles){const t=this._tiles[e];if(s[e]||!t.hasData())continue;let i=t.tileID;for(;i.overscaledZ>n;){i=i.scaledTo(i.overscaledZ-1);const n=this._tiles[i.key];if(n&&n.hasData()&&r[i.key]){s[e]=t.tileID;break}}}for(const e in t)s[e]||(this._coveredTiles[e]=!0,s[e]=t[e])}for(const e in s)this._tiles[e].clearFadeHold();const a=e.b3(this._tiles,s);for(const e of a){const t=this._tiles[e];t.hasSymbolBuckets&&!t.holdingForFade()?t.setHoldDuration(this.map._fadeDuration):t.hasSymbolBuckets&&!t.symbolFadeFinished()||this._removeTile(+e)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(+e)}_updateRetainedTiles(e){const t={};if(0===e.length)return t;const r={},i=e.reduce(((e,t)=>Math.min(e,t.overscaledZ)),1/0),n=e[0].overscaledZ,o=Math.max(n-qt.maxOverzooming,this._source.minzoom),s=Math.max(n+qt.maxUnderzooming,this._source.minzoom),a={};for(const r of e){const e=this._addTile(r);t[r.key]=r,e.hasData()||i<this._source.maxzoom&&(a[r.key]=r)}this._retainLoadedChildren(a,i,s,t);for(const i of e){let e=this._tiles[i.key];if(e.hasData())continue;if(i.canonical.z>=this._source.maxzoom){const e=i.children(this._source.maxzoom)[0],r=this.getTile(e);if(r&&r.hasData()){t[e.key]=e;continue}}else{const e=i.children(this._source.maxzoom);if(t[e[0].key]&&t[e[1].key]&&t[e[2].key]&&t[e[3].key])continue}let n=e.wasRequested();for(let s=i.overscaledZ-1;s>=o;--s){const o=i.scaledTo(s);if(r[o.key])break;if(r[o.key]=!0,e=this.getTile(o),!e&&n&&(e=this._addTile(o)),e&&(t[o.key]=o,n=e.wasRequested(),e.hasData()))break}}return t}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const t=[];let r,i=this._tiles[e].tileID;for(;i.overscaledZ>0;){if(i.key in this._loadedParentTiles){r=this._loadedParentTiles[i.key];break}t.push(i.key);const e=i.scaledTo(i.overscaledZ-1);if(r=this._getLoadedTile(e),r)break;i=e}for(const e of t)this._loadedParentTiles[e]=r}}_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 i=Boolean(r);if(!i){const e=this.map?this.map.painter:null,i=this._source.tileSize*t.overscaleFactor();r="raster-array"===this._source.type?new Wt(t,i,this.transform.tileZoom,e,this._isRaster):new jt(t,i,this.transform.tileZoom,e,this._isRaster),this._loadTile(r,this._tileLoaded.bind(this,r,t.key,r.state))}return r?(r.uses++,this._tiles[t.key]=r,i||this._source.fire(new e.b("dataloading",{tile:r,coord:r.tileID,dataType:"source"})),r):null}_setTileReloadTimer(e,t){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const r=t.getExpiryTimeout();r&&(this._timers[e]=setTimeout((()=>{this._reloadTile(e,"expired"),delete this._timers[e]}),r))}_removeTile(e){const t=this._tiles[e];t&&(t.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),t.uses>0||(t.hasData()&&"reloading"!==t.state||"empty"===t.state?this._cache.add(t.tileID,t,t.getExpiryTimeout()):(t.aborted=!0,this._abortTile(t),this._unloadTile(t))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(+e);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,i){const n=[],o=this.transform;if(!o)return n;const s="globe"===o.projection.name,a=e.a8(o.center.lng);for(const l in this._tiles){const c=this._tiles[l];if(i&&c.clearQueryDebugViz(),c.holdingForFade())continue;let u;if(s){const t=c.tileID.canonical;if(0===t.z){const r=[Math.abs(e.ad(a,...$t(t,-1))-a),Math.abs(e.ad(a,...$t(t,1))-a)];u=[0,2*r.indexOf(Math.min(...r))-1]}else{const r=[Math.abs(e.ad(a,...$t(t,-1))-a),Math.abs(e.ad(a,...$t(t,0))-a),Math.abs(e.ad(a,...$t(t,1))-a)];u=[r.indexOf(Math.min(...r))-1]}}else u=[0];for(const e of u){const i=t.containsTile(c,o,r,e);i&&n.push(i)}}return n}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(e){return this._getRenderableCoordinates(e)}_getRenderableCoordinates(e,t){const r=this.getRenderableIds(e,t).map((e=>this._tiles[e].tileID)),i="globe"===this.transform.projection.name;for(const e of r)e.projMatrix=this.transform.calculateProjMatrix(e.toUnwrapped()),e.expandedProjMatrix=i?this.transform.calculateProjMatrix(e.toUnwrapped(),!1,!0):e.projMatrix;return r}sortCoordinatesByDistance(e){const t=e.slice(),r=this.transform._camera.position,i=this.transform._camera.forward(),n={};for(const e of t){const t=1/(1<<e.canonical.z);n[e.key]=((e.canonical.x+.5)*t+e.wrap-r[0])*i[0]+((e.canonical.y+.5)*t-r[1])*i[1]-r[2]*i[2]}return t.sort(((e,t)=>n[e.key]-n[t.key])),t}hasTransition(){if(this._source.hasTransition())return!0;if(Yt(this._source.type))for(const t in this._tiles){const r=this._tiles[t];if(void 0!==r.fadeEndTime&&r.fadeEndTime>=e.f.now())return!0}return!1}setFeatureState(e,t,r){this._state.updateState(e=e||"_geojsonTileLayer",t,r)}removeFeatureState(e,t,r){this._state.removeFeatureState(e=e||"_geojsonTileLayer",t,r)}getFeatureState(e,t){return this._state.getState(e=e||"_geojsonTileLayer",t)}setDependencies(e,t,r){const i=this._tiles[e];i&&i.setDependencies(t,r)}reloadTilesForDependencies(e,t){for(const r in this._tiles)this._tiles[r].hasDependency(e,t)&&this._reloadTile(+r,"reloading");this._cache.filter((r=>!r.hasDependency(e,t)))}_preloadTiles(t,r){if(!this._sourceLoaded){const e=()=>{this._sourceLoaded&&(this._source.off("data",e),this._preloadTiles(t,r))};return void this._source.on("data",e)}const i=new Map,n=Array.isArray(t)?t:[t],o=this.map.painter.terrain,s=this.usedForTerrain&&o?o.getScaledDemTileSize():this._source.tileSize;for(const e of n){const t=e.coveringTiles({tileSize:s,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const e of t)i.set(e.key,e);this.usedForTerrain&&e.updateElevation(!1)}const a=Array.from(i.values());e.b4(a,((e,t)=>{const r=new jt(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(r,(e=>{"raster-dem"===this._source.type&&r.dem&&this._backfillDEM(r),t(e,r)}))}),r)}}function Xt(e,t){const r=Math.abs(2*e.wrap)-+(e.wrap<0),i=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||i-r||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function Yt(e){return"raster"===e||"image"===e||"video"===e||"custom"===e}function $t(e,t){const r=1<<e.z;return[e.x/r+t,(e.x+1)/r+t]}qt.maxOverzooming=10,qt.maxUnderzooming=3;class Kt{constructor(e){this.style=e,this.layersGotHidden=!1,this.layers=[]}processLayersChanged(){this.layers=[];const e=!1,t=!1;for(const r in this.style._mergedLayers){const i=this.style._mergedLayers[r];if("fill-extrusion"===i.type)this.layers.push({layer:i,visible:e,visibilityChanged:t});else if("model"===i.type){const r=this.style.getLayerSource(i);r&&"batched-model"===r.type&&this.layers.push({layer:i,visible:e,visibilityChanged:t})}}}onNewFrame(e){this.layersGotHidden=!1;for(const t of this.layers){const r=t.layer;let i=!1;"fill-extrusion"===r.type?i=!r.isHidden(e)&&r.paint.get("fill-extrusion-opacity")>0:"model"===r.type&&(i=!r.isHidden(e)&&r.paint.get("model-opacity")>0),this.layersGotHidden=this.layersGotHidden||!i&&t.visible,t.visible=i}}updateZOffset(e,t){this.currentBuildingBuckets=[];for(const e of this.layers){const r=e.layer,i=this.style.getLayerSourceCache(r);let n=1;"fill-extrusion"===r.type&&(n=e.visible?r.paint.get("fill-extrusion-vertical-scale"):0);let o=i?i.getTile(t):null;if(!o&&i&&t.canonical.z>i.getSource().minzoom){let e=t.scaledTo(Math.min(i.getSource().maxzoom,t.overscaledZ-1));for(;e.overscaledZ>=i.getSource().minzoom&&(o=i.getTile(e),!o&&0!==e.overscaledZ);)e=e.scaledTo(e.overscaledZ-1)}this.currentBuildingBuckets.push({bucket:o?o.getBucket(r):null,tileID:o?o.tileID:t,verticalScale:n})}e.hasAnyZOffset=!1;let r=!1;for(let i=0;i<e.symbolInstances.length;i++){const n=e.symbolInstances.get(i),o=n.zOffset,s=this._getHeightAtTileOffset(t,n.tileAnchorX,n.tileAnchorY);n.zOffset=s!==Number.NEGATIVE_INFINITY?s:o,r||o===n.zOffset||(r=!0),e.hasAnyZOffset||0===n.zOffset||(e.hasAnyZOffset=!0)}r&&(e.zOffsetBuffersNeedUpload=!0,e.zOffsetSortDirty=!0)}_mapCoordToOverlappingTile(t,r,i,n){let o=r,s=i;if(t.canonical.z!==n.canonical.z){const a=n.canonical,l=1/(1<<t.canonical.z-a.z);o=(r+t.canonical.x*e.Y)*l-a.x*e.Y|0,s=(i+t.canonical.y*e.Y)*l-a.y*e.Y|0}return{tileX:o,tileY:s}}_getHeightAtTileOffset(e,t,r){let i,n;for(let o=0;o<this.layers.length;++o){if("fill-extrusion"!==this.layers[o].layer.type)continue;const{bucket:s,tileID:a,verticalScale:l}=this.currentBuildingBuckets[o];if(!s)continue;const{tileX:c,tileY:u}=this._mapCoordToOverlappingTile(e,t,r,a),h=s.getHeightAtTileCoord(c,u);h&&void 0!==h.height&&(h.hidden?i=h.height:n=Math.max(h.height*l,n||0))}if(void 0!==n)return n;for(let n=0;n<this.layers.length;++n){const o=this.layers[n];if("model"!==o.layer.type||!o.visible)continue;const{bucket:s,tileID:a}=this.currentBuildingBuckets[n];if(!s)continue;const{tileX:l,tileY:c}=this._mapCoordToOverlappingTile(e,t,r,a),u=s.getHeightAtTileCoord(l,c);if(u&&!u.hidden)return void 0===u.height&&void 0!==i?Math.min(u.maxHeight,i)*u.verticalScale:u.height?u.height*u.verticalScale:Number.NEGATIVE_INFINITY}return this.layersGotHidden?0:Number.NEGATIVE_INFINITY}}function Jt(t,r){const i={};for(const e in t)"ref"!==e&&(i[e]=t[e]);return e.b5.forEach((e=>{e in r&&(i[e]=r[e])})),i}function er(e){e=e.slice();const t=Object.create(null);for(let r=0;r<e.length;r++)t[e[r].id]=e[r];for(let r=0;r<e.length;r++)"ref"in e[r]&&(e[r]=Jt(e[r],t[e[r].ref]));return e}const tr={setStyle:"setStyle",addLayer:"addLayer",removeLayer:"removeLayer",setPaintProperty:"setPaintProperty",setLayoutProperty:"setLayoutProperty",setSlot:"setSlot",setFilter:"setFilter",addSource:"addSource",removeSource:"removeSource",setGeoJSONSourceData:"setGeoJSONSourceData",setLayerZoomRange:"setLayerZoomRange",setLayerProperty:"setLayerProperty",setCenter:"setCenter",setZoom:"setZoom",setBearing:"setBearing",setPitch:"setPitch",setSprite:"setSprite",setGlyphs:"setGlyphs",setTransition:"setTransition",setLight:"setLight",setTerrain:"setTerrain",setFog:"setFog",setCamera:"setCamera",setLights:"setLights",setProjection:"setProjection",addImport:"addImport",removeImport:"removeImport",updateImport:"updateImport"};function rr(e,t,r){r.push({command:tr.addSource,args:[e,t[e]]})}function ir(e,t,r){t.push({command:tr.removeSource,args:[e]}),r[e]=!0}function nr(e,t,r,i){ir(e,r,i),rr(e,t,r)}function or(e,r,i){let n;for(n in e[i])if(e[i].hasOwnProperty(n)&&"data"!==n&&!t(e[i][n],r[i][n]))return!1;for(n in r[i])if(r[i].hasOwnProperty(n)&&"data"!==n&&!t(e[i][n],r[i][n]))return!1;return!0}function sr(e,r,i,n,o,s){let a;for(a in r=r||{},e=e||{})e.hasOwnProperty(a)&&(t(e[a],r[a])||i.push({command:s,args:[n,a,r[a],o]}));for(a in r)r.hasOwnProperty(a)&&!e.hasOwnProperty(a)&&(t(e[a],r[a])||i.push({command:s,args:[n,a,r[a],o]}))}function ar(e){return e.id}function lr(e,t){return e[t.id]=t,e}class cr{constructor(e,t){this.reset(e,t)}reset(e,t){this.points=e||[],this._distances=[0];for(let e=1;e<this.points.length;e++)this._distances[e]=this._distances[e-1]+this.points[e].dist(this.points[e-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(t||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(t){if(1===this.points.length)return this.points[0];t=e.ad(t,0,1);let r=1,i=this._distances[r];const n=t*this.paddedLength+this.padding;for(;i<n&&r<this._distances.length;)i=this._distances[++r];const o=r-1,s=this._distances[o],a=i-s,l=a>0?(n-s)/a:0;return this.points[o].mult(1-l).add(this.points[r].mult(l))}}class ur{constructor(e,t,r){const i=this.boxCells=[],n=this.circleCells=[];this.xCellCount=Math.ceil(e/r),this.yCellCount=Math.ceil(t/r);for(let e=0;e<this.xCellCount*this.yCellCount;e++)i.push([]),n.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=e,this.height=t,this.xScale=this.xCellCount/e,this.yScale=this.yCellCount/t,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(e,t,r,i,n){this._forEachCell(t,r,i,n,this._insertBoxCell,this.boxUid++),this.boxKeys.push(e),this.bboxes.push(t),this.bboxes.push(r),this.bboxes.push(i),this.bboxes.push(n)}insertCircle(e,t,r,i){this._forEachCell(t-i,r-i,t+i,r+i,this._insertCircleCell,this.circleUid++),this.circleKeys.push(e),this.circles.push(t),this.circles.push(r),this.circles.push(i)}_insertBoxCell(e,t,r,i,n,o){this.boxCells[n].push(o)}_insertCircleCell(e,t,r,i,n,o){this.circleCells[n].push(o)}_query(e,t,r,i,n,o){if(r<0||e>this.width||i<0||t>this.height)return!n&&[];const s=[];if(e<=0&&t<=0&&this.width<=r&&this.height<=i){if(n)return!0;for(let e=0;e<this.boxKeys.length;e++)s.push({key:this.boxKeys[e],x1:this.bboxes[4*e],y1:this.bboxes[4*e+1],x2:this.bboxes[4*e+2],y2:this.bboxes[4*e+3]});for(let e=0;e<this.circleKeys.length;e++){const t=this.circles[3*e],r=this.circles[3*e+1],i=this.circles[3*e+2];s.push({key:this.circleKeys[e],x1:t-i,y1:r-i,x2:t+i,y2:r+i})}return o?s.filter(o):s}return this._forEachCell(e,t,r,i,this._queryCell,s,{hitTest:n,seenUids:{box:{},circle:{}}},o),n?s.length>0:s}_queryCircle(e,t,r,i,n){const o=e-r,s=e+r,a=t-r,l=t+r;if(s<0||o>this.width||l<0||a>this.height)return!i&&[];const c=[];return this._forEachCell(o,a,s,l,this._queryCellCircle,c,{hitTest:i,circle:{x:e,y:t,radius:r},seenUids:{box:{},circle:{}}},n),i?c.length>0:c}query(e,t,r,i,n){return this._query(e,t,r,i,!1,n)}hitTest(e,t,r,i,n){return this._query(e,t,r,i,!0,n)}hitTestCircle(e,t,r,i){return this._queryCircle(e,t,r,!0,i)}_queryCell(e,t,r,i,n,o,s,a){const l=s.seenUids,c=this.boxCells[n];if(null!==c){const n=this.bboxes;for(const u of c)if(!l.box[u]){l.box[u]=!0;const c=4*u;if(e<=n[c+2]&&t<=n[c+3]&&r>=n[c+0]&&i>=n[c+1]&&(!a||a(this.boxKeys[u]))){if(s.hitTest)return o.push(!0),!0;o.push({key:this.boxKeys[u],x1:n[c],y1:n[c+1],x2:n[c+2],y2:n[c+3]})}}}const u=this.circleCells[n];if(null!==u){const n=this.circles;for(const c of u)if(!l.circle[c]){l.circle[c]=!0;const u=3*c;if(this._circleAndRectCollide(n[u],n[u+1],n[u+2],e,t,r,i)&&(!a||a(this.circleKeys[c]))){if(s.hitTest)return o.push(!0),!0;{const e=n[u],t=n[u+1],r=n[u+2];o.push({key:this.circleKeys[c],x1:e-r,y1:t-r,x2:e+r,y2:t+r})}}}}}_queryCellCircle(e,t,r,i,n,o,s,a){const l=s.circle,c=s.seenUids,u=this.boxCells[n];if(null!==u){const e=this.bboxes;for(const t of u)if(!c.box[t]){c.box[t]=!0;const r=4*t;if(this._circleAndRectCollide(l.x,l.y,l.radius,e[r+0],e[r+1],e[r+2],e[r+3])&&(!a||a(this.boxKeys[t])))return o.push(!0),!0}}const h=this.circleCells[n];if(null!==h){const e=this.circles;for(const t of h)if(!c.circle[t]){c.circle[t]=!0;const r=3*t;if(this._circlesCollide(e[r],e[r+1],e[r+2],l.x,l.y,l.radius)&&(!a||a(this.circleKeys[t])))return o.push(!0),!0}}}_forEachCell(e,t,r,i,n,o,s,a){const l=this._convertToXCellCoord(e),c=this._convertToYCellCoord(t),u=this._convertToXCellCoord(r),h=this._convertToYCellCoord(i);for(let d=l;d<=u;d++)for(let l=c;l<=h;l++)if(n.call(this,e,t,r,i,this.xCellCount*l+d,o,s,a))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,t,r,i,n,o){const s=i-e,a=n-t,l=r+o;return l*l>s*s+a*a}_circleAndRectCollide(e,t,r,i,n,o,s){const a=(o-i)/2,l=Math.abs(e-(i+a));if(l>a+r)return!1;const c=(s-n)/2,u=Math.abs(t-(n+c));if(u>c+r)return!1;if(l<=a||u<=c)return!0;const h=l-a,d=u-c;return h*h+d*d<=r*r}}const hr={unknown:0,flipRequired:1,flipNotRequired:2},dr=Math.tan(85*Math.PI/180);function pr(t,r,i,n,o,s,a){const l=e.a9.create();if(i)if("globe"===s.name){const t=e.b6(o,r);e.a9.multiply(l,l,t)}else{const t=e.b7.invert([],a);l[0]=t[0],l[1]=t[1],l[4]=t[2],l[5]=t[3],n||e.a9.rotateZ(l,l,o.angle)}else e.a9.multiply(l,o.labelPlaneMatrix,t);return l}function fr(e,t,r,i,n,o,s){const a=pr(e,t,r,i,n,o,s);return"globe"===o.name&&r||(a[2]=a[6]=a[10]=a[14]=0),a}function mr(t,r,i,n,o,s,a){if(i){if("globe"===s.name){const l=pr(t,r,i,n,o,s,a);return e.a9.invert(l,l),e.a9.multiply(l,t,l),l}{const r=e.a9.clone(t),i=e.a9.identity([]);return i[0]=a[0],i[1]=a[1],i[4]=a[2],i[5]=a[3],e.a9.multiply(r,r,i),n||e.a9.rotateZ(r,r,-o.angle),r}}return o.glCoordMatrix}function Ar(t,r,i,n){const o=[t,r,i,1];i?e.aa.transformMat4(o,o,n):Mr(o,o,n);const s=o[3];return o[0]/=s,o[1]/=s,o[2]/=s,o}function gr(e,t){return Math.min(.5+e/t*.5,1.5)}function _r(e,t){const r=e[0]/e[3],i=e[1]/e[3];return r>=-t[0]&&r<=t[0]&&i>=-t[1]&&i<=t[1]}function yr(t,r,i,n,o,s,a,l,c,u){const h=i.transform,d=n?t.textSizeData:t.iconSizeData,p=e.b8(d,i.transform.zoom),f="globe"===h.projection.name,m=[256/i.width*2+1,256/i.height*2+1],A=n?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;A.clear();let g=null;f&&(g=n?t.text.globeExtVertexArray:t.icon.globeExtVertexArray);const _=t.lineVertexArray,y=n?t.text.placedSymbolArray:t.icon.placedSymbolArray,x=i.transform.width/i.transform.height;let v,b=!1;for(let n=0;n<y.length;n++){const f=y.get(n),{numGlyphs:w,writingMode:C}=f;if(C!==e.b9.vertical||b||v===e.b9.horizontal||(b=!0),v=C,(f.hidden||C===e.b9.vertical)&&!b){Er(w,A);continue}b=!1;const T=new e.P(f.tileAnchorX,f.tileAnchorY);let{x:E,y:M,z:S}=h.projection.projectTilePoint(T.x,T.y,u.canonical);if(c){const[e,t,r]=c(T);E+=e,M+=t,S+=r}const I=[E,M,S,1];if(e.aa.transformMat4(I,I,r),!_r(I,m)){Er(w,A);continue}const P=I[3],D=gr(i.transform.getCameraToCenterDistance(h.projection),P),k=e.ba(d,p,f),L=a?k/D:k*D,z=Ar(E,M,S,o);if(z[3]<=0){Er(w,A);continue}let O={};const B=a?null:c,R=br(f,L,!1,l,r,o,s,t.glyphOffsetArray,_,A,g,z,T,O,x,B,h.projection,u,a);b=R.useVertical,B&&R.needsFlipping&&(O={}),(R.notEnoughRoom||b||R.needsFlipping&&br(f,L,!0,l,r,o,s,t.glyphOffsetArray,_,A,g,z,T,O,x,B,h.projection,u,a).notEnoughRoom)&&Er(w,A)}n?(t.text.dynamicLayoutVertexBuffer.updateData(A),g&&t.text.globeExtVertexBuffer&&t.text.globeExtVertexBuffer.updateData(g)):(t.icon.dynamicLayoutVertexBuffer.updateData(A),g&&t.icon.globeExtVertexBuffer&&t.icon.globeExtVertexBuffer.updateData(g))}function xr(e,t,r,i,n,o,s,a,l,c,u,h,d,p,f,m){const{lineStartIndex:A,glyphStartIndex:g,segment:_}=a,y=g+a.numGlyphs,x=A+a.lineLength,v=t.getoffsetX(g),b=t.getoffsetX(y-1),w=Tr(e*v,r,i,n,o,s,_,A,x,l,c,u,h,d,!0,p,f,m);if(!w)return null;const C=Tr(e*b,r,i,n,o,s,_,A,x,l,c,u,h,d,!0,p,f,m);return C?{first:w,last:C}:null}function vr(t,r,i,n){return t===e.b9.horizontal&&Math.abs(n)>Math.abs(i)?{useVertical:!0}:t===e.b9.vertical?n>0?{needsFlipping:!0}:null:r!==hr.unknown&&function(e,t){return 0===e||Math.abs(t/e)>dr}(i,n)?r===hr.flipRequired?{needsFlipping:!0}:null:i<0?{needsFlipping:!0}:null}function br(t,r,i,n,o,s,a,l,c,u,h,d,p,f,m,A,g,_,y){const x=r/24,v=t.lineOffsetX*x,b=t.lineOffsetY*x,{lineStartIndex:w,glyphStartIndex:C,numGlyphs:T,segment:E,writingMode:M,flipState:S}=t,I=w+t.lineLength,P=t=>{if(h){const[r,i,n]=t.up,o=u.length;e.bb(h,o+0,r,i,n),e.bb(h,o+1,r,i,n),e.bb(h,o+2,r,i,n),e.bb(h,o+3,r,i,n)}const[r,i,n]=t.point;e.bc(u,r,i,n,t.angle)};if(T>1){const e=xr(x,l,v,b,i,d,p,t,c,s,f,A,!1,g,_,y);if(!e)return{notEnoughRoom:!0};if(n&&!i){let[r,i,n]=e.first.point,[o,s,l]=e.last.point;[r,i]=Ar(r,i,n,a),[o,s]=Ar(o,s,l,a);const c=vr(M,S,(o-r)*m,s-i);if(t.flipState=c&&c.needsFlipping?hr.flipRequired:hr.flipNotRequired,c)return c}P(e.first);for(let e=C+1;e<C+T-1;e++){const t=Tr(x*l.getoffsetX(e),v,b,i,d,p,E,w,I,c,s,f,A,!1,!1,g,_,y);if(!t)return u.length-=4*(e-C),{notEnoughRoom:!0};P(t)}P(e.last)}else{if(n&&!i){const r=Ar(p.x,p.y,0,o),i=w+E+1,n=new e.P(c.getx(i),c.gety(i)),s=Ar(n.x,n.y,0,o),a=s[3]>0?s:Cr(p,n,r,1,o,void 0,g,_.canonical),l=vr(M,S,(a[0]-r[0])*m,a[1]-r[1]);if(t.flipState=l&&l.needsFlipping?hr.flipRequired:hr.flipNotRequired,l)return l}const r=Tr(x*l.getoffsetX(C),v,b,i,d,p,E,w,I,c,s,f,A,!1,!1,g,_,y);if(!r)return{notEnoughRoom:!0};P(r)}return{}}function wr(e,t,r,i,n){const{x:o,y:s,z:a}=i.projectTilePoint(e.x,e.y,t);if(!n)return Ar(o,s,a,r);const[l,c,u]=n(e);return Ar(o+l,s+c,a+u,r)}function Cr(t,r,i,n,o,s,a,l){const c=wr(t.sub(r)._unit()._add(t),l,o,a,s);return e.Q.sub(c,i,c),e.Q.normalize(c,c),e.Q.scaleAndAdd(c,i,c,n)}function Tr(t,r,i,n,o,s,a,l,c,u,h,d,p,f,m,A,g,_){const y=n?t-r:t+r;let x=y>0?1:-1,v=0;n&&(x*=-1,v=Math.PI),x<0&&(v+=Math.PI);let b=l+a+(x>0?0:1)|0,w=o,C=o,T=0,E=0;const M=Math.abs(y),S=[],I=[];let P=s,D=P;const k=()=>Cr(D,P,C,M-T+1,h,p,A,g.canonical);for(;T+E<=M;){if(b+=x,b<l||b>=c)return null;if(C=w,D=P,S.push(C),f&&I.push(D),P=new e.P(u.getx(b),u.gety(b)),w=d[b],!w){const e=wr(P,g.canonical,h,A,p);w=e[3]>0?d[b]=e:k()}T+=E,E=e.Q.distance(C,w)}m&&p&&(d[b]&&(w=k(),E=e.Q.distance(C,w)),d[b]=w);const L=(M-T)/E,z=P.sub(D)._mult(L)._add(D),O=e.Q.sub([],w,C),B=e.Q.scaleAndAdd([],C,O,L);let R=[0,0,1],F=O[0],j=O[1];if(_&&(R=A.upVector(g.canonical,z.x,z.y),0!==R[0]||0!==R[1]||1!==R[2])){const t=[R[2],0,-R[0]],r=e.Q.cross([],R,t);e.Q.normalize(t,t),e.Q.normalize(r,r),F=e.Q.dot(O,t),j=e.Q.dot(O,r)}if(i){const t=e.Q.cross([],R,O);e.Q.normalize(t,t),e.Q.scaleAndAdd(B,B,t,i*x)}const V=v+Math.atan2(j,F);return S.push(B),f&&I.push(z),{point:B,angle:V,path:S,tilePath:I,up:R}}function Er(e,t){const r=t.length,i=r+4*e;t.resize(i),t.float32.fill(-1/0,4*r,4*i)}function Mr(e,t,r){const i=t[0],n=t[1];return e[0]=r[0]*i+r[4]*n+r[12],e[1]=r[1]*i+r[5]*n+r[13],e[3]=r[3]*i+r[7]*n+r[15],e}const Sr=100;class Ir{constructor(e,t,r=new ur(e.width+200,e.height+200,25),i=new ur(e.width+200,e.height+200,25)){this.transform=e,this.grid=r,this.ignoredGrid=i,this.pitchfactor=Math.cos(e._pitch)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+Sr,this.screenBottomBoundary=e.height+Sr,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.fogState=t}placeCollisionBox(e,t,r,i,n,o,s,a){let l=r.projectedAnchorX,c=r.projectedAnchorY,u=r.projectedAnchorZ;const h=r.elevation,d=r.tileID,p=e.getProjection();if(h&&d){const[e,t,i]=p.upVector(d.canonical,r.tileAnchorX,r.tileAnchorY),n=p.upVectorScale(d.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;l+=e*h*n,c+=t*h*n,u+=i*h*n}const f=this.projectAndGetPerspectiveRatio(s,l,c,u,r.tileID,"globe"===p.name||!!h||this.transform.pitch>0,p),m=o*f.perspectiveRatio,A=(r.x1*t+i.x-r.padding)*m+f.point.x,g=(r.y1*t+i.y-r.padding)*m+f.point.y,_=(r.x2*t+i.x+r.padding)*m+f.point.x,y=(r.y2*t+i.y+r.padding)*m+f.point.y,x=f.perspectiveRatio<=.55||f.occluded;return!this.isInsideGrid(A,g,_,y)||!n&&this.grid.hitTest(A,g,_,y,a)||x?{box:[],offscreen:!1,occluded:f.occluded}:{box:[A,g,_,y],offscreen:this.isOffscreen(A,g,_,y),occluded:!1}}placeCollisionCircles(t,r,i,n,o,s,a,l,c,u,h,d,p,f,m){const A=[],g=this.transform.elevation,_=t.getProjection(),y=g?g.getAtTileOffsetFunc(m,this.transform.center.lat,this.transform.worldSize,_):null,x=new e.P(i.tileAnchorX,i.tileAnchorY);let{x:v,y:b,z:w}=_.projectTilePoint(x.x,x.y,m.canonical);if(y){const[e,t,r]=y(x);v+=e,b+=t,w+=r}const C="globe"===_.name,T=this.projectAndGetPerspectiveRatio(a,v,b,w,m,C||!!g||this.transform.pitch>0,_),{perspectiveRatio:E}=T,M=(h?s/E:s*E)/e.bf,S=Ar(v,b,w,l),I=T.signedDistanceFromCamera>0?xr(M,o,i.lineOffsetX*M,i.lineOffsetY*M,!1,S,x,i,n,l,{},g&&!h?y:null,h&&!!g,_,m,h):null;let P=!1,D=!1,k=!0;if(I&&!T.occluded){const t=.5*p*E+f,i=new e.P(-100,-100),n=new e.P(this.screenRightBoundary,this.screenBottomBoundary),o=new cr,{first:s,last:a}=I,l=s.path.length;let h=[];for(let e=l-1;e>=1;e--)h.push(s.path[e]);for(let e=1;e<a.path.length;e++)h.push(a.path[e]);const m=2.5*t;c&&(h=h.map((([e,t,r],i)=>(y&&!C&&(r=y(i<l-1?s.tilePath[l-1-i]:a.tilePath[i-l+2])[2]),Ar(e,t,r,c)))),h.some((e=>e[3]<=0))&&(h=[]));let g=[];if(h.length>0){let t=1/0,r=-1/0,o=1/0,s=-1/0;for(const e of h)t=Math.min(t,e[0]),o=Math.min(o,e[1]),r=Math.max(r,e[0]),s=Math.max(s,e[1]);r>=i.x&&t<=n.x&&s>=i.y&&o<=n.y&&(g=[h.map((t=>new e.P(t[0],t[1])))],(t<i.x||r>n.x||o<i.y||s>n.y)&&(g=e.bd(g,i.x,i.y,n.x,n.y)))}for(const e of g){o.reset(e,.25*t);let i=0;i=o.length<=.5*t?1:Math.ceil(o.paddedLength/m)+1;for(let e=0;e<i;e++){const n=e/Math.max(i-1,1),s=o.lerp(n),a=s.x+Sr,l=s.y+Sr;A.push(a,l,t,0);const c=a-t,h=l-t,p=a+t,f=l+t;if(k=k&&this.isOffscreen(c,h,p,f),D=D||this.isInsideGrid(c,h,p,f),!r&&this.grid.hitTestCircle(a,l,t,d)&&(P=!0,!u))return{circles:[],offscreen:!1,collisionDetected:P,occluded:!1}}}}return{circles:!u&&P||!D?[]:A,offscreen:k,collisionDetected:P,occluded:T.occluded}}queryRenderedSymbols(t){if(0===t.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const r=[];let i=1/0,n=1/0,o=-1/0,s=-1/0;for(const a of t){const t=new e.P(a.x+Sr,a.y+Sr);i=Math.min(i,t.x),n=Math.min(n,t.y),o=Math.max(o,t.x),s=Math.max(s,t.y),r.push(t)}const a=this.grid.query(i,n,o,s).concat(this.ignoredGrid.query(i,n,o,s)),l={},c={};for(const t of a){const i=t.key;if(void 0===l[i.bucketInstanceId]&&(l[i.bucketInstanceId]={}),l[i.bucketInstanceId][i.featureIndex])continue;const n=[new e.P(t.x1,t.y1),new e.P(t.x2,t.y1),new e.P(t.x2,t.y2),new e.P(t.x1,t.y2)];e.be(r,n)&&(l[i.bucketInstanceId][i.featureIndex]=!0,void 0===c[i.bucketInstanceId]&&(c[i.bucketInstanceId]=[]),c[i.bucketInstanceId].push(i.featureIndex))}return c}insertCollisionBox(e,t,r,i,n){(t?this.ignoredGrid:this.grid).insert({bucketInstanceId:r,featureIndex:i,collisionGroupID:n},e[0],e[1],e[2],e[3])}insertCollisionCircles(e,t,r,i,n){const o=t?this.ignoredGrid:this.grid,s={bucketInstanceId:r,featureIndex:i,collisionGroupID:n};for(let t=0;t<e.length;t+=4)o.insertCircle(s,e[t],e[t+1],e[t+2])}projectAndGetPerspectiveRatio(t,r,i,n,o,s,a){const l=[r,i,n,1];let c=!1;if(n||this.transform.pitch>0){if(e.aa.transformMat4(l,l,t),this.fogState&&o&&"globe"!==a.name){const t=function(t,r,i,n,o,s){const a=s.calculateFogTileMatrix(o),l=[r,i,n];return e.Q.transformMat4(l,l,a),fe(t,e.Q.length(l),s.pitch,s._fov)}(this.fogState,r,i,n,o.toUnwrapped(),this.transform);c=t>.9}}else Mr(l,l,t);const u=l[3];return{point:new e.P((l[0]/u+1)/2*this.transform.width+Sr,(-l[1]/u+1)/2*this.transform.height+Sr),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(a)/u*.5,1.5),signedDistanceFromCamera:u,occluded:s&&l[2]>u||c}}isOffscreen(e,t,r,i){return r<Sr||e>=this.screenRightBoundary||i<Sr||t>this.screenBottomBoundary}isInsideGrid(e,t,r,i){return r>=0&&e<this.gridRightBoundary&&i>=0&&t<this.gridBottomBoundary}getViewportMatrix(){const t=e.a9.identity([]);return e.a9.translate(t,t,[-100,-100,0]),t}}function Pr(t,r,i){const n=r.createTileMatrix(t,t.worldSize,i.toUnwrapped());return e.a9.multiply(new Float32Array(16),t.projMatrix,n)}function Dr(e,t,r){if(t.projection.name===r.projection.name)return e.projMatrix;const i=r.clone();return i.setProjection(t.projection),Pr(i,t.getProjection(),e)}function kr(e,t,r){return t.name===r.projection.name?e.projMatrix:Pr(r,t,e)}class Lr{constructor(e,t,r,i){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?t:-t))):i&&r?1:0,this.placed=r}isHidden(){return 0===this.opacity&&!this.placed}}class zr{constructor(e,t,r,i,n,o=!1){this.text=new Lr(e?e.text:null,t,r,n),this.icon=new Lr(e?e.icon:null,t,i,n),this.clipped=o}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class Or{constructor(e,t,r,i=!1){this.text=e,this.icon=t,this.skipFade=r,this.clipped=i}}class Br{constructor(){this.invProjMatrix=e.a9.create(),this.viewportMatrix=e.a9.create(),this.circles=[]}}class Rr{constructor(e,t,r,i,n){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=r,this.bucketIndex=i,this.tileID=n}}class Fr{constructor(e){this.crossSourceCollisions=e,this.maxGroupID=0,this.collisionGroups={}}get(e){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[e]){const t=++this.maxGroupID;this.collisionGroups[e]={ID:t,predicate:e=>e.collisionGroupID===t}}return this.collisionGroups[e]}}function jr(t,r,i,n,o){const{horizontalAlign:s,verticalAlign:a}=e.bi(t),l=-(s-.5)*r,c=-(a-.5)*i,u=e.bh(t,n);return new e.P(l+u[0]*o,c+u[1]*o)}function Vr(t,r,i,n,o){const s=new e.P(t,r);return i&&s._rotate(n?o:-o),s}class Nr{constructor(e,t,r,i,n,o){this.transform=e.clone(),this.projection=e.projection.name,this.collisionIndex=new Ir(this.transform,n),this.buildingIndex=o,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=t,this.retainedQueryData={},this.collisionGroups=new Fr(r),this.collisionCircleArrays={},this.prevPlacement=i,i&&(i.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(t,r,i,n){const o=i.getBucket(r),s=i.latestFeatureIndex;if(!o||!s||r.fqid!==o.layerIds[0])return;const a=o.layers[0].layout,l=i.collisionBoxArray,c=Math.pow(2,this.transform.zoom-i.tileID.overscaledZ),u=i.tileSize/e.Y,h=i.tileID.toUnwrapped();this.transform.setProjection(o.projection);const d=(p=i.tileID,f=o.getProjection(),m=this.transform,f.name===this.projection?m.calculateProjMatrix(p.toUnwrapped()):Pr(m,f,p));var p,f,m;const A="map"===a.get("text-pitch-alignment"),g="map"===a.get("text-rotation-alignment");r.compileFilter();const _=r.dynamicFilter(),y=r.dynamicFilterNeedsFeature(),x=this.transform.calculatePixelsToTileUnitsMatrix(i),v=fr(d,i.tileID.canonical,A,g,this.transform,o.getProjection(),x);let b=null;if(A){const t=mr(d,i.tileID.canonical,A,g,this.transform,o.getProjection(),x);b=e.a9.multiply([],this.transform.labelPlaneMatrix,t)}let w=null;_&&i.latestFeatureIndex&&(w={unwrappedTileID:h,dynamicFilter:_,dynamicFilterNeedsFeature:y,featureIndex:i.latestFeatureIndex}),this.retainedQueryData[o.bucketInstanceId]=new Rr(o.bucketInstanceId,s,o.sourceLayerIndex,o.index,i.tileID);const C={bucket:o,layout:a,posMatrix:d,textLabelPlaneMatrix:v,labelToScreenMatrix:b,clippingData:w,scale:c,textPixelRatio:u,holdingForFade:i.holdingForFade(),collisionBoxArray:l,partiallyEvaluatedTextSize:e.b8(o.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:e.b8(o.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(o.sourceID)};if(n)for(const e of o.sortKeyRanges){const{sortKey:r,symbolInstanceStart:i,symbolInstanceEnd:n}=e;t.push({sortKey:r,symbolInstanceStart:i,symbolInstanceEnd:n,parameters:C})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:o.symbolInstances.length,parameters:C})}attemptAnchorPlacement(e,t,r,i,n,o,s,a,l,c,u,h,d,p,f,m,A,g){const{textOffset0:_,textOffset1:y,crossTileID:x}=h,v=[_,y],b=jr(e,r,i,v,n),w=this.collisionIndex.placeCollisionBox(p,n,t,Vr(b.x,b.y,o,s,this.transform.angle),u,a,l,c.predicate);if(m){const e=p.getSymbolInstanceIconSize(g,this.transform.zoom,h.placedIconSymbolIndex);if(0===this.collisionIndex.placeCollisionBox(p,e,m,Vr(b.x,b.y,o,s,this.transform.angle),u,a,l,c.predicate).box.length)return}if(w.box.length>0){let t;return this.prevPlacement&&this.prevPlacement.variableOffsets[x]&&this.prevPlacement.placements[x]&&this.prevPlacement.placements[x].text&&(t=this.prevPlacement.variableOffsets[x].anchor),this.variableOffsets[x]={textOffset:v,width:r,height:i,anchor:e,textScale:n,prevAnchor:t},this.markUsedJustification(p,e,h,f),p.allowVerticalPlacement&&(this.markUsedOrientation(p,f,h),this.placedOrientations[x]=f),{shift:b,placedGlyphBoxes:w}}}placeLayerBucketPart(t,r,i,n){const{bucket:o,layout:s,posMatrix:a,textLabelPlaneMatrix:l,labelToScreenMatrix:c,clippingData:u,textPixelRatio:h,holdingForFade:d,collisionBoxArray:p,partiallyEvaluatedTextSize:f,partiallyEvaluatedIconSize:m,collisionGroup:A}=t.parameters,g=s.get("text-optional"),_=s.get("icon-optional"),y=s.get("text-allow-overlap"),x=s.get("icon-allow-overlap"),v="map"===s.get("text-rotation-alignment"),b="map"===s.get("text-pitch-alignment"),w="viewport-y"===s.get("symbol-z-order"),C=s.get("symbol-z-elevate");this.transform.setProjection(o.projection);let T=y&&(x||!o.hasIconData()||_),E=x&&(y||!o.hasTextData()||g);!o.collisionArrays&&p&&o.deserializeCollisionBoxes(p),i&&n&&o.updateCollisionDebugBuffers(this.transform.zoom,p);const M=(t,n,p)=>{const{crossTileID:w,numVerticalGlyphVertices:C}=t;if(u){const i={zoom:this.transform.zoom,pitch:this.transform.pitch};let n=null;if(u.dynamicFilterNeedsFeature){const e=this.retainedQueryData[o.bucketInstanceId];n=u.featureIndex.loadFeature({featureIndex:t.featureIndex,bucketIndex:e.bucketIndex,sourceLayerIndex:e.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,u.dynamicFilter)(i,n,this.retainedQueryData[o.bucketInstanceId].tileID.canonical,new e.P(t.tileAnchorX,t.tileAnchorY),this.transform.calculateDistanceTileData(u.unwrappedTileID)))return this.placements[w]=new Or(!1,!1,!1,!0),void r.add(w)}if(r.has(w))return;if(d)return void(this.placements[w]=new Or(!1,!1,!1));let M=!1,S=!1,I=!0,P=!1,D=!1,k=null,L={box:null,offscreen:null,occluded:null},z={box:null,offscreen:null,occluded:null},O=null,B=null,R=null,F=0,j=0,V=0;p.textFeatureIndex?F=p.textFeatureIndex:t.useRuntimeCollisionCircles&&(F=t.featureIndex),p.verticalTextFeatureIndex&&(j=p.verticalTextFeatureIndex);const N=e=>{e.tileID=this.retainedQueryData[o.bucketInstanceId].tileID;const r=this.transform.elevation;e.elevation=t.zOffset+(r?r.getAtTileOffset(e.tileID,e.tileAnchorX,e.tileAnchorY):0)},U=p.textBox;if(U){N(U);const r=r=>{let i=e.b9.horizontal;if(o.allowVerticalPlacement&&!r&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[w];e&&(this.placedOrientations[w]=e,i=e,this.markUsedOrientation(o,i,t))}return i},i=(t,r)=>{if(o.allowVerticalPlacement&&C>0&&p.verticalTextBox){for(const i of o.writingModes)if(i===e.b9.vertical?(L=r(),z=L):L=t(),L&&L.box&&L.box.length)break}else L=t()};if(s.get("text-variable-anchor")){let l=s.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[w]){const e=this.prevPlacement.variableOffsets[w];l.indexOf(e.anchor)>0&&(l=l.filter((t=>t!==e.anchor)),l.unshift(e.anchor))}const c=(e,r,i)=>{const s=o.getSymbolInstanceTextSize(f,t,this.transform.zoom,n),c=(e.x2-e.x1)*s+2*e.padding,u=(e.y2-e.y1)*s+2*e.padding,d=t.hasIconTextFit&&!x?r:null;d&&N(d);let p={box:[],offscreen:!1,occluded:!1};const g=y?2*l.length:l.length;for(let r=0;r<g;++r){const g=this.attemptAnchorPlacement(l[r%l.length],e,c,u,s,v,b,h,a,A,r>=l.length,t,n,o,i,d,f,m);if(g&&(p=g.placedGlyphBoxes,p&&p.box&&p.box.length)){M=!0,k=g.shift;break}}return p};i((()=>c(U,p.iconBox,e.b9.horizontal)),(()=>{const t=p.verticalTextBox;return t&&N(t),o.allowVerticalPlacement&&!(L&&L.box&&L.box.length)&&C>0&&t?c(t,p.verticalIconBox,e.b9.vertical):{box:null,offscreen:null,occluded:null}})),L&&(M=L.box,I=L.offscreen,P=L.occluded);const u=r(!(!L||!L.box));if(!M&&this.prevPlacement){const e=this.prevPlacement.variableOffsets[w];e&&(this.variableOffsets[w]=e,this.markUsedJustification(o,e.anchor,t,u))}}else{const s=(r,i)=>{const s=o.getSymbolInstanceTextSize(f,t,this.transform.zoom,n),l=this.collisionIndex.placeCollisionBox(o,s,r,new e.P(0,0),y,h,a,A.predicate);return l&&l.box&&l.box.length&&(this.markUsedOrientation(o,i,t),this.placedOrientations[w]=i),l};i((()=>s(U,e.b9.horizontal)),(()=>{const t=p.verticalTextBox;return o.allowVerticalPlacement&&C>0&&t?(N(t),s(t,e.b9.vertical)):{box:null,offscreen:null,occluded:null}})),r(!!(L&&L.box&&L.box.length))}}if(O=L,M=O&&O.box&&O.box.length>0,I=O&&O.offscreen,P=O&&O.occluded,t.useRuntimeCollisionCircles){const r=o.text.placedSymbolArray.get(t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex),n=e.ba(o.textSizeData,f,r),u=s.get("text-padding");B=this.collisionIndex.placeCollisionCircles(o,y,r,o.lineVertexArray,o.glyphOffsetArray,n,a,l,c,i,b,A.predicate,t.collisionCircleDiameter*n/e.bf,u,this.retainedQueryData[o.bucketInstanceId].tileID),M=y||B.circles.length>0&&!B.collisionDetected,I=I&&B.offscreen,P=B.occluded}if(p.iconFeatureIndex&&(V=p.iconFeatureIndex),p.iconBox){const r=r=>{N(r);const i=t.hasIconTextFit&&k?Vr(k.x,k.y,v,b,this.transform.angle):new e.P(0,0),n=o.getSymbolInstanceIconSize(m,this.transform.zoom,t.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(o,n,r,i,x,h,a,A.predicate)};z&&z.box&&z.box.length&&p.verticalIconBox?(R=r(p.verticalIconBox),S=R.box.length>0):(R=r(p.iconBox),S=R.box.length>0),I=I&&R.offscreen,D=R.occluded}const H=g||0===t.numHorizontalGlyphVertices&&0===C,G=_||0===t.numIconVertices;if(H||G?G?H||(S=S&&M):M=S&&M:S=M=S&&M,M&&O&&O.box&&this.collisionIndex.insertCollisionBox(O.box,s.get("text-ignore-placement"),o.bucketInstanceId,z&&z.box&&j?j:F,A.ID),S&&R&&this.collisionIndex.insertCollisionBox(R.box,s.get("icon-ignore-placement"),o.bucketInstanceId,V,A.ID),B&&(M&&this.collisionIndex.insertCollisionCircles(B.circles,s.get("text-ignore-placement"),o.bucketInstanceId,F,A.ID),i)){const e=o.bucketInstanceId;let t=this.collisionCircleArrays[e];void 0===t&&(t=this.collisionCircleArrays[e]=new Br);for(let e=0;e<B.circles.length;e+=4)t.circles.push(B.circles[e+0]),t.circles.push(B.circles[e+1]),t.circles.push(B.circles[e+2]),t.circles.push(B.collisionDetected?1:0)}const Z="globe"!==o.projection.name;T=T&&(Z||!P),E=E&&(Z||!D),this.placements[w]=new Or(M||T,S||E,I||o.justReloaded),r.add(w)};if(C&&this.buildingIndex&&(this.buildingIndex.updateZOffset(o,this.retainedQueryData[o.bucketInstanceId].tileID),o.updateZOffset()),w){const t=o.getSortedSymbolIndexes(this.transform.angle);for(let e=t.length-1;e>=0;--e){const r=t[e];M(o.symbolInstances.get(r),r,o.collisionArrays[r])}o.hasAnyZOffset&&e.w(`${o.layerIds[0]} layer symbol-z-elevate: symbols are not sorted by elevation if symbol-z-order is evaluated to viewport-y`)}else if(o.hasAnyZOffset){const e=o.getSortedIndexesByZOffset();for(let t=0;t<e.length;++t){const r=e[t];M(o.symbolInstances.get(r),r,o.collisionArrays[r])}}else for(let e=t.symbolInstanceStart;e<t.symbolInstanceEnd;e++)M(o.symbolInstances.get(e),e,o.collisionArrays[e]);if(i&&o.bucketInstanceId in this.collisionCircleArrays){const t=this.collisionCircleArrays[o.bucketInstanceId];e.a9.invert(t.invProjMatrix,a),t.viewportMatrix=this.collisionIndex.getViewportMatrix()}o.justReloaded=!1}markUsedJustification(t,r,i,n){const{leftJustifiedTextSymbolIndex:o,centerJustifiedTextSymbolIndex:s,rightJustifiedTextSymbolIndex:a,verticalPlacedTextSymbolIndex:l,crossTileID:c}=i,u=e.bg(r),h=n===e.b9.vertical?l:"left"===u?o:"center"===u?s:"right"===u?a:-1;o>=0&&(t.text.placedSymbolArray.get(o).crossTileID=h>=0&&o!==h?0:c),s>=0&&(t.text.placedSymbolArray.get(s).crossTileID=h>=0&&s!==h?0:c),a>=0&&(t.text.placedSymbolArray.get(a).crossTileID=h>=0&&a!==h?0:c),l>=0&&(t.text.placedSymbolArray.get(l).crossTileID=h>=0&&l!==h?0:c)}markUsedOrientation(t,r,i){const n=r===e.b9.horizontal||r===e.b9.horizontalOnly?r:0,o=r===e.b9.vertical?r:0,{leftJustifiedTextSymbolIndex:s,centerJustifiedTextSymbolIndex:a,rightJustifiedTextSymbolIndex:l,verticalPlacedTextSymbolIndex:c}=i,u=t.text.placedSymbolArray;s>=0&&(u.get(s).placedOrientation=n),a>=0&&(u.get(a).placedOrientation=n),l>=0&&(u.get(l).placedOrientation=n),c>=0&&(u.get(c).placedOrientation=o)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const t=this.prevPlacement;let r=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;const i=t?t.symbolFadeChange(e):1,n=t?t.opacities:{},o=t?t.variableOffsets:{},s=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],o=n[e];o?(this.opacities[e]=new zr(o,i,t.text,t.icon,null,t.clipped),r=r||t.text!==o.text.placed||t.icon!==o.icon.placed):(this.opacities[e]=new zr(null,i,t.text,t.icon,t.skipFade,t.clipped),r=r||t.text||t.icon)}for(const e in n){const t=n[e];if(!this.opacities[e]){const n=new zr(t,i,!1,!1);n.isHidden()||(this.opacities[e]=n,r=r||t.text.placed||t.icon.placed)}}for(const e in o)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=o[e]);for(const e in s)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=s[e]);r?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)}updateLayerOpacities(e,t){const r=new Set;for(const i of t){const t=i.getBucket(e);t&&i.latestFeatureIndex&&e.fqid===t.layerIds[0]&&(this.updateBucketOpacities(t,r,i.collisionBoxArray),t.layers[0].layout.get("symbol-z-elevate")&&this.buildingIndex&&(this.buildingIndex.updateZOffset(t,i.tileID),t.updateZOffset()))}}updateBucketOpacities(t,r,i){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 n=t.layers[0].layout,o=!!t.layers[0].dynamicFilter(),s=new zr(null,0,!1,!1,!0),a=n.get("text-allow-overlap"),l=n.get("icon-allow-overlap"),c=n.get("text-variable-anchor"),u="map"===n.get("text-rotation-alignment"),h="map"===n.get("text-pitch-alignment"),d=new zr(null,0,a&&(l||!t.hasIconData()||n.get("icon-optional")),l&&(a||!t.hasTextData()||n.get("text-optional")),!0);!t.collisionArrays&&i&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(i);const p=(e,t,r)=>{for(let i=0;i<t/4;i++)e.opacityVertexArray.emplaceBack(r)};let f=0;for(let i=0;i<t.symbolInstances.length;i++){const n=t.symbolInstances.get(i),{numHorizontalGlyphVertices:a,numVerticalGlyphVertices:l,crossTileID:m,numIconVertices:A}=n,g=r.has(m);let _=this.opacities[m];g?_=s:_||(_=d,this.opacities[m]=_),r.add(m);const y=a>0||l>0,x=A>0,v=this.placedOrientations[m],b=v===e.b9.vertical,w=v===e.b9.horizontal||v===e.b9.horizontalOnly;if(!y&&!x||_.isHidden()||f++,y){const e=Yr(_.text);p(t.text,a,b?$r:e),p(t.text,l,w?$r:e);const r=_.text.isHidden(),{leftJustifiedTextSymbolIndex:i,centerJustifiedTextSymbolIndex:o,rightJustifiedTextSymbolIndex:s,verticalPlacedTextSymbolIndex:c}=n,u=t.text.placedSymbolArray,h=r||b?1:0;i>=0&&(u.get(i).hidden=h),o>=0&&(u.get(o).hidden=h),s>=0&&(u.get(s).hidden=h),c>=0&&(u.get(c).hidden=r||w?1:0);const d=this.variableOffsets[m];d&&this.markUsedJustification(t,d.anchor,n,v);const f=this.placedOrientations[m];f&&(this.markUsedJustification(t,"left",n,f),this.markUsedOrientation(t,f,n))}if(x){const e=Yr(_.icon),{placedIconSymbolIndex:r,verticalPlacedIconSymbolIndex:i}=n,o=t.icon.placedSymbolArray,s=_.icon.isHidden()?1:0;r>=0&&(p(t.icon,A,b?$r:e),o.get(r).hidden=s),i>=0&&(p(t.icon,n.numVerticalIconVertices,w?$r:e),o.get(i).hidden=s)}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const r=t.collisionArrays[i];if(r){let i=new e.P(0,0),s=!0;if(r.textBox||r.verticalTextBox){if(c){const e=this.variableOffsets[m];e?(i=jr(e.anchor,e.width,e.height,e.textOffset,e.textScale),u&&i._rotate(h?this.transform.angle:-this.transform.angle)):s=!1}o&&(s=!_.clipped),r.textBox&&Ur(t.textCollisionBox.collisionVertexArray,_.text.placed,!s||b,i.x,i.y),r.verticalTextBox&&Ur(t.textCollisionBox.collisionVertexArray,_.text.placed,!s||w,i.x,i.y)}const a=s&&Boolean(!w&&r.verticalIconBox);r.iconBox&&Ur(t.iconCollisionBox.collisionVertexArray,_.icon.placed,a,n.hasIconTextFit?i.x:0,n.hasIconTextFit?i.y:0),r.verticalIconBox&&Ur(t.iconCollisionBox.collisionVertexArray,_.icon.placed,!a,n.hasIconTextFit?i.x:0,n.hasIconTextFit?i.y:0)}}}if(t.fullyClipped=0===f,t.sortFeatures(this.transform.angle),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.bucketInstanceId in this.collisionCircleArrays){const e=this.collisionCircleArrays[t.bucketInstanceId];t.placementInvProjMatrix=e.invProjMatrix,t.placementViewportMatrix=e.viewportMatrix,t.collisionCircleArray=e.circles,delete this.collisionCircleArrays[t.bucketInstanceId]}}symbolFadeChange(e){return 0===this.fadeDuration?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(e,t){const r=this.zoomAtLastRecencyCheck===t?1-this.zoomAdjustment(t):1;return this.zoomAtLastRecencyCheck=t,this.commitTime+this.fadeDuration*r>e}setStale(){this.stale=!0}}function Ur(e,t,r,i,n){e.emplaceBack(t?1:0,r?1:0,i||0,n||0),e.emplaceBack(t?1:0,r?1:0,i||0,n||0),e.emplaceBack(t?1:0,r?1:0,i||0,n||0),e.emplaceBack(t?1:0,r?1:0,i||0,n||0)}const Hr=Math.pow(2,25),Gr=Math.pow(2,24),Zr=Math.pow(2,17),Wr=Math.pow(2,16),Qr=Math.pow(2,9),qr=Math.pow(2,8),Xr=Math.pow(2,1);function Yr(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;const t=e.placed?1:0,r=Math.floor(127*e.opacity);return r*Hr+t*Gr+r*Zr+t*Wr+r*Qr+t*qr+r*Xr+t}const $r=0;class Kr{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&void 0!==e.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs=new Set,this._bucketParts=[]}continuePlacement(e,t,r,i,n){const o=this._bucketParts;for(;this._currentTileIndex<e.length;)if(t.getBucketParts(o,i,e[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,n())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,o.sort(((e,t)=>e.sortKey-t.sortKey)));this._currentPartIndex<o.length;){const e=o[this._currentPartIndex];if(t.placeLayerBucketPart(e,this._seenCrossTileIDs,r,0===e.symbolInstanceStart),this._currentPartIndex++,n())return!0}return!1}}class Jr{constructor(e,t,r,i,n,o,s,a,l){this.placement=new Nr(e,n,o,s,a,l),this._currentPlacementIndex=t.length-1,this._forceFullPlacement=r,this._showCollisionBoxes=i,this._done=!1}isDone(){return this._done}continuePlacement(t,r,i,n){const o=e.f.now(),s=()=>{const t=e.f.now()-o;return!this._forceFullPlacement&&t>2};for(;this._currentPlacementIndex>=0;){const o=r[t[this._currentPlacementIndex]],a=this.placement.collisionIndex.transform.zoom;if("symbol"===o.type&&(!o.minzoom||o.minzoom<=a)&&(!o.maxzoom||o.maxzoom>a)){const t=o,r=t.layout.get("symbol-z-elevate"),a=this._inProgressLayer=this._inProgressLayer||new Kr(t),l=e.aj(o.source,o.scope);if(a.continuePlacement(r?n[l]:i[l],this.placement,this._showCollisionBoxes,o,s))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const ei=512/e.Y/2;class ti{constructor(t,r,i){this.tileID=t,this.bucketInstanceId=i,this.index=new e.bj(r.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const n=t.canonical.x*e.Y,o=t.canonical.y*e.Y;for(let e=0;e<r.length;e++){const{key:t,crossTileID:i,tileAnchorX:s,tileAnchorY:a}=r.get(e),l=Math.floor((n+s)*ei),c=Math.floor((o+a)*ei);this.index.add(l,c),this.keys.push(t),this.crossTileIDs.push(i)}this.index.finish()}findMatches(t,r,i){const n=this.tileID.canonical.z<r.canonical.z?1:Math.pow(2,this.tileID.canonical.z-r.canonical.z),o=ei/Math.pow(2,r.canonical.z-this.tileID.canonical.z),s=r.canonical.x*e.Y,a=r.canonical.y*e.Y;for(let e=0;e<t.length;e++){const r=t.get(e);if(r.crossTileID)continue;const{key:l,tileAnchorX:c,tileAnchorY:u}=r,h=Math.floor((s+c)*o),d=Math.floor((a+u)*o),p=this.index.range(h-n,d-n,h+n,d+n);for(const e of p){const t=this.crossTileIDs[e];if(this.keys[e]===l&&!i.has(t)){i.add(t),r.crossTileID=t;break}}}}}class ri{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class ii{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){const t=Math.round((e-this.lng)/360);if(0!==t)for(const e in this.indexes){const r=this.indexes[e],i={};for(const e in r){const n=r[e];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+t),i[n.tileID.key]=n}this.indexes[e]=i}this.lng=e}addBucket(e,t,r){if(this.indexes[e.overscaledZ]&&this.indexes[e.overscaledZ][e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===t.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key])}for(let e=0;e<t.symbolInstances.length;e++)t.symbolInstances.get(e).crossTileID=0;this.usedCrossTileIDs[e.overscaledZ]||(this.usedCrossTileIDs[e.overscaledZ]=new Set);const i=this.usedCrossTileIDs[e.overscaledZ];for(const r in this.indexes){const n=this.indexes[r];if(Number(r)>e.overscaledZ)for(const r in n){const o=n[r];o.tileID.isChildOf(e)&&o.findMatches(t.symbolInstances,e,i)}else{const o=n[e.scaledTo(Number(r)).key];o&&o.findMatches(t.symbolInstances,e,i)}}for(let e=0;e<t.symbolInstances.length;e++){const n=t.symbolInstances.get(e);n.crossTileID||(n.crossTileID=r.generate(),i.add(n.crossTileID))}return void 0===this.indexes[e.overscaledZ]&&(this.indexes[e.overscaledZ]={}),this.indexes[e.overscaledZ][e.key]=new ti(e,t.symbolInstances,t.bucketInstanceId),!0}removeBucketCrossTileIDs(e,t){for(const r of t.crossTileIDs)this.usedCrossTileIDs[e].delete(r)}removeStaleBuckets(e){let t=!1;for(const r in this.indexes){const i=this.indexes[r];for(const n in i)e[i[n].bucketInstanceId]||(this.removeBucketCrossTileIDs(r,i[n]),delete i[n],t=!0)}return t}}class ni{constructor(){this.layerIndexes={},this.crossTileIDs=new ri,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(e,t,r,i){let n=this.layerIndexes[e.fqid];void 0===n&&(n=this.layerIndexes[e.fqid]=new ii);let o=!1;const s={};"globe"!==i.name&&n.handleWrapJump(r);for(const r of t){const t=r.getBucket(e);t&&e.fqid===t.layerIds[0]&&(t.bucketInstanceId||(t.bucketInstanceId=++this.maxBucketInstanceId),n.addBucket(r.tileID,t,this.crossTileIDs)&&(o=!0),s[t.bucketInstanceId]=!0)}return n.removeStaleBuckets(s)&&(o=!0),o}pruneUnusedLayers(e){const t={};e.forEach((e=>{t[e]=!0}));for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e]}}class oi{constructor(e=0,t=0,r=0,i=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(r)||r<0||isNaN(i)||i<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=t,this.left=r,this.right=i}interpolate(t,r,i){return null!=r.top&&null!=t.top&&(this.top=e.X(t.top,r.top,i)),null!=r.bottom&&null!=t.bottom&&(this.bottom=e.X(t.bottom,r.bottom,i)),null!=r.left&&null!=t.left&&(this.left=e.X(t.left,r.left,i)),null!=r.right&&null!=t.right&&(this.right=e.X(t.right,r.right,i)),this}getCenter(t,r){const i=e.ad((this.left+t-this.right)/2,0,t),n=e.ad((this.top+r-this.bottom)/2,0,r);return new e.P(i,n)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new oi(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function si(t,r){const i=e.bn(t,3);e.a9.fromQuat(t,r),e.bp(t,3,i)}function ai(t,r){const i=e.bl.identity([]);return e.bl.rotateZ(i,i,-r),e.bl.rotateX(i,i,-t),i}function li(t,r){const i=[t[0],t[1],0],n=[r[0],r[1],0];if(e.Q.length(i)>=1e-15){const t=e.Q.normalize([],i);e.Q.scale(n,t,e.Q.dot(n,t)),r[0]=n[0],r[1]=n[1]}const o=e.Q.cross([],r,t);if(e.Q.len(o)<1e-15)return null;const s=Math.atan2(-o[1],o[0]);return ai(Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2]),s)}class ci{constructor(e,t){this.position=e,this.orientation=t}get position(){return this._position}set position(t){if(t){const r=t instanceof e.O?t:new e.O(t[0],t[1],t[2]);this._renderWorldCopies&&(r.x=e.bk(r.x,0,1)),this._position=r}else this._position=null}lookAtPoint(t,r){if(this.orientation=null,!this.position)return;const i=this.position,n=this._elevation?this._elevation.getAtPointOrZero(e.O.fromLngLat(t)):0,o=e.O.fromLngLat(t,n),s=[o.x-i.x,o.y-i.y,o.z-i.z];r||(r=[0,0,1]),r[2]=Math.abs(r[2]),this.orientation=li(s,r)}setPitchBearing(t,r){this.orientation=ai(e.bm(t),e.bm(-r))}}class ui{constructor(t,r){this._transform=e.a9.identity([]),this.orientation=r,this.position=t}get mercatorPosition(){const t=this.position;return new e.O(t[0],t[1],t[2])}get position(){const t=e.bn(this._transform,3);return[t[0],t[1],t[2]]}set position(t){var r;t&&e.bp(this._transform,3,[(r=t)[0],r[1],r[2],1])}get orientation(){return this._orientation}set orientation(t){this._orientation=t||e.bl.identity([]),t&&si(this._transform,this._orientation)}getPitchBearing(){const e=this.forward(),t=this.right();return{bearing:Math.atan2(-t[1],t[0]),pitch:Math.atan2(Math.sqrt(e[0]*e[0]+e[1]*e[1]),-e[2])}}setPitchBearing(e,t){this._orientation=ai(e,t),si(this._transform,this._orientation)}forward(){const t=e.bn(this._transform,2);return[-t[0],-t[1],-t[2]]}up(){const t=e.bn(this._transform,1);return[-t[0],-t[1],-t[2]]}right(){const t=e.bn(this._transform,0);return[t[0],t[1],t[2]]}getCameraToWorld(t,r){const i=new Float64Array(16);return e.a9.invert(i,this.getWorldToCamera(t,r)),i}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(t,r,i){const n=this.position;e.Q.scale(n,n,-t);const o=new Float64Array(16);return e.a9.fromScaling(o,[i,i,i]),e.a9.translate(o,o,n),o[10]*=r,o}getWorldToCamera(t,r){const i=new Float64Array(16),n=new Float64Array(4),o=this.position;return e.bl.conjugate(n,this._orientation),e.Q.scale(o,o,-t),e.a9.fromQuat(i,n),e.a9.translate(i,i,o),i[1]*=-1,i[5]*=-1,i[9]*=-1,i[13]*=-1,i[8]*=r,i[9]*=r,i[10]*=r,i[11]*=r,i}getCameraToClipPerspective(t,r,i,n){const o=new Float64Array(16);return e.a9.perspective(o,t,r,i,n),o}getCameraToClipOrthographic(t,r,i,n,o,s){const a=new Float64Array(16);return e.a9.ortho(a,t,r,i,n,o,s),a}getDistanceToElevation(t,r=!1){const i=0===t?0:e.bo(t,r?e.ax(this.position[1]):this.position[1]),n=this.forward();return(i-this.position[2])/n[2]}clone(){return new ui([...this.position],[...this.orientation])}}const hi=(e,t,r)=>(1-r)*e+r*t,di=e=>e*e*e*e*e;class pi{constructor(t,r,i,n,o,s,a){this.tileSize=512,this._renderWorldCopies=void 0===o||o,this._minZoom=t||0,this._maxZoom=r||22,this._minPitch=null==i?0:i,this._maxPitch=null==n?60:n,this.setProjection(s),this.setMaxBounds(a),this.width=0,this.height=0,this._center=new e.bq(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 oi,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new ui,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 e=new pi(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection());return e._elevation=this._elevation,e._centerAltitude=this._centerAltitude,e._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,e.tileSize=this.tileSize,e.mercatorFromTransition=this.mercatorFromTransition,e.width=this.width,e.height=this.height,e.cameraElevationReference=this.cameraElevationReference,e._center=this._center,e._setZoom(this.zoom),e._seaLevelZoom=this._seaLevelZoom,e.angle=this.angle,e._fov=this._fov,e._pitch=this._pitch,e._nearZ=this._nearZ,e._farZ=this._farZ,e._averageElevation=this._averageElevation,e._orthographicProjectionAtLowPitch=this._orthographicProjectionAtLowPitch,e._unmodified=this._unmodified,e._edgeInsets=this._edgeInsets.clone(),e._camera=this._camera.clone(),e._calcMatrices(),e.freezeTileCoverage=this.freezeTileCoverage,e.frustumCorners=this.frustumCorners,e}get isOrthographic(){return"globe"!==this.projection.name&&this._orthographicProjectionAtLowPitch&&this.pitch<15}get elevation(){return this._elevation}set elevation(e){this._elevation!==e&&(this._elevation=e,this._updateCameraOnTerrain(),this._calcMatrices())}get depthOcclusionForSymbolsAndCircles(){return"globe"!==this.projection.name&&!this.isOrthographic}updateElevation(e,t=!1){const r=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(null==this._seaLevelZoom||r)&&this._updateCameraOnTerrain(),(e||r)&&this._constrainCamera(t),this._calcMatrices()}getProjection(){return e.af(this.projection,["name","center","parallels"])}setProjection(r){this.projectionOptions=r||{name:"mercator"};const i=this.projection?this.getProjection():void 0;this.projection=e.br(this.projectionOptions);const n=!t(i,this.getProjection());return n&&this._calcMatrices(),this.mercatorFromTransition=!1,n}setOrthographicProjectionAtLowPitch(e){return this._orthographicProjectionAtLowPitch!==e&&(this._orthographicProjectionAtLowPitch=e,this._calcMatrices(),!0)}setMercatorFromTransition(){const t=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=e.br({name:"mercator"});const r=t!==this.projection.name;return r&&this._calcMatrices(),r}get minZoom(){return this._minZoom}set minZoom(e){this._minZoom!==e&&(this._minZoom=e,this.zoom=Math.max(this.zoom,e))}get maxZoom(){return this._maxZoom}set maxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.zoom=Math.min(this.zoom,e))}get minPitch(){return this._minPitch}set minPitch(e){this._minPitch!==e&&(this._minPitch=e,this.pitch=Math.max(this.pitch,e))}get maxPitch(){return this._maxPitch}set maxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.pitch=Math.min(this.pitch,e))}get renderWorldCopies(){return this._renderWorldCopies&&!0===this.projection.supportsWorldCopies}set renderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e}get worldSize(){return this.tileSize*this.scale}get cameraWorldSizeForFog(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get cameraWorldSize(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation,!0),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return e.bo(1,this.center.lat)*this.cameraWorldSizeForFog}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new e.P(this.width,this.height)}get bearing(){return e.bk(this.rotation,-180,180)}set bearing(e){this.rotation=e}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=e.b7.create(),e.b7.rotate(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(t){const r=e.ad(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 e=1/Math.tan(.5*this.fovX);return 2*Math.atan(1/this.aspect/e)}set fov(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=e.bm(t),this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(e){this._averageElevation=e,this._calcFogMatrices(),this._distanceTileDataCache={}}get zoom(){return this._zoom}set zoom(e){const t=Math.min(Math.max(e,this.minZoom),this.maxZoom);this._zoom!==t&&(this._unmodified=!1,this._setZoom(t),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(e){this._zoom=e,this.scale=this.zoomScale(e),this.tileZoom=Math.floor(e),this.zoomFraction=e-this.tileZoom}get tileCoverLift(){return this._tileCoverLift}set tileCoverLift(e){this._tileCoverLift!==e&&(this._tileCoverLift=e)}_updateCameraOnTerrain(){const e=this.elevation?this.elevation.getAtPoint(this.locationCoordinate(this.center),Number.NEGATIVE_INFINITY):Number.NEGATIVE_INFINITY,t=this.elevation&&e===Number.NEGATIVE_INFINITY&&this.elevation.visibleDemTiles.length>0&&this.elevation.exaggeration()>0&&this._centerAltitudeValidForExaggeration;if(!this._elevation||e===Number.NEGATIVE_INFINITY&&(!t||!this._centerAltitude))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const r=this._elevation;t||this._centerAltitude&&this._centerAltitudeValidForExaggeration&&r.exaggeration()&&this._centerAltitudeValidForExaggeration!==r.exaggeration()?(this._centerAltitude=this._centerAltitude/this._centerAltitudeValidForExaggeration*r.exaggeration(),this._centerAltitudeValidForExaggeration=r.exaggeration()):(this._centerAltitude=e||0,this._centerAltitudeValidForExaggeration=r.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]],i=this.horizonLineFromTop();let n=0,o=0;for(let s=0;s<r.length;s++){const a=new e.P(r[s][0]*this.width,i+r[s][1]*(this.height-i)),l=t.pointCoordinate(a);if(!l)continue;const c=1/Math.hypot(l[0]-this._camera.position[0],l[1]-this._camera.position[1]);n+=l[3]*c,o+=c}return 0===o?NaN:n/o}get center(){return this._center}set center(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this._terrainEnabled()&&("ground"===this.cameraElevationReference?this._updateCameraOnTerrain():this._updateZoomFromElevation()),this._constrain(),this._calcMatrices())}_updateZoomFromElevation(){if(null==this._seaLevelZoom||!this._elevation)return;const e=this._seaLevelZoom,t=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center)),r=this.pixelsPerMeter/this.worldSize*t,i=this._mercatorZfromZoom(e),n=this._mercatorZfromZoom(this._maxZoom),o=Math.max(i-r,n);this._setZoom(this._zoomFromMercatorZ(o))}get padding(){return this._edgeInsets.toJSON()}set padding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices())}computeZoomRelativeTo(t){const r=this.rayIntersectionCoordinate(this.pointRayIntersection(this.centerPoint,t.toAltitude()));let i;i=t.z<this._camera.position[2]?[r.x,r.y,r.z]:[t.x,t.y,t.z];const n=e.Q.length(e.Q.sub([],this._camera.position,i));return e.ad(this._zoomFromMercatorZ(n),this._minZoom,this._maxZoom)}setFreeCameraOptions(t){if(!this.height)return;if(!t.position&&!t.orientation)return;this._updateCameraState();let r=!1;if(t.orientation&&!e.bl.exactEquals(t.orientation,this._camera.orientation)&&(r=this._setCameraOrientation(t.orientation)),t.position){const i=[t.position.x,t.position.y,t.position.z];e.Q.exactEquals(i,this._camera.position)||(this._setCameraPosition(i),r=!0)}r&&(this._updateStateFromCamera(),this.recenterOnTerrain())}getFreeCameraOptions(){this._updateCameraState();const t=this._camera.position,r=new ci;return r.position=new e.O(t[0],t[1],t[2]),r.orientation=this._camera.orientation,r._elevation=this.elevation,r._renderWorldCopies=this.renderWorldCopies,r}_setCameraOrientation(t){if(!e.bl.length(t))return!1;e.bl.normalize(t,t);const r=e.Q.transformQuat([],[0,0,-1],t),i=e.Q.transformQuat([],[0,-1,0],t);if(i[2]<0)return!1;const n=li(r,i);return!!n&&(this._camera.orientation=n,!0)}_setCameraPosition(t){const r=this.zoomScale(this.minZoom)*this.tileSize,i=this.zoomScale(this.maxZoom)*this.tileSize,n=this.cameraToCenterDistance;t[2]=e.ad(t[2],n/i,n/r),this._camera.position=t}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}get fovAboveCenter(){return this._fov*(.5+this.centerOffset.y/this.height)}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,t,r){this._unmodified=!1,this._edgeInsets.interpolate(e,t,r),this._constrain(),this._calcMatrices()}coveringZoomLevel(e){const t=(e.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/e.tileSize));return Math.max(0,t)}getVisibleUnwrappedCoordinates(t){const r=[new e.bs(0,t)];if(this.renderWorldCopies){const i=this.pointCoordinate(new e.P(0,0)),n=this.pointCoordinate(new e.P(this.width,0)),o=this.pointCoordinate(new e.P(this.width,this.height)),s=this.pointCoordinate(new e.P(0,this.height)),a=Math.floor(Math.min(i.x,n.x,o.x,s.x)),l=Math.floor(Math.max(i.x,n.x,o.x,s.x)),c=1;for(let i=a-c;i<=l+c;i++)0!==i&&r.push(new e.bs(i,t))}return r}isLODDisabled(e){return(!e||this.pitch<=60)&&this._edgeInsets.top<=this._edgeInsets.bottom&&!this._elevation&&!this.projection.isReprojectedInTileSpace}extendTileCoverForShadows(t,r,i){let n=[];if(0===r[0]&&0===r[1])return n;for(const i of t){const t=i.canonical,o=i.overscaledZ,s=i.wrap,a=1<<t.z,l=t.x+1<a,c=t.x>0,u=t.y+1<a,h=t.y>0,d=i.wrap-(c?0:1),p=i.wrap+(l?0:1),f=c?t.x-1:a-1,m=l?t.x+1:0;r[0]<0?(n.push(new e.ap(o,p,t.z,m,t.y)),r[1]<0&&u&&(n.push(new e.ap(o,s,t.z,t.x,t.y+1)),n.push(new e.ap(o,p,t.z,m,t.y+1))),r[1]>0&&h&&(n.push(new e.ap(o,s,t.z,t.x,t.y-1)),n.push(new e.ap(o,p,t.z,m,t.y-1)))):r[0]>0?(n.push(new e.ap(o,d,t.z,f,t.y)),r[1]<0&&u&&(n.push(new e.ap(o,s,t.z,t.x,t.y+1)),n.push(new e.ap(o,d,t.z,f,t.y+1))),r[1]>0&&h&&(n.push(new e.ap(o,s,t.z,t.x,t.y-1)),n.push(new e.ap(o,d,t.z,f,t.y-1)))):r[1]<0&&u?n.push(new e.ap(o,s,t.z,t.x,t.y+1)):h&&n.push(new e.ap(o,s,t.z,t.x,t.y-1))}if(n.length>1){n.sort(((e,t)=>e.overscaledZ-t.overscaledZ||e.wrap-t.wrap||e.canonical.z-t.canonical.z||e.canonical.x-t.canonical.x||e.canonical.y-t.canonical.y));let e=0,t=0;for(;t<n.length;)n[t].equals(n[e])?++t:n[++e]=n[t++];n.length=e+1}const o=[];for(const e of n)n.some((t=>e.isChildOf(t)))||o.push(e);return n=o.filter((e=>!t.some((t=>!!(e.overscaledZ<i&&t.isChildOf(e))||e.equals(t)||e.isChildOf(t))))),n}coveringTiles(t){let r=this.coveringZoomLevel(t);const i=r,n=this.elevation&&this.elevation.exaggeration(),o=n&&!t.isTerrainDEM,s="mercator"===this.projection.name;if(void 0!==t.minzoom&&r<t.minzoom)return[];void 0!==t.maxzoom&&r>t.maxzoom&&(r=t.maxzoom);const a=this.locationCoordinate(this.center),l=this.center.lat,c=1<<r,u=[c*a.x,c*a.y,0],h="globe"===this.projection.name,d=!h,p=e.bt.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,r,d),f=h?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),m=c*e.bo(1,this.center.lat),A=this._camera.position[2]/e.bo(1,this.center.lat),g=[c*f.x,c*f.y,A*(d?1:m)],_=h||n,y=this.cameraToCenterDistance/t.tileSize*(t.roundZoom?1:.502),x=this.isLODDisabled(!0)?r:0;let v;if(this._elevation&&t.isTerrainDEM)v=1e4*this._elevation.exaggeration();else if(this._elevation){const e=this._elevation.getMinMaxForVisibleTiles();v=e?e.max:this._centerAltitude}else v=this._centerAltitude;const b=t.isTerrainDEM?-v:this._elevation?this._elevation.getMinElevationBelowMSL():0,w=this.projection.isReprojectedInTileSpace?e.bu(this):1,C=t=>{const r=1/4e4,i=new e.O(t.x+r,t.y,t.z),n=new e.O(t.x,t.y+r,t.z),o=t.toLngLat(),s=i.toLngLat(),a=n.toLngLat(),l=this.locationCoordinate(o),c=this.locationCoordinate(s),u=this.locationCoordinate(a),h=Math.hypot(c.x-l.x,c.y-l.y),d=Math.hypot(u.x-l.x,u.y-l.y);return Math.sqrt(h*d)*w/r},T=t=>{const r=v,i=b;return{aabb:e.bx(this,c,0,0,0,t,i,r,this.projection),zoom:0,x:0,y:0,minZ:i,maxZ:r,wrap:t,fullyVisible:!1}},E=[];let M=[];const S=r,I=t.reparseOverscaled?i:r,P=e=>e*e,D=P((A-this._centerAltitude)*m),k=e=>{if(!this._elevation||!e.tileID||!s)return;const t=this._elevation.getMinMaxForTile(e.tileID),r=e.aabb;t?(r.min[2]=t.min,r.max[2]=t.max,r.center[2]=(r.min[2]+r.max[2])/2):(e.shouldSplit=L(e),e.shouldSplit||(r.min[2]=r.max[2]=r.center[2]=this._centerAltitude))},L=t=>{if(t.zoom<x)return!0;if(t.zoom===S)return!1;if(null!=t.shouldSplit)return t.shouldSplit;const r=t.aabb.distanceX(g),n=t.aabb.distanceY(g);let s=D,a=1;if(h){s=P(t.aabb.distanceZ(g));const r=Math.pow(2,t.zoom),i=e.ax((t.y+1)/r),n=e.ax(t.y/r),o=Math.min(Math.max(l,i),n),c=e.bM(o)/e.bM(l);if(a=o===l?1/Math.max(1,this._mercatorScaleRatio-.3):Math.min(1,c/this._mercatorScaleRatio),this.zoom<=e.bJ&&t.zoom===S-1&&c>=.9)return!0}else if(o&&(s=P(t.aabb.distanceZ(g)*m)),this.projection.isReprojectedInTileSpace&&i<=5){const r=Math.pow(2,t.zoom),i=C(new e.O((t.x+.5)/r,(t.y+.5)/r));a=i>.85?1:i}const c=r*r+n*n+s,u=P((1<<S-t.zoom)*y*a*((e,t)=>{if(t*P(.707)<e)return 1;const r=Math.sqrt(t/e);return r/(1.4144271570014144+(Math.pow(1.1,r-1.4144271570014144+1)-1)/(1.1-1)-1)})(Math.max(s,D),c));return c<u};if(this.renderWorldCopies)for(let e=1;e<=3;e++)E.push(T(-e)),E.push(T(e));for(E.push(T(0));E.length>0;){const i=E.pop(),n=i.x,a=i.y;let l=i.fullyVisible;const d=()=>"globe"===this.projection.name&&(0===i.y||i.y===(1<<i.zoom)-1);if(!l){let t=_?i.aabb.intersects(p):i.aabb.intersectsFlat(p);if(0===t&&d()){const r=new e.bv(i.zoom,n,a);t=e.bw(this,c,r,!0).intersects(p)}if(0===t)continue;l=2===t}if(i.zoom!==S&&L(i))for(let t=0;t<4;t++){const r=(n<<1)+t%2,u=(a<<1)+(t>>1),d={aabb:s?i.aabb.quadrant(t):e.bx(this,c,i.zoom+1,r,u,i.wrap,i.minZ,i.maxZ,this.projection),zoom:i.zoom+1,x:r,y:u,wrap:i.wrap,fullyVisible:l,tileID:void 0,shouldSplit:void 0,minZ:i.minZ,maxZ:i.maxZ};o&&!h&&(d.tileID=new e.ap(i.zoom+1===S?I:i.zoom+1,i.wrap,i.zoom+1,r,u),k(d)),E.push(d)}else{const o=i.zoom===S?I:i.zoom;if(t.minzoom&&t.minzoom>o)continue;if(!l){let t=_?i.aabb.intersectsPrecise(p):i.aabb.intersectsPreciseFlat(p);if(0===t&&d()){const r=new e.bv(i.zoom,n,a);t=e.bw(this,c,r,!0).intersectsPrecise(p)}if(0===t)continue}const s=u[0]-(.5+n+(i.wrap<<i.zoom))*(1<<r-i.zoom),h=u[1]-.5-a,f=i.tileID?i.tileID:new e.ap(o,i.wrap,i.zoom,n,a);M.push({tileID:f,distanceSq:s*s+h*h})}}if(this.fogCullDistSq){const r=this.fogCullDistSq,i=this.horizonLineFromTop();M=M.filter((n=>{const o=[0,0,0,1],s=[e.Y,e.Y,0,1],a=this.calculateFogTileMatrix(n.tileID.toUnwrapped());e.aa.transformMat4(o,o,a),e.aa.transformMat4(s,s,a);const l=e.aa.min([],o,s),c=e.aa.max([],o,s),u=e.by(l,c);if(0===u)return!0;let h=!1;const d=this._elevation;if(d&&u>r&&0!==i){const r=this.calculateProjMatrix(n.tileID.toUnwrapped());let o;t.isTerrainDEM||(o=d.getMinMaxForTile(n.tileID)),o||(o={min:b,max:v});const s=e.bK(this.rotation),a=[s[0]*e.Y,s[1]*e.Y,o.max];e.Q.transformMat4(a,a,r),h=(1-a[1])*this.height*.5<i}return u<r||h}))}return M.sort(((e,t)=>e.distanceSq-t.distanceSq)).map((e=>e.tileID))}resize(e,t){this.width=e,this.height=t,this.pixelsToGLUnits=[2/e,-2/t],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(e){return Math.pow(2,e)}scaleZoom(e){return Math.log(e)/Math.LN2}project(t){const r=e.ad(t.lat,-e.bz,e.bz),i=this.projection.project(t.lng,r);return new e.P(i.x*this.worldSize,i.y*this.worldSize)}unproject(e){return this.projection.unproject(e.x/this.worldSize,e.y/this.worldSize)}get point(){return this.project(this.center)}get pointMerc(){return this.point._div(this.worldSize)}get pixelsPerMeterRatio(){return this.pixelsPerMeter/e.bo(1,this.center.lat)/this.worldSize}setLocationAtPoint(t,r){let i,n;const o=this.centerPoint;if("globe"===this.projection.name){const e=this.worldSize;i=(r.x-o.x)/e,n=(r.y-o.y)/e}else{const e=this.pointCoordinate(r),t=this.pointCoordinate(o);i=e.x-t.x,n=e.y-t.y}const s=this.locationCoordinate(t);this.setLocation(new e.O(s.x-i,s.y-n))}setLocation(e){this.center=this.coordinateLocation(e),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(e){return this.projection.locationPoint(this,e)}locationPoint3D(e){return this.projection.locationPoint(this,e,!0)}pointLocation(e){return this.coordinateLocation(this.pointCoordinate(e))}pointLocation3D(e){return this.coordinateLocation(this.pointCoordinate3D(e))}locationCoordinate(t,r){const i=r?e.bo(r,t.lat):void 0,n=this.projection.project(t.lng,t.lat);return new e.O(n.x,n.y,i)}coordinateLocation(e){return this.projection.unproject(e.x,e.y)}pointRayIntersection(t,r){const i=null!=r?r:this._centerAltitude,n=[t.x,t.y,0,1],o=[t.x,t.y,1,1];e.aa.transformMat4(n,n,this.pixelMatrixInverse),e.aa.transformMat4(o,o,this.pixelMatrixInverse);const s=o[3];e.aa.scale(n,n,1/n[3]),e.aa.scale(o,o,1/s);const a=n[2],l=o[2];return{p0:n,p1:o,t:a===l?0:(i-a)/(l-a)}}screenPointToMercatorRay(t){const r=[t.x,t.y,0,1],i=[t.x,t.y,1,1];return e.aa.transformMat4(r,r,this.pixelMatrixInverse),e.aa.transformMat4(i,i,this.pixelMatrixInverse),e.aa.scale(r,r,1/r[3]),e.aa.scale(i,i,1/i[3]),r[2]=e.bo(r[2],this._center.lat)*this.worldSize,i[2]=e.bo(i[2],this._center.lat)*this.worldSize,e.aa.scale(r,r,1/this.worldSize),e.aa.scale(i,i,1/this.worldSize),new e.a5([r[0],r[1],r[2]],e.Q.normalize([],e.Q.sub([],i,r)))}rayIntersectionCoordinate(t){const{p0:r,p1:i,t:n}=t,o=e.bo(r[2],this._center.lat),s=e.bo(i[2],this._center.lat);return new e.O(e.X(r[0],i[0],n)/this.worldSize,e.X(r[1],i[1],n)/this.worldSize,e.X(o,s,n))}pointCoordinate(e,t=this._centerAltitude){return this.projection.pointCoordinate(this,e.x,e.y,t)}pointCoordinate3D(t){if(!this.elevation)return this.pointCoordinate(t);let r=this.projection.pointCoordinate3D(this,t.x,t.y);if(r)return new e.O(r[0],r[1],r[2]);let i=0,n=this.horizonLineFromTop();if(t.y>n)return this.pointCoordinate(t);const o=.02*n,s=t.clone();for(let t=0;t<10&&n-i>o;t++){s.y=e.X(i,n,.66);const t=this.projection.pointCoordinate3D(this,s.x,s.y);t?(n=s.y,r=t):i=s.y}return r?new e.O(r[0],r[1],r[2]):this.pointCoordinate(t)}isPointAboveHorizon(e){return this.projection.isPointAboveHorizon(this,e)}isPointOnSurface(t){if(t.y<0||t.y>this.height||t.x<0||t.x>this.width)return!1;if(this.elevation||this.zoom>=e.bA)return!this.isPointAboveHorizon(t);const r=this.pointCoordinate(t);return r.y>=0&&r.y<=1}_coordinatePoint(t,r){const i=r&&this.elevation?this.elevation.getAtPointOrZero(t,this._centerAltitude):this._centerAltitude,n=[t.x*this.worldSize,t.y*this.worldSize,i+t.toAltitude(),1];return e.aa.transformMat4(n,n,this.pixelMatrix),n[3]>0?new e.P(n[0]/n[3],n[1]/n[3]):new e.P(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){const{top:t,left:r}=this._edgeInsets,i=this.height-this._edgeInsets.bottom,n=this.width-this._edgeInsets.right,o=this.pointLocation3D(new e.P(r,t)),s=this.pointLocation3D(new e.P(n,t)),a=this.pointLocation3D(new e.P(n,i)),l=this.pointLocation3D(new e.P(r,i));let c=Math.min(o.lng,s.lng,a.lng,l.lng),u=Math.max(o.lng,s.lng,a.lng,l.lng),h=Math.min(o.lat,s.lat,a.lat,l.lat),d=Math.max(o.lat,s.lat,a.lat,l.lat);const p=Math.pow(2,-this.zoom)/16*270,f="globe"===this.projection.name?1:4,m=(t,r,i,n,o)=>{const s=(t+i)/2,a=(r+n)/2,l=new e.P(s,a),{lng:A,lat:g}=this.pointLocation3D(l),_=Math.max(0,c-A,h-g,A-u,g-d);c=Math.min(c,A),u=Math.max(u,A),h=Math.min(h,g),d=Math.max(d,g),(o<f||_>p)&&(m(t,r,s,a,o+1),m(s,a,i,n,o+1))};if(m(r,t,n,t,1),m(n,t,n,i,1),m(n,i,r,i,1),m(r,i,r,t,1),"globe"===this.projection.name){const[t,r]=e.bB(this);t?(d=90,u=180,c=-180):r&&(h=-90,u=180,c=-180)}return new e.ag(new e.bq(c,h),new e.bq(u,d))}_getBoundsRectangular(t,r){const{top:i,left:n}=this._edgeInsets,o=this.height-this._edgeInsets.bottom,s=this.width-this._edgeInsets.right,a=new e.P(n,i),l=new e.P(s,i),c=new e.P(s,o),u=new e.P(n,o);let h=this.pointCoordinate(a,t),d=this.pointCoordinate(l,t);const p=this.pointCoordinate(c,r),f=this.pointCoordinate(u,r),m=(e,t)=>(t.y-e.y)/(t.x-e.x);return h.y>1&&d.y>=0?h=new e.O((1-f.y)/m(f,h)+f.x,1):h.y<0&&d.y<=1&&(h=new e.O(-f.y/m(f,h)+f.x,0)),d.y>1&&h.y>=0?d=new e.O((1-p.y)/m(p,d)+p.x,1):d.y<0&&h.y<=1&&(d=new e.O(-p.y/m(p,d)+p.x,0)),(new e.ag).extend(this.coordinateLocation(h)).extend(this.coordinateLocation(d)).extend(this.coordinateLocation(f)).extend(this.coordinateLocation(p))}_getBoundsRectangularTerrain(){const e=this.elevation;if(!e.visibleDemTiles.length||e.isUsingMockSource())return this._getBoundsRectangular(0,0);const t=e.visibleDemTiles.reduce(((e,t)=>{if(t.dem){const r=t.dem.tree;e.min=Math.min(e.min,r.minimums[0]),e.max=Math.max(e.max,r.maximums[0])}return e}),{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(t.min*e.exaggeration(),t.max*e.exaggeration())}getBounds(){return"mercator"===this.projection.name||"equirectangular"===this.projection.name?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}horizonLineFromTop(e=!0){const t=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))-this.centerOffset.y,r=this.height/2-t*(1-this._horizonShift);return e?Math.max(0,r):r}getMaxBounds(){return this.maxBounds}setMaxBounds(t){this.maxBounds=t,this.minLat=-e.bz,this.maxLat=e.bz,this.minLng=-180,this.maxLng=180,t&&(this.minLat=t.getSouth(),this.maxLat=t.getNorth(),this.minLng=t.getWest(),this.maxLng=t.getEast(),this.maxLng<this.minLng&&(this.maxLng+=360)),this.worldMinX=e.a8(this.minLng)*this.tileSize,this.worldMaxX=e.a8(this.maxLng)*this.tileSize,this.worldMinY=e.ah(this.maxLat)*this.tileSize,this.worldMaxY=e.ah(this.minLat)*this.tileSize,this._constrain()}calculatePosMatrix(e,t){return this.projection.createTileMatrix(this,t,e)}calculateDistanceTileData(t){const r=t.key,i=this._distanceTileDataCache;if(i[r])return i[r];const n=t.canonical,o=1/this.height,s=this.cameraWorldSize,a=s/this.zoomScale(n.z),l=(n.x+Math.pow(2,n.z)*t.wrap)*a,c=n.y*a,u=this.point;u.x*=s/this.worldSize,u.y*=s/this.worldSize;const h=this.angle,d=Math.sin(-h),p=-Math.cos(-h);return i[r]={bearing:[d,p],center:[(u.x-l)*o,(u.y-c)*o],scale:a/e.Y*o},i[r]}calculateFogTileMatrix(t){const r=t.key,i=this._fogTileMatrixCache;if(i[r])return i[r];const n=this.projection.createTileMatrix(this,this.cameraWorldSizeForFog,t);return e.a9.multiply(n,this.worldToFogMatrix,n),i[r]=new Float32Array(n),i[r]}calculateProjMatrix(t,r=!1,i=!1){const n=t.key;let o;if(o=i?this._expandedProjMatrixCache:r?this._alignedProjMatrixCache:this._projMatrixCache,o[n])return o[n];const s=this.calculatePosMatrix(t,this.worldSize);let a;return a=this.projection.isReprojectedInTileSpace?this.mercatorMatrix:i?this.expandedFarZProjMatrix:r?this.alignedProjMatrix:this.projMatrix,e.a9.multiply(s,a,s),o[n]=new Float32Array(s),o[n]}calculatePixelsToTileUnitsMatrix(t){const r=t.tileID.key,i=this._pixelsToTileUnitsCache;if(i[r])return i[r];const n=e.bC(t,this);return i[r]=n,i[r]}customLayerMatrix(){return this.mercatorMatrix.slice()}globeToMercatorMatrix(){if("globe"===this.projection.name){const t=1/this.worldSize,r=e.a9.fromScaling([],[t,t,t]);return e.a9.multiply(r,r,this.globeMatrix),r}}recenterOnTerrain(){if(!this._elevation||"globe"===this.projection.name)return;const t=this._elevation;this._updateCameraState();const r=e.bo(1,this._center.lat)*this.worldSize,i=this._computeCameraPosition(r),n=this._camera.forward(),o=e.bo(1,this._center.lat);i[2]/=o,n[2]/=o,e.Q.normalize(n,n);const s=t.raycast(i,n,t.exaggeration());if(s){const t=e.Q.scaleAndAdd([],i,n,s),r=new e.O(t[0],t[1],e.bo(t[2],e.ax(t[1]))),a=(r.z+e.Q.length([r.x-i[0],r.y-i[1],r.z-i[2]*o]))*this._pixelsPerMercatorPixel;this._seaLevelZoom=this._zoomFromMercatorZ(a),this._centerAltitude=r.toAltitude(),this._center=this.coordinateLocation(r),this._updateZoomFromElevation(),this._constrain(),this._calcMatrices()}}_constrainCamera(t=!1){if(!this._elevation)return;const r=this._elevation,i=e.bo(1,this._center.lat)*this.worldSize,n=this._computeCameraPosition(i),o=r.getAtPointOrZero(new e.O(...n)),s=this.pixelsPerMeter/this.worldSize*o,a=this._minimumHeightOverTerrain(),l=n[2]-s;if(l<=a)if(l<0||t){const t=this.locationCoordinate(this._center,this._centerAltitude),r=[n[0],n[1],t.z-n[2]],i=e.Q.length(r);r[2]-=(a-l)/this._pixelsPerMercatorPixel;const o=e.Q.length(r);if(0===o)return;e.Q.scale(r,r,i/o*this._pixelsPerMercatorPixel),this._camera.position=[n[0],n[1],t.z*this._pixelsPerMercatorPixel-r[2]],this._updateStateFromCamera()}else this._isCameraConstrained=!0}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const t="globe"===this.projection.name||this.mercatorFromTransition;if(this.projection.isReprojectedInTileSpace||t){const r=this.center;return r.lat=e.ad(r.lat,this.minLat,this.maxLat),(this.maxBounds||!this.renderWorldCopies&&!t)&&(r.lng=e.ad(r.lng,this.minLng,this.maxLng)),this.center=r,void(this._constraining=!1)}const r=this._unmodified,{x:i,y:n}=this.point;let o=0,s=i,a=n;const l=this.width/2,c=this.height/2,u=this.worldMinY*this.scale,h=this.worldMaxY*this.scale;if(n-c<u&&(a=u+c),n+c>h&&(a=h-c),h-u<this.height&&(o=Math.max(o,this.height/(h-u)),a=(h+u)/2),this.maxBounds||!this._renderWorldCopies||!this.projection.wrap){const e=this.worldMinX*this.scale,t=this.worldMaxX*this.scale,r=this.worldSize/2-(e+t)/2;s=(i+r+this.worldSize)%this.worldSize-r,s-l<e&&(s=e+l),s+l>t&&(s=t-l),t-e<this.width&&(o=Math.max(o,this.width/(t-e)),s=(t+e)/2)}s===i&&a===n||(this.center=this.unproject(new e.P(s,a))),o&&(this.zoom+=this.scaleZoom(o)),this._constrainCamera(),this._unmodified=r,this._constraining=!1}_minZoomForBounds(){let e=Math.max(0,this.scaleZoom(this.height/(this.worldMaxY-this.worldMinY)));return this.maxBounds&&(e=Math.max(e,this.scaleZoom(this.width/(this.worldMaxX-this.worldMinX)))),e}_maxCameraBoundsDistance(){return this._mercatorZfromZoom(this._minZoomForBounds())}_calcMatrices(){if(!this.height)return;const t=this.centerOffset,r="globe"===this.projection.name,i=this.pixelsPerMeter;"globe"===this.projection.name&&(this._mercatorScaleRatio=e.bo(1,this.center.lat)/e.bo(1,e.bL));const n=e.bD(this.projection,this.zoom,this.width,this.height,1024);this._pixelsPerMercatorPixel=this.projection.pixelSpaceConversion(this.center.lat,this.worldSize,n),this.cameraToCenterDistance=.5/Math.tan(.5*this._fov)*this.height*this._pixelsPerMercatorPixel,this._updateCameraState(),this._farZ=this.projection.farthestPixelDistance(this),this._nearZ=this.height/50;const o="meters"===this.projection.zAxisUnit?i:1,s=this._camera.getWorldToCamera(this.worldSize,o);let a;const l=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,this._farZ);if(l[8]=2*-t.x/this.width,l[9]=2*t.y/this.height,this.isOrthographic){let e=.5*this.height/Math.tan(this._fov/2)*1*Math.tan(.5*this._fov),r=e*this.aspect,i=-r,n=-e;r-=t.x,i-=t.x,e+=t.y,n+=t.y,a=this._camera.getCameraToClipOrthographic(i,r,n,e,this._nearZ,this._farZ),((e,t,r,i)=>{for(let n=0;n<16;n++)e[n]=hi(t[n],r[n],i)})(a,a,l,di(this.pitch>=15?1:this.pitch/15))}else a=l;const c=e.a9.mul([],l,s);let u=e.a9.mul([],a,s);if(this.projection.isReprojectedInTileSpace){const t=this.locationCoordinate(this.center),r=e.a9.identity([]);e.a9.translate(r,r,[t.x*this.worldSize,t.y*this.worldSize,0]),e.a9.multiply(r,r,e.bE(this)),e.a9.translate(r,r,[-t.x*this.worldSize,-t.y*this.worldSize,0]),e.a9.multiply(u,u,r),e.a9.multiply(c,c,r),this.inverseAdjustmentMatrix=e.bF(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];if(this.mercatorMatrix=e.a9.scale([],u,[this.worldSize,this.worldSize,this.worldSize/o,1]),this.projMatrix=u,this.invProjMatrix=e.a9.invert(new Float64Array(16),this.projMatrix),r){const r=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);r[8]=2*-t.x/this.width,r[9]=2*t.y/this.height,this.expandedFarZProjMatrix=e.a9.mul([],r,s)}else this.expandedFarZProjMatrix=this.projMatrix;const h=e.a9.invert([],a);this.frustumCorners=e.bG.fromInvProjectionMatrix(h,this.horizonLineFromTop(),this.height),this.cameraFrustum=e.bt.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!r);const d=new Float32Array(16);e.a9.identity(d),e.a9.scale(d,d,[1,-1,1]),e.a9.rotateX(d,d,this._pitch),e.a9.rotateZ(d,d,this.angle);const p=e.a9.perspective(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ);this.starsProjMatrix=e.a9.clone(p);const f=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;p[8]=2*-t.x/this.width,p[9]=2*(t.y+f)/this.height,this.skyboxMatrix=e.a9.multiply(d,p,d);const m=this.point,A=m.x,g=m.y,_=this.width%2/2,y=this.height%2/2,x=Math.cos(this.angle),v=Math.sin(this.angle),b=A-Math.round(A)+x*_+v*y,w=g-Math.round(g)+x*y+v*_,C=new Float64Array(u);if(e.a9.translate(C,C,[b>.5?b-1:b,w>.5?w-1:w,0]),this.alignedProjMatrix=C,u=e.a9.create(),e.a9.scale(u,u,[this.width/2,-this.height/2,1]),e.a9.translate(u,u,[1,-1,0]),this.labelPlaneMatrix=u,u=e.a9.create(),e.a9.scale(u,u,[1,-1,1]),e.a9.translate(u,u,[-1,-1,0]),e.a9.scale(u,u,[2/this.width,2/this.height,1]),this.glCoordMatrix=u,this.pixelMatrix=e.a9.multiply(new Float64Array(16),this.labelPlaneMatrix,c),this._calcFogMatrices(),this._distanceTileDataCache={},u=e.a9.invert(new Float64Array(16),this.pixelMatrix),!u)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=u,"globe"===this.projection.name||this.mercatorFromTransition){this.globeMatrix=e.bH(this);const t=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=e.Q.transformMat4(t,t,s),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=u;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const t=this.cameraWorldSizeForFog,r=this.cameraPixelsPerMeter,i=this._camera.position,n=1/this.height/this._pixelsPerMercatorPixel,o=[t,t,r];e.Q.scale(o,o,n),e.Q.scale(i,i,-1),e.Q.multiply(i,i,o);const s=e.a9.create();e.a9.translate(s,s,i),e.a9.scale(s,s,o),this.mercatorFogMatrix=s,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(t,r,n)}_computeCameraPosition(e){const t=(e=e||this.pixelsPerMeter)/this.pixelsPerMeter,r=this._camera.forward(),i=this.point,n=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*t-e/this.worldSize*this._centerAltitude;return[i.x/this.worldSize-r[0]*n,i.y/this.worldSize-r[1]*n,e/this.worldSize*this._centerAltitude-r[2]*n]}_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),i=this._camera.position[2],n=t[2];let o=1;this.projection.wrap&&(this.center=this.center.wrap()),n>0&&(o=Math.min((r-i)/n,1)),this._camera.position=e.Q.scaleAndAdd([],this._camera.position,t,o),this._updateStateFromCamera()}_updateStateFromCamera(){const t=this._camera.position,r=this._camera.forward(),{pitch:i,bearing:n}=this._camera.getPitchBearing(),o=e.bo(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,s=this._mercatorZfromZoom(this._maxZoom)*Math.cos(e.bm(this._maxPitch)),a=Math.max((t[2]-o)/Math.cos(i),s),l=this._zoomFromMercatorZ(a);e.Q.scaleAndAdd(t,t,r,a),this._pitch=e.ad(i,e.bm(this.minPitch),e.bm(this.maxPitch)),this.angle=e.bk(n,-Math.PI,Math.PI),this._setZoom(e.ad(l,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new e.O(t[0],t[1],t[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(e){return Math.pow(2,e)*this.tileSize}_mercatorZfromZoom(e){return this.cameraToCenterDistance/this._worldSizeFromZoom(e)}_minimumHeightOverTerrain(){const e=Math.min(null!=this._seaLevelZoom?this._seaLevelZoom:this._zoom,this._maxZoom)+4;return this._mercatorZfromZoom(e)}_zoomFromMercatorZ(e){return this.scaleZoom(this.cameraToCenterDistance/(e*this.tileSize))}zoomFromMercatorZAdjusted(t){let r=0,i=e.bA,n=0,o=1/0;for(;i-r>1e-6&&i>r;){const e=r+.5*(i-r),s=this.tileSize*Math.pow(2,e),a=this.getCameraToCenterDistance(this.projection,e,s),l=this.scaleZoom(a/(t*this.tileSize)),c=Math.abs(e-l);c<o&&(o=c,n=e),e<l?r=e:i=e}return n}_terrainEnabled(){return!(!this._elevation||!this.projection.supportsTerrain&&(e.w("Terrain is not yet supported with alternate projections. Use mercator or globe to enable terrain."),1))}anyCornerOffEdge(t,r){const i=Math.min(t.x,r.x),n=Math.max(t.x,r.x),o=Math.min(t.y,r.y),s=Math.max(t.y,r.y);if(o<this.horizonLineFromTop(!1))return!0;if("mercator"!==this.projection.name)return!1;const a=[new e.P(i,o),new e.P(n,s),new e.P(i,s),new e.P(n,o)],l=this.renderWorldCopies?-3:0,c=this.renderWorldCopies?4:1;for(const e of a){const t=this.pointRayIntersection(e);if(t.t<0)return!0;const r=this.rayIntersectionCoordinate(t);if(r.x<l||r.y<0||r.x>c||r.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+e.bI(this.fovAboveCenter)>88||this.anyCornerOffEdge(new e.P(0,0),new e.P(this.width,this.height))}zoomDeltaToMovement(t,r){const i=e.Q.length(e.Q.sub([],this._camera.position,t)),n=this._zoomFromMercatorZ(i)+r;return i-this._mercatorZfromZoom(n)}getCameraPoint(){if("globe"===this.projection.name){const t=function([t,r,i],n){const o=[t,r,i,1];e.aa.transformMat4(o,o,n);const s=o[3]=Math.max(o[3],1e-6);return o[0]/=s,o[1]/=s,o[2]/=s,o}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new e.P(t[0],t[1])}{const t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new e.P(0,t))}}getCameraToCenterDistance(t,r=this.zoom,i=this.worldSize){const n=e.bD(t,r,this.width,this.height,1024),o=t.pixelSpaceConversion(this.center.lat,i,n);let s=.5/Math.tan(.5*this._fov)*this.height*o;return this.isOrthographic&&(s=hi(1,s,di(this.pitch>=15?1:this.pitch/15))),s}getWorldToCameraMatrix(){const t=this._camera.getWorldToCamera(this.worldSize,"meters"===this.projection.zAxisUnit?this.pixelsPerMeter:1);return"globe"===this.projection.name&&e.a9.multiply(t,t,this.globeMatrix),t}getFrustum(t){return e.bt.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,t,"meters"===this.projection.zAxisUnit)}}const fi={BaseColor:5,MetallicRoughness:6,Normal:7,Occlusion:8,Emission:9,ShadowMap0:10},mi=(t,r)=>{if(r>0&&t.terrain&&e.w("Cutoff is currently disabled on terrain"),r<=0||t.terrain)return{shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};const i=t.transform,n=Math.max(Math.abs(i._zoom-(t.minCutoffZoom-1)),1),o=i.isLODDisabled(!1)?e.S(60,45,i.pitch):e.S(30,15,i.pitch),s=i._farZ-i._nearZ,a=r*i.height,l=((1-(c=o))*i.cameraToCenterDistance+c*(i._farZ+a))*n;var c;return{shouldRenderCutoff:o<1,uniformValues:{u_cutoff_params:[i._nearZ,i._farZ,(l-i._nearZ)/s,(l-a-i._nearZ)/s]}}},Ai={cascadeCount:2,shadowMapResolution:2048};class gi{constructor(e,t){this.aabb=e,this.lastCascade=t}}class _i{add(e,t){const r=this.receivers[e.key];void 0!==r?(r.aabb.min[0]=Math.min(r.aabb.min[0],t.min[0]),r.aabb.min[1]=Math.min(r.aabb.min[1],t.min[1]),r.aabb.min[2]=Math.min(r.aabb.min[2],t.min[2]),r.aabb.max[0]=Math.max(r.aabb.max[0],t.max[0]),r.aabb.max[1]=Math.max(r.aabb.max[1],t.max[1]),r.aabb.max[2]=Math.max(r.aabb.max[2],t.max[2])):this.receivers[e.key]=new gi(t,null)}clear(){this.receivers={}}get(e){return this.receivers[e.key]}computeRequiredCascades(t,r,i){const n=e.bV.fromPoints(t.points);let o=0;for(const t in this.receivers){const s=this.receivers[t];if(!s)continue;if(!n.intersectsAabb(s.aabb))continue;s.aabb.min=n.closestPoint(s.aabb.min),s.aabb.max=n.closestPoint(s.aabb.max);const a=s.aabb.getCorners();for(let t=0;t<i.length;t++){let n=!0;for(const o of a){const s=[o[0]*r,o[1]*r,o[2]];if(e.Q.transformMat4(s,s,i[t].matrix),s[0]<-1||s[0]>1||s[1]<-1||s[1]>1){n=!1;break}}if(s.lastCascade=t,o=Math.max(o,t),n)break}}return o+1}}class yi{constructor(e){this.painter=e,this._enabled=!1,this._shadowLayerCount=0,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new _i,this._depthMode=new Et(e.context.gl.LEQUAL,Et.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,e.tp.registerParameter(this,["Shadows"],"_forceDisable",{label:"forceDisable"},(()=>{this.painter.style.map.triggerRepaint()})),e.tp.registerParameter(Ai,["Shadows"],"cascadeCount",{min:1,max:2,step:1}),e.tp.registerParameter(Ai,["Shadows"],"shadowMapResolution",{min:32,max:2048,step:32}),e.tp.registerBinding(this,["Shadows"],"_numCascadesToRender",{readonly:!0,label:"numCascadesToRender"})}destroy(){for(const e of this._cascades)e.texture.destroy(),e.framebuffer.destroy();this._cascades=[]}updateShadowParameters(t,r){const i=this.painter;if(this._enabled=!1,this._shadowLayerCount=0,this._receivers.clear(),!r||!r.properties)return;const n=r.properties.get("shadow-intensity");if(!r.shadowsEnabled()||n<=0)return;if(this._shadowLayerCount=i.style.order.reduce(((e,r)=>{const n=i.style._mergedLayers[r];return e+(n.hasShadowPass()&&!n.isHidden(t.zoom)?1:0)}),0),this._enabled=this._shadowLayerCount>0,!this.enabled)return;const o=i.context,s=Ai.shadowMapResolution,a=Ai.shadowMapResolution;if(0===this._cascades.length||Ai.shadowMapResolution!==this._cascades[0].texture.size[0]){this._cascades=[];for(let t=0;t<Ai.cascadeCount;++t){const t=i._shadowMapDebug,r=o.gl,n=o.createFramebuffer(s,a,t,"texture"),l=new e.T(o,{width:s,height:a,data:null},r.DEPTH_COMPONENT);if(n.depthAttachment.set(l.texture),t){const t=new e.T(o,{width:s,height:a,data:null},r.RGBA);n.colorAttachment.set(t.texture)}this._cascades.push({framebuffer:n,texture:l,matrix:[],far:0,boundingSphereRadius:0,frustum:new e.bt,scale:0})}}this.shadowDirection=vi(r);let l=0;if(t.elevation){const e=t.elevation,r=[1e4,-1e4];e.visibleDemTiles.filter((e=>e.dem)).forEach((e=>{const t=e.dem.tree;r[0]=Math.min(r[0],t.minimums[0]),r[1]=Math.max(r[1],t.maximums[0])})),1e4!==r[0]&&(l=(r[1]-r[0])*e.exaggeration())}const c=1.5*t.cameraToCenterDistance,u=3*c,h=new Float64Array(16);for(let r=0;r<this._cascades.length;++r){const i=this._cascades[r];let n=t.height/50,o=1;1===Ai.cascadeCount?o=u:0===r?o=c:(n=c,o=u);const[s,a]=wi(t,this.shadowDirection,n,o,Ai.shadowMapResolution,l);i.scale=t.scale,i.matrix=s,i.boundingSphereRadius=a,e.a9.invert(h,i.matrix),i.frustum=e.bt.fromInvProjectionMatrix(h,1,0,!0),i.far=o}const d=this._cascades.length-1;this._uniformValues.u_fade_range=[.75*this._cascades[d].far,this._cascades[d].far],this._uniformValues.u_shadow_intensity=n,this._uniformValues.u_shadow_direction=[this.shadowDirection[0],this.shadowDirection[1],this.shadowDirection[2]],this._uniformValues.u_shadow_texel_size=1/Ai.shadowMapResolution,this._uniformValues.u_shadow_map_resolution=Ai.shadowMapResolution,this._uniformValues.u_shadowmap_0=fi.ShadowMap0,this._uniformValues.u_shadowmap_1=fi.ShadowMap0+1,this._groundShadowTiles=i.transform.coveringTiles({tileSize:512,renderWorldCopies:!0});const p=i.transform.elevation;for(const e of this._groundShadowTiles){let t={min:0,max:0};if(p){const r=p.getMinMaxForTile(e);r&&(t=r)}this.addShadowReceiver(e.toUnwrapped(),t.min,t.max)}}get enabled(){return this._enabled&&!this._forceDisable}set enabled(e){this._enabled=e}drawShadowPass(t,r){if(!this.enabled)return;const i=this.painter,n=i.context;this._numCascadesToRender=this._receivers.computeRequiredCascades(i.transform.getFrustum(0),i.transform.worldSize,this._cascades),n.viewport.set([0,0,Ai.shadowMapResolution,Ai.shadowMapResolution]);for(let o=0;o<this._numCascadesToRender;++o){i.currentShadowCascade=o,n.bindFramebuffer.set(this._cascades[o].framebuffer.framebuffer),n.clear({color:e.aA.white,depth:1});for(const e of t.order){const n=t._mergedLayers[e];if(!n.hasShadowPass()||n.isHidden(i.transform.zoom))continue;const o=t.getLayerSourceCache(n),s=o?r[o.id]:void 0;("model"===n.type||s&&s.length)&&i.renderLayer(i,o,n,s)}}i.currentShadowCascade=0}drawGroundShadows(){if(!this.enabled)return;const e=this.painter,t=e.style,r=e.context,i=t.directionalLight,n=t.ambientLight;if(!i||!n)return;const o=[],s=mi(e,e.longestCutoffRange);s.shouldRenderCutoff&&o.push("RENDER_CUTOFF");const a=bi(i,n),l=new Et(r.gl.LEQUAL,Et.ReadOnly,e.depthRangeFor3D);for(const t of this._groundShadowTiles){const i=t.toUnwrapped(),n=e.isTileAffectedByFog(t),c=e.getOrCreateProgram("groundShadow",{defines:o,overrideFog:n});this.setupShadows(i,c),e.uploadCommonUniforms(r,c,i,null,s);const u={u_matrix:e.transform.calculateProjMatrix(i),u_ground_shadow_factor:a};c.draw(e,r.gl.TRIANGLES,l,St.disabled,Pt.multiply,Lt.disabled,u,"ground_shadow",e.tileExtentBuffer,e.quadTriangleIndexBuffer,e.tileExtentSegments,{},e.transform.zoom,null,null)}}getShadowPassColorMode(){return this.painter._shadowMapDebug?Pt.unblended:Pt.disabled}getShadowPassDepthMode(){return this._depthMode}getShadowCastingLayerCount(){return this._shadowLayerCount}calculateShadowPassMatrixFromTile(t){const r=this.painter.transform,i=r.calculatePosMatrix(t,r.worldSize);return e.a9.multiply(i,this._cascades[this.painter.currentShadowCascade].matrix,i),Float32Array.from(i)}calculateShadowPassMatrixFromMatrix(t){return e.a9.multiply(t,this._cascades[this.painter.currentShadowCascade].matrix,t),Float32Array.from(t)}setupShadows(t,r,i,n=0){if(!this.enabled)return;const o=this.painter.transform,s=this.painter.context,a=s.gl,l=this._uniformValues,c=new Float64Array(16),u=o.calculatePosMatrix(t,o.worldSize);for(let t=0;t<this._cascades.length;t++)e.a9.multiply(c,this._cascades[t].matrix,u),l[0===t?"u_light_matrix_0":"u_light_matrix_1"]=Float32Array.from(c),s.activeTexture.set(a.TEXTURE0+fi.ShadowMap0+t),this._cascades[t].texture.bind(a.NEAREST,a.CLAMP_TO_EDGE);if(this.useNormalOffset=!!i,this.useNormalOffset){const r=e.bU(t.canonical),s=2/o.tileSize*e.Y/Ai.shadowMapResolution,a=s*this._cascades[0].boundingSphereRadius,c=s*this._cascades[this._cascades.length-1].boundingSphereRadius,u=("vector-tile"===i?1:3)/Math.pow(2,n-t.canonical.z-(1-o.zoom+Math.floor(o.zoom)));l.u_shadow_normal_offset=[r,a*u,c*u],l.u_shadow_bias=[6e-5,.0012,.012]}else l.u_shadow_bias=[36e-5,.0012,.012];r.setShadowUniformValues(s,l)}setupShadowsFromMatrix(t,r,i=!1){if(!this.enabled)return;const n=this.painter.context,o=n.gl,s=this._uniformValues,a=new Float64Array(16);for(let r=0;r<Ai.cascadeCount;r++)e.a9.multiply(a,this._cascades[r].matrix,t),s[0===r?"u_light_matrix_0":"u_light_matrix_1"]=Float32Array.from(a),n.activeTexture.set(o.TEXTURE0+fi.ShadowMap0+r),this._cascades[r].texture.bind(o.NEAREST,o.CLAMP_TO_EDGE);if(this.useNormalOffset=i,i){const e=5;s.u_shadow_normal_offset=[1,e,e],s.u_shadow_bias=[6e-5,.0012,.012]}else s.u_shadow_bias=[36e-5,.0012,.012];r.setShadowUniformValues(n,s)}getShadowUniformValues(){return this._uniformValues}getCurrentCascadeFrustum(){return this._cascades[this.painter.currentShadowCascade].frustum}computeSimplifiedTileShadowVolume(t,r,i,n){if(n[2]>=0)return{};const o=function(t,r,i){const n=i/(1<<t.canonical.z);return new e.bV([t.canonical.x*n+t.wrap*i,t.canonical.y*n+t.wrap*i,0],[(t.canonical.x+1)*n+t.wrap*i,(t.canonical.y+1)*n+t.wrap*i,r])}(t,r,i).getCorners(),s=r/-n[2];n[0]<0?(e.Q.add(o[0],o[0],[n[0]*s,0,0]),e.Q.add(o[3],o[3],[n[0]*s,0,0])):n[0]>0&&(e.Q.add(o[1],o[1],[n[0]*s,0,0]),e.Q.add(o[2],o[2],[n[0]*s,0,0])),n[1]<0?(e.Q.add(o[0],o[0],[0,n[1]*s,0]),e.Q.add(o[1],o[1],[0,n[1]*s,0])):n[1]>0&&(e.Q.add(o[2],o[2],[0,n[1]*s,0]),e.Q.add(o[3],o[3],[0,n[1]*s,0]));const a={};return a.vertices=o,a.planes=[xi(o[1],o[0],o[4]),xi(o[2],o[1],o[5]),xi(o[3],o[2],o[6]),xi(o[0],o[3],o[7])],a}addShadowReceiver(t,r,i){this._receivers.add(t,e.bV.fromTileIdAndHeight(t,r,i))}getMaxCascadeForTile(e){const t=this._receivers.get(e);return t&&t.lastCascade?t.lastCascade:0}}function xi(t,r,i){const n=e.Q.sub([],i,r),o=e.Q.sub([],t,r),s=e.Q.cross([],n,o),a=e.Q.length(s);return 0===a?[0,0,1,0]:(e.Q.scale(s,s,1/a),[s[0],s[1],s[2],-e.Q.dot(s,r)])}function vi(t){const r=t.properties.get("direction"),i=e.bT(r.x,r.y,r.z);i[2]=e.ad(i[2],0,75);const n=e.bW([i[0],i[1],i[2]]);return e.Q.fromValues(n.x,n.y,n.z)}function bi(t,r){const i=t.properties.get("color"),n=t.properties.get("intensity"),o=t.properties.get("direction"),s=[o.x,o.y,o.z],a=r.properties.get("color"),l=r.properties.get("intensity"),c=Math.max(e.Q.dot([0,0,1],s),0),u=[0,0,0];e.Q.scale(u,a.toArray01Linear().slice(0,3),l);const h=[0,0,0];return e.Q.scale(h,i.toArray01Linear().slice(0,3),c*n),e.bX([u[0]>0?u[0]/(u[0]+h[0]):0,u[1]>0?u[1]/(u[1]+h[1]):0,u[2]>0?u[2]/(u[2]+h[2]):0])}function wi(t,r,i,n,o,s){const a=t.zoom,l=t.scale,c=t.worldSize,u=1/c,h=t.aspect,d=Math.sqrt(1+h*h)*Math.tan(.5*t.fovX),p=d*d,f=n-i,m=n+i;let A,g;p>f/m?(A=n,g=n*d):(A=.5*m*(1+p),g=.5*Math.sqrt(f*f+2*(n*n+i*i)*p+m*m*p*p));const _=t.projection.pixelsPerMeter(t.center.lat,c),y=t._camera.getCameraToWorldMercator(),x=[0,0,-A*u];e.Q.transformMat4(x,x,y);let v=g*u;const b=t._edgeInsets;if(!(0===b.left&&0===b.top&&0===b.right&&0===b.bottom||b.left===b.right&&b.top===b.bottom)){const r=t._camera.getWorldToCamera(t.worldSize,"meters"===t.projection.zAxisUnit?_:1),o=t._camera.getCameraToClipPerspective(t._fov,t.width/t.height,i,n);o[8]=2*-t.centerOffset.x/t.width,o[9]=2*t.centerOffset.y/t.height;const s=new Float64Array(16);e.a9.mul(s,o,r);const u=new Float64Array(16);e.a9.invert(u,s);const h=e.bt.fromInvProjectionMatrix(u,c,a,!0);for(const r of h.points){const i=((w=r)[0]/=l,w[1]/=l,w[2]=e.bo(w[2],t._center.lat),w);v=Math.max(v,e.Q.len(e.Q.subtract([],x,i)))}}var w;v*=o/(o-1);const C=Math.acos(r[2]),T=Math.atan2(-r[0],-r[1]),E=new ui;E.position=x,E.setPitchBearing(C,T);const M=E.getWorldToCamera(c,_),S=v*c,I=Math.min(t._mercatorZfromZoom(17)*c*-2,-2*S),P=E.getCameraToClipOrthographic(-S,S,-S,S,I,(S+s*_)/r[2]),D=new Float64Array(16);e.a9.multiply(D,P,M);const k=e.Q.fromValues(Math.floor(1e6*x[0])/1e6*c,Math.floor(1e6*x[1])/1e6*c,0),L=.5*o,z=[0,0,0];e.Q.transformMat4(z,k,D),e.Q.scale(z,z,L);const O=[Math.floor(z[0]),Math.floor(z[1]),Math.floor(z[2])],B=[0,0,0];e.Q.sub(B,z,O),e.Q.scale(B,B,-1/L);const R=new Float64Array(16);return e.a9.identity(R),e.a9.translate(R,R,B),e.a9.multiply(D,R,D),[D,S]}const Ci=(e,t)=>se(e,t&&t.filter((e=>"source.canvas"!==e.identifier))),Ti=e.af(tr,["addLayer","removeLayer","setLights","setPaintProperty","setLayoutProperty","setSlot","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection","setCamera","addImport","removeImport","updateImport"]),Ei=e.af(tr,["setCenter","setZoom","setBearing","setPitch"]),Mi={version:8,layers:[],sources:{}},Si={duration:300,delay:0};class Ii extends e.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=e.e({},Si),this._buildingIndex=new Kt(this),this.crossTileSymbolIndex=new ni,this._mergedOrder=[],this._drapedFirstOrder=[],this._mergedLayers={},this._mergedSourceCaches={},this._mergedOtherSourceCaches={},this._mergedSymbolSourceCaches={},this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this._changes=r.styleChanges||new _,this.dispatcher=r.dispatcher?r.dispatcher:new e.bZ(e.b_(),this),r.imageManager?this.imageManager=r.imageManager:(this.imageManager=new b,this.imageManager.setEventedParent(this)),this.imageManager.createScope(this.scope),this.glyphManager=r.glyphManager?r.glyphManager:new e.b$(t._requestManager,r.localFontFamily?e.c0.all:r.localIdeographFontFamily?e.c0.ideographs:e.c0.none,r.localFontFamily||r.localIdeographFontFamily),r.modelManager?this.modelManager=r.modelManager:(this.modelManager=new y(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.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",e.c1());const i=this;this._rtlTextPluginCallback=Ii.registerForPluginStateChange((t=>{i.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:t.pluginStatus,pluginURL:t.pluginURL},((t,r)=>{if(e.c2(t),r&&r.every((e=>e)))for(const e in i._sourceCaches){const t=i._sourceCaches[e],r=t.getSource().type;"vector"!==r&&"geojson"!==r||t.reload()}}))})),this.on("data",(e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const t=this.getOwnSource(e.sourceId);if(t&&t.vectorLayerIds)for(const e in this._layers){const r=this._layers[e];r.source===t.id&&this._validateLayer(r)}}))}load(e){return e?("string"==typeof e?this.loadURL(e):this.loadJSON(e),this):this}_getGlobalId(t){if(!t)return null;if("string"==typeof t){if(e.c3(t))return t;const r=e.c4(t);if(!r.startsWith("http"))try{return new URL(r,location.href).toString()}catch(e){return r}return r}return`json://${e.c5(JSON.stringify(t))}`}_diffStyle(t,r,i){this.globalId=this._getGlobalId(t);const n=(e,t)=>{try{t(null,this.setState(e,i))}catch(e){t(e,!1)}};if("string"==typeof t){const i=this.map._requestManager.normalizeStyleURL(t),o=this.map._requestManager.transformRequest(i,e.R.Style);e.g(o,((t,i)=>{t?this.fire(new e.a(t)):i&&n(i,r)}))}else"object"==typeof t&&n(t,r)}loadURL(t,r={}){this.fire(new e.b("dataloading",{dataType:"style"}));const i="boolean"==typeof r.validate?r.validate:!e.c3(t);this.globalId=this._getGlobalId(t),t=this.map._requestManager.normalizeStyleURL(t,r.accessToken),this.resolvedImports.add(t);const n=this.importsCache.get(t);if(n)return this._load(n,i);const o=this.map._requestManager.transformRequest(t,e.R.Style);this._request=e.g(o,((r,n)=>{if(this._request=null,r)this.fire(new e.a(r));else if(n)return this.importsCache.set(t,n),this._load(n,i)}))}loadJSON(t,r={}){this.fire(new e.b("dataloading",{dataType:"style"})),this.globalId=this._getGlobalId(t),this._request=e.f.frame((()=>{this._request=null,this._load(t,!1!==r.validate)}))}loadEmpty(){this.fire(new e.b("dataloading",{dataType:"style"})),this._load(Mi,!1)}_loadImports(t,r,i){if(this.importDepth>=4)return e.w("Style doesn't support nesting deeper than 5"),Promise.resolve();const n=[];for(const e of t){const t=this._createFragmentStyle(e),o=new Promise((e=>{t.once("style.import.load",e),t.once("error",e)})).then((()=>this.mergeAll()));if(n.push(o),this.resolvedImports.has(e.url)){t.loadEmpty();continue}const s=e.data||this.importsCache.get(e.url);s?(t.loadJSON(s,{validate:r}),this._isInternalStyle(s)&&(t.globalId=null)):e.url?t.loadURL(e.url,{validate:r}):t.loadEmpty();const a={style:t,id:e.id,config:e.config};if(i){const e=this.fragments.findIndex((({id:e})=>e===i));this.fragments=this.fragments.slice(0,e).concat(a).concat(this.fragments.slice(e))}else this.fragments.push(a)}return Promise.allSettled(n)}getImportGlobalIds(e=this,t=new Set){for(const r of e.fragments)r.style.globalId&&t.add(r.style.globalId),this.getImportGlobalIds(r.style,t);return[...t.values()]}_createFragmentStyle(t){const r=this.scope?e.aj(t.id,this.scope):t.id;let i;const n=this._initialConfig&&this._initialConfig[r];(t.config||n)&&(i=e.e({},t.config,n));const o=new Ii(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:i,configOptions:this.options,configDependentLayers:this._configDependentLayers});return o.setEventedParent(this.map,{style:o}),o}_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.isRootStyle()}_isInternalStyle(e){return this.isRootStyle()&&(e.fragment||!!e.schema&&!1!==e.fragment)}_load(t,r){const i=t.schema;if(this._isInternalStyle(t)){const i=e.e({},Mi,{imports:[{id:"basemap",data:t,url:""}]});return void this._load(i,r)}if(this.updateConfig(this._config,i),r&&Ci(this,q(t)))return;this._loaded=!0,this.stylesheet=e.c6(t);for(const e in t.sources)this.addSource(e,t.sources[e],{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 n=er(this.stylesheet.layers);if(this._order=n.map((e=>e.id)),this.stylesheet.light&&e.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 e=this.stylesheet.lights[0];this.light=new le(e.properties,e.id)}else this.setLights(this.stylesheet.lights);this.light||(this.light=new le(this.stylesheet.light)),this._layers={},this._serializedLayers={};for(const t of n){const r=e.c7(t,this.scope,this.options);r.isConfigDependent&&this._configDependentLayers.add(r.fqid),r.setEventedParent(this,{layer:{id:r.id}}),this._layers[r.id]=r,this._serializedLayers[r.id]=r.serialize();const i=this.getOwnLayerSourceCache(r),n=!!this.directionalLight&&this.directionalLight.shadowsEnabled();i&&r.canCastShadows()&&n&&(i.castsShadows=!0)}this.stylesheet.models&&this.modelManager.addModels(this.stylesheet.models,this.scope);const o=this.stylesheet.terrain;o&&(void 0===this.disableElevatedTerrain&&(this.disableElevatedTerrain=e.f.hasCanvasFingerprintNoise()),this.disableElevatedTerrain?e.w("Terrain and hillshade are disabled because of Canvas2D limitations when fingerprinting protection is enabled (e.g. in private browsing mode)."):this.terrainSetForDrapingOnly()||this._createTerrain(o,1)),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this.stylesheet.transition&&this.setTransition(this.stylesheet.transition),this.fire(new e.b("data",{dataType:"style"}));const s=this.isRootStyle();t.imports?this._loadImports(t.imports,r).then((()=>{this._reloadImports(),this.fire(new e.b(s?"style.load":"style.import.load"))})):(this._reloadImports(),this.fire(new e.b(s?"style.load":"style.import.load")))}isRootStyle(){return 0===this.importDepth}mergeAll(){let t,r,i,n,o,s,a,l;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle((e=>{if(e.stylesheet){if(null!=e.light&&(t=e.light),e.stylesheet.lights)for(const t of e.stylesheet.lights)"ambient"===t.type&&null!=e.ambientLight&&(r=e.ambientLight),"directional"===t.type&&null!=e.directionalLight&&(i=e.directionalLight);n=this._prioritizeTerrain(n,e.terrain,e.stylesheet.terrain),e.stylesheet.fog&&null!=e.fog&&(o=e.fog),null!=e.stylesheet.camera&&(l=e.stylesheet.camera),null!=e.stylesheet.projection&&(s=e.stylesheet.projection),null!=e.stylesheet.transition&&(a=e.stylesheet.transition)}})),this.light=t,this.ambientLight=r,this.directionalLight=i,this.fog=o,null===n?delete this.terrain:this.terrain=n,this.camera=l||{"camera-projection":"perspective"},this.projection=s||{name:"mercator"},this.transition=e.e({},Si,a),this.mergeSources(),this.mergeLayers()}forEachFragmentStyle(e){const t=r=>{for(const e of r.fragments)t(e.style);e(r)};t(this)}_prioritizeTerrain(e,t,r){const i=e&&0===e.drapeRenderMode;return null===r?t&&0===t.drapeRenderMode?t:i?e:null:null!=t&&(!e||i||t&&1===t.drapeRenderMode)?t:e}mergeTerrain(){let e;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle((t=>{e=this._prioritizeTerrain(e,t.terrain,t.stylesheet.terrain)})),null===e?delete this.terrain:this.terrain=e}mergeProjection(){let e;this.forEachFragmentStyle((t=>{null!=t.stylesheet.projection&&(e=t.stylesheet.projection)})),this.projection=e||{name:"mercator"}}mergeSources(){const t={},r={},i={};this.forEachFragmentStyle((n=>{for(const r in n._sourceCaches){const i=e.aj(r,n.scope);t[i]=n._sourceCaches[r]}for(const t in n._otherSourceCaches){const i=e.aj(t,n.scope);r[i]=n._otherSourceCaches[t]}for(const t in n._symbolSourceCaches){const r=e.aj(t,n.scope);i[r]=n._symbolSourceCaches[t]}})),this._mergedSourceCaches=t,this._mergedOtherSourceCaches=r,this._mergedSymbolSourceCaches=i}mergeLayers(){const t={},r=[],i={};this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle((i=>{for(const n of i._order){const o=i._layers[n];if("slot"===o.type){const r=e.c8(n);if(t[r])continue;t[r]=[]}o.slot&&t[o.slot]?t[o.slot].push(o):r.push(o)}})),this._mergedOrder=[];const n=(r=[])=>{for(const o of r)if("slot"===o.type){const r=e.c8(o.id);t[r]&&n(t[r])}else{const t=e.aj(o.id,o.scope);this._mergedOrder.push(t),i[t]=o,o.is3D()&&(this._has3DLayers=!0),"circle"===o.type&&(this._hasCircleLayers=!0),"symbol"===o.type&&(this._hasSymbolLayers=!0)}};n(r),this._mergedLayers=i,this.updateDrapeFirstLayers(),this._buildingIndex.processLayersChanged()}terrainSetForDrapingOnly(){return!!this.terrain&&0===this.terrain.drapeRenderMode}getCamera(){return this.stylesheet.camera}setCamera(t){return this.stylesheet.camera=e.e({},this.stylesheet.camera,t),this.camera=this.stylesheet.camera,this}setProjection(e){e?this.stylesheet.projection=e: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(t,r,i){let n,o,s;const a=e.f.devicePixelRatio>1?"@2x":"";let l=e.g(r.transformRequest(r.normalizeSpriteURL(t,a,".json"),e.R.SpriteJSON),((e,t)=>{l=null,s||(s=e,n=t,u())})),c=e.d(r.transformRequest(r.normalizeSpriteURL(t,a,".png"),e.R.SpriteImage),((e,t)=>{c=null,s||(s=e,o=t,u())}));function u(){if(s)i(s);else if(n&&o){const t=e.f.getImageData(o),r={};for(const i in n){const{width:o,height:s,x:a,y:l,sdf:c,pixelRatio:u,stretchX:h,stretchY:d,content:p}=n[i],f=new e.h({width:o,height:s});e.h.copy(t,f,{x:a,y:l},{x:0,y:0},{width:o,height:s}),r[i]={data:f,pixelRatio:u,sdf:c,stretchX:h,stretchY:d,content:p}}i(null,r)}}return{cancel(){l&&(l.cancel(),l=null),c&&(c.cancel(),c=null)}}}(t,this.map._requestManager,((t,r)=>{if(this._spriteRequest=null,t)this.fire(new e.a(t));else if(r)for(const e in r)this.imageManager.addImage(e,this.scope,r[e]);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 e.b("data",{dataType:"style"}))}))}_validateLayer(t){const r=this.getOwnSource(t.source);if(!r)return;const i=t.sourceLayer;i&&("geojson"===r.type||r.vectorLayerIds&&-1===r.vectorLayerIds.indexOf(i))&&this.fire(new e.a(new Error(`Source layer "${i}" does not exist on source "${r.id}" as specified by style layer "${t.id}"`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._changes.getUpdatedSourceCaches()).length)return!1;for(const e in this._sourceCaches)if(!this._sourceCaches[e].loaded())return!1;if(!this.imageManager.isLoaded())return!1;if(!this.modelManager.isLoaded())return!1;for(const{style:e}of this.fragments)if(!e.loaded())return!1;return!0}_serializeImports(){if(this.stylesheet.imports)return this.stylesheet.imports.map(((e,t)=>{const r=this.fragments[t];return r&&r.style&&(e.data=r.style.serialize()),e}))}_serializeSources(){const e={};for(const t in this._sourceCaches){const r=this._sourceCaches[t].getSource();e[r.id]||(e[r.id]=r.serialize())}return e}_serializeLayers(e){const t=[];for(const r of e){const e=this._layers[r];e&&"custom"!==e.type&&t.push(e.serialize())}return t}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())return!0;if(this.hasFogTransition())return!0;for(const e in this._sourceCaches)if(this._sourceCaches[e].hasTransition())return!0;for(const e in this._layers)if(this._layers[e].hasTransition())return!0;return!1}get order(){return this.terrain?this._drapedFirstOrder:this._mergedOrder}isLayerDraped(e){return!!this.terrain&&e.isDraped(this.getLayerSourceCache(e))}_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 e.a(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 e.a(new Error(`The source '${t}' does not exist in the map's style.`)))}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 i=this._changes.isDirty();if(this._changes.isDirty()){const e=this._changes.getLayerUpdatesByScope();for(const t in e){const{updatedIds:r,removedIds:i}=e[t];(r||i)&&this._updateWorkerLayers(t,r,i)}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 n={};for(const e in this._mergedSourceCaches){const t=this._mergedSourceCaches[e];n[e]=t.used,t.used=!1,t.tileCoverLift=0}for(const e of this._mergedOrder){const r=this._mergedLayers[e];if(r.recalculate(t,this._availableImages),!r.isHidden(t.zoom)){const e=this.getLayerSourceCache(r);e&&(e.used=!0,e.tileCoverLift=Math.max(e.tileCoverLift,r.tileCoverLift()))}if(!this._precompileDone&&this._shouldPrecompile)for(let e=r.minzoom||0;e<(r.maxzoom||25.5);e++){const e=this.map.painter;if(e){const i=r.getProgramIds();if(!i)continue;for(const n of i){const i=r.getDefaultProgramParams(n,t.zoom);i&&(e.style=this,this.fog&&(e._fogVisible=!0,i.overrideFog=!0,e.getOrCreateProgram(n,i)),e._fogVisible=!1,i.overrideFog=!1,e.getOrCreateProgram(n,i),(this.stylesheet.terrain||this.stylesheet.projection&&"globe"===this.stylesheet.projection.name)&&(i.overrideRtt=!0,e.getOrCreateProgram(n,i)))}}}}this._shouldPrecompile&&(this._precompileDone=!0);for(const t in n){const r=this._mergedSourceCaches[t];n[t]!==r.used&&r.getSource().fire(new e.b("data",{sourceDataType:"visibility",dataType:"source",sourceId:r.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),i&&this.fire(new e.b("data",{dataType:"style"}))}_updateTilesForChangedImages(){const e=this._changes.getUpdatedImages();if(e.length){for(const t in this._sourceCaches)this._sourceCaches[t].reloadTilesForDependencies(["icons","patterns"],e);this._changes.resetUpdatedImages()}}_updateWorkerLayers(e,t,r){const i=this.getFragmentStyle(e);i&&this.dispatcher.broadcast("updateLayers",{layers:t?i._serializeLayers(t):[],scope:e,removedIds:r||[],options:i.options})}setState(r,i){if(this._checkLoaded(),Ci(this,q(r)))return!1;(r=e.c6(r)).layers=er(r.layers);const n=function(e,r){if(!e)return[{command:tr.setStyle,args:[r]}];let i=[];try{if(!t(e.version,r.version))return[{command:tr.setStyle,args:[r]}];t(e.center,r.center)||i.push({command:tr.setCenter,args:[r.center]}),t(e.zoom,r.zoom)||i.push({command:tr.setZoom,args:[r.zoom]}),t(e.bearing,r.bearing)||i.push({command:tr.setBearing,args:[r.bearing]}),t(e.pitch,r.pitch)||i.push({command:tr.setPitch,args:[r.pitch]}),t(e.sprite,r.sprite)||i.push({command:tr.setSprite,args:[r.sprite]}),t(e.glyphs,r.glyphs)||i.push({command:tr.setGlyphs,args:[r.glyphs]}),t(e.imports,r.imports)||function(e=[],r=[],i){r=r||[];const n=(e=e||[]).map(ar),o=r.map(ar),s=e.reduce(lr,{}),a=r.reduce(lr,{}),l=n.slice();let c,u,h,d;for(c=0,u=0;c<n.length;c++)h=n[c],a.hasOwnProperty(h)?u++:(i.push({command:tr.removeImport,args:[h]}),l.splice(l.indexOf(h,u),1));for(c=0,u=0;c<o.length;c++)h=o[o.length-1-c],l[l.length-1-c]!==h&&(s.hasOwnProperty(h)?(i.push({command:tr.removeImport,args:[h]}),l.splice(l.lastIndexOf(h,l.length-u),1)):u++,d=l[l.length-c],i.push({command:tr.addImport,args:[a[h],d]}),l.splice(l.length-c,0,h));for(const e of r){const r=s[e.id];r&&!t(r,e)&&i.push({command:tr.updateImport,args:[e.id,e]})}}(e.imports,r.imports,i),t(e.transition,r.transition)||i.push({command:tr.setTransition,args:[r.transition]}),t(e.light,r.light)||i.push({command:tr.setLight,args:[r.light]}),t(e.fog,r.fog)||i.push({command:tr.setFog,args:[r.fog]}),t(e.projection,r.projection)||i.push({command:tr.setProjection,args:[r.projection]}),t(e.lights,r.lights)||i.push({command:tr.setLights,args:[r.lights]}),t(e.camera,r.camera)||i.push({command:tr.setCamera,args:[r.camera]});const n={},o=[];!function(e,r,i,n){let o;for(o in r=r||{},e=e||{})e.hasOwnProperty(o)&&(r.hasOwnProperty(o)||ir(o,i,n));for(o in r){if(!r.hasOwnProperty(o))continue;const s=r[o];e.hasOwnProperty(o)?t(e[o],s)||("geojson"===e[o].type&&"geojson"===s.type&&or(e,r,o)?i.push({command:tr.setGeoJSONSourceData,args:[o,s.data]}):nr(o,r,i,n)):rr(o,r,i)}}(e.sources,r.sources,o,n);const s=[];e.layers&&e.layers.forEach((e=>{e.source&&n[e.source]?i.push({command:tr.removeLayer,args:[e.id]}):s.push(e)}));let a=e.terrain;a&&n[a.source]&&(i.push({command:tr.setTerrain,args:[void 0]}),a=void 0),i=i.concat(o),t(a,r.terrain)||i.push({command:tr.setTerrain,args:[r.terrain]}),function(e,r,i){r=r||[];const n=(e=e||[]).map(ar),o=r.map(ar),s=e.reduce(lr,{}),a=r.reduce(lr,{}),l=n.slice(),c=Object.create(null);let u,h,d,p,f,m,A;for(u=0,h=0;u<n.length;u++)d=n[u],a.hasOwnProperty(d)?h++:(i.push({command:tr.removeLayer,args:[d]}),l.splice(l.indexOf(d,h),1));for(u=0,h=0;u<o.length;u++)d=o[o.length-1-u],l[l.length-1-u]!==d&&(s.hasOwnProperty(d)?(i.push({command:tr.removeLayer,args:[d]}),l.splice(l.lastIndexOf(d,l.length-h),1)):h++,m=l[l.length-u],i.push({command:tr.addLayer,args:[a[d],m]}),l.splice(l.length-u,0,d),c[d]=!0);for(u=0;u<o.length;u++)if(d=o[u],p=s[d],f=a[d],!c[d]&&!t(p,f))if(t(p.source,f.source)&&t(p["source-layer"],f["source-layer"])&&t(p.type,f.type)){for(A in sr(p.layout,f.layout,i,d,null,tr.setLayoutProperty),sr(p.paint,f.paint,i,d,null,tr.setPaintProperty),t(p.slot,f.slot)||i.push({command:tr.setSlot,args:[d,f.slot]}),t(p.filter,f.filter)||i.push({command:tr.setFilter,args:[d,f.filter]}),t(p.minzoom,f.minzoom)&&t(p.maxzoom,f.maxzoom)||i.push({command:tr.setLayerZoomRange,args:[d,f.minzoom,f.maxzoom]}),p)p.hasOwnProperty(A)&&"layout"!==A&&"paint"!==A&&"filter"!==A&&"metadata"!==A&&"minzoom"!==A&&"maxzoom"!==A&&"slot"!==A&&(0===A.indexOf("paint.")?sr(p[A],f[A],i,d,A.slice(6),tr.setPaintProperty):t(p[A],f[A])||i.push({command:tr.setLayerProperty,args:[d,A,f[A]]}));for(A in f)f.hasOwnProperty(A)&&!p.hasOwnProperty(A)&&"layout"!==A&&"paint"!==A&&"filter"!==A&&"metadata"!==A&&"minzoom"!==A&&"maxzoom"!==A&&"slot"!==A&&(0===A.indexOf("paint.")?sr(p[A],f[A],i,d,A.slice(6),tr.setPaintProperty):t(p[A],f[A])||i.push({command:tr.setLayerProperty,args:[d,A,f[A]]}))}else i.push({command:tr.removeLayer,args:[d]}),m=l[l.lastIndexOf(d)+1],i.push({command:tr.addLayer,args:[f,m]})}(s,r.layers,i)}catch(e){console.warn("Unable to compute style diff:",e),i=[{command:tr.setStyle,args:[r]}]}return i}(this.serialize(),r).filter((e=>!(e.command in Ei)));if(0===n.length)return!1;const o=n.filter((e=>!(e.command in Ti)));if(o.length>0)throw new Error(`Unimplemented: ${o.map((e=>e.command)).join(", ")}.`);const s=[];return n.forEach((e=>{s.push(this[e.command].apply(this,e.args))})),i&&Promise.all(s).then(i),this.stylesheet=r,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 e.a(new Error("An image with this name already exists."))):(this.imageManager.addImage(t,this.scope,r),this._afterImageUpdated(t),this)}updateImage(e,t){this.imageManager.updateImage(e,this.scope,t)}getImage(e){return this.imageManager.getImage(e,this.scope)}removeImage(t){return this.getImage(t)?(this.imageManager.removeImage(t,this.scope),this._afterImageUpdated(t),this):this.fire(new e.a(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 e.b("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addModel(e,t,r={}){return this._checkLoaded(),this._validate(ne,`models.${e}`,t,null,r)||(this.modelManager.addModel(e,t,this.scope),this._changes.setDirty()),this}hasModel(e){return this.modelManager.hasModel(e,this.scope)}removeModel(t){return this.hasModel(t)?(this.modelManager.removeModel(t,this.scope),this):this.fire(new e.a(new Error("No model with this ID exists.")))}listModels(){return this._checkLoaded(),this.modelManager.listModels(this.scope)}addSource(t,r,i={}){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(X,`sources.${t}`,r,null,i))return;this.map&&this.map._collectResourceTiming&&(r.collectResourceTiming=!0);const n=Nt(t,r,this.dispatcher,this);n.scope=this.scope,n.setEventedParent(this,(()=>({isSourceLoaded:this._isSourceCacheLoaded(n.id),source:n.serialize(),sourceId:n.id})));const o=t=>{const r=(t?"symbol:":"other:")+n.id,i=e.aj(r,this.scope),o=this._sourceCaches[r]=new qt(i,n,t);(t?this._symbolSourceCaches:this._otherSourceCaches)[n.id]=o,o.onAdd(this.map)};o(!1),"vector"!==r.type&&"geojson"!==r.type||o(!0),n.onAdd&&n.onAdd(this.map),i.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 r in this._layers)if(this._layers[r].source===t)return this.fire(new e.a(new Error(`Source "${t}" cannot be removed while layer "${r}" is using it.`)));if(this.terrain&&this.terrain.scope===this.scope&&this.terrain.get().source===t)return this.fire(new e.a(new Error(`Source "${t}" cannot be removed while terrain is using it.`)));const i=this.getOwnSourceCaches(t);for(const t of i){const r=e.c8(t.id);delete this._sourceCaches[r],this._changes.discardSourceCacheUpdate(t.id),t.fire(new e.b("data",{sourceDataType:"metadata",dataType:"source",sourceId:t.getSource().id})),t.setEventedParent(null),t.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(e,t){this._checkLoaded(),this.getOwnSource(e).setData(t),this._changes.setDirty()}getOwnSource(e){const t=this.getOwnSourceCache(e);return t&&t.getSource()}getOwnSources(){const e=[];for(const t in this._otherSourceCaches){const r=this.getOwnSourceCache(t);r&&e.push(r.getSource())}return e}areTilesLoaded(){const e=this._mergedSourceCaches;for(const t in e){const r=e[t]._tiles;for(const e in r){const t=r[e];if("loaded"!==t.state&&"errored"!==t.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 e of t){if(this._validate($,"lights",e))return;switch(e.type){case"ambient":if(this.ambientLight){const t=this.ambientLight;t.set(e),t.updateTransitions(r)}else this.ambientLight=new xe(e,ve,this.scope,this.options);break;case"directional":if(this.directionalLight){const t=this.directionalLight;t.set(e),t.updateTransitions(r)}else this.directionalLight=new xe(e,be,this.scope,this.options)}}const i=new e.N(this.z||0,r);this.ambientLight&&this.ambientLight.recalculate(i),this.directionalLight&&this.directionalLight.recalculate(i),this._brightness=this.calculateLightsBrightness(),this.dispatcher.broadcast("setBrightness",this._brightness)}calculateLightsBrightness(){const t=this.directionalLight,r=this.ambientLight;if(!t||!r)return;const i=e=>.2126*(e[0]<=.03928?e[0]/12.92:Math.pow((e[0]+.055)/1.055,2.4))+.7152*(e[1]<=.03928?e[1]/12.92:Math.pow((e[1]+.055)/1.055,2.4))+.0722*(e[2]<=.03928?e[2]/12.92:Math.pow((e[2]+.055)/1.055,2.4)),n=t.properties.get("color").toArray01(),o=t.properties.get("intensity"),s=t.properties.get("direction"),a=1-e.bT(s.x,s.y,s.z)[2]/90,l=i(n)*o*a,c=r.properties.get("color").toArray01(),u=r.properties.get("intensity");return(l+i(c)*u)/2}getBrightness(){return this._brightness}getLights(){if(!this.enable3dLights())return null;const e=[];return this.directionalLight&&e.push(this.directionalLight.get()),this.ambientLight&&e.push(this.ambientLight.get()),e}enable3dLights(){return!!this.ambientLight&&!!this.directionalLight}getFragmentStyle(t){if(!t)return this;if(e.c9(t)){const r=e.ca(t),i=this.fragments.find((({id:e})=>e===r));if(!i)throw new Error(`Style import not found: ${t}`);const n=e.c8(t);return i.style.getFragmentStyle(n)}{const e=this.fragments.find((({id:e})=>e===t));if(!e)throw new Error(`Style import not found: ${t}`);return e.style}}getConfigProperty(t,r){const i=this.getFragmentStyle(t);if(!i)return null;const n=e.aj(r,i.scope),o=i.options.get(n),s=o?o.value||o.default:null;return s?s.serialize():null}setConfigProperty(t,r,i){const n=this.getFragmentStyle(t);if(!n)return;const o=n.stylesheet.schema;if(!o||!o[r])return;const s=e.t(i);if("success"!==s.result)return void Ci(this,s.value);const a=s.value.expression,l=e.aj(r,n.scope),c=n.options.get(l);if(!c)return;let u;const{minValue:h,maxValue:d,stepValue:p,type:f,values:m}=o[r],A=e.t(o[r].default);"success"===A.result&&(u=A.value.expression),u?(this.options.set(l,{...c,value:a,default:u,minValue:h,maxValue:d,stepValue:p,type:f,values:m}),this.updateConfigDependencies()):this.fire(new e.a(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 i=r.stylesheet.schema;if(!i)return null;const n={};for(const t in i){const i=e.aj(t,r.scope),o=r.options.get(i),s=o?o.value||o.default:null;n[t]=s?s.serialize():null}return n}setConfig(e,t){const r=this.getFragmentStyle(e);r&&(r.updateConfig(t,r.stylesheet.schema),this.updateConfigDependencies())}getSchema(e){const t=this.getFragmentStyle(e);return t?t.stylesheet.schema:null}setSchema(e,t){const r=this.getFragmentStyle(e);r&&(r.stylesheet.schema=t,r.updateConfig(r._config,t),this.updateConfigDependencies())}updateConfig(t,r){if(this._config=t,t||r)if(r)for(const i in r){let n,o;const s=e.t(r[i].default);if("success"===s.result&&(n=s.value.expression),t&&void 0!==t[i]){const r=e.t(t[i]);"success"===r.result&&(o=r.value.expression)}const{minValue:a,maxValue:l,stepValue:c,type:u,values:h}=r[i];if(n){const t=e.aj(i,this.scope);this.options.set(t,{default:n,value:o,minValue:a,maxValue:l,stepValue:c,type:u,values:h})}else this.fire(new e.a(new Error(`No schema defined for config option "${i}".`)))}else this.fire(new e.a(new Error("Attempting to set config for a style without schema.")))}updateConfigDependencies(){for(const e of this._configDependentLayers){const t=this.getLayer(e);t&&(t.possiblyEvaluateVisibility(),this._updateLayer(t))}this.ambientLight&&this.ambientLight.updateConfig(this.options),this.directionalLight&&this.directionalLight.updateConfig(this.options),this.fog&&this.fog.updateConfig(this.options),this._changes.setDirty()}addLayer(t,r,i={}){this._checkLoaded();const n=t.id;if(this._layers[n])return void this.fire(new e.a(new Error(`Layer with id "${n}" already exists on this map`)));let o;if("custom"===t.type){if(Ci(this,e.cb(t)))return;o=e.c7(t,this.scope,this.options)}else{if("object"==typeof t.source&&(this.addSource(n,t.source),t=e.c6(t),t=e.e(t,{source:n})),this._validate(ee,`layers.${n}`,t,{arrayIndex:-1},i))return;o=e.c7(t,this.scope,this.options),this._validateLayer(o),o.setEventedParent(this,{layer:{id:n}}),this._serializedLayers[o.id]=o.serialize()}o.isConfigDependent&&this._configDependentLayers.add(o.fqid);let s=this._order.length;if(r){const t=this._order.indexOf(r);if(-1===t)return void this.fire(new e.a(new Error(`Layer with id "${r}" does not exist on this map.`)));o.slot===this._layers[r].slot?s=t:e.w(`Layer with id "${r}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(s,0,n),this._layerOrderChanged=!0,this._layers[n]=o;const a=this.getOwnLayerSourceCache(o),l=!!this.directionalLight&&this.directionalLight.shadowsEnabled();a&&o.canCastShadows()&&l&&(a.castsShadows=!0);const c=this._changes.getRemovedLayer(o);if(c&&o.source&&a&&"custom"!==o.type){this._changes.discardLayerRemoval(o);const t=e.aj(o.source,o.scope);c.type!==o.type?this._changes.updateSourceCache(t,"clear"):(this._changes.updateSourceCache(t,"reload"),a.pause())}this._updateLayer(o),o.onAdd&&o.onAdd(this.map),o.scope=this.scope,this.mergeLayers()}moveLayer(t,r){this._checkLoaded();const i=this._checkLayer(t);if(!i)return;if(t===r)return;const n=this._order.indexOf(t);this._order.splice(n,1);let o=this._order.length;if(r){const t=this._order.indexOf(r);if(-1===t)return void this.fire(new e.a(new Error(`Layer with id "${r}" does not exist on this map.`)));i.slot===this._layers[r].slot?o=t:e.w(`Layer with id "${r}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(o,0,t),this._changes.setDirty(),this._layerOrderChanged=!0,this.mergeLayers()}removeLayer(e){this._checkLoaded();const t=this._checkLayer(e);if(!t)return;t.setEventedParent(null);const r=this._order.indexOf(e);this._order.splice(r,1),delete this._layers[e],delete this._serializedLayers[e],this._changes.setDirty(),this._layerOrderChanged=!0,this._configDependentLayers.delete(t.fqid),this._changes.removeLayer(t);const i=this.getOwnLayerSourceCache(t);if(i&&i.castsShadows){let e=!1;for(const r in this._layers)if(this._layers[r].source===t.source&&this._layers[r].canCastShadows()){e=!0;break}i.castsShadows=e}t.onRemove&&t.onRemove(this.map),this.mergeLayers()}getOwnLayer(e){return this._layers[e]}hasLayer(e){return e in this._mergedLayers}hasLayerType(e){for(const t in this._layers)if(this._layers[t].type===e)return!0;return!1}setLayerZoomRange(e,t,r){this._checkLoaded();const i=this._checkLayer(e);i&&(i.minzoom===t&&i.maxzoom===r||(null!=t&&(i.minzoom=t),null!=r&&(i.maxzoom=r),this._updateLayer(i)))}setSlot(e,t){this._checkLoaded();const r=this._checkLayer(e);r&&r.slot!==t&&(r.slot=t,this._updateLayer(r))}setFilter(r,i,n={}){this._checkLoaded();const o=this._checkLayer(r);if(o&&!t(o.filter,i))return null==i?(o.filter=void 0,void this._updateLayer(o)):void(this._validate(te,`layers.${o.id}.filter`,i,{layerType:o.type},n)||(o.filter=e.c6(i),this._updateLayer(o)))}getFilter(t){const r=this._checkLayer(t);if(r)return e.c6(r.filter)}setLayoutProperty(r,i,n,o={}){this._checkLoaded();const s=this._checkLayer(r);if(s&&!t(s.getLayoutProperty(i),n)){if(null!=n&&(!o||!1!==o.validate)&&Ci(s,ie.call(q,{key:`layers.${r}.layout.${i}`,layerType:s.type,objectKey:i,value:n,styleSpec:e.G,style:{glyphs:!0,sprite:!0}})))return;s.setLayoutProperty(i,n),s.isConfigDependent&&this._configDependentLayers.add(s.fqid),this._updateLayer(s)}}getLayoutProperty(e,t){const r=this._checkLayer(e);if(r)return r.getLayoutProperty(t)}setPaintProperty(r,i,n,o={}){this._checkLoaded();const s=this._checkLayer(r);if(!s)return;if(t(s.getPaintProperty(i),n))return;if(null!=n&&(!o||!1!==o.validate)&&Ci(s,re.call(q,{key:`layers.${r}.paint.${i}`,layerType:s.type,objectKey:i,value:n,styleSpec:e.G})))return;const a=s.setPaintProperty(i,n);s.isConfigDependent&&this._configDependentLayers.add(s.fqid),a&&this._updateLayer(s),this._changes.updatePaintProperties(s)}getPaintProperty(e,t){const r=this._checkLayer(e);if(r)return r.getPaintProperty(t)}setFeatureState(t,r){this._checkLoaded();const i=t.source,n=t.sourceLayer,o=this._checkSource(i);if(!o)return;const s=o.type;if("geojson"===s&&n)return void this.fire(new e.a(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===s&&!n)return void this.fire(new e.a(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===t.id&&this.fire(new e.a(new Error("The feature id parameter must be provided.")));const a=this.getOwnSourceCaches(i);for(const e of a)e.setFeatureState(n,t.id,r)}removeFeatureState(t,r){this._checkLoaded();const i=t.source,n=this._checkSource(i);if(!n)return;const o=n.type,s="vector"===o?t.sourceLayer:void 0;if("vector"===o&&!s)return void this.fire(new e.a(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 e.a(new Error("A feature id is required to remove its specific state property.")));const a=this.getOwnSourceCaches(i);for(const e of a)e.removeFeatureState(s,t.id,r)}getFeatureState(t){this._checkLoaded();const r=t.source,i=t.sourceLayer,n=this._checkSource(r);if(n){if("vector"!==n.type||i)return void 0===t.id&&this.fire(new e.a(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(r)[0].getFeatureState(i,t.id);this.fire(new e.a(new Error("The sourceLayer parameter must be provided for vector source types.")))}}setTransition(t){return this.stylesheet.transition=e.e({},this.stylesheet.transition,t),this.transition=this.stylesheet.transition,this}getTransition(){return e.e({},this.stylesheet.transition)}serialize(){this._checkLoaded();const t=this.getTerrain(),r=t&&this.terrain&&this.terrain.scope===this.scope?t:this.stylesheet.terrain;return e.cc({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,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)},(e=>void 0!==e))}_updateLayer(t){this._changes.updateLayer(t);const r=this.getLayerSourceCache(t),i=e.aj(t.source,t.scope),n=this._changes.getUpdatedSourceCaches();t.source&&!n[i]&&r&&"raster"!==r.getSource().type&&(this._changes.updateSourceCache(i,"reload"),r.pause()),t.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(e){const t=e=>"fill-extrusion"===this._mergedLayers[e].type||"model"===this._mergedLayers[e].type,r=this.order,i={},n=[];for(let o=r.length-1;o>=0;o--){const s=r[o];if(t(s)){i[s]=o;for(const t of e){const e=t[s];if(e)for(const t of e)n.push(t)}}}n.sort(((e,t)=>t.intersectionZ-e.intersectionZ));const o=[];for(let s=r.length-1;s>=0;s--){const a=r[s];if(t(a))for(let e=n.length-1;e>=0;e--){const t=n[e].feature;if(i[t.layer.id]<s)break;o.push(t),n.pop()}else for(const t of e){const e=t[a];if(e)for(const t of e)o.push(t.feature)}}return o}queryRenderedFeatures(t,r,i){r&&r.filter&&this._validate(te,"queryRenderedFeatures.filter",r.filter,null,r),r.scope=this.scope,r.availableImages=this._availableImages,r.serializedLayers=this._serializedLayers;const n={};if(r&&r.layers){if(!Array.isArray(r.layers))return this.fire(new e.a(new Error("parameters.layers must be an Array."))),[];for(const t of r.layers){const r=this._mergedLayers[t];if(!r)return this.fire(new e.a(new Error(`The layer '${t}' does not exist in the map's style and cannot be queried for features.`))),[];n[r.source]=!0}}const o=[],s=r.serializedLayers||{},a=r&&r.layers?r.layers.some((e=>{const t=this.getLayer(e);return t&&t.is3D()})):this.has3DLayers(),l=we.createFromScreenPoints(t,i);for(const e in this._mergedSourceCaches){const t=this._mergedSourceCaches[e].getSource();if(!t||t.scope!==r.scope)continue;const c=this._mergedSourceCaches[e].getSource().id;r.layers&&!n[c]||o.push(Ht(this._mergedSourceCaches[e],this._mergedLayers,s,l,r,i,a,!!this.map._showQueryGeometry))}return this.placement&&o.push(function(e,t,r,i,n,o,s){const a={},l=o.queryRenderedSymbols(i),c=[];for(const e of Object.keys(l).map(Number))c.push(s[e]);c.sort(Zt);for(const r of c){const i=r.featureIndex.lookupSymbolFeatures(l[r.bucketInstanceId],t,r.bucketIndex,r.sourceLayerIndex,n.filter,n.layers,n.availableImages,e);for(const e in i){const t=a[e]=a[e]||[],n=i[e];n.sort(((e,t)=>{const i=r.featureSortOrder;if(i){const r=i.indexOf(e.featureIndex);return i.indexOf(t.featureIndex)-r}return t.featureIndex-e.featureIndex}));for(const e of n)t.push(e)}}for(const t in a)a[t].forEach((i=>{const n=i.feature,o=r(e[t]);if(!o)return;const s=o.getFeatureState(n.layer["source-layer"],n.id);n.source=n.layer.source,n.layer["source-layer"]&&(n.sourceLayer=n.layer["source-layer"]),n.state=s}));return a}(this._mergedLayers,s,this.getLayerSourceCache.bind(this),l.screenGeometry,r,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(o)}querySourceFeatures(e,t){t&&t.filter&&this._validate(te,"querySourceFeatures.filter",t.filter,null,t);const r=this.getOwnSourceCaches(e);let i=[];for(const e of r)i=i.concat(Gt(e,t));return i}addSourceType(e,t,r){return Ii.getSourceType(e)?r(new Error(`A source type called "${e}" already exists.`)):(Ii.setSourceType(e,t),t.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:e,url:t.workerSourceURL},r):r(null,null))}getFlatLight(){return this.light.getLight()}setFlatLight(e,r,i={}){this._checkLoaded();const n=this.light.getLight();let o=!1;for(const r in e)if(!t(e[r],n[r])){o=!0;break}if(!o)return;const s=this._getTransitionParameters();this.light.setLight(e,r,i),this.light.updateTransitions(s)}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}setTerrain(r,i=1){if(this._checkLoaded(),!r)return this.terrainSetForDrapingOnly()&&0!==i||delete this.terrain,null===r?this.stylesheet.terrain=null:delete this.stylesheet.terrain,this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);let n=r;const o=null==r.source;if(1===i){if("object"==typeof n.source){const t="terrain-dem-src";this.addSource(t,n.source),n=e.c6(n),n=e.e(n,{source:t})}const t=e.e({},n),r={};if(this.terrain&&o){t.source=this.terrain.get().source;const e=this.terrain?this.getFragmentStyle(this.terrain.scope):null;e&&(r.style=e.serialize())}if(this._validate(K,"terrain",t,r))return}if(!this.terrain||this.terrain.scope!==this.scope&&!o||this.terrain&&i!==this.terrain.drapeRenderMode){if(!n)return;this._createTerrain(n,i),this.fire(new e.b("data",{dataType:"style"}))}else{const i=this.terrain,o=i.get();for(const t of Object.keys(e.G.terrain))!n.hasOwnProperty(t)&&e.G.terrain[t].default&&(n[t]=e.G.terrain[t].default);for(const n in r)if(!t(r[n],o[n])){i.set(r,this.options),this.stylesheet.terrain=r;const t=this._getTransitionParameters({duration:0});i.updateTransitions(t),this.fire(new e.b("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(e){const t=this.fog=new ye(e,this.map.transform,this.scope,this.options);this.stylesheet.fog=t.get();const r=this._getTransitionParameters({duration:0});t.updateTransitions(r)}_updateMarkersOpacity(){0!==this.map._markers.length&&this.map._requestDomTask((()=>{for(const e of this.map._markers)e._evaluateOpacity()}))}getFog(){return this.fog?this.fog.get():null}setFog(e){if(this._checkLoaded(),!e)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const r=this.fog;if(!t(r.get(),e)){r.set(e,this.options),this.stylesheet.fog=r.get();const t=this._getTransitionParameters({duration:0});r.updateTransitions(t)}}else this._createFog(e);this._markersNeedUpdate=!0}_getTransitionParameters(t){return{now:e.f.now(),transition:e.e(this.transition,t)}}updateDrapeFirstLayers(){if(!this.terrain)return;const e=[],t=[];for(const r in this._mergedLayers)this.isLayerDraped(this._mergedLayers[r])?e.push(r):t.push(r);this._drapedFirstOrder=[],this._drapedFirstOrder.push(...e),this._drapedFirstOrder.push(...t)}_createTerrain(e,t){const r=this.terrain=new ue(e,t,this.scope,this.options);1===t&&(this.stylesheet.terrain=e),this.mergeTerrain(),this.updateDrapeFirstLayers(),this._force3DLayerUpdate();const i=this._getTransitionParameters({duration:0});r.updateTransitions(i)}_force3DLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"fill-extrusion"===t.type&&this._updateLayer(t)}}_forceSymbolLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"symbol"===t.type&&this._updateLayer(t)}}_validate(t,r,i,n,o={}){if(o&&!1===o.validate)return!1;const s=e.e({},this.serialize());return Ci(this,t.call(q,e.e({key:r,style:s,value:i,styleSpec:e.G},n)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),e.cd.off("pluginStateChange",this._rtlTextPluginCallback);for(const e in this._mergedLayers)this._mergedLayers[e].setEventedParent(null);for(const e in this._mergedSourceCaches)this._mergedSourceCaches[e].clearTiles(),this._mergedSourceCaches[e].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(e){const t=this.getSourceCaches(e);for(const e of t)e.clearTiles()}clearSources(){for(const e in this._mergedSourceCaches)this._mergedSourceCaches[e].clearTiles()}reloadSource(e){const t=this.getSourceCaches(e);for(const e of t)e.resume(),e.reload()}reloadSources(){for(const e of this.getSources())e.reload&&e.reload()}updateSources(e){let t;this.directionalLight&&(t=vi(this.directionalLight));for(const r in this._mergedSourceCaches)this._mergedSourceCaches[r].update(e,void 0,void 0,t)}_generateCollisionBoxes(){for(const e in this._sourceCaches){const t=this._sourceCaches[e];t.resume(),t.reload()}}_updatePlacement(t,r,i,n,o=!1){let s=!1,a=!1;const l={},c={};for(const r of this._mergedOrder){const i=this._mergedLayers[r];if("symbol"!==i.type)continue;const n=e.aj(i.source,i.scope);let o=l[n];if(!o){const e=this.getLayerSourceCache(i);if(!e)continue;const t=e.getRenderableIds(!0).map((t=>e.getTileByID(t)));c[n]=t.slice(),o=l[n]=t.sort(((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1)))}const a=this.crossTileSymbolIndex.addLayer(i,o,t.center.lng,t.projection);s=s||a}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder),o=o||this._layerOrderChanged||0===i,this._layerOrderChanged&&this.fire(new e.b("neworder")),(o||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(e.f.now(),t.zoom))&&(this.pauseablePlacement=new Jr(t,this._mergedOrder,o,r,i,n,this.placement,this.fog&&t.projection.supportsFog?this.fog.state:null,this._buildingIndex),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._mergedOrder,this._mergedLayers,l,c),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(e.f.now()),a=!0),s&&this.pauseablePlacement.placement.setStale()),a||s){this._buildingIndex.onNewFrame(t.zoom);for(const t of this._mergedOrder){const r=this._mergedLayers[t];"symbol"===r.type&&this.placement.updateLayerOpacities(r,l[e.aj(r.source,r.scope)])}}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(e.f.now())}_releaseSymbolFadeTiles(){for(const e in this._sourceCaches)this._sourceCaches[e].releaseSymbolFadeTiles()}addImport(t,r){this._checkLoaded();const i=this.stylesheet.imports=this.stylesheet.imports||[];if(-1!==i.findIndex((({id:e})=>e===t.id)))return void this.fire(new e.a(new Error(`Import with id '${t.id}' already exists in the map's style.`)));if(!r)return i.push(t),this._loadImports([t],!0);const n=i.findIndex((({id:e})=>e===r));return-1===n&&this.fire(new e.a(new Error(`Import with id "${r}" does not exist on this map.`))),this.stylesheet.imports=i.slice(0,n).concat(t).concat(i.slice(n)),this._loadImports([t],!0,r)}updateImport(e,r){this._checkLoaded();const i=this.stylesheet.imports||[],n=this.getImportIndex(e);return-1===n?this:"string"==typeof r?(this.setImportUrl(e,r),this):(r.url&&r.url!==i[n].url&&this.setImportUrl(e,r.url),t(r.config,i[n].config)||this.setImportConfig(e,r.config),t(r.data,i[n].data)||this.setImportData(e,r.data),this)}moveImport(e,t){this._checkLoaded();let r=this.stylesheet.imports||[];const i=this.getImportIndex(e);if(-1===i)return this;const n=this.getImportIndex(t);if(-1===n)return this;const o=r[i],s=this.fragments[i];return r=r.filter((({id:t})=>t!==e)),this.fragments=this.fragments.filter((({id:t})=>t!==e)),this.stylesheet.imports=r.slice(0,n).concat(o).concat(r.slice(n)),this.fragments=this.fragments.slice(0,n).concat(s).concat(this.fragments.slice(n)),this.mergeLayers(),this}setImportUrl(e,t){this._checkLoaded();const r=this.stylesheet.imports||[],i=this.getImportIndex(e);if(-1===i)return this;r[i].url=t;const n=this.fragments[i];return n.style=this._createFragmentStyle(r[i]),n.style.on("style.import.load",(()=>this.mergeAll())),n.style.loadURL(t),this}setImportData(e,t){this._checkLoaded();const r=this.getImportIndex(e),i=this.stylesheet.imports||[];return-1===r?this:t?(this.fragments[r].style.setState(t),this._reloadImports(),this):(delete i[r].data,this.setImportUrl(e,i[r].url))}setImportConfig(e,t){this._checkLoaded();const r=this.getImportIndex(e),i=this.stylesheet.imports||[];if(-1===r)return this;t?i[r].config=t:delete i[r].config;const n=this.fragments[r],o=n.style.stylesheet&&n.style.stylesheet.schema;return n.config=t,n.style.updateConfig(t,o),this.updateConfigDependencies(),this}removeImport(e){this._checkLoaded();const t=this.stylesheet.imports||[],r=this.getImportIndex(e);-1!==r&&(t.splice(r,1),this.fragments[r].style._remove(),this.fragments.splice(r,1),this._reloadImports())}getImportIndex(t){const r=(this.stylesheet.imports||[]).findIndex((e=>e.id===t));return-1===r&&this.fire(new e.a(new Error(`Import '${t}' does not exist in the map's style and cannot be updated.`))),r}getLayer(e){return this._mergedLayers[e]}getSources(){const e=[];for(const t in this._mergedOtherSourceCaches){const r=this._mergedOtherSourceCaches[t];r&&e.push(r.getSource())}return e}getSource(e,t){const r=this.getSourceCache(e,t);return r&&r.getSource()}getLayerSource(e){const t=this.getLayerSourceCache(e);return t&&t.getSource()}getSourceCache(t,r){const i=e.aj(t,r);return this._mergedOtherSourceCaches[i]}getLayerSourceCache(t){const r=e.aj(t.source,t.scope);return"symbol"===t.type?this._mergedSymbolSourceCaches[r]:this._mergedOtherSourceCaches[r]}getSourceCaches(e){if(null==e)return Object.values(this._mergedSourceCaches);const t=[];return this._mergedOtherSourceCaches[e]&&t.push(this._mergedOtherSourceCaches[e]),this._mergedSymbolSourceCaches[e]&&t.push(this._mergedSymbolSourceCaches[e]),t}updateSourceCaches(){const e=this._changes.getUpdatedSourceCaches();for(const t in e){const r=e[t];"reload"===r?this.reloadSource(t):"clear"===r&&this.clearSource(t)}}updateLayers(e){const t=this._changes.getUpdatedPaintProperties();for(const r of t){const t=this.getLayer(r);t&&t.updateTransitions(e)}}getImages(e,t,r){this.imageManager.getImages(t.icons,t.scope,r),this._updateTilesForChangedImages();const i=e=>{e&&e.setDependencies(t.tileID.key,t.type,t.icons)};i(this._otherSourceCaches[t.source]),i(this._symbolSourceCaches[t.source])}getGlyphs(e,t,r){this.glyphManager.getGlyphs(t.stacks,t.scope,r)}getResource(t,r,i){return e.ce(r,i)}getOwnSourceCache(e){return this._otherSourceCaches[e]}getOwnLayerSourceCache(e){return"symbol"===e.type?this._symbolSourceCaches[e.source]:this._otherSourceCaches[e.source]}getOwnSourceCaches(e){const t=[];return this._otherSourceCaches[e]&&t.push(this._otherSourceCaches[e]),this._symbolSourceCaches[e]&&t.push(this._symbolSourceCaches[e]),t}_isSourceCacheLoaded(t){const r=this.getOwnSourceCaches(t);return 0===r.length?(this.fire(new e.a(new Error(`There is no source with ID '${t}'`))),!1):r.every((e=>e.loaded()))}has3DLayers(){return this._has3DLayers}hasSymbolLayers(){return this._hasSymbolLayers}hasCircleLayers(){return this._hasCircleLayers}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}destroy(){this._clearWorkerCaches(),this.fragments.forEach((e=>{e.style._remove()})),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}Ii.getSourceType=function(e){return Vt[e]},Ii.setSourceType=function(e,t){Vt[e]=t},Ii.registerForPluginStateChange=e.bY;var Pi="\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",Di="\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,vec2 pos,vec2 lod_coord) {vec2 size=vec2(textureSize(image,0));vec2 dx=dFdx(lod_coord.xy*size);vec2 dy=dFdy(lod_coord.xy*size);float delta_max_sqr=max(dot(dx,dx),dot(dy,dy));float lod=0.5*log2(delta_max_sqr);return textureLod(image,pos,lod);}",ki="\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 float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}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);}",Li="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;}",zi="\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;uniform sampler2D u_depth;uniform vec2 u_depth_size_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\nhighp 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;}bool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;float depth=unpack_depth(texture(u_depth,(coord.xy+1.0)*0.5));return coord.z > depth+0.0005;}float occlusionFade(vec4 frag) {vec3 coord=frag.xyz/frag.w;vec3 df=vec3(5.0*u_depth_size_inv,0.0);vec2 uv=0.5*coord.xy+0.5;vec4 depth=vec4(\nunpack_depth(texture(u_depth,uv-df.xz)),unpack_depth(texture(u_depth,uv+df.xz)),unpack_depth(texture(u_depth,uv-df.zy)),unpack_depth(texture(u_depth,uv+df.zy))\n);return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z-0.001)-depth),0.0,1.0));}vec4 fourSample(vec2 pos,vec2 off) {float tl=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(off.x,0.0)).r;float bl=texture(u_dem,pos+vec2(0.0,off.y)).r;float br=texture(u_dem,pos+off).r;return vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);}\n#else\nfloat elevation(vec2 pos) { return 0.0; }bool isOccluded(vec4 frag) { return false; }float occlusionFade(vec4 frag) { return 1.0; }\n#endif",Oi="#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",Bi="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",Ri="#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",Fi="#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 vec4 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=vec2(u_data_offset+dot(t.rg,u_data_scale.yx),-(u_data_offset+dot(t.ba,u_data_scale.yx)));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;}",ji="#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) {float dotScale=min(1.0-dot(normal,u_shadow_direction),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",Vi="#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_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 Ni=[];Qi(Pi,Ni),Qi(ki,Ni),Qi(Di,Ni);const Ui={"_prelude_fog.vertex.glsl":Oi,"_prelude_terrain.vertex.glsl":zi,"_prelude_shadow.vertex.glsl":ji,"_prelude_fog.fragment.glsl":Bi,"_prelude_shadow.fragment.glsl":Vi,"_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":Ri,"_prelude_raster_particle.glsl":Fi},Hi={};qi("",zi),qi(Bi,Oi),qi(Vi,ji),qi(Ri,""),qi(Fi,"");const Gi=qi(Di,ki),Zi=Pi;var Wi={background:qi('#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:qi('#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 vec2 v_pos;void main() {vec2 imagecoord=mod(v_pos,1.0);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 float u_tile_units_to_pixels;in vec2 a_pos;out 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_tile_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),circle:qi('#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 extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,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:qi("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:qi('#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:qi("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:qi("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 float a_size_scale;in vec2 a_padding;in float a_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() {vec4 projectedPoint=u_matrix*vec4(a_pos+elevationVector(a_anchor_pos)*(a_z_offset+elevation(a_anchor_pos)),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:qi("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:qi("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:qi('#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;uniform mat4 u_matrix;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillOutline:qi('#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;uniform 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\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);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:qi('#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;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);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;out 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\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;gl_Position=u_matrix*vec4(a_pos,0,1);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:qi('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;in 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;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);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;out 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\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;gl_Position=u_matrix*vec4(a_pos,0,1);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:qi('#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\nuniform float u_emissive_strength;in float v_height;void main() {\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=shadowed_light_factor_normal(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);color.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,u_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;in vec4 a_pos_normal_ed;in vec2 a_centroid_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;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\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\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=max(0.01,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;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.01 && centroid_pos.x !=0.0));gl_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:qi("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_vertical_scale;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\nout highp float v_depth;void main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\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\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);v_depth=gl_Position.z/gl_Position.w;}'),fillExtrusionPattern:qi('#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 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;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);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 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 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 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\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;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\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:qi('#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:qi("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 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(1.0,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:qi("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:qi('#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:qi('#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;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 trimmed=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) {if (line_progress <=trim_end && line_progress >=trim_start) {out_color=vec4(0,0,0,0);trimmed=0.0;}}\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) { \nfloat 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*trimmed,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#define EXTRUDE_SCALE 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;\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);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\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:qi('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform mediump 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 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 lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;vec2 pattern_size=vec2(display_size.x/u_tile_units_to_pixels,display_size.y);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);float pattern_x=v_linesofar/pattern_size.x*aspect;float x=mod(pattern_x,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(x,y));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.x/aspect;float segment_phase=pattern_len-mod((v_linesofar-v_pattern_data.x),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);\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#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;\n#ifdef RENDER_LINE_TRIM_OFFSET\nin highp vec4 a_packed;\n#endif\nin float a_linesofar;\n#ifdef LINE_JOIN_NONE\nin vec2 a_pattern_data;out vec2 v_pattern_data;\n#endif\nuniform mat4 u_matrix;uniform mediump float u_tile_units_to_pixels;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out 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 lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp 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);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*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\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+=ANTIALIASING;float offset_sign=(fract(a_pattern_data.x)-0.5)*4.0;float line_progress_offset=offset_sign*v_width*0.5/u_tile_units_to_pixels;v_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:qi('#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:qi('#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:qi("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-vec2(1.0),0.0,1.0);v_particle_speed=length(velocity);}gl_PointSize=1.0;}'),rasterParticleTexture:qi("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:qi('#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;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 float speed=velocity==INVALID_VELOCITY ? 0.0 : length(velocity);highp float reset_rate_bump=speed*u_reset_rate;highp vec2 particle_pos_min=-u_particle_pos_offset;highp vec2 particle_pos_max=vec2(1.0)+u_particle_pos_offset;highp vec2 pos_drop_rate=vec2(1.0)-step(particle_pos_min,pos)+step(particle_pos_max,pos);highp float drop_rate=max(u_reset_rate+reset_rate_bump,length(pos_drop_rate));highp float drop=step(1.0-drop_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);}"),symbolIcon:qi('#include "_prelude_lighting.glsl"\nuniform sampler2D u_texture;\n#ifdef ICON_TRANSITION\nuniform float u_icon_transition;\n#endif\nin float v_fade_opacity;in vec2 v_tex_a;\n#ifdef ICON_TRANSITION\nin vec2 v_tex_b;\n#endif\n#ifdef COLOR_ADJUSTMENT\nuniform mat4 u_color_adj_mat;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float emissive_strength\nlowp float alpha=opacity*v_fade_opacity;vec4 out_color;\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\nout_color*=alpha;\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_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\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 highp float u_camera_to_center_distance;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform vec3 u_up_vector;\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_fade_opacity;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float emissive_strength\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=elevation(tile_anchor);\n#ifdef Z_OFFSET\ne+=a_z_offset;\n#endif\nvec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,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;\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);\n#else\noffsetProjected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);\n#endif\nvec2 a=projected_point.xy/projected_point.w;vec2 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\nfloat occlusion_fade=occlusionFade(projected_point)*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 out_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change))*projection_transition_fade;float 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\nv_tex_a=a_tex/u_texsize;\n#ifdef ICON_TRANSITION\nv_tex_b=a_texb/u_texsize;\n#endif\nv_fade_opacity=out_fade_opacity;}'),symbolSDF:qi('#include "_prelude_lighting.glsl"\n#define SDF_PX 8.0\nuniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;uniform bool u_is_halo;in float v_draw_halo;in vec2 v_data0;in vec3 v_data1;\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\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 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) {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,tex).r;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);vec4 out_color=color*(alpha*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_z_offset;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_globe_anchor;in vec3 a_globe_normal;\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_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 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 float v_draw_halo;out vec2 v_data0;out vec3 v_data1;\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\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;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=elevation(tile_anchor);\n#ifdef Z_OFFSET\ne+=a_z_offset;\n#endif\nvec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,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 fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetprojected_point;\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);\n#else\noffsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);\n#endif\nvec2 a=projected_point.xy/projected_point.w;vec2 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*fontScale+a_pxoffset);\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\nfloat occlusion_fade=occlusionFade(projected_point)*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;float 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_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,out_fade_opacity);}'),symbolTextAndIcon:qi('#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_halo;in float v_draw_halo;in vec4 v_data0;in vec4 v_data1;\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\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;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;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 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) {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,tex).r;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);vec4 out_color=color*(alpha*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_projected_pos;in float a_fade_opacity;\n#ifdef Z_OFFSET\nin float a_z_offset;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_globe_anchor;in vec3 a_globe_normal;\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_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 float v_draw_halo;out vec4 v_data0;out vec4 v_data1;\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\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);float is_sdf=a_size[0]-2.0*a_size_min;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=elevation(tile_anchor);\n#ifdef Z_OFFSET\ne+=a_z_offset;\n#endif\nvec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,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=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offset_projected_point=u_matrix*vec4(a_pos+vec2(1,0),0,1);vec2 a=projected_point.xy/projected_point.w;vec2 b=offset_projected_point.xy/offset_projected_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*font_scale);\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\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));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\nfloat out_fade_opacity=interpolated_fade_opacity*projection_transition_fade;float 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_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,out_fade_opacity,is_sdf);}'),terrainRaster:qi('#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:qi("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:qi('#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}',Li),skyboxGradient:qi('#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}',Li),skyboxCapture:qi("\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:qi('#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:qi('#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:qi('#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 vec4 v_pos_light_view_0;in 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 TERRAIN_FRAGMENT_OCCLUSION\nin highp float v_depth;uniform sampler2D u_depthTexture;uniform vec2 u_inv_depth_size;bool isOccluded() {vec2 coord=gl_FragCoord.xy*u_inv_depth_size;highp float depth=unpack_depth(texture(u_depthTexture,coord));return 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\nreturn vec4(mix(albedo.rgb,v_color_mix.rgb,v_color_mix.a),albedo.a);}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\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);color=mix(color,v_color_mix.rgb,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 vec4 v_pos_light_view_0;out 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 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=u_matrix*pos;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(normalize(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:qi("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 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=u_matrix*pos;\n#else\ngl_Position=u_matrix*vec4(a_pos_3f,1);\n#endif\nv_depth=gl_Position.z/gl_Position.w;}"),stars:qi("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);}")};function Qi(e,t){const r=e.replace(/\s*\/\/[^\n]*\n/g,"\n").split("\n");for(let e of r)if(e=e.trim(),"#"===e[0]&&e.includes("if")&&!e.includes("endif")){e=e.replace("#","").replace(/ifdef|ifndef|elif|if/g,"").replace(/!|defined|\(|\)|\|\||&&/g,"").replace(/\s+/g," ").trim();const r=e.split(" ");for(const e of r)t.includes(e)||t.push(e)}}function qi(e,t){const r=/#include\s+"([^"]+)"/g,i=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g;let n=t.match(/(attribute(\S*)|(^\s*|;)in) (highp |mediump |lowp )?([\w]+) ([\w]+)/gm);n&&(n=n.map((e=>{const t=e.split(" ");return t[t.length-1]})),n=[...new Set(n)]);const o={},s=[],a=[];if(e=e.replace(r,((e,t)=>(a.push(t),""))),(t=t.replace(r,((e,t)=>(s.push(t),"")))).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 l=[...Ni];Qi(e,l),Qi(t,l);for(const e of[...s,...a])Ui[e]||console.error(`Undefined include: ${e}`),Hi[e]||(Hi[e]=[],Qi(Ui[e],Hi[e])),l=[...l,...Hi[e]];return{fragmentSource:e=e.replace(i,((e,t,r,i,n)=>(o[n]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nin ${r} ${i} ${n};\n#else\nuniform ${r} ${i} u_${n};\n#endif\n`:"initialize"===t?`\n#ifdef HAS_UNIFORM_u_${n}\n ${r} ${i} ${n} = u_${n};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n in ${r} ${i} ${n};\n#endif\n`:"initialize-attribute"===t?"":void 0))),vertexSource:t=t.replace(i,((e,t,r,i,n)=>{const s="float"===i?"vec2":i,a=n.match(/color/)?"color":s;return"define-attribute-vertex-shader-only"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\nin ${r} ${i} a_${n};\n#endif\n`:o[n]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nin ${r} ${s} a_${n};\nout ${r} ${i} ${n};\n#else\nuniform ${r} ${i} u_${n};\n#endif\n`:"initialize"===t?"vec4"===a?`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = a_${n};\n#else\n ${r} ${i} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = unpack_mix_${a}(a_${n}, u_${n}_t);\n#else\n ${r} ${i} ${n} = u_${n};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n in ${r} ${i} a_${n};\n out ${r} ${i} ${n};\n#endif\n`:"initialize-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n ${n} = a_${n};\n#endif\n`:void 0:"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nin ${r} ${s} a_${n};\n#else\nuniform ${r} ${i} u_${n};\n#endif\n`:"define-instanced"===t?"mat4"===a?`\n#ifdef INSTANCED_ARRAYS\nin vec4 a_${n}0;\nin vec4 a_${n}1;\nin vec4 a_${n}2;\nin vec4 a_${n}3;\n#else\nuniform ${r} ${i} u_${n};\n#endif\n`:`\n#ifdef INSTANCED_ARRAYS\nin ${r} ${s} a_${n};\n#else\nuniform ${r} ${i} u_${n};\n#endif\n`:"initialize-attribute-custom"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n ${r} ${i} ${n} = a_${n};\n#endif\n`:"vec4"===a?`\n#ifndef HAS_UNIFORM_u_${n}\n ${r} ${i} ${n} = a_${n};\n#else\n ${r} ${i} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${r} ${i} ${n} = unpack_mix_${a}(a_${n}, u_${n}_t);\n#else\n ${r} ${i} ${n} = u_${n};\n#endif\n`})),staticAttributes:n,usedDefines:l,vertexIncludes:s,fragmentIncludes:a}}class Xi{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(e,t,r,i,n,o,s,a){this.context=e;let l=this.boundPaintVertexBuffers.length!==i.length;for(let e=0;!l&&e<i.length;e++)this.boundPaintVertexBuffers[e]!==i[e]&&(l=!0);let c=this.boundDynamicVertexBuffers.length!==s.length;for(let e=0;!c&&e<s.length;e++)this.boundDynamicVertexBuffers[e]!==s[e]&&(c=!0);if(!this.vao||this.boundProgram!==t||this.boundLayoutVertexBuffer!==r||l||c||this.boundIndexBuffer!==n||this.boundVertexOffset!==o)this.freshBind(t,r,i,n,o,s,a);else{e.bindVertexArrayOES.set(this.vao);for(const r of s)r&&(r.bind(),a&&r.instanceCount&&r.setVertexAttribDivisor(e.gl,t,a));n&&n.dynamicDraw&&n.bind()}}freshBind(e,t,r,i,n,o,s){const a=e.numAttributes,l=this.context,c=l.gl;this.vao&&this.destroy(),this.vao=l.gl.createVertexArray(),l.bindVertexArrayOES.set(this.vao),this.boundProgram=e,this.boundLayoutVertexBuffer=t,this.boundPaintVertexBuffers=r,this.boundIndexBuffer=i,this.boundVertexOffset=n,this.boundDynamicVertexBuffers=o,t.enableAttributes(c,e),t.bind(),t.setVertexAttribPointers(c,e,n);for(const t of r)t.enableAttributes(c,e),t.bind(),t.setVertexAttribPointers(c,e,n);for(const t of o)t&&(t.enableAttributes(c,e),t.bind(),t.setVertexAttribPointers(c,e,n),s&&t.instanceCount&&t.setVertexAttribDivisor(c,e,s));i&&i.bind(),l.currentNumAttributes=a}destroy(){this.vao&&(this.context.gl.deleteVertexArray(this.vao),this.vao=null)}}function Yi(t,r){const i=Math.pow(2,r.canonical.z),n=r.canonical.y;return[new e.O(0,n/i).toLngLat().lat,new e.O(0,(n+1)/i).toLngLat().lat]}function $i(t,r,i,n,o,s,a){const l=t.context,c=l.gl,u=i.hillshadeFBO;if(!u)return;t.prepareDrawTile();const h=t.isTileAffectedByFog(r),d=t.getOrCreateProgram("hillshade",{overrideFog:h});l.activeTexture.set(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,u.colorAttachment.get());const p=((t,r,i,n)=>{const o=i.paint.get("hillshade-shadow-color"),s=i.paint.get("hillshade-highlight-color"),a=i.paint.get("hillshade-accent-color"),l=i.paint.get("hillshade-emissive-strength");let c=e.bm(i.paint.get("hillshade-illumination-direction"));if("viewport"===i.paint.get("hillshade-illumination-anchor"))c-=t.transform.angle;else if(t.style&&t.style.enable3dLights()&&t.style.directionalLight){const r=t.style.directionalLight.properties.get("direction"),i=e.bT(r.x,r.y,r.z);c=e.bm(i[1])}const u=!t.options.moving;return{u_matrix:n||t.transform.calculateProjMatrix(r.tileID.toUnwrapped(),u),u_image:0,u_latrange:Yi(0,r.tileID),u_light:[i.paint.get("hillshade-exaggeration"),c],u_shadow:o,u_highlight:s,u_emissive_strength:l,u_accent:a}})(t,i,n,t.terrain?r.projMatrix:null);t.uploadCommonUniforms(l,d,r.toUnwrapped());const{tileBoundsBuffer:f,tileBoundsIndexBuffer:m,tileBoundsSegments:A}=t.getTileBoundsBuffers(i);d.draw(t,c.TRIANGLES,o,s,a,Lt.disabled,p,n.id,f,m,A)}function Ki(t,r,i){if(!r.needsDEMTextureUpload)return;const n=t.context,o=n.gl;n.pixelStoreUnpackPremultiplyAlpha.set(!1),r.demTexture=r.demTexture||t.getTileTexture(i.stride);const s=i.getPixels();r.demTexture?r.demTexture.update(s,{premultiply:!1}):r.demTexture=new e.T(n,s,o.R32F,{premultiply:!1}),r.needsDEMTextureUpload=!1}function Ji(t,r,i){const n=t.context,o=n.gl;if(!r.dem)return;const s=r.dem;if(n.activeTexture.set(o.TEXTURE1),Ki(t,r,s),!r.demTexture)return;r.demTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE);const a=s.dim;n.activeTexture.set(o.TEXTURE0);let l=r.hillshadeFBO;if(!l){const t=new e.T(n,{width:a,height:a,data:null},o.RGBA);t.bind(o.LINEAR,o.CLAMP_TO_EDGE),l=r.hillshadeFBO=n.createFramebuffer(a,a,!0,"renderbuffer"),l.colorAttachment.set(t.texture)}n.bindFramebuffer.set(l.framebuffer),n.viewport.set([0,0,a,a]);const{tileBoundsBuffer:c,tileBoundsIndexBuffer:u,tileBoundsSegments:h}=t.getMercatorTileBoundsBuffers(),d=[];t.linearFloatFilteringSupported()&&d.push("TERRAIN_DEM_FLOAT_FORMAT"),t.getOrCreateProgram("hillshadePrepare",{defines:d}).draw(t,o.TRIANGLES,Et.disabled,St.disabled,Pt.unblended,Lt.disabled,((t,r)=>{const i=r.stride,n=e.a9.create();return e.a9.ortho(n,0,e.Y,-e.Y,0,0,1),e.a9.translate(n,n,[0,-e.Y,0]),{u_matrix:n,u_image:1,u_dimension:[i,i],u_zoom:t.overscaledZ}})(r.tileID,s),i.id,c,u,h),r.needsHillshadePrepare=!1}const en=t=>({u_matrix:new e.bN(t),u_image0:new e.bR(t),u_skirt_height:new e.bQ(t),u_ground_shadow_factor:new e.bP(t)}),tn=(e,t,r)=>({u_matrix:e,u_image0:0,u_skirt_height:t,u_ground_shadow_factor:r}),rn=(e,t,r,i,n,o,s,a,l,c,u,h,d,p,f,m)=>({u_proj_matrix:Float32Array.from(e),u_globe_matrix:t,u_normalize_matrix:Float32Array.from(i),u_merc_matrix:r,u_zoom_transition:n,u_merc_center:o,u_image0:0,u_frustum_tl:s,u_frustum_tr:a,u_frustum_br:l,u_frustum_bl:c,u_globe_pos:u,u_globe_radius:h,u_viewport:d,u_grid_matrix:m?Float32Array.from(m):new Float32Array(9),u_skirt_height:p,u_far_z_cutoff:f});function nn(e,t){return null!=e&&null!=t&&!(!e.hasData()||!t.hasData())&&null!=e.demTexture&&null!=t.demTexture&&e.tileID.key!==t.tileID.key}const on=new class{constructor(){this.operations={}}newMorphing(e,t,r,i,n){if(e in this.operations){const t=this.operations[e];t.to.tileID.key!==r.tileID.key&&(t.queued=r)}else this.operations[e]={startTime:i,phase:0,duration:n,from:t,to:r,queued:null}}getMorphValuesForProxy(e){if(!(e in this.operations))return null;const t=this.operations[e];return{from:t.from,to:t.to,phase:t.phase}}update(e){for(const t in this.operations){const r=this.operations[t];for(r.phase=(e-r.startTime)/r.duration;r.phase>=1||!this._validOp(r);)if(!this._nextOp(r,e)){delete this.operations[t];break}}}_nextOp(e,t){return!!e.queued&&(e.from=e.to,e.to=e.queued,e.queued=null,e.phase=0,e.startTime=t,!0)}_validOp(e){return e.from.hasData()&&e.to.hasData()}},sn={0:null,1:"TERRAIN_VERTEX_MORPHING"};function an(e,t,r){if(0===t)return 0;const i=t<1&&514===r?.25/t:1;return 6*Math.pow(1.5,22-e)*Math.max(t,1)*i}function ln(e,t){const r=1<<e.z;return!t&&(0===e.x||e.x===r-1)||0===e.y||e.y===r-1}const cn=e=>({u_matrix:e});function un(t,r,i,n,o){if(o>0){const s=e.f.now(),a=(s-t.timeAdded)/o,l=r?(s-r.timeAdded)/o:-1,c=i.getSource(),u=n.coveringZoomLevel({tileSize:c.tileSize,roundZoom:c.roundZoom}),h=!r||Math.abs(r.tileID.overscaledZ-u)>Math.abs(t.tileID.overscaledZ-u),d=h&&t.refreshedUponExpiration?1:e.ad(h?a:1-l,0,1);return t.refreshedUponExpiration&&a>=1&&(t.refreshedUponExpiration=!1),r?{opacity:1,mix:1-d}:{opacity:d,mix:0}}return{opacity:1,mix:0}}class hn extends qt{constructor(t){const r={type:"raster-dem",maxzoom:t.transform.maxZoom},i=new e.bZ(e.b_(),null),n=Nt("mock-dem",r,i,t.style);super("mock-dem",n,!1),n.setEventedParent(this),this._sourceLoaded=!0}_loadTile(e,t){e.state="loaded",t(null)}}class dn extends qt{constructor(t){const r=Nt("proxy",{type:"geojson",maxzoom:t.transform.maxZoom},new e.bZ(e.b_(),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(e,t,r){if(e.freezeTileCoverage)return;this.transform=e;const i=e.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce(((t,r)=>{if(t[r.key]="",!this._tiles[r.key]){const t=new jt(r,this._source.tileSize*r.overscaleFactor(),e.tileZoom);t.state="loaded",this._tiles[r.key]=t}return t}),{});for(const e in this._tiles)e in i||(this.freeFBO(e),this._tiles[e].unloadVectorData(),delete this._tiles[e])}freeFBO(e){const t=this.proxyCachedFBO[e];if(void 0!==t){const r=Object.values(t);this.renderCachePool.push(...r),delete this.proxyCachedFBO[e]}}deallocRenderCache(){this.renderCache.forEach((e=>e.fb.destroy())),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class pn extends e.ap{constructor(e,t,r){super(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y),this.proxyTileKey=t,this.projMatrix=r}}class fn extends e.cp{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[i,n,o]=function(t){const r=new e.aQ,i=new e.az,n=131;r.reserve(17161),i.reserve(33800);const o=e.Y/128,s=e.Y+o/2,a=s+o;for(let t=-o;t<a;t+=o)for(let i=-o;i<a;i+=o){const n=i<0||i>s||t<0||t>s?24575:0,o=e.ad(Math.round(i),0,e.Y),a=e.ad(Math.round(t),0,e.Y);r.emplaceBack(o+n,a)}const l=(e,t)=>{const r=t*n+e;i.emplaceBack(r+1,r,r+n),i.emplaceBack(r+n,r+n+1,r+1)};for(let e=1;e<129;e++)for(let t=1;t<129;t++)l(t,e);return[0,129].forEach((e=>{for(let t=0;t<130;t++)l(t,e),l(e,t)})),[r,i,32768]}(),s=t.context;this.gridBuffer=s.createVertexBuffer(i,e.aS.members),this.gridIndexBuffer=s.createIndexBuffer(n),this.gridSegments=e.aE.simpleSegment(0,0,i.length,n.length),this.gridNoSkirtSegments=e.aE.simpleSegment(0,0,i.length,o),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new dn(r.map),this.orthoMatrix=e.a9.create(),e.a9.ortho(this.orthoMatrix,"globe"===this.painter.transform.projection.name?.015:0,e.Y,0,e.Y,0,1);const a=s.gl;this._overlapStencilMode=new St({func:a.GEQUAL,mask:255},0,255,a.KEEP,a.KEEP,a.REPLACE),this._previousZoom=t.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=r,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new hn(r.map),this._pendingGroundEffectLayers=[]}set style(e){e.on("data",this._onStyleDataEvent.bind(this)),this._style=e,this._style.map.on("moveend",(()=>{this._clearLineLayersFromRenderCache()}))}update(t,r,i){if(t&&t.terrain){this._style!==t&&(this.style=t,this._evaluationZoom=void 0);const n=t.terrain.properties,o=0===t.terrain.drapeRenderMode,s=t.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=e.f.now();const a=t.terrain&&t.terrain.scope,l=n.get("source"),c=o?this._mockSourceCache:t.getSourceCache(l,a);if(!c)return void e.w(`Couldn't find terrain source "${l}".`);if(this.sourceCache=c,this._exaggeration=s?this.calculateExaggeration(r):n.get("exaggeration"),!r.projection.requiresDraping&&s&&0===this._exaggeration)return void this._disable();this.enabled=!0;const u=()=>{this.sourceCache.used&&e.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 t=this.getScaledDemTileSize();this.sourceCache.update(r,t,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,u(),this._initializing=!0),u(),r.updateElevation(!0,i),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,i=t.getFreeCameraOptions().position.z/t.pixelsPerMeter*t.worldSize;this._previousCameraAltitude=i;const n=null!=r?i-r:Number.MAX_VALUE;if(Math.abs(n)<2)return this._exaggeration;const o=t.zoom,s=this._style.terrain;if(!this._previousUpdateTimestamp)return s.getExaggeration(o);let a=o-this._previousZoom;const l=this._previousUpdateTimestamp;let c=o;null!=this._evaluationZoom&&(c=this._evaluationZoom,Math.abs(o-c)>.5&&(a=.5*(o-c+a)),a*n<0&&(c+=a)),this._evaluationZoom=c;const u=s.getExaggeration(c),h=u===s.getExaggeration(Math.max(0,c-.1));if(h&&Math.abs(u-this._exaggeration)<.01)return u;let d=Math.min(.1,.00375*(this._updateTimestamp-l));return(h||u<.1||Math.abs(a)<1e-4)&&(d=Math.min(.2,4*d)),e.X(this._exaggeration,u,d)}resetTileLookupCache(e){this._findCoveringTileCache[e]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_onStyleDataEvent(e){e.coord&&"source"===e.dataType?this._clearRenderCacheForTile(e.sourceCacheId,e.coord):"style"===e.dataType&&(this.invalidateRenderCache=!0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this._previousCameraAltitude=void 0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const e in this._style._mergedSourceCaches)this._style._mergedSourceCaches[e].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach((e=>e.fb.destroy())),this.pool=[],this._depthFBO&&(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),this.framebufferCopyTexture&&this.framebufferCopyTexture.destroy()}_source(){return this.enabled?this.sourceCache:null}isUsingMockSource(){return this.sourceCache===this._mockSourceCache}exaggeration(){return this._exaggeration}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const e=2*this.proxySourceCache.getSource().tileSize;return[e,e]}set useVertexMorphing(e){this._useVertexMorphing=e}updateTileBinding(t){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const r=this.proxySourceCache,i=this.painter.transform;this._initializing&&(this._initializing=0===i._centerAltitude&&-1===this.getAtPointOrZero(e.O.fromLngLat(i.center),-1),this._emptyDEMTextureDirty=!this._initializing);const n=this.proxyCoords=r.getIds().map((e=>{const t=r.getTileByID(e).tileID;return t.projMatrix=i.calculateProjMatrix(t.toUnwrapped()),t}));!function(t,r){const i=r.transform.pointCoordinate(r.transform.getCameraPoint()),n=new e.P(i.x,i.y);t.sort(((t,r)=>{if(r.overscaledZ-t.overscaledZ)return r.overscaledZ-t.overscaledZ;const i=new e.P(t.canonical.x+(1<<t.canonical.z)*t.wrap,t.canonical.y),o=new e.P(r.canonical.x+(1<<r.canonical.z)*r.wrap,r.canonical.y),s=n.mult(1<<t.canonical.z);return s.x-=.5,s.y-=.5,s.distSqr(i)-s.distSqr(o)}))}(n,this.painter);const o=this.proxyToSource||{};this.proxyToSource={},n.forEach((e=>{this.proxyToSource[e.key]={}})),this.terrainTileForTile={};const s=this._style._mergedSourceCaches;for(const e in s){const r=s[e];if(!r.used)continue;if(r!==this.sourceCache&&this.resetTileLookupCache(r.id),this._setupProxiedCoordsForOrtho(r,t[e],o),r.usedForTerrain)continue;const i=t[e];r.getSource().reparseOverscaled&&this._assignTerrainTiles(i)}this.proxiedCoords[r.id]=n.map((e=>new pn(e,e.key,this.orthoMatrix))),this._assignTerrainTiles(n),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(o),this.renderingToTexture=!1;const a={};this._visibleDemTiles=[];for(const e of this.proxyCoords){const t=this.terrainTileForTile[e.key];if(!t)continue;const r=t.tileID.key;r in a||(this._visibleDemTiles.push(t),a[r]=r)}}_assignTerrainTiles(e){this._initializing||e.forEach((e=>{if(this.terrainTileForTile[e.key])return;const t=this._findTileCoveringTileID(e,this.sourceCache);t&&(this.terrainTileForTile[e.key]=t)}))}_prepareDEMTextures(){const e=this.painter.context,t=e.gl;for(const r in this.terrainTileForTile){const i=this.terrainTileForTile[r],n=i.dem;!n||i.demTexture&&!i.needsDEMTextureUpload||(e.activeTexture.set(t.TEXTURE1),Ki(this.painter,i,n))}}_prepareDemTileUniforms(e,t,r,i){if(!t||null==t.demTexture)return!1;const n=e.tileID.canonical,o=Math.pow(2,t.tileID.canonical.z-n.z),s=i||"";return r[`u_dem_tl${s}`]=[n.x*o%1,n.y*o%1],r[`u_dem_scale${s}`]=o,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const t=this.painter.context,r=t.gl;if(!this._emptyDepthBufferTexture){const i=new e.h({width:1,height:1},Uint8Array.of(255,255,255,255));this._emptyDepthBufferTexture=new e.T(t,i,r.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let e=0;const t=this._visibleDemTiles.reduce(((t,r)=>{if(!r.dem)return t;const i=r.dem.tree.minimums[0];return i>0&&e++,t+i}),0);return e?t/e:0}_updateEmptyDEMTexture(){const t=this.painter.context,r=t.gl;t.activeTexture.set(r.TEXTURE2);const i=this._getLoadedAreaMinimum(),[n,o]=(()=>{const t=new e.cr({width:1,height:1},new Float32Array([i]));return[r.R32F,t]})();this._emptyDEMTextureDirty=!1;let s=this._emptyDEMTexture;return s?s.update(o,{premultiply:!1}):s=this._emptyDEMTexture=new e.T(t,o,n,{premultiply:!1}),s}setupElevationDraw(t,r,i){const n=this.painter.context,o=n.gl,s={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_exaggeration:0};s.u_exaggeration=this.exaggeration();let a=null,l=null,c=1;if(i&&i.morphing&&this._useVertexMorphing){const e=i.morphing.srcDemTile,r=i.morphing.dstDemTile;c=i.morphing.phase,e&&r&&(this._prepareDemTileUniforms(t,e,s,"_prev")&&(l=e),this._prepareDemTileUniforms(t,r,s)&&(a=r))}const u=e=>e&&e.demTexture&&this.painter.linearFloatFilteringSupported()?o.LINEAR:o.NEAREST,h=e=>{s.u_dem_size=1===e.size[0]?1:e.size[0]-2};if(l&&a)n.activeTexture.set(o.TEXTURE2),a.demTexture.bind(u(a),o.CLAMP_TO_EDGE),n.activeTexture.set(o.TEXTURE4),l.demTexture.bind(u(l),o.CLAMP_TO_EDGE),a.demTexture&&h(a.demTexture),s.u_dem_lerp=c;else{a=this.terrainTileForTile[t.tileID.key],n.activeTexture.set(o.TEXTURE2);const e=this._prepareDemTileUniforms(t,a,s)?a.demTexture:this.emptyDEMTexture;e.bind(u(a),o.CLAMP_TO_EDGE),h(e)}if(n.activeTexture.set(o.TEXTURE3),i&&i.useDepthForOcclusion?(this._depthTexture&&this._depthTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE),this._depthFBO&&(s.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height])):(this.emptyDepthBufferTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE),s.u_depth_size_inv=[1,1]),i&&i.useMeterToDem&&a){const t=(1<<a.tileID.canonical.z)*e.bo(1,this.painter.transform.center.lat)*this.sourceCache.getSource().tileSize;s.u_meter_to_dem=t}if(i&&i.labelPlaneMatrixInv&&(s.u_label_plane_matrix_inv=i.labelPlaneMatrixInv),r.setTerrainUniformValues(n,s),"globe"===this.painter.transform.projection.name){const e=this.globeUniformValues(this.painter.transform,t.tileID.canonical,i&&i.useDenormalizedUpVectorScale);r.setGlobeUniformValues(n,e)}}globeUniformValues(t,r,i){const n=t.projection;return{u_tile_tl_up:n.upVector(r,0,0),u_tile_tr_up:n.upVector(r,e.Y,0),u_tile_br_up:n.upVector(r,e.Y,e.Y),u_tile_bl_up:n.upVector(r,0,e.Y),u_tile_up_scale:i?e.cq(1):n.upVectorScale(r,t.center.lat,t.worldSize).metersToTile}}renderToBackBuffer(t){const r=this.painter,i=this.painter.context;0!==t.length&&(i.bindFramebuffer.set(null),i.viewport.set([0,0,r.width,r.height]),r.gpuTimingDeferredRenderStart(),this.renderingToTexture=!1,function(t,r,i,n,o){if("globe"===t.transform.projection.name)!function(t,r,i,n,o){const s=t.context,a=s.gl;let l,c;const u=t.transform,h=e.ci(t,s,u),d=(e,r)=>{if(c===r)return;const i=[sn[r],"PROJECTION_GLOBE_VIEW"];h&&i.push("CUSTOM_ANTIALIASING");const n=t.isTileAffectedByFog(e);l=t.getOrCreateProgram("globeRaster",{defines:i,overrideFog:n}),c=r},p=t.colorModeForRenderPass(),f=new Et(a.LEQUAL,Et.ReadWrite,t.depthRangeFor3D);on.update(o);const m=e.cj(u),A=[e.a8(u.center.lng),e.ah(u.center.lat)],g=t.globeSharedBuffers,_=[u.width*e.f.devicePixelRatio,u.height*e.f.devicePixelRatio],y=Float32Array.from(u.globeMatrix),x={useDenormalizedUpVectorScale:!0};{const u=t.transform,h=an(u.zoom,r.exaggeration(),r.sourceCache._source.tileSize);c=-1;const v=a.TRIANGLES;for(const c of n){const n=i.getTile(c),b=St.disabled,w=r.prevTerrainTileForTile[c.key],C=r.terrainTileForTile[c.key];nn(w,C)&&on.newMorphing(c.key,w,C,o,250),s.activeTexture.set(a.TEXTURE0),n.texture&&n.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const T=on.getMorphValuesForProxy(c.key),E=T?1:0;T&&e.k(x,{morphing:{srcDemTile:T.from,dstDemTile:T.to,phase:e.ch(T.phase)}});const M=e.ck(c.canonical),S=e.cl(M.getCenter().lat),I=e.cm(c.canonical,M,S,u.worldSize/u._pixelsPerMercatorPixel),P=e.aW(e.cn(c.canonical)),D=rn(u.expandedFarZProjMatrix,y,m,P,e.W(u.zoom),A,u.frustumCorners.TL,u.frustumCorners.TR,u.frustumCorners.BR,u.frustumCorners.BL,u.globeCenterInViewSpace,u.globeRadius,_,h,u._farZ,I);if(d(c,E),l&&(r.setupElevationDraw(n,l,x),t.uploadCommonUniforms(s,l,c.toUnwrapped()),g)){const[e,r,i]=g.getGridBuffers(S,0!==h);l.draw(t,v,f,b,p,Lt.backCCW,D,"globe_raster",e,r,i)}}}if(g&&(t.renderDefaultNorthPole||t.renderDefaultSouthPole)){const o=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];h&&o.push("CUSTOM_ANTIALIASING"),l=t.getOrCreateProgram("globeRaster",{defines:o});for(const o of n){const{x:n,y:c,z:h}=o.canonical,d=0===c,m=c===(1<<h)-1,[y,v,b,w]=g.getPoleBuffers(h,!1);if(w&&(d||m)){const c=i.getTile(o);s.activeTexture.set(a.TEXTURE0),c.texture&&c.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);let g=e.co(h,n,u);const C=e.aW(e.cn(o.canonical)),T=(e,r)=>e.draw(t,a.TRIANGLES,f,St.disabled,p,Lt.disabled,rn(u.expandedFarZProjMatrix,g,g,C,0,A,u.frustumCorners.TL,u.frustumCorners.TR,u.frustumCorners.BR,u.frustumCorners.BL,u.globeCenterInViewSpace,u.globeRadius,_,0,u._farZ),"globe_pole_raster",r,b,w);r.setupElevationDraw(c,l,x),t.uploadCommonUniforms(s,l,o.toUnwrapped()),d&&t.renderDefaultNorthPole&&T(l,y),m&&t.renderDefaultSouthPole&&(g=e.a9.scale(e.a9.create(),g,[1,-1,1]),T(l,v))}}}}(t,r,i,n,o);else{const s=t.context,a=s.gl;let l,c;const u=t.shadowRenderer,h=mi(t,t.longestCutoffRange),d=e=>{if(c===e)return;const r=[];r.push(sn[e]),h.shouldRenderCutoff&&r.push("RENDER_CUTOFF"),l=t.getOrCreateProgram("terrainRaster",{defines:r}),c=e},p=t.colorModeForRenderPass(),f=new Et(a.LEQUAL,Et.ReadWrite,t.depthRangeFor3D);on.update(o);const m=t.transform,A=an(m.zoom,r.exaggeration(),r.sourceCache._source.tileSize);let g=[0,0,0];if(u){const e=t.style.directionalLight,r=t.style.ambientLight;e&&r&&(g=bi(e,r))}{c=-1;const _=a.TRIANGLES,[y,x]=[r.gridIndexBuffer,r.gridSegments];for(const c of n){const n=i.getTile(c),v=St.disabled,b=r.prevTerrainTileForTile[c.key],w=r.terrainTileForTile[c.key];nn(b,w)&&on.newMorphing(c.key,b,w,o,250),s.activeTexture.set(a.TEXTURE0),n.texture&&n.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const C=on.getMorphValuesForProxy(c.key),T=C?1:0;let E;C&&(E={morphing:{srcDemTile:C.from,dstDemTile:C.to,phase:e.ch(C.phase)}});const M=tn(c.projMatrix,ln(c.canonical,m.renderWorldCopies)?A/10:A,g);if(d(T),!l)continue;r.setupElevationDraw(n,l,E);const S=c.toUnwrapped();u&&u.setupShadows(S,l),t.uploadCommonUniforms(s,l,S,null,h),l.draw(t,_,f,v,p,Lt.backCCW,M,"terrain_raster",r.gridBuffer,y,x)}}}}(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,i=this.painter.context,n=this.proxySourceCache,o=this.proxiedCoords[n.id],s=this._drapedRenderBatches.shift(),a=r.style.order,l=[];let c=0;for(const u of o){const o=n.getTileByID(u.proxyTileKey),h=n.proxyCachedFBO[u.key]?n.proxyCachedFBO[u.key][t]:void 0,d=void 0!==h?n.renderCache[h]:this.pool[c++],p=void 0!==h;if(o.texture=d.tex,p&&!d.dirty){l.push(o.tileID);continue}let f;i.bindFramebuffer.set(d.fb.framebuffer),this.renderedToTile=!1,d.dirty&&(i.clear({color:e.aA.transparent,stencil:0}),d.dirty=!1);for(let e=s.start;e<=s.end;++e){const t=r.style._mergedLayers[a[e]];if(t.isHidden(r.transform.zoom))continue;const n=r.style.getLayerSourceCache(t),o=n?this.proxyToSource[u.key][n.id]:[u];if(!o)continue;const s=o;i.viewport.set([0,0,d.fb.width,d.fb.height]),f!==(n?n.id:null)&&(this._setupStencil(d,o,t,n),f=n?n.id:null),r.renderLayer(r,n,t,s)}if(0===this._drapedRenderBatches.length)for(const e of this._pendingGroundEffectLayers){const t=r.style._mergedLayers[a[e]];if(t.isHidden(r.transform.zoom))continue;const n=r.style.getLayerSourceCache(t),o=n?this.proxyToSource[u.key][n.id]:[u];if(!o)continue;const s=o;i.viewport.set([0,0,d.fb.width,d.fb.height]),f!==(n?n.id:null)&&(this._setupStencil(d,o,t,n),f=n?n.id:null),r.renderLayer(r,n,t,s)}this.renderedToTile?(d.dirty=!0,l.push(o.tileID)):p||--c,5===c&&(c=0,this.renderToBackBuffer(l))}return this.renderToBackBuffer(l),this.renderingToTexture=!1,i.bindFramebuffer.set(null),i.viewport.set([0,0,r.width,r.height]),s.end+1}postRender(){}isLayerOrderingCorrect(e){const t=e.order.length;let r=-1,i=t;for(let n=0;n<t;++n)this._style.isLayerDraped(e._mergedLayers[e.order[n]])?r=Math.max(r,n):i=Math.min(i,n);return i>r}getMinElevationBelowMSL(){let e=0;return this._visibleDemTiles.filter((e=>e.dem)).forEach((t=>{e=Math.min(e,t.dem.tree.minimums[0])})),0===e?e:(e-30)*this._exaggeration}raycast(e,t,r){if(!this._visibleDemTiles)return null;const i=this._visibleDemTiles.filter((e=>e.dem)).map((i=>{const n=i.tileID,o=1<<n.overscaledZ,{x:s,y:a}=n.canonical,l=s/o,c=(s+1)/o,u=a/o,h=(a+1)/o;return{minx:l,miny:u,maxx:c,maxy:h,t:i.dem.tree.raycastRoot(l,u,c,h,e,t,r),tile:i}}));i.sort(((e,t)=>(null!==e.t?e.t:Number.MAX_VALUE)-(null!==t.t?t.t:Number.MAX_VALUE)));for(const n of i){if(null==n.t)return null;const i=n.tile.dem.tree.raycast(n.minx,n.miny,n.maxx,n.maxy,e,t,r);if(null!=i)return i}return null}_createFBO(){const t=this.painter.context,r=t.gl,i=this.drapeBufferSize;t.activeTexture.set(r.TEXTURE0);const n=new e.T(t,{width:i[0],height:i[1],data:null},r.RGBA);n.bind(r.LINEAR,r.CLAMP_TO_EDGE);const o=t.createFramebuffer(i[0],i[1],!0,null);return o.colorAttachment.set(n.texture),o.depthAttachment=new Ct(t,o.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=t.createRenderbuffer(t.gl.DEPTH_STENCIL,i[0],i[1]),this._stencilRef=0,o.depthAttachment.set(this._sharedDepthStencil),t.clear({stencil:0})):o.depthAttachment.set(this._sharedDepthStencil),t.extTextureFilterAnisotropic&&r.texParameterf(r.TEXTURE_2D,t.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,t.extTextureFilterAnisotropicMax),{fb:o,tex:n,dirty:!1}}_initFBOPool(){for(;this.pool.length<Math.min(5,this.proxyCoords.length);)this.pool.push(this._createFBO())}_shouldDisableRenderCache(){if(this._debugParams.disableRenderCache)return!0;if(this._style.hasLightTransitions())return!0;for(const e in this._style._mergedSourceCaches)if(this._style._mergedSourceCaches[e].hasTransition())return!0;return this._style.order.some((e=>{const t=this._style._mergedLayers[e],r=t.isHidden(this.painter.transform.zoom);return"custom"===t.type?!r&&t.shouldRedrape():!r&&t.hasTransition()}))}_clearLineLayersFromRenderCache(){let t=!1;for(const e of this._style.getSources())if(e instanceof Ie){t=!0;break}if(!t)return;const r={};for(let t=0;t<this._style.order.length;++t){const i=this._style._mergedLayers[this._style.order[t]],n=this._style.getLayerSourceCache(i);if(n&&!r[n.id]&&!i.isHidden(this.painter.transform.zoom)&&"line"===i.type&&i.widthExpression()instanceof e.Z){r[n.id]=!0;for(const e of this.proxyCoords){const t=this.proxyToSource[e.key][n.id];if(t)for(const e of t)this._clearRenderCacheForTile(n.id,e)}}}}_clearRasterLayersFromRenderCache(){let e=!1;for(const t in this._style._mergedSourceCaches)if(this._style._mergedSourceCaches[t]._source instanceof Pe){e=!0;break}if(!e)return;const t={};for(let e=0;e<this._style.order.length;++e){const r=this._style._mergedLayers[this._style.order[e]],i=this._style.getLayerSourceCache(r);if(!i||t[i.id])continue;if(r.isHidden(this.painter.transform.zoom)||"raster"!==r.type)continue;const n=r.paint.get("raster-fade-duration");for(const e of this.proxyCoords){const t=this.proxyToSource[e.key][i.id];if(t)for(const e of t){const t=un(i.getTile(e),i.findLoadedParent(e,0),i,this.painter.transform,n);(1!==t.opacity||0!==t.mix)&&this._clearRenderCacheForTile(i.id,e)}}}}_setupDrapedRenderBatches(){const t=this._style.order,r=t.length;if(0===r)return;const i=[];this._pendingGroundEffectLayers=[];let n,o=0,s=this._style._mergedLayers[t[o]];for(;!this._style.isLayerDraped(s)&&s.isHidden(this.painter.transform.zoom)&&++o<r;)s=this._style._mergedLayers[t[o]];for(;o<r;++o){const e=this._style._mergedLayers[t[o]];e.isHidden(this.painter.transform.zoom)||(this._style.isLayerDraped(e)?void 0===n&&(n=o):("fill-extrusion"===e.type&&this._pendingGroundEffectLayers.push(o),void 0!==n&&(i.push({start:n,end:o-1}),n=void 0)))}if(void 0!==n&&i.push({start:n,end:o-1}),0!==i.length){const t=i[i.length-1];this._pendingGroundEffectLayers.every((e=>e>t.end))||e.w("fill-extrusion with flood lighting and/or ground ambient occlusion should be moved to be on top of all draped layers.")}this._drapedRenderBatches=i}_setupRenderCache(e){const t=this.proxySourceCache;if(this._shouldDisableRenderCache()||this.invalidateRenderCache){if(this.invalidateRenderCache=!1,t.renderCache.length>t.renderCachePool.length){const e=Object.values(t.proxyCachedFBO);t.proxyCachedFBO={};for(let r=0;r<e.length;++r){const i=Object.values(e[r]);t.renderCachePool.push(...i)}}return}this._clearRasterLayersFromRenderCache();const r=this.proxyCoords,i=this._tilesDirty;for(let n=r.length-1;n>=0;n--){const o=r[n];if(t.getTileByID(o.key),void 0!==t.proxyCachedFBO[o.key]){const r=e[o.key],n=this.proxyToSource[o.key];let s=0;for(const e in n){const t=n[e],o=r[e];if(!o||o.length!==t.length||t.some(((t,r)=>t!==o[r]||i[e]&&i[e].hasOwnProperty(t.key)))){s=-1;break}++s}for(const e in t.proxyCachedFBO[o.key])t.renderCache[t.proxyCachedFBO[o.key][e]].dirty=s<0||s!==Object.values(r).length}}const n=[...this._drapedRenderBatches];n.sort(((e,t)=>t.end-t.start-(e.end-e.start)));for(const e of n)for(const i of r){if(t.proxyCachedFBO[i.key])continue;let r=t.renderCachePool.pop();void 0===r&&t.renderCache.length<50&&(r=t.renderCache.length,t.renderCache.push(this._createFBO())),void 0!==r&&(t.proxyCachedFBO[i.key]={},t.proxyCachedFBO[i.key][e.start]=r,t.renderCache[r].dirty=!0)}this._tilesDirty={}}_setupStencil(e,t,r,i){if(!i||!this._sourceTilesOverlap[i.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const n=this.painter.context,o=n.gl;if(t.length<=1)return void(this._overlapStencilType=!1);let s;if(r.isTileClipped())s=t.length,this._overlapStencilMode.test={func:o.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(t[0].overscaledZ>t[t.length-1].overscaledZ))return void(this._overlapStencilType=!1);s=1,this._overlapStencilMode.test={func:o.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+s>255&&(n.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=s,this._overlapStencilMode.ref=this._stencilRef,r.isTileClipped()&&this._renderTileClippingMasks(t,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return"Clip"===this._overlapStencilType||"Mask"===this._overlapStencilType}stencilModeForRTTOverlap(e){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[e.key]),this._overlapStencilMode):St.disabled}_renderTileClippingMasks(e,t){const r=this.painter,i=this.painter.context,n=i.gl;r._tileClippingMaskIDs={},i.setColorMode(Pt.disabled),i.setDepthMode(Et.disabled);const o=r.getOrCreateProgram("clippingMask");for(const i of e){const e=r._tileClippingMaskIDs[i.key]=--t;o.draw(r,n.TRIANGLES,Et.disabled,new St({func:n.ALWAYS,mask:0},e,255,n.KEEP,n.KEEP,n.REPLACE),Pt.disabled,Lt.disabled,cn(i.projMatrix),"$clipping",r.tileExtentBuffer,r.quadTriangleIndexBuffer,r.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 i=[t.x,t.y,1,1];e.aa.transformMat4(i,i,r.pixelMatrixInverse),e.aa.scale(i,i,1/i[3]),i[0]/=r.worldSize,i[1]/=r.worldSize;const n=r._camera.position,o=e.bo(1,r.center.lat),s=[n[0],n[1],n[2]/o,0],a=e.Q.subtract([],i.slice(0,3),s);e.Q.normalize(a,a);const l=this.raycast(s,a,this._exaggeration);return null!==l&&l?(e.Q.scaleAndAdd(s,s,a,l),s[3]=s[2],s[2]*=o,s):null}drawDepth(){const t=this.painter,r=t.context,i=this.proxySourceCache,n=Math.ceil(t.width),o=Math.ceil(t.height);if(!this._depthFBO||this._depthFBO.width===n&&this._depthFBO.height===o||(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),!this._depthFBO){const t=r.gl,i=r.createFramebuffer(n,o,!0,"renderbuffer");r.activeTexture.set(t.TEXTURE0);const s=new e.T(r,{width:n,height:o,data:null},t.RGBA);s.bind(t.NEAREST,t.CLAMP_TO_EDGE),i.colorAttachment.set(s.texture);const a=r.createRenderbuffer(r.gl.DEPTH_COMPONENT16,n,o);i.depthAttachment.set(a),this._depthFBO=i,this._depthTexture=s}r.bindFramebuffer.set(this._depthFBO.framebuffer),r.viewport.set([0,0,n,o]),function(e,t,r,i){if("globe"===e.transform.projection.name)return;const n=e.context,o=n.gl;n.clear({depth:1});const s=e.getOrCreateProgram("terrainDepth"),a=new Et(o.LESS,Et.ReadWrite,e.depthRangeFor3D);for(const n of i){const i=r.getTile(n),l=tn(n.projMatrix,0,[0,0,0]);t.setupElevationDraw(i,s),s.draw(e,o.TRIANGLES,a,St.disabled,Pt.unblended,Lt.backCCW,l,"terrain_depth",t.gridBuffer,t.gridIndexBuffer,t.gridNoSkirtSegments)}}(t,this,i,this.proxyCoords)}_setupProxiedCoordsForOrtho(t,r,i){if(t.getSource()instanceof e.as)return this._setupProxiedCoordsForImageSource(t,r,i);this._findCoveringTileCache[t.id]=this._findCoveringTileCache[t.id]||{};const n=this.proxiedCoords[t.id]=[],o=this.proxyCoords;for(let e=0;e<o.length;e++){const r=o[e],s=this._findTileCoveringTileID(r,t);if(s){const e=this._createProxiedId(r,s,i[r.key]&&i[r.key][t.id]);n.push(e),this.proxyToSource[r.key][t.id]=[e]}}let s=!1;const a=new Set;for(let e=0;e<r.length;e++){const o=t.getTile(r[e]);if(!o||!o.hasData())continue;const l=this._findTileCoveringTileID(o.tileID,this.proxySourceCache);if(l&&l.tileID.canonical.z!==o.tileID.canonical.z){const e=this.proxyToSource[l.tileID.key][t.id],r=this._createProxiedId(l.tileID,o,i[l.tileID.key]&&i[l.tileID.key][t.id]);e?e.splice(e.length-1,0,r):this.proxyToSource[l.tileID.key][t.id]=[r];const c=this.proxyToSource[l.tileID.key][t.id];a.has(c)||a.add(c),n.push(r),s=!0}}if(this._sourceTilesOverlap[t.id]=s,s&&this._debugParams.sortTilesHiZFirst)for(const e of a)e.sort(((e,t)=>t.overscaledZ-e.overscaledZ))}_setupProxiedCoordsForImageSource(t,r,i){if(!t.getSource().loaded())return;const n=this.proxiedCoords[t.id]=[],o=this.proxyCoords,s=t.getSource(),a=s.tileID;if(!a)return;const l=new e.P(a.x,a.y)._div(1<<a.z),c=s.coordinates.map(e.O.fromLngLat).reduce(((e,t)=>(e.min.x=Math.min(e.min.x,t.x-l.x),e.min.y=Math.min(e.min.y,t.y-l.y),e.max.x=Math.max(e.max.x,t.x-l.x),e.max.y=Math.max(e.max.y,t.y-l.y),e)),{min:new e.P(Number.MAX_VALUE,Number.MAX_VALUE),max:new e.P(-Number.MAX_VALUE,-Number.MAX_VALUE)}),u=(t,r)=>{const i=t.wrap+t.canonical.x/(1<<t.canonical.z),n=t.canonical.y/(1<<t.canonical.z),o=e.Y/(1<<t.canonical.z),s=r.wrap+r.canonical.x/(1<<r.canonical.z),a=r.canonical.y/(1<<r.canonical.z);return i+o<s+c.min.x||i>s+c.max.x||n+o<a+c.min.y||n>a+c.max.y};for(let e=0;e<o.length;e++){const s=o[e];for(let e=0;e<r.length;e++){const o=t.getTile(r[e]);if(!o||!o.hasData())continue;if(u(s,o.tileID))continue;const a=this._createProxiedId(s,o,i[s.key]&&i[s.key][t.id]),l=this.proxyToSource[s.key][t.id];l?l.push(a):this.proxyToSource[s.key][t.id]=[a],n.push(a)}}}_createProxiedId(t,r,i){let n=this.orthoMatrix;if(i){const e=i.find((e=>e.key===r.tileID.key));if(e)return e}if(r.tileID.key!==t.key){const i=t.canonical.z-r.tileID.canonical.z;let o,s,a;n=e.a9.create();const l=r.tileID.wrap-t.wrap<<t.overscaledZ;i>0?(o=e.Y>>i,s=o*((r.tileID.canonical.x<<i)-t.canonical.x+l),a=o*((r.tileID.canonical.y<<i)-t.canonical.y)):(o=e.Y<<-i,s=e.Y*(r.tileID.canonical.x-(t.canonical.x+l<<-i)),a=e.Y*(r.tileID.canonical.y-(t.canonical.y<<-i))),e.a9.ortho(n,0,o,0,o,0,1),e.a9.translate(n,n,[s,a,0])}return new pn(r.tileID,t.key,n)}_findTileCoveringTileID(t,r){let i=r.getTile(t);if(i&&i.hasData())return i;const n=this._findCoveringTileCache[r.id],o=n[t.key];if(i=o?r.getTileByID(o):null,i&&i.hasData()||null===o)return i;let s=i?i.tileID:t,a=s.overscaledZ;const l=r.getSource().minzoom,c=[];if(!o){const n=r.getSource().maxzoom;if(t.canonical.z>=n){const i=t.canonical.z-n;r.getSource().reparseOverscaled?(a=Math.max(t.canonical.z+2,r.transform.tileZoom),s=new e.ap(a,t.wrap,n,t.canonical.x>>i,t.canonical.y>>i)):0!==i&&(a=n,s=new e.ap(a,t.wrap,n,t.canonical.x>>i,t.canonical.y>>i))}s.key!==t.key&&(c.push(s.key),i=r.getTile(s))}const u=e=>{c.forEach((t=>{n[t]=e})),c.length=0};for(a-=1;a>=l&&(!i||!i.hasData());a--){i&&u(i.tileID.key);const e=s.calculateScaledKey(a);if(i=r.getTileByID(e),i&&i.hasData())break;const t=n[e];if(null===t)break;void 0===t?c.push(e):i=r.getTileByID(t)}return u(i?i.tileID.key:null),i&&i.hasData()?i:null}findDEMTileFor(e){return this.enabled?this._findTileCoveringTileID(e,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(e,t){let r=this._tilesDirty[e];r||(r=this._tilesDirty[e]={}),r[t.key]=!0}}function mn(t,r,i){const n=function(t,r,i){const n=e.Q.dot(r,t),o=e.Q.dot(i,[.2126,.7152,.0722]),s=(e,t,r)=>(1-r)*e+r*t,a=s(1-.3*Math.min(o,1),1,Math.min(n+1,1));return s(.92,1,Math.asin(e.ad(r[2],-1,1))/Math.PI+.5)*a}(t,[0,0,1],r),o=[0,0,0];e.Q.scale(o,i.slice(0,3),n);const s=[0,0,0];e.Q.scale(s,r.slice(0,3),t[2]);const a=[0,0,0];return e.Q.add(a,o,s),e.bX(a)}const An=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],gn=["stars","fillExtrusion","fillExtrusionGroundEffect","model","symbolSDF","symbolIcon","symbolTextAndIcon"];class _n{static cacheKey(e,t,r,i){let n=`${t}${i?i.cacheKey:""}`;for(const t of r)e.usedDefines.includes(t)&&(n+=`/${t}`);return n}constructor(t,r,i,n,o,s){const a=t.gl;this.program=a.createProgram(),this.configuration=n,this.name=r,this.fixedDefines=[...s];const l=n?n.getBinderAttributes():[],c=(i.staticAttributes||[]).concat(l);let u=n?n.defines():[];u=u.concat(s.map((e=>`#define ${e}`)));const h="#version 300 es\n";let d=h+u.concat("precision mediump float;",Zi,Gi.fragmentSource).join("\n");for(const e of i.fragmentIncludes)d+=`\n${Ui[e]}`;d+=`\n${i.fragmentSource}`;let p=h+u.concat("precision highp float;",Zi,Gi.vertexSource).join("\n");for(const e of i.vertexIncludes)p+=`\n${Ui[e]}`;p+=`\n${i.vertexSource}`;const f=a.createShader(a.FRAGMENT_SHADER);if(a.isContextLost())return void(this.failedToCreate=!0);a.shaderSource(f,d),a.compileShader(f),a.attachShader(this.program,f);const m=a.createShader(a.VERTEX_SHADER);if(a.isContextLost())this.failedToCreate=!0;else{a.shaderSource(m,p),a.compileShader(m),a.attachShader(this.program,m),this.attributes={},this.numAttributes=c.length;for(let e=0;e<this.numAttributes;e++)if(c[e]){const t=c[e].startsWith("a_")?c[e]:`a_${c[e]}`;a.bindAttribLocation(this.program,e,t),this.attributes[t]=e}a.linkProgram(this.program),a.deleteShader(m),a.deleteShader(f),this.fixedUniforms=o(t),this.binderUniforms=n?n.getUniforms(t):[],s.includes("TERRAIN")&&(this.terrainUniforms=(t=>({u_dem:new e.bR(t),u_dem_prev:new e.bR(t),u_dem_tl:new e.bO(t),u_dem_scale:new e.bQ(t),u_dem_tl_prev:new e.bO(t),u_dem_scale_prev:new e.bQ(t),u_dem_size:new e.bQ(t),u_dem_lerp:new e.bQ(t),u_exaggeration:new e.bQ(t),u_depth:new e.bR(t),u_depth_size_inv:new e.bO(t),u_meter_to_dem:new e.bQ(t),u_label_plane_matrix_inv:new e.bN(t)}))(t)),s.includes("GLOBE")&&(this.globeUniforms=(t=>({u_tile_tl_up:new e.bP(t),u_tile_tr_up:new e.bP(t),u_tile_br_up:new e.bP(t),u_tile_bl_up:new e.bP(t),u_tile_up_scale:new e.bQ(t)}))(t)),s.includes("FOG")&&(this.fogUniforms=(t=>({u_fog_matrix:new e.bN(t),u_fog_range:new e.bO(t),u_fog_color:new e.bS(t),u_fog_horizon_blend:new e.bQ(t),u_fog_vertical_limit:new e.bO(t),u_fog_temporal_offset:new e.bQ(t),u_frustum_tl:new e.bP(t),u_frustum_tr:new e.bP(t),u_frustum_br:new e.bP(t),u_frustum_bl:new e.bP(t),u_globe_pos:new e.bP(t),u_globe_radius:new e.bQ(t),u_globe_transition:new e.bQ(t),u_is_globe:new e.bR(t),u_viewport:new e.bO(t)}))(t)),s.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(t=>({u_cutoff_params:new e.bS(t)}))(t)),s.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(t=>({u_lighting_ambient_color:new e.bP(t),u_lighting_directional_dir:new e.bP(t),u_lighting_directional_color:new e.bP(t),u_ground_radiance:new e.bP(t)}))(t)),s.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(t=>({u_light_matrix_0:new e.bN(t),u_light_matrix_1:new e.bN(t),u_fade_range:new e.bO(t),u_shadow_normal_offset:new e.bP(t),u_shadow_intensity:new e.bQ(t),u_shadow_texel_size:new e.bQ(t),u_shadow_map_resolution:new e.bQ(t),u_shadow_direction:new e.bP(t),u_shadow_bias:new e.bP(t),u_shadowmap_0:new e.bR(t),u_shadowmap_1:new e.bR(t)}))(t))}}setTerrainUniformValues(e,t){if(!this.terrainUniforms)return;const r=this.terrainUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)r[e]&&r[e].set(this.program,e,t[e])}}setGlobeUniformValues(e,t){if(!this.globeUniforms)return;const r=this.globeUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)r[e]&&r[e].set(this.program,e,t[e])}}setFogUniformValues(e,t){if(!this.fogUniforms)return;const r=this.fogUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)r[e].set(this.program,e,t[e])}}setCutoffUniformValues(e,t){if(!this.cutoffUniforms)return;const r=this.cutoffUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)r[e].set(this.program,e,t[e])}}setLightsUniformValues(e,t){if(!this.lightsUniforms)return;const r=this.lightsUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)r[e].set(this.program,e,t[e])}}setShadowUniformValues(e,t){if(this.failedToCreate||!this.shadowUniforms)return;const r=this.shadowUniforms;e.program.set(this.program);for(const e in t)r[e].set(this.program,e,t[e])}_drawDebugWireframe(t,r,i,n,o,s,a,l,c,u){const h=t.options.wireframe;if(!1===h.terrain&&!1===h.layers2D&&!1===h.layers3D)return;const d=t.context;if(!(()=>!(!h.terrain||"terrainRaster"!==this.name&&"globeRaster"!==this.name)||!(!h.layers2D||t._terrain&&t._terrain.renderingToTexture||!An.includes(this.name))||!(!h.layers3D||!gn.includes(this.name)))())return;const p=d.gl,f=t.wireframeDebugCache.getLinesFromTrianglesBuffer(t.frameCounter,o,d);if(!f)return;const m=[...this.fixedDefines];m.push("DEBUG_WIREFRAME");const A=t.getOrCreateProgram(this.name,{config:this.configuration,defines:m});d.program.set(A.program);const g=(e,t,r)=>{if(t[e]&&r[e])for(const i in t[e])r[e][i]&&r[e][i].set(r.program,i,t[e][i].current)};c&&c.setUniforms(A.program,d,A.binderUniforms,a,{zoom:l}),g("fixedUniforms",this,A),g("terrainUniforms",this,A),g("globeUniforms",this,A),g("fogUniforms",this,A),g("lightsUniforms",this,A),g("shadowUniforms",this,A),f.bind(),d.setColorMode(new Pt([p.ONE,p.ONE_MINUS_SRC_ALPHA,p.ZERO,p.ONE],e.aA.transparent,[!0,!0,!0,!1])),d.setDepthMode(new Et(r.func===p.LESS?p.LEQUAL:r.func,Et.ReadOnly,r.range)),d.setStencilMode(St.disabled);const _=3*s.primitiveLength*2,y=3*s.primitiveOffset*2*2;u&&u>1?p.drawElementsInstanced(p.LINES,_,p.UNSIGNED_SHORT,y,u):p.drawElements(p.LINES,_,p.UNSIGNED_SHORT,y),o.bind(),d.program.set(this.program),d.setDepthMode(r),d.setStencilMode(i),d.setColorMode(n)}draw(e,t,r,i,n,o,s,a,l,c,u,h,d,p,f,m){const A=e.context,g=A.gl;if(this.failedToCreate)return;A.program.set(this.program),A.setDepthMode(r),A.setStencilMode(i),A.setColorMode(n),A.setCullFace(o);for(const e of Object.keys(this.fixedUniforms))this.fixedUniforms[e].set(this.program,e,s[e]);p&&p.setUniforms(this.program,A,this.binderUniforms,h,{zoom:d});const _={[g.POINTS]:1,[g.LINES]:2,[g.TRIANGLES]:3,[g.LINE_STRIP]:1}[t],y=m&&m>0?1:void 0;for(const o of u.get()){const s=o.vaos||(o.vaos={});(s[a]||(s[a]=new Xi)).bind(A,this,l,p?p.getPaintVertexBuffers():[],c,o.vertexOffset,f||[],y),m&&m>1?g.drawElementsInstanced(t,o.primitiveLength*_,g.UNSIGNED_SHORT,o.primitiveOffset*_*2,m):c?g.drawElements(t,o.primitiveLength*_,g.UNSIGNED_SHORT,o.primitiveOffset*_*2):g.drawArrays(t,o.vertexOffset,o.vertexLength),t===g.TRIANGLES&&c&&this._drawDebugWireframe(e,r,i,n,c,o,h,d,p,m)}}}function yn(t,r){const i=Math.pow(2,r.tileID.overscaledZ),n=r.tileSize*Math.pow(2,t.transform.tileZoom)/i,o=n*(r.tileID.canonical.x+r.tileID.wrap*i),s=n*r.tileID.canonical.y;return{u_image:0,u_texsize:r.imageAtlasTexture?r.imageAtlasTexture.size:[0,0],u_tile_units_to_pixels:1/e.a6(r,1,t.transform.tileZoom),u_pixel_coord_upper:[o>>16,s>>16],u_pixel_coord_lower:[65535&o,65535&s]}}const xn=e.a9.create(),vn=(t,r,i,n,o,s,a,l,c,u,h,d,p,f,m,A)=>{const g=r.style.light,_=g.properties.get("position"),y=[_.x,_.y,_.z],x=e.ct.create();"viewport"===g.properties.get("anchor")&&(e.ct.fromRotation(x,-r.transform.angle),e.Q.transformMat3(y,y,x));const v=g.properties.get("color"),b=r.transform,w={u_matrix:t,u_lightpos:y,u_lightintensity:g.properties.get("intensity"),u_lightcolor:[v.r,v.g,v.b],u_vertical_gradient:+i,u_opacity:n,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:xn,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_ao:o,u_edge_radius:s,u_flood_light_color:d,u_vertical_scale:p,u_flood_light_intensity:f,u_ground_shadow_factor:m,u_emissive_strength:A};return"globe"===b.projection.name&&(w.u_tile_id=[a.canonical.x,a.canonical.y,1<<a.canonical.z],w.u_zoom_transition=c,w.u_inv_rot_matrix=h,w.u_merc_center=u,w.u_up_dir=b.projection.upVector(new e.bv(0,0,0),u[0]*e.Y,u[1]*e.Y),w.u_height_lift=l),w},bn=(e,t,r)=>({u_matrix:e,u_edge_radius:t,u_vertical_scale:r}),wn=(t,r,i,n,o,s,a,l,c,u,h,d,p,f)=>{const m=vn(t,r,i,n,o,s,a,c,u,h,d,p,f,1,[0,0,0],0),A={u_height_factor:-Math.pow(2,a.overscaledZ)/l.tileSize/8};return e.e(m,yn(r,l),A)},Cn=(e,t)=>({u_matrix:e,u_emissive_strength:t}),Tn=(t,r,i,n)=>e.e(Cn(t,r),yn(i,n)),En=(e,t,r)=>({u_matrix:e,u_world:r,u_emissive_strength:t}),Mn=(t,r,i,n,o)=>e.e(Tn(t,r,i,n),{u_world:o}),Sn=(t,r,i,n)=>{const o=e.Y/i.tileSize;return{u_matrix:t,u_camera_to_center_distance:r.getCameraToCenterDistance(n),u_extrude_scale:[r.pixelsToGLUnits[0]/o,r.pixelsToGLUnits[1]/o]}},In=(e,t,r=1)=>({u_matrix:e,u_color:t,u_overlay:0,u_overlay_scale:r}),Pn=e.a9.create(),Dn=(t,r,i,n,o,s,a)=>{const l=t.transform,c="globe"===l.projection.name,u=c?e.cu(l.zoom,r.canonical)*l._pixelsPerMercatorPixel:e.a6(i,1,s),h={u_matrix:r.projMatrix,u_extrude_scale:u,u_intensity:a,u_inv_rot_matrix:Pn,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(c){h.u_inv_rot_matrix=n,h.u_merc_center=o,h.u_tile_id=[r.canonical.x,r.canonical.y,1<<r.canonical.z],h.u_zoom_transition=e.W(l.zoom);const t=o[0]*e.Y,i=o[1]*e.Y;h.u_up_dir=l.projection.upVector(new e.bv(0,0,0),t,i)}return h};function kn(e,[t,r,i,n],[o,s]){if(o===s)return[0,0,0,0];const a=255*(e-1)/(e*(s-o));return[t*a,r*a,i*a,n*a]}function Ln(e,t,[r,i]){return r===i?0:.5/e+(t-r)*(e-1)/(e*(i-r))}const zn=(t,r,i,n,o,s,a,l,c,u,h,d,p,f,m,A,g,_,y,x,v)=>({u_matrix:t,u_normalize_matrix:r,u_globe_matrix:i,u_merc_matrix:n,u_grid_matrix:o,u_tl_parent:s,u_scale_parent:u,u_fade_t:h.mix,u_opacity:h.opacity*d.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:d.paint.get("raster-brightness-min"),u_brightness_high:d.paint.get("raster-brightness-max"),u_saturation_factor:e.cv(d.paint.get("raster-saturation")),u_contrast_factor:e.cw(d.paint.get("raster-contrast")),u_spin_weights:On(d.paint.get("raster-hue-rotate")),u_perspective_transform:p,u_raster_elevation:f,u_zoom_transition:a,u_merc_center:l,u_cutoff_params:c,u_colorization_mix:kn(e.cx,A,_),u_colorization_offset:Ln(e.cx,g,_),u_color_ramp:m,u_texture_offset:[x/(y+2*x),y/(y+2*x)],u_texture_res:[y+2*x,y+2*x],u_emissive_strength:v});function On(e){e*=Math.PI/180;const t=Math.sin(e),r=Math.cos(e);return[(2*r+1)/3,(-Math.sqrt(3)*t-r+1)/3,(Math.sqrt(3)*t-r+1)/3]}const Bn=(e,t,r,i,n,o,s,a,l,c,u,h)=>({u_matrix:e,u_normalize_matrix:t,u_globe_matrix:r,u_merc_matrix:i,u_grid_matrix:n,u_tl_parent:o,u_scale_parent:c,u_fade_t:u.mix,u_opacity:u.opacity,u_image0:0,u_image1:1,u_raster_elevation:h,u_zoom_transition:s,u_merc_center:a,u_cutoff_params:l}),Rn=(e,t,r,i,n,o,s,a,l,c)=>({u_particle_texture:e,u_particle_texture_side_len:t,u_tile_offset:r,u_velocity:i,u_color_ramp:o,u_velocity_res:n,u_max_speed:s,u_uv_offset:a,u_data_scale:l,u_data_offset:c,u_particle_pos_scale:1.3,u_particle_pos_offset:[Bt,Bt]}),Fn=(e,t,r,i,n,o,s,a,l,c)=>({u_particle_texture:e,u_particle_texture_side_len:t,u_velocity:r,u_velocity_res:i,u_max_speed:n,u_speed_factor:o,u_reset_rate:s,u_rand_seed:Math.random(),u_uv_offset:a,u_data_scale:l,u_data_offset:c,u_particle_pos_scale:1.3,u_particle_pos_offset:[Bt,Bt]}),jn=e.a9.create(),Vn=(t,r,i,n,o,s,a,l,c,u,h,d,p,f,m,A,g,_)=>{const y=o.transform,x={u_is_size_zoom_constant:+("constant"===t||"source"===t),u_is_size_feature_constant:+("constant"===t||"camera"===t),u_size_t:r?r.uSizeT:0,u_size:r?r.uSize:0,u_camera_to_center_distance:y.getCameraToCenterDistance(A),u_rotate_symbol:+i,u_aspect_ratio:y.width/y.height,u_fade_change:o.options.fadeDuration?o.symbolFadeChange:1,u_matrix:s,u_label_plane_matrix:a,u_coord_matrix:l,u_is_text:+c,u_pitch_with_map:+n,u_texsize:u,u_texture:0,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:jn,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:jn,u_up_vector:[0,-1,0],u_color_adj_mat:g,u_icon_transition:_||0};return"globe"===A.name&&(x.u_tile_id=[h.canonical.x,h.canonical.y,1<<h.canonical.z],x.u_zoom_transition=d,x.u_inv_rot_matrix=f,x.u_merc_center=p,x.u_camera_forward=y._camera.forward(),x.u_ecef_origin=e.cy(y.globeMatrix,h.toUnwrapped()),x.u_tile_matrix=Float32Array.from(y.globeMatrix),x.u_up_vector=m),x},Nn=(t,r,i,n,o,s,a,l,c,u,h,d,p,f,m,A,g)=>e.e(Vn(t,r,i,n,o,s,a,l,c,u,d,p,f,m,A,g),{u_gamma_scale:n?o.transform.getCameraToCenterDistance(g)*Math.cos(o.terrain?0:o.transform._pitch):1,u_device_pixel_ratio:e.f.devicePixelRatio,u_is_halo:+h,undefined:void 0}),Un=(t,r,i,n,o,s,a,l,c,u,h,d,p,f,m,A)=>e.e(Nn(t,r,i,n,o,s,a,l,!0,c,!0,h,d,p,f,m,A),{u_texsize_icon:u,u_texture_icon:1}),Hn=(e,t,r,i)=>({u_matrix:e,u_emissive_strength:t,u_opacity:r,u_color:i}),Gn=(t,r,i,n,o,s,a)=>e.e(function(t,r,i,n){const o=i.imageManager.getPattern(t.toString(),r),{width:s,height:a}=i.imageManager.getPixelSize(r),l=Math.pow(2,n.tileID.overscaledZ),c=n.tileSize*Math.pow(2,i.transform.tileZoom)/l,u=c*(n.tileID.canonical.x+n.tileID.wrap*l),h=c*n.tileID.canonical.y;return{u_image:0,u_pattern_tl:o.tl,u_pattern_br:o.br,u_texsize:[s,a],u_pattern_size:o.displaySize,u_tile_units_to_pixels:1/e.a6(n,1,i.transform.tileZoom),u_pixel_coord_upper:[u>>16,h>>16],u_pixel_coord_lower:[65535&u,65535&h]}}(o,s,n,a),{u_matrix:t,u_emissive_strength:r,u_opacity:i}),Zn=new Float32Array(e.a9.identity([])),Wn=(t,r,i,n,o,s,a,l,c,u,h,d,p,f=[0,0,0],m)=>{const A=o.style.light,g=A.properties.get("position"),_=[-g.x,-g.y,g.z],y=e.ct.create();"viewport"===A.properties.get("anchor")&&(e.ct.fromRotation(y,-o.transform.angle),e.Q.transformMat3(_,_,y));const x="MASK"===h.alphaMode,v=A.properties.get("color"),b=p.paint.get("model-ambient-occlusion-intensity"),w=p.paint.get("model-color").constantOr(e.aA.white),C=p.paint.get("model-color-mix-intensity").constantOr(0);return{u_matrix:t,u_lighting_matrix:r,u_normal_matrix:i,u_node_matrix:n||Zn,u_lightpos:_,u_lightintensity:A.properties.get("intensity"),u_lightcolor:[v.r,v.g,v.b],u_camera_pos:f,u_opacity:s,u_baseTextureIsAlpha:0,u_alphaMask:+x,u_alphaCutoff:h.alphaCutoff,u_baseColorFactor:[a.r,a.g,a.b,a.a],u_emissiveFactor:[l[0],l[1],l[2],1],u_metallicFactor:c,u_roughnessFactor:u,u_baseColorTexture:fi.BaseColor,u_metallicRoughnessTexture:fi.MetallicRoughness,u_normalTexture:fi.Normal,u_occlusionTexture:fi.Occlusion,u_emissionTexture:fi.Emission,u_color_mix:[w.r,w.g,w.b,C],u_aoIntensity:b,u_emissive_strength:d,u_occlusionTextureTransform:m||[0,0,0,0]}},Qn=(e,t=Zn,r=Zn)=>({u_matrix:e,u_instance:t,u_node_matrix:r}),qn={fillExtrusion:t=>({u_matrix:new e.bN(t),u_lightpos:new e.bP(t),u_lightintensity:new e.bQ(t),u_lightcolor:new e.bP(t),u_vertical_gradient:new e.bQ(t),u_opacity:new e.bQ(t),u_edge_radius:new e.bQ(t),u_ao:new e.bO(t),u_tile_id:new e.bP(t),u_zoom_transition:new e.bQ(t),u_inv_rot_matrix:new e.bN(t),u_merc_center:new e.bO(t),u_up_dir:new e.bP(t),u_height_lift:new e.bQ(t),u_flood_light_color:new e.bP(t),u_vertical_scale:new e.bQ(t),u_flood_light_intensity:new e.bQ(t),u_ground_shadow_factor:new e.bP(t),u_emissive_strength:new e.bQ(t)}),fillExtrusionDepth:t=>({u_matrix:new e.bN(t),u_edge_radius:new e.bQ(t),u_vertical_scale:new e.bQ(t)}),fillExtrusionPattern:t=>({u_matrix:new e.bN(t),u_lightpos:new e.bP(t),u_lightintensity:new e.bQ(t),u_lightcolor:new e.bP(t),u_vertical_gradient:new e.bQ(t),u_height_factor:new e.bQ(t),u_edge_radius:new e.bQ(t),u_ao:new e.bO(t),u_tile_id:new e.bP(t),u_zoom_transition:new e.bQ(t),u_inv_rot_matrix:new e.bN(t),u_merc_center:new e.bO(t),u_up_dir:new e.bP(t),u_height_lift:new e.bQ(t),u_image:new e.bR(t),u_texsize:new e.bO(t),u_pixel_coord_upper:new e.bO(t),u_pixel_coord_lower:new e.bO(t),u_tile_units_to_pixels:new e.bQ(t),u_opacity:new e.bQ(t)}),fillExtrusionGroundEffect:t=>({u_matrix:new e.bN(t),u_opacity:new e.bQ(t),u_ao_pass:new e.bQ(t),u_meter_to_tile:new e.bQ(t),u_ao:new e.bO(t),u_flood_light_intensity:new e.bQ(t),u_flood_light_color:new e.bP(t),u_attenuation:new e.bQ(t),u_edge_radius:new e.bQ(t),u_fb:new e.bR(t),u_fb_size:new e.bQ(t)}),fill:t=>({u_matrix:new e.bN(t),u_emissive_strength:new e.bQ(t)}),fillPattern:t=>({u_matrix:new e.bN(t),u_emissive_strength:new e.bQ(t),u_image:new e.bR(t),u_texsize:new e.bO(t),u_pixel_coord_upper:new e.bO(t),u_pixel_coord_lower:new e.bO(t),u_tile_units_to_pixels:new e.bQ(t)}),fillOutline:t=>({u_matrix:new e.bN(t),u_emissive_strength:new e.bQ(t),u_world:new e.bO(t)}),fillOutlinePattern:t=>({u_matrix:new e.bN(t),u_emissive_strength:new e.bQ(t),u_world:new e.bO(t),u_image:new e.bR(t),u_texsize:new e.bO(t),u_pixel_coord_upper:new e.bO(t),u_pixel_coord_lower:new e.bO(t),u_tile_units_to_pixels:new e.bQ(t)}),circle:e.cz,collisionBox:t=>({u_matrix:new e.bN(t),u_camera_to_center_distance:new e.bQ(t),u_extrude_scale:new e.bO(t)}),collisionCircle:t=>({u_matrix:new e.bN(t),u_inv_matrix:new e.bN(t),u_camera_to_center_distance:new e.bQ(t),u_viewport_size:new e.bO(t)}),debug:t=>({u_color:new e.cf(t),u_matrix:new e.bN(t),u_overlay:new e.bR(t),u_overlay_scale:new e.bQ(t)}),clippingMask:t=>({u_matrix:new e.bN(t)}),heatmap:t=>({u_extrude_scale:new e.bQ(t),u_intensity:new e.bQ(t),u_matrix:new e.bN(t),u_inv_rot_matrix:new e.bN(t),u_merc_center:new e.bO(t),u_tile_id:new e.bP(t),u_zoom_transition:new e.bQ(t),u_up_dir:new e.bP(t)}),heatmapTexture:t=>({u_image:new e.bR(t),u_color_ramp:new e.bR(t),u_opacity:new e.bQ(t)}),hillshade:t=>({u_matrix:new e.bN(t),u_image:new e.bR(t),u_latrange:new e.bO(t),u_light:new e.bO(t),u_shadow:new e.cf(t),u_highlight:new e.cf(t),u_emissive_strength:new e.bQ(t),u_accent:new e.cf(t)}),hillshadePrepare:t=>({u_matrix:new e.bN(t),u_image:new e.bR(t),u_dimension:new e.bO(t),u_zoom:new e.bQ(t)}),line:e.cA,linePattern:e.cB,raster:t=>({u_matrix:new e.bN(t),u_normalize_matrix:new e.bN(t),u_globe_matrix:new e.bN(t),u_merc_matrix:new e.bN(t),u_grid_matrix:new e.cg(t),u_tl_parent:new e.bO(t),u_scale_parent:new e.bQ(t),u_fade_t:new e.bQ(t),u_opacity:new e.bQ(t),u_image0:new e.bR(t),u_image1:new e.bR(t),u_brightness_low:new e.bQ(t),u_brightness_high:new e.bQ(t),u_saturation_factor:new e.bQ(t),u_contrast_factor:new e.bQ(t),u_spin_weights:new e.bP(t),u_perspective_transform:new e.bO(t),u_raster_elevation:new e.bQ(t),u_zoom_transition:new e.bQ(t),u_merc_center:new e.bO(t),u_cutoff_params:new e.bS(t),u_colorization_mix:new e.bS(t),u_colorization_offset:new e.bQ(t),u_color_ramp:new e.bR(t),u_texture_offset:new e.bO(t),u_texture_res:new e.bO(t),u_emissive_strength:new e.bQ(t)}),rasterParticle:t=>({u_matrix:new e.bN(t),u_normalize_matrix:new e.bN(t),u_globe_matrix:new e.bN(t),u_merc_matrix:new e.bN(t),u_grid_matrix:new e.cg(t),u_tl_parent:new e.bO(t),u_scale_parent:new e.bQ(t),u_fade_t:new e.bQ(t),u_opacity:new e.bQ(t),u_image0:new e.bR(t),u_image1:new e.bR(t),u_raster_elevation:new e.bQ(t),u_zoom_transition:new e.bQ(t),u_merc_center:new e.bO(t),u_cutoff_params:new e.bS(t)}),rasterParticleTexture:t=>({u_texture:new e.bR(t),u_opacity:new e.bQ(t)}),rasterParticleDraw:t=>({u_particle_texture:new e.bR(t),u_particle_texture_side_len:new e.bQ(t),u_tile_offset:new e.bO(t),u_velocity:new e.bR(t),u_color_ramp:new e.bR(t),u_velocity_res:new e.bO(t),u_max_speed:new e.bQ(t),u_uv_offset:new e.bO(t),u_data_scale:new e.bS(t),u_data_offset:new e.bQ(t),u_particle_pos_scale:new e.bQ(t),u_particle_pos_offset:new e.bO(t)}),rasterParticleUpdate:t=>({u_particle_texture:new e.bR(t),u_particle_texture_side_len:new e.bQ(t),u_velocity:new e.bR(t),u_velocity_res:new e.bO(t),u_max_speed:new e.bQ(t),u_speed_factor:new e.bQ(t),u_reset_rate:new e.bQ(t),u_rand_seed:new e.bQ(t),u_uv_offset:new e.bO(t),u_data_scale:new e.bS(t),u_data_offset:new e.bQ(t),u_particle_pos_scale:new e.bQ(t),u_particle_pos_offset:new e.bO(t)}),symbolIcon:t=>({u_is_size_zoom_constant:new e.bR(t),u_is_size_feature_constant:new e.bR(t),u_size_t:new e.bQ(t),u_size:new e.bQ(t),u_camera_to_center_distance:new e.bQ(t),u_rotate_symbol:new e.bR(t),u_aspect_ratio:new e.bQ(t),u_fade_change:new e.bQ(t),u_matrix:new e.bN(t),u_label_plane_matrix:new e.bN(t),u_coord_matrix:new e.bN(t),u_is_text:new e.bR(t),u_pitch_with_map:new e.bR(t),u_texsize:new e.bO(t),u_tile_id:new e.bP(t),u_zoom_transition:new e.bQ(t),u_inv_rot_matrix:new e.bN(t),u_merc_center:new e.bO(t),u_camera_forward:new e.bP(t),u_tile_matrix:new e.bN(t),u_up_vector:new e.bP(t),u_ecef_origin:new e.bP(t),u_texture:new e.bR(t),u_icon_transition:new e.bQ(t),u_color_adj_mat:new e.bN(t)}),symbolSDF:t=>({u_is_size_zoom_constant:new e.bR(t),u_is_size_feature_constant:new e.bR(t),u_size_t:new e.bQ(t),u_size:new e.bQ(t),u_camera_to_center_distance:new e.bQ(t),u_rotate_symbol:new e.bR(t),u_aspect_ratio:new e.bQ(t),u_fade_change:new e.bQ(t),u_matrix:new e.bN(t),u_label_plane_matrix:new e.bN(t),u_coord_matrix:new e.bN(t),u_is_text:new e.bR(t),u_pitch_with_map:new e.bR(t),u_texsize:new e.bO(t),u_texture:new e.bR(t),u_gamma_scale:new e.bQ(t),u_device_pixel_ratio:new e.bQ(t),u_tile_id:new e.bP(t),u_zoom_transition:new e.bQ(t),u_inv_rot_matrix:new e.bN(t),u_merc_center:new e.bO(t),u_camera_forward:new e.bP(t),u_tile_matrix:new e.bN(t),u_up_vector:new e.bP(t),u_ecef_origin:new e.bP(t),u_is_halo:new e.bR(t)}),symbolTextAndIcon:t=>({u_is_size_zoom_constant:new e.bR(t),u_is_size_feature_constant:new e.bR(t),u_size_t:new e.bQ(t),u_size:new e.bQ(t),u_camera_to_center_distance:new e.bQ(t),u_rotate_symbol:new e.bR(t),u_aspect_ratio:new e.bQ(t),u_fade_change:new e.bQ(t),u_matrix:new e.bN(t),u_label_plane_matrix:new e.bN(t),u_coord_matrix:new e.bN(t),u_is_text:new e.bR(t),u_pitch_with_map:new e.bR(t),u_texsize:new e.bO(t),u_texsize_icon:new e.bO(t),u_texture:new e.bR(t),u_texture_icon:new e.bR(t),u_gamma_scale:new e.bQ(t),u_device_pixel_ratio:new e.bQ(t),u_is_halo:new e.bR(t)}),background:t=>({u_matrix:new e.bN(t),u_emissive_strength:new e.bQ(t),u_opacity:new e.bQ(t),u_color:new e.cf(t)}),backgroundPattern:t=>({u_matrix:new e.bN(t),u_emissive_strength:new e.bQ(t),u_opacity:new e.bQ(t),u_image:new e.bR(t),u_pattern_tl:new e.bO(t),u_pattern_br:new e.bO(t),u_texsize:new e.bO(t),u_pattern_size:new e.bO(t),u_pixel_coord_upper:new e.bO(t),u_pixel_coord_lower:new e.bO(t),u_tile_units_to_pixels:new e.bQ(t)}),terrainRaster:en,terrainDepth:en,skybox:t=>({u_matrix:new e.bN(t),u_sun_direction:new e.bP(t),u_cubemap:new e.bR(t),u_opacity:new e.bQ(t),u_temporal_offset:new e.bQ(t)}),skyboxGradient:t=>({u_matrix:new e.bN(t),u_color_ramp:new e.bR(t),u_center_direction:new e.bP(t),u_radius:new e.bQ(t),u_opacity:new e.bQ(t),u_temporal_offset:new e.bQ(t)}),skyboxCapture:t=>({u_matrix_3f:new e.cg(t),u_sun_direction:new e.bP(t),u_sun_intensity:new e.bQ(t),u_color_tint_r:new e.bS(t),u_color_tint_m:new e.bS(t),u_luminance:new e.bQ(t)}),globeRaster:t=>({u_proj_matrix:new e.bN(t),u_globe_matrix:new e.bN(t),u_normalize_matrix:new e.bN(t),u_merc_matrix:new e.bN(t),u_zoom_transition:new e.bQ(t),u_merc_center:new e.bO(t),u_image0:new e.bR(t),u_grid_matrix:new e.cg(t),u_skirt_height:new e.bQ(t),u_far_z_cutoff:new e.bQ(t),u_frustum_tl:new e.bP(t),u_frustum_tr:new e.bP(t),u_frustum_br:new e.bP(t),u_frustum_bl:new e.bP(t),u_globe_pos:new e.bP(t),u_globe_radius:new e.bQ(t),u_viewport:new e.bO(t)}),globeAtmosphere:t=>({u_frustum_tl:new e.bP(t),u_frustum_tr:new e.bP(t),u_frustum_br:new e.bP(t),u_frustum_bl:new e.bP(t),u_horizon:new e.bQ(t),u_transition:new e.bQ(t),u_fadeout_range:new e.bQ(t),u_color:new e.bS(t),u_high_color:new e.bS(t),u_space_color:new e.bS(t),u_temporal_offset:new e.bQ(t),u_horizon_angle:new e.bQ(t)}),model:t=>({u_matrix:new e.bN(t),u_lighting_matrix:new e.bN(t),u_normal_matrix:new e.bN(t),u_node_matrix:new e.bN(t),u_lightpos:new e.bP(t),u_lightintensity:new e.bQ(t),u_lightcolor:new e.bP(t),u_camera_pos:new e.bP(t),u_opacity:new e.bQ(t),u_baseColorFactor:new e.bS(t),u_emissiveFactor:new e.bS(t),u_metallicFactor:new e.bQ(t),u_roughnessFactor:new e.bQ(t),u_baseTextureIsAlpha:new e.bR(t),u_alphaMask:new e.bR(t),u_alphaCutoff:new e.bQ(t),u_baseColorTexture:new e.bR(t),u_metallicRoughnessTexture:new e.bR(t),u_normalTexture:new e.bR(t),u_occlusionTexture:new e.bR(t),u_emissionTexture:new e.bR(t),u_color_mix:new e.bS(t),u_aoIntensity:new e.bQ(t),u_emissive_strength:new e.bQ(t),u_occlusionTextureTransform:new e.bS(t)}),modelDepth:t=>({u_matrix:new e.bN(t),u_instance:new e.bN(t),u_node_matrix:new e.bN(t)}),groundShadow:t=>({u_matrix:new e.bN(t),u_ground_shadow_factor:new e.bP(t)}),stars:t=>({u_matrix:new e.bN(t),u_up:new e.bP(t),u_right:new e.bP(t),u_intensity_multiplier:new e.bQ(t)})};let Xn;function Yn(t,r,i,n,o,s,a){const l=t.context,c=l.gl,u=t.transform,h=t.getOrCreateProgram("collisionBox"),d=[];let p=0,f=0;for(let l=0;l<n.length;l++){const m=n[l],A=r.getTile(m),g=A.getBucket(i);if(!g)continue;const _=Dr(m,g,u);let y=_;0===o[0]&&0===o[1]||(y=t.translatePosMatrix(_,A,o,s));const x=a?g.textCollisionBox:g.iconCollisionBox,v=g.collisionCircleArray;if(v.length>0){const t=e.a9.create(),r=y;e.a9.mul(t,g.placementInvProjMatrix,u.glCoordMatrix),e.a9.mul(t,t,g.placementViewportMatrix),d.push({circleArray:v,circleOffset:f,transform:r,invTransform:t,projection:g.getProjection()}),p+=v.length/4,f=p}x&&(t.terrain&&t.terrain.setupElevationDraw(A,h),h.draw(t,c.LINES,Et.disabled,St.disabled,t.colorModeForRenderPass(),Lt.disabled,Sn(y,u,A,g.getProjection()),i.id,x.layoutVertexBuffer,x.indexBuffer,x.segments,null,u.zoom,null,[x.collisionVertexBuffer,x.collisionVertexBufferExt]))}if(!a||!d.length)return;const m=t.getOrCreateProgram("collisionCircle"),A=new e.cC;A.resize(4*p),A._trim();let g=0;for(const e of d)for(let t=0;t<e.circleArray.length/4;t++){const r=4*t,i=e.circleArray[r+0],n=e.circleArray[r+1],o=e.circleArray[r+2],s=e.circleArray[r+3];A.emplace(g++,i,n,o,s,0),A.emplace(g++,i,n,o,s,1),A.emplace(g++,i,n,o,s,2),A.emplace(g++,i,n,o,s,3)}(!Xn||Xn.length<2*p)&&(Xn=function(t){const r=2*t,i=new e.az;i.resize(r),i._trim();for(let e=0;e<r;e++){const t=6*e;i.uint16[t+0]=4*e+0,i.uint16[t+1]=4*e+1,i.uint16[t+2]=4*e+2,i.uint16[t+3]=4*e+2,i.uint16[t+4]=4*e+3,i.uint16[t+5]=4*e+0}return i}(p));const _=l.createIndexBuffer(Xn,!0),y=l.createVertexBuffer(A,e.cD.members,!0);for(const r of d){const n={u_matrix:r.transform,u_inv_matrix:r.invTransform,u_camera_to_center_distance:(x=u).getCameraToCenterDistance(r.projection),u_viewport_size:[x.width,x.height]};m.draw(t,c.TRIANGLES,Et.disabled,St.disabled,t.colorModeForRenderPass(),Lt.disabled,n,i.id,y,_,e.aE.simpleSegment(0,2*r.circleOffset,r.circleArray.length,r.circleArray.length/2),null,u.zoom)}var x;y.destroy(),_.destroy()}const $n=e.a9.create();function Kn(t){const r=t._camera.getWorldToCamera(t.worldSize,1),i=e.a9.multiply([],r,t.globeMatrix);e.a9.invert(i,i);const n=[0,0,0],o=[0,1,0,0];return e.aa.transformMat4(o,o,i),n[0]=o[0],n[1]=o[1],n[2]=o[2],e.Q.normalize(n,n),n}function Jn({width:t,height:r,anchor:i,textOffset:n,textScale:o},s){const{horizontalAlign:a,verticalAlign:l}=e.bi(i),c=-(a-.5)*t,u=-(l-.5)*r,h=e.bh(i,n);return new e.P((c/o+h[0])*s,(u/o+h[1])*s)}function eo(t,r,i,n,o,s,a,l,c,u,h){const d=t.text.placedSymbolArray,p=t.text.dynamicLayoutVertexArray,f=t.icon.dynamicLayoutVertexArray,m={},A=t.getProjection(),g=kr(l,A,s),_=s.elevation,y=A.upVectorScale(l.canonical,s.center.lat,s.worldSize).metersToTile;p.clear();for(let f=0;f<d.length;f++){const x=d.get(f),{tileAnchorX:v,tileAnchorY:b,numGlyphs:w}=x,C=x.hidden||!x.crossTileID||t.allowVerticalPlacement&&!x.placedOrientation?null:n[x.crossTileID];if(C){let n=0,d=0,f=0;if(_){const e=_?_.getAtTileOffset(l,v,b):0,[t,r,i]=A.upVector(l.canonical,v,b);n=e*t*y,d=e*r*y,f=e*i*y}let[T,E,M,S]=Ar(x.projectedAnchorX+n,x.projectedAnchorY+d,x.projectedAnchorZ+f,i?g:a);const I=gr(s.getCameraToCenterDistance(A),S);let P=o.evaluateSizeForFeature(t.textSizeData,u,x)*I/e.bf;i&&(P*=t.tilePixelRatio/c);const D=Jn(C,P);i?(({x:T,y:E,z:M}=A.projectTilePoint(v+D.x,b+D.y,l.canonical)),[T,E,M]=Ar(T+n,E+d,M+f,a)):(r&&D._rotate(-s.angle),T+=D.x,E+=D.y,M=0);const k=t.allowVerticalPlacement&&x.placedOrientation===e.b9.vertical?Math.PI/2:0;for(let t=0;t<w;t++)e.bc(p,T,E,M,k);h&&x.associatedIconIndex>=0&&(m[x.associatedIconIndex]={x:T,y:E,z:M,angle:k})}else Er(w,p)}if(h){f.clear();const r=t.icon.placedSymbolArray;for(let t=0;t<r.length;t++){const i=r.get(t),{numGlyphs:n}=i,o=m[t];if(i.hidden||!o)Er(n,f);else{const{x:t,y:r,z:i,angle:s}=o;for(let o=0;o<n;o++)e.bc(f,t,r,i,s)}}t.icon.dynamicLayoutVertexBuffer.updateData(f)}t.text.dynamicLayoutVertexBuffer.updateData(p)}function to(t,r,i,n,o,s,a={}){const l=i.paint.get("icon-translate"),c=i.paint.get("text-translate"),u=i.paint.get("icon-translate-anchor"),h=i.paint.get("text-translate-anchor"),d=i.layout.get("icon-rotation-alignment"),p=i.layout.get("text-rotation-alignment"),f=i.layout.get("icon-pitch-alignment"),m=i.layout.get("text-pitch-alignment"),A=i.layout.get("icon-keep-upright"),g=i.layout.get("text-keep-upright"),_=i.paint.get("icon-color-saturation"),y=i.paint.get("icon-color-contrast"),x=i.paint.get("icon-color-brightness-min"),v=i.paint.get("icon-color-brightness-max"),b=t.context,w=b.gl,C=t.transform,T="map"===d,E="map"===p,M="map"===f,S="map"===m,I=void 0!==i.layout.get("symbol-sort-key").constantOr(1);let P=!1;const D=t.depthModeForSublayer(0,Et.ReadOnly),k=[e.a8(C.center.lng),e.ah(C.center.lat)],L=i.layout.get("text-variable-anchor"),z="globe"===C.projection.name,O=[],B=[0,-1,0];for(const o of n){const n=r.getTile(o),s=n.getBucket(i);if(!s)continue;if("mercator"===s.projection.name&&z)continue;if(s.fullyClipped)continue;const d="globe"===s.projection.name,p=d?e.W(C.zoom):0,f=kr(o,s.getProjection(),C),m=C.calculatePixelsToTileUnitsMatrix(n),b=L&&s.hasTextData(),D=s.hasIconTextFit()&&b&&s.hasIconData(),R=s.getProjection().createInversionMatrix(C,o.canonical),F=()=>{const r=T&&"point"!==i.layout.get("symbol-placement"),a=[],c=r||D,h=i.paint.get("icon-image-cross-fade").constantOr(0);t.terrainRenderModeElevated()&&M&&a.push("PITCH_WITH_MAP_TERRAIN"),d&&(a.push("PROJECTION_GLOBE_VIEW"),c&&a.push("PROJECTED_POS_ON_VIEWPORT")),h>0&&a.push("ICON_TRANSITION"),s.icon.zOffsetVertexBuffer&&a.push("Z_OFFSET"),0===_&&0===y&&0===x&&1===v||a.push("COLOR_ADJUSTMENT");const g=s.icon.programConfigurations.get(i.id),b=t.getOrCreateProgram(s.sdfIcons?"symbolSDF":"symbolIcon",{config:g,defines:a});let E;const S=n.imageAtlasTexture?n.imageAtlasTexture.size:[0,0],I=s.iconSizeData,P=e.b8(I,C.zoom),L=M||0!==C.pitch,O=pr(f,n.tileID.canonical,M,T,C,s.getProjection(),m),F=mr(f,n.tileID.canonical,M,T,C,s.getProjection(),m),j=t.translatePosMatrix(F,n,l,u,!0),V=t.translatePosMatrix(f,n,l,u),N=c?$n:O,U=T&&!M&&!r;let H=B;!z&&!C.mercatorFromTransition||T||(H=Kn(C));const G=d?H:B;if(s.sdfIcons&&!s.iconsInText)E=Nn(I.kind,P,U,M,t,V,N,j,!1,S,!0,o,p,k,R,G,s.getProjection());else{const e=i.getColorAdjustmentMatrix(_,y,x,v);E=Vn(I.kind,P,U,M,t,V,N,j,!1,S,o,p,k,R,G,s.getProjection(),e,h)}const Z=n.imageAtlasTexture?n.imageAtlasTexture:null,W=1!==i.layout.get("icon-size").constantOr(0)||s.iconsNeedLinear,Q=s.sdfIcons||t.options.rotating||t.options.zooming||W||L?w.LINEAR:w.NEAREST,q=s.sdfIcons&&0!==i.paint.get("icon-halo-width").constantOr(1),X=t.terrain&&M&&r?e.a9.invert(e.a9.create(),O):$n;if(r&&s.icon){const e=C.elevation,r=e?e.getAtTileOffsetFunc(o,C.center.lat,C.worldSize,s.getProjection()):null,i=fr(f,n.tileID.canonical,M,T,C,s.getProjection(),m);yr(s,f,t,!1,i,F,M,A,r,o)}return{program:b,buffers:s.icon,uniformValues:E,atlasTexture:Z,atlasTextureIcon:null,atlasInterpolation:Q,atlasInterpolationIcon:null,isSDF:s.sdfIcons,hasHalo:q,tile:n,labelPlaneMatrixInv:X}},j=()=>{const r=E&&"point"!==i.layout.get("symbol-placement"),a=[],l=r||L||D;t.terrainRenderModeElevated()&&S&&a.push("PITCH_WITH_MAP_TERRAIN"),d&&(a.push("PROJECTION_GLOBE_VIEW"),l&&a.push("PROJECTED_POS_ON_VIEWPORT")),s.text.zOffsetVertexBuffer&&a.push("Z_OFFSET");const u=s.text.programConfigurations.get(i.id),A=t.getOrCreateProgram(s.iconsInText?"symbolTextAndIcon":"symbolSDF",{config:u,defines:a});let _,y=[0,0],x=null;const v=s.textSizeData;s.iconsInText&&(y=n.imageAtlasTexture?n.imageAtlasTexture.size:[0,0],x=n.imageAtlasTexture?n.imageAtlasTexture:null,_=S||0!==C.pitch||t.options.rotating||t.options.zooming||"composite"===v.kind||"camera"===v.kind?w.LINEAR:w.NEAREST);const b=n.glyphAtlasTexture?n.glyphAtlasTexture.size:[0,0],T=e.b8(v,C.zoom),M=pr(f,n.tileID.canonical,S,E,C,s.getProjection(),m),I=mr(f,n.tileID.canonical,S,E,C,s.getProjection(),m),P=t.translatePosMatrix(I,n,c,h,!0),O=t.translatePosMatrix(f,n,c,h),F=l?$n:M,j=E&&!S&&!r;let V=B;!z&&!C.mercatorFromTransition||E||(V=Kn(C));const N=d?V:B;let U;U=s.iconsInText?Un(v.kind,T,j,S,t,O,F,P,b,y,o,p,k,R,N,s.getProjection()):Nn(v.kind,T,j,S,t,O,F,P,!0,b,!0,o,p,k,R,N,s.getProjection());const H=n.glyphAtlasTexture?n.glyphAtlasTexture:null,G=w.LINEAR,Z=0!==i.paint.get("text-halo-width").constantOr(1),W=t.terrain&&S&&r?e.a9.invert(e.a9.create(),M):$n;if(r&&s.text){const e=C.elevation,r=e?e.getAtTileOffsetFunc(o,C.center.lat,C.worldSize,s.getProjection()):null,i=fr(f,n.tileID.canonical,S,E,C,s.getProjection(),m);yr(s,f,t,!0,i,I,S,g,r,o)}return{program:A,buffers:s.text,uniformValues:U,atlasTexture:H,atlasTextureIcon:x,atlasInterpolation:G,atlasInterpolationIcon:_,isSDF:!0,hasHalo:Z,tile:n,labelPlaneMatrixInv:W}},V=s.icon.segments.get().length,N=s.text.segments.get().length,U=V&&!a.onlyText?F():null,H=N&&!a.onlyIcons?j():null,G=i.paint.get("icon-opacity").constantOr(1),Z=i.paint.get("text-opacity").constantOr(1);if(I&&s.canOverlap){P=!0;const t=G&&!a.onlyText?s.icon.segments.get():[],r=Z&&!a.onlyIcons?s.text.segments.get():[];for(const r of t)O.push({segments:new e.aE([r]),sortKey:r.sortKey,state:U});for(const t of r)O.push({segments:new e.aE([t]),sortKey:t.sortKey,state:H})}else a.onlyText||O.push({segments:G?s.icon.segments:new e.aE([]),sortKey:0,state:U}),a.onlyIcons||O.push({segments:Z?s.text.segments:new e.aE([]),sortKey:0,state:H})}P&&O.sort(((e,t)=>e.sortKey-t.sortKey));for(const e of O){const r=e.state;if(r)if(t.terrain&&t.terrain.setupElevationDraw(r.tile,r.program,{useDepthForOcclusion:C.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:r.labelPlaneMatrixInv}),b.activeTexture.set(w.TEXTURE0),r.atlasTexture&&r.atlasTexture.bind(r.atlasInterpolation,w.CLAMP_TO_EDGE,!0),r.atlasTextureIcon&&(b.activeTexture.set(w.TEXTURE1),r.atlasTextureIcon&&r.atlasTextureIcon.bind(r.atlasInterpolationIcon,w.CLAMP_TO_EDGE,!0)),t.uploadCommonLightUniforms(t.context,r.program),r.hasHalo){const n=r.uniformValues;n.u_is_halo=1,ro(r.buffers,e.segments,i,t,r.program,D,o,s,n,2),n.u_is_halo=0}else{if(r.isSDF){const n=r.uniformValues;r.hasHalo&&(n.u_is_halo=1,ro(r.buffers,e.segments,i,t,r.program,D,o,s,n,1)),n.u_is_halo=0}ro(r.buffers,e.segments,i,t,r.program,D,o,s,r.uniformValues,1)}}}function ro(e,t,r,i,n,o,s,a,l,c){const u=[e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer,e.iconTransitioningVertexBuffer,e.globeExtVertexBuffer,e.zOffsetVertexBuffer];n.draw(i,i.context.gl.TRIANGLES,o,s,a,Lt.disabled,l,r.id,e.layoutVertexBuffer,e.indexBuffer,t,r.paint,i.transform.zoom,e.programConfigurations.get(r.id),u,c)}function io(e,t,r,i,n,o,s){const a=e.context.gl,l=r.paint.get("fill-pattern"),c=l&&l.constantOr(1);let u,h,d,p,f;s?(h=c&&!r.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",u=a.LINES):(h=c?"fillPattern":"fill",u=a.TRIANGLES);for(const m of i){const i=t.getTile(m);if(c&&!i.patternsLoaded())continue;const A=i.getBucket(r);if(!A)continue;e.prepareDrawTile();const g=A.programConfigurations.get(r.id),_=e.isTileAffectedByFog(m),y=e.getOrCreateProgram(h,{config:g,overrideFog:_});c&&(e.context.activeTexture.set(a.TEXTURE0),i.imageAtlasTexture&&i.imageAtlasTexture.bind(a.LINEAR,a.CLAMP_TO_EDGE),g.updatePaintBuffers());const x=l.constantOr(null);if(x&&i.imageAtlas){const e=i.imageAtlas.patternPositions[x.toString()];e&&g.setConstantPatternPositions(e)}const v=e.translatePosMatrix(m.projMatrix,i,r.paint.get("fill-translate"),r.paint.get("fill-translate-anchor")),b=r.paint.get("fill-emissive-strength");if(s){p=A.indexBuffer2,f=A.segments2;const t=e.terrain&&e.terrain.renderingToTexture?e.terrain.drapeBufferSize:[a.drawingBufferWidth,a.drawingBufferHeight];d="fillOutlinePattern"===h&&c?Mn(v,b,e,i,t):En(v,b,t)}else p=A.indexBuffer,f=A.segments,d=c?Tn(v,b,e,i):Cn(v,b);e.uploadCommonUniforms(e.context,y,m.toUnwrapped()),y.draw(e,u,n,e.stencilModeForClipping(m),o,Lt.disabled,d,r.id,A.layoutVertexBuffer,p,f,r.paint,e.transform.zoom,g,void 0)}}function no(t,r,i,n,o,s,a,l){i.resetLayerRenderingStats(t);const c=t.context,u=c.gl,h=t.transform,d=i.paint.get("fill-extrusion-pattern"),p=d.constantOr(1),f=i.paint.get("fill-extrusion-opacity"),m=t.style.enable3dLights(),A=i.paint.get(m&&!p?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),g=[i.paint.get("fill-extrusion-ambient-occlusion-intensity"),A],_=i.layout.get("fill-extrusion-edge-radius"),y=_>0&&!i.paint.get("fill-extrusion-rounded-roof"),x=y?0:_,v="globe"===h.projection.name?e.cM():0,b="globe"===h.projection.name,w=b?e.W(h.zoom):0,C=[e.a8(h.center.lng),e.ah(h.center.lat)],T=i.paint.get("fill-extrusion-flood-light-color").toArray01().slice(0,3),E=i.paint.get("fill-extrusion-flood-light-intensity"),M=i.paint.get("fill-extrusion-vertical-scale"),S=mi(t,i.paint.get("fill-extrusion-cutoff-fade-range")),I=i.paint.get("fill-extrusion-emissive-strength"),P=[];let D;b&&P.push("PROJECTION_GLOBE_VIEW"),g[0]>0&&P.push("FAUX_AO"),y&&P.push("ZERO_ROOF_RADIUS"),l&&P.push("HAS_CENTROID"),E>0&&P.push("FLOOD_LIGHT"),S.shouldRenderCutoff&&P.push("RENDER_CUTOFF");const k="shadow"===t.renderPass,L=t.shadowRenderer,z=k&&!!L;t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!0);let O=[0,0,0];if(L){const e=t.style.directionalLight,r=t.style.ambientLight;e&&r&&(O=bi(e,r)),D=P.concat(["SHADOWS_SINGLE_CASCADE"])}const B=z?"fillExtrusionDepth":p?"fillExtrusionPattern":"fillExtrusion",R=i.getLayerRenderingStats();for(const e of n){const n=r.getTile(e),m=n.getBucket(i);if(!m||m.projection.name!==h.projection.name)continue;let A=!1;L&&(A=0===L.getMaxCascadeForTile(e.toUnwrapped()));const _=t.isTileAffectedByFog(e),y=m.programConfigurations.get(i.id),z=t.getOrCreateProgram(B,{config:y,defines:A?D:P,overrideFog:_});if(t.terrain&&t.terrain.setupElevationDraw(n,z,{useMeterToDem:!0}),!m.centroidVertexBuffer){const e=z.attributes.a_centroid_pos;void 0!==e&&u.vertexAttrib2f(e,0,0)}!k&&L&&L.setupShadows(n.tileID.toUnwrapped(),z,"vector-tile",n.tileID.overscaledZ),p&&(t.context.activeTexture.set(u.TEXTURE0),n.imageAtlasTexture&&n.imageAtlasTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),y.updatePaintBuffers());const F=d.constantOr(null);if(F&&n.imageAtlas){const e=n.imageAtlas.patternPositions[F.toString()];e&&y.setConstantPatternPositions(e)}const j=i.paint.get("fill-extrusion-vertical-gradient");let V;if(k&&L){if(uo(n.tileID,m,t))continue;const e=L.calculateShadowPassMatrixFromTile(n.tileID.toUnwrapped());V=bn(e,x,M)}else{const r=t.translatePosMatrix(e.expandedProjMatrix,n,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),o=h.projection.createInversionMatrix(h,e.canonical);V=p?wn(r,t,j,f,g,x,e,n,v,w,C,o,T,M):vn(r,t,j,f,g,x,e,v,w,C,o,T,M,E,O,I)}t.uploadCommonUniforms(c,z,e.toUnwrapped(),null,S);let N=m.segments;if("mercator"===h.projection.name&&!k&&(N=m.getVisibleSegments(n.tileID,t.terrain,t.transform.getFrustum(0)),!N.get().length))continue;if(R)if(k)for(const e of N.get())R.numRenderedVerticesInShadowPass+=e.primitiveLength;else for(const e of N.get())R.numRenderedVerticesInTransparentPass+=e.primitiveLength;const U=[];(t.terrain||l)&&U.push(m.centroidVertexBuffer),b&&U.push(m.layoutVertexExtBuffer),z.draw(t,c.gl.TRIANGLES,o,s,a,Lt.backCCW,V,i.id,m.layoutVertexBuffer,m.indexBuffer,N,i.paint,t.transform.zoom,y,U)}t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!1)}function oo(t,r,i,n,o,s,a,l,c,u,h,d,p,f,m,A,g,_,y){const x=t.context,v=x.gl,b=t.transform,w=t.transform.zoom,C=[],T=mi(t,i.paint.get("fill-extrusion-cutoff-fade-range"));"clear"===u?(C.push("CLEAR_SUBPASS"),y&&(C.push("CLEAR_FROM_TEXTURE"),x.activeTexture.set(v.TEXTURE0),y.bind(v.LINEAR,v.CLAMP_TO_EDGE))):"sdf"===u&&C.push("SDF_SUBPASS"),g&&C.push("HAS_CENTROID"),T.shouldRenderCutoff&&C.push("RENDER_CUTOFF");const E=i.layout.get("fill-extrusion-edge-radius"),M=(e,r,n,u,_)=>{const v=r.programConfigurations.get(i.id),b=t.isTileAffectedByFog(e),M=t.getOrCreateProgram("fillExtrusionGroundEffect",{config:v,defines:C,overrideFog:b}),S=((e,t,r,i,n,o,s,a,l,c,u)=>({u_matrix:t,u_opacity:r,u_ao_pass:i?1:0,u_meter_to_tile:n,u_ao:o,u_flood_light_intensity:s,u_flood_light_color:a,u_attenuation:l,u_edge_radius:c,u_fb:0,u_fb_size:u}))(0,u,h,c,_,[d,p*_],f,m,A,w>=17?0:E*_,y?y.size[0]:0),I=[];g&&I.push(r.hiddenByLandmarkVertexBuffer),t.uploadCommonUniforms(x,M,e.toUnwrapped(),null,T),M.draw(t,x.gl.TRIANGLES,o,s,a,l,S,i.id,r.vertexBuffer,r.indexBuffer,n,i.paint,w,v,I)};for(const o of n){const n=r.getTile(o),s=n.getBucket(i);if(!s||s.projection.name!==b.projection.name||!s.groundEffect||s.groundEffect&&!s.groundEffect.hasData())continue;const a=s.groundEffect,l=1/s.tileToMeter;{const e=t.translatePosMatrix(o.projMatrix,n,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),r=a.getDefaultSegment();M(o,a,r,e,l)}if(_)for(let s=0;s<4;s++){const a=e.cN[s](o),c=r.getTile(a);if(!c)continue;const u=c.getBucket(i);if(!u||u.projection.name!==b.projection.name||!u.groundEffect||u.groundEffect&&!u.groundEffect.hasData())continue;const h=u.groundEffect;let d,p;0===s?(d=[-e.Y,0,0],p=1):1===s?(d=[e.Y,0,0],p=0):2===s?(d=[0,-e.Y,0],p=3):(d=[0,e.Y,0],p=2);const f=h.regionSegments[p];if(!f)continue;const m=new Float32Array(16);e.a9.translate(m,o.projMatrix,d),M(o,h,f,t.translatePosMatrix(m,n,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),l)}}}function so(t,r,i,n,o,s,a){0===n.centroidVertexArray.length&&n.createCentroidsBuffer();const l=s?s.findDEMTileFor(i):null;if(!(l&&l.dem||a))return;const c=t=>new e.P(Math.ceil((t+e.cQ)*e.cR),0),u=e=>{const t=r.getSource().minzoom,i=e=>{const t=r.getTileByID(e);if(t&&t.hasData())return t.getBucket(o)},n=[0,-1,1];for(const r of n){if(e.overscaledZ+r<t)continue;const n=i(e.calculateScaledKey(e.overscaledZ+r));if(n)return n}},h=[0,0,0],d=(t,r)=>(h[0]=Math.min(t.min.y,r.min.y),h[1]=Math.max(t.max.y,r.max.y),h[2]=e.Y-r.min.x>t.max.x?r.min.x-e.Y:t.max.x,h),p=(t,r)=>(h[0]=Math.min(t.min.x,r.min.x),h[1]=Math.max(t.max.x,r.max.x),h[2]=e.Y-r.min.y>t.max.y?r.min.y-e.Y:t.max.y,h),f=[(e,t)=>d(e,t),(e,t)=>d(t,e),(e,t)=>p(e,t),(e,t)=>p(t,e)],m=(t,r,n,o,a,c,u)=>{if(!s)return 0;const h=[[c?n:t,c?t:n,0],[c?n:r,c?r:n,0]],d=u<0?e.Y+u:u,p=[c?d:(t+r)/2,c?(t+r)/2:d,0];return 0===n&&u<0||0!==n&&u>0?s.getForTilePoints(a,[p],!0,o):h.push(p),s.getForTilePoints(i,h,!0,l),Math.max(h[0][2],h[1][2],p[2])/s.exaggeration()};for(let t=0;t<4;t++){const r=n.borderFeatureIndices[t];if(0===r.length)continue;const o=e.cN[t](i),l=u(o);if(!(l&&l instanceof e.cO))continue;if(n.borderDoneWithNeighborZ[t]===l.canonical.z)continue;0===l.centroidVertexArray.length&&l.createCentroidsBuffer();const h=s?s.findDEMTileFor(o):null;if(!(h&&h.dem||a))continue;const d=(t<2?1:5)-t,p=l.borderDoneWithNeighborZ[d]!==n.canonical.z,_=l.borderFeatureIndices[d];let y=0;if(n.canonical.z!==l.canonical.z){for(const e of r)n.showCentroid(n.featuresOnBorder[e]);if(p)for(const e of _)l.showCentroid(l.featuresOnBorder[e]);n.borderDoneWithNeighborZ[t]=l.canonical.z,l.borderDoneWithNeighborZ[d]=n.canonical.z}for(const i of r){const r=n.featuresOnBorder[i],s=n.centroidData[r.centroidDataIndex],u=r.borders[t];let p;for(;y<_.length;){p=l.featuresOnBorder[_[y]];const e=p.borders[d];if(e[1]>u[0]+3||e[0]>u[0]-3)break;l.showCentroid(p),y++}if(p&&y<_.length){const i=y;let x=0;for(;!(p.borders[d][0]>u[1]-3)&&(x++,++y!==_.length);)p=l.featuresOnBorder[_[y]];if(p=l.featuresOnBorder[_[i]],x>1){const e=p.borders[d];Math.abs(u[0]-e[0])<3&&Math.abs(u[1]-e[1])<3&&(x=1,y=i+1)}else if(0===x){n.showCentroid(r);continue}const v=l.centroidData[p.centroidDataIndex];a&&1===x&&(((A=s).flags|(g=v).flags)&e.cP?(A.flags|=e.cP,g.flags|=e.cP):(A.flags&=~e.cP,g.flags&=~e.cP));const b=r.intersectsCount()>1||p.intersectsCount()>1;if(x>1)y=i,s.centroidXY=v.centroidXY=new e.P(0,0);else if(h&&h.dem&&!b){const r=f[t](s,v),i=t%2?e.Y-1:0,n=m(r[0],Math.min(e.Y-1,r[1]),i,h,o,t<2,r[2]);s.centroidXY=v.centroidXY=c(n)}else b?s.centroidXY=v.centroidXY=new e.P(0,0):(s.centroidXY=n.encodeBorderCentroid(r),v.centroidXY=l.encodeBorderCentroid(p));n.writeCentroidToBuffer(s),l.writeCentroidToBuffer(v)}else n.showCentroid(r)}n.borderDoneWithNeighborZ[t]=l.canonical.z,l.borderDoneWithNeighborZ[d]=n.canonical.z}var A,g;(n.needsCentroidUpdate||!n.centroidVertexBuffer&&0!==n.centroidVertexArray.length)&&n.uploadCentroid(t)}const ao=[1,0,0],lo=[0,1,0],co=[0,0,1];function uo(t,r,i){const n=i.transform,o=i.shadowRenderer;if(!o)return!0;const s=t.toUnwrapped(),a=n.tileSize*o._cascades[i.currentShadowCascade].scale;let l=r.maxHeight;if(n.elevation){const e=n.elevation.getMinMaxForTile(t);e&&(l+=e.max)}const c=[...o.shadowDirection];c[2]=-c[2];const u=o.computeSimplifiedTileShadowVolume(s,l,a,c);if(!u)return!1;const h=[ao,lo,co,c,[c[0],0,c[2]],[0,c[1],c[2]]],d="globe"===n.projection.name,p=n.scaleZoom(a),f=e.bt.fromInvProjectionMatrix(n.invProjMatrix,n.worldSize,p,!d),m=o.getCurrentCascadeFrustum();return 0===f.intersectsPrecise(u.vertices,u.planes,h)||0===m.intersectsPrecise(u.vertices,u.planes,h)}function ho(t){return[t[0]*e.cS,t[1]*e.cS,t[2]*e.cS,0]}function po(t,r,i,n,o,s,a,l,c){const u=n.getSource(),h=i.globeSharedBuffers;if(!h)return;let d,p,f;if(r&&(d=n.getTile(r)),u instanceof e.as?(p=u.texture,f=e.co(0,0,i.transform)):d&&r&&(p=d.texture,f=e.co(r.canonical.z,r.canonical.x,i.transform)),!p||!f)return;t||(f=e.a9.scale(e.a9.create(),f,[1,-1,1]));const m=i.context,A=m.gl,g="nearest"===o.paint.get("raster-resampling")?A.NEAREST:A.LINEAR,_=i.colorModeForDrapableLayerRenderPass(s),y=a.defines;y.push("GLOBE_POLES");const x=new Et(A.LEQUAL,Et.ReadWrite,i.depthRangeFor3D),v=Float32Array.from(i.transform.expandedFarZProjMatrix),b=Float32Array.from(e.aW(e.cn(new e.bv(0,0,0))));i.terrain&&i.terrain.prepareDrawTile(),m.activeTexture.set(A.TEXTURE0),p.bind(g,A.CLAMP_TO_EDGE),m.activeTexture.set(A.TEXTURE1),p.bind(g,A.CLAMP_TO_EDGE),p.useMipmap&&m.extTextureFilterAnisotropic&&i.transform.pitch>20&&A.texParameterf(A.TEXTURE_2D,m.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,m.extTextureFilterAnisotropicMax);const[w,C,T,E]=r?h.getPoleBuffers(r.canonical.z,!1):h.getPoleBuffers(0,!0),M=o.paint.get("raster-elevation");let S;t?(S=w,i.renderDefaultNorthPole=0!==M):(S=C,i.renderDefaultSouthPole=0!==M);const I=ho(a.mix),P=((e,t,r,i,n,o,s,a,l,c,u,h,d)=>zn(e,t,r,new Float32Array(16),new Float32Array(9),[0,0],i,[0,0],[0,0,0,0],1,{opacity:1,mix:0},o,[0,0]||[0,0],a,2,c,u,h,1,0,d))(v,b,f,e.W(i.transform.zoom),0,o,0,M,0,I,a.offset,a.range,s),D=i.getOrCreateProgram("raster",{defines:y});i.uploadCommonUniforms(m,D,null),D.draw(i,A.TRIANGLES,x,c,_,l,P,o.id,S,T,E)}function fo(e){const t=e._nearZ,r=e.projection.farthestPixelDistance(e),i=r-t,n=.2*e.height,o=t+n;return[t,r,(o-n-t)/i,(o-t)/i]}function mo(e,t,r,i){if(e)return t instanceof De&&e instanceof Wt?t.getTextureDescriptor(e,r,!0):{texture:e.texture,mix:ho(i.mix),offset:i.offset,buffer:0,tileSize:1}}function Ao(t,r,i){if(!t)return null;const n=r.getTextureDescriptor(t,i,!0);if(!n)return null;let{texture:o,mix:s,offset:a,tileSize:l,buffer:c,format:u}=n;if(!o||!u)return null;let h=!1;return"uint32"===u&&(h=!0,s[3]=0,s=kn(e.cT,s,[0,i.paint.get("raster-particle-max-speed")]),a=Ln(e.cT,a,[0,i.paint.get("raster-particle-max-speed")])),{texture:o,textureOffset:[c/(l+2*c),l/(l+2*c)],tileSize:l,scalarData:h,scale:s,offset:a,defines:["RASTER_ARRAY",{uint8:"DATA_FORMAT_UINT8",uint16:"DATA_FORMAT_UINT16",uint32:"DATA_FORMAT_UINT32"}[u]]}}function go(e){const t=e._nearZ,r=e.projection.farthestPixelDistance(e),i=r-t,n=.2*e.height,o=t+n;return[t,r,(o-n-t)/i,(o-t)/i]}const _o=new e.aA(1,0,0,1),yo=new e.aA(0,1,0,1),xo=new e.aA(0,0,1,1),vo=new e.aA(1,0,1,1),bo=new e.aA(0,1,1,1);function wo(t,r,i,n,o,s,a){const l=t.context,c=t.transform,u=l.gl,h="globe"===c.projection.name,d=h?["PROJECTION_GLOBE_VIEW"]:[];let p=e.a9.clone(i.projMatrix);if(h&&e.W(c.zoom)>0){const t=e.aV(i.canonical,c),r=e.cU(t);p=e.a9.multiply(new Float32Array(16),c.globeMatrix,r),e.a9.multiply(p,c.projMatrix,p)}const f=e.a9.create();f[12]+=2*o/(e.f.devicePixelRatio*c.width),f[13]+=2*s/(e.f.devicePixelRatio*c.height),e.a9.multiply(p,f,p);const m=t.getOrCreateProgram("debug",{defines:d}),A=r.getTileByID(i.key);t.terrain&&t.terrain.setupElevationDraw(A,m);const g=Et.disabled,_=St.disabled,y=t.colorModeForRenderPass(),x="$debug";l.activeTexture.set(u.TEXTURE0),t.emptyTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),h?A._makeGlobeTileDebugBuffers(t.context,c):A._makeDebugTileBoundsBuffers(t.context,c.projection);const v=A._tileDebugBuffer||t.debugBuffer,b=A._tileDebugIndexBuffer||t.debugIndexBuffer,w=A._tileDebugSegments||t.debugSegments;if(m.draw(t,u.LINE_STRIP,g,_,y,Lt.disabled,In(p,n),x,v,b,w,null,null,null,[A._globeTileDebugBorderBuffer]),a){const e=A.latestRawTileData,r=Math.floor((e&&e.byteLength||0)/1024);let n=i.canonical.toString();i.overscaledZ!==i.canonical.z&&(n+=` => ${i.overscaledZ}`),n+=` ${A.state}`,n+=` ${r}kb`,function(e,t){e.initDebugOverlayCanvas();const r=e.debugOverlayCanvas,i=e.context.gl,n=e.debugOverlayCanvas.getContext("2d");n.clearRect(0,0,r.width,r.height),n.shadowColor="white",n.shadowBlur=2,n.lineWidth=1.5,n.strokeStyle="white",n.textBaseline="top",n.font="bold 36px Open Sans, sans-serif",n.fillText(t,5,5),n.strokeText(t,5,5),e.debugOverlayTexture.update(r),e.debugOverlayTexture.bind(i.LINEAR,i.CLAMP_TO_EDGE)}(t,n)}const C=r.getTile(i).tileSize,T=512/Math.min(C,512)*(i.overscaledZ/c.zoom)*.5,E=A._tileDebugTextBuffer||t.debugBuffer,M=A._tileDebugTextIndexBuffer||t.quadTriangleIndexBuffer,S=A._tileDebugTextSegments||t.debugSegments;m.draw(t,u.TRIANGLES,g,_,Pt.alphaBlended,Lt.disabled,In(p,e.aA.transparent,T),x,E,M,S,null,null,null,[A._globeTileDebugTextBuffer])}function Co(e,t,r,i){Eo(e,0,t+r/2,e.transform.width,r,i)}function To(e,t,r,i){Eo(e,t-r/2,0,r,e.transform.height,i)}function Eo(t,r,i,n,o,s){const a=t.context,l=a.gl;l.enable(l.SCISSOR_TEST),l.scissor(r*e.f.devicePixelRatio,i*e.f.devicePixelRatio,n*e.f.devicePixelRatio,o*e.f.devicePixelRatio),a.clear({color:s}),l.disable(l.SCISSOR_TEST)}const Mo=e.aB([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:So}=Mo;function Io(e,t,r,i){e.emplaceBack(t,r,i)}class Po{constructor(t){this.vertexArray=new e.cV,this.indices=new e.az,Io(this.vertexArray,-1,-1,1),Io(this.vertexArray,1,-1,1),Io(this.vertexArray,-1,1,1),Io(this.vertexArray,1,1,1),Io(this.vertexArray,-1,-1,-1),Io(this.vertexArray,1,-1,-1),Io(this.vertexArray,-1,1,-1),Io(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,So),this.indexBuffer=t.createIndexBuffer(this.indices),this.segment=e.aE.simpleSegment(0,0,36,12)}}function Do(t,r,i,n,o,s){const a=t.context.gl,l=r.paint.get("sky-atmosphere-color"),c=r.paint.get("sky-atmosphere-halo-color"),u=r.paint.get("sky-atmosphere-sun-intensity"),h=((e,t,r,i,n)=>({u_matrix_3f:e,u_sun_direction:t,u_sun_intensity:r,u_color_tint_r:[i.r,i.g,i.b,i.a],u_color_tint_m:[n.r,n.g,n.b,n.a],u_luminance:5e-5}))(e.ct.fromMat4(e.ct.create(),n),o,u,l,c);a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+s,r.skyboxTexture,0),i.draw(t,a.TRIANGLES,Et.disabled,St.disabled,Pt.unblended,Lt.frontCW,h,"skyboxCapture",r.skyboxGeometry.vertexBuffer,r.skyboxGeometry.indexBuffer,r.skyboxGeometry.segment)}const ko=e.aB([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class Lo{constructor(t){const r=new e.cW;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 i=new e.az;i.emplaceBack(0,1,2),i.emplaceBack(2,3,0),this.vertexBuffer=t.createVertexBuffer(r,ko.members),this.indexBuffer=t.createIndexBuffer(i),this.segments=e.aE.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const zo=e.aB([{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 Oo{constructor(){this.starsCount=16e3,this.sizeMultiplier=.15,this.sizeRange=100,this.intensityRange=200}}class Bo{constructor(t){this.colorModeAlphaBlendedWriteRGB=new Pt([1,It,1,It],e.aA.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new Pt([1,0,1,0],e.aA.transparent,[!1,!1,!1,!0]),this.params=new Oo,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 Lo(r);const t=this.params.sizeRange,i=this.params.intensityRange,n=function(t){const r=e.aC(30),i=[];for(let n=0;n<t;++n){const t=2*Math.PI*r(),n=Math.acos(1-2*r())-.5*Math.PI;i.push(e.Q.fromValues(Math.cos(n)*Math.cos(t),Math.cos(n)*Math.sin(t),Math.sin(n)))}return i}(this.params.starsCount),o=e.aC(300),s=new e.cX,a=new e.az;let l=0;for(let r=0;r<n.length;++r){const c=e.Q.scale([],n[r],200),u=Math.max(0,1+.01*t*(1*o()-.5)),h=Math.max(0,1+.01*i*(1*o()-.5));s.emplaceBack(c[0],c[1],c[2],-1,-1,u,h),s.emplaceBack(c[0],c[1],c[2],1,-1,u,h),s.emplaceBack(c[0],c[1],c[2],1,1,u,h),s.emplaceBack(c[0],c[1],c[2],-1,1,u,h),a.emplaceBack(l+0,l+1,l+2),a.emplaceBack(l+0,l+2,l+3),l+=4}this.starsVx=r.createVertexBuffer(s,zo.members),this.starsIdx=r.createIndexBuffer(a),this.starsSegments=e.aE.simpleSegment(0,0,s.length,a.length)}}destroy(){this.atmosphereBuffer&&this.atmosphereBuffer.destroy(),this.starsVx&&this.starsVx.destroy(),this.starsIdx&&this.starsIdx.destroy()}drawAtmosphereGlow(t,r){const i=t.context,n=i.gl,o=t.transform,s=new Et(n.LEQUAL,Et.ReadOnly,[0,1]),a=e.W(o.zoom),l=r.properties.get("color").toArray01(),c=r.properties.get("high-color").toArray01(),u=r.properties.get("space-color").toArray01PremultipliedAlpha(),h=5e-4,d=e.cY(r.properties.get("horizon-blend"),0,1,h,.25),p=e.ci(t,i,o)&&d===h?o.worldSize/(2*Math.PI*1.025)-1:o.globeRadius,f=t.frameCounter/1e3%1,m=e.Q.length(o.globeCenterInViewSpace),A=Math.sqrt(Math.pow(m,2)-Math.pow(p,2)),g=Math.acos(A/m),_=e=>{const r="globe"===o.projection.name?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];e&&r.push("ALPHA_PASS");const h=t.getOrCreateProgram("globeAtmosphere",{defines:r}),p=((e,t,r,i,n,o,s,a,l,c,u,h)=>({u_frustum_tl:e,u_frustum_tr:t,u_frustum_br:r,u_frustum_bl:i,u_horizon:n,u_transition:o,u_fadeout_range:s,u_color:a,u_high_color:l,u_space_color:c,u_temporal_offset:u,u_horizon_angle:h}))(o.frustumCorners.TL,o.frustumCorners.TR,o.frustumCorners.BR,o.frustumCorners.BL,o.frustumCorners.horizon,a,d,l,c,u,f,g);t.uploadCommonUniforms(i,h);const m=this.atmosphereBuffer;m&&h.draw(t,n.TRIANGLES,s,St.disabled,e?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,Lt.backCW,p,e?"atmosphere_glow_alpha":"atmosphere_glow",m.vertexBuffer,m.indexBuffer,m.segments)};_(!1),_(!0)}drawStars(t,r){const i=e.ad(r.properties.get("star-intensity"),0,1);if(0===i)return;const n=t.context,o=n.gl,s=t.transform,a=t.getOrCreateProgram("stars"),l=e.bl.identity([]);e.bl.rotateX(l,l,-s._pitch),e.bl.rotateZ(l,l,-s.angle),e.bl.rotateX(l,l,e.bm(s._center.lat)),e.bl.rotateY(l,l,-e.bm(s._center.lng));const c=e.a9.fromQuat(new Float32Array(16),l),u=e.a9.multiply([],s.starsProjMatrix,c),h=e.ct.fromMat4([],c),d=e.ct.invert([],h),p=[0,1,0];e.Q.transformMat3(p,p,d),e.Q.scale(p,p,this.params.sizeMultiplier);const f=[1,0,0];e.Q.transformMat3(f,f,d),e.Q.scale(f,f,this.params.sizeMultiplier);const m=(A=p,g=f,_=i,{u_matrix:Float32Array.from(u),u_up:A,u_right:g,u_intensity_multiplier:_});var A,g,_;t.uploadCommonUniforms(n,a),this.starsVx&&this.starsIdx&&a.draw(t,o.TRIANGLES,Et.disabled,St.disabled,this.colorModeAlphaBlendedWriteRGB,Lt.disabled,m,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments)}}function Ro(t,r){const i=[...t],n=r.cameraWorldSizeForFog/r.worldSize,o=e.a9.identity([]);return e.a9.scale(o,o,[n,n,1]),e.a9.multiply(i,o,i),e.a9.multiply(i,r.worldToFogMatrix,i),i}function Fo(e,t,r,i){const n=r.material,o=i.context,{baseColorTexture:s,metallicRoughnessTexture:a}=n.pbrMetallicRoughness,{normalTexture:l,occlusionTexture:c,emissionTexture:u}=n;function h(t,r,i){if(t&&(e.push(r),o.activeTexture.set(o.gl.TEXTURE0+i),t.gfxTexture)){const{minFilter:e,magFilter:r,wrapS:i,wrapT:n}=t.sampler;t.gfxTexture.bindExtraParam(e,r,i,n)}}h(s,"HAS_TEXTURE_u_baseColorTexture",fi.BaseColor),h(a,"HAS_TEXTURE_u_metallicRoughnessTexture",fi.MetallicRoughness),h(l,"HAS_TEXTURE_u_normalTexture",fi.Normal),h(c,"HAS_TEXTURE_u_occlusionTexture",fi.Occlusion),h(u,"HAS_TEXTURE_u_emissionTexture",fi.Emission),r.texcoordBuffer&&(e.push("HAS_ATTRIBUTE_a_uv_2f"),t.push(r.texcoordBuffer)),r.colorBuffer&&(e.push(12===r.colorBuffer.itemSize?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),t.push(r.colorBuffer)),r.normalBuffer&&(e.push("HAS_ATTRIBUTE_a_normal_3f"),t.push(r.normalBuffer)),r.pbrBuffer&&(e.push("HAS_ATTRIBUTE_a_pbr"),e.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),t.push(r.pbrBuffer)),"OPAQUE"!==n.alphaMode&&"MASK"!==n.alphaMode||e.push("UNPREMULT_TEXTURE_IN_SHADER"),n.defined||e.push("DIFFUSE_SHADED"),e.push("USE_STANDARD_DERIVATIVES")}function jo(t,r,i,n,o,s){const a=i.paint.get("model-opacity"),l=r.context,c=new Et(r.context.gl.LEQUAL,Et.ReadWrite,r.depthRangeFor3D),u=r.transform,h=t.mesh,d=h.material,p=d.pbrMetallicRoughness,f=r.style.fog;let m;m="pixels"===r.transform.projection.zAxisUnit?[...t.nodeModelMatrix]:e.a9.multiply([],n.zScaleMatrix,t.nodeModelMatrix),e.a9.multiply(m,n.negCameraPosMatrix,m);const A=e.a9.invert([],m);e.a9.transpose(A,A);const g=i.paint.get("model-emissive-strength").constantOr(0),_=Wn(new Float32Array(t.worldViewProjection),new Float32Array(m),new Float32Array(A),null,r,a,p.baseColorFactor,d.emissiveFactor,p.metallicFactor,p.roughnessFactor,d,g,i),y={defines:[]},x=[];Fo(y.defines,x,h,r);const v=r.shadowRenderer;v&&(v.useNormalOffset=!1);let b=null;if(f){const e=Ro(t.nodeModelMatrix,r.transform);if(b=new Float32Array(e),"globe"!==u.projection.name){const t=h.aabb.min,r=h.aabb.max,[i,n]=f.getOpacityForBounds(e,t[0],t[1],r[0],r[1]);y.overrideFog=i>=pe||n>=pe}}const w=mi(r,i.paint.get("model-cutoff-fade-range"));w.shouldRenderCutoff&&y.defines.push("RENDER_CUTOFF");const C=r.getOrCreateProgram("model",y);r.uploadCommonUniforms(l,C,null,b,w),"shadow"!==r.renderPass&&v&&v.setupShadowsFromMatrix(t.nodeModelMatrix,C),C.draw(r,l.gl.TRIANGLES,c,o,s,h.material.doubleSided?Lt.disabled:Lt.backCCW,_,i.id,h.vertexBuffer,h.indexBuffer,h.segments,i.paint,r.transform.zoom,void 0,x)}function Vo(t,r,i,n,o,s,a){let l;l="globe"===t.projection.name?e.c_(i,t):[...i],e.a9.multiply(l,l,r.matrix);const c=e.a9.multiply([],n,l);if(r.meshes)for(const t of r.meshes){if("BLEND"!==t.material.alphaMode){a.push({mesh:t,depth:0,modelIndex:o,worldViewProjection:c,nodeModelMatrix:l});continue}const r=e.Q.transformMat4([],t.centroid,c);r[2]>0&&s.push({mesh:t,depth:r[2],modelIndex:o,worldViewProjection:c,nodeModelMatrix:l})}if(r.children)for(const e of r.children)Vo(t,e,i,n,o,s,a)}function No(e,t,r,i){const n=r.shadowRenderer;if(!n)return;const o=n.getShadowPassDepthMode(),s=n.getShadowPassColorMode(),a=n.calculateShadowPassMatrixFromMatrix(t),l=Qn(a);r.getOrCreateProgram("modelDepth",{defines:r._shadowMapDebug?[]:["DEPTH_TEXTURE"]}).draw(r,r.context.gl.TRIANGLES,o,St.disabled,s,Lt.backCCW,l,i.id,e.vertexBuffer,e.indexBuffer,e.segments,i.paint,r.transform.zoom,void 0,void 0)}function Uo(t,r,i){const n=r.updateZoomBasedPaintProperties(),o=function(t,r,i){let n,o,s,a=t.terrain?t.terrain.exaggeration():0;if(t.terrain&&a>0){const r=t.terrain,o=r.findDEMTileFor(i);o&&o.dem?n=e.d0.create(r,i,o):a=0}if(0===a&&(r.terrainElevationMin=0,r.terrainElevationMax=0),a===r.validForExaggeration&&(0===a||n&&n._demTile&&n._demTile.tileID===r.validForDEMTile.id&&n._dem._timestamp===r.validForDEMTile.timestamp))return!1;for(const e in r.instancesPerModel){const t=r.instancesPerModel[e];for(let e=0;e<t.instancedDataArray.length;++e){const i=(n?a*n.getElevationAt(0|t.instancedDataArray.float32[16*e],0|t.instancedDataArray.float32[16*e+1],!0,!0):0)+t.instancesEvaluatedElevation[e];t.instancedDataArray.float32[16*e+6]=i,o=o?Math.min(r.terrainElevationMin,i):i,s=s?Math.max(r.terrainElevationMax,i):i}}return r.terrainElevationMin=o||0,r.terrainElevationMax=s||0,r.validForExaggeration=a,r.validForDEMTile=n&&n._demTile?{id:n._demTile.tileID,timestamp:n._dem._timestamp}:{id:void 0,timestamp:0},!0}(t,r,i);(n||o)&&(r.uploaded=!1,r.upload(t.context))}const Ho={shadowUniformsInitialized:!1,useSingleShadowCascade:!1,tileMatrix:new Float64Array(16),shadowTileMatrix:new Float32Array(16),aabb:new e.bV([0,0,0],[e.Y,e.Y,0])};function Go(t,r){const i=1<<t.canonical.z,n=r.getFreeCameraOptions().position,o=r.elevation,s=t.canonical.x/i,a=(t.canonical.x+1)/i,l=t.canonical.y/i,c=(t.canonical.y+1)/i;let u=r._centerAltitude;if(o){const e=o.getMinMaxForTile(t);e&&e.max>u&&(u=e.max)}const h=e.ad(n.x,s,a)-n.x,d=e.ad(n.y,l,c)-n.y,p=e.bo(u,r.center.lat)-n.z;return r._zoomFromMercatorZ(Math.sqrt(h*h+d*d+p*p))}function Zo(e,t,r,i,n,o,s){const a=e.context,l="shadow"===e.renderPass,c=e.shadowRenderer,u=l&&c?c.getShadowPassDepthMode():new Et(a.gl.LEQUAL,Et.ReadWrite,e.depthRangeFor3D),h=e.isTileAffectedByFog(o);if(r.meshes)for(const d of r.meshes){const p=["MODEL_POSITION_ON_GPU"],f=[];let m,A,g;i.instancedDataArray.length>20&&p.push("INSTANCED_ARRAYS");const _=mi(e,t.paint.get("model-cutoff-fade-range"));if(_.shouldRenderCutoff&&p.push("RENDER_CUTOFF"),l&&c)m=e.getOrCreateProgram("modelDepth",{defines:p}),A=Qn(s.shadowTileMatrix,s.shadowTileMatrix,Float32Array.from(r.matrix)),g=c.getShadowPassColorMode();else{Fo(p,f,d,e),m=e.getOrCreateProgram("model",{defines:p,overrideFog:h});const i=d.material,l=i.pbrMetallicRoughness,u=t.paint.get("model-opacity"),y=t.paint.get("model-emissive-strength").constantOr(0);A=Wn(o.expandedProjMatrix,Float32Array.from(r.matrix),new Float32Array(16),null,e,u,l.baseColorFactor,i.emissiveFactor,l.metallicFactor,l.roughnessFactor,i,y,t,n),c&&(s.shadowUniformsInitialized?m.setShadowUniformValues(a,c.getShadowUniformValues()):(c.setupShadows(o.toUnwrapped(),m,"model-tile",o.overscaledZ),s.shadowUniformsInitialized=!0)),g=_.shouldRenderCutoff||u<1||"OPAQUE"!==i.alphaMode?Pt.alphaBlended:Pt.unblended}e.uploadCommonUniforms(a,m,o.toUnwrapped(),null,_);const y=d.material.doubleSided?Lt.disabled:Lt.backCCW;if(i.instancedDataArray.length>20)f.push(i.instancedDataBuffer),m.draw(e,a.gl.TRIANGLES,u,St.disabled,g,y,A,t.id,d.vertexBuffer,d.indexBuffer,d.segments,t.paint,e.transform.zoom,void 0,f,i.instancedDataArray.length);else{const r=l?"u_instance":"u_normal_matrix";for(let n=0;n<i.instancedDataArray.length;++n)A[r]=new Float32Array(i.instancedDataArray.arrayBuffer,64*n,16),m.draw(e,a.gl.TRIANGLES,u,St.disabled,g,y,A,t.id,d.vertexBuffer,d.indexBuffer,d.segments,t.paint,e.transform.zoom,void 0,f)}}if(r.children)for(const a of r.children)Zo(e,t,a,i,n,o,s)}const Wo=[1,-1,1];function Qo(t,r,i,n){if(!i.modelManager)return!0;const o=i.modelManager;if(!i.shadowRenderer)return!0;const s=i.shadowRenderer,a=r.aabb;let l=!0,c=t.maxHeight;if(0===c){let e=0;for(const r in t.instancesPerModel){const t=o.getModel(r,n);t?e=Math.max(e,Math.max(Math.max(t.aabb.max[0],t.aabb.max[1]),t.aabb.max[2])):l=!1}c=t.maxScale*e*1.41+t.maxVerticalOffset,l&&(t.maxHeight=c)}a.max[2]=c,a.min[2]+=t.terrainElevationMin,a.max[2]+=t.terrainElevationMax,e.Q.transformMat4(a.min,a.min,r.tileMatrix),e.Q.transformMat4(a.max,a.max,r.tileMatrix);const u=a.intersects(s.getCurrentCascadeFrustum());return 0===i.currentShadowCascade&&(t.isInsideFirstShadowMapFrustum=2===u),0===u}class qo{}class Xo{constructor(){this._storage=new Map}getLinesFromTrianglesBuffer(t,r,i){{const e=this._storage.get(r.id);if(e)return e.lastUsedFrameIdx=t,e.buf}const n=i.gl,o=n.getBufferParameter(n.ELEMENT_ARRAY_BUFFER,n.BUFFER_SIZE),s=new ArrayBuffer(o),a=new Int16Array(s);n.getBufferSubData(n.ELEMENT_ARRAY_BUFFER,0,new Int16Array(s));const l=new e.d2;for(let e=0;e<o/2;e+=3){const t=a[e],r=a[e+1],i=a[e+2];l.emplaceBack(t,r),l.emplaceBack(r,i),l.emplaceBack(i,t)}const c=i.bindVertexArrayOES.current,u=new qo;return u.buf=new je(i,l),u.lastUsedFrameIdx=t,this._storage.set(r.id,u),i.bindVertexArrayOES.set(c),u.buf}update(e){for(const[t,r]of this._storage)e-r.lastUsedFrameIdx>30&&(r.buf.destroy(),this._storage.delete(t))}destroy(){for(const[e,t]of this._storage)t.buf.destroy(),this._storage.delete(e)}}const Yo={symbol:function(t,r,i,n,o){if("translucent"!==t.renderPass)return;const s=St.disabled,a=t.colorModeForRenderPass();i.layout.get("text-variable-anchor")&&function(t,r,i,n,o,s,a){const l=r.transform,c="map"===o,u="map"===s;for(const r of t){const t=n.getTile(r),o=t.getBucket(i);if(!o||!o.text||!o.text.segments.get().length)continue;const s=e.b8(o.textSizeData,l.zoom),h=kr(r,o.getProjection(),l),d=l.calculatePixelsToTileUnitsMatrix(t),p=pr(h,t.tileID.canonical,u,c,l,o.getProjection(),d),f=o.hasIconTextFit()&&o.hasIconData();if(s){const i=Math.pow(2,l.zoom-t.tileID.overscaledZ);eo(o,c,u,a,e.cE,l,p,r,i,s,f)}}}(n,t,i,r,i.layout.get("text-rotation-alignment"),i.layout.get("text-pitch-alignment"),o);const l=0!==i.paint.get("icon-opacity").constantOr(1),c=0!==i.paint.get("text-opacity").constantOr(1);void 0!==i.layout.get("symbol-sort-key").constantOr(1)&&(l||c)?to(t,r,i,n,s,a):(l&&to(t,r,i,n,s,a,{onlyIcons:!0}),c&&to(t,r,i,n,s,a,{onlyText:!0})),r.map.showCollisionBoxes&&(Yn(t,r,i,n,i.paint.get("text-translate"),i.paint.get("text-translate-anchor"),!0),Yn(t,r,i,n,i.paint.get("icon-translate"),i.paint.get("icon-translate-anchor"),!1))},circle:function(t,r,i,n){if("translucent"!==t.renderPass)return;const o=i.paint.get("circle-opacity"),s=i.paint.get("circle-stroke-width"),a=i.paint.get("circle-stroke-opacity"),l=void 0!==i.layout.get("circle-sort-key").constantOr(1),c=i.paint.get("circle-emissive-strength");if(0===o.constantOr(1)&&(0===s.constantOr(1)||0===a.constantOr(1)))return;const u=t.context,h=u.gl,d=t.transform,p=t.depthModeForSublayer(0,Et.ReadOnly),f=St.disabled,m=t.colorModeForDrapableLayerRenderPass(c),A="globe"===d.projection.name,g=[e.a8(d.center.lng),e.ah(d.center.lat)],_=[];for(let o=0;o<n.length;o++){const s=n[o],a=r.getTile(s),c=a.getBucket(i);if(!c||c.projection.name!==d.projection.name)continue;const u=c.programConfigurations.get(i.id),h=e.cF(i),p=t.isTileAffectedByFog(s);A&&h.push("PROJECTION_GLOBE_VIEW");const f=t.getOrCreateProgram("circle",{config:u,defines:h,overrideFog:p}),m=c.layoutVertexBuffer,y=c.globeExtVertexBuffer,x=c.indexBuffer,v=d.projection.createInversionMatrix(d,s.canonical),b={programConfiguration:u,program:f,layoutVertexBuffer:m,globeExtVertexBuffer:y,indexBuffer:x,uniformValues:e.cG(t,s,a,v,g,i),tile:a};if(l){const t=c.segments.get();for(const r of t)_.push({segments:new e.aE([r]),sortKey:r.sortKey,state:b})}else _.push({segments:c.segments,sortKey:0,state:b})}l&&_.sort(((e,t)=>e.sortKey-t.sortKey));const y={useDepthForOcclusion:d.depthOcclusionForSymbolsAndCircles};for(const e of _){const{programConfiguration:r,program:n,layoutVertexBuffer:o,globeExtVertexBuffer:s,indexBuffer:a,uniformValues:l,tile:c}=e.state,A=e.segments;t.terrain&&t.terrain.setupElevationDraw(c,n,y),t.uploadCommonUniforms(u,n,c.tileID.toUnwrapped()),n.draw(t,h.TRIANGLES,p,f,m,Lt.disabled,l,i.id,o,a,A,i.paint,d.zoom,r,[s])}},heatmap:function(t,r,i,n){if(0!==i.paint.get("heatmap-opacity"))if("offscreen"===t.renderPass){const o=t.context,s=o.gl,a=St.disabled,l=new Pt([s.ONE,s.ONE,s.ONE,s.ONE],e.aA.transparent,[!0,!0,!0,!0]);!function(e,t,r,i){const n=e.gl,o=t.width*i,s=t.height*i;e.activeTexture.set(n.TEXTURE1),e.viewport.set([0,0,o,s]);let a=r.heatmapFbo;if(!a||a&&(a.width!==o||a.height!==s)){a&&a.destroy();const t=n.createTexture();n.bindTexture(n.TEXTURE_2D,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),a=r.heatmapFbo=e.createFramebuffer(o,s,!0,null),function(e,t,r,i,n,o){const s=e.gl;s.texImage2D(s.TEXTURE_2D,0,e.extRenderToTextureHalfFloat?s.RGBA16F:s.RGBA,n,o,0,s.RGBA,e.extRenderToTextureHalfFloat?s.HALF_FLOAT:s.UNSIGNED_BYTE,null),i.colorAttachment.set(r)}(e,0,t,a,o,s)}else n.bindTexture(n.TEXTURE_2D,a.colorAttachment.get()),e.bindFramebuffer.set(a.framebuffer)}(o,t,i,"globe"===t.transform.projection.name?.5:.25),o.clear({color:e.aA.transparent});const c=t.transform,u="globe"===c.projection.name,h=u?["PROJECTION_GLOBE_VIEW"]:[],d=u?Lt.frontCCW:Lt.disabled,p=[e.a8(c.center.lng),e.ah(c.center.lat)];for(let e=0;e<n.length;e++){const f=n[e];if(r.hasRenderableParent(f))continue;const m=r.getTile(f),A=m.getBucket(i);if(!A||A.projection.name!==c.projection.name)continue;const g=t.isTileAffectedByFog(f),_=A.programConfigurations.get(i.id),y=t.getOrCreateProgram("heatmap",{config:_,defines:h,overrideFog:g}),{zoom:x}=t.transform;t.terrain&&t.terrain.setupElevationDraw(m,y),t.uploadCommonUniforms(o,y,f.toUnwrapped());const v=c.projection.createInversionMatrix(c,f.canonical);y.draw(t,s.TRIANGLES,Et.disabled,a,l,d,Dn(t,f,m,v,p,x,i.paint.get("heatmap-intensity")),i.id,A.layoutVertexBuffer,A.indexBuffer,A.segments,i.paint,t.transform.zoom,_,u?[A.globeExtVertexBuffer]:null)}o.viewport.set([0,0,t.width,t.height])}else"translucent"===t.renderPass&&(t.context.setColorMode(t.colorModeForRenderPass()),function(t,r){const i=t.context,n=i.gl,o=r.heatmapFbo;if(!o)return;i.activeTexture.set(n.TEXTURE0),n.bindTexture(n.TEXTURE_2D,o.colorAttachment.get()),i.activeTexture.set(n.TEXTURE1);let s=r.colorRampTexture;s||(s=r.colorRampTexture=new e.T(i,r.colorRamp,n.RGBA)),s.bind(n.LINEAR,n.CLAMP_TO_EDGE),t.getOrCreateProgram("heatmapTexture").draw(t,n.TRIANGLES,Et.disabled,St.disabled,t.colorModeForRenderPass(),Lt.disabled,((e,t,r,i)=>({u_image:0,u_color_ramp:1,u_opacity:t.paint.get("heatmap-opacity")}))(0,r),r.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,r.paint,t.transform.zoom)}(t,i))},line:function(t,r,i,n){if("translucent"!==t.renderPass)return;const o=i.paint.get("line-opacity"),s=i.paint.get("line-width");if(0===o.constantOr(1)||0===s.constantOr(1))return;const a=i.paint.get("line-emissive-strength"),l=t.depthModeForSublayer(0,Et.ReadOnly),c=t.colorModeForDrapableLayerRenderPass(a),u=t.terrain&&t.terrain.renderingToTexture?1:e.f.devicePixelRatio,h=i.paint.get("line-dasharray"),d=h.constantOr(1),p=i.layout.get("line-cap"),f=i.paint.get("line-pattern"),m=f.constantOr(1),A=1!==i.paint.get("line-opacity").constantOr(1);let g=!m&&A;const _=i.paint.get("line-gradient"),y=m?"linePattern":"line",x=t.context,v=x.gl,b=e.cH(i);t.terrain&&t.terrain.clipOrMaskOverlapStencilType()&&(g=!1);for(const o of n){const n=r.getTile(o);if(m&&!n.patternsLoaded())continue;const s=n.getBucket(i);if(!s)continue;t.prepareDrawTile();const a=s.programConfigurations.get(i.id),A=t.isTileAffectedByFog(o),w=t.getOrCreateProgram(y,{config:a,defines:b,overrideFog:A}),C=f.constantOr(null);if(C&&n.imageAtlas){const e=n.imageAtlas.patternPositions[C.toString()];e&&a.setConstantPatternPositions(e)}const T=h.constantOr(null),E=p.constantOr(null);if(!m&&T&&E&&n.lineAtlas){const e=n.lineAtlas.getDash(T,E);e&&a.setConstantPatternPositions(e)}let[M,S]=i.paint.get("line-trim-offset");if("round"===E||"square"===E){const e=1;M!==S&&(0===M&&(M-=e),1===S&&(S+=e))}const I=t.terrain?o.projMatrix:null,P=m?e.cI(t,n,i,I,u,[M,S]):e.cJ(t,n,i,I,s.lineClipsArray.length,u,[M,S]);if(_){const n=s.gradients[i.id];let a=n.texture;if(i.gradientVersion!==n.version){let l=256;if(i.stepInterpolant){const i=r.getSource().maxzoom,n=o.canonical.z===i?Math.ceil(1<<t.transform.maxZoom-o.canonical.z):1;l=e.ad(e.cK(s.maxLineLength/e.Y*1024*n),256,x.maxTextureSize)}n.gradient=e.cL({expression:i.gradientExpression(),evaluationKey:"lineProgress",resolution:l,image:n.gradient||void 0,clips:s.lineClipsArray}),n.texture?n.texture.update(n.gradient):n.texture=new e.T(x,n.gradient,v.RGBA),n.version=i.gradientVersion,a=n.texture}x.activeTexture.set(v.TEXTURE1),a.bind(i.stepInterpolant?v.NEAREST:v.LINEAR,v.CLAMP_TO_EDGE)}d&&(x.activeTexture.set(v.TEXTURE0),n.lineAtlasTexture&&n.lineAtlasTexture.bind(v.LINEAR,v.REPEAT),a.updatePaintBuffers()),m&&(x.activeTexture.set(v.TEXTURE0),n.imageAtlasTexture&&n.imageAtlasTexture.bind(v.LINEAR,v.CLAMP_TO_EDGE),a.updatePaintBuffers()),t.uploadCommonUniforms(x,w,o.toUnwrapped());const D=e=>{w.draw(t,v.TRIANGLES,l,e,c,Lt.disabled,P,i.id,s.layoutVertexBuffer,s.indexBuffer,s.segments,i.paint,t.transform.zoom,a,[s.layoutVertexBuffer2,s.patternVertexBuffer])};if(g){const e=t.stencilModeForClipping(o).ref;0===e&&t.terrain&&x.clear({stencil:0});const r={func:v.EQUAL,mask:255};P.u_alpha_discard_threshold=.8,D(new St(r,e,255,v.KEEP,v.KEEP,v.INVERT)),P.u_alpha_discard_threshold=0,D(new St(r,e,255,v.KEEP,v.KEEP,v.KEEP))}else D(t.stencilModeForClipping(o))}g&&(t.resetStencilClippingMasks(),t.terrain&&x.clear({stencil:0}))},fill:function(t,r,i,n){const o=i.paint.get("fill-color"),s=i.paint.get("fill-opacity");if(0===s.constantOr(1))return;const a=i.paint.get("fill-emissive-strength"),l=t.colorModeForDrapableLayerRenderPass(a),c=i.paint.get("fill-pattern"),u=t.opaquePassEnabledForLayer()&&!c.constantOr(1)&&1===o.constantOr(e.aA.transparent).a&&1===s.constantOr(0)?"opaque":"translucent";if(t.renderPass===u){const e=t.depthModeForSublayer(1,"opaque"===t.renderPass?Et.ReadWrite:Et.ReadOnly);io(t,r,i,n,e,l,!1)}if("translucent"===t.renderPass&&i.paint.get("fill-antialias")){const e=t.depthModeForSublayer(i.getPaintProperty("fill-outline-color")?2:0,Et.ReadOnly);io(t,r,i,n,e,l,!0)}},"fill-extrusion":function(t,r,i,n){const o=i.paint.get("fill-extrusion-opacity"),s=t.context,a=s.gl,l=t.terrain,c=l&&l.renderingToTexture;if(0===o)return;const u=t.conflationActive&&t.layerUsedInConflation(i,r.getSource());if(u&&function(e,t,r,i){for(const n of i){const i=t.getTile(n).getBucket(r);i&&(i.updateReplacement(n,e.replacementSource),i.uploadCentroid(e.context))}}(t,r,i,n),l||u)for(const e of n){const n=r.getTile(e).getBucket(i);n&&so(t.context,r,e,n,i,l,u)}if("shadow"===t.renderPass&&t.shadowRenderer){const s=t.shadowRenderer;if(l&&o<.65&&i._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof e.Z)return;const a=s.getShadowPassDepthMode(),c=s.getShadowPassColorMode();no(t,r,i,n,a,St.disabled,c,u)}else if("translucent"===t.renderPass){const h=!i.paint.get("fill-extrusion-pattern").constantOr(1),d=i.paint.get("fill-extrusion-color").constantOr(e.aA.white);if(!c&&0!==d.a){const e=new Et(t.context.gl.LEQUAL,Et.ReadWrite,t.depthRangeFor3D);1===o&&h?no(t,r,i,n,e,St.disabled,Pt.unblended,u):(no(t,r,i,n,e,St.disabled,Pt.disabled,u),no(t,r,i,n,e,t.stencilModeFor3D(),t.colorModeForRenderPass(),u),t.resetStencilClippingMasks())}if(t.style.enable3dLights()&&h&&(!l&&"globe"!==t.transform.projection.name||c)){const o=i.paint.get("fill-extrusion-opacity"),h=i.paint.get("fill-extrusion-ambient-occlusion-intensity"),d=i.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),p=i.paint.get("fill-extrusion-flood-light-intensity"),f=i.paint.get("fill-extrusion-flood-light-color").toArray01().slice(0,3),m=h>0&&d>0,A=p>0,g=(e,t,r)=>(1-r)*e+r*t,_=s=>{const l=t.depthModeForSublayer(1,Et.ReadOnly,a.LEQUAL,!0),c=i.paint.get(s?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),m=g(.1,3,c),A=t._showOverdrawInspector;if(!A){const c=new St({func:a.ALWAYS,mask:255},255,255,a.KEEP,a.KEEP,a.REPLACE),A=new Pt([a.ONE,a.ONE,a.ONE,a.ONE],e.aA.transparent,[!1,!1,!1,!0],a.MIN);oo(t,r,i,n,l,c,A,Lt.disabled,s,"sdf",o,h,d,p,f,m,u,!1)}{const c=A?St.disabled:new St({func:a.EQUAL,mask:255},255,255,a.KEEP,a.DECR,a.DECR),g=A?t.colorModeForRenderPass():new Pt([a.ONE_MINUS_DST_ALPHA,a.DST_ALPHA,a.ONE,a.ONE],e.aA.transparent,[!0,!0,!0,!0]);oo(t,r,i,n,l,c,g,Lt.disabled,s,"color",o,h,d,p,f,m,u,!1)}};if(c){const c=(s,l,c)=>{const m=t.depthModeForSublayer(1,Et.ReadOnly,a.LEQUAL,!1),A=i.paint.get(s?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),_=g(.1,3,A);{const c=new Pt([a.ONE,a.ONE,a.ONE,a.ONE],e.aA.transparent,[!1,!1,!1,!0]);oo(t,r,i,n,m,St.disabled,c,Lt.disabled,s,"clear",o,h,d,p,f,_,u,l)}{const c=new St({func:a.ALWAYS,mask:255},255,255,a.KEEP,a.KEEP,a.REPLACE),A=new Pt([a.ONE,a.ONE,a.ONE,a.ONE],e.aA.transparent,[!1,!1,!1,!0],a.MIN);oo(t,r,i,n,m,c,A,Lt.disabled,s,"sdf",o,h,d,p,f,_,u,l)}{const c=s?a.ZERO:a.ONE_MINUS_DST_ALPHA,A=new St({func:a.EQUAL,mask:255},255,255,a.KEEP,a.DECR,a.DECR),g=new Pt([c,a.DST_ALPHA,a.ONE_MINUS_DST_ALPHA,a.ZERO],e.aA.transparent,[!0,!0,!0,!0]);oo(t,r,i,n,m,A,g,Lt.disabled,s,"color",o,h,d,p,f,_,u,l)}{const A=new Pt([a.ONE,a.ONE,a.ONE,s?a.ZERO:a.ONE],e.aA.transparent,[!1,!1,!1,!0],s?a.FUNC_ADD:a.MAX);oo(t,r,i,n,m,St.disabled,A,Lt.disabled,s,"clear",o,h,d,p,f,_,u,l,c)}};if(m||A){let r;if(t.prepareDrawTile(),l){const t=l.drapeBufferSize[0],i=l.drapeBufferSize[1];r=l.framebufferCopyTexture,r&&(!r||r.size[0]===t&&r.size[1]===i)||(r&&r.destroy(),r=l.framebufferCopyTexture=new e.T(s,new e.h({width:t,height:i}),a.RGBA)),r.bind(a.LINEAR,a.CLAMP_TO_EDGE),a.copyTexImage2D(a.TEXTURE_2D,0,a.RGBA,0,0,t,i,0)}m&&c(!0,!1,r),A&&c(!1,!0,r)}}else m&&_(!0),A&&_(!1)}}},hillshade:function(e,t,r,i){if("offscreen"!==e.renderPass&&"translucent"!==e.renderPass)return;if(e.style.disableElevatedTerrain)return;const n=e.context,o=e.terrain&&e.terrain.renderingToTexture,[s,a]="translucent"!==e.renderPass||o?[{},i]:e.stencilConfigForOverlap(i);for(const i of a){const n=t.getTile(i);if(n.needsHillshadePrepare&&"offscreen"===e.renderPass)Ji(e,n,r);else if("translucent"===e.renderPass){const t=e.depthModeForSublayer(0,Et.ReadOnly),a=r.paint.get("hillshade-emissive-strength"),l=e.colorModeForDrapableLayerRenderPass(a),c=o&&e.terrain?e.terrain.stencilModeForRTTOverlap(i):s[i.overscaledZ];$i(e,i,n,r,t,c,l)}}n.viewport.set([0,0,e.width,e.height]),e.resetStencilClippingMasks()},raster:function(t,r,i,n,o,s){if("translucent"!==t.renderPass)return;if(0===i.paint.get("raster-opacity"))return;const a="globe"===t.transform.projection.name,l=0!==i.paint.get("raster-elevation"),c=l&&a;if(t.renderElevatedRasterBackface&&!c)return;const u=t.context,h=u.gl,d=r.getSource(),p=function(t,r,i,n){const o=r.paint.get("raster-color"),s="raster-array"===t.type,a=[],l=r.paint.get("raster-resampling"),c=r.paint.get("raster-color-mix");let u=r.paint.get("raster-color-range");const h=[c[0],c[1],c[2],0],d=c[3];let p="nearest"===l?n.NEAREST:n.LINEAR;if(s&&(a.push("RASTER_ARRAY"),o||a.push("RASTER_COLOR"),"linear"===l&&a.push("RASTER_ARRAY_LINEAR"),p=n.NEAREST,!u&&t.rasterLayers)){const e=t.rasterLayers.find((({id:e})=>e===r.sourceLayer));e&&e.fields&&e.fields.range&&(u=e.fields.range)}if(u=u||[0,1],o){a.push("RASTER_COLOR"),i.activeTexture.set(n.TEXTURE2),r.updateColorRamp(u);let t=r.colorRampTexture;t||(t=r.colorRampTexture=new e.T(i,r.colorRamp,n.RGBA)),t.bind(n.LINEAR,n.CLAMP_TO_EDGE)}return{mix:h,range:u,offset:d,defines:a,resampling:p}}(d,i,u,h);if(d instanceof e.as&&!n.length&&!a)return;const f=i.paint.get("raster-emissive-strength"),m=t.colorModeForDrapableLayerRenderPass(f),A=t.terrain&&t.terrain.renderingToTexture,g=!t.options.moving,_="nearest"===i.paint.get("raster-resampling")?h.NEAREST:h.LINEAR;if(d instanceof e.as&&!n.length&&(d.onNorthPole||d.onSouthPole)){const e=l?t.stencilModeFor3D():St.disabled;return void po(!!d.onNorthPole,null,t,r,i,f,p,Lt.disabled,e)}if(!n.length)return;const[y,x]=d instanceof e.as||A?[{},n]:t.stencilConfigForOverlap(n),v=x[x.length-1].overscaledZ;c&&p.defines.push("PROJECTION_GLOBE_VIEW"),l&&p.defines.push("RENDER_CUTOFF");const b=(n,o,x)=>{for(const b of n){const n=b.toUnwrapped(),w=r.getTile(b);if(A&&(!w||!w.hasData()))continue;u.activeTexture.set(h.TEXTURE0);const C=mo(w,d,i,p);if(!C||!C.texture)continue;const{texture:T,mix:E,offset:M,tileSize:S,buffer:I}=C;let P,D;A?(P=Et.disabled,D=b.projMatrix):l?(P=new Et(h.LEQUAL,Et.ReadWrite,t.depthRangeFor3D),D=a?Float32Array.from(t.transform.expandedFarZProjMatrix):t.transform.calculateProjMatrix(n,g)):(P=t.depthModeForSublayer(b.overscaledZ-v,1===i.paint.get("raster-opacity")?Et.ReadWrite:Et.ReadOnly,h.LESS),D=t.transform.calculateProjMatrix(n,g));const k=t.terrain&&A?t.terrain.stencilModeForRTTOverlap(b):y[b.overscaledZ],L=s?0:i.paint.get("raster-fade-duration");w.registerFadeDuration(L);const z=r.findLoadedParent(b,0),O=un(w,z,r,t.transform,L);let B,R;t.terrain&&t.terrain.prepareDrawTile(),u.activeTexture.set(h.TEXTURE0),T.bind(_,h.CLAMP_TO_EDGE),u.activeTexture.set(h.TEXTURE1),z?(z.texture&&z.texture.bind(_,h.CLAMP_TO_EDGE),B=Math.pow(2,z.tileID.overscaledZ-w.tileID.overscaledZ),R=[w.tileID.canonical.x*B%1,w.tileID.canonical.y*B%1]):T.bind(_,h.CLAMP_TO_EDGE),T.useMipmap&&u.extTextureFilterAnisotropic&&t.transform.pitch>20&&h.texParameterf(h.TEXTURE_2D,u.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,u.extTextureFilterAnisotropicMax);const F=t.transform;let j;const V=l?fo(F):[0,0,0,0];let N,U,H,G,Z,W=0;if(c&&d instanceof e.as&&d.coordinates.length>3)N=Float32Array.from(e.aW(e.cn(new e.bv(0,0,0)))),U=Float32Array.from(F.globeMatrix),H=Float32Array.from(e.cj(F)),G=[e.a8(F.center.lng),e.ah(F.center.lat)],j=d.elevatedGlobePerspectiveTransform,Z=d.elevatedGlobeGridMatrix||new Float32Array(9);else if(c){const t=e.ck(b.canonical);W=e.cl(t.getCenter().lat),N=Float32Array.from(e.aW(e.cn(b.canonical))),U=Float32Array.from(F.globeMatrix),H=Float32Array.from(e.cj(F)),G=[e.a8(F.center.lng),e.ah(F.center.lat)],j=[0,0],Z=Float32Array.from(e.cm(b.canonical,t,W,F.worldSize/F._pixelsPerMercatorPixel))}else j=d instanceof e.as?d.perspectiveTransform:[0,0],N=new Float32Array(16),U=new Float32Array(9),H=new Float32Array(16),G=[0,0],Z=new Float32Array(9);const Q=zn(D,N,U,H,Z,R||[0,0],e.W(t.transform.zoom),G,V,B||1,O,i,j,l?i.paint.get("raster-elevation"):0,2,E,M,p.range,S,I,f),q=t.isTileAffectedByFog(b),X=t.getOrCreateProgram("raster",{defines:p.defines,overrideFog:q});if(t.uploadCommonUniforms(u,X,n),d instanceof e.as){const r=d.elevatedGlobeVertexBuffer,n=d.elevatedGlobeIndexBuffer;if(A||!a)d.boundsBuffer&&d.boundsSegments&&X.draw(t,h.TRIANGLES,P,St.disabled,m,Lt.disabled,Q,i.id,d.boundsBuffer,t.quadTriangleIndexBuffer,d.boundsSegments);else if(r&&n){const s=F.zoom<=e.bJ?d.elevatedGlobeSegments:d.getSegmentsForLongitude(F.center.lng);s&&X.draw(t,h.TRIANGLES,P,St.disabled,m,o,Q,i.id,r,n,s)}}else if(c){P=new Et(h.LEQUAL,Et.ReadOnly,t.depthRangeFor3D);const e=t.globeSharedBuffers;if(e){const[r,n,s]=e.getGridBuffers(W,!1);X.draw(t,h.TRIANGLES,P,x||k,t.colorModeForRenderPass(),o,Q,i.id,r,n,s)}}else{const{tileBoundsBuffer:e,tileBoundsIndexBuffer:r,tileBoundsSegments:n}=t.getTileBoundsBuffers(w);X.draw(t,h.TRIANGLES,P,k,m,Lt.disabled,Q,i.id,e,r,n)}}if(!(d instanceof e.as)&&c)for(const e of n){const n=e.canonical.y===(1<<e.canonical.z)-1;0===e.canonical.y&&po(!0,e,t,r,i,f,p,o,x||St.disabled),n&&po(!1,e,t,r,i,f,p,o===Lt.frontCW?Lt.backCW:Lt.frontCW,x||St.disabled)}};c?b(x,t.renderElevatedRasterBackface?Lt.backCW:Lt.frontCW,t.stencilModeFor3D()):b(x,Lt.disabled,void 0),t.resetStencilClippingMasks()},"raster-particle":function(t,r,i,n,o,s){"offscreen"===t.renderPass&&function(t,r,i,n){if(!n.length)return;const o=t.context,s=o.gl,a=r.getSource();if(!(a instanceof De))return;const l=Math.ceil(Math.sqrt(i.paint.get("raster-particle-count")));let c=i.particleFramebuffer;c?c.width!==l&&(c.destroy(),c=i.particleFramebuffer=o.createFramebuffer(l,l,!0,null)):c=i.particleFramebuffer=o.createFramebuffer(l,l,!0,null);const u=[];for(const e of n){const t=r.getTile(e);if(!(t instanceof Wt))continue;const n=Ao(t,a,i);if(!n)continue;const s=[t.tileSize,t.tileSize];let c=i.tileFramebuffer;c||(c=i.tileFramebuffer=o.createFramebuffer(s[0],s[1],!0,null));let h=t.rasterParticleState;h||(h=t.rasterParticleState=new Rt(o,e,s,l));const d=h.update(i.lastInvalidatedAt);h.particleTextureDimension!==l&&h.setParticleTextureDimension(e,l);const p=h.targetColorTexture;h.targetColorTexture=h.backgroundColorTexture,h.backgroundColorTexture=p;const f=h.particleTexture0;h.particleTexture0=h.particleTexture1,h.particleTexture1=f,u.push([e,n,h,d])}if(0===u.length)return;const h=e.f.now(),d=i.previousDrawTimestamp?.001*(h-i.previousDrawTimestamp):.0167;if(i.previousDrawTimestamp=h,i.hasColorMap()){o.activeTexture.set(s.TEXTURE0+2);let t=i.colorRampTexture;t||(t=i.colorRampTexture=new e.T(o,i.colorRamp,s.RGBA)),t.bind(s.LINEAR,s.CLAMP_TO_EDGE)}o.bindFramebuffer.set(i.tileFramebuffer.framebuffer),function(t,r,i){const n=t.context,o=n.gl,s=r.tileFramebuffer;n.activeTexture.set(o.TEXTURE0);const a={u_texture:0,u_opacity:1.05*(c=r.paint.get("raster-particle-fade-opacity-factor"))/(c+.05)},l=t.getOrCreateProgram("rasterParticleTexture",{defines:[],overrideFog:!1});var c;for(const c of i){const[,,i,u]=c;s.colorAttachment.set(i.targetColorTexture.texture),n.viewport.set([0,0,s.width,s.height]),n.clear({color:e.aA.transparent}),u&&(i.backgroundColorTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE),l.draw(t,o.TRIANGLES,Et.disabled,St.disabled,Pt.alphaBlended,Lt.disabled,a,r.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments))}}(t,i,u),function(t,r,i,n){const o=t.context,s=o.gl,a=i.tileFramebuffer,l="globe"===t.transform.projection.name,c=i.paint.get("raster-particle-max-speed");for(const u of n){const[n,h,d]=u;o.activeTexture.set(s.TEXTURE0+0),h.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE),a.colorAttachment.set(d.targetColorTexture.texture);const p=t.getOrCreateProgram("rasterParticleDraw",{defines:h.defines,overrideFog:!1});o.activeTexture.set(s.TEXTURE0+1);const f=h.scalarData?[]:[0,1,2,3].map((t=>e.cN[t](n)));f.push(n);const m=n.canonical.x,A=n.canonical.y;for(const e of f){const o=r.getTile(l?e.wrapped():e);if(!o)continue;const a=o.rasterParticleState;if(!a)continue;const u=e.canonical.x+(1<<e.canonical.z)*(e.wrap-n.wrap),d=e.canonical.y;a.particleTexture0.bind(s.NEAREST,s.CLAMP_TO_EDGE);const f=Rn(1,a.particleTexture0.size[0],[u-m,d-A],0,h.texture.size,2,c,h.textureOffset,h.scale,h.offset);p.draw(t,s.POINTS,Et.disabled,St.disabled,Pt.alphaBlended,Lt.disabled,f,i.id,a.particleIndexBuffer,void 0,a.particleSegment)}}}(t,r,i,u),o.bindFramebuffer.set(i.particleFramebuffer.framebuffer),function(t,r,i,n){const o=t.context,s=o.gl,a=r.paint.get("raster-particle-max-speed"),l=n*r.paint.get("raster-particle-speed-factor")*.3,c=function(e){return Math.pow(e,6)}(.01+1*r.paint.get("raster-particle-reset-rate-factor")),u=r.particleFramebuffer;o.viewport.set([0,0,u.width,u.height]);for(const n of i){const[,i,h]=n;o.activeTexture.set(s.TEXTURE0+0),i.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE),o.activeTexture.set(s.TEXTURE0+1);const d=h.particleTexture0;d.bind(s.NEAREST,s.CLAMP_TO_EDGE);const p=Fn(1,d.size[0],0,i.texture.size,a,l,c,i.textureOffset,i.scale,i.offset);u.colorAttachment.set(h.particleTexture1.texture),o.clear({color:e.aA.transparent}),t.getOrCreateProgram("rasterParticleUpdate",{defines:i.defines}).draw(t,s.TRIANGLES,Et.disabled,St.disabled,Pt.unblended,Lt.disabled,p,r.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments)}}(t,i,u,d)}(t,r,i,n),"translucent"===t.renderPass&&(function(t,r,i,n,o){const s=t.context,a=s.gl,l=!t.options.moving,c="globe"===t.transform.projection.name;if(!n.length)return;const[u,h]=t.stencilConfigForOverlap(n),d=[];c&&d.push("PROJECTION_GLOBE_VIEW");const p=t.stencilModeFor3D();for(const n of h){const o=n.toUnwrapped(),h=r.getTile(n);if(!h.rasterParticleState)continue;const f=h.rasterParticleState,m=100;h.registerFadeDuration(m);const A=r.findLoadedParent(n,0),g=un(h,A,r,t.transform,m);let _,y;t.terrain&&t.terrain.prepareDrawTile(),s.activeTexture.set(a.TEXTURE0),f.targetColorTexture.bind(a.LINEAR,a.CLAMP_TO_EDGE),s.activeTexture.set(a.TEXTURE1),A&&A.rasterParticleState?(A.rasterParticleState.targetColorTexture.bind(a.LINEAR,a.CLAMP_TO_EDGE),_=Math.pow(2,A.tileID.overscaledZ-h.tileID.overscaledZ),y=[h.tileID.canonical.x*_%1,h.tileID.canonical.y*_%1]):f.targetColorTexture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const x=c?Float32Array.from(t.transform.expandedFarZProjMatrix):t.transform.calculateProjMatrix(o,l),v=t.transform,b=go(v),w=e.ck(n.canonical),C=e.cl(w.getCenter().lat);let T,E,M,S,I;c?(T=Float32Array.from(e.aW(e.cn(n.canonical))),E=Float32Array.from(v.globeMatrix),M=Float32Array.from(e.cj(v)),S=[e.a8(v.center.lng),e.ah(v.center.lat)],I=Float32Array.from(e.cm(n.canonical,w,C,v.worldSize/v._pixelsPerMercatorPixel))):(T=new Float32Array(16),E=new Float32Array(9),M=new Float32Array(16),S=[0,0],I=new Float32Array(9));const P=Bn(x,T,E,M,I,y||[0,0],e.W(t.transform.zoom),S,b,_||1,g,250),D=t.isTileAffectedByFog(n),k=t.getOrCreateProgram("rasterParticle",{defines:d,overrideFog:D});if(t.uploadCommonUniforms(s,k,o),c){const e=new Et(a.LEQUAL,Et.ReadWrite,t.depthRangeFor3D),r=0,n=t.globeSharedBuffers;if(n){const[o,s,l]=n.getGridBuffers(C,0!==r);k.draw(t,a.TRIANGLES,e,p,Pt.alphaBlended,Lt.backCCW,P,i.id,o,s,l)}}else{const e=t.depthModeForSublayer(0,Et.ReadOnly),r=u[n.overscaledZ],{tileBoundsBuffer:o,tileBoundsIndexBuffer:s,tileBoundsSegments:l}=t.getTileBoundsBuffers(h);k.draw(t,a.TRIANGLES,e,r,Pt.alphaBlended,Lt.disabled,P,i.id,o,s,l)}}t.resetStencilClippingMasks()}(t,r,i,n),t.style.map.triggerRepaint())},background:function(e,t,r,i){const n=r.paint.get("background-color"),o=r.paint.get("background-opacity"),s=r.paint.get("background-emissive-strength");if(0===o)return;const a=e.context,l=a.gl,c=e.transform,u=c.tileSize,h=r.paint.get("background-pattern");if(e.isPatternMissing(h,r.scope))return;const d=!h&&1===n.a&&1===o&&e.opaquePassEnabledForLayer()?"opaque":"translucent";if(e.renderPass!==d)return;const p=St.disabled,f=e.depthModeForSublayer(0,"opaque"===d?Et.ReadWrite:Et.ReadOnly),m=e.colorModeForDrapableLayerRenderPass(s),A=h?"backgroundPattern":"background";let g,_=i;_||(g=e.getBackgroundTiles(),_=Object.values(g).map((e=>e.tileID))),h&&(a.activeTexture.set(l.TEXTURE0),e.imageManager.bind(e.context,r.scope));for(const d of _){const _=e.isTileAffectedByFog(d),y=e.getOrCreateProgram(A,{overrideFog:_}),x=d.toUnwrapped(),v=i?d.projMatrix:e.transform.calculateProjMatrix(x);e.prepareDrawTile();const b=t?t.getTile(d):g?g[d.key]:new jt(d,u,c.zoom,e),w=h?Gn(v,s,o,e,h,r.scope,{tileID:d,tileSize:u}):Hn(v,s,o,n);e.uploadCommonUniforms(a,y,x);const{tileBoundsBuffer:C,tileBoundsIndexBuffer:T,tileBoundsSegments:E}=e.getTileBoundsBuffers(b);y.draw(e,l.TRIANGLES,f,p,m,Lt.disabled,w,r.id,C,T,E)}},sky:function(t,r,i){const n=t._atmosphere?e.W(t.transform.zoom):1,o=i.paint.get("sky-opacity")*n;if(0===o)return;const s=t.context,a=i.paint.get("sky-type"),l=new Et(s.gl.LEQUAL,Et.ReadOnly,[0,1]),c=t.frameCounter/1e3%1;"atmosphere"===a?"offscreen"===t.renderPass?i.needsSkyboxCapture(t)&&(function(t,r,i,n){const o=t.context,s=o.gl;let a=r.skyboxFbo;if(!a){a=r.skyboxFbo=o.createFramebuffer(32,32,!0,null),r.skyboxGeometry=new Po(o),r.skyboxTexture=o.gl.createTexture(),s.bindTexture(s.TEXTURE_CUBE_MAP,r.skyboxTexture),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MAG_FILTER,s.LINEAR);for(let e=0;e<6;++e)s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,s.RGBA,32,32,0,s.RGBA,s.UNSIGNED_BYTE,null)}o.bindFramebuffer.set(a.framebuffer),o.viewport.set([0,0,32,32]);const l=r.getCenter(t,!0),c=t.getOrCreateProgram("skyboxCapture"),u=new Float64Array(16);e.a9.identity(u),e.a9.rotateY(u,u,.5*-Math.PI),Do(t,r,c,u,l,0),e.a9.identity(u),e.a9.rotateY(u,u,.5*Math.PI),Do(t,r,c,u,l,1),e.a9.identity(u),e.a9.rotateX(u,u,.5*-Math.PI),Do(t,r,c,u,l,2),e.a9.identity(u),e.a9.rotateX(u,u,.5*Math.PI),Do(t,r,c,u,l,3),e.a9.identity(u),Do(t,r,c,u,l,4),e.a9.identity(u),e.a9.rotateY(u,u,Math.PI),Do(t,r,c,u,l,5),o.viewport.set([0,0,t.width,t.height])}(t,i),i.markSkyboxValid(t)):"sky"===t.renderPass&&function(e,t,r,i,n){const o=e.context,s=o.gl,a=e.transform,l=e.getOrCreateProgram("skybox");o.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_CUBE_MAP,t.skyboxTexture);const c=((e,t,r,i,n)=>({u_matrix:e,u_sun_direction:t,u_cubemap:0,u_opacity:i,u_temporal_offset:n}))(a.skyboxMatrix,t.getCenter(e,!1),0,i,n);e.uploadCommonUniforms(o,l),l.draw(e,s.TRIANGLES,r,St.disabled,e.colorModeForRenderPass(),Lt.backCW,c,"skybox",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment)}(t,i,l,o,c):"gradient"===a&&"sky"===t.renderPass&&function(t,r,i,n,o){const s=t.context,a=s.gl,l=t.transform,c=t.getOrCreateProgram("skyboxGradient");r.skyboxGeometry||(r.skyboxGeometry=new Po(s)),s.activeTexture.set(a.TEXTURE0);let u=r.colorRampTexture;u||(u=r.colorRampTexture=new e.T(s,r.colorRamp,a.RGBA)),u.bind(a.LINEAR,a.CLAMP_TO_EDGE);const h=((t,r,i,n,o)=>({u_matrix:t,u_color_ramp:0,u_center_direction:r,u_radius:e.bm(i),u_opacity:n,u_temporal_offset:o}))(l.skyboxMatrix,r.getCenter(t,!1),r.paint.get("sky-gradient-radius"),n,o);t.uploadCommonUniforms(s,c),c.draw(t,a.TRIANGLES,i,St.disabled,t.colorModeForRenderPass(),Lt.backCW,h,"skyboxGradient",r.skyboxGeometry.vertexBuffer,r.skyboxGeometry.indexBuffer,r.skyboxGeometry.segment)}(t,i,l,o,c)},debug:function(t,r,i,n,o,s){for(let a=0;a<i.length;a++)if(o){const o=1,l=.8,c=new e.aA(n.r*l,n.g*l,n.b*l,1);wo(t,r,i[a],n,-o,-o,s),wo(t,r,i[a],n,-o,o,s),wo(t,r,i[a],n,o,o,s),wo(t,r,i[a],n,o,-o,s),wo(t,r,i[a],c,0,0,s)}else wo(t,r,i[a],n,0,0,s)},custom:function(t,r,i,n){const o=t.context,s=i.implementation;if(!t.transform.projection.unsupportedLayers||!t.transform.projection.unsupportedLayers.includes("custom")||t.terrain&&(t.terrain.renderingToTexture||"offscreen"===t.renderPass)&&i.isDraped(r)){if("offscreen"===t.renderPass){const r=s.prerender;if(r){if(t.setCustomLayerDefaults(),o.setColorMode(t.colorModeForRenderPass()),"globe"===t.transform.projection.name){const i=t.transform.pointMerc;r.call(s,o.gl,t.transform.customLayerMatrix(),t.transform.getProjection(),t.transform.globeToMercatorMatrix(),e.W(t.transform.zoom),[i.x,i.y],t.transform.pixelsPerMeterRatio)}else r.call(s,o.gl,t.transform.customLayerMatrix());o.setDirty(),t.setBaseState()}}else if("translucent"===t.renderPass){if(t.terrain&&t.terrain.renderingToTexture){const r=s.renderToTile;if(r){const i=n[0].canonical,a=new e.O(i.x+n[0].wrap*(1<<i.z),i.y,i.z);o.setDepthMode(Et.disabled),o.setStencilMode(St.disabled),o.setColorMode(t.colorModeForRenderPass()),t.setCustomLayerDefaults(),r.call(s,o.gl,a),o.setDirty(),t.setBaseState()}return}t.setCustomLayerDefaults(),o.setColorMode(t.colorModeForRenderPass()),o.setStencilMode(St.disabled);const r="3d"===s.renderingMode?new Et(t.context.gl.LEQUAL,Et.ReadWrite,t.depthRangeFor3D):t.depthModeForSublayer(0,Et.ReadOnly);if(o.setDepthMode(r),"globe"===t.transform.projection.name){const r=t.transform.pointMerc;s.render(o.gl,t.transform.customLayerMatrix(),t.transform.getProjection(),t.transform.globeToMercatorMatrix(),e.W(t.transform.zoom),[r.x,r.y],t.transform.pixelsPerMeterRatio)}else s.render(o.gl,t.transform.customLayerMatrix());o.setDirty(),t.setBaseState(),o.bindFramebuffer.set(null)}}else e.w("Custom layers are not yet supported with this projection. Use mercator or globe to enable usage of custom layers.")},model:function(t,r,i,n){if("opaque"===t.renderPass)return;const o=i.paint.get("model-opacity");if(0===o)return;const s=i.paint.get("model-cast-shadows");if("shadow"===t.renderPass){if(!s)return;if(t.terrain&&o<.65&&i._transitionablePaint._values["model-opacity"].value.expression instanceof e.Z)return}const a=t.shadowRenderer,l=i.paint.get("model-receive-shadows");a&&(a.useNormalOffset=!0,l||(a.enabled=!1));const c=()=>{a&&(a.useNormalOffset=!0,l||(a.enabled=!0))},u=r.getSource();if("light-beam"===t.renderPass&&"batched-model"!==u.type)return;if("vector"===u.type||"geojson"===u.type)return function(t,r,i,n,o){const s=t.transform;if("mercator"!==s.projection.name)return void e.w(`Drawing 3D models for ${s.projection.name} projection is not yet implemented`);const a=s.getFreeCameraOptions().position;if(!t.modelManager)return;const l=t.modelManager;i.modelManager=l;const c=t.shadowRenderer;if(!i._unevaluatedLayout._values.hasOwnProperty("model-id"))return;const u=i._unevaluatedLayout._values["model-id"],h={...i.layout.get("model-id").parameters};for(const d of n){const n=r.getTile(d).getBucket(i);if(!n||n.projection.name!==s.projection.name)continue;const p=n.getModelUris();p&&!n.modelsRequested&&(l.addModelsFromBucket(p,o),n.modelsRequested=!0);const f=Go(d,s);h.zoom=f;const m=u.possiblyEvaluate(h);if(Uo(t,n,d),Ho.shadowUniformsInitialized=!1,Ho.useSingleShadowCascade=!!c&&0===c.getMaxCascadeForTile(d.toUnwrapped()),"shadow"===t.renderPass&&c){if(1===t.currentShadowCascade&&n.isInsideFirstShadowMapFrustum)continue;const r=s.calculatePosMatrix(d.toUnwrapped(),s.worldSize);if(Ho.tileMatrix.set(r),Ho.shadowTileMatrix=Float32Array.from(c.calculateShadowPassMatrixFromMatrix(r)),Ho.aabb.min.fill(0),Ho.aabb.max[0]=Ho.aabb.max[1]=e.Y,Ho.aabb.max[2]=0,Qo(n,Ho,t,i.scope))continue}const A=1<<d.canonical.z,g=[((a.x-d.wrap)*A-d.canonical.x)*e.Y,(a.y*A-d.canonical.y)*e.Y,a.z*A*e.Y];for(let e in n.instancesPerModel){const r=n.instancesPerModel[e];r.features.length>0&&(e=m.evaluate(r.features[0].feature,{}));const s=l.getModel(e,o);if(s&&s.uploaded)for(const e of s.nodes)Zo(t,i,e,r,g,d,Ho)}}}(t,r,i,n,"vector"===u.type?i.scope:""),void c();if(!u.loaded())return;if("batched-model"===u.type)return function(t,r,i,n){i.resetLayerRenderingStats(t);const o=t.context,s=t.transform,a=t.style.fog,l=t.shadowRenderer;if("mercator"!==s.projection.name)return void e.w(`Drawing 3D landmark models for ${s.projection.name} projection is not yet implemented`);const c=t.transform.getFreeCameraOptions().position,u=e.Q.scale([],[c.x,c.y,c.z],t.transform.worldSize);e.Q.negate(u,u);const h=e.a9.identity([]),d=e.cZ(s.center.lat,s.zoom),p=e.a9.fromScaling([],[1,1,1/d]);e.a9.translate(h,h,u);const f=i.paint.get("model-opacity"),m=new Et(o.gl.LEQUAL,Et.ReadWrite,t.depthRangeFor3D),A=new Et(o.gl.LEQUAL,Et.ReadOnly,t.depthRangeFor3D),g=new e.bV([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),_="shadow"===t.renderPass,y=_&&l?l.getCurrentCascadeFrustum():s.getFrustum(s.scaleZoom(s.worldSize)),x=i.getLayerRenderingStats(),v=function(c,u){for(const d of n){const n=r.getTile(d).getBucket(i);if(!n||!n.uploaded)continue;let v=!1;l&&(v=0===l.getMaxCascadeForTile(d.toUnwrapped()));const b=s.calculatePosMatrix(d.toUnwrapped(),s.worldSize),w=n.modelTraits;for(const r of n.getNodesInfo()){if(r.hiddenByReplacement)continue;if(!r.node.meshes)continue;const n=r.evaluatedScale,d=r.node;let C=0;if(t.terrain&&d.elevation&&(C=d.elevation*t.terrain.exaggeration()),n[0]<=1&&n[1]<=1&&n[2]<=1&&0===(()=>{const t=r.getLocalBounds();return g.min=[...t.min],g.max=[...t.max],g.min[2]+=C,g.max[2]+=C,e.Q.transformMat4(g.min,g.min,b),e.Q.transformMat4(g.max,g.max,b),g})().intersects(y))continue;const T=[...b];e.a9.translate(T,T,[(d.anchor?d.anchor[0]:0)*(n[0]-1),(d.anchor?d.anchor[1]:0)*(n[1]-1),C]),e.Q.exactEquals(n,e.c$)||e.a9.scale(T,T,n);const E=e.a9.multiply([],T,d.matrix);let M=e.a9.multiply([],p,T);e.a9.multiply(M,h,M);const S=e.a9.invert([],M);e.a9.transpose(S,S),e.a9.scale(S,S,Wo),M=e.a9.multiply(M,M,d.matrix);const I="light-beam"===t.renderPass,P=e.a9.multiply([],s.expandedFarZProjMatrix,E),D=e.a9.multiply([],s.expandedFarZProjMatrix,T),k=w&e.d1.HasMapboxMeshFeatures,L=k?0:r.evaluatedRMEA[0][2];for(let e=0;e<d.meshes.length;++e){const n=d.meshes[e],h=e===d.lightMeshIndex;let p=P;if(h){if(!I&&!t.terrain&&t.shadowRenderer){t.currentLayer<t.firstLightBeamLayer&&(t.firstLightBeamLayer=t.currentLayer);continue}p=D}else if(I)continue;const g={defines:[]},y=[];if(Fo(g.defines,y,n,t),k||g.defines.push("DIFFUSE_SHADED"),v&&g.defines.push("SHADOWS_SINGLE_CASCADE"),x&&(_?x.numRenderedVerticesInShadowPass+=n.vertexArray.length:x.numRenderedVerticesInTransparentPass+=n.vertexArray.length),_){No(n,E,t,i);continue}let b=null;if(a){const e=Ro(E,t.transform);if(b=new Float32Array(e),"globe"!==s.projection.name){const t=n.aabb.min,r=n.aabb.max,[i,o]=a.getOpacityForBounds(e,t[0],t[1],r[0],r[1]);g.overrideFog=i>=pe||o>=pe}}const w=n.material;let C;w.occlusionTexture&&w.occlusionTexture.offsetScale&&(C=w.occlusionTexture.offsetScale,g.defines.push("OCCLUSION_TEXTURE_TRANSFORM")),!_&&l&&(l.useNormalOffset=!!n.normalBuffer);const z=t.getOrCreateProgram("model",g);!_&&l&&l.setupShadowsFromMatrix(T,z,l.useNormalOffset),t.uploadCommonUniforms(o,z,null,b);const O=w.pbrMetallicRoughness;O.metallicFactor=.9,O.roughnessFactor=.5;const B=Wn(new Float32Array(p),new Float32Array(M),new Float32Array(S),new Float32Array(d.matrix),t,f,O.baseColorFactor,w.emissiveFactor,O.metallicFactor,O.roughnessFactor,w,L,i,[0,0,0],C);z.draw(t,o.gl.TRIANGLES,u&&!h?m:A,St.disabled,c?h||f<1||r.hasTranslucentParts?Pt.alphaBlended:Pt.unblended:Pt.disabled,Lt.backCCW,B,i.id,n.vertexBuffer,n.indexBuffer,n.segments,i.paint,t.transform.zoom,void 0,y)}}}};(function(e,t,r,i){const n=e.terrain?e.terrain.exaggeration():0,o=e.transform.zoom;for(const s of i){const i=t.getTile(s).getBucket(r);i&&(e.conflationActive&&i.updateReplacement(s,e.replacementSource),i.evaluateScale(e,r),e.terrain&&n>0&&i.elevationUpdate(e.terrain,n,s,r.source),i.needsReEvaluation(e,o,r)&&i.evaluate(r))}})(t,r,i,n),1===f?v(!0,!0):(v(!1,!0),v(!0,!1))}(t,r,i,n),void c();const h=u.getModels(),d=[],p=t.transform.getFreeCameraOptions().position,f=e.Q.scale([],[p.x,p.y,p.z],t.transform.worldSize);e.Q.negate(f,f);const m=[],A=[];let g=0;for(const r of h){const n=i.paint.get("model-rotation").constantOr(null),o=i.paint.get("model-scale").constantOr(null),s=i.paint.get("model-translation").constantOr(null);r.computeModelMatrix(t,n,o,s,!0,!0,!1);const a=e.a9.identity([]),l=e.cZ(r.position.lat,t.transform.zoom),c=e.a9.fromScaling([],[1,1,1/l]);e.a9.translate(a,a,f),d.push({zScaleMatrix:c,negCameraPosMatrix:a});for(const e of r.nodes)Vo(t.transform,e,r.matrix,t.transform.expandedFarZProjMatrix,g,m,A);g++}if(m.sort(((e,t)=>t.depth-e.depth)),"shadow"!==t.renderPass){if(1===o)for(const e of A)jo(e,t,i,d[e.modelIndex],St.disabled,t.colorModeForRenderPass());else{for(const e of A)jo(e,t,i,d[e.modelIndex],St.disabled,Pt.disabled);for(const e of A)jo(e,t,i,d[e.modelIndex],t.stencilModeFor3D(),t.colorModeForRenderPass());t.resetStencilClippingMasks()}for(const e of m)jo(e,t,i,d[e.modelIndex],St.disabled,t.colorModeForRenderPass());c()}else{for(const e of A)No(e.mesh,e.nodeModelMatrix,t,i);for(const e of m)No(e.mesh,e.nodeModelMatrix,t,i);c()}}},$o={model:function(e,t,r){const i=t.getSource();if(!i.loaded())return;if("vector"===i.type||"geojson"===i.type)return void(r.modelManager&&r.modelManager.upload(r,"vector"===i.type?e.scope:""));if("batched-model"===i.type)return;const n=i.getModels();for(const e of n)e.upload(r.context)},raster:function(e,t,r){const i=t.getSource();if(!(i instanceof De&&i.loaded()))return;const n=e.sourceLayer||i.rasterLayerIds&&i.rasterLayerIds[0];if(!n)return;const o=e.paint.get("raster-array-band")||i.getInitialBand(n);if(null==o)return;const s=t.getIds().map((e=>t.getTileByID(e)));for(const e of s)e.updateNeeded(n,o)&&i.prepareTile(e,n,o)},"raster-particle":function(e,t,r){const i=t.getSource();if(!(i instanceof De&&i.loaded()))return;const n=e.sourceLayer||i.rasterLayerIds&&i.rasterLayerIds[0];if(!n)return;const o=e.paint.get("raster-particle-array-band")||i.getInitialBand(n);if(null==o)return;const s=t.getIds().map((e=>t.getTileByID(e)));for(const e of s)e.updateNeeded(n,o)&&i.prepareTile(e,n,o)}};class Ko{constructor(t,r,i,n){this.context=new zt(t,r),this.transform=i,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.tp=n,this._timeStamp=(new Date).getTime(),this._averageFPS=0,this._fpsHistory=[],this._debugParams={showTerrainProxyTiles:!1,fpsWindow:30,continousRedraw:!1,enabledLayers:{}};const o=["fill","line","symbol","circle","heatmap","fill-extrusion","raster","raster-particle","hillshade","model","background","sky"];for(const e of o)this._debugParams.enabledLayers[e]=!0;n.registerParameter(this._debugParams,["Terrain"],"showTerrainProxyTiles",{},(()=>{this.style.map.triggerRepaint()})),n.registerParameter(this._debugParams,["FPS"],"fpsWindow",{min:1,max:100,step:1}),n.registerBinding(this._debugParams,["FPS"],"continousRedraw",{readonly:!0,label:"continuous redraw"}),n.registerBinding(this,["FPS"],"_averageFPS",{readonly:!0,label:"value"}),n.registerBinding(this,["FPS"],"_averageFPS",{readonly:!0,label:"graph",view:"graph",min:0,max:200});for(const e of o)n.registerParameter(this._debugParams.enabledLayers,["Debug","Layers"],e);this.setup(),this.numSublayers=qt.maxUnderzooming+qt.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.deferredRenderGpuTimeQueries=[],this.gpuTimers={},this.frameCounter=0,this._backgroundTiles={},this.conflationActive=!1,this.replacementSource=new e.d3,this.longestCutoffRange=0,this.minCutoffZoom=0,this._fogVisible=!1,this._cachedTileFogOpacities={},this._shadowRenderer=new yi(this),this._wireframeDebugCache=new Xo,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0}updateTerrain(e,t){const r=!!e&&!!e.terrain&&this.transform.projection.supportsTerrain;if(!(r||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new fn(this,e));const i=this._terrain;this.transform.elevation=r?i:null,i.update(e,this.transform,t),this.transform.elevation&&!i.enabled&&(this.transform.elevation=null)}_updateFog(e){const t=e.fog;if(!t||"globe"===this.transform.projection.name||t.getOpacity(this.transform.pitch)<1||t.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);const[r,i]=t.getFovAdjustedRange(this.transform._fov);if(r>i)return void(this.transform.fogCullDistSq=null);const n=r+.78*(i-r);this.transform.fogCullDistSq=n*n}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}get shadowRenderer(){return this._shadowRenderer&&this._shadowRenderer.enabled?this._shadowRenderer:null}get wireframeDebugCache(){return this._wireframeDebugCache}resize(t,r){if(this.width=t*e.f.devicePixelRatio,this.height=r*e.f.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const e of this.style.order)this.style._mergedLayers[e].resize()}setup(){const t=this.context,r=new e.aQ;r.emplaceBack(0,0),r.emplaceBack(e.Y,0),r.emplaceBack(0,e.Y),r.emplaceBack(e.Y,e.Y),this.tileExtentBuffer=t.createVertexBuffer(r,e.aS.members),this.tileExtentSegments=e.aE.simpleSegment(0,0,4,2);const i=new e.aQ;i.emplaceBack(0,0),i.emplaceBack(e.Y,0),i.emplaceBack(0,e.Y),i.emplaceBack(e.Y,e.Y),this.debugBuffer=t.createVertexBuffer(i,e.aS.members),this.debugSegments=e.aE.simpleSegment(0,0,4,5);const n=new e.aQ;n.emplaceBack(-1,-1),n.emplaceBack(1,-1),n.emplaceBack(-1,1),n.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(n,e.aS.members),this.viewportSegments=e.aE.simpleSegment(0,0,4,2);const o=new e.ay;o.emplaceBack(0,0,0,0),o.emplaceBack(e.Y,0,e.Y,0),o.emplaceBack(0,e.Y,0,e.Y),o.emplaceBack(e.Y,e.Y,e.Y,e.Y),this.mercatorBoundsBuffer=t.createVertexBuffer(o,e.aU.members),this.mercatorBoundsSegments=e.aE.simpleSegment(0,0,4,2);const s=new e.az;s.emplaceBack(0,1,2),s.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(s);const a=new e.aR;for(const e of[0,1,3,2,0])a.emplaceBack(e);this.debugIndexBuffer=t.createIndexBuffer(a),this.emptyTexture=new e.T(t,new e.h({width:1,height:1},Uint8Array.of(0,0,0,0)),t.gl.RGBA),this.identityMat=e.a9.create();const l=this.context.gl;this.stencilClearMode=new St({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.loadTimeStamps.push(performance.now())}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(e){return e._makeTileBoundsBuffers(this.context,this.transform.projection),e._tileBoundsBuffer?{tileBoundsBuffer:e._tileBoundsBuffer,tileBoundsIndexBuffer:e._tileBoundsIndexBuffer,tileBoundsSegments:e._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const e=this.context.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.getOrCreateProgram("clippingMask").draw(this,e.TRIANGLES,Et.disabled,this.stencilClearMode,Pt.disabled,Lt.disabled,cn(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(e,t,r){if(!t||this.currentStencilSource===t.id||!e.isTileClipped()||!r||0===r.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let e=!1;for(const t of r)if(void 0===this._tileClippingMaskIDs[t.key]){e=!0;break}if(!e)return}this.currentStencilSource=t.id;const i=this.context,n=i.gl;this.nextStencilID+r.length>256&&this.clearStencil(),i.setColorMode(Pt.disabled),i.setDepthMode(Et.disabled);const o=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const e of r){const r=t.getTile(e),i=this._tileClippingMaskIDs[e.key]=this.nextStencilID++,{tileBoundsBuffer:s,tileBoundsIndexBuffer:a,tileBoundsSegments:l}=this.getTileBoundsBuffers(r);o.draw(this,n.TRIANGLES,Et.disabled,new St({func:n.ALWAYS,mask:0},i,255,n.KEEP,n.KEEP,n.REPLACE),Pt.disabled,Lt.disabled,cn(e.projMatrix),"$clipping",s,a,l)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,t=this.context.gl;return new St({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(e);const t=this.context.gl;return new St({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}stencilConfigForOverlap(e){const t=this.context.gl,r=e.sort(((e,t)=>t.overscaledZ-e.overscaledZ)),i=r[r.length-1].overscaledZ,n=r[0].overscaledZ-i+1;if(n>1){this.currentStencilSource=void 0,this.nextStencilID+n>256&&this.clearStencil();const e={};for(let r=0;r<n;r++)e[r+i]=new St({func:t.GEQUAL,mask:255},r+this.nextStencilID,255,t.KEEP,t.KEEP,t.REPLACE);return this.nextStencilID+=n,[e,r]}return[{[i]:St.disabled},r]}colorModeForRenderPass(){const t=this.context.gl;if(this._showOverdrawInspector){const r=1/8;return new Pt([t.CONSTANT_COLOR,t.ONE,t.CONSTANT_COLOR,t.ONE],new e.aA(r,r,r,0),[!0,!0,!0,!0])}return"opaque"===this.renderPass?Pt.unblended:Pt.alphaBlended}colorModeForDrapableLayerRenderPass(t){const r=this.context.gl;return(()=>this.style&&this.style.enable3dLights()&&this.terrain&&this.terrain.renderingToTexture)()&&"translucent"===this.renderPass?new Pt([r.ONE,r.ONE_MINUS_SRC_ALPHA,r.CONSTANT_ALPHA,r.ONE_MINUS_SRC_ALPHA],new e.aA(0,0,0,void 0===t?0:t),[!0,!0,!0,!0]):this.colorModeForRenderPass()}depthModeForSublayer(e,t,r,i=!1){if(!this.opaquePassEnabledForLayer()&&!i)return Et.disabled;const n=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new Et(r||this.context.gl.LEQUAL,t,[n,n])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}updateAverageFPS(){const e=(new Date).getTime(),t=e-this._timeStamp;this._timeStamp=e,this._fpsHistory.push(0===t?0:1e3/t),this._fpsHistory.length>this._debugParams.fpsWindow&&this._fpsHistory.splice(0,this._fpsHistory.length-this._debugParams.fpsWindow),this._averageFPS=Math.round(this._fpsHistory.reduce(((e,t)=>e+t/this._fpsHistory.length),0))}render(t,r){this._wireframeDebugCache.update(this.frameCounter),this._debugParams.continousRedraw=t.map.repaint,this.style=t,this.options=r;const i=this.style._mergedLayers,n=this.style.order.filter((e=>{const t=i[e];return!(t.type in this._debugParams.enabledLayers)||this._debugParams.enabledLayers[t.type]})),o=n.map((e=>i[e])),s=this.style._mergedSourceCaches;this.imageManager=t.imageManager,this.modelManager=t.modelManager,this.symbolFadeChange=t.placement.symbolFadeChange(e.f.now()),this.imageManager.beginFrame();let a=0,l=!1;for(const e in s){const t=s[e];t.used&&(t.prepare(this.context),t.getSource().usedInConflation&&++a)}for(const e of o)e.isHidden(this.transform.zoom)||this.prepareLayer(e);const c={},u={},h={},d={},p={};for(const e in s){const t=s[e];c[e]=t.getVisibleCoordinates(),u[e]=c[e].slice().reverse(),h[e]=t.getVisibleCoordinates(!0).reverse(),d[e]=t.getShadowCasterCoordinates(),p[e]=t.sortCoordinatesByDistance(c[e])}const f=e=>{const t=this.style.getLayerSourceCache(e);return t&&t.used?t.getSource():null};if(a){const e=[];for(const t of o)this.layerUsedInConflation(t,f(t))&&e.push(t);if(e&&e.length>1){const t=[];for(const r of e){const e=this.style.getLayerSourceCache(r);e&&e.used&&e.getSource().usedInConflation&&t.push({layer:r.fqid,cache:e})}this.replacementSource.setSources(t),l=!0}}l||this.replacementSource.clear(),this.conflationActive=l,this.minCutoffZoom=0,this.longestCutoffRange=0;for(const e of o){const t=e.cutoffRange();if(this.longestCutoffRange=Math.max(t,this.longestCutoffRange),t>0){const t=f(e);t&&(this.minCutoffZoom=Math.max(t.minzoom,this.minCutoffZoom)),e.minzoom&&(this.minCutoffZoom=Math.max(e.minzoom,this.minCutoffZoom))}}this.opaquePassCutoff=1/0;for(let e=0;e<o.length;e++)if(o[e].is3D()){this.opaquePassCutoff=e;break}const m=this.style&&this.style.fog;m?(this._fogVisible=0!==m.getOpacity(this.transform.pitch),this._fogVisible&&"globe"!==this.transform.projection.name&&(this._fogVisible=m.isVisibleOnFrustum(this.transform.cameraFrustum))):this._fogVisible=!1,this._cachedTileFogOpacities={},this.terrain&&(this.terrain.updateTileBinding(h),this.opaquePassCutoff=0);const A=this._shadowRenderer;if(A){A.updateShadowParameters(this.transform,this.style.directionalLight);for(const e in s)for(const t of c[e]){let e={min:0,max:0};this.terrain&&(e=this.terrain.getMinMaxForTile(t)||e),A.addShadowReceiver(t.toUnwrapped(),e.min,e.max)}}if("globe"!==this.transform.projection.name||this.globeSharedBuffers||(this.globeSharedBuffers=new e.d4(this.context)),this.style.fog&&this.transform.projection.supportsFog?(this._atmosphere||(this._atmosphere=new Bo(this)),this._atmosphere.update(this)):this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0),!e.d5(this.context.gl))return;this.renderPass="offscreen";for(const e of o){const r=t.getLayerSourceCache(e);if(!e.hasOffscreenPass()||e.isHidden(this.transform.zoom))continue;const i=r?u[r.id]:void 0;("custom"===e.type||"raster"===e.type||"raster-particle"===e.type||e.isSky()||i&&i.length)&&this.renderLayer(this,r,e,i)}this.depthRangeFor3D=[0,1-(o.length+2)*this.numSublayers*this.depthEpsilon];const g=this.terrain;g&&(this.style.hasSymbolLayers()||this.style.hasCircleLayers())&&!this.transform.isOrthographic&&g.drawDepth(),this._shadowRenderer&&(this.renderPass="shadow",this._shadowRenderer.drawShadowPass(this.style,d)),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]);const _="globe"===this.transform.projection.name||this.transform.isHorizonVisible(),y=(()=>{if(r.showOverdrawInspector)return e.aA.black;if(this.style.fog&&this.transform.projection.supportsFog&&!_){const t=this.style.fog.properties.get("color").toArray01();return new e.aA(...t)}if(this.style.fog&&this.transform.projection.supportsFog&&_){const t=this.style.fog.properties.get("space-color").toArray01();return new e.aA(...t)}return e.aA.transparent})();if(this.context.clear({color:y,depth:1}),this.clearStencil(),this._showOverdrawInspector=r.showOverdrawInspector,this.renderPass="opaque",this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&_&&this._atmosphere.drawStars(this,this.style.fog),!this.terrain)for(this.currentLayer=n.length-1;this.currentLayer>=0;this.currentLayer--){const e=o[this.currentLayer],r=t.getLayerSourceCache(e);if(e.isSky())continue;const i=r?(e.is3D()?p:u)[r.id]:void 0;this._renderTileClippingMasks(e,r,i),this.renderLayer(this,r,e,i)}if(this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&_&&this._atmosphere.drawAtmosphereGlow(this,this.style.fog),this.renderPass="sky",(!this._atmosphere||e.W(this.transform.zoom)>0)&&("globe"===this.transform.projection.name||this.transform.isHorizonVisible()))for(this.currentLayer=0;this.currentLayer<n.length;this.currentLayer++){const e=o[this.currentLayer],r=t.getLayerSourceCache(e);e.isSky()&&this.renderLayer(this,r,e,r?u[r.id]:void 0)}function x(e,t){let r;return t&&(r=("symbol"===e.type?h:e.is3D()?p:u)[t.id]),r}if(this.renderPass="translucent","globe"===this.transform.projection.name){for(this.renderElevatedRasterBackface=!0,this.currentLayer=0;this.currentLayer<n.length;){const e=o[this.currentLayer];if("raster"===e.type){const r=t.getLayerSourceCache(e);this.renderLayer(this,r,e,x(e,r))}++this.currentLayer}this.renderElevatedRasterBackface=!1}this.currentLayer=0,this.firstLightBeamLayer=Number.MAX_SAFE_INTEGER;let v=0;for(A&&(v=A.getShadowCastingLayerCount());this.currentLayer<n.length;){const e=o[this.currentLayer],r=t.getLayerSourceCache(e);if(e.isSky())++this.currentLayer;else if(g&&this.style.isLayerDraped(e)){if(e.isHidden(this.transform.zoom)){++this.currentLayer;continue}this.currentLayer=g.renderBatch(this.currentLayer)}else{if(this._renderTileClippingMasks(e,r,r?c[r.id]:void 0),this.renderLayer(this,r,e,x(e,r)),!g&&A&&v>0&&e.hasShadowPass()&&0==--v&&(A.drawGroundShadows(),this.firstLightBeamLayer<=this.currentLayer)){const e=this.currentLayer;for(this.renderPass="light-beam",this.currentLayer=this.firstLightBeamLayer;this.currentLayer<=e;this.currentLayer++){const e=o[this.currentLayer];if(!e.hasLightBeamPass())continue;const r=t.getLayerSourceCache(e);this.renderLayer(this,r,e,r?u[r.id]:void 0)}this.currentLayer=e,this.renderPass="translucent"}++this.currentLayer}}if(this.terrain&&this.terrain.postRender(),this.options.showTileBoundaries||this.options.showQueryGeometry||this.options.showTileAABBs){let r=null;o.forEach((e=>{const i=t.getLayerSourceCache(e);i&&!e.isHidden(this.transform.zoom)&&i.getVisibleCoordinates().length&&(!r||r.getSource().maxzoom<i.getSource().maxzoom)&&(r=i)})),r&&this.options.showTileBoundaries&&Yo.debug(this,r,r.getVisibleCoordinates(),e.aA.red,!1,this.options.showParseStatus)}this.terrain&&this._debugParams.showTerrainProxyTiles&&Yo.debug(this,this.terrain.proxySourceCache,this.terrain.proxyCoords,new e.aA(1,.8,.1,1),!0,this.options.showParseStatus),this.options.showPadding&&function(e){const t=e.transform.padding;Co(e,e.transform.height-(t.top||0),3,_o),Co(e,t.bottom||0,3,yo),To(e,t.left||0,3,xo),To(e,e.transform.width-(t.right||0),3,vo);const r=e.transform.centerPoint;!function(e,t,r,i){Eo(e,t-1,r-10,2,20,i),Eo(e,t-10,r-1,20,2,i)}(e,r.x,e.transform.height-r.y,bo)}(this),this.context.setDefault(),this.frameCounter=(this.frameCounter+1)%Number.MAX_SAFE_INTEGER,this.tileLoaded&&this.options.speedIndexTiming&&(this.loadTimeStamps.push(performance.now()),this.saveCanvasCopy()),l||(this.conflationActive=!1)}prepareLayer(e){this.gpuTimingStart(e);const{unsupportedLayers:t}=this.transform.projection,r=!t||!t.includes(e.type);if($o[e.type]&&(r||this.terrain&&"custom"===e.type)){const t=this.style.getLayerSourceCache(e);$o[e.type](e,t,this)}this.gpuTimingEnd()}renderLayer(e,t,r,i){r.isHidden(this.transform.zoom)||("background"===r.type||"sky"===r.type||"custom"===r.type||"model"===r.type||"raster"===r.type||"raster-particle"===r.type||i&&i.length)&&(this.id=r.id,this.gpuTimingStart(r),(!e.transform.projection.unsupportedLayers||!e.transform.projection.unsupportedLayers.includes(r.type)||e.terrain&&"custom"===r.type)&&Yo[r.type](e,t,r,i,this.style.placement.variableOffsets,this.options.isInitialLoad),this.gpuTimingEnd())}gpuTimingStart(e){if(!this.options.gpuTiming)return;const t=this.context.extTimerQuery,r=this.context.gl;let i=this.gpuTimers[e.id];i||(i=this.gpuTimers[e.id]={calls:0,cpuTime:0,query:r.createQuery()}),i.calls++,r.beginQuery(t.TIME_ELAPSED_EXT,i.query)}gpuTimingDeferredRenderStart(){if(this.options.gpuTimingDeferredRender){const e=this.context.extTimerQuery,t=this.context.gl,r=t.createQuery();this.deferredRenderGpuTimeQueries.push(r),t.beginQuery(e.TIME_ELAPSED_EXT,r)}}gpuTimingDeferredRenderEnd(){this.options.gpuTimingDeferredRender&&this.context.gl.endQuery(this.context.extTimerQuery.TIME_ELAPSED_EXT)}gpuTimingEnd(){this.options.gpuTiming&&this.context.gl.endQuery(this.context.extTimerQuery.TIME_ELAPSED_EXT)}collectGpuTimers(){const e=this.gpuTimers;return this.gpuTimers={},e}collectDeferredRenderGpuQueries(){const e=this.deferredRenderGpuTimeQueries;return this.deferredRenderGpuTimeQueries=[],e}queryGpuTimers(e){const t={};for(const r in e){const i=e[r],n=this.context.extTimerQuery,o=n.getQueryParameter(i.query,this.context.gl.QUERY_RESULT)/1e6;n.deleteQueryEXT(i.query),t[r]=o}return t}queryGpuTimeDeferredRender(e){if(!this.options.gpuTimingDeferredRender)return 0;const t=this.context.extTimerQuery,r=this.context.gl;let i=0;for(const n of e)i+=t.getQueryParameter(n,r.QUERY_RESULT)/1e6,t.deleteQueryEXT(n);return i}translatePosMatrix(t,r,i,n,o){if(!i[0]&&!i[1])return t;const s=o?"map"===n?this.transform.angle:0:"viewport"===n?-this.transform.angle:0;if(s){const e=Math.sin(s),t=Math.cos(s);i=[i[0]*t-i[1]*e,i[0]*e+i[1]*t]}const a=[o?i[0]:e.a6(r,i[0],this.transform.zoom),o?i[1]:e.a6(r,i[1],this.transform.zoom),0],l=new Float32Array(16);return e.a9.translate(l,t,a),l}saveTileTexture(e){const t=e.size[0],r=this._tileTextures[t];r?r.push(e):this._tileTextures[t]=[e]}getTileTexture(e){const t=this._tileTextures[e];return t&&t.length>0?t.pop():null}isPatternMissing(e,t){return null===e||void 0!==e&&!this.imageManager.getPattern(e.toString(),t)}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture}linearFloatFilteringSupported(){return null!=this.context.extTextureFloatLinear}currentGlobalDefines(e,t,r){const i=void 0===r?this.terrain&&this.terrain.renderingToTexture:r,n=this.terrain&&0===this.terrain.exaggeration(),o=[];return this.style&&this.style.enable3dLights()&&("globeRaster"===e||"terrainRaster"===e?(o.push("LIGHTING_3D_MODE"),o.push("LIGHTING_3D_ALPHA_EMISSIVENESS")):i||o.push("LIGHTING_3D_MODE")),"shadow"===this.renderPass?this._shadowMapDebug||o.push("DEPTH_TEXTURE"):this.shadowRenderer&&(this.shadowRenderer.useNormalOffset?o.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"):o.push("RENDER_SHADOWS","DEPTH_TEXTURE")),this.terrainRenderModeElevated()&&(o.push("TERRAIN"),this.linearFloatFilteringSupported()&&o.push("TERRAIN_DEM_FLOAT_FORMAT"),n&&o.push("ZERO_EXAGGERATION")),"globe"===this.transform.projection.name&&o.push("GLOBE"),!this._fogVisible||i||void 0!==t&&!t||o.push("FOG","FOG_DITHERING"),i&&o.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&o.push("OVERDRAW_INSPECTOR"),o}getOrCreateProgram(e,t){this.cache=this.cache||{};const r=t&&t.defines||[],i=t&&t.config,n=this.currentGlobalDefines(e,t&&t.overrideFog,t&&t.overrideRtt).concat(r),o=_n.cacheKey(Wi[e],e,n,i);return this.cache[o]||(this.cache[o]=new _n(this.context,e,Wi[e],i,qn[e],n)),this.cache[o]}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 e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new e.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}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()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}uploadCommonLightUniforms(t,r){if(this.style.enable3dLights()){const i=this.style.directionalLight,n=this.style.ambientLight;if(i&&n){const o=((t,r)=>{const i=t.properties.get("direction"),n=t.properties.get("color").toArray01(),o=t.properties.get("intensity"),s=r.properties.get("color").toArray01(),a=r.properties.get("intensity"),l=[i.x,i.y,i.z],c=e.cs(s,a),u=e.cs(n,o);return{u_lighting_ambient_color:c,u_lighting_directional_dir:l,u_lighting_directional_color:u,u_ground_radiance:mn(l,u,c)}})(i,n);r.setLightsUniformValues(t,o)}}}uploadCommonUniforms(t,r,i,n,o){if(this.uploadCommonLightUniforms(t,r),this.terrain&&this.terrain.renderingToTexture)return;const s=this.style.fog;if(s){const o=s.getOpacity(this.transform.pitch),a=((t,r,i,n,o,s,a,l,c,u,h,d)=>{const p=t.transform,f=r.properties.get("color").toArray01();f[3]=n;const m=t.frameCounter/1e3%1,[A,g]=r.properties.get("vertical-range");return{u_fog_matrix:i?p.calculateFogTileMatrix(i):d||t.identityMat,u_fog_range:r.getFovAdjustedRange(p._fov),u_fog_color:f,u_fog_horizon_blend:r.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(A,g),g],u_fog_temporal_offset:m,u_frustum_tl:o,u_frustum_tr:s,u_frustum_br:a,u_frustum_bl:l,u_globe_pos:c,u_globe_radius:u,u_viewport:h,u_globe_transition:e.W(p.zoom),u_is_globe:+("globe"===p.projection.name)}})(this,s,i,o,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*e.f.devicePixelRatio,this.transform.height*e.f.devicePixelRatio],n);r.setFogUniformValues(t,a)}o&&r.setCutoffUniformValues(t,o.uniformValues)}setTileLoadedFlag(e){this.tileLoaded=e}saveCanvasCopy(){const e=this.canvasCopy();e&&(this.frameCopies.push(e),this.tileLoaded=!1)}canvasCopy(){const e=this.context.gl,t=e.createTexture();return e.bindTexture(e.TEXTURE_2D,t),e.copyTexImage2D(e.TEXTURE_2D,0,e.RGBA,0,0,e.drawingBufferWidth,e.drawingBufferHeight,0),t}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const e=this.style&&this.style.fog;return!!e&&0!==e.getOpacity(this.transform.pitch)}getBackgroundTiles(){const e=this._backgroundTiles,t=this._backgroundTiles={},r=this.transform.coveringTiles({tileSize:512});for(const i of r)t[i.key]=e[i.key]||new jt(i,512,this.transform.tileZoom,this);return t}clearBackgroundTiles(){this._backgroundTiles={}}layerUsedInConflation(e,t){return!(!e.is3D()||e.minzoom&&e.minzoom>this.transform.zoom||"building"!==e.sourceLayer&&(!t||"batched-model"!==t.type))}isTileAffectedByFog(e){if(!this.style||!this.style.fog)return!1;if("globe"===this.transform.projection.name)return!0;let t=this._cachedTileFogOpacities[e.key];return t||(this._cachedTileFogOpacities[e.key]=t=this.style.fog.getOpacityForTile(e)),t[0]>=pe||t[1]>=pe}}function Jo(e,t){let r=!1,i=null;const n=()=>{i=null,r&&(e(),i=setTimeout(n,t),r=!1)};return()=>(r=!0,i||n(),i)}class es{constructor(t){this._hashName=t&&encodeURIComponent(t),e.a$(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=Jo(this._updateHashUnthrottled.bind(this),300)}addTo(e){return this._map=e,window.addEventListener("hashchange",this._onHashChange,!1),e.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 e=this._map;if(!e)return"";const t=ts(e);if(this._hashName){const e=this._hashName;let r=!1;const i=location.hash.slice(1).split("&").map((i=>{const n=i.split("=")[0];return n===e?(r=!0,`${n}=${t}`):i})).filter((e=>e));return r||i.push(`${e}=${t}`),`#${i.join("&")}`}return`#${t}`}_getCurrentHash(){const e=location.hash.replace("#","");if(this._hashName){let t;return e.split("&").map((e=>e.split("="))).forEach((e=>{e[0]===this._hashName&&(t=e)})),(t&&t[1]||"").split("/")}return e.split("/")}_onHashChange(){const e=this._map;if(!e)return!1;const t=this._getCurrentHash();if(t.length>=3&&!t.some((e=>isNaN(e)))){const r=e.dragRotate.isEnabled()&&e.touchZoomRotate.isEnabled()?+(t[3]||0):e.getBearing();return e.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:r,pitch:+(t[4]||0)}),!0}return!1}_updateHashUnthrottled(){history.replaceState(history.state,"",location.href.replace(/(#.+)?$/,this.getHashString()))}}function ts(e,t){const r=e.getCenter(),i=Math.round(100*e.getZoom())/100,n=Math.ceil((i*Math.LN2+Math.log(512/360/.5))/Math.LN10),o=Math.pow(10,n),s=Math.round(r.lng*o)/o,a=Math.round(r.lat*o)/o,l=e.getBearing(),c=e.getPitch();let u=t?`/${s}/${a}/${i}`:`${i}/${a}/${s}`;return(l||c)&&(u+="/"+Math.round(10*l)/10),c&&(u+=`/${Math.round(c)}`),u}const rs={linearity:.3,easing:e.d6(0,0,.3,1)},is=e.e({deceleration:2500,maxSpeed:1400},rs),ns=e.e({deceleration:20,maxSpeed:1400},rs),os=e.e({deceleration:1e3,maxSpeed:360},rs),ss=e.e({deceleration:1e3,maxSpeed:90},rs);class as{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:e.f.now(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,r=e.f.now();for(;t.length>0&&r-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._map._prefersReducedMotion())return;if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const r={zoom:0,bearing:0,pitch:0,pan:new e.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)r.zoom+=e.zoomDelta||0,r.bearing+=e.bearingDelta||0,r.pitch+=e.pitchDelta||0,e.panDelta&&r.pan._add(e.panDelta),e.around&&(r.around=e.around),e.pinchAround&&(r.pinchAround=e.pinchAround);const i=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,n={};if(r.pan.mag()){const o=cs(r.pan.mag(),i,e.e({},is,t||{}));n.offset=r.pan.mult(o.amount/r.pan.mag()),n.center=this._map.transform.center,ls(n,o)}if(r.zoom){const e=cs(r.zoom,i,ns);n.zoom=this._map.transform.zoom+e.amount,ls(n,e)}if(r.bearing){const t=cs(r.bearing,i,os);n.bearing=this._map.transform.bearing+e.ad(t.amount,-179,179),ls(n,t)}if(r.pitch){const e=cs(r.pitch,i,ss);n.pitch=this._map.transform.pitch+e.amount,ls(n,e)}if(n.zoom||n.bearing){const e=void 0===r.pinchAround?r.around:r.pinchAround;n.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),n.noMoveStart=!0,n}}function ls(e,t){(!e.duration||e.duration<t.duration)&&(e.duration=t.duration,e.easing=t.easing)}function cs(t,r,i){const{maxSpeed:n,linearity:o,deceleration:s}=i,a=e.ad(t*o/(r/1e3),-n,n),l=Math.abs(a)/(s*o);return{easing:i.easing,duration:1e3*l,amount:a*(l/2)}}class us extends e.b{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,r,i,n={}){const o=f(r.getCanvasContainer(),i),s=r.unproject(o);super(t,e.e({point:o,lngLat:s,originalEvent:i},n)),this._defaultPrevented=!1,this.target=r}}class hs extends e.b{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,r,i){const n="touchend"===t?i.changedTouches:i.touches,o=m(r.getCanvasContainer(),n),s=o.map((e=>r.unproject(e))),a=o.reduce(((e,t,r,i)=>e.add(t.div(i.length))),new e.P(0,0));super(t,{points:o,point:a,lngLats:s,lngLat:r.unproject(a),originalEvent:i}),this._defaultPrevented=!1}}class ds extends e.b{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,r){super(e,{originalEvent:r}),this._defaultPrevented=!1}}class ps{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){this._mousedownPos=void 0}wheel(e){return this._firePreventable(new ds(e.type,this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new us(e.type,this._map,e))}mouseup(e){this._map.fire(new us(e.type,this._map,e))}preclick(t){const r=e.e({},t);r.type="preclick",this._map.fire(new us(r.type,this._map,r))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||(this.preclick(e),this._map.fire(new us(e.type,this._map,e)))}dblclick(e){return this._firePreventable(new us(e.type,this._map,e))}mouseover(e){this._map.fire(new us(e.type,this._map,e))}mouseout(e){this._map.fire(new us(e.type,this._map,e))}touchstart(e){return this._firePreventable(new hs(e.type,this._map,e))}touchmove(e){this._map.fire(new hs(e.type,this._map,e))}touchend(e){this._map.fire(new hs(e.type,this._map,e))}touchcancel(e){this._map.fire(new hs(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class fs{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(e){this._map.fire(new us(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new us("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._map.fire(new us(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class ms{constructor(e,t){this._map=e,this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=t.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(e,t){this.isEnabled()&&e.shiftKey&&0===e.button&&(u(),this._startPos=this._lastPos=t,this._active=!0)}mousemoveWindow(e,t){if(!this._active)return;const r=t,i=this._startPos,n=this._lastPos;if(!i||!n||n.equals(r)||!this._box&&r.dist(i)<this._clickTolerance)return;this._lastPos=r,this._box||(this._box=o("div","mapboxgl-boxzoom",this._container),this._container.classList.add("mapboxgl-crosshair"),this._fireEvent("boxzoomstart",e));const s=Math.min(i.x,r.x),a=Math.max(i.x,r.x),l=Math.min(i.y,r.y),c=Math.max(i.y,r.y);this._map._requestDomTask((()=>{this._box&&(this._box.style.transform=`translate(${s}px,${l}px)`,this._box.style.width=a-s+"px",this._box.style.height=c-l+"px")}))}mouseupWindow(t,r){if(!this._active)return;const i=this._startPos,n=r;if(i&&0===t.button){if(this.reset(),p(),i.x!==n.x||i.y!==n.y)return this._map.fire(new e.b("boxzoomend",{originalEvent:t})),{cameraAnimation:e=>e.fitScreenCoordinates(i,n,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",t)}}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),h(),delete this._startPos,delete this._lastPos}_fireEvent(t,r){return this._map.fire(new e.b(t,{originalEvent:r}))}}function As(e,t){const r={};for(let i=0;i<e.length;i++)r[e[i].identifier]=t[i];return r}class gs{constructor(e){this.reset(),this.numTouches=e.numTouches}reset(){this.centroid=void 0,this.startTime=0,this.touches={},this.aborted=!1}touchstart(t,r,i){(this.centroid||i.length>this.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=t.timeStamp),i.length===this.numTouches&&(this.centroid=function(t){const r=new e.P(0,0);for(const e of t)r._add(e);return r.div(t.length)}(r),this.touches=As(i,r)))}touchmove(e,t,r){if(this.aborted||!this.centroid)return;const i=As(r,t);for(const e in this.touches){const t=i[e];(!t||t.dist(this.touches[e])>30)&&(this.aborted=!0)}}touchend(e,t,r){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===r.length){const e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class _s{constructor(e){this.singleTap=new gs(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(e,t,r){this.singleTap.touchstart(e,t,r)}touchmove(e,t,r){this.singleTap.touchmove(e,t,r)}touchend(e,t,r){const i=this.singleTap.touchend(e,t,r);if(i){const t=e.timeStamp-this.lastTime<500,r=!this.lastTap||this.lastTap.dist(i)<30;if(t&&r||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=i,this.count===this.numTaps)return this.reset(),i}}}class ys{constructor(){this._zoomIn=new _s({numTouches:1,numTaps:2}),this._zoomOut=new _s({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,t,r){this._zoomIn.touchstart(e,t,r),this._zoomOut.touchstart(e,t,r)}touchmove(e,t,r){this._zoomIn.touchmove(e,t,r),this._zoomOut.touchmove(e,t,r)}touchend(e,t,r){const i=this._zoomIn.touchend(e,t,r),n=this._zoomOut.touchend(e,t,r);return i?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()+1,around:t.unproject(i)},{originalEvent:e})}):n?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()-1,around:t.unproject(n)},{originalEvent:e})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const xs={0:1,2:2};class vs{constructor(e){this.reset(),this._clickTolerance=e.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(e,t){return!1}_move(e,t){return{}}mousedown(e,t){if(this._lastPoint)return;const r=A(e);this._correctButton(e,r)&&(this._lastPoint=t,this._eventButton=r)}mousemoveWindow(e,t){const r=this._lastPoint;if(r)if(e.preventDefault(),null!=this._eventButton&&function(e,t){const r=xs[t];return void 0===e.buttons||(e.buttons&r)!==r}(e,this._eventButton))this.reset();else if(this._moved||!(t.dist(r)<this._clickTolerance))return this._moved=!0,this._lastPoint=t,this._move(r,t)}mouseupWindow(e){this._lastPoint&&A(e)===this._eventButton&&(this._moved&&p(),this.reset())}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class bs extends vs{mousedown(e,t){super.mousedown(e,t),this._lastPoint&&(this._active=!0)}_correctButton(e,t){return 0===t&&!e.ctrlKey}_move(e,t){return{around:t,panDelta:t.sub(e)}}}class ws extends vs{_correctButton(e,t){return 0===t&&e.ctrlKey||2===t}_move(e,t){const r=.8*(t.x-e.x);if(r)return this._active=!0,{bearingDelta:r}}contextmenu(e){e.preventDefault()}}class Cs extends vs{_correctButton(e,t){return 0===t&&e.ctrlKey||2===t}_move(e,t){const r=-.5*(t.y-e.y);if(r)return this._active=!0,{pitchDelta:r}}contextmenu(e){e.preventDefault()}}class Ts{constructor(t,r){this._map=t,this._el=t.getCanvasContainer(),this._minTouches=1,this._clickTolerance=r.clickTolerance||1,this.reset(),e.a$(["_addTouchPanBlocker","_showTouchPanBlockerAlert"],this)}reset(){this._active=!1,this._touches={},this._sum=new e.P(0,0)}touchstart(e,t,r){return this._calculateTransform(e,t,r)}touchmove(t,r,i){if(this._active&&!(i.length<this._minTouches)){if(this._map._cooperativeGestures&&!this._map.isMoving()){if(1===i.length&&!e.d7())return void this._showTouchPanBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}return t.cancelable&&t.preventDefault(),this._calculateTransform(t,r,i)}}touchend(e,t,r){this._calculateTransform(e,t,r),this._active&&r.length<this._minTouches&&this.reset()}touchcancel(){this.reset()}_calculateTransform(t,r,i){i.length>0&&(this._active=!0);const n=As(i,r),o=new e.P(0,0),s=new e.P(0,0);let a=0;for(const e in n){const t=n[e],r=this._touches[e];r&&(o._add(t),s._add(t.sub(r)),a++,n[e]=t)}if(this._touches=n,a<this._minTouches||!s.mag())return;const l=s.div(a);return this._sum._add(l),this._sum.mag()<this._clickTolerance?void 0:{around:o.div(a),panDelta:l}}enable(){this._enabled=!0,this._map._cooperativeGestures&&(this._addTouchPanBlocker(),this._el.classList.add("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page"))}disable(){this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove(),this._el.classList.remove("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page")),this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}_addTouchPanBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=o("div","mapboxgl-touch-pan-blocker",this._map._container),this._alertContainer.textContent=this._map._getUIString("TouchPanBlocker.Message"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_showTouchPanBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-touch-pan-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout((()=>{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.removeAttribute("role")}),500)}}class Es{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(e){}_move(e,t,r){return{}}touchstart(e,t,r){this._firstTwoTouches||r.length<2||(this._firstTwoTouches=[r[0].identifier,r[1].identifier],this._start([t[0],t[1]]))}touchmove(e,t,r){const i=this._firstTwoTouches;if(!i)return;e.preventDefault();const[n,o]=i,s=Ms(r,t,n),a=Ms(r,t,o);if(!s||!a)return;const l=this._aroundCenter?null:s.add(a).div(2);return this._move([s,a],l,e)}touchend(e,t,r){if(!this._firstTwoTouches)return;const[i,n]=this._firstTwoTouches,o=Ms(r,t,i),s=Ms(r,t,n);o&&s||(this._active&&p(),this.reset())}touchcancel(){this.reset()}enable(e){this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function Ms(e,t,r){for(let i=0;i<e.length;i++)if(e[i].identifier===r)return t[i]}function Ss(e,t){return Math.log(e/t)/Math.LN2}class Is extends Es{reset(){super.reset(),this._distance=0,this._startDistance=0}_start(e){this._startDistance=this._distance=e[0].dist(e[1])}_move(e,t){const r=this._distance;if(this._distance=e[0].dist(e[1]),this._active||!(Math.abs(Ss(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:Ss(this._distance,r),pinchAround:t}}}function Ps(e,t){return 180*e.angleWith(t)/Math.PI}class Ds extends Es{reset(){super.reset(),this._minDiameter=0,this._startVector=void 0,this._vector=void 0}_start(e){this._startVector=this._vector=e[0].sub(e[1]),this._minDiameter=e[0].dist(e[1])}_move(e,t){const r=this._vector;if(this._vector=e[0].sub(e[1]),r&&(this._active||!this._isBelowThreshold(this._vector)))return this._active=!0,{bearingDelta:Ps(this._vector,r),pinchAround:t}}_isBelowThreshold(e){this._minDiameter=Math.min(this._minDiameter,e.mag());const t=25/(Math.PI*this._minDiameter)*360,r=this._startVector;if(!r)return!1;const i=Ps(e,r);return Math.abs(i)<t}}function ks(e){return Math.abs(e.y)>Math.abs(e.x)}class Ls extends Es{constructor(e){super(),this._map=e}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(e){this._lastPoints=e,ks(e[0].sub(e[1]))&&(this._valid=!1)}_move(t,r,i){const n=this._lastPoints;if(!n)return;const o=t[0].sub(n[0]),s=t[1].sub(n[1]);return this._map._cooperativeGestures&&!e.d7()&&i.touches.length<3||(this._valid=this.gestureBeginsVertically(o,s,i.timeStamp),!this._valid)?void 0:(this._lastPoints=t,this._active=!0,{pitchDelta:(o.y+s.y)/2*-.5})}gestureBeginsVertically(e,t,r){if(void 0!==this._valid)return this._valid;const i=e.mag()>=2,n=t.mag()>=2;if(!i&&!n)return;if(!i||!n)return null==this._firstMove&&(this._firstMove=r),r-this._firstMove<100&&void 0;const o=e.y>0==t.y>0;return ks(e)&&ks(t)&&o}}const zs={panStep:100,bearingStep:15,pitchStep:10};class Os{constructor(){const e=zs;this._panStep=e.panStep,this._bearingStep=e.bearingStep,this._pitchStep=e.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,r=0,i=0,n=0,o=0;switch(e.keyCode){case 61:case 107:case 171:case 187:t=1;break;case 189:case 109:case 173:t=-1;break;case 37:e.shiftKey?r=-1:(e.preventDefault(),n=-1);break;case 39:e.shiftKey?r=1:(e.preventDefault(),n=1);break;case 38:e.shiftKey?i=1:(e.preventDefault(),o=-1);break;case 40:e.shiftKey?i=-1:(e.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(r=0,i=0),{cameraAnimation:s=>{const a=s.getZoom();s.easeTo({duration:300,easeId:"keyboardHandler",easing:Bs,zoom:t?Math.round(a)+t*(e.shiftKey?2:1):a,bearing:s.getBearing()+r*this._bearingStep,pitch:s.getPitch()+i*this._pitchStep,offset:[-n*this._panStep,-o*this._panStep],center:s.getCenter()},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function Bs(e){return e*(2-e)}const Rs=4.000244140625,Fs=1/450;class js{constructor(t,r){this._map=t,this._el=t.getCanvasContainer(),this._handler=r,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=Fs,e.a$(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this)}setZoomRate(e){this._defaultZoomRate=e}setWheelZoomRate(e){this._wheelZoomRate=e}isEnabled(){return!!this._enabled}isActive(){return this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&"center"===e.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()||e.d7()))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 i=e.f.now(),n=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,0!==r&&r%Rs==0?this._type="wheel":0!==r&&Math.abs(r)<4?this._type="trackpad":n>400?(this._type=null,this._lastValue=r,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(n*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(e){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e)}_start(e){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 t=f(this._el,e);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:t,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId)return;if(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 e="wheel"===this._type&&Math.abs(this._delta)>Rs?this._wheelZoomRate:this._defaultZoomRate;let i=2/(1+Math.exp(-Math.abs(this._delta*e)));this._delta<0&&0!==i&&(i=1/i);const n=r(),o=Math.pow(2,n),s="number"==typeof this._targetZoom?t.zoomScale(this._targetZoom):o;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(s*i))),"wheel"===this._type&&(this._startZoom=n,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0}const i="number"==typeof this._targetZoom?this._targetZoom:r(),n=this._startZoom,o=this._easing;let s,a=!1;if("wheel"===this._type&&n&&o){const t=Math.min((e.f.now()-this._lastWheelEventTime)/200,1),r=o(t);s=e.X(n,i,r),t<1?this._frameId||(this._frameId=!0):a=!0}else s=i,a=!0;this._active=!0,a&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout}),200));let l=s-r();return l*this._lastDelta<0&&(l=0),{noInertia:!0,needsRenderFrame:!a,zoomDelta:l,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let r=e.d8;if(this._prevEase){const t=this._prevEase,i=(e.f.now()-t.start)/t.duration,n=t.easing(i+.01)-t.easing(i),o=.27/Math.sqrt(n*n+1e-4)*.01,s=Math.sqrt(.0729-o*o);r=e.d6(o,s,.25,1)}return this._prevEase={start:e.f.now(),duration:t,easing:r},r}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=o("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=setTimeout((()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.removeAttribute("role")}),200)}}class Vs{constructor(e,t){this._clickZoom=e,this._tapZoom=t}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class Ns{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(e,t){return e.preventDefault(),{cameraAnimation:r=>{r.easeTo({duration:300,zoom:r.getZoom()+(e.shiftKey?-1:1),around:r.unproject(t)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Us{constructor(){this._tap=new _s({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(e,t,r){this._swipePoint||(this._tapTime&&e.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?r.length>0&&(this._swipePoint=t[0],this._swipeTouch=r[0].identifier):this._tap.touchstart(e,t,r))}touchmove(e,t,r){if(this._tapTime){if(this._swipePoint){if(r[0].identifier!==this._swipeTouch)return;const i=t[0],n=i.y-this._swipePoint.y;return this._swipePoint=i,e.preventDefault(),this._active=!0,{zoomDelta:n/128}}}else this._tap.touchmove(e,t,r)}touchend(e,t,r){this._tapTime?this._swipePoint&&0===r.length&&this.reset():this._tap.touchend(e,t,r)&&(this._tapTime=e.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Hs{constructor(e,t,r){this._el=e,this._mousePan=t,this._touchPan=r}enable(e){this._inertiaOptions=e||{},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 Gs{constructor(e,t,r){this._pitchWithRotate=e.pitchWithRotate,this._mouseRotate=t,this._mousePitch=r}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 Zs{constructor(e,t,r,i){this._el=e,this._touchZoom=t,this._touchRotate=r,this._tapDragZoom=i,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("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 Ws=e=>e.zoom||e.drag||e.pitch||e.rotate;class Qs extends e.b{}class qs{constructor(){this.constants=[1,1,.01],this.radius=0}setup(t,r){const i=e.Q.sub([],r,t);this.radius=e.Q.length(i[2]<0?e.Q.div([],i,this.constants):[i[0],i[1],0])}projectRay(t){e.Q.div(t,t,this.constants),e.Q.normalize(t,t),e.Q.mul(t,t,this.constants);const r=e.Q.scale([],t,this.radius);if(r[2]>0){const t=e.Q.scale([],[0,0,1],e.Q.dot(r,[0,0,1])),i=e.Q.scale([],e.Q.normalize([],[r[0],r[1],0]),this.radius),n=e.Q.add([],r,e.Q.scale([],e.Q.sub([],e.Q.add([],i,t),r),2));r[0]=n[0],r[1]=n[1]}return r}}function Xs(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta}class Ys{constructor(t,r){this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new as(t),this._bearingSnap=r.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new qs,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(r),e.a$(["handleEvent","handleWindowEvent"],this);const i=this._el;this._listeners=[[i,"touchstart",{passive:!0}],[i,"touchmove",{passive:!1}],[i,"touchend",void 0],[i,"touchcancel",void 0],[i,"mousedown",void 0],[i,"mousemove",void 0],[i,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[i,"mouseover",void 0],[i,"mouseout",void 0],[i,"dblclick",void 0],[i,"click",void 0],[i,"keydown",{capture:!1}],[i,"keyup",void 0],[i,"wheel",{passive:!1}],[i,"contextmenu",void 0],[window,"blur",void 0]];for(const[e,t,r]of this._listeners){const i=e===document?this.handleWindowEvent:this.handleEvent;e.addEventListener(t,i,r)}}destroy(){for(const[e,t,r]of this._listeners){const i=e===document?this.handleWindowEvent:this.handleEvent;e.removeEventListener(t,i,r)}}_addDefaultHandlers(e){const t=this._map,r=t.getCanvasContainer();this._add("mapEvent",new ps(t,e));const i=t.boxZoom=new ms(t,e);this._add("boxZoom",i);const n=new ys,o=new Ns;t.doubleClickZoom=new Vs(o,n),this._add("tapZoom",n),this._add("clickZoom",o);const s=new Us;this._add("tapDragZoom",s);const a=t.touchPitch=new Ls(t);this._add("touchPitch",a);const l=new ws(e),c=new Cs(e);t.dragRotate=new Gs(e,l,c),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",c,["mouseRotate"]);const u=new bs(e),h=new Ts(t,e);t.dragPan=new Hs(r,u,h),this._add("mousePan",u),this._add("touchPan",h,["touchZoom","touchRotate"]);const d=new Ds,p=new Is;t.touchZoomRotate=new Zs(r,p,d,s),this._add("touchRotate",d,["touchPan","touchZoom"]),this._add("touchZoom",p,["touchPan","touchRotate"]),this._add("blockableMapEvent",new fs(t));const f=t.scrollZoom=new js(t,this);this._add("scrollZoom",f,["mousePan"]);const m=t.keyboard=new Os;this._add("keyboard",m);for(const r of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])e.interactive&&e[r]&&t[r].enable(e[r])}_add(e,t,r){this._handlers.push({handlerName:e,handler:t,allowed:r}),this._handlersById[e]=t}stop(e){if(!this._updatingCamera){for(const{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[],this._originalZoom=void 0}}isActive(){for(const{handler:e}of this._handlers)if(e.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!Ws(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(e,t,r){for(const i in e)if(i!==r&&(!t||t.indexOf(i)<0))return!0;return!1}handleWindowEvent(e){this.handleEvent(e,`${e.type}Window`)}_getMapTouches(e){const t=[];for(const r of e)this._el.contains(r.target)&&t.push(r);return t}handleEvent(e,t){this._updatingCamera=!0;const r="renderFrame"===e.type,i=r?void 0:e,n={needsRenderFrame:!1},o={},s={},a=e.touches?this._getMapTouches(e.touches):void 0,l=a?m(this._el,a):r?void 0:f(this._el,e);for(const{handlerName:r,handler:c,allowed:u}of this._handlers){if(!c.isEnabled())continue;let h;this._blockedByActive(s,u,r)?c.reset():c[t||e.type]&&(h=c[t||e.type](e,l,a),this.mergeHandlerResult(n,o,h,r,i),h&&h.needsRenderFrame&&this._triggerRenderFrame()),(h||c.isActive())&&(s[r]=c)}const c={};for(const e in this._previousActiveHandlers)s[e]||(c[e]=i);this._previousActiveHandlers=s,(Object.keys(c).length||Xs(n))&&(this._changes.push([n,o,c]),this._triggerRenderFrame()),(Object.keys(s).length||Xs(n))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:u}=n;u&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],u(this._map))}mergeHandlerResult(t,r,i,n,o){if(!i)return;e.e(t,i);const s={handlerName:n,originalEvent:i.originalEvent||o};void 0!==i.zoomDelta&&(r.zoom=s),void 0!==i.panDelta&&(r.drag=s),void 0!==i.pitchDelta&&(r.pitch=s),void 0!==i.bearingDelta&&(r.rotate=s)}_applyChanges(){const t={},r={},i={};for(const[n,o,s]of this._changes)n.panDelta&&(t.panDelta=(t.panDelta||new e.P(0,0))._add(n.panDelta)),n.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+n.zoomDelta),n.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+n.bearingDelta),n.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+n.pitchDelta),void 0!==n.around&&(t.around=n.around),void 0!==n.aroundCoord&&(t.aroundCoord=n.aroundCoord),void 0!==n.pinchAround&&(t.pinchAround=n.pinchAround),n.noInertia&&(t.noInertia=n.noInertia),e.e(r,o),e.e(i,s);this._updateMapTransform(t,r,i),this._changes=[]}_updateMapTransform(t,r,i){const n=this._map,o=n.transform,s=e=>[e.x,e.y,e.z];if((e=>{const t=this._eventsInProgress.drag;return t&&!this._handlersById[t.handlerName].isActive()})()&&!Xs(t)){const e=o.zoom;o.cameraElevationReference="sea",null!=this._originalZoom&&o._orthographicProjectionAtLowPitch&&"globe"!==o.projection.name&&0===o.pitch?(o.cameraElevationReference="ground",o.zoom=this._originalZoom):(o.recenterOnTerrain(),o.cameraElevationReference="ground"),e!==o.zoom&&this._map._update(!0)}if(o._isCameraConstrained&&n._stop(!0),!Xs(t))return void this._fireEvents(r,i,!0);let{panDelta:a,zoomDelta:l,bearingDelta:c,pitchDelta:u,around:h,aroundCoord:d,pinchAround:p}=t;o._isCameraConstrained&&(l>0&&(l=0),o._isCameraConstrained=!1),void 0!==p&&(h=p),(l||(e=>r[e]&&!this._eventsInProgress[e])("drag"))&&h&&(this._dragOrigin=s(o.pointCoordinate3D(h)),this._originalZoom=o.zoom,this._trackingEllipsoid.setup(o._camera.position,this._dragOrigin)),o.cameraElevationReference="sea",n._stop(!0),h=h||n.transform.centerPoint,c&&(o.bearing+=c),u&&(o.pitch+=u),o._updateCameraState();const f=[0,0,0];if(a)if("mercator"===o.projection.name){const e=this._trackingEllipsoid.projectRay(o.screenPointToMercatorRay(h).dir),t=this._trackingEllipsoid.projectRay(o.screenPointToMercatorRay(h.sub(a)).dir);f[0]=t[0]-e[0],f[1]=t[1]-e[1]}else{const t=o.pointCoordinate(h);if("globe"===o.projection.name){a=a.rotate(-o.angle);const r=o._pixelsPerMercatorPixel/o.worldSize;f[0]=-a.x*e.d9(e.ax(t.y))*r,f[1]=-a.y*e.d9(o.center.lat)*r}else{const e=o.pointCoordinate(h.sub(a));t&&e&&(f[0]=e.x-t.x,f[1]=e.y-t.y)}}const m=o.zoom,A=[0,0,0];if(l){const t=s(d||o.pointCoordinate3D(h)),r={dir:e.Q.normalize([],e.Q.sub([],t,o._camera.position))};if(r.dir[2]<0){const i=o.zoomDeltaToMovement(t,l);e.Q.scale(A,r.dir,i)}}const g=e.Q.add(f,f,A);o._translateCameraConstrained(g),l&&Math.abs(o.zoom-m)>1e-4&&o.recenterOnTerrain(),o.cameraElevationReference="ground",this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(r,i,!0)}_fireEvents(t,r,i){const n=Ws(this._eventsInProgress),o=Ws(t),s={};for(const e in t){const{originalEvent:r}=t[e];this._eventsInProgress[e]||(s[`${e}start`]=r),this._eventsInProgress[e]=t[e]}!n&&o&&this._fireEvent("movestart",o.originalEvent);for(const e in s)this._fireEvent(e,s[e]);o&&this._fireEvent("move",o.originalEvent);for(const e in t){const{originalEvent:r}=t[e];this._fireEvent(e,r)}const a={};let l;for(const e in this._eventsInProgress){const{handlerName:t,originalEvent:i}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],l=r[t]||i,a[`${e}end`]=l)}for(const e in a)this._fireEvent(e,a[e]);const c=Ws(this._eventsInProgress);if(i&&(n||o)&&!c){this._updatingCamera=!0;const t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),r=e=>0!==e&&-this._bearingSnap<e&&e<this._bearingSnap;t?(r(t.bearing||this._map.getBearing())&&(t.bearing=0),this._map.easeTo(t,{originalEvent:l})):(this._map.fire(new e.b("moveend",{originalEvent:l})),r(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(t,r){this._map.fire(new e.b(t,r?{originalEvent:r}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add((e=>{this._frameId=void 0,this.handleEvent(new Qs("renderFrame",{timeStamp:e})),this._applyChanges()}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}const $s="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class Ks extends e.E{constructor(t,r){super(),this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=r.bearingSnap,this._respectPrefersReducedMotion=!1!==r.respectPrefersReducedMotion,e.a$(["_renderFrameCallback"],this)}getCenter(){return new e.bq(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}panBy(t,r,i){return t=e.P.convert(t).mult(-1),this.panTo(this.transform.center,e.e({offset:t},r),i)}panTo(t,r,i){return this.easeTo(e.e({center:t},r),i)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(t,r,i){return this.easeTo(e.e({zoom:t},r),i)}zoomIn(e,t){return this.zoomTo(this.getZoom()+1,e,t),this}zoomOut(e,t){return this.zoomTo(this.getZoom()-1,e,t),this}getBearing(){return this.transform.bearing}setBearing(e,t){return this.jumpTo({bearing:e},t),this}getPadding(){return this.transform.padding}setPadding(e,t){return this.jumpTo({padding:e},t),this}rotateTo(t,r,i){return this.easeTo(e.e({bearing:t},r),i)}resetNorth(t,r){return this.rotateTo(0,e.e({duration:1e3},t),r),this}resetNorthPitch(t,r){return this.easeTo(e.e({bearing:0,pitch:0,duration:1e3},t),r),this}snapToNorth(e,t){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(e,t):this}getPitch(){return this.transform.pitch}setPitch(e,t){return this.jumpTo({pitch:e},t),this}cameraForBounds(t,r){t=e.ag.convert(t);const i=r&&r.bearing||0,n=r&&r.pitch||0,o=t.getNorthWest(),s=t.getSouthEast();return this._cameraForBounds(this.transform,o,s,i,n,r)}_extendPadding(t){const r={top:0,right:0,bottom:0,left:0};return null==t?e.e({},r,this.transform.padding):"number"==typeof t?{top:t,bottom:t,right:t,left:t}:e.e({},r,t)}_extendCameraOptions(t){return(t=e.e({offset:[0,0],maxZoom:this.transform.maxZoom},t)).padding=this._extendPadding(t.padding),t}_minimumAABBFrustumDistance(e,t){const r=t.max[0]-t.min[0],i=t.max[1]-t.min[1];return r/i>e.aspect?r/(2*Math.tan(.5*e.fovX)*e.aspect):i/(2*Math.tan(.5*e.fovY)*e.aspect)}_cameraForBoundsOnGlobe(t,r,i,n,o,s){const a=t.clone(),l=this._extendCameraOptions(s);a.bearing=n,a.pitch=o;const c=e.bq.convert(r),u=e.bq.convert(i),h=.5*(c.lat+u.lat),d=.5*(c.lng+u.lng),p=e.da(h,d),f=e.Q.normalize([],p),m=e.Q.normalize([],e.Q.cross([],f,[0,1,0])),A=e.Q.cross([],m,f),g=[m[0],m[1],m[2],0,A[0],A[1],A[2],0,f[0],f[1],f[2],0,0,0,0,1],_=[p,e.da(c.lat,c.lng),e.da(u.lat,c.lng),e.da(u.lat,u.lng),e.da(c.lat,u.lng),e.da(h,c.lng),e.da(h,u.lng),e.da(c.lat,d),e.da(u.lat,d)];let y=e.bV.fromPoints(_.map((t=>[e.Q.dot(m,t),e.Q.dot(A,t),e.Q.dot(f,t)])));const x=e.Q.transformMat4([],y.center,g);0===e.Q.squaredLength(x)&&e.Q.set(x,0,0,1),e.Q.normalize(x,x),e.Q.scale(x,x,e.ae),a.center=e.db(x);const v=a.getWorldToCameraMatrix(),b=e.a9.invert(new Float64Array(16),v);y=e.bV.applyTransform(y,e.a9.multiply([],v,g));const w=this._extendAABB(y,a,l,n);if(!w)return void e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");y=w,e.Q.transformMat4(x,x,v);const C=.5*(y.max[2]-y.min[2]),T=this._minimumAABBFrustumDistance(a,y),E=e.Q.scale([],[0,0,1],C),M=e.Q.add(E,x,E),S=T+(0===a.pitch?0:e.Q.distance(x,M)),I=a.globeCenterInViewSpace,P=e.Q.sub([],x,[I[0],I[1],I[2]]);e.Q.normalize(P,P),e.Q.scale(P,P,S);const D=e.Q.add([],x,P);e.Q.transformMat4(D,D,b);const k=e.dc/e.ae,L=e.Q.length(D),z=e.bo(Math.max(L*k-e.dc,Number.EPSILON),0),O=Math.min(a.zoomFromMercatorZAdjusted(z),l.maxZoom);return O>.5*(e.bJ+e.bA)?(a.setProjection({name:"mercator"}),a.zoom=O,this._cameraForBounds(a,r,i,n,o,s)):{center:a.center,zoom:O,bearing:n,pitch:o}}_extendAABB(t,r,i,n){const o=.5*((i.padding.left||0)+(i.padding.right||0)),s=.5*((i.padding.top||0)+(i.padding.bottom||0)),a=s,l=o,c=o,u=s,h=r.width-(l+c),d=r.height-(a+u),p=e.Q.sub([],t.max,t.min),f=Math.min(h/p[0],d/p[1]),m=Math.min(r.scaleZoom(r.scale*f),i.maxZoom);if(isNaN(m))return null;const A=r.scale/r.zoomScale(m),g=new e.bV([t.min[0]-l*A,t.min[1]-u*A,t.min[2]],[t.max[0]+c*A,t.max[1]+a*A,t.max[2]]),_=("number"==typeof i.offset.x&&"number"==typeof i.offset.y?new e.P(i.offset.x,i.offset.y):e.P.convert(i.offset)).rotate(-e.bm(n));return g.center[0]-=_.x*A,g.center[1]+=_.y*A,g}queryTerrainElevation(t,r){const i=this.transform.elevation;return i?(r=e.e({},{exaggerated:!0},r),i.getAtPoint(e.O.fromLngLat(t),null,r.exaggerated)):null}_cameraForBounds(t,r,i,n,o,s){if("globe"===t.projection.name)return this._cameraForBoundsOnGlobe(t,r,i,n,o,s);const a=t.clone(),l=this._extendCameraOptions(s);a.bearing=n,a.pitch=o;const c=e.bq.convert(r),u=e.bq.convert(i),h=new e.bq(c.lng,u.lat),d=new e.bq(u.lng,c.lat),p=a.project(c),f=a.project(u),m=this.queryTerrainElevation(c),A=this.queryTerrainElevation(u),g=this.queryTerrainElevation(h),_=this.queryTerrainElevation(d),y=[[p.x,p.y,Math.min(m||0,A||0,g||0,_||0)],[f.x,f.y,Math.max(m||0,A||0,g||0,_||0)]];let x=e.bV.fromPoints(y);const v=a.getWorldToCameraMatrix(),b=e.a9.invert(new Float64Array(16),v);x=e.bV.applyTransform(x,v);const w=this._extendAABB(x,a,l,n);if(!w)return void e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");x=w;const C=.5*e.Q.sub([],x.max,x.min)[2],T=this._minimumAABBFrustumDistance(a,x),E=[0,0,1,0];e.aa.transformMat4(E,E,v),e.aa.normalize(E,E);const M=e.Q.scale([],E,T+C),S=e.Q.add([],x.center,M);e.Q.transformMat4(x.center,x.center,b),e.Q.transformMat4(S,S,b);const I=[x.center[0],x.center[1],S[2]*a.pixelsPerMeter];e.Q.scale(I,I,1/a.worldSize);const P=e.aw(I[0]),D=e.ax(I[1]),k=Math.min(a._zoomFromMercatorZ(I[2]),l.maxZoom),L=new e.bq(P,D);return a.mercatorFromTransition&&k<.5*(e.bJ+e.bA)?(a.setProjection({name:"globe"}),a.zoom=k,this._cameraForBounds(a,r,i,n,o,s)):{center:L,zoom:k,bearing:n,pitch:o}}fitBounds(e,t,r){const i=this.cameraForBounds(e,t);return this._fitInternal(i,t,r)}fitScreenCoordinates(t,r,i,n,o){const s=e.P.convert(t),a=e.P.convert(r),l=new e.P(Math.min(s.x,a.x),Math.min(s.y,a.y)),c=new e.P(Math.max(s.x,a.x),Math.max(s.y,a.y));if("mercator"===this.transform.projection.name&&this.transform.anyCornerOffEdge(s,a))return this;const u=this.transform.pointLocation3D(l),h=this.transform.pointLocation3D(c),d=this.transform.pointLocation3D(new e.P(l.x,c.y)),p=this.transform.pointLocation3D(new e.P(c.x,l.y)),f=[Math.min(u.lng,h.lng,d.lng,p.lng),Math.min(u.lat,h.lat,d.lat,p.lat)],m=[Math.max(u.lng,h.lng,d.lng,p.lng),Math.max(u.lat,h.lat,d.lat,p.lat)],A=n&&n.pitch?n.pitch:this.getPitch(),g=this._cameraForBounds(this.transform,f,m,i,A,n);return this._fitInternal(g,n,o)}_fitInternal(t,r,i){return t?(r=e.e(t,r)).linear?this.easeTo(r,i):this.flyTo(r,i):this}jumpTo(t,r){this.stop();const i=t.preloadOnly?this.transform.clone():this.transform;let n=!1,o=!1,s=!1;return"zoom"in t&&i.zoom!==+t.zoom&&(n=!0,i.zoom=+t.zoom),void 0!==t.center&&(i.center=e.bq.convert(t.center)),"bearing"in t&&i.bearing!==+t.bearing&&(o=!0,i.bearing=+t.bearing),"pitch"in t&&i.pitch!==+t.pitch&&(s=!0,i.pitch=+t.pitch),null==t.padding||i.isPaddingEqual(t.padding)||(i.padding=t.padding),t.preloadOnly?(this._preloadTiles(i),this):(this.fire(new e.b("movestart",r)).fire(new e.b("move",r)),n&&this.fire(new e.b("zoomstart",r)).fire(new e.b("zoom",r)).fire(new e.b("zoomend",r)),o&&this.fire(new e.b("rotatestart",r)).fire(new e.b("rotate",r)).fire(new e.b("rotateend",r)),s&&this.fire(new e.b("pitchstart",r)).fire(new e.b("pitch",r)).fire(new e.b("pitchend",r)),this.fire(new e.b("moveend",r)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||e.w($s),this.transform.getFreeCameraOptions()}setFreeCameraOptions(t,r){const i=this.transform;if(!i.projection.supportsFreeCamera)return e.w($s),this;this.stop();const n=i.zoom,o=i.pitch,s=i.bearing;i.setFreeCameraOptions(t);const a=n!==i.zoom,l=o!==i.pitch,c=s!==i.bearing;return this.fire(new e.b("movestart",r)).fire(new e.b("move",r)),a&&this.fire(new e.b("zoomstart",r)).fire(new e.b("zoom",r)).fire(new e.b("zoomend",r)),c&&this.fire(new e.b("rotatestart",r)).fire(new e.b("rotate",r)).fire(new e.b("rotateend",r)),l&&this.fire(new e.b("pitchstart",r)).fire(new e.b("pitch",r)).fire(new e.b("pitchend",r)),this.fire(new e.b("moveend",r)),this}easeTo(t,r){this._stop(!1,t.easeId),(!1===(t=e.e({offset:[0,0],duration:500,easing:e.d8},t)).animate||this._prefersReducedMotion(t))&&(t.duration=0);const i=this.transform,n=this.getZoom(),o=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in t?+t.zoom:n,c="bearing"in t?this._normalizeBearing(t.bearing,o):o,u="pitch"in t?+t.pitch:s,h=this._extendPadding(t.padding),d=e.P.convert(t.offset);let p,f,m;if("globe"===i.projection.name){const r=e.O.fromLngLat(i.center),n=d.rotate(-i.angle);r.x+=n.x/i.worldSize,r.y+=n.y/i.worldSize;const o=r.toLngLat(),s=e.bq.convert(t.center||o);this._normalizeCenter(s),p=i.centerPoint.add(n),f=new e.P(r.x,r.y).mult(i.worldSize),m=new e.P(e.a8(s.lng),e.ah(s.lat)).mult(i.worldSize).sub(f)}else{p=i.centerPoint.add(d);const r=i.pointLocation(p),n=e.bq.convert(t.center||r);this._normalizeCenter(n),f=i.project(r),m=i.project(n).sub(f)}const A=i.zoomScale(l-n);let g,_;t.around&&(g=e.bq.convert(t.around),_=i.locationPoint(g));const y=this._zooming||l!==n,x=this._rotating||o!==c,v=this._pitching||u!==s,b=!i.isPaddingEqual(h),w=i=>w=>{if(y&&(i.zoom=e.X(n,l,w)),x&&(i.bearing=e.X(o,c,w)),v&&(i.pitch=e.X(s,u,w)),b&&(i.interpolatePadding(a,h,w),p=i.centerPoint.add(d)),g)i.setLocationAtPoint(g,_);else{const e=i.zoomScale(i.zoom-n),t=l>n?Math.min(2,A):Math.max(.5,A),r=Math.pow(t,1-w),o=i.unproject(f.add(m.mult(w*r)).mult(e));i.setLocationAtPoint(i.renderWorldCopies?o.wrap():o,p)}return t.preloadOnly||this._fireMoveEvents(r),i};if(t.preloadOnly){const e=this._emulate(w,t.duration,i);return this._preloadTiles(e),this}const C={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=y,this._rotating=x,this._pitching=v,this._padding=b,this._easeId=t.easeId,this._prepareEase(r,t.noMoveStart,C),this._ease(w(i),(e=>{"sea"===i.cameraElevationReference&&i.recenterOnTerrain(),this._afterEase(r,e)}),t),this}_prepareEase(t,r,i={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&0===this.transform.pitch&&"globe"!==this.transform.projection.name&&(this.transform.cameraElevationReference="ground"),r||i.moving||this.fire(new e.b("movestart",t)),this._zooming&&!i.zooming&&this.fire(new e.b("zoomstart",t)),this._rotating&&!i.rotating&&this.fire(new e.b("rotatestart",t)),this._pitching&&!i.pitching&&this.fire(new e.b("pitchstart",t))}_fireMoveEvents(t){this.fire(new e.b("move",t)),this._zooming&&this.fire(new e.b("zoom",t)),this._rotating&&this.fire(new e.b("rotate",t)),this._pitching&&this.fire(new e.b("pitch",t))}_afterEase(t,r){if(this._easeId&&r&&this._easeId===r)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const i=this._zooming,n=this._rotating,o=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,i&&this.fire(new e.b("zoomend",t)),n&&this.fire(new e.b("rotateend",t)),o&&this.fire(new e.b("pitchend",t)),this.fire(new e.b("moveend",t))}flyTo(t,r){if(this._prefersReducedMotion(t)){const i=e.af(t,["center","zoom","bearing","pitch","around"]);return this.jumpTo(i,r)}this.stop(),t=e.e({offset:[0,0],speed:1.2,curve:1.42,easing:e.d8},t);const i=this.transform,n=this.getZoom(),o=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in t?e.ad(+t.zoom,i.minZoom,i.maxZoom):n,c="bearing"in t?this._normalizeBearing(t.bearing,o):o,u="pitch"in t?+t.pitch:s,h=this._extendPadding(t.padding),d=i.zoomScale(l-n),p=e.P.convert(t.offset);let f=i.centerPoint.add(p);const m=i.pointLocation(f),A=e.bq.convert(t.center||m);this._normalizeCenter(A);const g=i.project(m),_=i.project(A).sub(g);let y=t.curve;const x=Math.max(i.width,i.height),v=x/d,b=_.mag();if("minZoom"in t){const r=e.ad(Math.min(t.minZoom,n,l),i.minZoom,i.maxZoom),o=x/i.zoomScale(r-n);y=Math.sqrt(o/b*2)}const w=y*y;function C(e){const t=(v*v-x*x+(e?-1:1)*w*w*b*b)/(2*(e?v:x)*w*b);return Math.log(Math.sqrt(t*t+1)-t)}function T(e){return(Math.exp(e)-Math.exp(-e))/2}function E(e){return(Math.exp(e)+Math.exp(-e))/2}const M=C(0);let S=function(e){return E(M)/E(M+y*e)},I=function(e){return x*((E(M)*(T(t=M+y*e)/E(t))-T(M))/w)/b;var t},P=(C(1)-M)/y;if(Math.abs(b)<1e-6||!isFinite(P)){if(Math.abs(x-v)<1e-6)return this.easeTo(t,r);const e=v<x?-1:1;P=Math.abs(Math.log(v/x))/y,I=function(){return 0},S=function(t){return Math.exp(e*y*t)}}t.duration="duration"in t?+t.duration:1e3*P/("screenSpeed"in t?+t.screenSpeed/y:+t.speed),t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0);const D=o!==c,k=u!==s,L=!i.isPaddingEqual(h),z=i=>d=>{const m=d*P,y=1/S(m);i.zoom=1===d?l:n+i.scaleZoom(y),D&&(i.bearing=e.X(o,c,d)),k&&(i.pitch=e.X(s,u,d)),L&&(i.interpolatePadding(a,h,d),f=i.centerPoint.add(p));const x=1===d?A:i.unproject(g.add(_.mult(I(m))).mult(y));return i.setLocationAtPoint(i.renderWorldCopies?x.wrap():x,f),i._updateCameraOnTerrain(),t.preloadOnly||this._fireMoveEvents(r),i};if(t.preloadOnly){const e=this._emulate(z,t.duration,i);return this._preloadTiles(e),this}return this._zooming=!0,this._rotating=D,this._pitching=k,this._padding=L,this._prepareEase(r,!1),this._ease(z(i),(()=>this._afterEase(r)),t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_requestRenderFrame(e){}_cancelRenderFrame(e){}_stop(e,t){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const e=this._onEaseEnd;this._onEaseEnd=void 0,e.call(this,t)}if(!e){const e=this.handlers;e&&e.stop(!1)}return this}_ease(t,r,i){!1===i.animate||0===i.duration?(t(1),r()):(this._easeStart=e.f.now(),this._easeOptions=i,this._onEaseFrame=t,this._onEaseEnd=r,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const t=Math.min((e.f.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=e.bk(t,-180,180);const i=Math.abs(t-r);return Math.abs(t-360-r)<i&&(t-=360),Math.abs(t+360-r)<i&&(t+=360),t}_normalizeCenter(e){const t=this.transform;if(t.maxBounds)return;if("globe"!==t.projection.name&&!t.renderWorldCopies)return;const r=e.lng-t.center.lng;e.lng+=r>180?-360:r<-180?360:0}_prefersReducedMotion(t){return this._respectPrefersReducedMotion&&e.f.prefersReducedMotion&&!(t&&t.essential)}_emulate(e,t,r){const i=Math.ceil(15*t/1e3),n=[],o=e(r.clone());for(let e=0;e<=i;e++){const t=o(e/i);n.push(t.clone())}return n}_preloadTiles(e,t){}}class Js{constructor(t={}){this.options=t,e.a$(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(e){const t=this.options&&this.options.compact;return this._map=e,this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=o("button","mapboxgl-ctrl-attrib-button",this._container),o("span","mapboxgl-ctrl-icon",this._compactButton).setAttribute("aria-hidden","true"),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=o("div","mapboxgl-ctrl-attrib-inner",this._container),t&&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===t&&(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}_setElementTitle(e,t){const r=this._map._getUIString(`AttributionControl.${t}`);e.removeAttribute("title"),e.firstElementChild&&e.firstElementChild.setAttribute("title",r)}_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||e.dd.ACCESS_TOKEN}];if(t){const i=r.reduce(((e,t,i)=>(t.value&&(e+=`${t.key}=${t.value}${i<r.length-1?"&":""}`),e)),"?");t.href=`${e.dd.FEEDBACK_URL}/${i}#${ts(this._map,!0)}`,t.rel="noopener nofollow",this._setElementTitle(t,"MapFeedback")}}_updateData(e){!e||"metadata"!==e.sourceDataType&&"visibility"!==e.sourceDataType&&"style"!==e.dataType||(this._updateAttributions(),this._updateEditLink())}_updateAttributions(){if(!this._map.style)return;let e=[];if(this._map.style.stylesheet){const e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id}const t=this._map.style._mergedSourceCaches;for(const r in t){const i=t[r];if(i.used){const t=i.getSource();t.attribution&&e.indexOf(t.attribution)<0&&e.push(t.attribution)}}e.sort(((e,t)=>e.length-t.length)),e=e.filter(((t,r)=>{for(let i=r+1;i<e.length;i++)if(e[i].indexOf(t)>=0)return!1;return!0})),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=[...this.options.customAttribution,...e]:e.unshift(this.options.customAttribution));const r=e.join(" | ");r!==this._attribHTML&&(this._attribHTML=r,e.length?(this._innerContainer.innerHTML=r,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 ea{constructor(){e.a$(["_updateLogo","_updateCompact"],this)}onAdd(e){this._map=e,this._container=o("div","mapboxgl-ctrl");const t=o("a","mapboxgl-ctrl-logo");return t.target="_blank",t.rel="noopener nofollow",t.href="https://www.mapbox.com/",t.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),t.setAttribute("rel","noopener nofollow"),this._container.appendChild(t),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(e){e&&"metadata"!==e.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const e=this._map.style._sourceCaches;if(0===Object.entries(e).length)return!0;for(const t in e){const r=e[t].getSource();if(r.hasOwnProperty("mapbox_logo")&&!r.mapbox_logo)return!1}return!0}_updateCompact(){const e=this._container.children;if(e.length){const t=e[0];this._map.getCanvasContainer().offsetWidth<250?t.classList.add("mapboxgl-compact"):t.classList.remove("mapboxgl-compact")}}}class ta{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){const t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}remove(e){const t=this._currentlyRunning,r=t?this._queue.concat(t):this._queue;for(const t of r)if(t.id===e)return void(t.cancelled=!0)}run(e=0){const t=this._currentlyRunning=this._queue;this._queue=[];for(const r of t)if(!r.cancelled&&(r.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function ra(t,r,i){if(t=new e.bq(t.lng,t.lat),r){const n=new e.bq(t.lng-360,t.lat),o=new e.bq(t.lng+360,t.lat),s=360*Math.ceil(Math.abs(t.lng-i.center.lng)/360),a=i.locationPoint(t).distSqr(r),l=r.x<0||r.y<0||r.x>i.width||r.y>i.height;i.locationPoint(n).distSqr(r)<a&&(l||Math.abs(n.lng-i.center.lng)<s)?t=n:i.locationPoint(o).distSqr(r)<a&&(l||Math.abs(o.lng-i.center.lng)<s)&&(t=o)}for(;Math.abs(t.lng-i.center.lng)>180;){const e=i.locationPoint(t);if(e.x>=0&&e.y>=0&&e.x<=i.width&&e.y<=i.height)break;t.lng>i.center.lng?t.lng-=360:t.lng+=360}return t}const ia={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 na extends e.E{constructor(t,r){if(super(),(t instanceof HTMLElement||r)&&(t=e.e({element:t},r)),e.a$(["_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=e.P.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=o("div");const r=41,i=27,n=s("svg",{display:"block",height:r*this._scale+"px",width:i*this._scale+"px",viewBox:`0 0 ${i} ${r}`},this._element),a=s("radialGradient",{id:"shadowGradient"},s("defs",{},n));s("stop",{offset:"10%","stop-opacity":.4},a),s("stop",{offset:"100%","stop-opacity":.05},a),s("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},n),s("path",{fill:this._color,d:"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z"},n),s("path",{opacity:.25,d:"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z"},n),s("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},n),this._offset=e.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",(e=>{e.preventDefault()})),this._element.addEventListener("mousedown",(e=>{e.preventDefault()}));const i=this._element.classList;for(const e in ia)i.remove(`mapboxgl-marker-anchor-${e}`);i.add(`mapboxgl-marker-anchor-${this._anchor}`);const n=t&&t.className?t.className.trim().split(/\s+/):[];i.add(...n),this._popup=null}addTo(e){return e===this._map||(this.remove(),this._map=e,e.getCanvasContainer().appendChild(this._element),e.on("move",this._updateMoving),e.on("moveend",this._update),e.on("remove",this._clearFadeTimer),e._addMarker(this),this.setDraggable(this._draggable),this._update(),e.on("click",this._onMapClick)),this}remove(){const e=this._map;return e&&(e.off("click",this._onMapClick),e.off("move",this._updateMoving),e.off("moveend",this._update),e.off("mousedown",this._addDragHandler),e.off("touchstart",this._addDragHandler),e.off("mouseup",this._onUp),e.off("touchend",this._onUp),e.off("mousemove",this._onMove),e.off("touchmove",this._onMove),e.off("remove",this._clearFadeTimer),e._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=e.bq.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(e){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")),e){if(!("offset"in e.options)){const t=38.1,r=13.5,i=Math.sqrt(Math.pow(r,2)/2);e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-t],"bottom-left":[i,-1*(t-r+i)],"bottom-right":[-i,-1*(t-r+i)],left:[r,-1*(t-r)],right:[-r,-1*(t-r)]}:this._offset}this._popup=e,e._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(e){const t=e.code,r=e.charCode||e.keyCode;"Space"!==t&&"Enter"!==t&&32!==r&&13!==r||this.togglePopup()}_onMapClick(e){const t=e.originalEvent.target,r=this._element;this._popup&&(t===r||r.contains(t))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const e=this._popup;return e?(e.isOpen()?(e.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(e.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const e=this._map,t=this._pos;if(!e||!t)return!1;const r=e.unproject(t),i=e.getFreeCameraOptions();if(!i.position)return!1;const n=i.position.toLngLat();return n.distanceTo(r)<.9*n.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 i=t.unproject(r);let n;t._showingGlobe()&&e.de(t.transform,this._lngLat)?n=0:(n=1-t._queryFogOpacity(i),t.transform._terrainEnabled()&&t.getTerrain()&&this._behindTerrain()&&(n*=this._occludedOpacity)),this._element.style.opacity=`${n}`,this._element.style.pointerEvents=n>0?"auto":"none",this._popup&&this._popup._setOpacity(n),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){const e=this._pos;if(!e||!this._map)return;const t=this._offset.mult(this._scale);this._element.style.transform=`\n translate(${e.x}px,${e.y}px)\n ${ia[this._anchor]}\n ${this._calculateXYTransform()} ${this._calculateZTransform()}\n translate(${t.x}px,${t.y}px)\n `}_calculateXYTransform(){const t=this._pos,r=this._map,i=this.getPitchAlignment();if(!r||!t||"map"!==i)return"";if(!r._showingGlobe()){const e=r.getPitch();return e?`rotateX(${e}deg)`:""}const n=e.bI(e.df(r.transform,this._lngLat)),o=t.sub(e.dg(r.transform)),s=Math.abs(o.x)+Math.abs(o.y);if(0===s)return"";const a=n/s;return`rotateX(${-o.y*a}deg) rotateY(${o.x*a}deg)`}_calculateZTransform(){const t=this._pos,r=this._map;if(!r||!t)return"";let i=0;const n=this.getRotationAlignment();if("map"===n)if(r._showingGlobe()){const t=r.project(new e.bq(this._lngLat.lng,this._lngLat.lat+.001)),n=r.project(new e.bq(this._lngLat.lng,this._lngLat.lat-.001)).sub(t);i=e.bI(Math.atan2(n.y,n.x))-90}else i=-r.getBearing();else if("horizon"===n){const n=e.S(4,6,r.getZoom()),o=e.dg(r.transform);o.y+=n*r.transform.height;const s=t.sub(o),a=e.bI(Math.atan2(s.y,s.x));i=(a>90?a-270:a+90)*(1-n)}return i+=this._rotation,i?`rotateZ(${i}deg)`:""}_update(e){cancelAnimationFrame(this._updateFrameId);const t=this._map;t&&(t.transform.renderWorldCopies&&(this._lngLat=ra(this._lngLat,this._pos,t.transform)),this._pos=t.project(this._lngLat),!0===e?this._updateFrameId=requestAnimationFrame((()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())})):this._pos=this._pos.round(),t._requestDomTask((()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(t._showingGlobe()||t.getTerrain()||t.getFog())&&!this._fadeTimer&&(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))})))}getOffset(){return this._offset}setOffset(t){return this._offset=e.P.convert(t),this._update(),this}addClassName(e){return this._element.classList.add(e),this}removeClassName(e){return this._element.classList.remove(e),this}toggleClassName(e){return this._element.classList.toggle(e)}_onMove(t){const r=this._map;if(!r)return;const i=this._pointerdownPos,n=this._positionDelta;if(i&&n){if(!this._isDragging){const e=this._clickTolerance||r._clickTolerance;if(t.point.dist(i)<e)return;this._isDragging=!0}this._pos=t.point.sub(n),this._lngLat=r.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new e.b("dragstart"))),this.fire(new e.b("drag"))}}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1;const t=this._map;t&&(t.off("mousemove",this._onMove),t.off("touchmove",this._onMove)),"active"===this._state&&this.fire(new e.b("dragend")),this._state="inactive"}_addDragHandler(e){const t=this._map,r=this._pos;t&&r&&this._element.contains(e.originalEvent.target)&&(e.preventDefault(),this._positionDelta=e.point.sub(r),this._pointerdownPos=e.point,this._state="pending",t.on("mousemove",this._onMove),t.on("touchmove",this._onMove),t.once("mouseup",this._onUp),t.once("touchend",this._onUp))}setDraggable(e){this._draggable=!!e;const t=this._map;return t&&(e?(t.on("mousedown",this._addDragHandler),t.on("touchstart",this._addDragHandler)):(t.off("mousedown",this._addDragHandler),t.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||"auto",this._update(),this}getRotationAlignment(){return"auto"===this._rotationAlignment||"horizon"===this._rotationAlignment&&this._map&&!this._map._showingGlobe()?"viewport":this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e||"auto",this._update(),this}getPitchAlignment(){return"auto"===this._pitchAlignment?this.getRotationAlignment():this._pitchAlignment}setOccludedOpacity(e){return this._occludedOpacity=e||.2,this._update(),this}getOccludedOpacity(){return this._occludedOpacity}}const oa={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},sa=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function aa(t=new e.P(0,0),r="bottom"){if("number"==typeof t){const i=Math.round(Math.sqrt(.5*Math.pow(t,2)));switch(r){case"top":return new e.P(0,t);case"top-left":return new e.P(i,i);case"top-right":return new e.P(-i,i);case"bottom":return new e.P(0,-t);case"bottom-left":return new e.P(i,-i);case"bottom-right":return new e.P(-i,-i);case"left":return new e.P(t,0);case"right":return new e.P(-t,0)}return new e.P(0,0)}return t instanceof e.P||Array.isArray(t)?e.P.convert(t):e.P.convert(t[r]||[0,0])}class la{constructor(e){this.jumpTo(e)}getValue(t){if(t<=this._startTime)return this._start;if(t>=this._endTime)return this._end;const r=e.ch((t-this._startTime)/(this._endTime-this._startTime));return this._start*(1-r)+this._end*r}isEasing(e){return e>=this._startTime&&e<=this._endTime}jumpTo(e){this._startTime=-1/0,this._endTime=-1/0,this._start=e,this._end=e}easeTo(e,t,r){this._start=this.getValue(t),this._end=e,this._startTime=t,this._endTime=t+r}}class ca{registerParameter(e,t,r,i,n){}registerButton(e,t,r){}registerBinding(e,t,r,i){}refreshUI(){}}const ua={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox logo","Map.Title":"Map","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use ⌘ + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"},ha={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},da={showCompass:!0,showZoom:!0,visualizePitch:!1};class pa{constructor(t,r,i=!1){this._clickTolerance=10,this.element=r,this.mouseRotate=new ws({clickTolerance:t.dragRotate._mouseRotate._clickTolerance}),this.map=t,i&&(this.mousePitch=new Cs({clickTolerance:t.dragRotate._mousePitch._clickTolerance})),e.a$(["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(e,t){this.mouseRotate.mousedown(e,t),this.mousePitch&&this.mousePitch.mousedown(e,t),u()}move(e,t){const r=this.map,i=this.mouseRotate.mousemoveWindow(e,t),n=i&&i.bearingDelta;if(n&&r.setBearing(r.getBearing()+n),this.mousePitch){const i=this.mousePitch.mousemoveWindow(e,t),n=i&&i.pitchDelta;n&&r.setPitch(r.getPitch()+n)}}off(){const e=this.element;e.removeEventListener("mousedown",this.mousedown),e.removeEventListener("touchstart",this.touchstart,{passive:!1}),e.removeEventListener("touchmove",this.touchmove),e.removeEventListener("touchend",this.touchend),e.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){h(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup)}mousedown(t){this.down(e.e({},t,{ctrlKey:!0,preventDefault:()=>t.preventDefault()}),f(this.element,t)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)}mousemove(e){this.move(e,f(this.element,e))}mouseup(e){this.mouseRotate.mouseupWindow(e),this.mousePitch&&this.mousePitch.mouseupWindow(e),this.offTemp()}touchstart(e){1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=m(this.element,e.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>e.preventDefault()},this._startPos))}touchmove(e){1!==e.targetTouches.length?this.reset():(this._lastPos=m(this.element,e.targetTouches)[0],this.move({preventDefault:()=>e.preventDefault()},this._lastPos))}touchend(e){0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),this.reset()}reset(){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp()}}const fa={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0,showUserHeading:!1},ma={maxWidth:100,unit:"metric"},Aa={kilometer:"km",meter:"m",mile:"mi",foot:"ft","nautical-mile":"nm"},ga={version:e.du,supported:r,setRTLTextPlugin:e.dw,getRTLTextPluginStatus:e.dx,Map:class extends Ks{constructor(t){const r=t;if(null!=(t=e.e({},ha,t)).minZoom&&null!=t.maxZoom&&t.minZoom>t.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=t.minPitch&&null!=t.maxPitch&&t.minPitch>t.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=t.minPitch&&t.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=t.maxPitch&&t.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(t.antialias&&e.dh(window)&&(t.antialias=!1,e.w("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new pi(t.minZoom,t.maxZoom,t.minPitch,t.maxPitch,t.renderWorldCopies),t),this._repaint=!!t.repaint,this._interactive=t.interactive,this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._failIfMajorPerformanceCaveat=t.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=t.preserveDrawingBuffer,this._antialias=t.antialias,this._trackResize=t.trackResize,this._bearingSnap=t.bearingSnap,this._refreshExpiredTiles=t.refreshExpiredTiles,this._fadeDuration=t.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=t.crossSourceCollisions,this._collectResourceTiming=t.collectResourceTiming,this._language=this._parseLanguage(t.language),this._worldview=t.worldview,this._renderTaskQueue=new ta,this._domRenderTaskQueue=new ta,this._controls=[],this._markers=[],this._popups=[],this._mapId=e.aF(),this._locale=e.e({},ua,t.locale),this._clickTolerance=t.clickTolerance,this._cooperativeGestures=t.cooperativeGestures,this._performanceMetricsCollection=t.performanceMetricsCollection,this._containerWidth=0,this._containerHeight=0,this._showParseStatus=!0,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new la(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._requestManager=new e.di(t.transformRequest,t.accessToken,t.testMode),this._silenceAuthErrors=!!t.testMode,this._contextCreateOptions=t.contextCreateOptions?{...t.contextCreateOptions}:{},"string"==typeof t.container){const e=document.getElementById(t.container);if(!e)throw new Error(`Container '${t.container.toString()}' not found.`);this._container=e}else{if(!(t.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=t.container}if(this._container.childNodes.length>0&&e.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."),t.maxBounds&&this.setMaxBounds(t.maxBounds),e.a$(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._tp=t.devtools?new ca(this):new ca,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 Ys(this,t),this._localFontFamily=t.localFontFamily,this._localIdeographFontFamily=t.localIdeographFontFamily,(t.style||!t.testMode)&&this.setStyle(t.style||e.dd.DEFAULT_STYLE,{config:t.config,localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),t.projection&&this.setProjection(t.projection),t.hash&&(this._hash=new es("string"==typeof t.hash&&t.hash||void 0).addTo(this)),!this._hash||!this._hash._onHashChange()){null==r.center&&null==r.zoom||(this.transform._unmodified=!1),this.jumpTo({center:t.center,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch});const i=t.bounds;i&&(this.resize(),this.fitBounds(i,e.e({},t.fitBoundsOptions,{duration:0})))}this.resize(),t.attributionControl&&this.addControl(new Js({customAttribution:t.customAttribution})),this._logoControl=new ea,this.addControl(this._logoControl,t.logoPosition),this.on("style.load",(()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet),this._postStyleLoadEvent()})),this.on("data",(t=>{this._update("style"===t.dataType),this.fire(new e.b(`${t.dataType}data`,t))})),this.on("dataloading",(t=>{this.fire(new e.b(`${t.dataType}dataloading`,t))}))}_getMapId(){return this._mapId}addControl(t,r){if(void 0===r&&(r=t.getDefaultPosition?t.getDefaultPosition():"top-right"),!t||!t.onAdd)return this.fire(new e.a(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const i=t.onAdd(this);this._controls.push(t);const n=this._controlPositions[r];return-1!==r.indexOf("bottom")?n.insertBefore(i,n.firstChild):n.appendChild(i),this}removeControl(t){if(!t||!t.onRemove)return this.fire(new e.a(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const r=this._controls.indexOf(t);return r>-1&&this._controls.splice(r,1),t.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(t){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 r=!this._moving;return r&&this.fire(new e.b("movestart",t)).fire(new e.b("move",t)),this.fire(new e.b("resize",t)),r&&this.fire(new e.b("moveend",t)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(t){return this.transform.setMaxBounds(e.ag.convert(t)),this._update()}setMinZoom(t){if((t=null==t?-2:t)>=-2&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()<t?this.setZoom(t):this.fire(new e.b("zoomstart")).fire(new e.b("zoom")).fire(new e.b("zoomend")),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(t){if((t=null==t?22:t)>=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t?this.setZoom(t):this.fire(new e.b("zoomstart")).fire(new e.b("zoom")).fire(new e.b("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(t){if((t=null==t?0:t)<0)throw new Error("minPitch must be greater than or equal to 0");if(t>=0&&t<=this.transform.maxPitch)return this.transform.minPitch=t,this._update(),this.getPitch()<t?this.setPitch(t):this.fire(new e.b("pitchstart")).fire(new e.b("pitch")).fire(new e.b("pitchend")),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(t){if((t=null==t?85:t)>85)throw new Error("maxPitch must be less than or equal to 85");if(t>=this.transform.minPitch)return this.transform.maxPitch=t,this._update(),this.getPitch()>t?this.setPitch(t):this.fire(new e.b("pitchstart")).fire(new e.b("pitch")).fire(new e.b("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(e){return this.transform.renderWorldCopies=e,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(e){return"auto"===e?navigator.language:Array.isArray(e)?0===e.length?void 0:e.map((e=>"auto"===e?navigator.language:e)):e}setLanguage(e){const t=this._parseLanguage(e);if(!this.style||t===this._language)return this;this._language=t,this.style.reloadSources();for(const e of this._controls)e._setLanguage&&e._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(e){return this.style&&e!==this._worldview?(this._worldview=e,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(e){return this._lazyInitEmptyStyle(),e?"string"==typeof e&&(e={name:e}):e=null,this._useExplicitProjection=!!e,this._prioritizeAndUpdateProjection(e,this.style.projection)}_updateProjectionTransition(){if("globe"!==this.getProjection().name)return;const t=this.transform,r=t.projection.name;let i;"globe"===r&&t.zoom>=e.bA?(t.setMercatorFromTransition(),i=!0):"mercator"===r&&t.zoom<e.bA&&(t.setProjection({name:"globe"}),i=!0),i&&(this.style.applyProjectionUpdate(),this.style._forceSymbolLayerUpdate())}_prioritizeAndUpdateProjection(e,t){return this._updateProjection(e||t||{name:"mercator"})}_updateProjection(t){let r;return r="globe"===t.name&&this.transform.zoom>=e.bA?this.transform.setMercatorFromTransition():this.transform.setProjection(t),this.style.applyProjectionUpdate(),r&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}project(t){return this.transform.locationPoint3D(e.bq.convert(t))}unproject(t){return this.transform.pointLocation3D(e.P.convert(t))}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()||!1}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()||!1}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()||!1}_isDragging(){return this.handlers&&this.handlers._isDragging()||!1}_createDelegatedListener(e,t,r){if("mouseenter"===e||"mouseover"===e){let i=!1;const n=n=>{const o=t.filter((e=>this.getLayer(e))),s=o.length?this.queryRenderedFeatures(n.point,{layers:o}):[];s.length?i||(i=!0,r.call(this,new us(e,this,n.originalEvent,{features:s}))):i=!1},o=()=>{i=!1};return{layers:new Set(t),listener:r,delegates:{mousemove:n,mouseout:o}}}if("mouseleave"===e||"mouseout"===e){let i=!1;const n=n=>{const o=t.filter((e=>this.getLayer(e)));(o.length?this.queryRenderedFeatures(n.point,{layers:o}):[]).length?i=!0:i&&(i=!1,r.call(this,new us(e,this,n.originalEvent)))},o=t=>{i&&(i=!1,r.call(this,new us(e,this,t.originalEvent)))};return{layers:new Set(t),listener:r,delegates:{mousemove:n,mouseout:o}}}{const i=e=>{const i=t.filter((e=>this.getLayer(e))),n=i.length?this.queryRenderedFeatures(e.point,{layers:i}):[];n.length&&(e.features=n,r.call(this,e),delete e.features)};return{layers:new Set(t),listener:r,delegates:{[e]:i}}}}on(e,t,r){if(void 0===r)return super.on(e,t);if(Array.isArray(t)||(t=[t]),t)for(const e of t)if(!this._isValidId(e))return this;const i=this._createDelegatedListener(e,t,r);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(i);for(const e in i.delegates)this.on(e,i.delegates[e]);return this}once(e,t,r){if(void 0===r)return super.once(e,t);if(Array.isArray(t)||(t=[t]),t)for(const e of t)if(!this._isValidId(e))return this;const i=this._createDelegatedListener(e,t,r);for(const e in i.delegates)this.once(e,i.delegates[e]);return this}off(e,t,r){if(void 0===r)return super.off(e,t);t=new Set(Array.isArray(t)?t:[t]);for(const e of t)if(!this._isValidId(e))return this;const i=(e,t)=>{if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0},n=this._delegatedListeners?this._delegatedListeners[e]:void 0;return n&&(e=>{for(let n=0;n<e.length;n++){const o=e[n];if(o.listener===r&&i(o.layers,t)){for(const e in o.delegates)this.off(e,o.delegates[e]);return e.splice(n,1),this}}})(n),this}queryRenderedFeatures(t,r){if(!this.style)return[];if(void 0!==r||void 0===t||t instanceof e.P||Array.isArray(t)||(r=t,t=void 0),t=t||[[0,0],[this.transform.width,this.transform.height]],(r=r||{}).layers&&Array.isArray(r.layers))for(const e of r.layers)if(!this._isValidId(e))return[];return this.style.queryRenderedFeatures(t,r,this.transform)}querySourceFeatures(e,t){return this._isValidId(e)?this.style.querySourceFeatures(e,t):[]}isPointOnSurface(t){const{name:r}=this.transform.projection;return"globe"!==r&&"mercator"!==r&&e.w(`${r} projection does not support isPointOnSurface, this API may behave unexpectedly.`),this.transform.isPointOnSurface(e.P.convert(t))}setStyle(t,r){return r=e.e({},{localIdeographFontFamily:this._localIdeographFontFamily,localFontFamily:this._localFontFamily},r),this.style&&t&&!1!==r.diff&&r.localFontFamily===this._localFontFamily&&r.localIdeographFontFamily===this._localIdeographFontFamily&&!r.config?(this.style._diffStyle(t,((i,n)=>{i?(e.w(`Unable to perform style diff: ${String(i.message||i.error||i)}. Rebuilding the style from scratch.`),this._updateStyle(t,r)):n&&this._update(!0)}),(()=>{this._postStyleLoadEvent()})),this):(this._localIdeographFontFamily=r.localIdeographFontFamily,this._localFontFamily=r.localFontFamily,this._updateStyle(t,r))}_getUIString(e){const t=this._locale[e];if(null==t)throw new Error(`Missing UI string '${e}'`);return t}_updateStyle(t,r){if(this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),t){const i=e.e({},r);r&&r.config&&(i.initialConfig=r.config,delete i.config),this.style=new Ii(this,i).setEventedParent(this,{style:this.style}).load(t)}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new Ii(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():(e.w("There is no style added to the map."),!1)}_isValidId(t){return null==t?(this.fire(new e.a(new Error("IDs can't be empty."))),!1):!e.c9(t)||(this.fire(new e.a(new Error(`IDs can't contain special symbols: "${t}".`))),!1)}addSource(e,t){return this._isValidId(e)?(this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)):this}isSourceLoaded(e){return!!this._isValidId(e)&&!!this.style&&this.style._isSourceCacheLoaded(e)}areTilesLoaded(){return this.style.areTilesLoaded()}addSourceType(e,t,r){this._lazyInitEmptyStyle(),this.style.addSourceType(e,t,r)}removeSource(e){return this._isValidId(e)?(this.style.removeSource(e),this._updateTerrain(),this._update(!0)):this}getSource(e){return this._isValidId(e)?this.style.getOwnSource(e):null}addImage(t,r,{pixelRatio:i=1,sdf:n=!1,stretchX:o,stretchY:s,content:a}={}){if(this._lazyInitEmptyStyle(),r instanceof HTMLImageElement||ImageBitmap&&r instanceof ImageBitmap){const{width:l,height:c,data:u}=e.f.getImageData(r);this.style.addImage(t,{data:new e.h({width:l,height:c},u),pixelRatio:i,stretchX:o,stretchY:s,content:a,sdf:n,version:0})}else if(void 0===r.width||void 0===r.height)this.fire(new e.a(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));else{const{width:l,height:c}=r,u=r;this.style.addImage(t,{data:new e.h({width:l,height:c},new Uint8Array(u.data)),pixelRatio:i,stretchX:o,stretchY:s,content:a,sdf:n,version:0,userImage:u}),u.onAdd&&u.onAdd(this,t)}}updateImage(t,r){this._lazyInitEmptyStyle();const i=this.style.getImage(t);if(!i)return void this.fire(new e.a(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const n=r instanceof HTMLImageElement||ImageBitmap&&r instanceof ImageBitmap?e.f.getImageData(r):r,{width:o,height:s}=n,a=n.data;if(void 0===o||void 0===s)return void this.fire(new e.a(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(o!==i.data.width||s!==i.data.height)return void this.fire(new e.a(new Error(`The width and height of the updated image (${o}, ${s})\n must be that same as the previous version of the image\n (${i.data.width}, ${i.data.height})`)));const l=!(r instanceof HTMLImageElement||ImageBitmap&&r instanceof ImageBitmap);i.data.replace(a,l),this.style.updateImage(t,i)}hasImage(t){return t?!!this.style&&!!this.style.getImage(t):(this.fire(new e.a(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e)}loadImage(t,r){e.d(this._requestManager.transformRequest(t,e.R.Image),((t,i)=>{r(t,i instanceof HTMLImageElement?e.f.getImageData(i):i)}))}listImages(){return this.style.listImages()}addModel(e,t){this._lazyInitEmptyStyle(),this.style.addModel(e,t)}hasModel(t){return t?this.style.hasModel(t):(this.fire(new e.a(new Error("Missing required model id"))),!1)}removeModel(e){this.style.removeModel(e)}listModels(){return this.style.listModels()}addLayer(e,t){return this._isValidId(e.id)?(this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)):this}getSlot(e){const t=this.getLayer(e);return t&&t.slot||null}setSlot(e,t){return this.style.setSlot(e,t),this.style.mergeLayers(),this._update(!0)}addImport(e,t){return this.style.addImport(e,t),this}updateImport(e,t){return"string"!=typeof t&&t.id!==e?(this.removeImport(e),this.addImport(t)):(this.style.updateImport(e,t),this._update(!0))}removeImport(e){return this.style.removeImport(e),this}moveImport(e,t){return this.style.moveImport(e,t),this._update(!0)}moveLayer(e,t){return this._isValidId(e)?(this.style.moveLayer(e,t),this._update(!0)):this}removeLayer(e){return this._isValidId(e)?(this.style.removeLayer(e),this._update(!0)):this}getLayer(e){return this._isValidId(e)?this.style.getOwnLayer(e):null}setLayerZoomRange(e,t,r){return this._isValidId(e)?(this.style.setLayerZoomRange(e,t,r),this._update(!0)):this}setFilter(e,t,r={}){return this._isValidId(e)?(this.style.setFilter(e,t,r),this._update(!0)):this}getFilter(e){return this._isValidId(e)?this.style.getFilter(e):null}setPaintProperty(e,t,r,i={}){return this._isValidId(e)?(this.style.setPaintProperty(e,t,r,i),this._update(!0)):this}getPaintProperty(e,t){return this._isValidId(e)?this.style.getPaintProperty(e,t):null}setLayoutProperty(e,t,r,i={}){return this._isValidId(e)?(this.style.setLayoutProperty(e,t,r,i),this._update(!0)):this}getLayoutProperty(e,t){return this._isValidId(e)?this.style.getLayoutProperty(e,t):null}getSchema(e){return this.style.getSchema(e)}setSchema(e,t){return this.style.setSchema(e,t),this._update(!0)}getConfig(e){return this.style.getConfig(e)}setConfig(e,t){return this.style.setConfig(e,t),this._update(!0)}getConfigProperty(e,t){return this.style.getConfigProperty(e,t)}setConfigProperty(e,t,r){return this.style.setConfigProperty(e,t,r),this._update(!0)}setLights(e){if(this._lazyInitEmptyStyle(),e&&1===e.length&&"flat"===e[0].type){const t=e[0];t.properties?this.style.setFlatLight(t.properties,t.id,{}):this.style.setFlatLight({},"flat")}else this.style.setLights(e),this.painter.terrain&&(this.painter.terrain.invalidateRenderCache=!0);return this._update(!0)}getLights(){const e=this.style.getLights()||[];return 0===e.length&&e.push({id:this.style.light.id,type:"flat",properties:this.style.getFlatLight()}),e}setLight(e,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:e}])}getLight(){return console.log("The `map.getLight` function is deprecated, prefer using `map.getLights` instead."),this.style.getFlatLight()}setTerrain(e){return this._lazyInitEmptyStyle(),!e&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(e),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(e){return this._lazyInitEmptyStyle(),this.style.setFog(e),this._update(!0)}getFog(){return this.style?this.style.getFog():null}setCamera(e){return this.style.setCamera(e),this._triggerCameraUpdate(e)}_triggerCameraUpdate(e){return this._update(this.transform.setOrthographicProjectionAtLowPitch("orthographic"===e["camera-projection"]))}getCamera(){return this.style.camera}_queryFogOpacity(t){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(e.bq.convert(t),this.transform):0}setFeatureState(e,t){return this._isValidId(e.source)?(this.style.setFeatureState(e,t),this._update()):this}removeFeatureState(e,t){return this._isValidId(e.source)?(this.style.removeFeatureState(e,t),this._update()):this}getFeatureState(e){return this._isValidId(e.source)?this.style.getFeatureState(e):null}_updateContainerDimensions(){if(!this._container)return;const e=this._container.getBoundingClientRect().width||400,t=this._container.getBoundingClientRect().height||300;let r,i,n,o=this._container;for(;o&&(!i||!n);){const e=window.getComputedStyle(o).transform;e&&"none"!==e&&(r=e.match(/matrix.*\((.+)\)/)[1].split(", "),r[0]&&"0"!==r[0]&&"1"!==r[0]&&(i=r[0]),r[3]&&"0"!==r[3]&&"1"!==r[3]&&(n=r[3])),o=o.parentElement}this._containerWidth=i?Math.abs(e/i):e,this._containerHeight=n?Math.abs(t/n):t}_detectMissingCSS(){"rgb(250, 128, 114)"!==window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&e.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 e=this._container;e.classList.add("mapboxgl-map"),(this._missingCSSCanary=o("div","mapboxgl-canary",e)).style.visibility="hidden",this._detectMissingCSS();const t=this._canvasContainer=o("div","mapboxgl-canvas-container",e);this._canvas=o("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=o("div","mapboxgl-control-container",e),i=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((e=>{i[e]=o("div",`mapboxgl-ctrl-${e}`,r)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(t,r){const i=e.f.devicePixelRatio||1;this._canvas.width=i*Math.ceil(t),this._canvas.height=i*Math.ceil(r),this._canvas.style.width=`${t}px`,this._canvas.style.height=`${r}px`}_addMarker(e){this._markers.push(e)}_removeMarker(e){const t=this._markers.indexOf(e);-1!==t&&this._markers.splice(t,1)}_addPopup(e){this._popups.push(e)}_removePopup(e){const t=this._popups.indexOf(e);-1!==t&&this._popups.splice(t,1)}_setupPainter(){const t=e.e({},r.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),i=this._canvas.getContext("webgl2",t);i?(e.dj(i,!0),this.painter=new Ko(i,this._contextCreateOptions,this.transform,this._tp),this.on("data",(e=>{"source"===e.dataType&&this.painter.setTileLoadedFlag(!0)})),e.dk.testSupport(i)):this.fire(new e.a(new Error("Failed to initialize WebGL")))}_contextLost(t){t.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new e.b("webglcontextlost",{originalEvent:t}))}_contextRestored(t){this._setupPainter(),this.resize(),this._update(),this.fire(new e.b("webglcontextrestored",{originalEvent:t}))}_onMapScroll(e){if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(e){return this.style?(this._styleDirty=this._styleDirty||e,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e)}_requestDomTask(e){!this.loaded()||this.loaded()&&!this.isMoving()?e():this._domRenderTaskQueue.add(e)}_render(t){let r;this.fire(new e.b("renderstart"));const i=this.painter.context.extTimerQuery,n=e.f.now(),o=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(r=o.createQuery(),o.beginQuery(i.TIME_ELAPSED_EXT,r)),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(t),this._domRenderTaskQueue.run(t),this._removed)return;this._updateProjectionTransition();const s=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const t=this.transform.zoom,r=this.transform.pitch,i=e.f.now(),n=new e.N(t,{now:i,fadeDuration:s,pitch:r,transition:this.style.transition});this.style.update(n)}this.style&&this.style.hasFogTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let a=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),a=this._updateAverageElevation(n),this.style.updateSources(this.transform),this._forceMarkerAndPopupUpdate()):a=this._updateAverageElevation(n),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,s,this._crossSourceCollisions),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:s,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 e.b("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new e.b("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),r){const t=e.f.now()-n;o.endQuery(i.TIME_ELAPSED_EXT),setTimeout((()=>{const i=o.getQueryParameter(r,o.QUERY_RESULT)/1e6;o.deleteQuery(r),this.fire(new e.b("gpu-timing-frame",{cpuTime:t,gpuTime:i}))}),50)}if(this.listens("gpu-timing-layer")){const t=this.painter.collectGpuTimers();setTimeout((()=>{const r=this.painter.queryGpuTimers(t);this.fire(new e.b("gpu-timing-layer",{layerTimes:r}))}),50)}if(this.listens("gpu-timing-deferred-render")){const t=this.painter.collectDeferredRenderGpuQueries();setTimeout((()=>{const r=this.painter.queryGpuTimeDeferredRender(t);this.fire(new e.b("gpu-timing-deferred-render",{gpuTime:r}))}),50)}const l=this._sourcesDirty||this._styleDirty||this._placementDirty||a;if(l||this._repaint)this.triggerRepaint();else{const t=!this.isMoving()&&this.loaded();if(t&&(a=this._updateAverageElevation(n,!0)),a)this.triggerRepaint();else if(this._triggerFrame(!1),t&&(this.fire(new e.b("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const t=this._calculateSpeedIndex();this.fire(new e.b("speedindexcompleted",{speedIndex:t})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||l||(this._fullyLoaded=!0,this._performanceMetricsCollection&&e.dl(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(e){for(const t of this._markers)e&&!this.getRenderWorldCopies()&&(t._lngLat=t._lngLat.wrap()),t._update();for(const t of this._popups)!e||this.getRenderWorldCopies()||t._trackPointer||(t._lngLat=t._lngLat.wrap()),t._update()}_updateAverageElevation(e,t=!1){const r=e=>(this.transform.averageElevation=e,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&r(0);const i=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(i||(t||e-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(e)){const t=this.transform.averageElevation;let n=this.transform.sampleAverageElevation();this.transform.elevation&&(this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(n)?n=0:this._averageElevationLastSampledAt=e;const o=Math.abs(t-n);if(o>1){if(this._isInitialLoad||i)return this._averageElevation.jumpTo(n),r(n);this._averageElevation.easeTo(n,e,300)}else if(o>1e-4)return this._averageElevation.jumpTo(n),r(n)}return!!this._averageElevation.isEasing(e)&&r(this._averageElevation.getValue(e))}_authenticate(){e.dm(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(t=>{if(t&&(t.message===e.dn||401===t.status)){const t=this.painter.context.gl;e.dj(t,!1),this._logoControl instanceof ea&&this._logoControl._updateLogo(),t&&t.clear(t.DEPTH_BUFFER_BIT|t.COLOR_BUFFER_BIT|t.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new e.a(new Error("A valid Mapbox access token is required to use Mapbox GL JS. To create an account or a new access token, visit https://account.mapbox.com/")))}})),e.dp(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(()=>{}))}_postStyleLoadEvent(){this.style.globalId&&e.dq(this._requestManager._customAccessToken,{map:this,skuToken:this._requestManager._skuToken,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()})}_updateTerrain(){const e=this._isDragging();this.painter.updateTerrain(this.style,e)}_calculateSpeedIndex(){const e=this.painter.canvasCopy(),t=this.painter.getCanvasCopiesAndTimestamps();t.timeStamps.push(performance.now());const r=this.painter.context.gl,i=r.createFramebuffer();function n(e){r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,e,0);const t=new Uint8Array(r.drawingBufferWidth*r.drawingBufferHeight*4);return r.readPixels(0,0,r.drawingBufferWidth,r.drawingBufferHeight,r.RGBA,r.UNSIGNED_BYTE,t),t}return r.bindFramebuffer(r.FRAMEBUFFER,i),this._canvasPixelComparison(n(e),t.canvasCopies.map(n),t.timeStamps)}_canvasPixelComparison(e,t,r){let i=r[1]-r[0];const n=e.length/4;for(let o=0;o<t.length;o++){const s=t[o];let a=0;for(let t=0;t<s.length;t+=4)s[t]===e[t]&&s[t+1]===e[t+1]&&s[t+2]===e[t+2]&&s[t+3]===e[t+3]&&(a+=1);i+=(r[o+2]-r[o+1])*(1-a/n)}return i}remove(){this._hash&&this._hash.remove();for(const e of this._controls)e.onRemove(this);this._controls=[],this._frame&&(this._frame.cancel(),this._frame=null),this._renderTaskQueue.clear(),this._domRenderTaskQueue.clear(),this.style&&this.style.destroy(),this.painter.destroy(),this.handlers&&this.handlers.destroy(),this.handlers=void 0,this.setStyle(null),window.removeEventListener("resize",this._onWindowResize,!1),window.removeEventListener("orientationchange",this._onWindowResize,!1),window.removeEventListener(this._fullscreenchangeEvent,this._onWindowResize,!1),window.removeEventListener("online",this._onWindowOnline,!1),window.removeEventListener("visibilitychange",this._onVisibilityChange,!1);const t=this.painter.context.gl.getExtension("WEBGL_lose_context");t&&t.loseContext(),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvasContainer.remove(),this._controlContainer.remove(),this._missingCSSCanary.remove(),this._canvas=void 0,this._canvasContainer=void 0,this._controlContainer=void 0,this._missingCSSCanary=void 0,this._container.classList.remove("mapboxgl-map"),this._container.removeEventListener("scroll",this._onMapScroll,!1),e.dr(this.painter.context.gl),e.ds.remove(),e.dt.remove(),this._removed=!0,this.fire(new e.b("remove"))}triggerRepaint(){this._triggerFrame(!0)}_triggerFrame(t){this._renderNextFrame=this._renderNextFrame||t,this.style&&!this._frame&&(this._frame=e.f.frame((e=>{const t=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,t&&this._render(e)})))}_preloadTiles(t){const r=this.style?this.style.getSourceCaches():[];return e.b4(r,((e,r)=>e._preloadTiles(t,r)),(()=>{this.triggerRepaint()})),this}_onWindowOnline(){this._update()}_onWindowResize(e){this._trackResize&&this.resize({originalEvent:e})._update()}_onVisibilityChange(){"hidden"===document.visibilityState&&this._visibilityHidden++}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._tp.refreshUI(),this._update())}get showParseStatus(){return!!this._showParseStatus}set showParseStatus(e){this._showParseStatus!==e&&(this._showParseStatus=e,this._tp.refreshUI(),this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(e){this._showTerrainWireframe!==e&&(this._showTerrainWireframe=e,this._tp.refreshUI(),this._update())}get showLayers2DWireframe(){return!!this._showLayers2DWireframe}set showLayers2DWireframe(e){this._showLayers2DWireframe!==e&&(this._showLayers2DWireframe=e,this._tp.refreshUI(),this._update())}get showLayers3DWireframe(){return!!this._showLayers3DWireframe}set showLayers3DWireframe(e){this._showLayers3DWireframe!==e&&(this._showLayers3DWireframe=e,this._tp.refreshUI(),this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(e){this._speedIndexTiming!==e&&(this._speedIndexTiming=e,this._update())}get showPadding(){return!!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._tp.refreshUI(),this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,this._tp.refreshUI(),e?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._tp.refreshUI(),this._update())}get repaint(){return!!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this._tp.refreshUI(),this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(e){this._vertices=e,this._update()}get showTileAABBs(){return!!this._showTileAABBs}set showTileAABBs(e){this._showTileAABBs!==e&&(this._showTileAABBs=e,this._tp.refreshUI(),e&&this._update())}_setCacheLimits(t,r){e.dv(t,r)}get version(){return e.du}},NavigationControl:class{constructor(t){this.options=e.e({},da,t),this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this.options.showZoom&&(e.a$(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",(e=>{this._map&&this._map.zoomIn({},{originalEvent:e})})),o("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",(e=>{this._map&&this._map.zoomOut({},{originalEvent:e})})),o("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(e.a$(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",(e=>{const t=this._map;t&&(this.options.visualizePitch?t.resetNorthPitch({},{originalEvent:e}):t.resetNorth({},{originalEvent:e}))})),this._compassIcon=o("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const e=this._map;if(!e)return;const t=e.getZoom(),r=t===e.getMaxZoom(),i=t===e.getMinZoom();this._zoomInButton.disabled=r,this._zoomOutButton.disabled=i,this._zoomInButton.setAttribute("aria-disabled",r.toString()),this._zoomOutButton.setAttribute("aria-disabled",i.toString())}_rotateCompassArrow(){const e=this._map;if(!e)return;const t=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(e.transform.pitch*(Math.PI/180)),.5)}) rotateX(${e.transform.pitch}deg) rotateZ(${e.transform.angle*(180/Math.PI)}deg)`:`rotate(${e.transform.angle*(180/Math.PI)}deg)`;e._requestDomTask((()=>{this._compassIcon&&(this._compassIcon.style.transform=t)}))}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),e.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&e.on("pitch",this._rotateCompassArrow),e.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new pa(e,this._compass,this.options.visualizePitch)),this._container}onRemove(){const e=this._map;e&&(this._container.remove(),this.options.showZoom&&e.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&e.off("pitch",this._rotateCompassArrow),e.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(e,t){const r=o("button",e,this._container);return r.type="button",r.addEventListener("click",t),r}_setButtonTitle(e,t){if(!this._map)return;const r=this._map._getUIString(`NavigationControl.${t}`);e.setAttribute("aria-label",r),e.firstElementChild&&e.firstElementChild.setAttribute("title",r)}},GeolocateControl:class extends e.E{constructor(t){super();const r=navigator.geolocation;this.options=e.e({geolocation:r},fa,t),e.a$(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=Jo(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(e){return this._map=e,this._container=o("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(e){const t=(t=!!this.options.geolocation)=>{this._supportsGeolocation=t,e(t)};void 0!==this._supportsGeolocation?e(this._supportsGeolocation):void 0!==navigator.permissions?navigator.permissions.query({name:"geolocation"}).then((e=>t("denied"!==e.state))).catch((()=>t())):t()}_isOutOfMapMaxBounds(e){const t=this._map.getMaxBounds(),r=e.coords;return!!t&&(r.longitude<t.getWest()||r.longitude>t.getEast()||r.latitude<t.getSouth()||r.latitude>t.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(t){if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new e.b("outofmaxbounds",t)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=t,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("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(t),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(t),this.options.showUserLocation&&this._userLocationDotMarker.removeClassName("mapboxgl-user-location-dot-stale"),this.fire(new e.b("geolocate",t)),this._finish()}}_updateCamera(t){const r=new e.bq(t.coords.longitude,t.coords.latitude),i=t.coords.accuracy,n=this._map.getBearing(),o=e.e({bearing:n},this.options.fitBoundsOptions);this._map.fitBounds(r.toBounds(i),o,{geolocateSource:!0})}_updateMarker(t){if(t){const r=new e.bq(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(r).addTo(this._map),this._userLocationDotMarker.setLngLat(r).addTo(this._map),this._accuracy=t.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const t=this._map.transform,r=e.bo(1,t._center.lat)*t.worldSize,i=Math.ceil(2*this._accuracy*r);this._circleElement.style.width=`${i}px`,this._circleElement.style.height=`${i}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(t){if(this._map){if(this.options.trackUserLocation)if(1===t.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 e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===t.code&&this._noTimeout)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._userLocationDotMarker.addClassName("mapboxgl-user-location-dot-stale"),this.fire(new e.b("error",t)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(t){if(void 0!==this._map){if(this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this._geolocateButton=o("button","mapboxgl-ctrl-geolocate",this._container),o("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",!1===t){e.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 e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=o("div","mapboxgl-user-location"),this._dotElement.appendChild(o("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(o("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new na({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=o("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new na({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 e.b("trackuserlocationend")))}))}}_onDeviceOrientation(e){this._userLocationDotMarker&&(e.webkitCompassHeading?this._heading=e.webkitCompassHeading:!0===e.absolute&&(this._heading=-1*e.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return e.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 e.b("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 e.b("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 e.b("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 e;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(e={maximumAge:6e5,timeout:0},this._noTimeout=!0):(e=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,e),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const e=()=>{"ondeviceorientationabsolute"in window?window.addEventListener("deviceorientationabsolute",this._onDeviceOrientation):window.addEventListener("deviceorientation",this._onDeviceOrientation)};"undefined"!=typeof DeviceMotionEvent&&"function"==typeof DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((t=>{"granted"===t&&e()})).catch(console.error):e()}_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:Js,ScaleControl:class{constructor(t){this.options=e.e({},ma,t),this._isNumberFormatSupported=function(){try{return new Intl.NumberFormat("en",{style:"unit",unitDisplay:"short",unit:"meter"}),!0}catch(e){return!1}}(),e.a$(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const e=this.options.maxWidth||100,t=this._map,r=t._containerHeight/2,i=t._containerWidth/2-e/2,n=t.unproject([i,r]),o=t.unproject([i+e,r]),s=n.distanceTo(o);if("imperial"===this.options.unit){const t=3.2808*s;t>5280?this._setScale(e,t/5280,"mile"):this._setScale(e,t,"foot")}else"nautical"===this.options.unit?this._setScale(e,s/1852,"nautical-mile"):s>=1e3?this._setScale(e,s/1e3,"kilometer"):this._setScale(e,s,"meter")}_setScale(e,t,r){this._map._requestDomTask((()=>{const i=function(e){const t=Math.pow(10,`${Math.floor(e)}`.length-1);let r=e/t;return r=r>=10?10:r>=5?5:r>=3?3:r>=2?2:r>=1?1:function(e){const t=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*t)/t}(r),t*r}(t),n=i/t;this._container.innerHTML=this._isNumberFormatSupported&&"nautical-mile"!==r?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:r}).format(i):`${i}&nbsp;${Aa[r]}`,this._container.style.width=e*n+"px"}))}onAdd(e){return this._map=e,this._language=e.getLanguage(),this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-scale",e.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(e){this._language=e,this._update()}setUnit(e){this.options.unit=e,this._update()}},FullscreenControl:class{constructor(t){this._fullscreen=!1,t&&t.container&&(t.container instanceof HTMLElement?this._container=t.container:e.w("Full screen control 'container' must be a DOM element.")),e.a$(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(t){return this._map=t,this._container||(this._container=this._map.getContainer()),this._controlContainer=o("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",e.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 e=this._fullscreenButton=o("button","mapboxgl-ctrl-fullscreen",this._controlContainer);o("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",e)}_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 e.E{constructor(t){super(),this.options=e.e(Object.create(oa),t),e.a$(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(t&&t.className?t.className.trim().split(/\s+/):[])}addTo(t){return this._map&&this.remove(),this._map=t,this.options.closeOnClick&&t.on("preclick",this._onClose),this.options.closeOnMove&&t.on("move",this._onClose),t.on("remove",this.remove),this._update(),t._addPopup(this),this._focusFirstElement(),this._trackPointer?(t.on("mousemove",this._onMouseEvent),t.on("mouseup",this._onMouseEvent),t._canvasContainer.classList.add("mapboxgl-track-pointer")):t.on("move",this._update),this.fire(new e.b("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const t=this._map;return t&&(t.off("move",this._update),t.off("move",this._onClose),t.off("preclick",this._onClose),t.off("click",this._onClose),t.off("remove",this.remove),t.off("mousemove",this._onMouseEvent),t.off("mouseup",this._onMouseEvent),t.off("drag",this._onMouseEvent),t._canvasContainer&&t._canvasContainer.classList.remove("mapboxgl-track-pointer"),t._removePopup(this),this._map=void 0),this.fire(new e.b("close")),this}getLngLat(){return this._lngLat}setLngLat(t){this._lngLat=e.bq.convert(t),this._pos=null,this._trackPointer=!1,this._update();const r=this._map;return r&&(r.on("move",this._update),r.off("mousemove",this._onMouseEvent),r._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const e=this._map;return e&&(e.off("move",this._update),e.on("mousemove",this._onMouseEvent),e.on("drag",this._onMouseEvent),e._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(document.createTextNode(e))}setHTML(e){const t=document.createDocumentFragment(),r=document.createElement("body");let i;for(r.innerHTML=e;i=r.firstChild,i;)t.appendChild(i);return this.setDOMContent(t)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){let t=this._content;if(t)for(;t.hasChildNodes();)t.firstChild&&t.removeChild(t.firstChild);else t=this._content=o("div","mapboxgl-popup-content",this._container||void 0);if(t.appendChild(e),this.options.closeButton){const e=this._closeButton=o("button","mapboxgl-popup-close-button",t);e.type="button",e.setAttribute("aria-label","Close popup"),e.setAttribute("aria-hidden","true"),e.innerHTML="&#215;",e.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(e){return this._classList.add(e),this._updateClassList(),this}removeClassName(e){return this._classList.delete(e),this._updateClassList(),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){let t;return this._classList.delete(e)?t=!1:(this._classList.add(e),t=!0),this._updateClassList(),t}_onMouseEvent(e){this._update(e.point)}_getAnchor(e){if(this.options.anchor)return this.options.anchor;const t=this._map,r=this._container,i=this._pos;if(!t||!r||!i)return"bottom";const n=r.offsetWidth,o=r.offsetHeight,s=i.x<n/2,a=i.x>t.transform.width-n/2;if(i.y+e<o)return s?"top-left":a?"top-right":"top";if(i.y>t.transform.height-o){if(s)return"bottom-left";if(a)return"bottom-right"}return s?"left":a?"right":"bottom"}_updateClassList(){const e=this._container;if(!e)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"),e.className=t.join(" ")}_update(t){const r=this._map,i=this._content;if(!r||!this._lngLat&&!this._trackPointer||!i)return;let n=this._container;if(n||(n=this._container=o("div","mapboxgl-popup",r.getContainer()),this._tip=o("div","mapboxgl-popup-tip",n),n.appendChild(i)),this.options.maxWidth&&n.style.maxWidth!==this.options.maxWidth&&(n.style.maxWidth=this.options.maxWidth),r.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=ra(this._lngLat,this._pos,r.transform)),!this._trackPointer||t){const e=this._pos=this._trackPointer&&t?t:r.project(this._lngLat),i=aa(this.options.offset),n=this._anchor=this._getAnchor(i.y),o=aa(this.options.offset,n),s=e.add(o).round();r._requestDomTask((()=>{this._container&&n&&(this._container.style.transform=`${ia[n]} translate(${s.x}px,${s.y}px)`)}))}if(!this._marker&&r._showingGlobe()){const t=e.de(r.transform,this._lngLat)?0:1;this._setOpacity(t)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(sa);e&&e.focus()}_onClose(){this.remove()}_setOpacity(e){this._container&&(this._container.style.opacity=`${e}`),this._content&&(this._content.style.pointerEvents=e?"auto":"none")}},Marker:na,Style:Ii,LngLat:e.bq,LngLatBounds:e.ag,Point:e.P,MercatorCoordinate:e.O,FreeCameraOptions:ci,Evented:e.E,config:e.dd,prewarm:e.dy,clearPrewarmedResources:e.dz,get accessToken(){return e.dd.ACCESS_TOKEN},set accessToken(t){e.dd.ACCESS_TOKEN=t},get baseApiUrl(){return e.dd.API_URL},set baseApiUrl(t){e.dd.API_URL=t},get workerCount(){return e.dA.workerCount},set workerCount(t){e.dA.workerCount=t},get maxParallelImageRequests(){return e.dd.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(t){e.dd.MAX_PARALLEL_IMAGE_REQUESTS=t},clearStorage(t){e.dB(t)},get workerUrl(){return e.dC.workerUrl},set workerUrl(t){e.dC.workerUrl=t},get workerClass(){return e.dC.workerClass},set workerClass(t){e.dC.workerClass=t},get workerParams(){return e.dC.workerParams},set workerParams(t){e.dC.workerParams=t},get dracoUrl(){return e.dD()},set dracoUrl(t){e.dE(t)},get meshoptUrl(){return e.dF()},set meshoptUrl(t){e.dG(t)},setNow:e.f.setNow,restoreNow:e.f.restoreNow};return ga})),r}(),Fs=Ue({__proto__:null,default:Ge(Rs)},[Rs]);const js=te.createContext(null);function Vs(e,t){if(e===t)return!0;if(!e||!t)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!Vs(e[r],t[r]))return!1;return!0}if(Array.isArray(t))return!1;if("object"==typeof e&&"object"==typeof t){const r=Object.keys(e),i=Object.keys(t);if(r.length!==i.length)return!1;for(const i of r){if(!t.hasOwnProperty(i))return!1;if(!Vs(e[i],t[i]))return!1}return!0}return!1}function Ns(e,t){if(!e.getProjection)return;const r=e.getProjection();Vs(r,t.getProjection())||t.setProjection(r)}function Us(e){return{longitude:e.center.lng,latitude:e.center.lat,zoom:e.zoom,pitch:e.pitch,bearing:e.bearing,padding:e.padding}}function Hs(e,t){const r=t.viewState||t;let i=!1;if("longitude"in r&&"latitude"in r){const t=e.center;e.center=new t.constructor(r.longitude,r.latitude),i=i||t!==e.center}if("zoom"in r){const t=e.zoom;e.zoom=r.zoom,i=i||t!==e.zoom}if("bearing"in r){const t=e.bearing;e.bearing=r.bearing,i=i||t!==e.bearing}if("pitch"in r){const t=e.pitch;e.pitch=r.pitch,i=i||t!==e.pitch}return r.padding&&!e.isPaddingEqual(r.padding)&&(i=!0,e.padding=r.padding),i}const Gs=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function Zs(e){if(!e)return null;if("string"==typeof e)return e;if("toJS"in e&&(e=e.toJS()),!e.layers)return e;const t={};for(const r of e.layers)t[r.id]=r;const r=e.layers.map((e=>{let r=null;"interactive"in e&&(r=Object.assign({},e),delete r.interactive);const i=t[e.ref];if(i){r=r||Object.assign({},e),delete r.ref;for(const e of Gs)e in i&&(r[e]=i[e])}return r||e}));return{...e,layers:r}}const Ws={version:8,sources:{},layers:[]},Qs={mousedown:"onMouseDown",mouseup:"onMouseUp",mouseover:"onMouseOver",mousemove:"onMouseMove",click:"onClick",dblclick:"onDblClick",mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",mouseout:"onMouseOut",contextmenu:"onContextMenu",touchstart:"onTouchStart",touchend:"onTouchEnd",touchmove:"onTouchMove",touchcancel:"onTouchCancel"},qs={movestart:"onMoveStart",move:"onMove",moveend:"onMoveEnd",dragstart:"onDragStart",drag:"onDrag",dragend:"onDragEnd",zoomstart:"onZoomStart",zoom:"onZoom",zoomend:"onZoomEnd",rotatestart:"onRotateStart",rotate:"onRotate",rotateend:"onRotateEnd",pitchstart:"onPitchStart",pitch:"onPitch",pitchend:"onPitchEnd"},Xs={wheel:"onWheel",boxzoomstart:"onBoxZoomStart",boxzoomend:"onBoxZoomEnd",boxzoomcancel:"onBoxZoomCancel",resize:"onResize",load:"onLoad",render:"onRender",idle:"onIdle",remove:"onRemove",data:"onData",styledata:"onStyleData",sourcedata:"onSourceData",error:"onError"},Ys=["minZoom","maxZoom","minPitch","maxPitch","maxBounds","projection","renderWorldCopies"],$s=["scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate","touchPitch"];class Ks{constructor(e,t,r){this._map=null,this._internalUpdate=!1,this._inRender=!1,this._hoveredFeatures=null,this._deferredEvents={move:!1,zoom:!1,pitch:!1,rotate:!1},this._onEvent=e=>{const t=this.props[Xs[e.type]];t?t(e):"error"===e.type&&console.error(e.error)},this._onPointerEvent=e=>{"mousemove"!==e.type&&"mouseout"!==e.type||this._updateHover(e);const t=this.props[Qs[e.type]];t&&(this.props.interactiveLayerIds&&"mouseover"!==e.type&&"mouseout"!==e.type&&(e.features=this._hoveredFeatures||this._queryRenderedFeatures(e.point)),t(e),delete e.features)},this._onCameraEvent=e=>{if(!this._internalUpdate){const t=this.props[qs[e.type]];t&&t(e)}e.type in this._deferredEvents&&(this._deferredEvents[e.type]=!1)},this._MapClass=e,this.props=t,this._initialize(r)}get map(){return this._map}get transform(){return this._renderTransform}setProps(e){const t=this.props;this.props=e;const r=this._updateSettings(e,t);r&&this._createShadowTransform(this._map);const i=this._updateSize(e),n=this._updateViewState(e,!0);this._updateStyle(e,t),this._updateStyleComponents(e,t),this._updateHandlers(e,t),(r||i||n&&!this._map.isMoving())&&this.redraw()}static reuse(e,t){const r=Ks.savedMaps.pop();if(!r)return null;const i=r.map,n=i.getContainer();for(t.className=n.className;n.childNodes.length>0;)t.appendChild(n.childNodes[0]);i._container=t;const o=i._resizeObserver;o&&(o.disconnect(),o.observe(t)),r.setProps({...e,styleDiffing:!1}),i.resize();const{initialViewState:s}=e;return s&&(s.bounds?i.fitBounds(s.bounds,{...s.fitBoundsOptions,duration:0}):r._updateViewState(s,!1)),i.isStyleLoaded()?i.fire("load"):i.once("styledata",(()=>i.fire("load"))),i._update(),r}_initialize(e){const{props:t}=this,{mapStyle:r=Ws}=t,i={...t,...t.initialViewState,accessToken:t.mapboxAccessToken||Js()||null,container:e,style:Zs(r)},n=i.initialViewState||i.viewState||i;if(Object.assign(i,{center:[n.longitude||0,n.latitude||0],zoom:n.zoom||0,pitch:n.pitch||0,bearing:n.bearing||0}),t.gl){const e=HTMLCanvasElement.prototype.getContext;HTMLCanvasElement.prototype.getContext=()=>(HTMLCanvasElement.prototype.getContext=e,t.gl)}const o=new this._MapClass(i);n.padding&&o.setPadding(n.padding),t.cursor&&(o.getCanvas().style.cursor=t.cursor),this._createShadowTransform(o);const s=o._render;o._render=e=>{this._inRender=!0,s.call(o,e),this._inRender=!1};const a=o._renderTaskQueue.run;o._renderTaskQueue.run=e=>{a.call(o._renderTaskQueue,e),this._onBeforeRepaint()},o.on("render",(()=>this._onAfterRepaint()));const l=o.fire;o.fire=this._fireEvent.bind(this,l),o.on("resize",(()=>{this._renderTransform.resize(o.transform.width,o.transform.height)})),o.on("styledata",(()=>{this._updateStyleComponents(this.props,{}),Ns(o.transform,this._renderTransform)})),o.on("sourcedata",(()=>this._updateStyleComponents(this.props,{})));for(const e in Qs)o.on(e,this._onPointerEvent);for(const e in qs)o.on(e,this._onCameraEvent);for(const e in Xs)o.on(e,this._onEvent);this._map=o}recycle(){const e=this.map.getContainer().querySelector("[mapboxgl-children]");null==e||e.remove(),Ks.savedMaps.push(this)}destroy(){this._map.remove()}redraw(){const e=this._map;!this._inRender&&e.style&&(e._frame&&(e._frame.cancel(),e._frame=null),e._render())}_createShadowTransform(e){const t=function(e){const t=e.clone();return t.pixelsToGLUnits=e.pixelsToGLUnits,t}(e.transform);e.painter.transform=t,this._renderTransform=t}_updateSize(e){const{viewState:t}=e;if(t){const e=this._map;if(t.width!==e.transform.width||t.height!==e.transform.height)return e.resize(),!0}return!1}_updateViewState(e,t){if(this._internalUpdate)return!1;const r=this._map,i=this._renderTransform,{zoom:n,pitch:o,bearing:s}=i,a=r.isMoving();a&&(i.cameraElevationReference="sea");const l=Hs(i,{...Us(r.transform),...e});if(a&&(i.cameraElevationReference="ground"),l&&t){const e=this._deferredEvents;e.move=!0,e.zoom||(e.zoom=n!==i.zoom),e.rotate||(e.rotate=s!==i.bearing),e.pitch||(e.pitch=o!==i.pitch)}return a||Hs(r.transform,e),l}_updateSettings(e,t){const r=this._map;let i=!1;for(const n of Ys)if(n in e&&!Vs(e[n],t[n])){i=!0;const t=r[`set${n[0].toUpperCase()}${n.slice(1)}`];null==t||t.call(r,e[n])}return i}_updateStyle(e,t){if(e.cursor!==t.cursor&&(this._map.getCanvas().style.cursor=e.cursor||""),e.mapStyle!==t.mapStyle){const{mapStyle:t=Ws,styleDiffing:r=!0}=e,i={diff:r};return"localIdeographFontFamily"in e&&(i.localIdeographFontFamily=e.localIdeographFontFamily),this._map.setStyle(Zs(t),i),!0}return!1}_updateStyleComponents(e,t){const r=this._map;let i=!1;return r.isStyleLoaded()&&("light"in e&&r.setLight&&!Vs(e.light,t.light)&&(i=!0,r.setLight(e.light)),"fog"in e&&r.setFog&&!Vs(e.fog,t.fog)&&(i=!0,r.setFog(e.fog)),"terrain"in e&&r.setTerrain&&!Vs(e.terrain,t.terrain)&&(e.terrain&&!r.getSource(e.terrain.source)||(i=!0,r.setTerrain(e.terrain)))),i}_updateHandlers(e,t){var r,i;const n=this._map;let o=!1;for(const s of $s){const a=null===(r=e[s])||void 0===r||r;Vs(a,null===(i=t[s])||void 0===i||i)||(o=!0,a?n[s].enable(a):n[s].disable())}return o}_queryRenderedFeatures(e){const t=this._map,r=t.transform,{interactiveLayerIds:i=[]}=this.props;try{return t.transform=this._renderTransform,t.queryRenderedFeatures(e,{layers:i.filter(t.getLayer.bind(t))})}catch(e){return[]}finally{t.transform=r}}_updateHover(e){var t;const{props:r}=this;if(r.interactiveLayerIds&&(r.onMouseMove||r.onMouseEnter||r.onMouseLeave)){const r=e.type,i=(null===(t=this._hoveredFeatures)||void 0===t?void 0:t.length)>0,n=this._queryRenderedFeatures(e.point),o=n.length>0;!o&&i&&(e.type="mouseleave",this._onPointerEvent(e)),this._hoveredFeatures=n,o&&!i&&(e.type="mouseenter",this._onPointerEvent(e)),e.type=r}else this._hoveredFeatures=null}_fireEvent(e,t,r){const i=this._map,n=i.transform,o="string"==typeof t?t:t.type;return"move"===o&&this._updateViewState(this.props,!1),o in qs&&("object"==typeof t&&(t.viewState=Us(n)),this._map.isMoving())?(i.transform=this._renderTransform,e.call(i,t,r),i.transform=n,i):(e.call(i,t,r),i)}_onBeforeRepaint(){const e=this._map;this._internalUpdate=!0;for(const t in this._deferredEvents)this._deferredEvents[t]&&e.fire(t);this._internalUpdate=!1;const t=this._map.transform;e.transform=this._renderTransform,this._onAfterRepaint=()=>{Ns(this._renderTransform,t),e.transform=t}}}function Js(){let e=null;if("undefined"!=typeof location){const t=/access_token=([^&\/]*)/.exec(location.search);e=t&&t[1]}try{e=e||process.env.MapboxAccessToken}catch(e){}try{e=e||process.env.REACT_APP_MAPBOX_ACCESS_TOKEN}catch(e){}return e}Ks.savedMaps=[];const ea=["setMaxBounds","setMinZoom","setMaxZoom","setMinPitch","setMaxPitch","setRenderWorldCopies","setProjection","setStyle","addSource","removeSource","addLayer","removeLayer","setLayerZoomRange","setFilter","setPaintProperty","setLayoutProperty","setLight","setTerrain","setFog","remove"];function ta(e){if(!e)return null;const t=e.map,r={getMap:()=>t,getCenter:()=>e.transform.center,getZoom:()=>e.transform.zoom,getBearing:()=>e.transform.bearing,getPitch:()=>e.transform.pitch,getPadding:()=>e.transform.padding,getBounds:()=>e.transform.getBounds(),project:r=>{const i=t.transform;t.transform=e.transform;const n=t.project(r);return t.transform=i,n},unproject:r=>{const i=t.transform;t.transform=e.transform;const n=t.unproject(r);return t.transform=i,n},queryTerrainElevation:(r,i)=>{const n=t.transform;t.transform=e.transform;const o=t.queryTerrainElevation(r,i);return t.transform=n,o},queryRenderedFeatures:(r,i)=>{const n=t.transform;t.transform=e.transform;const o=t.queryRenderedFeatures(r,i);return t.transform=n,o}};for(const e of function(e){const t=new Set;let r=e;for(;r;){for(const i of Object.getOwnPropertyNames(r))"_"!==i[0]&&"function"==typeof e[i]&&"fire"!==i&&"setEventedParent"!==i&&t.add(i);r=Object.getPrototypeOf(r)}return Array.from(t)}(t))e in r||ea.includes(e)||(r[e]=t[e].bind(t));return r}const ra="undefined"!=typeof document?se:oe,ia=["baseApiUrl","maxParallelImageRequests","workerClass","workerCount","workerUrl"];const na=te.createContext(null);function oa(e,t,r){const i=ie(js),[n,o]=ne(null),s=ae(),{current:a}=ae({mapLib:null,map:null});oe((()=>{const t=e.mapLib;let n,l=!0;return Promise.resolve(t||r).then((t=>{if(!l)return;if(!t)throw new Error("Invalid mapLib");const r="Map"in t?t:t.default;if(!r.Map)throw new Error("Invalid mapLib");if(function(e,t){for(const r of ia)r in t&&(e[r]=t[r]);const{RTLTextPlugin:r="https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-rtl-text/v0.2.3/mapbox-gl-rtl-text.js"}=t;r&&e.getRTLTextPluginStatus&&"unavailable"===e.getRTLTextPluginStatus()&&e.setRTLTextPlugin(r,(e=>{e&&console.error(e)}),!0)}(r,e),r.supported&&!r.supported(e))throw new Error("Map is not supported by this browser");e.reuseMaps&&(n=Ks.reuse(e,s.current)),n||(n=new Ks(r.Map,e,s.current)),a.map=ta(n),a.mapLib=r,o(n),null==i||i.onMapMount(a.map,e.id)})).catch((t=>{const{onError:r}=e;r?r({type:"error",target:null,originalEvent:null,error:t}):console.error(t)})),()=>{l=!1,n&&(null==i||i.onMapUnmount(e.id),e.reuseMaps?n.recycle():n.destroy())}}),[]),ra((()=>{n&&n.setProps(e)})),Ae(t,(()=>a.map),[n]);const l=ue((()=>({position:"relative",width:"100%",height:"100%",...e.style})),[e.style]);return te.createElement("div",{id:e.id,ref:s,style:l},n&&te.createElement(na.Provider,{value:a},te.createElement("div",{"mapboxgl-children":"",style:{height:"100%"}},e.children)))}const sa=/box|flex|grid|column|lineHeight|fontWeight|opacity|order|tabSize|zIndex/;function aa(e,t){if(!e||!t)return;const r=e.style;for(const e in t){const i=t[e];Number.isFinite(i)&&!sa.test(e)?r[e]=`${i}px`:r[e]=i}}var la=he(me((function(e,t){const{map:r,mapLib:i}=ie(na),n=ae({props:e});n.current.props=e;const o=ue((()=>{let t=!1;te.Children.forEach(e.children,(e=>{e&&(t=!0)}));const r={...e,element:t?document.createElement("div"):null},s=new i.Marker(r);return s.setLngLat([e.longitude,e.latitude]),s.getElement().addEventListener("click",(e=>{var t,r;null===(r=(t=n.current.props).onClick)||void 0===r||r.call(t,{type:"click",target:s,originalEvent:e})})),s.on("dragstart",(e=>{var t,r;const i=e;i.lngLat=o.getLngLat(),null===(r=(t=n.current.props).onDragStart)||void 0===r||r.call(t,i)})),s.on("drag",(e=>{var t,r;const i=e;i.lngLat=o.getLngLat(),null===(r=(t=n.current.props).onDrag)||void 0===r||r.call(t,i)})),s.on("dragend",(e=>{var t,r;const i=e;i.lngLat=o.getLngLat(),null===(r=(t=n.current.props).onDragEnd)||void 0===r||r.call(t,i)})),s}),[]);oe((()=>(o.addTo(r.getMap()),()=>{o.remove()})),[]);const{longitude:s,latitude:a,offset:l,style:c,draggable:u=!1,popup:h=null,rotation:d=0,rotationAlignment:p="auto",pitchAlignment:f="auto"}=e;return oe((()=>{aa(o.getElement(),c)}),[c]),Ae(t,(()=>o),[]),o.getLngLat().lng===s&&o.getLngLat().lat===a||o.setLngLat([s,a]),l&&!function(e,t){const r=Array.isArray(e)?e[0]:e?e.x:0,i=Array.isArray(e)?e[1]:e?e.y:0,n=Array.isArray(t)?t[0]:t?t.x:0,o=Array.isArray(t)?t[1]:t?t.y:0;return r===n&&i===o}(o.getOffset(),l)&&o.setOffset(l),o.isDraggable()!==u&&o.setDraggable(u),o.getRotation()!==d&&o.setRotation(d),o.getRotationAlignment()!==p&&o.setRotationAlignment(p),o.getPitchAlignment()!==f&&o.setPitchAlignment(f),o.getPopup()!==h&&o.setPopup(h),Ie(e.children,o.getElement())})));function ca(e){return new Set(e?e.trim().split(/\s+/):[])}var ua=he(me((function(e,t){const{map:r,mapLib:i}=ie(na),n=ue((()=>document.createElement("div")),[]),o=ae({props:e});o.current.props=e;const s=ue((()=>{const t={...e},r=new i.Popup(t);return r.setLngLat([e.longitude,e.latitude]),r.once("open",(e=>{var t,r;null===(r=(t=o.current.props).onOpen)||void 0===r||r.call(t,e)})),r}),[]);if(oe((()=>{const e=e=>{var t,r;null===(r=(t=o.current.props).onClose)||void 0===r||r.call(t,e)};return s.on("close",e),s.setDOMContent(n).addTo(r.getMap()),()=>{s.off("close",e),s.isOpen()&&s.remove()}}),[]),oe((()=>{aa(s.getElement(),e.style)}),[e.style]),Ae(t,(()=>s),[]),s.isOpen()&&(s.getLngLat().lng===e.longitude&&s.getLngLat().lat===e.latitude||s.setLngLat([e.longitude,e.latitude]),e.offset&&!Vs(s.options.offset,e.offset)&&s.setOffset(e.offset),s.options.anchor===e.anchor&&s.options.maxWidth===e.maxWidth||(s.options.anchor=e.anchor,s.setMaxWidth(e.maxWidth)),s.options.className!==e.className)){const t=ca(s.options.className),r=ca(e.className);for(const e of t)r.has(e)||s.removeClassName(e);for(const e of r)t.has(e)||s.addClassName(e);s.options.className=e.className}return Ie(e.children,n)})));function ha(e,t,r,i){const n=ie(na),o=ue((()=>e(n)),[]);return oe((()=>{const e=t,i="function"==typeof t&&"function"==typeof r?t:null,s="function"==typeof t?t:null,{map:a}=n;return a.hasControl(o)||(a.addControl(o,null==e?void 0:e.position),i&&i(n)),()=>{s&&s(n),a.hasControl(o)&&a.removeControl(o)}}),[]),o}he((function(e){const t=ha((({mapLib:t})=>new t.AttributionControl(e)),{position:e.position});return oe((()=>{aa(t._container,e.style)}),[e.style]),null})),he((function(e){const t=ha((({mapLib:t})=>new t.FullscreenControl({container:e.containerId&&document.getElementById(e.containerId)})),{position:e.position});return oe((()=>{aa(t._controlContainer,e.style)}),[e.style]),null})),he(me((function(e,t){const r=ae({props:e}),i=ha((({mapLib:t})=>{const i=new t.GeolocateControl(e),n=i._setupUI;return i._setupUI=e=>{i._container.hasChildNodes()||n(e)},i.on("geolocate",(e=>{var t,i;null===(i=(t=r.current.props).onGeolocate)||void 0===i||i.call(t,e)})),i.on("error",(e=>{var t,i;null===(i=(t=r.current.props).onError)||void 0===i||i.call(t,e)})),i.on("outofmaxbounds",(e=>{var t,i;null===(i=(t=r.current.props).onOutOfMaxBounds)||void 0===i||i.call(t,e)})),i.on("trackuserlocationstart",(e=>{var t,i;null===(i=(t=r.current.props).onTrackUserLocationStart)||void 0===i||i.call(t,e)})),i.on("trackuserlocationend",(e=>{var t,i;null===(i=(t=r.current.props).onTrackUserLocationEnd)||void 0===i||i.call(t,e)})),i}),{position:e.position});return r.current.props=e,Ae(t,(()=>i),[]),oe((()=>{aa(i._container,e.style)}),[e.style]),null})));var da=he((function(e){const t=ha((({mapLib:t})=>new t.NavigationControl(e)),{position:e.position});return oe((()=>{aa(t._container,e.style)}),[e.style]),null}));function pa(e,t){if(!e)throw new Error(t)}he((function(e){const t=ha((({mapLib:t})=>new t.ScaleControl(e)),{position:e.position}),r=ae(e),i=r.current;r.current=e;const{style:n}=e;return void 0!==e.maxWidth&&e.maxWidth!==i.maxWidth&&(t.options.maxWidth=e.maxWidth),void 0!==e.unit&&e.unit!==i.unit&&t.setUnit(e.unit),oe((()=>{aa(t._container,n)}),[n]),null}));let fa=0;let ma=0;const Aa=Promise.resolve().then((function(){return Fs})),ga=te.forwardRef((function(e,t){return oa(e,t,Aa)})),_a=la,ya=ua,xa=da,va=function(e){const t=ie(na).map.getMap(),r=ae(e),[,i]=ne(0),n=ue((()=>e.id||"jsx-layer-"+fa++),[]);if(oe((()=>{if(t){const e=()=>i((e=>e+1));return t.on("styledata",e),e(),()=>{t.off("styledata",e),t.style&&t.style._loaded&&t.getLayer(n)&&t.removeLayer(n)}}}),[t]),t&&t.style&&t.getLayer(n))try{!function(e,t,r,i){if(pa(r.id===i.id,"layer id changed"),pa(r.type===i.type,"layer type changed"),"custom"===r.type||"custom"===i.type)return;const{layout:n={},paint:o={},filter:s,minzoom:a,maxzoom:l,beforeId:c}=r;if(c!==i.beforeId&&e.moveLayer(t,c),n!==i.layout){const r=i.layout||{};for(const i in n)Vs(n[i],r[i])||e.setLayoutProperty(t,i,n[i]);for(const i in r)n.hasOwnProperty(i)||e.setLayoutProperty(t,i,void 0)}if(o!==i.paint){const r=i.paint||{};for(const i in o)Vs(o[i],r[i])||e.setPaintProperty(t,i,o[i]);for(const i in r)o.hasOwnProperty(i)||e.setPaintProperty(t,i,void 0)}Vs(s,i.filter)||e.setFilter(t,s),a===i.minzoom&&l===i.maxzoom||e.setLayerZoomRange(t,a,l)}(t,n,e,r.current)}catch(e){console.warn(e)}else!function(e,t,r){if(e.style&&e.style._loaded&&(!("source"in r)||e.getSource(r.source))){const i={...r,id:t};delete i.beforeId,e.addLayer(i,r.beforeId)}}(t,n,e);return r.current=e,null},ba=function(e){const t=ie(na).map.getMap(),r=ae(e),[,i]=ne(0),n=ue((()=>e.id||"jsx-source-"+ma++),[]);oe((()=>{if(t){const e=()=>setTimeout((()=>i((e=>e+1))),0);return t.on("styledata",e),e(),()=>{var r;if(t.off("styledata",e),t.style&&t.style._loaded&&t.getSource(n)){const e=null===(r=t.getStyle())||void 0===r?void 0:r.layers;if(e)for(const r of e)r.source===n&&t.removeLayer(r.id);t.removeSource(n)}}}}),[t]);let o=t&&t.style&&t.getSource(n);return o?function(e,t,r){pa(t.id===r.id,"source id changed"),pa(t.type===r.type,"source type changed");let i="",n=0;for(const e in t)"children"===e||"id"===e||Vs(r[e],t[e])||(i=e,n++);if(!n)return;const o=t.type;if("geojson"===o)e.setData(t.data);else if("image"===o)e.updateImage({url:t.url,coordinates:t.coordinates});else if("setCoordinates"in e&&1===n&&"coordinates"===i)e.setCoordinates(t.coordinates);else if("setUrl"in e)switch(i){case"url":e.setUrl(t.url);break;case"tiles":e.setTiles(t.tiles)}else console.warn(`Unable to update <Source> prop: ${i}`)}(o,e,r.current):o=function(e,t,r){if(e.style&&e.style._loaded){const i={...r};return delete i.id,delete i.children,e.addSource(t,i),e.getSource(t)}return null}(t,n,e),r.current=e,o&&te.Children.map(e.children,(e=>e&&ge(e,{source:n})))||null};br(".mapboxgl-map{font:12px/20px Helvetica Neue,Arial,Helvetica,sans-serif;overflow:hidden;position:relative;-webkit-tap-highlight-color:rgb(0 0 0/0)}.mapboxgl-canvas{left:0;position:absolute;top:0}.mapboxgl-map:-webkit-full-screen{height:100%;width:100%}.mapboxgl-canary{background-color:salmon}.mapboxgl-canvas-container.mapboxgl-interactive,.mapboxgl-ctrl-group button.mapboxgl-ctrl-compass{cursor:grab;-webkit-user-select:none;user-select:none}.mapboxgl-canvas-container.mapboxgl-interactive.mapboxgl-track-pointer{cursor:pointer}.mapboxgl-canvas-container.mapboxgl-interactive:active,.mapboxgl-ctrl-group button.mapboxgl-ctrl-compass:active{cursor:grabbing}.mapboxgl-canvas-container.mapboxgl-touch-zoom-rotate,.mapboxgl-canvas-container.mapboxgl-touch-zoom-rotate .mapboxgl-canvas{touch-action:pan-x pan-y}.mapboxgl-canvas-container.mapboxgl-touch-drag-pan,.mapboxgl-canvas-container.mapboxgl-touch-drag-pan .mapboxgl-canvas{touch-action:pinch-zoom}.mapboxgl-canvas-container.mapboxgl-touch-zoom-rotate.mapboxgl-touch-drag-pan,.mapboxgl-canvas-container.mapboxgl-touch-zoom-rotate.mapboxgl-touch-drag-pan .mapboxgl-canvas{touch-action:none}.mapboxgl-ctrl-bottom-left,.mapboxgl-ctrl-bottom-right,.mapboxgl-ctrl-top-left,.mapboxgl-ctrl-top-right{pointer-events:none;position:absolute;z-index:2}.mapboxgl-ctrl-top-left{left:0;top:0}.mapboxgl-ctrl-top-right{right:0;top:0}.mapboxgl-ctrl-bottom-left{bottom:0;left:0}.mapboxgl-ctrl-bottom-right{bottom:0;right:0}.mapboxgl-ctrl{clear:both;pointer-events:auto;transform:translate(0)}.mapboxgl-ctrl-top-left .mapboxgl-ctrl{float:left;margin:10px 0 0 10px}.mapboxgl-ctrl-top-right .mapboxgl-ctrl{float:right;margin:10px 10px 0 0}.mapboxgl-ctrl-bottom-left .mapboxgl-ctrl{float:left;margin:0 0 10px 10px}.mapboxgl-ctrl-bottom-right .mapboxgl-ctrl{float:right;margin:0 10px 10px 0}.mapboxgl-ctrl-group{background:#fff;border-radius:4px}.mapboxgl-ctrl-group:not(:empty){box-shadow:0 0 0 2px rgba(0,0,0,.1)}@media (-ms-high-contrast:active){.mapboxgl-ctrl-group:not(:empty){box-shadow:0 0 0 2px ButtonText}}.mapboxgl-ctrl-group button{background-color:transparent;border:0;box-sizing:border-box;cursor:pointer;display:block;height:29px;outline:none;overflow:hidden;padding:0;width:29px}.mapboxgl-ctrl-group button+button{border-top:1px solid #ddd}.mapboxgl-ctrl button .mapboxgl-ctrl-icon{background-position:50%;background-repeat:no-repeat;display:block;height:100%;width:100%}@media (-ms-high-contrast:active){.mapboxgl-ctrl-icon{background-color:transparent}.mapboxgl-ctrl-group button+button{border-top:1px solid ButtonText}}.mapboxgl-ctrl-attrib-button:focus,.mapboxgl-ctrl-group button:focus{box-shadow:0 0 2px 2px #0096ff}.mapboxgl-ctrl button:disabled{cursor:not-allowed}.mapboxgl-ctrl button:disabled .mapboxgl-ctrl-icon{opacity:.25}.mapboxgl-ctrl-group button:first-child{border-radius:4px 4px 0 0}.mapboxgl-ctrl-group button:last-child{border-radius:0 0 4px 4px}.mapboxgl-ctrl-group button:only-child{border-radius:inherit}.mapboxgl-ctrl button:not(:disabled):hover{background-color:rgb(0 0 0/5%)}.mapboxgl-ctrl-group button:focus:focus-visible{box-shadow:0 0 2px 2px #0096ff}.mapboxgl-ctrl-group button:focus:not(:focus-visible){box-shadow:none}.mapboxgl-ctrl button.mapboxgl-ctrl-zoom-out .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-9z'/%3E%3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-zoom-in .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5z'/%3E%3C/svg%3E\")}@media (-ms-high-contrast:active){.mapboxgl-ctrl button.mapboxgl-ctrl-zoom-out .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-9z'/%3E%3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-zoom-in .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5z'/%3E%3C/svg%3E\")}}@media (-ms-high-contrast:black-on-white){.mapboxgl-ctrl button.mapboxgl-ctrl-zoom-out .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23000' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-9z'/%3E%3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-zoom-in .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23000' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5z'/%3E%3C/svg%3E\")}}.mapboxgl-ctrl button.mapboxgl-ctrl-fullscreen .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3h1zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16h1zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5H13zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1V7.5z'/%3E%3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-shrink .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1h-5.5zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1v-5.5zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1v5.5zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1h5.5z'/%3E%3C/svg%3E\")}@media (-ms-high-contrast:active){.mapboxgl-ctrl button.mapboxgl-ctrl-fullscreen .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3h1zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16h1zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5H13zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1V7.5z'/%3E%3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-shrink .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1h-5.5zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1v-5.5zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1v5.5zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1h5.5z'/%3E%3C/svg%3E\")}}@media (-ms-high-contrast:black-on-white){.mapboxgl-ctrl button.mapboxgl-ctrl-fullscreen .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23000' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3h1zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16h1zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5H13zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1V7.5z'/%3E%3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-shrink .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23000' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1h-5.5zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1v-5.5zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1v5.5zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1h5.5z'/%3E%3C/svg%3E\")}}.mapboxgl-ctrl button.mapboxgl-ctrl-compass .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M10.5 14l4-8 4 8h-8z'/%3E%3Cpath id='south' d='M10.5 16l4 8 4-8h-8z' fill='%23ccc'/%3E%3C/svg%3E\")}@media (-ms-high-contrast:active){.mapboxgl-ctrl button.mapboxgl-ctrl-compass .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M10.5 14l4-8 4 8h-8z'/%3E%3Cpath id='south' d='M10.5 16l4 8 4-8h-8z' fill='%23999'/%3E%3C/svg%3E\")}}@media (-ms-high-contrast:black-on-white){.mapboxgl-ctrl button.mapboxgl-ctrl-compass .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23000' viewBox='0 0 29 29'%3E%3Cpath d='M10.5 14l4-8 4 8h-8z'/%3E%3Cpath id='south' d='M10.5 16l4 8 4-8h-8z' fill='%23ccc'/%3E%3C/svg%3E\")}}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23333'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate:disabled .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23aaa'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' fill='%23f00'/%3E%3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-active .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%2333b5e5'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-active-error .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23e58978'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-background .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%2333b5e5'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2' display='none'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-background-error .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23e54e33'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2' display='none'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-waiting .mapboxgl-ctrl-icon{animation:mapboxgl-spin 2s linear infinite}@media (-ms-high-contrast:active){.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23fff'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate:disabled .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23999'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' fill='%23f00'/%3E%3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-active .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%2333b5e5'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-active-error .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23e58978'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-background .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%2333b5e5'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2' display='none'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-background-error .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23e54e33'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2' display='none'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E\")}}@media (-ms-high-contrast:black-on-white){.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23000'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate:disabled .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23666'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' fill='%23f00'/%3E%3C/svg%3E\")}}@keyframes mapboxgl-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}a.mapboxgl-ctrl-logo{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' fill-rule='evenodd' viewBox='0 0 88 23'%3E%3Cdefs%3E%3Cpath id='logo' d='M11.5 2.25c5.105 0 9.25 4.145 9.25 9.25s-4.145 9.25-9.25 9.25-9.25-4.145-9.25-9.25 4.145-9.25 9.25-9.25zM6.997 15.983c-.051-.338-.828-5.802 2.233-8.873a4.395 4.395 0 013.13-1.28c1.27 0 2.49.51 3.39 1.42.91.9 1.42 2.12 1.42 3.39 0 1.18-.449 2.301-1.28 3.13C12.72 16.93 7 16 7 16l-.003-.017zM15.3 10.5l-2 .8-.8 2-.8-2-2-.8 2-.8.8-2 .8 2 2 .8z'/%3E%3Cpath id='text' d='M50.63 8c.13 0 .23.1.23.23V9c.7-.76 1.7-1.18 2.73-1.18 2.17 0 3.95 1.85 3.95 4.17s-1.77 4.19-3.94 4.19c-1.04 0-2.03-.43-2.74-1.18v3.77c0 .13-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V8.23c0-.12.1-.23.23-.23h1.4zm-3.86.01c.01 0 .01 0 .01-.01.13 0 .22.1.22.22v7.55c0 .12-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V15c-.7.76-1.69 1.19-2.73 1.19-2.17 0-3.94-1.87-3.94-4.19 0-2.32 1.77-4.19 3.94-4.19 1.03 0 2.02.43 2.73 1.18v-.75c0-.12.1-.23.23-.23h1.4zm26.375-.19a4.24 4.24 0 00-4.16 3.29c-.13.59-.13 1.19 0 1.77a4.233 4.233 0 004.17 3.3c2.35 0 4.26-1.87 4.26-4.19 0-2.32-1.9-4.17-4.27-4.17zM60.63 5c.13 0 .23.1.23.23v3.76c.7-.76 1.7-1.18 2.73-1.18 1.88 0 3.45 1.4 3.84 3.28.13.59.13 1.2 0 1.8-.39 1.88-1.96 3.29-3.84 3.29-1.03 0-2.02-.43-2.73-1.18v.77c0 .12-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V5.23c0-.12.1-.23.23-.23h1.4zm-34 11h-1.4c-.13 0-.23-.11-.23-.23V8.22c.01-.13.1-.22.23-.22h1.4c.13 0 .22.11.23.22v.68c.5-.68 1.3-1.09 2.16-1.1h.03c1.09 0 2.09.6 2.6 1.55.45-.95 1.4-1.55 2.44-1.56 1.62 0 2.93 1.25 2.9 2.78l.03 5.2c0 .13-.1.23-.23.23h-1.41c-.13 0-.23-.11-.23-.23v-4.59c0-.98-.74-1.71-1.62-1.71-.8 0-1.46.7-1.59 1.62l.01 4.68c0 .13-.11.23-.23.23h-1.41c-.13 0-.23-.11-.23-.23v-4.59c0-.98-.74-1.71-1.62-1.71-.85 0-1.54.79-1.6 1.8v4.5c0 .13-.1.23-.23.23zm53.615 0h-1.61c-.04 0-.08-.01-.12-.03-.09-.06-.13-.19-.06-.28l2.43-3.71-2.39-3.65a.213.213 0 01-.03-.12c0-.12.09-.21.21-.21h1.61c.13 0 .24.06.3.17l1.41 2.37 1.4-2.37a.34.34 0 01.3-.17h1.6c.04 0 .08.01.12.03.09.06.13.19.06.28l-2.37 3.65 2.43 3.7c0 .05.01.09.01.13 0 .12-.09.21-.21.21h-1.61c-.13 0-.24-.06-.3-.17l-1.44-2.42-1.44 2.42a.34.34 0 01-.3.17zm-7.12-1.49c-1.33 0-2.42-1.12-2.42-2.51 0-1.39 1.08-2.52 2.42-2.52 1.33 0 2.42 1.12 2.42 2.51 0 1.39-1.08 2.51-2.42 2.52zm-19.865 0c-1.32 0-2.39-1.11-2.42-2.48v-.07c.02-1.38 1.09-2.49 2.4-2.49 1.32 0 2.41 1.12 2.41 2.51 0 1.39-1.07 2.52-2.39 2.53zm-8.11-2.48c-.01 1.37-1.09 2.47-2.41 2.47s-2.42-1.12-2.42-2.51c0-1.39 1.08-2.52 2.4-2.52 1.33 0 2.39 1.11 2.41 2.48l.02.08zm18.12 2.47c-1.32 0-2.39-1.11-2.41-2.48v-.06c.02-1.38 1.09-2.48 2.41-2.48s2.42 1.12 2.42 2.51c0 1.39-1.09 2.51-2.42 2.51z'/%3E%3C/defs%3E%3Cmask id='clip'%3E%3Crect x='0' y='0' width='100%25' height='100%25' fill='white'/%3E%3Cuse xlink:href='%23logo'/%3E%3Cuse xlink:href='%23text'/%3E%3C/mask%3E%3Cg id='outline' opacity='0.3' stroke='%23000' stroke-width='3'%3E%3Ccircle mask='url(%23clip)' cx='11.5' cy='11.5' r='9.25'/%3E%3Cuse xlink:href='%23text' mask='url(%23clip)'/%3E%3C/g%3E%3Cg id='fill' opacity='0.9' fill='%23fff'%3E%3Cuse xlink:href='%23logo'/%3E%3Cuse xlink:href='%23text'/%3E%3C/g%3E%3C/svg%3E\");background-repeat:no-repeat;cursor:pointer;display:block;height:23px;margin:0 0 -4px -4px;overflow:hidden;width:88px}a.mapboxgl-ctrl-logo.mapboxgl-compact{width:23px}@media (-ms-high-contrast:active){a.mapboxgl-ctrl-logo{background-color:transparent;background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' fill-rule='evenodd' viewBox='0 0 88 23'%3E%3Cdefs%3E%3Cpath id='logo' d='M11.5 2.25c5.105 0 9.25 4.145 9.25 9.25s-4.145 9.25-9.25 9.25-9.25-4.145-9.25-9.25 4.145-9.25 9.25-9.25zM6.997 15.983c-.051-.338-.828-5.802 2.233-8.873a4.395 4.395 0 013.13-1.28c1.27 0 2.49.51 3.39 1.42.91.9 1.42 2.12 1.42 3.39 0 1.18-.449 2.301-1.28 3.13C12.72 16.93 7 16 7 16l-.003-.017zM15.3 10.5l-2 .8-.8 2-.8-2-2-.8 2-.8.8-2 .8 2 2 .8z'/%3E%3Cpath id='text' d='M50.63 8c.13 0 .23.1.23.23V9c.7-.76 1.7-1.18 2.73-1.18 2.17 0 3.95 1.85 3.95 4.17s-1.77 4.19-3.94 4.19c-1.04 0-2.03-.43-2.74-1.18v3.77c0 .13-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V8.23c0-.12.1-.23.23-.23h1.4zm-3.86.01c.01 0 .01 0 .01-.01.13 0 .22.1.22.22v7.55c0 .12-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V15c-.7.76-1.69 1.19-2.73 1.19-2.17 0-3.94-1.87-3.94-4.19 0-2.32 1.77-4.19 3.94-4.19 1.03 0 2.02.43 2.73 1.18v-.75c0-.12.1-.23.23-.23h1.4zm26.375-.19a4.24 4.24 0 00-4.16 3.29c-.13.59-.13 1.19 0 1.77a4.233 4.233 0 004.17 3.3c2.35 0 4.26-1.87 4.26-4.19 0-2.32-1.9-4.17-4.27-4.17zM60.63 5c.13 0 .23.1.23.23v3.76c.7-.76 1.7-1.18 2.73-1.18 1.88 0 3.45 1.4 3.84 3.28.13.59.13 1.2 0 1.8-.39 1.88-1.96 3.29-3.84 3.29-1.03 0-2.02-.43-2.73-1.18v.77c0 .12-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V5.23c0-.12.1-.23.23-.23h1.4zm-34 11h-1.4c-.13 0-.23-.11-.23-.23V8.22c.01-.13.1-.22.23-.22h1.4c.13 0 .22.11.23.22v.68c.5-.68 1.3-1.09 2.16-1.1h.03c1.09 0 2.09.6 2.6 1.55.45-.95 1.4-1.55 2.44-1.56 1.62 0 2.93 1.25 2.9 2.78l.03 5.2c0 .13-.1.23-.23.23h-1.41c-.13 0-.23-.11-.23-.23v-4.59c0-.98-.74-1.71-1.62-1.71-.8 0-1.46.7-1.59 1.62l.01 4.68c0 .13-.11.23-.23.23h-1.41c-.13 0-.23-.11-.23-.23v-4.59c0-.98-.74-1.71-1.62-1.71-.85 0-1.54.79-1.6 1.8v4.5c0 .13-.1.23-.23.23zm53.615 0h-1.61c-.04 0-.08-.01-.12-.03-.09-.06-.13-.19-.06-.28l2.43-3.71-2.39-3.65a.213.213 0 01-.03-.12c0-.12.09-.21.21-.21h1.61c.13 0 .24.06.3.17l1.41 2.37 1.4-2.37a.34.34 0 01.3-.17h1.6c.04 0 .08.01.12.03.09.06.13.19.06.28l-2.37 3.65 2.43 3.7c0 .05.01.09.01.13 0 .12-.09.21-.21.21h-1.61c-.13 0-.24-.06-.3-.17l-1.44-2.42-1.44 2.42a.34.34 0 01-.3.17zm-7.12-1.49c-1.33 0-2.42-1.12-2.42-2.51 0-1.39 1.08-2.52 2.42-2.52 1.33 0 2.42 1.12 2.42 2.51 0 1.39-1.08 2.51-2.42 2.52zm-19.865 0c-1.32 0-2.39-1.11-2.42-2.48v-.07c.02-1.38 1.09-2.49 2.4-2.49 1.32 0 2.41 1.12 2.41 2.51 0 1.39-1.07 2.52-2.39 2.53zm-8.11-2.48c-.01 1.37-1.09 2.47-2.41 2.47s-2.42-1.12-2.42-2.51c0-1.39 1.08-2.52 2.4-2.52 1.33 0 2.39 1.11 2.41 2.48l.02.08zm18.12 2.47c-1.32 0-2.39-1.11-2.41-2.48v-.06c.02-1.38 1.09-2.48 2.41-2.48s2.42 1.12 2.42 2.51c0 1.39-1.09 2.51-2.42 2.51z'/%3E%3C/defs%3E%3Cmask id='clip'%3E%3Crect x='0' y='0' width='100%25' height='100%25' fill='white'/%3E%3Cuse xlink:href='%23logo'/%3E%3Cuse xlink:href='%23text'/%3E%3C/mask%3E%3Cg id='outline' opacity='1' stroke='%23000' stroke-width='3'%3E%3Ccircle mask='url(%23clip)' cx='11.5' cy='11.5' r='9.25'/%3E%3Cuse xlink:href='%23text' mask='url(%23clip)'/%3E%3C/g%3E%3Cg id='fill' opacity='1' fill='%23fff'%3E%3Cuse xlink:href='%23logo'/%3E%3Cuse xlink:href='%23text'/%3E%3C/g%3E%3C/svg%3E\")}}@media (-ms-high-contrast:black-on-white){a.mapboxgl-ctrl-logo{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' fill-rule='evenodd' viewBox='0 0 88 23'%3E%3Cdefs%3E%3Cpath id='logo' d='M11.5 2.25c5.105 0 9.25 4.145 9.25 9.25s-4.145 9.25-9.25 9.25-9.25-4.145-9.25-9.25 4.145-9.25 9.25-9.25zM6.997 15.983c-.051-.338-.828-5.802 2.233-8.873a4.395 4.395 0 013.13-1.28c1.27 0 2.49.51 3.39 1.42.91.9 1.42 2.12 1.42 3.39 0 1.18-.449 2.301-1.28 3.13C12.72 16.93 7 16 7 16l-.003-.017zM15.3 10.5l-2 .8-.8 2-.8-2-2-.8 2-.8.8-2 .8 2 2 .8z'/%3E%3Cpath id='text' d='M50.63 8c.13 0 .23.1.23.23V9c.7-.76 1.7-1.18 2.73-1.18 2.17 0 3.95 1.85 3.95 4.17s-1.77 4.19-3.94 4.19c-1.04 0-2.03-.43-2.74-1.18v3.77c0 .13-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V8.23c0-.12.1-.23.23-.23h1.4zm-3.86.01c.01 0 .01 0 .01-.01.13 0 .22.1.22.22v7.55c0 .12-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V15c-.7.76-1.69 1.19-2.73 1.19-2.17 0-3.94-1.87-3.94-4.19 0-2.32 1.77-4.19 3.94-4.19 1.03 0 2.02.43 2.73 1.18v-.75c0-.12.1-.23.23-.23h1.4zm26.375-.19a4.24 4.24 0 00-4.16 3.29c-.13.59-.13 1.19 0 1.77a4.233 4.233 0 004.17 3.3c2.35 0 4.26-1.87 4.26-4.19 0-2.32-1.9-4.17-4.27-4.17zM60.63 5c.13 0 .23.1.23.23v3.76c.7-.76 1.7-1.18 2.73-1.18 1.88 0 3.45 1.4 3.84 3.28.13.59.13 1.2 0 1.8-.39 1.88-1.96 3.29-3.84 3.29-1.03 0-2.02-.43-2.73-1.18v.77c0 .12-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V5.23c0-.12.1-.23.23-.23h1.4zm-34 11h-1.4c-.13 0-.23-.11-.23-.23V8.22c.01-.13.1-.22.23-.22h1.4c.13 0 .22.11.23.22v.68c.5-.68 1.3-1.09 2.16-1.1h.03c1.09 0 2.09.6 2.6 1.55.45-.95 1.4-1.55 2.44-1.56 1.62 0 2.93 1.25 2.9 2.78l.03 5.2c0 .13-.1.23-.23.23h-1.41c-.13 0-.23-.11-.23-.23v-4.59c0-.98-.74-1.71-1.62-1.71-.8 0-1.46.7-1.59 1.62l.01 4.68c0 .13-.11.23-.23.23h-1.41c-.13 0-.23-.11-.23-.23v-4.59c0-.98-.74-1.71-1.62-1.71-.85 0-1.54.79-1.6 1.8v4.5c0 .13-.1.23-.23.23zm53.615 0h-1.61c-.04 0-.08-.01-.12-.03-.09-.06-.13-.19-.06-.28l2.43-3.71-2.39-3.65a.213.213 0 01-.03-.12c0-.12.09-.21.21-.21h1.61c.13 0 .24.06.3.17l1.41 2.37 1.4-2.37a.34.34 0 01.3-.17h1.6c.04 0 .08.01.12.03.09.06.13.19.06.28l-2.37 3.65 2.43 3.7c0 .05.01.09.01.13 0 .12-.09.21-.21.21h-1.61c-.13 0-.24-.06-.3-.17l-1.44-2.42-1.44 2.42a.34.34 0 01-.3.17zm-7.12-1.49c-1.33 0-2.42-1.12-2.42-2.51 0-1.39 1.08-2.52 2.42-2.52 1.33 0 2.42 1.12 2.42 2.51 0 1.39-1.08 2.51-2.42 2.52zm-19.865 0c-1.32 0-2.39-1.11-2.42-2.48v-.07c.02-1.38 1.09-2.49 2.4-2.49 1.32 0 2.41 1.12 2.41 2.51 0 1.39-1.07 2.52-2.39 2.53zm-8.11-2.48c-.01 1.37-1.09 2.47-2.41 2.47s-2.42-1.12-2.42-2.51c0-1.39 1.08-2.52 2.4-2.52 1.33 0 2.39 1.11 2.41 2.48l.02.08zm18.12 2.47c-1.32 0-2.39-1.11-2.41-2.48v-.06c.02-1.38 1.09-2.48 2.41-2.48s2.42 1.12 2.42 2.51c0 1.39-1.09 2.51-2.42 2.51z'/%3E%3C/defs%3E%3Cmask id='clip'%3E%3Crect x='0' y='0' width='100%25' height='100%25' fill='white'/%3E%3Cuse xlink:href='%23logo'/%3E%3Cuse xlink:href='%23text'/%3E%3C/mask%3E%3Cg id='outline' opacity='1' stroke='%23fff' stroke-width='3' fill='%23fff'%3E%3Ccircle mask='url(%23clip)' cx='11.5' cy='11.5' r='9.25'/%3E%3Cuse xlink:href='%23text' mask='url(%23clip)'/%3E%3C/g%3E%3Cg id='fill' opacity='1' fill='%23000'%3E%3Cuse xlink:href='%23logo'/%3E%3Cuse xlink:href='%23text'/%3E%3C/g%3E%3C/svg%3E\")}}.mapboxgl-ctrl.mapboxgl-ctrl-attrib{background-color:hsla(0,0%,100%,.5);margin:0;padding:0 5px}@media screen{.mapboxgl-ctrl-attrib.mapboxgl-compact{background-color:#fff;border-radius:12px;box-sizing:content-box;margin:10px;min-height:20px;padding:2px 24px 2px 0;position:relative}.mapboxgl-ctrl-attrib.mapboxgl-compact-show{padding:2px 28px 2px 8px;visibility:visible}.mapboxgl-ctrl-bottom-left>.mapboxgl-ctrl-attrib.mapboxgl-compact-show,.mapboxgl-ctrl-top-left>.mapboxgl-ctrl-attrib.mapboxgl-compact-show{border-radius:12px;padding:2px 8px 2px 28px}.mapboxgl-ctrl-attrib.mapboxgl-compact .mapboxgl-ctrl-attrib-inner{display:none}.mapboxgl-ctrl-attrib-button{background-color:hsla(0,0%,100%,.5);background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill-rule='evenodd'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E\");border:0;border-radius:12px;box-sizing:border-box;cursor:pointer;display:none;height:24px;outline:none;position:absolute;right:0;top:0;width:24px}.mapboxgl-ctrl-bottom-left .mapboxgl-ctrl-attrib-button,.mapboxgl-ctrl-top-left .mapboxgl-ctrl-attrib-button{left:0}.mapboxgl-ctrl-attrib.mapboxgl-compact .mapboxgl-ctrl-attrib-button,.mapboxgl-ctrl-attrib.mapboxgl-compact-show .mapboxgl-ctrl-attrib-inner{display:block}.mapboxgl-ctrl-attrib.mapboxgl-compact-show .mapboxgl-ctrl-attrib-button{background-color:rgb(0 0 0/5%)}.mapboxgl-ctrl-bottom-right>.mapboxgl-ctrl-attrib.mapboxgl-compact:after{bottom:0;right:0}.mapboxgl-ctrl-top-right>.mapboxgl-ctrl-attrib.mapboxgl-compact:after{right:0;top:0}.mapboxgl-ctrl-top-left>.mapboxgl-ctrl-attrib.mapboxgl-compact:after{left:0;top:0}.mapboxgl-ctrl-bottom-left>.mapboxgl-ctrl-attrib.mapboxgl-compact:after{bottom:0;left:0}}@media screen and (-ms-high-contrast:active){.mapboxgl-ctrl-attrib.mapboxgl-compact:after{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill-rule='evenodd' fill='%23fff'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E\")}}@media screen and (-ms-high-contrast:black-on-white){.mapboxgl-ctrl-attrib.mapboxgl-compact:after{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill-rule='evenodd'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E\")}}.mapboxgl-ctrl-attrib a{color:rgba(0,0,0,.75);text-decoration:none}.mapboxgl-ctrl-attrib a:hover{color:inherit;text-decoration:underline}.mapboxgl-ctrl-attrib .mapbox-improve-map{font-weight:700;margin-left:2px}.mapboxgl-attrib-empty{display:none}.mapboxgl-ctrl-scale{background-color:hsla(0,0%,100%,.75);border:2px solid #333;border-top:#333;box-sizing:border-box;color:#333;font-size:10px;padding:0 5px;white-space:nowrap}.mapboxgl-popup{display:flex;left:0;pointer-events:none;position:absolute;top:0;will-change:transform}.mapboxgl-popup-anchor-top,.mapboxgl-popup-anchor-top-left,.mapboxgl-popup-anchor-top-right{flex-direction:column}.mapboxgl-popup-anchor-bottom,.mapboxgl-popup-anchor-bottom-left,.mapboxgl-popup-anchor-bottom-right{flex-direction:column-reverse}.mapboxgl-popup-anchor-left{flex-direction:row}.mapboxgl-popup-anchor-right{flex-direction:row-reverse}.mapboxgl-popup-tip{border:10px solid transparent;height:0;width:0;z-index:1}.mapboxgl-popup-anchor-top .mapboxgl-popup-tip{align-self:center;border-bottom-color:#fff;border-top:none}.mapboxgl-popup-anchor-top-left .mapboxgl-popup-tip{align-self:flex-start;border-bottom-color:#fff;border-left:none;border-top:none}.mapboxgl-popup-anchor-top-right .mapboxgl-popup-tip{align-self:flex-end;border-bottom-color:#fff;border-right:none;border-top:none}.mapboxgl-popup-anchor-bottom .mapboxgl-popup-tip{align-self:center;border-bottom:none;border-top-color:#fff}.mapboxgl-popup-anchor-bottom-left .mapboxgl-popup-tip{align-self:flex-start;border-bottom:none;border-left:none;border-top-color:#fff}.mapboxgl-popup-anchor-bottom-right .mapboxgl-popup-tip{align-self:flex-end;border-bottom:none;border-right:none;border-top-color:#fff}.mapboxgl-popup-anchor-left .mapboxgl-popup-tip{align-self:center;border-left:none;border-right-color:#fff}.mapboxgl-popup-anchor-right .mapboxgl-popup-tip{align-self:center;border-left-color:#fff;border-right:none}.mapboxgl-popup-close-button{background-color:transparent;border:0;border-radius:0 3px 0 0;cursor:pointer;position:absolute;right:0;top:0}.mapboxgl-popup-close-button:hover{background-color:rgb(0 0 0/5%)}.mapboxgl-popup-content{background:#fff;border-radius:3px;box-shadow:0 1px 2px rgba(0,0,0,.1);padding:10px 10px 15px;pointer-events:auto;position:relative}.mapboxgl-popup-anchor-top-left .mapboxgl-popup-content{border-top-left-radius:0}.mapboxgl-popup-anchor-top-right .mapboxgl-popup-content{border-top-right-radius:0}.mapboxgl-popup-anchor-bottom-left .mapboxgl-popup-content{border-bottom-left-radius:0}.mapboxgl-popup-anchor-bottom-right .mapboxgl-popup-content{border-bottom-right-radius:0}.mapboxgl-popup-track-pointer{display:none}.mapboxgl-popup-track-pointer *{pointer-events:none;user-select:none}.mapboxgl-map:hover .mapboxgl-popup-track-pointer{display:flex}.mapboxgl-map:active .mapboxgl-popup-track-pointer{display:none}.mapboxgl-marker{left:0;opacity:1;position:absolute;top:0;transition:opacity .2s;will-change:transform}.mapboxgl-user-location-dot,.mapboxgl-user-location-dot:before{background-color:#1da1f2;border-radius:50%;height:15px;width:15px}.mapboxgl-user-location-dot:before{animation:mapboxgl-user-location-dot-pulse 2s infinite;content:\"\";position:absolute}.mapboxgl-user-location-dot:after{border:2px solid #fff;border-radius:50%;box-shadow:0 0 3px rgba(0,0,0,.35);box-sizing:border-box;content:\"\";height:19px;left:-2px;position:absolute;top:-2px;width:19px}.mapboxgl-user-location-show-heading .mapboxgl-user-location-heading{height:0;width:0}.mapboxgl-user-location-show-heading .mapboxgl-user-location-heading:after,.mapboxgl-user-location-show-heading .mapboxgl-user-location-heading:before{border-bottom:7.5px solid #4aa1eb;content:\"\";position:absolute}.mapboxgl-user-location-show-heading .mapboxgl-user-location-heading:before{border-left:7.5px solid transparent;transform:translateY(-28px) skewY(-20deg)}.mapboxgl-user-location-show-heading .mapboxgl-user-location-heading:after{border-right:7.5px solid transparent;transform:translate(7.5px,-28px) skewY(20deg)}@keyframes mapboxgl-user-location-dot-pulse{0%{opacity:1;transform:scale(1)}70%{opacity:0;transform:scale(3)}to{opacity:0;transform:scale(1)}}.mapboxgl-user-location-dot-stale{background-color:#aaa}.mapboxgl-user-location-dot-stale:after{display:none}.mapboxgl-user-location-accuracy-circle{background-color:#1da1f233;border-radius:100%;height:1px;width:1px}.mapboxgl-crosshair,.mapboxgl-crosshair .mapboxgl-interactive,.mapboxgl-crosshair .mapboxgl-interactive:active{cursor:crosshair}.mapboxgl-boxzoom{background:#fff;border:2px dotted #202020;height:0;left:0;opacity:.5;position:absolute;top:0;width:0}@media print{.mapbox-improve-map{display:none}}.mapboxgl-scroll-zoom-blocker,.mapboxgl-touch-pan-blocker{align-items:center;background:rgba(0,0,0,.7);color:#fff;display:flex;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif;height:100%;justify-content:center;left:0;opacity:0;pointer-events:none;position:absolute;text-align:center;top:0;transition:opacity .75s ease-in-out;transition-delay:1s;width:100%}.mapboxgl-scroll-zoom-blocker-show,.mapboxgl-touch-pan-blocker-show{opacity:1;transition:opacity .1s ease-in-out}.mapboxgl-canvas-container.mapboxgl-touch-pan-blocker-override.mapboxgl-scrollable-page,.mapboxgl-canvas-container.mapboxgl-touch-pan-blocker-override.mapboxgl-scrollable-page .mapboxgl-canvas{touch-action:pan-x pan-y}");const wa=e=>e?.split(",")?.[0],Ca=e=>{let{tagIndex:t,isochronesTags:r=!1,filters:i,county:n,isochrones:o,resetCounty:a,updateTagIndex:c}=e;const h=u((e=>e.breakpoints.down("md"))),d=ue((()=>r?function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=ds(e,"destination"),r=ds(e,"destinationTwo"),i=wa(t?.destination),n=wa(r?.destination),o=hs(+(e?.time||10)),s=hs(+(e?.timeTwo||10));return{"1_cycling_destination":{id:"1_cycling_destination",icon:"cycling",name:`${o} from ${i}`},"1_driving_destination":{id:"1_driving_destination",icon:"driving",name:`${o} from ${i}`},"1_public_transport_destination":{id:"1_public_transport_destination",icon:"public_transport",name:`${o} from ${i}`},"1_walking_destination":{id:"1_walking_destination",icon:"walking",name:`${o} from ${i}`},"2_cycling_destinationTwo":{id:"2_cycling_destinationTwo",icon:"cycling",name:`${s} from ${n}`},"2_driving_destinationTwo":{id:"2_driving_destinationTwo",icon:"driving",name:`${s} from ${n}`},"2_public_transport_destinationTwo":{id:"2_public_transport_destinationTwo",icon:"public_transport",name:`${s} from ${n}`},"2_walking_destinationTwo":{id:"2_walking_destinationTwo",icon:"walking",name:`${s} from ${n}`},"1_aggregated":{isMultiple:!0,id:"1_aggregated",icons:Os.isString(e?.methods)?e?.methods?.length>0?[e?.methods]:[]:e?.methods,name:`${o} from ${i}`},"2_aggregated":{isMultiple:!0,id:"2_aggregated",icons:Os.isString(e?.methodsTwo)?e?.methodsTwo?.length>0?[e?.methodsTwo]:[]:e?.methodsTwo,name:`${s} from ${n}`},"1_public_transport":{id:"1_public_transport",icon:"public_transport",name:`${o} from ${i}`},"2_public_transport":{id:"2_public_transport",icon:"public_transport",name:`${s} from ${n}`},"1_driving":{id:"1_driving",icon:"driving",name:`${o} from ${i}`},"2_driving":{id:"2_driving",icon:"driving",name:`${s} from ${n}`},"1_cycling":{id:"1_cycling",icon:"cycling",name:`${o} from ${i}`},"2_cycling":{id:"2_cycling",icon:"cycling",name:`${s} from ${n}`},"1_walking":{id:"1_walking",icon:"walking",name:`${o} from ${i}`},"2_walking":{id:"2_walking",icon:"walking",name:`${s} from ${n}`}}}(i):function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=`${us(e?.commutes?.[0]?.time,!0)} from ${e?.commutes?.[0]?.location?.name}`,r=`${us(e?.commutes?.[1]?.time,!0)} from ${e?.commutes?.[1]?.location?.name}`;return{"1_aggregated":{id:"1_aggregated",icons:e?.commutes?.[0]?.methods,name:t},"2_aggregated":{id:"2_aggregated",icons:e?.commutes?.[1]?.methods,name:r}}}(i)),[i]),p=ue((()=>o?.map((e=>e?.properties?.search_id||e?.properties?.name))?.filter(Boolean)),[o]),f=ue((()=>n?.properties?.search_id||n?.properties?.name),[n]),m=e=>()=>{c(e),a()};return oe((()=>{const e=document.querySelectorAll(".map-tag");if(h&&e?.length)if(t)setTimeout((()=>{e[t].scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})}),100);else{const t=n?.layer?.id?n.layer.id.split("-"):void 0,r=t?.[t?.length-1];r&&setTimeout((()=>{e[+r].scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})}),100)}}),[t,n,h]),s(g,{direction:"row",gap:.75,pr:6,flexWrap:["nowrap","nowrap","wrap"],sx:e=>({[e.breakpoints.down("md")]:{overflowX:"scroll",backgroundColor:"white",borderRadius:"10px",boxShadow:"0px 2px 8px 0px rgba(40, 35, 68, 0.15)",padding:"6px",msOverflowStyle:"none",scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}}}),children:r?p?.map(((e,r)=>{const i=fs[d?.[e]?.icon]||s(l,{}),n=d?.[e]?.isMultiple;return s(Lo,{className:"map-tag",onMouseEnter:m(r),onMouseLeave:()=>c(null),label:d?.[e]?.name,TypographyProps:{fontWeight:400,sx:f===d?.[e]?.id||t===r?{color:"white"}:{}},sx:i=>({transition:i.transitions.create("backgroundColor"),height:24,backgroundColor:f===d?.[e]?.id||t===r?i.palette.primary.main:h?"#DCE1E8":"white"}),icon:n?s(g,{direction:"row",gap:.25,children:d?.[e]?.icons?.map((t=>{const r=fs?.[t]||s(l,{});return s(r,{sx:{fontSize:18}},`${e}-${t}`)}))}):s(i,{sx:{fontSize:18}})},e)})):p?.map(((e,r)=>s(Lo,{className:"map-tag",onMouseEnter:m(r),onMouseLeave:()=>c(null),fontSize:14,label:d?.[e]?.name,sx:i=>({transition:i.transitions.create("backgroundColor"),height:30,borderRadius:"10px !important",backgroundColor:f===d?.[e]?.id||t===r?i.palette.secondary.main:"#E5EFF0",color:f===d?.[e]?.id||t===r?"white !important":i.palette.success.main}),icon:s(g,{gap:.5,direction:"row",alignItems:"center",children:ms.map((t=>{let{id:r,icon:i}=t;return d?.[e]?.icons?.includes(r)&&s(_,{width:20,height:20,bgcolor:"white",borderRadius:50,display:"flex",alignItems:"center",justifyContent:"center",children:s(i,{sx:{width:16,height:16}})},r)}))})},e)))})};function Ta(e,t,r){if(null!==e)for(var i,n,o,s,a,l,c,u,h=0,d=0,p=e.type,f="FeatureCollection"===p,m="Feature"===p,A=f?e.features.length:1,g=0;g<A;g++){a=(u=!!(c=f?e.features[g].geometry:m?e.geometry:e)&&"GeometryCollection"===c.type)?c.geometries.length:1;for(var _=0;_<a;_++){var y=0,x=0;if(null!==(s=u?c.geometries[_]:c)){l=s.coordinates;var v=s.type;switch(h=0,v){case null:break;case"Point":if(!1===t(l,d,g,y,x))return!1;d++,y++;break;case"LineString":case"MultiPoint":for(i=0;i<l.length;i++){if(!1===t(l[i],d,g,y,x))return!1;d++,"MultiPoint"===v&&y++}"LineString"===v&&y++;break;case"Polygon":case"MultiLineString":for(i=0;i<l.length;i++){for(n=0;n<l[i].length-h;n++){if(!1===t(l[i][n],d,g,y,x))return!1;d++}"MultiLineString"===v&&y++,"Polygon"===v&&x++}"Polygon"===v&&y++;break;case"MultiPolygon":for(i=0;i<l.length;i++){for(x=0,n=0;n<l[i].length;n++){for(o=0;o<l[i][n].length-h;o++){if(!1===t(l[i][n][o],d,g,y,x))return!1;d++}x++}y++}break;case"GeometryCollection":for(i=0;i<s.geometries.length;i++)if(!1===Ta(s.geometries[i],t))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function Ea(e){var t=[1/0,1/0,-1/0,-1/0];return Ta(e,(function(e){t[0]>e[0]&&(t[0]=e[0]),t[1]>e[1]&&(t[1]=e[1]),t[2]<e[0]&&(t[2]=e[0]),t[3]<e[1]&&(t[3]=e[1])})),t}Ea.default=Ea;const Ma=e=>{let{polygonStyles:t,tagIndex:r,county:i,isochrones:n}=e;const o=c(),u=ue((()=>({styles:{"fill-outline-color":o.palette.secondary.main,"fill-color":Je(o.palette.secondary.main,.2)},lineStyles:{"line-width":3,"line-color":o.palette.secondary.main},hoverStyles:{"fill-outline-color":o.palette.secondary.main,"fill-color":Je(o.palette.secondary.main,.35)}})),[n]),h=t||u;return a(l,{children:[n?.map(((e,t)=>s(ba,{id:`polygon-${t}`,type:"geojson",data:e,children:s(va,{id:`polygon-${t}`,type:"fill",source:`polygon-${t}`,paint:i?.layer?.id===`polygon-${t}`||i?.layer?.id===`polygon-line-${t}`||r===t?h.hoverStyles:h.styles})},`polygon-${t}`))),n?.map(((e,t)=>s(ba,{id:`polygon-line-${t}`,type:"geojson",data:e,children:s(va,{id:`polygon-line-${t}`,type:"line",source:`polygon-line-${t}`,paint:h.lineStyles})},`polygon-line-${t}`)))]})},Sa=b(ya)((e=>{let{theme:t}=e;return{zIndex:2,filter:"drop-shadow(0px 2px 8px rgba(40, 35, 68, 0.15))",[t.breakpoints.down("sm")]:{maxWidth:"220px !important"},".mapboxgl-popup-content":{overflow:"hidden",padding:0,borderRadius:"15px",boxShadow:"none",background:"#2e3841"},"&.mapboxgl-popup-anchor-bottom-right .mapboxgl-popup-content":{borderBottomRightRadius:"0 !important"},"&.mapboxgl-popup-anchor-bottom-left .mapboxgl-popup-content":{borderBottomLeftRadius:"0 !important"},"&.mapboxgl-popup-anchor-top-right .mapboxgl-popup-content":{borderTopRightRadius:"0 !important"},"&.mapboxgl-popup-anchor-top-left .mapboxgl-popup-content":{borderTopLeftRadius:"0 !important"},"&.mapboxgl-popup-anchor-right .mapboxgl-popup-tip":{borderLeftColor:"#2e3841 !important"},"&.mapboxgl-popup-anchor-left .mapboxgl-popup-tip":{borderRightColor:"#2e3841 !important"},"&.mapboxgl-popup-anchor-top-right .mapboxgl-popup-tip, &.mapboxgl-popup-anchor-top .mapboxgl-popup-tip, &.mapboxgl-popup-anchor-top-left .mapboxgl-popup-tip":{borderBottomColor:"#2e3841 !important"},"&.mapboxgl-popup-anchor-bottom .mapboxgl-popup-tip, &.mapboxgl-popup-anchor-bottom-right .mapboxgl-popup-tip, &.mapboxgl-popup-anchor-bottom-left .mapboxgl-popup-tip":{borderTopColor:"#2e3841 !important"}}})),Ia=e=>{let{styles:t,center:r,addLoader:i=!1,isochronesTags:n=!1,disableCluster:o=!1,disableBounds:c=!1,disablePolygonHover:h=!1,disableTags:d=!0,disableNavigationControl:p=!1,disablePopup:f=!0,disablePinsFeatures:m=!1,height:A="100%",tagIndex:g,polygonStyles:y,mapboxAccessToken:x,propertyPinComponent:v=Bt,commutePinComponent:b=Ot,loading:w,showDrawer:C=!1,filters:T,pins:E,popup:M,commutePins:S=[],isochrones:I,updateTagIndex:P,onPinSelect:D,generatePin:k,onUpdatePolygon:L,onDeletePolygon:z}=e;const O=ae(null),j=ae(null),V=u((e=>e.breakpoints.down("md"))),N=ae(null),U=ae(null),[H,G]=ne(null),[Z,W]=ne({}),[Q,q]=ne(!1),X=()=>D?.(void 0),Y=B((e=>{e&&"commute"===e?.type||(N.current&&window.clearTimeout(N.current),N.current=window.setTimeout((()=>D?.(e)),300))})),$=B((()=>{U.current&&window.clearTimeout(U.current),U.current=window.setTimeout(X,300)})),K=ue((()=>m?[]:E.map((e=>({type:"Feature",geometry:{type:"Point",coordinates:[e.longitude,e.latitude]},properties:{id:e.id,icon:"pin-pink",url:e.listing_url}})))),[E]),J=ue((()=>({type:"FeatureCollection",features:K})),[K]),ee=ue((()=>S?.map((e=>{const t=!f&&!e?.disablePopup;return s(_,{component:_a,longitude:e.lng||e.longitude,latitude:e.lat||e.latitude,anchor:"bottom",children:s(_,{display:"flex",sx:{cursor:"pointer"},onClick:V&&t?t=>{t.preventDefault(),t.stopPropagation(),D?.(e)}:void 0,onMouseEnter:!V&&t?()=>Y(e):void 0,onMouseLeave:!V&&t?$:void 0,children:k?k(e):s(b,{sx:{width:30,height:36}})})},`${e?.id||e?.urn}${e?.smartscore||0}`)}))),[S]),te=ue((()=>{if(!c&&E.length)return E.reduce(((e,t)=>e.extend([t.longitude,t.latitude])),new Rs.LngLatBounds([E[0].longitude,E[0].latitude],[E[0].longitude,E[0].latitude]));if(!I?.length&&!E.length){const e=process.env.NEXT_PUBLIC_MAP_DEFAULT_BOUNDS?.split(",");if(4===e?.length&&e.every((e=>!isNaN(Number(e)))))return new Rs.LngLatBounds([Number(e[0]),Number(e[1])],[Number(e[2]),Number(e[3])])}}),[E,c]),re=ce((e=>{const t=O?.current?.queryRenderedFeatures?.(e?.point),r=t?.filter((e=>e?.source?.includes("polygon"))),i=r?.[r?.length-1];!o&&O.current&&(O.current.getMap().getCanvas().style.cursor=r?.length?"pointer":"auto"),P(null),h||H&&Os.isEqual(i,H)?ie():G(i??null)}),[H]),ie=()=>{G(null)},se=ce((e=>{W((t=>({...t,...e})))}),[]),le=e=>{let{viewState:t}=e;W({...t,bearing:0,pitch:0})};return oe((()=>{if(o||!O.current)return;const e=O.current.getMap();if(e.hasImage("pin-pink"))return;const t=new Image(30,36);t.onload=()=>{e.addImage("pin-pink",t)};s(v,{}).src=t.src}),[]),oe((()=>{const e=e=>{j.current&&!j?.current?.contains(e.target)&&ie()};return document.addEventListener("click",e,!0),document.addEventListener("visibilitychange",ie),()=>{document.removeEventListener("click",e,!0),document.removeEventListener("visibilitychange",ie)}}),[H]),oe((()=>{O.current&&te&&O.current.fitBounds(te,{padding:100,duration:1e3})}),[te]),oe((()=>{if(I?.length&&Q){const e=(e=>{if(!e?.length)return;const t=function(e,t){void 0===t&&(t={});var r={type:"FeatureCollection"};return t.id&&(r.id=t.id),t.bbox&&(r.bbox=t.bbox),r.features=e,r}(e),r=Ea(t),i=r[0],n=r[1],o=r[2],s=(n+r[3])/2,a=(i+o)/2;return{bounds:[[r?.[0],r?.[1]],[r?.[2],r?.[3]]],latitude:s,longitude:a}})(I);if(!O.current||!e)return;se({...Z,latitude:e?.latitude,longitude:e?.longitude}),O.current.fitBounds(e?.bounds,{padding:40,duration:1e3})}}),[I,Q]),oe((()=>{const e=()=>{le({viewState:Z}),X()};return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[]),a(_,{ref:j,position:"relative",width:"100%",height:A,onMouseLeave:ie,children:[i&&w&&s(_,{position:"absolute",sx:{top:0,left:0,right:0,zIndex:1},children:s(R,{})}),a(ga,{...Z,ref:O,minZoom:3,maxZoom:19,initialViewState:{bounds:te,...c?{zoom:9,latitude:r?.lat??E?.[0]?.latitude,longitude:r?.lng??E?.[0]?.longitude}:{},fitBoundsOptions:{padding:I?.length||E?.length?100:0}},style:{width:"100%",height:"100%"},mapboxAccessToken:x,mapStyle:t.streets,onMove:le,attributionControl:!1,onMouseMove:re,onLoad:()=>q(!0),onClick:e=>{if(re(),o)return;const t=O.current;if(!t)return;const r=e.features&&e.features[0];if("unclustered-point"===r?.layer.id){const e=r?.properties?.url;if(!e)return;window.open(e,"_blank")}if(!r)return;const i=r.properties?.cluster_id;if(!i)return;t.getSource("pins").getClusterExpansionZoom(i,((e,i)=>{if(e)return;const n="coordinates"in r.geometry?r.geometry.coordinates:void 0;n&&t.easeTo({center:n,zoom:i,duration:500})}))},...!o&&{interactiveLayerIds:["clusters","unclustered-point","commute-pin"]},children:[C&&s(DrawControl,{mapRef:O,onCreate:L,onUpdate:L,onDelete:z}),!p&&s(xa,{position:V?"bottom-right":"top-right",showCompass:!1}),!w&&a(l,{children:[!d&&I?.length>0&&s(_,{position:"absolute",sx:{top:9,left:8,right:8,zIndex:1},children:s(Ca,{isochronesTags:n,tagIndex:g,updateTagIndex:P,filters:T,isochrones:I,county:H,resetCounty:ie})}),s(Ma,{polygonStyles:y,tagIndex:g,isochrones:I,county:H}),(S??[])?.length>0&&ee,!o&&J?.features?.length>0&&a(ba,{id:"pins",type:"geojson",data:J,cluster:!0,clusterMaxZoom:14,clusterRadius:40,children:[s(va,{id:"clusters",source:"pins",type:"circle",filter:["has","point_count"],paint:{"circle-color":["step",["get","point_count"],"#fff",100,"#fff",750,"#fff"],"circle-radius":["step",["get","point_count"],20,100,30,750,40]}}),s(va,{id:"cluster-count",type:"symbol",source:"pins",filter:["has","point_count"],layout:{"text-field":["get","point_count_abbreviated"],"text-font":["DIN Offc Pro Medium","Arial Unicode MS Bold"],"text-size":12,"text-color":"#414141"}}),s(va,{id:"unclustered-point",source:"pins",type:"symbol",filter:["!",["has","point_count"]],layout:{"icon-image":"pin-pink","icon-anchor":"bottom"}})]})]}),!f&&M&&s(Sa,{maxWidth:"none",className:"smartscorePopup",longitude:M.longitude,latitude:M.latitude,closeButton:!1,offset:{right:[-15,-15],left:[15,-15],bottom:[0,-30],"bottom-right":[0,-40],"bottom-left":[0,-40]},children:s(F,{onClickAway:()=>M.onClose?.(),children:s("div",{onMouseEnter:V?void 0:()=>{N.current&&window.clearInterval(N.current),U.current&&window.clearInterval(U.current)},onMouseLeave:V?void 0:X,children:M.content})})})]})]})},Pa=r((e=>{let{className:t,...r}=e;return s(z,{...r,arrow:!0,classes:{popper:t}})}))((e=>{let{theme:t,maxWidth:r,placement:i}=e;return{[`& .${j.arrow}`]:{color:"#2E3841",[t.breakpoints.down("md")]:"bottom"===i?{marginLeft:t.spacing(-1.25)+" !important"}:{}},[`& .${j.tooltip}`]:{padding:t.spacing(1.5,2),backgroundColor:"#2E3841",borderRadius:"15px",...{maxWidth:r}||{},[t.breakpoints.down("md")]:"bottom"===i||"top"===i?{marginLeft:t.spacing(5.5)+" !important"}:{},[t.breakpoints.down("sm")]:"bottom"===i||"top"===i?{marginLeft:t.spacing(3)+" !important"}:{},"@media (max-width: 320px)":{maxWidth:270}}}})),Da=e=>{let{disableTooltip:t=!1,placement:r="right",open:i=!1,maxWidth:n=292,title:o,children:a,closeTooltip:l,sx:c={},boxSx:u={},...h}=e;const[d,p]=ne(i),f=()=>{p(!1),l?.()},m=e=>{e.preventDefault(),e.stopPropagation(),p(!0)};return oe((()=>{t||(i?(p(!0),setTimeout((()=>{p(!1),l?.()}),3500)):p(!1))}),[i]),t?a:s(Pa,{open:d,title:o,leaveTouchDelay:4e3,enterTouchDelay:50,placement:r,onClose:f,onOpen:m,maxWidth:n,sx:c,...h,children:s(_,{component:"span",sx:[...Array.isArray(u)?u:[u]],onClick:m,children:s(F,{disableReactTree:!0,onClickAway:f,children:a})})})},ka=e=>{let{sx:t={},children:r}=e;return s(v,{component:_,variant:"h6",sx:t,children:r})},La=e=>{let{error:t}=e;return t?s(v,{align:"center",color:"error",fontSize:12,lineHeight:"15.6px",sx:{pt:.5},children:t}):null},za=b(V)((e=>{let{multiline:t}=e;return{fontFamily:"Poppins","& input::-webkit-inner-spin-button":{WebkitAppearance:"none",margin:0},'& input[type="number"]':{MozAppearance:"textfield"},".MuiOutlinedInput-root":{fontFamily:"Poppins",borderRadius:t?"20px":"100px","input::-webkit-outer-spin-button, input::-webkit-inner-spin-button":{WebkitAppearance:"none",margin:0},'input[type="number"]':{MozAppearance:"textfield"}},".MuiFormHelperText-root":{textAlign:"center"}}})),Oa=me(((e,t)=>{let{minWidth:r,isClearable:n=!1,disabled:o=!1,fullWidth:l=!0,showTooltip:c=!1,openTooltip:h=!1,closeTooltip:d,tooltipTitle:p,type:f="text",label:m=null,helperText:A,error:y,name:x="",defaultValue:b,onChange:w,InputProps:C={},wrapperSx:T={},...E}=e;const S=i(),I=u(S.breakpoints.down("sm")),P=u(S.breakpoints.between("sm","md")),[D,k]=ne(b),L=ae(!1);return oe((()=>{b&&!D&&k(`${b}`)}),[b]),a(g,{gap:.5,flex:1,sx:T,children:[m&&s(Da,{disableTooltip:!c&&!p,open:h,closeTooltip:d,placement:P?"bottom":I?"top":"right",maxWidth:P?498:I?310:292,title:s(ka,{children:p}),children:a(_,{display:"inline-flex",alignItems:"center",mb:1.25,children:[s(v,{variant:"h5",sx:{mr:1},children:m}),c&&!!p&&s(Ve,{color:"disabled",sx:{fontSize:19,mb:-.25}})]})}),s(za,{value:D,fullWidth:l,disabled:o,error:y,type:f,name:x,onChange:e=>{L.current=!0;let t=e.target.value;"number"===f&&t.length>1&&t.startsWith("0")&&(t=t.slice(1)),k(t),w?.(e)},InputProps:{...C,...!C.endAdornment&&n&&!!D&&{endAdornment:s(N,{position:"end",children:s(M,{size:"small",color:y?"error":"default",onClick:()=>{k(void 0),w?.({event:{target:{value:void 0}}})},children:s(je,{})})})},sx:{py:E?.multiline?1:.25,"&.MuiOutlinedInput-root":{fontFamily:"CircularStd, sans-serif !important"},"&.MuiInput-root:before":{borderBottomStyle:"solid",borderBottomColor:S.palette.text.primary},...C?.sx||{}}},sx:{minWidth:r,...E.sx},InputLabelProps:{sx:{"&.MuiInputLabel-root":{color:S.palette.text.primary},"&.Mui-focused":{color:S.palette.primary.main}}},...E,ref:t}),A&&s(La,{error:A})]})}));function Ba(e){let{name:t,label:r,disabled:i=!1,showTooltip:n=!1,openTooltip:o=!1,tooltipTitle:l,closeTooltip:c,width:u=300,placeholder:h="Please select",value:d,inputValue:p,onChange:f,toggleError:m,onNeedFetch:A,...g}=e;const _=ae(!1),[y,x]=ne(!1),[v,b]=ne(null),[w,C]=ne([]),[T,M]=ne(null),[S,I]=ne(""),[P,D]=ne(!1),[k,L]=ne(""),z=y&&!P,O=e=>{let{search:t="",loadedOptions:r=[]}=e;A({search:t,loadedOptions:r}).then((e=>{let{options:t}=e;C(t),D(!0)}))},B=ce(Os.debounce((e=>{let{search:t,loadedOptions:r}=e;O({search:t,loadedOptions:r})}),600),[]);return oe((()=>{z&&O({search:"",loadedOptions:[]})}),[z]),oe((()=>{"clear"===k&&D(!1),v||"selectOption"!==k||f&&f(T)}),[v,k,T]),oe((()=>{y||(C([]),D(!1))}),[y]),oe((()=>{d&&!T&&(M(d),I(p||""))}),[d,p]),oe((()=>{_.current&&(S&&T||(b("Please select a city from the list"),m&&m(!0)),S&&T&&(b(null),m&&m(!1)))}),[_.current,T,S]),s(U,{openOnFocus:!0,open:y,disabled:i,onOpen:()=>x(!0),onClose:()=>x(!1),isOptionEqualToValue:(e,t)=>Os.isEqual(e,t),onInputChange:(e,t,r)=>{e&&(L("input"!==r?Os.isString(r)?r:"selectOption":""),"change"===e.type&&B({search:t}),I(t),_.current=!0)},onChange:(e,t,r)=>{L(r),M(t)},value:T,options:w,loading:z,inputValue:S,componentsProps:{paper:{sx:{borderRadius:"20px"}}},sx:{width:["100%",u,u],"&.MuiAutocomplete-root .MuiFormControl-root .MuiInputBase-root":{height:50,fontSize:"16px !important",fontFamily:"CircularStd, sans-serif",flexWrap:"nowrap",overflow:"hidden"}},renderInput:e=>s(Oa,{...e,name:t,value:d||T||null,label:r,tooltipTitle:l,showTooltip:n,openTooltip:o,closeTooltip:c,error:!!v,helperText:v||null,placeholder:h,InputProps:{...e.InputProps,endAdornment:a(de,{children:[z?s(E,{color:"inherit",size:20}):null,e.InputProps.endAdornment]})}}),...g})}const Ra=e=>{let{sliderLabels:t,blocks:r,children:i}=e;return a(g,{pt:[1,2],gap:[0,.25],children:[s(H,{container:!0,alignItems:"center",sx:{width:"100%",overflow:"visible"},wrap:"nowrap",spacing:0,children:r.map((e=>s(H,{item:!0,sx:{flex:`${e.width} 1 auto`,mx:.1},children:s(_,{sx:{background:e.background,height:11,width:"100%"}})},e.background)))}),a(H,{container:!0,alignItems:"center",sx:{width:"100%",overflow:"visible",color:"#949FA5"},wrap:"nowrap",spacing:0,children:[r.map(((e,t)=>s(H,{item:!0,component:_,alignItems:"center",justifyContent:"center",mr:t>0?1:0,sx:{width:`${e.width}%`},children:s(v,{variant:"body2",color:"inherit",children:e.text})},t))),s(H,{item:!0,sx:{width:"1%",pr:2},children:s(v,{variant:"body2",color:"inherit",children:"0%"})})]}),s(H,{container:!0,spacing:0,flexWrap:"nowrap",justifyContent:"space-between",sx:{color:"#949FA5"},children:t.map(((e,t)=>s(H,{item:!0,sm:6,xs:3,children:s(v,{align:t>0?"right":"left",variant:"body2",color:"inherit",children:e})},e)))}),i&&s(H,{container:!0,spacing:0,sx:{color:"#949FA5",mt:1.5},children:s(H,{item:!0,xs:12,children:s(v,{component:_,align:"left",variant:"subtitle2",color:"inherit",children:i})})})]})},Fa=e=>{let{disableSlider:t=!1,sliderLabels:r,header:i,blocks:n,open:o,toggleOpen:l,children:c}=e;return a(_,{position:"absolute",sx:{py:1,px:1.75,top:0,left:0,...o&&{width:["100%",456],maxWidth:"100%","@media (max-width: 320px)":{height:"168px !important"}}},children:[s(_,{position:"absolute",sx:{py:1,px:1.75,top:0,left:0,display:o?"flex":"none",flexDirection:"column",justifyContent:"space-between",width:"100%",maxWidth:"100%"},children:s(G,{in:o,style:{transformOrigin:"0 0 0"},...o?{timeout:300}:{},children:a(_,{sx:{background:"white",py:[1,1.5],px:1.15,boxShadow:"0px 3px 20px 0px rgba(82, 78, 183, 0.08)",zIndex:2,width:"100%",borderRadius:"10px",overflow:"hidden"},children:[a(g,{direction:"row",alignItems:"flex-start",gap:1,position:"relative",children:[s(v,{variant:"subtitle2",sx:{maxWidth:"95%",color:"#2E3841"},children:i}),s(M,{sx:{position:"absolute",right:-8,top:[-8,-12]},onClick:()=>{l(!1)},children:s(Le,{sx:{fontSize:20}})})]}),t?c:s(Ra,{sliderLabels:r,blocks:n,children:c})]})})}),s(Z,{size:"medium",sx:{background:"white",zIndex:1},onClick:()=>{l(!0)},children:s(Ne,{})})]})},ja=e=>{let{children:t,item:r,centered:i,sx:n={}}=e;const o=c();return s(W,{sx:{display:"flex",alignItems:"center",justifyContent:i?"center":"flex-start",width:r?.minWidth??120,flexGrow:r?.growCoefficient??0,flexBasis:r?.minWidth??120,flexShrink:0,fontSize:16,[o.breakpoints.down("sm")]:{fontSize:14},...n},children:t})};function Va(e){let{rowHeight:t=44,getUniqueId:r,align:i="left",minWidth:n=295,columns:o=[],data:l=[]}=e;const h=c(),d=u(h.breakpoints.down("sm"));return s(Q,{component:q,variant:"outlined",sx:{borderRadius:"15px"},children:a(X,{sx:{minWidth:n},children:[s(Y,{sx:{background:"#E9EEF0"},children:s($,{sx:{height:d?(t??0)+10:t,display:"flex"},children:o.map(((e,t)=>s(ja,{align:i,item:e,children:s(v,{fontSize:[16,18,18],fontWeight:500,"aria-label":`${e?.title}`,children:e?.title})},e?.name+t)))})}),s(K,{children:l.map(((e,n)=>s($,{sx:{height:t,minHeight:40,display:"flex","&:last-child td, &:last-child th":{border:0}},children:o?.map(((t,r)=>{let{name:o,getValue:a,minWidth:l,growCoefficient:c,sx:u={}}=t;const d=a({...e,index:n});return s(ja,{align:i,item:{minWidth:l,growCoefficient:c},children:s(v,{noWrap:!0,"aria-label":`${d}`,sx:{color:d?h.palette.text.primary:h.palette.text.disabled,...u},children:d||"-"})},`${o||r}-${n}`)}))},r?r(e,n):n)))})]})})}const Na=e=>{let{pathname:t,children:r,theme:i}=e;return s(n,{injectFirst:!0,children:a(o,{theme:i,children:[s(J,{}),s(Ss,{pathname:t,children:s(Cs,{children:r})})]})})};export{Ft as AmenityButton,Fo as AmenityTags,xs as AreasForm,Ba as AsyncAutocomplete,jt as BaseLayout,Ct as BeachesIcon,St as BedIcon,$o as BedroomsForm,kt as BikeIcon,ts as BudgetForm,Tt as BusIcon,Dt as BusTagIcon,pt as Button,ms as COMMUTE_METHODS,Lt as CarIcon,yr as CardImage,_s as CommuteForm,Ot as CommuteIcon,ps as CommuteMethod,yt as CopyButton,Do as EmptyDefaultImage,Cs as ErrorBoundary,Rt as FilterButton,Pt as FiltersIcon,bs as FiltersModal,vs as FooterButtons,Mt as GymIcon,La as HelperText,wr as LazyLoadImage,as as LifestyleForm,Qo as ListHeader,ws as Loader,Ca as MapTags,Ia as MapWrapper,Es as ModalBase,ks as ModalContainer,Ds as ModalFooter,Ps as ModalHeader,Ms as ModalsContext,Ss as ModalsProvider,Nt as Onboarding,Ut as OnboardingStepLayout,vt as ParksIcon,Bt as PinIcon,Ma as Polygon,Fa as Popover,Vt as Powered,Xo as PropertiesList,Ho as PropertyCard,zo as PropertyTag,os as PropertyTypeForm,is as RentBuyForm,bt as RestaurantsIcon,wt as SchoolsIcon,It as SearchsmartlyLogo,Et as ShopIcon,ko as SlickCarousel,Ra as SliderChart,Ls as Snackbar,xt as StarIcon,Va as Table,Lo as Tag,Oa as TextField,Na as ThemeProvider,Da as Tooltip,ka as TooltipTitle,Ts as Transition,zt as WalkIcon,Oo as amenityTagConfig,No as currencyFormatterProperty,es as formatPrice,Ro as getAmenityTags,Vo as getBedroomsText,ds as getDestination,us as getFormattedTime,fs as iconsMap,hs as minuteFormatter,Go as pluralize,jo as renderPlural,Wo as scrollIntoView,Bo as thresholds,Zo as titleCase,At as useClipboardFallback,mt as useModal,Is as useModalProvider,_t as usePrevious,ft as useResponsive,gt as useWindowSize};
43
+ class Cy{constructor(e=0,t=0,r=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=e,this.resetTtl=r,this.size=0,this.ttl=t}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(e){if(this.has(e)){const t=this.items[e];delete this.items[e],this.size--,null!==t.prev&&(t.prev.next=t.next),null!==t.next&&(t.next.prev=t.prev),this.first===t&&(this.first=t.next),this.last===t&&(this.last=t.prev)}return this}entries(e=this.keys()){return e.map((e=>[e,this.get(e)]))}evict(e=!1){if(e||this.size>0){const e=this.first;delete this.items[e.key],0==--this.size?(this.first=null,this.last=null):(this.first=e.next,this.first.prev=null)}return this}expiresAt(e){let t;return this.has(e)&&(t=this.items[e].expiry),t}get(e){let t;if(this.has(e)){const r=this.items[e];this.ttl>0&&r.expiry<=Date.now()?this.delete(e):(t=r.value,this.set(e,t,!0))}return t}has(e){return e in this.items}keys(){const e=[];let t=this.first;for(;null!==t;)e.push(t.key),t=t.next;return e}set(e,t,r=!1,i=this.resetTtl){let n;if(r||this.has(e)){if(n=this.items[e],n.value=t,!1===r&&i&&(n.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.last!==n){const e=this.last,t=n.next,r=n.prev;this.first===n&&(this.first=n.next),n.next=null,n.prev=this.last,e.next=n,null!==r&&(r.next=t),null!==t&&(t.prev=r)}}else this.max>0&&this.size===this.max&&this.evict(!0),n=this.items[e]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:e,prev:this.last,next:null,value:t},1==++this.size?this.first=n:this.last.next=n;return this.last=n,this}values(e=this.keys()){return e.map((e=>this.get(e)))}}function Ty(e,t){if(4!==t.length)throw new Error(`Expected data of dimension 4 but got ${t.length}.`);let r=t[3];for(let i=2;i>=1;i--){const n=1===i?1:0,o=2===i?1:0;for(let i=0;i<t[0];i++){const s=t[1]*i;for(let i=n;i<t[1];i++){const n=t[2]*(i+s);for(let i=o;i<t[2];i++){const o=t[3]*(i+n);for(let i=0;i<t[3];i++){const t=o+i;e[t]+=e[t-r]}}}}r*=t[i]}return e}function Ey(e){for(let t=0,r=e.length;t<r;t++)e[t]=e[t]>>>1^-(1&e[t]);return e}function My(e,t){switch(t){case"uint32":return e;case"uint16":for(let t=0;t<e.length;t+=2){const r=e[t],i=e[t+1];e[t]=(240&r)>>4|(61440&r)>>8|(240&i)<<4|61440&i,e[t+1]=15&r|(3840&r)>>4|(15&i)<<8|(3840&i)<<4}return e;case"uint8":for(let t=0;t<e.length;t+=4){const r=e[t],i=e[t+1],n=e[t+2],o=e[t+3];e[t+0]=(192&r)>>6|(192&i)>>4|(192&n)>>2|192&o,e[t+1]=(48&r)>>4|(48&i)>>2|48&n|(48&o)<<2,e[t+2]=(12&r)>>2|12&i|(12&n)<<2|(12&o)<<4,e[t+3]=3&r|(3&i)<<2|(3&n)<<4|(3&o)<<6}return e;default:throw new Error(`Invalid pixel format, "${t}"`)}}class Sy extends Error{constructor(e){super(e),this.name="MRTError"}}var Iy=Uint8Array,Py=Uint16Array,Dy=Int32Array,ky=new Iy([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]),Ly=new Iy([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]),zy=new Iy([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Oy=function(e,t){for(var r=new Py(31),i=0;i<31;++i)r[i]=t+=1<<e[i-1];var n=new Dy(r[30]);for(i=1;i<30;++i)for(var o=r[i];o<r[i+1];++o)n[o]=o-r[i]<<5|i;return{b:r,r:n}},By=Oy(ky,2),Ry=By.b,Fy=By.r;Ry[28]=258,Fy[258]=28;for(var jy=Oy(Ly,0).b,Vy=new Py(32768),Ny=0;Ny<32768;++Ny){var Uy=(43690&Ny)>>1|(21845&Ny)<<1;Vy[Ny]=((65280&(Uy=(61680&(Uy=(52428&Uy)>>2|(13107&Uy)<<2))>>4|(3855&Uy)<<4))>>8|(255&Uy)<<8)>>1}var Hy=function(e,t,r){for(var i=e.length,n=0,o=new Py(t);n<i;++n)e[n]&&++o[e[n]-1];var s,a=new Py(t);for(n=1;n<t;++n)a[n]=a[n-1]+o[n-1]<<1;s=new Py(1<<t);var l=15-t;for(n=0;n<i;++n)if(e[n])for(var c=n<<4|e[n],u=t-e[n],h=a[e[n]-1]++<<u,d=h|(1<<u)-1;h<=d;++h)s[Vy[h]>>l]=c;return s},Gy=new Iy(288);for(Ny=0;Ny<144;++Ny)Gy[Ny]=8;for(Ny=144;Ny<256;++Ny)Gy[Ny]=9;for(Ny=256;Ny<280;++Ny)Gy[Ny]=7;for(Ny=280;Ny<288;++Ny)Gy[Ny]=8;var Zy=new Iy(32);for(Ny=0;Ny<32;++Ny)Zy[Ny]=5;var Wy=Hy(Gy,9),Qy=Hy(Zy,5),qy=function(e){for(var t=e[0],r=1;r<e.length;++r)e[r]>t&&(t=e[r]);return t},Xy=function(e,t,r){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(7&t)&r},Yy=function(e,t){var r=t/8|0;return(e[r]|e[r+1]<<8|e[r+2]<<16)>>(7&t)},$y=["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"],Ky=function(e,t,r){var i=new Error(t||$y[e]);if(i.code=e,Error.captureStackTrace&&Error.captureStackTrace(i,Ky),!r)throw i;return i},Jy=new Iy(0),ex="undefined"!=typeof TextDecoder&&new TextDecoder;try{ex.decode(Jy,{stream:!0})}catch(e){}const tx={gzip_data:"gzip"},rx={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},ix={uint32:1,uint16:2,uint8:4},nx={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};class ox{constructor(e=1){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=e}getLayer(e){return this.layers[e]}getHeaderLength(e){const t=new Uint8Array(e),r=new DataView(e);if(13!==t[0])throw new Sy("File is not a valid MRT.");return r.getUint32(1,!0)}parseHeader(e){const t=new Uint8Array(e),r=this.getHeaderLength(e);if(t.length<r)throw new Sy(`Expected header with length >= ${r} but got buffer of length ${t.length}`);const i=new bm(t.subarray(0,r)),n=by.read(i);if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new Sy(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const e of n.layers)this.layers[e.name]=new sx(e,{cacheSize:this._cacheSize});return this}createDecodingTask(e){const t=[],r=this.getLayer(e.layerName);for(let i=0;i<r.dataIndex.length;i++){const n=r.dataIndex[i],o=n.first_byte-e.firstByte,s=n.last_byte+1-e.firstByte;if(i<e.firstBlock||i>e.lastBlock)continue;if(r._blocksInProgress.has(i))continue;const a={layerName:r.name,firstByte:o,lastByte:s,pixelFormat:r.pixelFormat,blockIndex:i,blockShape:[n.bands.length].concat(r.bandShape),buffer:r.buffer,codec:n.codec.codec,filters:n.filters.map((e=>e.filter))};r._blocksInProgress.add(i),t.push(a)}return new ax(t,(()=>{t.forEach((e=>r._blocksInProgress.delete(e.blockIndex)))}),((e,i)=>{if(t.forEach((e=>r._blocksInProgress.delete(e.blockIndex))),e)throw e;i.forEach((e=>{this.getLayer(e.layerName).processDecodedData(e)}))}))}}class sx{constructor({version:e,name:t,units:r,tilesize:i,pixel_format:n,buffer:o,data_index:s},a){if(this.version=e,1!==this.version)throw new Sy(`Cannot parse raster layer encoded with MRT version ${e}`);this.name=t,this.units=r,this.tileSize=i,this.buffer=o,this.pixelFormat=rx[n],this.dataIndex=s,this.bandShape=[i+2*o,i+2*o,ix[this.pixelFormat]],this._decodedBlocks=function(e=1e3,t=0,r=!1){if(isNaN(e)||e<0)throw new TypeError("Invalid max value");if(isNaN(t)||t<0)throw new TypeError("Invalid ttl value");if("boolean"!=typeof r)throw new TypeError("Invalid resetTtl value");return new Cy(e,t,r)}(a?a.cacheSize:5),this._blocksInProgress=new Set}processDecodedData(e){const t=e.blockIndex.toString();this._decodedBlocks.get(t)||this._decodedBlocks.set(t,e.data)}getBlockForBand(e){let t=0;switch(typeof e){case"string":for(const[r,i]of this.dataIndex.entries()){for(const[n,o]of i.bands.entries())if(o===e)return{bandIndex:t+n,blockIndex:r,blockBandIndex:n};t+=i.bands.length}break;case"number":for(const[r,i]of this.dataIndex.entries()){if(e>=t&&e<t+i.bands.length)return{bandIndex:e,blockIndex:r,blockBandIndex:e-t};t+=i.bands.length}break;default:throw new Sy(`Invalid band \`${JSON.stringify(e)}\`. Expected string or integer.`)}throw new Sy(`Band not found: ${JSON.stringify(e)}`)}getDataRange(e){let t=1/0,r=-1/0,i=1/0,n=-1/0;for(const o of e){const{blockIndex:e}=this.getBlockForBand(o);if(e<0)throw new Sy(`Invalid band: ${JSON.stringify(o)}`);const s=this.dataIndex[e];i=Math.min(i,e),n=Math.max(n,e),t=Math.min(t,s.first_byte),r=Math.max(r,s.last_byte)}return{layerName:this.name,firstByte:t,lastByte:r,firstBlock:i,lastBlock:n}}hasBand(e){const{blockIndex:t}=this.getBlockForBand(e);return t>=0}hasDataForBand(e){const{blockIndex:t}=this.getBlockForBand(e);return t>=0&&!!this._decodedBlocks.get(t.toString())}getBandView(e){const{blockIndex:t,blockBandIndex:r}=this.getBlockForBand(e),i=this._decodedBlocks.get(t.toString());if(!i)throw new Sy(`Data for band ${JSON.stringify(e)} of layer "${this.name}" not decoded.`);const n=this.dataIndex[t],o=this.bandShape.reduce(((e,t)=>e*t),1),s=r*o,a=i.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,offset:n.offset,scale:n.scale}}}class ax{constructor(e,t,r){this.tasks=e,this._onCancel=t,this._onComplete=r,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(e,t){this._finalized||(this._onComplete(e,t),this._finalized=!0)}}ox.performDecoding=function(e,t){return Promise.all(t.tasks.map((t=>{const{layerName:r,firstByte:i,lastByte:n,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:c}=t,u=new Uint8Array(e).subarray(i,n+1),h=new Uint32Array(s[0]*s[1]*s[2]);let d;if("gzip_data"!==c)throw new Error(`Unhandled codec: ${c}`);return d=function(e,t){if(!globalThis.DecompressionStream&&"gzip_data"===t)return Promise.resolve(((o=function(e){31==e[0]&&139==e[1]&&8==e[2]||Ky(6,"invalid gzip data");var t=e[3],r=10;4&t&&(r+=2+(e[10]|e[11]<<8));for(var i=(t>>3&1)+(t>>4&1);i>0;i-=!e[r++]);return r+(2&t)}(n=e))+8>n.length&&Ky(6,"invalid gzip data"),function(e,t,r,i){var n=e.length;if(!n||t.f&&!t.l)return r||new Iy(0);var o=!r,s=o||2!=t.i,a=t.i;o&&(r=new Iy(3*n));var l,c,u=function(e){var t=r.length;if(e>t){var i=new Iy(Math.max(2*t,e));i.set(r),r=i}},h=t.f||0,d=t.p||0,p=t.b||0,f=t.l,m=t.d,A=t.m,g=t.n,_=8*n;do{if(!f){h=Xy(e,d,1);var y=Xy(e,d+1,3);if(d+=3,!y){var x=e[(D=4+((d+7)/8|0))-4]|e[D-3]<<8,v=D+x;if(v>n){a&&Ky(0);break}s&&u(p+x),r.set(e.subarray(D,v),p),t.b=p+=x,t.p=d=8*v,t.f=h;continue}if(1==y)f=Wy,m=Qy,A=9,g=5;else if(2==y){var b=Xy(e,d,31)+257,w=Xy(e,d+10,15)+4,C=b+Xy(e,d+5,31)+1;d+=14;for(var T=new Iy(C),E=new Iy(19),M=0;M<w;++M)E[zy[M]]=Xy(e,d+3*M,7);d+=3*w;var S=qy(E),I=(1<<S)-1,P=Hy(E,S);for(M=0;M<C;){var D,k=P[Xy(e,d,I)];if(d+=15&k,(D=k>>4)<16)T[M++]=D;else{var L=0,z=0;for(16==D?(z=3+Xy(e,d,3),d+=2,L=T[M-1]):17==D?(z=3+Xy(e,d,7),d+=3):18==D&&(z=11+Xy(e,d,127),d+=7);z--;)T[M++]=L}}var O=T.subarray(0,b),B=T.subarray(b);A=qy(O),g=qy(B),f=Hy(O,A),m=Hy(B,g)}else Ky(1);if(d>_){a&&Ky(0);break}}s&&u(p+131072);for(var R=(1<<A)-1,F=(1<<g)-1,j=d;;j=d){var V=(L=f[Yy(e,d)&R])>>4;if((d+=15&L)>_){a&&Ky(0);break}if(L||Ky(2),V<256)r[p++]=V;else{if(256==V){j=d,f=null;break}var N=V-254;V>264&&(N=Xy(e,d,(1<<(G=ky[M=V-257]))-1)+Ry[M],d+=G);var U=m[Yy(e,d)&F],H=U>>4;if(U||Ky(3),d+=15&U,B=jy[H],H>3){var G=Ly[H];B+=Yy(e,d)&(1<<G)-1,d+=G}if(d>_){a&&Ky(0);break}s&&u(p+131072);var Z=p+N;if(p<B){var W=0-B,Q=Math.min(B,Z);for(W+p<0&&Ky(3);p<Q;++p)r[p]=(void 0)[W+p]}for(;p<Z;++p)r[p]=r[p-B]}}t.l=f,t.p=j,t.b=p,t.f=h,f&&(h=1,t.m=A,t.d=m,t.n=g)}while(!h);return p!=r.length&&o?(l=r,(null==(c=p)||c>l.length)&&(c=l.length),new Iy(l.subarray(0,c))):r.subarray(0,p)}(n.subarray(o,-8),{i:2},new Iy(((r=n)[(i=r.length)-4]|r[i-3]<<8|r[i-2]<<16|r[i-1]<<24)>>>0))));var r,i,n,o;const s=tx[t];if(!s)throw new Error(`Unhandled codec: ${t}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([e]).stream().pipeThrough(a)).arrayBuffer().then((e=>new Uint8Array(e)))}(u,c).then((e=>{const t=wy.read(new bm(e));if("uint32_values"===t.values)return t.uint32_values.readValuesInto(h),new nx[o](h.buffer);throw new Error(`Unhandled numeric data "${t.values}"`)})),d.then((e=>{for(let t=l.length-1;t>=0;t--)switch(l[t]){case"delta_filter":Ty(e,s);break;case"zigzag_filter":Ey(e);break;case"bitshuffle_filter":My(e,o);break;default:throw new Error(`Unhandled filter "${l[t]}"`)}return{layerName:r,blockIndex:a,data:e}})).catch((e=>{throw e}))})))},fa(ax,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]});const lx=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class cx{static from(e){if(!(e instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[t,r]=new Uint8Array(e,0,2);if(219!==t)throw new Error("Data does not appear to be in a KDBush format.");const i=r>>4;if(1!==i)throw new Error(`Got v${i} data when expected v1.`);const n=lx[15&r];if(!n)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(e,2,1),[s]=new Uint32Array(e,4,1);return new cx(s,o,n,e)}constructor(e,t=64,r=Float64Array,i){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=r,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const n=lx.indexOf(this.ArrayType),o=2*e*this.ArrayType.BYTES_PER_ELEMENT,s=e*this.IndexArrayType.BYTES_PER_ELEMENT,a=(8-s%8)%8;if(n<0)throw new Error(`Unexpected typed array class: ${r}.`);i&&i instanceof ArrayBuffer?(this.data=i,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+s+a,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+o+s+a),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+s+a,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+n]),new Uint16Array(this.data,2,1)[0]=t,new Uint32Array(this.data,4,1)[0]=e)}add(e,t){const r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=e,this.coords[this._pos++]=t,r}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return ux(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,r,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:o,nodeSize:s}=this,a=[0,n.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,u=a.pop()||0,h=a.pop()||0;if(u-h<=s){for(let s=h;s<=u;s++){const a=o[2*s],c=o[2*s+1];a>=e&&a<=r&&c>=t&&c<=i&&l.push(n[s])}continue}const d=h+u>>1,p=o[2*d],f=o[2*d+1];p>=e&&p<=r&&f>=t&&f<=i&&l.push(n[d]),(0===c?e<=p:t<=f)&&(a.push(h),a.push(d-1),a.push(1-c)),(0===c?r>=p:i>=f)&&(a.push(d+1),a.push(u),a.push(1-c))}return l}within(e,t,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:i,coords:n,nodeSize:o}=this,s=[0,i.length-1,0],a=[],l=r*r;for(;s.length;){const c=s.pop()||0,u=s.pop()||0,h=s.pop()||0;if(u-h<=o){for(let r=h;r<=u;r++)fx(n[2*r],n[2*r+1],e,t)<=l&&a.push(i[r]);continue}const d=h+u>>1,p=n[2*d],f=n[2*d+1];fx(p,f,e,t)<=l&&a.push(i[d]),(0===c?e-r<=p:t-r<=f)&&(s.push(h),s.push(d-1),s.push(1-c)),(0===c?e+r>=p:t+r>=f)&&(s.push(d+1),s.push(u),s.push(1-c))}return a}}function ux(e,t,r,i,n,o){if(n-i<=r)return;const s=i+n>>1;hx(e,t,s,i,n,o),ux(e,t,r,i,s-1,1-o),ux(e,t,r,s+1,n,1-o)}function hx(e,t,r,i,n,o){for(;n>i;){if(n-i>600){const s=n-i+1,a=r-i+1,l=Math.log(s),c=.5*Math.exp(2*l/3),u=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2<0?-1:1);hx(e,t,r,Math.max(i,Math.floor(r-a*c/s+u)),Math.min(n,Math.floor(r+(s-a)*c/s+u)),o)}const s=t[2*r+o];let a=i,l=n;for(dx(e,t,i,r),t[2*n+o]>s&&dx(e,t,i,n);a<l;){for(dx(e,t,a,l),a++,l--;t[2*a+o]<s;)a++;for(;t[2*l+o]>s;)l--}t[2*i+o]===s?dx(e,t,i,l):(l++,dx(e,t,l,n)),l<=r&&(i=l+1),r<=l&&(n=l-1)}}function dx(e,t,r,i){px(e,r,i),px(t,2*r,2*i),px(t,2*r+1,2*i+1)}function px(e,t,r){const i=e[t];e[t]=e[r],e[r]=i}function fx(e,t,r,i){const n=e-r,o=t-i;return n*n+o*o}e.$=class{constructor(e){this.specification=e}possiblyEvaluate(e,t){return function([e,t]){const r=fr([1,e,t]);return{x:r.x,y:r.y,z:r.z}}(e.expression.evaluate(t))}interpolate(e,t,r){return{x:Ui(e.x,t.x,r),y:Ui(e.y,t.y,r),z:Ui(e.z,t.z,r)}}},e.A=rl,e.B=Qs,e.C=Pn,e.D=Gs,e.E=Oi,e.F=function(e){const t=e.value;let r=[];if(!t)return r;const i=Tn(t);return"string"!==i?(r=r.concat([new Kg(e.key,t,`string expected, "${i}" found`)]),r):(Jg(t,!0)||(r=r.concat([new Kg(e.key,t,`invalid url "${t}"`)])),r)},e.G=tl,e.H=Ka,e.I=eA,e.J=Xa,e.K=class{constructor(e){this.specification=e}possiblyEvaluate(e,t){return fr(e.expression.evaluate(t))}interpolate(e,t,r){return{x:Ui(e.x,t.x,r),y:Ui(e.y,t.y,r),z:Ui(e.z,t.z,r),azimuthal:Ui(e.azimuthal,t.azimuthal,r),polar:Ui(e.polar,t.polar,r)}}},e.L=Ha,e.M=class{constructor(e,t,r,i){this.id=e,this.position=null!=t?new su(t[0],t[1]):new su(0,0),this.orientation=null!=r?r:[0,0,0],this.nodes=i,this.uploaded=!1,this.aabb=new mh([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[]}_applyTransformations(t,r){if(e.a9.multiply(t.matrix,r,t.matrix),t.meshes)for(const e of t.meshes){const r=mh.applyTransform(e.aabb,t.matrix);this.aabb.encapsulate(r)}if(t.children)for(const e of t.children)this._applyTransformations(e,t.matrix)}computeBoundsAndApplyParent(){const t=e.a9.identity([]);for(const e of this.nodes)this._applyTransformations(e,t)}computeModelMatrix(e,t,r,i,n,o,s=!1){a_(this.matrix,this,e.transform,this.position,t,r,i,n,o,s)}upload(e){if(!this.uploaded){for(const t of this.nodes)u_(t,e);for(const e of this.nodes)h_(e);this.uploaded=!0}}destroy(){for(const e of this.nodes)d_(e)}},e.N=Va,e.O=Iu,e.P=Vt,e.R=Xr,e.S=Yt,e.T=yg,e.U=qa,e.V=Kg,e.W=jh,e.X=Ui,e.Y=no,e.Z=oa,e._=Hi,e.a=zi,e.a$=or,e.a0=function(e,t,r=0,i=!0){const n=new Vt(r,r),o=e.sub(n),s=t.add(n),a=[o,new Vt(s.x,o.y),s,new Vt(o.x,s.y)];return i&&a.push(o.clone()),a},e.a1=function(e,t){const r=[];for(let i=0;i<e.length;i++){const n=$t(i-1,-1,e.length-1),o=$t(i+1,-1,e.length-1),s=e[i],a=e[o],l=e[n].sub(s).unit(),c=a.sub(s).unit(),u=c.angleWithSep(l.x,l.y),h=l.add(c).unit().mult(-1*t/Math.sin(u/2));r.push(s.add(h))}return r},e.a2=kA,e.a3=Ku,e.a4=function(t,r,i=0){return e.Q.fromValues(((r.x-i)*t.scale-t.x)*no,(r.y*t.scale-t.y)*no,wu(r.z,r.y))},e.a5=lh,e.a6=Sf,e.a7=function(e){let t=1/0,r=1/0,i=-1/0,n=-1/0;for(const o of e)t=Math.min(t,o.x),r=Math.min(r,o.y),i=Math.max(i,o.x),n=Math.max(n,o.y);return{min:new Vt(t,r),max:new Vt(i,n)}},e.a8=_u,e.aA=Ni,e.aB=wl,e.aC=Ls,e.aD=ec,e.aE=mc,e.aF=tr,e.aG=ic,e.aH=cg,e.aI=function(){ja.isLoading()||ja.isLoaded()||"deferred"!==Ra()||Fa()},e.aJ=il,e.aK=Fu,e.aL=sy,e.aM=Ar,e.aN=Tf,e.aO=Gd,e.aP=Ru,e.aQ=Tl,e.aR=Yl,e.aS=yh,e.aT=jd,e.aU=_g,e.aV=function(t,r){const i=jh(r.zoom);if(0===i)return Th(t);const n=Ih(t),o=Ph(n),s=_u(n.getWest())*r.worldSize,a=_u(n.getEast())*r.worldSize,l=yu(n.getNorth())*r.worldSize,c=yu(n.getSouth())*r.worldSize,u=[s,l,0],h=[a,l,0],d=[s,c,0],p=[a,c,0],f=e.a9.invert([],r.globeMatrix);return e.Q.transformMat4(u,u,f),e.Q.transformMat4(h,h,f),e.Q.transformMat4(d,d,f),e.Q.transformMat4(p,p,f),o[0]=Eh(o[0],d,i),o[1]=Eh(o[1],p,i),o[2]=Eh(o[2],h,i),o[3]=Eh(o[3],u,i),mh.fromPoints(o)},e.aW=zh,e.aX=Dh,e.aY=Eh,e.aZ=El,e.a_=_h,e.ab=$u,e.ac=Du,e.ad=Xt,e.ae=qc,e.af=function(e,t){const r={};for(let i=0;i<t.length;i++){const n=t[i];n in e&&(r[n]=e[n])}return r},e.ag=au,e.ah=yu,e.ai=class{constructor(e){this.entries={},this.scheduler=e}request(e,t,r,i){const n=this.entries[e]=this.entries[e]||{callbacks:[]};if(n.result){const[e,r]=n.result;return this.scheduler?this.scheduler.add((()=>{i(e,r)}),t):i(e,r),()=>{}}return n.callbacks.push(i),n.cancel||(n.cancel=r(((r,i)=>{n.result=[r,i];for(const e of n.callbacks)this.scheduler?this.scheduler.add((()=>{e(r,i)}),t):e(r,i);setTimeout((()=>delete this.entries[e]),3e3)}))),()=>{n.result||(n.callbacks=n.callbacks.filter((e=>e!==i)),n.callbacks.length||(n.cancel(),delete this.entries[e]))}}},e.aj=Al,e.ak=function(e,t,r){const i=JSON.stringify(e.request);return e.data&&(this.deduped.entries[i]={result:[null,e.data]}),this.deduped.request(i,{type:"parseTile",isSymbolTile:e.isSymbolTile,zoom:e.tileZoom},(t=>{const i=Jr(e.request,((e,i,n,o)=>{e?t(e):i&&t(null,{vectorTile:r?void 0:new hp(new bm(i)),rawData:i,cacheControl:n,expires:o})}));return()=>{i.cancel(),t()}}),t)},e.al=function(e){Nr++,Nr>Fr&&(e.getActor().send("enforceCacheSizeLimit",Rr),Nr=0)},e.am=fi,e.an=Pr,e.ao=function(e){return e<=1?1:Math.pow(2,Math.floor(Math.log(e)/Math.LN2))},e.ap=du,e.aq=Eg,e.ar=Ig,e.as=Cg,e.at=function(e,t){const r=document.createElement("video");r.muted=!0,r.onloadstart=function(){t(null,r)};for(let t=0;t<e.length;t++){const i=document.createElement("source");ei(e[t])||(r.crossOrigin="Anonymous"),i.src=e[t],r.appendChild(i)}return{cancel:()=>{}}},e.au=xg,e.av=DA,e.aw=vu,e.ax=bu,e.ay=Ml,e.az=Hl,e.b=Li,e.b$=aA,e.b0=ox,e.b1=Jr,e.b2=function(e){const t=[];for(const r in e)t.push(e[r]);return t},e.b3=function(e,t){const r=[];for(const i in e)i in t||r.push(i);return r},e.b4=Kt,e.b5=["type","source","source-layer","minzoom","maxzoom","filter","layout"],e.b6=function(t,r){const{x:i,y:n}=t.point,o=Fh(i,n,t.worldSize/t._pixelsPerMercatorPixel,0,0);return e.a9.multiply(o,o,Oh(Th(r)))},e.b8=qf,e.b9=Sm,e.bA=Yc,e.bB=function(t){const r=e.a9.identity(new Float64Array(16));e.a9.multiply(r,t.pixelMatrix,t.globeMatrix);const i=[0,eu,0],n=[0,tu,0];return e.Q.transformMat4(i,i,r),e.Q.transformMat4(n,n,r),[i[0]>0&&i[0]<=t.width&&i[1]>0&&i[1]<=t.height&&!Nh(t,new su(t.center.lat,90)),n[0]>0&&n[0]<=t.width&&n[1]>0&&n[1]<=t.height&&!Nh(t,new su(t.center.lat,-90))]},e.bC=function(t,r){const{scale:i}=t.tileTransform,n=i*no/(t.tileSize*Math.pow(2,r.zoom-t.tileID.overscaledZ+t.tileID.canonical.z));return e.b7.scale(new Float32Array(4),r.inverseAdjustmentMatrix,[n,n])},e.bD=Rg,e.bE=Og,e.bF=function(t){const r=Og(t,!0);return e.b7.invert([],[r[0],r[1],r[4],r[5]])},e.bG=ch,e.bH=function(e){const{x:t,y:r}=e.point,{lng:i,lat:n}=e._center;return Fh(t,r,e.worldSize,i,n)},e.bI=Gt,e.bJ=Xc,e.bK=function(e){const t=Math.round((e+45+360)%360/90)%4;return Zt[t]},e.bL=45,e.bM=gu,e.bN=Dc,e.bO=Ec,e.bP=Mc,e.bQ=Tc,e.bR=Cc,e.bS=Sc,e.bT=function(e,t,r){const i=Math.sqrt(e*e+t*t+r*r),n=i>0?Math.acos(r/i)*Ut:0;let o=0!==e||0!==t?Math.atan2(-t,-e)*Ut+90:0;return o<0&&(o+=360),[i,o,n]},e.bU=Su,e.bV=mh,e.bW=fr,e.bX=function(e){return[Math.pow(e[0],1/2.2),Math.pow(e[1],1/2.2),Math.pow(e[2],1/2.2)]},e.bY=function(e){return e({pluginStatus:ka,pluginURL:La}),Ba.on("pluginStateChange",e),e},e.bZ=A_,e.b_=b_,e.ba=Qf,e.bb=function(e,t,r,i,n){const o=5*t+2;e.float32[o+0]=r,e.float32[o+1]=i,e.float32[o+2]=n},e.bc=og,e.bd=$m,e.be=Uu,e.bf=Gf,e.bg=vA,e.bh=xA,e.bi=jm,e.bj=cx,e.bk=$t,e.bm=Ht,e.bn=Tr,e.bo=xu,e.bp=function(e,t,r){e[4*t+0]=r[0],e[4*t+1]=r[1],e[4*t+2]=r[2],e[4*t+3]=r[3]},e.bq=su,e.br=JA,e.bs=hu,e.bt=fh,e.bu=Bg,e.bv=uu,e.bw=Sh,e.bx=function(e,t,r,i,n,o,s,a,l){if("globe"===l.name)return Sh(e,t,new uu(r,i,n),!1);const c=DA({z:r,x:i,y:n},l);return new mh([(o+c.x/c.scale)*t,t*(c.y/c.scale),s],[(o+c.x2/c.scale)*t,t*(c.y2/c.scale),a])},e.by=function(e,t,r){let i=0;for(let r=0;r<2;++r){const n=0;e[r]>n&&(i+=(e[r]-n)*(e[r]-n)),t[r]<n&&(i+=(n-t[r])*(n-t[r]))}return i},e.bz=Cu,e.c=ty,e.c$=[1,1,1],e.c0=sA,e.c1=$r,e.c2=za,e.c3=o,e.c4=Lr,e.c5=Pi,e.c6=cr,e.c7=function(e,t,r){return"custom"===e.type?new Pg(e,t):new vy[e.type](e,t,r)},e.c8=function(e){const t=e.indexOf(ml);return t>=0?e.slice(0,t):e},e.c9=function(e){return e.indexOf(ml)>=0},e.cA=e=>({u_matrix:new Dc(e),u_pixels_to_tile_units:new zc(e),u_device_pixel_ratio:new Tc(e),u_units_to_pixels:new Ec(e),u_dash_image:new Cc(e),u_gradient_image:new Cc(e),u_image_height:new Tc(e),u_texsize:new Ec(e),u_tile_units_to_pixels:new Tc(e),u_alpha_discard_threshold:new Tc(e),u_trim_offset:new Ec(e),u_emissive_strength:new Tc(e)}),e.cB=e=>({u_matrix:new Dc(e),u_texsize:new Ec(e),u_pixels_to_tile_units:new zc(e),u_device_pixel_ratio:new Tc(e),u_image:new Cc(e),u_units_to_pixels:new Ec(e),u_tile_units_to_pixels:new Tc(e),u_alpha_discard_threshold:new Tc(e),u_trim_offset:new Ec(e)}),e.cC=Nl,e.cD=Hf,e.cE=Xf,e.cF=Wh,e.cG=(e,t,r,i,n,o)=>{const s=e.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const e=Rh(s.zoom,t.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([e,0,0,e])}else l=s.calculatePixelsToTileUnitsMatrix(r);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:e.transform.getCameraToCenterDistance(s.projection),u_matrix:e.translatePosMatrix(t.projMatrix,r,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:Dr.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Zh,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=i,c.u_merc_center=n,c.u_tile_id=[t.canonical.x,t.canonical.y,1<<t.canonical.z],c.u_zoom_transition=jh(s.zoom);const e=n[0]*no,r=n[1]*no;c.u_up_dir=s.projection.upVector(new uu(0,0,0),e,r)}return c},e.cH=Df,e.cI=(e,t,r,i,n,o)=>{const s=e.transform;return{u_matrix:Pf(e,t,r,i),u_texsize:t.imageAtlasTexture?t.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(t),u_device_pixel_ratio:n,u_image:0,u_tile_units_to_pixels:If(t,s),u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:o}},e.cJ=(e,t,r,i,n,o,s)=>{const a=e.transform,l=a.calculatePixelsToTileUnitsMatrix(t);return{u_matrix:Pf(e,t,r,i),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:n,u_texsize:kf(r)&&t.lineAtlasTexture?t.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:If(t,e.transform),u_alpha_discard_threshold:0,u_trim_offset:s,u_emissive_strength:r.paint.get("line-emissive-strength")}},e.cK=ir,e.cL=ad,e.cM=sf,e.cN=fu,e.cO=$p,e.cP=Vp,e.cQ=450,e.cR=7,e.cS=Tg,e.cT=256,e.cU=Oh,e.cV=$l,e.cW=Ql,e.cX=ql,e.cY=function(e,t,r,i,n){return Xt((e-t)/(r-t)*(n-i)+i,i,n)},e.cZ=Eu,e.c_=Hg,e.ca=function(e){const t=e.indexOf(ml);return t>=0?e.slice(t+1):""},e.cb=function(e){const t=[],r=e.id;return void 0===r&&t.push({message:`layers.${r}: missing required property "id"`}),void 0===e.render&&t.push({message:`layers.${r}: missing required method "render"`}),e.renderingMode&&"2d"!==e.renderingMode&&"3d"!==e.renderingMode&&t.push({message:`layers.${r}: property "renderingMode" must be either "2d" or "3d"`}),t},e.cc=lr,e.cd=Ba,e.ce=Kr,e.cf=Ic,e.cg=class extends wc{constructor(e){super(e),this.current=kc}set(e,t,r){if(this.fetchUniformLocation(e,t))for(let e=0;e<9;e++)if(r[e]!==this.current[e]){this.current=r,this.gl.uniformMatrix3fv(this.location,!1,r);break}}},e.ch=Wt,e.ci=function(e,t,r){const i=jh(r.zoom),n=e.style.map._antialias,o=t.options.extStandardDerivativesForceOff||e.terrain&&e.terrain.exaggeration()>0;return 0===i&&!n&&!o},e.cj=function(t){const r=t.pixelsPerMeter,i=r/xu(1,t.center.lat),n=e.a9.identity(new Float64Array(16));return e.a9.translate(n,n,[t.point.x,t.point.y,0]),e.a9.scale(n,n,[i,i,r]),Float32Array.from(n)},e.ck=Ih,e.cl=function(e){const t=Cu-5;e=Xt(e,-t,t)/t*90;const r=Math.pow(Math.abs(Math.sin(Ht(e))),3);return Math.round(r*(Jc.length-1))},e.cm=function(t,r,i,n){const o=r.getNorth(),s=r.getSouth(),a=r.getWest(),l=r.getEast(),c=1<<t.z,u=l-a,h=o-s,d=u/Kc,p=-h/Jc[i],f=[0,d,0,p,0,0,o,a,0];if(t.z>0){const t=180/n;e.ct.multiply(f,f,[t/u+1,0,0,0,t/h+1,0,-.5*t/d,.5*t/p,1])}return f[2]=c,f[5]=t.x,f[8]=t.y,f},e.cn=Th,e.co=function(t,r,i){const n=e.a9.identity(new Float64Array(16)),o=(r/(1<<t)-.5)*Math.PI*2;return e.a9.rotateY(n,i.globeMatrix,o),Float32Array.from(n)},e.cp=class{isDataAvailableAtPoint(e){const t=this._source();if(this.isUsingMockSource()||!t||e.y<0||e.y>1)return!1;const r=t.getSource().maxzoom,i=1<<r,n=Math.floor(e.x),o=Math.floor((e.x-n)*i),s=Math.floor(e.y*i),a=this.findDEMTileFor(new du(r,n,r,o,s));return!(!a||!a.dem)}getAtPointOrZero(e,t=0){return this.getAtPoint(e,t)||0}getAtPoint(e,t,r=!0){if(this.isUsingMockSource())return null;null==t&&(t=null);const i=this._source();if(!i)return t;if(e.y<0||e.y>1)return t;const n=i.getSource().maxzoom,o=1<<n,s=Math.floor(e.x),a=e.x-s,l=new du(n,s,n,Math.floor(a*o),Math.floor(e.y*o)),c=this.findDEMTileFor(l);if(!c||!c.dem)return t;const u=c.dem,h=1<<c.tileID.canonical.z,d=(a*h-c.tileID.canonical.x)*u.dim,p=(e.y*h-c.tileID.canonical.y)*u.dim,f=Math.floor(d),m=Math.floor(p);return(r?this.exaggeration():1)*Ui(Ui(u.get(f,m),u.get(f,m+1),p-m),Ui(u.get(f+1,m),u.get(f+1,m+1),p-m),d-f)}getAtTileOffset(e,t,r){const i=1<<e.canonical.z;return this.getAtPointOrZero(new Iu(e.wrap+(e.canonical.x+t/no)/i,(e.canonical.y+r/no)/i))}getAtTileOffsetFunc(t,r,i,n){return o=>{const s=this.getAtTileOffset(t,o.x,o.y),a=n.upVector(t.canonical,o.x,o.y),l=n.upVectorScale(t.canonical,r,i).metersToTile;return e.Q.scale(a,a,s*l),a}}getForTilePoints(e,t,r,i){if(this.isUsingMockSource())return!1;const n=Lp.create(this,e,i);return!!n&&(t.forEach((e=>{e[2]=this.exaggeration()*n.getElevationAt(e[0],e[1],r)})),!0)}getMinMaxForTile(e){if(this.isUsingMockSource())return null;const t=this.findDEMTileFor(e);if(!t||!t.dem)return null;const r=t.dem.tree,i=t.tileID,n=1<<e.canonical.z-i.canonical.z;let o=e.canonical.x/n-i.canonical.x,s=e.canonical.y/n-i.canonical.y,a=0;for(let t=0;t<e.canonical.z-i.canonical.z&&!r.leaves[a];t++){o*=2,s*=2;const e=2*Math.floor(s)+Math.floor(o);a=r.childOffsets[a]+e,o%=1,s%=1}return{min:this.exaggeration()*r.minimums[a],max:this.exaggeration()*r.maximums[a]}}getMinElevationBelowMSL(){throw new Error("Pure virtual method called.")}raycast(e,t,r){throw new Error("Pure virtual method called.")}pointCoordinate(e){throw new Error("Pure virtual method called.")}_source(){throw new Error("Pure virtual method called.")}isUsingMockSource(){throw new Error("Pure virtual method called.")}exaggeration(){throw new Error("Pure virtual method called.")}findDEMTileFor(e){throw new Error("Pure virtual method called.")}get visibleDemTiles(){throw new Error("Getter must be implemented in subclass.")}getMinMaxForVisibleTiles(){const e=this.visibleDemTiles;if(0===e.length)return null;let t=!1,r=Number.MAX_VALUE,i=Number.MIN_VALUE;for(const n of e){const e=this.getMinMaxForTile(n.tileID);e&&(r=Math.min(r,e.min),i=Math.max(i,e.max),t=!0)}return t?{min:r,max:i}:null}},e.cq=xh,e.cr=nd,e.cs=function(e,t){return[Math.pow(e[0],2.2)*t,Math.pow(e[1],2.2)*t,Math.pow(e[2],2.2)*t]},e.cu=Rh,e.cv=Ir,e.cw=Sr,e.cx=256,e.cy=function(t,r){const i=[0,0,0],n=zh(Th(r.canonical));return e.Q.transformMat4(i,i,n),e.Q.transformMat4(i,i,t),i},e.cz=e=>({u_camera_to_center_distance:new Tc(e),u_extrude_scale:new zc(e),u_device_pixel_ratio:new Tc(e),u_matrix:new Dc(e),u_inv_rot_matrix:new Dc(e),u_merc_center:new Ec(e),u_tile_id:new Mc(e),u_zoom_transition:new Tc(e),u_up_dir:new Mc(e),u_emissive_strength:new Tc(e)}),e.d=ni,e.d$=m_,e.d0=Lp,e.d1=s_,e.d2=Fl,e.d3=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[]}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(e){const t=gp(new Vt(0,0),new Vt(no,no),e),r=[];for(const i of this._activeRegions){if(i.hiddenByOverlap)continue;if(!Ap(t,i))continue;const n=_p(i.min,i.max,e);r.push({min:n.min,max:n.max,sourceId:this._sourceIds[i.priority],footprint:i.footprint,footprintTileId:i.tileId})}return r}setSources(e){this._setSources(e.map((e=>({getSourceId:()=>e.cache.id,getFootprints:()=>{const t=[];for(const r of e.cache.getVisibleCoordinates()){const i=e.cache.getTile(r).buckets[e.layer];if(i)for(const e of i.getNodesInfo()){const i=e.node;i.footprint&&t.push({footprint:i.footprint,id:r.toUnwrapped()})}}return t}}))))}_addSource(e){const t=e.getFootprints();if(0!==t.length){for(const e of t){if(!e.footprint)continue;const t=gp(e.footprint.min,e.footprint.max,e.id);this._activeRegions.push({min:t.min,max:t.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:e.id,footprint:e.footprint})}this._sourceIds.push(e.getSourceId())}}_computeReplacement(){this._activeRegions.sort(((e,t)=>e.priority-t.priority||fp(e.min,t.min)||fp(e.max,t.max)));let e=this._activeRegions.length!==this._prevRegions.length;if(!e){let t=0,r=0;for(;!e&&t!==this._activeRegions.length;){const i=this._activeRegions[t],n=this._prevRegions[r];e=i.priority!==n.priority||!mp(i,n),++t,++r}}if(e){++this._updateTime;const e=e=>{const t=this._activeRegions;if(e>=t.length)return e;const r=t[e].priority;for(;e<t.length&&t[e].priority===r;)++e;return e};if(this._sourceIds.length>1){let t=0,r=e(t);for(;t!==r;){let i=t;const n=t;for(;i!==r;){const e=this._activeRegions[i];e.hiddenByOverlap=!1;for(let t=0;t<n;t++){const r=this._activeRegions[t];if(!r.hiddenByOverlap&&Ap(e,r)&&(e.hiddenByOverlap=xp(e.footprint,e.tileId,r.footprint,r.tileId),e.hiddenByOverlap))break}++i}t=r,r=e(t)}}}}_setSources(e){[this._prevRegions,this._activeRegions]=[this._activeRegions,[]],this._sourceIds=[];for(let t=e.length-1;t>=0;t--)this._addSource(e[t]);this._computeReplacement()}},e.d4=class{constructor(e){this._createGrid(e),this._createPoles(e)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const e of this._poleSegments)e.destroy();for(const e of this._gridSegments)e.withSkirts.destroy(),e.withoutSkirts.destroy()}_fillGridMeshWithLods(e,t){const r=new Tl,i=new Hl,n=[],o=e+1+2,s=t[0]+1,a=t[0]+1+(1+t.length),l=(e,t,r)=>{let i=e===o-1?e-2:0===e?e:e-1;return i+=r?24575:0,[i,t]};for(let e=0;e<o;++e)r.emplaceBack(...l(e,0,!0));for(let e=0;e<s;++e)for(let t=0;t<o;++t)r.emplaceBack(...l(t,e,(0===t||t===o-1)&&!0));for(let e=0;e<t.length;++e){const i=t[e];for(let e=0;e<o;++e)r.emplaceBack(...l(e,i,!0))}for(let e=0;e<t.length;++e){const s=i.length,l=t[e]+1+2,c=new Hl;for(let r=0;r<l-1;r++){const n=r===l-2,s=n?o*(a-t.length+e-r):o;for(let e=0;e<o-1;e++){const t=r*o+e;0===r||n||0===e||e===o-2?(c.emplaceBack(t+1,t,t+s),c.emplaceBack(t+s,t+s+1,t+1)):(i.emplaceBack(t+1,t,t+s),i.emplaceBack(t+s,t+s+1,t+1))}}const u=mc.simpleSegment(0,s,r.length,i.length-s);for(let e=0;e<c.uint16.length;e+=3)i.emplaceBack(c.uint16[e],c.uint16[e+1],c.uint16[e+2]);const h=mc.simpleSegment(0,s,r.length,i.length-s);n.push({withoutSkirts:u,withSkirts:h})}return{vertices:r,indices:i,segments:n}}_createGrid(e){const t=this._fillGridMeshWithLods(Kc,Jc);this._gridSegments=t.segments,this._gridBuffer=e.createVertexBuffer(t.vertices,yh.members),this._gridIndexBuffer=e.createIndexBuffer(t.indices,!0)}_createPoles(e){const t=new Hl;for(let e=0;e<=Kc;e++)t.emplaceBack(0,e+1,e+2);this._poleIndexBuffer=e.createIndexBuffer(t,!0);const r=new Ql,i=new Ql,n=new Ql,o=new Ql;this._poleSegments=[];for(let e=0,t=0;e<Xc;e++){const s=360/(1<<e);r.emplaceBack(0,-qc,0,.5,0),i.emplaceBack(0,-qc,0,.5,1),n.emplaceBack(0,-qc,0,.5,.5),o.emplaceBack(0,-qc,0,.5,.5);for(let e=0;e<=Kc;e++){let t=e/Kc,a=0;const l=Ui(0,s,t),[c,u,h]=ru(Hh,Gh,l,qc);r.emplaceBack(c,u,h,t,a),i.emplaceBack(c,u,h,t,1-a);const d=Ht(l);t=.5+.5*Math.sin(d),a=.5+.5*Math.cos(d),n.emplaceBack(c,u,h,t,a),o.emplaceBack(c,u,h,t,1-a)}this._poleSegments.push(mc.simpleSegment(t,0,66,64)),t+=66}this._poleNorthVertexBuffer=e.createVertexBuffer(r,gh,!1),this._poleSouthVertexBuffer=e.createVertexBuffer(i,gh,!1),this._texturedPoleNorthVertexBuffer=e.createVertexBuffer(n,gh,!1),this._texturedPoleSouthVertexBuffer=e.createVertexBuffer(o,gh,!1)}getGridBuffers(e,t){return[this._gridBuffer,this._gridIndexBuffer,t?this._gridSegments[e].withSkirts:this._gridSegments[e].withoutSkirts]}getPoleBuffers(e,t){return[t?this._texturedPoleNorthVertexBuffer:this._poleNorthVertexBuffer,t?this._texturedPoleSouthVertexBuffer:this._poleSouthVertexBuffer,this._poleIndexBuffer,this._poleSegments[e]]}},e.d5=function(e){return wi.has(e)},e.d6=Qt,e.d7=function(){return!!document.fullscreenElement||!!document.webkitFullscreenElement},e.d8=qt,e.d9=Mu,e.dA=x_,e.dB=function(e){const t=jr();if(!t)return;const r=t.delete(zr);e&&r.catch(e).then((()=>e()))},e.dC=g_,e.dD=I_,e.dE=function(e){C_=Dr.resolveURL(e),S_||(S_=new A_(b_(),new Oi)),S_.broadcast("setDracoUrl",C_)},e.dF=P_,e.dG=function(e){E_=Dr.resolveURL(e),S_||(S_=new A_(b_(),new Oi)),S_.broadcast("setMeshoptUrl",E_)},e.dH=fa,e.dI=rd,e.dJ=oA,e.dK=ny,e.dL=ay,e.dM=vf,e.dN=ar,e.dO=tA,e.dP=function(e,t,r,i,n,o,s,a,l,c,u){e.createArrays(),e.tilePixelRatio=no/(512*e.overscaling),e.compareText={},e.iconsNeedLinear=!1;const h=e.layers[0].layout,d=e.layers[0]._unevaluatedLayout._values,p={};if("composite"===e.textSizeData.kind){const{minZoom:t,maxZoom:r}=e.textSizeData;p.compositeTextSizes=[d["text-size"].possiblyEvaluate(new Va(t),a),d["text-size"].possiblyEvaluate(new Va(r),a)]}if("composite"===e.iconSizeData.kind){const{minZoom:t,maxZoom:r}=e.iconSizeData;p.compositeIconSizes=[d["icon-size"].possiblyEvaluate(new Va(t),a),d["icon-size"].possiblyEvaluate(new Va(r),a)]}p.layoutTextSize=d["text-size"].possiblyEvaluate(new Va(l+1),a),p.layoutIconSize=d["icon-size"].possiblyEvaluate(new Va(l+1),a),p.textMaxSize=d["text-size"].possiblyEvaluate(new Va(18),a);const f="map"===h.get("text-rotation-alignment")&&"point"!==h.get("symbol-placement"),m=h.get("text-size");let A=!1;for(const t of e.features)if(t.icon&&t.icon.nameSecondary){A=!0;break}for(const o of e.features){const l=h.get("text-font").evaluate(o,{},a).join(","),d=m.evaluate(o,{},a),g=p.layoutTextSize.evaluate(o,{},a),_=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),y=o.text;let x,v=[0,0];if(y){const i=y.toString(),s=h.get("text-letter-spacing").evaluate(o,{},a)*Gf,c=h.get("text-line-height").evaluate(o,{},a)*Gf,u=va(i)?s:0,p=h.get("text-anchor").evaluate(o,{},a),m=h.get("text-variable-anchor");if(!m){const e=h.get("text-radial-offset").evaluate(o,{},a);v=e?xA(p,[e*Gf,_A]):h.get("text-offset").evaluate(o,{},a).map((e=>e*Gf))}let A=f?"center":h.get("text-justify").evaluate(o,{},a);const x="point"===h.get("symbol-placement"),b=x?h.get("text-max-width").evaluate(o,{},a)*Gf:1/0,w=o=>{e.allowVerticalPlacement&&xa(i)&&(_.vertical=Dm(y,t,r,n,l,b,c,p,o,u,v,Sm.vertical,!0,g,d))};if(!f&&m){const e="auto"===A?m.map((e=>vA(e))):[A];let i=!1;for(let o=0;o<e.length;o++){const s=e[o];if(!_.horizontal[s])if(i)_.horizontal[s]=_.horizontal[0];else{const e=Dm(y,t,r,n,l,b,c,"center",s,u,v,Sm.horizontal,!1,g,d);e&&(_.horizontal[s]=e,i=1===e.positionedLines.length)}}w("left")}else{if("auto"===A&&(A=vA(p)),x||h.get("text-writing-mode").indexOf("horizontal")>=0||!xa(i)){const e=Dm(y,t,r,n,l,b,c,p,A,u,v,Sm.horizontal,!1,g,d);e&&(_.horizontal[A]=e)}w(x?"left":A)}}let b=!1;if(o.icon&&o.icon.namePrimary){const t=i[o.icon.namePrimary];t&&(x=Nm(n[o.icon.namePrimary],o.icon.nameSecondary?n[o.icon.nameSecondary]:void 0,h.get("icon-offset").evaluate(o,{},a),h.get("icon-anchor").evaluate(o,{},a)),b=t.sdf,void 0===e.sdfIcons?e.sdfIcons=t.sdf:e.sdfIcons!==t.sdf&&hr("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(t.pixelRatio!==e.pixelRatio||0!==h.get("icon-rotate").constantOr(1))&&(e.iconsNeedLinear=!0))}const w=EA(_.horizontal)||_.vertical;e.iconsInText||(e.iconsInText=!!w&&w.iconsInText),(w||x)&&bA(e,o,_,x,i,p,g,0,v,b,s,a,c,u,A)}o&&e.generateCollisionDebugBuffers(l,e.collisionBoxArray)},e.dQ=hp,e.dR=bm,e.dS=kp,e.dT=dp,e.dU=Jd,e.dV=Ft,e.dW=tm,e.dX=h,e.dY=function(e){let t=0;if(new Uint32Array(e,0,1)[0]!==j_){const r=new Uint32Array(e,0,7),[,,i,n,o,s]=r;t=r.byteLength+n+o+s+o,(i!==e.byteLength||t>=e.byteLength)&&hr("Invalid b3dm header information.")}return Z_(e,t)},e.dZ=function(e,t){const r=ty(e);for(const e of r){for(const t of e.meshes)ry(t);e.lights&&(e.lightMeshIndex=e.meshes.length,e.meshes.push(iy(e.lights,t)))}return r},e.d_=Ay,e.da=iu,e.db=function([e,t,r]){const i=Math.hypot(e,t,r),n=Math.atan2(e,r),o=.5*Math.PI-Math.acos(-t/i);return new su(Gt(n),Gt(o))},e.dc=nu,e.dd=i,e.de=Nh,e.df=Vh,e.dg=function(t){const r=[0,0,0],i=e.a9.identity(new Float64Array(16));return e.a9.multiply(i,t.pixelMatrix,t.globeMatrix),e.Q.transformMat4(r,r,i),new Vt(r[0],r[1])},e.dh=function(e){const t=e.navigator?e.navigator.userAgent:null;return!!function(e){if(null==wr){const t=e.navigator?e.navigator.userAgent:null;wr=!!e.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return wr}(e)&&t&&(t.match("Version/15.4")||t.match("Version/15.5")||t.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},e.di=class{constructor(e,t,r){this._transformRequestFn=e,this._customAccessToken=t,this._silenceAuthErrors=!!r,this._createSkuToken()}_createSkuToken(){const e=function(){let e="";for(let t=0;t<10;t++)e+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1",oi,e].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=e.token,this._skuTokenExpiresAt=e.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}normalizeStyleURL(e,r){if(!o(e))return e;const i=li(e);return i.params.push(`sdk=js-${t}`),i.path=`/styles/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||r)}normalizeGlyphsURL(e,t){if(!o(e))return e;const r=li(e);return r.path=`/fonts/v1${r.path}`,this._makeAPIURL(r,this._customAccessToken||t)}normalizeModelURL(e,t){if(!o(e))return e;const r=li(e);return r.path=`/models/v1${r.path}`,this._makeAPIURL(r,this._customAccessToken||t)}normalizeSourceURL(e,t,r,i){if(!o(e))return e;const n=li(e);return n.path=`/v4/${n.authority}.json`,n.params.push("secure"),r&&n.params.push(`language=${r}`),i&&n.params.push(`worldview=${i}`),this._makeAPIURL(n,this._customAccessToken||t)}normalizeSpriteURL(e,t,r,i){const n=li(e);return o(e)?(n.path=`/styles/v1${n.path}/sprite${t}${r}`,this._makeAPIURL(n,this._customAccessToken||i)):(n.path+=`${t}${r}`,ci(n))}normalizeTileURL(e,t,r){if(this._isSkuTokenExpired()&&this._createSkuToken(),e&&!o(e))return e;const n=li(e);n.path=n.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${t||r&&"raster"!==n.authority&&512===r?"@2x":""}${Ur.supported?".webp":"$1"}`),"raster"===n.authority?n.path=`/${i.RASTER_URL_PREFIX}${n.path}`:"rasterarrays"===n.authority?n.path=`/${i.RASTERARRAYS_URL_PREFIX}${n.path}`:(n.path=n.path.replace(/^.+\/v4\//,"/"),n.path=`/${i.TILE_URL_VERSION}${n.path}`);const s=this._customAccessToken||function(e){for(const t of e){const e=t.match(/^access_token=(.*)$/);if(e)return e[1]}return null}(n.params)||i.ACCESS_TOKEN;return i.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&n.params.push(`sku=${this._skuToken}`),this._makeAPIURL(n,s)}canonicalizeTileURL(e,t){const r=li(e);if(!r.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!r.path.match(/\.[\w]+$/))return e;let n="mapbox://";r.path.match(/^\/raster\/v1\//)?n+=`raster/${r.path.replace(`/${i.RASTER_URL_PREFIX}/`,"")}`:r.path.match(/^\/rasterarrays\/v1\//)?n+=`rasterarrays/${r.path.replace(`/${i.RASTERARRAYS_URL_PREFIX}/`,"")}`:n+=`tiles/${r.path.replace(`/${i.TILE_URL_VERSION}/`,"")}`;let o=r.params;return t&&(o=o.filter((e=>!e.match(/^access_token=/)))),o.length&&(n+=`?${o.join("&")}`),n}canonicalizeTileset(e,t){const r=!!t&&o(t),i=[];for(const t of e.tiles||[])n(t)?i.push(this.canonicalizeTileURL(t,r)):i.push(t);return i}_makeAPIURL(e,t){const r="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",n=li(i.API_URL);if(e.protocol=n.protocol,e.authority=n.authority,"http"===e.protocol){const t=e.params.indexOf("secure");t>=0&&e.params.splice(t,1)}if("/"!==n.path&&(e.path=`${n.path}${e.path}`),!i.REQUIRE_ACCESS_TOKEN)return ci(e);if(t=t||i.ACCESS_TOKEN,!this._silenceAuthErrors){if(!t)throw new Error(`An API access token is required to use Mapbox GL. ${r}`);if("s"===t[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${r}`)}return e.params=e.params.filter((e=>-1===e.indexOf("access_token"))),e.params.push(`access_token=${t||""}`),ci(e)}},e.dj=function(e,t){t?wi.add(e):wi.delete(e)},e.dk=Ur,e.dl=xi,e.dm=bi,e.dn=si,e.dp=Ai,e.dq=_i,e.dr=function(e){wi.delete(e)},e.ds=vi,e.dt=mi,e.du=t,e.dv=function(e,t){Rr=e,Fr=t},e.dw=function(e,t,r=!1){if(ka===Sa||ka===Ia||ka===Pa)throw new Error("setRTLTextPlugin cannot be called multiple times.");La=Dr.resolveURL(e),ka=Sa,Da=t,Oa(),r||Fa()},e.dx=Ra,e.dy=function(){b_().acquire(y_)},e.dz=function(){const e=v_;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(y_),v_=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()"))},e.e=Jt,e.e0=ja,e.e1=function(e){Vr(),Or&&Or.then((t=>{t.keys().then((r=>{for(let i=0;i<r.length-e;i++)t.delete(r[i])}))}))},e.f=Dr,e.g=function(e,t){return Kr(Jt(e,{type:"json"}),t)},e.h=id,e.i=class extends Kg{},e.j=Tn,e.k=Zi,e.l=function(e){return fetch(e).then((e=>e.arrayBuffer())).then((t=>Z_(t,0,e)))},e.m=Hs,e.n=Zs,e.o=ra,e.p=Km,e.q=el,e.r=sa,e.s=Ws,e.t=ia,e.u=Ja,e.v=Vo,e.w=hr,e.x=Uo,e.y=jo})),i(["./shared"],(function(e){function t(e){const t=e?e.url.toString():void 0;return t?performance.getEntriesByName(t):[]}function r(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e||null==e)return JSON.stringify(e);if(Array.isArray(e)){let t="[";for(const i of e)t+=`${r(i)},`;return`${t}]`}let t="{";for(const i of Object.keys(e).sort())t+=`${i}:${r(e[i])},`;return`${t}}`}function i(t){let i="";for(const n of e.b5)i+=`/${r(t[n])}`;return i}class n{constructor(e){this.keyCache={},this._layers={},this._layerConfigs={},e&&this.replace(e)}replace(e,t){this._layerConfigs={},this._layers={},this.update(e,[],t)}update(t,r,n){this._options=n;for(const r of t)this._layerConfigs[r.id]=r,(this._layers[r.id]=e.c7(r,this.scope,this._options)).compileFilter(),this.keyCache[r.id]&&delete this.keyCache[r.id];for(const e of r)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const o=function(e,t){const r={};for(let n=0;n<e.length;n++){const o=t&&t[e[n].id]||i(e[n]);t&&(t[e[n].id]=o);let s=r[o];s||(s=r[o]=[]),s.push(e[n])}const n=[];for(const e in r)n.push(r[e]);return n}(e.b2(this._layerConfigs),this.keyCache);for(const e of o){const t=e.map((e=>this._layers[e.id])),r=t[0];if("none"===r.visibility)continue;const i=r.source||"";let n=this.familiesBySource[i];n||(n=this.familiesBySource[i]={});const o=r.sourceLayer||"_geojsonTileLayer";let s=n[o];s||(s=n[o]=[]),s.push(t)}}}const o=1*e.dJ;class s{constructor(t){const r={},i=[];for(const e in t){const n=t[e],s=r[e]={};for(const e in n.glyphs){const t=n.glyphs[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const r=t.metrics.localGlyph?o:1,a={x:0,y:0,w:t.bitmap.width+2*r,h:t.bitmap.height+2*r};i.push(a),s[e]=a}}const{w:n,h:s}=e.p(i),a=new e.dI({width:n||1,height:s||1});for(const i in t){const n=t[i];for(const t in n.glyphs){const s=n.glyphs[+t];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=r[i][t],c=s.metrics.localGlyph?o:1;e.dI.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=r}}e.dH(s,"GlyphAtlas");class a{constructor(t){this.tileID=new e.ap(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.tileZoom=t.tileZoom,this.uid=t.uid,this.zoom=t.zoom,this.canonical=t.tileID.canonical,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.scope=t.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=t.showCollisionBoxes,this.collectResourceTiming=!!t.collectResourceTiming,this.promoteId=t.promoteId,this.isSymbolTile=t.isSymbolTile,this.tileTransform=e.av(t.tileID.canonical,t.projection),this.projection=t.projection,this.brightness=t.brightness,this.extraShadowCaster=!!t.extraShadowCaster}parse(t,r,i,n,o){this.status="parsing",this.data=t,this.collisionBoxArray=new e.aG;const a=new e.dK(Object.keys(t.layers).sort()),c=new e.dL(this.tileID,this.promoteId);c.bucketLayerIDs=[];const u={},h=new e.dM(256,256),d={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:h,availableImages:i,brightness:this.brightness},p=r.familiesBySource[this.source];for(const r in p){const n=t.layers[r];if(!n)continue;let o=!1,s=!1,h=!1;for(const e of p[r])"symbol"===e[0].type?o=!0:s=!0,e[0].is3D()&&"model"!==e[0].type&&(h=!0);if(this.extraShadowCaster&&!h)continue;if(!0===this.isSymbolTile&&!o)continue;if(!1===this.isSymbolTile&&!s)continue;1===n.version&&e.w(`Vector tile source "${this.source}" layer "${r}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const f=a.encode(r),m=[];for(let e=0;e<n.length;e++){const t=n.feature(e),i=c.getId(t,r);m.push({feature:t,id:i,index:e,sourceLayerIndex:f})}for(const e of p[r]){const t=e[0];(!this.extraShadowCaster||t.is3D()&&"model"!==t.type)&&(void 0!==this.isSymbolTile&&"symbol"===t.type!==this.isSymbolTile||t.minzoom&&this.zoom<Math.floor(t.minzoom)||t.maxzoom&&this.zoom>=t.maxzoom||"none"!==t.visibility&&(l(e,this.zoom,d.brightness,i),(u[t.id]=t.createBucket({index:c.bucketLayerIDs.length,layers:e,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:f,sourceID:this.source,projection:this.projection.spec})).populate(m,d,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(e.map((e=>e.id)))))}}let f,m,A,g;h.trim();const _={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},y=()=>{if(f)return this.status="done",o(f);if(this.extraShadowCaster)this.status="done",o(null,{buckets:e.b2(u).filter((e=>!e.isEmpty())),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:d.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(m&&A&&g){const t=new s(m),r=new e.dO(A,g);for(const n in u){const o=u[n];o instanceof e.aH?(l(o.layers,this.zoom,d.brightness,i),e.dP(o,m,t.positions,A,r.iconPositions,this.showCollisionBoxes,i,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):o.hasPattern&&(o instanceof e.aN||o instanceof e.aO||o instanceof e.cO)&&(l(o.layers,this.zoom,d.brightness,i),o.addFeatures(d,this.tileID.canonical,r.patternPositions,i,this.tileTransform,this.brightness))}this.status="done",o(null,{buckets:e.b2(u).filter((e=>!e.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:t.image,lineAtlas:h,imageAtlas:r,brightness:d.brightness})}};if(!this.extraShadowCaster){const t=e.dN(d.glyphDependencies,(e=>Object.keys(e).map(Number)));Object.keys(t).length?n.send("getGlyphs",{uid:this.uid,stacks:t,scope:this.scope},((e,t)=>{f||(f=e,m=t,y())}),void 0,!1,_):m={};const r=Object.keys(d.iconDependencies);r.length?n.send("getImages",{icons:r,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((e,t)=>{f||(f=e,A=t,y())}),void 0,!1,_):A={};const i=Object.keys(d.patternDependencies);i.length?n.send("getImages",{icons:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((e,t)=>{f||(f=e,g=t,y())}),void 0,!1,_):g={}}y()}}function l(t,r,i,n){const o=new e.N(r,{brightness:i});for(const e of t)e.recalculate(o,n)}class c extends e.E{constructor(t,r,i,n,o,s){super(),this.actor=t,this.layerIndex=r,this.availableImages=i,this.loadVectorData=o||e.ak,this.loading={},this.loaded={},this.deduped=new e.ai(t.scheduler),this.isSpriteLoaded=n,this.scheduler=t.scheduler,this.brightness=s}loadTile(r,i){const n=r.uid,o=r&&r.request,s=o&&o.collectResourceTiming,l=this.loading[n]=new a(r);l.abort=this.loadVectorData(r,((a,c)=>{const u=!this.loading[n];if(delete this.loading[n],u||a||!c)return l.status="done",u||(this.loaded[n]=l),i(a);const h=c.rawData,d={};c.expires&&(d.expires=c.expires),c.cacheControl&&(d.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new e.dQ(new e.dR(h));const p=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((r,n)=>{if(r||!n)return i(r);const a={};if(s){const e=t(o);e.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(e)))}i(null,e.e({rawTileData:h.slice(0)},n,d,a))}))};this.isSpriteLoaded?p():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:r.isSymbolTile,zoom:r.tileZoom}):p()})),this.loaded=this.loaded||{},this.loaded[n]=l}))}reloadTile(t,r){const i=this.loaded,n=t.uid,o=this;if(i&&i[n]){const s=i[n];s.showCollisionBoxes=t.showCollisionBoxes,s.projection=t.projection,s.brightness=t.brightness,s.tileTransform=e.av(t.tileID.canonical,t.projection),s.extraShadowCaster=t.extraShadowCaster;const a=(e,t)=>{const i=s.reloadCallback;i&&(delete s.reloadCallback,s.parse(s.vectorTile,o.layerIndex,this.availableImages,o.actor,i)),r(e,t)};"parsing"===s.status?s.reloadCallback=a:"done"===s.status&&(s.vectorTile?s.parse(s.vectorTile,this.layerIndex,this.availableImages,this.actor,a):a())}else r(null,void 0)}abortTile(e,t){const r=e.uid,i=this.loading[r];i&&(i.abort&&i.abort(),delete this.loading[r]),t()}removeTile(e,t){const r=this.loaded,i=e.uid;r&&r[i]&&delete r[i],t()}}class u{loadTile(t,r){const{uid:i,encoding:n,rawImageData:o,padding:s}=t,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;r(null,new e.dS(i,a,n,s<1))}getImageData(e,t){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(e.width,e.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=e.width,this.offscreenCanvas.height=e.height,this.offscreenCanvasContext.drawImage(e,0,0,e.width,e.height);const r=this.offscreenCanvasContext.getImageData(-t,-t,e.width+2*t,e.height+2*t);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),r}}class h{decodeRasterArray({task:t,buffer:r},i){e.b0.performDecoding(r,t).then((e=>{i(null,e)}),(e=>{i(e)}))}}const d=e.dT.prototype.toGeoJSON;let p=class{constructor(t){this._feature=t,this.extent=e.Y,this.type=t.type,this.properties=t.tags,"id"in t&&!isNaN(t.id)&&(this.id=parseInt(t.id,10))}loadGeometry(){if(1===this._feature.type){const t=[];for(const r of this._feature.geometry)t.push([new e.P(r[0],r[1])]);return t}{const t=[];for(const r of this._feature.geometry){const i=[];for(const t of r)i.push(new e.P(t[0],t[1]));t.push(i)}return t}}toGeoJSON(e,t,r){return d.call(this,e,t,r)}},f=class{constructor(t){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=e.Y,this.length=t.length,this._features=t}feature(e){return new p(this._features[e])}};var m={exports:{}},A=e.dV,g=e.dU.VectorTileFeature,_=y;function y(e,t){this.options=t||{},this.features=e,this.length=e.length}function x(e,t){this.id="number"==typeof e.id?e.id:void 0,this.type=e.type,this.rawGeometry=1===e.type?[e.geometry]:e.geometry,this.properties=e.tags,this.extent=t||4096}y.prototype.feature=function(e){return new x(this.features[e],this.options.extent)},x.prototype.loadGeometry=function(){var e=this.rawGeometry;this.geometry=[];for(var t=0;t<e.length;t++){for(var r=e[t],i=[],n=0;n<r.length;n++)i.push(new A(r[n][0],r[n][1]));this.geometry.push(i)}return this.geometry},x.prototype.bbox=function(){this.geometry||this.loadGeometry();for(var e=this.geometry,t=1/0,r=-1/0,i=1/0,n=-1/0,o=0;o<e.length;o++)for(var s=e[o],a=0;a<s.length;a++){var l=s[a];t=Math.min(t,l.x),r=Math.max(r,l.x),i=Math.min(i,l.y),n=Math.max(n,l.y)}return[t,i,r,n]},x.prototype.toGeoJSON=g.prototype.toGeoJSON;var v=e.dW,b=_;function w(e){var t=new v;return function(e,t){for(var r in e.layers)t.writeMessage(3,C,e.layers[r])}(e,t),t.finish()}function C(e,t){var r;t.writeVarintField(15,e.version||1),t.writeStringField(1,e.name||""),t.writeVarintField(5,e.extent||4096);var i={keys:[],values:[],keycache:{},valuecache:{}};for(r=0;r<e.length;r++)i.feature=e.feature(r),t.writeMessage(2,T,i);var n=i.keys;for(r=0;r<n.length;r++)t.writeStringField(3,n[r]);var o=i.values;for(r=0;r<o.length;r++)t.writeMessage(4,P,o[r])}function T(e,t){var r=e.feature;void 0!==r.id&&t.writeVarintField(1,r.id),t.writeMessage(2,E,e),t.writeVarintField(3,r.type),t.writeMessage(4,I,r)}function E(e,t){var r=e.feature,i=e.keys,n=e.values,o=e.keycache,s=e.valuecache;for(var a in r.properties){var l=r.properties[a],c=o[a];if(null!==l){void 0===c&&(i.push(a),o[a]=c=i.length-1),t.writeVarint(c);var u=typeof l;"string"!==u&&"boolean"!==u&&"number"!==u&&(l=JSON.stringify(l));var h=u+":"+l,d=s[h];void 0===d&&(n.push(l),s[h]=d=n.length-1),t.writeVarint(d)}}}function M(e,t){return(t<<3)+(7&e)}function S(e){return e<<1^e>>31}function I(e,t){for(var r=e.loadGeometry(),i=e.type,n=0,o=0,s=r.length,a=0;a<s;a++){var l=r[a],c=1;1===i&&(c=l.length),t.writeVarint(M(1,c));for(var u=3===i?l.length-1:l.length,h=0;h<u;h++){1===h&&1!==i&&t.writeVarint(M(2,u-1));var d=l[h].x-n,p=l[h].y-o;t.writeVarint(S(d)),t.writeVarint(S(p)),n+=d,o+=p}3===i&&t.writeVarint(M(7,1))}}function P(e,t){var r=typeof e;"string"===r?t.writeStringField(1,e):"boolean"===r?t.writeBooleanField(7,e):"number"===r&&(e%1!=0?t.writeDoubleField(3,e):e<0?t.writeSVarintField(6,e):t.writeVarintField(5,e))}m.exports=w,m.exports.fromVectorTileJs=w,m.exports.fromGeojsonVt=function(e,t){t=t||{};var r={};for(var i in e)r[i]=new b(e[i].features,t),r[i].name=i,r[i].version=t.version,r[i].extent=t.extent;return w({layers:r})},m.exports.GeoJSONWrapper=b;var D=e.dX(m.exports);const k={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:e=>e},L=Math.fround||(z=new Float32Array(1),e=>(z[0]=+e,z[0]));var z;const O=3,B=5,R=6;class F{constructor(e){this.options=Object.assign(Object.create(k),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(e){const{log:t,minZoom:r,maxZoom:i}=this.options;t&&console.time("total time");const n=`prepare ${e.length} points`;t&&console.time(n),this.points=e;const o=[];for(let t=0;t<e.length;t++){const r=e[t];if(!r.geometry)continue;const[i,n]=r.geometry.coordinates,s=L(N(i)),a=L(U(n));o.push(s,a,1/0,t,-1,1),this.options.reduce&&o.push(0)}let s=this.trees[i+1]=this._createTree(o);t&&console.timeEnd(n);for(let e=i;e>=r;e--){const r=+Date.now();s=this.trees[e]=this._createTree(this._cluster(s,e)),t&&console.log("z%d: %d clusters in %dms",e,s.numItems,+Date.now()-r)}return t&&console.timeEnd("total time"),this}getClusters(e,t){let r=((e[0]+180)%360+360)%360-180;const i=Math.max(-90,Math.min(90,e[1]));let n=180===e[2]?180:((e[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)r=-180,n=180;else if(r>n){const e=this.getClusters([r,i,180,o],t),s=this.getClusters([-180,i,n,o],t);return e.concat(s)}const s=this.trees[this._limitZoom(t)],a=s.range(N(r),U(o),N(n),U(i)),l=s.data,c=[];for(const e of a){const t=this.stride*e;c.push(l[t+B]>1?j(l,t,this.clusterProps):this.points[l[t+O]])}return c}getChildren(e){const t=this._getOriginId(e),r=this._getOriginZoom(e),i="No cluster with the specified id.",n=this.trees[r];if(!n)throw new Error(i);const o=n.data;if(t*this.stride>=o.length)throw new Error(i);const s=this.options.radius/(this.options.extent*Math.pow(2,r-1)),a=n.within(o[t*this.stride],o[t*this.stride+1],s),l=[];for(const t of a){const r=t*this.stride;o[r+4]===e&&l.push(o[r+B]>1?j(o,r,this.clusterProps):this.points[o[r+O]])}if(0===l.length)throw new Error(i);return l}getLeaves(e,t,r){const i=[];return this._appendLeaves(i,e,t=t||10,r=r||0,0),i}getTile(e,t,r){const i=this.trees[this._limitZoom(e)],n=Math.pow(2,e),{extent:o,radius:s}=this.options,a=s/o,l=(r-a)/n,c=(r+1+a)/n,u={features:[]};return this._addTileFeatures(i.range((t-a)/n,l,(t+1+a)/n,c),i.data,t,r,n,u),0===t&&this._addTileFeatures(i.range(1-a/n,l,1,c),i.data,n,r,n,u),t===n-1&&this._addTileFeatures(i.range(0,l,a/n,c),i.data,-1,r,n,u),u.features.length?u:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const r=this.getChildren(e);if(t++,1!==r.length)break;e=r[0].properties.cluster_id}return t}_appendLeaves(e,t,r,i,n){const o=this.getChildren(t);for(const t of o){const o=t.properties;if(o&&o.cluster?n+o.point_count<=i?n+=o.point_count:n=this._appendLeaves(e,o.cluster_id,r,i,n):n<i?n++:e.push(t),e.length===r)break}return n}_createTree(t){const r=new e.bj(t.length/this.stride|0,this.options.nodeSize,Float32Array);for(let e=0;e<t.length;e+=this.stride)r.add(t[e],t[e+1]);return r.finish(),r.data=t,r}_addTileFeatures(e,t,r,i,n,o){for(const s of e){const e=s*this.stride,a=t[e+B]>1;let l,c,u;if(a)l=V(t,e,this.clusterProps),c=t[e],u=t[e+1];else{const r=this.points[t[e+O]];l=r.properties;const[i,n]=r.geometry.coordinates;c=N(i),u=U(n)}const h={type:1,geometry:[[Math.round(this.options.extent*(c*n-r)),Math.round(this.options.extent*(u*n-i))]],tags:l};let d;d=a||this.options.generateId?t[e+O]:this.points[t[e+O]].id,void 0!==d&&(h.id=d),o.features.push(h)}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,t){const{radius:r,extent:i,reduce:n,minPoints:o}=this.options,s=r/(i*Math.pow(2,t)),a=e.data,l=[],c=this.stride;for(let r=0;r<a.length;r+=c){if(a[r+2]<=t)continue;a[r+2]=t;const i=a[r],u=a[r+1],h=e.within(a[r],a[r+1],s),d=a[r+B];let p=d;for(const e of h){const r=e*c;a[r+2]>t&&(p+=a[r+B])}if(p>d&&p>=o){let e,o=i*d,s=u*d,f=-1;const m=(r/c<<5)+(t+1)+this.points.length;for(const i of h){const l=i*c;if(a[l+2]<=t)continue;a[l+2]=t;const u=a[l+B];o+=a[l]*u,s+=a[l+1]*u,a[l+4]=m,n&&(e||(e=this._map(a,r,!0),f=this.clusterProps.length,this.clusterProps.push(e)),n(e,this._map(a,l)))}a[r+4]=m,l.push(o/p,s/p,1/0,m,-1,p),n&&l.push(f)}else{for(let e=0;e<c;e++)l.push(a[r+e]);if(p>1)for(const e of h){const r=e*c;if(!(a[r+2]<=t)){a[r+2]=t;for(let e=0;e<c;e++)l.push(a[r+e])}}}}return l}_getOriginId(e){return e-this.points.length>>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,t,r){if(e[t+B]>1){const i=this.clusterProps[e[t+R]];return r?Object.assign({},i):i}const i=this.points[e[t+O]].properties,n=this.options.map(i);return r&&n===i?Object.assign({},n):n}}function j(e,t,r){return{type:"Feature",id:e[t+O],properties:V(e,t,r),geometry:{type:"Point",coordinates:[(i=e[t],360*(i-.5)),H(e[t+1])]}};var i}function V(e,t,r){const i=e[t+B],n=i>=1e4?`${Math.round(i/1e3)}k`:i>=1e3?Math.round(i/100)/10+"k":i,o=e[t+R],s=-1===o?{}:Object.assign({},r[o]);return Object.assign(s,{cluster:!0,cluster_id:e[t+O],point_count:i,point_count_abbreviated:n})}function N(e){return e/360+.5}function U(e){const t=Math.sin(e*Math.PI/180),r=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return r<0?0:r>1?1:r}function H(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}var G={exports:{}};G.exports=function(){function e(r,i,n,o){for(var s,a=o,l=n-i>>1,c=n-i,u=r[i],h=r[i+1],d=r[n],p=r[n+1],f=i+3;f<n;f+=3){var m=t(r[f],r[f+1],u,h,d,p);if(m>a)s=f,a=m;else if(m===a){var A=Math.abs(f-l);A<c&&(s=f,c=A)}}a>o&&(s-i>3&&e(r,i,s,o),r[s+2]=a,n-s>3&&e(r,s,n,o))}function t(e,t,r,i,n,o){var s=n-r,a=o-i;if(0!==s||0!==a){var l=((e-r)*s+(t-i)*a)/(s*s+a*a);l>1?(r=n,i=o):l>0&&(r+=s*l,i+=a*l)}return(s=e-r)*s+(a=t-i)*a}function r(e,t,r,n){var o={id:void 0===e?null:e,type:t,geometry:r,tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(e){var t=e.geometry,r=e.type;if("Point"===r||"MultiPoint"===r||"LineString"===r)i(e,t);else if("Polygon"===r||"MultiLineString"===r)for(var n=0;n<t.length;n++)i(e,t[n]);else if("MultiPolygon"===r)for(n=0;n<t.length;n++)for(var o=0;o<t[n].length;o++)i(e,t[n][o])}(o),o}function i(e,t){for(var r=0;r<t.length;r+=3)e.minX=Math.min(e.minX,t[r]),e.minY=Math.min(e.minY,t[r+1]),e.maxX=Math.max(e.maxX,t[r]),e.maxY=Math.max(e.maxY,t[r+1])}function n(e,t,i,l){if(t.geometry){var c=t.geometry.coordinates,u=t.geometry.type,h=Math.pow(i.tolerance/((1<<i.maxZoom)*i.extent),2),d=[],p=t.id;if(i.promoteId?p=t.properties[i.promoteId]:i.generateId&&(p=l||0),"Point"===u)o(c,d);else if("MultiPoint"===u)for(var f=0;f<c.length;f++)o(c[f],d);else if("LineString"===u)s(c,d,h,!1);else if("MultiLineString"===u){if(i.lineMetrics){for(f=0;f<c.length;f++)s(c[f],d=[],h,!1),e.push(r(p,"LineString",d,t.properties));return}a(c,d,h,!1)}else if("Polygon"===u)a(c,d,h,!0);else{if("MultiPolygon"!==u){if("GeometryCollection"===u){for(f=0;f<t.geometry.geometries.length;f++)n(e,{id:p,geometry:t.geometry.geometries[f],properties:t.properties},i,l);return}throw new Error("Input data is not a valid GeoJSON object.")}for(f=0;f<c.length;f++){var m=[];a(c[f],m,h,!0),d.push(m)}}e.push(r(p,u,d,t.properties))}}function o(e,t){t.push(l(e[0])),t.push(c(e[1])),t.push(0)}function s(t,r,i,n){for(var o,s,a=0,u=0;u<t.length;u++){var h=l(t[u][0]),d=c(t[u][1]);r.push(h),r.push(d),r.push(0),u>0&&(a+=n?(o*d-h*s)/2:Math.sqrt(Math.pow(h-o,2)+Math.pow(d-s,2))),o=h,s=d}var p=r.length-3;r[2]=1,e(r,0,p,i),r[p+2]=1,r.size=Math.abs(a),r.start=0,r.end=r.size}function a(e,t,r,i){for(var n=0;n<e.length;n++){var o=[];s(e[n],o,r,i),t.push(o)}}function l(e){return e/360+.5}function c(e){var t=Math.sin(e*Math.PI/180),r=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return r<0?0:r>1?1:r}function u(e,t,i,n,o,s,a,l){if(n/=t,s>=(i/=t)&&a<n)return e;if(a<i||s>=n)return null;for(var c=[],u=0;u<e.length;u++){var p=e[u],m=p.geometry,A=p.type,g=0===o?p.minX:p.minY,_=0===o?p.maxX:p.maxY;if(g>=i&&_<n)c.push(p);else if(!(_<i||g>=n)){var y=[];if("Point"===A||"MultiPoint"===A)h(m,y,i,n,o);else if("LineString"===A)d(m,y,i,n,o,!1,l.lineMetrics);else if("MultiLineString"===A)f(m,y,i,n,o,!1);else if("Polygon"===A)f(m,y,i,n,o,!0);else if("MultiPolygon"===A)for(var x=0;x<m.length;x++){var v=[];f(m[x],v,i,n,o,!0),v.length&&y.push(v)}if(y.length){if(l.lineMetrics&&"LineString"===A){for(x=0;x<y.length;x++)c.push(r(p.id,A,y[x],p.tags));continue}"LineString"!==A&&"MultiLineString"!==A||(1===y.length?(A="LineString",y=y[0]):A="MultiLineString"),"Point"!==A&&"MultiPoint"!==A||(A=3===y.length?"Point":"MultiPoint"),c.push(r(p.id,A,y,p.tags))}}}return c.length?c:null}function h(e,t,r,i,n){for(var o=0;o<e.length;o+=3){var s=e[o+n];s>=r&&s<=i&&(t.push(e[o]),t.push(e[o+1]),t.push(e[o+2]))}}function d(e,t,r,i,n,o,s){for(var a,l,c=p(e),u=0===n?A:g,h=e.start,d=0;d<e.length-3;d+=3){var f=e[d],_=e[d+1],y=e[d+2],x=e[d+3],v=e[d+4],b=0===n?f:_,w=0===n?x:v,C=!1;s&&(a=Math.sqrt(Math.pow(f-x,2)+Math.pow(_-v,2))),b<r?w>r&&(l=u(c,f,_,x,v,r),s&&(c.start=h+a*l)):b>i?w<i&&(l=u(c,f,_,x,v,i),s&&(c.start=h+a*l)):m(c,f,_,y),w<r&&b>=r&&(l=u(c,f,_,x,v,r),C=!0),w>i&&b<=i&&(l=u(c,f,_,x,v,i),C=!0),!o&&C&&(s&&(c.end=h+a*l),t.push(c),c=p(e)),s&&(h+=a)}var T=e.length-3;f=e[T],_=e[T+1],y=e[T+2],(b=0===n?f:_)>=r&&b<=i&&m(c,f,_,y),T=c.length-3,o&&T>=3&&(c[T]!==c[0]||c[T+1]!==c[1])&&m(c,c[0],c[1],c[2]),c.length&&t.push(c)}function p(e){var t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function f(e,t,r,i,n,o){for(var s=0;s<e.length;s++)d(e[s],t,r,i,n,o,!1)}function m(e,t,r,i){e.push(t),e.push(r),e.push(i)}function A(e,t,r,i,n,o){var s=(o-t)/(i-t);return e.push(o),e.push(r+(n-r)*s),e.push(1),s}function g(e,t,r,i,n,o){var s=(o-r)/(n-r);return e.push(t+(i-t)*s),e.push(o),e.push(1),s}function _(e,t){for(var i=[],n=0;n<e.length;n++){var o,s=e[n],a=s.type;if("Point"===a||"MultiPoint"===a||"LineString"===a)o=y(s.geometry,t);else if("MultiLineString"===a||"Polygon"===a){o=[];for(var l=0;l<s.geometry.length;l++)o.push(y(s.geometry[l],t))}else if("MultiPolygon"===a)for(o=[],l=0;l<s.geometry.length;l++){for(var c=[],u=0;u<s.geometry[l].length;u++)c.push(y(s.geometry[l][u],t));o.push(c)}i.push(r(s.id,a,o,s.tags))}return i}function y(e,t){var r=[];r.size=e.size,void 0!==e.start&&(r.start=e.start,r.end=e.end);for(var i=0;i<e.length;i+=3)r.push(e[i]+t,e[i+1],e[i+2]);return r}function x(e,t){if(e.transformed)return e;var r,i,n,o=1<<e.z,s=e.x,a=e.y;for(r=0;r<e.features.length;r++){var l=e.features[r],c=l.geometry,u=l.type;if(l.geometry=[],1===u)for(i=0;i<c.length;i+=2)l.geometry.push(v(c[i],c[i+1],t,o,s,a));else for(i=0;i<c.length;i++){var h=[];for(n=0;n<c[i].length;n+=2)h.push(v(c[i][n],c[i][n+1],t,o,s,a));l.geometry.push(h)}}return e.transformed=!0,e}function v(e,t,r,i,n,o){return[Math.round(r*(e*i-n)),Math.round(r*(t*i-o))]}function b(e,t,r,i,n){for(var o=t===n.maxZoom?0:n.tolerance/((1<<t)*n.extent),s={features:[],numPoints:0,numSimplified:0,numFeatures:0,source:null,x:r,y:i,z:t,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0},a=0;a<e.length;a++){s.numFeatures++,w(s,e[a],o,n);var l=e[a].minX,c=e[a].minY,u=e[a].maxX,h=e[a].maxY;l<s.minX&&(s.minX=l),c<s.minY&&(s.minY=c),u>s.maxX&&(s.maxX=u),h>s.maxY&&(s.maxY=h)}return s}function w(e,t,r,i){var n=t.geometry,o=t.type,s=[];if("Point"===o||"MultiPoint"===o)for(var a=0;a<n.length;a+=3)s.push(n[a]),s.push(n[a+1]),e.numPoints++,e.numSimplified++;else if("LineString"===o)C(s,n,e,r,!1,!1);else if("MultiLineString"===o||"Polygon"===o)for(a=0;a<n.length;a++)C(s,n[a],e,r,"Polygon"===o,0===a);else if("MultiPolygon"===o)for(var l=0;l<n.length;l++){var c=n[l];for(a=0;a<c.length;a++)C(s,c[a],e,r,!0,0===a)}if(s.length){var u=t.tags||null;if("LineString"===o&&i.lineMetrics){for(var h in u={},t.tags)u[h]=t.tags[h];u.mapbox_clip_start=n.start/n.size,u.mapbox_clip_end=n.end/n.size}var d={geometry:s,type:"Polygon"===o||"MultiPolygon"===o?3:"LineString"===o||"MultiLineString"===o?2:1,tags:u};null!==t.id&&(d.id=t.id),e.features.push(d)}}function C(e,t,r,i,n,o){var s=i*i;if(i>0&&t.size<(n?s:i))r.numPoints+=t.length/3;else{for(var a=[],l=0;l<t.length;l+=3)(0===i||t[l+2]>s)&&(r.numSimplified++,a.push(t[l]),a.push(t[l+1])),r.numPoints++;n&&function(e,t){for(var r=0,i=0,n=e.length,o=n-2;i<n;o=i,i+=2)r+=(e[i]-e[o])*(e[i+1]+e[o+1]);if(r>0===t)for(i=0,n=e.length;i<n/2;i+=2){var s=e[i],a=e[i+1];e[i]=e[n-2-i],e[i+1]=e[n-1-i],e[n-2-i]=s,e[n-1-i]=a}}(a,o),e.push(a)}}function T(e,t){var r=(t=this.options=function(e,t){for(var r in t)e[r]=t[r];return e}(Object.create(this.options),t)).debug;if(r&&console.time("preprocess data"),t.maxZoom<0||t.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(t.promoteId&&t.generateId)throw new Error("promoteId and generateId cannot be used together.");var i=function(e,t){var r=[];if("FeatureCollection"===e.type)for(var i=0;i<e.features.length;i++)n(r,e.features[i],t,i);else n(r,"Feature"===e.type?e:{geometry:e},t);return r}(e,t);this.tiles={},this.tileCoords=[],r&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",t.indexMaxZoom,t.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),(i=function(e,t){var r=t.buffer/t.extent,i=e,n=u(e,1,-1-r,r,0,-1,2,t),o=u(e,1,1-r,2+r,0,-1,2,t);return(n||o)&&(i=u(e,1,-r,1+r,0,-1,2,t)||[],n&&(i=_(n,1).concat(i)),o&&(i=i.concat(_(o,-1)))),i}(i,t)).length&&this.splitTile(i,0,0,0),r&&(i.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}function E(e,t,r){return 32*((1<<e)*r+t)+e}return T.prototype.options={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0},T.prototype.splitTile=function(e,t,r,i,n,o,s){for(var a=[e,t,r,i],l=this.options,c=l.debug;a.length;){i=a.pop(),r=a.pop(),t=a.pop(),e=a.pop();var h=1<<t,d=E(t,r,i),p=this.tiles[d];if(!p&&(c>1&&console.time("creation"),p=this.tiles[d]=b(e,t,r,i,l),this.tileCoords.push({z:t,x:r,y:i}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,r,i,p.numFeatures,p.numPoints,p.numSimplified),console.timeEnd("creation"));var f="z"+t;this.stats[f]=(this.stats[f]||0)+1,this.total++}if(p.source=e,n){if(t===l.maxZoom||t===n)continue;var m=1<<n-t;if(r!==Math.floor(o/m)||i!==Math.floor(s/m))continue}else if(t===l.indexMaxZoom||p.numPoints<=l.indexMaxPoints)continue;if(p.source=null,0!==e.length){c>1&&console.time("clipping");var A,g,_,y,x,v,w=.5*l.buffer/l.extent,C=.5-w,T=.5+w,M=1+w;A=g=_=y=null,x=u(e,h,r-w,r+T,0,p.minX,p.maxX,l),v=u(e,h,r+C,r+M,0,p.minX,p.maxX,l),e=null,x&&(A=u(x,h,i-w,i+T,1,p.minY,p.maxY,l),g=u(x,h,i+C,i+M,1,p.minY,p.maxY,l),x=null),v&&(_=u(v,h,i-w,i+T,1,p.minY,p.maxY,l),y=u(v,h,i+C,i+M,1,p.minY,p.maxY,l),v=null),c>1&&console.timeEnd("clipping"),a.push(A||[],t+1,2*r,2*i),a.push(g||[],t+1,2*r,2*i+1),a.push(_||[],t+1,2*r+1,2*i),a.push(y||[],t+1,2*r+1,2*i+1)}}},T.prototype.getTile=function(e,t,r){var i=this.options,n=i.extent,o=i.debug;if(e<0||e>24)return null;var s=1<<e,a=E(e,t=(t%s+s)%s,r);if(this.tiles[a])return x(this.tiles[a],n);o>1&&console.log("drilling down to z%d-%d-%d",e,t,r);for(var l,c=e,u=t,h=r;!l&&c>0;)c--,u=Math.floor(u/2),h=Math.floor(h/2),l=this.tiles[E(c,u,h)];return l&&l.source?(o>1&&console.log("found parent tile z%d-%d-%d",c,u,h),o>1&&console.time("drilling down"),this.splitTile(l.source,c,u,h,e,t,r),o>1&&console.timeEnd("drilling down"),this.tiles[a]?x(this.tiles[a],n):null):null},function(e,t){return new T(e,t)}}();var Z=e.dX(G.exports);function W(e,t){const r=e.tileID.canonical;if(!this._geoJSONIndex)return t(null,null);const i=this._geoJSONIndex.getTile(r.z,r.x,r.y);if(!i)return t(null,null);const n=new f(i.features);let o=D(n);0===o.byteOffset&&o.byteLength===o.buffer.byteLength||(o=new Uint8Array(o)),t(null,{vectorTile:n,rawData:o.buffer})}class Q extends c{constructor(e,t,r,i,n,o){super(e,t,r,i,W,o),n&&(this.loadGeoJSON=n),this._featureMap=new Map}loadData(r,i){const n=r&&r.request,o=n&&n.collectResourceTiming;this.loadGeoJSON(r,((s,a)=>{if(s||!a)return i(s);if("object"!=typeof a)return i(new Error(`Input data given to '${r.source}' is not a valid GeoJSON object.`));{try{if(r.filter){const t=e.t(r.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===t.result)throw new Error(t.value.map((e=>`${e.key}: ${e.message}`)).join(", "));a.features=a.features.filter((e=>t.value.evaluate({zoom:0},e)))}if(r.dynamic){"Feature"===a.type&&(a={type:"FeatureCollection",features:[a]}),r.append||this._featureMap.clear();for(const e of a.features||[]){const t=e.id;void 0!==t&&(e.geometry?this._featureMap.set(t,e):this._featureMap.delete(t))}a.features=[...this._featureMap.values()]}this._geoJSONIndex=r.cluster?new F(function({superclusterOptions:t,clusterProperties:r}){if(!r||!t)return t;const i={},n={},o={accumulated:null,zoom:0},s={properties:null},a=Object.keys(r);for(const t of a){const[o,s]=r[t],a=e.t(s),l=e.t("string"==typeof o?[o,["accumulated"],["get",t]]:o);i[t]=a.value,n[t]=l.value}return t.map=e=>{s.properties=e;const t={};for(const e of a)t[e]=i[e].evaluate(o,s);return t},t.reduce=(e,t)=>{s.properties=t;for(const t of a)o.accumulated=e[t],e[t]=n[t].evaluate(o,s)},t}(r)).load(a.features):Z(a,r.geojsonVtOptions)}catch(s){return i(s)}this.loaded={};const l={};if(o){const e=t(n);e&&(l.resourceTiming={},l.resourceTiming[r.source]=JSON.parse(JSON.stringify(e)))}i(null,l)}}))}reloadTile(e,t){const r=this.loaded;return r&&r[e.uid]?super.reloadTile(e,t):this.loadTile(e,t)}loadGeoJSON(t,r){if(t.request)e.g(t.request,r);else{if("string"!=typeof t.data)return r(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));try{return r(null,JSON.parse(t.data))}catch(e){return r(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(e,t){try{t(null,this._geoJSONIndex.getClusterExpansionZoom(e.clusterId))}catch(e){t(e)}}getClusterChildren(e,t){try{t(null,this._geoJSONIndex.getChildren(e.clusterId))}catch(e){t(e)}}getClusterLeaves(e,t){try{t(null,this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset))}catch(e){t(e)}}}class q{constructor(t,r){this.tileID=new e.ap(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.tileZoom=t.tileZoom,this.uid=t.uid,this.zoom=t.zoom,this.canonical=t.tileID.canonical,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.overscaling=this.tileID.overscaleFactor(),this.projection=t.projection,this.brightness=r}parse(t,r,i,n){this.status="parsing";const o=new e.ap(i.tileID.overscaledZ,i.tileID.wrap,i.tileID.canonical.z,i.tileID.canonical.x,i.tileID.canonical.y),s={},a=r.familiesBySource[i.source],l=new e.dL(o,i.promoteId);return l.bucketLayerIDs=[],l.is3DTile=!0,e.dY(t).then((t=>{if(!t)return n(new Error("Could not parse tile"));const r=e.dZ(t,1/e.bU(i.tileID.canonical)),c=t.json.extensionsUsed&&t.json.extensionsUsed.includes("MAPBOX_mesh_features")||t.json.asset.extras&&t.json.asset.extras.MAPBOX_mesh_features,u=t.json.extensionsUsed&&t.json.extensionsUsed.includes("EXT_meshopt_compression"),h=new e.N(this.zoom,{brightness:this.brightness});for(const t in a)for(const i of a[t]){const t=i[0];l.bucketLayerIDs.push(i.map((e=>e.id))),t.recalculate(h,[]);const n=new e.d_(r,o,c,u,this.brightness,l);c||(n.needsUpload=!0),s[t.fqid]=n,n.evaluate(t)}this.status="done",n(null,{buckets:s,featureIndex:l})})).catch((e=>n(new Error(e.message))))}}class X{constructor(e,t,r,i,n,o){this.actor=e,this.layerIndex=t,this.brightness=o,this.loading={},this.loaded={}}loadTile(t,r){const i=t.uid,n=this.loading[i]=new q(t,this.brightness);e.b1(t.request,((e,o)=>{const s=!this.loading[i];return delete this.loading[i],s||e?(n.status="done",s||(this.loaded[i]=n),r(e)):o&&0!==o.byteLength?void n.parse(o,this.layerIndex,t,((e,t)=>{n.status="done",this.loaded=this.loaded||{},this.loaded[i]=n,e||!t?r(e):r(null,t)})):(n.status="done",this.loaded[i]=n,r())}))}reloadTile(e,t){const r=this.loaded,i=e.uid;if(r&&r[i]){const n=r[i];n.projection=e.projection,n.brightness=e.brightness;const o=(r,i)=>{n.reloadCallback&&(delete n.reloadCallback,this.loadTile(e,t)),t(r,i)};"parsing"===n.status?n.reloadCallback=o:"done"===n.status&&this.loadTile(e,t)}}abortTile(e,t){const r=e.uid;this.loading[r]&&delete this.loading[r],t()}removeTile(e,t){const r=this.loaded,i=e.uid;r&&r[i]&&delete r[i],t()}}class Y{constructor(t){this.self=t,this.actor=new e.d$(t,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=e.br({name:"mercator"}),this.workerSourceTypes={vector:c,geojson:Q,"batched-model":X},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(e,t)=>{if(this.workerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.workerSourceTypes[e]=t},this.self.registerRTLTextPlugin=t=>{if(e.e0.isParsed())throw new Error("RTL text plugin already registered.");e.e0.applyArabicShaping=t.applyArabicShaping,e.e0.processBidirectionalText=t.processBidirectionalText,e.e0.processStyledBidirectionalText=t.processStyledBidirectionalText}}clearCaches(e,t,r){delete this.layerIndexes[e],delete this.availableImages[e],delete this.workerSources[e],delete this.demWorkerSources[e],delete this.rasterArrayWorkerSource,r()}checkIfReady(e,t,r){r()}setReferrer(e,t){this.referrer=t}spriteLoaded(t,{scope:r,isLoaded:i}){if(this.isSpriteLoaded[t]||(this.isSpriteLoaded[t]={}),this.isSpriteLoaded[t][r]=i,this.workerSources[t]&&this.workerSources[t][r])for(const n in this.workerSources[t][r]){const o=this.workerSources[t][r][n];for(const t in o)o[t]instanceof c&&(o[t].isSpriteLoaded=i,o[t].fire(new e.b("isSpriteLoaded")))}}setImages(e,{scope:t,images:r},i){if(this.availableImages[e]||(this.availableImages[e]={}),this.availableImages[e][t]=r,this.workerSources[e]&&this.workerSources[e][t]){for(const i in this.workerSources[e][t]){const n=this.workerSources[e][t][i];for(const e in n)n[e].availableImages=r}i()}else i()}setProjection(t,r){this.projections[t]=e.br(r)}setBrightness(e,t,r){this.brightness=t,r()}setLayers(e,t,r){this.getLayerIndex(e,t.scope).replace(t.layers,t.options),r()}updateLayers(e,t,r){this.getLayerIndex(e,t.scope).update(t.layers,t.removedIds,t.options),r()}loadTile(e,t,r){t.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t.type,t.source,t.scope).loadTile(t,r)}loadDEMTile(e,t,r){this.getDEMWorkerSource(e,t.source,t.scope).loadTile(t,r)}decodeRasterArray(e,t,r){this.getRasterArrayWorkerSource().decodeRasterArray(t,r)}reloadTile(e,t,r){t.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t.type,t.source,t.scope).reloadTile(t,r)}abortTile(e,t,r){this.getWorkerSource(e,t.type,t.source,t.scope).abortTile(t,r)}removeTile(e,t,r){this.getWorkerSource(e,t.type,t.source,t.scope).removeTile(t,r)}removeSource(e,t,r){if(!(this.workerSources[e]&&this.workerSources[e][t.scope]&&this.workerSources[e][t.scope][t.type]&&this.workerSources[e][t.scope][t.type][t.source]))return;const i=this.workerSources[e][t.scope][t.type][t.source];delete this.workerSources[e][t.scope][t.type][t.source],void 0!==i.removeSource?i.removeSource(t,r):r()}loadWorkerSource(e,t,r){try{this.self.importScripts(t.url),r()}catch(e){r(e.toString())}}syncRTLPluginState(t,r,i){try{e.e0.setState(r);const t=e.e0.getPluginURL();if(e.e0.isLoaded()&&!e.e0.isParsed()&&null!=t){this.self.importScripts(t);const r=e.e0.isParsed();i(r?void 0:new Error(`RTL Text Plugin failed to import scripts from ${t}`),r)}}catch(e){i(e.toString())}}setDracoUrl(e,t){this.dracoUrl=t}getAvailableImages(e,t){this.availableImages[e]||(this.availableImages[e]={});let r=this.availableImages[e][t];return r||(r=[]),r}getLayerIndex(e,t){this.layerIndexes[e]||(this.layerIndexes[e]={});let r=this.layerIndexes[e][t];return r||(r=this.layerIndexes[e][t]=new n,r.scope=t),r}getWorkerSource(e,t,r,i){if(this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][i]||(this.workerSources[e][i]={}),this.workerSources[e][i][t]||(this.workerSources[e][i][t]={}),this.isSpriteLoaded[e]||(this.isSpriteLoaded[e]={}),!this.workerSources[e][i][t][r]){const n={send:(t,r,i,n,o,s)=>{this.actor.send(t,r,i,e,o,s)},scheduler:this.actor.scheduler};this.workerSources[e][i][t][r]=new this.workerSourceTypes[t](n,this.getLayerIndex(e,i),this.getAvailableImages(e,i),this.isSpriteLoaded[e][i],void 0,this.brightness)}return this.workerSources[e][i][t][r]}getDEMWorkerSource(e,t,r){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][r]||(this.demWorkerSources[e][r]={}),this.demWorkerSources[e][r][t]||(this.demWorkerSources[e][r][t]=new u),this.demWorkerSources[e][r][t]}getRasterArrayWorkerSource(){return this.rasterArrayWorkerSource||(this.rasterArrayWorkerSource=new h),this.rasterArrayWorkerSource}enforceCacheSizeLimit(t,r){e.e1(r)}getWorkerPerformanceMetrics(e,t,r){r(void 0,void 0)}}return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new Y(self)),Y})),i(["./shared"],(function(e){function t(e,r){if(Array.isArray(e)){if(!Array.isArray(r)||e.length!==r.length)return!1;for(let i=0;i<e.length;i++)if(!t(e[i],r[i]))return!1;return!0}if("object"==typeof e&&null!==e&&null!==r){if("object"!=typeof r)return!1;if(Object.keys(e).length!==Object.keys(r).length)return!1;for(const i in e)if(!t(e[i],r[i]))return!1;return!0}return e===r}var r=i;function i(e){return!function(e){return"undefined"==typeof window||"undefined"==typeof document?"not a browser":function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var e,t,r=new Blob([""],{type:"text/javascript"}),i=URL.createObjectURL(r);try{t=new Worker(i),e=!0}catch(t){e=!1}return t&&t.terminate(),URL.revokeObjectURL(i),e}()?function(){var e=document.createElement("canvas");e.width=e.height=1;var t=e.getContext("2d");if(!t)return!1;var r=t.getImageData(0,0,1,1);return r&&r.width===e.width}()?(void 0===n[t=e&&e.failIfMajorPerformanceCaveat]&&(n[t]=function(e){var t,r=function(e){var t=document.createElement("canvas"),r=Object.create(i.webGLContextAttributes);return r.failIfMajorPerformanceCaveat=e,t.getContext("webgl2",r)}(e);if(!r)return!1;try{t=r.createShader(r.VERTEX_SHADER)}catch(e){return!1}return!(!t||r.isContextLost())&&(r.shaderSource(t,"void main() {}"),r.compileShader(t),!0===r.getShaderParameter(t,r.COMPILE_STATUS))}(t)),n[t]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL2 support"):"insufficient Canvas/getImageData support":"insufficient worker support";var t}(e)}var n={};function o(e,t,r){const i=document.createElement(e);return null!=t&&(i.className=t),r&&r.appendChild(i),i}function s(e,t,r){const i=document.createElementNS("http://www.w3.org/2000/svg",e);for(const e of Object.keys(t))i.setAttributeNS(null,e,String(t[e]));return r&&r.appendChild(i),i}i.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0};const a="undefined"!=typeof document?document.documentElement&&document.documentElement.style:null,l=a&&void 0!==a.userSelect?"userSelect":"WebkitUserSelect";let c;function u(){a&&l&&(c=a[l],a[l]="none")}function h(){a&&l&&(a[l]=c)}function d(e){e.preventDefault(),e.stopPropagation(),window.removeEventListener("click",d,!0)}function p(){window.addEventListener("click",d,!0),window.setTimeout((()=>{window.removeEventListener("click",d,!0)}),0)}function f(e,t){const r=e.getBoundingClientRect();return g(e,r,t)}function m(e,t){const r=e.getBoundingClientRect(),i=[];for(let n=0;n<t.length;n++)i.push(g(e,r,t[n]));return i}function A(e){return void 0!==window.InstallTrigger&&2===e.button&&e.ctrlKey&&window.navigator.platform.toUpperCase().indexOf("MAC")>=0?0:e.button}function g(t,r,i){const n=t.offsetWidth===r.width?1:t.offsetWidth/r.width;return new e.P((i.clientX-r.left)*n,(i.clientY-r.top)*n)}class _{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(e,t){this._updatedSourceCaches[e]=t,this.setDirty()}discardSourceCacheUpdate(e){delete this._updatedSourceCaches[e]}updateLayer(e){const t=e.scope;this._updatedLayers[t]=this._updatedLayers[t]||new Set,this._updatedLayers[t].add(e.id),this.setDirty()}removeLayer(e){const t=e.scope;this._removedLayers[t]=this._removedLayers[t]||{},this._updatedLayers[t]=this._updatedLayers[t]||new Set,this._removedLayers[t][e.id]=e,this._updatedLayers[t].delete(e.id),this._updatedPaintProps.delete(e.fqid),this.setDirty()}getRemovedLayer(e){return this._removedLayers[e.scope]?this._removedLayers[e.scope][e.id]:null}discardLayerRemoval(e){this._removedLayers[e.scope]&&delete this._removedLayers[e.scope][e.id]}getLayerUpdatesByScope(){const e={};for(const t in this._updatedLayers)e[t]=e[t]||{},e[t].updatedIds=Array.from(this._updatedLayers[t].values());for(const t in this._removedLayers)e[t]=e[t]||{},e[t].removedIds=Object.keys(this._removedLayers[t]);return e}getUpdatedPaintProperties(){return this._updatedPaintProps}updatePaintProperties(e){this._updatedPaintProps.add(e.fqid),this.setDirty()}getUpdatedImages(){return Array.from(this._updatedImages.values())}updateImage(e){this._updatedImages.add(e),this.setDirty()}resetUpdatedImages(){this._updatedImages.clear()}reset(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps.clear(),this._updatedImages.clear()}}class y extends e.E{constructor(e){super(),this.requestManager=e,this.models={"":{}},this.numModelsLoading={}}loadModel(t,r){return e.l(this.requestManager.transformRequest(r,e.R.Model).url).then((r=>{if(!r)return;const i=e.c(r),n=new e.M(t,void 0,void 0,i);return n.computeBoundsAndApplyParent(),n})).catch((i=>{if(i&&404===i.status)return null;this.fire(new e.a(new Error(`Could not load model ${t} from ${r}: ${i.message}`)))}))}load(t,r){this.models[r]||(this.models[r]={});const i=Object.keys(t);this.numModelsLoading[r]=(this.numModelsLoading[r]||0)+i.length;const n=[];for(const e of i)n.push(this.loadModel(e,t[e]));Promise.allSettled(n).then((t=>{for(let e=0;e<t.length;e++){const{status:n,value:o}=t[e];"fulfilled"===n&&o&&(this.models[r][i[e]]={model:o,numReferences:1})}this.numModelsLoading[r]-=i.length,this.fire(new e.b("data",{dataType:"style"}))})).catch((t=>{this.fire(new e.a(new Error(`Could not load models: ${t.message}`)))}))}isLoaded(){for(const e in this.numModelsLoading)if(this.numModelsLoading[e]>0)return!1;return!0}hasModel(e,t){return!!this.getModel(e,t)}getModel(e,t){return this.models[t]||(this.models[t]={}),this.models[t][e]?this.models[t][e].model:void 0}addModel(e,t,r){this.models[r]||(this.models[r]={}),this.hasModel(e,r)&&this.models[r][e].numReferences++,this.load({[e]:this.requestManager.normalizeModelURL(t)},r)}addModels(e,t){this.models[t]||(this.models[t]={});const r={};for(const i in e)this.models[t][i]={},r[i]=this.requestManager.normalizeModelURL(e[i]);this.load(r,t)}addModelsFromBucket(e,t){this.models[t]||(this.models[t]={});const r={};for(const i of e)this.hasModel(i,t)?this.models[t][i].numReferences++:r[i]=this.requestManager.normalizeModelURL(i);this.load(r,t)}removeModel(e,t){if(this.models[t]&&this.models[t][e]&&(this.models[t][e].numReferences--,0===this.models[t][e].numReferences)){const r=this.models[t][e].model;delete this.models[t][e],r.destroy()}}listModels(e){return this.models[e]||(this.models[e]={}),Object.keys(this.models[e])}upload(e,t){this.models[t]||(this.models[t]={});for(const r in this.models[t])this.models[t][r].model&&this.models[t][r].model.upload(e.context)}}class x{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,r,i){const n=String(r);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][n]=this.stateChanges[t][n]||{},e.e(this.stateChanges[t][n],i),null===this.deletedStates[t]){this.deletedStates[t]={};for(const e in this.state[t])e!==n&&(this.deletedStates[t][e]=null)}else if(this.deletedStates[t]&&null===this.deletedStates[t][n]){this.deletedStates[t][n]={};for(const e in this.state[t][n])i[e]||(this.deletedStates[t][n][e]=null)}else for(const e in i)this.deletedStates[t]&&this.deletedStates[t][n]&&null===this.deletedStates[t][n][e]&&delete this.deletedStates[t][n][e]}removeFeatureState(e,t,r){if(null===this.deletedStates[e])return;const i=String(t);if(this.deletedStates[e]=this.deletedStates[e]||{},r&&void 0!==t)null!==this.deletedStates[e][i]&&(this.deletedStates[e][i]=this.deletedStates[e][i]||{},this.deletedStates[e][i][r]=null);else if(void 0!==t)if(this.stateChanges[e]&&this.stateChanges[e][i])for(r in this.deletedStates[e][i]={},this.stateChanges[e][i])this.deletedStates[e][i][r]=null;else this.deletedStates[e][i]=null;else this.deletedStates[e]=null}getState(t,r){const i=String(r),n=e.e({},(this.state[t]||{})[i],(this.stateChanges[t]||{})[i]);if(null===this.deletedStates[t])return{};if(this.deletedStates[t]){const e=this.deletedStates[t][r];if(null===e)return{};for(const t in e)delete n[t]}return n}initializeTileState(e,t){e.setFeatureState(this.state,t)}coalesceChanges(t,r){const i={};for(const t in this.stateChanges){this.state[t]=this.state[t]||{};const r={};for(const i in this.stateChanges[t])this.state[t][i]||(this.state[t][i]={}),e.e(this.state[t][i],this.stateChanges[t][i]),r[i]=this.state[t][i];i[t]=r}for(const t in this.deletedStates){this.state[t]=this.state[t]||{};const r={};if(null===this.deletedStates[t])for(const e in this.state[t])r[e]={},this.state[t][e]={};else for(const e in this.deletedStates[t]){if(null===this.deletedStates[t][e])this.state[t][e]={};else if(this.state[t][e])for(const r of Object.keys(this.deletedStates[t][e]))delete this.state[t][e][r];r[e]=this.state[t][e]}i[t]=i[t]||{},e.e(i[t],r)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(i).length)for(const e in t)t[e].setFeatureState(i,r)}}function v(e){const{userImage:t}=e;return!!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}class b extends e.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 e.h({width:1,height:1})}isLoaded(){for(const e in this.loaded)if(!this.loaded[e])return!1;return!0}setLoaded(e,t){if(this.loaded[t]!==e&&(this.loaded[t]=e,e)){for(const{ids:e,callback:r}of this.requestors)this._notify(e,t,r);this.requestors=[]}}hasImage(e,t){return!!this.getImage(e,t)}getImage(e,t){return this.images[t][e]}addImage(e,t,r){this._validate(e,r)&&(this.images[t][e]=r)}_validate(t,r){let i=!0;return this._validateStretch(r.stretchX,r.data&&r.data.width)||(this.fire(new e.a(new Error(`Image "${t}" has invalid "stretchX" value`))),i=!1),this._validateStretch(r.stretchY,r.data&&r.data.height)||(this.fire(new e.a(new Error(`Image "${t}" has invalid "stretchY" value`))),i=!1),this._validateContent(r.content,r)||(this.fire(new e.a(new Error(`Image "${t}" has invalid "content" value`))),i=!1),i}_validateStretch(e,t){if(!e)return!0;let r=0;for(const i of e){if(i[0]<r||i[1]<i[0]||t<i[1])return!1;r=i[1]}return!0}_validateContent(e,t){return!(e&&(4!==e.length||e[0]<0||t.data.width<e[0]||e[1]<0||t.data.height<e[1]||e[2]<0||t.data.width<e[2]||e[3]<0||t.data.height<e[3]||e[2]<e[0]||e[3]<e[1]))}updateImage(e,t,r){r.version=this.images[t][e].version+1,this.images[t][e]=r,this.updatedImages[t][e]=!0}removeImage(e,t){const r=this.images[t][e];delete this.images[t][e],delete this.patterns[t][e],r.userImage&&r.userImage.onRemove&&r.userImage.onRemove()}listImages(e){return Object.keys(this.images[e])}getImages(e,t,r){let i=!0;const n=!!this.loaded[t];if(!n)for(const r of e)this.images[t][r]||(i=!1);n||i?this._notify(e,t,r):this.requestors.push({ids:e,scope:t,callback:r})}getUpdatedImages(e){return this.updatedImages[e]}_notify(t,r,i){const n={};for(const i of t){this.images[r][i]||this.fire(new e.b("styleimagemissing",{id:i}));const t=this.images[r][i];t?n[i]={data:t.data.clone(),pixelRatio:t.pixelRatio,sdf:t.sdf,version:t.version,stretchX:t.stretchX,stretchY:t.stretchY,content:t.content,hasRenderCallback:Boolean(t.userImage&&t.userImage.render)}:e.w(`Image "${i}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`)}i(null,n)}getPixelSize(e){const{width:t,height:r}=this.atlasImage[e];return{width:t,height:r}}getPattern(t,r){const i=this.patterns[r][t],n=this.getImage(t,r);if(!n)return null;if(i&&i.position.version===n.version)return i.position;if(i)i.position.version=n.version;else{const i={w:n.data.width+2,h:n.data.height+2,x:0,y:0},o=new e.I(i,n);this.patterns[r][t]={bin:i,position:o}}return this._updatePatternAtlas(r),this.patterns[r][t].position}bind(t,r){const i=t.gl;let n=this.atlasTexture[r];n?this.dirty&&(n.update(this.atlasImage[r]),this.dirty=!1):(n=new e.T(t,this.atlasImage[r],i.RGBA),this.atlasTexture[r]=n),n.bind(i.LINEAR,i.CLAMP_TO_EDGE)}_updatePatternAtlas(t){const r=[];for(const e in this.patterns[t])r.push(this.patterns[t][e].bin);const{w:i,h:n}=e.p(r),o=this.atlasImage[t];o.resize({width:i||1,height:n||1});for(const r in this.patterns[t]){const{bin:i}=this.patterns[t][r],n=i.x+1,s=i.y+1,a=this.images[t][r].data,l=a.width,c=a.height;e.h.copy(a,o,{x:0,y:0},{x:n,y:s},{width:l,height:c}),e.h.copy(a,o,{x:0,y:c-1},{x:n,y:s-1},{width:l,height:1}),e.h.copy(a,o,{x:0,y:0},{x:n,y:s+c},{width:l,height:1}),e.h.copy(a,o,{x:l-1,y:0},{x:n-1,y:s},{width:1,height:c}),e.h.copy(a,o,{x:0,y:0},{x:n+l,y:s},{width:1,height:c})}this.dirty=!0}beginFrame(){for(const e in this.images)this.callbackDispatchedThisFrame[e]={}}dispatchRenderCallbacks(e,t){for(const r of e){if(this.callbackDispatchedThisFrame[t][r])continue;this.callbackDispatchedThisFrame[t][r]=!0;const e=this.images[t][r];v(e)&&this.updateImage(r,t,e)}}}function w(t){const r=t.key,i=t.value,n=t.valueSpec||{},o=t.objectElementValidators||{},s=t.style,a=t.styleSpec;let l=[];const c=e.j(i);if("object"!==c)return[new e.V(r,i,`object expected, ${c} found`)];for(const t in i){const c=t.split(".")[0];let u;o[c]?u=o[c]:n[c]?u=Z:o["*"]?u=o["*"]:n["*"]&&(u=Z),u?l=l.concat(u({key:(r?`${r}.`:r)+t,value:i[t],valueSpec:n[c]||n["*"],style:s,styleSpec:a,object:i,objectKey:t},i)):l.push(new e.i(r,i[t],`unknown property "${t}"`))}for(const t in n)o[t]||n[t].required&&void 0===n[t].default&&void 0===i[t]&&l.push(new e.V(r,i,`missing required property "${t}"`));return l}function C(t){const r=t.value,i=t.valueSpec,n=t.style,o=t.styleSpec,s=t.key,a=t.arrayElementValidator||Z;if("array"!==e.j(r))return[new e.V(s,r,`array expected, ${e.j(r)} found`)];if(i.length&&r.length!==i.length)return[new e.V(s,r,`array length ${i.length} expected, length ${r.length} found`)];if(i["min-length"]&&r.length<i["min-length"])return[new e.V(s,r,`array length at least ${i["min-length"]} expected, length ${r.length} found`)];let l={type:i.value,values:i.values,minimum:i.minimum,maximum:i.maximum,function:void 0};o.$version<7&&(l.function=i.function),"object"===e.j(i.value)&&(l=i.value);let c=[];for(let e=0;e<r.length;e++)c=c.concat(a({array:r,arrayIndex:e,value:r[e],valueSpec:l,style:n,styleSpec:o,key:`${s}[${e}]`},!0));return c}function T(t){const r=t.key,i=t.value,n=t.valueSpec;let o=e.j(i);if("number"===o&&i!=i&&(o="NaN"),"number"!==o)return[new e.V(r,i,`number expected, ${o} found`)];if("minimum"in n){let o=n.minimum;if("array"===e.j(n.minimum)&&(o=n.minimum[t.arrayIndex]),i<o)return[new e.V(r,i,`${i} is less than the minimum value ${o}`)]}if("maximum"in n){let o=n.maximum;if("array"===e.j(n.maximum)&&(o=n.maximum[t.arrayIndex]),i>o)return[new e.V(r,i,`${i} is greater than the maximum value ${o}`)]}return[]}function E(t){const r=t.valueSpec,i=e.u(t.value.type);let n,o,s,a={};const l="categorical"!==i&&void 0===t.value.property,c=!l,u="array"===e.j(t.value.stops)&&"array"===e.j(t.value.stops[0])&&"object"===e.j(t.value.stops[0][0]),h=w({key:t.key,value:t.value,valueSpec:t.styleSpec.function,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===i)return[new e.V(t.key,t.value,'identity function may not have a "stops" property')];let r=[];const n=t.value;return r=r.concat(C({key:t.key,value:n,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:d})),"array"===e.j(n)&&0===n.length&&r.push(new e.V(t.key,n,"array must have at least one stop")),r},default:function(e){return Z({key:e.key,value:e.value,valueSpec:r,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===i&&l&&h.push(new e.V(t.key,t.value,'missing required property "property"')),"identity"===i||t.value.stops||h.push(new e.V(t.key,t.value,'missing required property "stops"')),"exponential"===i&&t.valueSpec.expression&&!e.s(t.valueSpec)&&h.push(new e.V(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(c&&!e.m(t.valueSpec)?h.push(new e.V(t.key,t.value,"property functions not supported")):l&&!e.n(t.valueSpec)&&h.push(new e.V(t.key,t.value,"zoom functions not supported"))),"categorical"!==i&&!u||void 0!==t.value.property||h.push(new e.V(t.key,t.value,'"property" property is required')),h;function d(t){let i=[];const n=t.value,l=t.key;if("array"!==e.j(n))return[new e.V(l,n,`array expected, ${e.j(n)} found`)];if(2!==n.length)return[new e.V(l,n,`array length 2 expected, length ${n.length} found`)];if(u){if("object"!==e.j(n[0]))return[new e.V(l,n,`object expected, ${e.j(n[0])} found`)];if(void 0===n[0].zoom)return[new e.V(l,n,"object stop key must have zoom")];if(void 0===n[0].value)return[new e.V(l,n,"object stop key must have value")];const r=e.u(n[0].zoom);if("number"!=typeof r)return[new e.V(l,n[0].zoom,"stop zoom values must be numbers")];if(s&&s>r)return[new e.V(l,n[0].zoom,"stop zoom values must appear in ascending order")];r!==s&&(s=r,o=void 0,a={}),i=i.concat(w({key:`${l}[0]`,value:n[0],valueSpec:{zoom:{}},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:T,value:p}}))}else i=i.concat(p({key:`${l}[0]`,value:n[0],valueSpec:{},style:t.style,styleSpec:t.styleSpec},n));return e.o(e.q(n[1]))?i.concat([new e.V(`${l}[1]`,n[1],"expressions are not allowed in function stops.")]):i.concat(Z({key:`${l}[1]`,value:n[1],valueSpec:r,style:t.style,styleSpec:t.styleSpec}))}function p(t,s){const l=e.j(t.value),c=e.u(t.value),u=null!==t.value?t.value:s;if(n){if(l!==n)return[new e.V(t.key,u,`${l} stop domain type must match previous stop domain type ${n}`)]}else n=l;if("number"!==l&&"string"!==l&&"boolean"!==l&&"number"!=typeof c&&"string"!=typeof c&&"boolean"!=typeof c)return[new e.V(t.key,u,"stop domain value must be a number, string, or boolean")];if("number"!==l&&"categorical"!==i){let n=`number expected, ${l} found`;return e.m(r)&&void 0===i&&(n+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new e.V(t.key,u,n)]}return"categorical"!==i||"number"!==l||"number"==typeof c&&isFinite(c)&&Math.floor(c)===c?"categorical"!==i&&"number"===l&&"number"==typeof c&&"number"==typeof o&&void 0!==o&&c<o?[new e.V(t.key,u,"stop domain values must appear in ascending order")]:(o=c,"categorical"===i&&c in a?[new e.V(t.key,u,"stop domain values must be unique")]:(a[c]=!0,[])):[new e.V(t.key,u,`integer expected, found ${String(c)}`)]}}function M(t){const r=("property"===t.expressionContext?e.r:e.t)(e.q(t.value),t.valueSpec);if("error"===r.result)return r.value.map((r=>new e.V(`${t.key}${r.key}`,t.value,r.message)));const i=r.value.expression||r.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!i.outputDefined())return[new e.V(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===t.expressionContext&&"layout"===t.propertyType&&!e.v(i))return[new e.V(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext)return S(i,t);if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!e.x(i,["zoom","feature-state"]))return[new e.V(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!e.y(i))return[new e.V(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function S(t,r){const i=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(r.valueSpec&&r.valueSpec.expression)for(const e of r.valueSpec.expression.parameters)i.delete(e);if(0===i.size)return[];const n=[];return t instanceof e.C&&i.has(t.name)?[new e.V(r.key,r.value,`["${t.name}"] expression is not supported in a filter for a ${r.object.type} layer with id: ${r.object.id}`)]:(t.eachChild((e=>{n.push(...S(e,r))})),n)}function I(t){const r=t.key,i=t.value,n=t.valueSpec,o=[];return Array.isArray(n.values)?-1===n.values.indexOf(e.u(i))&&o.push(new e.V(r,i,`expected one of [${n.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(n.values).indexOf(e.u(i))&&o.push(new e.V(r,i,`expected one of [${Object.keys(n.values).join(", ")}], ${JSON.stringify(i)} found`)),o}function P(t){return e.A(e.q(t.value))?M(e.k({},t,{expressionContext:"filter",valueSpec:t.styleSpec[`filter_${t.layerType||"fill"}`]})):D(t)}function D(t){const r=t.value,i=t.key;if("array"!==e.j(r))return[new e.V(i,r,`array expected, ${e.j(r)} found`)];const n=t.styleSpec;let o,s=[];if(r.length<1)return[new e.V(i,r,"filter array must have at least 1 element")];switch(s=s.concat(I({key:`${i}[0]`,value:r[0],valueSpec:n.filter_operator,style:t.style,styleSpec:t.styleSpec})),e.u(r[0])){case"<":case"<=":case">":case">=":r.length>=2&&"$type"===e.u(r[1])&&s.push(new e.V(i,r,`"$type" cannot be use with operator "${r[0]}"`));case"==":case"!=":3!==r.length&&s.push(new e.V(i,r,`filter array for operator "${r[0]}" must have 3 elements`));case"in":case"!in":r.length>=2&&(o=e.j(r[1]),"string"!==o&&s.push(new e.V(`${i}[1]`,r[1],`string expected, ${o} found`)));for(let a=2;a<r.length;a++)o=e.j(r[a]),"$type"===e.u(r[1])?s=s.concat(I({key:`${i}[${a}]`,value:r[a],valueSpec:n.geometry_type,style:t.style,styleSpec:t.styleSpec})):"string"!==o&&"number"!==o&&"boolean"!==o&&s.push(new e.V(`${i}[${a}]`,r[a],`string, number, or boolean expected, ${o} found`));break;case"any":case"all":case"none":for(let e=1;e<r.length;e++)s=s.concat(D({key:`${i}[${e}]`,value:r[e],style:t.style,styleSpec:t.styleSpec}));break;case"has":case"!has":o=e.j(r[1]),2!==r.length?s.push(new e.V(i,r,`filter array for "${r[0]}" operator must have 2 elements`)):"string"!==o&&s.push(new e.V(`${i}[1]`,r[1],`string expected, ${o} found`))}return s}function k(t,r){const i=t.key,n=t.style,o=t.layer,s=t.styleSpec,a=t.value,l=t.objectKey,c=s[`${r}_${t.layerType}`];if(!c)return[];const u=l.match(/^(.*)-transition$/);if("paint"===r&&u&&c[u[1]]&&c[u[1]].transition)return Z({key:i,value:a,valueSpec:s.transition,style:n,styleSpec:s});const h=t.valueSpec||c[l];if(!h)return[new e.i(i,a,`unknown property "${l}"`)];let d;if("string"===e.j(a)&&e.m(h)&&!h.tokens&&(d=/^{([^}]+)}$/.exec(a))){const t=`\`{ "type": "identity", "property": ${d?JSON.stringify(d[1]):'"_"'} }\``;return[new e.V(i,a,`"${l}" does not support interpolation syntax\nUse an identity property function instead: ${t}.`)]}const p=[];if("symbol"===t.layerType)"text-field"!==l||!n||n.glyphs||n.imports||p.push(new e.V(i,a,'use of "text-field" requires a style "glyphs" property')),"text-font"===l&&e.B(e.q(a))&&"identity"===e.u(a.type)&&p.push(new e.V(i,a,'"text-font" does not support identity functions'));else if("model"===t.layerType&&"paint"===r&&o&&o.layout&&o.layout.hasOwnProperty("model-id")&&e.m(h)&&(e.D(h)||e.n(h))){const t=e.r(e.q(a),h),r=t.value.expression||t.value._styleExpression.expression;r&&!e.x(r,["measure-light"])&&("model-emissive-strength"===l&&e.y(r)&&e.v(r)||p.push(new e.V(i,a,`${l} does not support measure-light expressions when the model layer source is vector tile or GeoJSON.`)))}return p.concat(Z({key:t.key,value:a,valueSpec:h,style:n,styleSpec:s,expressionContext:"property",propertyType:r,propertyKey:l}))}function L(e){return k(e,"paint")}function z(e){return k(e,"layout")}function O(t){let r=[];const i=t.value,n=t.key,o=t.style,s=t.styleSpec;i.type||i.ref||r.push(new e.V(n,i,'either "type" or "ref" is required'));let a=e.u(i.type);const l=e.u(i.ref);if(i.id){const s=e.u(i.id);for(let a=0;a<t.arrayIndex;a++){const t=o.layers[a];e.u(t.id)===s&&r.push(new e.V(n,i.id,`duplicate layer id "${i.id}", previously used at line ${t.id.__line__}`))}}if("ref"in i){let t;["type","source","source-layer","filter","layout"].forEach((t=>{t in i&&r.push(new e.V(n,i[t],`"${t}" is prohibited for ref layers`))})),o.layers.forEach((r=>{e.u(r.id)===l&&(t=r)})),t?t.ref?r.push(new e.V(n,i.ref,"ref cannot reference another ref layer")):a=e.u(t.type):"string"==typeof l&&r.push(new e.V(n,i.ref,`ref layer "${l}" not found`))}else if("background"!==a&&"sky"!==a&&"slot"!==a)if(i.source){const t=o.sources&&o.sources[i.source],s=t&&e.u(t.type);t?"vector"===s&&"raster"===a?r.push(new e.V(n,i.source,`layer "${i.id}" requires a raster source`)):"raster"===s&&"raster"!==a?r.push(new e.V(n,i.source,`layer "${i.id}" requires a vector source`)):"vector"!==s||i["source-layer"]?"raster-dem"===s&&"hillshade"!==a?r.push(new e.V(n,i.source,"raster-dem source can only be used with layer type 'hillshade'.")):"raster-array"!==s||["raster","raster-particle"].includes(a)?"line"!==a||!i.paint||!i.paint["line-gradient"]&&!i.paint["line-trim-offset"]||"geojson"===s&&t.lineMetrics?"raster-particle"===a&&"raster-array"!==s&&r.push(new e.V(n,i.source,`layer "${i.id}" requires a 'raster-array' source.`)):r.push(new e.V(n,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):r.push(new e.V(n,i.source,"raster-array source can only be used with layer type 'raster'.")):r.push(new e.V(n,i,`layer "${i.id}" must specify a "source-layer"`)):r.push(new e.V(n,i.source,`source "${i.source}" not found`))}else r.push(new e.V(n,i,'missing required property "source"'));return r=r.concat(w({key:n,value:i,valueSpec:s.layer,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":()=>[],type:()=>Z({key:`${n}.type`,value:i.type,valueSpec:s.layer.type,style:t.style,styleSpec:t.styleSpec,object:i,objectKey:"type"}),filter:t=>P(e.k({layerType:a},t)),layout:t=>w({layer:i,key:t.key,value:t.value,valueSpec:{},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":t=>z(e.k({layerType:a},t))}}),paint:t=>w({layer:i,key:t.key,value:t.value,valueSpec:{},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":t=>L(e.k({layerType:a,layer:i},t))}})}})),r}function B(t){const r=t.value,i=t.key,n=e.j(r);return"string"!==n?[new e.V(i,r,`string expected, ${n} found`)]:[]}const R={promoteId:function({key:t,value:r}){if("string"===e.j(r))return B({key:t,value:r});{const e=[];for(const i in r)e.push(...B({key:`${t}.${i}`,value:r[i]}));return e}}};function F(t){const r=t.value,i=t.key,n=t.styleSpec,o=t.style;if(!r.type)return[new e.V(i,r,'"type" is required')];const s=e.u(r.type);let a=[];switch(["vector","raster","raster-dem","raster-array"].includes(s)&&(r.url||r.tiles||a.push(new e.i(i,r,'Either "url" or "tiles" is required.'))),s){case"vector":case"raster":case"raster-dem":case"raster-array":return a=a.concat(w({key:i,value:r,valueSpec:n[`source_${s.replace("-","_")}`],style:t.style,styleSpec:n,objectElementValidators:R})),a;case"geojson":if(a=w({key:i,value:r,valueSpec:n.source_geojson,style:o,styleSpec:n,objectElementValidators:R}),r.cluster)for(const e in r.clusterProperties){const[t,n]=r.clusterProperties[e],o="string"==typeof t?[t,["accumulated"],["get",e]]:t;a.push(...M({key:`${i}.${e}.map`,value:n,expressionContext:"cluster-map"})),a.push(...M({key:`${i}.${e}.reduce`,value:o,expressionContext:"cluster-reduce"}))}return a;case"video":return w({key:i,value:r,valueSpec:n.source_video,style:o,styleSpec:n});case"image":return w({key:i,value:r,valueSpec:n.source_image,style:o,styleSpec:n});case"canvas":return[new e.V(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return I({key:`${i}.type`,value:r.type,valueSpec:{values:j(n)},style:o,styleSpec:n})}}function j(e){return e.source.reduce(((t,r)=>{const i=e[r];return"enum"===i.type.type&&(t=t.concat(Object.keys(i.type.values))),t}),[])}function V(t){const r=t.value,i=t.styleSpec,n=i.light,o=t.style;let s=[];const a=e.j(r);if(void 0===r)return s;if("object"!==a)return s=s.concat([new e.V("light",r,`object expected, ${a} found`)]),s;for(const t in r){const a=t.match(/^(.*)-transition$/);s=s.concat(a&&n[a[1]]&&n[a[1]].transition?Z({key:t,value:r[t],valueSpec:i.transition,style:o,styleSpec:i}):n[t]?Z({key:t,value:r[t],valueSpec:n[t],style:o,styleSpec:i}):[new e.V(t,r[t],`unknown property "${t}"`)])}return s}function N(t){const r=t.value;let i=[];if(!r)return i;const n=e.j(r);if("object"!==n)return i=i.concat([new e.V("light-3d",r,`object expected, ${n} found`)]),i;const o=t.styleSpec,s=o["light-3d"],a=t.key,l=t.style,c=t.style.lights;for(const t of["type","id"])if(!(t in r))return i=i.concat([new e.V("light-3d",r,`missing property ${t} on light`)]),i;if(r.type&&c)for(let n=0;n<t.arrayIndex;n++){const t=e.u(r.type),o=c[n];e.u(o.type)===t&&i.push(new e.V(a,r.id,`duplicate light type "${r.type}", previously defined at line ${o.id.__line__}`))}const u=`properties_light_${r.type}`;if(!(u in o))return i=i.concat([new e.V("light-3d",r,`Invalid light type ${r.type}`)]),i;const h=o[u];for(const n in r)if("properties"===n){const s=r[n],a=e.j(s);if("object"!==a)return i=i.concat([new e.V("properties",s,`object expected, ${a} found`)]),i;for(const r in s)i=i.concat(h[r]?Z({key:r,value:s[r],valueSpec:h[r],style:l,styleSpec:o}):[new e.i(t.key,s[r],`unknown property "${r}"`)])}else{const t=n.match(/^(.*)-transition$/);i=i.concat(t&&s[t[1]]&&s[t[1]].transition?Z({key:n,value:r[n],valueSpec:o.transition,style:l,styleSpec:o}):s[n]?Z({key:n,value:r[n],valueSpec:s[n],style:l,styleSpec:o}):[new e.i(n,r[n],`unknown property "${n}"`)])}return i}function U(t){const r=t.value,i=t.key,n=t.style,o=t.styleSpec,s=o.terrain;let a=[];const l=e.j(r);if(void 0===r)return a;if("null"===l)return a;if("object"!==l)return a=a.concat([new e.V("terrain",r,`object expected, ${l} found`)]),a;for(const t in r){const i=t.match(/^(.*)-transition$/);a=a.concat(i&&s[i[1]]&&s[i[1]].transition?Z({key:t,value:r[t],valueSpec:o.transition,style:n,styleSpec:o}):s[t]?Z({key:t,value:r[t],valueSpec:s[t],style:n,styleSpec:o}):[new e.i(t,r[t],`unknown property "${t}"`)])}if(r.source){const t=n.sources&&n.sources[r.source],o=t&&e.u(t.type);t?"raster-dem"!==o&&a.push(new e.V(i,r.source,`terrain cannot be used with a source of type ${String(o)}, it only be used with a "raster-dem" source type`)):a.push(new e.V(i,r.source,`source "${r.source}" not found`))}else a.push(new e.V(i,r,'terrain is missing required property "source"'));return a}function H(t){const r=t.value,i=t.style,n=t.styleSpec,o=n.fog;let s=[];const a=e.j(r);if(void 0===r)return s;if("object"!==a)return s=s.concat([new e.V("fog",r,`object expected, ${a} found`)]),s;for(const t in r){const a=t.match(/^(.*)-transition$/);s=s.concat(a&&o[a[1]]&&o[a[1]].transition?Z({key:t,value:r[t],valueSpec:n.transition,style:i,styleSpec:n}):o[t]?Z({key:t,value:r[t],valueSpec:o[t],style:i,styleSpec:n}):[new e.i(t,r[t],`unknown property "${t}"`)])}return s}const G={"*":()=>[],array:C,boolean:function(t){const r=t.value,i=t.key,n=e.j(r);return"boolean"!==n?[new e.V(i,r,`boolean expected, ${n} found`)]:[]},number:T,color:function(t){const r=t.key,i=t.value,n=e.j(i);return"string"!==n?[new e.V(r,i,`color expected, ${n} found`)]:null===e.z(i)?[new e.V(r,i,`color expected, "${i}" found`)]:[]},enum:I,filter:P,function:E,layer:O,object:w,source:F,model:e.F,light:V,"light-3d":N,terrain:U,fog:H,string:B,formatted:function(e){return 0===B(e).length?[]:M(e)},resolvedImage:function(e){return 0===B(e).length?[]:M(e)},projection:function(t){const r=t.value,i=t.styleSpec,n=i.projection,o=t.style;let s=[];const a=e.j(r);if("object"===a)for(const e in r)s=s.concat(Z({key:e,value:r[e],valueSpec:n[e],style:o,styleSpec:i}));else"string"!==a&&(s=s.concat([new e.V("projection",r,`object or string expected, ${a} found`)]));return s},import:function(t){const{value:r,styleSpec:i}=t,{data:n,...o}=r;Object.defineProperty(o,"__line__",{value:r.__line__,enumerable:!1});let s=w(e.k({},t,{value:o,valueSpec:i.import}));return""===e.u(o.id)&&s.push(new e.V(`${t.key}.id`,o,"import id can't be an empty string")),n&&(s=s.concat(Q(n,i,{key:`${t.key}.data`}))),s}};function Z(t,r=!1){const i=t.value,n=t.valueSpec,o=t.styleSpec;if(n.expression&&e.B(e.u(i)))return E(t);if(n.expression&&e.o(e.q(i)))return M(t);if(n.type&&G[n.type]){const i=G[n.type](t);return!0===r&&i.length>0&&"array"===e.j(t.value)?M(t):i}return w(e.k({},t,{valueSpec:n.type?o[n.type]:n}))}function W(t){const r=t.value,i=t.key,n=B(t);return n.length||(-1===r.indexOf("{fontstack}")&&n.push(new e.V(i,r,'"glyphs" url must include a "{fontstack}" token')),-1===r.indexOf("{range}")&&n.push(new e.V(i,r,'"glyphs" url must include a "{range}" token'))),n}function Q(t,r=e.G,i={}){return Z({key:i.key||"",value:t,valueSpec:r.$root,styleSpec:r,style:t,objectElementValidators:{glyphs:W,"*":()=>[]}})}function q(t,r=e.G){return oe(Q(t,r))}const X=e=>oe(F(e)),Y=e=>oe(V(e)),$=e=>oe(N(e)),K=e=>oe(U(e)),J=e=>oe(H(e)),ee=e=>oe(O(e)),te=e=>oe(P(e)),re=e=>oe(L(e)),ie=e=>oe(z(e)),ne=t=>oe(e.F(t));function oe(e){return e.slice().sort(((e,t)=>e.line&&t.line?e.line-t.line:0))}function se(t,r){let i=!1;if(r&&r.length)for(const n of r)n instanceof e.i?e.w(n.message):(t.fire(new e.a(new Error(n.message))),i=!0);return i}const ae=new e.H({anchor:new e.J(e.G.light.anchor),position:new e.K(e.G.light.position),color:new e.J(e.G.light.color),intensity:new e.J(e.G.light.intensity)});class le extends e.E{constructor(t,r="flat"){super(),this._transitionable=new e.L(ae),this.setLight(t,r),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(e,t,r={}){this._validate(Y,e,r)||(this._transitionable.setTransitionOrValue(e),this.id=t)}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(t,r,i){return(!i||!1!==i.validate)&&se(this,t.call(q,e.e({value:r,style:{glyphs:!0,sprite:!0},styleSpec:e.G})))}}const ce=new e.H({source:new e.J(e.G.terrain.source),exaggeration:new e.J(e.G.terrain.exaggeration)});let ue=class extends e.E{constructor(t,r,i,n){super(),this.scope=i,this._transitionable=new e.L(ce,i,n),this._transitionable.setTransitionOrValue(t,n),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=r}get(){return this._transitionable.serialize()}set(e,t){this._transitionable.setTransitionOrValue(e,t)}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}getExaggeration(t){return this._transitioning.possiblyEvaluate(new e.N(t)).get("exaggeration")}isZoomDependent(){const t=this._transitionable._values.exaggeration;return null!=t&&null!=t.value&&null!=t.value.expression&&t.value.expression instanceof e.Z}};const he=45,de=65,pe=.05;function fe(t,r,i,n){const o=e.S(he,de,i),[s,a]=me(t,n);let l=1-Math.min(1,Math.exp((r-s)/(a-s)*-6));return l*=l*l,l=Math.min(1,1.00747*l),l*o*t.alpha}function me(e,t){const r=.5/Math.tan(.5*t);return[e.range[0]+r,e.range[1]+r]}function Ae(t,r,i,n,o){const s=e.Q.transformMat4([],[r,i,n],o.mercatorFogMatrix);return fe(t,e.Q.length(s),o.pitch,o._fov)}function ge(t,r,i,n,o,s,a){const l=[[i,n,0],[o,n,0],[o,s,0],[i,s,0]];let c=Number.MAX_VALUE,u=-Number.MAX_VALUE;for(const t of l){const i=e.Q.transformMat4([],t,r),n=e.Q.length(i);c=Math.min(c,n),u=Math.max(u,n)}return[fe(t,c,a.pitch,a._fov),fe(t,u,a.pitch,a._fov)]}const _e=new e.H({range:new e.J(e.G.fog.range),color:new e.J(e.G.fog.color),"high-color":new e.J(e.G.fog["high-color"]),"space-color":new e.J(e.G.fog["space-color"]),"horizon-blend":new e.J(e.G.fog["horizon-blend"]),"star-intensity":new e.J(e.G.fog["star-intensity"]),"vertical-range":new e.J(e.G.fog["vertical-range"])});class ye extends e.E{constructor(t,r,i,n){super(),this._transitionable=new e.L(_e,i,new Map(n)),this.set(t,n),this._transitioning=this._transitionable.untransitioned(),this._transform=r,this.properties=new e.U(_e)}get state(){const t=this._transform,r="globe"===t.projection.name,i=e.W(t.zoom),n=this.properties.get("range"),o=[.5,3];return{range:r?[e.X(o[0],n[0],i),e.X(o[1],n[1],i)]:n,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(t,r,i={}){if(this._validate(J,t,i))return;const n=e.e({},t);for(const t of Object.keys(e.G.fog))void 0===n[t]&&(n[t]=e.G.fog[t].default);this._options=n,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:e.S(he,de,t))*r.a}getOpacityAtLatLng(t,r){return this._transform.projection.supportsFog?function(t,r,i){const n=e.O.fromLngLat(r),o=i.elevation?i.elevation.getAtPointOrZero(n):0;return Ae(t,n.x,n.y,o,i)}(this.state,t,r):0}getOpacityForTile(t){if(!this._transform.projection.supportsFog)return[1,1];const r=this._transform.calculateFogTileMatrix(t.toUnwrapped());return ge(this.state,r,0,0,e.Y,e.Y,this._transform)}getOpacityForBounds(e,t,r,i,n){return this._transform.projection.supportsFog?ge(this.state,e,t,r,i,n,this._transform):[1,1]}getFovAdjustedRange(e){return this._transform.projection.supportsFog?me(this.state,e):[0,1]}isVisibleOnFrustum(t){if(!this._transform.projection.supportsFog)return!1;const r=[4,5,6,7];for(const i of r){const r=t.points[i];let n;if(r[2]>=0)n=r;else{const o=t.points[i-4];n=e._(o,r,o[2]/(o[2]-r[2]))}if(Ae(this.state,n[0],n[1],0,this._transform)>=pe)return!0}return!1}updateConfig(e){this._transitionable.setTransitionOrValue(this._options,new Map(e))}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(t,r,i){return(!i||!1!==i.validate)&&se(this,t.call(q,e.e({value:r,style:{glyphs:!0,sprite:!0},styleSpec:e.G})))}}class xe extends e.E{constructor(t,r,i,n){super(),this.scope=i,this._options=t,this.properties=new e.U(r),this._transitionable=new e.L(r,i,new Map(n)),this._transitionable.setTransitionOrValue(t.properties),this._transitioning=this._transitionable.untransitioned()}updateConfig(e){this._transitionable.setTransitionOrValue(this._options.properties,new Map(e))}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}get(){return this._options.properties=this._transitionable.serialize(),this._options}set(e,t){this._options=e,this._transitionable.setTransitionOrValue(e.properties,t)}shadowsEnabled(){return!!this.properties&&!0===this.properties.get("cast-shadows")}}const ve=new e.H({color:new e.J(e.G.properties_light_ambient.color),intensity:new e.J(e.G.properties_light_ambient.intensity)}),be=new e.H({direction:new e.$(e.G.properties_light_directional.direction),color:new e.J(e.G.properties_light_directional.color),intensity:new e.J(e.G.properties_light_directional.intensity),"cast-shadows":new e.J(e.G.properties_light_directional["cast-shadows"]),"shadow-intensity":new e.J(e.G.properties_light_directional["shadow-intensity"])});class we{constructor(e,t,r,i){this.screenBounds=e,this.cameraPoint=t,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=r,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,i)}static createFromScreenPoints(t,r){let i,n;if(t instanceof e.P||"number"==typeof t[0]){const o=e.P.convert(t);i=[o],n=r.isPointAboveHorizon(o)}else{const o=e.P.convert(t[0]),s=e.P.convert(t[1]);i=[o,s],n=e.a0(o,s).every((e=>r.isPointAboveHorizon(e)))}return new we(i,r.getCameraPoint(),n,r)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(t){return e.a0(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],t)}bufferedCameraGeometry(t){const r=this.screenBounds[0],i=1===this.screenBounds.length?this.screenBounds[0].add(new e.P(1,1)):this.screenBounds[1],n=e.a0(r,i,0,!1);return this.cameraPoint.y>i.y&&(this.cameraPoint.x>r.x&&this.cameraPoint.x<i.x?n.splice(3,0,this.cameraPoint):this.cameraPoint.x>=i.x?n[2]=this.cameraPoint:this.cameraPoint.x<=r.x&&(n[3]=this.cameraPoint)),e.a1(n,t)}bufferedCameraGeometryGlobe(t){const r=this.screenBounds[0],i=1===this.screenBounds.length?this.screenBounds[0].add(new e.P(1,1)):this.screenBounds[1],n=e.a0(r,i,t),o=this.cameraPoint.clone();switch(3*((o.y>r.y)+(o.y>i.y))+((o.x>r.x)+(o.x>i.x))){case 0:n[0]=o,n[4]=o.clone();break;case 1:n.splice(1,0,o);break;case 2:n[1]=o;break;case 3:n.splice(4,0,o);break;case 5:n.splice(2,0,o);break;case 6:n[3]=o;break;case 7:n.splice(3,0,o);break;case 8:n[2]=o}return n}containsTile(t,r,i,n=0){const o=t.queryPadding/r._pixelsPerMercatorPixel+1,s=i?this._bufferedCameraMercator(o,r):this._bufferedScreenMercator(o,r);let a=t.tileID.wrap+(s.unwrapped?n:0);const l=s.polygon.map((r=>e.a2(t.tileTransform,r,a)));if(!e.a3(l,0,0,e.Y,e.Y))return;a=t.tileID.wrap+(this.screenGeometryMercator.unwrapped?n:0);const c=this.screenGeometryMercator.polygon.map((r=>e.a4(t.tileTransform,r,a))),u=c.map((t=>new e.P(t[0],t[1]))),h=r.getFreeCameraOptions().position||new e.O(0,0,0),d=e.a4(t.tileTransform,h,a),p=c.map((t=>{const r=e.Q.sub(t,t,d);return e.Q.normalize(r,r),new e.a5(d,r)})),f=e.a6(t,1,r.zoom)*r._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:u,tilespaceRays:p,bufferedTilespaceGeometry:l,bufferedTilespaceBounds:(m=e.a7(l),m.min.x=e.ad(m.min.x,0,e.Y),m.min.y=e.ad(m.min.y,0,e.Y),m.max.x=e.ad(m.max.x,0,e.Y),m.max.y=e.ad(m.max.y,0,e.Y),m),tile:t,tileID:t.tileID,pixelToTileUnitsFactor:f};var m}_bufferedScreenMercator(e,t){const r=Ee(e);if(this._screenRaycastCache[r])return this._screenRaycastCache[r];{let i;return i="globe"===t.projection.name?this._projectAndResample(this.bufferedScreenGeometry(e),t):{polygon:this.bufferedScreenGeometry(e).map((e=>t.pointCoordinate3D(e))),unwrapped:!0},this._screenRaycastCache[r]=i,i}}_bufferedCameraMercator(e,t){const r=Ee(e);if(this._cameraRaycastCache[r])return this._cameraRaycastCache[r];{let i;return i="globe"===t.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(e),t):{polygon:this.bufferedCameraGeometry(e).map((e=>t.pointCoordinate3D(e))),unwrapped:!0},this._cameraRaycastCache[r]=i,i}}_projectAndResample(t,r){const i=function(t,r){const i=e.a9.multiply([],r.pixelMatrix,r.globeMatrix),n=[0,-e.ae,0,1],o=[0,e.ae,0,1],s=[0,0,0,1];e.aa.transformMat4(n,n,i),e.aa.transformMat4(o,o,i),e.aa.transformMat4(s,s,i);const a=new e.P(n[0]/n[3],n[1]/n[3]),l=new e.P(o[0]/o[3],o[1]/o[3]),c=e.ab(t,a)&&n[3]<s[3],u=e.ab(t,l)&&o[3]<s[3];if(!c&&!u)return null;const h=function(e,t,r){for(let i=1;i<e.length;i++){const n=Te(t.pointCoordinate3D(e[i-1]).x),o=Te(t.pointCoordinate3D(e[i]).x);if(r<0){if(n<o)return{idx:i,t:-n/(o-1-n)}}else if(o<n)return{idx:i,t:(1-n)/(o+1-n)}}return null}(t,r,c?-1:1);if(!h)return null;const{idx:d,t:p}=h;let f=d>1?Ce(t.slice(0,d),r):[],m=d<t.length?Ce(t.slice(d),r):[];f=f.map((t=>new e.P(Te(t.x),t.y))),m=m.map((t=>new e.P(Te(t.x),t.y)));const A=[...f];0===A.length&&A.push(m[m.length-1]);const g=e.X(A[A.length-1].y,(0===m.length?f[0]:m[0]).y,p);let _;return _=c?[new e.P(0,g),new e.P(0,0),new e.P(1,0),new e.P(1,g)]:[new e.P(1,g),new e.P(1,1),new e.P(0,1),new e.P(0,g)],A.push(..._),0===m.length?A.push(f[0]):A.push(...m),{polygon:A.map((t=>new e.O(t.x,t.y))),unwrapped:!1}}(t,r);if(i)return i;const n=function(t,r){let i=!1,n=-1/0,o=0;for(let e=0;e<t.length-1;e++)t[e].x>n&&(n=t[e].x,o=e);for(let e=0;e<t.length-1;e++){const r=(o+e)%(t.length-1),n=t[r],s=t[r+1];Math.abs(n.x-s.x)>.5&&(n.x<s.x?(n.x+=1,0===r&&(t[t.length-1].x+=1)):(s.x+=1,r+1===t.length-1&&(t[0].x+=1)),i=!0)}const s=e.a8(r.center.lng);return i&&s<Math.abs(s-1)&&t.forEach((e=>{e.x-=1})),{polygon:t,unwrapped:i}}(Ce(t,r).map((t=>new e.P(Te(t.x),t.y))),r);return{polygon:n.polygon.map((t=>new e.O(t.x,t.y))),unwrapped:n.unwrapped}}}function Ce(t,r){return e.ac(t,(e=>{const t=r.pointCoordinate3D(e);e.x=t.x,e.y=t.y}),1/256)}function Te(e){return e<0?1+e%1:e%1}function Ee(e){return 100*e|0}function Me(t,r,i,n,o){const s=function(i,n){if(i)return o(i);if(n){t.url&&n.tiles&&t.tiles&&delete t.tiles;const i=e.af(e.e(n,t),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);n.vector_layers&&(i.vectorLayers=n.vector_layers,i.vectorLayerIds=i.vectorLayers.map((e=>e.id))),n.raster_layers&&(i.rasterLayers=n.raster_layers,i.rasterLayerIds=i.rasterLayers.map((e=>e.id))),i.tiles=r.canonicalizeTileset(i,t.url),o(null,i)}};return t.url?e.g(r.transformRequest(r.normalizeSourceURL(t.url,null,i,n),e.R.Source),s):e.f.frame((()=>s(null,t)))}class Se{constructor(t,r,i){this.bounds=e.ag.convert(this.validateBounds(t)),this.minzoom=r||0,this.maxzoom=i||24}validateBounds(e){return Array.isArray(e)&&4===e.length?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(t){const r=Math.pow(2,t.z),i=Math.floor(e.a8(this.bounds.getWest())*r),n=Math.floor(e.ah(this.bounds.getNorth())*r),o=Math.ceil(e.a8(this.bounds.getEast())*r),s=Math.ceil(e.ah(this.bounds.getSouth())*r);return t.x>=i&&t.x<o&&t.y>=n&&t.y<s}}class Ie extends e.E{constructor(t,r,i,n){if(super(),this.id=t,this.dispatcher=i,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,e.e(this,e.af(r,["url","scheme","tileSize","promoteId"])),this._options=e.e({type:"vector"},r),this._collectResourceTiming=!!r.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(n),this._tileWorkers={},this._deduped=new e.ai}load(t){this._loaded=!1,this.fire(new e.b("dataloading",{dataType:"source"}));const r=Array.isArray(this.map._language)?this.map._language.join():this.map._language,i=this.map._worldview;this._tileJSONRequest=Me(this._options,this.map._requestManager,r,i,((n,o)=>{this._tileJSONRequest=null,this._loaded=!0,n?(r&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${r}`),i&&2!==i.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${i}`),this.fire(new e.a(n))):o&&(e.e(this,o),o.bounds&&(this.tileBounds=new Se(o.bounds,this.minzoom,this.maxzoom)),e.am(o.tiles,this.map._requestManager._customAccessToken),this.fire(new e.b("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.b("data",{dataType:"source",sourceDataType:"content"}))),t&&t(n)}))}loaded(){return this._loaded}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load()}reload(){this.cancelTileJSONRequest();const t=e.aj(this.id,this.scope);this.load((()=>this.map.style.clearSource(t)))}setTiles(e){return this._options.tiles=e,this.reload(),this}setUrl(e){return this.url=e,this._options.url=e,this.reload(),this}onRemove(){this.cancelTileJSONRequest()}serialize(){return e.e({},this._options)}loadTile(t,r){const i=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme)),n={request:this.map._requestManager.transformRequest(i,e.R.Tile),data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,pixelRatio:e.f.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:t.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:t.isExtraShadowCaster};if(n.request.collectResourceTiming=this._collectResourceTiming,t.actor&&"expired"!==t.state)"loading"===t.state?t.reloadCallback=r:t.request=t.actor.send("reloadTile",n,o.bind(this));else if(t.actor=this._tileWorkers[i]=this._tileWorkers[i]||this.dispatcher.getActor(),this.dispatcher.ready)t.request=t.actor.send("loadTile",n,o.bind(this),void 0,!0);else{const r=e.ak.call({deduped:this._deduped},n,((e,r)=>{e||!r?o.call(this,e):(n.data={cacheControl:r.cacheControl,expires:r.expires,rawData:r.rawData.slice(0)},t.actor&&t.actor.send("loadTile",n,o.bind(this),void 0,!0))}),!0);t.request={cancel:r}}function o(i,n){return delete t.request,t.aborted?r(null):i&&404!==i.status?r(i):(n&&n.resourceTiming&&(t.resourceTiming=n.resourceTiming),this.map._refreshExpiredTiles&&n&&t.setExpiryData(n),t.loadVectorData(n,this.map.painter),e.al(this.dispatcher),r(null),void(t.reloadCallback&&(this.loadTile(t,t.reloadCallback),t.reloadCallback=null)))}}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.actor&&e.actor.send("abortTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope})}unloadTile(e){e.actor&&e.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope}),e.destroy()}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}class Pe extends e.E{constructor(t,r,i,n){super(),this.id=t,this.dispatcher=i,this.setEventedParent(n),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=e.e({type:"raster"},r),e.e(this,e.af(r,["url","scheme","tileSize"]))}load(t){this._loaded=!1,this.fire(new e.b("dataloading",{dataType:"source"})),this._tileJSONRequest=Me(this._options,this.map._requestManager,null,null,((r,i)=>{this._tileJSONRequest=null,this._loaded=!0,r?this.fire(new e.a(r)):i&&(e.e(this,i),i.bounds&&(this.tileBounds=new Se(i.bounds,this.minzoom,this.maxzoom)),e.am(i.tiles),this.fire(new e.b("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.b("data",{dataType:"source",sourceDataType:"content"}))),t&&t(r)}))}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}reload(){this.cancelTileJSONRequest();const t=e.aj(this.id,this.scope);this.load((()=>this.map.style.clearSource(t)))}setTiles(e){return this._options.tiles=e,this.reload(),this}setUrl(e){return this.url=e,this._options.url=e,this.reload(),this}onRemove(){this.cancelTileJSONRequest()}serialize(){return e.e({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(t,r){const i=e.f.devicePixelRatio>=2,n=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),i,this.tileSize);t.request=e.d(this.map._requestManager.transformRequest(n,e.R.Tile),((i,n,o,s)=>(delete t.request,t.aborted?(t.state="unloaded",r(null)):i?(t.state="errored",r(i)):n?(this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:o,expires:s}),t.setTexture(n,this.map.painter),t.state="loaded",e.al(this.dispatcher),void r(null)):r(null))))}abortTile(e,t){e.request&&(e.request.cancel(),delete e.request),t()}unloadTile(t,r){t.texture&&t.texture instanceof e.T?(t.destroy(!0),t.texture&&t.texture instanceof e.T&&this.map.painter.saveTileTexture(t.texture)):t.destroy(),r()}hasTransition(){return!1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}class De extends Pe{constructor(t,r,i,n){super(t,r,i,n),this.type="raster-array",this.maxzoom=22,this._options=e.e({type:"raster-array"},r)}triggerRepaint(e){const t=this.map.painter._terrain,r=this.map.style.getSourceCache(this.id);t&&t.enabled&&r&&t._clearRenderCacheForTile(r.id,e.tileID),this.map.triggerRepaint()}loadTile(t,r){const i=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),n=this.map._requestManager.transformRequest(i,e.R.Tile);t.requestParams=n,t.actor||(t.actor=this.dispatcher.getActor()),t.request=t.fetchHeader(void 0,((e,i,n,o)=>{if(delete t.request,t.aborted)return t.state="unloaded",r(null);if(e){if(20===e.code)return;return t.state="errored",r(e)}this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:n,expires:o}),t.state="empty",r(null)}))}unloadTile(t){const r=t.texture;r&&r instanceof e.T?(t.destroy(!0),this.map.painter.saveTileTexture(r)):(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,i){t._isHeaderLoaded&&("empty"!==t.state&&(t.state="reloading"),t.fetchBand(r,i,((r,i)=>{if(r)return t.state="errored",this.fire(new e.a(r)),void this.triggerRepaint(t);i&&(t.setTexture(i,this.map.painter),t.state="loaded",this.triggerRepaint(t))})))}getInitialBand(e){if(!this.rasterLayers)return 0;const t=this.rasterLayers.find((({id:t})=>t===e)),r=t&&t.fields,i=r&&r.bands&&r.bands;return i?i[0]:0}getTextureDescriptor(t,r,i){if(!t)return;const n=r.sourceLayer||this.rasterLayerIds&&this.rasterLayerIds[0];if(!n)return;let o=null;r instanceof e.aq?o=r.paint.get("raster-array-band"):r instanceof e.ar&&(o=r.paint.get("raster-particle-array-band"));const s=o||this.getInitialBand(n);if(null!=s)if(t.textureDescriptor){if(!t.updateNeeded(n,s)||i)return Object.assign({},t.textureDescriptor,{texture:t.texture})}else this.prepareTile(t,n,s)}}const ke=32,Le=33,ze=new Uint16Array(8184);for(let e=0;e<2046;e++){let t=e+2,r=0,i=0,n=0,o=0,s=0,a=0;for(1&t?n=o=s=ke:r=i=a=ke;(t>>=1)>1;){const e=r+n>>1,l=i+o>>1;1&t?(n=r,o=i,r=s,i=a):(r=n,i=o,n=s,o=a),s=e,a=l}const l=4*e;ze[l+0]=r,ze[l+1]=i,ze[l+2]=n,ze[l+3]=o}const Oe=new Uint16Array(2178),Be=new Uint8Array(1089),Re=new Uint16Array(1089);function Fe(e){return 0===e?-.03125:32===e?.03125:0}class je{constructor(e,t,r,i){this.id=je.uniqueIdxCounter,je.uniqueIdxCounter++,this.context=e;const n=e.gl;this.buffer=n.createBuffer(),this.dynamicDraw=Boolean(r),this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?n.DYNAMIC_DRAW:n.STATIC_DRAW),this.dynamicDraw||i||t.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){this.id=je.uniqueIdxCounter,je.uniqueIdxCounter++;const t=this.context.gl;this.context.unbindVAO(),this.bind(),t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}je.uniqueIdxCounter=0;const Ve={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Ne{constructor(e,t,r,i,n,o){this.length=t.length,this.attributes=r,this.itemSize=t.bytesPerElement,this.dynamicDraw=i,this.instanceCount=o,this.context=e;const s=e.gl;this.buffer=s.createBuffer(),e.bindVertexBuffer.set(this.buffer),s.bufferData(s.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?s.DYNAMIC_DRAW:s.STATIC_DRAW),this.dynamicDraw||n||t.destroy()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){const t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,t){for(let r=0;r<this.attributes.length;r++){const i=t.attributes[this.attributes[r].name];void 0!==i&&e.enableVertexAttribArray(i)}}setVertexAttribPointers(e,t,r){for(let i=0;i<this.attributes.length;i++){const n=this.attributes[i],o=t.attributes[n.name];void 0!==o&&e.vertexAttribPointer(o,n.components,e[Ve[n.type]],!1,this.itemSize,n.offset+this.itemSize*(r||0))}}setVertexAttribDivisor(e,t,r){for(let i=0;i<this.attributes.length;i++){const n=t.attributes[this.attributes[i].name];void 0!==n&&this.instanceCount&&this.instanceCount>0&&e.vertexAttribDivisor(n,r)}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class Ue{constructor(e){this.gl=e.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(e){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class He extends Ue{getDefault(){return e.aA.transparent}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.clearColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class Ge extends Ue{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}}class Ze extends Ue{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}}class We extends Ue{getDefault(){return[!0,!0,!0,!0]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.colorMask(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class Qe extends Ue{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}}class qe extends Ue{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}}class Xe extends Ue{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(e){const t=this.current;(e.func!==t.func||e.ref!==t.ref||e.mask!==t.mask||this.dirty)&&(this.gl.stencilFunc(e.func,e.ref,e.mask),this.current=e,this.dirty=!1)}}class Ye extends Ue{getDefault(){const e=this.gl;return[e.KEEP,e.KEEP,e.KEEP]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||this.dirty)&&(this.gl.stencilOp(e[0],e[1],e[2]),this.current=e,this.dirty=!1)}}class $e extends Ue{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST),this.current=e,this.dirty=!1}}class Ke extends Ue{getDefault(){return[0,1]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||this.dirty)&&(this.gl.depthRange(e[0],e[1]),this.current=e,this.dirty=!1)}}class Je extends Ue{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST),this.current=e,this.dirty=!1}}class et extends Ue{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}}class tt extends Ue{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.BLEND):t.disable(t.BLEND),this.current=e,this.dirty=!1}}class rt extends Ue{getDefault(){const e=this.gl;return[e.ONE,e.ZERO,e.ONE,e.ZERO]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.blendFuncSeparate(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class it extends Ue{getDefault(){return e.aA.transparent}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.blendColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class nt extends Ue{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquationSeparate(e,e),this.current=e,this.dirty=!1)}}class ot extends Ue{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.CULL_FACE):t.disable(t.CULL_FACE),this.current=e,this.dirty=!1}}class st extends Ue{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1)}}class at extends Ue{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1)}}let lt=class extends Ue{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}};class ct extends Ue{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}}class ut extends Ue{getDefault(){const e=this.gl;return[0,0,e.drawingBufferWidth,e.drawingBufferHeight]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.viewport(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class ht extends Ue{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,e),this.current=e,this.dirty=!1}}class dt extends Ue{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindRenderbuffer(t.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class pt extends Ue{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindTexture(t.TEXTURE_2D,e),this.current=e,this.dirty=!1}}class ft extends Ue{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindBuffer(t.ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class mt extends Ue{getDefault(){return null}set(e){const t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class At extends Ue{getDefault(){return null}set(e){this.gl&&(e!==this.current||this.dirty)&&(this.gl.bindVertexArray(e),this.current=e,this.dirty=!1)}}class gt extends Ue{getDefault(){return 4}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_ALIGNMENT,e),this.current=e,this.dirty=!1}}class _t extends Ue{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e),this.current=e,this.dirty=!1}}class yt extends Ue{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e),this.current=e,this.dirty=!1}}class xt extends Ue{constructor(e,t){super(e),this.context=e,this.parent=t}getDefault(){return null}}class vt extends xt{setDirty(){this.dirty=!0}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}}class bt extends xt{attachment(){return this.gl.DEPTH_ATTACHMENT}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,this.attachment(),t.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class wt extends xt{attachment(){return this.gl.DEPTH_ATTACHMENT}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,this.attachment(),t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}}class Ct extends bt{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}class Tt{constructor(e,t,r,i,n){this.context=e,this.width=t,this.height=r;const o=this.framebuffer=e.gl.createFramebuffer();i&&(this.colorAttachment=new vt(e,o)),n&&(this.depthAttachmentType=n,this.depthAttachment="renderbuffer"===n?new bt(e,o):new wt(e,o))}destroy(){const e=this.context.gl;if(this.colorAttachment){const t=this.colorAttachment.get();t&&e.deleteTexture(t)}if(this.depthAttachment&&this.depthAttachmentType)if("renderbuffer"===this.depthAttachmentType){const t=this.depthAttachment.get();t&&e.deleteRenderbuffer(t)}else{const t=this.depthAttachment.get();t&&e.deleteTexture(t)}e.deleteFramebuffer(this.framebuffer)}}class Et{constructor(e,t,r){this.func=e,this.mask=t,this.range=r}}Et.ReadOnly=!1,Et.ReadWrite=!0,Et.disabled=new Et(519,Et.ReadOnly,[0,1]);const Mt=7680;class St{constructor(e,t,r,i,n,o){this.test=e,this.ref=t,this.mask=r,this.fail=i,this.depthFail=n,this.pass=o}}St.disabled=new St({func:519,mask:0},0,0,Mt,Mt,Mt);const It=771;class Pt{constructor(e,t,r,i){this.blendFunction=e,this.blendColor=t,this.mask=r,this.blendEquation=i}}Pt.Replace=[1,0,1,0],Pt.disabled=new Pt(Pt.Replace,e.aA.transparent,[!1,!1,!1,!1]),Pt.unblended=new Pt(Pt.Replace,e.aA.transparent,[!0,!0,!0,!0]),Pt.alphaBlended=new Pt([1,It,1,It],e.aA.transparent,[!0,!0,!0,!0]),Pt.multiply=new Pt([774,0,774,0],e.aA.transparent,[!0,!0,!0,!0]);const Dt=1029,kt=2305;class Lt{constructor(e,t,r){this.enable=e,this.mode=t,this.frontFace=r}}Lt.disabled=new Lt(!1,Dt,kt),Lt.backCCW=new Lt(!0,Dt,kt),Lt.backCW=new Lt(!0,Dt,2304),Lt.frontCW=new Lt(!0,1028,2304),Lt.frontCCW=new Lt(!0,1028,kt);class zt{constructor(e,t){this.gl=e,this.clearColor=new He(this),this.clearDepth=new Ge(this),this.clearStencil=new Ze(this),this.colorMask=new We(this),this.depthMask=new Qe(this),this.stencilMask=new qe(this),this.stencilFunc=new Xe(this),this.stencilOp=new Ye(this),this.stencilTest=new $e(this),this.depthRange=new Ke(this),this.depthTest=new Je(this),this.depthFunc=new et(this),this.blend=new tt(this),this.blendFunc=new rt(this),this.blendColor=new it(this),this.blendEquation=new nt(this),this.cullFace=new ot(this),this.cullFaceSide=new st(this),this.frontFace=new at(this),this.program=new lt(this),this.activeTexture=new ct(this),this.viewport=new ut(this),this.bindFramebuffer=new ht(this),this.bindRenderbuffer=new dt(this),this.bindTexture=new pt(this),this.bindVertexBuffer=new ft(this),this.bindElementBuffer=new mt(this),this.bindVertexArrayOES=new At(this),this.pixelStoreUnpack=new gt(this),this.pixelStoreUnpackPremultiplyAlpha=new _t(this),this.pixelStoreUnpackFlipY=new yt(this),this.options=t?{...t}:{},this.options.extTextureFilterAnisotropicForceOff||(this.extTextureFilterAnisotropic=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=e.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT))),this.extDebugRendererInfo=e.getExtension("WEBGL_debug_renderer_info"),this.extDebugRendererInfo&&(this.renderer=e.getParameter(this.extDebugRendererInfo.UNMASKED_RENDERER_WEBGL),this.vendor=e.getParameter(this.extDebugRendererInfo.UNMASKED_VENDOR_WEBGL)),this.options.extTextureFloatLinearForceOff||(this.extTextureFloatLinear=e.getExtension("OES_texture_float_linear")),this.extRenderToTextureHalfFloat=e.getExtension("EXT_color_buffer_half_float"),this.extTimerQuery=e.getExtension("EXT_disjoint_timer_query_webgl2"),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),this.maxPointSize=e.getParameter(e.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(e,t,r){return new je(this,e,t,r)}createVertexBuffer(e,t,r,i,n){return new Ne(this,e,t,r,i,n)}createRenderbuffer(e,t,r){const i=this.gl,n=i.createRenderbuffer();return this.bindRenderbuffer.set(n),i.renderbufferStorage(i.RENDERBUFFER,e,t,r),this.bindRenderbuffer.set(null),n}createFramebuffer(e,t,r,i){return new Tt(this,e,t,r,i)}clear({color:e,depth:t,stencil:r,colorMask:i}){const n=this.gl;let o=0;e&&(o|=n.COLOR_BUFFER_BIT,this.clearColor.set(e),this.colorMask.set(i||[!0,!0,!0,!0])),void 0!==t&&(o|=n.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(t),this.depthMask.set(!0)),void 0!==r&&(o|=n.STENCIL_BUFFER_BIT,this.clearStencil.set(r),this.stencilMask.set(255)),n.clear(o)}setCullFace(e){!1===e.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(e.mode),this.frontFace.set(e.frontFace))}setDepthMode(e){e.func!==this.gl.ALWAYS||e.mask?(this.depthTest.set(!0),this.depthFunc.set(e.func),this.depthMask.set(e.mask),this.depthRange.set(e.range)):this.depthTest.set(!1)}setStencilMode(e){e.test.func!==this.gl.ALWAYS||e.mask?(this.stencilTest.set(!0),this.stencilMask.set(e.mask),this.stencilOp.set([e.fail,e.depthFail,e.pass]),this.stencilFunc.set({func:e.test.func,ref:e.ref,mask:e.test.mask})):this.stencilTest.set(!1)}setColorMode(e){t(e.blendFunction,Pt.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(e.blendFunction),this.blendColor.set(e.blendColor),e.blendEquation?this.blendEquation.set(e.blendEquation):this.blendEquation.setDefault()),this.colorMask.set(e.mask)}unbindVAO(){this.bindVertexArrayOES.set(null)}}var Ot=e.aB([{name:"a_index",type:"Int16",components:1}]);const Bt=.15000000000000002;class Rt{constructor(t,r,i,n){const o={width:i[0],height:i[1],data:null},s=t.gl;this.targetColorTexture=new e.T(t,o,s.RGBA,{useMipmap:!1}),this.backgroundColorTexture=new e.T(t,o,s.RGBA,{useMipmap:!1}),this.context=t,this.setParticleTextureDimension(r,n),this.lastInvalidatedAt=0}setParticleTextureDimension(t,r){if(this.particleTextureDimension===r)return;(this.particleTexture0||this.particleTexture1||this.particleIndexBuffer||this.particleSegment)&&(this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleIndexBuffer.destroy(),this.particleSegment.destroy());const i=this.context.gl,n=r*r,o=new Uint8Array(4*n),s=.7692307692307692,a=e.aC(t.key);for(let e=0;e<o.length;e+=4){const t=s*(a()+Bt),r=s*(a()+Bt),i=255*t%1,n=255*r%1,l=i,c=r-n/255,u=n;o[e+0]=Math.floor(255*(t-i/255)),o[e+1]=Math.floor(255*l),o[e+2]=Math.floor(255*c),o[e+3]=Math.floor(255*u)}const l=new e.h({width:r,height:r},o);this.particleTexture0=new e.T(this.context,l,i.RGBA,{premultiply:!1,useMipmap:!1}),this.particleTexture1=new e.T(this.context,l,i.RGBA,{premultiply:!1,useMipmap:!1});const c=new e.aD;c.reserve(n);for(let e=0;e<n;e++)c.emplaceBack(e);this.particleIndexBuffer=this.context.createVertexBuffer(c,Ot.members,!0),this.particleSegment=e.aE.simpleSegment(0,0,this.particleIndexBuffer.length,0),this.particleTextureDimension=r}update(t){return!(this.lastInvalidatedAt<t&&(this.lastInvalidatedAt=e.f.now(),1))}destroy(){this.targetColorTexture.destroy(),this.backgroundColorTexture.destroy(),this.particleIndexBuffer.destroy(),this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleSegment.destroy()}}const Ft={type:2,extent:e.Y,loadGeometry:()=>[[new e.P(0,0),new e.P(e.Y+1,0),new e.P(e.Y+1,e.Y+1),new e.P(0,e.Y+1),new e.P(0,0)]]};class jt{constructor(t,r,i,n,o){this.tileID=t,this.uid=e.aF(),this.uses=0,this.tileSize=r,this.tileZoom=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=o,n&&n.style&&(this._lastUpdatedBrightness=n.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",n&&n.transform&&(this.projection=n.transform.projection)}registerFadeDuration(t){const r=t+this.timeAdded;r<e.f.now()||this.fadeEndTime&&r<this.fadeEndTime||(this.fadeEndTime=r)}wasRequested(){return"errored"===this.state||"loaded"===this.state||"reloading"===this.state}get tileTransform(){return this._tileTransform||(this._tileTransform=e.av(this.tileID.canonical,this.projection)),this._tileTransform}loadVectorData(t,r,i){if(this.unloadVectorData(),this.state="loaded",t){t.featureIndex&&(this.latestFeatureIndex=t.featureIndex,t.rawTileData?(this.latestRawTileData=t.rawTileData,this.latestFeatureIndex.rawTileData=t.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=t.collisionBoxArray,this.buckets=function(e,t){const r={};if(!t)return r;for(const i of e){const e=i.layerIds.map((e=>t.getLayer(e))).filter(Boolean);if(0!==e.length){i.layers=e,i.stateDependentLayerIds&&(i.stateDependentLayers=i.stateDependentLayerIds.map((t=>e.filter((e=>e.id===t))[0])));for(const t of e)r[t.fqid]=i}}return r}(t.buckets,r.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const r=this.buckets[t];if(r instanceof e.aH){if(this.hasSymbolBuckets=!0,!i)break;r.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const r=this.buckets[t];if(r instanceof e.aH&&r.hasRTLText){this.hasRTLText=!0,e.aI();break}}this.queryPadding=0;for(const e in this.buckets){const t=this.buckets[e],i=r.style.getOwnLayer(e);if(!i)continue;const n=i.queryRadius(t);this.queryPadding=Math.max(this.queryPadding,n)}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 e.aG}unloadVectorData(){if(this.hasData()){for(const e in this.buckets)this.buckets[e].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(e){return this.buckets[e.fqid]}upload(t){for(const e in this.buckets){const r=this.buckets[e];r.uploadPending()&&r.upload(t)}const r=t.gl,i=this.imageAtlas;if(i&&!i.uploaded){const n=!!Object.keys(i.patternPositions).length;this.imageAtlasTexture=new e.T(t,i.image,r.RGBA,{useMipmap:n}),this.imageAtlas.uploaded=!0}this.glyphAtlasImage&&(this.glyphAtlasTexture=new e.T(t,this.glyphAtlasImage,r.R8),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new e.T(t,this.lineAtlas.image,r.R8),this.lineAtlas.uploaded=!0)}prepare(e,t,r){if(this.imageAtlas&&this.imageAtlasTexture&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture,r),!t||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;const i=t.style.getBrightness();(this._lastUpdatedBrightness||i)&&(this._lastUpdatedBrightness&&i&&Math.abs(this._lastUpdatedBrightness-i)<.001||(this._lastUpdatedBrightness=i,this.updateBuckets(void 0,t)))}queryRenderedFeatures(e,t,r,i,n,o,s,a){return this.latestFeatureIndex&&(this.latestFeatureIndex.rawTileData||this.latestFeatureIndex.is3DTile)?this.latestFeatureIndex.query({tileResult:i,pixelPosMatrix:s,transform:o,params:n,tileTransform:this.tileTransform},e,t,r):{}}querySourceFeatures(t,r){const i=this.latestFeatureIndex;if(!i||!i.rawTileData)return;const n=i.loadVTLayers(),o=r?r.sourceLayer:"",s=n._geojsonTileLayer||n[o];if(!s)return;const a=e.aJ(r&&r.filter),{z:l,x:c,y:u}=this.tileID.canonical,h={z:l,x:c,y:u};for(let r=0;r<s.length;r++){const n=s.feature(r);if(a.needGeometry){const t=e.aK(n,!0);if(!a.filter(new e.N(this.tileID.overscaledZ),t,this.tileID.canonical))continue}else if(!a.filter(new e.N(this.tileID.overscaledZ),n))continue;const d=i.getId(n,o),p=new e.aL(n,l,c,u,d);p.tile=h,t.push(p)}}hasData(){return"loaded"===this.state||"reloading"===this.state||"expired"===this.state}bucketsLoaded(){for(const e in this.buckets)if(this.buckets[e].uploadPending())return!1;return!0}patternsLoaded(){return!!this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(t){const r=this.expirationTime;if(t.cacheControl){const r=e.aM(t.cacheControl);r["max-age"]&&(this.expirationTime=Date.now()+1e3*r["max-age"])}else t.expires&&(this.expirationTime=new Date(t.expires).getTime());if(this.expirationTime){const e=Date.now();let t=!1;if(this.expirationTime>e)t=!1;else if(r)if(this.expirationTime<r)t=!0;else{const i=this.expirationTime-r;i?this.expirationTime=e+Math.max(i,3e4):t=!0}else t=!0;t?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-(new Date).getTime(),Math.pow(2,31)-1)}setFeatureState(e,t){this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData&&0!==Object.keys(e).length&&t&&this.updateBuckets(e,t)}updateBuckets(t,r){if(!this.latestFeatureIndex)return;const i=this.latestFeatureIndex.loadVTLayers(),n=r.style.listImages(),o=r.style.getBrightness();for(const s in this.buckets){if(!r.style.hasLayer(s))continue;const a=this.buckets[s],l=a.layers[0].sourceLayer||"_geojsonTileLayer",c=i[l];let u={};if(t&&(u=t[l],!c||!u||0===Object.keys(u).length))continue;if(a.update(u,c,n,this.imageAtlas&&this.imageAtlas.patternPositions||{},o),a instanceof e.aN||a instanceof e.aO){const e=r.style.getOwnSourceCache(a.layers[0].source);r._terrain&&r._terrain.enabled&&e&&a.programConfigurations.needsUpload&&r._terrain._clearRenderCacheForTile(e.id,this.tileID)}const h=r&&r.style&&r.style.getOwnLayer(s);h&&(this.queryPadding=Math.max(this.queryPadding,h.queryRadius(a)))}}holdingForFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<e.f.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(t){this.symbolFadeHoldUntil=e.f.now()+t}setTexture(t,r){const i=r.context,n=i.gl;this.texture=this.texture||r.getTileTexture(t.width),this.texture&&this.texture instanceof e.T?this.texture.update(t,{useMipmap:!0}):(this.texture=new e.T(i,t,n.RGBA,{useMipmap:!0}),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE))}setDependencies(e,t){const r={};for(const e of t)r[e]=!0;this.dependencies[e]=r}hasDependency(e,t){for(const r of e){const e=this.dependencies[r];if(e)for(const r of t)if(e[r])return!0}return!1}clearQueryDebugViz(){}_makeDebugTileBoundsBuffers(t,r){if(!r||"mercator"===r.name||this._tileDebugBuffer)return;const i=e.aP(Ft,this.tileID.canonical,this.tileTransform)[0],n=new e.aQ,o=new e.aR;for(let e=0;e<i.length;e++){const{x:t,y:r}=i[e];n.emplaceBack(t,r),o.emplaceBack(e)}o.emplaceBack(0),this._tileDebugIndexBuffer=t.createIndexBuffer(o),this._tileDebugBuffer=t.createVertexBuffer(n,e.aS.members),this._tileDebugSegments=e.aE.simpleSegment(0,0,n.length,o.length)}_makeTileBoundsBuffers(t,r){if(this._tileBoundsBuffer||!r||"mercator"===r.name)return;const i=e.aP(Ft,this.tileID.canonical,this.tileTransform)[0];let n,o;if(this.isRaster){const t=function(t,r){const i=e.av(t,r),n=Math.pow(2,t.z);for(let o=0;o<Le;o++)for(let s=0;s<Le;s++){const a=e.aw((t.x+(s+Fe(s))/ke)/n),l=e.ax((t.y+(o+Fe(o))/ke)/n),c=r.project(a,l),u=o*Le+s;Oe[2*u+0]=Math.round((c.x*i.scale-i.x)*e.Y),Oe[2*u+1]=Math.round((c.y*i.scale-i.y)*e.Y)}Be.fill(0),Re.fill(0);for(let e=2045;e>=0;e--){const t=4*e,r=ze[t+0],i=ze[t+1],n=ze[t+2],o=ze[t+3],s=r+n>>1,a=i+o>>1,l=s+a-i,c=a+r-s,u=i*Le+r,h=o*Le+n,d=a*Le+s,p=Math.hypot((Oe[2*u+0]+Oe[2*h+0])/2-Oe[2*d+0],(Oe[2*u+1]+Oe[2*h+1])/2-Oe[2*d+1])>=16;Be[d]=Be[d]||(p?1:0),e<1022&&(Be[d]=Be[d]||Be[(i+c>>1)*Le+(r+l>>1)]||Be[(o+c>>1)*Le+(n+l>>1)])}const o=new e.ay,s=new e.az;let a=0;function l(t,r){const i=r*Le+t;return 0===Re[i]&&(o.emplaceBack(Oe[2*i+0],Oe[2*i+1],t*e.Y/ke,r*e.Y/ke),Re[i]=++a),Re[i]-1}function c(e,t,r,i,n,o){const a=e+r>>1,u=t+i>>1;if(Math.abs(e-n)+Math.abs(t-o)>1&&Be[u*Le+a])c(n,o,e,t,a,u),c(r,i,n,o,a,u);else{const a=l(e,t),c=l(r,i),u=l(n,o);s.emplaceBack(a,c,u)}}return c(0,0,ke,ke,ke,0),c(ke,ke,0,0,0,ke),{vertices:o,indices:s}}(this.tileID.canonical,r);n=t.vertices,o=t.indices}else{n=new e.ay,o=new e.az;for(const{x:e,y:t}of i)n.emplaceBack(e,t,0,0);const t=e.aT(n.int16,void 0,4);for(let e=0;e<t.length;e+=3)o.emplaceBack(t[e],t[e+1],t[e+2])}this._tileBoundsBuffer=t.createVertexBuffer(n,e.aU.members),this._tileBoundsIndexBuffer=t.createIndexBuffer(o),this._tileBoundsSegments=e.aE.simpleSegment(0,0,n.length,o.length)}_makeGlobeTileDebugBuffers(t,r){const i=r.projection;if(!i||"globe"!==i.name||r.freezeTileCoverage)return;const n=this.tileID.canonical,o=e.aV(n,r),s=e.aW(o),a=e.W(r.zoom);let l;a>0&&(l=e.a9.invert(new Float64Array(16),r.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(t,n,r,s,l,a),this._makeGlobeTileDebugTextBuffer(t,n,r,s,l,a)}_globePoint(t,r,i,n,o,s,a){let l=e.aX(t,r,i);if(s){const o=1<<i.z,c=e.a8(n.center.lng),u=e.ah(n.center.lat),h=(i.x+.5)/o-c;let d=0;h>.5?d=-1:h<-.5&&(d=1);let p=(t/e.Y+i.x)/o+d,f=(r/e.Y+i.y)/o;p=(p-c)*n._pixelsPerMercatorPixel+c,f=(f-u)*n._pixelsPerMercatorPixel+u;const m=[p*n.worldSize,f*n.worldSize,0];e.Q.transformMat4(m,m,s),l=e.aY(l,m,a)}return e.Q.transformMat4(l,l,o)}_makeGlobeTileDebugBorderBuffer(t,r,i,n,o,s){const a=new e.aQ,l=new e.aR,c=new e.aZ,u=(e,t,u,h,d)=>{const p=(u-e)/(d-1),f=(h-t)/(d-1),m=a.length;for(let u=0;u<d;u++){const h=e+u*p,d=t+u*f;a.emplaceBack(h,d);const A=this._globePoint(h,d,r,i,n,o,s);c.emplaceBack(A[0],A[1],A[2]),l.emplaceBack(m+u)}},h=e.Y;u(0,0,h,0,16),u(h,0,h,h,16),u(h,h,0,h,16),u(0,h,0,0,16),this._tileDebugIndexBuffer=t.createIndexBuffer(l),this._tileDebugBuffer=t.createVertexBuffer(a,e.aS.members),this._globeTileDebugBorderBuffer=t.createVertexBuffer(c,e.a_.members),this._tileDebugSegments=e.aE.simpleSegment(0,0,a.length,l.length)}_makeGlobeTileDebugTextBuffer(t,r,i,n,o,s){const a=e.Y/4,l=new e.aQ,c=new e.az,u=new e.aZ,h=25;c.reserve(32),l.reserve(h),u.reserve(h);const d=(e,t)=>h*e+t;for(let e=0;e<h;e++){const t=e*a;for(let e=0;e<h;e++){const c=e*a;l.emplaceBack(c,t);const h=this._globePoint(c,t,r,i,n,o,s);u.emplaceBack(h[0],h[1],h[2])}}for(let e=0;e<4;e++)for(let t=0;t<4;t++){const r=d(e,t),i=d(e,t+1),n=d(e+1,t),o=d(e+1,t+1);c.emplaceBack(r,i,n),c.emplaceBack(n,i,o)}this._tileDebugTextIndexBuffer=t.createIndexBuffer(c),this._tileDebugTextBuffer=t.createVertexBuffer(l,e.aS.members),this._globeTileDebugTextBuffer=t.createVertexBuffer(u,e.a_.members),this._tileDebugTextSegments=e.aE.simpleSegment(0,0,h,32)}destroy(t=!1){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&(this.imageAtlasTexture.destroy(),delete this.imageAtlasTexture),this.glyphAtlasTexture&&(this.glyphAtlasTexture.destroy(),delete this.glyphAtlasTexture),this.lineAtlasTexture&&(this.lineAtlasTexture.destroy(),delete this.lineAtlasTexture),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),!t&&this.texture&&this.texture instanceof e.T&&(this.texture.destroy(),delete this.texture),this.hillshadeFBO&&(this.hillshadeFBO.destroy(),delete this.hillshadeFBO),this.dem&&delete this.dem,this.neighboringTiles&&delete this.neighboringTiles,this.demTexture&&(this.demTexture.destroy(),delete this.demTexture),this.rasterParticleState&&(this.rasterParticleState.destroy(),delete this.rasterParticleState),this.latestFeatureIndex=null,this.state="unloaded"}}const Vt={vector:Ie,raster:Pe,"raster-dem":class extends Pe{constructor(t,r,i,n){super(t,r,i,n),this.type="raster-dem",this.maxzoom=22,this._options=e.e({type:"raster-dem"},r),this.encoding=r.encoding||"mapbox"}loadTile(t,r){const i=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function n(e,i){e&&(t.state="errored",r(e)),i&&(t.dem=i,t.dem.onDeserialize(),t.needsHillshadePrepare=!0,t.needsDEMTextureUpload=!0,t.state="loaded",r(null))}t.request=e.d(this.map._requestManager.transformRequest(i,e.R.Tile),function(i,o,s,a){if(delete t.request,t.aborted)t.state="unloaded",r(null);else if(i)t.state="errored",r(i);else if(o){this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:s,expires:a});const r=ImageBitmap&&o instanceof ImageBitmap&&e.an(),i=1-(o.width-e.ao(o.width))/2;i<1||t.neighboringTiles||(t.neighboringTiles=this._getNeighboringTiles(t.tileID));const l=r?o:e.f.getImageData(o,i),c={uid:t.uid,coord:t.tileID,source:this.id,scope:this.scope,rawImageData:l,encoding:this.encoding,padding:i};t.actor&&"expired"!==t.state||(t.actor=this.dispatcher.getActor(),t.actor.send("loadDEMTile",c,n.bind(this),void 0,!0))}}.bind(this))}_getNeighboringTiles(t){const r=t.canonical,i=Math.pow(2,r.z),n=(r.x-1+i)%i,o=0===r.x?t.wrap-1:t.wrap,s=(r.x+1+i)%i,a=r.x+1===i?t.wrap+1:t.wrap,l={};return l[new e.ap(t.overscaledZ,o,r.z,n,r.y).key]={backfilled:!1},l[new e.ap(t.overscaledZ,a,r.z,s,r.y).key]={backfilled:!1},r.y>0&&(l[new e.ap(t.overscaledZ,o,r.z,n,r.y-1).key]={backfilled:!1},l[new e.ap(t.overscaledZ,t.wrap,r.z,r.x,r.y-1).key]={backfilled:!1},l[new e.ap(t.overscaledZ,a,r.z,s,r.y-1).key]={backfilled:!1}),r.y+1<i&&(l[new e.ap(t.overscaledZ,o,r.z,n,r.y+1).key]={backfilled:!1},l[new e.ap(t.overscaledZ,t.wrap,r.z,r.x,r.y+1).key]={backfilled:!1},l[new e.ap(t.overscaledZ,a,r.z,s,r.y+1).key]={backfilled:!1}),l}},"raster-array":De,geojson:class extends e.E{constructor(t,r,i,n){super(),this.id=t,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._loaded=!1,this.actor=i.getActor(),this.setEventedParent(n),this._data=r.data,this._options=e.e({},r),this._collectResourceTiming=r.collectResourceTiming,void 0!==r.maxzoom&&(this.maxzoom=r.maxzoom),void 0!==r.minzoom&&(this.minzoom=r.minzoom),r.type&&(this.type=r.type),r.attribution&&(this.attribution=r.attribution),this.promoteId=r.promoteId;const o=e.Y/this.tileSize;this.workerOptions=e.e({source:this.id,scope:this.scope,cluster:r.cluster||!1,geojsonVtOptions:{buffer:(void 0!==r.buffer?r.buffer:128)*o,tolerance:(void 0!==r.tolerance?r.tolerance:.375)*o,extent:e.Y,maxZoom:this.maxzoom,lineMetrics:r.lineMetrics||!1,generateId:r.generateId||!1},superclusterOptions:{maxZoom:void 0!==r.clusterMaxZoom?r.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,r.clusterMinPoints||2),extent:e.Y,radius:(void 0!==r.clusterRadius?r.clusterRadius:50)*o,log:!1,generateId:r.generateId||!1},clusterProperties:r.clusterProperties,filter:r.filter,dynamic:r.dynamic},r.workerOptions)}onAdd(e){this.map=e,this.setData(this._data)}setData(e){return this._data=e,this._updateWorkerData(),this}updateData(t){return this._options.dynamic?(this._data=t,this._updateWorkerData(!0),this):this.fire(new e.a(new Error("Can't call updateData on a GeoJSON source with dynamic set to false.")))}getClusterExpansionZoom(e,t){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:e,source:this.id,scope:this.scope},t),this}getClusterChildren(e,t){return this.actor.send("geojson.getClusterChildren",{clusterId:e,source:this.id,scope:this.scope},t),this}getClusterLeaves(e,t,r,i){return this.actor.send("geojson.getClusterLeaves",{source:this.id,scope:this.scope,clusterId:e,limit:t,offset:r},i),this}_updateWorkerData(t=!1){if(this._pendingLoad)return void(this._coalesce=!0);this.fire(new e.b("dataloading",{dataType:"source"})),this._loaded=!1;const r=e.e({append:t},this.workerOptions);r.scope=this.scope;const i=this._data;"string"==typeof i?(r.request=this.map._requestManager.transformRequest(e.f.resolveURL(i),e.R.Source),r.request.collectResourceTiming=this._collectResourceTiming):r.data=JSON.stringify(i),this._pendingLoad=this.actor.send(`${this.type}.loadData`,r,((r,i)=>{if(this._loaded=!0,this._pendingLoad=null,r)this.fire(new e.a(r));else{const t={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&i&&i.resourceTiming&&i.resourceTiming[this.id]&&(t.resourceTiming=i.resourceTiming[this.id]),this.fire(new e.b("data",t)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(t),this._coalesce=!1)}))}loaded(){return this._loaded}loadTile(t,r){const i=t.actor?"reloadTile":"loadTile";t.actor=this.actor;const n={type:this.type,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,scope:this.scope,pixelRatio:e.f.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,brightness:this.map.style&&this.map.style.getBrightness()||0};t.request=this.actor.send(i,n,((e,n)=>(delete t.request,t.destroy(),t.aborted?r(null):e?r(e):(t.loadVectorData(n,this.map.painter,"reloadTile"===i),r(null)))),void 0,"loadTile"===i)}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.aborted=!0}unloadTile(e){this.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope}),e.destroy()}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return e.e({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends e.as{constructor(e,t,r,i){super(e,t,r,i),this.roundZoom=!0,this.type="video",this.options=t}load(){this._loaded=!1;const t=this.options;this.urls=[];for(const r of t.urls)this.urls.push(this.map._requestManager.transformRequest(r,e.R.Source).url);e.at(this.urls,((t,r)=>{this._loaded=!0,t?this.fire(new e.a(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(t){if(this.video){const r=this.video.seekable;t<r.start(0)||t>r.end(0)?this.fire(new e.a(new e.V(`sources.${this.id}`,null,`Playback for this video can be set only between the ${r.start(0)} and ${r.end(0)}-second mark.`))):this.video.currentTime=t}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const t=this.map.painter.context,r=t.gl;this.texture?this.video.paused||(this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE),r.texSubImage2D(r.TEXTURE_2D,0,0,0,r.RGBA,r.UNSIGNED_BYTE,this.video)):(this.texture=new e.T(t,this.video,r.RGBA),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(t)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:e.as,model:class extends e.E{constructor(e,t,r,i){super(),this.id=e,this.type="model",this.models=[],this._loaded=!1,this._options=t}load(){const t=[];for(const r in this._options.models){const i=this._options.models[r],n=e.l(this.map._requestManager.transformRequest(i.uri,e.R.Model).url).then((t=>{if(!t)return;const n=e.c(t),o=new e.M(r,i.position,i.orientation,n);o.computeBoundsAndApplyParent(),this.models.push(o)})).catch((t=>{this.fire(new e.a(new Error(`Could not load model ${r} from ${i.uri}: ${t.message}`)))}));t.push(n)}return Promise.allSettled(t).then((()=>{this._loaded=!0,this.fire(new e.b("data",{dataType:"source",sourceDataType:"metadata"}))})).catch((t=>{this.fire(new e.a(new Error(`Could not load models: ${t.message}`)))}))}onAdd(e){this.map=e,this.load()}hasTransition(){return!1}loaded(){return this._loaded}getModels(){return this.models}loadTile(e,t){}serialize(){return{type:"model"}}},"batched-model":class extends e.E{constructor(e,t,r,i){super(),this.type="batched-model",this.id=e,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(i)}onAdd(e){this.map=e,this.load()}load(t){this._loaded=!1,this.fire(new e.b("dataloading",{dataType:"source"}));const r=Array.isArray(this.map._language)?this.map._language.join():this.map._language,i=this.map._worldview;this._tileJSONRequest=Me(this._options,this.map._requestManager,r,i,((n,o)=>{this._tileJSONRequest=null,this._loaded=!0,n?(r&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${r}`),i&&2!==i.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${i}`),this.fire(new e.a(n))):o&&(e.e(this,o),o.bounds&&(this.tileBounds=new Se(o.bounds,this.minzoom,this.maxzoom)),e.am(o.tiles,this.map._requestManager._customAccessToken),this.fire(new e.b("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.b("data",{dataType:"source",sourceDataType:"content"}))),t&&t(n)}))}hasTransition(){return!1}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loaded(){return this._loaded}loadTile(t,r){const i=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme)),n={request:this.map._requestManager.transformRequest(i,e.R.Tile),data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,showCollisionBoxes:this.map.showCollisionBoxes,isSymbolTile:t.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0};if(t.actor&&"expired"!==t.state)if("loading"===t.state)t.reloadCallback=r;else{if(t.buckets){const e=Object.values(t.buckets);for(const t of e)t.dirty=!0;return void(t.state="loaded")}t.request=t.actor.send("reloadTile",n,o.bind(this))}else t.actor=this.dispatcher.getActor(),t.request=t.actor.send("loadTile",n,o.bind(this),void 0,!0);function o(e,i){return t.aborted?r(null):e&&404!==e.status?r(e):(i&&(i.resourceTiming&&(t.resourceTiming=i.resourceTiming),this.map._refreshExpiredTiles&&t.setExpiryData(i),t.buckets={...t.buckets,...i.buckets},i.featureIndex&&(t.latestFeatureIndex=i.featureIndex)),t.state="loaded",void r(null))}}serialize(){return e.e({},this._options)}},canvas:class extends e.as{constructor(t,r,i,n){super(t,r,i,n),r.coordinates?Array.isArray(r.coordinates)&&4===r.coordinates.length&&!r.coordinates.some((e=>!Array.isArray(e)||2!==e.length||e.some((e=>"number"!=typeof e))))||this.fire(new e.a(new e.V(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new e.a(new e.V(`sources.${t}`,null,'missing required property "coordinates"'))),r.animate&&"boolean"!=typeof r.animate&&this.fire(new e.a(new e.V(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),r.canvas?"string"==typeof r.canvas||r.canvas instanceof HTMLCanvasElement||this.fire(new e.a(new e.V(`sources.${t}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new e.a(new e.V(`sources.${t}`,null,'missing required property "canvas"'))),this.options=r,this.animate=void 0===r.animate||r.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 e.a(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const r=this.map.painter.context;this.texture?!t&&!this._playing||this.texture instanceof e.au||this.texture.update(this.canvas,{premultiply:!0}):this.texture=new e.T(r,this.canvas,r.gl.RGBA,{premultiply:!0}),this._prepareData(r)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const e of[this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return!0;return!1}},custom:class extends e.E{constructor(t,r,i,n){super(),this.id=t,this.type="custom",this._dataType="raster",this._dispatcher=i,this._implementation=r,this.setEventedParent(n),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new e.a(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new e.a(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new Se(this._implementation.bounds,this.minzoom,this.maxzoom)),r.update=this._update.bind(this),r.clearTiles=this._clearTiles.bind(this),r.coveringTiles=this._coveringTiles.bind(this),e.e(this,e.af(r,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return e.af(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new e.b("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.b("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(t){this._map=t,this._loaded=!1,this.fire(new e.b("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(t),this.load()}onRemove(e){this._implementation.onRemove&&this._implementation.onRemove(e)}hasTile(e){if(this._implementation.hasTile){const{x:t,y:r,z:i}=e.canonical;return this._implementation.hasTile({x:t,y:r,z:i})}return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e,t){const{x:r,y:i,z:n}=e.tileID.canonical,o=new AbortController;e.request=Promise.resolve(this._implementation.loadTile({x:r,y:i,z:n},{signal:o.signal})).then(function(r){return delete e.request,e.aborted?(e.state="unloaded",t(null)):void 0===r?(e.state="errored",t(null)):null===r?(this.loadTileData(e,{width:this.tileSize,height:this.tileSize,data:null}),e.state="loaded",t(null)):function(e){return e instanceof ImageData||e instanceof HTMLCanvasElement||e instanceof ImageBitmap||e instanceof HTMLImageElement}(r)?(this.loadTileData(e,r),e.state="loaded",void t(null)):(e.state="errored",t(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}.bind(this)).catch((r=>{20!==r.code&&(e.state="errored",t(r))})),e.request.cancel=()=>o.abort()}loadTileData(e,t){e.setTexture(t,this._map.painter)}unloadTile(t,r){if(t.texture&&t.texture instanceof e.T?(t.destroy(!0),t.texture&&t.texture instanceof e.T&&this._map.painter.saveTileTexture(t.texture)):t.destroy(),this._implementation.unloadTile){const{x:e,y:r,z:i}=t.tileID.canonical;this._implementation.unloadTile({x:e,y:r,z:i})}r()}abortTile(e,t){e.request&&e.request.cancel&&(e.request.cancel(),delete e.request),t()}hasTransition(){return!1}_coveringTiles(){return this._map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map((e=>({x:e.canonical.x,y:e.canonical.y,z:e.canonical.z})))}_clearTiles(){const t=e.aj(this.id,this.scope);this._map.style.clearSource(t)}_update(){this.fire(new e.b("data",{dataType:"source",sourceDataType:"content"}))}}},Nt=function(t,r,i,n){const o=new Vt[r.type](t,r,i,n);if(o.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${o.id}`);return e.a$(["load","abort","unload","serialize","prepare"],o),o};function Ut(t,r){const i=e.a9.identity([]);return e.a9.scale(i,i,[.5*t.width,.5*-t.height,1]),e.a9.translate(i,i,[1,-1,0]),e.a9.multiply(i,i,t.calculateProjMatrix(r.toUnwrapped())),Float32Array.from(i)}function Ht(e,t,r,i,n,o,s,a=!1){const l=e.tilesIn(i,s,a);l.sort(Zt);const c=[];for(const i of l)c.push({wrappedTileID:i.tile.tileID.wrapped().key,queryResults:i.tile.queryRenderedFeatures(t,r,e._state,i,n,o,Ut(e.transform,i.tile.tileID),a)});const u=function(e){const t={},r={};for(const i of e){const e=i.queryResults,n=i.wrappedTileID,o=r[n]=r[n]||{};for(const r in e){const i=e[r],n=o[r]=o[r]||{},s=t[r]=t[r]||[];for(const e of i)n[e.featureIndex]||(n[e.featureIndex]=!0,s.push(e))}}return t}(c);for(const t in u)u[t].forEach((t=>{const r=t.feature,i=r.layer;i&&"background"!==i.type&&"sky"!==i.type&&"slot"!==i.type&&(r.source=i.source,i["source-layer"]&&(r.sourceLayer=i["source-layer"]),r.state=void 0!==r.id?e.getFeatureState(i["source-layer"],r.id):{})}));return u}function Gt(e,t){const r=e.getRenderableIds().map((t=>e.getTileByID(t))),i=[],n={};for(let e=0;e<r.length;e++){const o=r[e],s=o.tileID.canonical.key;n[s]||(n[s]=!0,o.querySourceFeatures(i,t))}return i}function Zt(e,t){const r=e.tileID,i=t.tileID;return r.overscaledZ-i.overscaledZ||r.canonical.y-i.canonical.y||r.wrap-i.wrap||r.canonical.x-i.canonical.x}class Wt extends jt{constructor(e,t,r,i,n){super(e,t,r,i,n),this._workQueue=[],this._fetchQueue=[],this._isHeaderLoaded=!1}setTexture(t,r){const i=r.context,n=i.gl;this.texture=this.texture||r.getTileTexture(t.width),this.texture&&this.texture instanceof e.T?this.texture.update(t,{useMipmap:!1,premultiply:!1}):this.texture=new e.T(i,t,n.RGBA,{useMipmap:!1,premultiply:!1})}flushQueues(){for(;this._workQueue.length;)this._workQueue.pop()();for(;this._fetchQueue.length;)this._fetchQueue.pop()()}fetchHeader(t=16384,r){const i=this._mrt=new e.b0(30),n=Object.assign({},this.requestParams,{headers:{Range:"bytes=0-"+(t-1)}});return this.entireBuffer=null,this.request=e.b1(n,((e,n,o,s)=>{if(e)r(e);else try{const e=i.getHeaderLength(n);if(e>t)return void(this.request=this.fetchHeader(e,r));i.parseHeader(n),this._isHeaderLoaded=!0;let a=0;for(const e of Object.values(i.layers))a=Math.max(a,e.dataIndex[e.dataIndex.length-1].last_byte);n.byteLength>=a&&(this.entireBuffer=n),r(null,this.entireBuffer||n,o,s)}catch(e){r(e)}})),this.request}fetchBand(t,r,i){const n=this._mrt;if(!this._isHeaderLoaded||!n)return void i(new Error("Tile header is not ready"));const o=this.actor;if(!o)return void i(new Error("Can't fetch tile band without an actor"));let s;const a=(e,n)=>{s.complete(e,n),e?i(e):(this.updateTextureDescriptor(t,r),i(null,this.textureDescriptor&&this.textureDescriptor.img))},l=(e,t)=>{if(e)return i(e);const r=o.send("decodeRasterArray",{buffer:t,task:s},a,void 0,!0);this._workQueue.push((()=>{r&&r.cancel(),s.cancel()}))},c=n.getLayer(t);if(!c)return void i(new Error(`Unknown sourceLayer "${t}"`));if(c.hasDataForBand(r))return this.updateTextureDescriptor(t,r),void i(null,this.textureDescriptor?this.textureDescriptor.img:null);const u=c.getDataRange([r]);if(s=n.createDecodingTask(u),!s||s.tasks.length)if(this.flushQueues(),this.entireBuffer)l(null,this.entireBuffer.slice(u.firstByte,u.lastByte+1));else{const t=Object.assign({},this.requestParams,{headers:{Range:`bytes=${u.firstByte}-${u.lastByte}`}}),r=e.b1(t,l);this._fetchQueue.push((()=>{r.cancel(),s.cancel()}))}else i(null)}updateNeeded(e,t){return(!this.textureDescriptor||this.textureDescriptor.band!==t||this.textureDescriptor.layer!==e)&&"errored"!==this.state}updateTextureDescriptor(t,r){if(!this._mrt)return;const i=this._mrt.getLayer(t);if(!i||!i.hasBand(r)||!i.hasDataForBand(r))return;const{bytes:n,tileSize:o,buffer:s,offset:a,scale:l}=i.getBandView(r),c=o+2*s,u={data:n,width:c,height:c},h=this.texture;h&&h instanceof e.T&&h.update(u,{useMipmap:!1,premultiply:!1}),this.textureDescriptor={layer:t,band:r,img:u,buffer:s,offset:a,tileSize:o,format:i.pixelFormat,mix:[l,256*l,65536*l,16777216*l]}}}class Qt{constructor(e,t){this.max=e,this.onRemove=t,this.reset()}reset(){for(const e in this.data)for(const t of this.data[e])t.timeout&&clearTimeout(t.timeout),this.onRemove(t.value);return this.data={},this.order=[],this}add(e,t,r){const i=e.wrapped().key;void 0===this.data[i]&&(this.data[i]=[]);const n={value:t,timeout:void 0};if(void 0!==r&&(n.timeout=setTimeout((()=>{this.remove(e,n)}),r)),this.data[i].push(n),this.order.push(i),this.order.length>this.max){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){const t=this.data[e].shift();return t.timeout&&clearTimeout(t.timeout),0===this.data[e].length&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),t.value}getByKey(e){const t=this.data[e];return t?t[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,t){if(!this.has(e))return this;const r=e.wrapped().key,i=void 0===t?0:this.data[r].indexOf(t),n=this.data[r][i];return this.data[r].splice(i,1),n.timeout&&clearTimeout(n.timeout),0===this.data[r].length&&delete this.data[r],this.onRemove(n.value),this.order.splice(this.order.indexOf(r),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}filter(e){const t=[];for(const r in this.data)for(const i of this.data[r])e(i.value)||t.push(i);for(const e of t)this.remove(e.value.tileID,e)}}class qt extends e.E{constructor(e,t,r){super(),this.id=e,this._onlySymbols=r,t.on("data",(e=>{"source"===e.dataType&&"metadata"===e.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===e.dataType&&"content"===e.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))})),t.on("error",(()=>{this._sourceErrored=!0})),this._source=t,this._tiles={},this._cache=new Qt(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new x,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(e){this.map=e,this._minTileCacheSize=void 0===this._minTileCacheSize&&e?e._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&e?e._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const e in this._tiles){const t=this._tiles[e];if("errored"!==t.state&&("loaded"!==t.state||!t.bucketsLoaded()))return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(e,t){return e.isSymbolTile=this._onlySymbols,e.isExtraShadowCaster=this._shadowCasterTiles[e.tileID.key],this._source.loadTile(e,t)}_unloadTile(e){if(this._source.unloadTile)return this._source.unloadTile(e,(()=>{}))}_abortTile(e){if(this._source.abortTile)return this._source.abortTile(e,(()=>{}))}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const t in this._tiles){const r=this._tiles[t];r.upload(e),r.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return e.b2(this._tiles).map((e=>e.tileID)).sort(Xt).map((e=>e.key))}getRenderableIds(t,r){const i=[];for(const e in this._tiles)this._isIdRenderable(+e,t,r)&&i.push(this._tiles[e]);return t?i.sort(((t,r)=>{const i=t.tileID,n=r.tileID,o=new e.P(i.canonical.x,i.canonical.y)._rotate(this.transform.angle),s=new e.P(n.canonical.x,n.canonical.y)._rotate(this.transform.angle);return i.overscaledZ-n.overscaledZ||s.y-o.y||s.x-o.x})).map((e=>e.tileID.key)):i.map((e=>e.tileID)).sort(Xt).map((e=>e.key))}hasRenderableParent(e){const t=this.findLoadedParent(e,0);return!!t&&this._isIdRenderable(t.tileID.key)}_isIdRenderable(e,t,r){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(t||!this._tiles[e].holdingForFade())&&(r||!this._shadowCasterTiles[e])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const e in this._tiles)"errored"!==this._tiles[e].state&&this._reloadTile(+e,"reloading")}}_reloadTile(e,t){const r=this._tiles[e];r&&("loading"!==r.state&&(r.state=t),this._loadTile(r,this._tileLoaded.bind(this,r,e,t)))}_tileLoaded(t,r,i,n){if(n)if(t.state="errored",404!==n.status)this._source.fire(new e.a(n,{tile:t}));else{if(!(t.tileID.key in this._loadedParentTiles))return void this._source.fire(new e.b("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id}));if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const e=this.map.painter.terrain;this.update(this.transform,e.getScaledDemTileSize(),!0),e.resetTileLookupCache(this.id)}else this.update(this.transform)}else t.timeAdded=e.f.now(),"expired"===i&&(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 e.b("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id}))}_backfillDEM(e){const t=this.getRenderableIds();for(let i=0;i<t.length;i++){const n=t[i];if(e.neighboringTiles&&e.neighboringTiles[n]){const t=this.getTileByID(n);r(e,t),r(t,e)}}function r(e,t){if(!e.dem||e.dem.borderReady)return;e.needsHillshadePrepare=!0,e.needsDEMTextureUpload=!0;let r=t.tileID.canonical.x-e.tileID.canonical.x;const i=t.tileID.canonical.y-e.tileID.canonical.y,n=Math.pow(2,e.tileID.canonical.z),o=t.tileID.key;0===r&&0===i||Math.abs(i)>1||(Math.abs(r)>1&&(1===Math.abs(r+n)?r+=n:1===Math.abs(r-n)&&(r-=n)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,r,i),e.neighboringTiles&&e.neighboringTiles[o]&&(e.neighboringTiles[o].backfilled=!0)))}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,t,r,i){for(const n in this._tiles){let o=this._tiles[n];if(i[n]||!o.hasData()||o.tileID.overscaledZ<=t||o.tileID.overscaledZ>r)continue;let s=o.tileID;for(;o&&o.tileID.overscaledZ>t+1;){const e=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[e.key],o&&o.hasData()&&(s=e)}let a=s;for(;a.overscaledZ>t;)if(a=a.scaledTo(a.overscaledZ-1),e[a.key]){i[s.key]=s;break}}}findLoadedParent(e,t){if(e.key in this._loadedParentTiles){const r=this._loadedParentTiles[e.key];return r&&r.tileID.overscaledZ>=t?r:null}for(let r=e.overscaledZ-1;r>=t;r--){const t=e.scaledTo(r),i=this._getLoadedTile(t);if(i)return i}}_getLoadedTile(e){const t=this._tiles[e.key];return t&&t.hasData()?t:this._cache.getByKey(this._source.reparseOverscaled?e.wrapped().key:e.canonical.key)}updateCacheSize(e,t){t=t||this._source.tileSize;const r=Math.ceil(e.width/t)+1,i=Math.ceil(e.height/t)+1,n=Math.floor(r*i*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,n):n,s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(s)}handleWrapJump(e){const t=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);if(this._prevLng=e,t){const e={};for(const r in this._tiles){const i=this._tiles[r];i.tileID=i.tileID.unwrapTo(i.tileID.wrap+t),e[i.tileID.key]=i}this._tiles=e;for(const e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const e in this._tiles)this._setTileReloadTimer(+e,this._tiles[e])}}update(t,r,i,n){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!i)return;let o;if(this.updateCacheSize(t,r),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={},this.used||this.usedForTerrain)if(this._source.tileID)o=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new e.ap(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y)));else if(0!==this.tileCoverLift){const n=t.clone();n.tileCoverLift=this.tileCoverLift,o=n.coveringTiles({tileSize:r||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!i,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.minzoom<=1&&"globe"===t.projection.name&&(o.push(new e.ap(1,0,1,0,0)),o.push(new e.ap(1,0,1,1,0)),o.push(new e.ap(1,0,1,0,1)),o.push(new e.ap(1,0,1,1,1)))}else o=t.coveringTiles({tileSize:r||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!i,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(o=o.filter((e=>this._source.hasTile(e))));else o=[];if(o.length>0&&this.castsShadows&&n&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!Yt(this._source.type)){const e=t.coveringZoomLevel({tileSize:r||this._source.tileSize,roundZoom:this._source.roundZoom&&!i}),s=Math.min(e,this._source.maxzoom),a=t.extendTileCoverForShadows(o,n,s);for(const e of a)this._shadowCasterTiles[e.key]=!0,o.push(e)}const s=this._updateRetainedTiles(o);if(Yt(this._source.type)&&0!==o.length){const t={},r={},i=Object.keys(s);for(const n of i){const i=s[n],o=this._tiles[n];if(!o||o.fadeEndTime&&o.fadeEndTime<=e.f.now())continue;const a=this.findLoadedParent(i,Math.max(i.overscaledZ-qt.maxOverzooming,this._source.minzoom));a&&(this._addTile(a.tileID),t[a.tileID.key]=a.tileID),r[n]=i}const n=o[o.length-1].overscaledZ;for(const e in this._tiles){const t=this._tiles[e];if(s[e]||!t.hasData())continue;let i=t.tileID;for(;i.overscaledZ>n;){i=i.scaledTo(i.overscaledZ-1);const n=this._tiles[i.key];if(n&&n.hasData()&&r[i.key]){s[e]=t.tileID;break}}}for(const e in t)s[e]||(this._coveredTiles[e]=!0,s[e]=t[e])}for(const e in s)this._tiles[e].clearFadeHold();const a=e.b3(this._tiles,s);for(const e of a){const t=this._tiles[e];t.hasSymbolBuckets&&!t.holdingForFade()?t.setHoldDuration(this.map._fadeDuration):t.hasSymbolBuckets&&!t.symbolFadeFinished()||this._removeTile(+e)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(+e)}_updateRetainedTiles(e){const t={};if(0===e.length)return t;const r={},i=e.reduce(((e,t)=>Math.min(e,t.overscaledZ)),1/0),n=e[0].overscaledZ,o=Math.max(n-qt.maxOverzooming,this._source.minzoom),s=Math.max(n+qt.maxUnderzooming,this._source.minzoom),a={};for(const r of e){const e=this._addTile(r);t[r.key]=r,e.hasData()||i<this._source.maxzoom&&(a[r.key]=r)}this._retainLoadedChildren(a,i,s,t);for(const i of e){let e=this._tiles[i.key];if(e.hasData())continue;if(i.canonical.z>=this._source.maxzoom){const e=i.children(this._source.maxzoom)[0],r=this.getTile(e);if(r&&r.hasData()){t[e.key]=e;continue}}else{const e=i.children(this._source.maxzoom);if(t[e[0].key]&&t[e[1].key]&&t[e[2].key]&&t[e[3].key])continue}let n=e.wasRequested();for(let s=i.overscaledZ-1;s>=o;--s){const o=i.scaledTo(s);if(r[o.key])break;if(r[o.key]=!0,e=this.getTile(o),!e&&n&&(e=this._addTile(o)),e&&(t[o.key]=o,n=e.wasRequested(),e.hasData()))break}}return t}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const t=[];let r,i=this._tiles[e].tileID;for(;i.overscaledZ>0;){if(i.key in this._loadedParentTiles){r=this._loadedParentTiles[i.key];break}t.push(i.key);const e=i.scaledTo(i.overscaledZ-1);if(r=this._getLoadedTile(e),r)break;i=e}for(const e of t)this._loadedParentTiles[e]=r}}_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 i=Boolean(r);if(!i){const e=this.map?this.map.painter:null,i=this._source.tileSize*t.overscaleFactor();r="raster-array"===this._source.type?new Wt(t,i,this.transform.tileZoom,e,this._isRaster):new jt(t,i,this.transform.tileZoom,e,this._isRaster),this._loadTile(r,this._tileLoaded.bind(this,r,t.key,r.state))}return r?(r.uses++,this._tiles[t.key]=r,i||this._source.fire(new e.b("dataloading",{tile:r,coord:r.tileID,dataType:"source"})),r):null}_setTileReloadTimer(e,t){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const r=t.getExpiryTimeout();r&&(this._timers[e]=setTimeout((()=>{this._reloadTile(e,"expired"),delete this._timers[e]}),r))}_removeTile(e){const t=this._tiles[e];t&&(t.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),t.uses>0||(t.hasData()&&"reloading"!==t.state||"empty"===t.state?this._cache.add(t.tileID,t,t.getExpiryTimeout()):(t.aborted=!0,this._abortTile(t),this._unloadTile(t))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(+e);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,i){const n=[],o=this.transform;if(!o)return n;const s="globe"===o.projection.name,a=e.a8(o.center.lng);for(const l in this._tiles){const c=this._tiles[l];if(i&&c.clearQueryDebugViz(),c.holdingForFade())continue;let u;if(s){const t=c.tileID.canonical;if(0===t.z){const r=[Math.abs(e.ad(a,...$t(t,-1))-a),Math.abs(e.ad(a,...$t(t,1))-a)];u=[0,2*r.indexOf(Math.min(...r))-1]}else{const r=[Math.abs(e.ad(a,...$t(t,-1))-a),Math.abs(e.ad(a,...$t(t,0))-a),Math.abs(e.ad(a,...$t(t,1))-a)];u=[r.indexOf(Math.min(...r))-1]}}else u=[0];for(const e of u){const i=t.containsTile(c,o,r,e);i&&n.push(i)}}return n}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(e){return this._getRenderableCoordinates(e)}_getRenderableCoordinates(e,t){const r=this.getRenderableIds(e,t).map((e=>this._tiles[e].tileID)),i="globe"===this.transform.projection.name;for(const e of r)e.projMatrix=this.transform.calculateProjMatrix(e.toUnwrapped()),e.expandedProjMatrix=i?this.transform.calculateProjMatrix(e.toUnwrapped(),!1,!0):e.projMatrix;return r}sortCoordinatesByDistance(e){const t=e.slice(),r=this.transform._camera.position,i=this.transform._camera.forward(),n={};for(const e of t){const t=1/(1<<e.canonical.z);n[e.key]=((e.canonical.x+.5)*t+e.wrap-r[0])*i[0]+((e.canonical.y+.5)*t-r[1])*i[1]-r[2]*i[2]}return t.sort(((e,t)=>n[e.key]-n[t.key])),t}hasTransition(){if(this._source.hasTransition())return!0;if(Yt(this._source.type))for(const t in this._tiles){const r=this._tiles[t];if(void 0!==r.fadeEndTime&&r.fadeEndTime>=e.f.now())return!0}return!1}setFeatureState(e,t,r){this._state.updateState(e=e||"_geojsonTileLayer",t,r)}removeFeatureState(e,t,r){this._state.removeFeatureState(e=e||"_geojsonTileLayer",t,r)}getFeatureState(e,t){return this._state.getState(e=e||"_geojsonTileLayer",t)}setDependencies(e,t,r){const i=this._tiles[e];i&&i.setDependencies(t,r)}reloadTilesForDependencies(e,t){for(const r in this._tiles)this._tiles[r].hasDependency(e,t)&&this._reloadTile(+r,"reloading");this._cache.filter((r=>!r.hasDependency(e,t)))}_preloadTiles(t,r){if(!this._sourceLoaded){const e=()=>{this._sourceLoaded&&(this._source.off("data",e),this._preloadTiles(t,r))};return void this._source.on("data",e)}const i=new Map,n=Array.isArray(t)?t:[t],o=this.map.painter.terrain,s=this.usedForTerrain&&o?o.getScaledDemTileSize():this._source.tileSize;for(const e of n){const t=e.coveringTiles({tileSize:s,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const e of t)i.set(e.key,e);this.usedForTerrain&&e.updateElevation(!1)}const a=Array.from(i.values());e.b4(a,((e,t)=>{const r=new jt(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(r,(e=>{"raster-dem"===this._source.type&&r.dem&&this._backfillDEM(r),t(e,r)}))}),r)}}function Xt(e,t){const r=Math.abs(2*e.wrap)-+(e.wrap<0),i=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||i-r||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function Yt(e){return"raster"===e||"image"===e||"video"===e||"custom"===e}function $t(e,t){const r=1<<e.z;return[e.x/r+t,(e.x+1)/r+t]}qt.maxOverzooming=10,qt.maxUnderzooming=3;class Kt{constructor(e){this.style=e,this.layersGotHidden=!1,this.layers=[]}processLayersChanged(){this.layers=[];const e=!1,t=!1;for(const r in this.style._mergedLayers){const i=this.style._mergedLayers[r];if("fill-extrusion"===i.type)this.layers.push({layer:i,visible:e,visibilityChanged:t});else if("model"===i.type){const r=this.style.getLayerSource(i);r&&"batched-model"===r.type&&this.layers.push({layer:i,visible:e,visibilityChanged:t})}}}onNewFrame(e){this.layersGotHidden=!1;for(const t of this.layers){const r=t.layer;let i=!1;"fill-extrusion"===r.type?i=!r.isHidden(e)&&r.paint.get("fill-extrusion-opacity")>0:"model"===r.type&&(i=!r.isHidden(e)&&r.paint.get("model-opacity")>0),this.layersGotHidden=this.layersGotHidden||!i&&t.visible,t.visible=i}}updateZOffset(e,t){this.currentBuildingBuckets=[];for(const e of this.layers){const r=e.layer,i=this.style.getLayerSourceCache(r);let n=1;"fill-extrusion"===r.type&&(n=e.visible?r.paint.get("fill-extrusion-vertical-scale"):0);let o=i?i.getTile(t):null;if(!o&&i&&t.canonical.z>i.getSource().minzoom){let e=t.scaledTo(Math.min(i.getSource().maxzoom,t.overscaledZ-1));for(;e.overscaledZ>=i.getSource().minzoom&&(o=i.getTile(e),!o&&0!==e.overscaledZ);)e=e.scaledTo(e.overscaledZ-1)}this.currentBuildingBuckets.push({bucket:o?o.getBucket(r):null,tileID:o?o.tileID:t,verticalScale:n})}e.hasAnyZOffset=!1;let r=!1;for(let i=0;i<e.symbolInstances.length;i++){const n=e.symbolInstances.get(i),o=n.zOffset,s=this._getHeightAtTileOffset(t,n.tileAnchorX,n.tileAnchorY);n.zOffset=s!==Number.NEGATIVE_INFINITY?s:o,r||o===n.zOffset||(r=!0),e.hasAnyZOffset||0===n.zOffset||(e.hasAnyZOffset=!0)}r&&(e.zOffsetBuffersNeedUpload=!0,e.zOffsetSortDirty=!0)}_mapCoordToOverlappingTile(t,r,i,n){let o=r,s=i;if(t.canonical.z!==n.canonical.z){const a=n.canonical,l=1/(1<<t.canonical.z-a.z);o=(r+t.canonical.x*e.Y)*l-a.x*e.Y|0,s=(i+t.canonical.y*e.Y)*l-a.y*e.Y|0}return{tileX:o,tileY:s}}_getHeightAtTileOffset(e,t,r){let i,n;for(let o=0;o<this.layers.length;++o){if("fill-extrusion"!==this.layers[o].layer.type)continue;const{bucket:s,tileID:a,verticalScale:l}=this.currentBuildingBuckets[o];if(!s)continue;const{tileX:c,tileY:u}=this._mapCoordToOverlappingTile(e,t,r,a),h=s.getHeightAtTileCoord(c,u);h&&void 0!==h.height&&(h.hidden?i=h.height:n=Math.max(h.height*l,n||0))}if(void 0!==n)return n;for(let n=0;n<this.layers.length;++n){const o=this.layers[n];if("model"!==o.layer.type||!o.visible)continue;const{bucket:s,tileID:a}=this.currentBuildingBuckets[n];if(!s)continue;const{tileX:l,tileY:c}=this._mapCoordToOverlappingTile(e,t,r,a),u=s.getHeightAtTileCoord(l,c);if(u&&!u.hidden)return void 0===u.height&&void 0!==i?Math.min(u.maxHeight,i)*u.verticalScale:u.height?u.height*u.verticalScale:Number.NEGATIVE_INFINITY}return this.layersGotHidden?0:Number.NEGATIVE_INFINITY}}function Jt(t,r){const i={};for(const e in t)"ref"!==e&&(i[e]=t[e]);return e.b5.forEach((e=>{e in r&&(i[e]=r[e])})),i}function er(e){e=e.slice();const t=Object.create(null);for(let r=0;r<e.length;r++)t[e[r].id]=e[r];for(let r=0;r<e.length;r++)"ref"in e[r]&&(e[r]=Jt(e[r],t[e[r].ref]));return e}const tr={setStyle:"setStyle",addLayer:"addLayer",removeLayer:"removeLayer",setPaintProperty:"setPaintProperty",setLayoutProperty:"setLayoutProperty",setSlot:"setSlot",setFilter:"setFilter",addSource:"addSource",removeSource:"removeSource",setGeoJSONSourceData:"setGeoJSONSourceData",setLayerZoomRange:"setLayerZoomRange",setLayerProperty:"setLayerProperty",setCenter:"setCenter",setZoom:"setZoom",setBearing:"setBearing",setPitch:"setPitch",setSprite:"setSprite",setGlyphs:"setGlyphs",setTransition:"setTransition",setLight:"setLight",setTerrain:"setTerrain",setFog:"setFog",setCamera:"setCamera",setLights:"setLights",setProjection:"setProjection",addImport:"addImport",removeImport:"removeImport",updateImport:"updateImport"};function rr(e,t,r){r.push({command:tr.addSource,args:[e,t[e]]})}function ir(e,t,r){t.push({command:tr.removeSource,args:[e]}),r[e]=!0}function nr(e,t,r,i){ir(e,r,i),rr(e,t,r)}function or(e,r,i){let n;for(n in e[i])if(e[i].hasOwnProperty(n)&&"data"!==n&&!t(e[i][n],r[i][n]))return!1;for(n in r[i])if(r[i].hasOwnProperty(n)&&"data"!==n&&!t(e[i][n],r[i][n]))return!1;return!0}function sr(e,r,i,n,o,s){let a;for(a in r=r||{},e=e||{})e.hasOwnProperty(a)&&(t(e[a],r[a])||i.push({command:s,args:[n,a,r[a],o]}));for(a in r)r.hasOwnProperty(a)&&!e.hasOwnProperty(a)&&(t(e[a],r[a])||i.push({command:s,args:[n,a,r[a],o]}))}function ar(e){return e.id}function lr(e,t){return e[t.id]=t,e}class cr{constructor(e,t){this.reset(e,t)}reset(e,t){this.points=e||[],this._distances=[0];for(let e=1;e<this.points.length;e++)this._distances[e]=this._distances[e-1]+this.points[e].dist(this.points[e-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(t||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(t){if(1===this.points.length)return this.points[0];t=e.ad(t,0,1);let r=1,i=this._distances[r];const n=t*this.paddedLength+this.padding;for(;i<n&&r<this._distances.length;)i=this._distances[++r];const o=r-1,s=this._distances[o],a=i-s,l=a>0?(n-s)/a:0;return this.points[o].mult(1-l).add(this.points[r].mult(l))}}class ur{constructor(e,t,r){const i=this.boxCells=[],n=this.circleCells=[];this.xCellCount=Math.ceil(e/r),this.yCellCount=Math.ceil(t/r);for(let e=0;e<this.xCellCount*this.yCellCount;e++)i.push([]),n.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=e,this.height=t,this.xScale=this.xCellCount/e,this.yScale=this.yCellCount/t,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(e,t,r,i,n){this._forEachCell(t,r,i,n,this._insertBoxCell,this.boxUid++),this.boxKeys.push(e),this.bboxes.push(t),this.bboxes.push(r),this.bboxes.push(i),this.bboxes.push(n)}insertCircle(e,t,r,i){this._forEachCell(t-i,r-i,t+i,r+i,this._insertCircleCell,this.circleUid++),this.circleKeys.push(e),this.circles.push(t),this.circles.push(r),this.circles.push(i)}_insertBoxCell(e,t,r,i,n,o){this.boxCells[n].push(o)}_insertCircleCell(e,t,r,i,n,o){this.circleCells[n].push(o)}_query(e,t,r,i,n,o){if(r<0||e>this.width||i<0||t>this.height)return!n&&[];const s=[];if(e<=0&&t<=0&&this.width<=r&&this.height<=i){if(n)return!0;for(let e=0;e<this.boxKeys.length;e++)s.push({key:this.boxKeys[e],x1:this.bboxes[4*e],y1:this.bboxes[4*e+1],x2:this.bboxes[4*e+2],y2:this.bboxes[4*e+3]});for(let e=0;e<this.circleKeys.length;e++){const t=this.circles[3*e],r=this.circles[3*e+1],i=this.circles[3*e+2];s.push({key:this.circleKeys[e],x1:t-i,y1:r-i,x2:t+i,y2:r+i})}return o?s.filter(o):s}return this._forEachCell(e,t,r,i,this._queryCell,s,{hitTest:n,seenUids:{box:{},circle:{}}},o),n?s.length>0:s}_queryCircle(e,t,r,i,n){const o=e-r,s=e+r,a=t-r,l=t+r;if(s<0||o>this.width||l<0||a>this.height)return!i&&[];const c=[];return this._forEachCell(o,a,s,l,this._queryCellCircle,c,{hitTest:i,circle:{x:e,y:t,radius:r},seenUids:{box:{},circle:{}}},n),i?c.length>0:c}query(e,t,r,i,n){return this._query(e,t,r,i,!1,n)}hitTest(e,t,r,i,n){return this._query(e,t,r,i,!0,n)}hitTestCircle(e,t,r,i){return this._queryCircle(e,t,r,!0,i)}_queryCell(e,t,r,i,n,o,s,a){const l=s.seenUids,c=this.boxCells[n];if(null!==c){const n=this.bboxes;for(const u of c)if(!l.box[u]){l.box[u]=!0;const c=4*u;if(e<=n[c+2]&&t<=n[c+3]&&r>=n[c+0]&&i>=n[c+1]&&(!a||a(this.boxKeys[u]))){if(s.hitTest)return o.push(!0),!0;o.push({key:this.boxKeys[u],x1:n[c],y1:n[c+1],x2:n[c+2],y2:n[c+3]})}}}const u=this.circleCells[n];if(null!==u){const n=this.circles;for(const c of u)if(!l.circle[c]){l.circle[c]=!0;const u=3*c;if(this._circleAndRectCollide(n[u],n[u+1],n[u+2],e,t,r,i)&&(!a||a(this.circleKeys[c]))){if(s.hitTest)return o.push(!0),!0;{const e=n[u],t=n[u+1],r=n[u+2];o.push({key:this.circleKeys[c],x1:e-r,y1:t-r,x2:e+r,y2:t+r})}}}}}_queryCellCircle(e,t,r,i,n,o,s,a){const l=s.circle,c=s.seenUids,u=this.boxCells[n];if(null!==u){const e=this.bboxes;for(const t of u)if(!c.box[t]){c.box[t]=!0;const r=4*t;if(this._circleAndRectCollide(l.x,l.y,l.radius,e[r+0],e[r+1],e[r+2],e[r+3])&&(!a||a(this.boxKeys[t])))return o.push(!0),!0}}const h=this.circleCells[n];if(null!==h){const e=this.circles;for(const t of h)if(!c.circle[t]){c.circle[t]=!0;const r=3*t;if(this._circlesCollide(e[r],e[r+1],e[r+2],l.x,l.y,l.radius)&&(!a||a(this.circleKeys[t])))return o.push(!0),!0}}}_forEachCell(e,t,r,i,n,o,s,a){const l=this._convertToXCellCoord(e),c=this._convertToYCellCoord(t),u=this._convertToXCellCoord(r),h=this._convertToYCellCoord(i);for(let d=l;d<=u;d++)for(let l=c;l<=h;l++)if(n.call(this,e,t,r,i,this.xCellCount*l+d,o,s,a))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,t,r,i,n,o){const s=i-e,a=n-t,l=r+o;return l*l>s*s+a*a}_circleAndRectCollide(e,t,r,i,n,o,s){const a=(o-i)/2,l=Math.abs(e-(i+a));if(l>a+r)return!1;const c=(s-n)/2,u=Math.abs(t-(n+c));if(u>c+r)return!1;if(l<=a||u<=c)return!0;const h=l-a,d=u-c;return h*h+d*d<=r*r}}const hr={unknown:0,flipRequired:1,flipNotRequired:2},dr=Math.tan(85*Math.PI/180);function pr(t,r,i,n,o,s,a){const l=e.a9.create();if(i)if("globe"===s.name){const t=e.b6(o,r);e.a9.multiply(l,l,t)}else{const t=e.b7.invert([],a);l[0]=t[0],l[1]=t[1],l[4]=t[2],l[5]=t[3],n||e.a9.rotateZ(l,l,o.angle)}else e.a9.multiply(l,o.labelPlaneMatrix,t);return l}function fr(e,t,r,i,n,o,s){const a=pr(e,t,r,i,n,o,s);return"globe"===o.name&&r||(a[2]=a[6]=a[10]=a[14]=0),a}function mr(t,r,i,n,o,s,a){if(i){if("globe"===s.name){const l=pr(t,r,i,n,o,s,a);return e.a9.invert(l,l),e.a9.multiply(l,t,l),l}{const r=e.a9.clone(t),i=e.a9.identity([]);return i[0]=a[0],i[1]=a[1],i[4]=a[2],i[5]=a[3],e.a9.multiply(r,r,i),n||e.a9.rotateZ(r,r,-o.angle),r}}return o.glCoordMatrix}function Ar(t,r,i,n){const o=[t,r,i,1];i?e.aa.transformMat4(o,o,n):Mr(o,o,n);const s=o[3];return o[0]/=s,o[1]/=s,o[2]/=s,o}function gr(e,t){return Math.min(.5+e/t*.5,1.5)}function _r(e,t){const r=e[0]/e[3],i=e[1]/e[3];return r>=-t[0]&&r<=t[0]&&i>=-t[1]&&i<=t[1]}function yr(t,r,i,n,o,s,a,l,c,u){const h=i.transform,d=n?t.textSizeData:t.iconSizeData,p=e.b8(d,i.transform.zoom),f="globe"===h.projection.name,m=[256/i.width*2+1,256/i.height*2+1],A=n?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;A.clear();let g=null;f&&(g=n?t.text.globeExtVertexArray:t.icon.globeExtVertexArray);const _=t.lineVertexArray,y=n?t.text.placedSymbolArray:t.icon.placedSymbolArray,x=i.transform.width/i.transform.height;let v,b=!1;for(let n=0;n<y.length;n++){const f=y.get(n),{numGlyphs:w,writingMode:C}=f;if(C!==e.b9.vertical||b||v===e.b9.horizontal||(b=!0),v=C,(f.hidden||C===e.b9.vertical)&&!b){Er(w,A);continue}b=!1;const T=new e.P(f.tileAnchorX,f.tileAnchorY);let{x:E,y:M,z:S}=h.projection.projectTilePoint(T.x,T.y,u.canonical);if(c){const[e,t,r]=c(T);E+=e,M+=t,S+=r}const I=[E,M,S,1];if(e.aa.transformMat4(I,I,r),!_r(I,m)){Er(w,A);continue}const P=I[3],D=gr(i.transform.getCameraToCenterDistance(h.projection),P),k=e.ba(d,p,f),L=a?k/D:k*D,z=Ar(E,M,S,o);if(z[3]<=0){Er(w,A);continue}let O={};const B=a?null:c,R=br(f,L,!1,l,r,o,s,t.glyphOffsetArray,_,A,g,z,T,O,x,B,h.projection,u,a);b=R.useVertical,B&&R.needsFlipping&&(O={}),(R.notEnoughRoom||b||R.needsFlipping&&br(f,L,!0,l,r,o,s,t.glyphOffsetArray,_,A,g,z,T,O,x,B,h.projection,u,a).notEnoughRoom)&&Er(w,A)}n?(t.text.dynamicLayoutVertexBuffer.updateData(A),g&&t.text.globeExtVertexBuffer&&t.text.globeExtVertexBuffer.updateData(g)):(t.icon.dynamicLayoutVertexBuffer.updateData(A),g&&t.icon.globeExtVertexBuffer&&t.icon.globeExtVertexBuffer.updateData(g))}function xr(e,t,r,i,n,o,s,a,l,c,u,h,d,p,f,m){const{lineStartIndex:A,glyphStartIndex:g,segment:_}=a,y=g+a.numGlyphs,x=A+a.lineLength,v=t.getoffsetX(g),b=t.getoffsetX(y-1),w=Tr(e*v,r,i,n,o,s,_,A,x,l,c,u,h,d,!0,p,f,m);if(!w)return null;const C=Tr(e*b,r,i,n,o,s,_,A,x,l,c,u,h,d,!0,p,f,m);return C?{first:w,last:C}:null}function vr(t,r,i,n){return t===e.b9.horizontal&&Math.abs(n)>Math.abs(i)?{useVertical:!0}:t===e.b9.vertical?n>0?{needsFlipping:!0}:null:r!==hr.unknown&&function(e,t){return 0===e||Math.abs(t/e)>dr}(i,n)?r===hr.flipRequired?{needsFlipping:!0}:null:i<0?{needsFlipping:!0}:null}function br(t,r,i,n,o,s,a,l,c,u,h,d,p,f,m,A,g,_,y){const x=r/24,v=t.lineOffsetX*x,b=t.lineOffsetY*x,{lineStartIndex:w,glyphStartIndex:C,numGlyphs:T,segment:E,writingMode:M,flipState:S}=t,I=w+t.lineLength,P=t=>{if(h){const[r,i,n]=t.up,o=u.length;e.bb(h,o+0,r,i,n),e.bb(h,o+1,r,i,n),e.bb(h,o+2,r,i,n),e.bb(h,o+3,r,i,n)}const[r,i,n]=t.point;e.bc(u,r,i,n,t.angle)};if(T>1){const e=xr(x,l,v,b,i,d,p,t,c,s,f,A,!1,g,_,y);if(!e)return{notEnoughRoom:!0};if(n&&!i){let[r,i,n]=e.first.point,[o,s,l]=e.last.point;[r,i]=Ar(r,i,n,a),[o,s]=Ar(o,s,l,a);const c=vr(M,S,(o-r)*m,s-i);if(t.flipState=c&&c.needsFlipping?hr.flipRequired:hr.flipNotRequired,c)return c}P(e.first);for(let e=C+1;e<C+T-1;e++){const t=Tr(x*l.getoffsetX(e),v,b,i,d,p,E,w,I,c,s,f,A,!1,!1,g,_,y);if(!t)return u.length-=4*(e-C),{notEnoughRoom:!0};P(t)}P(e.last)}else{if(n&&!i){const r=Ar(p.x,p.y,0,o),i=w+E+1,n=new e.P(c.getx(i),c.gety(i)),s=Ar(n.x,n.y,0,o),a=s[3]>0?s:Cr(p,n,r,1,o,void 0,g,_.canonical),l=vr(M,S,(a[0]-r[0])*m,a[1]-r[1]);if(t.flipState=l&&l.needsFlipping?hr.flipRequired:hr.flipNotRequired,l)return l}const r=Tr(x*l.getoffsetX(C),v,b,i,d,p,E,w,I,c,s,f,A,!1,!1,g,_,y);if(!r)return{notEnoughRoom:!0};P(r)}return{}}function wr(e,t,r,i,n){const{x:o,y:s,z:a}=i.projectTilePoint(e.x,e.y,t);if(!n)return Ar(o,s,a,r);const[l,c,u]=n(e);return Ar(o+l,s+c,a+u,r)}function Cr(t,r,i,n,o,s,a,l){const c=wr(t.sub(r)._unit()._add(t),l,o,a,s);return e.Q.sub(c,i,c),e.Q.normalize(c,c),e.Q.scaleAndAdd(c,i,c,n)}function Tr(t,r,i,n,o,s,a,l,c,u,h,d,p,f,m,A,g,_){const y=n?t-r:t+r;let x=y>0?1:-1,v=0;n&&(x*=-1,v=Math.PI),x<0&&(v+=Math.PI);let b=l+a+(x>0?0:1)|0,w=o,C=o,T=0,E=0;const M=Math.abs(y),S=[],I=[];let P=s,D=P;const k=()=>Cr(D,P,C,M-T+1,h,p,A,g.canonical);for(;T+E<=M;){if(b+=x,b<l||b>=c)return null;if(C=w,D=P,S.push(C),f&&I.push(D),P=new e.P(u.getx(b),u.gety(b)),w=d[b],!w){const e=wr(P,g.canonical,h,A,p);w=e[3]>0?d[b]=e:k()}T+=E,E=e.Q.distance(C,w)}m&&p&&(d[b]&&(w=k(),E=e.Q.distance(C,w)),d[b]=w);const L=(M-T)/E,z=P.sub(D)._mult(L)._add(D),O=e.Q.sub([],w,C),B=e.Q.scaleAndAdd([],C,O,L);let R=[0,0,1],F=O[0],j=O[1];if(_&&(R=A.upVector(g.canonical,z.x,z.y),0!==R[0]||0!==R[1]||1!==R[2])){const t=[R[2],0,-R[0]],r=e.Q.cross([],R,t);e.Q.normalize(t,t),e.Q.normalize(r,r),F=e.Q.dot(O,t),j=e.Q.dot(O,r)}if(i){const t=e.Q.cross([],R,O);e.Q.normalize(t,t),e.Q.scaleAndAdd(B,B,t,i*x)}const V=v+Math.atan2(j,F);return S.push(B),f&&I.push(z),{point:B,angle:V,path:S,tilePath:I,up:R}}function Er(e,t){const r=t.length,i=r+4*e;t.resize(i),t.float32.fill(-1/0,4*r,4*i)}function Mr(e,t,r){const i=t[0],n=t[1];return e[0]=r[0]*i+r[4]*n+r[12],e[1]=r[1]*i+r[5]*n+r[13],e[3]=r[3]*i+r[7]*n+r[15],e}const Sr=100;class Ir{constructor(e,t,r=new ur(e.width+200,e.height+200,25),i=new ur(e.width+200,e.height+200,25)){this.transform=e,this.grid=r,this.ignoredGrid=i,this.pitchfactor=Math.cos(e._pitch)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+Sr,this.screenBottomBoundary=e.height+Sr,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.fogState=t}placeCollisionBox(e,t,r,i,n,o,s,a){let l=r.projectedAnchorX,c=r.projectedAnchorY,u=r.projectedAnchorZ;const h=r.elevation,d=r.tileID,p=e.getProjection();if(h&&d){const[e,t,i]=p.upVector(d.canonical,r.tileAnchorX,r.tileAnchorY),n=p.upVectorScale(d.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;l+=e*h*n,c+=t*h*n,u+=i*h*n}const f=this.projectAndGetPerspectiveRatio(s,l,c,u,r.tileID,"globe"===p.name||!!h||this.transform.pitch>0,p),m=o*f.perspectiveRatio,A=(r.x1*t+i.x-r.padding)*m+f.point.x,g=(r.y1*t+i.y-r.padding)*m+f.point.y,_=(r.x2*t+i.x+r.padding)*m+f.point.x,y=(r.y2*t+i.y+r.padding)*m+f.point.y,x=f.perspectiveRatio<=.55||f.occluded;return!this.isInsideGrid(A,g,_,y)||!n&&this.grid.hitTest(A,g,_,y,a)||x?{box:[],offscreen:!1,occluded:f.occluded}:{box:[A,g,_,y],offscreen:this.isOffscreen(A,g,_,y),occluded:!1}}placeCollisionCircles(t,r,i,n,o,s,a,l,c,u,h,d,p,f,m){const A=[],g=this.transform.elevation,_=t.getProjection(),y=g?g.getAtTileOffsetFunc(m,this.transform.center.lat,this.transform.worldSize,_):null,x=new e.P(i.tileAnchorX,i.tileAnchorY);let{x:v,y:b,z:w}=_.projectTilePoint(x.x,x.y,m.canonical);if(y){const[e,t,r]=y(x);v+=e,b+=t,w+=r}const C="globe"===_.name,T=this.projectAndGetPerspectiveRatio(a,v,b,w,m,C||!!g||this.transform.pitch>0,_),{perspectiveRatio:E}=T,M=(h?s/E:s*E)/e.bf,S=Ar(v,b,w,l),I=T.signedDistanceFromCamera>0?xr(M,o,i.lineOffsetX*M,i.lineOffsetY*M,!1,S,x,i,n,l,{},g&&!h?y:null,h&&!!g,_,m,h):null;let P=!1,D=!1,k=!0;if(I&&!T.occluded){const t=.5*p*E+f,i=new e.P(-100,-100),n=new e.P(this.screenRightBoundary,this.screenBottomBoundary),o=new cr,{first:s,last:a}=I,l=s.path.length;let h=[];for(let e=l-1;e>=1;e--)h.push(s.path[e]);for(let e=1;e<a.path.length;e++)h.push(a.path[e]);const m=2.5*t;c&&(h=h.map((([e,t,r],i)=>(y&&!C&&(r=y(i<l-1?s.tilePath[l-1-i]:a.tilePath[i-l+2])[2]),Ar(e,t,r,c)))),h.some((e=>e[3]<=0))&&(h=[]));let g=[];if(h.length>0){let t=1/0,r=-1/0,o=1/0,s=-1/0;for(const e of h)t=Math.min(t,e[0]),o=Math.min(o,e[1]),r=Math.max(r,e[0]),s=Math.max(s,e[1]);r>=i.x&&t<=n.x&&s>=i.y&&o<=n.y&&(g=[h.map((t=>new e.P(t[0],t[1])))],(t<i.x||r>n.x||o<i.y||s>n.y)&&(g=e.bd(g,i.x,i.y,n.x,n.y)))}for(const e of g){o.reset(e,.25*t);let i=0;i=o.length<=.5*t?1:Math.ceil(o.paddedLength/m)+1;for(let e=0;e<i;e++){const n=e/Math.max(i-1,1),s=o.lerp(n),a=s.x+Sr,l=s.y+Sr;A.push(a,l,t,0);const c=a-t,h=l-t,p=a+t,f=l+t;if(k=k&&this.isOffscreen(c,h,p,f),D=D||this.isInsideGrid(c,h,p,f),!r&&this.grid.hitTestCircle(a,l,t,d)&&(P=!0,!u))return{circles:[],offscreen:!1,collisionDetected:P,occluded:!1}}}}return{circles:!u&&P||!D?[]:A,offscreen:k,collisionDetected:P,occluded:T.occluded}}queryRenderedSymbols(t){if(0===t.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const r=[];let i=1/0,n=1/0,o=-1/0,s=-1/0;for(const a of t){const t=new e.P(a.x+Sr,a.y+Sr);i=Math.min(i,t.x),n=Math.min(n,t.y),o=Math.max(o,t.x),s=Math.max(s,t.y),r.push(t)}const a=this.grid.query(i,n,o,s).concat(this.ignoredGrid.query(i,n,o,s)),l={},c={};for(const t of a){const i=t.key;if(void 0===l[i.bucketInstanceId]&&(l[i.bucketInstanceId]={}),l[i.bucketInstanceId][i.featureIndex])continue;const n=[new e.P(t.x1,t.y1),new e.P(t.x2,t.y1),new e.P(t.x2,t.y2),new e.P(t.x1,t.y2)];e.be(r,n)&&(l[i.bucketInstanceId][i.featureIndex]=!0,void 0===c[i.bucketInstanceId]&&(c[i.bucketInstanceId]=[]),c[i.bucketInstanceId].push(i.featureIndex))}return c}insertCollisionBox(e,t,r,i,n){(t?this.ignoredGrid:this.grid).insert({bucketInstanceId:r,featureIndex:i,collisionGroupID:n},e[0],e[1],e[2],e[3])}insertCollisionCircles(e,t,r,i,n){const o=t?this.ignoredGrid:this.grid,s={bucketInstanceId:r,featureIndex:i,collisionGroupID:n};for(let t=0;t<e.length;t+=4)o.insertCircle(s,e[t],e[t+1],e[t+2])}projectAndGetPerspectiveRatio(t,r,i,n,o,s,a){const l=[r,i,n,1];let c=!1;if(n||this.transform.pitch>0){if(e.aa.transformMat4(l,l,t),this.fogState&&o&&"globe"!==a.name){const t=function(t,r,i,n,o,s){const a=s.calculateFogTileMatrix(o),l=[r,i,n];return e.Q.transformMat4(l,l,a),fe(t,e.Q.length(l),s.pitch,s._fov)}(this.fogState,r,i,n,o.toUnwrapped(),this.transform);c=t>.9}}else Mr(l,l,t);const u=l[3];return{point:new e.P((l[0]/u+1)/2*this.transform.width+Sr,(-l[1]/u+1)/2*this.transform.height+Sr),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(a)/u*.5,1.5),signedDistanceFromCamera:u,occluded:s&&l[2]>u||c}}isOffscreen(e,t,r,i){return r<Sr||e>=this.screenRightBoundary||i<Sr||t>this.screenBottomBoundary}isInsideGrid(e,t,r,i){return r>=0&&e<this.gridRightBoundary&&i>=0&&t<this.gridBottomBoundary}getViewportMatrix(){const t=e.a9.identity([]);return e.a9.translate(t,t,[-100,-100,0]),t}}function Pr(t,r,i){const n=r.createTileMatrix(t,t.worldSize,i.toUnwrapped());return e.a9.multiply(new Float32Array(16),t.projMatrix,n)}function Dr(e,t,r){if(t.projection.name===r.projection.name)return e.projMatrix;const i=r.clone();return i.setProjection(t.projection),Pr(i,t.getProjection(),e)}function kr(e,t,r){return t.name===r.projection.name?e.projMatrix:Pr(r,t,e)}class Lr{constructor(e,t,r,i){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?t:-t))):i&&r?1:0,this.placed=r}isHidden(){return 0===this.opacity&&!this.placed}}class zr{constructor(e,t,r,i,n,o=!1){this.text=new Lr(e?e.text:null,t,r,n),this.icon=new Lr(e?e.icon:null,t,i,n),this.clipped=o}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class Or{constructor(e,t,r,i=!1){this.text=e,this.icon=t,this.skipFade=r,this.clipped=i}}class Br{constructor(){this.invProjMatrix=e.a9.create(),this.viewportMatrix=e.a9.create(),this.circles=[]}}class Rr{constructor(e,t,r,i,n){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=r,this.bucketIndex=i,this.tileID=n}}class Fr{constructor(e){this.crossSourceCollisions=e,this.maxGroupID=0,this.collisionGroups={}}get(e){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[e]){const t=++this.maxGroupID;this.collisionGroups[e]={ID:t,predicate:e=>e.collisionGroupID===t}}return this.collisionGroups[e]}}function jr(t,r,i,n,o){const{horizontalAlign:s,verticalAlign:a}=e.bi(t),l=-(s-.5)*r,c=-(a-.5)*i,u=e.bh(t,n);return new e.P(l+u[0]*o,c+u[1]*o)}function Vr(t,r,i,n,o){const s=new e.P(t,r);return i&&s._rotate(n?o:-o),s}class Nr{constructor(e,t,r,i,n,o){this.transform=e.clone(),this.projection=e.projection.name,this.collisionIndex=new Ir(this.transform,n),this.buildingIndex=o,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=t,this.retainedQueryData={},this.collisionGroups=new Fr(r),this.collisionCircleArrays={},this.prevPlacement=i,i&&(i.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(t,r,i,n){const o=i.getBucket(r),s=i.latestFeatureIndex;if(!o||!s||r.fqid!==o.layerIds[0])return;const a=o.layers[0].layout,l=i.collisionBoxArray,c=Math.pow(2,this.transform.zoom-i.tileID.overscaledZ),u=i.tileSize/e.Y,h=i.tileID.toUnwrapped();this.transform.setProjection(o.projection);const d=(p=i.tileID,f=o.getProjection(),m=this.transform,f.name===this.projection?m.calculateProjMatrix(p.toUnwrapped()):Pr(m,f,p));var p,f,m;const A="map"===a.get("text-pitch-alignment"),g="map"===a.get("text-rotation-alignment");r.compileFilter();const _=r.dynamicFilter(),y=r.dynamicFilterNeedsFeature(),x=this.transform.calculatePixelsToTileUnitsMatrix(i),v=fr(d,i.tileID.canonical,A,g,this.transform,o.getProjection(),x);let b=null;if(A){const t=mr(d,i.tileID.canonical,A,g,this.transform,o.getProjection(),x);b=e.a9.multiply([],this.transform.labelPlaneMatrix,t)}let w=null;_&&i.latestFeatureIndex&&(w={unwrappedTileID:h,dynamicFilter:_,dynamicFilterNeedsFeature:y,featureIndex:i.latestFeatureIndex}),this.retainedQueryData[o.bucketInstanceId]=new Rr(o.bucketInstanceId,s,o.sourceLayerIndex,o.index,i.tileID);const C={bucket:o,layout:a,posMatrix:d,textLabelPlaneMatrix:v,labelToScreenMatrix:b,clippingData:w,scale:c,textPixelRatio:u,holdingForFade:i.holdingForFade(),collisionBoxArray:l,partiallyEvaluatedTextSize:e.b8(o.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:e.b8(o.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(o.sourceID)};if(n)for(const e of o.sortKeyRanges){const{sortKey:r,symbolInstanceStart:i,symbolInstanceEnd:n}=e;t.push({sortKey:r,symbolInstanceStart:i,symbolInstanceEnd:n,parameters:C})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:o.symbolInstances.length,parameters:C})}attemptAnchorPlacement(e,t,r,i,n,o,s,a,l,c,u,h,d,p,f,m,A,g){const{textOffset0:_,textOffset1:y,crossTileID:x}=h,v=[_,y],b=jr(e,r,i,v,n),w=this.collisionIndex.placeCollisionBox(p,n,t,Vr(b.x,b.y,o,s,this.transform.angle),u,a,l,c.predicate);if(m){const e=p.getSymbolInstanceIconSize(g,this.transform.zoom,h.placedIconSymbolIndex);if(0===this.collisionIndex.placeCollisionBox(p,e,m,Vr(b.x,b.y,o,s,this.transform.angle),u,a,l,c.predicate).box.length)return}if(w.box.length>0){let t;return this.prevPlacement&&this.prevPlacement.variableOffsets[x]&&this.prevPlacement.placements[x]&&this.prevPlacement.placements[x].text&&(t=this.prevPlacement.variableOffsets[x].anchor),this.variableOffsets[x]={textOffset:v,width:r,height:i,anchor:e,textScale:n,prevAnchor:t},this.markUsedJustification(p,e,h,f),p.allowVerticalPlacement&&(this.markUsedOrientation(p,f,h),this.placedOrientations[x]=f),{shift:b,placedGlyphBoxes:w}}}placeLayerBucketPart(t,r,i,n){const{bucket:o,layout:s,posMatrix:a,textLabelPlaneMatrix:l,labelToScreenMatrix:c,clippingData:u,textPixelRatio:h,holdingForFade:d,collisionBoxArray:p,partiallyEvaluatedTextSize:f,partiallyEvaluatedIconSize:m,collisionGroup:A}=t.parameters,g=s.get("text-optional"),_=s.get("icon-optional"),y=s.get("text-allow-overlap"),x=s.get("icon-allow-overlap"),v="map"===s.get("text-rotation-alignment"),b="map"===s.get("text-pitch-alignment"),w="viewport-y"===s.get("symbol-z-order"),C=s.get("symbol-z-elevate");this.transform.setProjection(o.projection);let T=y&&(x||!o.hasIconData()||_),E=x&&(y||!o.hasTextData()||g);!o.collisionArrays&&p&&o.deserializeCollisionBoxes(p),i&&n&&o.updateCollisionDebugBuffers(this.transform.zoom,p);const M=(t,n,p)=>{const{crossTileID:w,numVerticalGlyphVertices:C}=t;if(u){const i={zoom:this.transform.zoom,pitch:this.transform.pitch};let n=null;if(u.dynamicFilterNeedsFeature){const e=this.retainedQueryData[o.bucketInstanceId];n=u.featureIndex.loadFeature({featureIndex:t.featureIndex,bucketIndex:e.bucketIndex,sourceLayerIndex:e.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,u.dynamicFilter)(i,n,this.retainedQueryData[o.bucketInstanceId].tileID.canonical,new e.P(t.tileAnchorX,t.tileAnchorY),this.transform.calculateDistanceTileData(u.unwrappedTileID)))return this.placements[w]=new Or(!1,!1,!1,!0),void r.add(w)}if(r.has(w))return;if(d)return void(this.placements[w]=new Or(!1,!1,!1));let M=!1,S=!1,I=!0,P=!1,D=!1,k=null,L={box:null,offscreen:null,occluded:null},z={box:null,offscreen:null,occluded:null},O=null,B=null,R=null,F=0,j=0,V=0;p.textFeatureIndex?F=p.textFeatureIndex:t.useRuntimeCollisionCircles&&(F=t.featureIndex),p.verticalTextFeatureIndex&&(j=p.verticalTextFeatureIndex);const N=e=>{e.tileID=this.retainedQueryData[o.bucketInstanceId].tileID;const r=this.transform.elevation;e.elevation=t.zOffset+(r?r.getAtTileOffset(e.tileID,e.tileAnchorX,e.tileAnchorY):0)},U=p.textBox;if(U){N(U);const r=r=>{let i=e.b9.horizontal;if(o.allowVerticalPlacement&&!r&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[w];e&&(this.placedOrientations[w]=e,i=e,this.markUsedOrientation(o,i,t))}return i},i=(t,r)=>{if(o.allowVerticalPlacement&&C>0&&p.verticalTextBox){for(const i of o.writingModes)if(i===e.b9.vertical?(L=r(),z=L):L=t(),L&&L.box&&L.box.length)break}else L=t()};if(s.get("text-variable-anchor")){let l=s.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[w]){const e=this.prevPlacement.variableOffsets[w];l.indexOf(e.anchor)>0&&(l=l.filter((t=>t!==e.anchor)),l.unshift(e.anchor))}const c=(e,r,i)=>{const s=o.getSymbolInstanceTextSize(f,t,this.transform.zoom,n),c=(e.x2-e.x1)*s+2*e.padding,u=(e.y2-e.y1)*s+2*e.padding,d=t.hasIconTextFit&&!x?r:null;d&&N(d);let p={box:[],offscreen:!1,occluded:!1};const g=y?2*l.length:l.length;for(let r=0;r<g;++r){const g=this.attemptAnchorPlacement(l[r%l.length],e,c,u,s,v,b,h,a,A,r>=l.length,t,n,o,i,d,f,m);if(g&&(p=g.placedGlyphBoxes,p&&p.box&&p.box.length)){M=!0,k=g.shift;break}}return p};i((()=>c(U,p.iconBox,e.b9.horizontal)),(()=>{const t=p.verticalTextBox;return t&&N(t),o.allowVerticalPlacement&&!(L&&L.box&&L.box.length)&&C>0&&t?c(t,p.verticalIconBox,e.b9.vertical):{box:null,offscreen:null,occluded:null}})),L&&(M=L.box,I=L.offscreen,P=L.occluded);const u=r(!(!L||!L.box));if(!M&&this.prevPlacement){const e=this.prevPlacement.variableOffsets[w];e&&(this.variableOffsets[w]=e,this.markUsedJustification(o,e.anchor,t,u))}}else{const s=(r,i)=>{const s=o.getSymbolInstanceTextSize(f,t,this.transform.zoom,n),l=this.collisionIndex.placeCollisionBox(o,s,r,new e.P(0,0),y,h,a,A.predicate);return l&&l.box&&l.box.length&&(this.markUsedOrientation(o,i,t),this.placedOrientations[w]=i),l};i((()=>s(U,e.b9.horizontal)),(()=>{const t=p.verticalTextBox;return o.allowVerticalPlacement&&C>0&&t?(N(t),s(t,e.b9.vertical)):{box:null,offscreen:null,occluded:null}})),r(!!(L&&L.box&&L.box.length))}}if(O=L,M=O&&O.box&&O.box.length>0,I=O&&O.offscreen,P=O&&O.occluded,t.useRuntimeCollisionCircles){const r=o.text.placedSymbolArray.get(t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex),n=e.ba(o.textSizeData,f,r),u=s.get("text-padding");B=this.collisionIndex.placeCollisionCircles(o,y,r,o.lineVertexArray,o.glyphOffsetArray,n,a,l,c,i,b,A.predicate,t.collisionCircleDiameter*n/e.bf,u,this.retainedQueryData[o.bucketInstanceId].tileID),M=y||B.circles.length>0&&!B.collisionDetected,I=I&&B.offscreen,P=B.occluded}if(p.iconFeatureIndex&&(V=p.iconFeatureIndex),p.iconBox){const r=r=>{N(r);const i=t.hasIconTextFit&&k?Vr(k.x,k.y,v,b,this.transform.angle):new e.P(0,0),n=o.getSymbolInstanceIconSize(m,this.transform.zoom,t.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(o,n,r,i,x,h,a,A.predicate)};z&&z.box&&z.box.length&&p.verticalIconBox?(R=r(p.verticalIconBox),S=R.box.length>0):(R=r(p.iconBox),S=R.box.length>0),I=I&&R.offscreen,D=R.occluded}const H=g||0===t.numHorizontalGlyphVertices&&0===C,G=_||0===t.numIconVertices;if(H||G?G?H||(S=S&&M):M=S&&M:S=M=S&&M,M&&O&&O.box&&this.collisionIndex.insertCollisionBox(O.box,s.get("text-ignore-placement"),o.bucketInstanceId,z&&z.box&&j?j:F,A.ID),S&&R&&this.collisionIndex.insertCollisionBox(R.box,s.get("icon-ignore-placement"),o.bucketInstanceId,V,A.ID),B&&(M&&this.collisionIndex.insertCollisionCircles(B.circles,s.get("text-ignore-placement"),o.bucketInstanceId,F,A.ID),i)){const e=o.bucketInstanceId;let t=this.collisionCircleArrays[e];void 0===t&&(t=this.collisionCircleArrays[e]=new Br);for(let e=0;e<B.circles.length;e+=4)t.circles.push(B.circles[e+0]),t.circles.push(B.circles[e+1]),t.circles.push(B.circles[e+2]),t.circles.push(B.collisionDetected?1:0)}const Z="globe"!==o.projection.name;T=T&&(Z||!P),E=E&&(Z||!D),this.placements[w]=new Or(M||T,S||E,I||o.justReloaded),r.add(w)};if(C&&this.buildingIndex&&(this.buildingIndex.updateZOffset(o,this.retainedQueryData[o.bucketInstanceId].tileID),o.updateZOffset()),w){const t=o.getSortedSymbolIndexes(this.transform.angle);for(let e=t.length-1;e>=0;--e){const r=t[e];M(o.symbolInstances.get(r),r,o.collisionArrays[r])}o.hasAnyZOffset&&e.w(`${o.layerIds[0]} layer symbol-z-elevate: symbols are not sorted by elevation if symbol-z-order is evaluated to viewport-y`)}else if(o.hasAnyZOffset){const e=o.getSortedIndexesByZOffset();for(let t=0;t<e.length;++t){const r=e[t];M(o.symbolInstances.get(r),r,o.collisionArrays[r])}}else for(let e=t.symbolInstanceStart;e<t.symbolInstanceEnd;e++)M(o.symbolInstances.get(e),e,o.collisionArrays[e]);if(i&&o.bucketInstanceId in this.collisionCircleArrays){const t=this.collisionCircleArrays[o.bucketInstanceId];e.a9.invert(t.invProjMatrix,a),t.viewportMatrix=this.collisionIndex.getViewportMatrix()}o.justReloaded=!1}markUsedJustification(t,r,i,n){const{leftJustifiedTextSymbolIndex:o,centerJustifiedTextSymbolIndex:s,rightJustifiedTextSymbolIndex:a,verticalPlacedTextSymbolIndex:l,crossTileID:c}=i,u=e.bg(r),h=n===e.b9.vertical?l:"left"===u?o:"center"===u?s:"right"===u?a:-1;o>=0&&(t.text.placedSymbolArray.get(o).crossTileID=h>=0&&o!==h?0:c),s>=0&&(t.text.placedSymbolArray.get(s).crossTileID=h>=0&&s!==h?0:c),a>=0&&(t.text.placedSymbolArray.get(a).crossTileID=h>=0&&a!==h?0:c),l>=0&&(t.text.placedSymbolArray.get(l).crossTileID=h>=0&&l!==h?0:c)}markUsedOrientation(t,r,i){const n=r===e.b9.horizontal||r===e.b9.horizontalOnly?r:0,o=r===e.b9.vertical?r:0,{leftJustifiedTextSymbolIndex:s,centerJustifiedTextSymbolIndex:a,rightJustifiedTextSymbolIndex:l,verticalPlacedTextSymbolIndex:c}=i,u=t.text.placedSymbolArray;s>=0&&(u.get(s).placedOrientation=n),a>=0&&(u.get(a).placedOrientation=n),l>=0&&(u.get(l).placedOrientation=n),c>=0&&(u.get(c).placedOrientation=o)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const t=this.prevPlacement;let r=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;const i=t?t.symbolFadeChange(e):1,n=t?t.opacities:{},o=t?t.variableOffsets:{},s=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],o=n[e];o?(this.opacities[e]=new zr(o,i,t.text,t.icon,null,t.clipped),r=r||t.text!==o.text.placed||t.icon!==o.icon.placed):(this.opacities[e]=new zr(null,i,t.text,t.icon,t.skipFade,t.clipped),r=r||t.text||t.icon)}for(const e in n){const t=n[e];if(!this.opacities[e]){const n=new zr(t,i,!1,!1);n.isHidden()||(this.opacities[e]=n,r=r||t.text.placed||t.icon.placed)}}for(const e in o)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=o[e]);for(const e in s)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=s[e]);r?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)}updateLayerOpacities(e,t){const r=new Set;for(const i of t){const t=i.getBucket(e);t&&i.latestFeatureIndex&&e.fqid===t.layerIds[0]&&(this.updateBucketOpacities(t,r,i.collisionBoxArray),t.layers[0].layout.get("symbol-z-elevate")&&this.buildingIndex&&(this.buildingIndex.updateZOffset(t,i.tileID),t.updateZOffset()))}}updateBucketOpacities(t,r,i){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 n=t.layers[0].layout,o=!!t.layers[0].dynamicFilter(),s=new zr(null,0,!1,!1,!0),a=n.get("text-allow-overlap"),l=n.get("icon-allow-overlap"),c=n.get("text-variable-anchor"),u="map"===n.get("text-rotation-alignment"),h="map"===n.get("text-pitch-alignment"),d=new zr(null,0,a&&(l||!t.hasIconData()||n.get("icon-optional")),l&&(a||!t.hasTextData()||n.get("text-optional")),!0);!t.collisionArrays&&i&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(i);const p=(e,t,r)=>{for(let i=0;i<t/4;i++)e.opacityVertexArray.emplaceBack(r)};let f=0;for(let i=0;i<t.symbolInstances.length;i++){const n=t.symbolInstances.get(i),{numHorizontalGlyphVertices:a,numVerticalGlyphVertices:l,crossTileID:m,numIconVertices:A}=n,g=r.has(m);let _=this.opacities[m];g?_=s:_||(_=d,this.opacities[m]=_),r.add(m);const y=a>0||l>0,x=A>0,v=this.placedOrientations[m],b=v===e.b9.vertical,w=v===e.b9.horizontal||v===e.b9.horizontalOnly;if(!y&&!x||_.isHidden()||f++,y){const e=Yr(_.text);p(t.text,a,b?$r:e),p(t.text,l,w?$r:e);const r=_.text.isHidden(),{leftJustifiedTextSymbolIndex:i,centerJustifiedTextSymbolIndex:o,rightJustifiedTextSymbolIndex:s,verticalPlacedTextSymbolIndex:c}=n,u=t.text.placedSymbolArray,h=r||b?1:0;i>=0&&(u.get(i).hidden=h),o>=0&&(u.get(o).hidden=h),s>=0&&(u.get(s).hidden=h),c>=0&&(u.get(c).hidden=r||w?1:0);const d=this.variableOffsets[m];d&&this.markUsedJustification(t,d.anchor,n,v);const f=this.placedOrientations[m];f&&(this.markUsedJustification(t,"left",n,f),this.markUsedOrientation(t,f,n))}if(x){const e=Yr(_.icon),{placedIconSymbolIndex:r,verticalPlacedIconSymbolIndex:i}=n,o=t.icon.placedSymbolArray,s=_.icon.isHidden()?1:0;r>=0&&(p(t.icon,A,b?$r:e),o.get(r).hidden=s),i>=0&&(p(t.icon,n.numVerticalIconVertices,w?$r:e),o.get(i).hidden=s)}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const r=t.collisionArrays[i];if(r){let i=new e.P(0,0),s=!0;if(r.textBox||r.verticalTextBox){if(c){const e=this.variableOffsets[m];e?(i=jr(e.anchor,e.width,e.height,e.textOffset,e.textScale),u&&i._rotate(h?this.transform.angle:-this.transform.angle)):s=!1}o&&(s=!_.clipped),r.textBox&&Ur(t.textCollisionBox.collisionVertexArray,_.text.placed,!s||b,i.x,i.y),r.verticalTextBox&&Ur(t.textCollisionBox.collisionVertexArray,_.text.placed,!s||w,i.x,i.y)}const a=s&&Boolean(!w&&r.verticalIconBox);r.iconBox&&Ur(t.iconCollisionBox.collisionVertexArray,_.icon.placed,a,n.hasIconTextFit?i.x:0,n.hasIconTextFit?i.y:0),r.verticalIconBox&&Ur(t.iconCollisionBox.collisionVertexArray,_.icon.placed,!a,n.hasIconTextFit?i.x:0,n.hasIconTextFit?i.y:0)}}}if(t.fullyClipped=0===f,t.sortFeatures(this.transform.angle),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.bucketInstanceId in this.collisionCircleArrays){const e=this.collisionCircleArrays[t.bucketInstanceId];t.placementInvProjMatrix=e.invProjMatrix,t.placementViewportMatrix=e.viewportMatrix,t.collisionCircleArray=e.circles,delete this.collisionCircleArrays[t.bucketInstanceId]}}symbolFadeChange(e){return 0===this.fadeDuration?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(e,t){const r=this.zoomAtLastRecencyCheck===t?1-this.zoomAdjustment(t):1;return this.zoomAtLastRecencyCheck=t,this.commitTime+this.fadeDuration*r>e}setStale(){this.stale=!0}}function Ur(e,t,r,i,n){e.emplaceBack(t?1:0,r?1:0,i||0,n||0),e.emplaceBack(t?1:0,r?1:0,i||0,n||0),e.emplaceBack(t?1:0,r?1:0,i||0,n||0),e.emplaceBack(t?1:0,r?1:0,i||0,n||0)}const Hr=Math.pow(2,25),Gr=Math.pow(2,24),Zr=Math.pow(2,17),Wr=Math.pow(2,16),Qr=Math.pow(2,9),qr=Math.pow(2,8),Xr=Math.pow(2,1);function Yr(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;const t=e.placed?1:0,r=Math.floor(127*e.opacity);return r*Hr+t*Gr+r*Zr+t*Wr+r*Qr+t*qr+r*Xr+t}const $r=0;class Kr{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&void 0!==e.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs=new Set,this._bucketParts=[]}continuePlacement(e,t,r,i,n){const o=this._bucketParts;for(;this._currentTileIndex<e.length;)if(t.getBucketParts(o,i,e[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,n())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,o.sort(((e,t)=>e.sortKey-t.sortKey)));this._currentPartIndex<o.length;){const e=o[this._currentPartIndex];if(t.placeLayerBucketPart(e,this._seenCrossTileIDs,r,0===e.symbolInstanceStart),this._currentPartIndex++,n())return!0}return!1}}class Jr{constructor(e,t,r,i,n,o,s,a,l){this.placement=new Nr(e,n,o,s,a,l),this._currentPlacementIndex=t.length-1,this._forceFullPlacement=r,this._showCollisionBoxes=i,this._done=!1}isDone(){return this._done}continuePlacement(t,r,i,n){const o=e.f.now(),s=()=>{const t=e.f.now()-o;return!this._forceFullPlacement&&t>2};for(;this._currentPlacementIndex>=0;){const o=r[t[this._currentPlacementIndex]],a=this.placement.collisionIndex.transform.zoom;if("symbol"===o.type&&(!o.minzoom||o.minzoom<=a)&&(!o.maxzoom||o.maxzoom>a)){const t=o,r=t.layout.get("symbol-z-elevate"),a=this._inProgressLayer=this._inProgressLayer||new Kr(t),l=e.aj(o.source,o.scope);if(a.continuePlacement(r?n[l]:i[l],this.placement,this._showCollisionBoxes,o,s))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const ei=512/e.Y/2;class ti{constructor(t,r,i){this.tileID=t,this.bucketInstanceId=i,this.index=new e.bj(r.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const n=t.canonical.x*e.Y,o=t.canonical.y*e.Y;for(let e=0;e<r.length;e++){const{key:t,crossTileID:i,tileAnchorX:s,tileAnchorY:a}=r.get(e),l=Math.floor((n+s)*ei),c=Math.floor((o+a)*ei);this.index.add(l,c),this.keys.push(t),this.crossTileIDs.push(i)}this.index.finish()}findMatches(t,r,i){const n=this.tileID.canonical.z<r.canonical.z?1:Math.pow(2,this.tileID.canonical.z-r.canonical.z),o=ei/Math.pow(2,r.canonical.z-this.tileID.canonical.z),s=r.canonical.x*e.Y,a=r.canonical.y*e.Y;for(let e=0;e<t.length;e++){const r=t.get(e);if(r.crossTileID)continue;const{key:l,tileAnchorX:c,tileAnchorY:u}=r,h=Math.floor((s+c)*o),d=Math.floor((a+u)*o),p=this.index.range(h-n,d-n,h+n,d+n);for(const e of p){const t=this.crossTileIDs[e];if(this.keys[e]===l&&!i.has(t)){i.add(t),r.crossTileID=t;break}}}}}class ri{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class ii{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){const t=Math.round((e-this.lng)/360);if(0!==t)for(const e in this.indexes){const r=this.indexes[e],i={};for(const e in r){const n=r[e];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+t),i[n.tileID.key]=n}this.indexes[e]=i}this.lng=e}addBucket(e,t,r){if(this.indexes[e.overscaledZ]&&this.indexes[e.overscaledZ][e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===t.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key])}for(let e=0;e<t.symbolInstances.length;e++)t.symbolInstances.get(e).crossTileID=0;this.usedCrossTileIDs[e.overscaledZ]||(this.usedCrossTileIDs[e.overscaledZ]=new Set);const i=this.usedCrossTileIDs[e.overscaledZ];for(const r in this.indexes){const n=this.indexes[r];if(Number(r)>e.overscaledZ)for(const r in n){const o=n[r];o.tileID.isChildOf(e)&&o.findMatches(t.symbolInstances,e,i)}else{const o=n[e.scaledTo(Number(r)).key];o&&o.findMatches(t.symbolInstances,e,i)}}for(let e=0;e<t.symbolInstances.length;e++){const n=t.symbolInstances.get(e);n.crossTileID||(n.crossTileID=r.generate(),i.add(n.crossTileID))}return void 0===this.indexes[e.overscaledZ]&&(this.indexes[e.overscaledZ]={}),this.indexes[e.overscaledZ][e.key]=new ti(e,t.symbolInstances,t.bucketInstanceId),!0}removeBucketCrossTileIDs(e,t){for(const r of t.crossTileIDs)this.usedCrossTileIDs[e].delete(r)}removeStaleBuckets(e){let t=!1;for(const r in this.indexes){const i=this.indexes[r];for(const n in i)e[i[n].bucketInstanceId]||(this.removeBucketCrossTileIDs(r,i[n]),delete i[n],t=!0)}return t}}class ni{constructor(){this.layerIndexes={},this.crossTileIDs=new ri,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(e,t,r,i){let n=this.layerIndexes[e.fqid];void 0===n&&(n=this.layerIndexes[e.fqid]=new ii);let o=!1;const s={};"globe"!==i.name&&n.handleWrapJump(r);for(const r of t){const t=r.getBucket(e);t&&e.fqid===t.layerIds[0]&&(t.bucketInstanceId||(t.bucketInstanceId=++this.maxBucketInstanceId),n.addBucket(r.tileID,t,this.crossTileIDs)&&(o=!0),s[t.bucketInstanceId]=!0)}return n.removeStaleBuckets(s)&&(o=!0),o}pruneUnusedLayers(e){const t={};e.forEach((e=>{t[e]=!0}));for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e]}}class oi{constructor(e=0,t=0,r=0,i=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(r)||r<0||isNaN(i)||i<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=t,this.left=r,this.right=i}interpolate(t,r,i){return null!=r.top&&null!=t.top&&(this.top=e.X(t.top,r.top,i)),null!=r.bottom&&null!=t.bottom&&(this.bottom=e.X(t.bottom,r.bottom,i)),null!=r.left&&null!=t.left&&(this.left=e.X(t.left,r.left,i)),null!=r.right&&null!=t.right&&(this.right=e.X(t.right,r.right,i)),this}getCenter(t,r){const i=e.ad((this.left+t-this.right)/2,0,t),n=e.ad((this.top+r-this.bottom)/2,0,r);return new e.P(i,n)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new oi(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function si(t,r){const i=e.bn(t,3);e.a9.fromQuat(t,r),e.bp(t,3,i)}function ai(t,r){const i=e.bl.identity([]);return e.bl.rotateZ(i,i,-r),e.bl.rotateX(i,i,-t),i}function li(t,r){const i=[t[0],t[1],0],n=[r[0],r[1],0];if(e.Q.length(i)>=1e-15){const t=e.Q.normalize([],i);e.Q.scale(n,t,e.Q.dot(n,t)),r[0]=n[0],r[1]=n[1]}const o=e.Q.cross([],r,t);if(e.Q.len(o)<1e-15)return null;const s=Math.atan2(-o[1],o[0]);return ai(Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2]),s)}class ci{constructor(e,t){this.position=e,this.orientation=t}get position(){return this._position}set position(t){if(t){const r=t instanceof e.O?t:new e.O(t[0],t[1],t[2]);this._renderWorldCopies&&(r.x=e.bk(r.x,0,1)),this._position=r}else this._position=null}lookAtPoint(t,r){if(this.orientation=null,!this.position)return;const i=this.position,n=this._elevation?this._elevation.getAtPointOrZero(e.O.fromLngLat(t)):0,o=e.O.fromLngLat(t,n),s=[o.x-i.x,o.y-i.y,o.z-i.z];r||(r=[0,0,1]),r[2]=Math.abs(r[2]),this.orientation=li(s,r)}setPitchBearing(t,r){this.orientation=ai(e.bm(t),e.bm(-r))}}class ui{constructor(t,r){this._transform=e.a9.identity([]),this.orientation=r,this.position=t}get mercatorPosition(){const t=this.position;return new e.O(t[0],t[1],t[2])}get position(){const t=e.bn(this._transform,3);return[t[0],t[1],t[2]]}set position(t){var r;t&&e.bp(this._transform,3,[(r=t)[0],r[1],r[2],1])}get orientation(){return this._orientation}set orientation(t){this._orientation=t||e.bl.identity([]),t&&si(this._transform,this._orientation)}getPitchBearing(){const e=this.forward(),t=this.right();return{bearing:Math.atan2(-t[1],t[0]),pitch:Math.atan2(Math.sqrt(e[0]*e[0]+e[1]*e[1]),-e[2])}}setPitchBearing(e,t){this._orientation=ai(e,t),si(this._transform,this._orientation)}forward(){const t=e.bn(this._transform,2);return[-t[0],-t[1],-t[2]]}up(){const t=e.bn(this._transform,1);return[-t[0],-t[1],-t[2]]}right(){const t=e.bn(this._transform,0);return[t[0],t[1],t[2]]}getCameraToWorld(t,r){const i=new Float64Array(16);return e.a9.invert(i,this.getWorldToCamera(t,r)),i}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(t,r,i){const n=this.position;e.Q.scale(n,n,-t);const o=new Float64Array(16);return e.a9.fromScaling(o,[i,i,i]),e.a9.translate(o,o,n),o[10]*=r,o}getWorldToCamera(t,r){const i=new Float64Array(16),n=new Float64Array(4),o=this.position;return e.bl.conjugate(n,this._orientation),e.Q.scale(o,o,-t),e.a9.fromQuat(i,n),e.a9.translate(i,i,o),i[1]*=-1,i[5]*=-1,i[9]*=-1,i[13]*=-1,i[8]*=r,i[9]*=r,i[10]*=r,i[11]*=r,i}getCameraToClipPerspective(t,r,i,n){const o=new Float64Array(16);return e.a9.perspective(o,t,r,i,n),o}getCameraToClipOrthographic(t,r,i,n,o,s){const a=new Float64Array(16);return e.a9.ortho(a,t,r,i,n,o,s),a}getDistanceToElevation(t,r=!1){const i=0===t?0:e.bo(t,r?e.ax(this.position[1]):this.position[1]),n=this.forward();return(i-this.position[2])/n[2]}clone(){return new ui([...this.position],[...this.orientation])}}const hi=(e,t,r)=>(1-r)*e+r*t,di=e=>e*e*e*e*e;class pi{constructor(t,r,i,n,o,s,a){this.tileSize=512,this._renderWorldCopies=void 0===o||o,this._minZoom=t||0,this._maxZoom=r||22,this._minPitch=null==i?0:i,this._maxPitch=null==n?60:n,this.setProjection(s),this.setMaxBounds(a),this.width=0,this.height=0,this._center=new e.bq(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 oi,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new ui,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 e=new pi(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection());return e._elevation=this._elevation,e._centerAltitude=this._centerAltitude,e._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,e.tileSize=this.tileSize,e.mercatorFromTransition=this.mercatorFromTransition,e.width=this.width,e.height=this.height,e.cameraElevationReference=this.cameraElevationReference,e._center=this._center,e._setZoom(this.zoom),e._seaLevelZoom=this._seaLevelZoom,e.angle=this.angle,e._fov=this._fov,e._pitch=this._pitch,e._nearZ=this._nearZ,e._farZ=this._farZ,e._averageElevation=this._averageElevation,e._orthographicProjectionAtLowPitch=this._orthographicProjectionAtLowPitch,e._unmodified=this._unmodified,e._edgeInsets=this._edgeInsets.clone(),e._camera=this._camera.clone(),e._calcMatrices(),e.freezeTileCoverage=this.freezeTileCoverage,e.frustumCorners=this.frustumCorners,e}get isOrthographic(){return"globe"!==this.projection.name&&this._orthographicProjectionAtLowPitch&&this.pitch<15}get elevation(){return this._elevation}set elevation(e){this._elevation!==e&&(this._elevation=e,this._updateCameraOnTerrain(),this._calcMatrices())}get depthOcclusionForSymbolsAndCircles(){return"globe"!==this.projection.name&&!this.isOrthographic}updateElevation(e,t=!1){const r=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(null==this._seaLevelZoom||r)&&this._updateCameraOnTerrain(),(e||r)&&this._constrainCamera(t),this._calcMatrices()}getProjection(){return e.af(this.projection,["name","center","parallels"])}setProjection(r){this.projectionOptions=r||{name:"mercator"};const i=this.projection?this.getProjection():void 0;this.projection=e.br(this.projectionOptions);const n=!t(i,this.getProjection());return n&&this._calcMatrices(),this.mercatorFromTransition=!1,n}setOrthographicProjectionAtLowPitch(e){return this._orthographicProjectionAtLowPitch!==e&&(this._orthographicProjectionAtLowPitch=e,this._calcMatrices(),!0)}setMercatorFromTransition(){const t=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=e.br({name:"mercator"});const r=t!==this.projection.name;return r&&this._calcMatrices(),r}get minZoom(){return this._minZoom}set minZoom(e){this._minZoom!==e&&(this._minZoom=e,this.zoom=Math.max(this.zoom,e))}get maxZoom(){return this._maxZoom}set maxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.zoom=Math.min(this.zoom,e))}get minPitch(){return this._minPitch}set minPitch(e){this._minPitch!==e&&(this._minPitch=e,this.pitch=Math.max(this.pitch,e))}get maxPitch(){return this._maxPitch}set maxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.pitch=Math.min(this.pitch,e))}get renderWorldCopies(){return this._renderWorldCopies&&!0===this.projection.supportsWorldCopies}set renderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e}get worldSize(){return this.tileSize*this.scale}get cameraWorldSizeForFog(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get cameraWorldSize(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation,!0),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return e.bo(1,this.center.lat)*this.cameraWorldSizeForFog}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new e.P(this.width,this.height)}get bearing(){return e.bk(this.rotation,-180,180)}set bearing(e){this.rotation=e}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=e.b7.create(),e.b7.rotate(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(t){const r=e.ad(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 e=1/Math.tan(.5*this.fovX);return 2*Math.atan(1/this.aspect/e)}set fov(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=e.bm(t),this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(e){this._averageElevation=e,this._calcFogMatrices(),this._distanceTileDataCache={}}get zoom(){return this._zoom}set zoom(e){const t=Math.min(Math.max(e,this.minZoom),this.maxZoom);this._zoom!==t&&(this._unmodified=!1,this._setZoom(t),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(e){this._zoom=e,this.scale=this.zoomScale(e),this.tileZoom=Math.floor(e),this.zoomFraction=e-this.tileZoom}get tileCoverLift(){return this._tileCoverLift}set tileCoverLift(e){this._tileCoverLift!==e&&(this._tileCoverLift=e)}_updateCameraOnTerrain(){const e=this.elevation?this.elevation.getAtPoint(this.locationCoordinate(this.center),Number.NEGATIVE_INFINITY):Number.NEGATIVE_INFINITY,t=this.elevation&&e===Number.NEGATIVE_INFINITY&&this.elevation.visibleDemTiles.length>0&&this.elevation.exaggeration()>0&&this._centerAltitudeValidForExaggeration;if(!this._elevation||e===Number.NEGATIVE_INFINITY&&(!t||!this._centerAltitude))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const r=this._elevation;t||this._centerAltitude&&this._centerAltitudeValidForExaggeration&&r.exaggeration()&&this._centerAltitudeValidForExaggeration!==r.exaggeration()?(this._centerAltitude=this._centerAltitude/this._centerAltitudeValidForExaggeration*r.exaggeration(),this._centerAltitudeValidForExaggeration=r.exaggeration()):(this._centerAltitude=e||0,this._centerAltitudeValidForExaggeration=r.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]],i=this.horizonLineFromTop();let n=0,o=0;for(let s=0;s<r.length;s++){const a=new e.P(r[s][0]*this.width,i+r[s][1]*(this.height-i)),l=t.pointCoordinate(a);if(!l)continue;const c=1/Math.hypot(l[0]-this._camera.position[0],l[1]-this._camera.position[1]);n+=l[3]*c,o+=c}return 0===o?NaN:n/o}get center(){return this._center}set center(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this._terrainEnabled()&&("ground"===this.cameraElevationReference?this._updateCameraOnTerrain():this._updateZoomFromElevation()),this._constrain(),this._calcMatrices())}_updateZoomFromElevation(){if(null==this._seaLevelZoom||!this._elevation)return;const e=this._seaLevelZoom,t=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center)),r=this.pixelsPerMeter/this.worldSize*t,i=this._mercatorZfromZoom(e),n=this._mercatorZfromZoom(this._maxZoom),o=Math.max(i-r,n);this._setZoom(this._zoomFromMercatorZ(o))}get padding(){return this._edgeInsets.toJSON()}set padding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices())}computeZoomRelativeTo(t){const r=this.rayIntersectionCoordinate(this.pointRayIntersection(this.centerPoint,t.toAltitude()));let i;i=t.z<this._camera.position[2]?[r.x,r.y,r.z]:[t.x,t.y,t.z];const n=e.Q.length(e.Q.sub([],this._camera.position,i));return e.ad(this._zoomFromMercatorZ(n),this._minZoom,this._maxZoom)}setFreeCameraOptions(t){if(!this.height)return;if(!t.position&&!t.orientation)return;this._updateCameraState();let r=!1;if(t.orientation&&!e.bl.exactEquals(t.orientation,this._camera.orientation)&&(r=this._setCameraOrientation(t.orientation)),t.position){const i=[t.position.x,t.position.y,t.position.z];e.Q.exactEquals(i,this._camera.position)||(this._setCameraPosition(i),r=!0)}r&&(this._updateStateFromCamera(),this.recenterOnTerrain())}getFreeCameraOptions(){this._updateCameraState();const t=this._camera.position,r=new ci;return r.position=new e.O(t[0],t[1],t[2]),r.orientation=this._camera.orientation,r._elevation=this.elevation,r._renderWorldCopies=this.renderWorldCopies,r}_setCameraOrientation(t){if(!e.bl.length(t))return!1;e.bl.normalize(t,t);const r=e.Q.transformQuat([],[0,0,-1],t),i=e.Q.transformQuat([],[0,-1,0],t);if(i[2]<0)return!1;const n=li(r,i);return!!n&&(this._camera.orientation=n,!0)}_setCameraPosition(t){const r=this.zoomScale(this.minZoom)*this.tileSize,i=this.zoomScale(this.maxZoom)*this.tileSize,n=this.cameraToCenterDistance;t[2]=e.ad(t[2],n/i,n/r),this._camera.position=t}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}get fovAboveCenter(){return this._fov*(.5+this.centerOffset.y/this.height)}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,t,r){this._unmodified=!1,this._edgeInsets.interpolate(e,t,r),this._constrain(),this._calcMatrices()}coveringZoomLevel(e){const t=(e.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/e.tileSize));return Math.max(0,t)}getVisibleUnwrappedCoordinates(t){const r=[new e.bs(0,t)];if(this.renderWorldCopies){const i=this.pointCoordinate(new e.P(0,0)),n=this.pointCoordinate(new e.P(this.width,0)),o=this.pointCoordinate(new e.P(this.width,this.height)),s=this.pointCoordinate(new e.P(0,this.height)),a=Math.floor(Math.min(i.x,n.x,o.x,s.x)),l=Math.floor(Math.max(i.x,n.x,o.x,s.x)),c=1;for(let i=a-c;i<=l+c;i++)0!==i&&r.push(new e.bs(i,t))}return r}isLODDisabled(e){return(!e||this.pitch<=60)&&this._edgeInsets.top<=this._edgeInsets.bottom&&!this._elevation&&!this.projection.isReprojectedInTileSpace}extendTileCoverForShadows(t,r,i){let n=[];if(0===r[0]&&0===r[1])return n;for(const i of t){const t=i.canonical,o=i.overscaledZ,s=i.wrap,a=1<<t.z,l=t.x+1<a,c=t.x>0,u=t.y+1<a,h=t.y>0,d=i.wrap-(c?0:1),p=i.wrap+(l?0:1),f=c?t.x-1:a-1,m=l?t.x+1:0;r[0]<0?(n.push(new e.ap(o,p,t.z,m,t.y)),r[1]<0&&u&&(n.push(new e.ap(o,s,t.z,t.x,t.y+1)),n.push(new e.ap(o,p,t.z,m,t.y+1))),r[1]>0&&h&&(n.push(new e.ap(o,s,t.z,t.x,t.y-1)),n.push(new e.ap(o,p,t.z,m,t.y-1)))):r[0]>0?(n.push(new e.ap(o,d,t.z,f,t.y)),r[1]<0&&u&&(n.push(new e.ap(o,s,t.z,t.x,t.y+1)),n.push(new e.ap(o,d,t.z,f,t.y+1))),r[1]>0&&h&&(n.push(new e.ap(o,s,t.z,t.x,t.y-1)),n.push(new e.ap(o,d,t.z,f,t.y-1)))):r[1]<0&&u?n.push(new e.ap(o,s,t.z,t.x,t.y+1)):h&&n.push(new e.ap(o,s,t.z,t.x,t.y-1))}if(n.length>1){n.sort(((e,t)=>e.overscaledZ-t.overscaledZ||e.wrap-t.wrap||e.canonical.z-t.canonical.z||e.canonical.x-t.canonical.x||e.canonical.y-t.canonical.y));let e=0,t=0;for(;t<n.length;)n[t].equals(n[e])?++t:n[++e]=n[t++];n.length=e+1}const o=[];for(const e of n)n.some((t=>e.isChildOf(t)))||o.push(e);return n=o.filter((e=>!t.some((t=>!!(e.overscaledZ<i&&t.isChildOf(e))||e.equals(t)||e.isChildOf(t))))),n}coveringTiles(t){let r=this.coveringZoomLevel(t);const i=r,n=this.elevation&&this.elevation.exaggeration(),o=n&&!t.isTerrainDEM,s="mercator"===this.projection.name;if(void 0!==t.minzoom&&r<t.minzoom)return[];void 0!==t.maxzoom&&r>t.maxzoom&&(r=t.maxzoom);const a=this.locationCoordinate(this.center),l=this.center.lat,c=1<<r,u=[c*a.x,c*a.y,0],h="globe"===this.projection.name,d=!h,p=e.bt.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,r,d),f=h?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),m=c*e.bo(1,this.center.lat),A=this._camera.position[2]/e.bo(1,this.center.lat),g=[c*f.x,c*f.y,A*(d?1:m)],_=h||n,y=this.cameraToCenterDistance/t.tileSize*(t.roundZoom?1:.502),x=this.isLODDisabled(!0)?r:0;let v;if(this._elevation&&t.isTerrainDEM)v=1e4*this._elevation.exaggeration();else if(this._elevation){const e=this._elevation.getMinMaxForVisibleTiles();v=e?e.max:this._centerAltitude}else v=this._centerAltitude;const b=t.isTerrainDEM?-v:this._elevation?this._elevation.getMinElevationBelowMSL():0,w=this.projection.isReprojectedInTileSpace?e.bu(this):1,C=t=>{const r=1/4e4,i=new e.O(t.x+r,t.y,t.z),n=new e.O(t.x,t.y+r,t.z),o=t.toLngLat(),s=i.toLngLat(),a=n.toLngLat(),l=this.locationCoordinate(o),c=this.locationCoordinate(s),u=this.locationCoordinate(a),h=Math.hypot(c.x-l.x,c.y-l.y),d=Math.hypot(u.x-l.x,u.y-l.y);return Math.sqrt(h*d)*w/r},T=t=>{const r=v,i=b;return{aabb:e.bx(this,c,0,0,0,t,i,r,this.projection),zoom:0,x:0,y:0,minZ:i,maxZ:r,wrap:t,fullyVisible:!1}},E=[];let M=[];const S=r,I=t.reparseOverscaled?i:r,P=e=>e*e,D=P((A-this._centerAltitude)*m),k=e=>{if(!this._elevation||!e.tileID||!s)return;const t=this._elevation.getMinMaxForTile(e.tileID),r=e.aabb;t?(r.min[2]=t.min,r.max[2]=t.max,r.center[2]=(r.min[2]+r.max[2])/2):(e.shouldSplit=L(e),e.shouldSplit||(r.min[2]=r.max[2]=r.center[2]=this._centerAltitude))},L=t=>{if(t.zoom<x)return!0;if(t.zoom===S)return!1;if(null!=t.shouldSplit)return t.shouldSplit;const r=t.aabb.distanceX(g),n=t.aabb.distanceY(g);let s=D,a=1;if(h){s=P(t.aabb.distanceZ(g));const r=Math.pow(2,t.zoom),i=e.ax((t.y+1)/r),n=e.ax(t.y/r),o=Math.min(Math.max(l,i),n),c=e.bM(o)/e.bM(l);if(a=o===l?1/Math.max(1,this._mercatorScaleRatio-.3):Math.min(1,c/this._mercatorScaleRatio),this.zoom<=e.bJ&&t.zoom===S-1&&c>=.9)return!0}else if(o&&(s=P(t.aabb.distanceZ(g)*m)),this.projection.isReprojectedInTileSpace&&i<=5){const r=Math.pow(2,t.zoom),i=C(new e.O((t.x+.5)/r,(t.y+.5)/r));a=i>.85?1:i}const c=r*r+n*n+s,u=P((1<<S-t.zoom)*y*a*((e,t)=>{if(t*P(.707)<e)return 1;const r=Math.sqrt(t/e);return r/(1.4144271570014144+(Math.pow(1.1,r-1.4144271570014144+1)-1)/(1.1-1)-1)})(Math.max(s,D),c));return c<u};if(this.renderWorldCopies)for(let e=1;e<=3;e++)E.push(T(-e)),E.push(T(e));for(E.push(T(0));E.length>0;){const i=E.pop(),n=i.x,a=i.y;let l=i.fullyVisible;const d=()=>"globe"===this.projection.name&&(0===i.y||i.y===(1<<i.zoom)-1);if(!l){let t=_?i.aabb.intersects(p):i.aabb.intersectsFlat(p);if(0===t&&d()){const r=new e.bv(i.zoom,n,a);t=e.bw(this,c,r,!0).intersects(p)}if(0===t)continue;l=2===t}if(i.zoom!==S&&L(i))for(let t=0;t<4;t++){const r=(n<<1)+t%2,u=(a<<1)+(t>>1),d={aabb:s?i.aabb.quadrant(t):e.bx(this,c,i.zoom+1,r,u,i.wrap,i.minZ,i.maxZ,this.projection),zoom:i.zoom+1,x:r,y:u,wrap:i.wrap,fullyVisible:l,tileID:void 0,shouldSplit:void 0,minZ:i.minZ,maxZ:i.maxZ};o&&!h&&(d.tileID=new e.ap(i.zoom+1===S?I:i.zoom+1,i.wrap,i.zoom+1,r,u),k(d)),E.push(d)}else{const o=i.zoom===S?I:i.zoom;if(t.minzoom&&t.minzoom>o)continue;if(!l){let t=_?i.aabb.intersectsPrecise(p):i.aabb.intersectsPreciseFlat(p);if(0===t&&d()){const r=new e.bv(i.zoom,n,a);t=e.bw(this,c,r,!0).intersectsPrecise(p)}if(0===t)continue}const s=u[0]-(.5+n+(i.wrap<<i.zoom))*(1<<r-i.zoom),h=u[1]-.5-a,f=i.tileID?i.tileID:new e.ap(o,i.wrap,i.zoom,n,a);M.push({tileID:f,distanceSq:s*s+h*h})}}if(this.fogCullDistSq){const r=this.fogCullDistSq,i=this.horizonLineFromTop();M=M.filter((n=>{const o=[0,0,0,1],s=[e.Y,e.Y,0,1],a=this.calculateFogTileMatrix(n.tileID.toUnwrapped());e.aa.transformMat4(o,o,a),e.aa.transformMat4(s,s,a);const l=e.aa.min([],o,s),c=e.aa.max([],o,s),u=e.by(l,c);if(0===u)return!0;let h=!1;const d=this._elevation;if(d&&u>r&&0!==i){const r=this.calculateProjMatrix(n.tileID.toUnwrapped());let o;t.isTerrainDEM||(o=d.getMinMaxForTile(n.tileID)),o||(o={min:b,max:v});const s=e.bK(this.rotation),a=[s[0]*e.Y,s[1]*e.Y,o.max];e.Q.transformMat4(a,a,r),h=(1-a[1])*this.height*.5<i}return u<r||h}))}return M.sort(((e,t)=>e.distanceSq-t.distanceSq)).map((e=>e.tileID))}resize(e,t){this.width=e,this.height=t,this.pixelsToGLUnits=[2/e,-2/t],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(e){return Math.pow(2,e)}scaleZoom(e){return Math.log(e)/Math.LN2}project(t){const r=e.ad(t.lat,-e.bz,e.bz),i=this.projection.project(t.lng,r);return new e.P(i.x*this.worldSize,i.y*this.worldSize)}unproject(e){return this.projection.unproject(e.x/this.worldSize,e.y/this.worldSize)}get point(){return this.project(this.center)}get pointMerc(){return this.point._div(this.worldSize)}get pixelsPerMeterRatio(){return this.pixelsPerMeter/e.bo(1,this.center.lat)/this.worldSize}setLocationAtPoint(t,r){let i,n;const o=this.centerPoint;if("globe"===this.projection.name){const e=this.worldSize;i=(r.x-o.x)/e,n=(r.y-o.y)/e}else{const e=this.pointCoordinate(r),t=this.pointCoordinate(o);i=e.x-t.x,n=e.y-t.y}const s=this.locationCoordinate(t);this.setLocation(new e.O(s.x-i,s.y-n))}setLocation(e){this.center=this.coordinateLocation(e),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(e){return this.projection.locationPoint(this,e)}locationPoint3D(e){return this.projection.locationPoint(this,e,!0)}pointLocation(e){return this.coordinateLocation(this.pointCoordinate(e))}pointLocation3D(e){return this.coordinateLocation(this.pointCoordinate3D(e))}locationCoordinate(t,r){const i=r?e.bo(r,t.lat):void 0,n=this.projection.project(t.lng,t.lat);return new e.O(n.x,n.y,i)}coordinateLocation(e){return this.projection.unproject(e.x,e.y)}pointRayIntersection(t,r){const i=null!=r?r:this._centerAltitude,n=[t.x,t.y,0,1],o=[t.x,t.y,1,1];e.aa.transformMat4(n,n,this.pixelMatrixInverse),e.aa.transformMat4(o,o,this.pixelMatrixInverse);const s=o[3];e.aa.scale(n,n,1/n[3]),e.aa.scale(o,o,1/s);const a=n[2],l=o[2];return{p0:n,p1:o,t:a===l?0:(i-a)/(l-a)}}screenPointToMercatorRay(t){const r=[t.x,t.y,0,1],i=[t.x,t.y,1,1];return e.aa.transformMat4(r,r,this.pixelMatrixInverse),e.aa.transformMat4(i,i,this.pixelMatrixInverse),e.aa.scale(r,r,1/r[3]),e.aa.scale(i,i,1/i[3]),r[2]=e.bo(r[2],this._center.lat)*this.worldSize,i[2]=e.bo(i[2],this._center.lat)*this.worldSize,e.aa.scale(r,r,1/this.worldSize),e.aa.scale(i,i,1/this.worldSize),new e.a5([r[0],r[1],r[2]],e.Q.normalize([],e.Q.sub([],i,r)))}rayIntersectionCoordinate(t){const{p0:r,p1:i,t:n}=t,o=e.bo(r[2],this._center.lat),s=e.bo(i[2],this._center.lat);return new e.O(e.X(r[0],i[0],n)/this.worldSize,e.X(r[1],i[1],n)/this.worldSize,e.X(o,s,n))}pointCoordinate(e,t=this._centerAltitude){return this.projection.pointCoordinate(this,e.x,e.y,t)}pointCoordinate3D(t){if(!this.elevation)return this.pointCoordinate(t);let r=this.projection.pointCoordinate3D(this,t.x,t.y);if(r)return new e.O(r[0],r[1],r[2]);let i=0,n=this.horizonLineFromTop();if(t.y>n)return this.pointCoordinate(t);const o=.02*n,s=t.clone();for(let t=0;t<10&&n-i>o;t++){s.y=e.X(i,n,.66);const t=this.projection.pointCoordinate3D(this,s.x,s.y);t?(n=s.y,r=t):i=s.y}return r?new e.O(r[0],r[1],r[2]):this.pointCoordinate(t)}isPointAboveHorizon(e){return this.projection.isPointAboveHorizon(this,e)}isPointOnSurface(t){if(t.y<0||t.y>this.height||t.x<0||t.x>this.width)return!1;if(this.elevation||this.zoom>=e.bA)return!this.isPointAboveHorizon(t);const r=this.pointCoordinate(t);return r.y>=0&&r.y<=1}_coordinatePoint(t,r){const i=r&&this.elevation?this.elevation.getAtPointOrZero(t,this._centerAltitude):this._centerAltitude,n=[t.x*this.worldSize,t.y*this.worldSize,i+t.toAltitude(),1];return e.aa.transformMat4(n,n,this.pixelMatrix),n[3]>0?new e.P(n[0]/n[3],n[1]/n[3]):new e.P(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){const{top:t,left:r}=this._edgeInsets,i=this.height-this._edgeInsets.bottom,n=this.width-this._edgeInsets.right,o=this.pointLocation3D(new e.P(r,t)),s=this.pointLocation3D(new e.P(n,t)),a=this.pointLocation3D(new e.P(n,i)),l=this.pointLocation3D(new e.P(r,i));let c=Math.min(o.lng,s.lng,a.lng,l.lng),u=Math.max(o.lng,s.lng,a.lng,l.lng),h=Math.min(o.lat,s.lat,a.lat,l.lat),d=Math.max(o.lat,s.lat,a.lat,l.lat);const p=Math.pow(2,-this.zoom)/16*270,f="globe"===this.projection.name?1:4,m=(t,r,i,n,o)=>{const s=(t+i)/2,a=(r+n)/2,l=new e.P(s,a),{lng:A,lat:g}=this.pointLocation3D(l),_=Math.max(0,c-A,h-g,A-u,g-d);c=Math.min(c,A),u=Math.max(u,A),h=Math.min(h,g),d=Math.max(d,g),(o<f||_>p)&&(m(t,r,s,a,o+1),m(s,a,i,n,o+1))};if(m(r,t,n,t,1),m(n,t,n,i,1),m(n,i,r,i,1),m(r,i,r,t,1),"globe"===this.projection.name){const[t,r]=e.bB(this);t?(d=90,u=180,c=-180):r&&(h=-90,u=180,c=-180)}return new e.ag(new e.bq(c,h),new e.bq(u,d))}_getBoundsRectangular(t,r){const{top:i,left:n}=this._edgeInsets,o=this.height-this._edgeInsets.bottom,s=this.width-this._edgeInsets.right,a=new e.P(n,i),l=new e.P(s,i),c=new e.P(s,o),u=new e.P(n,o);let h=this.pointCoordinate(a,t),d=this.pointCoordinate(l,t);const p=this.pointCoordinate(c,r),f=this.pointCoordinate(u,r),m=(e,t)=>(t.y-e.y)/(t.x-e.x);return h.y>1&&d.y>=0?h=new e.O((1-f.y)/m(f,h)+f.x,1):h.y<0&&d.y<=1&&(h=new e.O(-f.y/m(f,h)+f.x,0)),d.y>1&&h.y>=0?d=new e.O((1-p.y)/m(p,d)+p.x,1):d.y<0&&h.y<=1&&(d=new e.O(-p.y/m(p,d)+p.x,0)),(new e.ag).extend(this.coordinateLocation(h)).extend(this.coordinateLocation(d)).extend(this.coordinateLocation(f)).extend(this.coordinateLocation(p))}_getBoundsRectangularTerrain(){const e=this.elevation;if(!e.visibleDemTiles.length||e.isUsingMockSource())return this._getBoundsRectangular(0,0);const t=e.visibleDemTiles.reduce(((e,t)=>{if(t.dem){const r=t.dem.tree;e.min=Math.min(e.min,r.minimums[0]),e.max=Math.max(e.max,r.maximums[0])}return e}),{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(t.min*e.exaggeration(),t.max*e.exaggeration())}getBounds(){return"mercator"===this.projection.name||"equirectangular"===this.projection.name?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}horizonLineFromTop(e=!0){const t=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))-this.centerOffset.y,r=this.height/2-t*(1-this._horizonShift);return e?Math.max(0,r):r}getMaxBounds(){return this.maxBounds}setMaxBounds(t){this.maxBounds=t,this.minLat=-e.bz,this.maxLat=e.bz,this.minLng=-180,this.maxLng=180,t&&(this.minLat=t.getSouth(),this.maxLat=t.getNorth(),this.minLng=t.getWest(),this.maxLng=t.getEast(),this.maxLng<this.minLng&&(this.maxLng+=360)),this.worldMinX=e.a8(this.minLng)*this.tileSize,this.worldMaxX=e.a8(this.maxLng)*this.tileSize,this.worldMinY=e.ah(this.maxLat)*this.tileSize,this.worldMaxY=e.ah(this.minLat)*this.tileSize,this._constrain()}calculatePosMatrix(e,t){return this.projection.createTileMatrix(this,t,e)}calculateDistanceTileData(t){const r=t.key,i=this._distanceTileDataCache;if(i[r])return i[r];const n=t.canonical,o=1/this.height,s=this.cameraWorldSize,a=s/this.zoomScale(n.z),l=(n.x+Math.pow(2,n.z)*t.wrap)*a,c=n.y*a,u=this.point;u.x*=s/this.worldSize,u.y*=s/this.worldSize;const h=this.angle,d=Math.sin(-h),p=-Math.cos(-h);return i[r]={bearing:[d,p],center:[(u.x-l)*o,(u.y-c)*o],scale:a/e.Y*o},i[r]}calculateFogTileMatrix(t){const r=t.key,i=this._fogTileMatrixCache;if(i[r])return i[r];const n=this.projection.createTileMatrix(this,this.cameraWorldSizeForFog,t);return e.a9.multiply(n,this.worldToFogMatrix,n),i[r]=new Float32Array(n),i[r]}calculateProjMatrix(t,r=!1,i=!1){const n=t.key;let o;if(o=i?this._expandedProjMatrixCache:r?this._alignedProjMatrixCache:this._projMatrixCache,o[n])return o[n];const s=this.calculatePosMatrix(t,this.worldSize);let a;return a=this.projection.isReprojectedInTileSpace?this.mercatorMatrix:i?this.expandedFarZProjMatrix:r?this.alignedProjMatrix:this.projMatrix,e.a9.multiply(s,a,s),o[n]=new Float32Array(s),o[n]}calculatePixelsToTileUnitsMatrix(t){const r=t.tileID.key,i=this._pixelsToTileUnitsCache;if(i[r])return i[r];const n=e.bC(t,this);return i[r]=n,i[r]}customLayerMatrix(){return this.mercatorMatrix.slice()}globeToMercatorMatrix(){if("globe"===this.projection.name){const t=1/this.worldSize,r=e.a9.fromScaling([],[t,t,t]);return e.a9.multiply(r,r,this.globeMatrix),r}}recenterOnTerrain(){if(!this._elevation||"globe"===this.projection.name)return;const t=this._elevation;this._updateCameraState();const r=e.bo(1,this._center.lat)*this.worldSize,i=this._computeCameraPosition(r),n=this._camera.forward(),o=e.bo(1,this._center.lat);i[2]/=o,n[2]/=o,e.Q.normalize(n,n);const s=t.raycast(i,n,t.exaggeration());if(s){const t=e.Q.scaleAndAdd([],i,n,s),r=new e.O(t[0],t[1],e.bo(t[2],e.ax(t[1]))),a=(r.z+e.Q.length([r.x-i[0],r.y-i[1],r.z-i[2]*o]))*this._pixelsPerMercatorPixel;this._seaLevelZoom=this._zoomFromMercatorZ(a),this._centerAltitude=r.toAltitude(),this._center=this.coordinateLocation(r),this._updateZoomFromElevation(),this._constrain(),this._calcMatrices()}}_constrainCamera(t=!1){if(!this._elevation)return;const r=this._elevation,i=e.bo(1,this._center.lat)*this.worldSize,n=this._computeCameraPosition(i),o=r.getAtPointOrZero(new e.O(...n)),s=this.pixelsPerMeter/this.worldSize*o,a=this._minimumHeightOverTerrain(),l=n[2]-s;if(l<=a)if(l<0||t){const t=this.locationCoordinate(this._center,this._centerAltitude),r=[n[0],n[1],t.z-n[2]],i=e.Q.length(r);r[2]-=(a-l)/this._pixelsPerMercatorPixel;const o=e.Q.length(r);if(0===o)return;e.Q.scale(r,r,i/o*this._pixelsPerMercatorPixel),this._camera.position=[n[0],n[1],t.z*this._pixelsPerMercatorPixel-r[2]],this._updateStateFromCamera()}else this._isCameraConstrained=!0}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const t="globe"===this.projection.name||this.mercatorFromTransition;if(this.projection.isReprojectedInTileSpace||t){const r=this.center;return r.lat=e.ad(r.lat,this.minLat,this.maxLat),(this.maxBounds||!this.renderWorldCopies&&!t)&&(r.lng=e.ad(r.lng,this.minLng,this.maxLng)),this.center=r,void(this._constraining=!1)}const r=this._unmodified,{x:i,y:n}=this.point;let o=0,s=i,a=n;const l=this.width/2,c=this.height/2,u=this.worldMinY*this.scale,h=this.worldMaxY*this.scale;if(n-c<u&&(a=u+c),n+c>h&&(a=h-c),h-u<this.height&&(o=Math.max(o,this.height/(h-u)),a=(h+u)/2),this.maxBounds||!this._renderWorldCopies||!this.projection.wrap){const e=this.worldMinX*this.scale,t=this.worldMaxX*this.scale,r=this.worldSize/2-(e+t)/2;s=(i+r+this.worldSize)%this.worldSize-r,s-l<e&&(s=e+l),s+l>t&&(s=t-l),t-e<this.width&&(o=Math.max(o,this.width/(t-e)),s=(t+e)/2)}s===i&&a===n||(this.center=this.unproject(new e.P(s,a))),o&&(this.zoom+=this.scaleZoom(o)),this._constrainCamera(),this._unmodified=r,this._constraining=!1}_minZoomForBounds(){let e=Math.max(0,this.scaleZoom(this.height/(this.worldMaxY-this.worldMinY)));return this.maxBounds&&(e=Math.max(e,this.scaleZoom(this.width/(this.worldMaxX-this.worldMinX)))),e}_maxCameraBoundsDistance(){return this._mercatorZfromZoom(this._minZoomForBounds())}_calcMatrices(){if(!this.height)return;const t=this.centerOffset,r="globe"===this.projection.name,i=this.pixelsPerMeter;"globe"===this.projection.name&&(this._mercatorScaleRatio=e.bo(1,this.center.lat)/e.bo(1,e.bL));const n=e.bD(this.projection,this.zoom,this.width,this.height,1024);this._pixelsPerMercatorPixel=this.projection.pixelSpaceConversion(this.center.lat,this.worldSize,n),this.cameraToCenterDistance=.5/Math.tan(.5*this._fov)*this.height*this._pixelsPerMercatorPixel,this._updateCameraState(),this._farZ=this.projection.farthestPixelDistance(this),this._nearZ=this.height/50;const o="meters"===this.projection.zAxisUnit?i:1,s=this._camera.getWorldToCamera(this.worldSize,o);let a;const l=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,this._farZ);if(l[8]=2*-t.x/this.width,l[9]=2*t.y/this.height,this.isOrthographic){let e=.5*this.height/Math.tan(this._fov/2)*1*Math.tan(.5*this._fov),r=e*this.aspect,i=-r,n=-e;r-=t.x,i-=t.x,e+=t.y,n+=t.y,a=this._camera.getCameraToClipOrthographic(i,r,n,e,this._nearZ,this._farZ),((e,t,r,i)=>{for(let n=0;n<16;n++)e[n]=hi(t[n],r[n],i)})(a,a,l,di(this.pitch>=15?1:this.pitch/15))}else a=l;const c=e.a9.mul([],l,s);let u=e.a9.mul([],a,s);if(this.projection.isReprojectedInTileSpace){const t=this.locationCoordinate(this.center),r=e.a9.identity([]);e.a9.translate(r,r,[t.x*this.worldSize,t.y*this.worldSize,0]),e.a9.multiply(r,r,e.bE(this)),e.a9.translate(r,r,[-t.x*this.worldSize,-t.y*this.worldSize,0]),e.a9.multiply(u,u,r),e.a9.multiply(c,c,r),this.inverseAdjustmentMatrix=e.bF(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];if(this.mercatorMatrix=e.a9.scale([],u,[this.worldSize,this.worldSize,this.worldSize/o,1]),this.projMatrix=u,this.invProjMatrix=e.a9.invert(new Float64Array(16),this.projMatrix),r){const r=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);r[8]=2*-t.x/this.width,r[9]=2*t.y/this.height,this.expandedFarZProjMatrix=e.a9.mul([],r,s)}else this.expandedFarZProjMatrix=this.projMatrix;const h=e.a9.invert([],a);this.frustumCorners=e.bG.fromInvProjectionMatrix(h,this.horizonLineFromTop(),this.height),this.cameraFrustum=e.bt.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!r);const d=new Float32Array(16);e.a9.identity(d),e.a9.scale(d,d,[1,-1,1]),e.a9.rotateX(d,d,this._pitch),e.a9.rotateZ(d,d,this.angle);const p=e.a9.perspective(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ);this.starsProjMatrix=e.a9.clone(p);const f=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;p[8]=2*-t.x/this.width,p[9]=2*(t.y+f)/this.height,this.skyboxMatrix=e.a9.multiply(d,p,d);const m=this.point,A=m.x,g=m.y,_=this.width%2/2,y=this.height%2/2,x=Math.cos(this.angle),v=Math.sin(this.angle),b=A-Math.round(A)+x*_+v*y,w=g-Math.round(g)+x*y+v*_,C=new Float64Array(u);if(e.a9.translate(C,C,[b>.5?b-1:b,w>.5?w-1:w,0]),this.alignedProjMatrix=C,u=e.a9.create(),e.a9.scale(u,u,[this.width/2,-this.height/2,1]),e.a9.translate(u,u,[1,-1,0]),this.labelPlaneMatrix=u,u=e.a9.create(),e.a9.scale(u,u,[1,-1,1]),e.a9.translate(u,u,[-1,-1,0]),e.a9.scale(u,u,[2/this.width,2/this.height,1]),this.glCoordMatrix=u,this.pixelMatrix=e.a9.multiply(new Float64Array(16),this.labelPlaneMatrix,c),this._calcFogMatrices(),this._distanceTileDataCache={},u=e.a9.invert(new Float64Array(16),this.pixelMatrix),!u)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=u,"globe"===this.projection.name||this.mercatorFromTransition){this.globeMatrix=e.bH(this);const t=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=e.Q.transformMat4(t,t,s),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=u;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const t=this.cameraWorldSizeForFog,r=this.cameraPixelsPerMeter,i=this._camera.position,n=1/this.height/this._pixelsPerMercatorPixel,o=[t,t,r];e.Q.scale(o,o,n),e.Q.scale(i,i,-1),e.Q.multiply(i,i,o);const s=e.a9.create();e.a9.translate(s,s,i),e.a9.scale(s,s,o),this.mercatorFogMatrix=s,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(t,r,n)}_computeCameraPosition(e){const t=(e=e||this.pixelsPerMeter)/this.pixelsPerMeter,r=this._camera.forward(),i=this.point,n=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*t-e/this.worldSize*this._centerAltitude;return[i.x/this.worldSize-r[0]*n,i.y/this.worldSize-r[1]*n,e/this.worldSize*this._centerAltitude-r[2]*n]}_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),i=this._camera.position[2],n=t[2];let o=1;this.projection.wrap&&(this.center=this.center.wrap()),n>0&&(o=Math.min((r-i)/n,1)),this._camera.position=e.Q.scaleAndAdd([],this._camera.position,t,o),this._updateStateFromCamera()}_updateStateFromCamera(){const t=this._camera.position,r=this._camera.forward(),{pitch:i,bearing:n}=this._camera.getPitchBearing(),o=e.bo(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,s=this._mercatorZfromZoom(this._maxZoom)*Math.cos(e.bm(this._maxPitch)),a=Math.max((t[2]-o)/Math.cos(i),s),l=this._zoomFromMercatorZ(a);e.Q.scaleAndAdd(t,t,r,a),this._pitch=e.ad(i,e.bm(this.minPitch),e.bm(this.maxPitch)),this.angle=e.bk(n,-Math.PI,Math.PI),this._setZoom(e.ad(l,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new e.O(t[0],t[1],t[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(e){return Math.pow(2,e)*this.tileSize}_mercatorZfromZoom(e){return this.cameraToCenterDistance/this._worldSizeFromZoom(e)}_minimumHeightOverTerrain(){const e=Math.min(null!=this._seaLevelZoom?this._seaLevelZoom:this._zoom,this._maxZoom)+4;return this._mercatorZfromZoom(e)}_zoomFromMercatorZ(e){return this.scaleZoom(this.cameraToCenterDistance/(e*this.tileSize))}zoomFromMercatorZAdjusted(t){let r=0,i=e.bA,n=0,o=1/0;for(;i-r>1e-6&&i>r;){const e=r+.5*(i-r),s=this.tileSize*Math.pow(2,e),a=this.getCameraToCenterDistance(this.projection,e,s),l=this.scaleZoom(a/(t*this.tileSize)),c=Math.abs(e-l);c<o&&(o=c,n=e),e<l?r=e:i=e}return n}_terrainEnabled(){return!(!this._elevation||!this.projection.supportsTerrain&&(e.w("Terrain is not yet supported with alternate projections. Use mercator or globe to enable terrain."),1))}anyCornerOffEdge(t,r){const i=Math.min(t.x,r.x),n=Math.max(t.x,r.x),o=Math.min(t.y,r.y),s=Math.max(t.y,r.y);if(o<this.horizonLineFromTop(!1))return!0;if("mercator"!==this.projection.name)return!1;const a=[new e.P(i,o),new e.P(n,s),new e.P(i,s),new e.P(n,o)],l=this.renderWorldCopies?-3:0,c=this.renderWorldCopies?4:1;for(const e of a){const t=this.pointRayIntersection(e);if(t.t<0)return!0;const r=this.rayIntersectionCoordinate(t);if(r.x<l||r.y<0||r.x>c||r.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+e.bI(this.fovAboveCenter)>88||this.anyCornerOffEdge(new e.P(0,0),new e.P(this.width,this.height))}zoomDeltaToMovement(t,r){const i=e.Q.length(e.Q.sub([],this._camera.position,t)),n=this._zoomFromMercatorZ(i)+r;return i-this._mercatorZfromZoom(n)}getCameraPoint(){if("globe"===this.projection.name){const t=function([t,r,i],n){const o=[t,r,i,1];e.aa.transformMat4(o,o,n);const s=o[3]=Math.max(o[3],1e-6);return o[0]/=s,o[1]/=s,o[2]/=s,o}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new e.P(t[0],t[1])}{const t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new e.P(0,t))}}getCameraToCenterDistance(t,r=this.zoom,i=this.worldSize){const n=e.bD(t,r,this.width,this.height,1024),o=t.pixelSpaceConversion(this.center.lat,i,n);let s=.5/Math.tan(.5*this._fov)*this.height*o;return this.isOrthographic&&(s=hi(1,s,di(this.pitch>=15?1:this.pitch/15))),s}getWorldToCameraMatrix(){const t=this._camera.getWorldToCamera(this.worldSize,"meters"===this.projection.zAxisUnit?this.pixelsPerMeter:1);return"globe"===this.projection.name&&e.a9.multiply(t,t,this.globeMatrix),t}getFrustum(t){return e.bt.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,t,"meters"===this.projection.zAxisUnit)}}const fi={BaseColor:5,MetallicRoughness:6,Normal:7,Occlusion:8,Emission:9,ShadowMap0:10},mi=(t,r)=>{if(r>0&&t.terrain&&e.w("Cutoff is currently disabled on terrain"),r<=0||t.terrain)return{shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};const i=t.transform,n=Math.max(Math.abs(i._zoom-(t.minCutoffZoom-1)),1),o=i.isLODDisabled(!1)?e.S(60,45,i.pitch):e.S(30,15,i.pitch),s=i._farZ-i._nearZ,a=r*i.height,l=((1-(c=o))*i.cameraToCenterDistance+c*(i._farZ+a))*n;var c;return{shouldRenderCutoff:o<1,uniformValues:{u_cutoff_params:[i._nearZ,i._farZ,(l-i._nearZ)/s,(l-a-i._nearZ)/s]}}},Ai={cascadeCount:2,shadowMapResolution:2048};class gi{constructor(e,t){this.aabb=e,this.lastCascade=t}}class _i{add(e,t){const r=this.receivers[e.key];void 0!==r?(r.aabb.min[0]=Math.min(r.aabb.min[0],t.min[0]),r.aabb.min[1]=Math.min(r.aabb.min[1],t.min[1]),r.aabb.min[2]=Math.min(r.aabb.min[2],t.min[2]),r.aabb.max[0]=Math.max(r.aabb.max[0],t.max[0]),r.aabb.max[1]=Math.max(r.aabb.max[1],t.max[1]),r.aabb.max[2]=Math.max(r.aabb.max[2],t.max[2])):this.receivers[e.key]=new gi(t,null)}clear(){this.receivers={}}get(e){return this.receivers[e.key]}computeRequiredCascades(t,r,i){const n=e.bV.fromPoints(t.points);let o=0;for(const t in this.receivers){const s=this.receivers[t];if(!s)continue;if(!n.intersectsAabb(s.aabb))continue;s.aabb.min=n.closestPoint(s.aabb.min),s.aabb.max=n.closestPoint(s.aabb.max);const a=s.aabb.getCorners();for(let t=0;t<i.length;t++){let n=!0;for(const o of a){const s=[o[0]*r,o[1]*r,o[2]];if(e.Q.transformMat4(s,s,i[t].matrix),s[0]<-1||s[0]>1||s[1]<-1||s[1]>1){n=!1;break}}if(s.lastCascade=t,o=Math.max(o,t),n)break}}return o+1}}class yi{constructor(e){this.painter=e,this._enabled=!1,this._shadowLayerCount=0,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new _i,this._depthMode=new Et(e.context.gl.LEQUAL,Et.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,e.tp.registerParameter(this,["Shadows"],"_forceDisable",{label:"forceDisable"},(()=>{this.painter.style.map.triggerRepaint()})),e.tp.registerParameter(Ai,["Shadows"],"cascadeCount",{min:1,max:2,step:1}),e.tp.registerParameter(Ai,["Shadows"],"shadowMapResolution",{min:32,max:2048,step:32}),e.tp.registerBinding(this,["Shadows"],"_numCascadesToRender",{readonly:!0,label:"numCascadesToRender"})}destroy(){for(const e of this._cascades)e.texture.destroy(),e.framebuffer.destroy();this._cascades=[]}updateShadowParameters(t,r){const i=this.painter;if(this._enabled=!1,this._shadowLayerCount=0,this._receivers.clear(),!r||!r.properties)return;const n=r.properties.get("shadow-intensity");if(!r.shadowsEnabled()||n<=0)return;if(this._shadowLayerCount=i.style.order.reduce(((e,r)=>{const n=i.style._mergedLayers[r];return e+(n.hasShadowPass()&&!n.isHidden(t.zoom)?1:0)}),0),this._enabled=this._shadowLayerCount>0,!this.enabled)return;const o=i.context,s=Ai.shadowMapResolution,a=Ai.shadowMapResolution;if(0===this._cascades.length||Ai.shadowMapResolution!==this._cascades[0].texture.size[0]){this._cascades=[];for(let t=0;t<Ai.cascadeCount;++t){const t=i._shadowMapDebug,r=o.gl,n=o.createFramebuffer(s,a,t,"texture"),l=new e.T(o,{width:s,height:a,data:null},r.DEPTH_COMPONENT);if(n.depthAttachment.set(l.texture),t){const t=new e.T(o,{width:s,height:a,data:null},r.RGBA);n.colorAttachment.set(t.texture)}this._cascades.push({framebuffer:n,texture:l,matrix:[],far:0,boundingSphereRadius:0,frustum:new e.bt,scale:0})}}this.shadowDirection=vi(r);let l=0;if(t.elevation){const e=t.elevation,r=[1e4,-1e4];e.visibleDemTiles.filter((e=>e.dem)).forEach((e=>{const t=e.dem.tree;r[0]=Math.min(r[0],t.minimums[0]),r[1]=Math.max(r[1],t.maximums[0])})),1e4!==r[0]&&(l=(r[1]-r[0])*e.exaggeration())}const c=1.5*t.cameraToCenterDistance,u=3*c,h=new Float64Array(16);for(let r=0;r<this._cascades.length;++r){const i=this._cascades[r];let n=t.height/50,o=1;1===Ai.cascadeCount?o=u:0===r?o=c:(n=c,o=u);const[s,a]=wi(t,this.shadowDirection,n,o,Ai.shadowMapResolution,l);i.scale=t.scale,i.matrix=s,i.boundingSphereRadius=a,e.a9.invert(h,i.matrix),i.frustum=e.bt.fromInvProjectionMatrix(h,1,0,!0),i.far=o}const d=this._cascades.length-1;this._uniformValues.u_fade_range=[.75*this._cascades[d].far,this._cascades[d].far],this._uniformValues.u_shadow_intensity=n,this._uniformValues.u_shadow_direction=[this.shadowDirection[0],this.shadowDirection[1],this.shadowDirection[2]],this._uniformValues.u_shadow_texel_size=1/Ai.shadowMapResolution,this._uniformValues.u_shadow_map_resolution=Ai.shadowMapResolution,this._uniformValues.u_shadowmap_0=fi.ShadowMap0,this._uniformValues.u_shadowmap_1=fi.ShadowMap0+1,this._groundShadowTiles=i.transform.coveringTiles({tileSize:512,renderWorldCopies:!0});const p=i.transform.elevation;for(const e of this._groundShadowTiles){let t={min:0,max:0};if(p){const r=p.getMinMaxForTile(e);r&&(t=r)}this.addShadowReceiver(e.toUnwrapped(),t.min,t.max)}}get enabled(){return this._enabled&&!this._forceDisable}set enabled(e){this._enabled=e}drawShadowPass(t,r){if(!this.enabled)return;const i=this.painter,n=i.context;this._numCascadesToRender=this._receivers.computeRequiredCascades(i.transform.getFrustum(0),i.transform.worldSize,this._cascades),n.viewport.set([0,0,Ai.shadowMapResolution,Ai.shadowMapResolution]);for(let o=0;o<this._numCascadesToRender;++o){i.currentShadowCascade=o,n.bindFramebuffer.set(this._cascades[o].framebuffer.framebuffer),n.clear({color:e.aA.white,depth:1});for(const e of t.order){const n=t._mergedLayers[e];if(!n.hasShadowPass()||n.isHidden(i.transform.zoom))continue;const o=t.getLayerSourceCache(n),s=o?r[o.id]:void 0;("model"===n.type||s&&s.length)&&i.renderLayer(i,o,n,s)}}i.currentShadowCascade=0}drawGroundShadows(){if(!this.enabled)return;const e=this.painter,t=e.style,r=e.context,i=t.directionalLight,n=t.ambientLight;if(!i||!n)return;const o=[],s=mi(e,e.longestCutoffRange);s.shouldRenderCutoff&&o.push("RENDER_CUTOFF");const a=bi(i,n),l=new Et(r.gl.LEQUAL,Et.ReadOnly,e.depthRangeFor3D);for(const t of this._groundShadowTiles){const i=t.toUnwrapped(),n=e.isTileAffectedByFog(t),c=e.getOrCreateProgram("groundShadow",{defines:o,overrideFog:n});this.setupShadows(i,c),e.uploadCommonUniforms(r,c,i,null,s);const u={u_matrix:e.transform.calculateProjMatrix(i),u_ground_shadow_factor:a};c.draw(e,r.gl.TRIANGLES,l,St.disabled,Pt.multiply,Lt.disabled,u,"ground_shadow",e.tileExtentBuffer,e.quadTriangleIndexBuffer,e.tileExtentSegments,{},e.transform.zoom,null,null)}}getShadowPassColorMode(){return this.painter._shadowMapDebug?Pt.unblended:Pt.disabled}getShadowPassDepthMode(){return this._depthMode}getShadowCastingLayerCount(){return this._shadowLayerCount}calculateShadowPassMatrixFromTile(t){const r=this.painter.transform,i=r.calculatePosMatrix(t,r.worldSize);return e.a9.multiply(i,this._cascades[this.painter.currentShadowCascade].matrix,i),Float32Array.from(i)}calculateShadowPassMatrixFromMatrix(t){return e.a9.multiply(t,this._cascades[this.painter.currentShadowCascade].matrix,t),Float32Array.from(t)}setupShadows(t,r,i,n=0){if(!this.enabled)return;const o=this.painter.transform,s=this.painter.context,a=s.gl,l=this._uniformValues,c=new Float64Array(16),u=o.calculatePosMatrix(t,o.worldSize);for(let t=0;t<this._cascades.length;t++)e.a9.multiply(c,this._cascades[t].matrix,u),l[0===t?"u_light_matrix_0":"u_light_matrix_1"]=Float32Array.from(c),s.activeTexture.set(a.TEXTURE0+fi.ShadowMap0+t),this._cascades[t].texture.bind(a.NEAREST,a.CLAMP_TO_EDGE);if(this.useNormalOffset=!!i,this.useNormalOffset){const r=e.bU(t.canonical),s=2/o.tileSize*e.Y/Ai.shadowMapResolution,a=s*this._cascades[0].boundingSphereRadius,c=s*this._cascades[this._cascades.length-1].boundingSphereRadius,u=("vector-tile"===i?1:3)/Math.pow(2,n-t.canonical.z-(1-o.zoom+Math.floor(o.zoom)));l.u_shadow_normal_offset=[r,a*u,c*u],l.u_shadow_bias=[6e-5,.0012,.012]}else l.u_shadow_bias=[36e-5,.0012,.012];r.setShadowUniformValues(s,l)}setupShadowsFromMatrix(t,r,i=!1){if(!this.enabled)return;const n=this.painter.context,o=n.gl,s=this._uniformValues,a=new Float64Array(16);for(let r=0;r<Ai.cascadeCount;r++)e.a9.multiply(a,this._cascades[r].matrix,t),s[0===r?"u_light_matrix_0":"u_light_matrix_1"]=Float32Array.from(a),n.activeTexture.set(o.TEXTURE0+fi.ShadowMap0+r),this._cascades[r].texture.bind(o.NEAREST,o.CLAMP_TO_EDGE);if(this.useNormalOffset=i,i){const e=5;s.u_shadow_normal_offset=[1,e,e],s.u_shadow_bias=[6e-5,.0012,.012]}else s.u_shadow_bias=[36e-5,.0012,.012];r.setShadowUniformValues(n,s)}getShadowUniformValues(){return this._uniformValues}getCurrentCascadeFrustum(){return this._cascades[this.painter.currentShadowCascade].frustum}computeSimplifiedTileShadowVolume(t,r,i,n){if(n[2]>=0)return{};const o=function(t,r,i){const n=i/(1<<t.canonical.z);return new e.bV([t.canonical.x*n+t.wrap*i,t.canonical.y*n+t.wrap*i,0],[(t.canonical.x+1)*n+t.wrap*i,(t.canonical.y+1)*n+t.wrap*i,r])}(t,r,i).getCorners(),s=r/-n[2];n[0]<0?(e.Q.add(o[0],o[0],[n[0]*s,0,0]),e.Q.add(o[3],o[3],[n[0]*s,0,0])):n[0]>0&&(e.Q.add(o[1],o[1],[n[0]*s,0,0]),e.Q.add(o[2],o[2],[n[0]*s,0,0])),n[1]<0?(e.Q.add(o[0],o[0],[0,n[1]*s,0]),e.Q.add(o[1],o[1],[0,n[1]*s,0])):n[1]>0&&(e.Q.add(o[2],o[2],[0,n[1]*s,0]),e.Q.add(o[3],o[3],[0,n[1]*s,0]));const a={};return a.vertices=o,a.planes=[xi(o[1],o[0],o[4]),xi(o[2],o[1],o[5]),xi(o[3],o[2],o[6]),xi(o[0],o[3],o[7])],a}addShadowReceiver(t,r,i){this._receivers.add(t,e.bV.fromTileIdAndHeight(t,r,i))}getMaxCascadeForTile(e){const t=this._receivers.get(e);return t&&t.lastCascade?t.lastCascade:0}}function xi(t,r,i){const n=e.Q.sub([],i,r),o=e.Q.sub([],t,r),s=e.Q.cross([],n,o),a=e.Q.length(s);return 0===a?[0,0,1,0]:(e.Q.scale(s,s,1/a),[s[0],s[1],s[2],-e.Q.dot(s,r)])}function vi(t){const r=t.properties.get("direction"),i=e.bT(r.x,r.y,r.z);i[2]=e.ad(i[2],0,75);const n=e.bW([i[0],i[1],i[2]]);return e.Q.fromValues(n.x,n.y,n.z)}function bi(t,r){const i=t.properties.get("color"),n=t.properties.get("intensity"),o=t.properties.get("direction"),s=[o.x,o.y,o.z],a=r.properties.get("color"),l=r.properties.get("intensity"),c=Math.max(e.Q.dot([0,0,1],s),0),u=[0,0,0];e.Q.scale(u,a.toArray01Linear().slice(0,3),l);const h=[0,0,0];return e.Q.scale(h,i.toArray01Linear().slice(0,3),c*n),e.bX([u[0]>0?u[0]/(u[0]+h[0]):0,u[1]>0?u[1]/(u[1]+h[1]):0,u[2]>0?u[2]/(u[2]+h[2]):0])}function wi(t,r,i,n,o,s){const a=t.zoom,l=t.scale,c=t.worldSize,u=1/c,h=t.aspect,d=Math.sqrt(1+h*h)*Math.tan(.5*t.fovX),p=d*d,f=n-i,m=n+i;let A,g;p>f/m?(A=n,g=n*d):(A=.5*m*(1+p),g=.5*Math.sqrt(f*f+2*(n*n+i*i)*p+m*m*p*p));const _=t.projection.pixelsPerMeter(t.center.lat,c),y=t._camera.getCameraToWorldMercator(),x=[0,0,-A*u];e.Q.transformMat4(x,x,y);let v=g*u;const b=t._edgeInsets;if(!(0===b.left&&0===b.top&&0===b.right&&0===b.bottom||b.left===b.right&&b.top===b.bottom)){const r=t._camera.getWorldToCamera(t.worldSize,"meters"===t.projection.zAxisUnit?_:1),o=t._camera.getCameraToClipPerspective(t._fov,t.width/t.height,i,n);o[8]=2*-t.centerOffset.x/t.width,o[9]=2*t.centerOffset.y/t.height;const s=new Float64Array(16);e.a9.mul(s,o,r);const u=new Float64Array(16);e.a9.invert(u,s);const h=e.bt.fromInvProjectionMatrix(u,c,a,!0);for(const r of h.points){const i=((w=r)[0]/=l,w[1]/=l,w[2]=e.bo(w[2],t._center.lat),w);v=Math.max(v,e.Q.len(e.Q.subtract([],x,i)))}}var w;v*=o/(o-1);const C=Math.acos(r[2]),T=Math.atan2(-r[0],-r[1]),E=new ui;E.position=x,E.setPitchBearing(C,T);const M=E.getWorldToCamera(c,_),S=v*c,I=Math.min(t._mercatorZfromZoom(17)*c*-2,-2*S),P=E.getCameraToClipOrthographic(-S,S,-S,S,I,(S+s*_)/r[2]),D=new Float64Array(16);e.a9.multiply(D,P,M);const k=e.Q.fromValues(Math.floor(1e6*x[0])/1e6*c,Math.floor(1e6*x[1])/1e6*c,0),L=.5*o,z=[0,0,0];e.Q.transformMat4(z,k,D),e.Q.scale(z,z,L);const O=[Math.floor(z[0]),Math.floor(z[1]),Math.floor(z[2])],B=[0,0,0];e.Q.sub(B,z,O),e.Q.scale(B,B,-1/L);const R=new Float64Array(16);return e.a9.identity(R),e.a9.translate(R,R,B),e.a9.multiply(D,R,D),[D,S]}const Ci=(e,t)=>se(e,t&&t.filter((e=>"source.canvas"!==e.identifier))),Ti=e.af(tr,["addLayer","removeLayer","setLights","setPaintProperty","setLayoutProperty","setSlot","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection","setCamera","addImport","removeImport","updateImport"]),Ei=e.af(tr,["setCenter","setZoom","setBearing","setPitch"]),Mi={version:8,layers:[],sources:{}},Si={duration:300,delay:0};class Ii extends e.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=e.e({},Si),this._buildingIndex=new Kt(this),this.crossTileSymbolIndex=new ni,this._mergedOrder=[],this._drapedFirstOrder=[],this._mergedLayers={},this._mergedSourceCaches={},this._mergedOtherSourceCaches={},this._mergedSymbolSourceCaches={},this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this._changes=r.styleChanges||new _,this.dispatcher=r.dispatcher?r.dispatcher:new e.bZ(e.b_(),this),r.imageManager?this.imageManager=r.imageManager:(this.imageManager=new b,this.imageManager.setEventedParent(this)),this.imageManager.createScope(this.scope),this.glyphManager=r.glyphManager?r.glyphManager:new e.b$(t._requestManager,r.localFontFamily?e.c0.all:r.localIdeographFontFamily?e.c0.ideographs:e.c0.none,r.localFontFamily||r.localIdeographFontFamily),r.modelManager?this.modelManager=r.modelManager:(this.modelManager=new y(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.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",e.c1());const i=this;this._rtlTextPluginCallback=Ii.registerForPluginStateChange((t=>{i.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:t.pluginStatus,pluginURL:t.pluginURL},((t,r)=>{if(e.c2(t),r&&r.every((e=>e)))for(const e in i._sourceCaches){const t=i._sourceCaches[e],r=t.getSource().type;"vector"!==r&&"geojson"!==r||t.reload()}}))})),this.on("data",(e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const t=this.getOwnSource(e.sourceId);if(t&&t.vectorLayerIds)for(const e in this._layers){const r=this._layers[e];r.source===t.id&&this._validateLayer(r)}}))}load(e){return e?("string"==typeof e?this.loadURL(e):this.loadJSON(e),this):this}_getGlobalId(t){if(!t)return null;if("string"==typeof t){if(e.c3(t))return t;const r=e.c4(t);if(!r.startsWith("http"))try{return new URL(r,location.href).toString()}catch(e){return r}return r}return`json://${e.c5(JSON.stringify(t))}`}_diffStyle(t,r,i){this.globalId=this._getGlobalId(t);const n=(e,t)=>{try{t(null,this.setState(e,i))}catch(e){t(e,!1)}};if("string"==typeof t){const i=this.map._requestManager.normalizeStyleURL(t),o=this.map._requestManager.transformRequest(i,e.R.Style);e.g(o,((t,i)=>{t?this.fire(new e.a(t)):i&&n(i,r)}))}else"object"==typeof t&&n(t,r)}loadURL(t,r={}){this.fire(new e.b("dataloading",{dataType:"style"}));const i="boolean"==typeof r.validate?r.validate:!e.c3(t);this.globalId=this._getGlobalId(t),t=this.map._requestManager.normalizeStyleURL(t,r.accessToken),this.resolvedImports.add(t);const n=this.importsCache.get(t);if(n)return this._load(n,i);const o=this.map._requestManager.transformRequest(t,e.R.Style);this._request=e.g(o,((r,n)=>{if(this._request=null,r)this.fire(new e.a(r));else if(n)return this.importsCache.set(t,n),this._load(n,i)}))}loadJSON(t,r={}){this.fire(new e.b("dataloading",{dataType:"style"})),this.globalId=this._getGlobalId(t),this._request=e.f.frame((()=>{this._request=null,this._load(t,!1!==r.validate)}))}loadEmpty(){this.fire(new e.b("dataloading",{dataType:"style"})),this._load(Mi,!1)}_loadImports(t,r,i){if(this.importDepth>=4)return e.w("Style doesn't support nesting deeper than 5"),Promise.resolve();const n=[];for(const e of t){const t=this._createFragmentStyle(e),o=new Promise((e=>{t.once("style.import.load",e),t.once("error",e)})).then((()=>this.mergeAll()));if(n.push(o),this.resolvedImports.has(e.url)){t.loadEmpty();continue}const s=e.data||this.importsCache.get(e.url);s?(t.loadJSON(s,{validate:r}),this._isInternalStyle(s)&&(t.globalId=null)):e.url?t.loadURL(e.url,{validate:r}):t.loadEmpty();const a={style:t,id:e.id,config:e.config};if(i){const e=this.fragments.findIndex((({id:e})=>e===i));this.fragments=this.fragments.slice(0,e).concat(a).concat(this.fragments.slice(e))}else this.fragments.push(a)}return Promise.allSettled(n)}getImportGlobalIds(e=this,t=new Set){for(const r of e.fragments)r.style.globalId&&t.add(r.style.globalId),this.getImportGlobalIds(r.style,t);return[...t.values()]}_createFragmentStyle(t){const r=this.scope?e.aj(t.id,this.scope):t.id;let i;const n=this._initialConfig&&this._initialConfig[r];(t.config||n)&&(i=e.e({},t.config,n));const o=new Ii(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:i,configOptions:this.options,configDependentLayers:this._configDependentLayers});return o.setEventedParent(this.map,{style:o}),o}_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.isRootStyle()}_isInternalStyle(e){return this.isRootStyle()&&(e.fragment||!!e.schema&&!1!==e.fragment)}_load(t,r){const i=t.schema;if(this._isInternalStyle(t)){const i=e.e({},Mi,{imports:[{id:"basemap",data:t,url:""}]});return void this._load(i,r)}if(this.updateConfig(this._config,i),r&&Ci(this,q(t)))return;this._loaded=!0,this.stylesheet=e.c6(t);for(const e in t.sources)this.addSource(e,t.sources[e],{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 n=er(this.stylesheet.layers);if(this._order=n.map((e=>e.id)),this.stylesheet.light&&e.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 e=this.stylesheet.lights[0];this.light=new le(e.properties,e.id)}else this.setLights(this.stylesheet.lights);this.light||(this.light=new le(this.stylesheet.light)),this._layers={},this._serializedLayers={};for(const t of n){const r=e.c7(t,this.scope,this.options);r.isConfigDependent&&this._configDependentLayers.add(r.fqid),r.setEventedParent(this,{layer:{id:r.id}}),this._layers[r.id]=r,this._serializedLayers[r.id]=r.serialize();const i=this.getOwnLayerSourceCache(r),n=!!this.directionalLight&&this.directionalLight.shadowsEnabled();i&&r.canCastShadows()&&n&&(i.castsShadows=!0)}this.stylesheet.models&&this.modelManager.addModels(this.stylesheet.models,this.scope);const o=this.stylesheet.terrain;o&&(void 0===this.disableElevatedTerrain&&(this.disableElevatedTerrain=e.f.hasCanvasFingerprintNoise()),this.disableElevatedTerrain?e.w("Terrain and hillshade are disabled because of Canvas2D limitations when fingerprinting protection is enabled (e.g. in private browsing mode)."):this.terrainSetForDrapingOnly()||this._createTerrain(o,1)),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this.stylesheet.transition&&this.setTransition(this.stylesheet.transition),this.fire(new e.b("data",{dataType:"style"}));const s=this.isRootStyle();t.imports?this._loadImports(t.imports,r).then((()=>{this._reloadImports(),this.fire(new e.b(s?"style.load":"style.import.load"))})):(this._reloadImports(),this.fire(new e.b(s?"style.load":"style.import.load")))}isRootStyle(){return 0===this.importDepth}mergeAll(){let t,r,i,n,o,s,a,l;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle((e=>{if(e.stylesheet){if(null!=e.light&&(t=e.light),e.stylesheet.lights)for(const t of e.stylesheet.lights)"ambient"===t.type&&null!=e.ambientLight&&(r=e.ambientLight),"directional"===t.type&&null!=e.directionalLight&&(i=e.directionalLight);n=this._prioritizeTerrain(n,e.terrain,e.stylesheet.terrain),e.stylesheet.fog&&null!=e.fog&&(o=e.fog),null!=e.stylesheet.camera&&(l=e.stylesheet.camera),null!=e.stylesheet.projection&&(s=e.stylesheet.projection),null!=e.stylesheet.transition&&(a=e.stylesheet.transition)}})),this.light=t,this.ambientLight=r,this.directionalLight=i,this.fog=o,null===n?delete this.terrain:this.terrain=n,this.camera=l||{"camera-projection":"perspective"},this.projection=s||{name:"mercator"},this.transition=e.e({},Si,a),this.mergeSources(),this.mergeLayers()}forEachFragmentStyle(e){const t=r=>{for(const e of r.fragments)t(e.style);e(r)};t(this)}_prioritizeTerrain(e,t,r){const i=e&&0===e.drapeRenderMode;return null===r?t&&0===t.drapeRenderMode?t:i?e:null:null!=t&&(!e||i||t&&1===t.drapeRenderMode)?t:e}mergeTerrain(){let e;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle((t=>{e=this._prioritizeTerrain(e,t.terrain,t.stylesheet.terrain)})),null===e?delete this.terrain:this.terrain=e}mergeProjection(){let e;this.forEachFragmentStyle((t=>{null!=t.stylesheet.projection&&(e=t.stylesheet.projection)})),this.projection=e||{name:"mercator"}}mergeSources(){const t={},r={},i={};this.forEachFragmentStyle((n=>{for(const r in n._sourceCaches){const i=e.aj(r,n.scope);t[i]=n._sourceCaches[r]}for(const t in n._otherSourceCaches){const i=e.aj(t,n.scope);r[i]=n._otherSourceCaches[t]}for(const t in n._symbolSourceCaches){const r=e.aj(t,n.scope);i[r]=n._symbolSourceCaches[t]}})),this._mergedSourceCaches=t,this._mergedOtherSourceCaches=r,this._mergedSymbolSourceCaches=i}mergeLayers(){const t={},r=[],i={};this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle((i=>{for(const n of i._order){const o=i._layers[n];if("slot"===o.type){const r=e.c8(n);if(t[r])continue;t[r]=[]}o.slot&&t[o.slot]?t[o.slot].push(o):r.push(o)}})),this._mergedOrder=[];const n=(r=[])=>{for(const o of r)if("slot"===o.type){const r=e.c8(o.id);t[r]&&n(t[r])}else{const t=e.aj(o.id,o.scope);this._mergedOrder.push(t),i[t]=o,o.is3D()&&(this._has3DLayers=!0),"circle"===o.type&&(this._hasCircleLayers=!0),"symbol"===o.type&&(this._hasSymbolLayers=!0)}};n(r),this._mergedLayers=i,this.updateDrapeFirstLayers(),this._buildingIndex.processLayersChanged()}terrainSetForDrapingOnly(){return!!this.terrain&&0===this.terrain.drapeRenderMode}getCamera(){return this.stylesheet.camera}setCamera(t){return this.stylesheet.camera=e.e({},this.stylesheet.camera,t),this.camera=this.stylesheet.camera,this}setProjection(e){e?this.stylesheet.projection=e: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(t,r,i){let n,o,s;const a=e.f.devicePixelRatio>1?"@2x":"";let l=e.g(r.transformRequest(r.normalizeSpriteURL(t,a,".json"),e.R.SpriteJSON),((e,t)=>{l=null,s||(s=e,n=t,u())})),c=e.d(r.transformRequest(r.normalizeSpriteURL(t,a,".png"),e.R.SpriteImage),((e,t)=>{c=null,s||(s=e,o=t,u())}));function u(){if(s)i(s);else if(n&&o){const t=e.f.getImageData(o),r={};for(const i in n){const{width:o,height:s,x:a,y:l,sdf:c,pixelRatio:u,stretchX:h,stretchY:d,content:p}=n[i],f=new e.h({width:o,height:s});e.h.copy(t,f,{x:a,y:l},{x:0,y:0},{width:o,height:s}),r[i]={data:f,pixelRatio:u,sdf:c,stretchX:h,stretchY:d,content:p}}i(null,r)}}return{cancel(){l&&(l.cancel(),l=null),c&&(c.cancel(),c=null)}}}(t,this.map._requestManager,((t,r)=>{if(this._spriteRequest=null,t)this.fire(new e.a(t));else if(r)for(const e in r)this.imageManager.addImage(e,this.scope,r[e]);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 e.b("data",{dataType:"style"}))}))}_validateLayer(t){const r=this.getOwnSource(t.source);if(!r)return;const i=t.sourceLayer;i&&("geojson"===r.type||r.vectorLayerIds&&-1===r.vectorLayerIds.indexOf(i))&&this.fire(new e.a(new Error(`Source layer "${i}" does not exist on source "${r.id}" as specified by style layer "${t.id}"`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._changes.getUpdatedSourceCaches()).length)return!1;for(const e in this._sourceCaches)if(!this._sourceCaches[e].loaded())return!1;if(!this.imageManager.isLoaded())return!1;if(!this.modelManager.isLoaded())return!1;for(const{style:e}of this.fragments)if(!e.loaded())return!1;return!0}_serializeImports(){if(this.stylesheet.imports)return this.stylesheet.imports.map(((e,t)=>{const r=this.fragments[t];return r&&r.style&&(e.data=r.style.serialize()),e}))}_serializeSources(){const e={};for(const t in this._sourceCaches){const r=this._sourceCaches[t].getSource();e[r.id]||(e[r.id]=r.serialize())}return e}_serializeLayers(e){const t=[];for(const r of e){const e=this._layers[r];e&&"custom"!==e.type&&t.push(e.serialize())}return t}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())return!0;if(this.hasFogTransition())return!0;for(const e in this._sourceCaches)if(this._sourceCaches[e].hasTransition())return!0;for(const e in this._layers)if(this._layers[e].hasTransition())return!0;return!1}get order(){return this.terrain?this._drapedFirstOrder:this._mergedOrder}isLayerDraped(e){return!!this.terrain&&e.isDraped(this.getLayerSourceCache(e))}_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 e.a(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 e.a(new Error(`The source '${t}' does not exist in the map's style.`)))}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 i=this._changes.isDirty();if(this._changes.isDirty()){const e=this._changes.getLayerUpdatesByScope();for(const t in e){const{updatedIds:r,removedIds:i}=e[t];(r||i)&&this._updateWorkerLayers(t,r,i)}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 n={};for(const e in this._mergedSourceCaches){const t=this._mergedSourceCaches[e];n[e]=t.used,t.used=!1,t.tileCoverLift=0}for(const e of this._mergedOrder){const r=this._mergedLayers[e];if(r.recalculate(t,this._availableImages),!r.isHidden(t.zoom)){const e=this.getLayerSourceCache(r);e&&(e.used=!0,e.tileCoverLift=Math.max(e.tileCoverLift,r.tileCoverLift()))}if(!this._precompileDone&&this._shouldPrecompile)for(let e=r.minzoom||0;e<(r.maxzoom||25.5);e++){const e=this.map.painter;if(e){const i=r.getProgramIds();if(!i)continue;for(const n of i){const i=r.getDefaultProgramParams(n,t.zoom);i&&(e.style=this,this.fog&&(e._fogVisible=!0,i.overrideFog=!0,e.getOrCreateProgram(n,i)),e._fogVisible=!1,i.overrideFog=!1,e.getOrCreateProgram(n,i),(this.stylesheet.terrain||this.stylesheet.projection&&"globe"===this.stylesheet.projection.name)&&(i.overrideRtt=!0,e.getOrCreateProgram(n,i)))}}}}this._shouldPrecompile&&(this._precompileDone=!0);for(const t in n){const r=this._mergedSourceCaches[t];n[t]!==r.used&&r.getSource().fire(new e.b("data",{sourceDataType:"visibility",dataType:"source",sourceId:r.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),i&&this.fire(new e.b("data",{dataType:"style"}))}_updateTilesForChangedImages(){const e=this._changes.getUpdatedImages();if(e.length){for(const t in this._sourceCaches)this._sourceCaches[t].reloadTilesForDependencies(["icons","patterns"],e);this._changes.resetUpdatedImages()}}_updateWorkerLayers(e,t,r){const i=this.getFragmentStyle(e);i&&this.dispatcher.broadcast("updateLayers",{layers:t?i._serializeLayers(t):[],scope:e,removedIds:r||[],options:i.options})}setState(r,i){if(this._checkLoaded(),Ci(this,q(r)))return!1;(r=e.c6(r)).layers=er(r.layers);const n=function(e,r){if(!e)return[{command:tr.setStyle,args:[r]}];let i=[];try{if(!t(e.version,r.version))return[{command:tr.setStyle,args:[r]}];t(e.center,r.center)||i.push({command:tr.setCenter,args:[r.center]}),t(e.zoom,r.zoom)||i.push({command:tr.setZoom,args:[r.zoom]}),t(e.bearing,r.bearing)||i.push({command:tr.setBearing,args:[r.bearing]}),t(e.pitch,r.pitch)||i.push({command:tr.setPitch,args:[r.pitch]}),t(e.sprite,r.sprite)||i.push({command:tr.setSprite,args:[r.sprite]}),t(e.glyphs,r.glyphs)||i.push({command:tr.setGlyphs,args:[r.glyphs]}),t(e.imports,r.imports)||function(e=[],r=[],i){r=r||[];const n=(e=e||[]).map(ar),o=r.map(ar),s=e.reduce(lr,{}),a=r.reduce(lr,{}),l=n.slice();let c,u,h,d;for(c=0,u=0;c<n.length;c++)h=n[c],a.hasOwnProperty(h)?u++:(i.push({command:tr.removeImport,args:[h]}),l.splice(l.indexOf(h,u),1));for(c=0,u=0;c<o.length;c++)h=o[o.length-1-c],l[l.length-1-c]!==h&&(s.hasOwnProperty(h)?(i.push({command:tr.removeImport,args:[h]}),l.splice(l.lastIndexOf(h,l.length-u),1)):u++,d=l[l.length-c],i.push({command:tr.addImport,args:[a[h],d]}),l.splice(l.length-c,0,h));for(const e of r){const r=s[e.id];r&&!t(r,e)&&i.push({command:tr.updateImport,args:[e.id,e]})}}(e.imports,r.imports,i),t(e.transition,r.transition)||i.push({command:tr.setTransition,args:[r.transition]}),t(e.light,r.light)||i.push({command:tr.setLight,args:[r.light]}),t(e.fog,r.fog)||i.push({command:tr.setFog,args:[r.fog]}),t(e.projection,r.projection)||i.push({command:tr.setProjection,args:[r.projection]}),t(e.lights,r.lights)||i.push({command:tr.setLights,args:[r.lights]}),t(e.camera,r.camera)||i.push({command:tr.setCamera,args:[r.camera]});const n={},o=[];!function(e,r,i,n){let o;for(o in r=r||{},e=e||{})e.hasOwnProperty(o)&&(r.hasOwnProperty(o)||ir(o,i,n));for(o in r){if(!r.hasOwnProperty(o))continue;const s=r[o];e.hasOwnProperty(o)?t(e[o],s)||("geojson"===e[o].type&&"geojson"===s.type&&or(e,r,o)?i.push({command:tr.setGeoJSONSourceData,args:[o,s.data]}):nr(o,r,i,n)):rr(o,r,i)}}(e.sources,r.sources,o,n);const s=[];e.layers&&e.layers.forEach((e=>{e.source&&n[e.source]?i.push({command:tr.removeLayer,args:[e.id]}):s.push(e)}));let a=e.terrain;a&&n[a.source]&&(i.push({command:tr.setTerrain,args:[void 0]}),a=void 0),i=i.concat(o),t(a,r.terrain)||i.push({command:tr.setTerrain,args:[r.terrain]}),function(e,r,i){r=r||[];const n=(e=e||[]).map(ar),o=r.map(ar),s=e.reduce(lr,{}),a=r.reduce(lr,{}),l=n.slice(),c=Object.create(null);let u,h,d,p,f,m,A;for(u=0,h=0;u<n.length;u++)d=n[u],a.hasOwnProperty(d)?h++:(i.push({command:tr.removeLayer,args:[d]}),l.splice(l.indexOf(d,h),1));for(u=0,h=0;u<o.length;u++)d=o[o.length-1-u],l[l.length-1-u]!==d&&(s.hasOwnProperty(d)?(i.push({command:tr.removeLayer,args:[d]}),l.splice(l.lastIndexOf(d,l.length-h),1)):h++,m=l[l.length-u],i.push({command:tr.addLayer,args:[a[d],m]}),l.splice(l.length-u,0,d),c[d]=!0);for(u=0;u<o.length;u++)if(d=o[u],p=s[d],f=a[d],!c[d]&&!t(p,f))if(t(p.source,f.source)&&t(p["source-layer"],f["source-layer"])&&t(p.type,f.type)){for(A in sr(p.layout,f.layout,i,d,null,tr.setLayoutProperty),sr(p.paint,f.paint,i,d,null,tr.setPaintProperty),t(p.slot,f.slot)||i.push({command:tr.setSlot,args:[d,f.slot]}),t(p.filter,f.filter)||i.push({command:tr.setFilter,args:[d,f.filter]}),t(p.minzoom,f.minzoom)&&t(p.maxzoom,f.maxzoom)||i.push({command:tr.setLayerZoomRange,args:[d,f.minzoom,f.maxzoom]}),p)p.hasOwnProperty(A)&&"layout"!==A&&"paint"!==A&&"filter"!==A&&"metadata"!==A&&"minzoom"!==A&&"maxzoom"!==A&&"slot"!==A&&(0===A.indexOf("paint.")?sr(p[A],f[A],i,d,A.slice(6),tr.setPaintProperty):t(p[A],f[A])||i.push({command:tr.setLayerProperty,args:[d,A,f[A]]}));for(A in f)f.hasOwnProperty(A)&&!p.hasOwnProperty(A)&&"layout"!==A&&"paint"!==A&&"filter"!==A&&"metadata"!==A&&"minzoom"!==A&&"maxzoom"!==A&&"slot"!==A&&(0===A.indexOf("paint.")?sr(p[A],f[A],i,d,A.slice(6),tr.setPaintProperty):t(p[A],f[A])||i.push({command:tr.setLayerProperty,args:[d,A,f[A]]}))}else i.push({command:tr.removeLayer,args:[d]}),m=l[l.lastIndexOf(d)+1],i.push({command:tr.addLayer,args:[f,m]})}(s,r.layers,i)}catch(e){console.warn("Unable to compute style diff:",e),i=[{command:tr.setStyle,args:[r]}]}return i}(this.serialize(),r).filter((e=>!(e.command in Ei)));if(0===n.length)return!1;const o=n.filter((e=>!(e.command in Ti)));if(o.length>0)throw new Error(`Unimplemented: ${o.map((e=>e.command)).join(", ")}.`);const s=[];return n.forEach((e=>{s.push(this[e.command].apply(this,e.args))})),i&&Promise.all(s).then(i),this.stylesheet=r,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 e.a(new Error("An image with this name already exists."))):(this.imageManager.addImage(t,this.scope,r),this._afterImageUpdated(t),this)}updateImage(e,t){this.imageManager.updateImage(e,this.scope,t)}getImage(e){return this.imageManager.getImage(e,this.scope)}removeImage(t){return this.getImage(t)?(this.imageManager.removeImage(t,this.scope),this._afterImageUpdated(t),this):this.fire(new e.a(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 e.b("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addModel(e,t,r={}){return this._checkLoaded(),this._validate(ne,`models.${e}`,t,null,r)||(this.modelManager.addModel(e,t,this.scope),this._changes.setDirty()),this}hasModel(e){return this.modelManager.hasModel(e,this.scope)}removeModel(t){return this.hasModel(t)?(this.modelManager.removeModel(t,this.scope),this):this.fire(new e.a(new Error("No model with this ID exists.")))}listModels(){return this._checkLoaded(),this.modelManager.listModels(this.scope)}addSource(t,r,i={}){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(X,`sources.${t}`,r,null,i))return;this.map&&this.map._collectResourceTiming&&(r.collectResourceTiming=!0);const n=Nt(t,r,this.dispatcher,this);n.scope=this.scope,n.setEventedParent(this,(()=>({isSourceLoaded:this._isSourceCacheLoaded(n.id),source:n.serialize(),sourceId:n.id})));const o=t=>{const r=(t?"symbol:":"other:")+n.id,i=e.aj(r,this.scope),o=this._sourceCaches[r]=new qt(i,n,t);(t?this._symbolSourceCaches:this._otherSourceCaches)[n.id]=o,o.onAdd(this.map)};o(!1),"vector"!==r.type&&"geojson"!==r.type||o(!0),n.onAdd&&n.onAdd(this.map),i.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 r in this._layers)if(this._layers[r].source===t)return this.fire(new e.a(new Error(`Source "${t}" cannot be removed while layer "${r}" is using it.`)));if(this.terrain&&this.terrain.scope===this.scope&&this.terrain.get().source===t)return this.fire(new e.a(new Error(`Source "${t}" cannot be removed while terrain is using it.`)));const i=this.getOwnSourceCaches(t);for(const t of i){const r=e.c8(t.id);delete this._sourceCaches[r],this._changes.discardSourceCacheUpdate(t.id),t.fire(new e.b("data",{sourceDataType:"metadata",dataType:"source",sourceId:t.getSource().id})),t.setEventedParent(null),t.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(e,t){this._checkLoaded(),this.getOwnSource(e).setData(t),this._changes.setDirty()}getOwnSource(e){const t=this.getOwnSourceCache(e);return t&&t.getSource()}getOwnSources(){const e=[];for(const t in this._otherSourceCaches){const r=this.getOwnSourceCache(t);r&&e.push(r.getSource())}return e}areTilesLoaded(){const e=this._mergedSourceCaches;for(const t in e){const r=e[t]._tiles;for(const e in r){const t=r[e];if("loaded"!==t.state&&"errored"!==t.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 e of t){if(this._validate($,"lights",e))return;switch(e.type){case"ambient":if(this.ambientLight){const t=this.ambientLight;t.set(e),t.updateTransitions(r)}else this.ambientLight=new xe(e,ve,this.scope,this.options);break;case"directional":if(this.directionalLight){const t=this.directionalLight;t.set(e),t.updateTransitions(r)}else this.directionalLight=new xe(e,be,this.scope,this.options)}}const i=new e.N(this.z||0,r);this.ambientLight&&this.ambientLight.recalculate(i),this.directionalLight&&this.directionalLight.recalculate(i),this._brightness=this.calculateLightsBrightness(),this.dispatcher.broadcast("setBrightness",this._brightness)}calculateLightsBrightness(){const t=this.directionalLight,r=this.ambientLight;if(!t||!r)return;const i=e=>.2126*(e[0]<=.03928?e[0]/12.92:Math.pow((e[0]+.055)/1.055,2.4))+.7152*(e[1]<=.03928?e[1]/12.92:Math.pow((e[1]+.055)/1.055,2.4))+.0722*(e[2]<=.03928?e[2]/12.92:Math.pow((e[2]+.055)/1.055,2.4)),n=t.properties.get("color").toArray01(),o=t.properties.get("intensity"),s=t.properties.get("direction"),a=1-e.bT(s.x,s.y,s.z)[2]/90,l=i(n)*o*a,c=r.properties.get("color").toArray01(),u=r.properties.get("intensity");return(l+i(c)*u)/2}getBrightness(){return this._brightness}getLights(){if(!this.enable3dLights())return null;const e=[];return this.directionalLight&&e.push(this.directionalLight.get()),this.ambientLight&&e.push(this.ambientLight.get()),e}enable3dLights(){return!!this.ambientLight&&!!this.directionalLight}getFragmentStyle(t){if(!t)return this;if(e.c9(t)){const r=e.ca(t),i=this.fragments.find((({id:e})=>e===r));if(!i)throw new Error(`Style import not found: ${t}`);const n=e.c8(t);return i.style.getFragmentStyle(n)}{const e=this.fragments.find((({id:e})=>e===t));if(!e)throw new Error(`Style import not found: ${t}`);return e.style}}getConfigProperty(t,r){const i=this.getFragmentStyle(t);if(!i)return null;const n=e.aj(r,i.scope),o=i.options.get(n),s=o?o.value||o.default:null;return s?s.serialize():null}setConfigProperty(t,r,i){const n=this.getFragmentStyle(t);if(!n)return;const o=n.stylesheet.schema;if(!o||!o[r])return;const s=e.t(i);if("success"!==s.result)return void Ci(this,s.value);const a=s.value.expression,l=e.aj(r,n.scope),c=n.options.get(l);if(!c)return;let u;const{minValue:h,maxValue:d,stepValue:p,type:f,values:m}=o[r],A=e.t(o[r].default);"success"===A.result&&(u=A.value.expression),u?(this.options.set(l,{...c,value:a,default:u,minValue:h,maxValue:d,stepValue:p,type:f,values:m}),this.updateConfigDependencies()):this.fire(new e.a(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 i=r.stylesheet.schema;if(!i)return null;const n={};for(const t in i){const i=e.aj(t,r.scope),o=r.options.get(i),s=o?o.value||o.default:null;n[t]=s?s.serialize():null}return n}setConfig(e,t){const r=this.getFragmentStyle(e);r&&(r.updateConfig(t,r.stylesheet.schema),this.updateConfigDependencies())}getSchema(e){const t=this.getFragmentStyle(e);return t?t.stylesheet.schema:null}setSchema(e,t){const r=this.getFragmentStyle(e);r&&(r.stylesheet.schema=t,r.updateConfig(r._config,t),this.updateConfigDependencies())}updateConfig(t,r){if(this._config=t,t||r)if(r)for(const i in r){let n,o;const s=e.t(r[i].default);if("success"===s.result&&(n=s.value.expression),t&&void 0!==t[i]){const r=e.t(t[i]);"success"===r.result&&(o=r.value.expression)}const{minValue:a,maxValue:l,stepValue:c,type:u,values:h}=r[i];if(n){const t=e.aj(i,this.scope);this.options.set(t,{default:n,value:o,minValue:a,maxValue:l,stepValue:c,type:u,values:h})}else this.fire(new e.a(new Error(`No schema defined for config option "${i}".`)))}else this.fire(new e.a(new Error("Attempting to set config for a style without schema.")))}updateConfigDependencies(){for(const e of this._configDependentLayers){const t=this.getLayer(e);t&&(t.possiblyEvaluateVisibility(),this._updateLayer(t))}this.ambientLight&&this.ambientLight.updateConfig(this.options),this.directionalLight&&this.directionalLight.updateConfig(this.options),this.fog&&this.fog.updateConfig(this.options),this._changes.setDirty()}addLayer(t,r,i={}){this._checkLoaded();const n=t.id;if(this._layers[n])return void this.fire(new e.a(new Error(`Layer with id "${n}" already exists on this map`)));let o;if("custom"===t.type){if(Ci(this,e.cb(t)))return;o=e.c7(t,this.scope,this.options)}else{if("object"==typeof t.source&&(this.addSource(n,t.source),t=e.c6(t),t=e.e(t,{source:n})),this._validate(ee,`layers.${n}`,t,{arrayIndex:-1},i))return;o=e.c7(t,this.scope,this.options),this._validateLayer(o),o.setEventedParent(this,{layer:{id:n}}),this._serializedLayers[o.id]=o.serialize()}o.isConfigDependent&&this._configDependentLayers.add(o.fqid);let s=this._order.length;if(r){const t=this._order.indexOf(r);if(-1===t)return void this.fire(new e.a(new Error(`Layer with id "${r}" does not exist on this map.`)));o.slot===this._layers[r].slot?s=t:e.w(`Layer with id "${r}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(s,0,n),this._layerOrderChanged=!0,this._layers[n]=o;const a=this.getOwnLayerSourceCache(o),l=!!this.directionalLight&&this.directionalLight.shadowsEnabled();a&&o.canCastShadows()&&l&&(a.castsShadows=!0);const c=this._changes.getRemovedLayer(o);if(c&&o.source&&a&&"custom"!==o.type){this._changes.discardLayerRemoval(o);const t=e.aj(o.source,o.scope);c.type!==o.type?this._changes.updateSourceCache(t,"clear"):(this._changes.updateSourceCache(t,"reload"),a.pause())}this._updateLayer(o),o.onAdd&&o.onAdd(this.map),o.scope=this.scope,this.mergeLayers()}moveLayer(t,r){this._checkLoaded();const i=this._checkLayer(t);if(!i)return;if(t===r)return;const n=this._order.indexOf(t);this._order.splice(n,1);let o=this._order.length;if(r){const t=this._order.indexOf(r);if(-1===t)return void this.fire(new e.a(new Error(`Layer with id "${r}" does not exist on this map.`)));i.slot===this._layers[r].slot?o=t:e.w(`Layer with id "${r}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(o,0,t),this._changes.setDirty(),this._layerOrderChanged=!0,this.mergeLayers()}removeLayer(e){this._checkLoaded();const t=this._checkLayer(e);if(!t)return;t.setEventedParent(null);const r=this._order.indexOf(e);this._order.splice(r,1),delete this._layers[e],delete this._serializedLayers[e],this._changes.setDirty(),this._layerOrderChanged=!0,this._configDependentLayers.delete(t.fqid),this._changes.removeLayer(t);const i=this.getOwnLayerSourceCache(t);if(i&&i.castsShadows){let e=!1;for(const r in this._layers)if(this._layers[r].source===t.source&&this._layers[r].canCastShadows()){e=!0;break}i.castsShadows=e}t.onRemove&&t.onRemove(this.map),this.mergeLayers()}getOwnLayer(e){return this._layers[e]}hasLayer(e){return e in this._mergedLayers}hasLayerType(e){for(const t in this._layers)if(this._layers[t].type===e)return!0;return!1}setLayerZoomRange(e,t,r){this._checkLoaded();const i=this._checkLayer(e);i&&(i.minzoom===t&&i.maxzoom===r||(null!=t&&(i.minzoom=t),null!=r&&(i.maxzoom=r),this._updateLayer(i)))}setSlot(e,t){this._checkLoaded();const r=this._checkLayer(e);r&&r.slot!==t&&(r.slot=t,this._updateLayer(r))}setFilter(r,i,n={}){this._checkLoaded();const o=this._checkLayer(r);if(o&&!t(o.filter,i))return null==i?(o.filter=void 0,void this._updateLayer(o)):void(this._validate(te,`layers.${o.id}.filter`,i,{layerType:o.type},n)||(o.filter=e.c6(i),this._updateLayer(o)))}getFilter(t){const r=this._checkLayer(t);if(r)return e.c6(r.filter)}setLayoutProperty(r,i,n,o={}){this._checkLoaded();const s=this._checkLayer(r);if(s&&!t(s.getLayoutProperty(i),n)){if(null!=n&&(!o||!1!==o.validate)&&Ci(s,ie.call(q,{key:`layers.${r}.layout.${i}`,layerType:s.type,objectKey:i,value:n,styleSpec:e.G,style:{glyphs:!0,sprite:!0}})))return;s.setLayoutProperty(i,n),s.isConfigDependent&&this._configDependentLayers.add(s.fqid),this._updateLayer(s)}}getLayoutProperty(e,t){const r=this._checkLayer(e);if(r)return r.getLayoutProperty(t)}setPaintProperty(r,i,n,o={}){this._checkLoaded();const s=this._checkLayer(r);if(!s)return;if(t(s.getPaintProperty(i),n))return;if(null!=n&&(!o||!1!==o.validate)&&Ci(s,re.call(q,{key:`layers.${r}.paint.${i}`,layerType:s.type,objectKey:i,value:n,styleSpec:e.G})))return;const a=s.setPaintProperty(i,n);s.isConfigDependent&&this._configDependentLayers.add(s.fqid),a&&this._updateLayer(s),this._changes.updatePaintProperties(s)}getPaintProperty(e,t){const r=this._checkLayer(e);if(r)return r.getPaintProperty(t)}setFeatureState(t,r){this._checkLoaded();const i=t.source,n=t.sourceLayer,o=this._checkSource(i);if(!o)return;const s=o.type;if("geojson"===s&&n)return void this.fire(new e.a(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===s&&!n)return void this.fire(new e.a(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===t.id&&this.fire(new e.a(new Error("The feature id parameter must be provided.")));const a=this.getOwnSourceCaches(i);for(const e of a)e.setFeatureState(n,t.id,r)}removeFeatureState(t,r){this._checkLoaded();const i=t.source,n=this._checkSource(i);if(!n)return;const o=n.type,s="vector"===o?t.sourceLayer:void 0;if("vector"===o&&!s)return void this.fire(new e.a(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 e.a(new Error("A feature id is required to remove its specific state property.")));const a=this.getOwnSourceCaches(i);for(const e of a)e.removeFeatureState(s,t.id,r)}getFeatureState(t){this._checkLoaded();const r=t.source,i=t.sourceLayer,n=this._checkSource(r);if(n){if("vector"!==n.type||i)return void 0===t.id&&this.fire(new e.a(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(r)[0].getFeatureState(i,t.id);this.fire(new e.a(new Error("The sourceLayer parameter must be provided for vector source types.")))}}setTransition(t){return this.stylesheet.transition=e.e({},this.stylesheet.transition,t),this.transition=this.stylesheet.transition,this}getTransition(){return e.e({},this.stylesheet.transition)}serialize(){this._checkLoaded();const t=this.getTerrain(),r=t&&this.terrain&&this.terrain.scope===this.scope?t:this.stylesheet.terrain;return e.cc({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,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)},(e=>void 0!==e))}_updateLayer(t){this._changes.updateLayer(t);const r=this.getLayerSourceCache(t),i=e.aj(t.source,t.scope),n=this._changes.getUpdatedSourceCaches();t.source&&!n[i]&&r&&"raster"!==r.getSource().type&&(this._changes.updateSourceCache(i,"reload"),r.pause()),t.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(e){const t=e=>"fill-extrusion"===this._mergedLayers[e].type||"model"===this._mergedLayers[e].type,r=this.order,i={},n=[];for(let o=r.length-1;o>=0;o--){const s=r[o];if(t(s)){i[s]=o;for(const t of e){const e=t[s];if(e)for(const t of e)n.push(t)}}}n.sort(((e,t)=>t.intersectionZ-e.intersectionZ));const o=[];for(let s=r.length-1;s>=0;s--){const a=r[s];if(t(a))for(let e=n.length-1;e>=0;e--){const t=n[e].feature;if(i[t.layer.id]<s)break;o.push(t),n.pop()}else for(const t of e){const e=t[a];if(e)for(const t of e)o.push(t.feature)}}return o}queryRenderedFeatures(t,r,i){r&&r.filter&&this._validate(te,"queryRenderedFeatures.filter",r.filter,null,r),r.scope=this.scope,r.availableImages=this._availableImages,r.serializedLayers=this._serializedLayers;const n={};if(r&&r.layers){if(!Array.isArray(r.layers))return this.fire(new e.a(new Error("parameters.layers must be an Array."))),[];for(const t of r.layers){const r=this._mergedLayers[t];if(!r)return this.fire(new e.a(new Error(`The layer '${t}' does not exist in the map's style and cannot be queried for features.`))),[];n[r.source]=!0}}const o=[],s=r.serializedLayers||{},a=r&&r.layers?r.layers.some((e=>{const t=this.getLayer(e);return t&&t.is3D()})):this.has3DLayers(),l=we.createFromScreenPoints(t,i);for(const e in this._mergedSourceCaches){const t=this._mergedSourceCaches[e].getSource();if(!t||t.scope!==r.scope)continue;const c=this._mergedSourceCaches[e].getSource().id;r.layers&&!n[c]||o.push(Ht(this._mergedSourceCaches[e],this._mergedLayers,s,l,r,i,a,!!this.map._showQueryGeometry))}return this.placement&&o.push(function(e,t,r,i,n,o,s){const a={},l=o.queryRenderedSymbols(i),c=[];for(const e of Object.keys(l).map(Number))c.push(s[e]);c.sort(Zt);for(const r of c){const i=r.featureIndex.lookupSymbolFeatures(l[r.bucketInstanceId],t,r.bucketIndex,r.sourceLayerIndex,n.filter,n.layers,n.availableImages,e);for(const e in i){const t=a[e]=a[e]||[],n=i[e];n.sort(((e,t)=>{const i=r.featureSortOrder;if(i){const r=i.indexOf(e.featureIndex);return i.indexOf(t.featureIndex)-r}return t.featureIndex-e.featureIndex}));for(const e of n)t.push(e)}}for(const t in a)a[t].forEach((i=>{const n=i.feature,o=r(e[t]);if(!o)return;const s=o.getFeatureState(n.layer["source-layer"],n.id);n.source=n.layer.source,n.layer["source-layer"]&&(n.sourceLayer=n.layer["source-layer"]),n.state=s}));return a}(this._mergedLayers,s,this.getLayerSourceCache.bind(this),l.screenGeometry,r,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(o)}querySourceFeatures(e,t){t&&t.filter&&this._validate(te,"querySourceFeatures.filter",t.filter,null,t);const r=this.getOwnSourceCaches(e);let i=[];for(const e of r)i=i.concat(Gt(e,t));return i}addSourceType(e,t,r){return Ii.getSourceType(e)?r(new Error(`A source type called "${e}" already exists.`)):(Ii.setSourceType(e,t),t.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:e,url:t.workerSourceURL},r):r(null,null))}getFlatLight(){return this.light.getLight()}setFlatLight(e,r,i={}){this._checkLoaded();const n=this.light.getLight();let o=!1;for(const r in e)if(!t(e[r],n[r])){o=!0;break}if(!o)return;const s=this._getTransitionParameters();this.light.setLight(e,r,i),this.light.updateTransitions(s)}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}setTerrain(r,i=1){if(this._checkLoaded(),!r)return this.terrainSetForDrapingOnly()&&0!==i||delete this.terrain,null===r?this.stylesheet.terrain=null:delete this.stylesheet.terrain,this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);let n=r;const o=null==r.source;if(1===i){if("object"==typeof n.source){const t="terrain-dem-src";this.addSource(t,n.source),n=e.c6(n),n=e.e(n,{source:t})}const t=e.e({},n),r={};if(this.terrain&&o){t.source=this.terrain.get().source;const e=this.terrain?this.getFragmentStyle(this.terrain.scope):null;e&&(r.style=e.serialize())}if(this._validate(K,"terrain",t,r))return}if(!this.terrain||this.terrain.scope!==this.scope&&!o||this.terrain&&i!==this.terrain.drapeRenderMode){if(!n)return;this._createTerrain(n,i),this.fire(new e.b("data",{dataType:"style"}))}else{const i=this.terrain,o=i.get();for(const t of Object.keys(e.G.terrain))!n.hasOwnProperty(t)&&e.G.terrain[t].default&&(n[t]=e.G.terrain[t].default);for(const n in r)if(!t(r[n],o[n])){i.set(r,this.options),this.stylesheet.terrain=r;const t=this._getTransitionParameters({duration:0});i.updateTransitions(t),this.fire(new e.b("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(e){const t=this.fog=new ye(e,this.map.transform,this.scope,this.options);this.stylesheet.fog=t.get();const r=this._getTransitionParameters({duration:0});t.updateTransitions(r)}_updateMarkersOpacity(){0!==this.map._markers.length&&this.map._requestDomTask((()=>{for(const e of this.map._markers)e._evaluateOpacity()}))}getFog(){return this.fog?this.fog.get():null}setFog(e){if(this._checkLoaded(),!e)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const r=this.fog;if(!t(r.get(),e)){r.set(e,this.options),this.stylesheet.fog=r.get();const t=this._getTransitionParameters({duration:0});r.updateTransitions(t)}}else this._createFog(e);this._markersNeedUpdate=!0}_getTransitionParameters(t){return{now:e.f.now(),transition:e.e(this.transition,t)}}updateDrapeFirstLayers(){if(!this.terrain)return;const e=[],t=[];for(const r in this._mergedLayers)this.isLayerDraped(this._mergedLayers[r])?e.push(r):t.push(r);this._drapedFirstOrder=[],this._drapedFirstOrder.push(...e),this._drapedFirstOrder.push(...t)}_createTerrain(e,t){const r=this.terrain=new ue(e,t,this.scope,this.options);1===t&&(this.stylesheet.terrain=e),this.mergeTerrain(),this.updateDrapeFirstLayers(),this._force3DLayerUpdate();const i=this._getTransitionParameters({duration:0});r.updateTransitions(i)}_force3DLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"fill-extrusion"===t.type&&this._updateLayer(t)}}_forceSymbolLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"symbol"===t.type&&this._updateLayer(t)}}_validate(t,r,i,n,o={}){if(o&&!1===o.validate)return!1;const s=e.e({},this.serialize());return Ci(this,t.call(q,e.e({key:r,style:s,value:i,styleSpec:e.G},n)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),e.cd.off("pluginStateChange",this._rtlTextPluginCallback);for(const e in this._mergedLayers)this._mergedLayers[e].setEventedParent(null);for(const e in this._mergedSourceCaches)this._mergedSourceCaches[e].clearTiles(),this._mergedSourceCaches[e].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(e){const t=this.getSourceCaches(e);for(const e of t)e.clearTiles()}clearSources(){for(const e in this._mergedSourceCaches)this._mergedSourceCaches[e].clearTiles()}reloadSource(e){const t=this.getSourceCaches(e);for(const e of t)e.resume(),e.reload()}reloadSources(){for(const e of this.getSources())e.reload&&e.reload()}updateSources(e){let t;this.directionalLight&&(t=vi(this.directionalLight));for(const r in this._mergedSourceCaches)this._mergedSourceCaches[r].update(e,void 0,void 0,t)}_generateCollisionBoxes(){for(const e in this._sourceCaches){const t=this._sourceCaches[e];t.resume(),t.reload()}}_updatePlacement(t,r,i,n,o=!1){let s=!1,a=!1;const l={},c={};for(const r of this._mergedOrder){const i=this._mergedLayers[r];if("symbol"!==i.type)continue;const n=e.aj(i.source,i.scope);let o=l[n];if(!o){const e=this.getLayerSourceCache(i);if(!e)continue;const t=e.getRenderableIds(!0).map((t=>e.getTileByID(t)));c[n]=t.slice(),o=l[n]=t.sort(((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1)))}const a=this.crossTileSymbolIndex.addLayer(i,o,t.center.lng,t.projection);s=s||a}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder),o=o||this._layerOrderChanged||0===i,this._layerOrderChanged&&this.fire(new e.b("neworder")),(o||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(e.f.now(),t.zoom))&&(this.pauseablePlacement=new Jr(t,this._mergedOrder,o,r,i,n,this.placement,this.fog&&t.projection.supportsFog?this.fog.state:null,this._buildingIndex),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._mergedOrder,this._mergedLayers,l,c),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(e.f.now()),a=!0),s&&this.pauseablePlacement.placement.setStale()),a||s){this._buildingIndex.onNewFrame(t.zoom);for(const t of this._mergedOrder){const r=this._mergedLayers[t];"symbol"===r.type&&this.placement.updateLayerOpacities(r,l[e.aj(r.source,r.scope)])}}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(e.f.now())}_releaseSymbolFadeTiles(){for(const e in this._sourceCaches)this._sourceCaches[e].releaseSymbolFadeTiles()}addImport(t,r){this._checkLoaded();const i=this.stylesheet.imports=this.stylesheet.imports||[];if(-1!==i.findIndex((({id:e})=>e===t.id)))return void this.fire(new e.a(new Error(`Import with id '${t.id}' already exists in the map's style.`)));if(!r)return i.push(t),this._loadImports([t],!0);const n=i.findIndex((({id:e})=>e===r));return-1===n&&this.fire(new e.a(new Error(`Import with id "${r}" does not exist on this map.`))),this.stylesheet.imports=i.slice(0,n).concat(t).concat(i.slice(n)),this._loadImports([t],!0,r)}updateImport(e,r){this._checkLoaded();const i=this.stylesheet.imports||[],n=this.getImportIndex(e);return-1===n?this:"string"==typeof r?(this.setImportUrl(e,r),this):(r.url&&r.url!==i[n].url&&this.setImportUrl(e,r.url),t(r.config,i[n].config)||this.setImportConfig(e,r.config),t(r.data,i[n].data)||this.setImportData(e,r.data),this)}moveImport(e,t){this._checkLoaded();let r=this.stylesheet.imports||[];const i=this.getImportIndex(e);if(-1===i)return this;const n=this.getImportIndex(t);if(-1===n)return this;const o=r[i],s=this.fragments[i];return r=r.filter((({id:t})=>t!==e)),this.fragments=this.fragments.filter((({id:t})=>t!==e)),this.stylesheet.imports=r.slice(0,n).concat(o).concat(r.slice(n)),this.fragments=this.fragments.slice(0,n).concat(s).concat(this.fragments.slice(n)),this.mergeLayers(),this}setImportUrl(e,t){this._checkLoaded();const r=this.stylesheet.imports||[],i=this.getImportIndex(e);if(-1===i)return this;r[i].url=t;const n=this.fragments[i];return n.style=this._createFragmentStyle(r[i]),n.style.on("style.import.load",(()=>this.mergeAll())),n.style.loadURL(t),this}setImportData(e,t){this._checkLoaded();const r=this.getImportIndex(e),i=this.stylesheet.imports||[];return-1===r?this:t?(this.fragments[r].style.setState(t),this._reloadImports(),this):(delete i[r].data,this.setImportUrl(e,i[r].url))}setImportConfig(e,t){this._checkLoaded();const r=this.getImportIndex(e),i=this.stylesheet.imports||[];if(-1===r)return this;t?i[r].config=t:delete i[r].config;const n=this.fragments[r],o=n.style.stylesheet&&n.style.stylesheet.schema;return n.config=t,n.style.updateConfig(t,o),this.updateConfigDependencies(),this}removeImport(e){this._checkLoaded();const t=this.stylesheet.imports||[],r=this.getImportIndex(e);-1!==r&&(t.splice(r,1),this.fragments[r].style._remove(),this.fragments.splice(r,1),this._reloadImports())}getImportIndex(t){const r=(this.stylesheet.imports||[]).findIndex((e=>e.id===t));return-1===r&&this.fire(new e.a(new Error(`Import '${t}' does not exist in the map's style and cannot be updated.`))),r}getLayer(e){return this._mergedLayers[e]}getSources(){const e=[];for(const t in this._mergedOtherSourceCaches){const r=this._mergedOtherSourceCaches[t];r&&e.push(r.getSource())}return e}getSource(e,t){const r=this.getSourceCache(e,t);return r&&r.getSource()}getLayerSource(e){const t=this.getLayerSourceCache(e);return t&&t.getSource()}getSourceCache(t,r){const i=e.aj(t,r);return this._mergedOtherSourceCaches[i]}getLayerSourceCache(t){const r=e.aj(t.source,t.scope);return"symbol"===t.type?this._mergedSymbolSourceCaches[r]:this._mergedOtherSourceCaches[r]}getSourceCaches(e){if(null==e)return Object.values(this._mergedSourceCaches);const t=[];return this._mergedOtherSourceCaches[e]&&t.push(this._mergedOtherSourceCaches[e]),this._mergedSymbolSourceCaches[e]&&t.push(this._mergedSymbolSourceCaches[e]),t}updateSourceCaches(){const e=this._changes.getUpdatedSourceCaches();for(const t in e){const r=e[t];"reload"===r?this.reloadSource(t):"clear"===r&&this.clearSource(t)}}updateLayers(e){const t=this._changes.getUpdatedPaintProperties();for(const r of t){const t=this.getLayer(r);t&&t.updateTransitions(e)}}getImages(e,t,r){this.imageManager.getImages(t.icons,t.scope,r),this._updateTilesForChangedImages();const i=e=>{e&&e.setDependencies(t.tileID.key,t.type,t.icons)};i(this._otherSourceCaches[t.source]),i(this._symbolSourceCaches[t.source])}getGlyphs(e,t,r){this.glyphManager.getGlyphs(t.stacks,t.scope,r)}getResource(t,r,i){return e.ce(r,i)}getOwnSourceCache(e){return this._otherSourceCaches[e]}getOwnLayerSourceCache(e){return"symbol"===e.type?this._symbolSourceCaches[e.source]:this._otherSourceCaches[e.source]}getOwnSourceCaches(e){const t=[];return this._otherSourceCaches[e]&&t.push(this._otherSourceCaches[e]),this._symbolSourceCaches[e]&&t.push(this._symbolSourceCaches[e]),t}_isSourceCacheLoaded(t){const r=this.getOwnSourceCaches(t);return 0===r.length?(this.fire(new e.a(new Error(`There is no source with ID '${t}'`))),!1):r.every((e=>e.loaded()))}has3DLayers(){return this._has3DLayers}hasSymbolLayers(){return this._hasSymbolLayers}hasCircleLayers(){return this._hasCircleLayers}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}destroy(){this._clearWorkerCaches(),this.fragments.forEach((e=>{e.style._remove()})),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}Ii.getSourceType=function(e){return Vt[e]},Ii.setSourceType=function(e,t){Vt[e]=t},Ii.registerForPluginStateChange=e.bY;var Pi="\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",Di="\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,vec2 pos,vec2 lod_coord) {vec2 size=vec2(textureSize(image,0));vec2 dx=dFdx(lod_coord.xy*size);vec2 dy=dFdy(lod_coord.xy*size);float delta_max_sqr=max(dot(dx,dx),dot(dy,dy));float lod=0.5*log2(delta_max_sqr);return textureLod(image,pos,lod);}",ki="\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 float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}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);}",Li="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;}",zi="\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;uniform sampler2D u_depth;uniform vec2 u_depth_size_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\nhighp 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;}bool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;float depth=unpack_depth(texture(u_depth,(coord.xy+1.0)*0.5));return coord.z > depth+0.0005;}float occlusionFade(vec4 frag) {vec3 coord=frag.xyz/frag.w;vec3 df=vec3(5.0*u_depth_size_inv,0.0);vec2 uv=0.5*coord.xy+0.5;vec4 depth=vec4(\nunpack_depth(texture(u_depth,uv-df.xz)),unpack_depth(texture(u_depth,uv+df.xz)),unpack_depth(texture(u_depth,uv-df.zy)),unpack_depth(texture(u_depth,uv+df.zy))\n);return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z-0.001)-depth),0.0,1.0));}vec4 fourSample(vec2 pos,vec2 off) {float tl=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(off.x,0.0)).r;float bl=texture(u_dem,pos+vec2(0.0,off.y)).r;float br=texture(u_dem,pos+off).r;return vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);}\n#else\nfloat elevation(vec2 pos) { return 0.0; }bool isOccluded(vec4 frag) { return false; }float occlusionFade(vec4 frag) { return 1.0; }\n#endif",Oi="#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",Bi="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",Ri="#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",Fi="#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 vec4 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=vec2(u_data_offset+dot(t.rg,u_data_scale.yx),-(u_data_offset+dot(t.ba,u_data_scale.yx)));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;}",ji="#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) {float dotScale=min(1.0-dot(normal,u_shadow_direction),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",Vi="#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_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 Ni=[];Qi(Pi,Ni),Qi(ki,Ni),Qi(Di,Ni);const Ui={"_prelude_fog.vertex.glsl":Oi,"_prelude_terrain.vertex.glsl":zi,"_prelude_shadow.vertex.glsl":ji,"_prelude_fog.fragment.glsl":Bi,"_prelude_shadow.fragment.glsl":Vi,"_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":Ri,"_prelude_raster_particle.glsl":Fi},Hi={};qi("",zi),qi(Bi,Oi),qi(Vi,ji),qi(Ri,""),qi(Fi,"");const Gi=qi(Di,ki),Zi=Pi;var Wi={background:qi('#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:qi('#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 vec2 v_pos;void main() {vec2 imagecoord=mod(v_pos,1.0);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 float u_tile_units_to_pixels;in vec2 a_pos;out 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_tile_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),circle:qi('#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 extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,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:qi("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:qi('#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:qi("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:qi("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 float a_size_scale;in vec2 a_padding;in float a_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() {vec4 projectedPoint=u_matrix*vec4(a_pos+elevationVector(a_anchor_pos)*(a_z_offset+elevation(a_anchor_pos)),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:qi("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:qi("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:qi('#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;uniform mat4 u_matrix;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillOutline:qi('#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;uniform 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\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);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:qi('#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;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);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;out 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\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;gl_Position=u_matrix*vec4(a_pos,0,1);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:qi('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;in 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;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);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;out 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\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;gl_Position=u_matrix*vec4(a_pos,0,1);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:qi('#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\nuniform float u_emissive_strength;in float v_height;void main() {\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=shadowed_light_factor_normal(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);color.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,u_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;in vec4 a_pos_normal_ed;in vec2 a_centroid_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;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\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\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=max(0.01,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;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.01 && centroid_pos.x !=0.0));gl_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:qi("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_vertical_scale;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\nout highp float v_depth;void main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\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\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);v_depth=gl_Position.z/gl_Position.w;}'),fillExtrusionPattern:qi('#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 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;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);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 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 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 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\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;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\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:qi('#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:qi("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 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(1.0,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:qi("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:qi('#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:qi('#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;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 trimmed=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) {if (line_progress <=trim_end && line_progress >=trim_start) {out_color=vec4(0,0,0,0);trimmed=0.0;}}\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) { \nfloat 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*trimmed,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#define EXTRUDE_SCALE 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;\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);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\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:qi('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform mediump 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 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 lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;vec2 pattern_size=vec2(display_size.x/u_tile_units_to_pixels,display_size.y);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);float pattern_x=v_linesofar/pattern_size.x*aspect;float x=mod(pattern_x,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(x,y));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.x/aspect;float segment_phase=pattern_len-mod((v_linesofar-v_pattern_data.x),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);\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#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;\n#ifdef RENDER_LINE_TRIM_OFFSET\nin highp vec4 a_packed;\n#endif\nin float a_linesofar;\n#ifdef LINE_JOIN_NONE\nin vec2 a_pattern_data;out vec2 v_pattern_data;\n#endif\nuniform mat4 u_matrix;uniform mediump float u_tile_units_to_pixels;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out 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 lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp 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);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*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\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+=ANTIALIASING;float offset_sign=(fract(a_pattern_data.x)-0.5)*4.0;float line_progress_offset=offset_sign*v_width*0.5/u_tile_units_to_pixels;v_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:qi('#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:qi('#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:qi("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-vec2(1.0),0.0,1.0);v_particle_speed=length(velocity);}gl_PointSize=1.0;}'),rasterParticleTexture:qi("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:qi('#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;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 float speed=velocity==INVALID_VELOCITY ? 0.0 : length(velocity);highp float reset_rate_bump=speed*u_reset_rate;highp vec2 particle_pos_min=-u_particle_pos_offset;highp vec2 particle_pos_max=vec2(1.0)+u_particle_pos_offset;highp vec2 pos_drop_rate=vec2(1.0)-step(particle_pos_min,pos)+step(particle_pos_max,pos);highp float drop_rate=max(u_reset_rate+reset_rate_bump,length(pos_drop_rate));highp float drop=step(1.0-drop_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);}"),symbolIcon:qi('#include "_prelude_lighting.glsl"\nuniform sampler2D u_texture;\n#ifdef ICON_TRANSITION\nuniform float u_icon_transition;\n#endif\nin float v_fade_opacity;in vec2 v_tex_a;\n#ifdef ICON_TRANSITION\nin vec2 v_tex_b;\n#endif\n#ifdef COLOR_ADJUSTMENT\nuniform mat4 u_color_adj_mat;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float emissive_strength\nlowp float alpha=opacity*v_fade_opacity;vec4 out_color;\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\nout_color*=alpha;\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_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\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 highp float u_camera_to_center_distance;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform vec3 u_up_vector;\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_fade_opacity;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float emissive_strength\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=elevation(tile_anchor);\n#ifdef Z_OFFSET\ne+=a_z_offset;\n#endif\nvec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,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;\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);\n#else\noffsetProjected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);\n#endif\nvec2 a=projected_point.xy/projected_point.w;vec2 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\nfloat occlusion_fade=occlusionFade(projected_point)*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 out_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change))*projection_transition_fade;float 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\nv_tex_a=a_tex/u_texsize;\n#ifdef ICON_TRANSITION\nv_tex_b=a_texb/u_texsize;\n#endif\nv_fade_opacity=out_fade_opacity;}'),symbolSDF:qi('#include "_prelude_lighting.glsl"\n#define SDF_PX 8.0\nuniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;uniform bool u_is_halo;in float v_draw_halo;in vec2 v_data0;in vec3 v_data1;\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\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 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) {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,tex).r;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);vec4 out_color=color*(alpha*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_z_offset;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_globe_anchor;in vec3 a_globe_normal;\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_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 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 float v_draw_halo;out vec2 v_data0;out vec3 v_data1;\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\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;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=elevation(tile_anchor);\n#ifdef Z_OFFSET\ne+=a_z_offset;\n#endif\nvec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,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 fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetprojected_point;\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);\n#else\noffsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);\n#endif\nvec2 a=projected_point.xy/projected_point.w;vec2 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*fontScale+a_pxoffset);\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\nfloat occlusion_fade=occlusionFade(projected_point)*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;float 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_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,out_fade_opacity);}'),symbolTextAndIcon:qi('#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_halo;in float v_draw_halo;in vec4 v_data0;in vec4 v_data1;\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\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;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;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 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) {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,tex).r;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);vec4 out_color=color*(alpha*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_projected_pos;in float a_fade_opacity;\n#ifdef Z_OFFSET\nin float a_z_offset;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_globe_anchor;in vec3 a_globe_normal;\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_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 float v_draw_halo;out vec4 v_data0;out vec4 v_data1;\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\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);float is_sdf=a_size[0]-2.0*a_size_min;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=elevation(tile_anchor);\n#ifdef Z_OFFSET\ne+=a_z_offset;\n#endif\nvec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,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=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offset_projected_point=u_matrix*vec4(a_pos+vec2(1,0),0,1);vec2 a=projected_point.xy/projected_point.w;vec2 b=offset_projected_point.xy/offset_projected_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*font_scale);\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\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));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\nfloat out_fade_opacity=interpolated_fade_opacity*projection_transition_fade;float 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_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,out_fade_opacity,is_sdf);}'),terrainRaster:qi('#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:qi("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:qi('#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}',Li),skyboxGradient:qi('#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}',Li),skyboxCapture:qi("\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:qi('#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:qi('#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:qi('#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 vec4 v_pos_light_view_0;in 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 TERRAIN_FRAGMENT_OCCLUSION\nin highp float v_depth;uniform sampler2D u_depthTexture;uniform vec2 u_inv_depth_size;bool isOccluded() {vec2 coord=gl_FragCoord.xy*u_inv_depth_size;highp float depth=unpack_depth(texture(u_depthTexture,coord));return 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\nreturn vec4(mix(albedo.rgb,v_color_mix.rgb,v_color_mix.a),albedo.a);}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\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);color=mix(color,v_color_mix.rgb,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 vec4 v_pos_light_view_0;out 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 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=u_matrix*pos;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(normalize(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:qi("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 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=u_matrix*pos;\n#else\ngl_Position=u_matrix*vec4(a_pos_3f,1);\n#endif\nv_depth=gl_Position.z/gl_Position.w;}"),stars:qi("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);}")};function Qi(e,t){const r=e.replace(/\s*\/\/[^\n]*\n/g,"\n").split("\n");for(let e of r)if(e=e.trim(),"#"===e[0]&&e.includes("if")&&!e.includes("endif")){e=e.replace("#","").replace(/ifdef|ifndef|elif|if/g,"").replace(/!|defined|\(|\)|\|\||&&/g,"").replace(/\s+/g," ").trim();const r=e.split(" ");for(const e of r)t.includes(e)||t.push(e)}}function qi(e,t){const r=/#include\s+"([^"]+)"/g,i=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g;let n=t.match(/(attribute(\S*)|(^\s*|;)in) (highp |mediump |lowp )?([\w]+) ([\w]+)/gm);n&&(n=n.map((e=>{const t=e.split(" ");return t[t.length-1]})),n=[...new Set(n)]);const o={},s=[],a=[];if(e=e.replace(r,((e,t)=>(a.push(t),""))),(t=t.replace(r,((e,t)=>(s.push(t),"")))).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 l=[...Ni];Qi(e,l),Qi(t,l);for(const e of[...s,...a])Ui[e]||console.error(`Undefined include: ${e}`),Hi[e]||(Hi[e]=[],Qi(Ui[e],Hi[e])),l=[...l,...Hi[e]];return{fragmentSource:e=e.replace(i,((e,t,r,i,n)=>(o[n]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nin ${r} ${i} ${n};\n#else\nuniform ${r} ${i} u_${n};\n#endif\n`:"initialize"===t?`\n#ifdef HAS_UNIFORM_u_${n}\n ${r} ${i} ${n} = u_${n};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n in ${r} ${i} ${n};\n#endif\n`:"initialize-attribute"===t?"":void 0))),vertexSource:t=t.replace(i,((e,t,r,i,n)=>{const s="float"===i?"vec2":i,a=n.match(/color/)?"color":s;return"define-attribute-vertex-shader-only"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\nin ${r} ${i} a_${n};\n#endif\n`:o[n]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nin ${r} ${s} a_${n};\nout ${r} ${i} ${n};\n#else\nuniform ${r} ${i} u_${n};\n#endif\n`:"initialize"===t?"vec4"===a?`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = a_${n};\n#else\n ${r} ${i} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = unpack_mix_${a}(a_${n}, u_${n}_t);\n#else\n ${r} ${i} ${n} = u_${n};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n in ${r} ${i} a_${n};\n out ${r} ${i} ${n};\n#endif\n`:"initialize-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n ${n} = a_${n};\n#endif\n`:void 0:"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nin ${r} ${s} a_${n};\n#else\nuniform ${r} ${i} u_${n};\n#endif\n`:"define-instanced"===t?"mat4"===a?`\n#ifdef INSTANCED_ARRAYS\nin vec4 a_${n}0;\nin vec4 a_${n}1;\nin vec4 a_${n}2;\nin vec4 a_${n}3;\n#else\nuniform ${r} ${i} u_${n};\n#endif\n`:`\n#ifdef INSTANCED_ARRAYS\nin ${r} ${s} a_${n};\n#else\nuniform ${r} ${i} u_${n};\n#endif\n`:"initialize-attribute-custom"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n ${r} ${i} ${n} = a_${n};\n#endif\n`:"vec4"===a?`\n#ifndef HAS_UNIFORM_u_${n}\n ${r} ${i} ${n} = a_${n};\n#else\n ${r} ${i} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${r} ${i} ${n} = unpack_mix_${a}(a_${n}, u_${n}_t);\n#else\n ${r} ${i} ${n} = u_${n};\n#endif\n`})),staticAttributes:n,usedDefines:l,vertexIncludes:s,fragmentIncludes:a}}class Xi{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(e,t,r,i,n,o,s,a){this.context=e;let l=this.boundPaintVertexBuffers.length!==i.length;for(let e=0;!l&&e<i.length;e++)this.boundPaintVertexBuffers[e]!==i[e]&&(l=!0);let c=this.boundDynamicVertexBuffers.length!==s.length;for(let e=0;!c&&e<s.length;e++)this.boundDynamicVertexBuffers[e]!==s[e]&&(c=!0);if(!this.vao||this.boundProgram!==t||this.boundLayoutVertexBuffer!==r||l||c||this.boundIndexBuffer!==n||this.boundVertexOffset!==o)this.freshBind(t,r,i,n,o,s,a);else{e.bindVertexArrayOES.set(this.vao);for(const r of s)r&&(r.bind(),a&&r.instanceCount&&r.setVertexAttribDivisor(e.gl,t,a));n&&n.dynamicDraw&&n.bind()}}freshBind(e,t,r,i,n,o,s){const a=e.numAttributes,l=this.context,c=l.gl;this.vao&&this.destroy(),this.vao=l.gl.createVertexArray(),l.bindVertexArrayOES.set(this.vao),this.boundProgram=e,this.boundLayoutVertexBuffer=t,this.boundPaintVertexBuffers=r,this.boundIndexBuffer=i,this.boundVertexOffset=n,this.boundDynamicVertexBuffers=o,t.enableAttributes(c,e),t.bind(),t.setVertexAttribPointers(c,e,n);for(const t of r)t.enableAttributes(c,e),t.bind(),t.setVertexAttribPointers(c,e,n);for(const t of o)t&&(t.enableAttributes(c,e),t.bind(),t.setVertexAttribPointers(c,e,n),s&&t.instanceCount&&t.setVertexAttribDivisor(c,e,s));i&&i.bind(),l.currentNumAttributes=a}destroy(){this.vao&&(this.context.gl.deleteVertexArray(this.vao),this.vao=null)}}function Yi(t,r){const i=Math.pow(2,r.canonical.z),n=r.canonical.y;return[new e.O(0,n/i).toLngLat().lat,new e.O(0,(n+1)/i).toLngLat().lat]}function $i(t,r,i,n,o,s,a){const l=t.context,c=l.gl,u=i.hillshadeFBO;if(!u)return;t.prepareDrawTile();const h=t.isTileAffectedByFog(r),d=t.getOrCreateProgram("hillshade",{overrideFog:h});l.activeTexture.set(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,u.colorAttachment.get());const p=((t,r,i,n)=>{const o=i.paint.get("hillshade-shadow-color"),s=i.paint.get("hillshade-highlight-color"),a=i.paint.get("hillshade-accent-color"),l=i.paint.get("hillshade-emissive-strength");let c=e.bm(i.paint.get("hillshade-illumination-direction"));if("viewport"===i.paint.get("hillshade-illumination-anchor"))c-=t.transform.angle;else if(t.style&&t.style.enable3dLights()&&t.style.directionalLight){const r=t.style.directionalLight.properties.get("direction"),i=e.bT(r.x,r.y,r.z);c=e.bm(i[1])}const u=!t.options.moving;return{u_matrix:n||t.transform.calculateProjMatrix(r.tileID.toUnwrapped(),u),u_image:0,u_latrange:Yi(0,r.tileID),u_light:[i.paint.get("hillshade-exaggeration"),c],u_shadow:o,u_highlight:s,u_emissive_strength:l,u_accent:a}})(t,i,n,t.terrain?r.projMatrix:null);t.uploadCommonUniforms(l,d,r.toUnwrapped());const{tileBoundsBuffer:f,tileBoundsIndexBuffer:m,tileBoundsSegments:A}=t.getTileBoundsBuffers(i);d.draw(t,c.TRIANGLES,o,s,a,Lt.disabled,p,n.id,f,m,A)}function Ki(t,r,i){if(!r.needsDEMTextureUpload)return;const n=t.context,o=n.gl;n.pixelStoreUnpackPremultiplyAlpha.set(!1),r.demTexture=r.demTexture||t.getTileTexture(i.stride);const s=i.getPixels();r.demTexture?r.demTexture.update(s,{premultiply:!1}):r.demTexture=new e.T(n,s,o.R32F,{premultiply:!1}),r.needsDEMTextureUpload=!1}function Ji(t,r,i){const n=t.context,o=n.gl;if(!r.dem)return;const s=r.dem;if(n.activeTexture.set(o.TEXTURE1),Ki(t,r,s),!r.demTexture)return;r.demTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE);const a=s.dim;n.activeTexture.set(o.TEXTURE0);let l=r.hillshadeFBO;if(!l){const t=new e.T(n,{width:a,height:a,data:null},o.RGBA);t.bind(o.LINEAR,o.CLAMP_TO_EDGE),l=r.hillshadeFBO=n.createFramebuffer(a,a,!0,"renderbuffer"),l.colorAttachment.set(t.texture)}n.bindFramebuffer.set(l.framebuffer),n.viewport.set([0,0,a,a]);const{tileBoundsBuffer:c,tileBoundsIndexBuffer:u,tileBoundsSegments:h}=t.getMercatorTileBoundsBuffers(),d=[];t.linearFloatFilteringSupported()&&d.push("TERRAIN_DEM_FLOAT_FORMAT"),t.getOrCreateProgram("hillshadePrepare",{defines:d}).draw(t,o.TRIANGLES,Et.disabled,St.disabled,Pt.unblended,Lt.disabled,((t,r)=>{const i=r.stride,n=e.a9.create();return e.a9.ortho(n,0,e.Y,-e.Y,0,0,1),e.a9.translate(n,n,[0,-e.Y,0]),{u_matrix:n,u_image:1,u_dimension:[i,i],u_zoom:t.overscaledZ}})(r.tileID,s),i.id,c,u,h),r.needsHillshadePrepare=!1}const en=t=>({u_matrix:new e.bN(t),u_image0:new e.bR(t),u_skirt_height:new e.bQ(t),u_ground_shadow_factor:new e.bP(t)}),tn=(e,t,r)=>({u_matrix:e,u_image0:0,u_skirt_height:t,u_ground_shadow_factor:r}),rn=(e,t,r,i,n,o,s,a,l,c,u,h,d,p,f,m)=>({u_proj_matrix:Float32Array.from(e),u_globe_matrix:t,u_normalize_matrix:Float32Array.from(i),u_merc_matrix:r,u_zoom_transition:n,u_merc_center:o,u_image0:0,u_frustum_tl:s,u_frustum_tr:a,u_frustum_br:l,u_frustum_bl:c,u_globe_pos:u,u_globe_radius:h,u_viewport:d,u_grid_matrix:m?Float32Array.from(m):new Float32Array(9),u_skirt_height:p,u_far_z_cutoff:f});function nn(e,t){return null!=e&&null!=t&&!(!e.hasData()||!t.hasData())&&null!=e.demTexture&&null!=t.demTexture&&e.tileID.key!==t.tileID.key}const on=new class{constructor(){this.operations={}}newMorphing(e,t,r,i,n){if(e in this.operations){const t=this.operations[e];t.to.tileID.key!==r.tileID.key&&(t.queued=r)}else this.operations[e]={startTime:i,phase:0,duration:n,from:t,to:r,queued:null}}getMorphValuesForProxy(e){if(!(e in this.operations))return null;const t=this.operations[e];return{from:t.from,to:t.to,phase:t.phase}}update(e){for(const t in this.operations){const r=this.operations[t];for(r.phase=(e-r.startTime)/r.duration;r.phase>=1||!this._validOp(r);)if(!this._nextOp(r,e)){delete this.operations[t];break}}}_nextOp(e,t){return!!e.queued&&(e.from=e.to,e.to=e.queued,e.queued=null,e.phase=0,e.startTime=t,!0)}_validOp(e){return e.from.hasData()&&e.to.hasData()}},sn={0:null,1:"TERRAIN_VERTEX_MORPHING"};function an(e,t,r){if(0===t)return 0;const i=t<1&&514===r?.25/t:1;return 6*Math.pow(1.5,22-e)*Math.max(t,1)*i}function ln(e,t){const r=1<<e.z;return!t&&(0===e.x||e.x===r-1)||0===e.y||e.y===r-1}const cn=e=>({u_matrix:e});function un(t,r,i,n,o){if(o>0){const s=e.f.now(),a=(s-t.timeAdded)/o,l=r?(s-r.timeAdded)/o:-1,c=i.getSource(),u=n.coveringZoomLevel({tileSize:c.tileSize,roundZoom:c.roundZoom}),h=!r||Math.abs(r.tileID.overscaledZ-u)>Math.abs(t.tileID.overscaledZ-u),d=h&&t.refreshedUponExpiration?1:e.ad(h?a:1-l,0,1);return t.refreshedUponExpiration&&a>=1&&(t.refreshedUponExpiration=!1),r?{opacity:1,mix:1-d}:{opacity:d,mix:0}}return{opacity:1,mix:0}}class hn extends qt{constructor(t){const r={type:"raster-dem",maxzoom:t.transform.maxZoom},i=new e.bZ(e.b_(),null),n=Nt("mock-dem",r,i,t.style);super("mock-dem",n,!1),n.setEventedParent(this),this._sourceLoaded=!0}_loadTile(e,t){e.state="loaded",t(null)}}class dn extends qt{constructor(t){const r=Nt("proxy",{type:"geojson",maxzoom:t.transform.maxZoom},new e.bZ(e.b_(),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(e,t,r){if(e.freezeTileCoverage)return;this.transform=e;const i=e.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce(((t,r)=>{if(t[r.key]="",!this._tiles[r.key]){const t=new jt(r,this._source.tileSize*r.overscaleFactor(),e.tileZoom);t.state="loaded",this._tiles[r.key]=t}return t}),{});for(const e in this._tiles)e in i||(this.freeFBO(e),this._tiles[e].unloadVectorData(),delete this._tiles[e])}freeFBO(e){const t=this.proxyCachedFBO[e];if(void 0!==t){const r=Object.values(t);this.renderCachePool.push(...r),delete this.proxyCachedFBO[e]}}deallocRenderCache(){this.renderCache.forEach((e=>e.fb.destroy())),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class pn extends e.ap{constructor(e,t,r){super(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y),this.proxyTileKey=t,this.projMatrix=r}}class fn extends e.cp{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[i,n,o]=function(t){const r=new e.aQ,i=new e.az,n=131;r.reserve(17161),i.reserve(33800);const o=e.Y/128,s=e.Y+o/2,a=s+o;for(let t=-o;t<a;t+=o)for(let i=-o;i<a;i+=o){const n=i<0||i>s||t<0||t>s?24575:0,o=e.ad(Math.round(i),0,e.Y),a=e.ad(Math.round(t),0,e.Y);r.emplaceBack(o+n,a)}const l=(e,t)=>{const r=t*n+e;i.emplaceBack(r+1,r,r+n),i.emplaceBack(r+n,r+n+1,r+1)};for(let e=1;e<129;e++)for(let t=1;t<129;t++)l(t,e);return[0,129].forEach((e=>{for(let t=0;t<130;t++)l(t,e),l(e,t)})),[r,i,32768]}(),s=t.context;this.gridBuffer=s.createVertexBuffer(i,e.aS.members),this.gridIndexBuffer=s.createIndexBuffer(n),this.gridSegments=e.aE.simpleSegment(0,0,i.length,n.length),this.gridNoSkirtSegments=e.aE.simpleSegment(0,0,i.length,o),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new dn(r.map),this.orthoMatrix=e.a9.create(),e.a9.ortho(this.orthoMatrix,"globe"===this.painter.transform.projection.name?.015:0,e.Y,0,e.Y,0,1);const a=s.gl;this._overlapStencilMode=new St({func:a.GEQUAL,mask:255},0,255,a.KEEP,a.KEEP,a.REPLACE),this._previousZoom=t.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=r,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new hn(r.map),this._pendingGroundEffectLayers=[]}set style(e){e.on("data",this._onStyleDataEvent.bind(this)),this._style=e,this._style.map.on("moveend",(()=>{this._clearLineLayersFromRenderCache()}))}update(t,r,i){if(t&&t.terrain){this._style!==t&&(this.style=t,this._evaluationZoom=void 0);const n=t.terrain.properties,o=0===t.terrain.drapeRenderMode,s=t.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=e.f.now();const a=t.terrain&&t.terrain.scope,l=n.get("source"),c=o?this._mockSourceCache:t.getSourceCache(l,a);if(!c)return void e.w(`Couldn't find terrain source "${l}".`);if(this.sourceCache=c,this._exaggeration=s?this.calculateExaggeration(r):n.get("exaggeration"),!r.projection.requiresDraping&&s&&0===this._exaggeration)return void this._disable();this.enabled=!0;const u=()=>{this.sourceCache.used&&e.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 t=this.getScaledDemTileSize();this.sourceCache.update(r,t,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,u(),this._initializing=!0),u(),r.updateElevation(!0,i),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,i=t.getFreeCameraOptions().position.z/t.pixelsPerMeter*t.worldSize;this._previousCameraAltitude=i;const n=null!=r?i-r:Number.MAX_VALUE;if(Math.abs(n)<2)return this._exaggeration;const o=t.zoom,s=this._style.terrain;if(!this._previousUpdateTimestamp)return s.getExaggeration(o);let a=o-this._previousZoom;const l=this._previousUpdateTimestamp;let c=o;null!=this._evaluationZoom&&(c=this._evaluationZoom,Math.abs(o-c)>.5&&(a=.5*(o-c+a)),a*n<0&&(c+=a)),this._evaluationZoom=c;const u=s.getExaggeration(c),h=u===s.getExaggeration(Math.max(0,c-.1));if(h&&Math.abs(u-this._exaggeration)<.01)return u;let d=Math.min(.1,.00375*(this._updateTimestamp-l));return(h||u<.1||Math.abs(a)<1e-4)&&(d=Math.min(.2,4*d)),e.X(this._exaggeration,u,d)}resetTileLookupCache(e){this._findCoveringTileCache[e]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_onStyleDataEvent(e){e.coord&&"source"===e.dataType?this._clearRenderCacheForTile(e.sourceCacheId,e.coord):"style"===e.dataType&&(this.invalidateRenderCache=!0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this._previousCameraAltitude=void 0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const e in this._style._mergedSourceCaches)this._style._mergedSourceCaches[e].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach((e=>e.fb.destroy())),this.pool=[],this._depthFBO&&(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),this.framebufferCopyTexture&&this.framebufferCopyTexture.destroy()}_source(){return this.enabled?this.sourceCache:null}isUsingMockSource(){return this.sourceCache===this._mockSourceCache}exaggeration(){return this._exaggeration}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const e=2*this.proxySourceCache.getSource().tileSize;return[e,e]}set useVertexMorphing(e){this._useVertexMorphing=e}updateTileBinding(t){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const r=this.proxySourceCache,i=this.painter.transform;this._initializing&&(this._initializing=0===i._centerAltitude&&-1===this.getAtPointOrZero(e.O.fromLngLat(i.center),-1),this._emptyDEMTextureDirty=!this._initializing);const n=this.proxyCoords=r.getIds().map((e=>{const t=r.getTileByID(e).tileID;return t.projMatrix=i.calculateProjMatrix(t.toUnwrapped()),t}));!function(t,r){const i=r.transform.pointCoordinate(r.transform.getCameraPoint()),n=new e.P(i.x,i.y);t.sort(((t,r)=>{if(r.overscaledZ-t.overscaledZ)return r.overscaledZ-t.overscaledZ;const i=new e.P(t.canonical.x+(1<<t.canonical.z)*t.wrap,t.canonical.y),o=new e.P(r.canonical.x+(1<<r.canonical.z)*r.wrap,r.canonical.y),s=n.mult(1<<t.canonical.z);return s.x-=.5,s.y-=.5,s.distSqr(i)-s.distSqr(o)}))}(n,this.painter);const o=this.proxyToSource||{};this.proxyToSource={},n.forEach((e=>{this.proxyToSource[e.key]={}})),this.terrainTileForTile={};const s=this._style._mergedSourceCaches;for(const e in s){const r=s[e];if(!r.used)continue;if(r!==this.sourceCache&&this.resetTileLookupCache(r.id),this._setupProxiedCoordsForOrtho(r,t[e],o),r.usedForTerrain)continue;const i=t[e];r.getSource().reparseOverscaled&&this._assignTerrainTiles(i)}this.proxiedCoords[r.id]=n.map((e=>new pn(e,e.key,this.orthoMatrix))),this._assignTerrainTiles(n),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(o),this.renderingToTexture=!1;const a={};this._visibleDemTiles=[];for(const e of this.proxyCoords){const t=this.terrainTileForTile[e.key];if(!t)continue;const r=t.tileID.key;r in a||(this._visibleDemTiles.push(t),a[r]=r)}}_assignTerrainTiles(e){this._initializing||e.forEach((e=>{if(this.terrainTileForTile[e.key])return;const t=this._findTileCoveringTileID(e,this.sourceCache);t&&(this.terrainTileForTile[e.key]=t)}))}_prepareDEMTextures(){const e=this.painter.context,t=e.gl;for(const r in this.terrainTileForTile){const i=this.terrainTileForTile[r],n=i.dem;!n||i.demTexture&&!i.needsDEMTextureUpload||(e.activeTexture.set(t.TEXTURE1),Ki(this.painter,i,n))}}_prepareDemTileUniforms(e,t,r,i){if(!t||null==t.demTexture)return!1;const n=e.tileID.canonical,o=Math.pow(2,t.tileID.canonical.z-n.z),s=i||"";return r[`u_dem_tl${s}`]=[n.x*o%1,n.y*o%1],r[`u_dem_scale${s}`]=o,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const t=this.painter.context,r=t.gl;if(!this._emptyDepthBufferTexture){const i=new e.h({width:1,height:1},Uint8Array.of(255,255,255,255));this._emptyDepthBufferTexture=new e.T(t,i,r.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let e=0;const t=this._visibleDemTiles.reduce(((t,r)=>{if(!r.dem)return t;const i=r.dem.tree.minimums[0];return i>0&&e++,t+i}),0);return e?t/e:0}_updateEmptyDEMTexture(){const t=this.painter.context,r=t.gl;t.activeTexture.set(r.TEXTURE2);const i=this._getLoadedAreaMinimum(),[n,o]=(()=>{const t=new e.cr({width:1,height:1},new Float32Array([i]));return[r.R32F,t]})();this._emptyDEMTextureDirty=!1;let s=this._emptyDEMTexture;return s?s.update(o,{premultiply:!1}):s=this._emptyDEMTexture=new e.T(t,o,n,{premultiply:!1}),s}setupElevationDraw(t,r,i){const n=this.painter.context,o=n.gl,s={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_exaggeration:0};s.u_exaggeration=this.exaggeration();let a=null,l=null,c=1;if(i&&i.morphing&&this._useVertexMorphing){const e=i.morphing.srcDemTile,r=i.morphing.dstDemTile;c=i.morphing.phase,e&&r&&(this._prepareDemTileUniforms(t,e,s,"_prev")&&(l=e),this._prepareDemTileUniforms(t,r,s)&&(a=r))}const u=e=>e&&e.demTexture&&this.painter.linearFloatFilteringSupported()?o.LINEAR:o.NEAREST,h=e=>{s.u_dem_size=1===e.size[0]?1:e.size[0]-2};if(l&&a)n.activeTexture.set(o.TEXTURE2),a.demTexture.bind(u(a),o.CLAMP_TO_EDGE),n.activeTexture.set(o.TEXTURE4),l.demTexture.bind(u(l),o.CLAMP_TO_EDGE),a.demTexture&&h(a.demTexture),s.u_dem_lerp=c;else{a=this.terrainTileForTile[t.tileID.key],n.activeTexture.set(o.TEXTURE2);const e=this._prepareDemTileUniforms(t,a,s)?a.demTexture:this.emptyDEMTexture;e.bind(u(a),o.CLAMP_TO_EDGE),h(e)}if(n.activeTexture.set(o.TEXTURE3),i&&i.useDepthForOcclusion?(this._depthTexture&&this._depthTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE),this._depthFBO&&(s.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height])):(this.emptyDepthBufferTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE),s.u_depth_size_inv=[1,1]),i&&i.useMeterToDem&&a){const t=(1<<a.tileID.canonical.z)*e.bo(1,this.painter.transform.center.lat)*this.sourceCache.getSource().tileSize;s.u_meter_to_dem=t}if(i&&i.labelPlaneMatrixInv&&(s.u_label_plane_matrix_inv=i.labelPlaneMatrixInv),r.setTerrainUniformValues(n,s),"globe"===this.painter.transform.projection.name){const e=this.globeUniformValues(this.painter.transform,t.tileID.canonical,i&&i.useDenormalizedUpVectorScale);r.setGlobeUniformValues(n,e)}}globeUniformValues(t,r,i){const n=t.projection;return{u_tile_tl_up:n.upVector(r,0,0),u_tile_tr_up:n.upVector(r,e.Y,0),u_tile_br_up:n.upVector(r,e.Y,e.Y),u_tile_bl_up:n.upVector(r,0,e.Y),u_tile_up_scale:i?e.cq(1):n.upVectorScale(r,t.center.lat,t.worldSize).metersToTile}}renderToBackBuffer(t){const r=this.painter,i=this.painter.context;0!==t.length&&(i.bindFramebuffer.set(null),i.viewport.set([0,0,r.width,r.height]),r.gpuTimingDeferredRenderStart(),this.renderingToTexture=!1,function(t,r,i,n,o){if("globe"===t.transform.projection.name)!function(t,r,i,n,o){const s=t.context,a=s.gl;let l,c;const u=t.transform,h=e.ci(t,s,u),d=(e,r)=>{if(c===r)return;const i=[sn[r],"PROJECTION_GLOBE_VIEW"];h&&i.push("CUSTOM_ANTIALIASING");const n=t.isTileAffectedByFog(e);l=t.getOrCreateProgram("globeRaster",{defines:i,overrideFog:n}),c=r},p=t.colorModeForRenderPass(),f=new Et(a.LEQUAL,Et.ReadWrite,t.depthRangeFor3D);on.update(o);const m=e.cj(u),A=[e.a8(u.center.lng),e.ah(u.center.lat)],g=t.globeSharedBuffers,_=[u.width*e.f.devicePixelRatio,u.height*e.f.devicePixelRatio],y=Float32Array.from(u.globeMatrix),x={useDenormalizedUpVectorScale:!0};{const u=t.transform,h=an(u.zoom,r.exaggeration(),r.sourceCache._source.tileSize);c=-1;const v=a.TRIANGLES;for(const c of n){const n=i.getTile(c),b=St.disabled,w=r.prevTerrainTileForTile[c.key],C=r.terrainTileForTile[c.key];nn(w,C)&&on.newMorphing(c.key,w,C,o,250),s.activeTexture.set(a.TEXTURE0),n.texture&&n.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const T=on.getMorphValuesForProxy(c.key),E=T?1:0;T&&e.k(x,{morphing:{srcDemTile:T.from,dstDemTile:T.to,phase:e.ch(T.phase)}});const M=e.ck(c.canonical),S=e.cl(M.getCenter().lat),I=e.cm(c.canonical,M,S,u.worldSize/u._pixelsPerMercatorPixel),P=e.aW(e.cn(c.canonical)),D=rn(u.expandedFarZProjMatrix,y,m,P,e.W(u.zoom),A,u.frustumCorners.TL,u.frustumCorners.TR,u.frustumCorners.BR,u.frustumCorners.BL,u.globeCenterInViewSpace,u.globeRadius,_,h,u._farZ,I);if(d(c,E),l&&(r.setupElevationDraw(n,l,x),t.uploadCommonUniforms(s,l,c.toUnwrapped()),g)){const[e,r,i]=g.getGridBuffers(S,0!==h);l.draw(t,v,f,b,p,Lt.backCCW,D,"globe_raster",e,r,i)}}}if(g&&(t.renderDefaultNorthPole||t.renderDefaultSouthPole)){const o=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];h&&o.push("CUSTOM_ANTIALIASING"),l=t.getOrCreateProgram("globeRaster",{defines:o});for(const o of n){const{x:n,y:c,z:h}=o.canonical,d=0===c,m=c===(1<<h)-1,[y,v,b,w]=g.getPoleBuffers(h,!1);if(w&&(d||m)){const c=i.getTile(o);s.activeTexture.set(a.TEXTURE0),c.texture&&c.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);let g=e.co(h,n,u);const C=e.aW(e.cn(o.canonical)),T=(e,r)=>e.draw(t,a.TRIANGLES,f,St.disabled,p,Lt.disabled,rn(u.expandedFarZProjMatrix,g,g,C,0,A,u.frustumCorners.TL,u.frustumCorners.TR,u.frustumCorners.BR,u.frustumCorners.BL,u.globeCenterInViewSpace,u.globeRadius,_,0,u._farZ),"globe_pole_raster",r,b,w);r.setupElevationDraw(c,l,x),t.uploadCommonUniforms(s,l,o.toUnwrapped()),d&&t.renderDefaultNorthPole&&T(l,y),m&&t.renderDefaultSouthPole&&(g=e.a9.scale(e.a9.create(),g,[1,-1,1]),T(l,v))}}}}(t,r,i,n,o);else{const s=t.context,a=s.gl;let l,c;const u=t.shadowRenderer,h=mi(t,t.longestCutoffRange),d=e=>{if(c===e)return;const r=[];r.push(sn[e]),h.shouldRenderCutoff&&r.push("RENDER_CUTOFF"),l=t.getOrCreateProgram("terrainRaster",{defines:r}),c=e},p=t.colorModeForRenderPass(),f=new Et(a.LEQUAL,Et.ReadWrite,t.depthRangeFor3D);on.update(o);const m=t.transform,A=an(m.zoom,r.exaggeration(),r.sourceCache._source.tileSize);let g=[0,0,0];if(u){const e=t.style.directionalLight,r=t.style.ambientLight;e&&r&&(g=bi(e,r))}{c=-1;const _=a.TRIANGLES,[y,x]=[r.gridIndexBuffer,r.gridSegments];for(const c of n){const n=i.getTile(c),v=St.disabled,b=r.prevTerrainTileForTile[c.key],w=r.terrainTileForTile[c.key];nn(b,w)&&on.newMorphing(c.key,b,w,o,250),s.activeTexture.set(a.TEXTURE0),n.texture&&n.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const C=on.getMorphValuesForProxy(c.key),T=C?1:0;let E;C&&(E={morphing:{srcDemTile:C.from,dstDemTile:C.to,phase:e.ch(C.phase)}});const M=tn(c.projMatrix,ln(c.canonical,m.renderWorldCopies)?A/10:A,g);if(d(T),!l)continue;r.setupElevationDraw(n,l,E);const S=c.toUnwrapped();u&&u.setupShadows(S,l),t.uploadCommonUniforms(s,l,S,null,h),l.draw(t,_,f,v,p,Lt.backCCW,M,"terrain_raster",r.gridBuffer,y,x)}}}}(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,i=this.painter.context,n=this.proxySourceCache,o=this.proxiedCoords[n.id],s=this._drapedRenderBatches.shift(),a=r.style.order,l=[];let c=0;for(const u of o){const o=n.getTileByID(u.proxyTileKey),h=n.proxyCachedFBO[u.key]?n.proxyCachedFBO[u.key][t]:void 0,d=void 0!==h?n.renderCache[h]:this.pool[c++],p=void 0!==h;if(o.texture=d.tex,p&&!d.dirty){l.push(o.tileID);continue}let f;i.bindFramebuffer.set(d.fb.framebuffer),this.renderedToTile=!1,d.dirty&&(i.clear({color:e.aA.transparent,stencil:0}),d.dirty=!1);for(let e=s.start;e<=s.end;++e){const t=r.style._mergedLayers[a[e]];if(t.isHidden(r.transform.zoom))continue;const n=r.style.getLayerSourceCache(t),o=n?this.proxyToSource[u.key][n.id]:[u];if(!o)continue;const s=o;i.viewport.set([0,0,d.fb.width,d.fb.height]),f!==(n?n.id:null)&&(this._setupStencil(d,o,t,n),f=n?n.id:null),r.renderLayer(r,n,t,s)}if(0===this._drapedRenderBatches.length)for(const e of this._pendingGroundEffectLayers){const t=r.style._mergedLayers[a[e]];if(t.isHidden(r.transform.zoom))continue;const n=r.style.getLayerSourceCache(t),o=n?this.proxyToSource[u.key][n.id]:[u];if(!o)continue;const s=o;i.viewport.set([0,0,d.fb.width,d.fb.height]),f!==(n?n.id:null)&&(this._setupStencil(d,o,t,n),f=n?n.id:null),r.renderLayer(r,n,t,s)}this.renderedToTile?(d.dirty=!0,l.push(o.tileID)):p||--c,5===c&&(c=0,this.renderToBackBuffer(l))}return this.renderToBackBuffer(l),this.renderingToTexture=!1,i.bindFramebuffer.set(null),i.viewport.set([0,0,r.width,r.height]),s.end+1}postRender(){}isLayerOrderingCorrect(e){const t=e.order.length;let r=-1,i=t;for(let n=0;n<t;++n)this._style.isLayerDraped(e._mergedLayers[e.order[n]])?r=Math.max(r,n):i=Math.min(i,n);return i>r}getMinElevationBelowMSL(){let e=0;return this._visibleDemTiles.filter((e=>e.dem)).forEach((t=>{e=Math.min(e,t.dem.tree.minimums[0])})),0===e?e:(e-30)*this._exaggeration}raycast(e,t,r){if(!this._visibleDemTiles)return null;const i=this._visibleDemTiles.filter((e=>e.dem)).map((i=>{const n=i.tileID,o=1<<n.overscaledZ,{x:s,y:a}=n.canonical,l=s/o,c=(s+1)/o,u=a/o,h=(a+1)/o;return{minx:l,miny:u,maxx:c,maxy:h,t:i.dem.tree.raycastRoot(l,u,c,h,e,t,r),tile:i}}));i.sort(((e,t)=>(null!==e.t?e.t:Number.MAX_VALUE)-(null!==t.t?t.t:Number.MAX_VALUE)));for(const n of i){if(null==n.t)return null;const i=n.tile.dem.tree.raycast(n.minx,n.miny,n.maxx,n.maxy,e,t,r);if(null!=i)return i}return null}_createFBO(){const t=this.painter.context,r=t.gl,i=this.drapeBufferSize;t.activeTexture.set(r.TEXTURE0);const n=new e.T(t,{width:i[0],height:i[1],data:null},r.RGBA);n.bind(r.LINEAR,r.CLAMP_TO_EDGE);const o=t.createFramebuffer(i[0],i[1],!0,null);return o.colorAttachment.set(n.texture),o.depthAttachment=new Ct(t,o.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=t.createRenderbuffer(t.gl.DEPTH_STENCIL,i[0],i[1]),this._stencilRef=0,o.depthAttachment.set(this._sharedDepthStencil),t.clear({stencil:0})):o.depthAttachment.set(this._sharedDepthStencil),t.extTextureFilterAnisotropic&&r.texParameterf(r.TEXTURE_2D,t.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,t.extTextureFilterAnisotropicMax),{fb:o,tex:n,dirty:!1}}_initFBOPool(){for(;this.pool.length<Math.min(5,this.proxyCoords.length);)this.pool.push(this._createFBO())}_shouldDisableRenderCache(){if(this._debugParams.disableRenderCache)return!0;if(this._style.hasLightTransitions())return!0;for(const e in this._style._mergedSourceCaches)if(this._style._mergedSourceCaches[e].hasTransition())return!0;return this._style.order.some((e=>{const t=this._style._mergedLayers[e],r=t.isHidden(this.painter.transform.zoom);return"custom"===t.type?!r&&t.shouldRedrape():!r&&t.hasTransition()}))}_clearLineLayersFromRenderCache(){let t=!1;for(const e of this._style.getSources())if(e instanceof Ie){t=!0;break}if(!t)return;const r={};for(let t=0;t<this._style.order.length;++t){const i=this._style._mergedLayers[this._style.order[t]],n=this._style.getLayerSourceCache(i);if(n&&!r[n.id]&&!i.isHidden(this.painter.transform.zoom)&&"line"===i.type&&i.widthExpression()instanceof e.Z){r[n.id]=!0;for(const e of this.proxyCoords){const t=this.proxyToSource[e.key][n.id];if(t)for(const e of t)this._clearRenderCacheForTile(n.id,e)}}}}_clearRasterLayersFromRenderCache(){let e=!1;for(const t in this._style._mergedSourceCaches)if(this._style._mergedSourceCaches[t]._source instanceof Pe){e=!0;break}if(!e)return;const t={};for(let e=0;e<this._style.order.length;++e){const r=this._style._mergedLayers[this._style.order[e]],i=this._style.getLayerSourceCache(r);if(!i||t[i.id])continue;if(r.isHidden(this.painter.transform.zoom)||"raster"!==r.type)continue;const n=r.paint.get("raster-fade-duration");for(const e of this.proxyCoords){const t=this.proxyToSource[e.key][i.id];if(t)for(const e of t){const t=un(i.getTile(e),i.findLoadedParent(e,0),i,this.painter.transform,n);(1!==t.opacity||0!==t.mix)&&this._clearRenderCacheForTile(i.id,e)}}}}_setupDrapedRenderBatches(){const t=this._style.order,r=t.length;if(0===r)return;const i=[];this._pendingGroundEffectLayers=[];let n,o=0,s=this._style._mergedLayers[t[o]];for(;!this._style.isLayerDraped(s)&&s.isHidden(this.painter.transform.zoom)&&++o<r;)s=this._style._mergedLayers[t[o]];for(;o<r;++o){const e=this._style._mergedLayers[t[o]];e.isHidden(this.painter.transform.zoom)||(this._style.isLayerDraped(e)?void 0===n&&(n=o):("fill-extrusion"===e.type&&this._pendingGroundEffectLayers.push(o),void 0!==n&&(i.push({start:n,end:o-1}),n=void 0)))}if(void 0!==n&&i.push({start:n,end:o-1}),0!==i.length){const t=i[i.length-1];this._pendingGroundEffectLayers.every((e=>e>t.end))||e.w("fill-extrusion with flood lighting and/or ground ambient occlusion should be moved to be on top of all draped layers.")}this._drapedRenderBatches=i}_setupRenderCache(e){const t=this.proxySourceCache;if(this._shouldDisableRenderCache()||this.invalidateRenderCache){if(this.invalidateRenderCache=!1,t.renderCache.length>t.renderCachePool.length){const e=Object.values(t.proxyCachedFBO);t.proxyCachedFBO={};for(let r=0;r<e.length;++r){const i=Object.values(e[r]);t.renderCachePool.push(...i)}}return}this._clearRasterLayersFromRenderCache();const r=this.proxyCoords,i=this._tilesDirty;for(let n=r.length-1;n>=0;n--){const o=r[n];if(t.getTileByID(o.key),void 0!==t.proxyCachedFBO[o.key]){const r=e[o.key],n=this.proxyToSource[o.key];let s=0;for(const e in n){const t=n[e],o=r[e];if(!o||o.length!==t.length||t.some(((t,r)=>t!==o[r]||i[e]&&i[e].hasOwnProperty(t.key)))){s=-1;break}++s}for(const e in t.proxyCachedFBO[o.key])t.renderCache[t.proxyCachedFBO[o.key][e]].dirty=s<0||s!==Object.values(r).length}}const n=[...this._drapedRenderBatches];n.sort(((e,t)=>t.end-t.start-(e.end-e.start)));for(const e of n)for(const i of r){if(t.proxyCachedFBO[i.key])continue;let r=t.renderCachePool.pop();void 0===r&&t.renderCache.length<50&&(r=t.renderCache.length,t.renderCache.push(this._createFBO())),void 0!==r&&(t.proxyCachedFBO[i.key]={},t.proxyCachedFBO[i.key][e.start]=r,t.renderCache[r].dirty=!0)}this._tilesDirty={}}_setupStencil(e,t,r,i){if(!i||!this._sourceTilesOverlap[i.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const n=this.painter.context,o=n.gl;if(t.length<=1)return void(this._overlapStencilType=!1);let s;if(r.isTileClipped())s=t.length,this._overlapStencilMode.test={func:o.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(t[0].overscaledZ>t[t.length-1].overscaledZ))return void(this._overlapStencilType=!1);s=1,this._overlapStencilMode.test={func:o.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+s>255&&(n.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=s,this._overlapStencilMode.ref=this._stencilRef,r.isTileClipped()&&this._renderTileClippingMasks(t,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return"Clip"===this._overlapStencilType||"Mask"===this._overlapStencilType}stencilModeForRTTOverlap(e){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[e.key]),this._overlapStencilMode):St.disabled}_renderTileClippingMasks(e,t){const r=this.painter,i=this.painter.context,n=i.gl;r._tileClippingMaskIDs={},i.setColorMode(Pt.disabled),i.setDepthMode(Et.disabled);const o=r.getOrCreateProgram("clippingMask");for(const i of e){const e=r._tileClippingMaskIDs[i.key]=--t;o.draw(r,n.TRIANGLES,Et.disabled,new St({func:n.ALWAYS,mask:0},e,255,n.KEEP,n.KEEP,n.REPLACE),Pt.disabled,Lt.disabled,cn(i.projMatrix),"$clipping",r.tileExtentBuffer,r.quadTriangleIndexBuffer,r.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 i=[t.x,t.y,1,1];e.aa.transformMat4(i,i,r.pixelMatrixInverse),e.aa.scale(i,i,1/i[3]),i[0]/=r.worldSize,i[1]/=r.worldSize;const n=r._camera.position,o=e.bo(1,r.center.lat),s=[n[0],n[1],n[2]/o,0],a=e.Q.subtract([],i.slice(0,3),s);e.Q.normalize(a,a);const l=this.raycast(s,a,this._exaggeration);return null!==l&&l?(e.Q.scaleAndAdd(s,s,a,l),s[3]=s[2],s[2]*=o,s):null}drawDepth(){const t=this.painter,r=t.context,i=this.proxySourceCache,n=Math.ceil(t.width),o=Math.ceil(t.height);if(!this._depthFBO||this._depthFBO.width===n&&this._depthFBO.height===o||(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),!this._depthFBO){const t=r.gl,i=r.createFramebuffer(n,o,!0,"renderbuffer");r.activeTexture.set(t.TEXTURE0);const s=new e.T(r,{width:n,height:o,data:null},t.RGBA);s.bind(t.NEAREST,t.CLAMP_TO_EDGE),i.colorAttachment.set(s.texture);const a=r.createRenderbuffer(r.gl.DEPTH_COMPONENT16,n,o);i.depthAttachment.set(a),this._depthFBO=i,this._depthTexture=s}r.bindFramebuffer.set(this._depthFBO.framebuffer),r.viewport.set([0,0,n,o]),function(e,t,r,i){if("globe"===e.transform.projection.name)return;const n=e.context,o=n.gl;n.clear({depth:1});const s=e.getOrCreateProgram("terrainDepth"),a=new Et(o.LESS,Et.ReadWrite,e.depthRangeFor3D);for(const n of i){const i=r.getTile(n),l=tn(n.projMatrix,0,[0,0,0]);t.setupElevationDraw(i,s),s.draw(e,o.TRIANGLES,a,St.disabled,Pt.unblended,Lt.backCCW,l,"terrain_depth",t.gridBuffer,t.gridIndexBuffer,t.gridNoSkirtSegments)}}(t,this,i,this.proxyCoords)}_setupProxiedCoordsForOrtho(t,r,i){if(t.getSource()instanceof e.as)return this._setupProxiedCoordsForImageSource(t,r,i);this._findCoveringTileCache[t.id]=this._findCoveringTileCache[t.id]||{};const n=this.proxiedCoords[t.id]=[],o=this.proxyCoords;for(let e=0;e<o.length;e++){const r=o[e],s=this._findTileCoveringTileID(r,t);if(s){const e=this._createProxiedId(r,s,i[r.key]&&i[r.key][t.id]);n.push(e),this.proxyToSource[r.key][t.id]=[e]}}let s=!1;const a=new Set;for(let e=0;e<r.length;e++){const o=t.getTile(r[e]);if(!o||!o.hasData())continue;const l=this._findTileCoveringTileID(o.tileID,this.proxySourceCache);if(l&&l.tileID.canonical.z!==o.tileID.canonical.z){const e=this.proxyToSource[l.tileID.key][t.id],r=this._createProxiedId(l.tileID,o,i[l.tileID.key]&&i[l.tileID.key][t.id]);e?e.splice(e.length-1,0,r):this.proxyToSource[l.tileID.key][t.id]=[r];const c=this.proxyToSource[l.tileID.key][t.id];a.has(c)||a.add(c),n.push(r),s=!0}}if(this._sourceTilesOverlap[t.id]=s,s&&this._debugParams.sortTilesHiZFirst)for(const e of a)e.sort(((e,t)=>t.overscaledZ-e.overscaledZ))}_setupProxiedCoordsForImageSource(t,r,i){if(!t.getSource().loaded())return;const n=this.proxiedCoords[t.id]=[],o=this.proxyCoords,s=t.getSource(),a=s.tileID;if(!a)return;const l=new e.P(a.x,a.y)._div(1<<a.z),c=s.coordinates.map(e.O.fromLngLat).reduce(((e,t)=>(e.min.x=Math.min(e.min.x,t.x-l.x),e.min.y=Math.min(e.min.y,t.y-l.y),e.max.x=Math.max(e.max.x,t.x-l.x),e.max.y=Math.max(e.max.y,t.y-l.y),e)),{min:new e.P(Number.MAX_VALUE,Number.MAX_VALUE),max:new e.P(-Number.MAX_VALUE,-Number.MAX_VALUE)}),u=(t,r)=>{const i=t.wrap+t.canonical.x/(1<<t.canonical.z),n=t.canonical.y/(1<<t.canonical.z),o=e.Y/(1<<t.canonical.z),s=r.wrap+r.canonical.x/(1<<r.canonical.z),a=r.canonical.y/(1<<r.canonical.z);return i+o<s+c.min.x||i>s+c.max.x||n+o<a+c.min.y||n>a+c.max.y};for(let e=0;e<o.length;e++){const s=o[e];for(let e=0;e<r.length;e++){const o=t.getTile(r[e]);if(!o||!o.hasData())continue;if(u(s,o.tileID))continue;const a=this._createProxiedId(s,o,i[s.key]&&i[s.key][t.id]),l=this.proxyToSource[s.key][t.id];l?l.push(a):this.proxyToSource[s.key][t.id]=[a],n.push(a)}}}_createProxiedId(t,r,i){let n=this.orthoMatrix;if(i){const e=i.find((e=>e.key===r.tileID.key));if(e)return e}if(r.tileID.key!==t.key){const i=t.canonical.z-r.tileID.canonical.z;let o,s,a;n=e.a9.create();const l=r.tileID.wrap-t.wrap<<t.overscaledZ;i>0?(o=e.Y>>i,s=o*((r.tileID.canonical.x<<i)-t.canonical.x+l),a=o*((r.tileID.canonical.y<<i)-t.canonical.y)):(o=e.Y<<-i,s=e.Y*(r.tileID.canonical.x-(t.canonical.x+l<<-i)),a=e.Y*(r.tileID.canonical.y-(t.canonical.y<<-i))),e.a9.ortho(n,0,o,0,o,0,1),e.a9.translate(n,n,[s,a,0])}return new pn(r.tileID,t.key,n)}_findTileCoveringTileID(t,r){let i=r.getTile(t);if(i&&i.hasData())return i;const n=this._findCoveringTileCache[r.id],o=n[t.key];if(i=o?r.getTileByID(o):null,i&&i.hasData()||null===o)return i;let s=i?i.tileID:t,a=s.overscaledZ;const l=r.getSource().minzoom,c=[];if(!o){const n=r.getSource().maxzoom;if(t.canonical.z>=n){const i=t.canonical.z-n;r.getSource().reparseOverscaled?(a=Math.max(t.canonical.z+2,r.transform.tileZoom),s=new e.ap(a,t.wrap,n,t.canonical.x>>i,t.canonical.y>>i)):0!==i&&(a=n,s=new e.ap(a,t.wrap,n,t.canonical.x>>i,t.canonical.y>>i))}s.key!==t.key&&(c.push(s.key),i=r.getTile(s))}const u=e=>{c.forEach((t=>{n[t]=e})),c.length=0};for(a-=1;a>=l&&(!i||!i.hasData());a--){i&&u(i.tileID.key);const e=s.calculateScaledKey(a);if(i=r.getTileByID(e),i&&i.hasData())break;const t=n[e];if(null===t)break;void 0===t?c.push(e):i=r.getTileByID(t)}return u(i?i.tileID.key:null),i&&i.hasData()?i:null}findDEMTileFor(e){return this.enabled?this._findTileCoveringTileID(e,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(e,t){let r=this._tilesDirty[e];r||(r=this._tilesDirty[e]={}),r[t.key]=!0}}function mn(t,r,i){const n=function(t,r,i){const n=e.Q.dot(r,t),o=e.Q.dot(i,[.2126,.7152,.0722]),s=(e,t,r)=>(1-r)*e+r*t,a=s(1-.3*Math.min(o,1),1,Math.min(n+1,1));return s(.92,1,Math.asin(e.ad(r[2],-1,1))/Math.PI+.5)*a}(t,[0,0,1],r),o=[0,0,0];e.Q.scale(o,i.slice(0,3),n);const s=[0,0,0];e.Q.scale(s,r.slice(0,3),t[2]);const a=[0,0,0];return e.Q.add(a,o,s),e.bX(a)}const An=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],gn=["stars","fillExtrusion","fillExtrusionGroundEffect","model","symbolSDF","symbolIcon","symbolTextAndIcon"];class _n{static cacheKey(e,t,r,i){let n=`${t}${i?i.cacheKey:""}`;for(const t of r)e.usedDefines.includes(t)&&(n+=`/${t}`);return n}constructor(t,r,i,n,o,s){const a=t.gl;this.program=a.createProgram(),this.configuration=n,this.name=r,this.fixedDefines=[...s];const l=n?n.getBinderAttributes():[],c=(i.staticAttributes||[]).concat(l);let u=n?n.defines():[];u=u.concat(s.map((e=>`#define ${e}`)));const h="#version 300 es\n";let d=h+u.concat("precision mediump float;",Zi,Gi.fragmentSource).join("\n");for(const e of i.fragmentIncludes)d+=`\n${Ui[e]}`;d+=`\n${i.fragmentSource}`;let p=h+u.concat("precision highp float;",Zi,Gi.vertexSource).join("\n");for(const e of i.vertexIncludes)p+=`\n${Ui[e]}`;p+=`\n${i.vertexSource}`;const f=a.createShader(a.FRAGMENT_SHADER);if(a.isContextLost())return void(this.failedToCreate=!0);a.shaderSource(f,d),a.compileShader(f),a.attachShader(this.program,f);const m=a.createShader(a.VERTEX_SHADER);if(a.isContextLost())this.failedToCreate=!0;else{a.shaderSource(m,p),a.compileShader(m),a.attachShader(this.program,m),this.attributes={},this.numAttributes=c.length;for(let e=0;e<this.numAttributes;e++)if(c[e]){const t=c[e].startsWith("a_")?c[e]:`a_${c[e]}`;a.bindAttribLocation(this.program,e,t),this.attributes[t]=e}a.linkProgram(this.program),a.deleteShader(m),a.deleteShader(f),this.fixedUniforms=o(t),this.binderUniforms=n?n.getUniforms(t):[],s.includes("TERRAIN")&&(this.terrainUniforms=(t=>({u_dem:new e.bR(t),u_dem_prev:new e.bR(t),u_dem_tl:new e.bO(t),u_dem_scale:new e.bQ(t),u_dem_tl_prev:new e.bO(t),u_dem_scale_prev:new e.bQ(t),u_dem_size:new e.bQ(t),u_dem_lerp:new e.bQ(t),u_exaggeration:new e.bQ(t),u_depth:new e.bR(t),u_depth_size_inv:new e.bO(t),u_meter_to_dem:new e.bQ(t),u_label_plane_matrix_inv:new e.bN(t)}))(t)),s.includes("GLOBE")&&(this.globeUniforms=(t=>({u_tile_tl_up:new e.bP(t),u_tile_tr_up:new e.bP(t),u_tile_br_up:new e.bP(t),u_tile_bl_up:new e.bP(t),u_tile_up_scale:new e.bQ(t)}))(t)),s.includes("FOG")&&(this.fogUniforms=(t=>({u_fog_matrix:new e.bN(t),u_fog_range:new e.bO(t),u_fog_color:new e.bS(t),u_fog_horizon_blend:new e.bQ(t),u_fog_vertical_limit:new e.bO(t),u_fog_temporal_offset:new e.bQ(t),u_frustum_tl:new e.bP(t),u_frustum_tr:new e.bP(t),u_frustum_br:new e.bP(t),u_frustum_bl:new e.bP(t),u_globe_pos:new e.bP(t),u_globe_radius:new e.bQ(t),u_globe_transition:new e.bQ(t),u_is_globe:new e.bR(t),u_viewport:new e.bO(t)}))(t)),s.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(t=>({u_cutoff_params:new e.bS(t)}))(t)),s.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(t=>({u_lighting_ambient_color:new e.bP(t),u_lighting_directional_dir:new e.bP(t),u_lighting_directional_color:new e.bP(t),u_ground_radiance:new e.bP(t)}))(t)),s.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(t=>({u_light_matrix_0:new e.bN(t),u_light_matrix_1:new e.bN(t),u_fade_range:new e.bO(t),u_shadow_normal_offset:new e.bP(t),u_shadow_intensity:new e.bQ(t),u_shadow_texel_size:new e.bQ(t),u_shadow_map_resolution:new e.bQ(t),u_shadow_direction:new e.bP(t),u_shadow_bias:new e.bP(t),u_shadowmap_0:new e.bR(t),u_shadowmap_1:new e.bR(t)}))(t))}}setTerrainUniformValues(e,t){if(!this.terrainUniforms)return;const r=this.terrainUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)r[e]&&r[e].set(this.program,e,t[e])}}setGlobeUniformValues(e,t){if(!this.globeUniforms)return;const r=this.globeUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)r[e]&&r[e].set(this.program,e,t[e])}}setFogUniformValues(e,t){if(!this.fogUniforms)return;const r=this.fogUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)r[e].set(this.program,e,t[e])}}setCutoffUniformValues(e,t){if(!this.cutoffUniforms)return;const r=this.cutoffUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)r[e].set(this.program,e,t[e])}}setLightsUniformValues(e,t){if(!this.lightsUniforms)return;const r=this.lightsUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)r[e].set(this.program,e,t[e])}}setShadowUniformValues(e,t){if(this.failedToCreate||!this.shadowUniforms)return;const r=this.shadowUniforms;e.program.set(this.program);for(const e in t)r[e].set(this.program,e,t[e])}_drawDebugWireframe(t,r,i,n,o,s,a,l,c,u){const h=t.options.wireframe;if(!1===h.terrain&&!1===h.layers2D&&!1===h.layers3D)return;const d=t.context;if(!(()=>!(!h.terrain||"terrainRaster"!==this.name&&"globeRaster"!==this.name)||!(!h.layers2D||t._terrain&&t._terrain.renderingToTexture||!An.includes(this.name))||!(!h.layers3D||!gn.includes(this.name)))())return;const p=d.gl,f=t.wireframeDebugCache.getLinesFromTrianglesBuffer(t.frameCounter,o,d);if(!f)return;const m=[...this.fixedDefines];m.push("DEBUG_WIREFRAME");const A=t.getOrCreateProgram(this.name,{config:this.configuration,defines:m});d.program.set(A.program);const g=(e,t,r)=>{if(t[e]&&r[e])for(const i in t[e])r[e][i]&&r[e][i].set(r.program,i,t[e][i].current)};c&&c.setUniforms(A.program,d,A.binderUniforms,a,{zoom:l}),g("fixedUniforms",this,A),g("terrainUniforms",this,A),g("globeUniforms",this,A),g("fogUniforms",this,A),g("lightsUniforms",this,A),g("shadowUniforms",this,A),f.bind(),d.setColorMode(new Pt([p.ONE,p.ONE_MINUS_SRC_ALPHA,p.ZERO,p.ONE],e.aA.transparent,[!0,!0,!0,!1])),d.setDepthMode(new Et(r.func===p.LESS?p.LEQUAL:r.func,Et.ReadOnly,r.range)),d.setStencilMode(St.disabled);const _=3*s.primitiveLength*2,y=3*s.primitiveOffset*2*2;u&&u>1?p.drawElementsInstanced(p.LINES,_,p.UNSIGNED_SHORT,y,u):p.drawElements(p.LINES,_,p.UNSIGNED_SHORT,y),o.bind(),d.program.set(this.program),d.setDepthMode(r),d.setStencilMode(i),d.setColorMode(n)}draw(e,t,r,i,n,o,s,a,l,c,u,h,d,p,f,m){const A=e.context,g=A.gl;if(this.failedToCreate)return;A.program.set(this.program),A.setDepthMode(r),A.setStencilMode(i),A.setColorMode(n),A.setCullFace(o);for(const e of Object.keys(this.fixedUniforms))this.fixedUniforms[e].set(this.program,e,s[e]);p&&p.setUniforms(this.program,A,this.binderUniforms,h,{zoom:d});const _={[g.POINTS]:1,[g.LINES]:2,[g.TRIANGLES]:3,[g.LINE_STRIP]:1}[t],y=m&&m>0?1:void 0;for(const o of u.get()){const s=o.vaos||(o.vaos={});(s[a]||(s[a]=new Xi)).bind(A,this,l,p?p.getPaintVertexBuffers():[],c,o.vertexOffset,f||[],y),m&&m>1?g.drawElementsInstanced(t,o.primitiveLength*_,g.UNSIGNED_SHORT,o.primitiveOffset*_*2,m):c?g.drawElements(t,o.primitiveLength*_,g.UNSIGNED_SHORT,o.primitiveOffset*_*2):g.drawArrays(t,o.vertexOffset,o.vertexLength),t===g.TRIANGLES&&c&&this._drawDebugWireframe(e,r,i,n,c,o,h,d,p,m)}}}function yn(t,r){const i=Math.pow(2,r.tileID.overscaledZ),n=r.tileSize*Math.pow(2,t.transform.tileZoom)/i,o=n*(r.tileID.canonical.x+r.tileID.wrap*i),s=n*r.tileID.canonical.y;return{u_image:0,u_texsize:r.imageAtlasTexture?r.imageAtlasTexture.size:[0,0],u_tile_units_to_pixels:1/e.a6(r,1,t.transform.tileZoom),u_pixel_coord_upper:[o>>16,s>>16],u_pixel_coord_lower:[65535&o,65535&s]}}const xn=e.a9.create(),vn=(t,r,i,n,o,s,a,l,c,u,h,d,p,f,m,A)=>{const g=r.style.light,_=g.properties.get("position"),y=[_.x,_.y,_.z],x=e.ct.create();"viewport"===g.properties.get("anchor")&&(e.ct.fromRotation(x,-r.transform.angle),e.Q.transformMat3(y,y,x));const v=g.properties.get("color"),b=r.transform,w={u_matrix:t,u_lightpos:y,u_lightintensity:g.properties.get("intensity"),u_lightcolor:[v.r,v.g,v.b],u_vertical_gradient:+i,u_opacity:n,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:xn,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_ao:o,u_edge_radius:s,u_flood_light_color:d,u_vertical_scale:p,u_flood_light_intensity:f,u_ground_shadow_factor:m,u_emissive_strength:A};return"globe"===b.projection.name&&(w.u_tile_id=[a.canonical.x,a.canonical.y,1<<a.canonical.z],w.u_zoom_transition=c,w.u_inv_rot_matrix=h,w.u_merc_center=u,w.u_up_dir=b.projection.upVector(new e.bv(0,0,0),u[0]*e.Y,u[1]*e.Y),w.u_height_lift=l),w},bn=(e,t,r)=>({u_matrix:e,u_edge_radius:t,u_vertical_scale:r}),wn=(t,r,i,n,o,s,a,l,c,u,h,d,p,f)=>{const m=vn(t,r,i,n,o,s,a,c,u,h,d,p,f,1,[0,0,0],0),A={u_height_factor:-Math.pow(2,a.overscaledZ)/l.tileSize/8};return e.e(m,yn(r,l),A)},Cn=(e,t)=>({u_matrix:e,u_emissive_strength:t}),Tn=(t,r,i,n)=>e.e(Cn(t,r),yn(i,n)),En=(e,t,r)=>({u_matrix:e,u_world:r,u_emissive_strength:t}),Mn=(t,r,i,n,o)=>e.e(Tn(t,r,i,n),{u_world:o}),Sn=(t,r,i,n)=>{const o=e.Y/i.tileSize;return{u_matrix:t,u_camera_to_center_distance:r.getCameraToCenterDistance(n),u_extrude_scale:[r.pixelsToGLUnits[0]/o,r.pixelsToGLUnits[1]/o]}},In=(e,t,r=1)=>({u_matrix:e,u_color:t,u_overlay:0,u_overlay_scale:r}),Pn=e.a9.create(),Dn=(t,r,i,n,o,s,a)=>{const l=t.transform,c="globe"===l.projection.name,u=c?e.cu(l.zoom,r.canonical)*l._pixelsPerMercatorPixel:e.a6(i,1,s),h={u_matrix:r.projMatrix,u_extrude_scale:u,u_intensity:a,u_inv_rot_matrix:Pn,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(c){h.u_inv_rot_matrix=n,h.u_merc_center=o,h.u_tile_id=[r.canonical.x,r.canonical.y,1<<r.canonical.z],h.u_zoom_transition=e.W(l.zoom);const t=o[0]*e.Y,i=o[1]*e.Y;h.u_up_dir=l.projection.upVector(new e.bv(0,0,0),t,i)}return h};function kn(e,[t,r,i,n],[o,s]){if(o===s)return[0,0,0,0];const a=255*(e-1)/(e*(s-o));return[t*a,r*a,i*a,n*a]}function Ln(e,t,[r,i]){return r===i?0:.5/e+(t-r)*(e-1)/(e*(i-r))}const zn=(t,r,i,n,o,s,a,l,c,u,h,d,p,f,m,A,g,_,y,x,v)=>({u_matrix:t,u_normalize_matrix:r,u_globe_matrix:i,u_merc_matrix:n,u_grid_matrix:o,u_tl_parent:s,u_scale_parent:u,u_fade_t:h.mix,u_opacity:h.opacity*d.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:d.paint.get("raster-brightness-min"),u_brightness_high:d.paint.get("raster-brightness-max"),u_saturation_factor:e.cv(d.paint.get("raster-saturation")),u_contrast_factor:e.cw(d.paint.get("raster-contrast")),u_spin_weights:On(d.paint.get("raster-hue-rotate")),u_perspective_transform:p,u_raster_elevation:f,u_zoom_transition:a,u_merc_center:l,u_cutoff_params:c,u_colorization_mix:kn(e.cx,A,_),u_colorization_offset:Ln(e.cx,g,_),u_color_ramp:m,u_texture_offset:[x/(y+2*x),y/(y+2*x)],u_texture_res:[y+2*x,y+2*x],u_emissive_strength:v});function On(e){e*=Math.PI/180;const t=Math.sin(e),r=Math.cos(e);return[(2*r+1)/3,(-Math.sqrt(3)*t-r+1)/3,(Math.sqrt(3)*t-r+1)/3]}const Bn=(e,t,r,i,n,o,s,a,l,c,u,h)=>({u_matrix:e,u_normalize_matrix:t,u_globe_matrix:r,u_merc_matrix:i,u_grid_matrix:n,u_tl_parent:o,u_scale_parent:c,u_fade_t:u.mix,u_opacity:u.opacity,u_image0:0,u_image1:1,u_raster_elevation:h,u_zoom_transition:s,u_merc_center:a,u_cutoff_params:l}),Rn=(e,t,r,i,n,o,s,a,l,c)=>({u_particle_texture:e,u_particle_texture_side_len:t,u_tile_offset:r,u_velocity:i,u_color_ramp:o,u_velocity_res:n,u_max_speed:s,u_uv_offset:a,u_data_scale:l,u_data_offset:c,u_particle_pos_scale:1.3,u_particle_pos_offset:[Bt,Bt]}),Fn=(e,t,r,i,n,o,s,a,l,c)=>({u_particle_texture:e,u_particle_texture_side_len:t,u_velocity:r,u_velocity_res:i,u_max_speed:n,u_speed_factor:o,u_reset_rate:s,u_rand_seed:Math.random(),u_uv_offset:a,u_data_scale:l,u_data_offset:c,u_particle_pos_scale:1.3,u_particle_pos_offset:[Bt,Bt]}),jn=e.a9.create(),Vn=(t,r,i,n,o,s,a,l,c,u,h,d,p,f,m,A,g,_)=>{const y=o.transform,x={u_is_size_zoom_constant:+("constant"===t||"source"===t),u_is_size_feature_constant:+("constant"===t||"camera"===t),u_size_t:r?r.uSizeT:0,u_size:r?r.uSize:0,u_camera_to_center_distance:y.getCameraToCenterDistance(A),u_rotate_symbol:+i,u_aspect_ratio:y.width/y.height,u_fade_change:o.options.fadeDuration?o.symbolFadeChange:1,u_matrix:s,u_label_plane_matrix:a,u_coord_matrix:l,u_is_text:+c,u_pitch_with_map:+n,u_texsize:u,u_texture:0,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:jn,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:jn,u_up_vector:[0,-1,0],u_color_adj_mat:g,u_icon_transition:_||0};return"globe"===A.name&&(x.u_tile_id=[h.canonical.x,h.canonical.y,1<<h.canonical.z],x.u_zoom_transition=d,x.u_inv_rot_matrix=f,x.u_merc_center=p,x.u_camera_forward=y._camera.forward(),x.u_ecef_origin=e.cy(y.globeMatrix,h.toUnwrapped()),x.u_tile_matrix=Float32Array.from(y.globeMatrix),x.u_up_vector=m),x},Nn=(t,r,i,n,o,s,a,l,c,u,h,d,p,f,m,A,g)=>e.e(Vn(t,r,i,n,o,s,a,l,c,u,d,p,f,m,A,g),{u_gamma_scale:n?o.transform.getCameraToCenterDistance(g)*Math.cos(o.terrain?0:o.transform._pitch):1,u_device_pixel_ratio:e.f.devicePixelRatio,u_is_halo:+h,undefined:void 0}),Un=(t,r,i,n,o,s,a,l,c,u,h,d,p,f,m,A)=>e.e(Nn(t,r,i,n,o,s,a,l,!0,c,!0,h,d,p,f,m,A),{u_texsize_icon:u,u_texture_icon:1}),Hn=(e,t,r,i)=>({u_matrix:e,u_emissive_strength:t,u_opacity:r,u_color:i}),Gn=(t,r,i,n,o,s,a)=>e.e(function(t,r,i,n){const o=i.imageManager.getPattern(t.toString(),r),{width:s,height:a}=i.imageManager.getPixelSize(r),l=Math.pow(2,n.tileID.overscaledZ),c=n.tileSize*Math.pow(2,i.transform.tileZoom)/l,u=c*(n.tileID.canonical.x+n.tileID.wrap*l),h=c*n.tileID.canonical.y;return{u_image:0,u_pattern_tl:o.tl,u_pattern_br:o.br,u_texsize:[s,a],u_pattern_size:o.displaySize,u_tile_units_to_pixels:1/e.a6(n,1,i.transform.tileZoom),u_pixel_coord_upper:[u>>16,h>>16],u_pixel_coord_lower:[65535&u,65535&h]}}(o,s,n,a),{u_matrix:t,u_emissive_strength:r,u_opacity:i}),Zn=new Float32Array(e.a9.identity([])),Wn=(t,r,i,n,o,s,a,l,c,u,h,d,p,f=[0,0,0],m)=>{const A=o.style.light,g=A.properties.get("position"),_=[-g.x,-g.y,g.z],y=e.ct.create();"viewport"===A.properties.get("anchor")&&(e.ct.fromRotation(y,-o.transform.angle),e.Q.transformMat3(_,_,y));const x="MASK"===h.alphaMode,v=A.properties.get("color"),b=p.paint.get("model-ambient-occlusion-intensity"),w=p.paint.get("model-color").constantOr(e.aA.white),C=p.paint.get("model-color-mix-intensity").constantOr(0);return{u_matrix:t,u_lighting_matrix:r,u_normal_matrix:i,u_node_matrix:n||Zn,u_lightpos:_,u_lightintensity:A.properties.get("intensity"),u_lightcolor:[v.r,v.g,v.b],u_camera_pos:f,u_opacity:s,u_baseTextureIsAlpha:0,u_alphaMask:+x,u_alphaCutoff:h.alphaCutoff,u_baseColorFactor:[a.r,a.g,a.b,a.a],u_emissiveFactor:[l[0],l[1],l[2],1],u_metallicFactor:c,u_roughnessFactor:u,u_baseColorTexture:fi.BaseColor,u_metallicRoughnessTexture:fi.MetallicRoughness,u_normalTexture:fi.Normal,u_occlusionTexture:fi.Occlusion,u_emissionTexture:fi.Emission,u_color_mix:[w.r,w.g,w.b,C],u_aoIntensity:b,u_emissive_strength:d,u_occlusionTextureTransform:m||[0,0,0,0]}},Qn=(e,t=Zn,r=Zn)=>({u_matrix:e,u_instance:t,u_node_matrix:r}),qn={fillExtrusion:t=>({u_matrix:new e.bN(t),u_lightpos:new e.bP(t),u_lightintensity:new e.bQ(t),u_lightcolor:new e.bP(t),u_vertical_gradient:new e.bQ(t),u_opacity:new e.bQ(t),u_edge_radius:new e.bQ(t),u_ao:new e.bO(t),u_tile_id:new e.bP(t),u_zoom_transition:new e.bQ(t),u_inv_rot_matrix:new e.bN(t),u_merc_center:new e.bO(t),u_up_dir:new e.bP(t),u_height_lift:new e.bQ(t),u_flood_light_color:new e.bP(t),u_vertical_scale:new e.bQ(t),u_flood_light_intensity:new e.bQ(t),u_ground_shadow_factor:new e.bP(t),u_emissive_strength:new e.bQ(t)}),fillExtrusionDepth:t=>({u_matrix:new e.bN(t),u_edge_radius:new e.bQ(t),u_vertical_scale:new e.bQ(t)}),fillExtrusionPattern:t=>({u_matrix:new e.bN(t),u_lightpos:new e.bP(t),u_lightintensity:new e.bQ(t),u_lightcolor:new e.bP(t),u_vertical_gradient:new e.bQ(t),u_height_factor:new e.bQ(t),u_edge_radius:new e.bQ(t),u_ao:new e.bO(t),u_tile_id:new e.bP(t),u_zoom_transition:new e.bQ(t),u_inv_rot_matrix:new e.bN(t),u_merc_center:new e.bO(t),u_up_dir:new e.bP(t),u_height_lift:new e.bQ(t),u_image:new e.bR(t),u_texsize:new e.bO(t),u_pixel_coord_upper:new e.bO(t),u_pixel_coord_lower:new e.bO(t),u_tile_units_to_pixels:new e.bQ(t),u_opacity:new e.bQ(t)}),fillExtrusionGroundEffect:t=>({u_matrix:new e.bN(t),u_opacity:new e.bQ(t),u_ao_pass:new e.bQ(t),u_meter_to_tile:new e.bQ(t),u_ao:new e.bO(t),u_flood_light_intensity:new e.bQ(t),u_flood_light_color:new e.bP(t),u_attenuation:new e.bQ(t),u_edge_radius:new e.bQ(t),u_fb:new e.bR(t),u_fb_size:new e.bQ(t)}),fill:t=>({u_matrix:new e.bN(t),u_emissive_strength:new e.bQ(t)}),fillPattern:t=>({u_matrix:new e.bN(t),u_emissive_strength:new e.bQ(t),u_image:new e.bR(t),u_texsize:new e.bO(t),u_pixel_coord_upper:new e.bO(t),u_pixel_coord_lower:new e.bO(t),u_tile_units_to_pixels:new e.bQ(t)}),fillOutline:t=>({u_matrix:new e.bN(t),u_emissive_strength:new e.bQ(t),u_world:new e.bO(t)}),fillOutlinePattern:t=>({u_matrix:new e.bN(t),u_emissive_strength:new e.bQ(t),u_world:new e.bO(t),u_image:new e.bR(t),u_texsize:new e.bO(t),u_pixel_coord_upper:new e.bO(t),u_pixel_coord_lower:new e.bO(t),u_tile_units_to_pixels:new e.bQ(t)}),circle:e.cz,collisionBox:t=>({u_matrix:new e.bN(t),u_camera_to_center_distance:new e.bQ(t),u_extrude_scale:new e.bO(t)}),collisionCircle:t=>({u_matrix:new e.bN(t),u_inv_matrix:new e.bN(t),u_camera_to_center_distance:new e.bQ(t),u_viewport_size:new e.bO(t)}),debug:t=>({u_color:new e.cf(t),u_matrix:new e.bN(t),u_overlay:new e.bR(t),u_overlay_scale:new e.bQ(t)}),clippingMask:t=>({u_matrix:new e.bN(t)}),heatmap:t=>({u_extrude_scale:new e.bQ(t),u_intensity:new e.bQ(t),u_matrix:new e.bN(t),u_inv_rot_matrix:new e.bN(t),u_merc_center:new e.bO(t),u_tile_id:new e.bP(t),u_zoom_transition:new e.bQ(t),u_up_dir:new e.bP(t)}),heatmapTexture:t=>({u_image:new e.bR(t),u_color_ramp:new e.bR(t),u_opacity:new e.bQ(t)}),hillshade:t=>({u_matrix:new e.bN(t),u_image:new e.bR(t),u_latrange:new e.bO(t),u_light:new e.bO(t),u_shadow:new e.cf(t),u_highlight:new e.cf(t),u_emissive_strength:new e.bQ(t),u_accent:new e.cf(t)}),hillshadePrepare:t=>({u_matrix:new e.bN(t),u_image:new e.bR(t),u_dimension:new e.bO(t),u_zoom:new e.bQ(t)}),line:e.cA,linePattern:e.cB,raster:t=>({u_matrix:new e.bN(t),u_normalize_matrix:new e.bN(t),u_globe_matrix:new e.bN(t),u_merc_matrix:new e.bN(t),u_grid_matrix:new e.cg(t),u_tl_parent:new e.bO(t),u_scale_parent:new e.bQ(t),u_fade_t:new e.bQ(t),u_opacity:new e.bQ(t),u_image0:new e.bR(t),u_image1:new e.bR(t),u_brightness_low:new e.bQ(t),u_brightness_high:new e.bQ(t),u_saturation_factor:new e.bQ(t),u_contrast_factor:new e.bQ(t),u_spin_weights:new e.bP(t),u_perspective_transform:new e.bO(t),u_raster_elevation:new e.bQ(t),u_zoom_transition:new e.bQ(t),u_merc_center:new e.bO(t),u_cutoff_params:new e.bS(t),u_colorization_mix:new e.bS(t),u_colorization_offset:new e.bQ(t),u_color_ramp:new e.bR(t),u_texture_offset:new e.bO(t),u_texture_res:new e.bO(t),u_emissive_strength:new e.bQ(t)}),rasterParticle:t=>({u_matrix:new e.bN(t),u_normalize_matrix:new e.bN(t),u_globe_matrix:new e.bN(t),u_merc_matrix:new e.bN(t),u_grid_matrix:new e.cg(t),u_tl_parent:new e.bO(t),u_scale_parent:new e.bQ(t),u_fade_t:new e.bQ(t),u_opacity:new e.bQ(t),u_image0:new e.bR(t),u_image1:new e.bR(t),u_raster_elevation:new e.bQ(t),u_zoom_transition:new e.bQ(t),u_merc_center:new e.bO(t),u_cutoff_params:new e.bS(t)}),rasterParticleTexture:t=>({u_texture:new e.bR(t),u_opacity:new e.bQ(t)}),rasterParticleDraw:t=>({u_particle_texture:new e.bR(t),u_particle_texture_side_len:new e.bQ(t),u_tile_offset:new e.bO(t),u_velocity:new e.bR(t),u_color_ramp:new e.bR(t),u_velocity_res:new e.bO(t),u_max_speed:new e.bQ(t),u_uv_offset:new e.bO(t),u_data_scale:new e.bS(t),u_data_offset:new e.bQ(t),u_particle_pos_scale:new e.bQ(t),u_particle_pos_offset:new e.bO(t)}),rasterParticleUpdate:t=>({u_particle_texture:new e.bR(t),u_particle_texture_side_len:new e.bQ(t),u_velocity:new e.bR(t),u_velocity_res:new e.bO(t),u_max_speed:new e.bQ(t),u_speed_factor:new e.bQ(t),u_reset_rate:new e.bQ(t),u_rand_seed:new e.bQ(t),u_uv_offset:new e.bO(t),u_data_scale:new e.bS(t),u_data_offset:new e.bQ(t),u_particle_pos_scale:new e.bQ(t),u_particle_pos_offset:new e.bO(t)}),symbolIcon:t=>({u_is_size_zoom_constant:new e.bR(t),u_is_size_feature_constant:new e.bR(t),u_size_t:new e.bQ(t),u_size:new e.bQ(t),u_camera_to_center_distance:new e.bQ(t),u_rotate_symbol:new e.bR(t),u_aspect_ratio:new e.bQ(t),u_fade_change:new e.bQ(t),u_matrix:new e.bN(t),u_label_plane_matrix:new e.bN(t),u_coord_matrix:new e.bN(t),u_is_text:new e.bR(t),u_pitch_with_map:new e.bR(t),u_texsize:new e.bO(t),u_tile_id:new e.bP(t),u_zoom_transition:new e.bQ(t),u_inv_rot_matrix:new e.bN(t),u_merc_center:new e.bO(t),u_camera_forward:new e.bP(t),u_tile_matrix:new e.bN(t),u_up_vector:new e.bP(t),u_ecef_origin:new e.bP(t),u_texture:new e.bR(t),u_icon_transition:new e.bQ(t),u_color_adj_mat:new e.bN(t)}),symbolSDF:t=>({u_is_size_zoom_constant:new e.bR(t),u_is_size_feature_constant:new e.bR(t),u_size_t:new e.bQ(t),u_size:new e.bQ(t),u_camera_to_center_distance:new e.bQ(t),u_rotate_symbol:new e.bR(t),u_aspect_ratio:new e.bQ(t),u_fade_change:new e.bQ(t),u_matrix:new e.bN(t),u_label_plane_matrix:new e.bN(t),u_coord_matrix:new e.bN(t),u_is_text:new e.bR(t),u_pitch_with_map:new e.bR(t),u_texsize:new e.bO(t),u_texture:new e.bR(t),u_gamma_scale:new e.bQ(t),u_device_pixel_ratio:new e.bQ(t),u_tile_id:new e.bP(t),u_zoom_transition:new e.bQ(t),u_inv_rot_matrix:new e.bN(t),u_merc_center:new e.bO(t),u_camera_forward:new e.bP(t),u_tile_matrix:new e.bN(t),u_up_vector:new e.bP(t),u_ecef_origin:new e.bP(t),u_is_halo:new e.bR(t)}),symbolTextAndIcon:t=>({u_is_size_zoom_constant:new e.bR(t),u_is_size_feature_constant:new e.bR(t),u_size_t:new e.bQ(t),u_size:new e.bQ(t),u_camera_to_center_distance:new e.bQ(t),u_rotate_symbol:new e.bR(t),u_aspect_ratio:new e.bQ(t),u_fade_change:new e.bQ(t),u_matrix:new e.bN(t),u_label_plane_matrix:new e.bN(t),u_coord_matrix:new e.bN(t),u_is_text:new e.bR(t),u_pitch_with_map:new e.bR(t),u_texsize:new e.bO(t),u_texsize_icon:new e.bO(t),u_texture:new e.bR(t),u_texture_icon:new e.bR(t),u_gamma_scale:new e.bQ(t),u_device_pixel_ratio:new e.bQ(t),u_is_halo:new e.bR(t)}),background:t=>({u_matrix:new e.bN(t),u_emissive_strength:new e.bQ(t),u_opacity:new e.bQ(t),u_color:new e.cf(t)}),backgroundPattern:t=>({u_matrix:new e.bN(t),u_emissive_strength:new e.bQ(t),u_opacity:new e.bQ(t),u_image:new e.bR(t),u_pattern_tl:new e.bO(t),u_pattern_br:new e.bO(t),u_texsize:new e.bO(t),u_pattern_size:new e.bO(t),u_pixel_coord_upper:new e.bO(t),u_pixel_coord_lower:new e.bO(t),u_tile_units_to_pixels:new e.bQ(t)}),terrainRaster:en,terrainDepth:en,skybox:t=>({u_matrix:new e.bN(t),u_sun_direction:new e.bP(t),u_cubemap:new e.bR(t),u_opacity:new e.bQ(t),u_temporal_offset:new e.bQ(t)}),skyboxGradient:t=>({u_matrix:new e.bN(t),u_color_ramp:new e.bR(t),u_center_direction:new e.bP(t),u_radius:new e.bQ(t),u_opacity:new e.bQ(t),u_temporal_offset:new e.bQ(t)}),skyboxCapture:t=>({u_matrix_3f:new e.cg(t),u_sun_direction:new e.bP(t),u_sun_intensity:new e.bQ(t),u_color_tint_r:new e.bS(t),u_color_tint_m:new e.bS(t),u_luminance:new e.bQ(t)}),globeRaster:t=>({u_proj_matrix:new e.bN(t),u_globe_matrix:new e.bN(t),u_normalize_matrix:new e.bN(t),u_merc_matrix:new e.bN(t),u_zoom_transition:new e.bQ(t),u_merc_center:new e.bO(t),u_image0:new e.bR(t),u_grid_matrix:new e.cg(t),u_skirt_height:new e.bQ(t),u_far_z_cutoff:new e.bQ(t),u_frustum_tl:new e.bP(t),u_frustum_tr:new e.bP(t),u_frustum_br:new e.bP(t),u_frustum_bl:new e.bP(t),u_globe_pos:new e.bP(t),u_globe_radius:new e.bQ(t),u_viewport:new e.bO(t)}),globeAtmosphere:t=>({u_frustum_tl:new e.bP(t),u_frustum_tr:new e.bP(t),u_frustum_br:new e.bP(t),u_frustum_bl:new e.bP(t),u_horizon:new e.bQ(t),u_transition:new e.bQ(t),u_fadeout_range:new e.bQ(t),u_color:new e.bS(t),u_high_color:new e.bS(t),u_space_color:new e.bS(t),u_temporal_offset:new e.bQ(t),u_horizon_angle:new e.bQ(t)}),model:t=>({u_matrix:new e.bN(t),u_lighting_matrix:new e.bN(t),u_normal_matrix:new e.bN(t),u_node_matrix:new e.bN(t),u_lightpos:new e.bP(t),u_lightintensity:new e.bQ(t),u_lightcolor:new e.bP(t),u_camera_pos:new e.bP(t),u_opacity:new e.bQ(t),u_baseColorFactor:new e.bS(t),u_emissiveFactor:new e.bS(t),u_metallicFactor:new e.bQ(t),u_roughnessFactor:new e.bQ(t),u_baseTextureIsAlpha:new e.bR(t),u_alphaMask:new e.bR(t),u_alphaCutoff:new e.bQ(t),u_baseColorTexture:new e.bR(t),u_metallicRoughnessTexture:new e.bR(t),u_normalTexture:new e.bR(t),u_occlusionTexture:new e.bR(t),u_emissionTexture:new e.bR(t),u_color_mix:new e.bS(t),u_aoIntensity:new e.bQ(t),u_emissive_strength:new e.bQ(t),u_occlusionTextureTransform:new e.bS(t)}),modelDepth:t=>({u_matrix:new e.bN(t),u_instance:new e.bN(t),u_node_matrix:new e.bN(t)}),groundShadow:t=>({u_matrix:new e.bN(t),u_ground_shadow_factor:new e.bP(t)}),stars:t=>({u_matrix:new e.bN(t),u_up:new e.bP(t),u_right:new e.bP(t),u_intensity_multiplier:new e.bQ(t)})};let Xn;function Yn(t,r,i,n,o,s,a){const l=t.context,c=l.gl,u=t.transform,h=t.getOrCreateProgram("collisionBox"),d=[];let p=0,f=0;for(let l=0;l<n.length;l++){const m=n[l],A=r.getTile(m),g=A.getBucket(i);if(!g)continue;const _=Dr(m,g,u);let y=_;0===o[0]&&0===o[1]||(y=t.translatePosMatrix(_,A,o,s));const x=a?g.textCollisionBox:g.iconCollisionBox,v=g.collisionCircleArray;if(v.length>0){const t=e.a9.create(),r=y;e.a9.mul(t,g.placementInvProjMatrix,u.glCoordMatrix),e.a9.mul(t,t,g.placementViewportMatrix),d.push({circleArray:v,circleOffset:f,transform:r,invTransform:t,projection:g.getProjection()}),p+=v.length/4,f=p}x&&(t.terrain&&t.terrain.setupElevationDraw(A,h),h.draw(t,c.LINES,Et.disabled,St.disabled,t.colorModeForRenderPass(),Lt.disabled,Sn(y,u,A,g.getProjection()),i.id,x.layoutVertexBuffer,x.indexBuffer,x.segments,null,u.zoom,null,[x.collisionVertexBuffer,x.collisionVertexBufferExt]))}if(!a||!d.length)return;const m=t.getOrCreateProgram("collisionCircle"),A=new e.cC;A.resize(4*p),A._trim();let g=0;for(const e of d)for(let t=0;t<e.circleArray.length/4;t++){const r=4*t,i=e.circleArray[r+0],n=e.circleArray[r+1],o=e.circleArray[r+2],s=e.circleArray[r+3];A.emplace(g++,i,n,o,s,0),A.emplace(g++,i,n,o,s,1),A.emplace(g++,i,n,o,s,2),A.emplace(g++,i,n,o,s,3)}(!Xn||Xn.length<2*p)&&(Xn=function(t){const r=2*t,i=new e.az;i.resize(r),i._trim();for(let e=0;e<r;e++){const t=6*e;i.uint16[t+0]=4*e+0,i.uint16[t+1]=4*e+1,i.uint16[t+2]=4*e+2,i.uint16[t+3]=4*e+2,i.uint16[t+4]=4*e+3,i.uint16[t+5]=4*e+0}return i}(p));const _=l.createIndexBuffer(Xn,!0),y=l.createVertexBuffer(A,e.cD.members,!0);for(const r of d){const n={u_matrix:r.transform,u_inv_matrix:r.invTransform,u_camera_to_center_distance:(x=u).getCameraToCenterDistance(r.projection),u_viewport_size:[x.width,x.height]};m.draw(t,c.TRIANGLES,Et.disabled,St.disabled,t.colorModeForRenderPass(),Lt.disabled,n,i.id,y,_,e.aE.simpleSegment(0,2*r.circleOffset,r.circleArray.length,r.circleArray.length/2),null,u.zoom)}var x;y.destroy(),_.destroy()}const $n=e.a9.create();function Kn(t){const r=t._camera.getWorldToCamera(t.worldSize,1),i=e.a9.multiply([],r,t.globeMatrix);e.a9.invert(i,i);const n=[0,0,0],o=[0,1,0,0];return e.aa.transformMat4(o,o,i),n[0]=o[0],n[1]=o[1],n[2]=o[2],e.Q.normalize(n,n),n}function Jn({width:t,height:r,anchor:i,textOffset:n,textScale:o},s){const{horizontalAlign:a,verticalAlign:l}=e.bi(i),c=-(a-.5)*t,u=-(l-.5)*r,h=e.bh(i,n);return new e.P((c/o+h[0])*s,(u/o+h[1])*s)}function eo(t,r,i,n,o,s,a,l,c,u,h){const d=t.text.placedSymbolArray,p=t.text.dynamicLayoutVertexArray,f=t.icon.dynamicLayoutVertexArray,m={},A=t.getProjection(),g=kr(l,A,s),_=s.elevation,y=A.upVectorScale(l.canonical,s.center.lat,s.worldSize).metersToTile;p.clear();for(let f=0;f<d.length;f++){const x=d.get(f),{tileAnchorX:v,tileAnchorY:b,numGlyphs:w}=x,C=x.hidden||!x.crossTileID||t.allowVerticalPlacement&&!x.placedOrientation?null:n[x.crossTileID];if(C){let n=0,d=0,f=0;if(_){const e=_?_.getAtTileOffset(l,v,b):0,[t,r,i]=A.upVector(l.canonical,v,b);n=e*t*y,d=e*r*y,f=e*i*y}let[T,E,M,S]=Ar(x.projectedAnchorX+n,x.projectedAnchorY+d,x.projectedAnchorZ+f,i?g:a);const I=gr(s.getCameraToCenterDistance(A),S);let P=o.evaluateSizeForFeature(t.textSizeData,u,x)*I/e.bf;i&&(P*=t.tilePixelRatio/c);const D=Jn(C,P);i?(({x:T,y:E,z:M}=A.projectTilePoint(v+D.x,b+D.y,l.canonical)),[T,E,M]=Ar(T+n,E+d,M+f,a)):(r&&D._rotate(-s.angle),T+=D.x,E+=D.y,M=0);const k=t.allowVerticalPlacement&&x.placedOrientation===e.b9.vertical?Math.PI/2:0;for(let t=0;t<w;t++)e.bc(p,T,E,M,k);h&&x.associatedIconIndex>=0&&(m[x.associatedIconIndex]={x:T,y:E,z:M,angle:k})}else Er(w,p)}if(h){f.clear();const r=t.icon.placedSymbolArray;for(let t=0;t<r.length;t++){const i=r.get(t),{numGlyphs:n}=i,o=m[t];if(i.hidden||!o)Er(n,f);else{const{x:t,y:r,z:i,angle:s}=o;for(let o=0;o<n;o++)e.bc(f,t,r,i,s)}}t.icon.dynamicLayoutVertexBuffer.updateData(f)}t.text.dynamicLayoutVertexBuffer.updateData(p)}function to(t,r,i,n,o,s,a={}){const l=i.paint.get("icon-translate"),c=i.paint.get("text-translate"),u=i.paint.get("icon-translate-anchor"),h=i.paint.get("text-translate-anchor"),d=i.layout.get("icon-rotation-alignment"),p=i.layout.get("text-rotation-alignment"),f=i.layout.get("icon-pitch-alignment"),m=i.layout.get("text-pitch-alignment"),A=i.layout.get("icon-keep-upright"),g=i.layout.get("text-keep-upright"),_=i.paint.get("icon-color-saturation"),y=i.paint.get("icon-color-contrast"),x=i.paint.get("icon-color-brightness-min"),v=i.paint.get("icon-color-brightness-max"),b=t.context,w=b.gl,C=t.transform,T="map"===d,E="map"===p,M="map"===f,S="map"===m,I=void 0!==i.layout.get("symbol-sort-key").constantOr(1);let P=!1;const D=t.depthModeForSublayer(0,Et.ReadOnly),k=[e.a8(C.center.lng),e.ah(C.center.lat)],L=i.layout.get("text-variable-anchor"),z="globe"===C.projection.name,O=[],B=[0,-1,0];for(const o of n){const n=r.getTile(o),s=n.getBucket(i);if(!s)continue;if("mercator"===s.projection.name&&z)continue;if(s.fullyClipped)continue;const d="globe"===s.projection.name,p=d?e.W(C.zoom):0,f=kr(o,s.getProjection(),C),m=C.calculatePixelsToTileUnitsMatrix(n),b=L&&s.hasTextData(),D=s.hasIconTextFit()&&b&&s.hasIconData(),R=s.getProjection().createInversionMatrix(C,o.canonical),F=()=>{const r=T&&"point"!==i.layout.get("symbol-placement"),a=[],c=r||D,h=i.paint.get("icon-image-cross-fade").constantOr(0);t.terrainRenderModeElevated()&&M&&a.push("PITCH_WITH_MAP_TERRAIN"),d&&(a.push("PROJECTION_GLOBE_VIEW"),c&&a.push("PROJECTED_POS_ON_VIEWPORT")),h>0&&a.push("ICON_TRANSITION"),s.icon.zOffsetVertexBuffer&&a.push("Z_OFFSET"),0===_&&0===y&&0===x&&1===v||a.push("COLOR_ADJUSTMENT");const g=s.icon.programConfigurations.get(i.id),b=t.getOrCreateProgram(s.sdfIcons?"symbolSDF":"symbolIcon",{config:g,defines:a});let E;const S=n.imageAtlasTexture?n.imageAtlasTexture.size:[0,0],I=s.iconSizeData,P=e.b8(I,C.zoom),L=M||0!==C.pitch,O=pr(f,n.tileID.canonical,M,T,C,s.getProjection(),m),F=mr(f,n.tileID.canonical,M,T,C,s.getProjection(),m),j=t.translatePosMatrix(F,n,l,u,!0),V=t.translatePosMatrix(f,n,l,u),N=c?$n:O,U=T&&!M&&!r;let H=B;!z&&!C.mercatorFromTransition||T||(H=Kn(C));const G=d?H:B;if(s.sdfIcons&&!s.iconsInText)E=Nn(I.kind,P,U,M,t,V,N,j,!1,S,!0,o,p,k,R,G,s.getProjection());else{const e=i.getColorAdjustmentMatrix(_,y,x,v);E=Vn(I.kind,P,U,M,t,V,N,j,!1,S,o,p,k,R,G,s.getProjection(),e,h)}const Z=n.imageAtlasTexture?n.imageAtlasTexture:null,W=1!==i.layout.get("icon-size").constantOr(0)||s.iconsNeedLinear,Q=s.sdfIcons||t.options.rotating||t.options.zooming||W||L?w.LINEAR:w.NEAREST,q=s.sdfIcons&&0!==i.paint.get("icon-halo-width").constantOr(1),X=t.terrain&&M&&r?e.a9.invert(e.a9.create(),O):$n;if(r&&s.icon){const e=C.elevation,r=e?e.getAtTileOffsetFunc(o,C.center.lat,C.worldSize,s.getProjection()):null,i=fr(f,n.tileID.canonical,M,T,C,s.getProjection(),m);yr(s,f,t,!1,i,F,M,A,r,o)}return{program:b,buffers:s.icon,uniformValues:E,atlasTexture:Z,atlasTextureIcon:null,atlasInterpolation:Q,atlasInterpolationIcon:null,isSDF:s.sdfIcons,hasHalo:q,tile:n,labelPlaneMatrixInv:X}},j=()=>{const r=E&&"point"!==i.layout.get("symbol-placement"),a=[],l=r||L||D;t.terrainRenderModeElevated()&&S&&a.push("PITCH_WITH_MAP_TERRAIN"),d&&(a.push("PROJECTION_GLOBE_VIEW"),l&&a.push("PROJECTED_POS_ON_VIEWPORT")),s.text.zOffsetVertexBuffer&&a.push("Z_OFFSET");const u=s.text.programConfigurations.get(i.id),A=t.getOrCreateProgram(s.iconsInText?"symbolTextAndIcon":"symbolSDF",{config:u,defines:a});let _,y=[0,0],x=null;const v=s.textSizeData;s.iconsInText&&(y=n.imageAtlasTexture?n.imageAtlasTexture.size:[0,0],x=n.imageAtlasTexture?n.imageAtlasTexture:null,_=S||0!==C.pitch||t.options.rotating||t.options.zooming||"composite"===v.kind||"camera"===v.kind?w.LINEAR:w.NEAREST);const b=n.glyphAtlasTexture?n.glyphAtlasTexture.size:[0,0],T=e.b8(v,C.zoom),M=pr(f,n.tileID.canonical,S,E,C,s.getProjection(),m),I=mr(f,n.tileID.canonical,S,E,C,s.getProjection(),m),P=t.translatePosMatrix(I,n,c,h,!0),O=t.translatePosMatrix(f,n,c,h),F=l?$n:M,j=E&&!S&&!r;let V=B;!z&&!C.mercatorFromTransition||E||(V=Kn(C));const N=d?V:B;let U;U=s.iconsInText?Un(v.kind,T,j,S,t,O,F,P,b,y,o,p,k,R,N,s.getProjection()):Nn(v.kind,T,j,S,t,O,F,P,!0,b,!0,o,p,k,R,N,s.getProjection());const H=n.glyphAtlasTexture?n.glyphAtlasTexture:null,G=w.LINEAR,Z=0!==i.paint.get("text-halo-width").constantOr(1),W=t.terrain&&S&&r?e.a9.invert(e.a9.create(),M):$n;if(r&&s.text){const e=C.elevation,r=e?e.getAtTileOffsetFunc(o,C.center.lat,C.worldSize,s.getProjection()):null,i=fr(f,n.tileID.canonical,S,E,C,s.getProjection(),m);yr(s,f,t,!0,i,I,S,g,r,o)}return{program:A,buffers:s.text,uniformValues:U,atlasTexture:H,atlasTextureIcon:x,atlasInterpolation:G,atlasInterpolationIcon:_,isSDF:!0,hasHalo:Z,tile:n,labelPlaneMatrixInv:W}},V=s.icon.segments.get().length,N=s.text.segments.get().length,U=V&&!a.onlyText?F():null,H=N&&!a.onlyIcons?j():null,G=i.paint.get("icon-opacity").constantOr(1),Z=i.paint.get("text-opacity").constantOr(1);if(I&&s.canOverlap){P=!0;const t=G&&!a.onlyText?s.icon.segments.get():[],r=Z&&!a.onlyIcons?s.text.segments.get():[];for(const r of t)O.push({segments:new e.aE([r]),sortKey:r.sortKey,state:U});for(const t of r)O.push({segments:new e.aE([t]),sortKey:t.sortKey,state:H})}else a.onlyText||O.push({segments:G?s.icon.segments:new e.aE([]),sortKey:0,state:U}),a.onlyIcons||O.push({segments:Z?s.text.segments:new e.aE([]),sortKey:0,state:H})}P&&O.sort(((e,t)=>e.sortKey-t.sortKey));for(const e of O){const r=e.state;if(r)if(t.terrain&&t.terrain.setupElevationDraw(r.tile,r.program,{useDepthForOcclusion:C.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:r.labelPlaneMatrixInv}),b.activeTexture.set(w.TEXTURE0),r.atlasTexture&&r.atlasTexture.bind(r.atlasInterpolation,w.CLAMP_TO_EDGE,!0),r.atlasTextureIcon&&(b.activeTexture.set(w.TEXTURE1),r.atlasTextureIcon&&r.atlasTextureIcon.bind(r.atlasInterpolationIcon,w.CLAMP_TO_EDGE,!0)),t.uploadCommonLightUniforms(t.context,r.program),r.hasHalo){const n=r.uniformValues;n.u_is_halo=1,ro(r.buffers,e.segments,i,t,r.program,D,o,s,n,2),n.u_is_halo=0}else{if(r.isSDF){const n=r.uniformValues;r.hasHalo&&(n.u_is_halo=1,ro(r.buffers,e.segments,i,t,r.program,D,o,s,n,1)),n.u_is_halo=0}ro(r.buffers,e.segments,i,t,r.program,D,o,s,r.uniformValues,1)}}}function ro(e,t,r,i,n,o,s,a,l,c){const u=[e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer,e.iconTransitioningVertexBuffer,e.globeExtVertexBuffer,e.zOffsetVertexBuffer];n.draw(i,i.context.gl.TRIANGLES,o,s,a,Lt.disabled,l,r.id,e.layoutVertexBuffer,e.indexBuffer,t,r.paint,i.transform.zoom,e.programConfigurations.get(r.id),u,c)}function io(e,t,r,i,n,o,s){const a=e.context.gl,l=r.paint.get("fill-pattern"),c=l&&l.constantOr(1);let u,h,d,p,f;s?(h=c&&!r.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",u=a.LINES):(h=c?"fillPattern":"fill",u=a.TRIANGLES);for(const m of i){const i=t.getTile(m);if(c&&!i.patternsLoaded())continue;const A=i.getBucket(r);if(!A)continue;e.prepareDrawTile();const g=A.programConfigurations.get(r.id),_=e.isTileAffectedByFog(m),y=e.getOrCreateProgram(h,{config:g,overrideFog:_});c&&(e.context.activeTexture.set(a.TEXTURE0),i.imageAtlasTexture&&i.imageAtlasTexture.bind(a.LINEAR,a.CLAMP_TO_EDGE),g.updatePaintBuffers());const x=l.constantOr(null);if(x&&i.imageAtlas){const e=i.imageAtlas.patternPositions[x.toString()];e&&g.setConstantPatternPositions(e)}const v=e.translatePosMatrix(m.projMatrix,i,r.paint.get("fill-translate"),r.paint.get("fill-translate-anchor")),b=r.paint.get("fill-emissive-strength");if(s){p=A.indexBuffer2,f=A.segments2;const t=e.terrain&&e.terrain.renderingToTexture?e.terrain.drapeBufferSize:[a.drawingBufferWidth,a.drawingBufferHeight];d="fillOutlinePattern"===h&&c?Mn(v,b,e,i,t):En(v,b,t)}else p=A.indexBuffer,f=A.segments,d=c?Tn(v,b,e,i):Cn(v,b);e.uploadCommonUniforms(e.context,y,m.toUnwrapped()),y.draw(e,u,n,e.stencilModeForClipping(m),o,Lt.disabled,d,r.id,A.layoutVertexBuffer,p,f,r.paint,e.transform.zoom,g,void 0)}}function no(t,r,i,n,o,s,a,l){i.resetLayerRenderingStats(t);const c=t.context,u=c.gl,h=t.transform,d=i.paint.get("fill-extrusion-pattern"),p=d.constantOr(1),f=i.paint.get("fill-extrusion-opacity"),m=t.style.enable3dLights(),A=i.paint.get(m&&!p?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),g=[i.paint.get("fill-extrusion-ambient-occlusion-intensity"),A],_=i.layout.get("fill-extrusion-edge-radius"),y=_>0&&!i.paint.get("fill-extrusion-rounded-roof"),x=y?0:_,v="globe"===h.projection.name?e.cM():0,b="globe"===h.projection.name,w=b?e.W(h.zoom):0,C=[e.a8(h.center.lng),e.ah(h.center.lat)],T=i.paint.get("fill-extrusion-flood-light-color").toArray01().slice(0,3),E=i.paint.get("fill-extrusion-flood-light-intensity"),M=i.paint.get("fill-extrusion-vertical-scale"),S=mi(t,i.paint.get("fill-extrusion-cutoff-fade-range")),I=i.paint.get("fill-extrusion-emissive-strength"),P=[];let D;b&&P.push("PROJECTION_GLOBE_VIEW"),g[0]>0&&P.push("FAUX_AO"),y&&P.push("ZERO_ROOF_RADIUS"),l&&P.push("HAS_CENTROID"),E>0&&P.push("FLOOD_LIGHT"),S.shouldRenderCutoff&&P.push("RENDER_CUTOFF");const k="shadow"===t.renderPass,L=t.shadowRenderer,z=k&&!!L;t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!0);let O=[0,0,0];if(L){const e=t.style.directionalLight,r=t.style.ambientLight;e&&r&&(O=bi(e,r)),D=P.concat(["SHADOWS_SINGLE_CASCADE"])}const B=z?"fillExtrusionDepth":p?"fillExtrusionPattern":"fillExtrusion",R=i.getLayerRenderingStats();for(const e of n){const n=r.getTile(e),m=n.getBucket(i);if(!m||m.projection.name!==h.projection.name)continue;let A=!1;L&&(A=0===L.getMaxCascadeForTile(e.toUnwrapped()));const _=t.isTileAffectedByFog(e),y=m.programConfigurations.get(i.id),z=t.getOrCreateProgram(B,{config:y,defines:A?D:P,overrideFog:_});if(t.terrain&&t.terrain.setupElevationDraw(n,z,{useMeterToDem:!0}),!m.centroidVertexBuffer){const e=z.attributes.a_centroid_pos;void 0!==e&&u.vertexAttrib2f(e,0,0)}!k&&L&&L.setupShadows(n.tileID.toUnwrapped(),z,"vector-tile",n.tileID.overscaledZ),p&&(t.context.activeTexture.set(u.TEXTURE0),n.imageAtlasTexture&&n.imageAtlasTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),y.updatePaintBuffers());const F=d.constantOr(null);if(F&&n.imageAtlas){const e=n.imageAtlas.patternPositions[F.toString()];e&&y.setConstantPatternPositions(e)}const j=i.paint.get("fill-extrusion-vertical-gradient");let V;if(k&&L){if(uo(n.tileID,m,t))continue;const e=L.calculateShadowPassMatrixFromTile(n.tileID.toUnwrapped());V=bn(e,x,M)}else{const r=t.translatePosMatrix(e.expandedProjMatrix,n,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),o=h.projection.createInversionMatrix(h,e.canonical);V=p?wn(r,t,j,f,g,x,e,n,v,w,C,o,T,M):vn(r,t,j,f,g,x,e,v,w,C,o,T,M,E,O,I)}t.uploadCommonUniforms(c,z,e.toUnwrapped(),null,S);let N=m.segments;if("mercator"===h.projection.name&&!k&&(N=m.getVisibleSegments(n.tileID,t.terrain,t.transform.getFrustum(0)),!N.get().length))continue;if(R)if(k)for(const e of N.get())R.numRenderedVerticesInShadowPass+=e.primitiveLength;else for(const e of N.get())R.numRenderedVerticesInTransparentPass+=e.primitiveLength;const U=[];(t.terrain||l)&&U.push(m.centroidVertexBuffer),b&&U.push(m.layoutVertexExtBuffer),z.draw(t,c.gl.TRIANGLES,o,s,a,Lt.backCCW,V,i.id,m.layoutVertexBuffer,m.indexBuffer,N,i.paint,t.transform.zoom,y,U)}t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!1)}function oo(t,r,i,n,o,s,a,l,c,u,h,d,p,f,m,A,g,_,y){const x=t.context,v=x.gl,b=t.transform,w=t.transform.zoom,C=[],T=mi(t,i.paint.get("fill-extrusion-cutoff-fade-range"));"clear"===u?(C.push("CLEAR_SUBPASS"),y&&(C.push("CLEAR_FROM_TEXTURE"),x.activeTexture.set(v.TEXTURE0),y.bind(v.LINEAR,v.CLAMP_TO_EDGE))):"sdf"===u&&C.push("SDF_SUBPASS"),g&&C.push("HAS_CENTROID"),T.shouldRenderCutoff&&C.push("RENDER_CUTOFF");const E=i.layout.get("fill-extrusion-edge-radius"),M=(e,r,n,u,_)=>{const v=r.programConfigurations.get(i.id),b=t.isTileAffectedByFog(e),M=t.getOrCreateProgram("fillExtrusionGroundEffect",{config:v,defines:C,overrideFog:b}),S=((e,t,r,i,n,o,s,a,l,c,u)=>({u_matrix:t,u_opacity:r,u_ao_pass:i?1:0,u_meter_to_tile:n,u_ao:o,u_flood_light_intensity:s,u_flood_light_color:a,u_attenuation:l,u_edge_radius:c,u_fb:0,u_fb_size:u}))(0,u,h,c,_,[d,p*_],f,m,A,w>=17?0:E*_,y?y.size[0]:0),I=[];g&&I.push(r.hiddenByLandmarkVertexBuffer),t.uploadCommonUniforms(x,M,e.toUnwrapped(),null,T),M.draw(t,x.gl.TRIANGLES,o,s,a,l,S,i.id,r.vertexBuffer,r.indexBuffer,n,i.paint,w,v,I)};for(const o of n){const n=r.getTile(o),s=n.getBucket(i);if(!s||s.projection.name!==b.projection.name||!s.groundEffect||s.groundEffect&&!s.groundEffect.hasData())continue;const a=s.groundEffect,l=1/s.tileToMeter;{const e=t.translatePosMatrix(o.projMatrix,n,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),r=a.getDefaultSegment();M(o,a,r,e,l)}if(_)for(let s=0;s<4;s++){const a=e.cN[s](o),c=r.getTile(a);if(!c)continue;const u=c.getBucket(i);if(!u||u.projection.name!==b.projection.name||!u.groundEffect||u.groundEffect&&!u.groundEffect.hasData())continue;const h=u.groundEffect;let d,p;0===s?(d=[-e.Y,0,0],p=1):1===s?(d=[e.Y,0,0],p=0):2===s?(d=[0,-e.Y,0],p=3):(d=[0,e.Y,0],p=2);const f=h.regionSegments[p];if(!f)continue;const m=new Float32Array(16);e.a9.translate(m,o.projMatrix,d),M(o,h,f,t.translatePosMatrix(m,n,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),l)}}}function so(t,r,i,n,o,s,a){0===n.centroidVertexArray.length&&n.createCentroidsBuffer();const l=s?s.findDEMTileFor(i):null;if(!(l&&l.dem||a))return;const c=t=>new e.P(Math.ceil((t+e.cQ)*e.cR),0),u=e=>{const t=r.getSource().minzoom,i=e=>{const t=r.getTileByID(e);if(t&&t.hasData())return t.getBucket(o)},n=[0,-1,1];for(const r of n){if(e.overscaledZ+r<t)continue;const n=i(e.calculateScaledKey(e.overscaledZ+r));if(n)return n}},h=[0,0,0],d=(t,r)=>(h[0]=Math.min(t.min.y,r.min.y),h[1]=Math.max(t.max.y,r.max.y),h[2]=e.Y-r.min.x>t.max.x?r.min.x-e.Y:t.max.x,h),p=(t,r)=>(h[0]=Math.min(t.min.x,r.min.x),h[1]=Math.max(t.max.x,r.max.x),h[2]=e.Y-r.min.y>t.max.y?r.min.y-e.Y:t.max.y,h),f=[(e,t)=>d(e,t),(e,t)=>d(t,e),(e,t)=>p(e,t),(e,t)=>p(t,e)],m=(t,r,n,o,a,c,u)=>{if(!s)return 0;const h=[[c?n:t,c?t:n,0],[c?n:r,c?r:n,0]],d=u<0?e.Y+u:u,p=[c?d:(t+r)/2,c?(t+r)/2:d,0];return 0===n&&u<0||0!==n&&u>0?s.getForTilePoints(a,[p],!0,o):h.push(p),s.getForTilePoints(i,h,!0,l),Math.max(h[0][2],h[1][2],p[2])/s.exaggeration()};for(let t=0;t<4;t++){const r=n.borderFeatureIndices[t];if(0===r.length)continue;const o=e.cN[t](i),l=u(o);if(!(l&&l instanceof e.cO))continue;if(n.borderDoneWithNeighborZ[t]===l.canonical.z)continue;0===l.centroidVertexArray.length&&l.createCentroidsBuffer();const h=s?s.findDEMTileFor(o):null;if(!(h&&h.dem||a))continue;const d=(t<2?1:5)-t,p=l.borderDoneWithNeighborZ[d]!==n.canonical.z,_=l.borderFeatureIndices[d];let y=0;if(n.canonical.z!==l.canonical.z){for(const e of r)n.showCentroid(n.featuresOnBorder[e]);if(p)for(const e of _)l.showCentroid(l.featuresOnBorder[e]);n.borderDoneWithNeighborZ[t]=l.canonical.z,l.borderDoneWithNeighborZ[d]=n.canonical.z}for(const i of r){const r=n.featuresOnBorder[i],s=n.centroidData[r.centroidDataIndex],u=r.borders[t];let p;for(;y<_.length;){p=l.featuresOnBorder[_[y]];const e=p.borders[d];if(e[1]>u[0]+3||e[0]>u[0]-3)break;l.showCentroid(p),y++}if(p&&y<_.length){const i=y;let x=0;for(;!(p.borders[d][0]>u[1]-3)&&(x++,++y!==_.length);)p=l.featuresOnBorder[_[y]];if(p=l.featuresOnBorder[_[i]],x>1){const e=p.borders[d];Math.abs(u[0]-e[0])<3&&Math.abs(u[1]-e[1])<3&&(x=1,y=i+1)}else if(0===x){n.showCentroid(r);continue}const v=l.centroidData[p.centroidDataIndex];a&&1===x&&(((A=s).flags|(g=v).flags)&e.cP?(A.flags|=e.cP,g.flags|=e.cP):(A.flags&=~e.cP,g.flags&=~e.cP));const b=r.intersectsCount()>1||p.intersectsCount()>1;if(x>1)y=i,s.centroidXY=v.centroidXY=new e.P(0,0);else if(h&&h.dem&&!b){const r=f[t](s,v),i=t%2?e.Y-1:0,n=m(r[0],Math.min(e.Y-1,r[1]),i,h,o,t<2,r[2]);s.centroidXY=v.centroidXY=c(n)}else b?s.centroidXY=v.centroidXY=new e.P(0,0):(s.centroidXY=n.encodeBorderCentroid(r),v.centroidXY=l.encodeBorderCentroid(p));n.writeCentroidToBuffer(s),l.writeCentroidToBuffer(v)}else n.showCentroid(r)}n.borderDoneWithNeighborZ[t]=l.canonical.z,l.borderDoneWithNeighborZ[d]=n.canonical.z}var A,g;(n.needsCentroidUpdate||!n.centroidVertexBuffer&&0!==n.centroidVertexArray.length)&&n.uploadCentroid(t)}const ao=[1,0,0],lo=[0,1,0],co=[0,0,1];function uo(t,r,i){const n=i.transform,o=i.shadowRenderer;if(!o)return!0;const s=t.toUnwrapped(),a=n.tileSize*o._cascades[i.currentShadowCascade].scale;let l=r.maxHeight;if(n.elevation){const e=n.elevation.getMinMaxForTile(t);e&&(l+=e.max)}const c=[...o.shadowDirection];c[2]=-c[2];const u=o.computeSimplifiedTileShadowVolume(s,l,a,c);if(!u)return!1;const h=[ao,lo,co,c,[c[0],0,c[2]],[0,c[1],c[2]]],d="globe"===n.projection.name,p=n.scaleZoom(a),f=e.bt.fromInvProjectionMatrix(n.invProjMatrix,n.worldSize,p,!d),m=o.getCurrentCascadeFrustum();return 0===f.intersectsPrecise(u.vertices,u.planes,h)||0===m.intersectsPrecise(u.vertices,u.planes,h)}function ho(t){return[t[0]*e.cS,t[1]*e.cS,t[2]*e.cS,0]}function po(t,r,i,n,o,s,a,l,c){const u=n.getSource(),h=i.globeSharedBuffers;if(!h)return;let d,p,f;if(r&&(d=n.getTile(r)),u instanceof e.as?(p=u.texture,f=e.co(0,0,i.transform)):d&&r&&(p=d.texture,f=e.co(r.canonical.z,r.canonical.x,i.transform)),!p||!f)return;t||(f=e.a9.scale(e.a9.create(),f,[1,-1,1]));const m=i.context,A=m.gl,g="nearest"===o.paint.get("raster-resampling")?A.NEAREST:A.LINEAR,_=i.colorModeForDrapableLayerRenderPass(s),y=a.defines;y.push("GLOBE_POLES");const x=new Et(A.LEQUAL,Et.ReadWrite,i.depthRangeFor3D),v=Float32Array.from(i.transform.expandedFarZProjMatrix),b=Float32Array.from(e.aW(e.cn(new e.bv(0,0,0))));i.terrain&&i.terrain.prepareDrawTile(),m.activeTexture.set(A.TEXTURE0),p.bind(g,A.CLAMP_TO_EDGE),m.activeTexture.set(A.TEXTURE1),p.bind(g,A.CLAMP_TO_EDGE),p.useMipmap&&m.extTextureFilterAnisotropic&&i.transform.pitch>20&&A.texParameterf(A.TEXTURE_2D,m.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,m.extTextureFilterAnisotropicMax);const[w,C,T,E]=r?h.getPoleBuffers(r.canonical.z,!1):h.getPoleBuffers(0,!0),M=o.paint.get("raster-elevation");let S;t?(S=w,i.renderDefaultNorthPole=0!==M):(S=C,i.renderDefaultSouthPole=0!==M);const I=ho(a.mix),P=((e,t,r,i,n,o,s,a,l,c,u,h,d)=>zn(e,t,r,new Float32Array(16),new Float32Array(9),[0,0],i,[0,0],[0,0,0,0],1,{opacity:1,mix:0},o,[0,0]||[0,0],a,2,c,u,h,1,0,d))(v,b,f,e.W(i.transform.zoom),0,o,0,M,0,I,a.offset,a.range,s),D=i.getOrCreateProgram("raster",{defines:y});i.uploadCommonUniforms(m,D,null),D.draw(i,A.TRIANGLES,x,c,_,l,P,o.id,S,T,E)}function fo(e){const t=e._nearZ,r=e.projection.farthestPixelDistance(e),i=r-t,n=.2*e.height,o=t+n;return[t,r,(o-n-t)/i,(o-t)/i]}function mo(e,t,r,i){if(e)return t instanceof De&&e instanceof Wt?t.getTextureDescriptor(e,r,!0):{texture:e.texture,mix:ho(i.mix),offset:i.offset,buffer:0,tileSize:1}}function Ao(t,r,i){if(!t)return null;const n=r.getTextureDescriptor(t,i,!0);if(!n)return null;let{texture:o,mix:s,offset:a,tileSize:l,buffer:c,format:u}=n;if(!o||!u)return null;let h=!1;return"uint32"===u&&(h=!0,s[3]=0,s=kn(e.cT,s,[0,i.paint.get("raster-particle-max-speed")]),a=Ln(e.cT,a,[0,i.paint.get("raster-particle-max-speed")])),{texture:o,textureOffset:[c/(l+2*c),l/(l+2*c)],tileSize:l,scalarData:h,scale:s,offset:a,defines:["RASTER_ARRAY",{uint8:"DATA_FORMAT_UINT8",uint16:"DATA_FORMAT_UINT16",uint32:"DATA_FORMAT_UINT32"}[u]]}}function go(e){const t=e._nearZ,r=e.projection.farthestPixelDistance(e),i=r-t,n=.2*e.height,o=t+n;return[t,r,(o-n-t)/i,(o-t)/i]}const _o=new e.aA(1,0,0,1),yo=new e.aA(0,1,0,1),xo=new e.aA(0,0,1,1),vo=new e.aA(1,0,1,1),bo=new e.aA(0,1,1,1);function wo(t,r,i,n,o,s,a){const l=t.context,c=t.transform,u=l.gl,h="globe"===c.projection.name,d=h?["PROJECTION_GLOBE_VIEW"]:[];let p=e.a9.clone(i.projMatrix);if(h&&e.W(c.zoom)>0){const t=e.aV(i.canonical,c),r=e.cU(t);p=e.a9.multiply(new Float32Array(16),c.globeMatrix,r),e.a9.multiply(p,c.projMatrix,p)}const f=e.a9.create();f[12]+=2*o/(e.f.devicePixelRatio*c.width),f[13]+=2*s/(e.f.devicePixelRatio*c.height),e.a9.multiply(p,f,p);const m=t.getOrCreateProgram("debug",{defines:d}),A=r.getTileByID(i.key);t.terrain&&t.terrain.setupElevationDraw(A,m);const g=Et.disabled,_=St.disabled,y=t.colorModeForRenderPass(),x="$debug";l.activeTexture.set(u.TEXTURE0),t.emptyTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),h?A._makeGlobeTileDebugBuffers(t.context,c):A._makeDebugTileBoundsBuffers(t.context,c.projection);const v=A._tileDebugBuffer||t.debugBuffer,b=A._tileDebugIndexBuffer||t.debugIndexBuffer,w=A._tileDebugSegments||t.debugSegments;if(m.draw(t,u.LINE_STRIP,g,_,y,Lt.disabled,In(p,n),x,v,b,w,null,null,null,[A._globeTileDebugBorderBuffer]),a){const e=A.latestRawTileData,r=Math.floor((e&&e.byteLength||0)/1024);let n=i.canonical.toString();i.overscaledZ!==i.canonical.z&&(n+=` => ${i.overscaledZ}`),n+=` ${A.state}`,n+=` ${r}kb`,function(e,t){e.initDebugOverlayCanvas();const r=e.debugOverlayCanvas,i=e.context.gl,n=e.debugOverlayCanvas.getContext("2d");n.clearRect(0,0,r.width,r.height),n.shadowColor="white",n.shadowBlur=2,n.lineWidth=1.5,n.strokeStyle="white",n.textBaseline="top",n.font="bold 36px Open Sans, sans-serif",n.fillText(t,5,5),n.strokeText(t,5,5),e.debugOverlayTexture.update(r),e.debugOverlayTexture.bind(i.LINEAR,i.CLAMP_TO_EDGE)}(t,n)}const C=r.getTile(i).tileSize,T=512/Math.min(C,512)*(i.overscaledZ/c.zoom)*.5,E=A._tileDebugTextBuffer||t.debugBuffer,M=A._tileDebugTextIndexBuffer||t.quadTriangleIndexBuffer,S=A._tileDebugTextSegments||t.debugSegments;m.draw(t,u.TRIANGLES,g,_,Pt.alphaBlended,Lt.disabled,In(p,e.aA.transparent,T),x,E,M,S,null,null,null,[A._globeTileDebugTextBuffer])}function Co(e,t,r,i){Eo(e,0,t+r/2,e.transform.width,r,i)}function To(e,t,r,i){Eo(e,t-r/2,0,r,e.transform.height,i)}function Eo(t,r,i,n,o,s){const a=t.context,l=a.gl;l.enable(l.SCISSOR_TEST),l.scissor(r*e.f.devicePixelRatio,i*e.f.devicePixelRatio,n*e.f.devicePixelRatio,o*e.f.devicePixelRatio),a.clear({color:s}),l.disable(l.SCISSOR_TEST)}const Mo=e.aB([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:So}=Mo;function Io(e,t,r,i){e.emplaceBack(t,r,i)}class Po{constructor(t){this.vertexArray=new e.cV,this.indices=new e.az,Io(this.vertexArray,-1,-1,1),Io(this.vertexArray,1,-1,1),Io(this.vertexArray,-1,1,1),Io(this.vertexArray,1,1,1),Io(this.vertexArray,-1,-1,-1),Io(this.vertexArray,1,-1,-1),Io(this.vertexArray,-1,1,-1),Io(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,So),this.indexBuffer=t.createIndexBuffer(this.indices),this.segment=e.aE.simpleSegment(0,0,36,12)}}function Do(t,r,i,n,o,s){const a=t.context.gl,l=r.paint.get("sky-atmosphere-color"),c=r.paint.get("sky-atmosphere-halo-color"),u=r.paint.get("sky-atmosphere-sun-intensity"),h=((e,t,r,i,n)=>({u_matrix_3f:e,u_sun_direction:t,u_sun_intensity:r,u_color_tint_r:[i.r,i.g,i.b,i.a],u_color_tint_m:[n.r,n.g,n.b,n.a],u_luminance:5e-5}))(e.ct.fromMat4(e.ct.create(),n),o,u,l,c);a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+s,r.skyboxTexture,0),i.draw(t,a.TRIANGLES,Et.disabled,St.disabled,Pt.unblended,Lt.frontCW,h,"skyboxCapture",r.skyboxGeometry.vertexBuffer,r.skyboxGeometry.indexBuffer,r.skyboxGeometry.segment)}const ko=e.aB([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class Lo{constructor(t){const r=new e.cW;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 i=new e.az;i.emplaceBack(0,1,2),i.emplaceBack(2,3,0),this.vertexBuffer=t.createVertexBuffer(r,ko.members),this.indexBuffer=t.createIndexBuffer(i),this.segments=e.aE.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const zo=e.aB([{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 Oo{constructor(){this.starsCount=16e3,this.sizeMultiplier=.15,this.sizeRange=100,this.intensityRange=200}}class Bo{constructor(t){this.colorModeAlphaBlendedWriteRGB=new Pt([1,It,1,It],e.aA.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new Pt([1,0,1,0],e.aA.transparent,[!1,!1,!1,!0]),this.params=new Oo,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 Lo(r);const t=this.params.sizeRange,i=this.params.intensityRange,n=function(t){const r=e.aC(30),i=[];for(let n=0;n<t;++n){const t=2*Math.PI*r(),n=Math.acos(1-2*r())-.5*Math.PI;i.push(e.Q.fromValues(Math.cos(n)*Math.cos(t),Math.cos(n)*Math.sin(t),Math.sin(n)))}return i}(this.params.starsCount),o=e.aC(300),s=new e.cX,a=new e.az;let l=0;for(let r=0;r<n.length;++r){const c=e.Q.scale([],n[r],200),u=Math.max(0,1+.01*t*(1*o()-.5)),h=Math.max(0,1+.01*i*(1*o()-.5));s.emplaceBack(c[0],c[1],c[2],-1,-1,u,h),s.emplaceBack(c[0],c[1],c[2],1,-1,u,h),s.emplaceBack(c[0],c[1],c[2],1,1,u,h),s.emplaceBack(c[0],c[1],c[2],-1,1,u,h),a.emplaceBack(l+0,l+1,l+2),a.emplaceBack(l+0,l+2,l+3),l+=4}this.starsVx=r.createVertexBuffer(s,zo.members),this.starsIdx=r.createIndexBuffer(a),this.starsSegments=e.aE.simpleSegment(0,0,s.length,a.length)}}destroy(){this.atmosphereBuffer&&this.atmosphereBuffer.destroy(),this.starsVx&&this.starsVx.destroy(),this.starsIdx&&this.starsIdx.destroy()}drawAtmosphereGlow(t,r){const i=t.context,n=i.gl,o=t.transform,s=new Et(n.LEQUAL,Et.ReadOnly,[0,1]),a=e.W(o.zoom),l=r.properties.get("color").toArray01(),c=r.properties.get("high-color").toArray01(),u=r.properties.get("space-color").toArray01PremultipliedAlpha(),h=5e-4,d=e.cY(r.properties.get("horizon-blend"),0,1,h,.25),p=e.ci(t,i,o)&&d===h?o.worldSize/(2*Math.PI*1.025)-1:o.globeRadius,f=t.frameCounter/1e3%1,m=e.Q.length(o.globeCenterInViewSpace),A=Math.sqrt(Math.pow(m,2)-Math.pow(p,2)),g=Math.acos(A/m),_=e=>{const r="globe"===o.projection.name?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];e&&r.push("ALPHA_PASS");const h=t.getOrCreateProgram("globeAtmosphere",{defines:r}),p=((e,t,r,i,n,o,s,a,l,c,u,h)=>({u_frustum_tl:e,u_frustum_tr:t,u_frustum_br:r,u_frustum_bl:i,u_horizon:n,u_transition:o,u_fadeout_range:s,u_color:a,u_high_color:l,u_space_color:c,u_temporal_offset:u,u_horizon_angle:h}))(o.frustumCorners.TL,o.frustumCorners.TR,o.frustumCorners.BR,o.frustumCorners.BL,o.frustumCorners.horizon,a,d,l,c,u,f,g);t.uploadCommonUniforms(i,h);const m=this.atmosphereBuffer;m&&h.draw(t,n.TRIANGLES,s,St.disabled,e?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,Lt.backCW,p,e?"atmosphere_glow_alpha":"atmosphere_glow",m.vertexBuffer,m.indexBuffer,m.segments)};_(!1),_(!0)}drawStars(t,r){const i=e.ad(r.properties.get("star-intensity"),0,1);if(0===i)return;const n=t.context,o=n.gl,s=t.transform,a=t.getOrCreateProgram("stars"),l=e.bl.identity([]);e.bl.rotateX(l,l,-s._pitch),e.bl.rotateZ(l,l,-s.angle),e.bl.rotateX(l,l,e.bm(s._center.lat)),e.bl.rotateY(l,l,-e.bm(s._center.lng));const c=e.a9.fromQuat(new Float32Array(16),l),u=e.a9.multiply([],s.starsProjMatrix,c),h=e.ct.fromMat4([],c),d=e.ct.invert([],h),p=[0,1,0];e.Q.transformMat3(p,p,d),e.Q.scale(p,p,this.params.sizeMultiplier);const f=[1,0,0];e.Q.transformMat3(f,f,d),e.Q.scale(f,f,this.params.sizeMultiplier);const m=(A=p,g=f,_=i,{u_matrix:Float32Array.from(u),u_up:A,u_right:g,u_intensity_multiplier:_});var A,g,_;t.uploadCommonUniforms(n,a),this.starsVx&&this.starsIdx&&a.draw(t,o.TRIANGLES,Et.disabled,St.disabled,this.colorModeAlphaBlendedWriteRGB,Lt.disabled,m,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments)}}function Ro(t,r){const i=[...t],n=r.cameraWorldSizeForFog/r.worldSize,o=e.a9.identity([]);return e.a9.scale(o,o,[n,n,1]),e.a9.multiply(i,o,i),e.a9.multiply(i,r.worldToFogMatrix,i),i}function Fo(e,t,r,i){const n=r.material,o=i.context,{baseColorTexture:s,metallicRoughnessTexture:a}=n.pbrMetallicRoughness,{normalTexture:l,occlusionTexture:c,emissionTexture:u}=n;function h(t,r,i){if(t&&(e.push(r),o.activeTexture.set(o.gl.TEXTURE0+i),t.gfxTexture)){const{minFilter:e,magFilter:r,wrapS:i,wrapT:n}=t.sampler;t.gfxTexture.bindExtraParam(e,r,i,n)}}h(s,"HAS_TEXTURE_u_baseColorTexture",fi.BaseColor),h(a,"HAS_TEXTURE_u_metallicRoughnessTexture",fi.MetallicRoughness),h(l,"HAS_TEXTURE_u_normalTexture",fi.Normal),h(c,"HAS_TEXTURE_u_occlusionTexture",fi.Occlusion),h(u,"HAS_TEXTURE_u_emissionTexture",fi.Emission),r.texcoordBuffer&&(e.push("HAS_ATTRIBUTE_a_uv_2f"),t.push(r.texcoordBuffer)),r.colorBuffer&&(e.push(12===r.colorBuffer.itemSize?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),t.push(r.colorBuffer)),r.normalBuffer&&(e.push("HAS_ATTRIBUTE_a_normal_3f"),t.push(r.normalBuffer)),r.pbrBuffer&&(e.push("HAS_ATTRIBUTE_a_pbr"),e.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),t.push(r.pbrBuffer)),"OPAQUE"!==n.alphaMode&&"MASK"!==n.alphaMode||e.push("UNPREMULT_TEXTURE_IN_SHADER"),n.defined||e.push("DIFFUSE_SHADED"),e.push("USE_STANDARD_DERIVATIVES")}function jo(t,r,i,n,o,s){const a=i.paint.get("model-opacity"),l=r.context,c=new Et(r.context.gl.LEQUAL,Et.ReadWrite,r.depthRangeFor3D),u=r.transform,h=t.mesh,d=h.material,p=d.pbrMetallicRoughness,f=r.style.fog;let m;m="pixels"===r.transform.projection.zAxisUnit?[...t.nodeModelMatrix]:e.a9.multiply([],n.zScaleMatrix,t.nodeModelMatrix),e.a9.multiply(m,n.negCameraPosMatrix,m);const A=e.a9.invert([],m);e.a9.transpose(A,A);const g=i.paint.get("model-emissive-strength").constantOr(0),_=Wn(new Float32Array(t.worldViewProjection),new Float32Array(m),new Float32Array(A),null,r,a,p.baseColorFactor,d.emissiveFactor,p.metallicFactor,p.roughnessFactor,d,g,i),y={defines:[]},x=[];Fo(y.defines,x,h,r);const v=r.shadowRenderer;v&&(v.useNormalOffset=!1);let b=null;if(f){const e=Ro(t.nodeModelMatrix,r.transform);if(b=new Float32Array(e),"globe"!==u.projection.name){const t=h.aabb.min,r=h.aabb.max,[i,n]=f.getOpacityForBounds(e,t[0],t[1],r[0],r[1]);y.overrideFog=i>=pe||n>=pe}}const w=mi(r,i.paint.get("model-cutoff-fade-range"));w.shouldRenderCutoff&&y.defines.push("RENDER_CUTOFF");const C=r.getOrCreateProgram("model",y);r.uploadCommonUniforms(l,C,null,b,w),"shadow"!==r.renderPass&&v&&v.setupShadowsFromMatrix(t.nodeModelMatrix,C),C.draw(r,l.gl.TRIANGLES,c,o,s,h.material.doubleSided?Lt.disabled:Lt.backCCW,_,i.id,h.vertexBuffer,h.indexBuffer,h.segments,i.paint,r.transform.zoom,void 0,x)}function Vo(t,r,i,n,o,s,a){let l;l="globe"===t.projection.name?e.c_(i,t):[...i],e.a9.multiply(l,l,r.matrix);const c=e.a9.multiply([],n,l);if(r.meshes)for(const t of r.meshes){if("BLEND"!==t.material.alphaMode){a.push({mesh:t,depth:0,modelIndex:o,worldViewProjection:c,nodeModelMatrix:l});continue}const r=e.Q.transformMat4([],t.centroid,c);r[2]>0&&s.push({mesh:t,depth:r[2],modelIndex:o,worldViewProjection:c,nodeModelMatrix:l})}if(r.children)for(const e of r.children)Vo(t,e,i,n,o,s,a)}function No(e,t,r,i){const n=r.shadowRenderer;if(!n)return;const o=n.getShadowPassDepthMode(),s=n.getShadowPassColorMode(),a=n.calculateShadowPassMatrixFromMatrix(t),l=Qn(a);r.getOrCreateProgram("modelDepth",{defines:r._shadowMapDebug?[]:["DEPTH_TEXTURE"]}).draw(r,r.context.gl.TRIANGLES,o,St.disabled,s,Lt.backCCW,l,i.id,e.vertexBuffer,e.indexBuffer,e.segments,i.paint,r.transform.zoom,void 0,void 0)}function Uo(t,r,i){const n=r.updateZoomBasedPaintProperties(),o=function(t,r,i){let n,o,s,a=t.terrain?t.terrain.exaggeration():0;if(t.terrain&&a>0){const r=t.terrain,o=r.findDEMTileFor(i);o&&o.dem?n=e.d0.create(r,i,o):a=0}if(0===a&&(r.terrainElevationMin=0,r.terrainElevationMax=0),a===r.validForExaggeration&&(0===a||n&&n._demTile&&n._demTile.tileID===r.validForDEMTile.id&&n._dem._timestamp===r.validForDEMTile.timestamp))return!1;for(const e in r.instancesPerModel){const t=r.instancesPerModel[e];for(let e=0;e<t.instancedDataArray.length;++e){const i=(n?a*n.getElevationAt(0|t.instancedDataArray.float32[16*e],0|t.instancedDataArray.float32[16*e+1],!0,!0):0)+t.instancesEvaluatedElevation[e];t.instancedDataArray.float32[16*e+6]=i,o=o?Math.min(r.terrainElevationMin,i):i,s=s?Math.max(r.terrainElevationMax,i):i}}return r.terrainElevationMin=o||0,r.terrainElevationMax=s||0,r.validForExaggeration=a,r.validForDEMTile=n&&n._demTile?{id:n._demTile.tileID,timestamp:n._dem._timestamp}:{id:void 0,timestamp:0},!0}(t,r,i);(n||o)&&(r.uploaded=!1,r.upload(t.context))}const Ho={shadowUniformsInitialized:!1,useSingleShadowCascade:!1,tileMatrix:new Float64Array(16),shadowTileMatrix:new Float32Array(16),aabb:new e.bV([0,0,0],[e.Y,e.Y,0])};function Go(t,r){const i=1<<t.canonical.z,n=r.getFreeCameraOptions().position,o=r.elevation,s=t.canonical.x/i,a=(t.canonical.x+1)/i,l=t.canonical.y/i,c=(t.canonical.y+1)/i;let u=r._centerAltitude;if(o){const e=o.getMinMaxForTile(t);e&&e.max>u&&(u=e.max)}const h=e.ad(n.x,s,a)-n.x,d=e.ad(n.y,l,c)-n.y,p=e.bo(u,r.center.lat)-n.z;return r._zoomFromMercatorZ(Math.sqrt(h*h+d*d+p*p))}function Zo(e,t,r,i,n,o,s){const a=e.context,l="shadow"===e.renderPass,c=e.shadowRenderer,u=l&&c?c.getShadowPassDepthMode():new Et(a.gl.LEQUAL,Et.ReadWrite,e.depthRangeFor3D),h=e.isTileAffectedByFog(o);if(r.meshes)for(const d of r.meshes){const p=["MODEL_POSITION_ON_GPU"],f=[];let m,A,g;i.instancedDataArray.length>20&&p.push("INSTANCED_ARRAYS");const _=mi(e,t.paint.get("model-cutoff-fade-range"));if(_.shouldRenderCutoff&&p.push("RENDER_CUTOFF"),l&&c)m=e.getOrCreateProgram("modelDepth",{defines:p}),A=Qn(s.shadowTileMatrix,s.shadowTileMatrix,Float32Array.from(r.matrix)),g=c.getShadowPassColorMode();else{Fo(p,f,d,e),m=e.getOrCreateProgram("model",{defines:p,overrideFog:h});const i=d.material,l=i.pbrMetallicRoughness,u=t.paint.get("model-opacity"),y=t.paint.get("model-emissive-strength").constantOr(0);A=Wn(o.expandedProjMatrix,Float32Array.from(r.matrix),new Float32Array(16),null,e,u,l.baseColorFactor,i.emissiveFactor,l.metallicFactor,l.roughnessFactor,i,y,t,n),c&&(s.shadowUniformsInitialized?m.setShadowUniformValues(a,c.getShadowUniformValues()):(c.setupShadows(o.toUnwrapped(),m,"model-tile",o.overscaledZ),s.shadowUniformsInitialized=!0)),g=_.shouldRenderCutoff||u<1||"OPAQUE"!==i.alphaMode?Pt.alphaBlended:Pt.unblended}e.uploadCommonUniforms(a,m,o.toUnwrapped(),null,_);const y=d.material.doubleSided?Lt.disabled:Lt.backCCW;if(i.instancedDataArray.length>20)f.push(i.instancedDataBuffer),m.draw(e,a.gl.TRIANGLES,u,St.disabled,g,y,A,t.id,d.vertexBuffer,d.indexBuffer,d.segments,t.paint,e.transform.zoom,void 0,f,i.instancedDataArray.length);else{const r=l?"u_instance":"u_normal_matrix";for(let n=0;n<i.instancedDataArray.length;++n)A[r]=new Float32Array(i.instancedDataArray.arrayBuffer,64*n,16),m.draw(e,a.gl.TRIANGLES,u,St.disabled,g,y,A,t.id,d.vertexBuffer,d.indexBuffer,d.segments,t.paint,e.transform.zoom,void 0,f)}}if(r.children)for(const a of r.children)Zo(e,t,a,i,n,o,s)}const Wo=[1,-1,1];function Qo(t,r,i,n){if(!i.modelManager)return!0;const o=i.modelManager;if(!i.shadowRenderer)return!0;const s=i.shadowRenderer,a=r.aabb;let l=!0,c=t.maxHeight;if(0===c){let e=0;for(const r in t.instancesPerModel){const t=o.getModel(r,n);t?e=Math.max(e,Math.max(Math.max(t.aabb.max[0],t.aabb.max[1]),t.aabb.max[2])):l=!1}c=t.maxScale*e*1.41+t.maxVerticalOffset,l&&(t.maxHeight=c)}a.max[2]=c,a.min[2]+=t.terrainElevationMin,a.max[2]+=t.terrainElevationMax,e.Q.transformMat4(a.min,a.min,r.tileMatrix),e.Q.transformMat4(a.max,a.max,r.tileMatrix);const u=a.intersects(s.getCurrentCascadeFrustum());return 0===i.currentShadowCascade&&(t.isInsideFirstShadowMapFrustum=2===u),0===u}class qo{}class Xo{constructor(){this._storage=new Map}getLinesFromTrianglesBuffer(t,r,i){{const e=this._storage.get(r.id);if(e)return e.lastUsedFrameIdx=t,e.buf}const n=i.gl,o=n.getBufferParameter(n.ELEMENT_ARRAY_BUFFER,n.BUFFER_SIZE),s=new ArrayBuffer(o),a=new Int16Array(s);n.getBufferSubData(n.ELEMENT_ARRAY_BUFFER,0,new Int16Array(s));const l=new e.d2;for(let e=0;e<o/2;e+=3){const t=a[e],r=a[e+1],i=a[e+2];l.emplaceBack(t,r),l.emplaceBack(r,i),l.emplaceBack(i,t)}const c=i.bindVertexArrayOES.current,u=new qo;return u.buf=new je(i,l),u.lastUsedFrameIdx=t,this._storage.set(r.id,u),i.bindVertexArrayOES.set(c),u.buf}update(e){for(const[t,r]of this._storage)e-r.lastUsedFrameIdx>30&&(r.buf.destroy(),this._storage.delete(t))}destroy(){for(const[e,t]of this._storage)t.buf.destroy(),this._storage.delete(e)}}const Yo={symbol:function(t,r,i,n,o){if("translucent"!==t.renderPass)return;const s=St.disabled,a=t.colorModeForRenderPass();i.layout.get("text-variable-anchor")&&function(t,r,i,n,o,s,a){const l=r.transform,c="map"===o,u="map"===s;for(const r of t){const t=n.getTile(r),o=t.getBucket(i);if(!o||!o.text||!o.text.segments.get().length)continue;const s=e.b8(o.textSizeData,l.zoom),h=kr(r,o.getProjection(),l),d=l.calculatePixelsToTileUnitsMatrix(t),p=pr(h,t.tileID.canonical,u,c,l,o.getProjection(),d),f=o.hasIconTextFit()&&o.hasIconData();if(s){const i=Math.pow(2,l.zoom-t.tileID.overscaledZ);eo(o,c,u,a,e.cE,l,p,r,i,s,f)}}}(n,t,i,r,i.layout.get("text-rotation-alignment"),i.layout.get("text-pitch-alignment"),o);const l=0!==i.paint.get("icon-opacity").constantOr(1),c=0!==i.paint.get("text-opacity").constantOr(1);void 0!==i.layout.get("symbol-sort-key").constantOr(1)&&(l||c)?to(t,r,i,n,s,a):(l&&to(t,r,i,n,s,a,{onlyIcons:!0}),c&&to(t,r,i,n,s,a,{onlyText:!0})),r.map.showCollisionBoxes&&(Yn(t,r,i,n,i.paint.get("text-translate"),i.paint.get("text-translate-anchor"),!0),Yn(t,r,i,n,i.paint.get("icon-translate"),i.paint.get("icon-translate-anchor"),!1))},circle:function(t,r,i,n){if("translucent"!==t.renderPass)return;const o=i.paint.get("circle-opacity"),s=i.paint.get("circle-stroke-width"),a=i.paint.get("circle-stroke-opacity"),l=void 0!==i.layout.get("circle-sort-key").constantOr(1),c=i.paint.get("circle-emissive-strength");if(0===o.constantOr(1)&&(0===s.constantOr(1)||0===a.constantOr(1)))return;const u=t.context,h=u.gl,d=t.transform,p=t.depthModeForSublayer(0,Et.ReadOnly),f=St.disabled,m=t.colorModeForDrapableLayerRenderPass(c),A="globe"===d.projection.name,g=[e.a8(d.center.lng),e.ah(d.center.lat)],_=[];for(let o=0;o<n.length;o++){const s=n[o],a=r.getTile(s),c=a.getBucket(i);if(!c||c.projection.name!==d.projection.name)continue;const u=c.programConfigurations.get(i.id),h=e.cF(i),p=t.isTileAffectedByFog(s);A&&h.push("PROJECTION_GLOBE_VIEW");const f=t.getOrCreateProgram("circle",{config:u,defines:h,overrideFog:p}),m=c.layoutVertexBuffer,y=c.globeExtVertexBuffer,x=c.indexBuffer,v=d.projection.createInversionMatrix(d,s.canonical),b={programConfiguration:u,program:f,layoutVertexBuffer:m,globeExtVertexBuffer:y,indexBuffer:x,uniformValues:e.cG(t,s,a,v,g,i),tile:a};if(l){const t=c.segments.get();for(const r of t)_.push({segments:new e.aE([r]),sortKey:r.sortKey,state:b})}else _.push({segments:c.segments,sortKey:0,state:b})}l&&_.sort(((e,t)=>e.sortKey-t.sortKey));const y={useDepthForOcclusion:d.depthOcclusionForSymbolsAndCircles};for(const e of _){const{programConfiguration:r,program:n,layoutVertexBuffer:o,globeExtVertexBuffer:s,indexBuffer:a,uniformValues:l,tile:c}=e.state,A=e.segments;t.terrain&&t.terrain.setupElevationDraw(c,n,y),t.uploadCommonUniforms(u,n,c.tileID.toUnwrapped()),n.draw(t,h.TRIANGLES,p,f,m,Lt.disabled,l,i.id,o,a,A,i.paint,d.zoom,r,[s])}},heatmap:function(t,r,i,n){if(0!==i.paint.get("heatmap-opacity"))if("offscreen"===t.renderPass){const o=t.context,s=o.gl,a=St.disabled,l=new Pt([s.ONE,s.ONE,s.ONE,s.ONE],e.aA.transparent,[!0,!0,!0,!0]);!function(e,t,r,i){const n=e.gl,o=t.width*i,s=t.height*i;e.activeTexture.set(n.TEXTURE1),e.viewport.set([0,0,o,s]);let a=r.heatmapFbo;if(!a||a&&(a.width!==o||a.height!==s)){a&&a.destroy();const t=n.createTexture();n.bindTexture(n.TEXTURE_2D,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),a=r.heatmapFbo=e.createFramebuffer(o,s,!0,null),function(e,t,r,i,n,o){const s=e.gl;s.texImage2D(s.TEXTURE_2D,0,e.extRenderToTextureHalfFloat?s.RGBA16F:s.RGBA,n,o,0,s.RGBA,e.extRenderToTextureHalfFloat?s.HALF_FLOAT:s.UNSIGNED_BYTE,null),i.colorAttachment.set(r)}(e,0,t,a,o,s)}else n.bindTexture(n.TEXTURE_2D,a.colorAttachment.get()),e.bindFramebuffer.set(a.framebuffer)}(o,t,i,"globe"===t.transform.projection.name?.5:.25),o.clear({color:e.aA.transparent});const c=t.transform,u="globe"===c.projection.name,h=u?["PROJECTION_GLOBE_VIEW"]:[],d=u?Lt.frontCCW:Lt.disabled,p=[e.a8(c.center.lng),e.ah(c.center.lat)];for(let e=0;e<n.length;e++){const f=n[e];if(r.hasRenderableParent(f))continue;const m=r.getTile(f),A=m.getBucket(i);if(!A||A.projection.name!==c.projection.name)continue;const g=t.isTileAffectedByFog(f),_=A.programConfigurations.get(i.id),y=t.getOrCreateProgram("heatmap",{config:_,defines:h,overrideFog:g}),{zoom:x}=t.transform;t.terrain&&t.terrain.setupElevationDraw(m,y),t.uploadCommonUniforms(o,y,f.toUnwrapped());const v=c.projection.createInversionMatrix(c,f.canonical);y.draw(t,s.TRIANGLES,Et.disabled,a,l,d,Dn(t,f,m,v,p,x,i.paint.get("heatmap-intensity")),i.id,A.layoutVertexBuffer,A.indexBuffer,A.segments,i.paint,t.transform.zoom,_,u?[A.globeExtVertexBuffer]:null)}o.viewport.set([0,0,t.width,t.height])}else"translucent"===t.renderPass&&(t.context.setColorMode(t.colorModeForRenderPass()),function(t,r){const i=t.context,n=i.gl,o=r.heatmapFbo;if(!o)return;i.activeTexture.set(n.TEXTURE0),n.bindTexture(n.TEXTURE_2D,o.colorAttachment.get()),i.activeTexture.set(n.TEXTURE1);let s=r.colorRampTexture;s||(s=r.colorRampTexture=new e.T(i,r.colorRamp,n.RGBA)),s.bind(n.LINEAR,n.CLAMP_TO_EDGE),t.getOrCreateProgram("heatmapTexture").draw(t,n.TRIANGLES,Et.disabled,St.disabled,t.colorModeForRenderPass(),Lt.disabled,((e,t,r,i)=>({u_image:0,u_color_ramp:1,u_opacity:t.paint.get("heatmap-opacity")}))(0,r),r.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,r.paint,t.transform.zoom)}(t,i))},line:function(t,r,i,n){if("translucent"!==t.renderPass)return;const o=i.paint.get("line-opacity"),s=i.paint.get("line-width");if(0===o.constantOr(1)||0===s.constantOr(1))return;const a=i.paint.get("line-emissive-strength"),l=t.depthModeForSublayer(0,Et.ReadOnly),c=t.colorModeForDrapableLayerRenderPass(a),u=t.terrain&&t.terrain.renderingToTexture?1:e.f.devicePixelRatio,h=i.paint.get("line-dasharray"),d=h.constantOr(1),p=i.layout.get("line-cap"),f=i.paint.get("line-pattern"),m=f.constantOr(1),A=1!==i.paint.get("line-opacity").constantOr(1);let g=!m&&A;const _=i.paint.get("line-gradient"),y=m?"linePattern":"line",x=t.context,v=x.gl,b=e.cH(i);t.terrain&&t.terrain.clipOrMaskOverlapStencilType()&&(g=!1);for(const o of n){const n=r.getTile(o);if(m&&!n.patternsLoaded())continue;const s=n.getBucket(i);if(!s)continue;t.prepareDrawTile();const a=s.programConfigurations.get(i.id),A=t.isTileAffectedByFog(o),w=t.getOrCreateProgram(y,{config:a,defines:b,overrideFog:A}),C=f.constantOr(null);if(C&&n.imageAtlas){const e=n.imageAtlas.patternPositions[C.toString()];e&&a.setConstantPatternPositions(e)}const T=h.constantOr(null),E=p.constantOr(null);if(!m&&T&&E&&n.lineAtlas){const e=n.lineAtlas.getDash(T,E);e&&a.setConstantPatternPositions(e)}let[M,S]=i.paint.get("line-trim-offset");if("round"===E||"square"===E){const e=1;M!==S&&(0===M&&(M-=e),1===S&&(S+=e))}const I=t.terrain?o.projMatrix:null,P=m?e.cI(t,n,i,I,u,[M,S]):e.cJ(t,n,i,I,s.lineClipsArray.length,u,[M,S]);if(_){const n=s.gradients[i.id];let a=n.texture;if(i.gradientVersion!==n.version){let l=256;if(i.stepInterpolant){const i=r.getSource().maxzoom,n=o.canonical.z===i?Math.ceil(1<<t.transform.maxZoom-o.canonical.z):1;l=e.ad(e.cK(s.maxLineLength/e.Y*1024*n),256,x.maxTextureSize)}n.gradient=e.cL({expression:i.gradientExpression(),evaluationKey:"lineProgress",resolution:l,image:n.gradient||void 0,clips:s.lineClipsArray}),n.texture?n.texture.update(n.gradient):n.texture=new e.T(x,n.gradient,v.RGBA),n.version=i.gradientVersion,a=n.texture}x.activeTexture.set(v.TEXTURE1),a.bind(i.stepInterpolant?v.NEAREST:v.LINEAR,v.CLAMP_TO_EDGE)}d&&(x.activeTexture.set(v.TEXTURE0),n.lineAtlasTexture&&n.lineAtlasTexture.bind(v.LINEAR,v.REPEAT),a.updatePaintBuffers()),m&&(x.activeTexture.set(v.TEXTURE0),n.imageAtlasTexture&&n.imageAtlasTexture.bind(v.LINEAR,v.CLAMP_TO_EDGE),a.updatePaintBuffers()),t.uploadCommonUniforms(x,w,o.toUnwrapped());const D=e=>{w.draw(t,v.TRIANGLES,l,e,c,Lt.disabled,P,i.id,s.layoutVertexBuffer,s.indexBuffer,s.segments,i.paint,t.transform.zoom,a,[s.layoutVertexBuffer2,s.patternVertexBuffer])};if(g){const e=t.stencilModeForClipping(o).ref;0===e&&t.terrain&&x.clear({stencil:0});const r={func:v.EQUAL,mask:255};P.u_alpha_discard_threshold=.8,D(new St(r,e,255,v.KEEP,v.KEEP,v.INVERT)),P.u_alpha_discard_threshold=0,D(new St(r,e,255,v.KEEP,v.KEEP,v.KEEP))}else D(t.stencilModeForClipping(o))}g&&(t.resetStencilClippingMasks(),t.terrain&&x.clear({stencil:0}))},fill:function(t,r,i,n){const o=i.paint.get("fill-color"),s=i.paint.get("fill-opacity");if(0===s.constantOr(1))return;const a=i.paint.get("fill-emissive-strength"),l=t.colorModeForDrapableLayerRenderPass(a),c=i.paint.get("fill-pattern"),u=t.opaquePassEnabledForLayer()&&!c.constantOr(1)&&1===o.constantOr(e.aA.transparent).a&&1===s.constantOr(0)?"opaque":"translucent";if(t.renderPass===u){const e=t.depthModeForSublayer(1,"opaque"===t.renderPass?Et.ReadWrite:Et.ReadOnly);io(t,r,i,n,e,l,!1)}if("translucent"===t.renderPass&&i.paint.get("fill-antialias")){const e=t.depthModeForSublayer(i.getPaintProperty("fill-outline-color")?2:0,Et.ReadOnly);io(t,r,i,n,e,l,!0)}},"fill-extrusion":function(t,r,i,n){const o=i.paint.get("fill-extrusion-opacity"),s=t.context,a=s.gl,l=t.terrain,c=l&&l.renderingToTexture;if(0===o)return;const u=t.conflationActive&&t.layerUsedInConflation(i,r.getSource());if(u&&function(e,t,r,i){for(const n of i){const i=t.getTile(n).getBucket(r);i&&(i.updateReplacement(n,e.replacementSource),i.uploadCentroid(e.context))}}(t,r,i,n),l||u)for(const e of n){const n=r.getTile(e).getBucket(i);n&&so(t.context,r,e,n,i,l,u)}if("shadow"===t.renderPass&&t.shadowRenderer){const s=t.shadowRenderer;if(l&&o<.65&&i._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof e.Z)return;const a=s.getShadowPassDepthMode(),c=s.getShadowPassColorMode();no(t,r,i,n,a,St.disabled,c,u)}else if("translucent"===t.renderPass){const h=!i.paint.get("fill-extrusion-pattern").constantOr(1),d=i.paint.get("fill-extrusion-color").constantOr(e.aA.white);if(!c&&0!==d.a){const e=new Et(t.context.gl.LEQUAL,Et.ReadWrite,t.depthRangeFor3D);1===o&&h?no(t,r,i,n,e,St.disabled,Pt.unblended,u):(no(t,r,i,n,e,St.disabled,Pt.disabled,u),no(t,r,i,n,e,t.stencilModeFor3D(),t.colorModeForRenderPass(),u),t.resetStencilClippingMasks())}if(t.style.enable3dLights()&&h&&(!l&&"globe"!==t.transform.projection.name||c)){const o=i.paint.get("fill-extrusion-opacity"),h=i.paint.get("fill-extrusion-ambient-occlusion-intensity"),d=i.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),p=i.paint.get("fill-extrusion-flood-light-intensity"),f=i.paint.get("fill-extrusion-flood-light-color").toArray01().slice(0,3),m=h>0&&d>0,A=p>0,g=(e,t,r)=>(1-r)*e+r*t,_=s=>{const l=t.depthModeForSublayer(1,Et.ReadOnly,a.LEQUAL,!0),c=i.paint.get(s?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),m=g(.1,3,c),A=t._showOverdrawInspector;if(!A){const c=new St({func:a.ALWAYS,mask:255},255,255,a.KEEP,a.KEEP,a.REPLACE),A=new Pt([a.ONE,a.ONE,a.ONE,a.ONE],e.aA.transparent,[!1,!1,!1,!0],a.MIN);oo(t,r,i,n,l,c,A,Lt.disabled,s,"sdf",o,h,d,p,f,m,u,!1)}{const c=A?St.disabled:new St({func:a.EQUAL,mask:255},255,255,a.KEEP,a.DECR,a.DECR),g=A?t.colorModeForRenderPass():new Pt([a.ONE_MINUS_DST_ALPHA,a.DST_ALPHA,a.ONE,a.ONE],e.aA.transparent,[!0,!0,!0,!0]);oo(t,r,i,n,l,c,g,Lt.disabled,s,"color",o,h,d,p,f,m,u,!1)}};if(c){const c=(s,l,c)=>{const m=t.depthModeForSublayer(1,Et.ReadOnly,a.LEQUAL,!1),A=i.paint.get(s?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),_=g(.1,3,A);{const c=new Pt([a.ONE,a.ONE,a.ONE,a.ONE],e.aA.transparent,[!1,!1,!1,!0]);oo(t,r,i,n,m,St.disabled,c,Lt.disabled,s,"clear",o,h,d,p,f,_,u,l)}{const c=new St({func:a.ALWAYS,mask:255},255,255,a.KEEP,a.KEEP,a.REPLACE),A=new Pt([a.ONE,a.ONE,a.ONE,a.ONE],e.aA.transparent,[!1,!1,!1,!0],a.MIN);oo(t,r,i,n,m,c,A,Lt.disabled,s,"sdf",o,h,d,p,f,_,u,l)}{const c=s?a.ZERO:a.ONE_MINUS_DST_ALPHA,A=new St({func:a.EQUAL,mask:255},255,255,a.KEEP,a.DECR,a.DECR),g=new Pt([c,a.DST_ALPHA,a.ONE_MINUS_DST_ALPHA,a.ZERO],e.aA.transparent,[!0,!0,!0,!0]);oo(t,r,i,n,m,A,g,Lt.disabled,s,"color",o,h,d,p,f,_,u,l)}{const A=new Pt([a.ONE,a.ONE,a.ONE,s?a.ZERO:a.ONE],e.aA.transparent,[!1,!1,!1,!0],s?a.FUNC_ADD:a.MAX);oo(t,r,i,n,m,St.disabled,A,Lt.disabled,s,"clear",o,h,d,p,f,_,u,l,c)}};if(m||A){let r;if(t.prepareDrawTile(),l){const t=l.drapeBufferSize[0],i=l.drapeBufferSize[1];r=l.framebufferCopyTexture,r&&(!r||r.size[0]===t&&r.size[1]===i)||(r&&r.destroy(),r=l.framebufferCopyTexture=new e.T(s,new e.h({width:t,height:i}),a.RGBA)),r.bind(a.LINEAR,a.CLAMP_TO_EDGE),a.copyTexImage2D(a.TEXTURE_2D,0,a.RGBA,0,0,t,i,0)}m&&c(!0,!1,r),A&&c(!1,!0,r)}}else m&&_(!0),A&&_(!1)}}},hillshade:function(e,t,r,i){if("offscreen"!==e.renderPass&&"translucent"!==e.renderPass)return;if(e.style.disableElevatedTerrain)return;const n=e.context,o=e.terrain&&e.terrain.renderingToTexture,[s,a]="translucent"!==e.renderPass||o?[{},i]:e.stencilConfigForOverlap(i);for(const i of a){const n=t.getTile(i);if(n.needsHillshadePrepare&&"offscreen"===e.renderPass)Ji(e,n,r);else if("translucent"===e.renderPass){const t=e.depthModeForSublayer(0,Et.ReadOnly),a=r.paint.get("hillshade-emissive-strength"),l=e.colorModeForDrapableLayerRenderPass(a),c=o&&e.terrain?e.terrain.stencilModeForRTTOverlap(i):s[i.overscaledZ];$i(e,i,n,r,t,c,l)}}n.viewport.set([0,0,e.width,e.height]),e.resetStencilClippingMasks()},raster:function(t,r,i,n,o,s){if("translucent"!==t.renderPass)return;if(0===i.paint.get("raster-opacity"))return;const a="globe"===t.transform.projection.name,l=0!==i.paint.get("raster-elevation"),c=l&&a;if(t.renderElevatedRasterBackface&&!c)return;const u=t.context,h=u.gl,d=r.getSource(),p=function(t,r,i,n){const o=r.paint.get("raster-color"),s="raster-array"===t.type,a=[],l=r.paint.get("raster-resampling"),c=r.paint.get("raster-color-mix");let u=r.paint.get("raster-color-range");const h=[c[0],c[1],c[2],0],d=c[3];let p="nearest"===l?n.NEAREST:n.LINEAR;if(s&&(a.push("RASTER_ARRAY"),o||a.push("RASTER_COLOR"),"linear"===l&&a.push("RASTER_ARRAY_LINEAR"),p=n.NEAREST,!u&&t.rasterLayers)){const e=t.rasterLayers.find((({id:e})=>e===r.sourceLayer));e&&e.fields&&e.fields.range&&(u=e.fields.range)}if(u=u||[0,1],o){a.push("RASTER_COLOR"),i.activeTexture.set(n.TEXTURE2),r.updateColorRamp(u);let t=r.colorRampTexture;t||(t=r.colorRampTexture=new e.T(i,r.colorRamp,n.RGBA)),t.bind(n.LINEAR,n.CLAMP_TO_EDGE)}return{mix:h,range:u,offset:d,defines:a,resampling:p}}(d,i,u,h);if(d instanceof e.as&&!n.length&&!a)return;const f=i.paint.get("raster-emissive-strength"),m=t.colorModeForDrapableLayerRenderPass(f),A=t.terrain&&t.terrain.renderingToTexture,g=!t.options.moving,_="nearest"===i.paint.get("raster-resampling")?h.NEAREST:h.LINEAR;if(d instanceof e.as&&!n.length&&(d.onNorthPole||d.onSouthPole)){const e=l?t.stencilModeFor3D():St.disabled;return void po(!!d.onNorthPole,null,t,r,i,f,p,Lt.disabled,e)}if(!n.length)return;const[y,x]=d instanceof e.as||A?[{},n]:t.stencilConfigForOverlap(n),v=x[x.length-1].overscaledZ;c&&p.defines.push("PROJECTION_GLOBE_VIEW"),l&&p.defines.push("RENDER_CUTOFF");const b=(n,o,x)=>{for(const b of n){const n=b.toUnwrapped(),w=r.getTile(b);if(A&&(!w||!w.hasData()))continue;u.activeTexture.set(h.TEXTURE0);const C=mo(w,d,i,p);if(!C||!C.texture)continue;const{texture:T,mix:E,offset:M,tileSize:S,buffer:I}=C;let P,D;A?(P=Et.disabled,D=b.projMatrix):l?(P=new Et(h.LEQUAL,Et.ReadWrite,t.depthRangeFor3D),D=a?Float32Array.from(t.transform.expandedFarZProjMatrix):t.transform.calculateProjMatrix(n,g)):(P=t.depthModeForSublayer(b.overscaledZ-v,1===i.paint.get("raster-opacity")?Et.ReadWrite:Et.ReadOnly,h.LESS),D=t.transform.calculateProjMatrix(n,g));const k=t.terrain&&A?t.terrain.stencilModeForRTTOverlap(b):y[b.overscaledZ],L=s?0:i.paint.get("raster-fade-duration");w.registerFadeDuration(L);const z=r.findLoadedParent(b,0),O=un(w,z,r,t.transform,L);let B,R;t.terrain&&t.terrain.prepareDrawTile(),u.activeTexture.set(h.TEXTURE0),T.bind(_,h.CLAMP_TO_EDGE),u.activeTexture.set(h.TEXTURE1),z?(z.texture&&z.texture.bind(_,h.CLAMP_TO_EDGE),B=Math.pow(2,z.tileID.overscaledZ-w.tileID.overscaledZ),R=[w.tileID.canonical.x*B%1,w.tileID.canonical.y*B%1]):T.bind(_,h.CLAMP_TO_EDGE),T.useMipmap&&u.extTextureFilterAnisotropic&&t.transform.pitch>20&&h.texParameterf(h.TEXTURE_2D,u.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,u.extTextureFilterAnisotropicMax);const F=t.transform;let j;const V=l?fo(F):[0,0,0,0];let N,U,H,G,Z,W=0;if(c&&d instanceof e.as&&d.coordinates.length>3)N=Float32Array.from(e.aW(e.cn(new e.bv(0,0,0)))),U=Float32Array.from(F.globeMatrix),H=Float32Array.from(e.cj(F)),G=[e.a8(F.center.lng),e.ah(F.center.lat)],j=d.elevatedGlobePerspectiveTransform,Z=d.elevatedGlobeGridMatrix||new Float32Array(9);else if(c){const t=e.ck(b.canonical);W=e.cl(t.getCenter().lat),N=Float32Array.from(e.aW(e.cn(b.canonical))),U=Float32Array.from(F.globeMatrix),H=Float32Array.from(e.cj(F)),G=[e.a8(F.center.lng),e.ah(F.center.lat)],j=[0,0],Z=Float32Array.from(e.cm(b.canonical,t,W,F.worldSize/F._pixelsPerMercatorPixel))}else j=d instanceof e.as?d.perspectiveTransform:[0,0],N=new Float32Array(16),U=new Float32Array(9),H=new Float32Array(16),G=[0,0],Z=new Float32Array(9);const Q=zn(D,N,U,H,Z,R||[0,0],e.W(t.transform.zoom),G,V,B||1,O,i,j,l?i.paint.get("raster-elevation"):0,2,E,M,p.range,S,I,f),q=t.isTileAffectedByFog(b),X=t.getOrCreateProgram("raster",{defines:p.defines,overrideFog:q});if(t.uploadCommonUniforms(u,X,n),d instanceof e.as){const r=d.elevatedGlobeVertexBuffer,n=d.elevatedGlobeIndexBuffer;if(A||!a)d.boundsBuffer&&d.boundsSegments&&X.draw(t,h.TRIANGLES,P,St.disabled,m,Lt.disabled,Q,i.id,d.boundsBuffer,t.quadTriangleIndexBuffer,d.boundsSegments);else if(r&&n){const s=F.zoom<=e.bJ?d.elevatedGlobeSegments:d.getSegmentsForLongitude(F.center.lng);s&&X.draw(t,h.TRIANGLES,P,St.disabled,m,o,Q,i.id,r,n,s)}}else if(c){P=new Et(h.LEQUAL,Et.ReadOnly,t.depthRangeFor3D);const e=t.globeSharedBuffers;if(e){const[r,n,s]=e.getGridBuffers(W,!1);X.draw(t,h.TRIANGLES,P,x||k,t.colorModeForRenderPass(),o,Q,i.id,r,n,s)}}else{const{tileBoundsBuffer:e,tileBoundsIndexBuffer:r,tileBoundsSegments:n}=t.getTileBoundsBuffers(w);X.draw(t,h.TRIANGLES,P,k,m,Lt.disabled,Q,i.id,e,r,n)}}if(!(d instanceof e.as)&&c)for(const e of n){const n=e.canonical.y===(1<<e.canonical.z)-1;0===e.canonical.y&&po(!0,e,t,r,i,f,p,o,x||St.disabled),n&&po(!1,e,t,r,i,f,p,o===Lt.frontCW?Lt.backCW:Lt.frontCW,x||St.disabled)}};c?b(x,t.renderElevatedRasterBackface?Lt.backCW:Lt.frontCW,t.stencilModeFor3D()):b(x,Lt.disabled,void 0),t.resetStencilClippingMasks()},"raster-particle":function(t,r,i,n,o,s){"offscreen"===t.renderPass&&function(t,r,i,n){if(!n.length)return;const o=t.context,s=o.gl,a=r.getSource();if(!(a instanceof De))return;const l=Math.ceil(Math.sqrt(i.paint.get("raster-particle-count")));let c=i.particleFramebuffer;c?c.width!==l&&(c.destroy(),c=i.particleFramebuffer=o.createFramebuffer(l,l,!0,null)):c=i.particleFramebuffer=o.createFramebuffer(l,l,!0,null);const u=[];for(const e of n){const t=r.getTile(e);if(!(t instanceof Wt))continue;const n=Ao(t,a,i);if(!n)continue;const s=[t.tileSize,t.tileSize];let c=i.tileFramebuffer;c||(c=i.tileFramebuffer=o.createFramebuffer(s[0],s[1],!0,null));let h=t.rasterParticleState;h||(h=t.rasterParticleState=new Rt(o,e,s,l));const d=h.update(i.lastInvalidatedAt);h.particleTextureDimension!==l&&h.setParticleTextureDimension(e,l);const p=h.targetColorTexture;h.targetColorTexture=h.backgroundColorTexture,h.backgroundColorTexture=p;const f=h.particleTexture0;h.particleTexture0=h.particleTexture1,h.particleTexture1=f,u.push([e,n,h,d])}if(0===u.length)return;const h=e.f.now(),d=i.previousDrawTimestamp?.001*(h-i.previousDrawTimestamp):.0167;if(i.previousDrawTimestamp=h,i.hasColorMap()){o.activeTexture.set(s.TEXTURE0+2);let t=i.colorRampTexture;t||(t=i.colorRampTexture=new e.T(o,i.colorRamp,s.RGBA)),t.bind(s.LINEAR,s.CLAMP_TO_EDGE)}o.bindFramebuffer.set(i.tileFramebuffer.framebuffer),function(t,r,i){const n=t.context,o=n.gl,s=r.tileFramebuffer;n.activeTexture.set(o.TEXTURE0);const a={u_texture:0,u_opacity:1.05*(c=r.paint.get("raster-particle-fade-opacity-factor"))/(c+.05)},l=t.getOrCreateProgram("rasterParticleTexture",{defines:[],overrideFog:!1});var c;for(const c of i){const[,,i,u]=c;s.colorAttachment.set(i.targetColorTexture.texture),n.viewport.set([0,0,s.width,s.height]),n.clear({color:e.aA.transparent}),u&&(i.backgroundColorTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE),l.draw(t,o.TRIANGLES,Et.disabled,St.disabled,Pt.alphaBlended,Lt.disabled,a,r.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments))}}(t,i,u),function(t,r,i,n){const o=t.context,s=o.gl,a=i.tileFramebuffer,l="globe"===t.transform.projection.name,c=i.paint.get("raster-particle-max-speed");for(const u of n){const[n,h,d]=u;o.activeTexture.set(s.TEXTURE0+0),h.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE),a.colorAttachment.set(d.targetColorTexture.texture);const p=t.getOrCreateProgram("rasterParticleDraw",{defines:h.defines,overrideFog:!1});o.activeTexture.set(s.TEXTURE0+1);const f=h.scalarData?[]:[0,1,2,3].map((t=>e.cN[t](n)));f.push(n);const m=n.canonical.x,A=n.canonical.y;for(const e of f){const o=r.getTile(l?e.wrapped():e);if(!o)continue;const a=o.rasterParticleState;if(!a)continue;const u=e.canonical.x+(1<<e.canonical.z)*(e.wrap-n.wrap),d=e.canonical.y;a.particleTexture0.bind(s.NEAREST,s.CLAMP_TO_EDGE);const f=Rn(1,a.particleTexture0.size[0],[u-m,d-A],0,h.texture.size,2,c,h.textureOffset,h.scale,h.offset);p.draw(t,s.POINTS,Et.disabled,St.disabled,Pt.alphaBlended,Lt.disabled,f,i.id,a.particleIndexBuffer,void 0,a.particleSegment)}}}(t,r,i,u),o.bindFramebuffer.set(i.particleFramebuffer.framebuffer),function(t,r,i,n){const o=t.context,s=o.gl,a=r.paint.get("raster-particle-max-speed"),l=n*r.paint.get("raster-particle-speed-factor")*.3,c=function(e){return Math.pow(e,6)}(.01+1*r.paint.get("raster-particle-reset-rate-factor")),u=r.particleFramebuffer;o.viewport.set([0,0,u.width,u.height]);for(const n of i){const[,i,h]=n;o.activeTexture.set(s.TEXTURE0+0),i.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE),o.activeTexture.set(s.TEXTURE0+1);const d=h.particleTexture0;d.bind(s.NEAREST,s.CLAMP_TO_EDGE);const p=Fn(1,d.size[0],0,i.texture.size,a,l,c,i.textureOffset,i.scale,i.offset);u.colorAttachment.set(h.particleTexture1.texture),o.clear({color:e.aA.transparent}),t.getOrCreateProgram("rasterParticleUpdate",{defines:i.defines}).draw(t,s.TRIANGLES,Et.disabled,St.disabled,Pt.unblended,Lt.disabled,p,r.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments)}}(t,i,u,d)}(t,r,i,n),"translucent"===t.renderPass&&(function(t,r,i,n,o){const s=t.context,a=s.gl,l=!t.options.moving,c="globe"===t.transform.projection.name;if(!n.length)return;const[u,h]=t.stencilConfigForOverlap(n),d=[];c&&d.push("PROJECTION_GLOBE_VIEW");const p=t.stencilModeFor3D();for(const n of h){const o=n.toUnwrapped(),h=r.getTile(n);if(!h.rasterParticleState)continue;const f=h.rasterParticleState,m=100;h.registerFadeDuration(m);const A=r.findLoadedParent(n,0),g=un(h,A,r,t.transform,m);let _,y;t.terrain&&t.terrain.prepareDrawTile(),s.activeTexture.set(a.TEXTURE0),f.targetColorTexture.bind(a.LINEAR,a.CLAMP_TO_EDGE),s.activeTexture.set(a.TEXTURE1),A&&A.rasterParticleState?(A.rasterParticleState.targetColorTexture.bind(a.LINEAR,a.CLAMP_TO_EDGE),_=Math.pow(2,A.tileID.overscaledZ-h.tileID.overscaledZ),y=[h.tileID.canonical.x*_%1,h.tileID.canonical.y*_%1]):f.targetColorTexture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const x=c?Float32Array.from(t.transform.expandedFarZProjMatrix):t.transform.calculateProjMatrix(o,l),v=t.transform,b=go(v),w=e.ck(n.canonical),C=e.cl(w.getCenter().lat);let T,E,M,S,I;c?(T=Float32Array.from(e.aW(e.cn(n.canonical))),E=Float32Array.from(v.globeMatrix),M=Float32Array.from(e.cj(v)),S=[e.a8(v.center.lng),e.ah(v.center.lat)],I=Float32Array.from(e.cm(n.canonical,w,C,v.worldSize/v._pixelsPerMercatorPixel))):(T=new Float32Array(16),E=new Float32Array(9),M=new Float32Array(16),S=[0,0],I=new Float32Array(9));const P=Bn(x,T,E,M,I,y||[0,0],e.W(t.transform.zoom),S,b,_||1,g,250),D=t.isTileAffectedByFog(n),k=t.getOrCreateProgram("rasterParticle",{defines:d,overrideFog:D});if(t.uploadCommonUniforms(s,k,o),c){const e=new Et(a.LEQUAL,Et.ReadWrite,t.depthRangeFor3D),r=0,n=t.globeSharedBuffers;if(n){const[o,s,l]=n.getGridBuffers(C,0!==r);k.draw(t,a.TRIANGLES,e,p,Pt.alphaBlended,Lt.backCCW,P,i.id,o,s,l)}}else{const e=t.depthModeForSublayer(0,Et.ReadOnly),r=u[n.overscaledZ],{tileBoundsBuffer:o,tileBoundsIndexBuffer:s,tileBoundsSegments:l}=t.getTileBoundsBuffers(h);k.draw(t,a.TRIANGLES,e,r,Pt.alphaBlended,Lt.disabled,P,i.id,o,s,l)}}t.resetStencilClippingMasks()}(t,r,i,n),t.style.map.triggerRepaint())},background:function(e,t,r,i){const n=r.paint.get("background-color"),o=r.paint.get("background-opacity"),s=r.paint.get("background-emissive-strength");if(0===o)return;const a=e.context,l=a.gl,c=e.transform,u=c.tileSize,h=r.paint.get("background-pattern");if(e.isPatternMissing(h,r.scope))return;const d=!h&&1===n.a&&1===o&&e.opaquePassEnabledForLayer()?"opaque":"translucent";if(e.renderPass!==d)return;const p=St.disabled,f=e.depthModeForSublayer(0,"opaque"===d?Et.ReadWrite:Et.ReadOnly),m=e.colorModeForDrapableLayerRenderPass(s),A=h?"backgroundPattern":"background";let g,_=i;_||(g=e.getBackgroundTiles(),_=Object.values(g).map((e=>e.tileID))),h&&(a.activeTexture.set(l.TEXTURE0),e.imageManager.bind(e.context,r.scope));for(const d of _){const _=e.isTileAffectedByFog(d),y=e.getOrCreateProgram(A,{overrideFog:_}),x=d.toUnwrapped(),v=i?d.projMatrix:e.transform.calculateProjMatrix(x);e.prepareDrawTile();const b=t?t.getTile(d):g?g[d.key]:new jt(d,u,c.zoom,e),w=h?Gn(v,s,o,e,h,r.scope,{tileID:d,tileSize:u}):Hn(v,s,o,n);e.uploadCommonUniforms(a,y,x);const{tileBoundsBuffer:C,tileBoundsIndexBuffer:T,tileBoundsSegments:E}=e.getTileBoundsBuffers(b);y.draw(e,l.TRIANGLES,f,p,m,Lt.disabled,w,r.id,C,T,E)}},sky:function(t,r,i){const n=t._atmosphere?e.W(t.transform.zoom):1,o=i.paint.get("sky-opacity")*n;if(0===o)return;const s=t.context,a=i.paint.get("sky-type"),l=new Et(s.gl.LEQUAL,Et.ReadOnly,[0,1]),c=t.frameCounter/1e3%1;"atmosphere"===a?"offscreen"===t.renderPass?i.needsSkyboxCapture(t)&&(function(t,r,i,n){const o=t.context,s=o.gl;let a=r.skyboxFbo;if(!a){a=r.skyboxFbo=o.createFramebuffer(32,32,!0,null),r.skyboxGeometry=new Po(o),r.skyboxTexture=o.gl.createTexture(),s.bindTexture(s.TEXTURE_CUBE_MAP,r.skyboxTexture),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MAG_FILTER,s.LINEAR);for(let e=0;e<6;++e)s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,s.RGBA,32,32,0,s.RGBA,s.UNSIGNED_BYTE,null)}o.bindFramebuffer.set(a.framebuffer),o.viewport.set([0,0,32,32]);const l=r.getCenter(t,!0),c=t.getOrCreateProgram("skyboxCapture"),u=new Float64Array(16);e.a9.identity(u),e.a9.rotateY(u,u,.5*-Math.PI),Do(t,r,c,u,l,0),e.a9.identity(u),e.a9.rotateY(u,u,.5*Math.PI),Do(t,r,c,u,l,1),e.a9.identity(u),e.a9.rotateX(u,u,.5*-Math.PI),Do(t,r,c,u,l,2),e.a9.identity(u),e.a9.rotateX(u,u,.5*Math.PI),Do(t,r,c,u,l,3),e.a9.identity(u),Do(t,r,c,u,l,4),e.a9.identity(u),e.a9.rotateY(u,u,Math.PI),Do(t,r,c,u,l,5),o.viewport.set([0,0,t.width,t.height])}(t,i),i.markSkyboxValid(t)):"sky"===t.renderPass&&function(e,t,r,i,n){const o=e.context,s=o.gl,a=e.transform,l=e.getOrCreateProgram("skybox");o.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_CUBE_MAP,t.skyboxTexture);const c=((e,t,r,i,n)=>({u_matrix:e,u_sun_direction:t,u_cubemap:0,u_opacity:i,u_temporal_offset:n}))(a.skyboxMatrix,t.getCenter(e,!1),0,i,n);e.uploadCommonUniforms(o,l),l.draw(e,s.TRIANGLES,r,St.disabled,e.colorModeForRenderPass(),Lt.backCW,c,"skybox",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment)}(t,i,l,o,c):"gradient"===a&&"sky"===t.renderPass&&function(t,r,i,n,o){const s=t.context,a=s.gl,l=t.transform,c=t.getOrCreateProgram("skyboxGradient");r.skyboxGeometry||(r.skyboxGeometry=new Po(s)),s.activeTexture.set(a.TEXTURE0);let u=r.colorRampTexture;u||(u=r.colorRampTexture=new e.T(s,r.colorRamp,a.RGBA)),u.bind(a.LINEAR,a.CLAMP_TO_EDGE);const h=((t,r,i,n,o)=>({u_matrix:t,u_color_ramp:0,u_center_direction:r,u_radius:e.bm(i),u_opacity:n,u_temporal_offset:o}))(l.skyboxMatrix,r.getCenter(t,!1),r.paint.get("sky-gradient-radius"),n,o);t.uploadCommonUniforms(s,c),c.draw(t,a.TRIANGLES,i,St.disabled,t.colorModeForRenderPass(),Lt.backCW,h,"skyboxGradient",r.skyboxGeometry.vertexBuffer,r.skyboxGeometry.indexBuffer,r.skyboxGeometry.segment)}(t,i,l,o,c)},debug:function(t,r,i,n,o,s){for(let a=0;a<i.length;a++)if(o){const o=1,l=.8,c=new e.aA(n.r*l,n.g*l,n.b*l,1);wo(t,r,i[a],n,-o,-o,s),wo(t,r,i[a],n,-o,o,s),wo(t,r,i[a],n,o,o,s),wo(t,r,i[a],n,o,-o,s),wo(t,r,i[a],c,0,0,s)}else wo(t,r,i[a],n,0,0,s)},custom:function(t,r,i,n){const o=t.context,s=i.implementation;if(!t.transform.projection.unsupportedLayers||!t.transform.projection.unsupportedLayers.includes("custom")||t.terrain&&(t.terrain.renderingToTexture||"offscreen"===t.renderPass)&&i.isDraped(r)){if("offscreen"===t.renderPass){const r=s.prerender;if(r){if(t.setCustomLayerDefaults(),o.setColorMode(t.colorModeForRenderPass()),"globe"===t.transform.projection.name){const i=t.transform.pointMerc;r.call(s,o.gl,t.transform.customLayerMatrix(),t.transform.getProjection(),t.transform.globeToMercatorMatrix(),e.W(t.transform.zoom),[i.x,i.y],t.transform.pixelsPerMeterRatio)}else r.call(s,o.gl,t.transform.customLayerMatrix());o.setDirty(),t.setBaseState()}}else if("translucent"===t.renderPass){if(t.terrain&&t.terrain.renderingToTexture){const r=s.renderToTile;if(r){const i=n[0].canonical,a=new e.O(i.x+n[0].wrap*(1<<i.z),i.y,i.z);o.setDepthMode(Et.disabled),o.setStencilMode(St.disabled),o.setColorMode(t.colorModeForRenderPass()),t.setCustomLayerDefaults(),r.call(s,o.gl,a),o.setDirty(),t.setBaseState()}return}t.setCustomLayerDefaults(),o.setColorMode(t.colorModeForRenderPass()),o.setStencilMode(St.disabled);const r="3d"===s.renderingMode?new Et(t.context.gl.LEQUAL,Et.ReadWrite,t.depthRangeFor3D):t.depthModeForSublayer(0,Et.ReadOnly);if(o.setDepthMode(r),"globe"===t.transform.projection.name){const r=t.transform.pointMerc;s.render(o.gl,t.transform.customLayerMatrix(),t.transform.getProjection(),t.transform.globeToMercatorMatrix(),e.W(t.transform.zoom),[r.x,r.y],t.transform.pixelsPerMeterRatio)}else s.render(o.gl,t.transform.customLayerMatrix());o.setDirty(),t.setBaseState(),o.bindFramebuffer.set(null)}}else e.w("Custom layers are not yet supported with this projection. Use mercator or globe to enable usage of custom layers.")},model:function(t,r,i,n){if("opaque"===t.renderPass)return;const o=i.paint.get("model-opacity");if(0===o)return;const s=i.paint.get("model-cast-shadows");if("shadow"===t.renderPass){if(!s)return;if(t.terrain&&o<.65&&i._transitionablePaint._values["model-opacity"].value.expression instanceof e.Z)return}const a=t.shadowRenderer,l=i.paint.get("model-receive-shadows");a&&(a.useNormalOffset=!0,l||(a.enabled=!1));const c=()=>{a&&(a.useNormalOffset=!0,l||(a.enabled=!0))},u=r.getSource();if("light-beam"===t.renderPass&&"batched-model"!==u.type)return;if("vector"===u.type||"geojson"===u.type)return function(t,r,i,n,o){const s=t.transform;if("mercator"!==s.projection.name)return void e.w(`Drawing 3D models for ${s.projection.name} projection is not yet implemented`);const a=s.getFreeCameraOptions().position;if(!t.modelManager)return;const l=t.modelManager;i.modelManager=l;const c=t.shadowRenderer;if(!i._unevaluatedLayout._values.hasOwnProperty("model-id"))return;const u=i._unevaluatedLayout._values["model-id"],h={...i.layout.get("model-id").parameters};for(const d of n){const n=r.getTile(d).getBucket(i);if(!n||n.projection.name!==s.projection.name)continue;const p=n.getModelUris();p&&!n.modelsRequested&&(l.addModelsFromBucket(p,o),n.modelsRequested=!0);const f=Go(d,s);h.zoom=f;const m=u.possiblyEvaluate(h);if(Uo(t,n,d),Ho.shadowUniformsInitialized=!1,Ho.useSingleShadowCascade=!!c&&0===c.getMaxCascadeForTile(d.toUnwrapped()),"shadow"===t.renderPass&&c){if(1===t.currentShadowCascade&&n.isInsideFirstShadowMapFrustum)continue;const r=s.calculatePosMatrix(d.toUnwrapped(),s.worldSize);if(Ho.tileMatrix.set(r),Ho.shadowTileMatrix=Float32Array.from(c.calculateShadowPassMatrixFromMatrix(r)),Ho.aabb.min.fill(0),Ho.aabb.max[0]=Ho.aabb.max[1]=e.Y,Ho.aabb.max[2]=0,Qo(n,Ho,t,i.scope))continue}const A=1<<d.canonical.z,g=[((a.x-d.wrap)*A-d.canonical.x)*e.Y,(a.y*A-d.canonical.y)*e.Y,a.z*A*e.Y];for(let e in n.instancesPerModel){const r=n.instancesPerModel[e];r.features.length>0&&(e=m.evaluate(r.features[0].feature,{}));const s=l.getModel(e,o);if(s&&s.uploaded)for(const e of s.nodes)Zo(t,i,e,r,g,d,Ho)}}}(t,r,i,n,"vector"===u.type?i.scope:""),void c();if(!u.loaded())return;if("batched-model"===u.type)return function(t,r,i,n){i.resetLayerRenderingStats(t);const o=t.context,s=t.transform,a=t.style.fog,l=t.shadowRenderer;if("mercator"!==s.projection.name)return void e.w(`Drawing 3D landmark models for ${s.projection.name} projection is not yet implemented`);const c=t.transform.getFreeCameraOptions().position,u=e.Q.scale([],[c.x,c.y,c.z],t.transform.worldSize);e.Q.negate(u,u);const h=e.a9.identity([]),d=e.cZ(s.center.lat,s.zoom),p=e.a9.fromScaling([],[1,1,1/d]);e.a9.translate(h,h,u);const f=i.paint.get("model-opacity"),m=new Et(o.gl.LEQUAL,Et.ReadWrite,t.depthRangeFor3D),A=new Et(o.gl.LEQUAL,Et.ReadOnly,t.depthRangeFor3D),g=new e.bV([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),_="shadow"===t.renderPass,y=_&&l?l.getCurrentCascadeFrustum():s.getFrustum(s.scaleZoom(s.worldSize)),x=i.getLayerRenderingStats(),v=function(c,u){for(const d of n){const n=r.getTile(d).getBucket(i);if(!n||!n.uploaded)continue;let v=!1;l&&(v=0===l.getMaxCascadeForTile(d.toUnwrapped()));const b=s.calculatePosMatrix(d.toUnwrapped(),s.worldSize),w=n.modelTraits;for(const r of n.getNodesInfo()){if(r.hiddenByReplacement)continue;if(!r.node.meshes)continue;const n=r.evaluatedScale,d=r.node;let C=0;if(t.terrain&&d.elevation&&(C=d.elevation*t.terrain.exaggeration()),n[0]<=1&&n[1]<=1&&n[2]<=1&&0===(()=>{const t=r.getLocalBounds();return g.min=[...t.min],g.max=[...t.max],g.min[2]+=C,g.max[2]+=C,e.Q.transformMat4(g.min,g.min,b),e.Q.transformMat4(g.max,g.max,b),g})().intersects(y))continue;const T=[...b];e.a9.translate(T,T,[(d.anchor?d.anchor[0]:0)*(n[0]-1),(d.anchor?d.anchor[1]:0)*(n[1]-1),C]),e.Q.exactEquals(n,e.c$)||e.a9.scale(T,T,n);const E=e.a9.multiply([],T,d.matrix);let M=e.a9.multiply([],p,T);e.a9.multiply(M,h,M);const S=e.a9.invert([],M);e.a9.transpose(S,S),e.a9.scale(S,S,Wo),M=e.a9.multiply(M,M,d.matrix);const I="light-beam"===t.renderPass,P=e.a9.multiply([],s.expandedFarZProjMatrix,E),D=e.a9.multiply([],s.expandedFarZProjMatrix,T),k=w&e.d1.HasMapboxMeshFeatures,L=k?0:r.evaluatedRMEA[0][2];for(let e=0;e<d.meshes.length;++e){const n=d.meshes[e],h=e===d.lightMeshIndex;let p=P;if(h){if(!I&&!t.terrain&&t.shadowRenderer){t.currentLayer<t.firstLightBeamLayer&&(t.firstLightBeamLayer=t.currentLayer);continue}p=D}else if(I)continue;const g={defines:[]},y=[];if(Fo(g.defines,y,n,t),k||g.defines.push("DIFFUSE_SHADED"),v&&g.defines.push("SHADOWS_SINGLE_CASCADE"),x&&(_?x.numRenderedVerticesInShadowPass+=n.vertexArray.length:x.numRenderedVerticesInTransparentPass+=n.vertexArray.length),_){No(n,E,t,i);continue}let b=null;if(a){const e=Ro(E,t.transform);if(b=new Float32Array(e),"globe"!==s.projection.name){const t=n.aabb.min,r=n.aabb.max,[i,o]=a.getOpacityForBounds(e,t[0],t[1],r[0],r[1]);g.overrideFog=i>=pe||o>=pe}}const w=n.material;let C;w.occlusionTexture&&w.occlusionTexture.offsetScale&&(C=w.occlusionTexture.offsetScale,g.defines.push("OCCLUSION_TEXTURE_TRANSFORM")),!_&&l&&(l.useNormalOffset=!!n.normalBuffer);const z=t.getOrCreateProgram("model",g);!_&&l&&l.setupShadowsFromMatrix(T,z,l.useNormalOffset),t.uploadCommonUniforms(o,z,null,b);const O=w.pbrMetallicRoughness;O.metallicFactor=.9,O.roughnessFactor=.5;const B=Wn(new Float32Array(p),new Float32Array(M),new Float32Array(S),new Float32Array(d.matrix),t,f,O.baseColorFactor,w.emissiveFactor,O.metallicFactor,O.roughnessFactor,w,L,i,[0,0,0],C);z.draw(t,o.gl.TRIANGLES,u&&!h?m:A,St.disabled,c?h||f<1||r.hasTranslucentParts?Pt.alphaBlended:Pt.unblended:Pt.disabled,Lt.backCCW,B,i.id,n.vertexBuffer,n.indexBuffer,n.segments,i.paint,t.transform.zoom,void 0,y)}}}};(function(e,t,r,i){const n=e.terrain?e.terrain.exaggeration():0,o=e.transform.zoom;for(const s of i){const i=t.getTile(s).getBucket(r);i&&(e.conflationActive&&i.updateReplacement(s,e.replacementSource),i.evaluateScale(e,r),e.terrain&&n>0&&i.elevationUpdate(e.terrain,n,s,r.source),i.needsReEvaluation(e,o,r)&&i.evaluate(r))}})(t,r,i,n),1===f?v(!0,!0):(v(!1,!0),v(!0,!1))}(t,r,i,n),void c();const h=u.getModels(),d=[],p=t.transform.getFreeCameraOptions().position,f=e.Q.scale([],[p.x,p.y,p.z],t.transform.worldSize);e.Q.negate(f,f);const m=[],A=[];let g=0;for(const r of h){const n=i.paint.get("model-rotation").constantOr(null),o=i.paint.get("model-scale").constantOr(null),s=i.paint.get("model-translation").constantOr(null);r.computeModelMatrix(t,n,o,s,!0,!0,!1);const a=e.a9.identity([]),l=e.cZ(r.position.lat,t.transform.zoom),c=e.a9.fromScaling([],[1,1,1/l]);e.a9.translate(a,a,f),d.push({zScaleMatrix:c,negCameraPosMatrix:a});for(const e of r.nodes)Vo(t.transform,e,r.matrix,t.transform.expandedFarZProjMatrix,g,m,A);g++}if(m.sort(((e,t)=>t.depth-e.depth)),"shadow"!==t.renderPass){if(1===o)for(const e of A)jo(e,t,i,d[e.modelIndex],St.disabled,t.colorModeForRenderPass());else{for(const e of A)jo(e,t,i,d[e.modelIndex],St.disabled,Pt.disabled);for(const e of A)jo(e,t,i,d[e.modelIndex],t.stencilModeFor3D(),t.colorModeForRenderPass());t.resetStencilClippingMasks()}for(const e of m)jo(e,t,i,d[e.modelIndex],St.disabled,t.colorModeForRenderPass());c()}else{for(const e of A)No(e.mesh,e.nodeModelMatrix,t,i);for(const e of m)No(e.mesh,e.nodeModelMatrix,t,i);c()}}},$o={model:function(e,t,r){const i=t.getSource();if(!i.loaded())return;if("vector"===i.type||"geojson"===i.type)return void(r.modelManager&&r.modelManager.upload(r,"vector"===i.type?e.scope:""));if("batched-model"===i.type)return;const n=i.getModels();for(const e of n)e.upload(r.context)},raster:function(e,t,r){const i=t.getSource();if(!(i instanceof De&&i.loaded()))return;const n=e.sourceLayer||i.rasterLayerIds&&i.rasterLayerIds[0];if(!n)return;const o=e.paint.get("raster-array-band")||i.getInitialBand(n);if(null==o)return;const s=t.getIds().map((e=>t.getTileByID(e)));for(const e of s)e.updateNeeded(n,o)&&i.prepareTile(e,n,o)},"raster-particle":function(e,t,r){const i=t.getSource();if(!(i instanceof De&&i.loaded()))return;const n=e.sourceLayer||i.rasterLayerIds&&i.rasterLayerIds[0];if(!n)return;const o=e.paint.get("raster-particle-array-band")||i.getInitialBand(n);if(null==o)return;const s=t.getIds().map((e=>t.getTileByID(e)));for(const e of s)e.updateNeeded(n,o)&&i.prepareTile(e,n,o)}};class Ko{constructor(t,r,i,n){this.context=new zt(t,r),this.transform=i,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.tp=n,this._timeStamp=(new Date).getTime(),this._averageFPS=0,this._fpsHistory=[],this._debugParams={showTerrainProxyTiles:!1,fpsWindow:30,continousRedraw:!1,enabledLayers:{}};const o=["fill","line","symbol","circle","heatmap","fill-extrusion","raster","raster-particle","hillshade","model","background","sky"];for(const e of o)this._debugParams.enabledLayers[e]=!0;n.registerParameter(this._debugParams,["Terrain"],"showTerrainProxyTiles",{},(()=>{this.style.map.triggerRepaint()})),n.registerParameter(this._debugParams,["FPS"],"fpsWindow",{min:1,max:100,step:1}),n.registerBinding(this._debugParams,["FPS"],"continousRedraw",{readonly:!0,label:"continuous redraw"}),n.registerBinding(this,["FPS"],"_averageFPS",{readonly:!0,label:"value"}),n.registerBinding(this,["FPS"],"_averageFPS",{readonly:!0,label:"graph",view:"graph",min:0,max:200});for(const e of o)n.registerParameter(this._debugParams.enabledLayers,["Debug","Layers"],e);this.setup(),this.numSublayers=qt.maxUnderzooming+qt.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.deferredRenderGpuTimeQueries=[],this.gpuTimers={},this.frameCounter=0,this._backgroundTiles={},this.conflationActive=!1,this.replacementSource=new e.d3,this.longestCutoffRange=0,this.minCutoffZoom=0,this._fogVisible=!1,this._cachedTileFogOpacities={},this._shadowRenderer=new yi(this),this._wireframeDebugCache=new Xo,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0}updateTerrain(e,t){const r=!!e&&!!e.terrain&&this.transform.projection.supportsTerrain;if(!(r||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new fn(this,e));const i=this._terrain;this.transform.elevation=r?i:null,i.update(e,this.transform,t),this.transform.elevation&&!i.enabled&&(this.transform.elevation=null)}_updateFog(e){const t=e.fog;if(!t||"globe"===this.transform.projection.name||t.getOpacity(this.transform.pitch)<1||t.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);const[r,i]=t.getFovAdjustedRange(this.transform._fov);if(r>i)return void(this.transform.fogCullDistSq=null);const n=r+.78*(i-r);this.transform.fogCullDistSq=n*n}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}get shadowRenderer(){return this._shadowRenderer&&this._shadowRenderer.enabled?this._shadowRenderer:null}get wireframeDebugCache(){return this._wireframeDebugCache}resize(t,r){if(this.width=t*e.f.devicePixelRatio,this.height=r*e.f.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const e of this.style.order)this.style._mergedLayers[e].resize()}setup(){const t=this.context,r=new e.aQ;r.emplaceBack(0,0),r.emplaceBack(e.Y,0),r.emplaceBack(0,e.Y),r.emplaceBack(e.Y,e.Y),this.tileExtentBuffer=t.createVertexBuffer(r,e.aS.members),this.tileExtentSegments=e.aE.simpleSegment(0,0,4,2);const i=new e.aQ;i.emplaceBack(0,0),i.emplaceBack(e.Y,0),i.emplaceBack(0,e.Y),i.emplaceBack(e.Y,e.Y),this.debugBuffer=t.createVertexBuffer(i,e.aS.members),this.debugSegments=e.aE.simpleSegment(0,0,4,5);const n=new e.aQ;n.emplaceBack(-1,-1),n.emplaceBack(1,-1),n.emplaceBack(-1,1),n.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(n,e.aS.members),this.viewportSegments=e.aE.simpleSegment(0,0,4,2);const o=new e.ay;o.emplaceBack(0,0,0,0),o.emplaceBack(e.Y,0,e.Y,0),o.emplaceBack(0,e.Y,0,e.Y),o.emplaceBack(e.Y,e.Y,e.Y,e.Y),this.mercatorBoundsBuffer=t.createVertexBuffer(o,e.aU.members),this.mercatorBoundsSegments=e.aE.simpleSegment(0,0,4,2);const s=new e.az;s.emplaceBack(0,1,2),s.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(s);const a=new e.aR;for(const e of[0,1,3,2,0])a.emplaceBack(e);this.debugIndexBuffer=t.createIndexBuffer(a),this.emptyTexture=new e.T(t,new e.h({width:1,height:1},Uint8Array.of(0,0,0,0)),t.gl.RGBA),this.identityMat=e.a9.create();const l=this.context.gl;this.stencilClearMode=new St({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.loadTimeStamps.push(performance.now())}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(e){return e._makeTileBoundsBuffers(this.context,this.transform.projection),e._tileBoundsBuffer?{tileBoundsBuffer:e._tileBoundsBuffer,tileBoundsIndexBuffer:e._tileBoundsIndexBuffer,tileBoundsSegments:e._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const e=this.context.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.getOrCreateProgram("clippingMask").draw(this,e.TRIANGLES,Et.disabled,this.stencilClearMode,Pt.disabled,Lt.disabled,cn(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(e,t,r){if(!t||this.currentStencilSource===t.id||!e.isTileClipped()||!r||0===r.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let e=!1;for(const t of r)if(void 0===this._tileClippingMaskIDs[t.key]){e=!0;break}if(!e)return}this.currentStencilSource=t.id;const i=this.context,n=i.gl;this.nextStencilID+r.length>256&&this.clearStencil(),i.setColorMode(Pt.disabled),i.setDepthMode(Et.disabled);const o=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const e of r){const r=t.getTile(e),i=this._tileClippingMaskIDs[e.key]=this.nextStencilID++,{tileBoundsBuffer:s,tileBoundsIndexBuffer:a,tileBoundsSegments:l}=this.getTileBoundsBuffers(r);o.draw(this,n.TRIANGLES,Et.disabled,new St({func:n.ALWAYS,mask:0},i,255,n.KEEP,n.KEEP,n.REPLACE),Pt.disabled,Lt.disabled,cn(e.projMatrix),"$clipping",s,a,l)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,t=this.context.gl;return new St({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(e);const t=this.context.gl;return new St({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}stencilConfigForOverlap(e){const t=this.context.gl,r=e.sort(((e,t)=>t.overscaledZ-e.overscaledZ)),i=r[r.length-1].overscaledZ,n=r[0].overscaledZ-i+1;if(n>1){this.currentStencilSource=void 0,this.nextStencilID+n>256&&this.clearStencil();const e={};for(let r=0;r<n;r++)e[r+i]=new St({func:t.GEQUAL,mask:255},r+this.nextStencilID,255,t.KEEP,t.KEEP,t.REPLACE);return this.nextStencilID+=n,[e,r]}return[{[i]:St.disabled},r]}colorModeForRenderPass(){const t=this.context.gl;if(this._showOverdrawInspector){const r=1/8;return new Pt([t.CONSTANT_COLOR,t.ONE,t.CONSTANT_COLOR,t.ONE],new e.aA(r,r,r,0),[!0,!0,!0,!0])}return"opaque"===this.renderPass?Pt.unblended:Pt.alphaBlended}colorModeForDrapableLayerRenderPass(t){const r=this.context.gl;return(()=>this.style&&this.style.enable3dLights()&&this.terrain&&this.terrain.renderingToTexture)()&&"translucent"===this.renderPass?new Pt([r.ONE,r.ONE_MINUS_SRC_ALPHA,r.CONSTANT_ALPHA,r.ONE_MINUS_SRC_ALPHA],new e.aA(0,0,0,void 0===t?0:t),[!0,!0,!0,!0]):this.colorModeForRenderPass()}depthModeForSublayer(e,t,r,i=!1){if(!this.opaquePassEnabledForLayer()&&!i)return Et.disabled;const n=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new Et(r||this.context.gl.LEQUAL,t,[n,n])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}updateAverageFPS(){const e=(new Date).getTime(),t=e-this._timeStamp;this._timeStamp=e,this._fpsHistory.push(0===t?0:1e3/t),this._fpsHistory.length>this._debugParams.fpsWindow&&this._fpsHistory.splice(0,this._fpsHistory.length-this._debugParams.fpsWindow),this._averageFPS=Math.round(this._fpsHistory.reduce(((e,t)=>e+t/this._fpsHistory.length),0))}render(t,r){this._wireframeDebugCache.update(this.frameCounter),this._debugParams.continousRedraw=t.map.repaint,this.style=t,this.options=r;const i=this.style._mergedLayers,n=this.style.order.filter((e=>{const t=i[e];return!(t.type in this._debugParams.enabledLayers)||this._debugParams.enabledLayers[t.type]})),o=n.map((e=>i[e])),s=this.style._mergedSourceCaches;this.imageManager=t.imageManager,this.modelManager=t.modelManager,this.symbolFadeChange=t.placement.symbolFadeChange(e.f.now()),this.imageManager.beginFrame();let a=0,l=!1;for(const e in s){const t=s[e];t.used&&(t.prepare(this.context),t.getSource().usedInConflation&&++a)}for(const e of o)e.isHidden(this.transform.zoom)||this.prepareLayer(e);const c={},u={},h={},d={},p={};for(const e in s){const t=s[e];c[e]=t.getVisibleCoordinates(),u[e]=c[e].slice().reverse(),h[e]=t.getVisibleCoordinates(!0).reverse(),d[e]=t.getShadowCasterCoordinates(),p[e]=t.sortCoordinatesByDistance(c[e])}const f=e=>{const t=this.style.getLayerSourceCache(e);return t&&t.used?t.getSource():null};if(a){const e=[];for(const t of o)this.layerUsedInConflation(t,f(t))&&e.push(t);if(e&&e.length>1){const t=[];for(const r of e){const e=this.style.getLayerSourceCache(r);e&&e.used&&e.getSource().usedInConflation&&t.push({layer:r.fqid,cache:e})}this.replacementSource.setSources(t),l=!0}}l||this.replacementSource.clear(),this.conflationActive=l,this.minCutoffZoom=0,this.longestCutoffRange=0;for(const e of o){const t=e.cutoffRange();if(this.longestCutoffRange=Math.max(t,this.longestCutoffRange),t>0){const t=f(e);t&&(this.minCutoffZoom=Math.max(t.minzoom,this.minCutoffZoom)),e.minzoom&&(this.minCutoffZoom=Math.max(e.minzoom,this.minCutoffZoom))}}this.opaquePassCutoff=1/0;for(let e=0;e<o.length;e++)if(o[e].is3D()){this.opaquePassCutoff=e;break}const m=this.style&&this.style.fog;m?(this._fogVisible=0!==m.getOpacity(this.transform.pitch),this._fogVisible&&"globe"!==this.transform.projection.name&&(this._fogVisible=m.isVisibleOnFrustum(this.transform.cameraFrustum))):this._fogVisible=!1,this._cachedTileFogOpacities={},this.terrain&&(this.terrain.updateTileBinding(h),this.opaquePassCutoff=0);const A=this._shadowRenderer;if(A){A.updateShadowParameters(this.transform,this.style.directionalLight);for(const e in s)for(const t of c[e]){let e={min:0,max:0};this.terrain&&(e=this.terrain.getMinMaxForTile(t)||e),A.addShadowReceiver(t.toUnwrapped(),e.min,e.max)}}if("globe"!==this.transform.projection.name||this.globeSharedBuffers||(this.globeSharedBuffers=new e.d4(this.context)),this.style.fog&&this.transform.projection.supportsFog?(this._atmosphere||(this._atmosphere=new Bo(this)),this._atmosphere.update(this)):this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0),!e.d5(this.context.gl))return;this.renderPass="offscreen";for(const e of o){const r=t.getLayerSourceCache(e);if(!e.hasOffscreenPass()||e.isHidden(this.transform.zoom))continue;const i=r?u[r.id]:void 0;("custom"===e.type||"raster"===e.type||"raster-particle"===e.type||e.isSky()||i&&i.length)&&this.renderLayer(this,r,e,i)}this.depthRangeFor3D=[0,1-(o.length+2)*this.numSublayers*this.depthEpsilon];const g=this.terrain;g&&(this.style.hasSymbolLayers()||this.style.hasCircleLayers())&&!this.transform.isOrthographic&&g.drawDepth(),this._shadowRenderer&&(this.renderPass="shadow",this._shadowRenderer.drawShadowPass(this.style,d)),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]);const _="globe"===this.transform.projection.name||this.transform.isHorizonVisible(),y=(()=>{if(r.showOverdrawInspector)return e.aA.black;if(this.style.fog&&this.transform.projection.supportsFog&&!_){const t=this.style.fog.properties.get("color").toArray01();return new e.aA(...t)}if(this.style.fog&&this.transform.projection.supportsFog&&_){const t=this.style.fog.properties.get("space-color").toArray01();return new e.aA(...t)}return e.aA.transparent})();if(this.context.clear({color:y,depth:1}),this.clearStencil(),this._showOverdrawInspector=r.showOverdrawInspector,this.renderPass="opaque",this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&_&&this._atmosphere.drawStars(this,this.style.fog),!this.terrain)for(this.currentLayer=n.length-1;this.currentLayer>=0;this.currentLayer--){const e=o[this.currentLayer],r=t.getLayerSourceCache(e);if(e.isSky())continue;const i=r?(e.is3D()?p:u)[r.id]:void 0;this._renderTileClippingMasks(e,r,i),this.renderLayer(this,r,e,i)}if(this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&_&&this._atmosphere.drawAtmosphereGlow(this,this.style.fog),this.renderPass="sky",(!this._atmosphere||e.W(this.transform.zoom)>0)&&("globe"===this.transform.projection.name||this.transform.isHorizonVisible()))for(this.currentLayer=0;this.currentLayer<n.length;this.currentLayer++){const e=o[this.currentLayer],r=t.getLayerSourceCache(e);e.isSky()&&this.renderLayer(this,r,e,r?u[r.id]:void 0)}function x(e,t){let r;return t&&(r=("symbol"===e.type?h:e.is3D()?p:u)[t.id]),r}if(this.renderPass="translucent","globe"===this.transform.projection.name){for(this.renderElevatedRasterBackface=!0,this.currentLayer=0;this.currentLayer<n.length;){const e=o[this.currentLayer];if("raster"===e.type){const r=t.getLayerSourceCache(e);this.renderLayer(this,r,e,x(e,r))}++this.currentLayer}this.renderElevatedRasterBackface=!1}this.currentLayer=0,this.firstLightBeamLayer=Number.MAX_SAFE_INTEGER;let v=0;for(A&&(v=A.getShadowCastingLayerCount());this.currentLayer<n.length;){const e=o[this.currentLayer],r=t.getLayerSourceCache(e);if(e.isSky())++this.currentLayer;else if(g&&this.style.isLayerDraped(e)){if(e.isHidden(this.transform.zoom)){++this.currentLayer;continue}this.currentLayer=g.renderBatch(this.currentLayer)}else{if(this._renderTileClippingMasks(e,r,r?c[r.id]:void 0),this.renderLayer(this,r,e,x(e,r)),!g&&A&&v>0&&e.hasShadowPass()&&0==--v&&(A.drawGroundShadows(),this.firstLightBeamLayer<=this.currentLayer)){const e=this.currentLayer;for(this.renderPass="light-beam",this.currentLayer=this.firstLightBeamLayer;this.currentLayer<=e;this.currentLayer++){const e=o[this.currentLayer];if(!e.hasLightBeamPass())continue;const r=t.getLayerSourceCache(e);this.renderLayer(this,r,e,r?u[r.id]:void 0)}this.currentLayer=e,this.renderPass="translucent"}++this.currentLayer}}if(this.terrain&&this.terrain.postRender(),this.options.showTileBoundaries||this.options.showQueryGeometry||this.options.showTileAABBs){let r=null;o.forEach((e=>{const i=t.getLayerSourceCache(e);i&&!e.isHidden(this.transform.zoom)&&i.getVisibleCoordinates().length&&(!r||r.getSource().maxzoom<i.getSource().maxzoom)&&(r=i)})),r&&this.options.showTileBoundaries&&Yo.debug(this,r,r.getVisibleCoordinates(),e.aA.red,!1,this.options.showParseStatus)}this.terrain&&this._debugParams.showTerrainProxyTiles&&Yo.debug(this,this.terrain.proxySourceCache,this.terrain.proxyCoords,new e.aA(1,.8,.1,1),!0,this.options.showParseStatus),this.options.showPadding&&function(e){const t=e.transform.padding;Co(e,e.transform.height-(t.top||0),3,_o),Co(e,t.bottom||0,3,yo),To(e,t.left||0,3,xo),To(e,e.transform.width-(t.right||0),3,vo);const r=e.transform.centerPoint;!function(e,t,r,i){Eo(e,t-1,r-10,2,20,i),Eo(e,t-10,r-1,20,2,i)}(e,r.x,e.transform.height-r.y,bo)}(this),this.context.setDefault(),this.frameCounter=(this.frameCounter+1)%Number.MAX_SAFE_INTEGER,this.tileLoaded&&this.options.speedIndexTiming&&(this.loadTimeStamps.push(performance.now()),this.saveCanvasCopy()),l||(this.conflationActive=!1)}prepareLayer(e){this.gpuTimingStart(e);const{unsupportedLayers:t}=this.transform.projection,r=!t||!t.includes(e.type);if($o[e.type]&&(r||this.terrain&&"custom"===e.type)){const t=this.style.getLayerSourceCache(e);$o[e.type](e,t,this)}this.gpuTimingEnd()}renderLayer(e,t,r,i){r.isHidden(this.transform.zoom)||("background"===r.type||"sky"===r.type||"custom"===r.type||"model"===r.type||"raster"===r.type||"raster-particle"===r.type||i&&i.length)&&(this.id=r.id,this.gpuTimingStart(r),(!e.transform.projection.unsupportedLayers||!e.transform.projection.unsupportedLayers.includes(r.type)||e.terrain&&"custom"===r.type)&&Yo[r.type](e,t,r,i,this.style.placement.variableOffsets,this.options.isInitialLoad),this.gpuTimingEnd())}gpuTimingStart(e){if(!this.options.gpuTiming)return;const t=this.context.extTimerQuery,r=this.context.gl;let i=this.gpuTimers[e.id];i||(i=this.gpuTimers[e.id]={calls:0,cpuTime:0,query:r.createQuery()}),i.calls++,r.beginQuery(t.TIME_ELAPSED_EXT,i.query)}gpuTimingDeferredRenderStart(){if(this.options.gpuTimingDeferredRender){const e=this.context.extTimerQuery,t=this.context.gl,r=t.createQuery();this.deferredRenderGpuTimeQueries.push(r),t.beginQuery(e.TIME_ELAPSED_EXT,r)}}gpuTimingDeferredRenderEnd(){this.options.gpuTimingDeferredRender&&this.context.gl.endQuery(this.context.extTimerQuery.TIME_ELAPSED_EXT)}gpuTimingEnd(){this.options.gpuTiming&&this.context.gl.endQuery(this.context.extTimerQuery.TIME_ELAPSED_EXT)}collectGpuTimers(){const e=this.gpuTimers;return this.gpuTimers={},e}collectDeferredRenderGpuQueries(){const e=this.deferredRenderGpuTimeQueries;return this.deferredRenderGpuTimeQueries=[],e}queryGpuTimers(e){const t={};for(const r in e){const i=e[r],n=this.context.extTimerQuery,o=n.getQueryParameter(i.query,this.context.gl.QUERY_RESULT)/1e6;n.deleteQueryEXT(i.query),t[r]=o}return t}queryGpuTimeDeferredRender(e){if(!this.options.gpuTimingDeferredRender)return 0;const t=this.context.extTimerQuery,r=this.context.gl;let i=0;for(const n of e)i+=t.getQueryParameter(n,r.QUERY_RESULT)/1e6,t.deleteQueryEXT(n);return i}translatePosMatrix(t,r,i,n,o){if(!i[0]&&!i[1])return t;const s=o?"map"===n?this.transform.angle:0:"viewport"===n?-this.transform.angle:0;if(s){const e=Math.sin(s),t=Math.cos(s);i=[i[0]*t-i[1]*e,i[0]*e+i[1]*t]}const a=[o?i[0]:e.a6(r,i[0],this.transform.zoom),o?i[1]:e.a6(r,i[1],this.transform.zoom),0],l=new Float32Array(16);return e.a9.translate(l,t,a),l}saveTileTexture(e){const t=e.size[0],r=this._tileTextures[t];r?r.push(e):this._tileTextures[t]=[e]}getTileTexture(e){const t=this._tileTextures[e];return t&&t.length>0?t.pop():null}isPatternMissing(e,t){return null===e||void 0!==e&&!this.imageManager.getPattern(e.toString(),t)}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture}linearFloatFilteringSupported(){return null!=this.context.extTextureFloatLinear}currentGlobalDefines(e,t,r){const i=void 0===r?this.terrain&&this.terrain.renderingToTexture:r,n=this.terrain&&0===this.terrain.exaggeration(),o=[];return this.style&&this.style.enable3dLights()&&("globeRaster"===e||"terrainRaster"===e?(o.push("LIGHTING_3D_MODE"),o.push("LIGHTING_3D_ALPHA_EMISSIVENESS")):i||o.push("LIGHTING_3D_MODE")),"shadow"===this.renderPass?this._shadowMapDebug||o.push("DEPTH_TEXTURE"):this.shadowRenderer&&(this.shadowRenderer.useNormalOffset?o.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"):o.push("RENDER_SHADOWS","DEPTH_TEXTURE")),this.terrainRenderModeElevated()&&(o.push("TERRAIN"),this.linearFloatFilteringSupported()&&o.push("TERRAIN_DEM_FLOAT_FORMAT"),n&&o.push("ZERO_EXAGGERATION")),"globe"===this.transform.projection.name&&o.push("GLOBE"),!this._fogVisible||i||void 0!==t&&!t||o.push("FOG","FOG_DITHERING"),i&&o.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&o.push("OVERDRAW_INSPECTOR"),o}getOrCreateProgram(e,t){this.cache=this.cache||{};const r=t&&t.defines||[],i=t&&t.config,n=this.currentGlobalDefines(e,t&&t.overrideFog,t&&t.overrideRtt).concat(r),o=_n.cacheKey(Wi[e],e,n,i);return this.cache[o]||(this.cache[o]=new _n(this.context,e,Wi[e],i,qn[e],n)),this.cache[o]}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 e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new e.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}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()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}uploadCommonLightUniforms(t,r){if(this.style.enable3dLights()){const i=this.style.directionalLight,n=this.style.ambientLight;if(i&&n){const o=((t,r)=>{const i=t.properties.get("direction"),n=t.properties.get("color").toArray01(),o=t.properties.get("intensity"),s=r.properties.get("color").toArray01(),a=r.properties.get("intensity"),l=[i.x,i.y,i.z],c=e.cs(s,a),u=e.cs(n,o);return{u_lighting_ambient_color:c,u_lighting_directional_dir:l,u_lighting_directional_color:u,u_ground_radiance:mn(l,u,c)}})(i,n);r.setLightsUniformValues(t,o)}}}uploadCommonUniforms(t,r,i,n,o){if(this.uploadCommonLightUniforms(t,r),this.terrain&&this.terrain.renderingToTexture)return;const s=this.style.fog;if(s){const o=s.getOpacity(this.transform.pitch),a=((t,r,i,n,o,s,a,l,c,u,h,d)=>{const p=t.transform,f=r.properties.get("color").toArray01();f[3]=n;const m=t.frameCounter/1e3%1,[A,g]=r.properties.get("vertical-range");return{u_fog_matrix:i?p.calculateFogTileMatrix(i):d||t.identityMat,u_fog_range:r.getFovAdjustedRange(p._fov),u_fog_color:f,u_fog_horizon_blend:r.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(A,g),g],u_fog_temporal_offset:m,u_frustum_tl:o,u_frustum_tr:s,u_frustum_br:a,u_frustum_bl:l,u_globe_pos:c,u_globe_radius:u,u_viewport:h,u_globe_transition:e.W(p.zoom),u_is_globe:+("globe"===p.projection.name)}})(this,s,i,o,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*e.f.devicePixelRatio,this.transform.height*e.f.devicePixelRatio],n);r.setFogUniformValues(t,a)}o&&r.setCutoffUniformValues(t,o.uniformValues)}setTileLoadedFlag(e){this.tileLoaded=e}saveCanvasCopy(){const e=this.canvasCopy();e&&(this.frameCopies.push(e),this.tileLoaded=!1)}canvasCopy(){const e=this.context.gl,t=e.createTexture();return e.bindTexture(e.TEXTURE_2D,t),e.copyTexImage2D(e.TEXTURE_2D,0,e.RGBA,0,0,e.drawingBufferWidth,e.drawingBufferHeight,0),t}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const e=this.style&&this.style.fog;return!!e&&0!==e.getOpacity(this.transform.pitch)}getBackgroundTiles(){const e=this._backgroundTiles,t=this._backgroundTiles={},r=this.transform.coveringTiles({tileSize:512});for(const i of r)t[i.key]=e[i.key]||new jt(i,512,this.transform.tileZoom,this);return t}clearBackgroundTiles(){this._backgroundTiles={}}layerUsedInConflation(e,t){return!(!e.is3D()||e.minzoom&&e.minzoom>this.transform.zoom||"building"!==e.sourceLayer&&(!t||"batched-model"!==t.type))}isTileAffectedByFog(e){if(!this.style||!this.style.fog)return!1;if("globe"===this.transform.projection.name)return!0;let t=this._cachedTileFogOpacities[e.key];return t||(this._cachedTileFogOpacities[e.key]=t=this.style.fog.getOpacityForTile(e)),t[0]>=pe||t[1]>=pe}}function Jo(e,t){let r=!1,i=null;const n=()=>{i=null,r&&(e(),i=setTimeout(n,t),r=!1)};return()=>(r=!0,i||n(),i)}class es{constructor(t){this._hashName=t&&encodeURIComponent(t),e.a$(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=Jo(this._updateHashUnthrottled.bind(this),300)}addTo(e){return this._map=e,window.addEventListener("hashchange",this._onHashChange,!1),e.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 e=this._map;if(!e)return"";const t=ts(e);if(this._hashName){const e=this._hashName;let r=!1;const i=location.hash.slice(1).split("&").map((i=>{const n=i.split("=")[0];return n===e?(r=!0,`${n}=${t}`):i})).filter((e=>e));return r||i.push(`${e}=${t}`),`#${i.join("&")}`}return`#${t}`}_getCurrentHash(){const e=location.hash.replace("#","");if(this._hashName){let t;return e.split("&").map((e=>e.split("="))).forEach((e=>{e[0]===this._hashName&&(t=e)})),(t&&t[1]||"").split("/")}return e.split("/")}_onHashChange(){const e=this._map;if(!e)return!1;const t=this._getCurrentHash();if(t.length>=3&&!t.some((e=>isNaN(e)))){const r=e.dragRotate.isEnabled()&&e.touchZoomRotate.isEnabled()?+(t[3]||0):e.getBearing();return e.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:r,pitch:+(t[4]||0)}),!0}return!1}_updateHashUnthrottled(){history.replaceState(history.state,"",location.href.replace(/(#.+)?$/,this.getHashString()))}}function ts(e,t){const r=e.getCenter(),i=Math.round(100*e.getZoom())/100,n=Math.ceil((i*Math.LN2+Math.log(512/360/.5))/Math.LN10),o=Math.pow(10,n),s=Math.round(r.lng*o)/o,a=Math.round(r.lat*o)/o,l=e.getBearing(),c=e.getPitch();let u=t?`/${s}/${a}/${i}`:`${i}/${a}/${s}`;return(l||c)&&(u+="/"+Math.round(10*l)/10),c&&(u+=`/${Math.round(c)}`),u}const rs={linearity:.3,easing:e.d6(0,0,.3,1)},is=e.e({deceleration:2500,maxSpeed:1400},rs),ns=e.e({deceleration:20,maxSpeed:1400},rs),os=e.e({deceleration:1e3,maxSpeed:360},rs),ss=e.e({deceleration:1e3,maxSpeed:90},rs);class as{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:e.f.now(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,r=e.f.now();for(;t.length>0&&r-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._map._prefersReducedMotion())return;if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const r={zoom:0,bearing:0,pitch:0,pan:new e.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)r.zoom+=e.zoomDelta||0,r.bearing+=e.bearingDelta||0,r.pitch+=e.pitchDelta||0,e.panDelta&&r.pan._add(e.panDelta),e.around&&(r.around=e.around),e.pinchAround&&(r.pinchAround=e.pinchAround);const i=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,n={};if(r.pan.mag()){const o=cs(r.pan.mag(),i,e.e({},is,t||{}));n.offset=r.pan.mult(o.amount/r.pan.mag()),n.center=this._map.transform.center,ls(n,o)}if(r.zoom){const e=cs(r.zoom,i,ns);n.zoom=this._map.transform.zoom+e.amount,ls(n,e)}if(r.bearing){const t=cs(r.bearing,i,os);n.bearing=this._map.transform.bearing+e.ad(t.amount,-179,179),ls(n,t)}if(r.pitch){const e=cs(r.pitch,i,ss);n.pitch=this._map.transform.pitch+e.amount,ls(n,e)}if(n.zoom||n.bearing){const e=void 0===r.pinchAround?r.around:r.pinchAround;n.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),n.noMoveStart=!0,n}}function ls(e,t){(!e.duration||e.duration<t.duration)&&(e.duration=t.duration,e.easing=t.easing)}function cs(t,r,i){const{maxSpeed:n,linearity:o,deceleration:s}=i,a=e.ad(t*o/(r/1e3),-n,n),l=Math.abs(a)/(s*o);return{easing:i.easing,duration:1e3*l,amount:a*(l/2)}}class us extends e.b{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,r,i,n={}){const o=f(r.getCanvasContainer(),i),s=r.unproject(o);super(t,e.e({point:o,lngLat:s,originalEvent:i},n)),this._defaultPrevented=!1,this.target=r}}class hs extends e.b{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,r,i){const n="touchend"===t?i.changedTouches:i.touches,o=m(r.getCanvasContainer(),n),s=o.map((e=>r.unproject(e))),a=o.reduce(((e,t,r,i)=>e.add(t.div(i.length))),new e.P(0,0));super(t,{points:o,point:a,lngLats:s,lngLat:r.unproject(a),originalEvent:i}),this._defaultPrevented=!1}}class ds extends e.b{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,r){super(e,{originalEvent:r}),this._defaultPrevented=!1}}class ps{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){this._mousedownPos=void 0}wheel(e){return this._firePreventable(new ds(e.type,this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new us(e.type,this._map,e))}mouseup(e){this._map.fire(new us(e.type,this._map,e))}preclick(t){const r=e.e({},t);r.type="preclick",this._map.fire(new us(r.type,this._map,r))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||(this.preclick(e),this._map.fire(new us(e.type,this._map,e)))}dblclick(e){return this._firePreventable(new us(e.type,this._map,e))}mouseover(e){this._map.fire(new us(e.type,this._map,e))}mouseout(e){this._map.fire(new us(e.type,this._map,e))}touchstart(e){return this._firePreventable(new hs(e.type,this._map,e))}touchmove(e){this._map.fire(new hs(e.type,this._map,e))}touchend(e){this._map.fire(new hs(e.type,this._map,e))}touchcancel(e){this._map.fire(new hs(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class fs{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(e){this._map.fire(new us(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new us("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._map.fire(new us(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class ms{constructor(e,t){this._map=e,this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=t.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(e,t){this.isEnabled()&&e.shiftKey&&0===e.button&&(u(),this._startPos=this._lastPos=t,this._active=!0)}mousemoveWindow(e,t){if(!this._active)return;const r=t,i=this._startPos,n=this._lastPos;if(!i||!n||n.equals(r)||!this._box&&r.dist(i)<this._clickTolerance)return;this._lastPos=r,this._box||(this._box=o("div","mapboxgl-boxzoom",this._container),this._container.classList.add("mapboxgl-crosshair"),this._fireEvent("boxzoomstart",e));const s=Math.min(i.x,r.x),a=Math.max(i.x,r.x),l=Math.min(i.y,r.y),c=Math.max(i.y,r.y);this._map._requestDomTask((()=>{this._box&&(this._box.style.transform=`translate(${s}px,${l}px)`,this._box.style.width=a-s+"px",this._box.style.height=c-l+"px")}))}mouseupWindow(t,r){if(!this._active)return;const i=this._startPos,n=r;if(i&&0===t.button){if(this.reset(),p(),i.x!==n.x||i.y!==n.y)return this._map.fire(new e.b("boxzoomend",{originalEvent:t})),{cameraAnimation:e=>e.fitScreenCoordinates(i,n,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",t)}}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),h(),delete this._startPos,delete this._lastPos}_fireEvent(t,r){return this._map.fire(new e.b(t,{originalEvent:r}))}}function As(e,t){const r={};for(let i=0;i<e.length;i++)r[e[i].identifier]=t[i];return r}class gs{constructor(e){this.reset(),this.numTouches=e.numTouches}reset(){this.centroid=void 0,this.startTime=0,this.touches={},this.aborted=!1}touchstart(t,r,i){(this.centroid||i.length>this.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=t.timeStamp),i.length===this.numTouches&&(this.centroid=function(t){const r=new e.P(0,0);for(const e of t)r._add(e);return r.div(t.length)}(r),this.touches=As(i,r)))}touchmove(e,t,r){if(this.aborted||!this.centroid)return;const i=As(r,t);for(const e in this.touches){const t=i[e];(!t||t.dist(this.touches[e])>30)&&(this.aborted=!0)}}touchend(e,t,r){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===r.length){const e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class _s{constructor(e){this.singleTap=new gs(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(e,t,r){this.singleTap.touchstart(e,t,r)}touchmove(e,t,r){this.singleTap.touchmove(e,t,r)}touchend(e,t,r){const i=this.singleTap.touchend(e,t,r);if(i){const t=e.timeStamp-this.lastTime<500,r=!this.lastTap||this.lastTap.dist(i)<30;if(t&&r||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=i,this.count===this.numTaps)return this.reset(),i}}}class ys{constructor(){this._zoomIn=new _s({numTouches:1,numTaps:2}),this._zoomOut=new _s({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,t,r){this._zoomIn.touchstart(e,t,r),this._zoomOut.touchstart(e,t,r)}touchmove(e,t,r){this._zoomIn.touchmove(e,t,r),this._zoomOut.touchmove(e,t,r)}touchend(e,t,r){const i=this._zoomIn.touchend(e,t,r),n=this._zoomOut.touchend(e,t,r);return i?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()+1,around:t.unproject(i)},{originalEvent:e})}):n?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()-1,around:t.unproject(n)},{originalEvent:e})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const xs={0:1,2:2};class vs{constructor(e){this.reset(),this._clickTolerance=e.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(e,t){return!1}_move(e,t){return{}}mousedown(e,t){if(this._lastPoint)return;const r=A(e);this._correctButton(e,r)&&(this._lastPoint=t,this._eventButton=r)}mousemoveWindow(e,t){const r=this._lastPoint;if(r)if(e.preventDefault(),null!=this._eventButton&&function(e,t){const r=xs[t];return void 0===e.buttons||(e.buttons&r)!==r}(e,this._eventButton))this.reset();else if(this._moved||!(t.dist(r)<this._clickTolerance))return this._moved=!0,this._lastPoint=t,this._move(r,t)}mouseupWindow(e){this._lastPoint&&A(e)===this._eventButton&&(this._moved&&p(),this.reset())}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class bs extends vs{mousedown(e,t){super.mousedown(e,t),this._lastPoint&&(this._active=!0)}_correctButton(e,t){return 0===t&&!e.ctrlKey}_move(e,t){return{around:t,panDelta:t.sub(e)}}}class ws extends vs{_correctButton(e,t){return 0===t&&e.ctrlKey||2===t}_move(e,t){const r=.8*(t.x-e.x);if(r)return this._active=!0,{bearingDelta:r}}contextmenu(e){e.preventDefault()}}class Cs extends vs{_correctButton(e,t){return 0===t&&e.ctrlKey||2===t}_move(e,t){const r=-.5*(t.y-e.y);if(r)return this._active=!0,{pitchDelta:r}}contextmenu(e){e.preventDefault()}}class Ts{constructor(t,r){this._map=t,this._el=t.getCanvasContainer(),this._minTouches=1,this._clickTolerance=r.clickTolerance||1,this.reset(),e.a$(["_addTouchPanBlocker","_showTouchPanBlockerAlert"],this)}reset(){this._active=!1,this._touches={},this._sum=new e.P(0,0)}touchstart(e,t,r){return this._calculateTransform(e,t,r)}touchmove(t,r,i){if(this._active&&!(i.length<this._minTouches)){if(this._map._cooperativeGestures&&!this._map.isMoving()){if(1===i.length&&!e.d7())return void this._showTouchPanBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}return t.cancelable&&t.preventDefault(),this._calculateTransform(t,r,i)}}touchend(e,t,r){this._calculateTransform(e,t,r),this._active&&r.length<this._minTouches&&this.reset()}touchcancel(){this.reset()}_calculateTransform(t,r,i){i.length>0&&(this._active=!0);const n=As(i,r),o=new e.P(0,0),s=new e.P(0,0);let a=0;for(const e in n){const t=n[e],r=this._touches[e];r&&(o._add(t),s._add(t.sub(r)),a++,n[e]=t)}if(this._touches=n,a<this._minTouches||!s.mag())return;const l=s.div(a);return this._sum._add(l),this._sum.mag()<this._clickTolerance?void 0:{around:o.div(a),panDelta:l}}enable(){this._enabled=!0,this._map._cooperativeGestures&&(this._addTouchPanBlocker(),this._el.classList.add("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page"))}disable(){this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove(),this._el.classList.remove("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page")),this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}_addTouchPanBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=o("div","mapboxgl-touch-pan-blocker",this._map._container),this._alertContainer.textContent=this._map._getUIString("TouchPanBlocker.Message"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_showTouchPanBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-touch-pan-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout((()=>{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.removeAttribute("role")}),500)}}class Es{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(e){}_move(e,t,r){return{}}touchstart(e,t,r){this._firstTwoTouches||r.length<2||(this._firstTwoTouches=[r[0].identifier,r[1].identifier],this._start([t[0],t[1]]))}touchmove(e,t,r){const i=this._firstTwoTouches;if(!i)return;e.preventDefault();const[n,o]=i,s=Ms(r,t,n),a=Ms(r,t,o);if(!s||!a)return;const l=this._aroundCenter?null:s.add(a).div(2);return this._move([s,a],l,e)}touchend(e,t,r){if(!this._firstTwoTouches)return;const[i,n]=this._firstTwoTouches,o=Ms(r,t,i),s=Ms(r,t,n);o&&s||(this._active&&p(),this.reset())}touchcancel(){this.reset()}enable(e){this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function Ms(e,t,r){for(let i=0;i<e.length;i++)if(e[i].identifier===r)return t[i]}function Ss(e,t){return Math.log(e/t)/Math.LN2}class Is extends Es{reset(){super.reset(),this._distance=0,this._startDistance=0}_start(e){this._startDistance=this._distance=e[0].dist(e[1])}_move(e,t){const r=this._distance;if(this._distance=e[0].dist(e[1]),this._active||!(Math.abs(Ss(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:Ss(this._distance,r),pinchAround:t}}}function Ps(e,t){return 180*e.angleWith(t)/Math.PI}class Ds extends Es{reset(){super.reset(),this._minDiameter=0,this._startVector=void 0,this._vector=void 0}_start(e){this._startVector=this._vector=e[0].sub(e[1]),this._minDiameter=e[0].dist(e[1])}_move(e,t){const r=this._vector;if(this._vector=e[0].sub(e[1]),r&&(this._active||!this._isBelowThreshold(this._vector)))return this._active=!0,{bearingDelta:Ps(this._vector,r),pinchAround:t}}_isBelowThreshold(e){this._minDiameter=Math.min(this._minDiameter,e.mag());const t=25/(Math.PI*this._minDiameter)*360,r=this._startVector;if(!r)return!1;const i=Ps(e,r);return Math.abs(i)<t}}function ks(e){return Math.abs(e.y)>Math.abs(e.x)}class Ls extends Es{constructor(e){super(),this._map=e}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(e){this._lastPoints=e,ks(e[0].sub(e[1]))&&(this._valid=!1)}_move(t,r,i){const n=this._lastPoints;if(!n)return;const o=t[0].sub(n[0]),s=t[1].sub(n[1]);return this._map._cooperativeGestures&&!e.d7()&&i.touches.length<3||(this._valid=this.gestureBeginsVertically(o,s,i.timeStamp),!this._valid)?void 0:(this._lastPoints=t,this._active=!0,{pitchDelta:(o.y+s.y)/2*-.5})}gestureBeginsVertically(e,t,r){if(void 0!==this._valid)return this._valid;const i=e.mag()>=2,n=t.mag()>=2;if(!i&&!n)return;if(!i||!n)return null==this._firstMove&&(this._firstMove=r),r-this._firstMove<100&&void 0;const o=e.y>0==t.y>0;return ks(e)&&ks(t)&&o}}const zs={panStep:100,bearingStep:15,pitchStep:10};class Os{constructor(){const e=zs;this._panStep=e.panStep,this._bearingStep=e.bearingStep,this._pitchStep=e.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,r=0,i=0,n=0,o=0;switch(e.keyCode){case 61:case 107:case 171:case 187:t=1;break;case 189:case 109:case 173:t=-1;break;case 37:e.shiftKey?r=-1:(e.preventDefault(),n=-1);break;case 39:e.shiftKey?r=1:(e.preventDefault(),n=1);break;case 38:e.shiftKey?i=1:(e.preventDefault(),o=-1);break;case 40:e.shiftKey?i=-1:(e.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(r=0,i=0),{cameraAnimation:s=>{const a=s.getZoom();s.easeTo({duration:300,easeId:"keyboardHandler",easing:Bs,zoom:t?Math.round(a)+t*(e.shiftKey?2:1):a,bearing:s.getBearing()+r*this._bearingStep,pitch:s.getPitch()+i*this._pitchStep,offset:[-n*this._panStep,-o*this._panStep],center:s.getCenter()},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function Bs(e){return e*(2-e)}const Rs=4.000244140625,Fs=1/450;class js{constructor(t,r){this._map=t,this._el=t.getCanvasContainer(),this._handler=r,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=Fs,e.a$(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this)}setZoomRate(e){this._defaultZoomRate=e}setWheelZoomRate(e){this._wheelZoomRate=e}isEnabled(){return!!this._enabled}isActive(){return this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&"center"===e.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()||e.d7()))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 i=e.f.now(),n=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,0!==r&&r%Rs==0?this._type="wheel":0!==r&&Math.abs(r)<4?this._type="trackpad":n>400?(this._type=null,this._lastValue=r,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(n*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(e){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e)}_start(e){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 t=f(this._el,e);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:t,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId)return;if(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 e="wheel"===this._type&&Math.abs(this._delta)>Rs?this._wheelZoomRate:this._defaultZoomRate;let i=2/(1+Math.exp(-Math.abs(this._delta*e)));this._delta<0&&0!==i&&(i=1/i);const n=r(),o=Math.pow(2,n),s="number"==typeof this._targetZoom?t.zoomScale(this._targetZoom):o;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(s*i))),"wheel"===this._type&&(this._startZoom=n,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0}const i="number"==typeof this._targetZoom?this._targetZoom:r(),n=this._startZoom,o=this._easing;let s,a=!1;if("wheel"===this._type&&n&&o){const t=Math.min((e.f.now()-this._lastWheelEventTime)/200,1),r=o(t);s=e.X(n,i,r),t<1?this._frameId||(this._frameId=!0):a=!0}else s=i,a=!0;this._active=!0,a&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout}),200));let l=s-r();return l*this._lastDelta<0&&(l=0),{noInertia:!0,needsRenderFrame:!a,zoomDelta:l,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let r=e.d8;if(this._prevEase){const t=this._prevEase,i=(e.f.now()-t.start)/t.duration,n=t.easing(i+.01)-t.easing(i),o=.27/Math.sqrt(n*n+1e-4)*.01,s=Math.sqrt(.0729-o*o);r=e.d6(o,s,.25,1)}return this._prevEase={start:e.f.now(),duration:t,easing:r},r}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=o("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=setTimeout((()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.removeAttribute("role")}),200)}}class Vs{constructor(e,t){this._clickZoom=e,this._tapZoom=t}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class Ns{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(e,t){return e.preventDefault(),{cameraAnimation:r=>{r.easeTo({duration:300,zoom:r.getZoom()+(e.shiftKey?-1:1),around:r.unproject(t)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Us{constructor(){this._tap=new _s({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(e,t,r){this._swipePoint||(this._tapTime&&e.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?r.length>0&&(this._swipePoint=t[0],this._swipeTouch=r[0].identifier):this._tap.touchstart(e,t,r))}touchmove(e,t,r){if(this._tapTime){if(this._swipePoint){if(r[0].identifier!==this._swipeTouch)return;const i=t[0],n=i.y-this._swipePoint.y;return this._swipePoint=i,e.preventDefault(),this._active=!0,{zoomDelta:n/128}}}else this._tap.touchmove(e,t,r)}touchend(e,t,r){this._tapTime?this._swipePoint&&0===r.length&&this.reset():this._tap.touchend(e,t,r)&&(this._tapTime=e.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Hs{constructor(e,t,r){this._el=e,this._mousePan=t,this._touchPan=r}enable(e){this._inertiaOptions=e||{},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 Gs{constructor(e,t,r){this._pitchWithRotate=e.pitchWithRotate,this._mouseRotate=t,this._mousePitch=r}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 Zs{constructor(e,t,r,i){this._el=e,this._touchZoom=t,this._touchRotate=r,this._tapDragZoom=i,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("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 Ws=e=>e.zoom||e.drag||e.pitch||e.rotate;class Qs extends e.b{}class qs{constructor(){this.constants=[1,1,.01],this.radius=0}setup(t,r){const i=e.Q.sub([],r,t);this.radius=e.Q.length(i[2]<0?e.Q.div([],i,this.constants):[i[0],i[1],0])}projectRay(t){e.Q.div(t,t,this.constants),e.Q.normalize(t,t),e.Q.mul(t,t,this.constants);const r=e.Q.scale([],t,this.radius);if(r[2]>0){const t=e.Q.scale([],[0,0,1],e.Q.dot(r,[0,0,1])),i=e.Q.scale([],e.Q.normalize([],[r[0],r[1],0]),this.radius),n=e.Q.add([],r,e.Q.scale([],e.Q.sub([],e.Q.add([],i,t),r),2));r[0]=n[0],r[1]=n[1]}return r}}function Xs(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta}class Ys{constructor(t,r){this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new as(t),this._bearingSnap=r.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new qs,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(r),e.a$(["handleEvent","handleWindowEvent"],this);const i=this._el;this._listeners=[[i,"touchstart",{passive:!0}],[i,"touchmove",{passive:!1}],[i,"touchend",void 0],[i,"touchcancel",void 0],[i,"mousedown",void 0],[i,"mousemove",void 0],[i,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[i,"mouseover",void 0],[i,"mouseout",void 0],[i,"dblclick",void 0],[i,"click",void 0],[i,"keydown",{capture:!1}],[i,"keyup",void 0],[i,"wheel",{passive:!1}],[i,"contextmenu",void 0],[window,"blur",void 0]];for(const[e,t,r]of this._listeners){const i=e===document?this.handleWindowEvent:this.handleEvent;e.addEventListener(t,i,r)}}destroy(){for(const[e,t,r]of this._listeners){const i=e===document?this.handleWindowEvent:this.handleEvent;e.removeEventListener(t,i,r)}}_addDefaultHandlers(e){const t=this._map,r=t.getCanvasContainer();this._add("mapEvent",new ps(t,e));const i=t.boxZoom=new ms(t,e);this._add("boxZoom",i);const n=new ys,o=new Ns;t.doubleClickZoom=new Vs(o,n),this._add("tapZoom",n),this._add("clickZoom",o);const s=new Us;this._add("tapDragZoom",s);const a=t.touchPitch=new Ls(t);this._add("touchPitch",a);const l=new ws(e),c=new Cs(e);t.dragRotate=new Gs(e,l,c),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",c,["mouseRotate"]);const u=new bs(e),h=new Ts(t,e);t.dragPan=new Hs(r,u,h),this._add("mousePan",u),this._add("touchPan",h,["touchZoom","touchRotate"]);const d=new Ds,p=new Is;t.touchZoomRotate=new Zs(r,p,d,s),this._add("touchRotate",d,["touchPan","touchZoom"]),this._add("touchZoom",p,["touchPan","touchRotate"]),this._add("blockableMapEvent",new fs(t));const f=t.scrollZoom=new js(t,this);this._add("scrollZoom",f,["mousePan"]);const m=t.keyboard=new Os;this._add("keyboard",m);for(const r of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])e.interactive&&e[r]&&t[r].enable(e[r])}_add(e,t,r){this._handlers.push({handlerName:e,handler:t,allowed:r}),this._handlersById[e]=t}stop(e){if(!this._updatingCamera){for(const{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[],this._originalZoom=void 0}}isActive(){for(const{handler:e}of this._handlers)if(e.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!Ws(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(e,t,r){for(const i in e)if(i!==r&&(!t||t.indexOf(i)<0))return!0;return!1}handleWindowEvent(e){this.handleEvent(e,`${e.type}Window`)}_getMapTouches(e){const t=[];for(const r of e)this._el.contains(r.target)&&t.push(r);return t}handleEvent(e,t){this._updatingCamera=!0;const r="renderFrame"===e.type,i=r?void 0:e,n={needsRenderFrame:!1},o={},s={},a=e.touches?this._getMapTouches(e.touches):void 0,l=a?m(this._el,a):r?void 0:f(this._el,e);for(const{handlerName:r,handler:c,allowed:u}of this._handlers){if(!c.isEnabled())continue;let h;this._blockedByActive(s,u,r)?c.reset():c[t||e.type]&&(h=c[t||e.type](e,l,a),this.mergeHandlerResult(n,o,h,r,i),h&&h.needsRenderFrame&&this._triggerRenderFrame()),(h||c.isActive())&&(s[r]=c)}const c={};for(const e in this._previousActiveHandlers)s[e]||(c[e]=i);this._previousActiveHandlers=s,(Object.keys(c).length||Xs(n))&&(this._changes.push([n,o,c]),this._triggerRenderFrame()),(Object.keys(s).length||Xs(n))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:u}=n;u&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],u(this._map))}mergeHandlerResult(t,r,i,n,o){if(!i)return;e.e(t,i);const s={handlerName:n,originalEvent:i.originalEvent||o};void 0!==i.zoomDelta&&(r.zoom=s),void 0!==i.panDelta&&(r.drag=s),void 0!==i.pitchDelta&&(r.pitch=s),void 0!==i.bearingDelta&&(r.rotate=s)}_applyChanges(){const t={},r={},i={};for(const[n,o,s]of this._changes)n.panDelta&&(t.panDelta=(t.panDelta||new e.P(0,0))._add(n.panDelta)),n.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+n.zoomDelta),n.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+n.bearingDelta),n.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+n.pitchDelta),void 0!==n.around&&(t.around=n.around),void 0!==n.aroundCoord&&(t.aroundCoord=n.aroundCoord),void 0!==n.pinchAround&&(t.pinchAround=n.pinchAround),n.noInertia&&(t.noInertia=n.noInertia),e.e(r,o),e.e(i,s);this._updateMapTransform(t,r,i),this._changes=[]}_updateMapTransform(t,r,i){const n=this._map,o=n.transform,s=e=>[e.x,e.y,e.z];if((e=>{const t=this._eventsInProgress.drag;return t&&!this._handlersById[t.handlerName].isActive()})()&&!Xs(t)){const e=o.zoom;o.cameraElevationReference="sea",null!=this._originalZoom&&o._orthographicProjectionAtLowPitch&&"globe"!==o.projection.name&&0===o.pitch?(o.cameraElevationReference="ground",o.zoom=this._originalZoom):(o.recenterOnTerrain(),o.cameraElevationReference="ground"),e!==o.zoom&&this._map._update(!0)}if(o._isCameraConstrained&&n._stop(!0),!Xs(t))return void this._fireEvents(r,i,!0);let{panDelta:a,zoomDelta:l,bearingDelta:c,pitchDelta:u,around:h,aroundCoord:d,pinchAround:p}=t;o._isCameraConstrained&&(l>0&&(l=0),o._isCameraConstrained=!1),void 0!==p&&(h=p),(l||(e=>r[e]&&!this._eventsInProgress[e])("drag"))&&h&&(this._dragOrigin=s(o.pointCoordinate3D(h)),this._originalZoom=o.zoom,this._trackingEllipsoid.setup(o._camera.position,this._dragOrigin)),o.cameraElevationReference="sea",n._stop(!0),h=h||n.transform.centerPoint,c&&(o.bearing+=c),u&&(o.pitch+=u),o._updateCameraState();const f=[0,0,0];if(a)if("mercator"===o.projection.name){const e=this._trackingEllipsoid.projectRay(o.screenPointToMercatorRay(h).dir),t=this._trackingEllipsoid.projectRay(o.screenPointToMercatorRay(h.sub(a)).dir);f[0]=t[0]-e[0],f[1]=t[1]-e[1]}else{const t=o.pointCoordinate(h);if("globe"===o.projection.name){a=a.rotate(-o.angle);const r=o._pixelsPerMercatorPixel/o.worldSize;f[0]=-a.x*e.d9(e.ax(t.y))*r,f[1]=-a.y*e.d9(o.center.lat)*r}else{const e=o.pointCoordinate(h.sub(a));t&&e&&(f[0]=e.x-t.x,f[1]=e.y-t.y)}}const m=o.zoom,A=[0,0,0];if(l){const t=s(d||o.pointCoordinate3D(h)),r={dir:e.Q.normalize([],e.Q.sub([],t,o._camera.position))};if(r.dir[2]<0){const i=o.zoomDeltaToMovement(t,l);e.Q.scale(A,r.dir,i)}}const g=e.Q.add(f,f,A);o._translateCameraConstrained(g),l&&Math.abs(o.zoom-m)>1e-4&&o.recenterOnTerrain(),o.cameraElevationReference="ground",this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(r,i,!0)}_fireEvents(t,r,i){const n=Ws(this._eventsInProgress),o=Ws(t),s={};for(const e in t){const{originalEvent:r}=t[e];this._eventsInProgress[e]||(s[`${e}start`]=r),this._eventsInProgress[e]=t[e]}!n&&o&&this._fireEvent("movestart",o.originalEvent);for(const e in s)this._fireEvent(e,s[e]);o&&this._fireEvent("move",o.originalEvent);for(const e in t){const{originalEvent:r}=t[e];this._fireEvent(e,r)}const a={};let l;for(const e in this._eventsInProgress){const{handlerName:t,originalEvent:i}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],l=r[t]||i,a[`${e}end`]=l)}for(const e in a)this._fireEvent(e,a[e]);const c=Ws(this._eventsInProgress);if(i&&(n||o)&&!c){this._updatingCamera=!0;const t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),r=e=>0!==e&&-this._bearingSnap<e&&e<this._bearingSnap;t?(r(t.bearing||this._map.getBearing())&&(t.bearing=0),this._map.easeTo(t,{originalEvent:l})):(this._map.fire(new e.b("moveend",{originalEvent:l})),r(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(t,r){this._map.fire(new e.b(t,r?{originalEvent:r}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add((e=>{this._frameId=void 0,this.handleEvent(new Qs("renderFrame",{timeStamp:e})),this._applyChanges()}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}const $s="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class Ks extends e.E{constructor(t,r){super(),this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=r.bearingSnap,this._respectPrefersReducedMotion=!1!==r.respectPrefersReducedMotion,e.a$(["_renderFrameCallback"],this)}getCenter(){return new e.bq(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}panBy(t,r,i){return t=e.P.convert(t).mult(-1),this.panTo(this.transform.center,e.e({offset:t},r),i)}panTo(t,r,i){return this.easeTo(e.e({center:t},r),i)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(t,r,i){return this.easeTo(e.e({zoom:t},r),i)}zoomIn(e,t){return this.zoomTo(this.getZoom()+1,e,t),this}zoomOut(e,t){return this.zoomTo(this.getZoom()-1,e,t),this}getBearing(){return this.transform.bearing}setBearing(e,t){return this.jumpTo({bearing:e},t),this}getPadding(){return this.transform.padding}setPadding(e,t){return this.jumpTo({padding:e},t),this}rotateTo(t,r,i){return this.easeTo(e.e({bearing:t},r),i)}resetNorth(t,r){return this.rotateTo(0,e.e({duration:1e3},t),r),this}resetNorthPitch(t,r){return this.easeTo(e.e({bearing:0,pitch:0,duration:1e3},t),r),this}snapToNorth(e,t){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(e,t):this}getPitch(){return this.transform.pitch}setPitch(e,t){return this.jumpTo({pitch:e},t),this}cameraForBounds(t,r){t=e.ag.convert(t);const i=r&&r.bearing||0,n=r&&r.pitch||0,o=t.getNorthWest(),s=t.getSouthEast();return this._cameraForBounds(this.transform,o,s,i,n,r)}_extendPadding(t){const r={top:0,right:0,bottom:0,left:0};return null==t?e.e({},r,this.transform.padding):"number"==typeof t?{top:t,bottom:t,right:t,left:t}:e.e({},r,t)}_extendCameraOptions(t){return(t=e.e({offset:[0,0],maxZoom:this.transform.maxZoom},t)).padding=this._extendPadding(t.padding),t}_minimumAABBFrustumDistance(e,t){const r=t.max[0]-t.min[0],i=t.max[1]-t.min[1];return r/i>e.aspect?r/(2*Math.tan(.5*e.fovX)*e.aspect):i/(2*Math.tan(.5*e.fovY)*e.aspect)}_cameraForBoundsOnGlobe(t,r,i,n,o,s){const a=t.clone(),l=this._extendCameraOptions(s);a.bearing=n,a.pitch=o;const c=e.bq.convert(r),u=e.bq.convert(i),h=.5*(c.lat+u.lat),d=.5*(c.lng+u.lng),p=e.da(h,d),f=e.Q.normalize([],p),m=e.Q.normalize([],e.Q.cross([],f,[0,1,0])),A=e.Q.cross([],m,f),g=[m[0],m[1],m[2],0,A[0],A[1],A[2],0,f[0],f[1],f[2],0,0,0,0,1],_=[p,e.da(c.lat,c.lng),e.da(u.lat,c.lng),e.da(u.lat,u.lng),e.da(c.lat,u.lng),e.da(h,c.lng),e.da(h,u.lng),e.da(c.lat,d),e.da(u.lat,d)];let y=e.bV.fromPoints(_.map((t=>[e.Q.dot(m,t),e.Q.dot(A,t),e.Q.dot(f,t)])));const x=e.Q.transformMat4([],y.center,g);0===e.Q.squaredLength(x)&&e.Q.set(x,0,0,1),e.Q.normalize(x,x),e.Q.scale(x,x,e.ae),a.center=e.db(x);const v=a.getWorldToCameraMatrix(),b=e.a9.invert(new Float64Array(16),v);y=e.bV.applyTransform(y,e.a9.multiply([],v,g));const w=this._extendAABB(y,a,l,n);if(!w)return void e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");y=w,e.Q.transformMat4(x,x,v);const C=.5*(y.max[2]-y.min[2]),T=this._minimumAABBFrustumDistance(a,y),E=e.Q.scale([],[0,0,1],C),M=e.Q.add(E,x,E),S=T+(0===a.pitch?0:e.Q.distance(x,M)),I=a.globeCenterInViewSpace,P=e.Q.sub([],x,[I[0],I[1],I[2]]);e.Q.normalize(P,P),e.Q.scale(P,P,S);const D=e.Q.add([],x,P);e.Q.transformMat4(D,D,b);const k=e.dc/e.ae,L=e.Q.length(D),z=e.bo(Math.max(L*k-e.dc,Number.EPSILON),0),O=Math.min(a.zoomFromMercatorZAdjusted(z),l.maxZoom);return O>.5*(e.bJ+e.bA)?(a.setProjection({name:"mercator"}),a.zoom=O,this._cameraForBounds(a,r,i,n,o,s)):{center:a.center,zoom:O,bearing:n,pitch:o}}_extendAABB(t,r,i,n){const o=.5*((i.padding.left||0)+(i.padding.right||0)),s=.5*((i.padding.top||0)+(i.padding.bottom||0)),a=s,l=o,c=o,u=s,h=r.width-(l+c),d=r.height-(a+u),p=e.Q.sub([],t.max,t.min),f=Math.min(h/p[0],d/p[1]),m=Math.min(r.scaleZoom(r.scale*f),i.maxZoom);if(isNaN(m))return null;const A=r.scale/r.zoomScale(m),g=new e.bV([t.min[0]-l*A,t.min[1]-u*A,t.min[2]],[t.max[0]+c*A,t.max[1]+a*A,t.max[2]]),_=("number"==typeof i.offset.x&&"number"==typeof i.offset.y?new e.P(i.offset.x,i.offset.y):e.P.convert(i.offset)).rotate(-e.bm(n));return g.center[0]-=_.x*A,g.center[1]+=_.y*A,g}queryTerrainElevation(t,r){const i=this.transform.elevation;return i?(r=e.e({},{exaggerated:!0},r),i.getAtPoint(e.O.fromLngLat(t),null,r.exaggerated)):null}_cameraForBounds(t,r,i,n,o,s){if("globe"===t.projection.name)return this._cameraForBoundsOnGlobe(t,r,i,n,o,s);const a=t.clone(),l=this._extendCameraOptions(s);a.bearing=n,a.pitch=o;const c=e.bq.convert(r),u=e.bq.convert(i),h=new e.bq(c.lng,u.lat),d=new e.bq(u.lng,c.lat),p=a.project(c),f=a.project(u),m=this.queryTerrainElevation(c),A=this.queryTerrainElevation(u),g=this.queryTerrainElevation(h),_=this.queryTerrainElevation(d),y=[[p.x,p.y,Math.min(m||0,A||0,g||0,_||0)],[f.x,f.y,Math.max(m||0,A||0,g||0,_||0)]];let x=e.bV.fromPoints(y);const v=a.getWorldToCameraMatrix(),b=e.a9.invert(new Float64Array(16),v);x=e.bV.applyTransform(x,v);const w=this._extendAABB(x,a,l,n);if(!w)return void e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");x=w;const C=.5*e.Q.sub([],x.max,x.min)[2],T=this._minimumAABBFrustumDistance(a,x),E=[0,0,1,0];e.aa.transformMat4(E,E,v),e.aa.normalize(E,E);const M=e.Q.scale([],E,T+C),S=e.Q.add([],x.center,M);e.Q.transformMat4(x.center,x.center,b),e.Q.transformMat4(S,S,b);const I=[x.center[0],x.center[1],S[2]*a.pixelsPerMeter];e.Q.scale(I,I,1/a.worldSize);const P=e.aw(I[0]),D=e.ax(I[1]),k=Math.min(a._zoomFromMercatorZ(I[2]),l.maxZoom),L=new e.bq(P,D);return a.mercatorFromTransition&&k<.5*(e.bJ+e.bA)?(a.setProjection({name:"globe"}),a.zoom=k,this._cameraForBounds(a,r,i,n,o,s)):{center:L,zoom:k,bearing:n,pitch:o}}fitBounds(e,t,r){const i=this.cameraForBounds(e,t);return this._fitInternal(i,t,r)}fitScreenCoordinates(t,r,i,n,o){const s=e.P.convert(t),a=e.P.convert(r),l=new e.P(Math.min(s.x,a.x),Math.min(s.y,a.y)),c=new e.P(Math.max(s.x,a.x),Math.max(s.y,a.y));if("mercator"===this.transform.projection.name&&this.transform.anyCornerOffEdge(s,a))return this;const u=this.transform.pointLocation3D(l),h=this.transform.pointLocation3D(c),d=this.transform.pointLocation3D(new e.P(l.x,c.y)),p=this.transform.pointLocation3D(new e.P(c.x,l.y)),f=[Math.min(u.lng,h.lng,d.lng,p.lng),Math.min(u.lat,h.lat,d.lat,p.lat)],m=[Math.max(u.lng,h.lng,d.lng,p.lng),Math.max(u.lat,h.lat,d.lat,p.lat)],A=n&&n.pitch?n.pitch:this.getPitch(),g=this._cameraForBounds(this.transform,f,m,i,A,n);return this._fitInternal(g,n,o)}_fitInternal(t,r,i){return t?(r=e.e(t,r)).linear?this.easeTo(r,i):this.flyTo(r,i):this}jumpTo(t,r){this.stop();const i=t.preloadOnly?this.transform.clone():this.transform;let n=!1,o=!1,s=!1;return"zoom"in t&&i.zoom!==+t.zoom&&(n=!0,i.zoom=+t.zoom),void 0!==t.center&&(i.center=e.bq.convert(t.center)),"bearing"in t&&i.bearing!==+t.bearing&&(o=!0,i.bearing=+t.bearing),"pitch"in t&&i.pitch!==+t.pitch&&(s=!0,i.pitch=+t.pitch),null==t.padding||i.isPaddingEqual(t.padding)||(i.padding=t.padding),t.preloadOnly?(this._preloadTiles(i),this):(this.fire(new e.b("movestart",r)).fire(new e.b("move",r)),n&&this.fire(new e.b("zoomstart",r)).fire(new e.b("zoom",r)).fire(new e.b("zoomend",r)),o&&this.fire(new e.b("rotatestart",r)).fire(new e.b("rotate",r)).fire(new e.b("rotateend",r)),s&&this.fire(new e.b("pitchstart",r)).fire(new e.b("pitch",r)).fire(new e.b("pitchend",r)),this.fire(new e.b("moveend",r)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||e.w($s),this.transform.getFreeCameraOptions()}setFreeCameraOptions(t,r){const i=this.transform;if(!i.projection.supportsFreeCamera)return e.w($s),this;this.stop();const n=i.zoom,o=i.pitch,s=i.bearing;i.setFreeCameraOptions(t);const a=n!==i.zoom,l=o!==i.pitch,c=s!==i.bearing;return this.fire(new e.b("movestart",r)).fire(new e.b("move",r)),a&&this.fire(new e.b("zoomstart",r)).fire(new e.b("zoom",r)).fire(new e.b("zoomend",r)),c&&this.fire(new e.b("rotatestart",r)).fire(new e.b("rotate",r)).fire(new e.b("rotateend",r)),l&&this.fire(new e.b("pitchstart",r)).fire(new e.b("pitch",r)).fire(new e.b("pitchend",r)),this.fire(new e.b("moveend",r)),this}easeTo(t,r){this._stop(!1,t.easeId),(!1===(t=e.e({offset:[0,0],duration:500,easing:e.d8},t)).animate||this._prefersReducedMotion(t))&&(t.duration=0);const i=this.transform,n=this.getZoom(),o=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in t?+t.zoom:n,c="bearing"in t?this._normalizeBearing(t.bearing,o):o,u="pitch"in t?+t.pitch:s,h=this._extendPadding(t.padding),d=e.P.convert(t.offset);let p,f,m;if("globe"===i.projection.name){const r=e.O.fromLngLat(i.center),n=d.rotate(-i.angle);r.x+=n.x/i.worldSize,r.y+=n.y/i.worldSize;const o=r.toLngLat(),s=e.bq.convert(t.center||o);this._normalizeCenter(s),p=i.centerPoint.add(n),f=new e.P(r.x,r.y).mult(i.worldSize),m=new e.P(e.a8(s.lng),e.ah(s.lat)).mult(i.worldSize).sub(f)}else{p=i.centerPoint.add(d);const r=i.pointLocation(p),n=e.bq.convert(t.center||r);this._normalizeCenter(n),f=i.project(r),m=i.project(n).sub(f)}const A=i.zoomScale(l-n);let g,_;t.around&&(g=e.bq.convert(t.around),_=i.locationPoint(g));const y=this._zooming||l!==n,x=this._rotating||o!==c,v=this._pitching||u!==s,b=!i.isPaddingEqual(h),w=i=>w=>{if(y&&(i.zoom=e.X(n,l,w)),x&&(i.bearing=e.X(o,c,w)),v&&(i.pitch=e.X(s,u,w)),b&&(i.interpolatePadding(a,h,w),p=i.centerPoint.add(d)),g)i.setLocationAtPoint(g,_);else{const e=i.zoomScale(i.zoom-n),t=l>n?Math.min(2,A):Math.max(.5,A),r=Math.pow(t,1-w),o=i.unproject(f.add(m.mult(w*r)).mult(e));i.setLocationAtPoint(i.renderWorldCopies?o.wrap():o,p)}return t.preloadOnly||this._fireMoveEvents(r),i};if(t.preloadOnly){const e=this._emulate(w,t.duration,i);return this._preloadTiles(e),this}const C={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=y,this._rotating=x,this._pitching=v,this._padding=b,this._easeId=t.easeId,this._prepareEase(r,t.noMoveStart,C),this._ease(w(i),(e=>{"sea"===i.cameraElevationReference&&i.recenterOnTerrain(),this._afterEase(r,e)}),t),this}_prepareEase(t,r,i={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&0===this.transform.pitch&&"globe"!==this.transform.projection.name&&(this.transform.cameraElevationReference="ground"),r||i.moving||this.fire(new e.b("movestart",t)),this._zooming&&!i.zooming&&this.fire(new e.b("zoomstart",t)),this._rotating&&!i.rotating&&this.fire(new e.b("rotatestart",t)),this._pitching&&!i.pitching&&this.fire(new e.b("pitchstart",t))}_fireMoveEvents(t){this.fire(new e.b("move",t)),this._zooming&&this.fire(new e.b("zoom",t)),this._rotating&&this.fire(new e.b("rotate",t)),this._pitching&&this.fire(new e.b("pitch",t))}_afterEase(t,r){if(this._easeId&&r&&this._easeId===r)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const i=this._zooming,n=this._rotating,o=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,i&&this.fire(new e.b("zoomend",t)),n&&this.fire(new e.b("rotateend",t)),o&&this.fire(new e.b("pitchend",t)),this.fire(new e.b("moveend",t))}flyTo(t,r){if(this._prefersReducedMotion(t)){const i=e.af(t,["center","zoom","bearing","pitch","around"]);return this.jumpTo(i,r)}this.stop(),t=e.e({offset:[0,0],speed:1.2,curve:1.42,easing:e.d8},t);const i=this.transform,n=this.getZoom(),o=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in t?e.ad(+t.zoom,i.minZoom,i.maxZoom):n,c="bearing"in t?this._normalizeBearing(t.bearing,o):o,u="pitch"in t?+t.pitch:s,h=this._extendPadding(t.padding),d=i.zoomScale(l-n),p=e.P.convert(t.offset);let f=i.centerPoint.add(p);const m=i.pointLocation(f),A=e.bq.convert(t.center||m);this._normalizeCenter(A);const g=i.project(m),_=i.project(A).sub(g);let y=t.curve;const x=Math.max(i.width,i.height),v=x/d,b=_.mag();if("minZoom"in t){const r=e.ad(Math.min(t.minZoom,n,l),i.minZoom,i.maxZoom),o=x/i.zoomScale(r-n);y=Math.sqrt(o/b*2)}const w=y*y;function C(e){const t=(v*v-x*x+(e?-1:1)*w*w*b*b)/(2*(e?v:x)*w*b);return Math.log(Math.sqrt(t*t+1)-t)}function T(e){return(Math.exp(e)-Math.exp(-e))/2}function E(e){return(Math.exp(e)+Math.exp(-e))/2}const M=C(0);let S=function(e){return E(M)/E(M+y*e)},I=function(e){return x*((E(M)*(T(t=M+y*e)/E(t))-T(M))/w)/b;var t},P=(C(1)-M)/y;if(Math.abs(b)<1e-6||!isFinite(P)){if(Math.abs(x-v)<1e-6)return this.easeTo(t,r);const e=v<x?-1:1;P=Math.abs(Math.log(v/x))/y,I=function(){return 0},S=function(t){return Math.exp(e*y*t)}}t.duration="duration"in t?+t.duration:1e3*P/("screenSpeed"in t?+t.screenSpeed/y:+t.speed),t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0);const D=o!==c,k=u!==s,L=!i.isPaddingEqual(h),z=i=>d=>{const m=d*P,y=1/S(m);i.zoom=1===d?l:n+i.scaleZoom(y),D&&(i.bearing=e.X(o,c,d)),k&&(i.pitch=e.X(s,u,d)),L&&(i.interpolatePadding(a,h,d),f=i.centerPoint.add(p));const x=1===d?A:i.unproject(g.add(_.mult(I(m))).mult(y));return i.setLocationAtPoint(i.renderWorldCopies?x.wrap():x,f),i._updateCameraOnTerrain(),t.preloadOnly||this._fireMoveEvents(r),i};if(t.preloadOnly){const e=this._emulate(z,t.duration,i);return this._preloadTiles(e),this}return this._zooming=!0,this._rotating=D,this._pitching=k,this._padding=L,this._prepareEase(r,!1),this._ease(z(i),(()=>this._afterEase(r)),t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_requestRenderFrame(e){}_cancelRenderFrame(e){}_stop(e,t){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const e=this._onEaseEnd;this._onEaseEnd=void 0,e.call(this,t)}if(!e){const e=this.handlers;e&&e.stop(!1)}return this}_ease(t,r,i){!1===i.animate||0===i.duration?(t(1),r()):(this._easeStart=e.f.now(),this._easeOptions=i,this._onEaseFrame=t,this._onEaseEnd=r,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const t=Math.min((e.f.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=e.bk(t,-180,180);const i=Math.abs(t-r);return Math.abs(t-360-r)<i&&(t-=360),Math.abs(t+360-r)<i&&(t+=360),t}_normalizeCenter(e){const t=this.transform;if(t.maxBounds)return;if("globe"!==t.projection.name&&!t.renderWorldCopies)return;const r=e.lng-t.center.lng;e.lng+=r>180?-360:r<-180?360:0}_prefersReducedMotion(t){return this._respectPrefersReducedMotion&&e.f.prefersReducedMotion&&!(t&&t.essential)}_emulate(e,t,r){const i=Math.ceil(15*t/1e3),n=[],o=e(r.clone());for(let e=0;e<=i;e++){const t=o(e/i);n.push(t.clone())}return n}_preloadTiles(e,t){}}class Js{constructor(t={}){this.options=t,e.a$(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(e){const t=this.options&&this.options.compact;return this._map=e,this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=o("button","mapboxgl-ctrl-attrib-button",this._container),o("span","mapboxgl-ctrl-icon",this._compactButton).setAttribute("aria-hidden","true"),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=o("div","mapboxgl-ctrl-attrib-inner",this._container),t&&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===t&&(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}_setElementTitle(e,t){const r=this._map._getUIString(`AttributionControl.${t}`);e.removeAttribute("title"),e.firstElementChild&&e.firstElementChild.setAttribute("title",r)}_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||e.dd.ACCESS_TOKEN}];if(t){const i=r.reduce(((e,t,i)=>(t.value&&(e+=`${t.key}=${t.value}${i<r.length-1?"&":""}`),e)),"?");t.href=`${e.dd.FEEDBACK_URL}/${i}#${ts(this._map,!0)}`,t.rel="noopener nofollow",this._setElementTitle(t,"MapFeedback")}}_updateData(e){!e||"metadata"!==e.sourceDataType&&"visibility"!==e.sourceDataType&&"style"!==e.dataType||(this._updateAttributions(),this._updateEditLink())}_updateAttributions(){if(!this._map.style)return;let e=[];if(this._map.style.stylesheet){const e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id}const t=this._map.style._mergedSourceCaches;for(const r in t){const i=t[r];if(i.used){const t=i.getSource();t.attribution&&e.indexOf(t.attribution)<0&&e.push(t.attribution)}}e.sort(((e,t)=>e.length-t.length)),e=e.filter(((t,r)=>{for(let i=r+1;i<e.length;i++)if(e[i].indexOf(t)>=0)return!1;return!0})),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=[...this.options.customAttribution,...e]:e.unshift(this.options.customAttribution));const r=e.join(" | ");r!==this._attribHTML&&(this._attribHTML=r,e.length?(this._innerContainer.innerHTML=r,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 ea{constructor(){e.a$(["_updateLogo","_updateCompact"],this)}onAdd(e){this._map=e,this._container=o("div","mapboxgl-ctrl");const t=o("a","mapboxgl-ctrl-logo");return t.target="_blank",t.rel="noopener nofollow",t.href="https://www.mapbox.com/",t.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),t.setAttribute("rel","noopener nofollow"),this._container.appendChild(t),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(e){e&&"metadata"!==e.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const e=this._map.style._sourceCaches;if(0===Object.entries(e).length)return!0;for(const t in e){const r=e[t].getSource();if(r.hasOwnProperty("mapbox_logo")&&!r.mapbox_logo)return!1}return!0}_updateCompact(){const e=this._container.children;if(e.length){const t=e[0];this._map.getCanvasContainer().offsetWidth<250?t.classList.add("mapboxgl-compact"):t.classList.remove("mapboxgl-compact")}}}class ta{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){const t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}remove(e){const t=this._currentlyRunning,r=t?this._queue.concat(t):this._queue;for(const t of r)if(t.id===e)return void(t.cancelled=!0)}run(e=0){const t=this._currentlyRunning=this._queue;this._queue=[];for(const r of t)if(!r.cancelled&&(r.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function ra(t,r,i){if(t=new e.bq(t.lng,t.lat),r){const n=new e.bq(t.lng-360,t.lat),o=new e.bq(t.lng+360,t.lat),s=360*Math.ceil(Math.abs(t.lng-i.center.lng)/360),a=i.locationPoint(t).distSqr(r),l=r.x<0||r.y<0||r.x>i.width||r.y>i.height;i.locationPoint(n).distSqr(r)<a&&(l||Math.abs(n.lng-i.center.lng)<s)?t=n:i.locationPoint(o).distSqr(r)<a&&(l||Math.abs(o.lng-i.center.lng)<s)&&(t=o)}for(;Math.abs(t.lng-i.center.lng)>180;){const e=i.locationPoint(t);if(e.x>=0&&e.y>=0&&e.x<=i.width&&e.y<=i.height)break;t.lng>i.center.lng?t.lng-=360:t.lng+=360}return t}const ia={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 na extends e.E{constructor(t,r){if(super(),(t instanceof HTMLElement||r)&&(t=e.e({element:t},r)),e.a$(["_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=e.P.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=o("div");const r=41,i=27,n=s("svg",{display:"block",height:r*this._scale+"px",width:i*this._scale+"px",viewBox:`0 0 ${i} ${r}`},this._element),a=s("radialGradient",{id:"shadowGradient"},s("defs",{},n));s("stop",{offset:"10%","stop-opacity":.4},a),s("stop",{offset:"100%","stop-opacity":.05},a),s("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},n),s("path",{fill:this._color,d:"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z"},n),s("path",{opacity:.25,d:"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z"},n),s("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},n),this._offset=e.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",(e=>{e.preventDefault()})),this._element.addEventListener("mousedown",(e=>{e.preventDefault()}));const i=this._element.classList;for(const e in ia)i.remove(`mapboxgl-marker-anchor-${e}`);i.add(`mapboxgl-marker-anchor-${this._anchor}`);const n=t&&t.className?t.className.trim().split(/\s+/):[];i.add(...n),this._popup=null}addTo(e){return e===this._map||(this.remove(),this._map=e,e.getCanvasContainer().appendChild(this._element),e.on("move",this._updateMoving),e.on("moveend",this._update),e.on("remove",this._clearFadeTimer),e._addMarker(this),this.setDraggable(this._draggable),this._update(),e.on("click",this._onMapClick)),this}remove(){const e=this._map;return e&&(e.off("click",this._onMapClick),e.off("move",this._updateMoving),e.off("moveend",this._update),e.off("mousedown",this._addDragHandler),e.off("touchstart",this._addDragHandler),e.off("mouseup",this._onUp),e.off("touchend",this._onUp),e.off("mousemove",this._onMove),e.off("touchmove",this._onMove),e.off("remove",this._clearFadeTimer),e._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=e.bq.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(e){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")),e){if(!("offset"in e.options)){const t=38.1,r=13.5,i=Math.sqrt(Math.pow(r,2)/2);e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-t],"bottom-left":[i,-1*(t-r+i)],"bottom-right":[-i,-1*(t-r+i)],left:[r,-1*(t-r)],right:[-r,-1*(t-r)]}:this._offset}this._popup=e,e._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(e){const t=e.code,r=e.charCode||e.keyCode;"Space"!==t&&"Enter"!==t&&32!==r&&13!==r||this.togglePopup()}_onMapClick(e){const t=e.originalEvent.target,r=this._element;this._popup&&(t===r||r.contains(t))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const e=this._popup;return e?(e.isOpen()?(e.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(e.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const e=this._map,t=this._pos;if(!e||!t)return!1;const r=e.unproject(t),i=e.getFreeCameraOptions();if(!i.position)return!1;const n=i.position.toLngLat();return n.distanceTo(r)<.9*n.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 i=t.unproject(r);let n;t._showingGlobe()&&e.de(t.transform,this._lngLat)?n=0:(n=1-t._queryFogOpacity(i),t.transform._terrainEnabled()&&t.getTerrain()&&this._behindTerrain()&&(n*=this._occludedOpacity)),this._element.style.opacity=`${n}`,this._element.style.pointerEvents=n>0?"auto":"none",this._popup&&this._popup._setOpacity(n),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){const e=this._pos;if(!e||!this._map)return;const t=this._offset.mult(this._scale);this._element.style.transform=`\n translate(${e.x}px,${e.y}px)\n ${ia[this._anchor]}\n ${this._calculateXYTransform()} ${this._calculateZTransform()}\n translate(${t.x}px,${t.y}px)\n `}_calculateXYTransform(){const t=this._pos,r=this._map,i=this.getPitchAlignment();if(!r||!t||"map"!==i)return"";if(!r._showingGlobe()){const e=r.getPitch();return e?`rotateX(${e}deg)`:""}const n=e.bI(e.df(r.transform,this._lngLat)),o=t.sub(e.dg(r.transform)),s=Math.abs(o.x)+Math.abs(o.y);if(0===s)return"";const a=n/s;return`rotateX(${-o.y*a}deg) rotateY(${o.x*a}deg)`}_calculateZTransform(){const t=this._pos,r=this._map;if(!r||!t)return"";let i=0;const n=this.getRotationAlignment();if("map"===n)if(r._showingGlobe()){const t=r.project(new e.bq(this._lngLat.lng,this._lngLat.lat+.001)),n=r.project(new e.bq(this._lngLat.lng,this._lngLat.lat-.001)).sub(t);i=e.bI(Math.atan2(n.y,n.x))-90}else i=-r.getBearing();else if("horizon"===n){const n=e.S(4,6,r.getZoom()),o=e.dg(r.transform);o.y+=n*r.transform.height;const s=t.sub(o),a=e.bI(Math.atan2(s.y,s.x));i=(a>90?a-270:a+90)*(1-n)}return i+=this._rotation,i?`rotateZ(${i}deg)`:""}_update(e){cancelAnimationFrame(this._updateFrameId);const t=this._map;t&&(t.transform.renderWorldCopies&&(this._lngLat=ra(this._lngLat,this._pos,t.transform)),this._pos=t.project(this._lngLat),!0===e?this._updateFrameId=requestAnimationFrame((()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())})):this._pos=this._pos.round(),t._requestDomTask((()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(t._showingGlobe()||t.getTerrain()||t.getFog())&&!this._fadeTimer&&(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))})))}getOffset(){return this._offset}setOffset(t){return this._offset=e.P.convert(t),this._update(),this}addClassName(e){return this._element.classList.add(e),this}removeClassName(e){return this._element.classList.remove(e),this}toggleClassName(e){return this._element.classList.toggle(e)}_onMove(t){const r=this._map;if(!r)return;const i=this._pointerdownPos,n=this._positionDelta;if(i&&n){if(!this._isDragging){const e=this._clickTolerance||r._clickTolerance;if(t.point.dist(i)<e)return;this._isDragging=!0}this._pos=t.point.sub(n),this._lngLat=r.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new e.b("dragstart"))),this.fire(new e.b("drag"))}}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1;const t=this._map;t&&(t.off("mousemove",this._onMove),t.off("touchmove",this._onMove)),"active"===this._state&&this.fire(new e.b("dragend")),this._state="inactive"}_addDragHandler(e){const t=this._map,r=this._pos;t&&r&&this._element.contains(e.originalEvent.target)&&(e.preventDefault(),this._positionDelta=e.point.sub(r),this._pointerdownPos=e.point,this._state="pending",t.on("mousemove",this._onMove),t.on("touchmove",this._onMove),t.once("mouseup",this._onUp),t.once("touchend",this._onUp))}setDraggable(e){this._draggable=!!e;const t=this._map;return t&&(e?(t.on("mousedown",this._addDragHandler),t.on("touchstart",this._addDragHandler)):(t.off("mousedown",this._addDragHandler),t.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||"auto",this._update(),this}getRotationAlignment(){return"auto"===this._rotationAlignment||"horizon"===this._rotationAlignment&&this._map&&!this._map._showingGlobe()?"viewport":this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e||"auto",this._update(),this}getPitchAlignment(){return"auto"===this._pitchAlignment?this.getRotationAlignment():this._pitchAlignment}setOccludedOpacity(e){return this._occludedOpacity=e||.2,this._update(),this}getOccludedOpacity(){return this._occludedOpacity}}const oa={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},sa=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function aa(t=new e.P(0,0),r="bottom"){if("number"==typeof t){const i=Math.round(Math.sqrt(.5*Math.pow(t,2)));switch(r){case"top":return new e.P(0,t);case"top-left":return new e.P(i,i);case"top-right":return new e.P(-i,i);case"bottom":return new e.P(0,-t);case"bottom-left":return new e.P(i,-i);case"bottom-right":return new e.P(-i,-i);case"left":return new e.P(t,0);case"right":return new e.P(-t,0)}return new e.P(0,0)}return t instanceof e.P||Array.isArray(t)?e.P.convert(t):e.P.convert(t[r]||[0,0])}class la{constructor(e){this.jumpTo(e)}getValue(t){if(t<=this._startTime)return this._start;if(t>=this._endTime)return this._end;const r=e.ch((t-this._startTime)/(this._endTime-this._startTime));return this._start*(1-r)+this._end*r}isEasing(e){return e>=this._startTime&&e<=this._endTime}jumpTo(e){this._startTime=-1/0,this._endTime=-1/0,this._start=e,this._end=e}easeTo(e,t,r){this._start=this.getValue(t),this._end=e,this._startTime=t,this._endTime=t+r}}class ca{registerParameter(e,t,r,i,n){}registerButton(e,t,r){}registerBinding(e,t,r,i){}refreshUI(){}}const ua={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox logo","Map.Title":"Map","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use ⌘ + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"},ha={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},da={showCompass:!0,showZoom:!0,visualizePitch:!1};class pa{constructor(t,r,i=!1){this._clickTolerance=10,this.element=r,this.mouseRotate=new ws({clickTolerance:t.dragRotate._mouseRotate._clickTolerance}),this.map=t,i&&(this.mousePitch=new Cs({clickTolerance:t.dragRotate._mousePitch._clickTolerance})),e.a$(["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(e,t){this.mouseRotate.mousedown(e,t),this.mousePitch&&this.mousePitch.mousedown(e,t),u()}move(e,t){const r=this.map,i=this.mouseRotate.mousemoveWindow(e,t),n=i&&i.bearingDelta;if(n&&r.setBearing(r.getBearing()+n),this.mousePitch){const i=this.mousePitch.mousemoveWindow(e,t),n=i&&i.pitchDelta;n&&r.setPitch(r.getPitch()+n)}}off(){const e=this.element;e.removeEventListener("mousedown",this.mousedown),e.removeEventListener("touchstart",this.touchstart,{passive:!1}),e.removeEventListener("touchmove",this.touchmove),e.removeEventListener("touchend",this.touchend),e.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){h(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup)}mousedown(t){this.down(e.e({},t,{ctrlKey:!0,preventDefault:()=>t.preventDefault()}),f(this.element,t)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)}mousemove(e){this.move(e,f(this.element,e))}mouseup(e){this.mouseRotate.mouseupWindow(e),this.mousePitch&&this.mousePitch.mouseupWindow(e),this.offTemp()}touchstart(e){1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=m(this.element,e.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>e.preventDefault()},this._startPos))}touchmove(e){1!==e.targetTouches.length?this.reset():(this._lastPos=m(this.element,e.targetTouches)[0],this.move({preventDefault:()=>e.preventDefault()},this._lastPos))}touchend(e){0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),this.reset()}reset(){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp()}}const fa={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0,showUserHeading:!1},ma={maxWidth:100,unit:"metric"},Aa={kilometer:"km",meter:"m",mile:"mi",foot:"ft","nautical-mile":"nm"},ga={version:e.du,supported:r,setRTLTextPlugin:e.dw,getRTLTextPluginStatus:e.dx,Map:class extends Ks{constructor(t){const r=t;if(null!=(t=e.e({},ha,t)).minZoom&&null!=t.maxZoom&&t.minZoom>t.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=t.minPitch&&null!=t.maxPitch&&t.minPitch>t.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=t.minPitch&&t.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=t.maxPitch&&t.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(t.antialias&&e.dh(window)&&(t.antialias=!1,e.w("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new pi(t.minZoom,t.maxZoom,t.minPitch,t.maxPitch,t.renderWorldCopies),t),this._repaint=!!t.repaint,this._interactive=t.interactive,this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._failIfMajorPerformanceCaveat=t.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=t.preserveDrawingBuffer,this._antialias=t.antialias,this._trackResize=t.trackResize,this._bearingSnap=t.bearingSnap,this._refreshExpiredTiles=t.refreshExpiredTiles,this._fadeDuration=t.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=t.crossSourceCollisions,this._collectResourceTiming=t.collectResourceTiming,this._language=this._parseLanguage(t.language),this._worldview=t.worldview,this._renderTaskQueue=new ta,this._domRenderTaskQueue=new ta,this._controls=[],this._markers=[],this._popups=[],this._mapId=e.aF(),this._locale=e.e({},ua,t.locale),this._clickTolerance=t.clickTolerance,this._cooperativeGestures=t.cooperativeGestures,this._performanceMetricsCollection=t.performanceMetricsCollection,this._containerWidth=0,this._containerHeight=0,this._showParseStatus=!0,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new la(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._requestManager=new e.di(t.transformRequest,t.accessToken,t.testMode),this._silenceAuthErrors=!!t.testMode,this._contextCreateOptions=t.contextCreateOptions?{...t.contextCreateOptions}:{},"string"==typeof t.container){const e=document.getElementById(t.container);if(!e)throw new Error(`Container '${t.container.toString()}' not found.`);this._container=e}else{if(!(t.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=t.container}if(this._container.childNodes.length>0&&e.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."),t.maxBounds&&this.setMaxBounds(t.maxBounds),e.a$(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._tp=t.devtools?new ca(this):new ca,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 Ys(this,t),this._localFontFamily=t.localFontFamily,this._localIdeographFontFamily=t.localIdeographFontFamily,(t.style||!t.testMode)&&this.setStyle(t.style||e.dd.DEFAULT_STYLE,{config:t.config,localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),t.projection&&this.setProjection(t.projection),t.hash&&(this._hash=new es("string"==typeof t.hash&&t.hash||void 0).addTo(this)),!this._hash||!this._hash._onHashChange()){null==r.center&&null==r.zoom||(this.transform._unmodified=!1),this.jumpTo({center:t.center,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch});const i=t.bounds;i&&(this.resize(),this.fitBounds(i,e.e({},t.fitBoundsOptions,{duration:0})))}this.resize(),t.attributionControl&&this.addControl(new Js({customAttribution:t.customAttribution})),this._logoControl=new ea,this.addControl(this._logoControl,t.logoPosition),this.on("style.load",(()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet),this._postStyleLoadEvent()})),this.on("data",(t=>{this._update("style"===t.dataType),this.fire(new e.b(`${t.dataType}data`,t))})),this.on("dataloading",(t=>{this.fire(new e.b(`${t.dataType}dataloading`,t))}))}_getMapId(){return this._mapId}addControl(t,r){if(void 0===r&&(r=t.getDefaultPosition?t.getDefaultPosition():"top-right"),!t||!t.onAdd)return this.fire(new e.a(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const i=t.onAdd(this);this._controls.push(t);const n=this._controlPositions[r];return-1!==r.indexOf("bottom")?n.insertBefore(i,n.firstChild):n.appendChild(i),this}removeControl(t){if(!t||!t.onRemove)return this.fire(new e.a(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const r=this._controls.indexOf(t);return r>-1&&this._controls.splice(r,1),t.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(t){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 r=!this._moving;return r&&this.fire(new e.b("movestart",t)).fire(new e.b("move",t)),this.fire(new e.b("resize",t)),r&&this.fire(new e.b("moveend",t)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(t){return this.transform.setMaxBounds(e.ag.convert(t)),this._update()}setMinZoom(t){if((t=null==t?-2:t)>=-2&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()<t?this.setZoom(t):this.fire(new e.b("zoomstart")).fire(new e.b("zoom")).fire(new e.b("zoomend")),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(t){if((t=null==t?22:t)>=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t?this.setZoom(t):this.fire(new e.b("zoomstart")).fire(new e.b("zoom")).fire(new e.b("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(t){if((t=null==t?0:t)<0)throw new Error("minPitch must be greater than or equal to 0");if(t>=0&&t<=this.transform.maxPitch)return this.transform.minPitch=t,this._update(),this.getPitch()<t?this.setPitch(t):this.fire(new e.b("pitchstart")).fire(new e.b("pitch")).fire(new e.b("pitchend")),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(t){if((t=null==t?85:t)>85)throw new Error("maxPitch must be less than or equal to 85");if(t>=this.transform.minPitch)return this.transform.maxPitch=t,this._update(),this.getPitch()>t?this.setPitch(t):this.fire(new e.b("pitchstart")).fire(new e.b("pitch")).fire(new e.b("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(e){return this.transform.renderWorldCopies=e,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(e){return"auto"===e?navigator.language:Array.isArray(e)?0===e.length?void 0:e.map((e=>"auto"===e?navigator.language:e)):e}setLanguage(e){const t=this._parseLanguage(e);if(!this.style||t===this._language)return this;this._language=t,this.style.reloadSources();for(const e of this._controls)e._setLanguage&&e._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(e){return this.style&&e!==this._worldview?(this._worldview=e,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(e){return this._lazyInitEmptyStyle(),e?"string"==typeof e&&(e={name:e}):e=null,this._useExplicitProjection=!!e,this._prioritizeAndUpdateProjection(e,this.style.projection)}_updateProjectionTransition(){if("globe"!==this.getProjection().name)return;const t=this.transform,r=t.projection.name;let i;"globe"===r&&t.zoom>=e.bA?(t.setMercatorFromTransition(),i=!0):"mercator"===r&&t.zoom<e.bA&&(t.setProjection({name:"globe"}),i=!0),i&&(this.style.applyProjectionUpdate(),this.style._forceSymbolLayerUpdate())}_prioritizeAndUpdateProjection(e,t){return this._updateProjection(e||t||{name:"mercator"})}_updateProjection(t){let r;return r="globe"===t.name&&this.transform.zoom>=e.bA?this.transform.setMercatorFromTransition():this.transform.setProjection(t),this.style.applyProjectionUpdate(),r&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}project(t){return this.transform.locationPoint3D(e.bq.convert(t))}unproject(t){return this.transform.pointLocation3D(e.P.convert(t))}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()||!1}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()||!1}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()||!1}_isDragging(){return this.handlers&&this.handlers._isDragging()||!1}_createDelegatedListener(e,t,r){if("mouseenter"===e||"mouseover"===e){let i=!1;const n=n=>{const o=t.filter((e=>this.getLayer(e))),s=o.length?this.queryRenderedFeatures(n.point,{layers:o}):[];s.length?i||(i=!0,r.call(this,new us(e,this,n.originalEvent,{features:s}))):i=!1},o=()=>{i=!1};return{layers:new Set(t),listener:r,delegates:{mousemove:n,mouseout:o}}}if("mouseleave"===e||"mouseout"===e){let i=!1;const n=n=>{const o=t.filter((e=>this.getLayer(e)));(o.length?this.queryRenderedFeatures(n.point,{layers:o}):[]).length?i=!0:i&&(i=!1,r.call(this,new us(e,this,n.originalEvent)))},o=t=>{i&&(i=!1,r.call(this,new us(e,this,t.originalEvent)))};return{layers:new Set(t),listener:r,delegates:{mousemove:n,mouseout:o}}}{const i=e=>{const i=t.filter((e=>this.getLayer(e))),n=i.length?this.queryRenderedFeatures(e.point,{layers:i}):[];n.length&&(e.features=n,r.call(this,e),delete e.features)};return{layers:new Set(t),listener:r,delegates:{[e]:i}}}}on(e,t,r){if(void 0===r)return super.on(e,t);if(Array.isArray(t)||(t=[t]),t)for(const e of t)if(!this._isValidId(e))return this;const i=this._createDelegatedListener(e,t,r);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(i);for(const e in i.delegates)this.on(e,i.delegates[e]);return this}once(e,t,r){if(void 0===r)return super.once(e,t);if(Array.isArray(t)||(t=[t]),t)for(const e of t)if(!this._isValidId(e))return this;const i=this._createDelegatedListener(e,t,r);for(const e in i.delegates)this.once(e,i.delegates[e]);return this}off(e,t,r){if(void 0===r)return super.off(e,t);t=new Set(Array.isArray(t)?t:[t]);for(const e of t)if(!this._isValidId(e))return this;const i=(e,t)=>{if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0},n=this._delegatedListeners?this._delegatedListeners[e]:void 0;return n&&(e=>{for(let n=0;n<e.length;n++){const o=e[n];if(o.listener===r&&i(o.layers,t)){for(const e in o.delegates)this.off(e,o.delegates[e]);return e.splice(n,1),this}}})(n),this}queryRenderedFeatures(t,r){if(!this.style)return[];if(void 0!==r||void 0===t||t instanceof e.P||Array.isArray(t)||(r=t,t=void 0),t=t||[[0,0],[this.transform.width,this.transform.height]],(r=r||{}).layers&&Array.isArray(r.layers))for(const e of r.layers)if(!this._isValidId(e))return[];return this.style.queryRenderedFeatures(t,r,this.transform)}querySourceFeatures(e,t){return this._isValidId(e)?this.style.querySourceFeatures(e,t):[]}isPointOnSurface(t){const{name:r}=this.transform.projection;return"globe"!==r&&"mercator"!==r&&e.w(`${r} projection does not support isPointOnSurface, this API may behave unexpectedly.`),this.transform.isPointOnSurface(e.P.convert(t))}setStyle(t,r){return r=e.e({},{localIdeographFontFamily:this._localIdeographFontFamily,localFontFamily:this._localFontFamily},r),this.style&&t&&!1!==r.diff&&r.localFontFamily===this._localFontFamily&&r.localIdeographFontFamily===this._localIdeographFontFamily&&!r.config?(this.style._diffStyle(t,((i,n)=>{i?(e.w(`Unable to perform style diff: ${String(i.message||i.error||i)}. Rebuilding the style from scratch.`),this._updateStyle(t,r)):n&&this._update(!0)}),(()=>{this._postStyleLoadEvent()})),this):(this._localIdeographFontFamily=r.localIdeographFontFamily,this._localFontFamily=r.localFontFamily,this._updateStyle(t,r))}_getUIString(e){const t=this._locale[e];if(null==t)throw new Error(`Missing UI string '${e}'`);return t}_updateStyle(t,r){if(this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),t){const i=e.e({},r);r&&r.config&&(i.initialConfig=r.config,delete i.config),this.style=new Ii(this,i).setEventedParent(this,{style:this.style}).load(t)}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new Ii(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():(e.w("There is no style added to the map."),!1)}_isValidId(t){return null==t?(this.fire(new e.a(new Error("IDs can't be empty."))),!1):!e.c9(t)||(this.fire(new e.a(new Error(`IDs can't contain special symbols: "${t}".`))),!1)}addSource(e,t){return this._isValidId(e)?(this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)):this}isSourceLoaded(e){return!!this._isValidId(e)&&!!this.style&&this.style._isSourceCacheLoaded(e)}areTilesLoaded(){return this.style.areTilesLoaded()}addSourceType(e,t,r){this._lazyInitEmptyStyle(),this.style.addSourceType(e,t,r)}removeSource(e){return this._isValidId(e)?(this.style.removeSource(e),this._updateTerrain(),this._update(!0)):this}getSource(e){return this._isValidId(e)?this.style.getOwnSource(e):null}addImage(t,r,{pixelRatio:i=1,sdf:n=!1,stretchX:o,stretchY:s,content:a}={}){if(this._lazyInitEmptyStyle(),r instanceof HTMLImageElement||ImageBitmap&&r instanceof ImageBitmap){const{width:l,height:c,data:u}=e.f.getImageData(r);this.style.addImage(t,{data:new e.h({width:l,height:c},u),pixelRatio:i,stretchX:o,stretchY:s,content:a,sdf:n,version:0})}else if(void 0===r.width||void 0===r.height)this.fire(new e.a(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));else{const{width:l,height:c}=r,u=r;this.style.addImage(t,{data:new e.h({width:l,height:c},new Uint8Array(u.data)),pixelRatio:i,stretchX:o,stretchY:s,content:a,sdf:n,version:0,userImage:u}),u.onAdd&&u.onAdd(this,t)}}updateImage(t,r){this._lazyInitEmptyStyle();const i=this.style.getImage(t);if(!i)return void this.fire(new e.a(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const n=r instanceof HTMLImageElement||ImageBitmap&&r instanceof ImageBitmap?e.f.getImageData(r):r,{width:o,height:s}=n,a=n.data;if(void 0===o||void 0===s)return void this.fire(new e.a(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(o!==i.data.width||s!==i.data.height)return void this.fire(new e.a(new Error(`The width and height of the updated image (${o}, ${s})\n must be that same as the previous version of the image\n (${i.data.width}, ${i.data.height})`)));const l=!(r instanceof HTMLImageElement||ImageBitmap&&r instanceof ImageBitmap);i.data.replace(a,l),this.style.updateImage(t,i)}hasImage(t){return t?!!this.style&&!!this.style.getImage(t):(this.fire(new e.a(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e)}loadImage(t,r){e.d(this._requestManager.transformRequest(t,e.R.Image),((t,i)=>{r(t,i instanceof HTMLImageElement?e.f.getImageData(i):i)}))}listImages(){return this.style.listImages()}addModel(e,t){this._lazyInitEmptyStyle(),this.style.addModel(e,t)}hasModel(t){return t?this.style.hasModel(t):(this.fire(new e.a(new Error("Missing required model id"))),!1)}removeModel(e){this.style.removeModel(e)}listModels(){return this.style.listModels()}addLayer(e,t){return this._isValidId(e.id)?(this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)):this}getSlot(e){const t=this.getLayer(e);return t&&t.slot||null}setSlot(e,t){return this.style.setSlot(e,t),this.style.mergeLayers(),this._update(!0)}addImport(e,t){return this.style.addImport(e,t),this}updateImport(e,t){return"string"!=typeof t&&t.id!==e?(this.removeImport(e),this.addImport(t)):(this.style.updateImport(e,t),this._update(!0))}removeImport(e){return this.style.removeImport(e),this}moveImport(e,t){return this.style.moveImport(e,t),this._update(!0)}moveLayer(e,t){return this._isValidId(e)?(this.style.moveLayer(e,t),this._update(!0)):this}removeLayer(e){return this._isValidId(e)?(this.style.removeLayer(e),this._update(!0)):this}getLayer(e){return this._isValidId(e)?this.style.getOwnLayer(e):null}setLayerZoomRange(e,t,r){return this._isValidId(e)?(this.style.setLayerZoomRange(e,t,r),this._update(!0)):this}setFilter(e,t,r={}){return this._isValidId(e)?(this.style.setFilter(e,t,r),this._update(!0)):this}getFilter(e){return this._isValidId(e)?this.style.getFilter(e):null}setPaintProperty(e,t,r,i={}){return this._isValidId(e)?(this.style.setPaintProperty(e,t,r,i),this._update(!0)):this}getPaintProperty(e,t){return this._isValidId(e)?this.style.getPaintProperty(e,t):null}setLayoutProperty(e,t,r,i={}){return this._isValidId(e)?(this.style.setLayoutProperty(e,t,r,i),this._update(!0)):this}getLayoutProperty(e,t){return this._isValidId(e)?this.style.getLayoutProperty(e,t):null}getSchema(e){return this.style.getSchema(e)}setSchema(e,t){return this.style.setSchema(e,t),this._update(!0)}getConfig(e){return this.style.getConfig(e)}setConfig(e,t){return this.style.setConfig(e,t),this._update(!0)}getConfigProperty(e,t){return this.style.getConfigProperty(e,t)}setConfigProperty(e,t,r){return this.style.setConfigProperty(e,t,r),this._update(!0)}setLights(e){if(this._lazyInitEmptyStyle(),e&&1===e.length&&"flat"===e[0].type){const t=e[0];t.properties?this.style.setFlatLight(t.properties,t.id,{}):this.style.setFlatLight({},"flat")}else this.style.setLights(e),this.painter.terrain&&(this.painter.terrain.invalidateRenderCache=!0);return this._update(!0)}getLights(){const e=this.style.getLights()||[];return 0===e.length&&e.push({id:this.style.light.id,type:"flat",properties:this.style.getFlatLight()}),e}setLight(e,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:e}])}getLight(){return console.log("The `map.getLight` function is deprecated, prefer using `map.getLights` instead."),this.style.getFlatLight()}setTerrain(e){return this._lazyInitEmptyStyle(),!e&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(e),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(e){return this._lazyInitEmptyStyle(),this.style.setFog(e),this._update(!0)}getFog(){return this.style?this.style.getFog():null}setCamera(e){return this.style.setCamera(e),this._triggerCameraUpdate(e)}_triggerCameraUpdate(e){return this._update(this.transform.setOrthographicProjectionAtLowPitch("orthographic"===e["camera-projection"]))}getCamera(){return this.style.camera}_queryFogOpacity(t){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(e.bq.convert(t),this.transform):0}setFeatureState(e,t){return this._isValidId(e.source)?(this.style.setFeatureState(e,t),this._update()):this}removeFeatureState(e,t){return this._isValidId(e.source)?(this.style.removeFeatureState(e,t),this._update()):this}getFeatureState(e){return this._isValidId(e.source)?this.style.getFeatureState(e):null}_updateContainerDimensions(){if(!this._container)return;const e=this._container.getBoundingClientRect().width||400,t=this._container.getBoundingClientRect().height||300;let r,i,n,o=this._container;for(;o&&(!i||!n);){const e=window.getComputedStyle(o).transform;e&&"none"!==e&&(r=e.match(/matrix.*\((.+)\)/)[1].split(", "),r[0]&&"0"!==r[0]&&"1"!==r[0]&&(i=r[0]),r[3]&&"0"!==r[3]&&"1"!==r[3]&&(n=r[3])),o=o.parentElement}this._containerWidth=i?Math.abs(e/i):e,this._containerHeight=n?Math.abs(t/n):t}_detectMissingCSS(){"rgb(250, 128, 114)"!==window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&e.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 e=this._container;e.classList.add("mapboxgl-map"),(this._missingCSSCanary=o("div","mapboxgl-canary",e)).style.visibility="hidden",this._detectMissingCSS();const t=this._canvasContainer=o("div","mapboxgl-canvas-container",e);this._canvas=o("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=o("div","mapboxgl-control-container",e),i=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((e=>{i[e]=o("div",`mapboxgl-ctrl-${e}`,r)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(t,r){const i=e.f.devicePixelRatio||1;this._canvas.width=i*Math.ceil(t),this._canvas.height=i*Math.ceil(r),this._canvas.style.width=`${t}px`,this._canvas.style.height=`${r}px`}_addMarker(e){this._markers.push(e)}_removeMarker(e){const t=this._markers.indexOf(e);-1!==t&&this._markers.splice(t,1)}_addPopup(e){this._popups.push(e)}_removePopup(e){const t=this._popups.indexOf(e);-1!==t&&this._popups.splice(t,1)}_setupPainter(){const t=e.e({},r.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),i=this._canvas.getContext("webgl2",t);i?(e.dj(i,!0),this.painter=new Ko(i,this._contextCreateOptions,this.transform,this._tp),this.on("data",(e=>{"source"===e.dataType&&this.painter.setTileLoadedFlag(!0)})),e.dk.testSupport(i)):this.fire(new e.a(new Error("Failed to initialize WebGL")))}_contextLost(t){t.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new e.b("webglcontextlost",{originalEvent:t}))}_contextRestored(t){this._setupPainter(),this.resize(),this._update(),this.fire(new e.b("webglcontextrestored",{originalEvent:t}))}_onMapScroll(e){if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(e){return this.style?(this._styleDirty=this._styleDirty||e,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e)}_requestDomTask(e){!this.loaded()||this.loaded()&&!this.isMoving()?e():this._domRenderTaskQueue.add(e)}_render(t){let r;this.fire(new e.b("renderstart"));const i=this.painter.context.extTimerQuery,n=e.f.now(),o=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(r=o.createQuery(),o.beginQuery(i.TIME_ELAPSED_EXT,r)),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(t),this._domRenderTaskQueue.run(t),this._removed)return;this._updateProjectionTransition();const s=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const t=this.transform.zoom,r=this.transform.pitch,i=e.f.now(),n=new e.N(t,{now:i,fadeDuration:s,pitch:r,transition:this.style.transition});this.style.update(n)}this.style&&this.style.hasFogTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let a=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),a=this._updateAverageElevation(n),this.style.updateSources(this.transform),this._forceMarkerAndPopupUpdate()):a=this._updateAverageElevation(n),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,s,this._crossSourceCollisions),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:s,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 e.b("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new e.b("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),r){const t=e.f.now()-n;o.endQuery(i.TIME_ELAPSED_EXT),setTimeout((()=>{const i=o.getQueryParameter(r,o.QUERY_RESULT)/1e6;o.deleteQuery(r),this.fire(new e.b("gpu-timing-frame",{cpuTime:t,gpuTime:i}))}),50)}if(this.listens("gpu-timing-layer")){const t=this.painter.collectGpuTimers();setTimeout((()=>{const r=this.painter.queryGpuTimers(t);this.fire(new e.b("gpu-timing-layer",{layerTimes:r}))}),50)}if(this.listens("gpu-timing-deferred-render")){const t=this.painter.collectDeferredRenderGpuQueries();setTimeout((()=>{const r=this.painter.queryGpuTimeDeferredRender(t);this.fire(new e.b("gpu-timing-deferred-render",{gpuTime:r}))}),50)}const l=this._sourcesDirty||this._styleDirty||this._placementDirty||a;if(l||this._repaint)this.triggerRepaint();else{const t=!this.isMoving()&&this.loaded();if(t&&(a=this._updateAverageElevation(n,!0)),a)this.triggerRepaint();else if(this._triggerFrame(!1),t&&(this.fire(new e.b("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const t=this._calculateSpeedIndex();this.fire(new e.b("speedindexcompleted",{speedIndex:t})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||l||(this._fullyLoaded=!0,this._performanceMetricsCollection&&e.dl(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(e){for(const t of this._markers)e&&!this.getRenderWorldCopies()&&(t._lngLat=t._lngLat.wrap()),t._update();for(const t of this._popups)!e||this.getRenderWorldCopies()||t._trackPointer||(t._lngLat=t._lngLat.wrap()),t._update()}_updateAverageElevation(e,t=!1){const r=e=>(this.transform.averageElevation=e,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&r(0);const i=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(i||(t||e-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(e)){const t=this.transform.averageElevation;let n=this.transform.sampleAverageElevation();this.transform.elevation&&(this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(n)?n=0:this._averageElevationLastSampledAt=e;const o=Math.abs(t-n);if(o>1){if(this._isInitialLoad||i)return this._averageElevation.jumpTo(n),r(n);this._averageElevation.easeTo(n,e,300)}else if(o>1e-4)return this._averageElevation.jumpTo(n),r(n)}return!!this._averageElevation.isEasing(e)&&r(this._averageElevation.getValue(e))}_authenticate(){e.dm(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(t=>{if(t&&(t.message===e.dn||401===t.status)){const t=this.painter.context.gl;e.dj(t,!1),this._logoControl instanceof ea&&this._logoControl._updateLogo(),t&&t.clear(t.DEPTH_BUFFER_BIT|t.COLOR_BUFFER_BIT|t.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new e.a(new Error("A valid Mapbox access token is required to use Mapbox GL JS. To create an account or a new access token, visit https://account.mapbox.com/")))}})),e.dp(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(()=>{}))}_postStyleLoadEvent(){this.style.globalId&&e.dq(this._requestManager._customAccessToken,{map:this,skuToken:this._requestManager._skuToken,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()})}_updateTerrain(){const e=this._isDragging();this.painter.updateTerrain(this.style,e)}_calculateSpeedIndex(){const e=this.painter.canvasCopy(),t=this.painter.getCanvasCopiesAndTimestamps();t.timeStamps.push(performance.now());const r=this.painter.context.gl,i=r.createFramebuffer();function n(e){r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,e,0);const t=new Uint8Array(r.drawingBufferWidth*r.drawingBufferHeight*4);return r.readPixels(0,0,r.drawingBufferWidth,r.drawingBufferHeight,r.RGBA,r.UNSIGNED_BYTE,t),t}return r.bindFramebuffer(r.FRAMEBUFFER,i),this._canvasPixelComparison(n(e),t.canvasCopies.map(n),t.timeStamps)}_canvasPixelComparison(e,t,r){let i=r[1]-r[0];const n=e.length/4;for(let o=0;o<t.length;o++){const s=t[o];let a=0;for(let t=0;t<s.length;t+=4)s[t]===e[t]&&s[t+1]===e[t+1]&&s[t+2]===e[t+2]&&s[t+3]===e[t+3]&&(a+=1);i+=(r[o+2]-r[o+1])*(1-a/n)}return i}remove(){this._hash&&this._hash.remove();for(const e of this._controls)e.onRemove(this);this._controls=[],this._frame&&(this._frame.cancel(),this._frame=null),this._renderTaskQueue.clear(),this._domRenderTaskQueue.clear(),this.style&&this.style.destroy(),this.painter.destroy(),this.handlers&&this.handlers.destroy(),this.handlers=void 0,this.setStyle(null),window.removeEventListener("resize",this._onWindowResize,!1),window.removeEventListener("orientationchange",this._onWindowResize,!1),window.removeEventListener(this._fullscreenchangeEvent,this._onWindowResize,!1),window.removeEventListener("online",this._onWindowOnline,!1),window.removeEventListener("visibilitychange",this._onVisibilityChange,!1);const t=this.painter.context.gl.getExtension("WEBGL_lose_context");t&&t.loseContext(),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvasContainer.remove(),this._controlContainer.remove(),this._missingCSSCanary.remove(),this._canvas=void 0,this._canvasContainer=void 0,this._controlContainer=void 0,this._missingCSSCanary=void 0,this._container.classList.remove("mapboxgl-map"),this._container.removeEventListener("scroll",this._onMapScroll,!1),e.dr(this.painter.context.gl),e.ds.remove(),e.dt.remove(),this._removed=!0,this.fire(new e.b("remove"))}triggerRepaint(){this._triggerFrame(!0)}_triggerFrame(t){this._renderNextFrame=this._renderNextFrame||t,this.style&&!this._frame&&(this._frame=e.f.frame((e=>{const t=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,t&&this._render(e)})))}_preloadTiles(t){const r=this.style?this.style.getSourceCaches():[];return e.b4(r,((e,r)=>e._preloadTiles(t,r)),(()=>{this.triggerRepaint()})),this}_onWindowOnline(){this._update()}_onWindowResize(e){this._trackResize&&this.resize({originalEvent:e})._update()}_onVisibilityChange(){"hidden"===document.visibilityState&&this._visibilityHidden++}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._tp.refreshUI(),this._update())}get showParseStatus(){return!!this._showParseStatus}set showParseStatus(e){this._showParseStatus!==e&&(this._showParseStatus=e,this._tp.refreshUI(),this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(e){this._showTerrainWireframe!==e&&(this._showTerrainWireframe=e,this._tp.refreshUI(),this._update())}get showLayers2DWireframe(){return!!this._showLayers2DWireframe}set showLayers2DWireframe(e){this._showLayers2DWireframe!==e&&(this._showLayers2DWireframe=e,this._tp.refreshUI(),this._update())}get showLayers3DWireframe(){return!!this._showLayers3DWireframe}set showLayers3DWireframe(e){this._showLayers3DWireframe!==e&&(this._showLayers3DWireframe=e,this._tp.refreshUI(),this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(e){this._speedIndexTiming!==e&&(this._speedIndexTiming=e,this._update())}get showPadding(){return!!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._tp.refreshUI(),this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,this._tp.refreshUI(),e?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._tp.refreshUI(),this._update())}get repaint(){return!!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this._tp.refreshUI(),this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(e){this._vertices=e,this._update()}get showTileAABBs(){return!!this._showTileAABBs}set showTileAABBs(e){this._showTileAABBs!==e&&(this._showTileAABBs=e,this._tp.refreshUI(),e&&this._update())}_setCacheLimits(t,r){e.dv(t,r)}get version(){return e.du}},NavigationControl:class{constructor(t){this.options=e.e({},da,t),this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this.options.showZoom&&(e.a$(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",(e=>{this._map&&this._map.zoomIn({},{originalEvent:e})})),o("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",(e=>{this._map&&this._map.zoomOut({},{originalEvent:e})})),o("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(e.a$(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",(e=>{const t=this._map;t&&(this.options.visualizePitch?t.resetNorthPitch({},{originalEvent:e}):t.resetNorth({},{originalEvent:e}))})),this._compassIcon=o("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const e=this._map;if(!e)return;const t=e.getZoom(),r=t===e.getMaxZoom(),i=t===e.getMinZoom();this._zoomInButton.disabled=r,this._zoomOutButton.disabled=i,this._zoomInButton.setAttribute("aria-disabled",r.toString()),this._zoomOutButton.setAttribute("aria-disabled",i.toString())}_rotateCompassArrow(){const e=this._map;if(!e)return;const t=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(e.transform.pitch*(Math.PI/180)),.5)}) rotateX(${e.transform.pitch}deg) rotateZ(${e.transform.angle*(180/Math.PI)}deg)`:`rotate(${e.transform.angle*(180/Math.PI)}deg)`;e._requestDomTask((()=>{this._compassIcon&&(this._compassIcon.style.transform=t)}))}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),e.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&e.on("pitch",this._rotateCompassArrow),e.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new pa(e,this._compass,this.options.visualizePitch)),this._container}onRemove(){const e=this._map;e&&(this._container.remove(),this.options.showZoom&&e.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&e.off("pitch",this._rotateCompassArrow),e.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(e,t){const r=o("button",e,this._container);return r.type="button",r.addEventListener("click",t),r}_setButtonTitle(e,t){if(!this._map)return;const r=this._map._getUIString(`NavigationControl.${t}`);e.setAttribute("aria-label",r),e.firstElementChild&&e.firstElementChild.setAttribute("title",r)}},GeolocateControl:class extends e.E{constructor(t){super();const r=navigator.geolocation;this.options=e.e({geolocation:r},fa,t),e.a$(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=Jo(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(e){return this._map=e,this._container=o("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(e){const t=(t=!!this.options.geolocation)=>{this._supportsGeolocation=t,e(t)};void 0!==this._supportsGeolocation?e(this._supportsGeolocation):void 0!==navigator.permissions?navigator.permissions.query({name:"geolocation"}).then((e=>t("denied"!==e.state))).catch((()=>t())):t()}_isOutOfMapMaxBounds(e){const t=this._map.getMaxBounds(),r=e.coords;return!!t&&(r.longitude<t.getWest()||r.longitude>t.getEast()||r.latitude<t.getSouth()||r.latitude>t.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(t){if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new e.b("outofmaxbounds",t)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=t,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("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(t),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(t),this.options.showUserLocation&&this._userLocationDotMarker.removeClassName("mapboxgl-user-location-dot-stale"),this.fire(new e.b("geolocate",t)),this._finish()}}_updateCamera(t){const r=new e.bq(t.coords.longitude,t.coords.latitude),i=t.coords.accuracy,n=this._map.getBearing(),o=e.e({bearing:n},this.options.fitBoundsOptions);this._map.fitBounds(r.toBounds(i),o,{geolocateSource:!0})}_updateMarker(t){if(t){const r=new e.bq(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(r).addTo(this._map),this._userLocationDotMarker.setLngLat(r).addTo(this._map),this._accuracy=t.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const t=this._map.transform,r=e.bo(1,t._center.lat)*t.worldSize,i=Math.ceil(2*this._accuracy*r);this._circleElement.style.width=`${i}px`,this._circleElement.style.height=`${i}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(t){if(this._map){if(this.options.trackUserLocation)if(1===t.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 e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===t.code&&this._noTimeout)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._userLocationDotMarker.addClassName("mapboxgl-user-location-dot-stale"),this.fire(new e.b("error",t)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(t){if(void 0!==this._map){if(this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this._geolocateButton=o("button","mapboxgl-ctrl-geolocate",this._container),o("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",!1===t){e.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 e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=o("div","mapboxgl-user-location"),this._dotElement.appendChild(o("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(o("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new na({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=o("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new na({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 e.b("trackuserlocationend")))}))}}_onDeviceOrientation(e){this._userLocationDotMarker&&(e.webkitCompassHeading?this._heading=e.webkitCompassHeading:!0===e.absolute&&(this._heading=-1*e.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return e.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 e.b("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 e.b("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 e.b("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 e;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(e={maximumAge:6e5,timeout:0},this._noTimeout=!0):(e=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,e),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const e=()=>{"ondeviceorientationabsolute"in window?window.addEventListener("deviceorientationabsolute",this._onDeviceOrientation):window.addEventListener("deviceorientation",this._onDeviceOrientation)};"undefined"!=typeof DeviceMotionEvent&&"function"==typeof DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((t=>{"granted"===t&&e()})).catch(console.error):e()}_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:Js,ScaleControl:class{constructor(t){this.options=e.e({},ma,t),this._isNumberFormatSupported=function(){try{return new Intl.NumberFormat("en",{style:"unit",unitDisplay:"short",unit:"meter"}),!0}catch(e){return!1}}(),e.a$(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const e=this.options.maxWidth||100,t=this._map,r=t._containerHeight/2,i=t._containerWidth/2-e/2,n=t.unproject([i,r]),o=t.unproject([i+e,r]),s=n.distanceTo(o);if("imperial"===this.options.unit){const t=3.2808*s;t>5280?this._setScale(e,t/5280,"mile"):this._setScale(e,t,"foot")}else"nautical"===this.options.unit?this._setScale(e,s/1852,"nautical-mile"):s>=1e3?this._setScale(e,s/1e3,"kilometer"):this._setScale(e,s,"meter")}_setScale(e,t,r){this._map._requestDomTask((()=>{const i=function(e){const t=Math.pow(10,`${Math.floor(e)}`.length-1);let r=e/t;return r=r>=10?10:r>=5?5:r>=3?3:r>=2?2:r>=1?1:function(e){const t=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*t)/t}(r),t*r}(t),n=i/t;this._container.innerHTML=this._isNumberFormatSupported&&"nautical-mile"!==r?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:r}).format(i):`${i}&nbsp;${Aa[r]}`,this._container.style.width=e*n+"px"}))}onAdd(e){return this._map=e,this._language=e.getLanguage(),this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-scale",e.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(e){this._language=e,this._update()}setUnit(e){this.options.unit=e,this._update()}},FullscreenControl:class{constructor(t){this._fullscreen=!1,t&&t.container&&(t.container instanceof HTMLElement?this._container=t.container:e.w("Full screen control 'container' must be a DOM element.")),e.a$(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(t){return this._map=t,this._container||(this._container=this._map.getContainer()),this._controlContainer=o("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",e.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 e=this._fullscreenButton=o("button","mapboxgl-ctrl-fullscreen",this._controlContainer);o("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",e)}_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 e.E{constructor(t){super(),this.options=e.e(Object.create(oa),t),e.a$(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(t&&t.className?t.className.trim().split(/\s+/):[])}addTo(t){return this._map&&this.remove(),this._map=t,this.options.closeOnClick&&t.on("preclick",this._onClose),this.options.closeOnMove&&t.on("move",this._onClose),t.on("remove",this.remove),this._update(),t._addPopup(this),this._focusFirstElement(),this._trackPointer?(t.on("mousemove",this._onMouseEvent),t.on("mouseup",this._onMouseEvent),t._canvasContainer.classList.add("mapboxgl-track-pointer")):t.on("move",this._update),this.fire(new e.b("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const t=this._map;return t&&(t.off("move",this._update),t.off("move",this._onClose),t.off("preclick",this._onClose),t.off("click",this._onClose),t.off("remove",this.remove),t.off("mousemove",this._onMouseEvent),t.off("mouseup",this._onMouseEvent),t.off("drag",this._onMouseEvent),t._canvasContainer&&t._canvasContainer.classList.remove("mapboxgl-track-pointer"),t._removePopup(this),this._map=void 0),this.fire(new e.b("close")),this}getLngLat(){return this._lngLat}setLngLat(t){this._lngLat=e.bq.convert(t),this._pos=null,this._trackPointer=!1,this._update();const r=this._map;return r&&(r.on("move",this._update),r.off("mousemove",this._onMouseEvent),r._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const e=this._map;return e&&(e.off("move",this._update),e.on("mousemove",this._onMouseEvent),e.on("drag",this._onMouseEvent),e._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(document.createTextNode(e))}setHTML(e){const t=document.createDocumentFragment(),r=document.createElement("body");let i;for(r.innerHTML=e;i=r.firstChild,i;)t.appendChild(i);return this.setDOMContent(t)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){let t=this._content;if(t)for(;t.hasChildNodes();)t.firstChild&&t.removeChild(t.firstChild);else t=this._content=o("div","mapboxgl-popup-content",this._container||void 0);if(t.appendChild(e),this.options.closeButton){const e=this._closeButton=o("button","mapboxgl-popup-close-button",t);e.type="button",e.setAttribute("aria-label","Close popup"),e.setAttribute("aria-hidden","true"),e.innerHTML="&#215;",e.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(e){return this._classList.add(e),this._updateClassList(),this}removeClassName(e){return this._classList.delete(e),this._updateClassList(),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){let t;return this._classList.delete(e)?t=!1:(this._classList.add(e),t=!0),this._updateClassList(),t}_onMouseEvent(e){this._update(e.point)}_getAnchor(e){if(this.options.anchor)return this.options.anchor;const t=this._map,r=this._container,i=this._pos;if(!t||!r||!i)return"bottom";const n=r.offsetWidth,o=r.offsetHeight,s=i.x<n/2,a=i.x>t.transform.width-n/2;if(i.y+e<o)return s?"top-left":a?"top-right":"top";if(i.y>t.transform.height-o){if(s)return"bottom-left";if(a)return"bottom-right"}return s?"left":a?"right":"bottom"}_updateClassList(){const e=this._container;if(!e)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"),e.className=t.join(" ")}_update(t){const r=this._map,i=this._content;if(!r||!this._lngLat&&!this._trackPointer||!i)return;let n=this._container;if(n||(n=this._container=o("div","mapboxgl-popup",r.getContainer()),this._tip=o("div","mapboxgl-popup-tip",n),n.appendChild(i)),this.options.maxWidth&&n.style.maxWidth!==this.options.maxWidth&&(n.style.maxWidth=this.options.maxWidth),r.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=ra(this._lngLat,this._pos,r.transform)),!this._trackPointer||t){const e=this._pos=this._trackPointer&&t?t:r.project(this._lngLat),i=aa(this.options.offset),n=this._anchor=this._getAnchor(i.y),o=aa(this.options.offset,n),s=e.add(o).round();r._requestDomTask((()=>{this._container&&n&&(this._container.style.transform=`${ia[n]} translate(${s.x}px,${s.y}px)`)}))}if(!this._marker&&r._showingGlobe()){const t=e.de(r.transform,this._lngLat)?0:1;this._setOpacity(t)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(sa);e&&e.focus()}_onClose(){this.remove()}_setOpacity(e){this._container&&(this._container.style.opacity=`${e}`),this._content&&(this._content.style.pointerEvents=e?"auto":"none")}},Marker:na,Style:Ii,LngLat:e.bq,LngLatBounds:e.ag,Point:e.P,MercatorCoordinate:e.O,FreeCameraOptions:ci,Evented:e.E,config:e.dd,prewarm:e.dy,clearPrewarmedResources:e.dz,get accessToken(){return e.dd.ACCESS_TOKEN},set accessToken(t){e.dd.ACCESS_TOKEN=t},get baseApiUrl(){return e.dd.API_URL},set baseApiUrl(t){e.dd.API_URL=t},get workerCount(){return e.dA.workerCount},set workerCount(t){e.dA.workerCount=t},get maxParallelImageRequests(){return e.dd.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(t){e.dd.MAX_PARALLEL_IMAGE_REQUESTS=t},clearStorage(t){e.dB(t)},get workerUrl(){return e.dC.workerUrl},set workerUrl(t){e.dC.workerUrl=t},get workerClass(){return e.dC.workerClass},set workerClass(t){e.dC.workerClass=t},get workerParams(){return e.dC.workerParams},set workerParams(t){e.dC.workerParams=t},get dracoUrl(){return e.dD()},set dracoUrl(t){e.dE(t)},get meshoptUrl(){return e.dF()},set meshoptUrl(t){e.dG(t)},setNow:e.f.setNow,restoreNow:e.f.restoreNow};return ga})),r}(),Fs=Ue({__proto__:null,default:Ge(Rs)},[Rs]);const js=te.createContext(null);function Vs(e,t){if(e===t)return!0;if(!e||!t)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!Vs(e[r],t[r]))return!1;return!0}if(Array.isArray(t))return!1;if("object"==typeof e&&"object"==typeof t){const r=Object.keys(e),i=Object.keys(t);if(r.length!==i.length)return!1;for(const i of r){if(!t.hasOwnProperty(i))return!1;if(!Vs(e[i],t[i]))return!1}return!0}return!1}function Ns(e,t){if(!e.getProjection)return;const r=e.getProjection();Vs(r,t.getProjection())||t.setProjection(r)}function Us(e){return{longitude:e.center.lng,latitude:e.center.lat,zoom:e.zoom,pitch:e.pitch,bearing:e.bearing,padding:e.padding}}function Hs(e,t){const r=t.viewState||t;let i=!1;if("longitude"in r&&"latitude"in r){const t=e.center;e.center=new t.constructor(r.longitude,r.latitude),i=i||t!==e.center}if("zoom"in r){const t=e.zoom;e.zoom=r.zoom,i=i||t!==e.zoom}if("bearing"in r){const t=e.bearing;e.bearing=r.bearing,i=i||t!==e.bearing}if("pitch"in r){const t=e.pitch;e.pitch=r.pitch,i=i||t!==e.pitch}return r.padding&&!e.isPaddingEqual(r.padding)&&(i=!0,e.padding=r.padding),i}const Gs=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function Zs(e){if(!e)return null;if("string"==typeof e)return e;if("toJS"in e&&(e=e.toJS()),!e.layers)return e;const t={};for(const r of e.layers)t[r.id]=r;const r=e.layers.map((e=>{let r=null;"interactive"in e&&(r=Object.assign({},e),delete r.interactive);const i=t[e.ref];if(i){r=r||Object.assign({},e),delete r.ref;for(const e of Gs)e in i&&(r[e]=i[e])}return r||e}));return{...e,layers:r}}const Ws={version:8,sources:{},layers:[]},Qs={mousedown:"onMouseDown",mouseup:"onMouseUp",mouseover:"onMouseOver",mousemove:"onMouseMove",click:"onClick",dblclick:"onDblClick",mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",mouseout:"onMouseOut",contextmenu:"onContextMenu",touchstart:"onTouchStart",touchend:"onTouchEnd",touchmove:"onTouchMove",touchcancel:"onTouchCancel"},qs={movestart:"onMoveStart",move:"onMove",moveend:"onMoveEnd",dragstart:"onDragStart",drag:"onDrag",dragend:"onDragEnd",zoomstart:"onZoomStart",zoom:"onZoom",zoomend:"onZoomEnd",rotatestart:"onRotateStart",rotate:"onRotate",rotateend:"onRotateEnd",pitchstart:"onPitchStart",pitch:"onPitch",pitchend:"onPitchEnd"},Xs={wheel:"onWheel",boxzoomstart:"onBoxZoomStart",boxzoomend:"onBoxZoomEnd",boxzoomcancel:"onBoxZoomCancel",resize:"onResize",load:"onLoad",render:"onRender",idle:"onIdle",remove:"onRemove",data:"onData",styledata:"onStyleData",sourcedata:"onSourceData",error:"onError"},Ys=["minZoom","maxZoom","minPitch","maxPitch","maxBounds","projection","renderWorldCopies"],$s=["scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate","touchPitch"];class Ks{constructor(e,t,r){this._map=null,this._internalUpdate=!1,this._inRender=!1,this._hoveredFeatures=null,this._deferredEvents={move:!1,zoom:!1,pitch:!1,rotate:!1},this._onEvent=e=>{const t=this.props[Xs[e.type]];t?t(e):"error"===e.type&&console.error(e.error)},this._onPointerEvent=e=>{"mousemove"!==e.type&&"mouseout"!==e.type||this._updateHover(e);const t=this.props[Qs[e.type]];t&&(this.props.interactiveLayerIds&&"mouseover"!==e.type&&"mouseout"!==e.type&&(e.features=this._hoveredFeatures||this._queryRenderedFeatures(e.point)),t(e),delete e.features)},this._onCameraEvent=e=>{if(!this._internalUpdate){const t=this.props[qs[e.type]];t&&t(e)}e.type in this._deferredEvents&&(this._deferredEvents[e.type]=!1)},this._MapClass=e,this.props=t,this._initialize(r)}get map(){return this._map}get transform(){return this._renderTransform}setProps(e){const t=this.props;this.props=e;const r=this._updateSettings(e,t);r&&this._createShadowTransform(this._map);const i=this._updateSize(e),n=this._updateViewState(e,!0);this._updateStyle(e,t),this._updateStyleComponents(e,t),this._updateHandlers(e,t),(r||i||n&&!this._map.isMoving())&&this.redraw()}static reuse(e,t){const r=Ks.savedMaps.pop();if(!r)return null;const i=r.map,n=i.getContainer();for(t.className=n.className;n.childNodes.length>0;)t.appendChild(n.childNodes[0]);i._container=t;const o=i._resizeObserver;o&&(o.disconnect(),o.observe(t)),r.setProps({...e,styleDiffing:!1}),i.resize();const{initialViewState:s}=e;return s&&(s.bounds?i.fitBounds(s.bounds,{...s.fitBoundsOptions,duration:0}):r._updateViewState(s,!1)),i.isStyleLoaded()?i.fire("load"):i.once("styledata",(()=>i.fire("load"))),i._update(),r}_initialize(e){const{props:t}=this,{mapStyle:r=Ws}=t,i={...t,...t.initialViewState,accessToken:t.mapboxAccessToken||Js()||null,container:e,style:Zs(r)},n=i.initialViewState||i.viewState||i;if(Object.assign(i,{center:[n.longitude||0,n.latitude||0],zoom:n.zoom||0,pitch:n.pitch||0,bearing:n.bearing||0}),t.gl){const e=HTMLCanvasElement.prototype.getContext;HTMLCanvasElement.prototype.getContext=()=>(HTMLCanvasElement.prototype.getContext=e,t.gl)}const o=new this._MapClass(i);n.padding&&o.setPadding(n.padding),t.cursor&&(o.getCanvas().style.cursor=t.cursor),this._createShadowTransform(o);const s=o._render;o._render=e=>{this._inRender=!0,s.call(o,e),this._inRender=!1};const a=o._renderTaskQueue.run;o._renderTaskQueue.run=e=>{a.call(o._renderTaskQueue,e),this._onBeforeRepaint()},o.on("render",(()=>this._onAfterRepaint()));const l=o.fire;o.fire=this._fireEvent.bind(this,l),o.on("resize",(()=>{this._renderTransform.resize(o.transform.width,o.transform.height)})),o.on("styledata",(()=>{this._updateStyleComponents(this.props,{}),Ns(o.transform,this._renderTransform)})),o.on("sourcedata",(()=>this._updateStyleComponents(this.props,{})));for(const e in Qs)o.on(e,this._onPointerEvent);for(const e in qs)o.on(e,this._onCameraEvent);for(const e in Xs)o.on(e,this._onEvent);this._map=o}recycle(){const e=this.map.getContainer().querySelector("[mapboxgl-children]");null==e||e.remove(),Ks.savedMaps.push(this)}destroy(){this._map.remove()}redraw(){const e=this._map;!this._inRender&&e.style&&(e._frame&&(e._frame.cancel(),e._frame=null),e._render())}_createShadowTransform(e){const t=function(e){const t=e.clone();return t.pixelsToGLUnits=e.pixelsToGLUnits,t}(e.transform);e.painter.transform=t,this._renderTransform=t}_updateSize(e){const{viewState:t}=e;if(t){const e=this._map;if(t.width!==e.transform.width||t.height!==e.transform.height)return e.resize(),!0}return!1}_updateViewState(e,t){if(this._internalUpdate)return!1;const r=this._map,i=this._renderTransform,{zoom:n,pitch:o,bearing:s}=i,a=r.isMoving();a&&(i.cameraElevationReference="sea");const l=Hs(i,{...Us(r.transform),...e});if(a&&(i.cameraElevationReference="ground"),l&&t){const e=this._deferredEvents;e.move=!0,e.zoom||(e.zoom=n!==i.zoom),e.rotate||(e.rotate=s!==i.bearing),e.pitch||(e.pitch=o!==i.pitch)}return a||Hs(r.transform,e),l}_updateSettings(e,t){const r=this._map;let i=!1;for(const n of Ys)if(n in e&&!Vs(e[n],t[n])){i=!0;const t=r[`set${n[0].toUpperCase()}${n.slice(1)}`];null==t||t.call(r,e[n])}return i}_updateStyle(e,t){if(e.cursor!==t.cursor&&(this._map.getCanvas().style.cursor=e.cursor||""),e.mapStyle!==t.mapStyle){const{mapStyle:t=Ws,styleDiffing:r=!0}=e,i={diff:r};return"localIdeographFontFamily"in e&&(i.localIdeographFontFamily=e.localIdeographFontFamily),this._map.setStyle(Zs(t),i),!0}return!1}_updateStyleComponents(e,t){const r=this._map;let i=!1;return r.isStyleLoaded()&&("light"in e&&r.setLight&&!Vs(e.light,t.light)&&(i=!0,r.setLight(e.light)),"fog"in e&&r.setFog&&!Vs(e.fog,t.fog)&&(i=!0,r.setFog(e.fog)),"terrain"in e&&r.setTerrain&&!Vs(e.terrain,t.terrain)&&(e.terrain&&!r.getSource(e.terrain.source)||(i=!0,r.setTerrain(e.terrain)))),i}_updateHandlers(e,t){var r,i;const n=this._map;let o=!1;for(const s of $s){const a=null===(r=e[s])||void 0===r||r;Vs(a,null===(i=t[s])||void 0===i||i)||(o=!0,a?n[s].enable(a):n[s].disable())}return o}_queryRenderedFeatures(e){const t=this._map,r=t.transform,{interactiveLayerIds:i=[]}=this.props;try{return t.transform=this._renderTransform,t.queryRenderedFeatures(e,{layers:i.filter(t.getLayer.bind(t))})}catch(e){return[]}finally{t.transform=r}}_updateHover(e){var t;const{props:r}=this;if(r.interactiveLayerIds&&(r.onMouseMove||r.onMouseEnter||r.onMouseLeave)){const r=e.type,i=(null===(t=this._hoveredFeatures)||void 0===t?void 0:t.length)>0,n=this._queryRenderedFeatures(e.point),o=n.length>0;!o&&i&&(e.type="mouseleave",this._onPointerEvent(e)),this._hoveredFeatures=n,o&&!i&&(e.type="mouseenter",this._onPointerEvent(e)),e.type=r}else this._hoveredFeatures=null}_fireEvent(e,t,r){const i=this._map,n=i.transform,o="string"==typeof t?t:t.type;return"move"===o&&this._updateViewState(this.props,!1),o in qs&&("object"==typeof t&&(t.viewState=Us(n)),this._map.isMoving())?(i.transform=this._renderTransform,e.call(i,t,r),i.transform=n,i):(e.call(i,t,r),i)}_onBeforeRepaint(){const e=this._map;this._internalUpdate=!0;for(const t in this._deferredEvents)this._deferredEvents[t]&&e.fire(t);this._internalUpdate=!1;const t=this._map.transform;e.transform=this._renderTransform,this._onAfterRepaint=()=>{Ns(this._renderTransform,t),e.transform=t}}}function Js(){let e=null;if("undefined"!=typeof location){const t=/access_token=([^&\/]*)/.exec(location.search);e=t&&t[1]}try{e=e||process.env.MapboxAccessToken}catch(e){}try{e=e||process.env.REACT_APP_MAPBOX_ACCESS_TOKEN}catch(e){}return e}Ks.savedMaps=[];const ea=["setMaxBounds","setMinZoom","setMaxZoom","setMinPitch","setMaxPitch","setRenderWorldCopies","setProjection","setStyle","addSource","removeSource","addLayer","removeLayer","setLayerZoomRange","setFilter","setPaintProperty","setLayoutProperty","setLight","setTerrain","setFog","remove"];function ta(e){if(!e)return null;const t=e.map,r={getMap:()=>t,getCenter:()=>e.transform.center,getZoom:()=>e.transform.zoom,getBearing:()=>e.transform.bearing,getPitch:()=>e.transform.pitch,getPadding:()=>e.transform.padding,getBounds:()=>e.transform.getBounds(),project:r=>{const i=t.transform;t.transform=e.transform;const n=t.project(r);return t.transform=i,n},unproject:r=>{const i=t.transform;t.transform=e.transform;const n=t.unproject(r);return t.transform=i,n},queryTerrainElevation:(r,i)=>{const n=t.transform;t.transform=e.transform;const o=t.queryTerrainElevation(r,i);return t.transform=n,o},queryRenderedFeatures:(r,i)=>{const n=t.transform;t.transform=e.transform;const o=t.queryRenderedFeatures(r,i);return t.transform=n,o}};for(const e of function(e){const t=new Set;let r=e;for(;r;){for(const i of Object.getOwnPropertyNames(r))"_"!==i[0]&&"function"==typeof e[i]&&"fire"!==i&&"setEventedParent"!==i&&t.add(i);r=Object.getPrototypeOf(r)}return Array.from(t)}(t))e in r||ea.includes(e)||(r[e]=t[e].bind(t));return r}const ra="undefined"!=typeof document?se:oe,ia=["baseApiUrl","maxParallelImageRequests","workerClass","workerCount","workerUrl"];const na=te.createContext(null);function oa(e,t,r){const i=ie(js),[n,o]=ne(null),s=ae(),{current:a}=ae({mapLib:null,map:null});oe((()=>{const t=e.mapLib;let n,l=!0;return Promise.resolve(t||r).then((t=>{if(!l)return;if(!t)throw new Error("Invalid mapLib");const r="Map"in t?t:t.default;if(!r.Map)throw new Error("Invalid mapLib");if(function(e,t){for(const r of ia)r in t&&(e[r]=t[r]);const{RTLTextPlugin:r="https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-rtl-text/v0.2.3/mapbox-gl-rtl-text.js"}=t;r&&e.getRTLTextPluginStatus&&"unavailable"===e.getRTLTextPluginStatus()&&e.setRTLTextPlugin(r,(e=>{e&&console.error(e)}),!0)}(r,e),r.supported&&!r.supported(e))throw new Error("Map is not supported by this browser");e.reuseMaps&&(n=Ks.reuse(e,s.current)),n||(n=new Ks(r.Map,e,s.current)),a.map=ta(n),a.mapLib=r,o(n),null==i||i.onMapMount(a.map,e.id)})).catch((t=>{const{onError:r}=e;r?r({type:"error",target:null,originalEvent:null,error:t}):console.error(t)})),()=>{l=!1,n&&(null==i||i.onMapUnmount(e.id),e.reuseMaps?n.recycle():n.destroy())}}),[]),ra((()=>{n&&n.setProps(e)})),Ae(t,(()=>a.map),[n]);const l=ue((()=>({position:"relative",width:"100%",height:"100%",...e.style})),[e.style]);return te.createElement("div",{id:e.id,ref:s,style:l},n&&te.createElement(na.Provider,{value:a},te.createElement("div",{"mapboxgl-children":"",style:{height:"100%"}},e.children)))}const sa=/box|flex|grid|column|lineHeight|fontWeight|opacity|order|tabSize|zIndex/;function aa(e,t){if(!e||!t)return;const r=e.style;for(const e in t){const i=t[e];Number.isFinite(i)&&!sa.test(e)?r[e]=`${i}px`:r[e]=i}}var la=he(me((function(e,t){const{map:r,mapLib:i}=ie(na),n=ae({props:e});n.current.props=e;const o=ue((()=>{let t=!1;te.Children.forEach(e.children,(e=>{e&&(t=!0)}));const r={...e,element:t?document.createElement("div"):null},s=new i.Marker(r);return s.setLngLat([e.longitude,e.latitude]),s.getElement().addEventListener("click",(e=>{var t,r;null===(r=(t=n.current.props).onClick)||void 0===r||r.call(t,{type:"click",target:s,originalEvent:e})})),s.on("dragstart",(e=>{var t,r;const i=e;i.lngLat=o.getLngLat(),null===(r=(t=n.current.props).onDragStart)||void 0===r||r.call(t,i)})),s.on("drag",(e=>{var t,r;const i=e;i.lngLat=o.getLngLat(),null===(r=(t=n.current.props).onDrag)||void 0===r||r.call(t,i)})),s.on("dragend",(e=>{var t,r;const i=e;i.lngLat=o.getLngLat(),null===(r=(t=n.current.props).onDragEnd)||void 0===r||r.call(t,i)})),s}),[]);oe((()=>(o.addTo(r.getMap()),()=>{o.remove()})),[]);const{longitude:s,latitude:a,offset:l,style:c,draggable:u=!1,popup:h=null,rotation:d=0,rotationAlignment:p="auto",pitchAlignment:f="auto"}=e;return oe((()=>{aa(o.getElement(),c)}),[c]),Ae(t,(()=>o),[]),o.getLngLat().lng===s&&o.getLngLat().lat===a||o.setLngLat([s,a]),l&&!function(e,t){const r=Array.isArray(e)?e[0]:e?e.x:0,i=Array.isArray(e)?e[1]:e?e.y:0,n=Array.isArray(t)?t[0]:t?t.x:0,o=Array.isArray(t)?t[1]:t?t.y:0;return r===n&&i===o}(o.getOffset(),l)&&o.setOffset(l),o.isDraggable()!==u&&o.setDraggable(u),o.getRotation()!==d&&o.setRotation(d),o.getRotationAlignment()!==p&&o.setRotationAlignment(p),o.getPitchAlignment()!==f&&o.setPitchAlignment(f),o.getPopup()!==h&&o.setPopup(h),Ie(e.children,o.getElement())})));function ca(e){return new Set(e?e.trim().split(/\s+/):[])}var ua=he(me((function(e,t){const{map:r,mapLib:i}=ie(na),n=ue((()=>document.createElement("div")),[]),o=ae({props:e});o.current.props=e;const s=ue((()=>{const t={...e},r=new i.Popup(t);return r.setLngLat([e.longitude,e.latitude]),r.once("open",(e=>{var t,r;null===(r=(t=o.current.props).onOpen)||void 0===r||r.call(t,e)})),r}),[]);if(oe((()=>{const e=e=>{var t,r;null===(r=(t=o.current.props).onClose)||void 0===r||r.call(t,e)};return s.on("close",e),s.setDOMContent(n).addTo(r.getMap()),()=>{s.off("close",e),s.isOpen()&&s.remove()}}),[]),oe((()=>{aa(s.getElement(),e.style)}),[e.style]),Ae(t,(()=>s),[]),s.isOpen()&&(s.getLngLat().lng===e.longitude&&s.getLngLat().lat===e.latitude||s.setLngLat([e.longitude,e.latitude]),e.offset&&!Vs(s.options.offset,e.offset)&&s.setOffset(e.offset),s.options.anchor===e.anchor&&s.options.maxWidth===e.maxWidth||(s.options.anchor=e.anchor,s.setMaxWidth(e.maxWidth)),s.options.className!==e.className)){const t=ca(s.options.className),r=ca(e.className);for(const e of t)r.has(e)||s.removeClassName(e);for(const e of r)t.has(e)||s.addClassName(e);s.options.className=e.className}return Ie(e.children,n)})));function ha(e,t,r,i){const n=ie(na),o=ue((()=>e(n)),[]);return oe((()=>{const e=t,i="function"==typeof t&&"function"==typeof r?t:null,s="function"==typeof t?t:null,{map:a}=n;return a.hasControl(o)||(a.addControl(o,null==e?void 0:e.position),i&&i(n)),()=>{s&&s(n),a.hasControl(o)&&a.removeControl(o)}}),[]),o}he((function(e){const t=ha((({mapLib:t})=>new t.AttributionControl(e)),{position:e.position});return oe((()=>{aa(t._container,e.style)}),[e.style]),null})),he((function(e){const t=ha((({mapLib:t})=>new t.FullscreenControl({container:e.containerId&&document.getElementById(e.containerId)})),{position:e.position});return oe((()=>{aa(t._controlContainer,e.style)}),[e.style]),null})),he(me((function(e,t){const r=ae({props:e}),i=ha((({mapLib:t})=>{const i=new t.GeolocateControl(e),n=i._setupUI;return i._setupUI=e=>{i._container.hasChildNodes()||n(e)},i.on("geolocate",(e=>{var t,i;null===(i=(t=r.current.props).onGeolocate)||void 0===i||i.call(t,e)})),i.on("error",(e=>{var t,i;null===(i=(t=r.current.props).onError)||void 0===i||i.call(t,e)})),i.on("outofmaxbounds",(e=>{var t,i;null===(i=(t=r.current.props).onOutOfMaxBounds)||void 0===i||i.call(t,e)})),i.on("trackuserlocationstart",(e=>{var t,i;null===(i=(t=r.current.props).onTrackUserLocationStart)||void 0===i||i.call(t,e)})),i.on("trackuserlocationend",(e=>{var t,i;null===(i=(t=r.current.props).onTrackUserLocationEnd)||void 0===i||i.call(t,e)})),i}),{position:e.position});return r.current.props=e,Ae(t,(()=>i),[]),oe((()=>{aa(i._container,e.style)}),[e.style]),null})));var da=he((function(e){const t=ha((({mapLib:t})=>new t.NavigationControl(e)),{position:e.position});return oe((()=>{aa(t._container,e.style)}),[e.style]),null}));function pa(e,t){if(!e)throw new Error(t)}he((function(e){const t=ha((({mapLib:t})=>new t.ScaleControl(e)),{position:e.position}),r=ae(e),i=r.current;r.current=e;const{style:n}=e;return void 0!==e.maxWidth&&e.maxWidth!==i.maxWidth&&(t.options.maxWidth=e.maxWidth),void 0!==e.unit&&e.unit!==i.unit&&t.setUnit(e.unit),oe((()=>{aa(t._container,n)}),[n]),null}));let fa=0;let ma=0;const Aa=Promise.resolve().then((function(){return Fs})),ga=te.forwardRef((function(e,t){return oa(e,t,Aa)})),_a=la,ya=ua,xa=da,va=function(e){const t=ie(na).map.getMap(),r=ae(e),[,i]=ne(0),n=ue((()=>e.id||"jsx-layer-"+fa++),[]);if(oe((()=>{if(t){const e=()=>i((e=>e+1));return t.on("styledata",e),e(),()=>{t.off("styledata",e),t.style&&t.style._loaded&&t.getLayer(n)&&t.removeLayer(n)}}}),[t]),t&&t.style&&t.getLayer(n))try{!function(e,t,r,i){if(pa(r.id===i.id,"layer id changed"),pa(r.type===i.type,"layer type changed"),"custom"===r.type||"custom"===i.type)return;const{layout:n={},paint:o={},filter:s,minzoom:a,maxzoom:l,beforeId:c}=r;if(c!==i.beforeId&&e.moveLayer(t,c),n!==i.layout){const r=i.layout||{};for(const i in n)Vs(n[i],r[i])||e.setLayoutProperty(t,i,n[i]);for(const i in r)n.hasOwnProperty(i)||e.setLayoutProperty(t,i,void 0)}if(o!==i.paint){const r=i.paint||{};for(const i in o)Vs(o[i],r[i])||e.setPaintProperty(t,i,o[i]);for(const i in r)o.hasOwnProperty(i)||e.setPaintProperty(t,i,void 0)}Vs(s,i.filter)||e.setFilter(t,s),a===i.minzoom&&l===i.maxzoom||e.setLayerZoomRange(t,a,l)}(t,n,e,r.current)}catch(e){console.warn(e)}else!function(e,t,r){if(e.style&&e.style._loaded&&(!("source"in r)||e.getSource(r.source))){const i={...r,id:t};delete i.beforeId,e.addLayer(i,r.beforeId)}}(t,n,e);return r.current=e,null},ba=function(e){const t=ie(na).map.getMap(),r=ae(e),[,i]=ne(0),n=ue((()=>e.id||"jsx-source-"+ma++),[]);oe((()=>{if(t){const e=()=>setTimeout((()=>i((e=>e+1))),0);return t.on("styledata",e),e(),()=>{var r;if(t.off("styledata",e),t.style&&t.style._loaded&&t.getSource(n)){const e=null===(r=t.getStyle())||void 0===r?void 0:r.layers;if(e)for(const r of e)r.source===n&&t.removeLayer(r.id);t.removeSource(n)}}}}),[t]);let o=t&&t.style&&t.getSource(n);return o?function(e,t,r){pa(t.id===r.id,"source id changed"),pa(t.type===r.type,"source type changed");let i="",n=0;for(const e in t)"children"===e||"id"===e||Vs(r[e],t[e])||(i=e,n++);if(!n)return;const o=t.type;if("geojson"===o)e.setData(t.data);else if("image"===o)e.updateImage({url:t.url,coordinates:t.coordinates});else if("setCoordinates"in e&&1===n&&"coordinates"===i)e.setCoordinates(t.coordinates);else if("setUrl"in e)switch(i){case"url":e.setUrl(t.url);break;case"tiles":e.setTiles(t.tiles)}else console.warn(`Unable to update <Source> prop: ${i}`)}(o,e,r.current):o=function(e,t,r){if(e.style&&e.style._loaded){const i={...r};return delete i.id,delete i.children,e.addSource(t,i),e.getSource(t)}return null}(t,n,e),r.current=e,o&&te.Children.map(e.children,(e=>e&&ge(e,{source:n})))||null};br(".mapboxgl-map{font:12px/20px Helvetica Neue,Arial,Helvetica,sans-serif;overflow:hidden;position:relative;-webkit-tap-highlight-color:rgb(0 0 0/0)}.mapboxgl-canvas{left:0;position:absolute;top:0}.mapboxgl-map:-webkit-full-screen{height:100%;width:100%}.mapboxgl-canary{background-color:salmon}.mapboxgl-canvas-container.mapboxgl-interactive,.mapboxgl-ctrl-group button.mapboxgl-ctrl-compass{cursor:grab;-webkit-user-select:none;user-select:none}.mapboxgl-canvas-container.mapboxgl-interactive.mapboxgl-track-pointer{cursor:pointer}.mapboxgl-canvas-container.mapboxgl-interactive:active,.mapboxgl-ctrl-group button.mapboxgl-ctrl-compass:active{cursor:grabbing}.mapboxgl-canvas-container.mapboxgl-touch-zoom-rotate,.mapboxgl-canvas-container.mapboxgl-touch-zoom-rotate .mapboxgl-canvas{touch-action:pan-x pan-y}.mapboxgl-canvas-container.mapboxgl-touch-drag-pan,.mapboxgl-canvas-container.mapboxgl-touch-drag-pan .mapboxgl-canvas{touch-action:pinch-zoom}.mapboxgl-canvas-container.mapboxgl-touch-zoom-rotate.mapboxgl-touch-drag-pan,.mapboxgl-canvas-container.mapboxgl-touch-zoom-rotate.mapboxgl-touch-drag-pan .mapboxgl-canvas{touch-action:none}.mapboxgl-ctrl-bottom-left,.mapboxgl-ctrl-bottom-right,.mapboxgl-ctrl-top-left,.mapboxgl-ctrl-top-right{pointer-events:none;position:absolute;z-index:2}.mapboxgl-ctrl-top-left{left:0;top:0}.mapboxgl-ctrl-top-right{right:0;top:0}.mapboxgl-ctrl-bottom-left{bottom:0;left:0}.mapboxgl-ctrl-bottom-right{bottom:0;right:0}.mapboxgl-ctrl{clear:both;pointer-events:auto;transform:translate(0)}.mapboxgl-ctrl-top-left .mapboxgl-ctrl{float:left;margin:10px 0 0 10px}.mapboxgl-ctrl-top-right .mapboxgl-ctrl{float:right;margin:10px 10px 0 0}.mapboxgl-ctrl-bottom-left .mapboxgl-ctrl{float:left;margin:0 0 10px 10px}.mapboxgl-ctrl-bottom-right .mapboxgl-ctrl{float:right;margin:0 10px 10px 0}.mapboxgl-ctrl-group{background:#fff;border-radius:4px}.mapboxgl-ctrl-group:not(:empty){box-shadow:0 0 0 2px rgba(0,0,0,.1)}@media (-ms-high-contrast:active){.mapboxgl-ctrl-group:not(:empty){box-shadow:0 0 0 2px ButtonText}}.mapboxgl-ctrl-group button{background-color:transparent;border:0;box-sizing:border-box;cursor:pointer;display:block;height:29px;outline:none;overflow:hidden;padding:0;width:29px}.mapboxgl-ctrl-group button+button{border-top:1px solid #ddd}.mapboxgl-ctrl button .mapboxgl-ctrl-icon{background-position:50%;background-repeat:no-repeat;display:block;height:100%;width:100%}@media (-ms-high-contrast:active){.mapboxgl-ctrl-icon{background-color:transparent}.mapboxgl-ctrl-group button+button{border-top:1px solid ButtonText}}.mapboxgl-ctrl-attrib-button:focus,.mapboxgl-ctrl-group button:focus{box-shadow:0 0 2px 2px #0096ff}.mapboxgl-ctrl button:disabled{cursor:not-allowed}.mapboxgl-ctrl button:disabled .mapboxgl-ctrl-icon{opacity:.25}.mapboxgl-ctrl-group button:first-child{border-radius:4px 4px 0 0}.mapboxgl-ctrl-group button:last-child{border-radius:0 0 4px 4px}.mapboxgl-ctrl-group button:only-child{border-radius:inherit}.mapboxgl-ctrl button:not(:disabled):hover{background-color:rgb(0 0 0/5%)}.mapboxgl-ctrl-group button:focus:focus-visible{box-shadow:0 0 2px 2px #0096ff}.mapboxgl-ctrl-group button:focus:not(:focus-visible){box-shadow:none}.mapboxgl-ctrl button.mapboxgl-ctrl-zoom-out .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-9z'/%3E%3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-zoom-in .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5z'/%3E%3C/svg%3E\")}@media (-ms-high-contrast:active){.mapboxgl-ctrl button.mapboxgl-ctrl-zoom-out .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-9z'/%3E%3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-zoom-in .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5z'/%3E%3C/svg%3E\")}}@media (-ms-high-contrast:black-on-white){.mapboxgl-ctrl button.mapboxgl-ctrl-zoom-out .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23000' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-9z'/%3E%3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-zoom-in .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23000' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5z'/%3E%3C/svg%3E\")}}.mapboxgl-ctrl button.mapboxgl-ctrl-fullscreen .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3h1zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16h1zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5H13zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1V7.5z'/%3E%3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-shrink .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1h-5.5zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1v-5.5zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1v5.5zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1h5.5z'/%3E%3C/svg%3E\")}@media (-ms-high-contrast:active){.mapboxgl-ctrl button.mapboxgl-ctrl-fullscreen .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3h1zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16h1zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5H13zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1V7.5z'/%3E%3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-shrink .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1h-5.5zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1v-5.5zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1v5.5zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1h5.5z'/%3E%3C/svg%3E\")}}@media (-ms-high-contrast:black-on-white){.mapboxgl-ctrl button.mapboxgl-ctrl-fullscreen .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23000' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3h1zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16h1zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5H13zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1V7.5z'/%3E%3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-shrink .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23000' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1h-5.5zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1v-5.5zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1v5.5zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1h5.5z'/%3E%3C/svg%3E\")}}.mapboxgl-ctrl button.mapboxgl-ctrl-compass .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M10.5 14l4-8 4 8h-8z'/%3E%3Cpath id='south' d='M10.5 16l4 8 4-8h-8z' fill='%23ccc'/%3E%3C/svg%3E\")}@media (-ms-high-contrast:active){.mapboxgl-ctrl button.mapboxgl-ctrl-compass .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M10.5 14l4-8 4 8h-8z'/%3E%3Cpath id='south' d='M10.5 16l4 8 4-8h-8z' fill='%23999'/%3E%3C/svg%3E\")}}@media (-ms-high-contrast:black-on-white){.mapboxgl-ctrl button.mapboxgl-ctrl-compass .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23000' viewBox='0 0 29 29'%3E%3Cpath d='M10.5 14l4-8 4 8h-8z'/%3E%3Cpath id='south' d='M10.5 16l4 8 4-8h-8z' fill='%23ccc'/%3E%3C/svg%3E\")}}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23333'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate:disabled .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23aaa'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' fill='%23f00'/%3E%3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-active .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%2333b5e5'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-active-error .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23e58978'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-background .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%2333b5e5'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2' display='none'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-background-error .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23e54e33'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2' display='none'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-waiting .mapboxgl-ctrl-icon{animation:mapboxgl-spin 2s linear infinite}@media (-ms-high-contrast:active){.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23fff'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate:disabled .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23999'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' fill='%23f00'/%3E%3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-active .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%2333b5e5'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-active-error .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23e58978'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-background .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%2333b5e5'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2' display='none'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-background-error .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23e54e33'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2' display='none'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E\")}}@media (-ms-high-contrast:black-on-white){.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23000'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E\")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate:disabled .mapboxgl-ctrl-icon{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23666'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' fill='%23f00'/%3E%3C/svg%3E\")}}@keyframes mapboxgl-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}a.mapboxgl-ctrl-logo{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' fill-rule='evenodd' viewBox='0 0 88 23'%3E%3Cdefs%3E%3Cpath id='logo' d='M11.5 2.25c5.105 0 9.25 4.145 9.25 9.25s-4.145 9.25-9.25 9.25-9.25-4.145-9.25-9.25 4.145-9.25 9.25-9.25zM6.997 15.983c-.051-.338-.828-5.802 2.233-8.873a4.395 4.395 0 013.13-1.28c1.27 0 2.49.51 3.39 1.42.91.9 1.42 2.12 1.42 3.39 0 1.18-.449 2.301-1.28 3.13C12.72 16.93 7 16 7 16l-.003-.017zM15.3 10.5l-2 .8-.8 2-.8-2-2-.8 2-.8.8-2 .8 2 2 .8z'/%3E%3Cpath id='text' d='M50.63 8c.13 0 .23.1.23.23V9c.7-.76 1.7-1.18 2.73-1.18 2.17 0 3.95 1.85 3.95 4.17s-1.77 4.19-3.94 4.19c-1.04 0-2.03-.43-2.74-1.18v3.77c0 .13-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V8.23c0-.12.1-.23.23-.23h1.4zm-3.86.01c.01 0 .01 0 .01-.01.13 0 .22.1.22.22v7.55c0 .12-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V15c-.7.76-1.69 1.19-2.73 1.19-2.17 0-3.94-1.87-3.94-4.19 0-2.32 1.77-4.19 3.94-4.19 1.03 0 2.02.43 2.73 1.18v-.75c0-.12.1-.23.23-.23h1.4zm26.375-.19a4.24 4.24 0 00-4.16 3.29c-.13.59-.13 1.19 0 1.77a4.233 4.233 0 004.17 3.3c2.35 0 4.26-1.87 4.26-4.19 0-2.32-1.9-4.17-4.27-4.17zM60.63 5c.13 0 .23.1.23.23v3.76c.7-.76 1.7-1.18 2.73-1.18 1.88 0 3.45 1.4 3.84 3.28.13.59.13 1.2 0 1.8-.39 1.88-1.96 3.29-3.84 3.29-1.03 0-2.02-.43-2.73-1.18v.77c0 .12-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V5.23c0-.12.1-.23.23-.23h1.4zm-34 11h-1.4c-.13 0-.23-.11-.23-.23V8.22c.01-.13.1-.22.23-.22h1.4c.13 0 .22.11.23.22v.68c.5-.68 1.3-1.09 2.16-1.1h.03c1.09 0 2.09.6 2.6 1.55.45-.95 1.4-1.55 2.44-1.56 1.62 0 2.93 1.25 2.9 2.78l.03 5.2c0 .13-.1.23-.23.23h-1.41c-.13 0-.23-.11-.23-.23v-4.59c0-.98-.74-1.71-1.62-1.71-.8 0-1.46.7-1.59 1.62l.01 4.68c0 .13-.11.23-.23.23h-1.41c-.13 0-.23-.11-.23-.23v-4.59c0-.98-.74-1.71-1.62-1.71-.85 0-1.54.79-1.6 1.8v4.5c0 .13-.1.23-.23.23zm53.615 0h-1.61c-.04 0-.08-.01-.12-.03-.09-.06-.13-.19-.06-.28l2.43-3.71-2.39-3.65a.213.213 0 01-.03-.12c0-.12.09-.21.21-.21h1.61c.13 0 .24.06.3.17l1.41 2.37 1.4-2.37a.34.34 0 01.3-.17h1.6c.04 0 .08.01.12.03.09.06.13.19.06.28l-2.37 3.65 2.43 3.7c0 .05.01.09.01.13 0 .12-.09.21-.21.21h-1.61c-.13 0-.24-.06-.3-.17l-1.44-2.42-1.44 2.42a.34.34 0 01-.3.17zm-7.12-1.49c-1.33 0-2.42-1.12-2.42-2.51 0-1.39 1.08-2.52 2.42-2.52 1.33 0 2.42 1.12 2.42 2.51 0 1.39-1.08 2.51-2.42 2.52zm-19.865 0c-1.32 0-2.39-1.11-2.42-2.48v-.07c.02-1.38 1.09-2.49 2.4-2.49 1.32 0 2.41 1.12 2.41 2.51 0 1.39-1.07 2.52-2.39 2.53zm-8.11-2.48c-.01 1.37-1.09 2.47-2.41 2.47s-2.42-1.12-2.42-2.51c0-1.39 1.08-2.52 2.4-2.52 1.33 0 2.39 1.11 2.41 2.48l.02.08zm18.12 2.47c-1.32 0-2.39-1.11-2.41-2.48v-.06c.02-1.38 1.09-2.48 2.41-2.48s2.42 1.12 2.42 2.51c0 1.39-1.09 2.51-2.42 2.51z'/%3E%3C/defs%3E%3Cmask id='clip'%3E%3Crect x='0' y='0' width='100%25' height='100%25' fill='white'/%3E%3Cuse xlink:href='%23logo'/%3E%3Cuse xlink:href='%23text'/%3E%3C/mask%3E%3Cg id='outline' opacity='0.3' stroke='%23000' stroke-width='3'%3E%3Ccircle mask='url(%23clip)' cx='11.5' cy='11.5' r='9.25'/%3E%3Cuse xlink:href='%23text' mask='url(%23clip)'/%3E%3C/g%3E%3Cg id='fill' opacity='0.9' fill='%23fff'%3E%3Cuse xlink:href='%23logo'/%3E%3Cuse xlink:href='%23text'/%3E%3C/g%3E%3C/svg%3E\");background-repeat:no-repeat;cursor:pointer;display:block;height:23px;margin:0 0 -4px -4px;overflow:hidden;width:88px}a.mapboxgl-ctrl-logo.mapboxgl-compact{width:23px}@media (-ms-high-contrast:active){a.mapboxgl-ctrl-logo{background-color:transparent;background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' fill-rule='evenodd' viewBox='0 0 88 23'%3E%3Cdefs%3E%3Cpath id='logo' d='M11.5 2.25c5.105 0 9.25 4.145 9.25 9.25s-4.145 9.25-9.25 9.25-9.25-4.145-9.25-9.25 4.145-9.25 9.25-9.25zM6.997 15.983c-.051-.338-.828-5.802 2.233-8.873a4.395 4.395 0 013.13-1.28c1.27 0 2.49.51 3.39 1.42.91.9 1.42 2.12 1.42 3.39 0 1.18-.449 2.301-1.28 3.13C12.72 16.93 7 16 7 16l-.003-.017zM15.3 10.5l-2 .8-.8 2-.8-2-2-.8 2-.8.8-2 .8 2 2 .8z'/%3E%3Cpath id='text' d='M50.63 8c.13 0 .23.1.23.23V9c.7-.76 1.7-1.18 2.73-1.18 2.17 0 3.95 1.85 3.95 4.17s-1.77 4.19-3.94 4.19c-1.04 0-2.03-.43-2.74-1.18v3.77c0 .13-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V8.23c0-.12.1-.23.23-.23h1.4zm-3.86.01c.01 0 .01 0 .01-.01.13 0 .22.1.22.22v7.55c0 .12-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V15c-.7.76-1.69 1.19-2.73 1.19-2.17 0-3.94-1.87-3.94-4.19 0-2.32 1.77-4.19 3.94-4.19 1.03 0 2.02.43 2.73 1.18v-.75c0-.12.1-.23.23-.23h1.4zm26.375-.19a4.24 4.24 0 00-4.16 3.29c-.13.59-.13 1.19 0 1.77a4.233 4.233 0 004.17 3.3c2.35 0 4.26-1.87 4.26-4.19 0-2.32-1.9-4.17-4.27-4.17zM60.63 5c.13 0 .23.1.23.23v3.76c.7-.76 1.7-1.18 2.73-1.18 1.88 0 3.45 1.4 3.84 3.28.13.59.13 1.2 0 1.8-.39 1.88-1.96 3.29-3.84 3.29-1.03 0-2.02-.43-2.73-1.18v.77c0 .12-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V5.23c0-.12.1-.23.23-.23h1.4zm-34 11h-1.4c-.13 0-.23-.11-.23-.23V8.22c.01-.13.1-.22.23-.22h1.4c.13 0 .22.11.23.22v.68c.5-.68 1.3-1.09 2.16-1.1h.03c1.09 0 2.09.6 2.6 1.55.45-.95 1.4-1.55 2.44-1.56 1.62 0 2.93 1.25 2.9 2.78l.03 5.2c0 .13-.1.23-.23.23h-1.41c-.13 0-.23-.11-.23-.23v-4.59c0-.98-.74-1.71-1.62-1.71-.8 0-1.46.7-1.59 1.62l.01 4.68c0 .13-.11.23-.23.23h-1.41c-.13 0-.23-.11-.23-.23v-4.59c0-.98-.74-1.71-1.62-1.71-.85 0-1.54.79-1.6 1.8v4.5c0 .13-.1.23-.23.23zm53.615 0h-1.61c-.04 0-.08-.01-.12-.03-.09-.06-.13-.19-.06-.28l2.43-3.71-2.39-3.65a.213.213 0 01-.03-.12c0-.12.09-.21.21-.21h1.61c.13 0 .24.06.3.17l1.41 2.37 1.4-2.37a.34.34 0 01.3-.17h1.6c.04 0 .08.01.12.03.09.06.13.19.06.28l-2.37 3.65 2.43 3.7c0 .05.01.09.01.13 0 .12-.09.21-.21.21h-1.61c-.13 0-.24-.06-.3-.17l-1.44-2.42-1.44 2.42a.34.34 0 01-.3.17zm-7.12-1.49c-1.33 0-2.42-1.12-2.42-2.51 0-1.39 1.08-2.52 2.42-2.52 1.33 0 2.42 1.12 2.42 2.51 0 1.39-1.08 2.51-2.42 2.52zm-19.865 0c-1.32 0-2.39-1.11-2.42-2.48v-.07c.02-1.38 1.09-2.49 2.4-2.49 1.32 0 2.41 1.12 2.41 2.51 0 1.39-1.07 2.52-2.39 2.53zm-8.11-2.48c-.01 1.37-1.09 2.47-2.41 2.47s-2.42-1.12-2.42-2.51c0-1.39 1.08-2.52 2.4-2.52 1.33 0 2.39 1.11 2.41 2.48l.02.08zm18.12 2.47c-1.32 0-2.39-1.11-2.41-2.48v-.06c.02-1.38 1.09-2.48 2.41-2.48s2.42 1.12 2.42 2.51c0 1.39-1.09 2.51-2.42 2.51z'/%3E%3C/defs%3E%3Cmask id='clip'%3E%3Crect x='0' y='0' width='100%25' height='100%25' fill='white'/%3E%3Cuse xlink:href='%23logo'/%3E%3Cuse xlink:href='%23text'/%3E%3C/mask%3E%3Cg id='outline' opacity='1' stroke='%23000' stroke-width='3'%3E%3Ccircle mask='url(%23clip)' cx='11.5' cy='11.5' r='9.25'/%3E%3Cuse xlink:href='%23text' mask='url(%23clip)'/%3E%3C/g%3E%3Cg id='fill' opacity='1' fill='%23fff'%3E%3Cuse xlink:href='%23logo'/%3E%3Cuse xlink:href='%23text'/%3E%3C/g%3E%3C/svg%3E\")}}@media (-ms-high-contrast:black-on-white){a.mapboxgl-ctrl-logo{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' fill-rule='evenodd' viewBox='0 0 88 23'%3E%3Cdefs%3E%3Cpath id='logo' d='M11.5 2.25c5.105 0 9.25 4.145 9.25 9.25s-4.145 9.25-9.25 9.25-9.25-4.145-9.25-9.25 4.145-9.25 9.25-9.25zM6.997 15.983c-.051-.338-.828-5.802 2.233-8.873a4.395 4.395 0 013.13-1.28c1.27 0 2.49.51 3.39 1.42.91.9 1.42 2.12 1.42 3.39 0 1.18-.449 2.301-1.28 3.13C12.72 16.93 7 16 7 16l-.003-.017zM15.3 10.5l-2 .8-.8 2-.8-2-2-.8 2-.8.8-2 .8 2 2 .8z'/%3E%3Cpath id='text' d='M50.63 8c.13 0 .23.1.23.23V9c.7-.76 1.7-1.18 2.73-1.18 2.17 0 3.95 1.85 3.95 4.17s-1.77 4.19-3.94 4.19c-1.04 0-2.03-.43-2.74-1.18v3.77c0 .13-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V8.23c0-.12.1-.23.23-.23h1.4zm-3.86.01c.01 0 .01 0 .01-.01.13 0 .22.1.22.22v7.55c0 .12-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V15c-.7.76-1.69 1.19-2.73 1.19-2.17 0-3.94-1.87-3.94-4.19 0-2.32 1.77-4.19 3.94-4.19 1.03 0 2.02.43 2.73 1.18v-.75c0-.12.1-.23.23-.23h1.4zm26.375-.19a4.24 4.24 0 00-4.16 3.29c-.13.59-.13 1.19 0 1.77a4.233 4.233 0 004.17 3.3c2.35 0 4.26-1.87 4.26-4.19 0-2.32-1.9-4.17-4.27-4.17zM60.63 5c.13 0 .23.1.23.23v3.76c.7-.76 1.7-1.18 2.73-1.18 1.88 0 3.45 1.4 3.84 3.28.13.59.13 1.2 0 1.8-.39 1.88-1.96 3.29-3.84 3.29-1.03 0-2.02-.43-2.73-1.18v.77c0 .12-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V5.23c0-.12.1-.23.23-.23h1.4zm-34 11h-1.4c-.13 0-.23-.11-.23-.23V8.22c.01-.13.1-.22.23-.22h1.4c.13 0 .22.11.23.22v.68c.5-.68 1.3-1.09 2.16-1.1h.03c1.09 0 2.09.6 2.6 1.55.45-.95 1.4-1.55 2.44-1.56 1.62 0 2.93 1.25 2.9 2.78l.03 5.2c0 .13-.1.23-.23.23h-1.41c-.13 0-.23-.11-.23-.23v-4.59c0-.98-.74-1.71-1.62-1.71-.8 0-1.46.7-1.59 1.62l.01 4.68c0 .13-.11.23-.23.23h-1.41c-.13 0-.23-.11-.23-.23v-4.59c0-.98-.74-1.71-1.62-1.71-.85 0-1.54.79-1.6 1.8v4.5c0 .13-.1.23-.23.23zm53.615 0h-1.61c-.04 0-.08-.01-.12-.03-.09-.06-.13-.19-.06-.28l2.43-3.71-2.39-3.65a.213.213 0 01-.03-.12c0-.12.09-.21.21-.21h1.61c.13 0 .24.06.3.17l1.41 2.37 1.4-2.37a.34.34 0 01.3-.17h1.6c.04 0 .08.01.12.03.09.06.13.19.06.28l-2.37 3.65 2.43 3.7c0 .05.01.09.01.13 0 .12-.09.21-.21.21h-1.61c-.13 0-.24-.06-.3-.17l-1.44-2.42-1.44 2.42a.34.34 0 01-.3.17zm-7.12-1.49c-1.33 0-2.42-1.12-2.42-2.51 0-1.39 1.08-2.52 2.42-2.52 1.33 0 2.42 1.12 2.42 2.51 0 1.39-1.08 2.51-2.42 2.52zm-19.865 0c-1.32 0-2.39-1.11-2.42-2.48v-.07c.02-1.38 1.09-2.49 2.4-2.49 1.32 0 2.41 1.12 2.41 2.51 0 1.39-1.07 2.52-2.39 2.53zm-8.11-2.48c-.01 1.37-1.09 2.47-2.41 2.47s-2.42-1.12-2.42-2.51c0-1.39 1.08-2.52 2.4-2.52 1.33 0 2.39 1.11 2.41 2.48l.02.08zm18.12 2.47c-1.32 0-2.39-1.11-2.41-2.48v-.06c.02-1.38 1.09-2.48 2.41-2.48s2.42 1.12 2.42 2.51c0 1.39-1.09 2.51-2.42 2.51z'/%3E%3C/defs%3E%3Cmask id='clip'%3E%3Crect x='0' y='0' width='100%25' height='100%25' fill='white'/%3E%3Cuse xlink:href='%23logo'/%3E%3Cuse xlink:href='%23text'/%3E%3C/mask%3E%3Cg id='outline' opacity='1' stroke='%23fff' stroke-width='3' fill='%23fff'%3E%3Ccircle mask='url(%23clip)' cx='11.5' cy='11.5' r='9.25'/%3E%3Cuse xlink:href='%23text' mask='url(%23clip)'/%3E%3C/g%3E%3Cg id='fill' opacity='1' fill='%23000'%3E%3Cuse xlink:href='%23logo'/%3E%3Cuse xlink:href='%23text'/%3E%3C/g%3E%3C/svg%3E\")}}.mapboxgl-ctrl.mapboxgl-ctrl-attrib{background-color:hsla(0,0%,100%,.5);margin:0;padding:0 5px}@media screen{.mapboxgl-ctrl-attrib.mapboxgl-compact{background-color:#fff;border-radius:12px;box-sizing:content-box;margin:10px;min-height:20px;padding:2px 24px 2px 0;position:relative}.mapboxgl-ctrl-attrib.mapboxgl-compact-show{padding:2px 28px 2px 8px;visibility:visible}.mapboxgl-ctrl-bottom-left>.mapboxgl-ctrl-attrib.mapboxgl-compact-show,.mapboxgl-ctrl-top-left>.mapboxgl-ctrl-attrib.mapboxgl-compact-show{border-radius:12px;padding:2px 8px 2px 28px}.mapboxgl-ctrl-attrib.mapboxgl-compact .mapboxgl-ctrl-attrib-inner{display:none}.mapboxgl-ctrl-attrib-button{background-color:hsla(0,0%,100%,.5);background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill-rule='evenodd'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E\");border:0;border-radius:12px;box-sizing:border-box;cursor:pointer;display:none;height:24px;outline:none;position:absolute;right:0;top:0;width:24px}.mapboxgl-ctrl-bottom-left .mapboxgl-ctrl-attrib-button,.mapboxgl-ctrl-top-left .mapboxgl-ctrl-attrib-button{left:0}.mapboxgl-ctrl-attrib.mapboxgl-compact .mapboxgl-ctrl-attrib-button,.mapboxgl-ctrl-attrib.mapboxgl-compact-show .mapboxgl-ctrl-attrib-inner{display:block}.mapboxgl-ctrl-attrib.mapboxgl-compact-show .mapboxgl-ctrl-attrib-button{background-color:rgb(0 0 0/5%)}.mapboxgl-ctrl-bottom-right>.mapboxgl-ctrl-attrib.mapboxgl-compact:after{bottom:0;right:0}.mapboxgl-ctrl-top-right>.mapboxgl-ctrl-attrib.mapboxgl-compact:after{right:0;top:0}.mapboxgl-ctrl-top-left>.mapboxgl-ctrl-attrib.mapboxgl-compact:after{left:0;top:0}.mapboxgl-ctrl-bottom-left>.mapboxgl-ctrl-attrib.mapboxgl-compact:after{bottom:0;left:0}}@media screen and (-ms-high-contrast:active){.mapboxgl-ctrl-attrib.mapboxgl-compact:after{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill-rule='evenodd' fill='%23fff'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E\")}}@media screen and (-ms-high-contrast:black-on-white){.mapboxgl-ctrl-attrib.mapboxgl-compact:after{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill-rule='evenodd'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E\")}}.mapboxgl-ctrl-attrib a{color:rgba(0,0,0,.75);text-decoration:none}.mapboxgl-ctrl-attrib a:hover{color:inherit;text-decoration:underline}.mapboxgl-ctrl-attrib .mapbox-improve-map{font-weight:700;margin-left:2px}.mapboxgl-attrib-empty{display:none}.mapboxgl-ctrl-scale{background-color:hsla(0,0%,100%,.75);border:2px solid #333;border-top:#333;box-sizing:border-box;color:#333;font-size:10px;padding:0 5px;white-space:nowrap}.mapboxgl-popup{display:flex;left:0;pointer-events:none;position:absolute;top:0;will-change:transform}.mapboxgl-popup-anchor-top,.mapboxgl-popup-anchor-top-left,.mapboxgl-popup-anchor-top-right{flex-direction:column}.mapboxgl-popup-anchor-bottom,.mapboxgl-popup-anchor-bottom-left,.mapboxgl-popup-anchor-bottom-right{flex-direction:column-reverse}.mapboxgl-popup-anchor-left{flex-direction:row}.mapboxgl-popup-anchor-right{flex-direction:row-reverse}.mapboxgl-popup-tip{border:10px solid transparent;height:0;width:0;z-index:1}.mapboxgl-popup-anchor-top .mapboxgl-popup-tip{align-self:center;border-bottom-color:#fff;border-top:none}.mapboxgl-popup-anchor-top-left .mapboxgl-popup-tip{align-self:flex-start;border-bottom-color:#fff;border-left:none;border-top:none}.mapboxgl-popup-anchor-top-right .mapboxgl-popup-tip{align-self:flex-end;border-bottom-color:#fff;border-right:none;border-top:none}.mapboxgl-popup-anchor-bottom .mapboxgl-popup-tip{align-self:center;border-bottom:none;border-top-color:#fff}.mapboxgl-popup-anchor-bottom-left .mapboxgl-popup-tip{align-self:flex-start;border-bottom:none;border-left:none;border-top-color:#fff}.mapboxgl-popup-anchor-bottom-right .mapboxgl-popup-tip{align-self:flex-end;border-bottom:none;border-right:none;border-top-color:#fff}.mapboxgl-popup-anchor-left .mapboxgl-popup-tip{align-self:center;border-left:none;border-right-color:#fff}.mapboxgl-popup-anchor-right .mapboxgl-popup-tip{align-self:center;border-left-color:#fff;border-right:none}.mapboxgl-popup-close-button{background-color:transparent;border:0;border-radius:0 3px 0 0;cursor:pointer;position:absolute;right:0;top:0}.mapboxgl-popup-close-button:hover{background-color:rgb(0 0 0/5%)}.mapboxgl-popup-content{background:#fff;border-radius:3px;box-shadow:0 1px 2px rgba(0,0,0,.1);padding:10px 10px 15px;pointer-events:auto;position:relative}.mapboxgl-popup-anchor-top-left .mapboxgl-popup-content{border-top-left-radius:0}.mapboxgl-popup-anchor-top-right .mapboxgl-popup-content{border-top-right-radius:0}.mapboxgl-popup-anchor-bottom-left .mapboxgl-popup-content{border-bottom-left-radius:0}.mapboxgl-popup-anchor-bottom-right .mapboxgl-popup-content{border-bottom-right-radius:0}.mapboxgl-popup-track-pointer{display:none}.mapboxgl-popup-track-pointer *{pointer-events:none;user-select:none}.mapboxgl-map:hover .mapboxgl-popup-track-pointer{display:flex}.mapboxgl-map:active .mapboxgl-popup-track-pointer{display:none}.mapboxgl-marker{left:0;opacity:1;position:absolute;top:0;transition:opacity .2s;will-change:transform}.mapboxgl-user-location-dot,.mapboxgl-user-location-dot:before{background-color:#1da1f2;border-radius:50%;height:15px;width:15px}.mapboxgl-user-location-dot:before{animation:mapboxgl-user-location-dot-pulse 2s infinite;content:\"\";position:absolute}.mapboxgl-user-location-dot:after{border:2px solid #fff;border-radius:50%;box-shadow:0 0 3px rgba(0,0,0,.35);box-sizing:border-box;content:\"\";height:19px;left:-2px;position:absolute;top:-2px;width:19px}.mapboxgl-user-location-show-heading .mapboxgl-user-location-heading{height:0;width:0}.mapboxgl-user-location-show-heading .mapboxgl-user-location-heading:after,.mapboxgl-user-location-show-heading .mapboxgl-user-location-heading:before{border-bottom:7.5px solid #4aa1eb;content:\"\";position:absolute}.mapboxgl-user-location-show-heading .mapboxgl-user-location-heading:before{border-left:7.5px solid transparent;transform:translateY(-28px) skewY(-20deg)}.mapboxgl-user-location-show-heading .mapboxgl-user-location-heading:after{border-right:7.5px solid transparent;transform:translate(7.5px,-28px) skewY(20deg)}@keyframes mapboxgl-user-location-dot-pulse{0%{opacity:1;transform:scale(1)}70%{opacity:0;transform:scale(3)}to{opacity:0;transform:scale(1)}}.mapboxgl-user-location-dot-stale{background-color:#aaa}.mapboxgl-user-location-dot-stale:after{display:none}.mapboxgl-user-location-accuracy-circle{background-color:#1da1f233;border-radius:100%;height:1px;width:1px}.mapboxgl-crosshair,.mapboxgl-crosshair .mapboxgl-interactive,.mapboxgl-crosshair .mapboxgl-interactive:active{cursor:crosshair}.mapboxgl-boxzoom{background:#fff;border:2px dotted #202020;height:0;left:0;opacity:.5;position:absolute;top:0;width:0}@media print{.mapbox-improve-map{display:none}}.mapboxgl-scroll-zoom-blocker,.mapboxgl-touch-pan-blocker{align-items:center;background:rgba(0,0,0,.7);color:#fff;display:flex;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif;height:100%;justify-content:center;left:0;opacity:0;pointer-events:none;position:absolute;text-align:center;top:0;transition:opacity .75s ease-in-out;transition-delay:1s;width:100%}.mapboxgl-scroll-zoom-blocker-show,.mapboxgl-touch-pan-blocker-show{opacity:1;transition:opacity .1s ease-in-out}.mapboxgl-canvas-container.mapboxgl-touch-pan-blocker-override.mapboxgl-scrollable-page,.mapboxgl-canvas-container.mapboxgl-touch-pan-blocker-override.mapboxgl-scrollable-page .mapboxgl-canvas{touch-action:pan-x pan-y}");const wa=e=>e?.split(",")?.[0],Ca=e=>{let{tagIndex:t,isochronesTags:r=!1,filters:i,county:n,isochrones:o,resetCounty:a,updateTagIndex:c}=e;const h=u((e=>e.breakpoints.down("md"))),d=ue((()=>r?function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=ds(e,"destination"),r=ds(e,"destinationTwo"),i=wa(t?.destination),n=wa(r?.destination),o=hs(+(e?.time||10)),s=hs(+(e?.timeTwo||10));return{"1_cycling_destination":{id:"1_cycling_destination",icon:"cycling",name:`${o} from ${i}`},"1_driving_destination":{id:"1_driving_destination",icon:"driving",name:`${o} from ${i}`},"1_public_transport_destination":{id:"1_public_transport_destination",icon:"public_transport",name:`${o} from ${i}`},"1_walking_destination":{id:"1_walking_destination",icon:"walking",name:`${o} from ${i}`},"2_cycling_destinationTwo":{id:"2_cycling_destinationTwo",icon:"cycling",name:`${s} from ${n}`},"2_driving_destinationTwo":{id:"2_driving_destinationTwo",icon:"driving",name:`${s} from ${n}`},"2_public_transport_destinationTwo":{id:"2_public_transport_destinationTwo",icon:"public_transport",name:`${s} from ${n}`},"2_walking_destinationTwo":{id:"2_walking_destinationTwo",icon:"walking",name:`${s} from ${n}`},"1_aggregated":{isMultiple:!0,id:"1_aggregated",icons:Os.isString(e?.methods)?e?.methods?.length>0?[e?.methods]:[]:e?.methods,name:`${o} from ${i}`},"2_aggregated":{isMultiple:!0,id:"2_aggregated",icons:Os.isString(e?.methodsTwo)?e?.methodsTwo?.length>0?[e?.methodsTwo]:[]:e?.methodsTwo,name:`${s} from ${n}`},"1_public_transport":{id:"1_public_transport",icon:"public_transport",name:`${o} from ${i}`},"2_public_transport":{id:"2_public_transport",icon:"public_transport",name:`${s} from ${n}`},"1_driving":{id:"1_driving",icon:"driving",name:`${o} from ${i}`},"2_driving":{id:"2_driving",icon:"driving",name:`${s} from ${n}`},"1_cycling":{id:"1_cycling",icon:"cycling",name:`${o} from ${i}`},"2_cycling":{id:"2_cycling",icon:"cycling",name:`${s} from ${n}`},"1_walking":{id:"1_walking",icon:"walking",name:`${o} from ${i}`},"2_walking":{id:"2_walking",icon:"walking",name:`${s} from ${n}`}}}(i):function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=`${us(e?.commutes?.[0]?.time,!0)} from ${e?.commutes?.[0]?.location?.name}`,r=`${us(e?.commutes?.[1]?.time,!0)} from ${e?.commutes?.[1]?.location?.name}`;return{"1_aggregated":{id:"1_aggregated",icons:e?.commutes?.[0]?.methods,name:t},"2_aggregated":{id:"2_aggregated",icons:e?.commutes?.[1]?.methods,name:r}}}(i)),[i]),p=ue((()=>o?.map((e=>e?.properties?.search_id||e?.properties?.name))?.filter(Boolean)),[o]),f=ue((()=>n?.properties?.search_id||n?.properties?.name),[n]),m=e=>()=>{c(e),a()};return oe((()=>{const e=document.querySelectorAll(".map-tag");if(h&&e?.length)if(t)setTimeout((()=>{e[t].scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})}),100);else{const t=n?.layer?.id?n.layer.id.split("-"):void 0,r=t?.[t?.length-1];r&&setTimeout((()=>{e[+r].scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})}),100)}}),[t,n,h]),s(g,{direction:"row",gap:.75,pr:6,flexWrap:["nowrap","nowrap","wrap"],sx:e=>({[e.breakpoints.down("md")]:{overflowX:"scroll",backgroundColor:"white",borderRadius:"10px",boxShadow:"0px 2px 8px 0px rgba(40, 35, 68, 0.15)",padding:"6px",msOverflowStyle:"none",scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}}}),children:r?p?.map(((e,r)=>{const i=fs[d?.[e]?.icon]||s(l,{}),n=d?.[e]?.isMultiple;return s(Lo,{className:"map-tag",onMouseEnter:m(r),onMouseLeave:()=>c(null),label:d?.[e]?.name,TypographyProps:{fontWeight:400,sx:f===d?.[e]?.id||t===r?{color:"white"}:{}},sx:i=>({transition:i.transitions.create("backgroundColor"),height:24,backgroundColor:f===d?.[e]?.id||t===r?i.palette.primary.main:h?"#DCE1E8":"white"}),icon:n?s(g,{direction:"row",gap:.25,children:d?.[e]?.icons?.map((t=>{const r=fs?.[t]||s(l,{});return s(r,{sx:{fontSize:18}},`${e}-${t}`)}))}):s(i,{sx:{fontSize:18}})},e)})):p?.map(((e,r)=>s(Lo,{className:"map-tag",onMouseEnter:m(r),onMouseLeave:()=>c(null),fontSize:14,label:d?.[e]?.name,sx:i=>({transition:i.transitions.create("backgroundColor"),height:30,borderRadius:"10px !important",backgroundColor:f===d?.[e]?.id||t===r?i.palette.secondary.main:"#E5EFF0",color:f===d?.[e]?.id||t===r?"white !important":i.palette.success.main}),icon:s(g,{gap:.5,direction:"row",alignItems:"center",children:ms.map((t=>{let{id:r,icon:i}=t;return d?.[e]?.icons?.includes(r)&&s(_,{width:20,height:20,bgcolor:"white",borderRadius:50,display:"flex",alignItems:"center",justifyContent:"center",children:s(i,{sx:{width:16,height:16}})},r)}))})},e)))})};function Ta(e,t,r){if(null!==e)for(var i,n,o,s,a,l,c,u,h=0,d=0,p=e.type,f="FeatureCollection"===p,m="Feature"===p,A=f?e.features.length:1,g=0;g<A;g++){a=(u=!!(c=f?e.features[g].geometry:m?e.geometry:e)&&"GeometryCollection"===c.type)?c.geometries.length:1;for(var _=0;_<a;_++){var y=0,x=0;if(null!==(s=u?c.geometries[_]:c)){l=s.coordinates;var v=s.type;switch(h=0,v){case null:break;case"Point":if(!1===t(l,d,g,y,x))return!1;d++,y++;break;case"LineString":case"MultiPoint":for(i=0;i<l.length;i++){if(!1===t(l[i],d,g,y,x))return!1;d++,"MultiPoint"===v&&y++}"LineString"===v&&y++;break;case"Polygon":case"MultiLineString":for(i=0;i<l.length;i++){for(n=0;n<l[i].length-h;n++){if(!1===t(l[i][n],d,g,y,x))return!1;d++}"MultiLineString"===v&&y++,"Polygon"===v&&x++}"Polygon"===v&&y++;break;case"MultiPolygon":for(i=0;i<l.length;i++){for(x=0,n=0;n<l[i].length;n++){for(o=0;o<l[i][n].length-h;o++){if(!1===t(l[i][n][o],d,g,y,x))return!1;d++}x++}y++}break;case"GeometryCollection":for(i=0;i<s.geometries.length;i++)if(!1===Ta(s.geometries[i],t))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function Ea(e){var t=[1/0,1/0,-1/0,-1/0];return Ta(e,(function(e){t[0]>e[0]&&(t[0]=e[0]),t[1]>e[1]&&(t[1]=e[1]),t[2]<e[0]&&(t[2]=e[0]),t[3]<e[1]&&(t[3]=e[1])})),t}Ea.default=Ea;const Ma=e=>{let{polygonStyles:t,tagIndex:r,county:i,isochrones:n}=e;const o=c(),u=ue((()=>({styles:{"fill-outline-color":o.palette.secondary.main,"fill-color":Je(o.palette.secondary.main,.2)},lineStyles:{"line-width":3,"line-color":o.palette.secondary.main},hoverStyles:{"fill-outline-color":o.palette.secondary.main,"fill-color":Je(o.palette.secondary.main,.35)}})),[n]),h=t||u;return a(l,{children:[n?.map(((e,t)=>s(ba,{id:`polygon-${t}`,type:"geojson",data:e,children:s(va,{id:`polygon-${t}`,type:"fill",source:`polygon-${t}`,paint:i?.layer?.id===`polygon-${t}`||i?.layer?.id===`polygon-line-${t}`||r===t?h.hoverStyles:h.styles})},`polygon-${t}`))),n?.map(((e,t)=>s(ba,{id:`polygon-line-${t}`,type:"geojson",data:e,children:s(va,{id:`polygon-line-${t}`,type:"line",source:`polygon-line-${t}`,paint:h.lineStyles})},`polygon-line-${t}`)))]})},Sa=b(ya)((e=>{let{theme:t}=e;return{zIndex:2,filter:"drop-shadow(0px 2px 8px rgba(40, 35, 68, 0.15))",[t.breakpoints.down("sm")]:{maxWidth:"220px !important"},".mapboxgl-popup-content":{overflow:"hidden",padding:0,borderRadius:"15px",boxShadow:"none",background:"#2e3841"},"&.mapboxgl-popup-anchor-bottom-right .mapboxgl-popup-content":{borderBottomRightRadius:"0 !important"},"&.mapboxgl-popup-anchor-bottom-left .mapboxgl-popup-content":{borderBottomLeftRadius:"0 !important"},"&.mapboxgl-popup-anchor-top-right .mapboxgl-popup-content":{borderTopRightRadius:"0 !important"},"&.mapboxgl-popup-anchor-top-left .mapboxgl-popup-content":{borderTopLeftRadius:"0 !important"},"&.mapboxgl-popup-anchor-right .mapboxgl-popup-tip":{borderLeftColor:"#2e3841 !important"},"&.mapboxgl-popup-anchor-left .mapboxgl-popup-tip":{borderRightColor:"#2e3841 !important"},"&.mapboxgl-popup-anchor-top-right .mapboxgl-popup-tip, &.mapboxgl-popup-anchor-top .mapboxgl-popup-tip, &.mapboxgl-popup-anchor-top-left .mapboxgl-popup-tip":{borderBottomColor:"#2e3841 !important"},"&.mapboxgl-popup-anchor-bottom .mapboxgl-popup-tip, &.mapboxgl-popup-anchor-bottom-right .mapboxgl-popup-tip, &.mapboxgl-popup-anchor-bottom-left .mapboxgl-popup-tip":{borderTopColor:"#2e3841 !important"}}})),Ia=e=>{let{styles:t,center:r,addLoader:i=!1,isochronesTags:n=!1,disableCluster:o=!1,disableBounds:c=!1,disablePolygonHover:h=!1,disableTags:d=!0,disableNavigationControl:p=!1,disablePopup:f=!0,disablePinsFeatures:m=!1,height:A="100%",tagIndex:g,polygonStyles:y,mapboxAccessToken:x,propertyPinComponent:v=Bt,commutePinComponent:b=Ot,loading:w,showDrawer:C=!1,filters:T,pins:E,popup:M,commutePins:S=[],isochrones:I,updateTagIndex:P,onPinSelect:D,generatePin:k,onUpdatePolygon:L,onDeletePolygon:z}=e;const O=ae(null),j=ae(null),V=u((e=>e.breakpoints.down("md"))),N=ae(null),U=ae(null),[H,G]=ne(null),[Z,W]=ne({}),[Q,q]=ne(!1),X=()=>D?.(void 0),Y=B((e=>{e&&"commute"===e?.type||(N.current&&window.clearTimeout(N.current),N.current=window.setTimeout((()=>D?.(e)),300))})),$=B((()=>{U.current&&window.clearTimeout(U.current),U.current=window.setTimeout(X,300)})),K=ue((()=>m?[]:E.map((e=>({type:"Feature",geometry:{type:"Point",coordinates:[e.longitude,e.latitude]},properties:{id:e.id,icon:"pin-pink",url:e.listing_url}})))),[E]),J=ue((()=>({type:"FeatureCollection",features:K})),[K]),ee=ue((()=>S?.map((e=>{const t=!f&&!e?.disablePopup;return s(_,{component:_a,longitude:e.lng||e.longitude,latitude:e.lat||e.latitude,anchor:"bottom",children:s(_,{display:"flex",sx:{cursor:"pointer"},onClick:V&&t?t=>{t.preventDefault(),t.stopPropagation(),D?.(e)}:void 0,onMouseEnter:!V&&t?()=>Y(e):void 0,onMouseLeave:!V&&t?$:void 0,children:k?k(e):s(b,{sx:{width:30,height:36}})})},`${e?.id||e?.urn}${e?.smartscore||0}`)}))),[S]),te=ue((()=>{if(!c&&E.length)return E.reduce(((e,t)=>e.extend([t.longitude,t.latitude])),new Rs.LngLatBounds([E[0].longitude,E[0].latitude],[E[0].longitude,E[0].latitude]));if(!I?.length&&!E.length){const e=process.env.NEXT_PUBLIC_MAP_DEFAULT_BOUNDS?.split(",");if(4===e?.length&&e.every((e=>!isNaN(Number(e)))))return new Rs.LngLatBounds([Number(e[0]),Number(e[1])],[Number(e[2]),Number(e[3])])}}),[E,c]),re=ce((e=>{const t=O?.current?.queryRenderedFeatures?.(e?.point),r=t?.filter((e=>e?.source?.includes("polygon"))),i=r?.[r?.length-1];!o&&O.current&&(O.current.getMap().getCanvas().style.cursor=r?.length?"pointer":"auto"),P(null),h||H&&Os.isEqual(i,H)?ie():G(i??null)}),[H]),ie=()=>{G(null)},se=ce((e=>{W((t=>({...t,...e})))}),[]),le=e=>{let{viewState:t}=e;W({...t,bearing:0,pitch:0})};return oe((()=>{if(o||!O.current)return;const e=O.current.getMap();if(e.hasImage("pin-pink"))return;const t=new Image(30,36);t.onload=()=>{e.addImage("pin-pink",t)};s(v,{}).src=t.src}),[]),oe((()=>{const e=e=>{j.current&&!j?.current?.contains(e.target)&&ie()};return document.addEventListener("click",e,!0),document.addEventListener("visibilitychange",ie),()=>{document.removeEventListener("click",e,!0),document.removeEventListener("visibilitychange",ie)}}),[H]),oe((()=>{O.current&&te&&O.current.fitBounds(te,{padding:100,duration:1e3})}),[te]),oe((()=>{if(I?.length&&Q){const e=(e=>{if(!e?.length)return;const t=function(e,t){void 0===t&&(t={});var r={type:"FeatureCollection"};return t.id&&(r.id=t.id),t.bbox&&(r.bbox=t.bbox),r.features=e,r}(e),r=Ea(t),i=r[0],n=r[1],o=r[2],s=(n+r[3])/2,a=(i+o)/2;return{bounds:[[r?.[0],r?.[1]],[r?.[2],r?.[3]]],latitude:s,longitude:a}})(I);if(!O.current||!e)return;se({...Z,latitude:e?.latitude,longitude:e?.longitude}),O.current.fitBounds(e?.bounds,{padding:40,duration:1e3})}}),[I,Q]),oe((()=>{const e=()=>{le({viewState:Z}),X()};return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[]),a(_,{ref:j,position:"relative",width:"100%",height:A,onMouseLeave:ie,children:[i&&w&&s(_,{position:"absolute",sx:{top:0,left:0,right:0,zIndex:1},children:s(R,{})}),a(ga,{...Z,ref:O,minZoom:3,maxZoom:19,initialViewState:{bounds:te,...c?{zoom:9,latitude:r?.lat??E?.[0]?.latitude,longitude:r?.lng??E?.[0]?.longitude}:{},fitBoundsOptions:{padding:I?.length||E?.length?100:0}},style:{width:"100%",height:"100%"},mapboxAccessToken:x,mapStyle:t.streets,onMove:le,attributionControl:!1,onMouseMove:re,onLoad:()=>q(!0),onClick:e=>{if(re(),o)return;const t=O.current;if(!t)return;const r=e.features&&e.features[0];if("unclustered-point"===r?.layer.id){const e=r?.properties?.url;if(!e)return;window.open(e,"_blank")}if(!r)return;const i=r.properties?.cluster_id;if(!i)return;t.getSource("pins").getClusterExpansionZoom(i,((e,i)=>{if(e)return;const n="coordinates"in r.geometry?r.geometry.coordinates:void 0;n&&t.easeTo({center:n,zoom:i,duration:500})}))},...!o&&{interactiveLayerIds:["clusters","unclustered-point","commute-pin"]},children:[C&&s(DrawControl,{mapRef:O,onCreate:L,onUpdate:L,onDelete:z}),!p&&s(xa,{position:V?"bottom-right":"top-right",showCompass:!1}),!w&&a(l,{children:[!d&&I?.length>0&&s(_,{position:"absolute",sx:{top:9,left:8,right:8,zIndex:1},children:s(Ca,{isochronesTags:n,tagIndex:g,updateTagIndex:P,filters:T,isochrones:I,county:H,resetCounty:ie})}),s(Ma,{polygonStyles:y,tagIndex:g,isochrones:I,county:H}),(S??[])?.length>0&&ee,!o&&J?.features?.length>0&&a(ba,{id:"pins",type:"geojson",data:J,cluster:!0,clusterMaxZoom:14,clusterRadius:40,children:[s(va,{id:"clusters",source:"pins",type:"circle",filter:["has","point_count"],paint:{"circle-color":["step",["get","point_count"],"#fff",100,"#fff",750,"#fff"],"circle-radius":["step",["get","point_count"],20,100,30,750,40]}}),s(va,{id:"cluster-count",type:"symbol",source:"pins",filter:["has","point_count"],layout:{"text-field":["get","point_count_abbreviated"],"text-font":["DIN Offc Pro Medium","Arial Unicode MS Bold"],"text-size":12,"text-color":"#414141"}}),s(va,{id:"unclustered-point",source:"pins",type:"symbol",filter:["!",["has","point_count"]],layout:{"icon-image":"pin-pink","icon-anchor":"bottom"}})]})]}),!f&&M&&s(Sa,{maxWidth:"none",className:"smartscorePopup",longitude:M.longitude,latitude:M.latitude,closeButton:!1,offset:{right:[-15,-15],left:[15,-15],bottom:[0,-30],"bottom-right":[0,-40],"bottom-left":[0,-40]},children:s(F,{onClickAway:()=>M.onClose?.(),children:s("div",{onMouseEnter:V?void 0:()=>{N.current&&window.clearInterval(N.current),U.current&&window.clearInterval(U.current)},onMouseLeave:V?void 0:X,children:M.content})})})]})]})},Pa=r((e=>{let{className:t,...r}=e;return s(z,{...r,arrow:!0,classes:{popper:t}})}))((e=>{let{theme:t,maxWidth:r,placement:i}=e;return{[`& .${j.arrow}`]:{color:"#2E3841",[t.breakpoints.down("md")]:"bottom"===i?{marginLeft:t.spacing(-1.25)+" !important"}:{}},[`& .${j.tooltip}`]:{padding:t.spacing(1.5,2),backgroundColor:"#2E3841",borderRadius:"15px",...{maxWidth:r}||{},[t.breakpoints.down("md")]:"bottom"===i||"top"===i?{marginLeft:t.spacing(5.5)+" !important"}:{},[t.breakpoints.down("sm")]:"bottom"===i||"top"===i?{marginLeft:t.spacing(3)+" !important"}:{},"@media (max-width: 320px)":{maxWidth:270}}}})),Da=e=>{let{disableTooltip:t=!1,placement:r="right",open:i=!1,maxWidth:n=292,title:o,children:a,closeTooltip:l,sx:c={},boxSx:u={},...h}=e;const[d,p]=ne(i),f=()=>{p(!1),l?.()},m=e=>{e.preventDefault(),e.stopPropagation(),p(!0)};return oe((()=>{t||(i?(p(!0),setTimeout((()=>{p(!1),l?.()}),3500)):p(!1))}),[i]),t?a:s(Pa,{open:d,title:o,leaveTouchDelay:4e3,enterTouchDelay:50,placement:r,onClose:f,onOpen:m,maxWidth:n,sx:c,...h,children:s(_,{component:"span",sx:[...Array.isArray(u)?u:[u]],onClick:m,children:s(F,{disableReactTree:!0,onClickAway:f,children:a})})})},ka=e=>{let{sx:t={},children:r}=e;return s(v,{component:_,variant:"h6",sx:t,children:r})},La=e=>{let{error:t}=e;return t?s(v,{align:"center",color:"error",fontSize:12,lineHeight:"15.6px",sx:{pt:.5},children:t}):null},za=b(V)((e=>{let{multiline:t}=e;return{fontFamily:"Poppins","& input::-webkit-inner-spin-button":{WebkitAppearance:"none",margin:0},'& input[type="number"]':{MozAppearance:"textfield"},".MuiOutlinedInput-root":{fontFamily:"Poppins",borderRadius:t?"20px":"100px","input::-webkit-outer-spin-button, input::-webkit-inner-spin-button":{WebkitAppearance:"none",margin:0},'input[type="number"]':{MozAppearance:"textfield"}},".MuiFormHelperText-root":{textAlign:"center"}}})),Oa=me(((e,t)=>{let{minWidth:r,isClearable:n=!1,disabled:o=!1,fullWidth:l=!0,showTooltip:c=!1,openTooltip:h=!1,closeTooltip:d,tooltipTitle:p,type:f="text",label:m=null,helperText:A,error:y,name:x="",defaultValue:b,onChange:w,InputProps:C={},wrapperSx:T={},...E}=e;const S=i(),I=u(S.breakpoints.down("sm")),P=u(S.breakpoints.between("sm","md")),[D,k]=ne(b),L=ae(!1);return oe((()=>{b&&!D&&k(`${b}`)}),[b]),a(g,{gap:.5,flex:1,sx:T,children:[m&&s(Da,{disableTooltip:!c&&!p,open:h,closeTooltip:d,placement:P?"bottom":I?"top":"right",maxWidth:P?498:I?310:"fit-content",title:s(ka,{children:p}),children:a(_,{display:"inline-flex",alignItems:"center",mb:1.25,children:[s(v,{variant:"h5",sx:{mr:1},children:m}),c&&!!p&&s(Ve,{color:"disabled",sx:{fontSize:19,mb:-.25}})]})}),s(za,{value:D,fullWidth:l,disabled:o,error:y,type:f,name:x,onChange:e=>{L.current=!0;let t=e.target.value;"number"===f&&t.length>1&&t.startsWith("0")&&(t=t.slice(1)),k(t),w?.(e)},InputProps:{...C,...!C.endAdornment&&n&&!!D&&{endAdornment:s(N,{position:"end",children:s(M,{size:"small",color:y?"error":"default",onClick:()=>{k(void 0),w?.({event:{target:{value:void 0}}})},children:s(je,{})})})},sx:{py:E?.multiline?1:.25,"&.MuiOutlinedInput-root":{fontFamily:"CircularStd, sans-serif !important"},"&.MuiInput-root:before":{borderBottomStyle:"solid",borderBottomColor:S.palette.text.primary},...C?.sx||{}}},sx:{minWidth:r,...E.sx},InputLabelProps:{sx:{"&.MuiInputLabel-root":{color:S.palette.text.primary},"&.Mui-focused":{color:S.palette.primary.main}}},...E,ref:t}),A&&s(La,{error:A})]})}));function Ba(e){let{name:t,label:r,disabled:i=!1,showTooltip:n=!1,openTooltip:o=!1,tooltipTitle:l,closeTooltip:c,width:u=300,placeholder:h="Please select",value:d,inputValue:p,onChange:f,toggleError:m,onNeedFetch:A,...g}=e;const _=ae(!1),[y,x]=ne(!1),[v,b]=ne(null),[w,C]=ne([]),[T,M]=ne(null),[S,I]=ne(""),[P,D]=ne(!1),[k,L]=ne(""),z=y&&!P,O=e=>{let{search:t="",loadedOptions:r=[]}=e;A({search:t,loadedOptions:r}).then((e=>{let{options:t}=e;C(t),D(!0)}))},B=ce(Os.debounce((e=>{let{search:t,loadedOptions:r}=e;O({search:t,loadedOptions:r})}),600),[]);return oe((()=>{z&&O({search:"",loadedOptions:[]})}),[z]),oe((()=>{"clear"===k&&D(!1),v||"selectOption"!==k||f&&f(T)}),[v,k,T]),oe((()=>{y||(C([]),D(!1))}),[y]),oe((()=>{d&&!T&&(M(d),I(p||""))}),[d,p]),oe((()=>{_.current&&(S&&T||(b("Please select a city from the list"),m&&m(!0)),S&&T&&(b(null),m&&m(!1)))}),[_.current,T,S]),s(U,{openOnFocus:!0,open:y,disabled:i,onOpen:()=>x(!0),onClose:()=>x(!1),isOptionEqualToValue:(e,t)=>Os.isEqual(e,t),onInputChange:(e,t,r)=>{e&&(L("input"!==r?Os.isString(r)?r:"selectOption":""),"change"===e.type&&B({search:t}),I(t),_.current=!0)},onChange:(e,t,r)=>{L(r),M(t)},value:T,options:w,loading:z,inputValue:S,componentsProps:{paper:{sx:{borderRadius:"20px"}}},sx:{width:["100%",u,u],"&.MuiAutocomplete-root .MuiFormControl-root .MuiInputBase-root":{height:50,fontSize:"16px !important",fontFamily:"CircularStd, sans-serif",flexWrap:"nowrap",overflow:"hidden"}},renderInput:e=>s(Oa,{...e,name:t,value:d||T||null,label:r,tooltipTitle:l,showTooltip:n,openTooltip:o,closeTooltip:c,error:!!v,helperText:v||null,placeholder:h,InputProps:{...e.InputProps,endAdornment:a(de,{children:[z?s(E,{color:"inherit",size:20}):null,e.InputProps.endAdornment]})}}),...g})}const Ra=e=>{let{sliderLabels:t,blocks:r,children:i}=e;return a(g,{pt:[1,2],gap:[0,.25],children:[s(H,{container:!0,alignItems:"center",sx:{width:"100%",overflow:"visible"},wrap:"nowrap",spacing:0,children:r.map((e=>s(H,{item:!0,sx:{flex:`${e.width} 1 auto`,mx:.1},children:s(_,{sx:{background:e.background,height:11,width:"100%"}})},e.background)))}),a(H,{container:!0,alignItems:"center",sx:{width:"100%",overflow:"visible",color:"#949FA5"},wrap:"nowrap",spacing:0,children:[r.map(((e,t)=>s(H,{item:!0,component:_,alignItems:"center",justifyContent:"center",mr:t>0?1:0,sx:{width:`${e.width}%`},children:s(v,{variant:"body2",color:"inherit",children:e.text})},t))),s(H,{item:!0,sx:{width:"1%",pr:2},children:s(v,{variant:"body2",color:"inherit",children:"0%"})})]}),s(H,{container:!0,spacing:0,flexWrap:"nowrap",justifyContent:"space-between",sx:{color:"#949FA5"},children:t.map(((e,t)=>s(H,{item:!0,sm:6,xs:3,children:s(v,{align:t>0?"right":"left",variant:"body2",color:"inherit",children:e})},e)))}),i&&s(H,{container:!0,spacing:0,sx:{color:"#949FA5",mt:1.5},children:s(H,{item:!0,xs:12,children:s(v,{component:_,align:"left",variant:"subtitle2",color:"inherit",children:i})})})]})},Fa=e=>{let{disableSlider:t=!1,sliderLabels:r,header:i,blocks:n,open:o,toggleOpen:l,children:c}=e;return a(_,{position:"absolute",sx:{py:1,px:1.75,top:0,left:0,...o&&{width:["100%",456],maxWidth:"100%","@media (max-width: 320px)":{height:"168px !important"}}},children:[s(_,{position:"absolute",sx:{py:1,px:1.75,top:0,left:0,display:o?"flex":"none",flexDirection:"column",justifyContent:"space-between",width:"100%",maxWidth:"100%"},children:s(G,{in:o,style:{transformOrigin:"0 0 0"},...o?{timeout:300}:{},children:a(_,{sx:{background:"white",py:[1,1.5],px:1.15,boxShadow:"0px 3px 20px 0px rgba(82, 78, 183, 0.08)",zIndex:2,width:"100%",borderRadius:"10px",overflow:"hidden"},children:[a(g,{direction:"row",alignItems:"flex-start",gap:1,position:"relative",children:[s(v,{variant:"subtitle2",sx:{maxWidth:"95%",color:"#2E3841"},children:i}),s(M,{sx:{position:"absolute",right:-8,top:[-8,-12]},onClick:()=>{l(!1)},children:s(Le,{sx:{fontSize:20}})})]}),t?c:s(Ra,{sliderLabels:r,blocks:n,children:c})]})})}),s(Z,{size:"medium",sx:{background:"white",zIndex:1},onClick:()=>{l(!0)},children:s(Ne,{})})]})},ja=e=>{let{children:t,item:r,centered:i,sx:n={}}=e;const o=c();return s(W,{sx:{display:"flex",alignItems:"center",justifyContent:i?"center":"flex-start",width:r?.minWidth??120,flexGrow:r?.growCoefficient??0,flexBasis:r?.minWidth??120,flexShrink:0,fontSize:16,[o.breakpoints.down("sm")]:{fontSize:14},...n},children:t})};function Va(e){let{rowHeight:t=44,getUniqueId:r,align:i="left",minWidth:n=295,columns:o=[],data:l=[]}=e;const h=c(),d=u(h.breakpoints.down("sm"));return s(Q,{component:q,variant:"outlined",sx:{borderRadius:"15px"},children:a(X,{sx:{minWidth:n},children:[s(Y,{sx:{background:"#E9EEF0"},children:s($,{sx:{height:d?(t??0)+10:t,display:"flex"},children:o.map(((e,t)=>s(ja,{align:i,item:e,children:s(v,{fontSize:[16,18,18],fontWeight:500,"aria-label":`${e?.title}`,children:e?.title})},e?.name+t)))})}),s(K,{children:l.map(((e,n)=>s($,{sx:{height:t,minHeight:40,display:"flex","&:last-child td, &:last-child th":{border:0}},children:o?.map(((t,r)=>{let{name:o,getValue:a,minWidth:l,growCoefficient:c,sx:u={}}=t;const d=a({...e,index:n});return s(ja,{align:i,item:{minWidth:l,growCoefficient:c},children:s(v,{noWrap:!0,"aria-label":`${d}`,sx:{color:d?h.palette.text.primary:h.palette.text.disabled,...u},children:d||"-"})},`${o||r}-${n}`)}))},r?r(e,n):n)))})]})})}const Na=e=>{let{pathname:t,children:r,theme:i}=e;return s(n,{injectFirst:!0,children:a(o,{theme:i,children:[s(J,{}),s(Ss,{pathname:t,children:s(Cs,{children:r})})]})})};export{Ft as AmenityButton,Fo as AmenityTags,xs as AreasForm,Ba as AsyncAutocomplete,jt as BaseLayout,Ct as BeachesIcon,St as BedIcon,$o as BedroomsForm,kt as BikeIcon,ts as BudgetForm,Tt as BusIcon,Dt as BusTagIcon,pt as Button,ms as COMMUTE_METHODS,Lt as CarIcon,yr as CardImage,_s as CommuteForm,Ot as CommuteIcon,ps as CommuteMethod,yt as CopyButton,Do as EmptyDefaultImage,Cs as ErrorBoundary,Rt as FilterButton,Pt as FiltersIcon,bs as FiltersModal,vs as FooterButtons,Mt as GymIcon,La as HelperText,wr as LazyLoadImage,as as LifestyleForm,Qo as ListHeader,ws as Loader,Ca as MapTags,Ia as MapWrapper,Es as ModalBase,ks as ModalContainer,Ds as ModalFooter,Ps as ModalHeader,Ms as ModalsContext,Ss as ModalsProvider,Nt as Onboarding,Ut as OnboardingStepLayout,vt as ParksIcon,Bt as PinIcon,Ma as Polygon,Fa as Popover,Vt as Powered,Xo as PropertiesList,Ho as PropertyCard,zo as PropertyTag,os as PropertyTypeForm,is as RentBuyForm,bt as RestaurantsIcon,wt as SchoolsIcon,It as SearchsmartlyLogo,Et as ShopIcon,ko as SlickCarousel,Ra as SliderChart,Ls as Snackbar,xt as StarIcon,Va as Table,Lo as Tag,Oa as TextField,Na as ThemeProvider,Da as Tooltip,ka as TooltipTitle,Ts as Transition,zt as WalkIcon,Oo as amenityTagConfig,No as currencyFormatterProperty,es as formatPrice,Ro as getAmenityTags,Vo as getBedroomsText,ds as getDestination,us as getFormattedTime,fs as iconsMap,hs as minuteFormatter,Go as pluralize,jo as renderPlural,Wo as scrollIntoView,Bo as thresholds,Zo as titleCase,At as useClipboardFallback,mt as useModal,Is as useModalProvider,_t as usePrevious,ft as useResponsive,gt as useWindowSize};
44
44
  //# sourceMappingURL=index.esm.js.map