/* Mapbox GL JS is Copyright © 2020 Mapbox and subject to the Mapbox Terms of Service ((https://www.mapbox.com/legal/tos/). */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.mapboxgl = factory()); })(this, (function () { 'use strict'; /* eslint-disable */ var shared, worker, mapboxgl; // define gets called three times: one for each chunk. we rely on the order // they're imported to know which is which function define(_, chunk) { if (!shared) { shared = chunk; } else if (!worker) { worker = chunk; } else { var workerBundleString = "self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; (" + shared + ")(sharedChunk); (" + worker + ")(sharedChunk); self.onerror = null;" var sharedChunk = {}; shared(sharedChunk); mapboxgl = chunk(sharedChunk); if (typeof window !== 'undefined' && window && window.URL && window.URL.createObjectURL) { mapboxgl.workerUrl = window.URL.createObjectURL(new Blob([workerBundleString], { type: 'text/javascript' })); } } } define(["exports"],function(e){var t=1e-6,r="undefined"!=typeof Float32Array?Float32Array:Array;function n(e,t){var r=t[0],n=t[1],i=t[2],s=t[3],o=r*s-i*n;return o?(e[0]=s*(o=1/o),e[1]=-n*o,e[2]=-i*o,e[3]=r*o,e):null}function i(){var e=new r(9);return r!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function s(e,t){var r=t[0],n=t[1],i=t[2],s=t[3],o=t[4],a=t[5],l=t[6],u=t[7],c=t[8];return e[0]=o*c-a*u,e[1]=i*u-n*c,e[2]=n*a-i*o,e[3]=a*l-s*c,e[4]=r*c-i*l,e[5]=i*s-r*a,e[6]=s*u-o*l,e[7]=n*l-r*u,e[8]=r*o-n*s,e}function o(e,t,r){var n=t[0],i=t[1],s=t[2],o=t[3],a=t[4],l=t[5],u=t[6],c=t[7],h=t[8],p=r[0],d=r[1],f=r[2],m=r[3],y=r[4],g=r[5],x=r[6],v=r[7],b=r[8];return e[0]=p*n+d*o+f*u,e[1]=p*i+d*a+f*c,e[2]=p*s+d*l+f*h,e[3]=m*n+y*o+g*u,e[4]=m*i+y*a+g*c,e[5]=m*s+y*l+g*h,e[6]=x*n+v*o+b*u,e[7]=x*i+v*a+b*c,e[8]=x*s+v*l+b*h,e}function a(){var e=new r(16);return r!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function l(e){var t=new r(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function u(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function c(e,t){var r=t[0],n=t[1],i=t[2],s=t[3],o=t[4],a=t[5],l=t[6],u=t[7],c=t[8],h=t[9],p=t[10],d=t[11],f=t[12],m=t[13],y=t[14],g=t[15],x=r*a-n*o,v=r*l-i*o,b=r*u-s*o,w=n*l-i*a,_=n*u-s*a,A=i*u-s*l,M=c*m-h*f,I=c*y-p*f,S=c*g-d*f,z=h*y-p*m,P=h*g-d*m,B=p*g-d*y,T=x*B-v*P+b*z+w*S-_*I+A*M;return T?(e[0]=(a*B-l*P+u*z)*(T=1/T),e[1]=(i*P-n*B-s*z)*T,e[2]=(m*A-y*_+g*w)*T,e[3]=(p*_-h*A-d*w)*T,e[4]=(l*S-o*B-u*I)*T,e[5]=(r*B-i*S+s*I)*T,e[6]=(y*b-f*A-g*v)*T,e[7]=(c*A-p*b+d*v)*T,e[8]=(o*P-a*S+u*M)*T,e[9]=(n*S-r*P-s*M)*T,e[10]=(f*_-m*b+g*x)*T,e[11]=(h*b-c*_-d*x)*T,e[12]=(a*I-o*z-l*M)*T,e[13]=(r*z-n*I+i*M)*T,e[14]=(m*v-f*w-y*x)*T,e[15]=(c*w-h*v+p*x)*T,e):null}function h(e,t,r){var n=t[0],i=t[1],s=t[2],o=t[3],a=t[4],l=t[5],u=t[6],c=t[7],h=t[8],p=t[9],d=t[10],f=t[11],m=t[12],y=t[13],g=t[14],x=t[15],v=r[0],b=r[1],w=r[2],_=r[3];return e[0]=v*n+b*a+w*h+_*m,e[1]=v*i+b*l+w*p+_*y,e[2]=v*s+b*u+w*d+_*g,e[3]=v*o+b*c+w*f+_*x,e[4]=(v=r[4])*n+(b=r[5])*a+(w=r[6])*h+(_=r[7])*m,e[5]=v*i+b*l+w*p+_*y,e[6]=v*s+b*u+w*d+_*g,e[7]=v*o+b*c+w*f+_*x,e[8]=(v=r[8])*n+(b=r[9])*a+(w=r[10])*h+(_=r[11])*m,e[9]=v*i+b*l+w*p+_*y,e[10]=v*s+b*u+w*d+_*g,e[11]=v*o+b*c+w*f+_*x,e[12]=(v=r[12])*n+(b=r[13])*a+(w=r[14])*h+(_=r[15])*m,e[13]=v*i+b*l+w*p+_*y,e[14]=v*s+b*u+w*d+_*g,e[15]=v*o+b*c+w*f+_*x,e}function p(e,t,r){var n,i,s,o,a,l,u,c,h,p,d,f,m=r[0],y=r[1],g=r[2];return t===e?(e[12]=t[0]*m+t[4]*y+t[8]*g+t[12],e[13]=t[1]*m+t[5]*y+t[9]*g+t[13],e[14]=t[2]*m+t[6]*y+t[10]*g+t[14],e[15]=t[3]*m+t[7]*y+t[11]*g+t[15]):(i=t[1],s=t[2],o=t[3],a=t[4],l=t[5],u=t[6],c=t[7],h=t[8],p=t[9],d=t[10],f=t[11],e[0]=n=t[0],e[1]=i,e[2]=s,e[3]=o,e[4]=a,e[5]=l,e[6]=u,e[7]=c,e[8]=h,e[9]=p,e[10]=d,e[11]=f,e[12]=n*m+a*y+h*g+t[12],e[13]=i*m+l*y+p*g+t[13],e[14]=s*m+u*y+d*g+t[14],e[15]=o*m+c*y+f*g+t[15]),e}function d(e,t,r){var n=r[0],i=r[1],s=r[2];return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*s,e[9]=t[9]*s,e[10]=t[10]*s,e[11]=t[11]*s,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function f(e,t,r){var n=Math.sin(r),i=Math.cos(r),s=t[4],o=t[5],a=t[6],l=t[7],u=t[8],c=t[9],h=t[10],p=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=s*i+u*n,e[5]=o*i+c*n,e[6]=a*i+h*n,e[7]=l*i+p*n,e[8]=u*i-s*n,e[9]=c*i-o*n,e[10]=h*i-a*n,e[11]=p*i-l*n,e}function m(e,t,r){var n=Math.sin(r),i=Math.cos(r),s=t[0],o=t[1],a=t[2],l=t[3],u=t[8],c=t[9],h=t[10],p=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=s*i-u*n,e[1]=o*i-c*n,e[2]=a*i-h*n,e[3]=l*i-p*n,e[8]=s*n+u*i,e[9]=o*n+c*i,e[10]=a*n+h*i,e[11]=l*n+p*i,e}function y(e,t,r){var n=Math.sin(r),i=Math.cos(r),s=t[0],o=t[1],a=t[2],l=t[3],u=t[4],c=t[5],h=t[6],p=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=s*i+u*n,e[1]=o*i+c*n,e[2]=a*i+h*n,e[3]=l*i+p*n,e[4]=u*i-s*n,e[5]=c*i-o*n,e[6]=h*i-a*n,e[7]=p*i-l*n,e}function g(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function x(e,r,n){var i,s,o,a=n[0],l=n[1],u=n[2],c=Math.sqrt(a*a+l*l+u*u);return c0&&(s=1/Math.sqrt(s)),e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e}function O(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function U(e,t,r){var n=t[0],i=t[1],s=t[2],o=r[0],a=r[1],l=r[2];return e[0]=i*l-s*a,e[1]=s*o-n*l,e[2]=n*a-i*o,e}function N(e,t,r,n){var i=t[0],s=t[1],o=t[2];return e[0]=i+n*(r[0]-i),e[1]=s+n*(r[1]-s),e[2]=o+n*(r[2]-o),e}function j(e,t,r){var n=t[0],i=t[1],s=t[2],o=r[3]*n+r[7]*i+r[11]*s+r[15];return e[0]=(r[0]*n+r[4]*i+r[8]*s+r[12])/(o=o||1),e[1]=(r[1]*n+r[5]*i+r[9]*s+r[13])/o,e[2]=(r[2]*n+r[6]*i+r[10]*s+r[14])/o,e}function G(e,t,r){var n=t[0],i=t[1],s=t[2];return e[0]=n*r[0]+i*r[3]+s*r[6],e[1]=n*r[1]+i*r[4]+s*r[7],e[2]=n*r[2]+i*r[5]+s*r[8],e}function $(e,t,r){var n=r[0],i=r[1],s=r[2],o=r[3],a=t[0],l=t[1],u=t[2],c=i*u-s*l,h=s*a-n*u,p=n*l-i*a;return e[0]=a+o*(c+=c)+i*(p+=p)-s*(h+=h),e[1]=l+o*h+s*c-n*p,e[2]=u+o*p+n*h-i*c,e}function q(e){return e[0]=0,e[1]=0,e[2]=0,e}function X(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}var H=P,Z=B,W=M;function Y(){var e=new r(4);return r!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function J(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e}function K(e,t){var r=t[0],n=t[1],i=t[2],s=t[3],o=r*r+n*n+i*i+s*s;return o>0&&(o=1/Math.sqrt(o)),e[0]=r*o,e[1]=n*o,e[2]=i*o,e[3]=s*o,e}function Q(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}function ee(e,t,r){var n=t[0],i=t[1],s=t[2],o=t[3];return e[0]=r[0]*n+r[4]*i+r[8]*s+r[12]*o,e[1]=r[1]*n+r[5]*i+r[9]*s+r[13]*o,e[2]=r[2]*n+r[6]*i+r[10]*s+r[14]*o,e[3]=r[3]*n+r[7]*i+r[11]*s+r[15]*o,e}function te(){var e=new r(4);return r!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function re(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function ne(e,t,r){r*=.5;var n=t[0],i=t[1],s=t[2],o=t[3],a=Math.sin(r),l=Math.cos(r);return e[0]=n*l+o*a,e[1]=i*l+s*a,e[2]=s*l-i*a,e[3]=o*l-n*a,e}function ie(e,t,r){r*=.5;var n=t[0],i=t[1],s=t[2],o=t[3],a=Math.sin(r),l=Math.cos(r);return e[0]=n*l-s*a,e[1]=i*l+o*a,e[2]=s*l+n*a,e[3]=o*l-i*a,e}_(),Y();var se,oe,ae,le=K,ue=(se=_(),oe=I(1,0,0),ae=I(0,1,0),function(e,t,r){var n=O(t,r);return n<-.999999?(U(se,oe,t),W(se)<1e-6&&U(se,ae,t),L(se,se),function(e,t,r){r*=.5;var n=Math.sin(r);e[0]=n*t[0],e[1]=n*t[1],e[2]=n*t[2],e[3]=Math.cos(r);}(e,se,Math.PI),e):n>.999999?(e[0]=0,e[1]=0,e[2]=0,e[3]=1,e):(U(se,t,r),e[0]=se[0],e[1]=se[1],e[2]=se[2],e[3]=1+n,le(e,e))});function ce(){var e=new r(2);return r!=Float32Array&&(e[0]=0,e[1]=0),e}function he(e,t){var n=new r(2);return n[0]=e,n[1]=t,n}function pe(e,t,r){return e[0]=t,e[1]=r,e}function de(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e}function fe(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e}function me(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e}function ye(e){var t=e[0],r=e[1];return Math.sqrt(t*t+r*r)}function ge(e,t){var r=t[0],n=t[1],i=r*r+n*n;return i>0&&(i=1/Math.sqrt(i)),e[0]=t[0]*i,e[1]=t[1]*i,e}function xe(e,t){return e[0]*t[0]+e[1]*t[1]}te(),te(),i();var ve,be,we=fe;function _e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}ce();var Ae=function(){if(be)return ve;function e(e,t,r,n){this.cx=3*e,this.bx=3*(r-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(n-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=t,this.p2x=r,this.p2y=n;}return be=1,ve=e,e.prototype={sampleCurveX:function(e){return ((this.ax*e+this.bx)*e+this.cx)*e},sampleCurveY:function(e){return ((this.ay*e+this.by)*e+this.cy)*e},sampleCurveDerivativeX:function(e){return (3*this.ax*e+2*this.bx)*e+this.cx},solveCurveX:function(e,t){if(void 0===t&&(t=1e-6),e<0)return 0;if(e>1)return 1;for(var r=e,n=0;n<8;n++){var i=this.sampleCurveX(r)-e;if(Math.abs(i)i?o=r:a=r,r=.5*(a-o)+o;return r},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}},ve}(),Me=_e(Ae);function Ie(e,t){this.x=e,this.y=t;}function Se(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return !1;for(let r=0;r=1)return 1;const t=e*e,r=t*e;return 4*(e<.5?r:3*(e-t)+r-.75)}function Ee(e,t,r,n){const i=new Me(e,t,r,n);return function(e){return i.solve(e)}}const Fe=Ee(.25,.1,.25,1);function De(e,t,r){return Math.min(r,Math.max(t,e))}function Ce(e,t,r){return (r=De((r-e)/(t-e),0,1))*r*(3-2*r)}function Re(e,t,r){const n=r-t,i=((e-t)%n+n)%n+t;return i===t?r:i}function Le(e,t,r){if(!e.length)return r(null,[]);let n=e.length;const i=new Array(e.length);let s=null;e.forEach((e,o)=>{t(e,(e,t)=>{e&&(s=e),i[o]=t,0===--n&&r(s,i);});});}let Oe=1;function Ue(){return Oe++}function Ne(e){return e<=1?1:Math.pow(2,Math.ceil(Math.log2(e)))}function je(e,t){e.forEach(e=>{t[e]&&(t[e]=t[e].bind(t));});}function Ge(e,t,r){const n={};for(const r in e)n[r]=t.call(this,e[r],r,e);return n}function $e(e,t,r){const n={};for(const r in e)t.call(this,e[r],r,e)&&(n[r]=e[r]);return n}function qe(e){return Array.isArray(e)?e.map(qe):"object"==typeof e&&e?Ge(e,qe):e}function Xe(e,t){for(let r=0;r=0)return !0;return !1}const He={};function Ze(e){He[e]||("undefined"!=typeof console&&console.warn(e),He[e]=!0);}function We(e,t,r){return (r.y-e.y)*(t.x-e.x)>(t.y-e.y)*(r.x-e.x)}function Ye(e){let t=0;for(let r,n,i=0,s=e.length,o=s-1;i@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(e,r,n,i)=>{const s=n||i;return t[r]=!s||s.toLowerCase(),""}),t["max-age"]){const e=parseInt(t["max-age"],10);isNaN(e)?delete t["max-age"]:t["max-age"]=e;}return t}let et=null;function tt(e,t){return [e[4*t],e[4*t+1],e[4*t+2],e[4*t+3]]}function rt(e,t,r,n){for(;t>1;e[i]>1;e[i]<=n?t=i+1:r=i;}return t}function it(e){return e>0?1/(1.001-e):1+e}function st(e){return e>0?1-1/(1.001-e):-e}function ot(e,t,r){return (e-t.min)*(r.max-r.min)/(t.max-t.min)+r.min}const at={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){return /^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i},get API_TILEJSON_REGEX(){return /^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/v[0-9]*\/.*\.json.*$)/i},get API_SPRITE_REGEX(){return /^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*\/sprite.*\..*$)/i},get API_FONTS_REGEX(){return /^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/fonts\/v[0-9]*\/)(.*\.pbf.*$)/i},get API_STYLE_REGEX(){return /^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*$)/i},get API_CDN_URL_REGEX(){return /^((https?:)?\/\/)?api\.mapbox\.c(n|om)(\/mapbox-gl-js\/)(.*$)/i},get EVENTS_URL(){if(!at.API_URL)return null;try{const e=new URL(at.API_URL);return "api.mapbox.cn"===e.hostname?"https://events.mapbox.cn/events/v2":"api.mapbox.com"===e.hostname?"https://events.mapbox.com/events/v2":null}catch(e){return null}},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",RASTERARRAYS_URL_PREFIX:"rasterarrays/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,DEFAULT_STYLE:"mapbox://styles/mapbox/standard",MAX_PARALLEL_IMAGE_REQUESTS:16,DRACO_URL:"https://api.mapbox.com/mapbox-gl-js/draco_decoder_gltf_v1.5.6.wasm",MESHOPT_URL:"https://api.mapbox.com/mapbox-gl-js/meshopt_base_v0.20.wasm",MESHOPT_SIMD_URL:"https://api.mapbox.com/mapbox-gl-js/meshopt_simd_v0.20.wasm",BUILDING_GEN_URL:"https://api.mapbox.com/mapbox-gl-js/building-gen/building_gen_v1.2.4.wasm",GLYPHS_URL:"mapbox://fonts/mapbox/{fontstack}/{range}.pbf",TILES3D_URL_PREFIX:"3dtiles/v1"};function lt(e){return at.API_URL_REGEX.test(e)}function ut(e){return at.API_SPRITE_REGEX.test(e)}let ct,ht,pt,dt,ft,mt;function yt(){return null==ct&&(ct=self.OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof self.createImageBitmap),ct}const gt={now:()=>void 0!==dt?dt:performance.now(),setNow(e){dt=e;},restoreNow(){dt=void 0;},frame(e){const t=requestAnimationFrame(e);return {cancel:()=>cancelAnimationFrame(t)}},getImageData(e,t=0){const{width:r,height:n}=e;ft||(ft=document.createElement("canvas"));const i=ft.getContext("2d",{willReadFrequently:!0});if(!i)throw new Error("failed to create canvas 2d context");return (r>ft.width||n>ft.height)&&(ft.width=r,ft.height=n),i.clearRect(-t,-t,r+2*t,n+2*t),i.drawImage(e,0,0,r,n),i.getImageData(-t,-t,r+2*t,n+2*t)},resolveURL:e=>(ht||(ht=document.createElement("a")),ht.href=e,ht.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return !!window.matchMedia&&(null==pt&&(pt=window.matchMedia("(prefers-reduced-motion: reduce)")),pt.matches)},hasCanvasFingerprintNoise(){if(void 0!==mt)return mt;if(!yt())return mt=!1,!1;const e=new OffscreenCanvas(85,1),t=e.getContext("2d",{willReadFrequently:!0});let r=0;for(let n=0;n0?`?${s}`:""}`}const bt="mapbox-tiles";let wt=500,_t=50;const At=["language","worldview","jobid"];let Mt;function It(){try{return caches}catch(e){}}function St(){const e=It();e&&null==Mt&&(Mt=e.open(bt));}let zt=1/0;const Pt={supported:!1,testSupport:function(e){!kt&&Tt&&(Vt?Ft(e):Bt=e);}};let Bt,Tt,kt=!1,Vt=!1;const Et="undefined"!=typeof self?self:{};function Ft(e){const t=e.createTexture();e.bindTexture(e.TEXTURE_2D,t);try{if(e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,Tt),e.isContextLost())return;Pt.supported=!0;}catch(e){}e.deleteTexture(t),kt=!0;}Et.document&&(Tt=Et.document.createElement("img"),Tt.onload=function(){Bt&&Ft(Bt),Bt=null,Vt=!0;},Tt.onerror=function(){kt=!0,Bt=null;},Tt.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const Dt={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Iconset:"Iconset",Image:"Image",Model:"Model"};Object.freeze(Dt);class Ct extends Error{constructor(e,t,r){401===t&<(r)&&(e+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),super(e),this.status=t,this.url=r;}toString(){return `${this.name}: ${this.message} (${this.status}): ${this.url}`}}const Rt=Ke()?()=>self.worker.referrer:()=>("blob:"===location.protocol?parent:self).location.href;const Lt=function(e,t){return /^file:/.test(r=e.url)||/^file:/.test(Rt())&&!/^\w+:/.test(r)?function(e,t){const r=new XMLHttpRequest;r.open(e.method||"GET",e.url,!0),"arrayBuffer"===e.type&&(r.responseType="arraybuffer");for(const t in e.headers)r.setRequestHeader(t,e.headers[t]);return "json"===e.type&&(r.responseType="text",r.setRequestHeader("Accept","application/json")),r.withCredentials="include"===e.credentials,r.onerror=()=>{t(new Error(r.statusText));},r.onload=()=>{if((r.status>=200&&r.status<300||0===r.status)&&null!==r.response){let n=r.response;if("json"===e.type)try{n=JSON.parse(r.response);}catch(e){return t(e)}const i=new Headers;r.getAllResponseHeaders().trim().split(/[\r\n]+/).forEach(e=>{const t=e.split(": "),r=t.shift(),n=t.join(": ");i.append(r,n);}),t(null,n,i);}else t(new Ct(r.statusText,r.status,e.url));},r.send(e.body),{cancel:()=>r.abort()}}(e,t):function(e,t){const r=new AbortController,n=new Request(e.url,{method:e.method||"GET",body:e.body,credentials:e.credentials,headers:e.headers,referrer:Rt(),referrerPolicy:e.referrerPolicy,signal:r.signal});let i=!1,s=!1;const o=(a=n.url).indexOf("sku=")>0&<(a);var a;"json"===e.type&&n.headers.set("Accept","application/json");const l=(r,i,a)=>{if(s)return;if(r&&"SecurityError"!==r.message&&Ze(r.toString()),i&&a)return u(i);const l=Date.now();fetch(n).then(r=>{if(r.ok){const e=o?r.clone():null;return u(r,e,l)}return t(new Ct(r.statusText,r.status,e.url))}).catch(r=>{"AbortError"!==r.name&&t(new Error(`${r.message} ${e.url}`));});},u=(r,o,a)=>{("arrayBuffer"===e.type?r.arrayBuffer():"json"===e.type?r.json():r.text()).then(e=>{s||(o&&a&&function(e,t,r){if(St(),null==Mt)return;const n=Qe(t.headers.get("cache-control")||"");if(n["no-store"])return;const i={status:t.status,statusText:t.statusText,headers:new Headers};t.headers.forEach((e,t)=>i.headers.set(t,e)),n["max-age"]&&i.headers.set("Expires",new Date(r+1e3*n["max-age"]).toUTCString());const s=i.headers.get("expires");if(!s)return;if(new Date(s).getTime()-r<42e4)return;let o=vt(e.url,{persistentParams:At});if(206===t.status){const t=e.headers.get("Range");if(!t)return;i.status=200,o=xt(o,{range:t});}const a=new Response(200!==(l=t.status)&&404!==l&&[101,103,204,205,304].includes(l)?null:t.body,i);var l;St(),null!=Mt&&Mt.then(e=>e.put(o,a)).catch(e=>Ze(e.message));}(n,o,a),i=!0,t(null,e,r.headers));}).catch(e=>{s||t(new Error(e.message));});};return o?function(e,t){if(St(),null==Mt)return t(null);Mt.then(r=>{let n=vt(e.url,{persistentParams:At});const i=e.headers.get("Range");i&&(n=xt(n,{range:i})),r.match(n).then(e=>{const i=function(e){if(!e)return !1;const t=new Date(e.headers.get("expires")||0),r=Qe(e.headers.get("cache-control")||"");return Number(t)>Date.now()&&!r["no-cache"]}(e);r.delete(n).catch(t),i&&r.put(n,e.clone()).catch(t),t(null,e,i);}).catch(t);}).catch(t);}(n,l):l(null,null),{cancel:()=>{s=!0,i||r.abort();}}}(e,t);var r;},Ot=function(e,t){return Lt(Object.assign(e,{type:"arrayBuffer"}),t)};function Ut(e){const t=document.createElement("a");return t.href=e,t.protocol===location.protocol&&t.host===location.host}let Nt,jt;Nt=[],jt=0;const Gt=function(e,t){if(Pt.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),jt>=at.MAX_PARALLEL_IMAGE_REQUESTS){const r={requestParameters:e,callback:t,cancelled:!1,cancel(){this.cancelled=!0;}};return Nt.push(r),r}jt++;let r=!1;const n=()=>{if(!r)for(r=!0,jt--;Nt.length&&jt{n(),e?t(e):r&&function(e,t){const r=new Blob([new Uint8Array(e)],{type:"image/png"});createImageBitmap(r).then(e=>{t(null,e);}).catch(e=>{t(new Error(`Could not load image because of ${e.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`));});}(r,(e,r)=>t(e,r,i));});return {cancel:()=>{i.cancel(),n();}}};var $t,qt,Xt,Ht={exports:{}},Zt={exports:{}},Wt={exports:{}},Yt=function(){if(Xt)return Ht.exports;Xt=1;var e=($t||($t=1,Zt.exports=function(e,t){var r,n,i,s,o,a,l,u;for(n=e.length-(r=3&e.length),i=t,o=3432918353,a=461845907,u=0;u>>16)*o&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<13|i>>>19))+((5*(i>>>16)&65535)<<16)&4294967295))+(((s>>>16)+58964&65535)<<16);switch(l=0,r){case 3:l^=(255&e.charCodeAt(u+2))<<16;case 2:l^=(255&e.charCodeAt(u+1))<<8;case 1:i^=l=(65535&(l=(l=(65535&(l^=255&e.charCodeAt(u)))*o+(((l>>>16)*o&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295;}return i^=e.length,i=2246822507*(65535&(i^=i>>>16))+((2246822507*(i>>>16)&65535)<<16)&4294967295,i=3266489909*(65535&(i^=i>>>13))+((3266489909*(i>>>16)&65535)<<16)&4294967295,(i^=i>>>16)>>>0}),Zt.exports),t=(qt||(qt=1,Wt.exports=function(e,t){for(var r,n=e.length,i=t^n,s=0;n>=4;)r=1540483477*(65535&(r=255&e.charCodeAt(s)|(255&e.charCodeAt(++s))<<8|(255&e.charCodeAt(++s))<<16|(255&e.charCodeAt(++s))<<24))+((1540483477*(r>>>16)&65535)<<16),i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16)^(r=1540483477*(65535&(r^=r>>>24))+((1540483477*(r>>>16)&65535)<<16)),n-=4,++s;switch(n){case 3:i^=(255&e.charCodeAt(s+2))<<16;case 2:i^=(255&e.charCodeAt(s+1))<<8;case 1:i=1540483477*(65535&(i^=255&e.charCodeAt(s)))+((1540483477*(i>>>16)&65535)<<16);}return i=1540483477*(65535&(i^=i>>>13))+((1540483477*(i>>>16)&65535)<<16),(i^=i>>>15)>>>0}),Wt.exports);return Ht.exports=e,Ht.exports.murmur3=e,Ht.exports.murmur2=t,Ht.exports}(),Jt=_e(Yt);class Kt{constructor(e,...t){Object.assign(this,t[0]||{}),this.type=e;}}class Qt extends Kt{constructor(e,t={}){super("error",Object.assign({error:e},t));}}function er(e,t,r){r[e]&&-1!==r[e].indexOf(t)||(r[e]=r[e]||[],r[e].push(t));}function tr(e,t,r){if(r&&r[e]){const n=r[e].indexOf(t);-1!==n&&r[e].splice(n,1);}}class rr{on(e,t){return this._listeners=this._listeners||{},er(e,t,this._listeners),this}off(e,t){return tr(e,t,this._listeners),tr(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners=this._oneTimeListeners||{},er(e,t,this._oneTimeListeners),this):new Promise(t=>{this.once(e,t);})}fire(e,t){const r="string"==typeof e?new Kt(e,t):e,n=r.type;if(this.listens(n)){r.target=this;const e=this._listeners&&this._listeners[n]?this._listeners[n].slice():[];for(const t of e)t.call(this,r);const t=this._oneTimeListeners&&this._oneTimeListeners[n]?this._oneTimeListeners[n].slice():[];for(const e of t)tr(n,e,this._oneTimeListeners),e.call(this,r);const i=this._eventedParent;if(i){const e="function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData;Object.assign(r,e),i.fire(r);}}else r instanceof Qt&&console.error(r.error);return this}listens(e){return !!(this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e))}setEventedParent(e,t){return this._eventedParent=e,this._eventedParentData=t,this}}class nr{constructor(e){"string"==typeof e?this.name=e:(this.name=e.name,this.iconsetId=e.iconsetId);}static from(e){return new nr(e)}static toString(e){return e.iconsetId?`${e.name}${e.iconsetId}`:e.name}static parse(e){const[t,r]=e.split("");return new nr({name:t,iconsetId:r})}static isEqual(e,t){return e.name===t.name&&e.iconsetId===t.iconsetId}toString(){return nr.toString(this)}serialize(){return {name:this.name,iconsetId:this.iconsetId}}}var ir,sr={},or=function(){if(ir)return sr;ir=1;var e={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function t(e){return (e=Math.round(e))<0?0:e>255?255:e}function r(e){return t("%"===e[e.length-1]?parseFloat(e)/100*255:parseInt(e))}function n(e){return (t="%"===e[e.length-1]?parseFloat(e)/100:parseFloat(e))<0?0:t>1?1:t;var t;}function i(e,t,r){return r<0?r+=1:r>1&&(r-=1),6*r<1?e+(t-e)*r*6:2*r<1?t:3*r<2?e+(t-e)*(2/3-r)*6:e}try{sr.parseCSSColor=function(s){var o,a=s.replace(/ /g,"").toLowerCase();if(a in e)return e[a].slice();if("#"===a[0])return 4===a.length?(o=parseInt(a.substr(1),16))>=0&&o<=4095?[(3840&o)>>4|(3840&o)>>8,240&o|(240&o)>>4,15&o|(15&o)<<4,1]:null:7===a.length&&(o=parseInt(a.substr(1),16))>=0&&o<=16777215?[(16711680&o)>>16,(65280&o)>>8,255&o,1]:null;var l=a.indexOf("("),u=a.indexOf(")");if(-1!==l&&u+1===a.length){var c=a.substr(0,l),h=a.substr(l+1,u-(l+1)).split(","),p=1;switch(c){case "rgba":if(4!==h.length)return null;p=n(h.pop());case "rgb":return 3!==h.length?null:[r(h[0]),r(h[1]),r(h[2]),p];case "hsla":if(4!==h.length)return null;p=n(h.pop());case "hsl":if(3!==h.length)return null;var d=(parseFloat(h[0])%360+360)%360/360,f=n(h[1]),m=n(h[2]),y=m<=.5?m*(f+1):m+f-m*f,g=2*m-y;return [t(255*i(g,y,d+1/3)),t(255*i(g,y,d)),t(255*i(g,y,d-1/3)),p];default:return null}}return null};}catch(e){}return sr}();class ar{constructor(e,t,r,n=1){this.r=e,this.g=t,this.b=r,this.a=n;}static parse(e){if(!e)return;if(e instanceof ar)return e;if("string"!=typeof e)return;const t=or.parseCSSColor(e);return t?new ar(t[0]/255,t[1]/255,t[2]/255,t[3]):void 0}toString(){const[e,t,r,n]=[this.r,this.g,this.b,this.a];return `rgba(${Math.round(255*e)},${Math.round(255*t)},${Math.round(255*r)},${n})`}toNonPremultipliedRenderColor(e){const{r:t,g:r,b:n,a:i}=this;return new ur(e,t,r,n,i)}toPremultipliedRenderColor(e){const{r:t,g:r,b:n,a:i}=this;return new cr(e,t*i,r*i,n*i,i)}clone(){return new ar(this.r,this.g,this.b,this.a)}}class lr{constructor(e,t,r,n,i,s=!1){if(this.premultiplied=!1,this.premultiplied=s,e){const s=e.image.height,o=s*s;this.premultiplied?(t=0===i?0:t/i*(s-1),r=0===i?0:r/i*(s-1),n=0===i?0:n/i*(s-1)):(t*=s-1,r*=s-1,n*=s-1),t=Math.max(0,Math.min(s-1,t)),r=Math.max(0,Math.min(s-1,r)),n=Math.max(0,Math.min(s-1,n));const a=Math.floor(t),l=Math.floor(r),u=Math.floor(n),c=Math.ceil(t),h=Math.ceil(r),p=Math.ceil(n),d=t-a,f=r-l,m=n-u,y=e.image.data,g=4*(a+l*o+u*s),x=4*(a+l*o+p*s),v=4*(a+h*o+u*s),b=4*(a+h*o+p*s),w=4*(c+l*o+u*s),_=4*(c+l*o+p*s),A=4*(c+h*o+u*s),M=4*(c+h*o+p*s);this.r=hr(hr(hr(y[g],y[x],m),hr(y[v],y[b],m),f),hr(hr(y[w],y[_],m),hr(y[A],y[M],m),f),d)/255*(this.premultiplied?i:1),this.g=hr(hr(hr(y[g+1],y[x+1],m),hr(y[v+1],y[b+1],m),f),hr(hr(y[w+1],y[_+1],m),hr(y[A+1],y[M+1],m),f),d)/255*(this.premultiplied?i:1),this.b=hr(hr(hr(y[g+2],y[x+2],m),hr(y[v+2],y[b+2],m),f),hr(hr(y[w+2],y[_+2],m),hr(y[A+2],y[M+2],m),f),d)/255*(this.premultiplied?i:1),this.a=i;}else this.r=t,this.g=r,this.b=n,this.a=i;}toArray(){const{r:e,g:t,b:r,a:n}=this;return [255*e,255*t,255*r,n]}toHslaArray(){let{r:e,g:t,b:r,a:n}=this;if(this.premultiplied){if(0===n)return [0,0,0,0];const i=1/n;e*=i,t*=i,r*=i;}const i=Math.min(Math.max(e,0),1),s=Math.min(Math.max(t,0),1),o=Math.min(Math.max(r,0),1),a=Math.min(i,s,o),l=Math.max(i,s,o),u=l-a,c=.5*(a+l);if(0===u)return [0,0,100*c,n];const h=c>.5?u/(2-l-a):u/(l+a);let p;switch(l){case i:p=60*((s-o)/u+(shr(e,t[n],r))}ar.black=new ar(0,0,0,1),ar.white=new ar(1,1,1,1),ar.transparent=new ar(0,0,0,0),ar.red=new ar(1,0,0,1),ar.blue=new ar(0,0,1,1);var dr=Object.freeze({__proto__:null,array:pr,color:function(e,t,r){return new ar(hr(e.r,t.r,r),hr(e.g,t.g,r),hr(e.b,t.b,r),hr(e.a,t.a,r))},number:hr});class fr extends Error{constructor(e,t){super(t),this.message=t,this.key=e;}}class mr{constructor(e,t=[]){this.parent=e,this.bindings={};for(const[e,r]of t)this.bindings[e]=r;}concat(e){return new mr(this,e)}get(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw new Error(`${e} not found in scope.`)}has(e){return !!this.bindings[e]||!!this.parent&&this.parent.has(e)}}const yr={kind:"null"},gr={kind:"number"},xr={kind:"string"},vr={kind:"boolean"},br={kind:"color"},wr={kind:"object"},_r={kind:"value"},Ar={kind:"collator"},Mr={kind:"formatted"},Ir={kind:"resolvedImage"};function Sr(e,t){return {kind:"array",itemType:e,N:t}}function zr(e){if("array"===e.kind){const t=zr(e.itemType);return "number"==typeof e.N?`array<${t}, ${e.N}>`:"value"===e.itemType.kind?"array":`array<${t}>`}return e.kind}const Pr=[yr,gr,xr,vr,br,Mr,wr,Sr(_r),Ir];function Br(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!Br(e.itemType,t.itemType))&&("number"!=typeof e.N||e.N===t.N))return null}else {if(e.kind===t.kind)return null;if("value"===e.kind)for(const e of Pr)if(!Br(e,t))return null}return `Expected ${zr(e)} but found ${zr(t)} instead.`}function Tr(e,t){return t.some(t=>t.kind===e.kind)}function kr(e,t){return t.some(t=>"null"===t?null===e:"array"===t?Array.isArray(e):"object"===t?e&&!Array.isArray(e)&&"object"==typeof e:t===typeof e)}function Vr(e,t){return "array"===e.kind&&"array"===t.kind?e.N===t.N&&Vr(e.itemType,t.itemType):e.kind===t.kind}class Er{constructor(e,t,r){this.sensitivity=e?t?"variant":"case":t?"accent":"base",this.locale=r,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"});}compare(e,t){return this.collator.compare(e,t)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class Fr{constructor(e,t,r,n,i){this.text=e.normalize?e.normalize():e,this.image=t,this.scale=r,this.fontStack=n,this.textColor=i;}}class Dr{constructor(e){this.sections=e;}static fromString(e){return new Dr([new Fr(e,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some(e=>0!==e.text.length||!!e.image&&e.image.hasPrimary())}static factory(e){return e instanceof Dr?e:Dr.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map(e=>e.text).join("")}serialize(){const e=["format"];for(const t of this.sections){if(t.image){const r=t.image.getPrimary().id.toString();e.push(["image",r]);continue}e.push(t.text);const r={};t.fontStack&&(r["text-font"]=["literal",t.fontStack.split(",")]),t.scale&&(r["font-scale"]=t.scale),t.textColor&&(r["text-color"]=["rgba"].concat(t.textColor.toNonPremultipliedRenderColor(null).toArray())),e.push(r);}return e}}class Cr{constructor(e,t={}){this.id=nr.from(e),this.params=t.params,this.sx=t.sx||1,this.sy=t.sy||1;}toString(){return JSON.stringify(this)}static parse(e){let t,r,n,i;try{({id:t,params:r,sx:n,sy:i}=JSON.parse(e)||{});}catch(e){return null}return t?new Cr(t,{params:r,sx:n,sy:i}):null}scaleSelf(e,t=e){return this.sx*=e,this.sy*=t,this}}class Rr{constructor(e,t,r,n,i=!1){this.primaryId=nr.from(e),this.primaryOptions=t,r&&(this.secondaryId=nr.from(r)),this.secondaryOptions=n,this.available=i;}toString(){return this.primaryId&&this.secondaryId?`[${this.primaryId.name},${this.secondaryId.name}]`:this.primaryId.name}hasPrimary(){return !!this.primaryId}getPrimary(){return new Cr(this.primaryId,this.primaryOptions)}hasSecondary(){return !!this.secondaryId}getSecondary(){return this.secondaryId?new Cr(this.secondaryId,this.secondaryOptions):null}static from(e){return "string"==typeof e?Rr.build({name:e}):e}static build(e,t,r,n){return !e||"object"==typeof e&&!("name"in e)?null:new Rr(e,r,t,n)}}function Lr(e,t,r,n){return "number"==typeof e&&e>=0&&e<=255&&"number"==typeof t&&t>=0&&t<=255&&"number"==typeof r&&r>=0&&r<=255?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid rgba value [${[e,t,r,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof n?[e,t,r,n]:[e,t,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Or(e){if(null===e)return !0;if("string"==typeof e)return !0;if("boolean"==typeof e)return !0;if("number"==typeof e)return !0;if(e instanceof ar)return !0;if(e instanceof Er)return !0;if(e instanceof Dr)return !0;if(e instanceof Rr)return !0;if(Array.isArray(e)){for(const t of e)if(!Or(t))return !1;return !0}if("object"==typeof e){for(const t in e)if(!Or(e[t]))return !1;return !0}return !1}function Ur(e){if(null===e)return yr;if("string"==typeof e)return xr;if("boolean"==typeof e)return vr;if("number"==typeof e)return gr;if(e instanceof ar)return br;if(e instanceof Er)return Ar;if(e instanceof Dr)return Mr;if(e instanceof Rr)return Ir;if(Array.isArray(e)){const t=e.length;let r;for(const t of e){const e=Ur(t);if(r){if(r===e)continue;r=_r;break}r=e;}return Sr(r||_r,t)}return wr}function Nr(e){const t=typeof e;return null===e?"":"string"===t||"number"===t||"boolean"===t?String(e):e instanceof Dr||e instanceof Rr||e instanceof ar?e.toString():JSON.stringify(e)}class jr{constructor(e,t){this.type=e,this.value=t;}static parse(e,t){if(2!==e.length)return t.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!Or(e[1]))return t.error("invalid value");const r=e[1];let n=Ur(r);const i=t.expectedType;return "array"!==n.kind||0!==n.N||!i||"array"!==i.kind||"number"==typeof i.N&&0!==i.N||(n=i),new jr(n,r)}evaluate(){return this.value}eachChild(){}outputDefined(){return !0}serialize(){return "array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof ar?["rgba"].concat(this.value.toNonPremultipliedRenderColor(null).toArray()):this.value instanceof Dr?this.value.serialize():this.value}}class Gr{constructor(e){this.name="ExpressionEvaluationError",this.message=e;}toJSON(){return this.message}}const $r={string:xr,number:gr,boolean:vr,object:wr};class qr{constructor(e,t){this.type=e,this.args=t;}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");let r,n=1;const i=e[0];if("array"===i){let i,s;if(e.length>2){const r=e[1];if("string"!=typeof r||!(r in $r)||"object"===r)return t.error('The item type argument of "array" must be one of string, number, boolean',1);i=$r[r],n++;}else i=_r;if(e.length>3){if(null!==e[2]&&("number"!=typeof e[2]||e[2]<0||e[2]!==Math.floor(e[2])))return t.error('The length argument to "array" must be a positive integer literal',2);s=e[2],n++;}r=Sr(i,s);}else r=$r[i];const s=[];for(;ne.outputDefined())}serialize(){const e=this.type,t=[e.kind];if("array"===e.kind){const r=e.itemType;if("string"===r.kind||"number"===r.kind||"boolean"===r.kind){t.push(r.kind);const n=e.N;("number"==typeof n||this.args.length>1)&&t.push(n);}}return t.concat(this.args.map(e=>e.serialize()))}}class Xr{constructor(e){this.type=Mr,this.sections=e;}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const r=e[1];if(!Array.isArray(r)&&"object"==typeof r)return t.error("First argument must be an image or text section.");const n=[];let i=!1;for(let r=1;r<=e.length-1;++r){const s=e[r];if(i&&"object"==typeof s&&!Array.isArray(s)){i=!1;let e=null;if(s["font-scale"]&&(e=t.parseObjectValue(s["font-scale"],r,"font-scale",gr),!e))return null;let o=null;if(s["text-font"]&&(o=t.parseObjectValue(s["text-font"],r,"text-font",Sr(xr)),!o))return null;let a=null;if(s["text-color"]&&(a=t.parseObjectValue(s["text-color"],r,"text-color",br),!a))return null;const l=n[n.length-1];l.scale=e,l.font=o,l.textColor=a;}else {const s=t.parse(e[r],r,_r);if(!s)return null;const o=s.type.kind;if("string"!==o&&"value"!==o&&"null"!==o&&"resolvedImage"!==o)return t.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");i=!0,n.push({content:s,scale:null,font:null,textColor:null});}}return new Xr(n)}evaluate(e){return new Dr(this.sections.map(t=>{const r=t.content.evaluate(e);return Vr(Ur(r),Ir)?new Fr("",r,null,null,null):new Fr(Nr(r),null,t.scale?t.scale.evaluate(e):null,t.font?t.font.evaluate(e).join(","):null,t.textColor?t.textColor.evaluate(e):null)}))}eachChild(e){for(const t of this.sections)e(t.content),t.scale&&e(t.scale),t.font&&e(t.font),t.textColor&&e(t.textColor);}outputDefined(){return !1}serialize(){const e=["format"];for(const t of this.sections){e.push(t.content.serialize());const r={};t.scale&&(r["font-scale"]=t.scale.serialize()),t.font&&(r["text-font"]=t.font.serialize()),t.textColor&&(r["text-color"]=t.textColor.serialize()),e.push(r);}return e}}class Hr{constructor(e,t,r,n){this._imageWarnHistory={},this.type=Ir,this.namePrimary=e,this.nameSecondary=t,r&&(this.paramsPrimary=r.params,this.iconsetIdPrimary=r.iconset?r.iconset.id:void 0),n&&(this.paramsSecondary=n.params,this.iconsetIdSecondary=n.iconset?n.iconset.id:void 0);}static parse(e,t){if(e.length<2)return t.error("Expected two or more arguments.");let r=1;const n=[];function i(){if(rnr.isEqual(e,t)),n.available){const t=n.getSecondary()?n.getSecondary().id:null;t&&(n.available=e.availableImages.some(e=>nr.isEqual(e,t)));}}return n}eachChild(e){if(e(this.namePrimary),this.paramsPrimary)for(const t in this.paramsPrimary)this.paramsPrimary[t]&&e(this.paramsPrimary[t]);if(this.nameSecondary&&(e(this.nameSecondary),this.paramsSecondary))for(const t in this.paramsSecondary)this.paramsSecondary[t]&&e(this.paramsSecondary[t]);}outputDefined(){return !1}serializeOptions(e,t){const r={};if(t&&(r.iconset={id:t}),e){r.params={};for(const t in e)e[t]&&(r.params[t]=e[t].serialize());}return Object.keys(r).length>0?r:void 0}serialize(){const e=["image",this.namePrimary.serialize()];if(this.paramsPrimary||this.iconsetIdPrimary){const t=this.serializeOptions(this.paramsPrimary,this.iconsetIdPrimary);t&&e.push(t);}if(this.nameSecondary&&(e.push(this.nameSecondary.serialize()),this.paramsSecondary||this.iconsetIdSecondary)){const t=this.serializeOptions(this.paramsSecondary,this.iconsetIdSecondary);t&&e.push(t);}return e}}function Zr(e){return Yr(e)?"string":Jr(e)?"number":Kr(e)?"boolean":Array.isArray(e)?"array":null===e?"null":Wr(e)?"object":typeof e}function Wr(e){return null!=e&&!Array.isArray(e)&&"function"!=typeof e&&!(e instanceof String||e instanceof Number||e instanceof Boolean)&&"object"==typeof e}function Yr(e){return "string"==typeof e||e instanceof String}function Jr(e){return "number"==typeof e||e instanceof Number}function Kr(e){return "boolean"==typeof e||e instanceof Boolean}const Qr={"to-boolean":vr,"to-color":br,"to-number":gr,"to-string":xr};class en{constructor(e,t){this.type=e,this.args=t;}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const r=e[0],n=[];let i=yr;if("to-array"===r){if(!Array.isArray(e[1]))return null;const r=e[1].length;if(t.expectedType){if("array"!==t.expectedType.kind)return t.error(`Expected ${t.expectedType.kind} but found array.`);i=Sr(t.expectedType.itemType,r);}else {if(!(r>0&&Or(e[1][0])))return null;i=Sr(Ur(e[1][0]),r);}for(let s=0;s4?`Invalid rbga value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:Lr(t[0],t[1],t[2],t[3]),!r))return new ar(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new Gr(r||`Could not parse color from value '${"string"==typeof t?t:String(JSON.stringify(t))}'`)}if("number"===this.type.kind){let t=null;for(const r of this.args){if(t=r.evaluate(e),null===t)return 0;const n=Number(t);if(!isNaN(n))return n}throw new Gr(`Could not convert ${JSON.stringify(t)} to number.`)}return "formatted"===this.type.kind?Dr.fromString(Nr(this.args[0].evaluate(e))):"resolvedImage"===this.type.kind?Rr.build(Nr(this.args[0].evaluate(e))):"array"===this.type.kind?this.args.map(t=>t.evaluate(e)):Nr(this.args[0].evaluate(e))}eachChild(e){this.args.forEach(e);}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){if("formatted"===this.type.kind)return new Xr([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new Hr(this.args[0]).serialize();const e="array"===this.type.kind?[]:[`to-${this.type.kind}`];return this.eachChild(t=>{e.push(t.serialize());}),e}}const tn=["Unknown","Point","LineString","Polygon"];class rn{constructor(e,t,r){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null,this.scope=e,this.options=t,this.iconImageUseTheme=r;}id(){return this.feature&&void 0!==this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?tn[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}measureLight(e){return this.globals.brightness||0}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const e=this.featureDistanceData.center,t=this.featureDistanceData.scale,{x:r,y:n}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(r*t-e[0])+this.featureDistanceData.bearing[1]*(n*t-e[1])}return 0}parseColor(e){let t=this._parseColorCache[e];return t||(t=this._parseColorCache[e]=ar.parse(e)),t}getConfig(e){return this.options?this.options.get(e):null}}class nn{constructor(e,t,r,n,i){this.name=e,this.type=t,this._evaluate=r,this.args=n,this._overloadIndex=i;}evaluate(e){if(!this._evaluate){const e=nn.definitions[this.name];this._evaluate=Array.isArray(e)?e[2]:e.overloads[this._overloadIndex][1];}return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e);}outputDefined(){return !1}serialize(){return [this.name].concat(this.args.map(e=>e.serialize()))}static parse(e,t){const r=e[0],n=nn.definitions[r];if(!n)return t.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0);const i=Array.isArray(n)?n[0]:n.type,s=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,o=[];let a=null,l=-1;for(const[n,u]of s){if(Array.isArray(n)&&n.length!==e.length-1)continue;o.push(n),l++,a=new Ai(t.registry,t.path,null,t.scope,void 0,t._scope,t.options,t.iconImageUseTheme);const s=[];let c=!1;for(let t=1;te)).map(sn).join(" | "),n=[];for(let r=1;rr;){if(n-r>600){const s=n-r+1,o=t-r+1,a=Math.log(s),l=.5*Math.exp(2*a/3),u=.5*Math.sqrt(a*l*(s-l)/s)*(o-s/2<0?-1:1);an(e,t,Math.max(r,Math.floor(t-o*l/s+u)),Math.min(n,Math.floor(t+(s-o)*l/s+u)),i);}const s=e[t];let o=r,a=n;for(ln(e,r,t),i(e[n],s)>0&&ln(e,r,n);o0;)a--;}0===i(e[r],s)?ln(e,r,a):(a++,ln(e,a,n)),a<=t&&(r=a+1),t<=a&&(n=a-1);}}function ln(e,t,r){const n=e[t];e[t]=e[r],e[r]=n;}function un(e,t){return et?1:0}function cn(e){let t=0;for(let r,n,i=0,s=e.length,o=s-1;i=t[2]||e[1]<=t[1]||e[3]>=t[3])}function dn(e,t,r){const n=e[0]-t[0],i=e[1]-t[1],s=e[0]-r[0],o=e[1]-r[1];return n*o-s*i===0&&n*s<=0&&i*o<=0}function fn(e,t,r){return t[1]>e[1]!=r[1]>e[1]&&e[0]<(r[0]-t[0])*(e[1]-t[1])/(r[1]-t[1])+t[0]}function mn(e,t,r=!1){let n=!1;for(let i=0,s=t.length;i0&&a<0||o<0&&a>0}function gn(e,t,r,n){return 0!==(i=[n[0]-r[0],n[1]-r[1]])[0]*(s=[t[0]-e[0],t[1]-e[1]])[1]-i[1]*s[0]&&!(!yn(e,t,r,n)||!yn(r,n,e,t));var i,s;}function xn(e){const t=new Ie(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),r=new Ie(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);for(const n of e[0])t.x>n.x&&(t.x=n.x),t.y>n.y&&(t.y=n.y),r.xr[2]){const t=.5*n;let i=e[0]-r[0]>t?-n:r[0]-e[0]>t?n:0;0===i&&(i=e[0]-r[2]>t?-n:r[2]-e[0]>t?n:0),e[0]+=i;}hn(t,e);}function Pn(e,t,r,n){const i=Math.pow(2,n.z)*vn,s=[n.x*vn,n.y*vn],o=[];if(!e)return o;for(const n of e)for(const e of n){const n=[e.x+s[0],e.y+s[1]];zn(n,t,r,i),o.push(n);}return o}function Bn(e,t,r,n){const i=Math.pow(2,n.z)*vn,s=[n.x*vn,n.y*vn],o=[];if(!e)return o;for(const r of e){const e=[];for(const n of r){const r=[n.x+s[0],n.y+s[1]];hn(t,r),e.push(r);}o.push(e);}if(t[2]-t[0]<=i/2){(a=t)[0]=a[1]=1/0,a[2]=a[3]=-1/0;for(const e of o)for(const n of e)zn(n,t,r,i);}var a;return o}class Tn{constructor(e,t){this.type=vr,this.geojson=e,this.geometries=t;}static parse(e,t){if(2!==e.length)return t.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Or(e[1])){const t=e[1];if("FeatureCollection"===t.type)for(let e=0;et)return Rn(i,s,(t-(r-o))/o)}return e[e.length-1]}pointToSegmentDistance(e,t,r){let[n,i]=t,s=Ln(r[0]-n)*this.kx,o=(r[1]-i)*this.ky;if(0!==s||0!==o){const t=(Ln(e[0]-n)*this.kx*s+(e[1]-i)*this.ky*o)/(s*s+o*o);t>1?(n=r[0],i=r[1]):t>0&&(n+=s/this.kx*t,i+=o/this.ky*t);}return s=Ln(e[0]-n)*this.kx,o=(e[1]-i)*this.ky,Math.sqrt(s*s+o*o)}pointOnLine(e,t){let r=1/0,n=e[0][0],i=e[0][1],s=0,o=0;for(let a=0;a1?(l=e[a+1][0],u=e[a+1][1]):p>0&&(l+=c/this.kx*p,u+=h/this.ky*p)),c=Ln(t[0]-l)*this.kx,h=(t[1]-u)*this.ky;const d=c*c+h*h;di.index||n.index===i.index&&n.t>i.t){const e=n;n=i,i=e;}const s=[n.point],o=n.index+1,a=i.index;!Cn(r[o],s[0])&&o<=a&&s.push(r[o]);for(let e=o+1;e<=a;e++)s.push(r[e]);return Cn(r[a],i.point)||s.push(i.point),s}lineSliceAlong(e,t,r){let n=0;const i=[];for(let s=0;se&&0===i.length&&i.push(Rn(o,a,(e-(n-l))/l)),n>=t)return i.push(Rn(o,a,(t-(n-l))/l)),i;n>e&&i.push(a);}return i}bufferPoint(e,t){const r=t/this.ky,n=t/this.kx;return [e[0]-n,e[1]-r,e[0]+n,e[1]+r]}bufferBBox(e,t){const r=t/this.ky,n=t/this.kx;return [e[0]-n,e[1]-r,e[2]+n,e[3]+r]}insideBBox(e,t){return Ln(e[0]-t[0])>=0&&Ln(e[0]-t[2])<=0&&e[1]>=t[1]&&e[1]<=t[3]}}function Cn(e,t){return e[0]===t[0]&&e[1]===t[1]}function Rn(e,t,r){const n=Ln(t[0]-e[0]);return [e[0]+n*r,e[1]+(t[1]-e[1])*r]}function Ln(e){for(;e<-180;)e+=360;for(;e>180;)e-=360;return e}class On{constructor(e=[],t=(e,t)=>et?1:0){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e);}push(e){this.data.push(e),this._up(this.length++);}pop(){if(0===this.length)return;const e=this.data[0],t=this.data.pop();return --this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:r}=this,n=t[e];for(;e>0;){const i=e-1>>1,s=t[i];if(r(n,s)>=0)break;t[e]=s,e=i;}t[e]=n;}_down(e){const{data:t,compare:r}=this,n=this.length>>1,i=t[e];for(;e=0)break;t[e]=t[n],e=n;}t[e]=i;}}var Un=8192;function Nn(e,t){return t.dist-e.dist}function jn(e){const t=[1/0,1/0,-1/0,-1/0];if(t.length!==e.length)return !1;for(let r=0;r=e[0]&&e[1]e[1])return [null,null];const r=Gn(e);if(t){if(2===r)return [e,null];const t=Math.floor(r/2);return [[e[0],e[0]+t],[e[0]+t,e[1]]]}{if(1===r)return [e,null];const t=Math.floor(r/2)-1;return [[e[0],e[0]+t],[e[0]+t+1,e[1]]]}}function Xn(e,t){const r=[1/0,1/0,-1/0,-1/0];if(!$n(t,e.length))return r;for(let n=t[0];n<=t[1];++n)hn(r,e[n]);return r}function Hn(e){const t=[1/0,1/0,-1/0,-1/0];for(let r=0;rt[2]&&(n=e[0]-t[2]),e[1]>t[3]&&(i=e[1]-t[3]),e[3]=n)return n;if(pn(i,s)){if(oi(e,t))return 0}else if(oi(t,e))return 0;let o=n;for(const n of e)for(let e=0,i=n.length,s=i-1;e=s)continue;const u=i.range1;if(Gn(u)<=a){if(!$n(u,e.length))return NaN;if(t){const t=si(e,u,r,n);if(0===(s=Math.min(s,t)))return s}else for(let t=u[0];t<=u[1];++t){const i=ii(e[t],r,n);if(0===(s=Math.min(s,i)))return s}}else {const r=qn(u,t);if(null!==r[0]){const t=Zn(Xn(e,r[0]),l,n);t=o)continue;const c=s.range1,h=s.range2;if(Gn(c)<=l&&Gn(h)<=u){if(!$n(c,e.length)||!$n(h,r.length))return NaN;if(t&&n?o=Math.min(o,ri(e,c,r,h,i)):t||n?t&&!n?o=Math.min(o,ei(r,h,e,c,i)):!t&&n&&(o=Math.min(o,ei(e,c,r,h,i))):o=Math.min(o,ni(e,c,r,h,i)),0===o)return o}else {const s=qn(c,t),l=qn(h,n);li(a,o,i,e,r,s[0],l[0]),li(a,o,i,e,r,s[0],l[1]),li(a,o,i,e,r,s[1],l[0]),li(a,o,i,e,r,s[1],l[1]);}}return o}function hi(e,t,r,n,i=1/0){let s=i;const o=Xn(e,[0,e.length-1]);for(const i of r)if(!(s!==1/0&&Zn(o,Xn(i,[0,i.length-1]),n)>=s)&&(s=Math.min(s,ci(e,t,i,!0,n,s)),0===s))return s;return s}function pi(e,t,r,n,i=1/0){let s=i;const o=Xn(e,[0,e.length-1]);for(const i of r){if(s!==1/0&&Zn(o,Hn(i),n)>=s)continue;const r=ui(e,t,i,n,s);if(isNaN(r))return r;if(0===(s=Math.min(s,r)))return s}return s}function di(e){return "Point"===e||"MultiPoint"===e||"LineString"===e||"MultiLineString"===e||"Polygon"===e||"MultiPolygon"===e}class fi{constructor(e,t){this.type=gr,this.geojson=e,this.geometries=t;}static parse(e,t){if(2!==e.length)return t.error(`'distance' expression requires either one argument, but found ' ${e.length-1} instead.`);if(Or(e[1])){const t=e[1];if("FeatureCollection"===t.type){for(let e=0;e{t&&!mi(e)&&(t=!1);}),t}function yi(e){if(e instanceof nn&&"feature-state"===e.name)return !1;let t=!0;return e.eachChild(e=>{t&&!yi(e)&&(t=!1);}),t}function gi(e,t){if(e instanceof nn&&t.indexOf(e.name)>=0)return !1;let r=!0;return e.eachChild(e=>{r&&!gi(e,t)&&(r=!1);}),r}function xi(e,t,r){return [e,t,r].filter(Boolean).join("")}function vi(e,t){switch(e){case "string":return Nr(t);case "number":return +t;case "boolean":return !!t;case "color":return ar.parse(t);case "formatted":return Dr.fromString(Nr(t));case "resolvedImage":return Rr.build(Nr(t))}return t}function bi(e,t,r,n){return void 0!==n&&(e=n*Math.round(e/n)),void 0!==t&&er&&(e=r),e}class wi{constructor(e,t,r,n=!1){this.type=e,this.key=t,this.scope=r,this.featureConstant=n;}static parse(e,t){let r=t.expectedType;if(null==r&&(r=_r),e.length<2||e.length>3)return t.error("Invalid number of arguments for 'config' expression.");const n=t.parse(e[1],1);if(!(n instanceof jr))return t.error("Key name of 'config' expression must be a string literal.");let i,s=!0;const o=Nr(n.value);if(e.length>=3){const r=t.parse(e[2],2);if(!(r instanceof jr))return t.error("Scope of 'config' expression must be a string literal.");i=Nr(r.value);}if(t.options){const e=xi(o,i,t._scope),r=t.options.get(e);r&&(s=mi(r.value||r.default));}return new wi(r,o,i,s)}evaluate(e){const t=xi(this.key,this.scope,e.scope),r=e.getConfig(t);if(!r)return null;const{type:n,value:i,values:s,minValue:o,maxValue:a,stepValue:l}=r,u=r.default.evaluate(e);let c=u;if(i){const t=e.scope;e.scope=(t||"").split("").slice(1).join(""),c=i.evaluate(e),e.scope=t;}return n&&(c=vi(n,c)),void 0===c||void 0===o&&void 0===a&&void 0===l||("number"==typeof c?c=bi(c,o,a,l):Array.isArray(c)&&(c=c.map(e=>"number"==typeof e?bi(e,o,a,l):e))),void 0!==i&&void 0!==c&&s&&!s.includes(c)&&(c=u,n&&(c=vi(n,c))),(n&&n!==this.type||void 0!==c&&!Vr(Ur(c),this.type))&&(c=vi(this.type.kind,c)),c}eachChild(){}outputDefined(){return !1}serialize(){const e=["config",this.key];return this.scope&&e.concat(this.scope),e}}class _i{constructor(e,t){this.type=t.type,this.name=e,this.boundExpression=t;}static parse(e,t){if(2!==e.length||"string"!=typeof e[1])return t.error("'var' expression requires exactly one string literal argument.");const r=e[1];return t.scope.has(r)?new _i(r,t.scope.get(r)):t.error(`Unknown variable "${r}". Make sure "${r}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return !1}serialize(){return ["var",this.name]}}class Ai{constructor(e,t=[],r,n=new mr,i=[],s,o,a){this.registry=e,this.path=t,this.key=t.map(e=>"string"==typeof e?`['${e}']`:`[${e}]`).join(""),this.scope=n,this.errors=i,this.expectedType=r,this._scope=s,this.options=o,this.iconImageUseTheme=a;}parse(e,t,r,n,i={}){return t||r?this.concat(t,null,r,n)._parse(e,i):this._parse(e,i)}parseObjectValue(e,t,r,n,i,s={}){return this.concat(t,r,n,i)._parse(e,s)}_parse(e,t){function r(e,t,r){return "assert"===r?new qr(t,[e]):"coerce"===r?new en(t,[e]):e}if(null!==e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e||(e=["literal",e]),Array.isArray(e)){if(0===e.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const n="string"==typeof e[0]?this.registry[e[0]]:void 0;if(n){let i=n.parse(e,this);if(!i)return null;if(this.expectedType){const e=this.expectedType,n=i.type;if("string"!==e.kind&&"number"!==e.kind&&"boolean"!==e.kind&&"object"!==e.kind&&"array"!==e.kind||"value"!==n.kind)if("color"!==e.kind&&"formatted"!==e.kind&&"resolvedImage"!==e.kind||"value"!==n.kind&&"string"!==n.kind){if(this.checkSubtype(e,n))return null}else i=r(i,e,t.typeAnnotation||"coerce");else i=r(i,e,t.typeAnnotation||"assert");}if(!(i instanceof jr)&&"resolvedImage"!==i.type.kind&&Mi(i)){const e=new rn(this._scope,this.options,this.iconImageUseTheme);try{i=new jr(i.type,i.evaluate(e));}catch(e){return this.error(e.message),null}}return i}return en.parse(["to-array",e],this)}return this.error(void 0===e?"'undefined' value invalid. Use null instead.":"object"==typeof e?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,t,r,n){let i="number"==typeof e?this.path.concat(e):this.path;i="string"==typeof t?i.concat(t):i;const s=n?this.scope.concat(n):this.scope;return new Ai(this.registry,i,r||null,s,this.errors,this._scope,this.options,this.iconImageUseTheme)}error(e,...t){const r=`${this.key}${t.map(e=>`[${e}]`).join("")}`;this.errors.push(new fr(r,e));}checkSubtype(e,t){const r=Br(e,t);return r&&this.error(r),r}}function Mi(e){if(e instanceof _i)return Mi(e.boundExpression);if(e instanceof nn&&"error"===e.name)return !1;if(e instanceof on)return !1;if(e instanceof Tn)return !1;if(e instanceof fi)return !1;if(e instanceof wi)return !1;const t=e instanceof en||e instanceof qr;let r=!0;return e.eachChild(e=>{r=t?r&&Mi(e):r&&e instanceof jr;}),!!r&&mi(e)&&gi(e,["zoom","heatmap-density","worldview","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed","is-active-floor"])}function Ii(e,t){const r=e.length-1;let n,i,s=0,o=r,a=0;for(;s<=o;)if(a=Math.floor((s+o)/2),n=e[a],i=e[a+1],n<=t){if(a===r||tt))throw new Gr("Input is not a number.");o=a-1;}return 0}class Si{constructor(e,t,r){this.type=e,this.input=t,this.labels=[],this.outputs=[];for(const[e,t]of r)this.labels.push(e),this.outputs.push(t);}static parse(e,t){if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");const r=t.parse(e[1],1,gr);if(!r)return null;const n=[];let i=null;t.expectedType&&"value"!==t.expectedType.kind&&(i=t.expectedType);for(let r=1;r=s)return t.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const u=t.parse(o,l,i);if(!u)return null;i=i||u.type,n.push([s,u]);}return new Si(i,r,n)}evaluate(e){const t=this.labels,r=this.outputs;if(1===t.length)return r[0].evaluate(e);const n=this.input.evaluate(e);if(n<=t[0])return r[0].evaluate(e);const i=t.length;return n>=t[i-1]?r[i-1].evaluate(e):r[Ii(t,n)].evaluate(e)}eachChild(e){e(this.input);for(const t of this.outputs)e(t);}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){const e=["step",this.input.serialize()];for(let t=0;t0&&e.push(this.labels[t]),e.push(this.outputs[t].serialize());return e}}const zi=.95047,Pi=1.08883,Bi=4/29,Ti=6/29,ki=3*Ti*Ti,Vi=Ti*Ti*Ti,Ei=Math.PI/180,Fi=180/Math.PI;function Di(e){return e>Vi?Math.pow(e,1/3):e/ki+Bi}function Ci(e){return e>Ti?e*e*e:ki*(e-Bi)}function Ri(e){return 255*(e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055)}function Li(e){return (e/=255)<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function Oi(e){const t=Li(e.r),r=Li(e.g),n=Li(e.b),i=Di((.4124564*t+.3575761*r+.1804375*n)/zi),s=Di((.2126729*t+.7151522*r+.072175*n)/1);return {l:116*s-16,a:500*(i-s),b:200*(s-Di((.0193339*t+.119192*r+.9503041*n)/Pi)),alpha:e.a}}function Ui(e){let t=(e.l+16)/116,r=isNaN(e.a)?t:t+e.a/500,n=isNaN(e.b)?t:t-e.b/200;return t=1*Ci(t),r=zi*Ci(r),n=Pi*Ci(n),new ar(Ri(3.2404542*r-1.5371385*t-.4985314*n),Ri(-.969266*r+1.8760108*t+.041556*n),Ri(.0556434*r-.2040259*t+1.0572252*n),e.alpha)}function Ni(e,t,r){const n=t-e;return e+r*(n>180||n<-180?n-360*Math.round(n/360):n)}const ji={forward:Oi,reverse:Ui,interpolate:function(e,t,r){return {l:hr(e.l,t.l,r),a:hr(e.a,t.a,r),b:hr(e.b,t.b,r),alpha:hr(e.alpha,t.alpha,r)}}},Gi={forward:function(e){const{l:t,a:r,b:n}=Oi(e),i=Math.atan2(n,r)*Fi;return {h:i<0?i+360:i,c:Math.sqrt(r*r+n*n),l:t,alpha:e.a}},reverse:function(e){const t=e.h*Ei,r=e.c;return Ui({l:e.l,a:Math.cos(t)*r,b:Math.sin(t)*r,alpha:e.alpha})},interpolate:function(e,t,r){return {h:Ni(e.h,t.h,r),c:hr(e.c,t.c,r),l:hr(e.l,t.l,r),alpha:hr(e.alpha,t.alpha,r)}}};var $i=Object.freeze({__proto__:null,hcl:Gi,lab:ji});class qi{constructor(e,t,r,n,i){this.type=e,this.operator=t,this.interpolation=r,this.input=n,this.labels=[],this.outputs=[];for(const[e,t]of i)this.labels.push(e),this.outputs.push(t);}static interpolationFactor(e,t,r,n){let i=0;if("exponential"===e.name)i=Xi(t,e.base,r,n);else if("linear"===e.name)i=Xi(t,1,r,n);else if("cubic-bezier"===e.name){const s=e.controlPoints;i=new Me(s[0],s[1],s[2],s[3]).solve(Xi(t,1,r,n));}return i}static parse(e,t){let[r,n,i,...s]=e;if(!Array.isArray(n)||0===n.length)return t.error("Expected an interpolation type expression.",1);if("linear"===n[0])n={name:"linear"};else if("exponential"===n[0]){const e=n[1];if("number"!=typeof e)return t.error("Exponential interpolation requires a numeric base.",1,1);n={name:"exponential",base:e};}else {if("cubic-bezier"!==n[0])return t.error(`Unknown interpolation type ${String(n[0])}`,1,0);{const e=n.slice(1);if(4!==e.length||e.some(e=>"number"!=typeof e||e<0||e>1))return t.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);n={name:"cubic-bezier",controlPoints:e};}}if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length-1>3&&(e.length-1)%2!=0)return t.error("Expected an even number of arguments.");if(i=t.parse(i,2,gr),!i)return null;const o=[];let a=null;"interpolate-hcl"===r||"interpolate-lab"===r?a=br:t.expectedType&&"value"!==t.expectedType.kind&&(a=t.expectedType);for(let e=0;e=r)return t.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',i);const u=t.parse(n,l,a);if(!u)return null;a=a||u.type,o.push([r,u]);}return "number"===a.kind||"color"===a.kind||"array"===a.kind&&"number"===a.itemType.kind&&"number"==typeof a.N?new qi(a,r,n,i,o):t.error(`Type ${zr(a)} is not interpolatable.`)}evaluate(e){const t=this.labels,r=this.outputs;if(1===t.length)return r[0].evaluate(e);const n=this.input.evaluate(e);if(n<=t[0])return r[0].evaluate(e);const i=t.length;if(n>=t[i-1])return r[i-1].evaluate(e);const s=Ii(t,n),o=qi.interpolationFactor(this.interpolation,n,t[s],t[s+1]),a=r[s].evaluate(e),l=r[s+1].evaluate(e);return "interpolate"===this.operator?dr[this.type.kind.toLowerCase()](a,l,o):"interpolate-hcl"===this.operator?Gi.reverse(Gi.interpolate(Gi.forward(a),Gi.forward(l),o)):ji.reverse(ji.interpolate(ji.forward(a),ji.forward(l),o))}eachChild(e){e(this.input);for(const t of this.outputs)e(t);}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){let e;e="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier",...this.interpolation.controlPoints];const t=[this.operator,e,this.input.serialize()];for(let e=0;eBr(n,e.type));return new Hi(s?_r:r,i)}evaluate(e){let t,r=null,n=0;for(const i of this.args){if(n++,r=i.evaluate(e),r&&r instanceof Rr&&!r.available&&(t||(t=r),r=null,n===this.args.length))return t;if(null!==r)break}return r}eachChild(e){this.args.forEach(e);}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){const e=["coalesce"];return this.eachChild(t=>{e.push(t.serialize());}),e}}class Zi{constructor(e,t){this.type=t.type,this.bindings=[].concat(e),this.result=t;}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const t of this.bindings)e(t[1]);e(this.result);}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const r=[];for(let n=1;n=r.length)throw new Gr("Array index out of bounds: index exceeds array size");if(t!==Math.floor(t))throw new Gr("Array index must be an integer. Use at-interpolated for fractional indices");return r[t]}eachChild(e){e(this.index),e(this.input);}outputDefined(){return !1}serialize(){return ["at",this.index.serialize(),this.input.serialize()]}}class Yi{constructor(e,t,r){this.type=e,this.index=t,this.input=r;}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const r=t.parse(e[1],1,gr),n=t.parse(e[2],2,Sr(t.expectedType||_r));return r&&n?new Yi(n.type.itemType,r,n):null}evaluate(e){const t=this.index.evaluate(e),r=this.input.evaluate(e);if(t<0)throw new Gr(`Array index out of bounds: ${t} < 0.`);if(t>r.length-1)throw new Gr(`Array index out of bounds: ${t} > ${r.length-1}.`);if(t===Math.floor(t))return r[t];const n=Math.floor(t),i=Math.ceil(t),s=r[n],o=r[i];if("number"!=typeof s||"number"!=typeof o)throw new Gr(`Cannot interpolate between non-number values at index ${t}.`);const a=t-n;return s*(1-a)+o*a}eachChild(e){e(this.index),e(this.input);}outputDefined(){return !1}serialize(){return ["at-interpolated",this.index.serialize(),this.input.serialize()]}}class Ji{constructor(e,t){this.type=vr,this.needle=e,this.haystack=t;}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const r=t.parse(e[1],1,_r),n=t.parse(e[2],2,_r);return r&&n?Tr(r.type,[vr,xr,gr,yr,_r])?new Ji(r,n):t.error(`Expected first argument to be of type boolean, string, number or null, but found ${zr(r.type)} instead`):null}evaluate(e){const t=this.needle.evaluate(e),r=this.haystack.evaluate(e);if(null==r)return !1;if(!kr(t,["boolean","string","number","null"]))throw new Gr(`Expected first argument to be of type boolean, string, number or null, but found ${zr(Ur(t))} instead.`);if(!kr(r,["string","array"]))throw new Gr(`Expected second argument to be of type array or string, but found ${zr(Ur(r))} instead.`);return r.indexOf(t)>=0}eachChild(e){e(this.needle),e(this.haystack);}outputDefined(){return !0}serialize(){return ["in",this.needle.serialize(),this.haystack.serialize()]}}class Ki{constructor(e,t,r){this.type=gr,this.needle=e,this.haystack=t,this.fromIndex=r;}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const r=t.parse(e[1],1,_r),n=t.parse(e[2],2,_r);if(!r||!n)return null;if(!Tr(r.type,[vr,xr,gr,yr,_r]))return t.error(`Expected first argument to be of type boolean, string, number or null, but found ${zr(r.type)} instead`);if(4===e.length){const i=t.parse(e[3],3,gr);return i?new Ki(r,n,i):null}return new Ki(r,n)}evaluate(e){const t=this.needle.evaluate(e),r=this.haystack.evaluate(e);if(!kr(t,["boolean","string","number","null"]))throw new Gr(`Expected first argument to be of type boolean, string, number or null, but found ${zr(Ur(t))} instead.`);if(!kr(r,["string","array"]))throw new Gr(`Expected second argument to be of type array or string, but found ${zr(Ur(r))} instead.`);if(this.fromIndex){const n=this.fromIndex.evaluate(e);return r.indexOf(t,n)}return r.indexOf(t)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex);}outputDefined(){return !1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const e=this.fromIndex.serialize();return ["index-of",this.needle.serialize(),this.haystack.serialize(),e]}return ["index-of",this.needle.serialize(),this.haystack.serialize()]}}class Qi{constructor(e,t,r,n,i,s){this.inputType=e,this.type=t,this.input=r,this.cases=n,this.outputs=i,this.otherwise=s;}static parse(e,t){if(e.length<5)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return t.error("Expected an even number of arguments.");let r,n;t.expectedType&&"value"!==t.expectedType.kind&&(n=t.expectedType);const i={},s=[];for(let o=2;oNumber.MAX_SAFE_INTEGER)return u.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof e&&Math.floor(e)!==e)return u.error("Numeric branch labels must be integer values.");if(r){if(u.checkSubtype(r,Ur(e)))return null}else r=Ur(e);if(void 0!==i[String(e)])return u.error("Branch labels must be unique.");i[String(e)]=s.length;}const c=t.parse(l,o,n);if(!c)return null;n=n||c.type,s.push(c);}const o=t.parse(e[1],1,_r);if(!o)return null;const a=t.parse(e[e.length-1],e.length-1,n);return a?"value"!==o.type.kind&&t.concat(1).checkSubtype(r,o.type)?null:new Qi(r,n,o,i,s,a):null}evaluate(e){const t=this.input.evaluate(e);return (Vr(Ur(t),this.inputType)&&this.outputs[this.cases[t]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise);}outputDefined(){return this.outputs.every(e=>e.outputDefined())&&this.otherwise.outputDefined()}serialize(){const e=["match",this.input.serialize()],t=Object.keys(this.cases).sort(),r=[],n={};for(const e of t){const t=n[this.cases[e]];void 0===t?(n[this.cases[e]]=r.length,r.push([this.cases[e],[e]])):r[t][1].push(e);}const i=e=>"number"===this.inputType.kind?Number(e):e;for(const[t,n]of r)e.push(1===n.length?i(n[0]):n.map(i)),e.push(this.outputs[t].serialize());return e.push(this.otherwise.serialize()),e}}class es{constructor(e,t,r){this.type=e,this.branches=t,this.otherwise=r;}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return t.error("Expected an odd number of arguments.");let r;t.expectedType&&"value"!==t.expectedType.kind&&(r=t.expectedType);const n=[];for(let i=1;it.outputDefined())&&this.otherwise.outputDefined()}serialize(){const e=["case"];return this.eachChild(t=>{e.push(t.serialize());}),e}}class ts{constructor(e,t,r,n){this.type=e,this.input=t,this.beginIndex=r,this.endIndex=n;}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const r=t.parse(e[1],1,_r),n=t.parse(e[2],2,gr);if(!r||!n)return null;if(!Tr(r.type,[Sr(_r),xr,_r]))return t.error(`Expected first argument to be of type array or string, but found ${zr(r.type)} instead`);if(4===e.length){const i=t.parse(e[3],3,gr);return i?new ts(r.type,r,n,i):null}return new ts(r.type,r,n)}evaluate(e){const t=this.input.evaluate(e),r=this.beginIndex.evaluate(e);if(!kr(t,["string","array"]))throw new Gr(`Expected first argument to be of type array or string, but found ${zr(Ur(t))} instead.`);if(this.endIndex){const n=this.endIndex.evaluate(e);return t.slice(r,n)}return t.slice(r)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex);}outputDefined(){return !1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const e=this.endIndex.serialize();return ["slice",this.input.serialize(),this.beginIndex.serialize(),e]}return ["slice",this.input.serialize(),this.beginIndex.serialize()]}}class rs{constructor(e,t){this.type=Sr(xr),this.str=e,this.delimiter=t;}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const r=t.parse(e[1],1,xr),n=t.parse(e[2],2,xr);return r&&n?new rs(r,n):void 0}evaluate(e){const t=this.str.evaluate(e),r=this.delimiter.evaluate(e);return t.split(r)}eachChild(e){e(this.str),e(this.delimiter);}outputDefined(){return !1}serialize(){return ["split",this.str.serialize(),this.delimiter.serialize()]}}function ns(e,t){return "=="===e||"!="===e?"boolean"===t.kind||"string"===t.kind||"number"===t.kind||"null"===t.kind||"value"===t.kind:"string"===t.kind||"number"===t.kind||"value"===t.kind}function is(e,t,r,n){return 0===n.compare(t,r)}function ss(e,t,r){const n="=="!==e&&"!="!==e;return class i{constructor(e,t,r){this.type=vr,this.lhs=e,this.rhs=t,this.collator=r,this.hasUntypedArgument="value"===e.type.kind||"value"===t.type.kind;}static parse(e,t){if(3!==e.length&&4!==e.length)return t.error("Expected two or three arguments.");const r=e[0];let s=t.parse(e[1],1,_r);if(!s)return null;if(!ns(r,s.type))return t.concat(1).error(`"${r}" comparisons are not supported for type '${zr(s.type)}'.`);let o=t.parse(e[2],2,_r);if(!o)return null;if(!ns(r,o.type))return t.concat(2).error(`"${r}" comparisons are not supported for type '${zr(o.type)}'.`);if(s.type.kind!==o.type.kind&&"value"!==s.type.kind&&"value"!==o.type.kind)return t.error(`Cannot compare types '${zr(s.type)}' and '${zr(o.type)}'.`);n&&("value"===s.type.kind&&"value"!==o.type.kind?s=new qr(o.type,[s]):"value"!==s.type.kind&&"value"===o.type.kind&&(o=new qr(s.type,[o])));let a=null;if(4===e.length){if("string"!==s.type.kind&&"string"!==o.type.kind&&"value"!==s.type.kind&&"value"!==o.type.kind)return t.error("Cannot use collator to compare non-string types.");if(a=t.parse(e[3],3,Ar),!a)return null}return new i(s,o,a)}evaluate(i){const s=this.lhs.evaluate(i),o=this.rhs.evaluate(i);if(n&&this.hasUntypedArgument){const t=Ur(s),r=Ur(o);if(t.kind!==r.kind||"string"!==t.kind&&"number"!==t.kind)throw new Gr(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${t.kind}, ${r.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const e=Ur(s),r=Ur(o);if("string"!==e.kind||"string"!==r.kind)return t(i,s,o)}return this.collator?r(i,s,o,this.collator.evaluate(i)):t(i,s,o)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator);}outputDefined(){return !0}serialize(){const t=[e];return this.eachChild(e=>{t.push(e.serialize());}),t}}}const os=ss("==",function(e,t,r){return t===r},is),as=ss("!=",function(e,t,r){return t!==r},function(e,t,r,n){return !is(0,t,r,n)}),ls=ss("<",function(e,t,r){return t",function(e,t,r){return t>r},function(e,t,r,n){return n.compare(t,r)>0}),cs=ss("<=",function(e,t,r){return t<=r},function(e,t,r,n){return n.compare(t,r)<=0}),hs=ss(">=",function(e,t,r){return t>=r},function(e,t,r,n){return n.compare(t,r)>=0});class ps{constructor(e,t,r,n,i,s){this.type=xr,this.number=e,this.locale=t,this.currency=r,this.unit=n,this.minFractionDigits=i,this.maxFractionDigits=s;}static parse(e,t){if(3!==e.length)return t.error("Expected two arguments.");const r=t.parse(e[1],1,gr);if(!r)return null;const n=e[2];if("object"!=typeof n||Array.isArray(n))return t.error("NumberFormat options argument must be an object.");let i=null;if(n.locale&&(i=t.parseObjectValue(n.locale,2,"locale",xr),!i))return null;let s=null;if(n.currency&&(s=t.parseObjectValue(n.currency,2,"currency",xr),!s))return null;let o=null;if(n.unit&&(o=t.parseObjectValue(n.unit,2,"unit",xr),!o))return null;let a=null;if(n["min-fraction-digits"]&&(a=t.parseObjectValue(n["min-fraction-digits"],2,"min-fraction-digits",gr),!a))return null;let l=null;return n["max-fraction-digits"]&&(l=t.parseObjectValue(n["max-fraction-digits"],2,"max-fraction-digits",gr),!l)?null:new ps(r,i,s,o,a,l)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(e):void 0,unit:this.unit?this.unit.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.unit&&e(this.unit),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits);}outputDefined(){return !1}serialize(){const e={};return this.locale&&(e.locale=this.locale.serialize()),this.currency&&(e.currency=this.currency.serialize()),this.unit&&(e.unit=this.unit.serialize()),this.minFractionDigits&&(e["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(e["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),e]}}class ds{constructor(e){this.type=gr,this.input=e;}static parse(e,t){if(2!==e.length)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`);const r=t.parse(e[1],1);return r?"array"!==r.type.kind&&"string"!==r.type.kind&&"value"!==r.type.kind?t.error(`Expected argument of type string or array, but found ${zr(r.type)} instead.`):new ds(r):null}evaluate(e){const t=this.input.evaluate(e);if("string"==typeof t)return t.length;if(Array.isArray(t))return t.length;throw new Gr(`Expected value to be of type string or array, but found ${zr(Ur(t))} instead.`)}eachChild(e){e(this.input);}outputDefined(){return !1}serialize(){const e=["length"];return this.eachChild(t=>{e.push(t.serialize());}),e}}function fs(e){return function(){e=1831565813+(e|=0)|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}const ms={"==":os,"!=":as,">":us,"<":ls,">=":hs,"<=":cs,array:qr,at:Wi,"at-interpolated":Yi,boolean:qr,case:es,coalesce:Hi,collator:on,format:Xr,image:Hr,in:Ji,"index-of":Ki,interpolate:qi,"interpolate-hcl":qi,"interpolate-lab":qi,length:ds,let:Zi,literal:jr,match:Qi,number:qr,"number-format":ps,object:qr,slice:ts,step:Si,string:qr,"to-boolean":en,"to-color":en,"to-number":en,"to-string":en,var:_i,within:Tn,distance:fi,config:wi,split:rs};function ys(e,[t,r,n,i]){t=t.evaluate(e),r=r.evaluate(e),n=n.evaluate(e);const s=i?i.evaluate(e):1,o=Lr(t,r,n,s);if(o)throw new Gr(o);return new ar(t/255,r/255,n/255,s)}function gs(e,[t,r,n,i]){t=t.evaluate(e),r=r.evaluate(e),n=n.evaluate(e);const s=i?i.evaluate(e):1,o=function(e,t,r,n){return "number"==typeof e&&e>=0&&e<=360?"number"==typeof t&&t>=0&&t<=100&&"number"==typeof r&&r>=0&&r<=100?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid hsla value [${[e,t,r,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${("number"==typeof n?[e,t,r,n]:[e,t,r]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${("number"==typeof n?[e,t,r,n]:[e,t,r]).join(", ")}]: 'h' must be between 0 and 360.`}(t,r,n,s);if(o)throw new Gr(o);const a=`hsla(${t}, ${r}%, ${n}%, ${s})`,l=ar.parse(a);if(!l)throw new Gr(`Failed to parse HSLA color: ${a}`);return l}function xs(e,t){return e in t}function vs(e,t){const r=t[e];return void 0===r?null:r}function bs(e){return {type:e}}function ws(e){if(e instanceof wi)return new Set([e.key]);let t=new Set;return e.eachChild(e=>{t=new Set([...t,...ws(e)]);}),t}function _s(e){if(e instanceof nn&&"is-active-floor"===e.name)return !0;let t=!1;return e.eachChild(e=>{!t&&_s(e)&&(t=!0);}),t}function As(e){return {result:"success",value:e}}function Ms(e){return {result:"error",value:e}}function Is(e,t){return !!e&&!!e.parameters&&e.parameters.indexOf(t)>-1}function Ss(e){return "data-driven"===e["property-type"]}function zs(e){return Is(e.expression,"measure-light")}function Ps(e){return Is(e.expression,"zoom")}function Bs(e){return !!e.expression&&e.expression.interpolated}function Ts(e){return "object"==typeof e&&null!==e&&!Array.isArray(e)}function ks(e){return e}function Vs(e,t){const r="color"===t.type,n=e.stops&&"object"==typeof e.stops[0][0],i=n||!(n||void 0!==e.property),s=e.type||(Bs(t)?"exponential":"interval");if(r&&((e=Object.assign({},e)).stops&&(e.stops=e.stops.map(e=>[e[0],ar.parse(e[1])])),e.default=ar.parse(e.default?e.default:t.default)),e.colorSpace&&"rgb"!==e.colorSpace&&!$i[e.colorSpace])throw new Error(`Unknown color space: ${e.colorSpace}`);let o,a,l;if("exponential"===s)o=Cs;else if("interval"===s)o=Ds;else if("categorical"===s){o=Fs,a=Object.create(null);for(const t of e.stops)a[t[0]]=t[1];l=typeof e.stops[0][0];}else {if("identity"!==s)throw new Error(`Unknown function type "${s}"`);o=Rs;}if(n){const r={},n=[];for(let t=0;te[0]),evaluate:({zoom:r},n)=>Cs({stops:i,base:e.base},t,r).evaluate(r,n)}}if(i){const r="exponential"===s?{name:"exponential",base:void 0!==e.base?e.base:1}:null;return {kind:"camera",interpolationType:r,interpolationFactor:qi.interpolationFactor.bind(void 0,r),zoomStops:e.stops.map(e=>e[0]),evaluate:({zoom:r})=>o(e,t,r,a,l)}}return {kind:"source",evaluate(r,n){const i=n&&n.properties?n.properties[e.property]:void 0;return void 0===i?Es(e.default,t.default):o(e,t,i,a,l)}}}function Es(e,t,r){return void 0!==e?e:void 0!==t?t:void 0!==r?r:void 0}function Fs(e,t,r,n,i){return Es(typeof r===i?n[r]:void 0,e.default,t.default)}function Ds(e,t,r){if(!Jr(r))return Es(e.default,t.default);const n=e.stops.length;if(1===n)return e.stops[0][1];if(r<=e.stops[0][0])return e.stops[0][1];if(r>=e.stops[n-1][0])return e.stops[n-1][1];const i=Ii(e.stops.map(e=>e[0]),r);return e.stops[i][1]}function Cs(e,t,r){const n=void 0!==e.base?e.base:1;if(!Jr(r))return Es(e.default,t.default);const i=e.stops.length;if(1===i)return e.stops[0][1];if(r<=e.stops[0][0])return e.stops[0][1];if(r>=e.stops[i-1][0])return e.stops[i-1][1];const s=Ii(e.stops.map(e=>e[0]),r),o=function(e,t,r,n){const i=n-r,s=e-r;return 0===i?0:1===t?s/i:(Math.pow(t,s)-1)/(Math.pow(t,i)-1)}(r,n,e.stops[s][0],e.stops[s+1][0]),a=e.stops[s][1],l=e.stops[s+1][1];let u=dr[t.type]||ks;if(e.colorSpace&&"rgb"!==e.colorSpace){const t=$i[e.colorSpace];u=(e,r)=>t.reverse(t.interpolate(t.forward(e),t.forward(r),o));}return "function"==typeof a.evaluate?{evaluate(...e){const t=a.evaluate.apply(void 0,e),r=l.evaluate.apply(void 0,e);if(void 0!==t&&void 0!==r)return u(t,r,o)}}:u(a,l,o)}function Rs(e,t,r){return "color"===t.type?r=ar.parse(r):"formatted"===t.type?r=Dr.fromString(r.toString()):"resolvedImage"===t.type?r=Rr.build(r.toString()):Zr(r)===t.type||"enum"===t.type&&t.values[r]||(r=void 0),Es(r,e.default,t.default)}nn.register(ms,{error:[{kind:"error"},[xr],(e,[t])=>{throw new Gr(t.evaluate(e))}],typeof:[xr,[_r],(e,[t])=>zr(Ur(t.evaluate(e)))],"to-rgba":[Sr(gr,4),[br],(e,[t])=>t.evaluate(e).toNonPremultipliedRenderColor(null).toArray()],"to-hsla":[Sr(gr,4),[br],(e,[t])=>t.evaluate(e).toNonPremultipliedRenderColor(null).toHslaArray()],rgb:[br,[gr,gr,gr],ys],rgba:[br,[gr,gr,gr,gr],ys],hsl:[br,[gr,gr,gr],gs],hsla:[br,[gr,gr,gr,gr],gs],has:{type:vr,overloads:[[[xr],(e,[t])=>xs(t.evaluate(e),e.properties())],[[xr,wr],(e,[t,r])=>xs(t.evaluate(e),r.evaluate(e))]]},get:{type:_r,overloads:[[[xr],(e,[t])=>vs(t.evaluate(e),e.properties())],[[xr,wr],(e,[t,r])=>vs(t.evaluate(e),r.evaluate(e))]]},"feature-state":[_r,[xr],(e,[t])=>vs(t.evaluate(e),e.featureState||{})],properties:[wr,[],e=>e.properties()],"geometry-type":[xr,[],e=>e.geometryType()],worldview:[xr,[],e=>e.globals.worldview||""],"is-active-floor":[vr,bs(xr),(e,t)=>{if(!(e.globals&&e.globals.activeFloors&&e.globals.activeFloors.size>0))return !1;if(0===t.length)return !0;const r=e.globals.activeFloors;return t.some(t=>{const n=t.evaluate(e);return r.has(n)})}],id:[_r,[],e=>e.id()],zoom:[gr,[],e=>e.globals.zoom],pitch:[gr,[],e=>e.globals.pitch||0],"distance-from-center":[gr,[],e=>e.distanceFromCenter()],"measure-light":[gr,[xr],(e,[t])=>e.measureLight(t.evaluate(e))],"heatmap-density":[gr,[],e=>e.globals.heatmapDensity||0],"line-progress":[gr,[],e=>e.globals.lineProgress||0],"raster-value":[gr,[],e=>e.globals.rasterValue||0],"raster-particle-speed":[gr,[],e=>e.globals.rasterParticleSpeed||0],"sky-radial-progress":[gr,[],e=>e.globals.skyRadialProgress||0],accumulated:[_r,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[gr,bs(gr),(e,t)=>{let r=0;for(const n of t)r+=n.evaluate(e);return r}],"*":[gr,bs(gr),(e,t)=>{let r=1;for(const n of t)r*=n.evaluate(e);return r}],"-":{type:gr,overloads:[[[gr,gr],(e,[t,r])=>t.evaluate(e)-r.evaluate(e)],[[gr],(e,[t])=>-t.evaluate(e)]]},"/":[gr,[gr,gr],(e,[t,r])=>t.evaluate(e)/r.evaluate(e)],"%":[gr,[gr,gr],(e,[t,r])=>t.evaluate(e)%r.evaluate(e)],ln2:[gr,[],()=>Math.LN2],pi:[gr,[],()=>Math.PI],e:[gr,[],()=>Math.E],"^":[gr,[gr,gr],(e,[t,r])=>Math.pow(t.evaluate(e),r.evaluate(e))],sqrt:[gr,[gr],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[gr,[gr],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[gr,[gr],(e,[t])=>Math.log(t.evaluate(e))],log2:[gr,[gr],(e,[t])=>Math.log2(t.evaluate(e))],sin:[gr,[gr],(e,[t])=>Math.sin(t.evaluate(e))],cos:[gr,[gr],(e,[t])=>Math.cos(t.evaluate(e))],tan:[gr,[gr],(e,[t])=>Math.tan(t.evaluate(e))],asin:[gr,[gr],(e,[t])=>Math.asin(t.evaluate(e))],acos:[gr,[gr],(e,[t])=>Math.acos(t.evaluate(e))],atan:[gr,[gr],(e,[t])=>Math.atan(t.evaluate(e))],min:[gr,bs(gr),(e,t)=>Math.min(...t.map(t=>t.evaluate(e)))],max:[gr,bs(gr),(e,t)=>Math.max(...t.map(t=>t.evaluate(e)))],abs:[gr,[gr],(e,[t])=>Math.abs(t.evaluate(e))],round:[gr,[gr],(e,[t])=>{const r=t.evaluate(e);return r<0?-Math.round(-r):Math.round(r)}],floor:[gr,[gr],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[gr,[gr],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[vr,[xr,_r],(e,[t,r])=>e.properties()[t.value]===r.value],"filter-id-==":[vr,[_r],(e,[t])=>e.id()===t.value],"filter-type-==":[vr,[xr],(e,[t])=>e.geometryType()===t.value],"filter-<":[vr,[xr,_r],(e,[t,r])=>{const n=e.properties()[t.value],i=r.value;return typeof n==typeof i&&n{const r=e.id(),n=t.value;return typeof r==typeof n&&r":[vr,[xr,_r],(e,[t,r])=>{const n=e.properties()[t.value],i=r.value;return typeof n==typeof i&&n>i}],"filter-id->":[vr,[_r],(e,[t])=>{const r=e.id(),n=t.value;return typeof r==typeof n&&r>n}],"filter-<=":[vr,[xr,_r],(e,[t,r])=>{const n=e.properties()[t.value],i=r.value;return typeof n==typeof i&&n<=i}],"filter-id-<=":[vr,[_r],(e,[t])=>{const r=e.id(),n=t.value;return typeof r==typeof n&&r<=n}],"filter->=":[vr,[xr,_r],(e,[t,r])=>{const n=e.properties()[t.value],i=r.value;return typeof n==typeof i&&n>=i}],"filter-id->=":[vr,[_r],(e,[t])=>{const r=e.id(),n=t.value;return typeof r==typeof n&&r>=n}],"filter-has":[vr,[_r],(e,[t])=>t.value in e.properties()],"filter-has-id":[vr,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[vr,[Sr(xr)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[vr,[Sr(_r)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[vr,[xr,Sr(_r)],(e,[t,r])=>r.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[vr,[xr,Sr(_r)],(e,[t,r])=>function(e,t,r,n){for(;r<=n;){const i=r+n>>1;if(t[i]===e)return !0;t[i]>e?n=i-1:r=i+1;}return !1}(e.properties()[t.value],r.value,0,r.value.length-1)],all:{type:vr,overloads:[[[vr,vr],(e,[t,r])=>t.evaluate(e)&&r.evaluate(e)],[bs(vr),(e,t)=>{for(const r of t)if(!r.evaluate(e))return !1;return !0}]]},any:{type:vr,overloads:[[[vr,vr],(e,[t,r])=>t.evaluate(e)||r.evaluate(e)],[bs(vr),(e,t)=>{for(const r of t)if(r.evaluate(e))return !0;return !1}]]},"!":[vr,[vr],(e,[t])=>!t.evaluate(e)],"is-supported-script":[vr,[xr],(e,[t])=>{const r=e.globals&&e.globals.isSupportedScript;return !r||r(t.evaluate(e))}],upcase:[xr,[xr],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[xr,[xr],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[xr,bs(_r),(e,t)=>t.map(t=>Nr(t.evaluate(e))).join("")],"resolved-locale":[xr,[Ar],(e,[t])=>t.evaluate(e).resolvedLocale()],random:[gr,[gr,gr,_r],(e,t)=>{const[r,n,i]=t.map(t=>t.evaluate(e));if(r>n)return r;if(r===n)return r;let s;if("string"==typeof i)s=function(e){let t=0;if(0===e.length)return t;for(let r=0;rJSON.stringify(e)).join(", ")}, but found ${JSON.stringify(e)} instead.`);return e}catch(e){const t=e;return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(`Failed to evaluate expression "${JSON.stringify(this.expression.serialize())}". ${t.message}`)),this._defaultValue}}}function Os(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in ms}function Us(e,t,r,n,i){const s=new Ai(ms,[],t?function(e){const t={color:br,string:xr,number:gr,enum:xr,boolean:vr,formatted:Mr,resolvedImage:Ir};return "array"===e.type?Sr(t[e.value]||_r,e.length):t[e.type]}(t):void 0,void 0,void 0,r,n,i),o=s.parse(e,void 0,void 0,void 0,t&&"string"===t.type?{typeAnnotation:"coerce"}:void 0);return o?As(new Ls(o,t,r,n,i)):Ms(s.errors)}class Ns{constructor(e,t,r,n){this.kind=e,this._styleExpression=t,this.isLightConstant=r,this.isLineProgressConstant=n,this.isStateDependent="constant"!==e&&!yi(t.expression),this.configDependencies=ws(t.expression),this.isIndoorDependent=_s(t.expression);}evaluateWithoutErrorHandling(e,t,r,n,i,s){return this._styleExpression.evaluateWithoutErrorHandling(e,t,r,n,i,s)}evaluate(e,t,r,n,i,s,o){return this._styleExpression.evaluate(e,t,r,n,i,s,void 0,void 0,o)}}class js{constructor(e,t,r,n,i,s){this.kind=e,this.zoomStops=r,this._styleExpression=t,this.isStateDependent="camera"!==e&&!yi(t.expression),this.isIndoorDependent=_s(t.expression),this.isLightConstant=i,this.isLineProgressConstant=s,this.configDependencies=ws(t.expression),this.interpolationType=n;}evaluateWithoutErrorHandling(e,t,r,n,i,s){return this._styleExpression.evaluateWithoutErrorHandling(e,t,r,n,i,s)}evaluate(e,t,r,n,i,s){return this._styleExpression.evaluate(e,t,r,n,i,s)}interpolationFactor(e,t,r){return this.interpolationType?qi.interpolationFactor(this.interpolationType,e,t,r):0}}function Gs(e,t,r,n,i){if("error"===(e=Us(e,t,r,n,i)).result)return e;const s=e.value.expression,o=mi(s);if(!o&&!Ss(t))return Ms([new fr("","data expressions not supported")]);const a=gi(s,["zoom","pitch","distance-from-center"]);if(!a&&!Ps(t))return Ms([new fr("","zoom expressions not supported")]);const l=gi(s,["measure-light"]);if(!l&&!zs(t))return Ms([new fr("","measure-light expression not supported")]);const u=gi(s,["line-progress"]);if(!u&&!function(e){return Is(e.expression,"line-progress")}(t))return Ms([new fr("","line-progress expression not supported")]);const c=t.expression&&t.expression.relaxZoomRestriction,h=qs(s);return h||a||c?h instanceof fr?Ms([h]):h instanceof qi&&!Bs(t)?Ms([new fr("",'"interpolate" expressions cannot be used with this property')]):As(h?new js(o&&u?"camera":"composite",e.value,h.labels,h instanceof qi?h.interpolation:void 0,l,u):new Ns(o&&u?"constant":"source",e.value,l,u)):Ms([new fr("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class $s{constructor(e,t){this._parameters=e,this._specification=t,Object.assign(this,Vs(this._parameters,this._specification));}static deserialize(e){return new $s(e._parameters,e._specification)}static serialize(e){return {_parameters:e._parameters,_specification:e._specification}}}function qs(e){let t=null;if(e instanceof Zi)t=qs(e.result);else if(e instanceof Hi){for(const r of e.args)if(t=qs(r),t)break}else (e instanceof Si||e instanceof qi)&&e.input instanceof nn&&"zoom"===e.input.name&&(t=e);return t instanceof fr||e.eachChild(e=>{const r=qs(e);r instanceof fr?t=r:t&&r&&t!==r&&(t=new fr("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'));}),t}var Xs,Hs,Zs=function(){if(Hs)return Xs;Hs=1,Xs=t;var e=3;function t(t,r,n){var i=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;var s=new Int32Array(this.arrayBuffer);t=s[0],this.d=(r=s[1])+2*(n=s[2]);for(var o=0;o=c[d+0]&&n>=c[d+1])?(o[p]=!0,s.push(u[p])):o[p]=!1;}}},t.prototype._forEachCell=function(e,t,r,n,i,s,o,a){for(var l=this._convertToCellCoord(e),u=this._convertToCellCoord(t),c=this._convertToCellCoord(r),h=this._convertToCellCoord(n),p=l;p<=c;p++)for(var d=u;d<=h;d++){var f=this.d*d+p;if((!a||a(this._convertFromCellCoord(p),this._convertFromCellCoord(d),this._convertFromCellCoord(p+1),this._convertFromCellCoord(d+1)))&&i.call(this,e,t,r,n,f,s,o,a))return}},t.prototype._convertFromCellCoord=function(e){return (e-this.padding)/this.scale},t.prototype._convertToCellCoord=function(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))},t.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var t=this.cells,r=e+this.cells.length+1+1,n=0,i=0;i=0||(i[r]=Qs(e[r],t)));e instanceof Error&&(i.message=e.message);}if(i.$name)throw new Error("$name property is reserved for worker serialization logic.");return "Object"!==n&&(i.$name=n),i}throw new Error("can't serialize object of type "+typeof e)}function eo(e){if(null==e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||e instanceof Boolean||e instanceof Number||e instanceof String||e instanceof Date||e instanceof RegExp||Ks(e)||e instanceof ImageBitmap||ArrayBuffer.isView(e)||e instanceof ImageData)return e;if(Array.isArray(e))return e.map(eo);if("object"==typeof e){const t=e.$name||"Object";if("Map"===t){const t=e.entries||[],r=new Map;for(let e=0;ee>=1536&&e<=1791,ro=e=>e>=1872&&e<=1919,no=e=>e>=2208&&e<=2303,io=e=>e>=11904&&e<=12031,so=e=>e>=12032&&e<=12255,oo=e=>e>=12272&&e<=12287,ao=e=>e>=12288&&e<=12351,lo=e=>e>=12352&&e<=12447,uo=e=>e>=12448&&e<=12543,co=e=>e>=12544&&e<=12591,ho=e=>e>=12704&&e<=12735,po=e=>e>=12736&&e<=12783,fo=e=>e>=12784&&e<=12799,mo=e=>e>=12800&&e<=13055,yo=e=>e>=13056&&e<=13311,go=e=>e>=13312&&e<=19903,xo=e=>e>=19968&&e<=40959,vo=e=>e>=40960&&e<=42127,bo=e=>e>=42128&&e<=42191,wo=e=>e>=44032&&e<=55215,_o=e=>e>=63744&&e<=64255,Ao=e=>e>=64336&&e<=65023,Mo=e=>e>=65040&&e<=65055,Io=e=>e>=65072&&e<=65103,So=e=>e>=65104&&e<=65135,zo=e=>e>=65136&&e<=65279,Po=e=>e>=65280&&e<=65519;function Bo(e){for(const t of e)if(Eo(t.charCodeAt(0)))return !0;return !1}function To(e){for(const t of e)if(!ko(t.charCodeAt(0)))return !1;return !0}function ko(e){return !(to(e)||ro(e)||no(e)||Ao(e)||zo(e))}function Vo(e){return !(e<11904||!(ho(e)||co(e)||Io(e)||_o(e)||yo(e)||io(e)||po(e)||ao(e)||go(e)||xo(e)||mo(e)||Po(e)||lo(e)||oo(e)||so(e)||fo(e)||uo(e)||Mo(e)||bo(e)||vo(e)))}function Eo(e){return !(746!==e&&747!==e&&(e<4352||!(ho(e)||co(e)||Io(e)&&!(e>=65097&&e<=65103)||_o(e)||yo(e)||io(e)||po(e)||!(!ao(e)||e>=12296&&e<=12305||e>=12308&&e<=12319||12336===e)||go(e)||xo(e)||mo(e)||(e=>e>=12592&&e<=12687)(e)||(e=>e>=43360&&e<=43391)(e)||(e=>e>=55216&&e<=55295)(e)||(e=>e>=4352&&e<=4607)(e)||wo(e)||lo(e)||oo(e)||(e=>e>=12688&&e<=12703)(e)||so(e)||fo(e)||uo(e)&&12540!==e||!(!Po(e)||65288===e||65289===e||65293===e||e>=65306&&e<=65310||65339===e||65341===e||65343===e||e>=65371&&e<=65503||65507===e||e>=65512&&e<=65519)||!(!So(e)||e>=65112&&e<=65118||e>=65123&&e<=65126)||(e=>e>=5120&&e<=5759)(e)||(e=>e>=6320&&e<=6399)(e)||Mo(e)||(e=>e>=19904&&e<=19967)(e)||vo(e)||bo(e))))}function Fo(e){return 12312===e||12313===e||12316===e||12540===e||12448===e}function Do(e){return !(Eo(e)||function(e){return !!((e=>e>=128&&e<=255)(e)&&(167===e||169===e||174===e||177===e||188===e||189===e||190===e||215===e||247===e)||(e=>e>=8192&&e<=8303)(e)&&(8214===e||8224===e||8225===e||8240===e||8241===e||8251===e||8252===e||8258===e||8263===e||8264===e||8265===e||8273===e)||(e=>e>=8448&&e<=8527)(e)||(e=>e>=8528&&e<=8591)(e)||(e=>e>=8960&&e<=9215)(e)&&(e>=8960&&e<=8967||e>=8972&&e<=8991||e>=8996&&e<=9e3||9003===e||e>=9085&&e<=9114||e>=9150&&e<=9165||9167===e||e>=9169&&e<=9179||e>=9186&&e<=9215)||(e=>e>=9216&&e<=9279)(e)&&9251!==e||(e=>e>=9280&&e<=9311)(e)||(e=>e>=9312&&e<=9471)(e)||(e=>e>=9632&&e<=9727)(e)||(e=>e>=9728&&e<=9983)(e)&&!(e>=9754&&e<=9759)||(e=>e>=11008&&e<=11263)(e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||ao(e)||uo(e)||(e=>e>=57344&&e<=63743)(e)||Io(e)||So(e)||Po(e)||8734===e||8756===e||8757===e||e>=9984&&e<=10087||e>=10102&&e<=10131||65532===e||65533===e)}(e))}function Co(e){return to(e)||ro(e)||no(e)||Ao(e)||zo(e)}function Ro(e){return e>=1424&&e<=2303||Ao(e)||zo(e)}function Lo(e,t){return !(!t&&Ro(e)||e>=2304&&e<=3583||e>=3840&&e<=4255||(e=>e>=6016&&e<=6143)(e))}function Oo(e){for(const t of e)if(Ro(t.charCodeAt(0)))return !0;return !1}const Uo={unavailable:"unavailable",deferred:"deferred",loading:"loading",parsing:"parsing",parsed:"parsed",loaded:"loaded",error:"error"};let No=null,jo=Uo.unavailable,Go=null;const $o=function(e){e&&"string"==typeof e&&e.indexOf("NetworkError")>-1&&(jo=Uo.error),No&&No(e);};function qo(){Xo.fire(new Kt("pluginStateChange",{pluginStatus:jo,pluginURL:Go}));}const Xo=new rr,Ho=function(){return jo},Zo=function(){if(jo!==Uo.deferred||!Go)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");jo=Uo.loading,qo(),Go&&Ot({url:Go},e=>{e?$o(e):(jo=Uo.loaded,qo());});},Wo={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>jo===Uo.loaded||null!=Wo.applyArabicShaping,isLoading:()=>jo===Uo.loading,setState(e){jo=e.pluginStatus,Go=e.pluginURL;},isParsing:()=>jo===Uo.parsing,isParsed:()=>jo===Uo.parsed,getPluginURL:()=>Go};class Yo{constructor(e,t){this.zoom=e,t?(this.now=t.now,this.fadeDuration=t.fadeDuration,this.transition=t.transition,this.pitch=t.pitch,this.brightness=t.brightness,this.worldview=t.worldview,this.activeFloors=t.activeFloors):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0);}isSupportedScript(e){return function(e,t){for(const r of e)if(!Lo(r.charCodeAt(0),t))return !1;return !0}(e,Wo.isLoaded())}}class Jo{constructor(e,t,r,n,i){this.property=e,this.value=t,this.expression=function(e,t,r,n,i){if(Ts(e))return new $s(e,t);if(Os(e)||Array.isArray(e)&&e.length>0){const s=Gs(e,t,r,n,i);if("error"===s.result)throw new Error(s.value.map(e=>`${e.key}: ${e.message}`).join(", "));return s.value}{let r=e;return "string"==typeof e&&"color"===t.type&&(r=ar.parse(e)),{kind:"constant",configDependencies:new Set,isIndoorDependent:!1,evaluate:()=>r}}}(void 0===t?e.specification.default:t,e.specification,r,n,i);}isIndoorDependent(){return this.expression.isIndoorDependent}isDataDriven(){return "source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(e,t,r,n){return this.property.possiblyEvaluate(this,e,t,r,n)}}class Ko{constructor(e,t,r,n){this.property=e,this.value=new Jo(e,void 0,t,r,n);}transitioned(e,t){return new ea(this.property,this.value,t,Object.assign({},e.transition,this.transition),e.now)}untransitioned(){return new ea(this.property,this.value,null,{},0)}}class Qo{constructor(e,t,r,n){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._scope=t,this._options=r,this._iconImageUseTheme=n,this._isIndoorDependent=!1,this.configDependencies=new Set;}getValue(e){return qe(this._values[e].value.value)}setValue(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new Ko(this._values[e].property,this._scope,this._options,this._iconImageUseTheme)),this._values[e].value=new Jo(this._values[e].property,null===t?void 0:qe(t),this._scope,this._options,this._iconImageUseTheme),this._values[e].value.expression.configDependencies&&(this.configDependencies=new Set([...this.configDependencies,...this._values[e].value.expression.configDependencies]),this._isIndoorDependent=this._isIndoorDependent||this._values[e].value.isIndoorDependent());}setTransitionOrValue(e,t){t&&(this._options=t);const r=this._properties.properties;if(e)for(const t in e){const n=e[t];if(t.endsWith("-transition")){const e=t.slice(0,-11);r[e]&&this.setTransition(e,n);}else r.hasOwnProperty(t)&&this.setValue(t,n);}}getTransition(e){return qe(this._values[e].transition)}setTransition(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new Ko(this._values[e].property)),this._values[e].transition=qe(t)||void 0;}serialize(){const e={};for(const t of Object.keys(this._values)){const r=this.getValue(t);void 0!==r&&(e[t]=r);const n=this.getTransition(t);void 0!==n&&(e[`${t}-transition`]=n);}return e}transitioned(e,t){const r=new ta(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].transitioned(e,t._values[n]);return r}untransitioned(){const e=new ta(this._properties);for(const t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}isIndoorDependent(){return this._isIndoorDependent}}class ea{constructor(e,t,r,n,i){const s=n.delay||0,o=n.duration||0;i=i||0,this.property=e,this.value=t,this.begin=i+s,this.end=this.begin+o,e.specification.transition&&(n.delay||n.duration)&&(this.prior=r);}possiblyEvaluate(e,t,r){const n=e.now||0,i=this.value.possiblyEvaluate(e,t,r),s=this.prior;if(s){if(n>this.end)return this.prior=null,i;if(this.value.isDataDriven())return this.prior=null,i;if(n":1,">=":1,"<":1,"<=":1,"in":1,"!in":1,"all":1,"any":1,"none":1,"has":1,"!has":1}},"geometry_type":{"type":"enum","values":{"Point":1,"LineString":1,"Polygon":1}},"function":{"expression":{"type":"expression"},"stops":{"type":"array","value":"function_stop"},"base":{"type":"number","default":1,"minimum":0},"property":{"type":"string","default":"$zoom"},"type":{"type":"enum","values":{"identity":1,"exponential":1,"interval":1,"categorical":1},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":1,"lab":1,"hcl":1},"default":"rgb"},"default":{"type":"*"}},"function_stop":{"type":"array","minimum":0,"maximum":24,"value":["number","color"],"length":2},"expression":{"type":"array","value":"*","minimum":1},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"high-color":{"type":"color","default":"#245cdf","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"space-color":{"type":"color","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"horizon-blend":{"type":"number","default":["interpolate",["linear"],["zoom"],4,0.2,7,0.1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"star-intensity":{"type":"number","default":["interpolate",["linear"],["zoom"],5,0.35,6,0],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vertical-range":{"type":"array","default":[0,0],"minimum":0,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}}},"snow":{"density":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.85],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.3],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette-color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"center-thinning":{"type":"number","default":0.4,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"direction":{"type":"array","default":[0,50],"minimum":0,"maximum":360,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"flake-size":{"type":"number","default":0.71,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true}},"rain":{"density":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.5],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"color":{"type":"color","default":["interpolate",["linear"],["measure-light","brightness"],0,"#03113d",0.3,"#a8adbc"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"opacity":{"type":"number","default":["interpolate",["linear"],["measure-light","brightness"],0,0.88,1,0.7],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette-color":{"type":"color","default":["interpolate",["linear"],["measure-light","brightness"],0,"#001736",0.3,"#464646"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"center-thinning":{"type":"number","default":0.57,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"direction":{"type":"array","default":[0,80],"minimum":0,"maximum":360,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"droplet-size":{"type":"array","default":[2.6,18.2],"minimum":0,"maximum":50,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"distortion-strength":{"type":"number","default":0.7,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true}},"camera":{"camera-projection":{"type":"enum","values":{"perspective":1,"orthographic":1},"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"default":"perspective"}},"colorTheme":{"data":{"type":"string","expression":{}}},"indoor_source":{"sourceId":{"type":"string"},"sourceLayers":{"type":"array","value":"string"}},"indoor":{"*":{"type":"indoor_source"}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"expression":{"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"use-theme":true,"transition":true},"intensity":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":1,"equalEarth":1,"equirectangular":1,"lambertConformalConic":1,"mercator":1,"naturalEarth":1,"winkelTripel":1,"globe":1},"default":"mercator"},"center":{"type":"array","length":2,"value":"number","minimum":[-180,-90],"maximum":[180,90]},"parallels":{"type":"array","length":2,"value":"number","minimum":[-90,-90],"maximum":[90,90]}},"terrain":{"source":{"type":"string"},"exaggeration":{"type":"number","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_building","paint_symbol","paint_raster","paint_raster-particle","paint_hillshade","paint_background","paint_sky","paint_model"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"fill-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-z-offset":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-bridge-guard-rail-color":{"type":"color","default":"rgba(241, 236, 225, 255)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature"]},"property-type":"data-driven"},"fill-tunnel-structure-color":{"type":"color","default":"rgba(241, 236, 225, 255)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature"]},"property-type":"data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"fill-extrusion-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-extrusion-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-height-alignment":{"type":"enum","values":{"terrain":1,"flat":1},"default":"flat"},"fill-extrusion-base-alignment":{"type":"enum","values":{"terrain":1,"flat":1},"default":"terrain"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-extrusion-ambient-occlusion-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-wall-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-flood-light-color":{"type":"color","default":"#ffffff","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-wall-radius":{"property-type":"data-driven","type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-radius":{"property-type":"data-driven","type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-vertical-scale":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-rounded-roof":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-extrusion-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"fill-extrusion-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"property-type":"data-driven"},"fill-extrusion-line-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-extrusion-cast-shadows":{"type":"boolean","default":true}},"paint_building":{"building-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"building-ambient-occlusion-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"parameters":[]},"transition":true},"building-ambient-occlusion-ground-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"building-ambient-occlusion-ground-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"building-ambient-occlusion-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"building-vertical-scale":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"building-cast-shadows":{"type":"boolean","default":true},"building-color":{"type":"color","default":"rgba(193, 154, 127, 1)","use-theme":true,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"property-type":"data-driven"},"building-emissive-strength":{"type":"number","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"property-type":"data-driven"},"building-facade-emissive-chance":{"type":"number","default":0.35,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["measure-light","zoom"]}},"building-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"building-flood-light-color":{"type":"color","default":"#ffffff","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"building-flood-light-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"building-flood-light-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"line-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light","line-progress"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"line-gradient":{"type":"color","use-theme":true,"expression":{"interpolated":true,"parameters":["line-progress"]}},"line-trim-offset":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1]},"line-trim-fade-range":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1],"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"line-trim-color":{"type":"color","default":"transparent","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"line-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-driven"},"line-border-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-border-color":{"type":"color","default":"rgba(0, 0, 0, 0)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-occlusion-opacity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"circle-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"circle-pitch-scale":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"circle-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"parameters":["zoom"]}},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"heatmap-color":{"type":"color","default":["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"],"use-theme":true,"expression":{"interpolated":true,"parameters":["heatmap-density"]}},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-occlusion-opacity":{"type":"number","minimum":0,"maximum":1,"default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"property-type":"data-driven"},"text-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"icon-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"icon-image-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-occlusion-opacity":{"type":"number","minimum":0,"maximum":1,"default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"overridable":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"text-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"icon-color-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{}},"icon-color-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{}},"icon-color-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"icon-color-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{}},"symbol-z-offset":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-color":{"type":"color","use-theme":true,"expression":{"interpolated":true,"parameters":["raster-value"]}},"raster-color-mix":{"type":"array","default":[0.2126,0.7152,0.0722,0],"length":4,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-color-range":{"type":"array","length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-resampling":{"type":"enum","values":{"linear":1,"nearest":1},"default":"linear","expression":{"parameters":["zoom"]}},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"raster-array-band":{"type":"string"},"raster-elevation":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-elevation-reference":{"type":"enum","values":{"sea":1,"ground":1},"default":"sea","expression":{}}},"paint_raster-particle":{"raster-particle-array-band":{"type":"string"},"raster-particle-count":{"type":"number","default":512,"minimum":1},"raster-particle-color":{"type":"color","use-theme":true,"expression":{"interpolated":true,"parameters":["raster-particle-speed"]}},"raster-particle-max-speed":{"type":"number","default":1,"minimum":1},"raster-particle-speed-factor":{"type":"number","default":0.2,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-particle-fade-opacity-factor":{"type":"number","default":0.98,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-particle-reset-rate-factor":{"type":"number","default":0.8,"minimum":0,"maximum":1},"raster-particle-elevation":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"expression":{"interpolated":true,"parameters":["zoom"]}},"hillshade-illumination-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"parameters":["zoom"]}},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"hillshade-shadow-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"hillshade-accent-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"hillshade-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}}},"paint_background":{"background-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":[]}},"background-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"background-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom"]}},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"background-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":1,"atmosphere":1},"default":"atmosphere","expression":{"parameters":["zoom"]}},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]}},"sky-atmosphere-sun-intensity":{"type":"number","default":10,"minimum":0,"maximum":100},"sky-gradient-center":{"type":"array","value":"number","default":[0,0],"length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]}},"sky-gradient-radius":{"type":"number","default":90,"minimum":0,"maximum":180,"expression":{"parameters":["zoom"]}},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"use-theme":true,"expression":{"interpolated":true,"parameters":["sky-radial-progress"]}},"sky-atmosphere-halo-color":{"type":"color","default":"white","use-theme":true},"sky-atmosphere-color":{"type":"color","default":"white","use-theme":true},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_model":{"model-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"property-type":"data-driven"},"model-rotation":{"type":"array","value":"number","length":3,"default":[0,0,0],"period":360,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-scale":{"type":"array","value":"number","length":3,"default":[1,1,1],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-translation":{"type":"array","value":"number","length":3,"default":[0,0,0],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-color":{"type":"color","default":"#ffffff","property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light","zoom"]},"use-theme":true,"transition":true},"model-color-mix-intensity":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-type":{"type":"enum","values":{"common-3d":1,"location-indicator":1},"default":"common-3d"},"model-cast-shadows":{"type":"boolean","default":true},"model-receive-shadows":{"type":"boolean","default":true},"model-ambient-occlusion-intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"model-emissive-strength":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-roughness":{"type":"number","default":1,"minimum":0,"maximum":1,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state"]},"transition":true},"model-height-based-emissive-strength-multiplier":{"type":"array","default":[1,1,1,1,0],"length":5,"value":"number","property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"model-front-cutoff":{"type":"array","value":"number","expression":{"interpolated":true,"parameters":["zoom"]},"length":3,"default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1]},"model-elevation-reference":{"type":"enum","values":{"sea":1,"ground":1,"hd-road-markup":1},"default":"ground","expression":{}}},"transition":{"duration":{"type":"number","default":300,"minimum":0},"delay":{"type":"number","default":0,"minimum":0}},"promoteId":{"*":{"type":"*"}}}');function ca(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function ha(e){if(Array.isArray(e))return e.map(ha);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){const t={};for(const r in e)t[r]=ha(e[r]);return t}return ca(e)}function pa(e){if(!0===e||!1===e)return !0;if(!Array.isArray(e)||0===e.length)return !1;switch(e[0]){case "has":return e.length>=2&&"$id"!==e[1]&&"$type"!==e[1];case "in":return e.length>=3&&("string"!=typeof e[1]||Array.isArray(e[2]));case "!in":case "!has":case "none":return !1;case "==":case "!=":case ">":case ">=":case "<":case "<=":return 3!==e.length||Array.isArray(e[1])||Array.isArray(e[2]);case "any":case "all":for(const t of e.slice(1))if(!pa(t)&&"boolean"!=typeof t)return !1;return !0;default:return !0}}function da(e,t="",r=null,n="fill"){if(null==e)return {filter:()=>!0,needGeometry:!1,needFeature:!1};pa(e)||(e=ba(e));const i=e;let s=!0;try{s=function(e){if(!ya(e))return e;let t=ha(e);return ma(t),t=fa(t),t}(i);}catch(e){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.\nThis is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md\nand paste the contents of this message in the report.\nThank you!\nFilter Expression:\n${JSON.stringify(i,null,2)}\n `);}let o=null,a=null;if("background"!==n&&"sky"!==n&&"slot"!==n){a=ua[`filter_${n}`];const e=Us(s,a,t,r);if("error"===e.result)throw new Error(e.value.map(e=>`${e.key}: ${e.message}`).join(", "));o=(t,r,n)=>e.value.evaluate(t,r,{},n);}let l=null,u=null;if(s!==i){const e=Us(i,a,t,r);if("error"===e.result)throw new Error(e.value.map(e=>`${e.key}: ${e.message}`).join(", "));l=(t,r,n,i,s)=>e.value.evaluate(t,r,{},n,void 0,void 0,i,s),u=!mi(e.value.expression);}return {filter:o,dynamicFilter:l||void 0,needGeometry:va(s),needFeature:!!u}}function fa(e){if(!Array.isArray(e))return e;const t=function(e){if(ga.has(e[0]))for(let t=1;tfa(e))}function ma(e){let t=!1;const r=[];if("case"===e[0]){for(let n=1;n",">=","<","<=","to-boolean"]);function xa(e,t){return et?1:0}function va(e){if(!Array.isArray(e))return !1;if("within"===e[0]||"distance"===e[0])return !0;for(let t=1;t"===t||"<="===t||">="===t?wa(e[1],e[2],t):"any"===t?(r=e.slice(1),["any"].concat(r.map(ba))):"all"===t?["all"].concat(e.slice(1).map(ba)):"none"===t?["all"].concat(e.slice(1).map(ba).map(Ma)):"in"===t?_a(e[1],e.slice(2)):"!in"===t?Ma(_a(e[1],e.slice(2))):"has"===t?Aa(e[1]):"!has"!==t||Ma(Aa(e[1]));var r;}function wa(e,t,r){switch(e){case "$type":return [`filter-type-${r}`,t];case "$id":return [`filter-id-${r}`,t];default:return [`filter-${r}`,e,t]}}function _a(e,t){if(0===t.length)return !1;switch(e){case "$type":return ["filter-type-in",["literal",t]];case "$id":return ["filter-id-in",["literal",t]];default:return t.length>200&&!t.some(e=>typeof e!=typeof t[0])?["filter-in-large",e,["literal",t.sort(xa)]]:["filter-in-small",e,["literal",t]]}}function Aa(e){switch(e){case "$type":return !0;case "$id":return ["filter-has-id"];default:return ["filter-has",e]}}function Ma(e){return ["!",e]}const Ia="";function Sa(e,t){return t?`${e}${Ia}${t}`:e}let za;const Pa=()=>za||(za=new la({"icon-size":new oa(ua.layout_symbol["icon-size"]),"icon-image":new oa(ua.layout_symbol["icon-image"]),"icon-rotate":new oa(ua.layout_symbol["icon-rotate"]),"icon-offset":new oa(ua.layout_symbol["icon-offset"]),"text-size":new oa(ua.layout_symbol["text-size"]),"text-rotate":new oa(ua.layout_symbol["text-rotate"]),"text-offset":new oa(ua.layout_symbol["text-offset"])}));class Ba{constructor(e,t,r,n,i,s){const o=Us(e,ua.appearance.condition);if("success"===o.result&&(this.condition=o.value),this.name=t,r){this.properties=new ia(Pa()),this.unevaluatedLayout=new ra(Pa(),n,i,s);for(const e in r)this.unevaluatedLayout.setValue(e,r[e]);}}isActive(e){return !(this.condition||!e.isHidden||"hidden"!==this.name)||this.condition.evaluate(e.globals,e.feature,e.featureState,e.canonical)}getCondition(){return this.condition}getName(){return this.name}getProperty(e){return this.properties.get(e)}getUnevaluatedProperties(){return this.unevaluatedLayout}getUnevaluatedProperty(e){return this.unevaluatedLayout._values[e]}recalculate(e,t,r){this.unevaluatedLayout&&(this.properties=this.unevaluatedLayout.possiblyEvaluate(e,void 0,t,r));}serialize(){const e={};return e.condition=this.condition.expression.serialize(),this.name&&(e.name=this.name),this.unevaluatedLayout&&(e.properties=this.unevaluatedLayout.serialize()),e}hasIconProperties(){const e=this.hasProperty("icon-image"),t=this.hasProperty("icon-size"),r=this.hasProperty("icon-offset"),n=this.hasProperty("icon-rotate");return e||t||r||n}hasTextProperties(){const e=this.hasProperty("text-size"),t=this.hasProperty("text-offset"),r=this.hasProperty("text-rotate");return e||t||r}hasProperty(e){return void 0!==this.getUnevaluatedProperty(e).value}}const Ta="-transition",ka=new Set(["fill","line","background","hillshade","raster"]);class Va extends rr{constructor(e,t,r,n,i,s){if(super(),this.id=e.id,this.fqid=Sa(this.id,r),this.type=e.type,this.scope=r,this.lut=n,this.options=i,this.iconImageUseTheme=s,this.appearances=new Array,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,this.expressionDependencies={isIndoorDependent:!1,configDependencies:new Set},"custom"!==e.type){if(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,e.type&&"background"!==e.type&&"sky"!==e.type&&"slot"!==e.type){this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter;const t=Us(this.filter,ua[`filter_${e.type}`]);"error"!==t.result&&(this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...t.value.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||t.value.isIndoorDependent);}if(e.slot&&(this.slot=e.slot),e.appearances&&this.setAppearances(e.appearances),t.layout&&(this._unevaluatedLayout=new ra(t.layout,this.scope,i,this.iconImageUseTheme),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...this._unevaluatedLayout.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||this._unevaluatedLayout.isIndoorDependent()),t.paint){this._transitionablePaint=new Qo(t.paint,this.scope,i);for(const t in e.paint)this.setPaintProperty(t,e.paint[t]);for(const t in e.layout)this.setLayoutProperty(t,e.layout[t]);this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...this._transitionablePaint.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||this._transitionablePaint.isIndoorDependent(),this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new ia(t.paint);}}}onAdd(e){}onRemove(e){}isDraped(e){return !this.is3D(!0)&&ka.has(this.type)}getLayoutProperty(e){return "visibility"===e?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,t){if("custom"===this.type&&"visibility"===e)return void(this.visibility=t);const r=this._unevaluatedLayout;r._properties.properties[e]&&(r.setValue(e,t),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...r.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||r.isIndoorDependent(),"visibility"===e&&this.possiblyEvaluateVisibility());}setAppearances(e){this.appearances=[],e.forEach(e=>{this.appearances.push(new Ba(e.condition,e.name,e.properties,this.scope,this.options,this.iconImageUseTheme));});}possiblyEvaluateVisibility(){this._unevaluatedLayout._values.visibility&&(this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0}));}getPaintProperty(e){return e.endsWith(Ta)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}isPaintProperty(e){return !!this._transitionablePaint._properties.properties[e]}setPaintProperty(e,t){const r=this._transitionablePaint,n=r._properties.properties;if(e.endsWith(Ta)){const i=e.slice(0,-11);return n[i]&&r.setTransition(i,t||void 0),!1}if(!n[e])return !1;const i=r._values[e],s=i.value.isDataDriven(),o=i.value;r.setValue(e,t),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...r.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||r.isIndoorDependent(),this._handleSpecialPaintPropertyUpdate(e);const a=r._values[e].value,l=a.isDataDriven(),u=e.endsWith("pattern")||"line-dasharray"===e;return l||s||u||this._handleOverridablePaintPropertyUpdate(e,o,a)}_handleSpecialPaintPropertyUpdate(e){}getProgramIds(){return null}getDefaultProgramParams(e,t,r){return null}_handleOverridablePaintPropertyUpdate(e,t,r){return !1}isHidden(e){return !!(this.minzoom&&e=this.maxzoom)||"none"===this.visibility}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint);}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,t){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,t,this.iconImageUseTheme)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,t);}serialize(){const e={id:this.id,type:this.type,slot:this.slot,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return 0!==this.appearances.length&&(e.appearances=this.appearances.map(e=>e.serialize())),$e(e,(e,t)=>!(void 0===e||"layout"===t&&!Object.keys(e).length||"paint"===t&&!Object.keys(e).length))}is3D(e){return !1}hasElevation(){return !1}isSky(){return !1}isTileClipped(){return !1}hasOffscreenPass(){return !1}hasShadowPass(){return !1}canCastShadows(){return !1}hasLightBeamPass(){return !1}cutoffRange(){return 0}tileCoverLift(){return 0}resize(){}_clear(){}isStateDependent(){for(const e in this.paint._values){const t=this.paint.get(e);if(t instanceof na&&Ss(t.property.specification)&&("source"===t.value.kind||"composite"===t.value.kind)&&t.value.isStateDependent)return !0}for(const e of this.appearances)if(!yi(e.condition.expression))return !0;return !1}compileFilter(e){this._filterCompiled||(this._featureFilter=da(this.filter,this.scope,e),this._filterCompiled=!0);}invalidateCompiledFilter(){this._filterCompiled=!1;}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}dynamicFilterNeedsGeometry(){return this._featureFilter.needGeometry}getLayerRenderingStats(){return this._stats}resetLayerRenderingStats(e){this._stats&&("shadow"===e.renderPass?this._stats.numRenderedVerticesInShadowPass=0:this._stats.numRenderedVerticesInTransparentPass=0);}getAppearances(){return this.appearances}queryRenderedFeatures(e,t,r){return {}}queryRadius(e){}queryIntersectsFeature(e,t,r,n,i,s,o,a,l,u){}}const Ea={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Fa{constructor(e,t){this._structArray=e,this._pos1=t*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8;}}const Da=new ArrayBuffer(0);class Ca{constructor(){this._reallocCount=0,this.capacity=0,this.length=0;}static serialize(e,t){return e._trim(),t&&e.arrayBuffer&&t.add(e.arrayBuffer),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const t=Object.create(this.prototype);return t.arrayBuffer=e.arrayBuffer,t.length=e.length,e.arrayBuffer?t.capacity=e.arrayBuffer.byteLength/t.bytesPerElement:(t.capacity=0,t.arrayBuffer=Da),t._refreshViews(),t}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews());}clear(){this.length=0;}resize(e){this.reserve(e),this.length=e;}reserve(e){if(e>this.capacity){this._reallocCount++,this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const t=this.uint8;this._refreshViews(),t&&this.uint8.set(t);}}reserveForAdditional(e){this.reserve(this.length+e);}_refreshViews(){throw new Error("StructArray#_refreshViews() must be implemented by each concrete StructArray layout")}emplace(...e){throw new Error("StructArray#emplace() must be implemented by each concrete StructArray layout")}emplaceBack(...e){throw new Error("StructArray#emplaceBack() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null;}}function Ra(e,t=1){let r=0,n=0;return {members:e.map(e=>{const i=Ea[e.type].BYTES_PER_ELEMENT,s=r=La(r,Math.max(t,i)),o=e.components||1;return n=Math.max(n,i),r+=i*o,{name:e.name,type:e.type,components:o,offset:s}}),size:La(r,Math.max(n,t)),alignment:t}}function La(e,t){return Math.ceil(e/t)*t}class Oa extends Ca{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t){const r=this.length;return this.resize(r+1),this.emplace(r,e,t)}emplace(e,t,r){const n=2*e;return this.int16[n+0]=t,this.int16[n+1]=r,e}}Oa.prototype.bytesPerElement=4,Js(Oa,"StructArrayLayout2i4");class Ua extends Ca{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,r)}emplace(e,t,r,n){const i=3*e;return this.int16[i+0]=t,this.int16[i+1]=r,this.int16[i+2]=n,e}}Ua.prototype.bytesPerElement=6,Js(Ua,"StructArrayLayout3i6");class Na extends Ca{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,r,n)}emplace(e,t,r,n,i){const s=4*e;return this.int16[s+0]=t,this.int16[s+1]=r,this.int16[s+2]=n,this.int16[s+3]=i,e}}Na.prototype.bytesPerElement=8,Js(Na,"StructArrayLayout4i8");class ja extends Ca{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.float32[1*e+0]=t,e}}ja.prototype.bytesPerElement=4,Js(ja,"StructArrayLayout1f4");class Ga extends Ca{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,r)}emplace(e,t,r,n){const i=4*e,s=2*e;return this.int16[i+0]=t,this.int16[i+1]=r,this.float32[s+1]=n,e}}Ga.prototype.bytesPerElement=8,Js(Ga,"StructArrayLayout2i1f8");class $a extends Ca{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,r)}emplace(e,t,r,n){const i=4*e;return this.int16[i+0]=t,this.int16[i+1]=r,this.int16[i+2]=n,e}}$a.prototype.bytesPerElement=8,Js($a,"StructArrayLayout3i8");class qa extends Ca{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,r,n,i)}emplace(e,t,r,n,i,s){const o=5*e;return this.int16[o+0]=t,this.int16[o+1]=r,this.int16[o+2]=n,this.int16[o+3]=i,this.int16[o+4]=s,e}}qa.prototype.bytesPerElement=10,Js(qa,"StructArrayLayout5i10");class Xa extends Ca{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s,o){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,r,n,i,s,o)}emplace(e,t,r,n,i,s,o,a){const l=6*e,u=12*e,c=3*e;return this.int16[l+0]=t,this.int16[l+1]=r,this.uint8[u+4]=n,this.uint8[u+5]=i,this.uint8[u+6]=s,this.uint8[u+7]=o,this.float32[c+2]=a,e}}Xa.prototype.bytesPerElement=12,Js(Xa,"StructArrayLayout2i4ub1f12");class Ha extends Ca{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,r)}emplace(e,t,r,n){const i=3*e;return this.float32[i+0]=t,this.float32[i+1]=r,this.float32[i+2]=n,e}}Ha.prototype.bytesPerElement=12,Js(Ha,"StructArrayLayout3f12");class Za extends Ca{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,r,n,i)}emplace(e,t,r,n,i,s){const o=6*e,a=3*e;return this.uint16[o+0]=t,this.uint16[o+1]=r,this.uint16[o+2]=n,this.uint16[o+3]=i,this.float32[a+2]=s,e}}Za.prototype.bytesPerElement=12,Js(Za,"StructArrayLayout4ui1f12");class Wa extends Ca{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e,t,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,r,n)}emplace(e,t,r,n,i){const s=4*e;return this.uint16[s+0]=t,this.uint16[s+1]=r,this.uint16[s+2]=n,this.uint16[s+3]=i,e}}Wa.prototype.bytesPerElement=8,Js(Wa,"StructArrayLayout4ui8");class Ya extends Ca{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,r,n,i,s)}emplace(e,t,r,n,i,s,o){const a=6*e;return this.int16[a+0]=t,this.int16[a+1]=r,this.int16[a+2]=n,this.int16[a+3]=i,this.int16[a+4]=s,this.int16[a+5]=o,e}}Ya.prototype.bytesPerElement=12,Js(Ya,"StructArrayLayout6i12");class Ja extends Ca{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s,o,a,l,u,c,h){const p=this.length;return this.resize(p+1),this.emplace(p,e,t,r,n,i,s,o,a,l,u,c,h)}emplace(e,t,r,n,i,s,o,a,l,u,c,h,p){const d=12*e;return this.int16[d+0]=t,this.int16[d+1]=r,this.int16[d+2]=n,this.int16[d+3]=i,this.uint16[d+4]=s,this.uint16[d+5]=o,this.uint16[d+6]=a,this.uint16[d+7]=l,this.int16[d+8]=u,this.int16[d+9]=c,this.int16[d+10]=h,this.int16[d+11]=p,e}}Ja.prototype.bytesPerElement=24,Js(Ja,"StructArrayLayout4i4ui4i24");class Ka extends Ca{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,r,n,i,s)}emplace(e,t,r,n,i,s,o){const a=10*e,l=5*e;return this.int16[a+0]=t,this.int16[a+1]=r,this.int16[a+2]=n,this.float32[l+2]=i,this.float32[l+3]=s,this.float32[l+4]=o,e}}Ka.prototype.bytesPerElement=20,Js(Ka,"StructArrayLayout3i3f20");class Qa extends Ca{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,r,n)}emplace(e,t,r,n,i){const s=4*e;return this.float32[s+0]=t,this.float32[s+1]=r,this.float32[s+2]=n,this.float32[s+3]=i,e}}Qa.prototype.bytesPerElement=16,Js(Qa,"StructArrayLayout4f16");class el extends Ca{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer);}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint32[1*e+0]=t,e}}el.prototype.bytesPerElement=4,Js(el,"StructArrayLayout1ul4");class tl extends Ca{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e,t){const r=this.length;return this.resize(r+1),this.emplace(r,e,t)}emplace(e,t,r){const n=2*e;return this.uint16[n+0]=t,this.uint16[n+1]=r,e}}tl.prototype.bytesPerElement=4,Js(tl,"StructArrayLayout2ui4");class rl extends Ca{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s,o,a,l,u,c,h,p){const d=this.length;return this.resize(d+1),this.emplace(d,e,t,r,n,i,s,o,a,l,u,c,h,p)}emplace(e,t,r,n,i,s,o,a,l,u,c,h,p,d){const f=20*e,m=10*e;return this.int16[f+0]=t,this.int16[f+1]=r,this.int16[f+2]=n,this.int16[f+3]=i,this.int16[f+4]=s,this.float32[m+3]=o,this.float32[m+4]=a,this.float32[m+5]=l,this.float32[m+6]=u,this.int16[f+14]=c,this.uint32[m+8]=h,this.uint16[f+18]=p,this.uint16[f+19]=d,e}}rl.prototype.bytesPerElement=40,Js(rl,"StructArrayLayout5i4f1i1ul2ui40");class nl extends Ca{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s,o){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,r,n,i,s,o)}emplace(e,t,r,n,i,s,o,a){const l=8*e;return this.int16[l+0]=t,this.int16[l+1]=r,this.int16[l+2]=n,this.int16[l+4]=i,this.int16[l+5]=s,this.int16[l+6]=o,this.int16[l+7]=a,e}}nl.prototype.bytesPerElement=16,Js(nl,"StructArrayLayout3i2i2i16");class il extends Ca{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,r,n,i)}emplace(e,t,r,n,i,s){const o=4*e,a=8*e;return this.float32[o+0]=t,this.float32[o+1]=r,this.float32[o+2]=n,this.int16[a+6]=i,this.int16[a+7]=s,e}}il.prototype.bytesPerElement=16,Js(il,"StructArrayLayout2f1f2i16");class sl extends Ca{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,r,n,i,s)}emplace(e,t,r,n,i,s,o){const a=20*e,l=5*e;return this.uint8[a+0]=t,this.uint8[a+1]=r,this.float32[l+1]=n,this.float32[l+2]=i,this.float32[l+3]=s,this.float32[l+4]=o,e}}sl.prototype.bytesPerElement=20,Js(sl,"StructArrayLayout2ub4f20");class ol extends Ca{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e,t,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,r)}emplace(e,t,r,n){const i=3*e;return this.uint16[i+0]=t,this.uint16[i+1]=r,this.uint16[i+2]=n,e}}ol.prototype.bytesPerElement=6,Js(ol,"StructArrayLayout3ui6");class al extends Ca{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s,o,a,l,u,c,h,p,d,f,m,y,g,x,v,b){const w=this.length;return this.resize(w+1),this.emplace(w,e,t,r,n,i,s,o,a,l,u,c,h,p,d,f,m,y,g,x,v,b)}emplace(e,t,r,n,i,s,o,a,l,u,c,h,p,d,f,m,y,g,x,v,b,w){const _=30*e,A=15*e,M=60*e;return this.int16[_+0]=t,this.int16[_+1]=r,this.int16[_+2]=n,this.float32[A+2]=i,this.float32[A+3]=s,this.uint16[_+8]=o,this.uint16[_+9]=a,this.uint32[A+5]=l,this.uint32[A+6]=u,this.uint32[A+7]=c,this.uint16[_+16]=h,this.uint16[_+17]=p,this.uint16[_+18]=d,this.float32[A+10]=f,this.float32[A+11]=m,this.uint8[M+48]=y,this.uint8[M+49]=g,this.uint8[M+50]=x,this.uint32[A+13]=v,this.int16[_+28]=b,this.uint8[M+58]=w,e}}al.prototype.bytesPerElement=60,Js(al,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class ll extends Ca{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s,o,a,l,u,c,h,p,d,f,m,y,g,x,v,b,w,_,A,M,I,S,z,P,B,T,k,V){const E=this.length;return this.resize(E+1),this.emplace(E,e,t,r,n,i,s,o,a,l,u,c,h,p,d,f,m,y,g,x,v,b,w,_,A,M,I,S,z,P,B,T,k,V)}emplace(e,t,r,n,i,s,o,a,l,u,c,h,p,d,f,m,y,g,x,v,b,w,_,A,M,I,S,z,P,B,T,k,V,E){const F=20*e,D=40*e,C=80*e;return this.float32[F+0]=t,this.float32[F+1]=r,this.int16[D+4]=n,this.int16[D+5]=i,this.int16[D+6]=s,this.int16[D+7]=o,this.int16[D+8]=a,this.int16[D+9]=l,this.int16[D+10]=u,this.int16[D+11]=c,this.int16[D+12]=h,this.uint16[D+13]=p,this.uint16[D+14]=d,this.uint16[D+15]=f,this.uint16[D+16]=m,this.uint16[D+17]=y,this.uint16[D+18]=g,this.uint16[D+19]=x,this.uint16[D+20]=v,this.uint16[D+21]=b,this.uint16[D+22]=w,this.uint16[D+23]=_,this.uint16[D+24]=A,this.uint16[D+25]=M,this.uint16[D+26]=I,this.uint16[D+27]=S,this.uint32[F+14]=z,this.float32[F+15]=P,this.float32[F+16]=B,this.float32[F+17]=T,this.float32[F+18]=k,this.uint8[C+76]=V,this.uint16[D+39]=E,e}}ll.prototype.bytesPerElement=80,Js(ll,"StructArrayLayout2f9i15ui1ul4f1ub1ui80");class ul extends Ca{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,r,n,i,s)}emplace(e,t,r,n,i,s,o){const a=6*e;return this.float32[a+0]=t,this.float32[a+1]=r,this.float32[a+2]=n,this.float32[a+3]=i,this.float32[a+4]=s,this.float32[a+5]=o,e}}ul.prototype.bytesPerElement=24,Js(ul,"StructArrayLayout6f24");class cl extends Ca{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,r,n,i)}emplace(e,t,r,n,i,s){const o=5*e;return this.float32[o+0]=t,this.float32[o+1]=r,this.float32[o+2]=n,this.float32[o+3]=i,this.float32[o+4]=s,e}}cl.prototype.bytesPerElement=20,Js(cl,"StructArrayLayout5f20");class hl extends Ca{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s,o){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,r,n,i,s,o)}emplace(e,t,r,n,i,s,o,a){const l=7*e;return this.float32[l+0]=t,this.float32[l+1]=r,this.float32[l+2]=n,this.float32[l+3]=i,this.float32[l+4]=s,this.float32[l+5]=o,this.float32[l+6]=a,e}}hl.prototype.bytesPerElement=28,Js(hl,"StructArrayLayout7f28");class pl extends Ca{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s,o,a,l,u,c){const h=this.length;return this.resize(h+1),this.emplace(h,e,t,r,n,i,s,o,a,l,u,c)}emplace(e,t,r,n,i,s,o,a,l,u,c,h){const p=11*e;return this.float32[p+0]=t,this.float32[p+1]=r,this.float32[p+2]=n,this.float32[p+3]=i,this.float32[p+4]=s,this.float32[p+5]=o,this.float32[p+6]=a,this.float32[p+7]=l,this.float32[p+8]=u,this.float32[p+9]=c,this.float32[p+10]=h,e}}pl.prototype.bytesPerElement=44,Js(pl,"StructArrayLayout11f44");class dl extends Ca{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s,o,a,l){const u=this.length;return this.resize(u+1),this.emplace(u,e,t,r,n,i,s,o,a,l)}emplace(e,t,r,n,i,s,o,a,l,u){const c=9*e;return this.float32[c+0]=t,this.float32[c+1]=r,this.float32[c+2]=n,this.float32[c+3]=i,this.float32[c+4]=s,this.float32[c+5]=o,this.float32[c+6]=a,this.float32[c+7]=l,this.float32[c+8]=u,e}}dl.prototype.bytesPerElement=36,Js(dl,"StructArrayLayout9f36");class fl extends Ca{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t){const r=this.length;return this.resize(r+1),this.emplace(r,e,t)}emplace(e,t,r){const n=2*e;return this.float32[n+0]=t,this.float32[n+1]=r,e}}fl.prototype.bytesPerElement=8,Js(fl,"StructArrayLayout2f8");class ml extends Ca{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e,t,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,r,n)}emplace(e,t,r,n,i){const s=6*e;return this.uint32[3*e+0]=t,this.uint16[s+2]=r,this.uint16[s+3]=n,this.uint16[s+4]=i,e}}ml.prototype.bytesPerElement=12,Js(ml,"StructArrayLayout1ul3ui12");class yl extends Ca{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint16[1*e+0]=t,e}}yl.prototype.bytesPerElement=2,Js(yl,"StructArrayLayout1ui2");class gl extends Ca{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s,o,a,l,u,c,h,p,d,f,m){const y=this.length;return this.resize(y+1),this.emplace(y,e,t,r,n,i,s,o,a,l,u,c,h,p,d,f,m)}emplace(e,t,r,n,i,s,o,a,l,u,c,h,p,d,f,m,y){const g=16*e;return this.float32[g+0]=t,this.float32[g+1]=r,this.float32[g+2]=n,this.float32[g+3]=i,this.float32[g+4]=s,this.float32[g+5]=o,this.float32[g+6]=a,this.float32[g+7]=l,this.float32[g+8]=u,this.float32[g+9]=c,this.float32[g+10]=h,this.float32[g+11]=p,this.float32[g+12]=d,this.float32[g+13]=f,this.float32[g+14]=m,this.float32[g+15]=y,e}}gl.prototype.bytesPerElement=64,Js(gl,"StructArrayLayout16f64");class xl extends Ca{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,r,n,i,s,o){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,r,n,i,s,o)}emplace(e,t,r,n,i,s,o,a){const l=10*e,u=5*e;return this.uint16[l+0]=t,this.uint16[l+1]=r,this.uint16[l+2]=n,this.uint16[l+3]=i,this.float32[u+2]=s,this.float32[u+3]=o,this.float32[u+4]=a,e}}xl.prototype.bytesPerElement=20,Js(xl,"StructArrayLayout4ui3f20");class vl extends Ca{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.int16[1*e+0]=t,e}}vl.prototype.bytesPerElement=2,Js(vl,"StructArrayLayout1i2");class bl extends Ca{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer);}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint8[1*e+0]=t,e}}bl.prototype.bytesPerElement=1,Js(bl,"StructArrayLayout1ub1");class wl extends Fa{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.int16[this._pos2+3]}get tileAnchorY(){return this._structArray.int16[this._pos2+4]}get x1(){return this._structArray.float32[this._pos4+3]}get y1(){return this._structArray.float32[this._pos4+4]}get x2(){return this._structArray.float32[this._pos4+5]}get y2(){return this._structArray.float32[this._pos4+6]}get padding(){return this._structArray.int16[this._pos2+14]}get featureIndex(){return this._structArray.uint32[this._pos4+8]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+18]}get bucketIndex(){return this._structArray.uint16[this._pos2+19]}}wl.prototype.size=40;class _l extends rl{get(e){return new wl(this,e)}}Js(_l,"CollisionBoxArray");class Al extends Fa{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(e){this._structArray.uint8[this._pos1+49]=e;}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(e){this._structArray.uint8[this._pos1+50]=e;}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(e){this._structArray.uint32[this._pos4+13]=e;}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(e){this._structArray.uint8[this._pos1+58]=e;}}Al.prototype.size=60;class Ml extends al{get(e){return new Al(this,e)}}Js(Ml,"PlacedSymbolArray");class Il extends Fa{get tileAnchorX(){return this._structArray.float32[this._pos4+0]}get tileAnchorY(){return this._structArray.float32[this._pos4+1]}get projectedAnchorX(){return this._structArray.int16[this._pos2+4]}get projectedAnchorY(){return this._structArray.int16[this._pos2+5]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+6]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+7]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+11]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get key(){return this._structArray.uint16[this._pos2+13]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+14]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+15]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+17]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+19]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+21]}get featureIndex(){return this._structArray.uint16[this._pos2+22]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+23]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numIconVertices(){return this._structArray.uint16[this._pos2+25]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+26]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+27]}get crossTileID(){return this._structArray.uint32[this._pos4+14]}set crossTileID(e){this._structArray.uint32[this._pos4+14]=e;}get textOffset0(){return this._structArray.float32[this._pos4+15]}get textOffset1(){return this._structArray.float32[this._pos4+16]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+17]}get zOffset(){return this._structArray.float32[this._pos4+18]}set zOffset(e){this._structArray.float32[this._pos4+18]=e;}get hasIconTextFit(){return this._structArray.uint8[this._pos1+76]}get elevationFeatureIndex(){return this._structArray.uint16[this._pos2+39]}}Il.prototype.size=80;class Sl extends ll{get(e){return new Il(this,e)}}Js(Sl,"SymbolInstanceArray");class zl extends ja{getoffsetX(e){return this.float32[1*e+0]}}Js(zl,"GlyphOffsetArray");class Pl extends Oa{getx(e){return this.int16[2*e+0]}gety(e){return this.int16[2*e+1]}}Js(Pl,"SymbolLineVertexArray");class Bl extends Fa{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}get layoutVertexArrayOffset(){return this._structArray.uint16[this._pos2+4]}}Bl.prototype.size=12;class Tl extends ml{get(e){return new Bl(this,e)}}Js(Tl,"FeatureIndexArray");class kl extends tl{geta_centroid_pos0(e){return this.uint16[2*e+0]}geta_centroid_pos1(e){return this.uint16[2*e+1]}}Js(kl,"FillExtrusionCentroidArray");class Vl extends Fa{get a_join_normal_inside0(){return this._structArray.int16[this._pos2+0]}get a_join_normal_inside1(){return this._structArray.int16[this._pos2+1]}get a_join_normal_inside2(){return this._structArray.int16[this._pos2+2]}}Vl.prototype.size=6;class El extends Ua{get(e){return new Vl(this,e)}}Js(El,"FillExtrusionWallArray");const Fl=Ra([{name:"a_pos",components:2,type:"Int16"}],4),Dl=Ra([{name:"a_circle_z_offset",components:1,type:"Float32"}],4),Cl=Ra([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class Rl{constructor(e=[]){this.segments=e;}_prepareSegment(e,t,r,n){let i=this.segments[this.segments.length-1];return e>Rl.MAX_VERTEX_ARRAY_LENGTH&&Ze(`Max vertices per segment is ${Rl.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!i||i.vertexLength+e>Rl.MAX_VERTEX_ARRAY_LENGTH||i.sortKey!==n)&&(i={vertexOffset:t,primitiveOffset:r,vertexLength:0,primitiveLength:0},void 0!==n&&(i.sortKey=n),this.segments.push(i)),i}prepareSegment(e,t,r,n){return this._prepareSegment(e,t.length,r.length,n)}get(){return this.segments}destroy(){for(const e of this.segments)for(const t in e.vaos)e.vaos[t].destroy();}static simpleSegment(e,t,r,n){return new Rl([{vertexOffset:e,primitiveOffset:t,vertexLength:r,primitiveLength:n,vaos:{},sortKey:0}])}}function Ll(e,t){return 256*(e=De(Math.floor(e),0,255))+De(Math.floor(t),0,255)}Rl.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Js(Rl,"SegmentVector");const Ol=Ra([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),Ul=Ra([{name:"a_pattern_b",components:4,type:"Uint16"}]),Nl=Ra([{name:"a_dash",components:4,type:"Uint16"}]);class jl{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1;}add(e,t,r,n){this.ids.push(Gl(e)),this.positions.push(t,r,n);}eachPosition(e,t){const r=Gl(e);let n=0,i=this.ids.length-1;for(;n>1;this.ids[e]>=r?i=e:n=e+1;}for(;this.ids[n]===r;)t(this.positions[3*n],this.positions[3*n+1],this.positions[3*n+2]),n++;}static serialize(e,t){const r=new Float64Array(e.ids),n=new Uint32Array(e.positions);return $l(r,n,0,r.length-1),t&&(t.add(r.buffer),t.add(n.buffer)),{ids:r,positions:n}}static deserialize(e){const t=new jl;let r;t.ids=e.ids,t.positions=e.positions;for(const e of t.ids)e!==r&&t.uniqueIds.push(e),r=e;return t.indexed=!0,t}}function Gl(e){const t=+e;return Number.isSafeInteger(t)?t:Jt(String(e))}function $l(e,t,r,n){for(;r>1];let s=r-1,o=n+1;for(;;){do{s++;}while(e[s]i);if(s>=o)break;ql(e,s,o),ql(t,3*s,3*o),ql(t,3*s+1,3*o+1),ql(t,3*s+2,3*o+2);}o-r`u_${e}`),this.type=r,this.context=n;}setUniform(e,t,r,n,i){const s=n.constantOr(this.value);t.set(e,i,s instanceof ar?s.toPremultipliedRenderColor(this.lutExpression&&"constant"===this.lutExpression.kind&&"none"===this.lutExpression.value?null:this.context.lut):s);}getBinding(e,t){return "color"===this.type?new Kl(e):new Zl(e)}}class au{constructor(e,t){this.uniformNames=t.map(e=>`u_${e}`),this.pattern=null,this.patternTransition=null,this.pixelRatio=1;}setConstantPatternPositions(e,t){this.pixelRatio=e.pixelRatio||1,this.pattern=e.tl.concat(e.br),this.patternTransition=t?t.tl.concat(t.br):this.pattern;}setUniform(e,t,r,n,i){let s=null;"u_pattern"!==i&&"u_dash"!==i||(s=this.pattern),"u_pattern_b"===i&&(s=this.patternTransition),"u_pixel_ratio"===i&&(s=this.pixelRatio),s&&t.set(e,i,s);}getBinding(e,t){return "u_pattern"===t||"u_pattern_b"===t||"u_dash"===t?new Jl(e):new Zl(e)}}class lu{constructor(e,t,r,n){this.expression=e,this.type=r,this.maxValue=0,this.paintVertexAttributes=t.map(e=>({name:`a_${e}`,type:"Float32",components:"color"===r?2:1,offset:0})),this.paintVertexArray=new n;}populatePaintArray(e,t,r,n,i,s,o,a){const l=this.paintVertexArray.length,u="composite"===this.expression.kind||"source"===this.expression.kind?this.expression.evaluate(new Yo(0,{brightness:s,worldview:a}),t,{},i,n,o):"constant"===this.expression.kind&&this.expression.value,c=su(this.lutExpression,t,{},n,i,s,o,a);this.paintVertexArray.resize(e),this._setPaintValue(l,e,u,c?null:this.context.lut);}updatePaintArray(e,t,r,n,i,s,o,a){const l="composite"===this.expression.kind||"source"===this.expression.kind?this.expression.evaluate({zoom:0,brightness:o,worldview:a},r,n,void 0,i):"constant"===this.expression.kind&&this.expression.value,u=su(this.lutExpression,r,n,i,void 0,o,void 0,a);this._setPaintValue(e,t,l,u?null:this.context.lut);}_setPaintValue(e,t,r,n){if("color"===this.type){const i=iu(r.toPremultipliedRenderColor(n));for(let r=e;r`u_${e}_t`),this.type=r,this.useIntegerZoom=n,this.context=i,this.maxValue=0,this.paintVertexAttributes=t.map(e=>({name:`a_${e}`,type:"Float32",components:"color"===r?4:2,offset:0})),this.paintVertexArray=new s;}populatePaintArray(e,t,r,n,i,s,o,a){const l=this.expression.evaluate(new Yo(this.context.zoom,{brightness:s,worldview:a}),t,{},i,n,o),u=this.expression.evaluate(new Yo(this.context.zoom+1,{brightness:s,worldview:a}),t,{},i,n,o),c=su(this.lutExpression,t,{},n,i,s,o,a),h=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(h,e,l,u,c?null:this.context.lut);}updatePaintArray(e,t,r,n,i,s,o,a){const l=this.expression.evaluate({zoom:this.context.zoom,brightness:o,worldview:a},r,n,void 0,i),u=this.expression.evaluate({zoom:this.context.zoom+1,brightness:o,worldview:a},r,n,void 0,i),c=su(this.lutExpression,r,n,i,void 0,o,void 0,a);this._setPaintValue(e,t,l,u,c?null:this.context.lut);}_setPaintValue(e,t,r,n,i){if("color"===this.type){const s=iu(r.toPremultipliedRenderColor(i)),o=iu(n.toPremultipliedRenderColor(i));for(let r=e;r!0){this.binders={},this._buffers=[],this.context=t;const n=[];for(const i in e.paint._values){const s=e.paint.get(i);if(i.endsWith("-use-theme"))continue;if(!r(i))continue;if(!(s instanceof na&&Ss(s.property.specification)))continue;const o=fu(i,e.type),a=s.value,l=s.property.specification.type,u=!!s.property.useIntegerZoom,c="line-dasharray"===i||i.endsWith("pattern"),h=e.paint.get(`${i}-use-theme`),p="line-dasharray"===i&&"constant"!==e.layout.get("line-cap").value.kind||h&&"constant"!==h.value.kind;if("constant"!==a.kind||p)if("source"===a.kind||p||c){const t=gu(i,l,"source");this.binders[i]=c?new cu(a,o,l,t,e.id):new lu(a,o,l,t),n.push(`/a_${i}`);}else {const e=gu(i,l,"composite");this.binders[i]=new uu(a,o,l,u,t,e),n.push(`/z_${i}`);}else this.binders[i]=c?new au(a.value,o):new ou(a.value,o,l,t),n.push(`/u_${i}`);h&&(this.binders[i].lutExpression=h.value);}this.cacheKey=n.sort().join("");}getMaxValue(e){const t=this.binders[e];return t instanceof lu||t instanceof uu?t.maxValue:0}populatePaintArrays(e,t,r,n,i,s,o,a){for(const l in this.binders){const u=this.binders[l];u.context=this.context,(u instanceof lu||u instanceof uu||u instanceof cu)&&u.populatePaintArray(e,t,r,n,i,s,o,a);}}setConstantPatternPositions(e,t){for(const r in this.binders){const n=this.binders[r];n instanceof au&&n.setConstantPatternPositions(e,t);}}getPatternTransitionVertexBuffer(e){const t=this.binders[e];return t instanceof cu?t.paintTransitionVertexBuffer:null}updatePaintArrays(e,t,r,n,i,s,o,a,l,u){let c=!1;const h=Object.keys(e),p=0!==h.length&&!a,d=p?h:t.uniqueIds;this.context.lut=i.lut;for(const a in this.binders){const h=this.binders[a];if(h.context=this.context,(h instanceof lu||h instanceof uu||h instanceof cu)&&h.expression&&h.expression.kind&&"constant"!==h.expression.kind&&(!0===h.expression.isStateDependent||!1===h.expression.isLightConstant)){const f=i.paint.get(a);h.expression=f.value;for(const r of d){const i=e[r.toString()];t.eachPosition(r,(e,t,r)=>{const a=n.feature(e);h.updatePaintArray(t,r,a,i,s,o,l,u);});}if(!p)for(const t of r.uniqueIds){const i=e[t.toString()];r.eachPosition(t,(e,t,r)=>{const a=n.feature(e);h.updatePaintArray(t,r,a,i,s,o,l,u);});}c=!0;}}return c}defines(){const e=[];for(const t in this.binders){const r=this.binders[t];(r instanceof ou||r instanceof au)&&e.push(...r.uniformNames.map(e=>`#define HAS_UNIFORM_${e}`));}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e){const t=[];for(const r in this.binders){const n=this.binders[r];if(n instanceof ou||n instanceof au||n instanceof uu)for(const i of n.uniformNames)t.push({name:i,property:r,binding:n.getBinding(e,i)});}return t}setUniforms(e,t,r,n,i){for(const{name:t,property:s,binding:o}of r)this.binders[s].setUniform(e,o,i,n.get(s),t);}updatePaintBuffers(){this._buffers=[];for(const e in this.binders){const t=this.binders[e];(t instanceof lu||t instanceof uu||t instanceof cu)&&t.paintVertexBuffer&&this._buffers.push(t.paintVertexBuffer),t instanceof cu&&t.paintTransitionVertexBuffer&&this._buffers.push(t.paintTransitionVertexBuffer);}}upload(e){for(const t in this.binders){const r=this.binders[t];(r instanceof lu||r instanceof uu||r instanceof cu)&&r.upload(e);}this.updatePaintBuffers();}destroy(){for(const e in this.binders){const t=this.binders[e];(t instanceof lu||t instanceof uu||t instanceof cu)&&t.destroy();}}}class pu{constructor(e,t,r=()=>!0){this.programConfigurations={};for(const n of e)this.programConfigurations[n.id]=new hu(n,t,r);this.needsUpload=!1,this._featureMap=new jl,this._featureMapWithoutIds=new jl,this._bufferOffset=0,this._idlessCounter=0;}populatePaintArrays(e,t,r,n,i,s,o,a,l){for(const r in this.programConfigurations)this.programConfigurations[r].populatePaintArrays(e,t,n,i,s,o,a,l);void 0!==t.id?this._featureMap.add(t.id,r,this._bufferOffset,e):(this._featureMapWithoutIds.add(this._idlessCounter,r,this._bufferOffset,e),this._idlessCounter+=1),this._bufferOffset=e,this.needsUpload=!0;}updatePaintArrays(e,t,r,n,i,s,o,a){for(const l of r)this.needsUpload=this.programConfigurations[l.id].updatePaintArrays(e,this._featureMap,this._featureMapWithoutIds,t,l,n,i,s,o||0,a)||this.needsUpload;}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const t in this.programConfigurations)this.programConfigurations[t].upload(e);this.needsUpload=!1;}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy();}}const du={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-occlusion-opacity":["occlusion_opacity"],"icon-occlusion-opacity":["occlusion_opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-emissive-strength":["emissive_strength"],"icon-emissive-strength":["emissive_strength"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"symbol-z-offset":["z_offset"],"line-gap-width":["gapwidth"],"line-pattern":["pattern","pixel_ratio","pattern_b"],"fill-pattern":["pattern","pixel_ratio","pattern_b"],"fill-extrusion-pattern":["pattern","pixel_ratio","pattern_b"],"line-dasharray":["dash"],"fill-bridge-guard-rail-color":["structure_color"],"fill-tunnel-structure-color":["structure_color"]};function fu(e,t){return du[e]||[e.replace(`${t}-`,"").replace(/-/g,"_")]}const mu={"line-pattern":{source:Za,composite:Za},"fill-pattern":{source:Za,composite:Za},"fill-extrusion-pattern":{source:Za,composite:Za},"line-dasharray":{source:Wa,composite:Wa}},yu={color:{source:fl,composite:Qa},number:{source:ja,composite:fl}};function gu(e,t,r){const n=mu[e];return n&&n[r]||yu[t][r]}Js(ou,"ConstantBinder"),Js(au,"PatternConstantBinder"),Js(lu,"SourceExpressionBinder"),Js(cu,"PatternCompositeBinder"),Js(uu,"CompositeExpressionBinder"),Js(hu,"ProgramConfiguration",{omit:["_buffers"]}),Js(pu,"ProgramConfigurationSet");const xu=Un/Math.PI/2,vu=64,bu=[vu,32,16],wu=-xu,_u=xu;function Au(e,t,r,n=xu){return r=Be(r),[e*Math.sin(r)*n,-t*n,e*Math.cos(r)*n]}function Mu(e,t,r){return Au(Math.cos(Be(e)),Math.sin(Be(e)),t,r)}const Iu=6371008.8,Su=2*Math.PI*Iu;class zu{constructor(e,t){if(isNaN(e)||isNaN(t))throw new Error(`Invalid LngLat object: (${e}, ${t})`);if(this.lng=+e,this.lat=+t,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new zu(Re(this.lng,-180,180),this.lat)}toArray(){return [this.lng,this.lat]}toString(){return `LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const t=Math.PI/180,r=this.lat*t,n=e.lat*t,i=Math.sin(r)*Math.sin(n)+Math.cos(r)*Math.cos(n)*Math.cos((e.lng-this.lng)*t);return Iu*Math.acos(Math.min(i,1))}toBounds(e=0){const t=360*e/40075017,r=t/Math.cos(Math.PI/180*this.lat);return new Pu({lng:this.lng-r,lat:this.lat-t},{lng:this.lng+r,lat:this.lat+t})}toEcef(e){return Mu(this.lat,this.lng,xu+e*xu/Iu)}static convert(e){if(e instanceof zu)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new zu(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new zu(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}class Pu{constructor(e,t){e&&(t?this.setSouthWest(e).setNorthEast(t):Array.isArray(e)&&4===e.length?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1]));}setNorthEast(e){return this._ne=e instanceof zu?new zu(e.lng,e.lat):zu.convert(e),this}setSouthWest(e){return this._sw=e instanceof zu?new zu(e.lng,e.lat):zu.convert(e),this}extend(e){const t=this._sw,r=this._ne;let n,i;if(e instanceof zu)n=e,i=e;else {if(!(e instanceof Pu))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(Pu.convert(e)):this.extend(zu.convert(e)):"object"==typeof e&&null!==e&&e.hasOwnProperty("lat")&&(e.hasOwnProperty("lon")||e.hasOwnProperty("lng"))?this.extend(zu.convert(e)):this;if(n=e._sw,i=e._ne,!n||!i)return this}return t||r?(t.lng=Math.min(n.lng,t.lng),t.lat=Math.min(n.lat,t.lat),r.lng=Math.max(i.lng,r.lng),r.lat=Math.max(i.lat,r.lat)):(this._sw=new zu(n.lng,n.lat),this._ne=new zu(i.lng,i.lat)),this}getCenter(){return new zu((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new zu(this.getWest(),this.getNorth())}getSouthEast(){return new zu(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return [this._sw.toArray(),this._ne.toArray()]}toString(){return `LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return !(this._sw&&this._ne)}contains(e){const{lng:t,lat:r}=zu.convert(e);let n=this._sw.lng<=t&&t<=this._ne.lng;return this._sw.lng>this._ne.lng&&(n=this._sw.lng>=t&&t>=this._ne.lng),this._sw.lat<=r&&r<=this._ne.lat&&n}static convert(e){if(e)return e instanceof Pu?e:new Pu(e)}}function Bu(e){return Su*Math.cos(e*Math.PI/180)}function Tu(e){return (180+e)/360}function ku(e){return (180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function Vu(e,t){return e/Bu(t)}function Eu(e){return 360*e-180}function Fu(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function Du(e,t){return e*Bu(Fu(t))}const Cu=85.051129;function Ru(e){return Math.cos(Be(De(e,-85.051129,Cu)))}function Lu(e,t){const r=De(t,0,25.5),n=Math.pow(2,r);return Ru(e)*Su/(512*n)}function Ou(e){return 1/Math.cos(e*Math.PI/180)}function Uu(e,t=0){const r=Math.exp(Math.PI*(1-(e.y+t/Un)/(1<=l?(ju(e,t,r,u,c,s,h,a,l),ju(e,u,c,n,i,h,o,a,l)):e.push(o);}function Gu(e,t,r){let n=e[0],i=n.x,s=n.y;t(n);const o=[n];for(let a=1;ae.x+1||ne.y+1)&&Ze("Geometry exceeds allowed extent, reduce your vector tile buffer size"),e}function Wu(e,t,r){const n=e.loadGeometry(),i=e.extent,s=Un/i;if(t&&r&&r.projection.isReprojectedInTileSpace){const s=1<{const r=Eu((t.x+e.x/i)/s),n=Fu((t.y+e.y/i)/s),c=u.project(r,n);e.x=(c.x*o-a)*i,e.y=(c.y*o-l)*i;};for(let t=0;t=i||r.y<0||r.y>=i||(c(r),e.push(r));n[t]=e;}}for(const e of n)for(const t of e)Zu(t,s);return n}function Yu(e,t){return {type:e.type,id:e.id,properties:e.properties,geometry:t?Wu(e):[]}}class Ju{constructor(e,t,r,n,i){this.properties={},this.extent=r,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=n,this._values=i,e.readFields(Ku,this,t);}loadGeometry(){const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos,r=[];let n,i=1,s=0,o=0,a=0;for(;e.pos>3;}if(s--,1===i||2===i)o+=e.readSVarint(),a+=e.readSVarint(),1===i&&(n&&r.push(n),n=[]),n&&n.push(new Ie(o,a));else {if(7!==i)throw new Error(`unknown command ${i}`);n&&n.push(n[0].clone());}}return n&&r.push(n),r}bbox(){const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos;let r=1,n=0,i=0,s=0,o=1/0,a=-1/0,l=1/0,u=-1/0;for(;e.pos>3;}if(n--,1===r||2===r)i+=e.readSVarint(),s+=e.readSVarint(),ia&&(a=i),su&&(u=s);else if(7!==r)throw new Error(`unknown command ${r}`)}return [o,l,a,u]}toGeoJSON(e,t,r){const n=this.extent*Math.pow(2,r),i=this.extent*e,s=this.extent*t,o=this.loadGeometry();function a(e){return [360*(e.x+i)/n-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+s)/n)*Math.PI))-90]}function l(e){return e.map(a)}let u;if(1===this.type){const e=[];for(const t of o)e.push(t[0]);const t=l(e);u=1===e.length?{type:"Point",coordinates:t[0]}:{type:"MultiPoint",coordinates:t};}else if(2===this.type){const e=o.map(l);u=1===e.length?{type:"LineString",coordinates:e[0]}:{type:"MultiLineString",coordinates:e};}else {if(3!==this.type)throw new Error("unknown feature type");{const e=function(e){const t=e.length;if(t<=1)return [e];const r=[];let n,i;for(let s=0;s=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];const t=this._pbf.readVarint()+this._pbf.pos;return new Ju(this._pbf,t,this.extent,this._keys,this._values)}}function tc(e,t,r){15===e?t.version=r.readVarint():1===e?t.name=r.readString():5===e?t.extent=r.readVarint():2===e?t._features.push(r.pos):3===e?t._keys.push(r.readString()):4===e&&t._values.push(function(e){let t=null;const r=e.readVarint()+e.pos;for(;e.pos>3;t=1===r?e.readString():2===r?e.readFloat():3===r?e.readDouble():4===r?e.readVarint64():5===r?e.readVarint():6===r?e.readSVarint():7===r?e.readBoolean():null;}if(null==t)throw new Error("unknown feature value");return t}(r));}class rc{constructor(e,t){this.layers=e.readFields(nc,{},t);}}function nc(e,t,r){if(3===e){const e=new ec(r,r.readVarint()+r.pos);e.length&&(t[e.name]=e);}}const ic="3d_elevation_id",sc="level";class oc{constructor(){this._valid=!1;}reset(e){return this.feature=e,this._valid=!0,this._geometry=e.loadGeometry(),0!==this._geometry.length&&0!==this._geometry[0].length||(this._valid=!1),this}geometry(e,t){return this._valid&&e(t(this._geometry)),this}require(e,t,r){return this.get(e,!0,t,r)}optional(e,t,r){return this.get(e,!1,t,r)}success(){return this._valid}get(e,t,r,n){const i=this.feature.properties.hasOwnProperty(e)?+this.feature.properties[e]:void 0;return this._valid&&void 0!==i&&!Number.isNaN(i)?r(n?n(i):i):t&&(this._valid=!1),this}}class ac{constructor(e,t){this.featureFunc=e,this.vertexFunc=t;}parseFeature(e,t,r){return this.featureFunc(e,t,r)}parseVertex(e,t,r){return this.vertexFunc(e,t,r)}}const lc=new ac((e,t,r)=>e.reset(t).require(ic,e=>{r.id=e;}).optional("fixed_height_relative",e=>{r.constantHeight=e;},cc.decodeRelativeHeight).geometry(e=>{r.bounds=e;},xn).success(),(e,t,r)=>e.reset(t).require(ic,e=>{r.id=e;}).require("elevation_idx",e=>{r.idx=e;}).require("extent",e=>{r.extent=e;}).require("height_relative",e=>{r.height=e;},cc.decodeRelativeHeight).geometry(e=>{r.position=e;},cc.getPoint).success()),uc=new ac((e,t,r)=>e.reset(t).require(ic,e=>{r.id=e;}).optional("fixed_height",e=>{r.constantHeight=e;},cc.decodeMetricHeight).geometry(e=>{r.bounds=e;},xn).success(),(e,t,r)=>e.reset(t).require(ic,e=>{r.id=e;}).require("elevation_idx",e=>{r.idx=e;}).require("extent",e=>{r.extent=e;}).require("height",e=>{r.height=e;},cc.decodeMetricHeight).geometry(e=>{r.position=e;},cc.getPoint).success());class cc{static getPoint(e){return he(e[0][0].x,e[0][0].y)}static decodeRelativeHeight(e){return 1e-4*e*5}static decodeMetricHeight(e){return 1e-4*e}static getVersionSchema(e){return e?"1.0.1"===e?uc:void 0:lc}static parse(e){const t=[],r=[],n=e.length,i=new oc;for(let s=0;s=0);if(0===s)return 0;s!==t.length&&(r=!1);}return r?2:1}function yc(e,t){for(const r of e.projections){const n=fc(t,e.points[0],r.axis);if(r.projection[1]n[1])return 0}return 1}function gc(e,t){let r=0;const n=[0,0,0,0];for(let i=0;i=0&&r++;return r}class xc{constructor(e,t){this.points=e||new Array(8).fill([0,0,0]),this.planes=t||new Array(6).fill([0,0,0,0]),this.bounds=vc.fromPoints(this.points),this.projections=[],this.frustumEdges=[H([],this.points[2],this.points[3]),H([],this.points[0],this.points[3]),H([],this.points[4],this.points[0]),H([],this.points[5],this.points[1]),H([],this.points[6],this.points[2]),H([],this.points[7],this.points[3])];for(const e of this.frustumEdges){const t=[0,-e[2],e[1]],r=[e[2],0,-e[0]];this.projections.push({axis:t,projection:fc(this.points,this.points[0],t)}),this.projections.push({axis:r,projection:fc(this.points,this.points[0],r)});}}static fromInvProjectionMatrix(e,t,r,n){const i=Math.pow(2,r),s=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map(r=>{const s=ee([],r,e),o=1/s[3]/t*i;return (a=s)[0]=(l=s)[0]*(u=[o,o,n?1/s[3]:o,o])[0],a[1]=l[1]*u[1],a[2]=l[2]*u[2],a[3]=l[3]*u[3],a;var a,l,u;}),o=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(e=>{const t=L([],U([],H([],s[e[0]],s[e[1]]),H([],s[e[2]],s[e[1]]))),r=-O(t,s[e[1]]);return t.concat(r)}),a=[];for(let e=0;eo[1]||o[0]>s[1])return 0}return 1}containsPoint(e){for(const t of this.planes){const r=t[3];if(O([t[0],t[1],t[2]],e)+r<0)return !1}return !0}}class vc{static fromPoints(e){const t=[1/0,1/0,1/0],r=[-1/0,-1/0,-1/0];for(const n of e)T(t,t,n),k(r,r,n);return new vc(t,r)}static fromTileIdAndHeight(e,t,r){const n=1<e.max[t]||e.min[t]>this.max[t])return !1;return !0}intersectsAabbXY(e){return !(this.min[0]>e.max[0]||e.min[0]>this.max[0]||this.min[1]>e.max[1]||e.min[1]>this.max[1])}encapsulate(e){for(let t=0;t<3;t++)this.min[t]=Math.min(this.min[t],e.min[t]),this.max[t]=Math.max(this.max[t],e.max[t]);}encapsulatePoint(e){for(let t=0;t<3;t++)this.min[t]=Math.min(this.min[t],e[t]),this.max[t]=Math.max(this.max[t],e[t]);}closestPoint(e){return [Math.max(Math.min(this.max[0],e[0]),this.min[0]),Math.max(Math.min(this.max[1],e[1]),this.min[1]),Math.max(Math.min(this.max[2],e[2]),this.min[2])]}}Js(vc,"Aabb");class bc{constructor(e,t){this.feature=e,this.metersToTile=t,this.index=0;}get(){const e=this.feature.vertices[this.index],t=this.feature.vertexProps[this.index].dir,r=t[1],n=-t[0],i=(e.extent+1)*this.metersToTile;return [new Ie(Math.trunc(e.position[0]+r*i),Math.trunc(e.position[1]+n*i)),new Ie(Math.trunc(e.position[0]-r*i),Math.trunc(e.position[1]-n*i))]}next(){this.index++;}valid(){return this.index{return e.a0?V(a,a,1/l):S(a,0,0,1)}getSafeArea(){return this.safeArea}isTunnel(){return this.heightRange.max<=-5}getClosestEdge(e){if(0===this.edges.length)return;let t=0,r=Number.POSITIVE_INFINITY,n=0;const[i,s,o,a,l,u,c]=this._tmpVec2;pe(c,e.x,e.y);const h=new hc(c,null);for(let e=0;e0?xe(a,o)/x:0,b=De(v,0,1),w=Math.abs((v-b)*this.edgeProps[e].len);fe(l,c,f),pe(u,d[1],-d[0]);const _=w+Math.abs(xe(l,u));_=0;--s){const o=this.edges[s].a,a=this.edges[s].b,{position:l,height:u,extent:c}=this.vertices[o],{position:h,height:p,extent:d}=this.vertices[a],f=this.vertexProps[o].dir,m=this.vertexProps[a].dir;if(S(t,l[0]/e,l[1]/e,u),S(r,h[0]/e,h[1]/e,p),S(n,f[1],-f[0],0),V(n,n,c),S(i,m[1],-m[0],0),V(i,i,d),this.distSqLines(I(t[0]+.5*n[0],t[1]+.5*n[1],t[2]+.5*n[2]),I(r[0]-.5*i[0],r[1]-.5*i[1],r[2]-.5*i[2]),I(t[0]-.5*n[0],t[1]-.5*n[1],t[2]-.5*n[2]),I(r[0]+.5*i[0],r[1]+.5*i[1],r[2]+.5*i[2]))<=.0025000000000000005)continue;const y=this.vertices.length,g=de(ce(),l,h);this.vertices.push({position:me(g,g,.5),height:.5*(u+p),extent:.5*(c+d)});const x=de(ce(),f,m);this.vertexProps.push({dir:ge(x,x)}),this.edges.splice(s,1),this.edgeProps.splice(s,1),this.edges.push({a:o,b:y}),this.edges.push({a:y,b:a});const v=fe(ce(),this.vertices[y].position,l),b=ye(v),w={vec:v,dir:me(ce(),v,1/b),len:b};this.edgeProps.push(w),this.edgeProps.push(w);}}distSqLines(e,t,r,n){const i=P(_(),t,e),s=P(_(),n,r),o=P(_(),e,r),a=O(i,i),l=O(i,s),u=O(i,o),c=O(s,s),h=O(s,o),p=a*c-l*l;if(0===p)return D(N(i,r,n,O(o,s)/O(s,s)),e);const d=(a*h-l*u)/p;return D(N(i,e,t,(l*h-u*c)/p),N(s,r,n,d))}}class _c{static parseFrom(e,t){const r=cc.parse(e);if(!r)return [];let{vertices:n,features:i}=r;const s=1/Uu(t);i.sort((e,t)=>e.id-t.id),n.sort((e,t)=>e.id-t.id||e.idx-t.idx),n=n.filter((e,t,r)=>t===r.findIndex(t=>t.id===e.id&&t.idx===e.idx));const o=new Array;let a=0;const l=n.length;for(const e of i){if(e.constantHeight){o.push(new wc(e.id,e.bounds,e.constantHeight));continue}for(;a!==l&&n[a].ide.id===r)}}class Ac{constructor(e,t){this.zScale=1,this.xOffset=0,this.yOffset=0,e.equals(t)||(this.zScale=Math.pow(2,t.z-e.z),this.xOffset=(e.x*this.zScale-t.x)*Un,this.yOffset=(e.y*this.zScale-t.y)*Un);}constantElevation(e,t){if(null!=e.constantHeight)return this.computeBiasedHeight(e.constantHeight,t)}pointElevation(e,t,r){const n=this.constantElevation(t,r);return null!=n?n:(e.x=e.x*this.zScale+this.xOffset,e.y=e.y*this.zScale+this.yOffset,this.computeBiasedHeight(t.pointElevation(e),r))}computeBiasedHeight(e,t){return t<=0?e:e+t*Ce(0,t,e>=0?e:Math.abs(.5*e))}}Js(wc,"ElevationFeature");class Mc{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.fqid),this.index=e.index,this.hasPattern=!1,this.projection=e.projection,this.layoutVertexArray=new Oa,this.indexArray=new ol,this.segments=new Rl,this.programConfigurations=new pu(e.layers,{zoom:e.zoom,lut:e.lut}),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.elevationMode=this.layers[0].layout.get("circle-elevation-reference"),this.hasElevation=!1,"none"!==this.elevationMode&&(this.elevatedLayoutVertexArray=new ja),this.worldview=e.worldview,this.hasAppearances=null;}updateFootprints(e,t){}updateAppearances(e,t,r,n){}populate(e,t,r,n){const i=this.layers[0],s=[];let o=null;"circle"===i.type&&(o=i.layout.get("circle-sort-key"));for(const{feature:i,id:a,index:l,sourceLayerIndex:u}of e){const e=this.layers[0]._featureFilter.needGeometry,c=Yu(i,e);if(!this.layers[0]._featureFilter.filter(new Yo(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),c,r))continue;const h=o?o.evaluate(c,{},r):void 0,p={id:a,properties:i.properties,type:i.type,sourceLayerIndex:u,index:l,geometry:e?c.geometry:Wu(i,r,n),patterns:{},sortKey:h};s.push(p);}o&&s.sort((e,t)=>e.sortKey-t.sortKey);let a=null;"globe"===n.projection.name&&(this.globeExtVertexArray=new Ya,a=n.projection);for(const n of s){const{geometry:i,index:s,sourceLayerIndex:o}=n,l=e[s].feature;this.addFeature(n,i,s,t.availableImages,r,a,t.brightness,t.elevationFeatures),t.featureIndex.insert(l,i,s,o,this.index);}this.hasElevation||(this.elevatedLayoutVertexArray=void 0);}update(e,t,r,n,i,s,o){this.programConfigurations.updatePaintArrays(e,t,i,r,n,s,o,this.worldview);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Fl.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,Cl.members)),this.elevatedLayoutVertexArray&&(this.elevatedLayoutVertexBuffer=e.createVertexBuffer(this.elevatedLayoutVertexArray,Dl.members))),this.programConfigurations.upload(e),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.elevatedLayoutVertexBuffer&&this.elevatedLayoutVertexBuffer.destroy());}addFeature(e,t,r,n,i,s,o,a){let l;"none"!==this.elevationMode&&(l=_c.getElevationFeature(e,a));for(const r of t)for(const t of r){const r=t.x,n=t.y;if(r<0||r>=Un||n<0||n>=Un)continue;if(s){const e=s.projectTilePoint(r,n,i),t=s.upVector(i,r,n);this.addGlobeExtVertex(e,t),this.addGlobeExtVertex(e,t),this.addGlobeExtVertex(e,t),this.addGlobeExtVertex(e,t);}const o=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),a=o.vertexLength;if(this.addCircleVertex(r,n,-1,-1),this.addCircleVertex(r,n,1,-1),this.addCircleVertex(r,n,1,1),this.addCircleVertex(r,n,-1,1),"none"!==this.elevationMode){const e=l?l.pointElevation(new Ie(r,n)):0;this.hasElevation=this.hasElevation||0!==e;for(let t=0;t<4;t++)this.elevatedLayoutVertexArray.emplaceBack(e);}this.indexArray.emplaceBack(a,a+1,a+2),this.indexArray.emplaceBack(a,a+2,a+3),o.vertexLength+=4,o.primitiveLength+=2;}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,r,{},n,i,o,void 0,this.worldview);}addCircleVertex(e,t,r,n){this.layoutVertexArray.emplaceBack(2*e+(r+1)/2,2*t+(n+1)/2);}addGlobeExtVertex(e,t){const r=16384;this.globeExtVertexArray.emplaceBack(e.x,e.y,e.z,t[0]*r,t[1]*r,t[2]*r);}}function Ic(e,t){for(let r=0;r1){if(Bc(e,t))return !0;for(let n=0;n1?r:r.sub(t)._mult(i)._add(t))}function Dc(e,t){let r,n,i,s=!1;for(let o=0;ot.y!=i.y>t.y&&t.x<(i.x-n.x)*(t.y-n.y)/(i.y-n.y)+n.x&&(s=!s);}return s}function Cc(e,t){let r=!1;for(let n=0,i=e.length-1;nt.y!=o.y>t.y&&t.x<(o.x-s.x)*(t.y-s.y)/(o.y-s.y)+s.x&&(r=!r);}return r}function Rc(e,t,r,n,i){for(const s of e)if(t<=s.x&&r<=s.y&&n>=s.x&&i>=s.y)return !0;const s=[new Ie(t,r),new Ie(t,i),new Ie(n,i),new Ie(n,r)];if(e.length>2)for(const t of s)if(Cc(e,t))return !0;for(let t=0;ti.x&&t.x>i.x||e.yi.y&&t.y>i.y)return !1;const s=We(e,t,r[0]);return s!==We(e,t,r[1])||s!==We(e,t,r[2])||s!==We(e,t,r[3])}function Oc(e,t,r,n,i,s){let o=t.y-e.y,a=e.x-t.x;if(s=s||0){const e=o*o+a*a;if(0===e)return !0;const t=Math.sqrt(e);o/=t,a/=t;}return !((r.x-e.x)*o+(r.y-e.y)*a-s<0||(n.x-e.x)*o+(n.y-e.y)*a-s<0||(i.x-e.x)*o+(i.y-e.y)*a-s<0)}function Uc(e,t,r,n,i,s,o){return !(Oc(e,t,n,i,s,o)||Oc(t,r,n,i,s,o)||Oc(r,e,n,i,s,o)||Oc(n,i,e,t,r,o)||Oc(i,s,e,t,r,o)||Oc(s,n,e,t,r,o))}function Nc(e,t,r){const n=t.paint.get(e).value;return "constant"===n.kind?n.value:r.programConfigurations.get(t.id).getMaxValue(e)}function jc(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function Gc(e,t,r,n,i){if(!t[0]&&!t[1])return e;const s=Ie.convert(t)._mult(i);"viewport"===r&&s._rotate(-n);const o=[];for(let t=0;t>t&&e.y===this.y>>t}url(e,t){const r=function(e,t,r){const n=2**r,i=2*Math.PI*6378137,s=i*(e/n-.5),o=i*(.5-(t+1)/n);return `${s},${o},${s+i/n},${o+i/n}`}(this.x,this.y,this.z),n=function(e,t,r){let n,i="";for(let s=e;s>0;s--)n=1<this.canonical.z?new Wc(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Wc(e,this.wrap,e,this.canonical.x>>t,this.canonical.y>>t)}calculateScaledKey(e,t=!0){if(this.overscaledZ===e&&t)return this.key;if(e>this.canonical.z)return Yc(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y);{const r=this.canonical.z-e;return Yc(this.wrap*+t,e,e,this.canonical.x>>r,this.canonical.y>>r)}}isChildOf(e){if(e.wrap!==this.wrap)return !1;const t=this.canonical.z-e.canonical.z;return 0===e.overscaledZ||e.overscaledZ>t&&e.canonical.y===this.canonical.y>>t}children(e){if(this.overscaledZ>=e)return [new Wc(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const t=this.canonical.z+1,r=2*this.canonical.x,n=2*this.canonical.y;return [new Wc(t,this.wrap,t,r,n),new Wc(t,this.wrap,t,r+1,n),new Wc(t,this.wrap,t,r,n+1),new Wc(t,this.wrap,t,r+1,n+1)]}isLessThan(e){return this.wrape.wrap)&&(this.overscaledZe.overscaledZ)&&(this.canonical.xe.canonical.x)&&this.canonical.y{let t=e.canonical.x-1,r=e.wrap;return t<0&&(t=(1<{let t=e.canonical.x+1,r=e.wrap;return t===1<new Wc(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,(0===e.canonical.y?1<new Wc(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y===(1<1?null:function(e,t,r,n){const i=Math.sin(r);return e*(Math.sin((1-n)*r)/i)+t*(Math.sin(n*r)/i)}(e.a[t],e.b[t],e.angle,De(r,0,1))+e.center[t]}function ah(e){if(e.z<=1)return nh[e.z+2*e.y+e.x];const t=ph(hh(e));return vc.fromPoints(t)}function lh(e,t,r){return V(e,e,1-r),E(e,e,t,r)}function uh(e,t,r){for(const n of e)j(n,n,t),V(n,n,r);}function ch(e,t,r,n){const i=t/e.worldSize,s=e.globeMatrix;if(r.z<=1){const e=ah(r).getCorners();return uh(e,s,i),vc.fromPoints(e)}const o=hh(r,n),a=ph(o,xu+rh(e._tileCoverLift));uh(a,s,i);const l=Number.MAX_VALUE,u=[-l,-l,-l],c=[l,l,l];if(o.contains(e.center)){for(const e of a)T(c,c,e),k(u,u,e);u[2]=0;const t=e.point,r=[t.x*i,t.y*i,0];return T(c,c,r),k(u,u,r),new vc(c,u)}if(e._tileCoverLift>0){for(const e of a)T(c,c,e),k(u,u,e);return new vc(c,u)}const h=[s[12]*i,s[13]*i,s[14]*i],p=o.getCenter(),d=De(e.center.lat,-85.051129,Cu),f=De(p.lat,-85.051129,Cu),m=Tu(e.center.lng),y=ku(d);let g=m-Tu(p.lng);const x=y-ku(f);g>.5?g-=1:g<-.5&&(g+=1);let v=0;Math.abs(g)>Math.abs(x)?v=g>=0?1:3:(v=x>=0?0:2,E(h,h,[s[4]*i,s[5]*i,s[6]*i],-Math.sin(Be(x>=0?o.getSouth():o.getNorth()))*xu));const b=a[v],w=a[(v+1)%4],_=new sh(b,w,h),A=[oh(_,0)||b[0],oh(_,1)||b[1],oh(_,2)||b[2]],M=wh(e.zoom);if(M>0){const n=function({x:e,y:t,z:r},n,i,s,o){const a=1/(1<.5?p=-1:d<-.5&&(p=1),l=((l+p)*n-(s*=n))*i+s,u=((u+p)*n-s)*i+s,c=(c*n-(o*=n))*i+o,h=(h*n-o)*i+o,[[l,h,0],[u,h,0],[u,c,0],[l,c,0]]}(r,t,e._pixelsPerMercatorPixel,m,y);for(let e=0;eMath.PI/2*1.01}const Mh=Be(85),Ih=Math.cos(Mh),Sh=Math.sin(Mh),zh=a(),Ph=e=>{const t=[];return "map"===e.paint.get("circle-pitch-alignment")&&t.push("PITCH_WITH_MAP"),"map"===e.paint.get("circle-pitch-scale")&&t.push("SCALE_WITH_MAP"),t};function Bh(e,t,r,n,i,s,o,a,l){if(s&&e.queryGeometry.isAboveHorizon)return !1;s&&(l*=e.pixelToTileUnitsFactor);const u=e.tileID.canonical,c=r.projection.upVectorScale(u,r.center.lat,r.worldSize).metersToTile;for(const h of t)for(const t of h){const h=t.add(a),p=i&&r.elevation?r.elevation.exaggeration()*i.getElevationAt(h.x,h.y,!0):0,d=r.projection.projectTilePoint(h.x,h.y,u);if(p>0){const e=r.projection.upVector(u,h.x,h.y);d.x+=e[0]*c*p,d.y+=e[1]*c*p,d.z+=e[2]*c*p;}const f=s?h:Th(d.x,d.y,d.z,n),m=s?e.tilespaceRays.map(e=>Eh(e,p)):e.queryGeometry.screenGeometry,y=ee([],[d.x,d.y,d.z,1],n);if(!o&&s?l*=y[3]/r.cameraToCenterDistance:o&&!s&&(l*=r.cameraToCenterDistance/y[3]),s){const e=Fu((t.y/Un+u.y)/(1<e.width||i.height>e.height||r.x>e.width-i.width||r.y>e.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>t.width||i.height>t.height||n.x>t.width-i.width||n.y>t.height-i.height)throw new RangeError("out of range destination coordinates for image copy");const l=e.data,u=t.data,c=4===s&&a;for(let a=0;a{t[e.evaluationKey]=s;const o=e.expression.evaluate(t),a=o?o.toNonPremultipliedRenderColor(null):null;a&&(i.data[r+n+0]=Math.floor(255*a.r),i.data[r+n+1]=Math.floor(255*a.g),i.data[r+n+2]=Math.floor(255*a.b),i.data[r+n+3]=Math.floor(255*a.a));};if(e.clips)for(let t=0,i=0;t80*r){a=e[0],l=e[1];let t=a,n=l;for(let s=r;st&&(t=r),i>n&&(n=i);}u=Math.max(t-a,n-l),u=0!==u?32767/u:0;}return Qh(s,o,r,a,l,u,0),o}function Jh(e,t,r,n,i){let s;if(i===function(e,t,r,n){let i=0;for(let s=t,o=r-n;s0)for(let i=t;i=t;i-=n)s=vp(i/n|0,e[i],e[i+1],s);return s&&dp(s,s.next)&&(bp(s),s=s.next),s}function Kh(e,t){if(!e)return e;t||(t=e);let r,n=e;do{if(r=!1,n.steiner||!dp(n,n.next)&&0!==pp(n.prev,n,n.next))n=n.next;else {if(bp(n),n=t=n.prev,n===n.next)break;r=!0;}}while(r||n!==t);return t}function Qh(e,t,r,n,i,s,o){if(!e)return;!o&&s&&function(e,t,r,n){let i=e;do{0===i.z&&(i.z=ap(i.x,i.y,t,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){let t,r=1;do{let n,i=e;e=null;let s=null;for(t=0;i;){t++;let o=i,a=0;for(let e=0;e0||l>0&&o;)0!==a&&(0===l||!o||i.z<=o.z)?(n=i,i=i.nextZ,a--):(n=o,o=o.nextZ,l--),s?s.nextZ=n:e=n,n.prevZ=s,s=n;i=o;}s.nextZ=null,r*=2;}while(t>1)}(i);}(e,n,i,s);let a=e;for(;e.prev!==e.next;){const l=e.prev,u=e.next;if(s?tp(e,n,i,s):ep(e))t.push(l.i,e.i,u.i),bp(e),e=u.next,a=u.next;else if((e=u)===a){o?1===o?Qh(e=rp(Kh(e),t),t,r,n,i,s,2):2===o&&np(e,t,r,n,i,s):Qh(Kh(e),t,r,n,i,s,1);break}}}function ep(e){const t=e.prev,r=e,n=e.next;if(pp(t,r,n)>=0)return !1;const i=t.x,s=r.x,o=n.x,a=t.y,l=r.y,u=n.y,c=Math.min(i,s,o),h=Math.min(a,l,u),p=Math.max(i,s,o),d=Math.max(a,l,u);let f=n.next;for(;f!==t;){if(f.x>=c&&f.x<=p&&f.y>=h&&f.y<=d&&cp(i,a,s,l,o,u,f.x,f.y)&&pp(f.prev,f,f.next)>=0)return !1;f=f.next;}return !0}function tp(e,t,r,n){const i=e.prev,s=e,o=e.next;if(pp(i,s,o)>=0)return !1;const a=i.x,l=s.x,u=o.x,c=i.y,h=s.y,p=o.y,d=Math.min(a,l,u),f=Math.min(c,h,p),m=Math.max(a,l,u),y=Math.max(c,h,p),g=ap(d,f,t,r,n),x=ap(m,y,t,r,n);let v=e.prevZ,b=e.nextZ;for(;v&&v.z>=g&&b&&b.z<=x;){if(v.x>=d&&v.x<=m&&v.y>=f&&v.y<=y&&v!==i&&v!==o&&cp(a,c,l,h,u,p,v.x,v.y)&&pp(v.prev,v,v.next)>=0)return !1;if(v=v.prevZ,b.x>=d&&b.x<=m&&b.y>=f&&b.y<=y&&b!==i&&b!==o&&cp(a,c,l,h,u,p,b.x,b.y)&&pp(b.prev,b,b.next)>=0)return !1;b=b.nextZ;}for(;v&&v.z>=g;){if(v.x>=d&&v.x<=m&&v.y>=f&&v.y<=y&&v!==i&&v!==o&&cp(a,c,l,h,u,p,v.x,v.y)&&pp(v.prev,v,v.next)>=0)return !1;v=v.prevZ;}for(;b&&b.z<=x;){if(b.x>=d&&b.x<=m&&b.y>=f&&b.y<=y&&b!==i&&b!==o&&cp(a,c,l,h,u,p,b.x,b.y)&&pp(b.prev,b,b.next)>=0)return !1;b=b.nextZ;}return !0}function rp(e,t){let r=e;do{const n=r.prev,i=r.next.next;!dp(n,i)&&fp(n,r,r.next,i)&&gp(n,i)&&gp(i,n)&&(t.push(n.i,r.i,i.i),bp(r),bp(r.next),r=e=i),r=r.next;}while(r!==e);return Kh(r)}function np(e,t,r,n,i,s){let o=e;do{let e=o.next.next;for(;e!==o.prev;){if(o.i!==e.i&&hp(o,e)){let a=xp(o,e);return o=Kh(o,o.next),a=Kh(a,a.next),Qh(o,t,r,n,i,s,0),void Qh(a,t,r,n,i,s,0)}e=e.next;}o=o.next;}while(o!==e)}function ip(e,t){let r=e.x-t.x;return 0===r&&(r=e.y-t.y,0===r)&&(r=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x)),r}function sp(e,t){const r=function(e,t){let r=t;const n=e.x,i=e.y;let s,o=-1/0;if(dp(e,r))return r;do{if(dp(e,r.next))return r.next;if(i<=r.y&&i>=r.next.y&&r.next.y!==r.y){const e=r.x+(i-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(e<=n&&e>o&&(o=e,s=r.x=r.x&&r.x>=l&&n!==r.x&&up(is.x||r.x===s.x&&op(s,r)))&&(s=r,c=t);}r=r.next;}while(r!==a);return s}(e,t);if(!r)return t;const n=xp(r,e);return Kh(n,n.next),Kh(r,r.next)}function op(e,t){return pp(e.prev,e,t.prev)<0&&pp(t.next,e,e.next)<0}function ap(e,t,r,n,i){return (e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function lp(e){let t=e,r=e;do{(t.x=(e-o)*(s-a)&&(e-o)*(n-a)>=(r-o)*(t-a)&&(r-o)*(s-a)>=(i-o)*(n-a)}function cp(e,t,r,n,i,s,o,a){return !(e===o&&t===a)&&up(e,t,r,n,i,s,o,a)}function hp(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let r=e;do{if(r.i!==e.i&&r.next.i!==e.i&&r.i!==t.i&&r.next.i!==t.i&&fp(r,r.next,e,t))return !0;r=r.next;}while(r!==e);return !1}(e,t)&&(gp(e,t)&&gp(t,e)&&function(e,t){let r=e,n=!1;const i=(e.x+t.x)/2,s=(e.y+t.y)/2;do{r.y>s!=r.next.y>s&&r.next.y!==r.y&&i<(r.next.x-r.x)*(s-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next;}while(r!==e);return n}(e,t)&&(pp(e.prev,e,t.prev)||pp(e,t.prev,t))||dp(e,t)&&pp(e.prev,e,e.next)>0&&pp(t.prev,t,t.next)>0)}function pp(e,t,r){return (t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function dp(e,t){return e.x===t.x&&e.y===t.y}function fp(e,t,r,n){const i=yp(pp(e,t,r)),s=yp(pp(e,t,n)),o=yp(pp(r,n,e)),a=yp(pp(r,n,t));return i!==s&&o!==a||!(0!==i||!mp(e,r,t))||!(0!==s||!mp(e,n,t))||!(0!==o||!mp(r,e,n))||!(0!==a||!mp(r,t,n))}function mp(e,t,r){return t.x<=Math.max(e.x,r.x)&&t.x>=Math.min(e.x,r.x)&&t.y<=Math.max(e.y,r.y)&&t.y>=Math.min(e.y,r.y)}function yp(e){return e>0?1:e<0?-1:0}function gp(e,t){return pp(e.prev,e,e.next)<0?pp(e,t,e.next)>=0&&pp(e,e.prev,t)>=0:pp(e,t,e.prev)<0||pp(e,e.next,t)<0}function xp(e,t){const r=wp(e.i,e.x,e.y),n=wp(t.i,t.x,t.y),i=e.next,s=t.prev;return e.next=t,t.prev=e,r.next=i,i.prev=r,n.next=r,r.prev=n,s.next=n,n.prev=s,n}function vp(e,t,r,n){const i=wp(e,t,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function bp(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ);}function wp(e,t,r){return {i:e,x:t,y:r,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function _p(e,t){const r=e.length;if(r<=1)return [e];const n=[];let i,s;for(let t=0;t1)for(let e=0;e=Un&&t>=Un}static evaluate(e){if(0===e.length)return new zp;let t=[];for(const r of e)t.push(...r.portals);if(0===t.length)return new zp;for(const e of t){const t=e.va,r=e.vb;(zp.isOnBorder(t.x,r.x)||zp.isOnBorder(t.y,r.y))&&(e.type="border");}const r=t.filter(e=>"unevaluated"!==e.type),n=t.filter(e=>"unevaluated"===e.type);if(0===n.length)return new zp;n.sort((e,t)=>e.hash===t.hash?e.isTunnel===t.isTunnel?0:e.isTunnel?-1:1:e.hashe.hash"fill-tunnel-structure-color"!==e),this.tunnelProgramConfigurations=new pu(t,{zoom:r,lut:n},e=>"fill-bridge-guard-rail-color"!==e);}addVertices(e,t){const r=this.unevalVertices.length;for(let r=0;r=i.min.x&&u.x<=i.max.x&&u.y>=i.min.y&&u.y<=i.max.y||c.x>=i.min.x&&c.x<=i.max.x&&c.y>=i.min.y&&c.y<=i.max.y||Lc(u,c,o)))continue;if(this.isOnBorder(u.x,c.x)||this.isOnBorder(u.y,c.y))continue;const h=Bp.computeEdgeHash(this.unevalVertices[r],this.unevalVertices[l]);let p,d=this.vertexHashLookup.get(Bp.computePosHash(u));null!=d?p=d.next:(d=this.vertexHashLookup.get(Bp.computePosHash(c)),p=null!=d?d.prev:h),this.unevalEdges.push({polygonIdx:e,a:r,b:l,hash:h,portalHash:p,isTunnel:n,type:"unevaluated",featureInfo:s});}}addPortalCandidates(e,t,r,n,i){if(0!==t.length){this.vertexHashLookup.clear();for(const i of t){if(0===i.length)continue;const t=i[0];let s=Bp.computeEdgeHash(t[t.length-2],t[t.length-1]);for(let i=0;i({vertexOffset:0,primitiveOffset:this.indexArray.length}),r=e=>{e.primitiveLength=this.indexArray.length-e.primitiveOffset;},n=new Pp(this.vertexPositions,this.vertexNormals,this.indexArray);this.prepareEdges(e.portals,this.unevalEdges);const i=t(),s=t(),o=t(),a=(e,t)=>{e.sort((e,r)=>e.type===t&&r.type!==t?-1:e.type!==t&&r.type===t?1:0);const r=e.findIndex(e=>e.type!==t);return r>=0?r:e.length};let l=0;this.unevalEdges.length>0&&(l=a(this.unevalEdges,"none"),this.constructBridgeStructures(n,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:l},this.tileToMeters)),r(o);const u=t(),c=t();if(this.unevalEdges.length>0){const e=this.unevalEdges.splice(l),t=a(e,"tunnel")+l;this.unevalEdges.push(...e),this.constructTunnelStructures(n,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:l},{min:l,max:t});}r(u),n.addTriangles(this.unevalTriangles,this.unevalVertices,this.unevalHeights),r(c),n.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,this.unevalHeights),r(s),n.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,[-.1]),r(i),this.maskSegments=Rl.simpleSegment(0,c.primitiveOffset,0,c.primitiveLength),this.depthSegments=Rl.simpleSegment(0,s.primitiveOffset,0,s.primitiveLength),this.renderableBridgeSegments=Rl.simpleSegment(0,o.primitiveOffset,0,o.primitiveLength),this.renderableTunnelSegments=Rl.simpleSegment(0,u.primitiveOffset,0,u.primitiveLength),this.shadowCasterSegments=Rl.simpleSegment(0,i.primitiveOffset,0,i.primitiveLength);}update(e,t,r,n,i,s,o,a){this.bridgeProgramConfigurations.updatePaintArrays(e,t,i,r,n,s,o,a),this.tunnelProgramConfigurations.updatePaintArrays(e,t,i,r,n,s,o,a);}upload(e){this.vertexBuffer||0===this.vertexPositions.length||0===this.vertexNormals.length||0===this.indexArray.length||(this.vertexBuffer=e.createVertexBuffer(this.vertexPositions,Zh.members),this.vertexBufferNormal=e.createVertexBuffer(this.vertexNormals,Wh.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.bridgeProgramConfigurations.upload(e),this.tunnelProgramConfigurations.upload(e));}destroy(){this.vertexBuffer&&(this.vertexBuffer.destroy(),this.vertexBufferNormal.destroy(),this.indexBuffer.destroy()),this.maskSegments&&(this.maskSegments.destroy(),this.depthSegments.destroy(),this.renderableBridgeSegments.destroy(),this.renderableTunnelSegments.destroy(),this.shadowCasterSegments.destroy()),this.bridgeProgramConfigurations.destroy(),this.tunnelProgramConfigurations.destroy();}populatePaintArrays(e,t,r,n,i){const s=(s,o)=>{for(let a=0;aS(e,t[n].x,t[n].y,r[n]*a),c=_(),h=_(),p=_(),d=_(),f=_(),m=(e,r)=>{const n=o.get(Bp.computePosHash(t[r])),i=n.from,s=n.to;if(!i||!s)return;u(c,i),u(h,r),u(p,s),q(d),X(c,h)||(H(f,h,c),L(d,f)),X(p,h)||(H(f,p,h),z(d,d,L(f,f)));const a=W(d);return a>0?V(e,d,1/a):void 0};let y=Number.POSITIVE_INFINITY;this.sortSubarray(n,i.min,i.max,(e,t)=>e.featureInfo.featureIndex-t.featureInfo.featureIndex);const g=_(),x=_(),v=_(),b=_(),w=_(),A=_(),M=_(),I=_(),P=_(),B=[_(),_(),_(),_()],T=[_(),_(),_(),_()],k=[{coord:new Ie(0,0),height:0},{coord:new Ie(0,0),height:0}],E=(e,t)=>e>t;for(let u=i.min;ue.featureInfo.featureIndex-t.featureInfo.featureIndex;this.sortSubarray(n,i.min,i.max,a),this.sortSubarray(n,s.min,s.max,a);const l=e=>L(e,e),u=[{coord:new Ie(0,0),height:0},{coord:new Ie(0,0),height:0}],c=(e,t)=>ee.hash===t.hash?t.polygonIdx-e.polygonIdx:t.hash>e.hash?1:-1);let r=0,n=0,i=0,s=t[r].polygonIdx;do{n++,(n===t.length||t[r].hash!==t[n].hash)&&((1===n-r||t[n-1].polygonIdx!==s)&&(ie.portalHashs.hash?r++:s.hash>i.portalHash?n++:(i.type=s.type,r++);}}}isOnBorder(e,t){return e<=0&&t<=0||e>=Un&&t>=Un}addFeatureSection(e,t,r,n){return e!==t&&(t=e,r.push({featureIndex:e,vertexStart:n.getVertexCount()}),n.clearVertexLookup()),t}sortSubarray(e,t,r,n){const i=e.slice(t,r);i.sort(n),e.splice(t,i.length,...i);}static computeEdgeHash(e,t){return (e.y===t.y&&e.x>t.x||e.y>t.y)&&([e,t]=[t,e]),BigInt(Bp.computePosHash(e))<<32n|BigInt(Bp.computePosHash(t))}static computePosHash(e){return ((65535&e.x)<<16|65535&e.y)>>>0}}function Tp(e,t){return e>t?1:e0))return t;t=t.left;}}return null}contains(e){for(var t=this._root,r=this._compare;t;){var n=r(e,t.key);if(0===n)return !0;t=n<0?t.left:t.right;}return !1}remove(e){var t=this.find(e);if(!t)return !1;if(this.splay(t),t.left)if(t.right){var r=this.minNode(t.right);r.parent!==t&&(this.replace(r,r.right),r.right=t.right,r.right.parent=r),this.replace(t,r),r.left=t.left,r.left.parent=r;}else this.replace(t,t.left);else this.replace(t,t.right);return this._size--,!0}removeNode(e){if(!e)return !1;if(this.splay(e),e.left)if(e.right){var t=this.minNode(e.right);t.parent!==e&&(this.replace(t,t.right),t.right=e.right,t.right.parent=t),this.replace(e,t),t.left=e.left,t.left.parent=t;}else this.replace(e,e.left);else this.replace(e,e.right);return this._size--,!0}erase(e){var t=this.find(e);if(t){this.splay(t);var r=t.left,n=t.right,i=null;r&&(r.parent=null,i=this.maxNode(r),this.splay(i),this._root=i),n&&(r?i.right=n:this._root=n,n.parent=i),this._size--;}}pop(){var e=this._root,t=null;if(e){for(;e.left;)e=e.left;t={key:e.key,data:e.data},this.remove(e.key);}return t}next(e){var t=e;if(t)if(t.right)for(t=t.right;t&&t.left;)t=t.left;else for(t=e.parent;t&&t.right===e;)e=t,t=t.parent;return t}prev(e){var t=e;if(t)if(t.left)for(t=t.left;t&&t.right;)t=t.right;else for(t=e.parent;t&&t.left===e;)e=t,t=t.parent;return t}forEach(e){for(var t=this._root,r=[],n=!1,i=0;!n;)t?(r.push(t),t=t.left):r.length>0?(e(t=r.pop(),i++),t=t.right):n=!0;return this}range(e,t,r,n){const i=[],s=this._compare;let o,a=this._root;for(;0!==i.length||a;)if(a)i.push(a),a=a.left;else {if(a=i.pop(),o=s(a.key,t),o>0)break;if(s(a.key,e)>=0&&r.call(n,a))return this;a=a.right;}return this}keys(){for(var e=this._root,t=[],r=[],n=!1;!n;)e?(t.push(e),e=e.left):t.length>0?(e=t.pop(),r.push(e.key),e=e.right):n=!0;return r}values(){for(var e=this._root,t=[],r=[],n=!1;!n;)e?(t.push(e),e=e.left):t.length>0?(e=t.pop(),r.push(e.data),e=e.right):n=!0;return r}at(e){for(var t=this._root,r=[],n=!1,i=0;!n;)if(t)r.push(t),t=t.left;else if(r.length>0){if(t=r.pop(),i===e)return t;i++,t=t.right;}else n=!0;return null}load(e=[],t=[],r=!1){if(0!==this._size)throw new Error("bulk-load: tree is not empty");const n=e.length;return r&&Ep(e,t,0,n-1,this._compare),this._root=Vp(null,e,t,0,n),this._size=n,this}min(){var e=this.minNode(this._root);return e?e.key:null}max(){var e=this.maxNode(this._root);return e?e.key:null}isEmpty(){return null===this._root}get size(){return this._size}static createTree(e,t,r,n,i){return new kp(r,i).load(e,t,n)}}function Vp(e,t,r,n,i){const s=i-n;if(s>0){const o=n+Math.floor(s/2),a={key:t[o],data:r[o],parent:e};return a.left=Vp(a,t,r,n,o),a.right=Vp(a,t,r,o+1,i),a}return null}function Ep(e,t,r,n,i){if(r>=n)return;const s=e[r+n>>1];let o=r-1,a=n+1;for(;;){do{o++;}while(i(e[o],s)<0);do{a--;}while(i(e[a],s)>0);if(o>=a)break;let r=e[o];e[o]=e[a],e[a]=r,r=t[o],t[o]=t[a],t[a]=r;}Ep(e,t,r,a,i),Ep(e,t,a+1,n,i);}const Fp=11102230246251565e-32,Dp=134217729,Cp=(3+8*Fp)*Fp;function Rp(e,t,r,n,i){let s,o,a,l,u=t[0],c=n[0],h=0,p=0;c>u==c>-u?(s=u,u=t[++h]):(s=c,c=n[++p]);let d=0;if(hu==c>-u?(o=u+s,a=s-(o-u),u=t[++h]):(o=c+s,a=s-(o-c),c=n[++p]),s=o,0!==a&&(i[d++]=a);hu==c>-u?(o=s+u,l=o-s,a=s-(o-l)+(u-l),u=t[++h]):(o=s+c,l=o-s,a=s-(o-l)+(c-l),c=n[++p]),s=o,0!==a&&(i[d++]=a);for(;h0:(r[0]-e[0])*(t[1]-e[1])-(t[0]-e[0])*(r[1]-e[1])>0}isAbove(e){return !this.isBelow(e)}isVertical(){return this.point[0]===this.otherEvent.point[0]}get inResult(){return 0!==this.resultTransition}clone(){const e=new Xp(this.point,this.left,this.otherEvent,this.isSubject,this.type);return e.contourId=this.contourId,e.resultTransition=this.resultTransition,e.prevInResult=this.prevInResult,e.isExteriorRing=this.isExteriorRing,e.inOut=this.inOut,e.otherInOut=this.otherInOut,e}}function Hp(e,t){return e[0]===t[0]&&e[1]===t[1]}function Zp(e,t,r){const n=function(e,t,r,n,i,s){const o=(t-s)*(r-i),a=(e-i)*(n-s),l=o-a;if(0===o||0===a||o>0!=a>0)return l;const u=Math.abs(o+a);return Math.abs(l)>=33306690738754716e-32*u?l:-function(e,t,r,n,i,s,o){let a,l,u,c,h,p,d,f,m,y,g,x,v,b,w,_,A,M;const I=e-i,S=r-i,z=t-s,P=n-s;b=I*P,p=Dp*I,d=p-(p-I),f=I-d,p=Dp*P,m=p-(p-P),y=P-m,w=f*y-(b-d*m-f*m-d*y),_=z*S,p=Dp*z,d=p-(p-z),f=z-d,p=Dp*S,m=p-(p-S),y=S-m,A=f*y-(_-d*m-f*m-d*y),g=w-A,h=w-g,Op[0]=w-(g+h)+(h-A),x=b+g,h=x-b,v=b-(x-h)+(g-h),g=v-_,h=v-g,Op[1]=v-(g+h)+(h-_),M=x+g,h=M-x,Op[2]=x-(M-h)+(g-h),Op[3]=M;let B=function(e,t){let r=t[0];for(let e=1;e<4;e++)r+=t[e];return r}(0,Op),T=22204460492503146e-32*o;if(B>=T||-B>=T)return B;if(h=e-I,a=e-(I+h)+(h-i),h=r-S,u=r-(S+h)+(h-i),h=t-z,l=t-(z+h)+(h-s),h=n-P,c=n-(P+h)+(h-s),0===a&&0===l&&0===u&&0===c)return B;if(T=11093356479670487e-47*o+Cp*Math.abs(B),B+=I*c+P*a-(z*u+S*l),B>=T||-B>=T)return B;b=a*P,p=Dp*a,d=p-(p-a),f=a-d,p=Dp*P,m=p-(p-P),y=P-m,w=f*y-(b-d*m-f*m-d*y),_=l*S,p=Dp*l,d=p-(p-l),f=l-d,p=Dp*S,m=p-(p-S),y=S-m,A=f*y-(_-d*m-f*m-d*y),g=w-A,h=w-g,Gp[0]=w-(g+h)+(h-A),x=b+g,h=x-b,v=b-(x-h)+(g-h),g=v-_,h=v-g,Gp[1]=v-(g+h)+(h-_),M=x+g,h=M-x,Gp[2]=x-(M-h)+(g-h),Gp[3]=M;const k=Rp(4,Op,4,Gp,Up);b=I*c,p=Dp*I,d=p-(p-I),f=I-d,p=Dp*c,m=p-(p-c),y=c-m,w=f*y-(b-d*m-f*m-d*y),_=z*u,p=Dp*z,d=p-(p-z),f=z-d,p=Dp*u,m=p-(p-u),y=u-m,A=f*y-(_-d*m-f*m-d*y),g=w-A,h=w-g,Gp[0]=w-(g+h)+(h-A),x=b+g,h=x-b,v=b-(x-h)+(g-h),g=v-_,h=v-g,Gp[1]=v-(g+h)+(h-_),M=x+g,h=M-x,Gp[2]=x-(M-h)+(g-h),Gp[3]=M;const V=Rp(k,Up,4,Gp,Np);b=a*c,p=Dp*a,d=p-(p-a),f=a-d,p=Dp*c,m=p-(p-c),y=c-m,w=f*y-(b-d*m-f*m-d*y),_=l*u,p=Dp*l,d=p-(p-l),f=l-d,p=Dp*u,m=p-(p-u),y=u-m,A=f*y-(_-d*m-f*m-d*y),g=w-A,h=w-g,Gp[0]=w-(g+h)+(h-A),x=b+g,h=x-b,v=b-(x-h)+(g-h),g=v-_,h=v-g,Gp[1]=v-(g+h)+(h-_),M=x+g,h=M-x,Gp[2]=x-(M-h)+(g-h),Gp[3]=M;const E=Rp(V,Np,4,Gp,jp);return jp[E-1]}(e,t,r,n,i,s,u)}(e[0],e[1],t[0],t[1],r[0],r[1]);return n>0?-1:n<0?1:0}function Wp(e,t){const r=e.point,n=t.point;return r[0]>n[0]?1:r[0]n[1]?1:-1:function(e,t,r){return e.left!==t.left?e.left?1:-1:0!==Zp(r,e.otherEvent.point,t.otherEvent.point)?e.isBelow(t.otherEvent.point)?-1:1:!e.isSubject&&t.isSubject?1:-1}(e,t,r)}function Yp(e,t,r){const n=new Xp(t,!1,e,e.isSubject),i=new Xp(t,!0,e.otherEvent,e.isSubject);return Hp(e.point,e.otherEvent.point)&&console.warn("what is that, a collapsed segment?",e),n.contourId=i.contourId=e.contourId,Wp(i,e.otherEvent)>0&&(e.otherEvent.left=!0,i.left=!1),e.otherEvent.otherEvent=i,e.otherEvent=n,r.push(i),r.push(n),r}function Jp(e,t){return e[0]*t[1]-e[1]*t[0]}function Kp(e,t){return e[0]*t[0]+e[1]*t[1]}function Qp(e,t,r){const n=function(e,t,r,n){const i=[t[0]-e[0],t[1]-e[1]],s=[n[0]-r[0],n[1]-r[1]];function o(e,t,r){return [e[0]+t*r[0],e[1]+t*r[1]]}const a=[r[0]-e[0],r[1]-e[1]];let l=Jp(i,s),u=l*l;const c=Kp(i,i);if(u>0){const t=Jp(a,s)/l;if(t<0||t>1)return null;const n=Jp(a,i)/l;return n<0||n>1?null:0===t||1===t?[o(e,t,i)]:0===n||1===n?[o(r,n,s)]:[o(e,t,i)]}if(l=Jp(a,i),u=l*l,u>0)return null;const h=Kp(i,a)/c,p=h+Kp(i,s)/c,d=Math.min(h,p),f=Math.max(h,p);return d<=1&&f>=0?1===d?[o(e,d>0?d:0,i)]:0===f?[o(e,f<1?f:1,i)]:[o(e,d>0?d:0,i),o(e,f<1?f:1,i)]:null}(e.point,e.otherEvent.point,t.point,t.otherEvent.point),i=n?n.length:0;if(0===i||1===i&&(Hp(e.point,t.point)||Hp(e.otherEvent.point,t.otherEvent.point))||2===i&&e.isSubject===t.isSubject)return 0;if(1===i)return !Hp(e.point,n[0])&&!Hp(e.otherEvent.point,n[0])&&Yp(e,n[0],r),!Hp(t.point,n[0])&&!Hp(t.otherEvent.point,n[0])&&Yp(t,n[0],r),1;const s=[];let o=!1,a=!1;return Hp(e.point,t.point)?o=!0:1===Wp(e,t)?s.push(t,e):s.push(e,t),Hp(e.otherEvent.point,t.otherEvent.point)?a=!0:1===Wp(e.otherEvent,t.otherEvent)?s.push(t.otherEvent,e.otherEvent):s.push(e.otherEvent,t.otherEvent),o&&a||o?(t.type=1,e.type=t.inOut===e.inOut?2:3,o&&!a&&Yp(s[1].otherEvent,s[0].point,r),2):a?(Yp(s[0],s[1].point,r),3):s[0]!==s[3].otherEvent?(Yp(s[0],s[1].point,r),Yp(s[1],s[2].point,r),3):(Yp(s[0],s[1].point,r),Yp(s[3].otherEvent,s[2].point,r),3)}function ed(e,t){if(e===t)return 0;if(0!==Zp(e.point,e.otherEvent.point,t.point)||0!==Zp(e.point,e.otherEvent.point,t.otherEvent.point))return Hp(e.point,t.point)?e.isBelow(t.otherEvent.point)?-1:1:e.point[0]===t.point[0]?e.point[1](t.contourId??0)?1:-1}return 1===Wp(e,t)?1:-1}class td{constructor(){this.points=[],this.holeIds=[],this.holeOf=null,this.depth=null;}isExterior(){return null==this.holeOf}}function rd(e,t,r,n){let i,s=e+1,o=t[e].point;const a=t.length;for(sn;)s--;return s}function nd(e,t,r){const n=new td;if(null!=e.prevInResult){const i=e.prevInResult,s=i.outputContourId;if(i.resultTransition>0){const e=t[s];if(null!=e.holeOf){const i=e.holeOf;t[i].holeIds.push(r),n.holeOf=i,n.depth=t[s].depth;}else t[s].holeIds.push(r),n.holeOf=s,n.depth=t[s].depth+1;}else n.holeOf=null,n.depth=t[s].depth;}else n.holeOf=null,n.depth=0;return n}const id=Math.max,sd=Math.min;let od=0;function ad(e,t,r,n,i,s){let o,a,l,u,c,h;for(o=0,a=e.length-1;o0?h.left=!0:c.left=!0;const a=l[0],p=l[1];i[0]=sd(i[0],a),i[1]=sd(i[1],p),i[2]=id(i[2],a),i[3]=id(i[3],p),n.push(c),n.push(h);}}const ld=[];function ud(e,t,r){let n=e,i=t;"number"==typeof e[0][0][0]&&(n=[e]),"number"==typeof t[0][0][0]&&(i=[t]);let s=function(e,t,r){let n=null;return e.length*t.length===0&&(0===r?n=ld:2===r?n=e:(1===r||3===r)&&(n=0===e.length?t:e)),n}(n,i,r);if(s)return s===ld?null:s;const o=[1/0,1/0,-1/0,-1/0],a=[1/0,1/0,-1/0,-1/0],l=function(e,t,r,n,i){const s=new On(void 0,Wp);let o,a,l,u,c,h;for(l=0,u=e.length;ln[2]||n[0]>r[2]||r[1]>n[3]||n[1]>r[3])&&(0===i?s=ld:2===i?s=e:(1===i||3===i)&&(s=e.concat(t))),s}(n,i,o,a,r),s)return s===ld?null:s;const u=function(e,t,r,n,i,s){const o=new kp(ed),a=[],l=Math.min(n[2],i[2]);let u,c,h;for(;0!==e.length;){let t=e.pop();if(a.push(t),0===s&&t.point[0]>l||2===s&&t.point[0]>n[2])break;if(t.left){c=u=o.insert(t),h=o.minNode(),u=u!==h?o.prev(u):null,c=o.next(c);const r=u?u.key:null;let n;if($p(t,r,s),c&&2===Qp(t,c.key,e)&&($p(t,r,s),$p(c.key,t,s)),u&&2===Qp(u.key,t,e)){let e=u;e=e!==h?o.prev(e):null,n=e?e.key:null,$p(r,n,s),$p(t,r,s);}}else t=t.otherEvent,c=u=o.find(t),u&&c&&(u=u!==h?o.prev(u):null,c=o.next(c),o.remove(t),c&&u&&Qp(u.key,c.key,e));}return a}(l,0,0,o,a,r),c=function(e){let t,r;const n=function(e){let t,r,n,i,s;const o=[];for(r=0,n=e.length;r{i[t]=!0,t=n.length)&&n[a];);s.push(r);}return s}(u),h=[];for(let e=0;e{e.push(new Ie(s,r+(s-t)/(n-t)*(i-r)));}:(e,t,r,n,i,s)=>{e.push(new Ie(t+(s-r)/(i-r)*(n-t),s));};for(const o of e){const e=[];for(const i of o){if(i.length<=2)continue;const o=[];for(let e=0;et&&s(o,a,l,u,c,t):h>r?p=t&&s(o,a,l,u,c,t),p>r&&h<=r&&s(o,a,l,u,c,r);}let a=i[i.length-1];const l=0===n?a.x:a.y;l>=t&&l<=r&&o.push(a),o.length&&(a=o[o.length-1],o[0].x===a.x&&o[0].y===a.y||o.push(o[0]),e.push(o));}e.length&&i.push(e);}return i}function hd(e,t){const r=ud(dd(e),dd([t]),0);return null==r?[]:fd(r)}function pd(e,t){const r=65536;let n=dd(e,r);const i=[];for(;t.valid();t.next()){const[e,n]=t.get(),s=e.x*r,o=e.y*r,a=n.x*r,l=n.y*r,u=a-s,c=l-o,h=Math.hypot(u,c);if(0===h)continue;const p=Math.trunc(c/h*3),d=-Math.trunc(u/h*3);i.push([[[s,o],[a,l],[a+p,l+d],[s+p,o+d],[s,o]]]);}return i.length>0&&(n=ud(n,i,2)),fd(n,1/r,128)}function dd(e,t=1){return [e.map(e=>e.map(e=>[e.x*t,e.y*t]))]}function fd(e,t=1,r){return e.map(e=>e.map((e,n)=>{const i=e.map(e=>{let n=e[0],i=e[1];return r&&(n=Math.round(n/r)*r,i=Math.round(i/r)*r),new Ie(n*t,i*t)._round()});return n>0&&i.reverse(),i}))}class md{constructor(e,t){this.layoutVertexArray=new Oa,this.indexArray=new ol,this.lineIndexArray=new tl,this.triangleSegments=new Rl,this.lineSegments=new Rl,this.programConfigurations=new pu(e.layers,{zoom:e.zoom,lut:e.lut}),this.uploaded=!1,t&&(this.elevatedLayoutVertexArray=new ja);}update(e,t,r,n,i,s,o,a){this.programConfigurations.updatePaintArrays(e,t,i,r,n,s,o,a);}isEmpty(){return 0===this.layoutVertexArray.length}needsUpload(){return this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Xh.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.lineIndexBuffer=e.createIndexBuffer(this.lineIndexArray),this.elevatedLayoutVertexArray&&this.elevatedLayoutVertexArray.length>0&&(this.elevatedLayoutVertexBuffer=e.createVertexBuffer(this.elevatedLayoutVertexArray,Hh.members))),this.programConfigurations.upload(e),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.elevatedLayoutVertexBuffer&&this.elevatedLayoutVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.lineIndexBuffer.destroy(),this.programConfigurations.destroy(),this.triangleSegments.destroy(),this.lineSegments.destroy());}populatePaintArrays(e,t,r,n,i,s,o){this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,t,r,n,i,s,void 0,o);}}class yd{constructor(e){this.zoom=e.zoom,this.pixelRatio=e.pixelRatio,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.fqid),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.lut=e.lut,this.bufferData=new md(e,!1),this.elevationBufferData=new md(e,!0),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.projection=e.projection,this.elevationMode=this.layers[0].layout.get("fill-elevation-reference"),this.sourceLayerIndex=e.sourceLayerIndex,this.worldview=e.worldview,this.hasAppearances=null;}updateFootprints(e,t){}updateAppearances(e,t,r,n){}populate(e,t,r,n){this.hasPattern=Ip("fill",this.layers,this.pixelRatio,t);const i=this.layers[0].layout.get("fill-sort-key"),s=[];for(const{feature:o,id:a,index:l,sourceLayerIndex:u}of e){const e=this.layers[0]._featureFilter.needGeometry,c=Yu(o,e);if(!this.layers[0]._featureFilter.filter(new Yo(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),c,r))continue;const h=i?i.evaluate(c,{},r,t.availableImages):void 0,p={id:a,properties:o.properties,type:o.type,sourceLayerIndex:u,index:l,geometry:e?c.geometry:Wu(o,r,n),patterns:{},sortKey:h};s.push(p);}i&&s.sort((e,t)=>e.sortKey-t.sortKey);for(const n of s){const{geometry:i,index:s,sourceLayerIndex:o}=n;if(this.hasPattern){const e=Sp("fill",this.layers,n,this.zoom,this.pixelRatio,t);this.patternFeatures.push(e);}else this.addFeature(n,i,s,r,{},t.availableImages,t.brightness,t.elevationFeatures);t.featureIndex.insert(e[s].feature,i,s,o,this.index);}}update(e,t,r,n,i,s,o){this.bufferData.update(e,t,r,n,i,s,o,this.worldview),this.elevationBufferData.update(e,t,r,n,i,s,o,this.worldview),this.elevatedStructures&&this.elevatedStructures.update(e,t,r,n,i,s,o,this.worldview);}addFeatures(e,t,r,n,i,s){for(const i of this.patternFeatures)this.addFeature(i,i.geometry,i.index,t,r,n,s,e.elevationFeatures);}isEmpty(){return this.bufferData.isEmpty()&&this.elevationBufferData.isEmpty()}uploadPending(){return !this.uploaded||this.bufferData.needsUpload()||this.elevationBufferData.needsUpload()}upload(e){this.bufferData.upload(e),this.elevationBufferData.upload(e),this.elevatedStructures&&this.elevatedStructures.upload(e);}destroy(){this.bufferData.destroy(),this.elevationBufferData.destroy(),this.elevatedStructures&&this.elevatedStructures.destroy();}addFeature(e,t,r,n,i,s=[],o,a){const l=_p(t,500);"none"!==this.elevationMode?this.addElevatedRoadFeature(e,l,n,r,a):this.addGeometry(l,this.bufferData),this.bufferData.populatePaintArrays(e,r,i,s,n,o,this.worldview),this.elevationBufferData.populatePaintArrays(e,r,i,s,n,o,this.worldview);}getUnevaluatedPortalGraph(){return this.elevatedStructures?this.elevatedStructures.unevaluatedPortals:void 0}setEvaluatedPortalGraph(e,t,r,n,i){this.elevatedStructures&&(this.elevatedStructures.construct(e),this.elevatedStructures.populatePaintArrays(t,r,n,i,this.worldview));}addElevatedRoadFeature(e,t,r,n,i){const s=new Array,o=_c.getElevationFeature(e,i);if(!o)return void this.addGeometry(t,this.bufferData);{const e=this.clipPolygonsToTile(t,1);e.length>0&&s.push({polygons:e,elevationFeature:o,elevationTileID:r});}const a={guardRailEnabled:this.layers[0].layout.get("fill-construct-bridge-guard-rail").evaluate(e,{},r),featureIndex:n};for(const t of s)if(t.elevationFeature){if("hd-road-base"===this.elevationMode){this.elevatedStructures||(this.elevatedStructures=new Bp(t.elevationTileID,this.layers,this.zoom,this.lut));const r=t.elevationFeature.isTunnel();let n=0;e.properties.hasOwnProperty(sc)&&(n=+e.properties[sc]),this.elevatedStructures.addPortalCandidates(t.elevationFeature.id,t.polygons,r,t.elevationFeature,n);}null==t.elevationFeature.constantHeight&&(t.polygons=this.prepareElevatedPolygons(t.polygons,t.elevationFeature,t.elevationTileID));const i=new Ac(r,t.elevationTileID);this.addElevatedGeometry(t.polygons,i,t.elevationFeature,"hd-road-base"===this.elevationMode?0:.05,n,a);}}addElevatedGeometry(e,t,r,n,i,s){const o={elevation:r,elevationSampler:t,bias:n,index:i,featureInfo:s},[a,l]=this.addGeometry(e,this.elevationBufferData,o);null==this.elevationBufferData.heightRange?this.elevationBufferData.heightRange={min:a,max:l}:(this.elevationBufferData.heightRange.min=Math.min(this.elevationBufferData.heightRange.min,a),this.elevationBufferData.heightRange.max=Math.max(this.elevationBufferData.heightRange.max,l));}addGeometry(e,t,r){let n=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,s=null;r&&(s=r.elevationSampler.constantElevation(r.elevation,r.bias),null!=s&&(n=s,i=s));const o=(e,o,a)=>{if(null!=r)if(o.push(e),null!=s)t.elevatedLayoutVertexArray.emplaceBack(s),a.push(s);else {const s=r.elevationSampler.pointElevation(e,r.elevation,r.bias);t.elevatedLayoutVertexArray.emplaceBack(s),a.push(s),n=Math.min(n,s),i=Math.max(i,s);}};for(const n of e){let e=0;for(const t of n)e+=t.length;const i=t.triangleSegments.prepareSegment(e,t.layoutVertexArray,t.indexArray),s=i.vertexLength,a=[],l=[],u=[],c=[],h=[],p=t.layoutVertexArray.length;for(const e of n){if(0===e.length)continue;e!==n[0]&&l.push(a.length/2);const i=t.lineSegments.prepareSegment(e.length,t.layoutVertexArray,t.lineIndexArray),s=i.vertexLength;r&&h.push(t.layoutVertexArray.length-p),o(e[0],u,c),t.layoutVertexArray.emplaceBack(e[0].x,e[0].y),t.lineIndexArray.emplaceBack(s+e.length-1,s),a.push(e[0].x),a.push(e[0].y);for(let r=1;r0&&r&&"hd-road-base"===this.elevationMode){const e=r.elevation.isTunnel(),t=r.elevation.safeArea,n=this.elevatedStructures.addVertices(u,c);this.elevatedStructures.addTriangles(d,n,e);const i=h.length;if(i>0){for(let s=0;s=r&&u.max.x<=i&&u.min.y>=n&&u.max.y<=s?a:l).push(t);}if(a.length===e.length)return e;const u=[new Ie(r,n),new Ie(i,n),new Ie(i,s),new Ie(r,s),new Ie(r,n)],c=a;for(const e of l)c.push(...hd(e,u));return c}}let gd,xd,vd,bd;Js(yd,"FillBucket",{omit:["layers","patternFeatures"]}),Js(md,"FillBufferData"),Js(Bp,"ElevatedStructures");class wd{constructor(e,t,r,n){if(this.triangleCount=t.length/3,this.min=new Ie(0,0),this.max=new Ie(0,0),this.xScale=0,this.yScale=0,this.cellsX=0,this.cellsY=0,this.cells=[],this.payload=[],0===this.triangleCount||0===e.length)return;const[i,s]=[e[0].clone(),e[0].clone()];for(let t=1;te.cellIdx-t.cellIdx||e.triIdx-t.triIdx);let u=0;for(;uthis.max.x||this.min.x>e.x||e.y>this.max.y||this.min.y>e.y)return;const r=_d(e.x-this.min.x,this.xScale,this.cellsX),n=_d(e.y-this.min.y,this.yScale,this.cellsY),i=this.cells[n*this.cellsX+r];if(i){this._lazyInitLookup();for(let e=0;ethis.max.x||this.min.x>t.x)return;if(e.y>this.max.y||this.min.y>t.y)return;this._lazyInitLookup();const n=_d(e.x-this.min.x,this.xScale,this.cellsX),i=_d(t.x-this.min.x,this.xScale,this.cellsX),s=_d(e.y-this.min.y,this.yScale,this.cellsY),o=_d(t.y-this.min.y,this.yScale,this.cellsY);for(let e=s;e<=o;e++)for(let t=n;t<=i;t++){const n=this.cells[e*this.cellsX+t];if(n)for(let e=0;ee.fqid),this.index=e.index,this.hasPattern=!1,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.footprints=[],this.worldview=e.worldview,this.hasAppearances=null;}updateFootprints(e,t){for(const r of this.footprints)t.push({footprint:r,id:e});}updateAppearances(e,t,r,n){}populate(e,t,r,n){const i=[];for(const{feature:s,id:o,index:a,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,u=Yu(s,e);if(!this.layers[0]._featureFilter.filter(new Yo(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),u,r))continue;const c={id:o,properties:s.properties,type:s.type,sourceLayerIndex:l,index:a,geometry:e?u.geometry:Wu(s,r,n),patterns:{}};i.push(c);}for(const n of i){const{geometry:i,index:s,sourceLayerIndex:o}=n;this.addFeature(n,i,s,r,{},t.availableImages,t.brightness),t.featureIndex.insert(e[s].feature,i,s,o,this.index);}}isEmpty(){return 0===this.footprints.length}uploadPending(){return !1}upload(e){}update(e,t,r,n,i,s,o){}destroy(){}addFeature(e,t,r,n,i,s=[],o){for(const e of _p(t,2)){const t=[],r=[],n=[],i=new Ie(1/0,1/0),s=new Ie(-1/0,-1/0);for(const o of e)if(0!==o.length){o!==e[0]&&n.push(r.length/2);for(let e=0;et===e)}(n,e.clipScope)}function Dd(e,t){return e.x-t.x||e.y-t.y}function Cd(e,t){return 0===Dd(e.min,t.min)&&0===Dd(e.max,t.max)}function Rd(e,t){return !(e.min.x>t.max.x||e.max.xt.max.y||e.max.ynew Ie((e.x+s.x*Un)*a-o.x*Un,(e.y+s.y*Un)*a-o.y*Un));}return Nd(r,i,e.indices,0,e.indices.length,0,0)}function Gd(e,t,r,n){const i=Math.pow(2,n.z-r.z);return new Ie((e+r.x*Un)*i-n.x*Un,(t+r.y*Un)*i-n.y*Un)}function $d(e,t){const r=[];t.grid.queryPoint(e,r);const n=t.indices,i=t.vertices;for(let t=0;t0&&(n.length>1&&r.push(n),n=[]);}return n.length>1&&r.push(n),r}const Hd=Ju.types,Zd=["fill-extrusion-base","fill-extrusion-height","fill-extrusion-color","fill-extrusion-pattern","fill-extrusion-flood-light-wall-radius","fill-extrusion-line-width","fill-extrusion-emissive-strength"],Wd=["fill-extrusion-flood-light-ground-radius"],Yd=Math.pow(2,13),Jd=Math.pow(2,15)-1,Kd=new Ie(0,1),Qd=2147483648;function ef(e,t,r,n,i,s,o,a){e.emplaceBack((t<<1)+o,(r<<1)+s,(Math.floor(n*Yd)<<1)+i,Math.round(a));}function tf(e,t,r){e.emplaceBack(t.x*Un,t.y*Un,r?1:0);}function rf(e,t,r,n,i,s){e.emplaceBack(t.x,t.y,(r.x<<1)+n,(r.y<<1)+i,s);}function nf(e,t,r){const n=16384;e.emplaceBack(t.x,t.y,t.z,r[0]*n,r[1]*n,r[2]*n);}class sf{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0;}}class of{constructor(){this.centroidXY=new Ie(0,0),this.vertexArrayOffset=0,this.vertexCount=0,this.groundVertexArrayOffset=0,this.groundVertexCount=0,this.flags=0,this.footprintSegIdx=-1,this.footprintSegLen=0,this.polygonSegIdx=-1,this.polygonSegLen=0,this.min=new Ie(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new Ie(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0,this.buildingId=0;}span(){return new Ie(this.max.x-this.min.x,this.max.y-this.min.y)}}class af{constructor(){this.acc=new Ie(0,0),this.accCount=0,this.centroidDataIndex=0;}startRing(e,t){e.min.x===Number.MAX_VALUE&&(e.min.x=e.max.x=t.x,e.min.y=e.max.y=t.y);}appendEdge(e,t,r){this.accCount++,this.acc._add(t);let n=!!this.borders;t.xe.max.x&&(e.max.x=t.x,n=!0),t.ye.max.y&&(e.max.y=t.y,n=!0),((0===t.x||t.x===Un)&&t.x===r.x)!=((0===t.y||t.y===Un)&&t.y===r.y)&&this.processBorderOverlap(t,r),n&&this.checkBorderIntersection(t,r);}checkBorderIntersection(e,t){t.x<0!=e.x<0&&this.addBorderIntersection(0,hr(t.y,e.y,(0-t.x)/(e.x-t.x))),t.x>Un!=e.x>Un&&this.addBorderIntersection(1,hr(t.y,e.y,(Un-t.x)/(e.x-t.x))),t.y<0!=e.y<0&&this.addBorderIntersection(2,hr(t.x,e.x,(0-t.y)/(e.y-t.y))),t.y>Un!=e.y>Un&&this.addBorderIntersection(3,hr(t.x,e.x,(Un-t.y)/(e.y-t.y)));}addBorderIntersection(e,t){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const r=this.borders[e];tr[1]&&(r[1]=t);}processBorderOverlap(e,t){if(e.x===t.x){if(e.y===t.y)return;const r=0===e.x?0:1;this.addBorderIntersection(r,t.y),this.addBorderIntersection(r,e.y);}else {const r=0===e.y?2:3;this.addBorderIntersection(r,t.x),this.addBorderIntersection(r,e.x);}}centroid(){return 0===this.accCount?new Ie(0,0):new Ie(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce((e,t)=>e+ +(t[0]!==Number.MAX_VALUE),0):0}}function lf(e,t){const r=e.add(t)._unit(),n=De(e.x*r.x+e.y*r.y,-1,1);var i,s,o;return o=Math.acos(n),Math.min(4,Math.max(-4,Math.tan(o)))/4*Jd*((i=e).x*(s=t).y-i.y*s.x<0?-1:1)}const uf=[e=>e.x<0,e=>e.x>Un,e=>e.y<0,e=>e.y>Un];function cf(e,t,r,n){const i=[4];if(0===n)return i;r._mult(n);const s=e.sub(r),o=t.sub(r),a=[e,t,s,o];for(let e=0;e<4;e++)for(const t of a)if(uf[e](t)){i.push(e);break}return i}class hf{constructor(e){this.groundRadiusArray=null,this.groundRadiusBuffer=null,this.vertexArray=new qa,this.indexArray=new ol,this.programConfigurations=new pu(e.layers,{zoom:e.zoom,lut:e.lut},e=>Wd.includes(e)),this._segments=new Rl,this.hiddenByLandmarkVertexArray=new bl,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new Rl;}getDefaultSegment(){return this.regionSegments[4]}hasData(){return 0!==this.vertexArray.length}addData(e,t,r,n=!1){const i=e.length;if(i>2){let s=Math.max(0,this._segments.get().length-1);const o=this._segments._prepareSegment(4*i,this.vertexArray.length,2*this._segmentToGroundQuads[s].length);let a;s!==this._segments.get().length-1&&(s++,this._segmentToGroundQuads[s]=[],this._segmentToRegionTriCounts[s]=[0,0,0,0,0]);{const t=e[0],r=e[1];a=lf(t.sub(e[i-1])._perp()._unit(),r.sub(t)._perp()._unit());}for(let l=0;le.region-t.region);for(let r=0;re+t,0);let s=0;for(let e=0;e<=4;e++){const t=i[e];if(0!==t){let r=this.regionSegments[e];r||(r=this.regionSegments[e]=new Rl);const i={vertexOffset:n.vertexOffset,primitiveOffset:n.primitiveOffset+s,vertexLength:n.vertexLength,primitiveLength:t};r.get().push(i);}s+=t;}for(let e=0;e0?this.hiddenByLandmarkVertexBuffer=e.createVertexBuffer(this.hiddenByLandmarkVertexArray,Bd.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1);}destroy(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this.groundRadiusBuffer&&this.groundRadiusBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let e=0;e<=4;e++){const t=this.regionSegments[e];t&&t.destroy();}}}}class pf{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.overscaling=e.overscaling,this.layers=e.layers,this.pixelRatio=e.pixelRatio,this.layerIds=this.layers.map(e=>e.fqid),this.index=e.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=e.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=[],this.footprintIndices=new ol,this.footprintVertices=new Oa,this.footprintSegments=[],this.layoutVertexArray=new Na,this.centroidVertexArray=new kl,this.wallVertexArray=new El,this.indexArray=new ol,this.programConfigurations=new pu(e.layers,{zoom:e.zoom,lut:e.lut},e=>Zd.includes(e)),this.segments=new Rl,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.groundEffect=new hf(e),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[],this.worldview=e.worldview,this.hasAppearances=null;}updateFootprints(e,t){}updateAppearances(e,t,r,n){}populate(e,t,r,n){this.features=[],this.hasPattern=Ip("fill-extrusion",this.layers,this.pixelRatio,t),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.selfDEMTileTimestamp=Number.MAX_VALUE,this.borderDEMTileTimestamp=[Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE],this.tileToMeter=Uu(r),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter,this.wallMode=0!==this.layers[0].paint.get("fill-extrusion-line-width").constantOr(1);for(const{feature:i,id:s,index:o,sourceLayerIndex:a}of e){const e=this.layers[0]._featureFilter.needGeometry,l=Yu(i,e);if(!this.layers[0]._featureFilter.filter(new Yo(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),l,r))continue;const u={id:s,sourceLayerIndex:a,index:o,geometry:e?l.geometry:Wu(i,r,n),properties:i.properties,type:i.type,patterns:{}},c=this.layoutVertexArray.length,h="Polygon"===Hd[u.type];if(this.hasPattern)this.features.push({featureId:i.id,feature:Sp("fill-extrusion",this.layers,u,this.zoom,this.pixelRatio,t)});else if(this.wallMode)for(const e of u.geometry)for(const s of Xd(e,h))this.addFeature(i.id,u,[s],o,r,{},t.availableImages,n,t.brightness);else this.addFeature(i.id,u,u.geometry,o,r,{},t.availableImages,n,t.brightness);t.featureIndex.insert(i,u.geometry,o,a,this.index,c);}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0;}addFeatures(e,t,r,n,i,s){for(const{featureId:e,feature:o}of this.features){const a="Polygon"===Hd[o.type],{geometry:l}=o;if(this.wallMode)for(const u of l)for(const l of Xd(u,a))this.addFeature(e,o,[l],o.index,t,r,n,i,s);else this.addFeature(e,o,l,o.index,t,r,n,i,s);}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles();}update(e,t,r,n,i,s,o){this.programConfigurations.updatePaintArrays(e,t,i,r,n,s,o,this.worldview),this.groundEffect.update(e,t,i,r,n,s,o,this.worldview);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,kd),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.wallVertexBuffer=e.createVertexBuffer(this.wallVertexArray,Pd.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=e.createVertexBuffer(this.layoutVertexExtArray,Td.members,!0)),this.groundEffect.upload(e)),this.groundEffect.uploadPaintProperties(e),this.programConfigurations.upload(e),this.uploaded=!0;}uploadCentroid(e){this.groundEffect.uploadHiddenByLandmark(e),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,zd.members,!0):this.centroidVertexBuffer&&this.centroidVertexBuffer.updateData(this.centroidVertexArray),this.needsCentroidUpdate=!1);}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.groundEffect.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy());}addFeature(e,t,r,n,i,s,o,a,l){const u=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(t,{})/this.tileToMeter,c=[new Ie(0,0),new Ie(Un,Un)],h=a.projection,p="globe"===h.name,d=this.wallMode||"Polygon"===Hd[t.type],f=new af;f.centroidDataIndex=this.centroidData.length;const m=new of;m.buildingId=e,t.properties&&t.properties.hasOwnProperty("building_id")&&(m.buildingId=Number(t.properties.building_id));const y=this.layers[0].paint.get("fill-extrusion-base").evaluate(t,{},i)<=0,g=this.layers[0].paint.get("fill-extrusion-height").evaluate(t,{},i);let x;if(m.height=g,m.vertexArrayOffset=this.layoutVertexArray.length,m.groundVertexArrayOffset=this.groundEffect.vertexArray.length,p&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new Ya),this.wallMode){if(p)return void Ze("Non zero fill-extrusion-line-width is not yet supported on globe.");if(1!==r.length)return;x=function(e){const t=e[0].x===e[e.length-1].x&&e[0].y===e[e.length-1].y,r=function(e){let t=0;const r=e.length;for(let n=0;n=0}(e);r||(e=e.reverse());const n={geometry:[],joinNormals:[],indices:[]},i=[],s=[],o=[];let a=e.length;for(;a>=2&&e[a-1].equals(e[a-2]);)a--;if(a<(t?3:2))return n;let l,u,c,h,p,d=0;for(;d0;let g="miter";const x=2;"miter"===g&&m>x&&(g="bevel"),"bevel"===g&&(m>100&&(g="flipbevel"),m{const a=new Ie(e.x,e.y),l=new Ie(e.x,e.y);a.x+=t.x*n,a.y+=t.y*n,l.x-=t.x*Math.max(r,1),l.y-=t.y*Math.max(r,1),o.push(t),i.push(a),s.push(l);};if("miter"===g)n._mult(m),v(l,n,0,0);else if("flipbevel"===g)n=p.mult(-1),v(l,n,0,0),v(l,n.mult(-1),0,0);else {const e=-Math.sqrt(m*m-1),t=y?e:0,r=y?0:e;u&&v(l,h,t,r),c&&v(l,p,t,r);}}n.geometry=[...i,...s.reverse(),i[0]],n.joinNormals=[...o,...o.reverse(),o[o.length-1]];const f=n.geometry.length-1;for(let e=0;ee<(t.length-1)/2||e===t.length-1,b=this.wallMode?[r]:_p(r,500);for(let e=b.length-1;e>=0;e--){const t=b[e];(0===t.length||xf(t[0]))&&b.splice(e,1);}let w;if(p)w=_f(b,c,i);else {w=[];for(const e of b)w.push({polygon:e,bounds:c});}const _=d?this.edgeRadius:0,A=_>0&&this.zoom<17,M=(e,t)=>{if(0===e.length)return !1;const r=e[e.length-1];return t.x===r.x&&t.y===r.y};for(const{polygon:e,bounds:t}of w){let r=0,n=0;for(const t of e)d&&!t[0].equals(t[t.length-1])&&t.push(t[0]),n+=d?t.length-1:t.length;const s=this.segments.prepareSegment((d?5:4)*n,this.layoutVertexArray,this.indexArray);m.footprintSegIdx<0&&(m.footprintSegIdx=this.footprintSegments.length),m.polygonSegIdx<0&&(m.polygonSegIdx=this.polygonSegments.length);const o={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},a=new sf;if(a.vertexOffset=this.footprintVertices.length,a.indexOffset=3*this.footprintIndices.length,a.ringIndices=[],d){const n=[],o=[];r=s.vertexLength;for(let r=0;r4&&vf(o[o.length-2],o[0],o[1]),l=_?ff(o[o.length-2],o[0],o[1],_):0;const c=[];let g,b,w;b=o[1].sub(o[0])._perp()._unit();let A=!0;for(let e=1,n=0;e0?1:0,B=u.dist(d);if(n+B>32768&&(n=0),_){w=I.sub(d)._perp()._unit();let e=mf(u,d,I,df(b,w),_);isNaN(e)&&(e=0);const t=d.sub(u)._unit();u=u.add(t.mult(l))._round(),d=d.add(t.mult(-e))._round(),l=e,b=w,y&&this.zoom>=17&&(M(c,u)||c.push(u),M(c,d)||c.push(d));}const T=s.vertexLength,k=o.length>4&&vf(u,d,I);let V=bf(n,a,A);if(ef(this.layoutVertexArray,u.x,u.y,z,P,0,0,V),ef(this.layoutVertexArray,u.x,u.y,z,P,0,1,V),this.wallMode){const t=v(e-1,o),r=x.joinNormals[e-1];tf(this.wallVertexArray,r,t),tf(this.wallVertexArray,r,t);}if(n+=B,V=bf(n,k,!A),a=k,ef(this.layoutVertexArray,d.x,d.y,z,P,0,0,V),ef(this.layoutVertexArray,d.x,d.y,z,P,0,1,V),this.wallMode){const t=v(e,o),r=x.joinNormals[e];tf(this.wallVertexArray,r,t),tf(this.wallVertexArray,r,t);}if(s.vertexLength+=4,this.indexArray.emplaceBack(T+0,T+1,T+2),this.indexArray.emplaceBack(T+1,T+3,T+2),s.primitiveLength+=2,_){const n=r+(1===e?o.length-2:e-2),i=1===e?r:n+1;if(this.indexArray.emplaceBack(T+1,n,T+3),this.indexArray.emplaceBack(n,i,T+3),s.primitiveLength+=2,void 0===g&&(g=T),!yf(I,o[e],t)){const t=e===o.length-1?g:s.vertexLength;this.indexArray.emplaceBack(T+2,T+3,t),this.indexArray.emplaceBack(T+3,t+1,t),this.indexArray.emplaceBack(T+3,i,t+1),s.primitiveLength+=3;}A=!A;}if(p){const e=this.layoutVertexExtArray,t=h.projectTilePoint(u.x,u.y,i),r=h.projectTilePoint(d.x,d.y,i),n=h.upVector(i,u.x,u.y),s=h.upVector(i,d.x,d.y);nf(e,t,n),nf(e,t,n),nf(e,r,s),nf(e,r,s);}}d&&(r+=o.length-1),y&&_&&this.zoom>=17&&(0!==c.length&&M(c,c[0])&&c.pop(),this.groundEffect.addData(c,t,u,_>0));}this.footprintSegments.push(a),o.triangleCount=this.indexArray.length-o.triangleArrayOffset,this.polygonSegments.push(o),++m.footprintSegLen,++m.polygonSegLen;}if(m.vertexCount=this.layoutVertexArray.length-m.vertexArrayOffset,m.groundVertexCount=this.groundEffect.vertexArray.length-m.groundVertexArrayOffset,0!==m.vertexCount){if(m.centroidXY=f.borders?Kd:this.encodeCentroid(f,m),this.centroidData.push(m),f.borders){this.featuresOnBorder.push(f);const e=this.featuresOnBorder.length-1;for(let t=0;tthis.featuresOnBorder[t].borders[e][0]-this.featuresOnBorder[r].borders[e][0]);}splitToSubtiles(){const e=[];for(let t=0;tUn),i=2*n+(+(r.min.x+r.max.x>Un)^n);for(let n=0;ne.triangleSegmentIdx===t.triangleSegmentIdx?e.subtile-t.subtile:e.triangleSegmentIdx-t.triangleSegmentIdx);let r=0,n=0,i=0;for(const t of e){if(t.triangleSegmentIdx!==r)break;i++;}const s=e.length;for(;n!==e.length;){r=e[n].triangleSegmentIdx;let o=0,a=n,l=n;for(let t=a;t0&&this.triangleSubSegments.push({segment:c,min:s,max:u}),a=l;for(let t=a;t[e[0]*(1-r[0])+t[0]*r[0],e[1]*(1-r[1])+t[1]*r[1]],p=[],d=[];for(const e of this.triangleSubSegments){p[0]=e.min.x/Un,p[1]=e.min.y/Un,d[0]=e.max.x/Un,d[1]=e.max.y/Un;const t=h(u,c,p),o=h(u,c,d);if(0===new vc([t[0],t[1],i],[o[0],o[1],s]).intersectsPrecise(r)){l&&(n.segments.push(l),l=void 0);continue}const a=e.segment;l&&l.vertexOffset!==a.vertexOffset&&(n.segments.push(l),l=void 0),l?(l.vertexLength+=a.vertexLength,l.primitiveLength+=a.primitiveLength):l={vertexOffset:a.vertexOffset,primitiveLength:a.primitiveLength,vertexLength:a.vertexLength,primitiveOffset:a.primitiveOffset,sortKey:void 0,vaos:{}};}return l&&n.segments.push(l),n}encodeCentroid(e,t){const r=e.centroid(),n=t.span(),i=Math.min(7,Math.round(n.x*this.tileToMeter/10)),s=Math.min(7,Math.round(n.y*this.tileToMeter/10));return new Ie(De(r.x,1,8191)<<3|i,De(r.y,1,8191)<<3|s)}encodeBorderCentroid(e){if(!e.borders)return new Ie(0,0);const t=e.borders,r=Number.MAX_VALUE;if(t[0][0]!==r||t[1][0]!==r){const e=t[0][0]!==r?0:1;return new Ie(6|(t[0][0]!==r?0:65528),(t[e][0]+t[e][1])/2<<3|6)}{const e=t[2][0]!==r?2:3;return new Ie((t[e][0]+t[e][1])/2<<3|6,6|(t[2][0]!==r?0:65528))}}showCentroid(e){const t=this.centroidData[e.centroidDataIndex];t.flags&=Qd,t.centroidXY.x=0,t.centroidXY.y=0,this.writeCentroidToBuffer(t);}writeCentroidToBuffer(e){this.groundEffect.updateHiddenByLandmark(e);const t=e.vertexArrayOffset,r=e.vertexCount+e.vertexArrayOffset,n=e.flags&Qd?Kd:e.centroidXY,i=this.centroidVertexArray.geta_centroid_pos0(t);if(this.centroidVertexArray.geta_centroid_pos1(t)!==n.y||i!==n.x){for(let e=t;ee.max.x||e.min.x>t.max.x||t.min.y>e.max.y||e.min.y>t.max.y||t.footprint.buildingIds.has(e.buildingId)&&(e.flags|=Qd);else for(const r of this.centroidData)if(!(r.flags&Qd||t.min.x>r.max.x||r.min.x>t.max.x||t.min.y>r.max.y||r.min.y>t.max.y))for(let s=0;st!=l>t&&e<(this.footprintVertices.int16[2*(a+s.vertexOffset)+0]-r)*(t-o)/(l-o)+r&&(n=!n);}o=r;}}return n}getHeightAtTileCoord(e,t){let r=Number.NEGATIVE_INFINITY,n=!0;const i=4*(e+Un)*Un+(t+Un);if(this.partLookup.hasOwnProperty(i)){const e=this.partLookup[i];return e?{height:e.height,hidden:!!(e.flags&Qd)}:void 0}for(const s of this.centroidData)e>s.max.x||s.min.x>e||t>s.max.y||s.min.y>t||s.height<=r||this.footprintContainsPoint(e,t,s)&&(r=s.height,this.partLookup[i]=s,n=!!(s.flags&Qd));if(r!==Number.NEGATIVE_INFINITY)return {height:r,hidden:n};this.partLookup[i]=void 0;}}function df(e,t){const r=e.add(t)._unit();return e.x*r.x+e.y*r.y}function ff(e,t,r,n){const i=t.sub(e)._perp()._unit(),s=r.sub(t)._perp()._unit();return mf(e,t,r,df(i,s),n)}function mf(e,t,r,n,i){const s=Math.sqrt(1-n*n);return Math.min(e.dist(t)/3,t.dist(r)/3,i*s/n)}function yf(e,t,r){return e.xr[1].x&&t.x>r[1].x||e.yr[1].y&&t.y>r[1].y}function gf(e,t){return e.xt[1].x||e.yt[1].y}function xf(e){return e.every(e=>e.x<=0)||e.every(e=>e.x>=Un)||e.every(e=>e.y<=0)||e.every(e=>e.y>=Un)}function vf(e,t,r){if(e.x<0||e.x>=Un||t.x<0||t.x>=Un||r.x<0||r.x>=Un)return !1;const n=r.sub(t),i=n.perp(),s=e.sub(t);return (n.x*s.x+n.y*s.y)/Math.sqrt((n.x*n.x+n.y*n.y)*(s.x*s.x+s.y*s.y))>-.866&&i.x*s.x+i.y*s.y<0}function bf(e,t,r){const n=t?2|e:-3&e;return r?1|n:-2&n}function wf(){const e=Math.PI/32,t=Math.tan(e),r=Iu;return r*Math.sqrt(1+2*t*t)-r}function _f(e,t,r){const n=1<{for(const r of e)o.push({polygon:r,bounds:t});},l=Math.ceil(Math.log2(r)),u=Math.ceil(Math.log2(n)),c=l-u,h=[];for(let e=0;e0?0:1);for(let e=0;et+1?d.push({polygons:p,bounds:e,depth:t+1}):a(p,e);}if(f.length){const e=[new Ie(0===r?c:n.x,1===r?c:n.y),o];h.length>t+1?d.push({polygons:f,bounds:e,depth:t+1}):a(f,e);}}return o}(e,t,Math.ceil((s-i)/11.25),Math.ceil((o-a)/11.25),1,(e,t,i)=>{if(0===e)return .5*(t+i);{const e=Fu((r.y+t/Un)/n);return (ku(.5*(Fu((r.y+i/Un)/n)+e))*n-r.y)*Un}})}function Af(e,t,r,n,i,s){const o=Math.pow(2,n.z-i.z);for(let a=0;a=o[r]&&(n=t,o=e),n[r]i&&Pf(n,o,r,i),n[r]s&&Pf(o,n,r,s);}}function Tf(e,t,r,n,i,s){const o=[];for(let a=0;a=n&&p.x>=n||(c.x>=n?c=new Ie(n,c.y+(n-c.x)/(p.x-c.x)*(p.y-c.y))._round():p.x>=n&&(p=new Ie(n,c.y+(n-c.x)/(p.x-c.x)*(p.y-c.y))._round()),c.y>=i&&p.y>=i||(c.y>=i?c=new Ie(c.x+(i-c.y)/(p.y-c.y)*(p.x-c.x),i)._round():p.y>=i&&(p=new Ie(c.x+(i-c.y)/(p.y-c.y)*(p.x-c.x),i)._round()),u&&c.equals(u[u.length-1])||(u=[c],o.push(u),s&&s.push({progress:{min:f+Vf(m,y,c)*d,max:1},parentIndex:a,prevPoint:m,nextPoint:y})),u.push(p),s&&(s[s.length-1].progress.max=f+Vf(m,y,p)*d,s[s.length-1].nextPoint=y)))));}if(s&&h>0)for(let e=c;ee.t-t.t);let o=0,a=0,l=[];for(n.push(l);o!==e.length;){if(a===s.length){for(;o!==e.length;)0!==l.length&&l[l.length-1].equals(e[o])||l.push(e[o]),o++;break}s[a].t<=o?(0!==l.length&&l[l.length-1].equals(s[a].point)||l.push(s[a].point),Math.trunc(s[a].t),a++):(0!==l.length&&l[l.length-1].equals(e[o])||l.push(e[o]),o++);}}function Vf(e,t,r){return e.x!==t.x?(r.x-e.x)/(t.x-e.x):e.y!==t.y?(r.y-e.y)/(t.y-e.y):0}function Ef(e,t){return e.x*t.x+e.y*t.y}function Ff(e,t){if(1===e.length){let r=0;const n=t[r++];let i;for(;!i||n.equals(i);)if(i=t[r++],!i)return 1/0;for(;r{e[0]=t,e[1]=r,e[2]=n,e[3]=1;},g=wf();r>0&&(r+=g),n+=g;for(const g of t){const t=[],x=[];for(const h of g){const p=h.x+i.x,g=h.y+i.y,v=e.projection.projectTilePoint(p,g,c),b=e.projection.upVector(c,h.x,h.y);let w=r,_=n;if(o){const e=Rf(p,g,r,n,o,a,l,u);w+=e.base,_+=e.top;}0!==r?y(f,v.x+b[0]*d*w,v.y+b[1]*d*w,v.z+b[2]*d*w):y(f,v.x,v.y,v.z),y(m,v.x+b[0]*d*_,v.y+b[1]*d*_,v.z+b[2]*d*_),j(f,f,s),j(m,m,s),t.push(new Sf(f[0],f[1],f[2])),x.push(new Sf(m[0],m[1],m[2]));}h.push(t),p.push(x);}return [h,p]}(e,t,r,n,i,s,o,a,l,u,c):o?function(e,t,r,n,i,s,o,a,l){const u=[],c=[],h=[0,0,0,1];for(const p of e){const e=[],d=[];for(const u of p){const c=u.x+n.x,p=u.y+n.y,f=Rf(c,p,t,r,s,o,a,l);h[0]=c,h[1]=p,h[2]=f.base,h[3]=1,ee(h,h,i),h[3]=Math.max(h[3],1e-5);const m=new Sf(h[0]/h[3],h[1]/h[3],h[2]/h[3]);h[0]=c,h[1]=p,h[2]=f.top,h[3]=1,ee(h,h,i),h[3]=Math.max(h[3],1e-5);const y=new Sf(h[0]/h[3],h[1]/h[3],h[2]/h[3]);e.push(m),d.push(y);}u.push(e),c.push(d);}return [u,c]}(t,r,n,i,s,o,a,l,u):function(e,t,r,n,i){const s=[],o=[],a=i[8]*t,l=i[9]*t,u=i[10]*t,c=i[11]*t,h=i[8]*r,p=i[9]*r,d=i[10]*r,f=i[11]*r;for(const t of e){const e=[],r=[];for(const s of t){const t=s.x+n.x,o=s.y+n.y,m=i[0]*t+i[4]*o+i[12],y=i[1]*t+i[5]*o+i[13],g=i[2]*t+i[6]*o+i[14],x=i[3]*t+i[7]*o+i[15],v=m+a,b=y+l,w=g+u,_=Math.max(x+c,1e-5),A=m+h,M=y+p,I=g+d,S=Math.max(x+f,1e-5);e.push(new Sf(v/_,b/_,w/_)),r.push(new Sf(A/S,M/S,I/S));}s.push(e),o.push(r);}return [s,o]}(t,r,n,i,s)}function Rf(e,t,r,n,i,s,o,a){const l=o*i.getElevationAt(e,t,!0,!0),u=0!==s[0],c=u?0===s[1]?o*(s[0]/7-450):o*function(e,t,r){const n=Math.floor(t[0]/8),i=Math.floor(t[1]/8),s=10*(t[0]-8*n),o=10*(t[1]-8*i),a=e.getElevationAt(n,i,!0,!0),l=e.getMeterToDEM(r),u=Math.floor(.5*(s*l-1)),c=Math.floor(.5*(o*l-1)),h=e.tileCoordToPixel(n,i),p=2*u+1,d=2*c+1,f=function(e,t,r,n,i){return [e.getElevationAtPixel(t,r,!0),e.getElevationAtPixel(t+i,r,!0),e.getElevationAtPixel(t,r+i,!0),e.getElevationAtPixel(t+n,r+i,!0)]}(e,h.x-u,h.y-c,p,d),m=Math.abs(f[0]-f[1]),y=Math.abs(f[2]-f[3]),g=Math.abs(f[0]-f[2])+Math.abs(f[1]-f[3]),x=Math.min(.25,.5*l*(m+y)/p),v=Math.min(.25,.5*l*g/d);return a+Math.max(x*s,v*o)}(i,s,a):l;return {base:l+(0===r?-1:r),top:u?Math.max(c+n,l+r+2):l+n}}class Lf{constructor(e){this._callback=e,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback();});}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._callback();},0));}remove(){this._channel=void 0,this._callback=()=>{};}}class Of{constructor(){this.tasks={},this.taskQueue=[],je(["process"],this),this.invoker=new Lf(this.process),this.nextId=0;}add(e,t){const r=this.nextId++,n=function({type:e,isSymbolTile:t,zoom:r}){return r=r||0,"message"===e?0:"maybePrepare"!==e||t?"parseTile"!==e||t?"parseTile"===e&&t?300-r:"maybePrepare"===e&&t?400-r:500:200-r:100-r}(t);if(0===n){try{e();}finally{}return null}return this.tasks[r]={fn:e,metadata:t,priority:n,id:r},this.taskQueue.push(r),this.invoker.trigger(),{cancel:()=>{delete this.tasks[r];}}}process(){try{if(this.taskQueue=this.taskQueue.filter(e=>!!this.tasks[e]),!this.taskQueue.length)return;const e=this.pick();if(null===e)return;const t=this.tasks[e];if(delete this.tasks[e],this.taskQueue.length&&this.invoker.trigger(),!t)return;t.fn();}finally{}}pick(){let e=null,t=1/0;for(let r=0;r{r&&delete this.callbacks[o],this.target.postMessage({id:o,type:"",targetMapId:n,sourceMapId:this.mapId});}}}receive(e){const t=e.data;if(!t)return;const r=t.id;if(r&&(!t.targetMapId||this.mapId===t.targetMapId))if(""===t.type){const e=this.cancelCallbacks[r];delete this.cancelCallbacks[r],e&&e.cancel();}else if(t.mustQueue||Ke(self)){const e=this.callbacks[r],n=this.scheduler.add(()=>this.processTask(r,t),e&&e.metadata||{type:"message"});n&&(this.cancelCallbacks[r]=n);}else this.processTask(r,t);}processTask(e,t){if(delete this.cancelCallbacks[e],""===t.type){const r=this.callbacks[e];delete this.callbacks[e],r&&(t.error?r(eo(t.error)):r(null,eo(t.data)));}else {const r=new Set,n=t.hasCallback?(t,n)=>{this.target.postMessage({id:e,type:"",sourceMapId:this.mapId,error:t?Qs(t):null,data:Qs(n,r)},r);}:()=>{},i=eo(t.data);if(this.parent[t.type])this.parent[t.type](t.sourceMapId,i,n);else if(this.parent.getWorkerSource){const e=t.type.split("."),{source:r,scope:s}=i;this.parent.getWorkerSource(t.sourceMapId,e[0],r,s)[e[1]](i,n);}else n(new Error(`Could not find function ${t.type}`));}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1);}}var Nf={workerUrl:"",workerClass:null,workerParams:void 0};function jf(e){return null!=Nf.workerClass?new Nf.workerClass:new self.Worker(Nf.workerUrl,Object.assign({name:e},Nf.workerParams))}const Gf="mapboxgl_preloaded_worker_pool";class $f{constructor(e){this.active={},this.name=e;}acquire(e,t=$f.workerCount){if(!this.workers)for(this.workers=[];this.workers.length{e.terminate();}),this.workers=null);}isPreloaded(){return !!this.active[Gf]}numActive(){return Object.keys(this.active).length}}$f.workerCount=2;class qf{constructor(e,t,r="Worker",n=$f.workerCount){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=Ue();const i=this.workerPool.acquire(this.id,n);for(let e=0;e{this.ready=!0;});}broadcast(e,t,r){Le(this.actors,(r,n)=>{r.send(e,t,n);},r=r||function(){});}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(e=>{e.remove();}),this.actors=[],this.workerPool.release(this.id);}}let Xf,Hf;function Zf(){return Xf||(Xf=new $f),Xf}qf.Actor=Uf;const Wf=4096;class Yf{constructor(e){this.module=e,this.memoryStack=this.module.malloc(Wf),this.memoryStackNextFree=this.memoryStack;}createIntArray(e){const t=this.memoryStackNextFree;return this.memoryStackNextFree+=e.length*Int32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>Wf?-1:(new Int32Array(this.module.heap32.buffer,t,e.length).set(e),t)}createFloatArray(e){const t=this.memoryStackNextFree;return this.memoryStackNextFree+=e.length*Float32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>Wf?-1:(new Float32Array(this.module.heapF32.buffer,t,e.length).set(e),t)}readStringBuffer(e){let t="";for(;0!==this.module.heapU8[e];)t+=String.fromCharCode(this.module.heapU8[e]),++e;return t}setStyle(e){const t=e.normalScale;this.module.setStyle(t[0],t[1],t[2],e.tileToMeters);}setAOOptions(e,t){this.module.setAOOptions(e?1:0,t);}setMetricOptions(e,t){this.module.setMetricOptions(e?1:0,t);}setStructuralOptions(e){this.module.setStructuralOptions(e?1:0);}setFacadeOptions(e,t){this.module.setFacadeOptions(e,t?1:0);}setFauxFacadeOptions(e,t,r){this.module.setFauxFacadeOptions(e?1:0,t?1:0,r);}setFacadeClassifierOptions(e){this.module.setFacadeClassifierOptions(e);}generateMesh(e,t){this.memoryStackNextFree=this.memoryStack;for(const t of e){const e=this.createIntArray(t.ringIndices),r=this.createFloatArray(t.coordinates);if(-1===e||-1===r)return `building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFeature(t.id,t.sourceId,t.minHeight,t.height,t.roofType,r,e,t.ringIndices.length-1);}for(const e of t){let t;t=e.entrances?JSON.parse(e.entrances):[];const r=this.createFloatArray(t),n=this.createFloatArray(e.coordinates);if(-1===r||-1===n)return `building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFacade(e.sourceId,e.crossPerc,e.distanceToRoad,r,t.length,n,e.coordinates.length);}if(!this.module.generateMesh()){const e=this.module.getLastError();return this.readStringBuffer(e)}const r=this.module.getMeshCount(),n=new Array(r);for(let e=0;e>2)-3,o=r[n++]>>2;if(n++,i.json=JSON.parse(Mm.decode(r.subarray(n,n+o))),n+=o,n>>0,Math.ceil(1.2*i)),o=Math.ceil((s-i)/65536);try{return r.grow(o),n(),!0}catch(e){return !1}},b:i}};return (WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(e,s):e.then(e=>e.arrayBuffer()).then(e=>WebAssembly.instantiate(e,s))).then(e=>{const{Rb:i,Qb:s,P:o,T:a,X:l,Ja:u,La:c,Qa:h,Va:p,Wa:d,eb:f,jb:m,f:y,e:g,yb:x,zb:v,Ab:b,Bb:w,Db:_,Gb:A}=e.instance.exports;r=g;const M=(()=>{let e=0,r=0,n=0,o=0;return a=>{n&&(i(o),i(e),r+=n,n=e=0),e||(r+=128,e=s(r));const l=a.length+7&-8;let u=e;l>=r&&(n=l,u=o=s(l));for(let e=0;e{Qf=e,Jf=void 0;}))}()),p&&c.push(function(){if(tm)return;const e=function(e){let t;const r=WebAssembly.instantiateStreaming(e,{}).then(e=>{t=e.instance,t.exports.__wasm_call_ctors();}),n={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},i={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return {ready:r,supported:!0,decodeGltfBuffer(e,r,s,o,a,l){!function(e,t,r,n,i,s,o){const a=e.exports.sbrk,l=n+3&-4,u=a(l*i),c=a(s.length),h=new Uint8Array(e.exports.memory.buffer);h.set(s,c);const p=t(u,n,i,c,s.length);if(0===p&&o&&o(u,l,i),r.set(h.subarray(u,u+n*i)),a(u-a(0)),0!==p)throw new Error(`Malformed buffer data: ${p}`)}(t,t.exports[i[a]],e,r,s,o,t.exports[n[l]]);}}}(fetch(am()));return e.ready.then(()=>{tm=e;})}()),o)for(let e=0;e{const i=Lt(e,(e,t)=>{e?n(e):r(t);});t&&t.addEventListener("abort",()=>{i.cancel(),n(new DOMException("Aborted","AbortError"));},{once:!0});})}({url:e,type:"arrayBuffer"},t);return Bm(r,0,e,t)}function km(e){switch(e){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.RGBA;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.DEPTH_COMPONENT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.DEPTH_STENCIL;case WebGL2RenderingContext.R8:case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.RED}}function Vm(e){switch(e){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.UNSIGNED_SHORT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.UNSIGNED_INT_24_8;case WebGL2RenderingContext.R8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.FLOAT}}class Em{constructor(e,t,r,n){this.context=e,this.format=r,this.useMipmap=n&&n.useMipmap,this.texture=e.gl.createTexture(),this.update(t,{premultiply:n&&n.premultiply});}update(e,t){const r=e&&e instanceof HTMLVideoElement&&0===e.width?e.videoWidth:e.width,n=e&&e instanceof HTMLVideoElement&&0===e.height?e.videoHeight:e.height,{context:i}=this,{gl:s}=i,{x:o,y:a}=t&&t.position?t.position:{x:0,y:0},l=o+r,u=a+n;!this.size||this.size[0]===l&&this.size[1]===u||(s.bindTexture(s.TEXTURE_2D,null),s.deleteTexture(this.texture),this.texture=s.createTexture(),this.size=null),s.bindTexture(s.TEXTURE_2D,this.texture),i.pixelStoreUnpackFlipY.set(!1),i.pixelStoreUnpack.set(1),i.pixelStoreUnpackPremultiplyAlpha.set(this.format===s.RGBA8&&(!t||!1!==t.premultiply));const c=e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||ImageBitmap&&e instanceof ImageBitmap;if(!this.size&&l>0&&u>0){const e=this.useMipmap?Math.floor(Math.log2(Math.max(l,u)))+1:1;s.texStorage2D(s.TEXTURE_2D,e,this.format,l,u),this.size=[l,u];}this.size&&(c?s.texSubImage2D(s.TEXTURE_2D,0,o,a,km(this.format),Vm(this.format),e):"data"in e&&e.data&&s.texSubImage2D(s.TEXTURE_2D,0,o,a,r,n,km(this.format),Vm(this.format),e.data)),this.useMipmap&&s.generateMipmap(s.TEXTURE_2D);}bind(e,t,r=!1){const{context:n}=this,{gl:i}=n;i.bindTexture(i.TEXTURE_2D,this.texture),e!==this.minFilter&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,e),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,this.useMipmap&&!r?e===i.NEAREST?i.NEAREST_MIPMAP_NEAREST:i.LINEAR_MIPMAP_LINEAR:e),this.minFilter=e),t!==this.wrapS&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,t),this.wrapS=t);}bindExtraParam(e,t,r,n,i){const{context:s}=this,{gl:o}=s;o.bindTexture(o.TEXTURE_2D,this.texture),t!==this.magFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,t),this.magFilter=t),e!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?e===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_LINEAR:e),this.minFilter=e),r!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,r),this.wrapS=r),n!==this.wrapT&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,n),this.wrapT=n),i!==this.compareMode&&(i?(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_COMPARE_MODE,o.COMPARE_REF_TO_TEXTURE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_COMPARE_FUNC,i)):o.texParameteri(o.TEXTURE_2D,o.TEXTURE_COMPARE_MODE,o.NONE),this.compareMode=i);}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null;}}class Fm{constructor(e,t){this.context=e,this.texture=t;}bind(e,t){const{context:r}=this,{gl:n}=r;n.bindTexture(n.TEXTURE_2D,this.texture),e!==this.minFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,e),this.minFilter=e),t!==this.wrapS&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,t),this.wrapS=t);}}const Dm=Ra([{name:"a_pos_3f",components:3,type:"Float32"}]),Cm=Ra([{name:"a_color_3f",components:3,type:"Float32"}]),Rm=Ra([{name:"a_color_4f",components:4,type:"Float32"}]),Lm=Ra([{name:"a_uv_2f",components:2,type:"Float32"}]),Om=Ra([{name:"a_normal_3f",components:3,type:"Float32"}]),Um=Ra([{name:"a_normal_matrix0",components:4,type:"Float32"},{name:"a_normal_matrix1",components:4,type:"Float32"},{name:"a_normal_matrix2",components:4,type:"Float32"},{name:"a_normal_matrix3",components:4,type:"Float32"}]),Nm=Ra([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);function jm(e,t){const r=$m(e.projection,e.zoom,e.width,e.height),n=function(e,t,r,n,i){const s=new zu(r.lng-180*qm,r.lat),o=new zu(r.lng+180*qm,r.lat),a=e.project(s.lng,s.lat),l=e.project(o.lng,o.lat),c=-Math.atan2(l.y-a.y,l.x-a.x),p=Nu.fromLngLat(r);p.y=De(p.y,-1+qm,1-qm);const f=p.toLngLat(),m=e.project(f.lng,f.lat),g=Nu.fromLngLat(f);g.x+=qm;const x=g.toLngLat(),v=e.project(x.lng,x.lat),b=Hm(v.x-m.x,v.y-m.y,c),w=Nu.fromLngLat(f);w.y+=qm;const _=w.toLngLat(),A=e.project(_.lng,_.lat),M=Hm(A.x-m.x,A.y-m.y,c),I=Math.abs(b.x)/Math.abs(M.y),S=u([]);y(S,S,-c*(1-(i?0:n)));const z=u([]);return d(z,z,[1,1-(1-I)*n,1]),z[4]=-M.x/M.y*n,y(z,z,c),h(z,S,z),z}(e.projection,0,e.center,r,t),i=Gm(e);return d(n,n,[i,i,1]),n}function Gm(e){const t=e.projection,r=$m(e.projection,e.zoom,e.width,e.height),n=Xm(t,e.center),i=Xm(t,zu.convert(t.center));return Math.pow(2,n*r+(1-r)*i)}function $m(e,t,r,n,i=1/0){const s=e.range;if(!s)return 0;const o=Math.min(i,Math.max(r,n)),a=Math.log2(o/1024);return Ce(s[0]+a,s[1]+a,t)}const qm=1/4e4;function Xm(e,t){const r=De(t.lat,-85.051129,Cu),n=new zu(t.lng-180*qm,r),i=new zu(t.lng+180*qm,r),s=e.project(n.lng,r),o=e.project(i.lng,r),a=Nu.fromLngLat(n),l=Nu.fromLngLat(i),u=o.x-s.x,c=o.y-s.y,h=l.x-a.x,p=l.y-a.y,d=Math.sqrt((h*h+p*p)/(u*u+c*c));return Math.log2(d)}function Hm(e,t,r){const n=Math.cos(r),i=Math.sin(r);return {x:e*n-t*i,y:e*i+t*n}}function Zm(e,t,r){u(e),y(e,e,Be(t[2])),f(e,e,Be(t[0])),m(e,e,Be(t[1])),d(e,e,r),h(e,e,[1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1]);}function Wm(e,t,r,n,i,s,o,a){const l=[r[0]-t[0],r[1]-t[1],0],u=[n[0]-t[0],n[1]-t[1],0];if(M(l)<1e-12||M(u)<1e-12)return re(e);const c=U([],l,u);L(c,c),P(u,n,t),l[2]=(s-i)*a,u[2]=(o-i)*a;const h=l;return U(h,l,u),L(h,h),ue(e,c,h)}function Ym(e,t,r=!1){const n=wh(t.zoom),i=function(e,t,r){const n=t.worldSize,i=[e[12],e[13],e[14]],s=Fu(i[1]/n),o=Eu(i[0]/n),a=u([]),l=Vu(1,s)*n,c=Vu(1,0)*n*Lu(s,t.zoom),f=1/xh(n);let m=c*f;if(r){const e=$m(t.projection,t.zoom,t.width,t.height,1024);m=f*t.projection.pixelSpaceConversion(t.center.lat,n,e);}const y=Mu(s,o);z(y,y,V([],L([],y),l*m*i[2]));const g=function(e){const t=[e[0],e[1],e[2]];let r=[0,1,0];const n=U([],r,t);return U(r,t,n),0===C(r)&&(r=[0,1,0],U(n,t,r)),L(n,n),L(r,r),L(t,t),[n[0],n[1],n[2],0,r[0],r[1],r[2],0,t[0],t[1],t[2],0,e[0],e[1],e[2],1]}(y);d(a,a,[m,m,m*l]),p(a,a,[-i[0],-i[1],-i[2]]);const x=h([],t.globeMatrix,g);return h(x,x,a),h(x,x,e),x}(e,t,r);if(n>0){const r=function(e,t){const r=t.worldSize,n=Vu(1,0)*r*Lu(t.center.lat,t.zoom)/xh(r),i=Vu(1,t.center.lat)*r,s=u([]);m(s,s,Be(t.center.lng)),f(s,s,Be(t.center.lat)),p(s,s,[0,0,xu]),d(s,s,[n,n,n*i]);const o=t.point;return p(s,s,[-o.x,-o.y,0]),h(s,s,e),h(s,t.globeMatrix,s)}(e,t);return function(e,t,r){const n=(e,t,r)=>{const n=M(e),i=M(t),s=lh(e,t,r);return V(s,s,1/M(s)*hr(n,i,r))},i=n([e[0],e[1],e[2]],[t[0],t[1],t[2]],r),s=n([e[4],e[5],e[6]],[t[4],t[5],t[6]],r),o=n([e[8],e[9],e[10]],[t[8],t[9],t[10]],r),a=lh([e[12],e[13],e[14]],[t[12],t[13],t[14]],r);return [i[0],i[1],i[2],0,s[0],s[1],s[2],0,o[0],o[1],o[2],0,a[0],a[1],a[2],1]}(i,r,n)}return i}function Jm(e,t,r,n){const i=vc.projectAabbCorners(n,r);let s=Number.MAX_VALUE;for(let e=0;e0||0===o&&r[0]*s[0]+r[1]*s[1]>=0&&r[0]*r[0]+r[1]*r[1]>s[0]*s[0]+s[1]*s[1])&&(n=t);}i=n;}while(i!==r);return t.length>0&&t.push(t[0]),t}(i);if(Ic(e,o))return s}const Km=64,Qm={CoordinateSpaceTile:1,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function ey(e,t,r,n,i,s,o,a,l,c=!1){const f=r.zoom,m=r.project(n),y=Lu(n.lat,f),g=1/y;u(e),p(e,e,[m.x+o[0]*g,m.y+o[1]*g,o[2]]);let x=1,v=1;const w=r.worldSize;if(c){if("mercator"===r.projection.name){let e=0;r.elevation&&(e=r.elevation.getAtPointOrZero(new Nu(m.x/w,m.y/w),0));const t=ee([],[m.x,m.y,e,1],r.projMatrix)[3]/r.cameraToCenterDistance;x=t,v=t*Lu(r.center.lat,f);}else if("globe"===r.projection.name){const t=Ym(e,r),i=[0,0,0,1];ee(i,i,h([],r.projMatrix,t));const s=i[3]/r.cameraToCenterDistance,o=wh(f),a=r.projection.pixelsPerMeter(n.lat,w)*Lu(n.lat,f),l=r.projection.pixelsPerMeter(r.center.lat,w)*Lu(r.center.lat,f);x=s/hr(a,Ru(r.center.lat),o),v=s*y/a,x*=l,v*=l;}}else x=g;d(e,e,[x,x,v]);const _=[...e],A=t.orientation,M=[];if(Zm(M,[A[0]+(i?i[0]:0),A[1]+(i?i[1]:0),A[2]+(i?i[2]:0)],s),h(e,_,M),a&&r.elevation){let i=0;const s=[];if(l&&r.elevation){i=function(e,t,r,n,i){const s=t.elevation;if(!s)return 0;const o=vc.projectAabbCorners(r,n),a=Vu(1,i.lat)*t.worldSize,l=function(e,t){const r=[0,0,1],n=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(const i of n){const n=e[i.corners[0]],s=e[i.corners[1]],o=e[i.corners[2]],a=[s[0]-n[0],s[1]-n[1],t*(s[2]-n[2])],l=U(a,a,[o[0]-n[0],o[1]-n[1],t*(o[2]-n[2])]);L(l,l),i.dotProductWithUp=O(l,r);}return n.sort((e,t)=>e.dotProductWithUp-t.dotProductWithUp),n[0].corners}(o,a),u=o[l[0]],c=o[l[1]],h=o[l[2]],p=o[l[3]],d=s.getAtPointOrZero(new Nu(u[0]/t.worldSize,u[1]/t.worldSize),0),f=s.getAtPointOrZero(new Nu(c[0]/t.worldSize,c[1]/t.worldSize),0),m=s.getAtPointOrZero(new Nu(h[0]/t.worldSize,h[1]/t.worldSize),0),y=s.getAtPointOrZero(new Nu(p[0]/t.worldSize,p[1]/t.worldSize),0),g=(d+y)/2,x=(f+m)/2;return g>x?f=t.gl.NEAREST_MIPMAP_NEAREST}),e.uploaded=!0,e.image=null);}function ny(e,t,r){e.indexBuffer=t.createIndexBuffer(e.indexArray,!1,!0),e.vertexBuffer=t.createVertexBuffer(e.vertexArray,Dm.members,!1,!0),e.normalArray&&(e.normalBuffer=t.createVertexBuffer(e.normalArray,Om.members,!1,!0)),e.texcoordArray&&(e.texcoordBuffer=t.createVertexBuffer(e.texcoordArray,Lm.members,!1,!0)),e.colorArray&&(e.colorBuffer=t.createVertexBuffer(e.colorArray,(12===e.colorArray.bytesPerElement?Cm:Rm).members,!1,!0)),e.featureArray&&(e.pbrBuffer=t.createVertexBuffer(e.featureArray,Nm.members,!0)),e.segments=Rl.simpleSegment(0,0,e.vertexArray.length,e.indexArray.length);const n=e.material;n.pbrMetallicRoughness.baseColorTexture&&ry(n.pbrMetallicRoughness.baseColorTexture,t),n.pbrMetallicRoughness.metallicRoughnessTexture&&ry(n.pbrMetallicRoughness.metallicRoughnessTexture,t),n.normalTexture&&ry(n.normalTexture,t),n.occlusionTexture&&ry(n.occlusionTexture,t,r),n.emissionTexture&&ry(n.emissionTexture,t);}function iy(e,t,r){if(e.meshes)for(const n of e.meshes)ny(n,t,r);if(e.children)for(const n of e.children)iy(n,t,r);}function sy(e){if(e.meshes)for(const t of e.meshes)t.indexArray.destroy(),t.vertexArray.destroy(),t.colorArray&&t.colorArray.destroy(),t.normalArray&&t.normalArray.destroy(),t.texcoordArray&&t.texcoordArray.destroy(),t.featureArray&&t.featureArray.destroy();if(e.children)for(const t of e.children)sy(t);}function oy(e){e.pbrMetallicRoughness.baseColorTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),e.pbrMetallicRoughness.metallicRoughnessTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),e.normalTexture&&e.normalTexture.gfxTexture&&e.normalTexture.gfxTexture.destroy(),e.emissionTexture&&e.emissionTexture.gfxTexture&&e.emissionTexture.gfxTexture.destroy(),e.occlusionTexture&&e.occlusionTexture.gfxTexture&&e.occlusionTexture.gfxTexture.destroy();}function ay(e){if(e.meshes)for(const t of e.meshes)t.vertexBuffer&&(t.vertexBuffer.destroy(),t.indexBuffer.destroy(),t.normalBuffer&&t.normalBuffer.destroy(),t.texcoordBuffer&&t.texcoordBuffer.destroy(),t.colorBuffer&&t.colorBuffer.destroy(),t.pbrBuffer&&t.pbrBuffer.destroy(),t.segments.destroy(),t.material&&oy(t.material));if(e.footprintDebugMesh&&(e.footprintDebugMesh.vertexBuffer.destroy(),e.footprintDebugMesh.indexBuffer.destroy(),e.footprintDebugMesh.segments.destroy()),e.children)for(const t of e.children)ay(t);}function ly(e,t){const r=e.json.bufferViews[t.bufferView],n=mm[t.componentType];return new n(e.buffers[r.buffer],(t.byteOffset||0)+(r.byteOffset||0),t.count*(r.byteStride&&r.byteStride!==gm[t.type]*n.BYTES_PER_ELEMENT?r.byteStride/n.BYTES_PER_ELEMENT:gm[t.type]))}function uy(e,t,r,n){const i=mm[t.componentType],s=function(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(i),o=e.json.bufferViews[t.bufferView],a=o.byteStride?o.byteStride/i.BYTES_PER_ELEMENT:gm[t.type],l=r.float32,u=l.length/r.capacity;for(let e=0,r=0;e0){for(let i=0;i0){s.texcoordArray=new fl;const e=t.json.accessors[i.TEXCOORD_0];s.texcoordArray.resize(e.count);const r=ly(t,e);uy(t,e,s.texcoordArray,r);}if(void 0!==i._FEATURE_ID_RGBA4444){const e=t.json.accessors[i._FEATURE_ID_RGBA4444];t.json.extensionsUsed&&t.json.extensionsUsed.includes("EXT_meshopt_compression")&&(s.featureData=ly(t,e));}void 0!==i._FEATURE_RGBA4444&&(s.featureData=new Uint32Array(ly(t,t.json.accessors[i._FEATURE_RGBA4444]).buffer));const h=e.material;return s.material=function(e,t){const{emissiveFactor:r=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:i=.5,normalTexture:s,occlusionTexture:o,emissiveTexture:a,doubleSided:l,name:u}=e,{baseColorFactor:c=[1,1,1,1],metallicFactor:h=1,roughnessFactor:p=1,baseColorTexture:d,metallicRoughnessTexture:f}=e.pbrMetallicRoughness||{},m=o?t[o.index]:void 0;if(o&&o.extensions&&o.extensions.KHR_texture_transform&&m){const e=o.extensions.KHR_texture_transform;m.offsetScale=[e.offset[0],e.offset[1],e.scale[0],e.scale[1]];}return {name:u,pbrMetallicRoughness:{baseColorFactor:new ar(...c),metallicFactor:h,roughnessFactor:p,baseColorTexture:d?t[d.index]:void 0,metallicRoughnessTexture:f?t[f.index]:void 0},doubleSided:l,emissiveFactor:new ar(...r),alphaMode:n,alphaCutoff:i,normalTexture:s?t[s.index]:void 0,occlusionTexture:m,emissionTexture:a?t[a.index]:void 0,defined:void 0===e.defined}}(void 0!==h?t.json.materials[h]:{defined:!1},r),s}function hy(e,t,r){const{matrix:n,rotation:i,translation:s,scale:o,mesh:a,extras:u,children:c,name:h}=e,p={};if(p.name=h,p.localMatrix=n||function(e,t,r,n){var i=t[0],s=t[1],o=t[2],a=t[3],l=i+i,u=s+s,c=o+o,h=i*l,p=i*u,d=i*c,f=s*u,m=s*c,y=o*c,g=a*l,x=a*u,v=a*c,b=n[0],w=n[1],_=n[2];return e[0]=(1-(f+y))*b,e[1]=(p+v)*b,e[2]=(d-x)*b,e[3]=0,e[4]=(p-v)*w,e[5]=(1-(h+y))*w,e[6]=(m+g)*w,e[7]=0,e[8]=(d+x)*_,e[9]=(m-g)*_,e[10]=(1-(h+f))*_,e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e}([],i||[0,0,0,1],s||[0,0,0],o||[1,1,1]),p.globalMatrix=l(p.localMatrix),void 0!==a){p.meshes=r[a];const e=p.anchor=[0,0];for(const t of p.meshes){const{min:r,max:n}=t.aabb;e[0]+=r[0]+n[0],e[1]+=r[1]+n[1];}e[0]=Math.floor(e[0]/p.meshes.length/2),e[1]=Math.floor(e[1]/p.meshes.length/2);}if(u&&(u.id&&(p.id=u.id),u.lights&&(p.lights=function(e){if(!e.length)return [];const t=function(e){const t=atob(e),r=new Uint8Array(t.length);for(let e=0;e1&&n[n.length-1].equals(n[0])&&n.pop();let i=0;for(let e=0;e0&&n.reverse();const s=Yh(n.flatMap(e=>[e.x,e.y]),[]);return 0===s.length?null:{vertices:n,indices:s}}function fy(e,t){const r=[],n=[];let i=0;const s=[];for(const o of e){i=r.length;const e=o.vertexArray.float32,a=o.indexArray.uint16;for(let n=0;n0&&([n[e+1],n[e+2]]=[n[e+2],n[e+1]]);}return {vertices:r,indices:n}}function my(e){const t=function(e,t){const r=[],n=WebGL2RenderingContext;if(e.json.textures)for(const i of e.json.textures){const s={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==i.sampler&&Object.assign(s,e.json.samplers[i.sampler]),r.push({image:t[i.source],sampler:s,uploaded:!1});}return r}(e,e.images),r=function(e,t){const r=[];for(const n of e.json.meshes){const i=[];for(const r of n.primitives)i.push(cy(r,e,t));r.push(i);}return r}(e,t),{scenes:n,scene:i,nodes:s}=e.json,o=n?n[i||0].nodes:[...s.keys()],a=[];for(const t of o)a.push(hy(s[t],e,r));return function(e,t,r){const n={},i=new Set;for(let s=0;s0){const t=Array.from(i.values()).sort((e,t)=>e-t);for(let r=t.length-1;r>=0;r--)e.splice(t[r],1);}}(a,o,e.json.nodes),a}function yy(e){e.heightmap=new Float32Array(4096),e.heightmap.fill(-1);const t=e.vertexArray.float32,r=e.aabb.min[0]-1,n=e.aabb.min[1]-1,i=Km/(e.aabb.max[0]-r+2),s=Km/(e.aabb.max[1]-n+2);for(let o=0;oe.heightmap[u*Km+l]&&(e.heightmap[u*Km+l]=a);}}function gy(e,t,r,n,i){r.reserve(r.length+4*e.length),n.reserve(n.length+10*e.length),i.reserve(i.length+10*e.length);let s=n.length;for(const o of e){const e=Math.min(10,Math.max(4,1.3*o.height))*t,a=[-o.normal[1],o.normal[0],0],l=Math.min(.29,.1*o.width/o.depth),u=o.width-2*o.depth*t*(l+.01),c=E([],o.pos,a,u/2),h=E([],o.pos,a,-u/2),p=[c[0],c[1],c[2]+o.height],d=[h[0],h[1],h[2]+o.height],f=E([],o.normal,a,l);V(f,f,e);const m=E([],o.normal,a,-l);V(m,m,e),z(f,c,f),z(m,h,m),c[2]+=.1,h[2]+=.1,n.emplaceBack(f[0],f[1],f[2]),n.emplaceBack(m[0],m[1],m[2]),n.emplaceBack(c[0],c[1],c[2]),n.emplaceBack(h[0],h[1],h[2]),n.emplaceBack(p[0],p[1],p[2]),n.emplaceBack(d[0],d[1],d[2]),n.emplaceBack(c[0],c[1],c[2]),n.emplaceBack(h[0],h[1],h[2]),n.emplaceBack(f[0],f[1],f[2]),n.emplaceBack(m[0],m[1],m[2]);const y=u/e/2;i.emplaceBack(-y-l,-1,y,.8),i.emplaceBack(y+l,-1,y,.8),i.emplaceBack(-y,0,y,1.3),i.emplaceBack(y,0,y,1.3),i.emplaceBack(y+l,-.8,y,.7),i.emplaceBack(y+l,-.8,y,.7),i.emplaceBack(0,0,y,1.3),i.emplaceBack(0,0,y,1.3),i.emplaceBack(y+l,-1.2,y,.8),i.emplaceBack(y+l,-1.2,y,.8),r.emplaceBack(6+s,4+s,8+s),r.emplaceBack(7+s,9+s,5+s),r.emplaceBack(0+s,1+s,2+s),r.emplaceBack(1+s,3+s,2+s),s+=10;}}function xy(e,t){const r={};r.indexArray=new ol,r.vertexArray=new Ha,r.colorArray=new Qa,gy(e,t,r.indexArray,r.vertexArray,r.colorArray);const n={defined:!0};n.emissiveFactor=ar.black;const i={};return i.baseColorFactor=ar.white,n.pbrMetallicRoughness=i,r.material=n,r.aabb=new vc([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),r}const vy=Ra([{name:"a_pos_3f",components:3,type:"Float32"}]),by=Ra([{name:"a_normal_3",components:3,type:"Int16"}]),wy=Ra([{name:"a_centroid_3",components:3,type:"Int16"}]),_y=Ra([{name:"a_part_color_emissive",components:2,type:"Uint16"}]),Ay=Ra([{name:"a_faux_facade_color_emissive",components:2,type:"Uint16"}]),My=Ra([{name:"a_faux_facade_data",components:4,type:"Uint16"}]),Iy=Ra([{name:"a_faux_facade_vertical_range",components:2,type:"Uint16"}]),Sy=Ra([{name:"a_bloom_attenuation",components:4,type:"Float32"}]),zy=Ra([{name:"a_flood_light_wall_radius_1i16",components:1,type:"Uint16"}]),Py=Ju.types,By=32767;function Ty(e,t){const r=Un+t;for(const n of e)for(const e of n)if(e.x<-t||e.x>r||e.y<-t||e.y>r)return !1;return !0}function ky(e){switch(e){case "flat":return 3;case "hipped":return 1;case "gabled":return 2;case "parapet":return 0;case "mansard":return 4;case "skillion":return 5;case "pyramidal":return 6;default:throw new Error(`Unknown roof shape: ${e}`)}}class Vy{constructor(){this.layoutVertexArray=new Ha,this.layoutAttenuationArray=new Qa,this.layoutColorArray=new tl,this.indexArray=new ol,this.indexArrayForConflation=new ol,this.segmentsBucket=new Rl;}}class Ey{constructor(e){this.layoutFacadePaintArray=null,this.layoutFacadeDataArray=null,this.layoutFacadeVerticalRangeArray=null,this.segmentsBucket=new Rl,this.entranceBloom=new Vy;const t=66560;this.layoutVertexArray=new Ha,this.layoutVertexArray.reserve(t),this.layoutNormalArray=new Ua,this.layoutNormalArray.reserve(t),this.layoutCentroidArray=new Ua,this.layoutCentroidArray.reserve(t),this.layoutColorArray=new tl,this.layoutColorArray.reserve(t),this.layoutFloodLightDataArray=new yl,this.layoutFloodLightDataArray.reserve(t),this.layoutAOArray=new bl,this.layoutAOArray.reserve(t),this.indexArray=new ol,this.indexArray.reserve(66560),this.indexArrayForConflation=new ol,this.segmentsBucket=new Rl,this.entranceBloom=new Vy,e&&(this.layoutFacadePaintArray=new tl,this.layoutFacadeDataArray=new Wa,this.layoutFacadeVerticalRangeArray=new tl);}reserve(e,t,r){this.layoutVertexArray.reserveForAdditional(e),this.layoutCentroidArray.reserveForAdditional(e),this.layoutFloodLightDataArray.reserveForAdditional(e),this.layoutNormalArray.reserveForAdditional(e),this.layoutAOArray.reserveForAdditional(e),this.layoutColorArray.reserveForAdditional(e),this.indexArray.reserveForAdditional(t),r&&(this.layoutFacadePaintArray.reserveForAdditional(e),this.layoutFacadeDataArray.reserveForAdditional(e),this.layoutFacadeVerticalRangeArray.reserveForAdditional(e));}}class Fy{constructor(e){this.colorBufferUploaded=!1,this.maxHeight=0,this.replacementUpdateTime=0,this.activeReplacements=[],this.footprints=[],this.footprintsVertices=new fl,this.footprintsIndices=new yl,this.footprintsMin=new Ie(1/0,1/0),this.footprintsMax=new Ie(-1/0,-1/0),this.featuresOnBorder=[],this.buildingWithoutFacade=new Ey(!1),this.buildingWithFacade=new Ey(!0),this.indexArrayForConflationUploaded=!1,this.featureFootprintLookup=new Map,this.buildingIds=new Set,this.footprintLookup={},this.zoom=e.zoom,this.canonical=e.canonical,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.fqid),this.index=e.index,this.hasPattern=!1,this.worldview=e.worldview,this.lut=e.lut,this.programConfigurations=new pu(e.layers,{zoom:e.zoom,lut:e.lut}),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.projection=e.projection,this.groundEffect=new hf(e),this.groundEffect.groundRadiusArray=new ja,this.hasAppearances=null;}updateFootprints(e,t){const r=new wd([],[],1),n={vertices:[],indices:new Uint32Array(0),grid:r,min:this.footprintsMin,max:this.footprintsMax,buildingIds:this.buildingIds};t.push({footprint:n,id:e});}updateAppearances(e,t,r,n){}prepare(){return function(){if(null!=sm||null!=im)return null;if(null!=nm)return nm;const e=fetch(at.BUILDING_GEN_URL);return nm=function(e){let t,r,n,i,s;function o(){t=new Uint8Array(s.buffer),r=new Int16Array(s.buffer),n=new Int32Array(s.buffer),i=new Float32Array(s.buffer);}function a(){throw new Error("Unexpected BuildingGen error.")}const l=()=>{},u={a:{a,f:function(e){const r=t.length,n=Math.max(e>>>0,Math.ceil(1.2*r)),i=Math.ceil((n-r)/65536);try{return s.grow(i),o(),!0}catch(e){return !1}},g:a,b:l,c:l,d:l,e:l}};return (WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(e,u):e.then(e=>e.arrayBuffer()).then(e=>WebAssembly.instantiate(e,u))).then(e=>{const a=e.instance.exports;return (0,a.g)(),s=a.f,o(),new Yf({setStyle:a.h,setAOOptions:a.i,setMetricOptions:a.j,setStructuralOptions:a.k,setFacadeOptions:a.l,setFauxFacadeOptions:a.m,setFacadeClassifierOptions:a.n,addFeature:a.o,addFacade:a.p,generateMesh:a.q,getLastError:a.r,getOuterRingLength:a.s,getMeshCount:a.t,getPositionsPtr:a.u,getPositionsLength:a.v,getNormalsPtr:a.w,getNormalsLength:a.x,getAOPtr:a.y,getAOLength:a.z,getUVPtr:a.A,getUVLength:a.B,getFauxFacadePtr:a.C,getFauxFacadeLength:a.D,getIndicesPtr:a.E,getIndicesLength:a.F,getBuildingPart:a.G,getRingCount:a.H,getRingPtr:a.I,getRingLength:a.J,malloc:a.K,free:a.L,heapU8:t,heap16:r,heap32:n,heapF32:i})})}(e).then(e=>(nm=null,sm=e,sm)).catch(e=>{Ze("Could not load building-gen"),nm=null,im=e;}),nm}()}populate(e,t,r,n){const i=lm();if(!i)return;const s=Uu(r);this.tileToMeter=s,this.brightness=t.brightness,i.setStyle({normalScale:[1,-1,s],tileToMeters:s}),i.setAOOptions(!1,.3),i.setMetricOptions(!1,16),i.setStructuralOptions(!0),i.setFacadeClassifierOptions(3);const o=new Map,a=new Map;let l=0;for(const{feature:t}of e){if("LineString"!==Py[t.type]){o.set(t.id,t.properties.source_id);continue}const e=this.layers[0]._featureFilter.needGeometry;if(e&&!this.layers[0]._featureFilter.filter(new Yo(this.zoom),t,r))continue;const i=Yu(t,e);if(!e&&!this.layers[0]._featureFilter.filter(new Yo(this.zoom),i,r))continue;const s=e?i.geometry:Wu(t,r,n),u=[];for(const e of s)for(const t of e)u.push(t.x),u.push(t.y);const c={coordinates:u,crossPerc:t.properties.cross_perc,distanceToRoad:t.properties.distance_to_road,entrances:t.properties.entrances,sourceId:0},h=t.properties.source_id;let p=a.get(h);p||(p=[],a.set(h,p)),p.push(c),++l;}this.maxHeight=0;const u=new Array,c=new Set,h=e=>{null!=e&&c.add(e);},p=(e,t)=>{null!=e&&u.push({buildingId:e,footprintIndex:t});},d=64*(e.length-l),f=d/2;this.buildingWithFacade.reserve(d,f,!0),this.buildingWithoutFacade.reserve(2*d,2*f,!1),this.footprintsIndices.reserve(16*(e.length-l)),this.footprintsVertices.reserve(8*(e.length-l));for(const{feature:l,id:u,index:d,sourceLayerIndex:f}of e){if("LineString"===Py[l.type])continue;const e=this.layers[0]._featureFilter.needGeometry;if(e&&!this.layers[0]._featureFilter.filter(new Yo(this.zoom),l,r))continue;let m=null;if(l.properties&&l.properties.hasOwnProperty("building_id")&&(m=Number(l.properties.building_id),c.has(m)))continue;const y=Yu(l,e);if(!e&&!this.layers[0]._featureFilter.filter(new Yo(this.zoom),y,r))continue;const g=e?y.geometry:Wu(l,r,n),x=_p(g,500);let v=!1;for(const e of x)if(1!==e.length){v=!0;break}if(v){h(m);continue}if(!Ty(g,163)){h(m);continue}const b=this.layers[0],w=ky(b.layout.get("building-roof-shape").evaluate(l,{},r)),_=b.layout.get("building-base").evaluate(l,{},r),A=b.layout.get("building-height").evaluate(l,{},r),M=b.layout.get("building-flood-light-ground-radius").evaluate(l,{},r),I=b.paint.get("building-ambient-occlusion-intensity"),S=M/this.tileToMeter;l.properties["building-part"]="roof";const z=b.paint.get("building-color").evaluate(l,{},this.canonical).toPremultipliedRenderColor(this.lut),P=b.paint.get("building-emissive-strength").evaluate(l,{},this.canonical);l.properties["building-part"]="wall";const B=b.paint.get("building-color").evaluate(l,{},this.canonical).toPremultipliedRenderColor(this.lut),T=b.paint.get("building-emissive-strength").evaluate(l,{},this.canonical);l.properties["building-part"]="window";const k=b.paint.get("building-color").evaluate(l,{},this.canonical).toPremultipliedRenderColor(this.lut),V=b.paint.get("building-emissive-strength").evaluate(l,{},this.canonical);l.properties["building-part"]="door";const E=b.paint.get("building-color").evaluate(l,{},this.canonical).toPremultipliedRenderColor(this.lut),F=b.paint.get("building-emissive-strength").evaluate(l,{},this.canonical);let D=b.layout.get("building-flood-light-wall-radius").evaluate(l,{},r);D=De(D,0,2048);const C=D/2048*By,R=o.get(u),L=a.get(R)||[],O=0!==L.length&&b.layout.get("building-facade").evaluate(l,{},r);i.setFacadeOptions(4,!0),i.setFauxFacadeOptions(O,!1,1);let U=0,N=0,j=0,G=0,$=0,q=0,X=0,H=0,Z=0,W=0,Y=0;if(O){let e=Math.round(b.layout.get("building-facade-floors").evaluate(l,{},r));if(0===_){e=Math.max(1,e-(L.length>0?1:0));let t=4;if(A>100){const e=[10,13,15];t=e[l.id?l.id%e.length:0];}else A<=10&&(t=3);i.setFacadeOptions(t,!0),$=(A<15?1.3:1.61803)*t/s;}else $=_/s;q=A/s,$=Math.min($,q),j=b.layout.get("building-facade-unit-width").evaluate(l,{},r)/s,G=(q-$)/e,i.setFauxFacadeOptions(!0,!0,j);const t=b.layout.get("building-facade-window").evaluate(l,{},r);U=t[0],N=t[1],X=Math.floor(65535*Math.min(1,$/Un)),H=Math.floor(65535*Math.min(1,q/Un)),Z=Math.floor(255*U)<<8|Math.floor(255*N),W=Math.floor(65535*Math.min(1,j/Un)),Y=Math.floor(65535*Math.min(1,G/Un));}const J=Array(x.length),K={x:1/0,y:1/0},Q={x:-1/0,y:-1/0},ee={x:0,y:0};let te=0;for(let e=0;e0){const r=[],n=Array(t.length+1);n[0]=0;for(let e=0;eUn||K.y<0||Q.y>Un)&&this.featuresOnBorder.push({featureId:l.id,footprintIndex:this.footprints.length});{const e=Yh(xe,null,2);this.footprintsIndices.resize(this.footprintsIndices.length+e.length),this.footprintsIndices.uint16.set(e,ye),this.buildingIds.add(null!=m?m:l.id),this.footprintsMin.x=Math.min(this.footprintsMin.x,ve.x),this.footprintsMin.y=Math.min(this.footprintsMin.y,ve.y),this.footprintsMax.x=Math.max(this.footprintsMax.x,be.x),this.footprintsMax.y=Math.max(this.footprintsMax.y,be.y);const t={footprintVertexOffset:ge,footprintVertexLength:this.footprintsVertices.length-ge,footprintIndexOffset:ye,footprintIndexLength:this.footprintsIndices.length-ye,min:ve,max:be,hiddenFlags:0,indicesOffset:pe,indicesLength:me,bloomIndicesOffset:le,bloomIndicesLength:ue,groundEffectVertexOffset:we,groundEffectVertexLength:_e,hasFauxFacade:O,height:de,promoteId:u,feature:y,parts:oe,buildingBloom:ae},r=this.footprints.length;void 0!==l.id&&this.featureFootprintLookup.set(l.id,r),p(m,r),this.footprints.push(t);}this.programConfigurations.populatePaintArrays(ne.layoutVertexArray.length,l,d,{},t.availableImages,r,t.brightness),this.groundEffect.addPaintPropertiesData(l,d,{},t.availableImages,r,t.brightness),t.featureIndex.insert(l,g,d,f,this.index,ce);}u.forEach(({buildingId:e,footprintIndex:t})=>{c.has(e)&&(this.footprints[t].hiddenFlags|=4);});const m=new Set;this.buildingIds.forEach((e,t,r)=>{c.has(e)||m.add(e);}),this.buildingIds=m,this.groundEffect.prepareBorderSegments();}update(e,t,r,n,i,s,o){this.programConfigurations.updatePaintArrays(e,t,i,r,n,s,o),this.groundEffect.update(e,t,i,r,n,s,o),this.evaluate(this.layers[0],e),this.colorBufferUploaded=!1;}isEmpty(){return 0===this.buildingWithoutFacade.layoutVertexArray.length&&0===this.buildingWithFacade.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(e){const t=t=>{t.layoutVertexBuffer=e.createVertexBuffer(t.layoutVertexArray,vy.members),t.layoutNormalBuffer=e.createVertexBuffer(t.layoutNormalArray,by.members),t.layoutCentroidBuffer=e.createVertexBuffer(t.layoutCentroidArray,wy.members),t.layoutFloodLightDataBuffer=e.createVertexBuffer(t.layoutFloodLightDataArray,zy.members),t.layoutFacadeDataArray&&t.layoutFacadeDataArray.length&&(t.layoutFacadeDataBuffer=e.createVertexBuffer(t.layoutFacadeDataArray,My.members)),t.layoutFacadeVerticalRangeArray&&t.layoutFacadeVerticalRangeArray.length&&(t.layoutFacadeVerticalRangeBuffer=e.createVertexBuffer(t.layoutFacadeVerticalRangeArray,Iy.members)),t.entranceBloom.layoutVertexArray.length&&(t.entranceBloom.layoutVertexBuffer=e.createVertexBuffer(t.entranceBloom.layoutVertexArray,vy.members),t.entranceBloom.layoutAttenuationBuffer=e.createVertexBuffer(t.entranceBloom.layoutAttenuationArray,Sy.members)),this.uploadUpdatedColorBuffer(e),this.uploadUpdatedIndexBuffer(e);};this.uploaded||(t(this.buildingWithoutFacade),t(this.buildingWithFacade),this.groundEffect.upload(e)),this.groundEffect.uploadPaintProperties(e),this.programConfigurations.upload(e),this.uploaded=!0;}destroy(){const e=e=>{e.layoutVertexBuffer&&(e.layoutVertexBuffer.destroy(),e.layoutNormalBuffer.destroy(),e.layoutColorBuffer.destroy(),e.segmentsBucket.destroy(),e.indexBuffer&&e.indexBuffer.destroy(),e.entranceBloom.layoutVertexBuffer&&(e.entranceBloom.layoutVertexBuffer.destroy(),e.entranceBloom.layoutColorBuffer.destroy(),e.entranceBloom.layoutAttenuationBuffer.destroy(),e.entranceBloom.indexBuffer.destroy(),e.entranceBloom.segmentsBucket.destroy()));};e(this.buildingWithoutFacade),e(this.buildingWithFacade),this.groundEffect.destroy(),this.programConfigurations.destroy();}updateFootprintHiddenFlags(e,t,r=!0){let n=!1;const i=r?t:0,s=0|(r?-1:~t);0===this.groundEffect.hiddenByLandmarkVertexArray.length&&this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const t of e){const e=this.footprints[t],r=e.hiddenFlags&s|i;e.hiddenFlags!==r&&(e.hiddenFlags=r,n=!0,this.groundEffect.updateHiddenByLandmarkRange(e.groundEffectVertexOffset,e.groundEffectVertexLength,0!==e.hiddenFlags));}return n&&(this.indexArrayForConflationUploaded=!1),n}uploadUpdatedIndexBuffer(e){if(this.groundEffect.uploadHiddenByLandmark(e),this.indexArrayForConflationUploaded)return;const t=e=>{0!==e.indexArray.length&&(e.indexArrayForConflation.resize(e.indexArray.length),e.indexArrayForConflation.uint16.set(e.indexArray.uint16),e.entranceBloom.indexArrayForConflation.resize(e.entranceBloom.indexArray.length),e.entranceBloom.indexArrayForConflation.uint16.set(e.entranceBloom.indexArray.uint16));};t(this.buildingWithoutFacade),t(this.buildingWithFacade);for(const e of this.footprints){const t=e.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade,r=e.indicesOffset+e.indicesLength;if(0!==e.hiddenFlags){for(let n=e.indicesOffset;n{0!==t.indexArray.length&&(t.indexBuffer?t.indexBuffer.updateData(t.indexArrayForConflation):t.indexBuffer=e.createIndexBuffer(t.indexArrayForConflation,!0),t.entranceBloom.indexBuffer?t.entranceBloom.indexBuffer.updateData(t.entranceBloom.indexArrayForConflation):t.entranceBloom.indexBuffer=e.createIndexBuffer(t.entranceBloom.indexArrayForConflation,!0));};r(this.buildingWithoutFacade),r(this.buildingWithFacade),this.indexArrayForConflationUploaded=!0;}uploadUpdatedColorBuffer(e){const t=t=>{t.layoutColorBuffer?t.layoutColorBuffer.updateData(t.layoutColorArray):t.layoutColorBuffer=e.createVertexBuffer(t.layoutColorArray,_y.members,!0),t.layoutFacadePaintArray&&(t.layoutFacadePaintBuffer?t.layoutFacadePaintBuffer.updateData(t.layoutFacadePaintArray):t.layoutFacadePaintBuffer=e.createVertexBuffer(t.layoutFacadePaintArray,Ay.members,!0)),t.entranceBloom.layoutColorBuffer?t.entranceBloom.layoutColorBuffer.updateData(t.entranceBloom.layoutColorArray):t.entranceBloom.layoutColorBuffer=e.createVertexBuffer(t.entranceBloom.layoutColorArray,_y.members,!0);};t(this.buildingWithoutFacade),t(this.buildingWithFacade),this.colorBufferUploaded=!0;}evaluate(e,t){const r=e.paint.get("building-ambient-occlusion-intensity");for(const n of this.footprints){if(4&n.hiddenFlags)continue;const i=t[n.promoteId],s=n.feature;s.properties["building-part"]="roof";const o=e.paint.get("building-color").evaluate(s,i,this.canonical).toPremultipliedRenderColor(this.lut),a=e.paint.get("building-emissive-strength").evaluate(s,i,this.canonical);s.properties["building-part"]="wall";const l=e.paint.get("building-color").evaluate(s,i,this.canonical).toPremultipliedRenderColor(this.lut),u=e.paint.get("building-emissive-strength").evaluate(s,i,this.canonical);s.properties["building-part"]="window";const c=e.paint.get("building-color").evaluate(s,i,this.canonical).toPremultipliedRenderColor(this.lut),h=e.paint.get("building-emissive-strength").evaluate(s,i,this.canonical);s.properties["building-part"]="door";const p=e.paint.get("building-color").evaluate(s,i,this.canonical).toPremultipliedRenderColor(this.lut),d=e.paint.get("building-emissive-strength").evaluate(s,i,this.canonical),f=n.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade;for(const e of n.parts){let t,i=o;1===e.part?(i=o,t=a):0===e.part?(i=l,t=u):2===e.part?(i=c,t=h):3===e.part&&(i=p,t=d),t=De(t,0,1);for(let s=0;st.max.x||r.max.xt.max.y||r.max.yo.max.x||o.min.x>e||t>o.max.y||o.min.y>t||o.height<=r||Dy(s,this.footprintsVertices.float32.subarray(2*o.footprintVertexOffset,2*(o.footprintVertexOffset+o.footprintVertexLength)),this.footprintsIndices.uint16.subarray(o.footprintIndexOffset,o.footprintIndexOffset+o.footprintIndexLength))&&(r=o.height,this.footprintLookup[i]=o,n=0!==o.hiddenFlags);if(r!==Number.NEGATIVE_INFINITY)return {height:r,hidden:n};this.footprintLookup[i]=void 0;}}function Dy(e,t,r){for(let n=0;n1&&(o=e[++s]);const l=Math.abs(a-o.left),u=Math.abs(a-o.right),c=Math.min(l,u);let h;const p=t/r*(n+1);if(o.isDash){const e=n-Math.abs(p);h=Math.sqrt(c*c+e*e);}else h=n-Math.sqrt(c*c+p*p);this.image.data[i+a]=Math.max(0,Math.min(255,h+128));}}}addRegularDash(e,t){for(let t=e.length-1;t>=0;--t){const r=e[t],n=e[t+1];r.zeroLength?e.splice(t,1):n&&n.isDash===r.isDash&&(n.left=r.left,e.splice(t,1));}const r=e[0],n=e[e.length-1];r.isDash===n.isDash&&(r.left=n.left-this.width,n.right=r.right+this.width);const i=this.width*this.nextRow;let s=0,o=e[s];for(let r=0;r1&&(o=e[++s]);const n=Math.abs(r-o.left),a=Math.abs(r-o.right),l=Math.min(n,a);this.image.data[i+r]=Math.max(0,Math.min(255,(o.isDash?l:-l)+t+128));}}addDash(e,t){const r=this.getKey(e,t);if(this.positions[r])return this.positions[r];const n="round"===t,i=n?7:0,s=2*i+1;if(this.nextRow+s>this.height)return Ze("LineAtlas out of space"),null;0===e.length&&e.push(1);let o=0;for(let t=0;te.fqid),this.index=e.index,this.projection=e.projection,this.hasPattern=!1,this.hasCrossSlope=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(e=>{this.gradients[e.id]={};}),this.layoutVertexArray=new Xa,this.layoutVertexArray2=new Ha,this.patternVertexArray=new Ha,this.indexArray=new ol,this.programConfigurations=new pu(e.layers,{zoom:e.zoom,lut:e.lut}),this.segments=new Rl,this.maxLineLength=0,this.zOffsetVertexArray=new Ha,this.elevationGroundScaleVertexArray=new ja,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.tessellationStep=e.tessellationStep?e.tessellationStep:128,this.worldview=e.worldview,this.hasAppearances=null;}updateFootprints(e,t){}updateAppearances(e,t,r,n){}populate(e,t,r,n){this.hasPattern=Ip("line",this.layers,this.pixelRatio,t);const i=this.layers[0].layout.get("line-sort-key");this.tileToMeter=Uu(r);const s=this.layers[0].layout.get("line-elevation-reference");if("hd-road-markup"===s)this.elevationType="road";else {const e=this.layers[0].layout.get("line-z-offset"),t=e.isConstant()&&!e.constantOr(0);this.elevationType="sea"!==s&&"ground"!==s&&t?"none":"offset","offset"===this.elevationType&&"none"===s&&Ze(`line-elevation-reference: ground is used for the layer ${this.layerIds[0]} because non-zero line-z-offset value was found.`),this.isSeaLevelReference="sea"===s;}const o=this.layers[0].layout.get("line-cross-slope");this.hasCrossSlope="offset"===this.elevationType&&void 0!==o;const a=[];for(const{feature:s,id:o,index:l,sourceLayerIndex:u}of e){const e=this.layers[0]._featureFilter.needGeometry,c=Yu(s,e);if(!this.layers[0]._featureFilter.filter(new Yo(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),c,r))continue;const h=i?i.evaluate(c,{},r):void 0,p={id:o,properties:s.properties,type:s.type,sourceLayerIndex:u,index:l,geometry:e?c.geometry:Wu(s,r,n),patterns:{},sortKey:h};a.push(p);}i&&a.sort((e,t)=>e.sortKey-t.sortKey);const{lineAtlas:l,featureIndex:u}=t,c=this.addConstantDashes(l);for(const n of a){const{geometry:i,index:s,sourceLayerIndex:o}=n;if(c&&this.addFeatureDashes(n,l),this.hasPattern){const e=Sp("line",this.layers,n,this.zoom,this.pixelRatio,t);this.patternFeatures.push(e);}else this.addFeature(n,i,s,r,l.positions,t.availableImages,t.brightness,t.elevationFeatures);u.insert(e[s].feature,i,s,o,this.index);}}addConstantDashes(e){let t=!1;for(const r of this.layers){const n=r.paint.get("line-dasharray").value,i=r.layout.get("line-cap").value;if("constant"!==n.kind||"constant"!==i.kind)t=!0;else {const t=i.value,r=n.value;if(!r)continue;e.addDash(r,t);}}return t}addFeatureDashes(e,t){const r=this.zoom;for(const n of this.layers){const i=n.paint.get("line-dasharray").value,s=n.layout.get("line-cap").value;if("constant"===i.kind&&"constant"===s.kind)continue;let o,a;if("constant"===i.kind){if(o=i.value,!o)continue}else o=i.evaluate({zoom:r},e);a="constant"===s.kind?s.value:s.evaluate({zoom:r},e),t.addDash(o,a),e.patterns[n.id]=[t.getKey(o,a)];}}update(e,t,r,n,i,s,o,a){this.programConfigurations.updatePaintArrays(e,t,i,r,n,s,o,a);}addFeatures(e,t,r,n,i,s){for(const i of this.patternFeatures)this.addFeature(i,i.geometry,i.index,t,r,n,s,e.elevationFeatures);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,$y)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=e.createVertexBuffer(this.patternVertexArray,Xy)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,Uy.members,!0)),!this.elevationGroundScaleVertexBuffer&&this.elevationGroundScaleVertexArray.length>0&&(this.elevationGroundScaleVertexBuffer=e.createVertexBuffer(this.elevationGroundScaleVertexArray,Ny.members,!0)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,jy),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.elevationGroundScaleVertexBuffer&&this.elevationGroundScaleVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy());}lineFeatureClips(e,t){let r,n;if(t&&t>0?(r=`mapbox_clip_start_${t}`,n=`mapbox_clip_end_${t}`):(r="mapbox_clip_start",n="mapbox_clip_end"),e.properties&&e.properties.hasOwnProperty(r)&&e.properties.hasOwnProperty(n))return {start:+e.properties[r],end:+e.properties[n]}}addFeature(e,t,r,n,i,s,o,a){const l=this.layers[0].layout,u=l.get("line-join").evaluate(e,{}),c=l.get("line-cap").evaluate(e,{}),h=l.get("line-miter-limit"),p=l.get("line-round-limit");this.lineClips=this.lineFeatureClips(e),this.lineFeature=e;const d=!(!e.properties||!e.properties.hasOwnProperty("mapbox_line_metrics"))&&e.properties.mapbox_line_metrics;this.zOffsetValue=l.get("line-z-offset").value;const f=this.layers[0].paint.get("line-width").value;if("constant"!==f.kind&&!1===f.isLineProgressConstant&&(this.variableWidthValue=f),this.isSeaLevelReference){const e=l.get("line-elevation-ground-scale").value;"constant"===e.kind&&0===e.value||(this.elevationGroundScaleValue=e);}if("road"===this.elevationType){const r=this.layoutVertexArray.length;if(!this.addElevatedRoadFeature(e,t,n,a,u,c,h,p)){const[i,s]=this.clipRuntimeLinesToTile(t,1);for(let t=0;t0?o.parentIndex:null);}this.fillNonElevatedRoadSegment(r);}}else for(let r=0;r0?r:null);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,r,i,s,n,o,void 0,this.worldview);}computeSegNextDir(e,t){return e.nextPoint.sub(t.at(-2)).unit()}computeSegPrevDir(e,t){return t[1].sub(e.prevPoint).unit()}clipLinesToTile(e,t){return Tf(e,-t,-t,Un+t,Un+t)}clipRuntimeLinesToTile(e,t){const r=[];return [Tf(e,-t,-t,Un+t,Un+t,r),r]}addElevatedRoadFeature(e,t,r,n,i,s,o,a){const l=[],u=_c.getElevationFeature(e,n);if(u){const e=this.clipLinesToTile(t,1),n=this.prepareElevatedLines(e,u,r);for(const e of n)l.push({geometry:e,elevation:u,elevationTileID:r,segment:{progress:{min:0,max:1},nextDir:void 0,prevDir:void 0}});}if(0===l.length)return !1;for(const t of l){const n=this.layoutVertexArray.length;this.addLine(t.geometry,e,r,i,s,o,a);const l=new Ac(r,t.elevationTileID);if(t.elevation)for(let e=n;e>1,this.layoutVertexArray.int16[6*e+1]>>1),n=l.pointElevation(r,t.elevation,.05);this.updateHeightRange(n),this.zOffsetVertexArray.emplaceBack(n,0,0);}else this.fillNonElevatedRoadSegment(n);}return !0}prepareElevatedLines(e,t,r){if(null!=t.constantHeight)return e;const n=[],i=1/Uu(r);for(const r of e)kf(r,new bc(t,i),0,n);return n}fillNonElevatedRoadSegment(e){for(let t=e;t0,h=a&&a.progress.max<1;if(this.lineClips){let r={min:this.lineClips.start,max:this.lineClips.end},n=1;if(a){const e=this.lineClips.end-this.lineClips.start;r=function(e,t,r){return {min:ot(e.min,t,r),max:ot(e.max,t,r)}}(a.progress,{min:0,max:1},r),e>0&&(n=(r.max-r.min)/e);}const i=+t.properties.mapbox_clip_feature_len,s=+t.properties.mapbox_clip_seg_len;if(Number.isNaN(i)||Number.isNaN(s)){for(let t=0;t=2&&e[d-1].equals(e[d-2]);)d--;let f=0;for(;f0,T=this.overscaling<=16?122880/(512*this.overscaling):0;if(r&&"round"===a)if(Ss&&(a="bevel"),"bevel"===a&&(S>2&&(a="flipbevel"),S2*T){const t=y.sub(y.sub(g)._mult(T/e)._round());this.updateDistance(g,t),this.addCurrentVertex(t,v,0,0,m,A),g=t;}this.updateDistance(g,y),M._mult(S),this.addCurrentVertex(y,M,0,0,m,A);const t=y.dist(x);if(t>2*T){const e=y.add(x.sub(y)._mult(T/t)._round());this.updateDistance(y,e),this.addCurrentVertex(e,b,0,0,m,A),y=e;}}else M._mult(S),this.addCurrentVertex(y,M,0,0,m,A);else if("flipbevel"===a){if(S>100)M=b.mult(-1);else {const e=S*v.add(b).mag()/v.sub(b).mag();M._perp()._mult(e*(B?-1:1));}this.addCurrentVertex(y,M,0,0,m,A),this.addCurrentVertex(y,M.mult(-1),0,0,m,A);}else if("bevel"===a||"fakeround"===a){const e=y.dist(g);let t=1;if("offset"===this.elevationType&&"bevel"===a&&"round"!==this.currentLineJoinType&&!this.patternJoinNone&&null!=A&&g&&x){const r=4*T;e1){this.lineSoFar=e.w;const r=(t.x-e.x)/c,n=(t.y-e.y)/c,i=(t.z-e.z)/c,s=(t.w-e.w)/c,o=t.x-e.x,a=t.y-e.y,p=Math.sqrt(o*o+a*a);if(0===p)return;const d=-a/p,f=o/p,m=d,y=f,g=-d,x=-f;for(let t=1;t=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,u),a.primitiveLength++),s?this.e2=u:this.e1=u,null!=l&&this.zOffsetVertexArray.emplaceBack(l.zOffset,l.variableWidth,l.variableWidth),this.elevationGroundScaleValue){const e=l?l.elevationGroundScale:this.evaluateElevationGroundScale();this.elevationGroundScaleVertexArray.emplaceBack(e);}}updateScaledDistance(){this.lineClips?(this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=this.totalFeatureLength*this.lineClips.start+this.distance):this.lineSoFar=this.distance;}updateDistance(e,t){this.prevDistance=this.distance,this.distance+=e.dist(t),this.updateScaledDistance();}}function Ky(e,t,r){return e.xr||e.yr}let Qy,eg;function tg(e,t,r){return t*(Un/(e.tileSize*Math.pow(2,r-e.tileID.overscaledZ)))}Js(Jy,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const rg=(e,t,r)=>(1-r)*e+r*t;function ng(e,t){return 1/tg(e,1,t.tileZoom)}function ig(e,t,r,n){return e.translatePosMatrix(n||t.tileID.projMatrix,t,r.paint.get("line-translate"),r.paint.get("line-translate-anchor"))}const sg=e=>{const t=[];og(e)&&t.push("RENDER_LINE_DASH"),e.paint.get("line-gradient")&&t.push("RENDER_LINE_GRADIENT");const r=e.paint.get("line-trim-offset");0===r[0]&&0===r[1]||t.push("RENDER_LINE_TRIM_OFFSET"),0!==e.paint.get("line-border-width").constantOr(1)&&t.push("RENDER_LINE_BORDER");const n="none"===e.layout.get("line-join").constantOr("miter"),i=!!e.paint.get("line-pattern").constantOr(1);return n&&i&&t.push("LINE_JOIN_NONE"),t};function og(e){const t=e.paint.get("line-dasharray").value;return "constant"!==t.kind||t.value}let ag;const lg=()=>ag||(ag={layout:Qy||(Qy=new la({"line-cap":new oa(ua.layout_line["line-cap"]),"line-join":new oa(ua.layout_line["line-join"]),"line-miter-limit":new sa(ua.layout_line["line-miter-limit"]),"line-round-limit":new sa(ua.layout_line["line-round-limit"]),"line-sort-key":new oa(ua.layout_line["line-sort-key"]),"line-z-offset":new oa(ua.layout_line["line-z-offset"]),"line-elevation-reference":new sa(ua.layout_line["line-elevation-reference"]),"line-cross-slope":new sa(ua.layout_line["line-cross-slope"]),visibility:new sa(ua.layout_line.visibility),"line-width-unit":new sa(ua.layout_line["line-width-unit"]),"line-elevation-ground-scale":new oa(ua.layout_line["line-elevation-ground-scale"])})),paint:eg||(eg=new la({"line-opacity":new oa(ua.paint_line["line-opacity"]),"line-color":new oa(ua.paint_line["line-color"]),"line-translate":new sa(ua.paint_line["line-translate"]),"line-translate-anchor":new sa(ua.paint_line["line-translate-anchor"]),"line-width":new oa(ua.paint_line["line-width"]),"line-gap-width":new oa(ua.paint_line["line-gap-width"]),"line-offset":new oa(ua.paint_line["line-offset"]),"line-blur":new oa(ua.paint_line["line-blur"]),"line-dasharray":new oa(ua.paint_line["line-dasharray"]),"line-pattern":new oa(ua.paint_line["line-pattern"]),"line-pattern-cross-fade":new sa(ua.paint_line["line-pattern-cross-fade"]),"line-gradient":new aa(ua.paint_line["line-gradient"]),"line-trim-offset":new sa(ua.paint_line["line-trim-offset"]),"line-trim-fade-range":new sa(ua.paint_line["line-trim-fade-range"]),"line-trim-color":new sa(ua.paint_line["line-trim-color"]),"line-emissive-strength":new oa(ua.paint_line["line-emissive-strength"]),"line-border-width":new oa(ua.paint_line["line-border-width"]),"line-border-color":new oa(ua.paint_line["line-border-color"]),"line-occlusion-opacity":new sa(ua.paint_line["line-occlusion-opacity"]),"line-color-use-theme":new oa({type:"string",default:"default","property-type":"data-driven"}),"line-gradient-use-theme":new oa({type:"string",default:"default","property-type":"data-driven"}),"line-trim-color-use-theme":new oa({type:"string",default:"default","property-type":"data-driven"}),"line-border-color-use-theme":new oa({type:"string",default:"default","property-type":"data-driven"})}))},ag);class ug extends oa{possiblyEvaluate(e,t){return t=new Yo(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,transition:t.transition,worldview:t.worldview}),super.possiblyEvaluate(e,t)}evaluate(e,t,r,n){return t=Object.assign({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,r,n)}}let cg;function hg(e,t){return t>0?t+2*e:e}const pg=Ra([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),dg=Ra([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),fg=Ra([{name:"a_projected_pos",components:4,type:"Float32"}],4);Ra([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const mg=Ra([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),yg=Ra([{name:"a_x_axis",components:3,type:"Float32"},{name:"a_y_axis",components:3,type:"Float32"}]),gg=Ra([{name:"a_texb",components:2,type:"Uint16"}]),xg=Ra([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),vg=Ra([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);Ra([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const bg=Ra([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),wg=Ra([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);Ra([{name:"triangle",components:3,type:"Uint16"}]),Ra([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"},{type:"Uint8",name:"flipState"}]),Ra([{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Float32",name:"zOffset"},{type:"Uint8",name:"hasIconTextFit"},{type:"Uint16",name:"elevationFeatureIndex"}]),Ra([{type:"Float32",name:"offsetX"}]),Ra([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var _g=24;function Ag(e,t,r){return e.sections.forEach(e=>{e.text=function(e,t,r){const n=t.layout.get("text-transform").evaluate(r,{});return "uppercase"===n?e=e.toLocaleUpperCase():"lowercase"===n&&(e=e.toLocaleLowerCase()),Wo.applyArabicShaping&&(e=Wo.applyArabicShaping(e)),e}(e.text,t,r);}),e}const Mg={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function Ig(e){return "︶"===e||"﹈"===e||"︸"===e||"﹄"===e||"﹂"===e||"︾"===e||"︼"===e||"︺"===e||"︘"===e||"﹀"===e||"︐"===e||"︓"===e||"︔"===e||"`"===e||" ̄"===e||"︑"===e||"︒"===e}function Sg(e){return "︵"===e||"﹇"===e||"︷"===e||"﹃"===e||"﹁"===e||"︽"===e||"︻"===e||"︹"===e||"︗"===e||"︿"===e}const zg=4294967296,Pg=1/zg,Bg="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");let Tg=class{constructor(e=new Uint8Array(16)){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length;}readFields(e,t,r=this.length){for(;this.pos>3,i=this.pos;this.type=7&r,e(n,t,this),this.pos===i&&this.skip(r);}return t}readMessage(e,t){return this.readFields(e,t,this.readVarint()+this.pos)}readFixed32(){const e=this.dataView.getUint32(this.pos,!0);return this.pos+=4,e}readSFixed32(){const e=this.dataView.getInt32(this.pos,!0);return this.pos+=4,e}readFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*zg;return this.pos+=8,e}readSFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*zg;return this.pos+=8,e}readFloat(){const e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}readDouble(){const e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}readVarint(e){const t=this.buf;let r,n;return n=t[this.pos++],r=127&n,n<128?r:(n=t[this.pos++],r|=(127&n)<<7,n<128?r:(n=t[this.pos++],r|=(127&n)<<14,n<128?r:(n=t[this.pos++],r|=(127&n)<<21,n<128?r:(n=t[this.pos],r|=(15&n)<<28,function(e,t,r){const n=r.buf;let i,s;if(s=n[r.pos++],i=(112&s)>>4,s<128)return kg(e,i,t);if(s=n[r.pos++],i|=(127&s)<<3,s<128)return kg(e,i,t);if(s=n[r.pos++],i|=(127&s)<<10,s<128)return kg(e,i,t);if(s=n[r.pos++],i|=(127&s)<<17,s<128)return kg(e,i,t);if(s=n[r.pos++],i|=(127&s)<<24,s<128)return kg(e,i,t);if(s=n[r.pos++],i|=(1&s)<<31,s<128)return kg(e,i,t);throw new Error("Expected varint not more than 10 bytes")}(r,e,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const e=this.readVarint();return e%2==1?(e+1)/-2:e/2}readBoolean(){return Boolean(this.readVarint())}readString(){const e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&Bg?Bg.decode(this.buf.subarray(t,e)):function(e,t,r){let n="",i=t;for(;i239?4:t>223?3:t>191?2:1;if(i+u>r)break;1===u?t<128&&(l=t):2===u?(s=e[i+1],128==(192&s)&&(l=(31&t)<<6|63&s,l<=127&&(l=null))):3===u?(s=e[i+1],o=e[i+2],128==(192&s)&&128==(192&o)&&(l=(15&t)<<12|(63&s)<<6|63&o,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===u&&(s=e[i+1],o=e[i+2],a=e[i+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(l=(15&t)<<18|(63&s)<<12|(63&o)<<6|63&a,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,u=1):l>65535&&(l-=65536,n+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),n+=String.fromCharCode(l),i+=u;}return n}(this.buf,t,e)}readBytes(){const e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t}readPackedVarint(e=[],t){const r=this.readPackedEnd();for(;this.pos127;);else if(2===t)this.pos=this.readVarint()+this.pos;else if(5===t)this.pos+=4;else {if(1!==t)throw new Error(`Unimplemented type: ${t}`);this.pos+=8;}}writeTag(e,t){this.writeVarint(e<<3|t);}realloc(e){let t=this.length||16;for(;t268435455||e<0?function(e,t){let r,n;if(e>=0?(r=e%4294967296|0,n=e/4294967296|0):(r=~(-e%4294967296),n=~(-e/4294967296),4294967295^r?r=r+1|0:(r=0,n=n+1|0)),e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),function(e,t,r){r.buf[r.pos++]=127&e|128,e>>>=7,r.buf[r.pos++]=127&e|128,e>>>=7,r.buf[r.pos++]=127&e|128,e>>>=7,r.buf[r.pos++]=127&e|128,r.buf[r.pos]=127&(e>>>=7);}(r,0,t),function(e,t){const r=(7&e)<<4;t.buf[t.pos++]|=r|((e>>>=3)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e)))));}(n,t);}(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))));}writeSVarint(e){this.writeVarint(e<0?2*-e-1:2*e);}writeBoolean(e){this.writeVarint(+e);}writeString(e){e=String(e),this.realloc(4*e.length),this.pos++;const t=this.pos;this.pos=function(e,t,r){for(let n,i,s=0;s55295&&n<57344){if(!i){n>56319||s+1===t.length?(e[r++]=239,e[r++]=191,e[r++]=189):i=n;continue}if(n<56320){e[r++]=239,e[r++]=191,e[r++]=189,i=n;continue}n=i-55296<<10|n-56320|65536,i=null;}else i&&(e[r++]=239,e[r++]=191,e[r++]=189,i=null);n<128?e[r++]=n:(n<2048?e[r++]=n>>6|192:(n<65536?e[r++]=n>>12|224:(e[r++]=n>>18|240,e[r++]=n>>12&63|128),e[r++]=n>>6&63|128),e[r++]=63&n|128);}return r}(this.buf,e,this.pos);const r=this.pos-t;r>=128&&Vg(t,r,this),this.pos=t-1,this.writeVarint(r),this.pos+=r;}writeFloat(e){this.realloc(4),this.dataView.setFloat32(this.pos,e,!0),this.pos+=4;}writeDouble(e){this.realloc(8),this.dataView.setFloat64(this.pos,e,!0),this.pos+=8;}writeBytes(e){const t=e.length;this.writeVarint(t),this.realloc(t);for(let r=0;r=128&&Vg(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n;}writeMessage(e,t,r){this.writeTag(e,2),this.writeRawMessage(t,r);}writePackedVarint(e,t){t.length&&this.writeMessage(e,Eg,t);}writePackedSVarint(e,t){t.length&&this.writeMessage(e,Fg,t);}writePackedBoolean(e,t){t.length&&this.writeMessage(e,Rg,t);}writePackedFloat(e,t){t.length&&this.writeMessage(e,Dg,t);}writePackedDouble(e,t){t.length&&this.writeMessage(e,Cg,t);}writePackedFixed32(e,t){t.length&&this.writeMessage(e,Lg,t);}writePackedSFixed32(e,t){t.length&&this.writeMessage(e,Og,t);}writePackedFixed64(e,t){t.length&&this.writeMessage(e,Ug,t);}writePackedSFixed64(e,t){t.length&&this.writeMessage(e,Ng,t);}writeBytesField(e,t){this.writeTag(e,2),this.writeBytes(t);}writeFixed32Field(e,t){this.writeTag(e,5),this.writeFixed32(t);}writeSFixed32Field(e,t){this.writeTag(e,5),this.writeSFixed32(t);}writeFixed64Field(e,t){this.writeTag(e,1),this.writeFixed64(t);}writeSFixed64Field(e,t){this.writeTag(e,1),this.writeSFixed64(t);}writeVarintField(e,t){this.writeTag(e,0),this.writeVarint(t);}writeSVarintField(e,t){this.writeTag(e,0),this.writeSVarint(t);}writeStringField(e,t){this.writeTag(e,2),this.writeString(t);}writeFloatField(e,t){this.writeTag(e,5),this.writeFloat(t);}writeDoubleField(e,t){this.writeTag(e,1),this.writeDouble(t);}writeBooleanField(e,t){this.writeVarintField(e,+t);}};function kg(e,t,r){return r?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function Vg(e,t,r){const n=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));r.realloc(n);for(let t=r.pos-1;t>=e;t--)r.buf[t+n]=r.buf[t];}function Eg(e,t){for(let r=0;r=0&&r>=e&&Wg[this.text.charCodeAt(r)];r--)t--;this.text=this.text.substring(e,t),this.sectionIndex=this.sectionIndex.slice(e,t);}substring(e,t){const r=new Hg;return r.text=this.text.substring(e,t),r.sectionIndex=this.sectionIndex.slice(e,t),r.sections=this.sections,r}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((e,t)=>Math.max(e,this.sections[t].scale),0)}addTextSection(e,t){this.text+=e.text,this.sections.push(Xg.forText(e.scale,e.fontStack||t));const r=this.sections.length-1;for(let t=0;t=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Zg(e,t,r,n,i,s,o,a,l,u,c,h,p,d,f,m=1,y=1){const g=Hg.fromFeature(e,i,m,y);h===qg.vertical&&g.verticalizePunctuation(p);let x=[];const v=function(e,t,r,n,i,s,o=1){if(!e)return [];const a=[],l=function(e,t,r,n,i,s,o=1){let a=0;for(let r=0;r=0;let c=0;for(let r=0;r0&&l>w&&(w=l);}else {const e=r[a.fontStack];if(!e)continue;e[y]&&(M=e[y]);const n=t[a.fontStack];if(!n)continue;const s=n.glyphs[y];if(!s)continue;if(v=s.metrics,S=8203!==y?_g:0,g){const e=void 0!==n.ascender?Math.abs(n.ascender):0,t=void 0!==n.descender?Math.abs(n.descender):0,r=(e+t)*x;_-r/2;){if(o--,o<0)return !1;a-=e[o].dist(s),s=e[o];}a+=e[o].dist(e[o+1]),o++;const l=[];let u=0;for(;an;)u-=l.shift().angleDelta;if(u>i)return !1;o++,a+=t.dist(r);}return !0}function yx(e){let t=0;for(let r=0;ru){const c=(u-l)/s,h=hr(n.x,i.x,c),p=hr(n.y,i.y,c),d=new fx(h,p,0,i.angleTo(n),r);return !o||mx(e,d,a,o,t)?d:void 0}l+=s;}}function bx(e,t,r,n,i,s,o,a,l){const u=gx(n,s,o),c=xx(n,i),h=c*o,p=0===e[0].x||e[0].x===l||0===e[0].y||e[0].y===l;return t-h=0&&g=0&&x=0&&p+u<=c){const r=new fx(g,x,0,m,t);n&&!mx(e,r,s,n,i)||d.push(r);}}h+=f;}return a||d.length||o||(d=wx(e,h/2,r,n,i,s,o,!0,l)),d}function _x(e){let t=0,r=0;for(const n of e)t+=n.w*n.h,r=Math.max(r,n.w);e.sort((e,t)=>t.h-e.h);const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),r),h:1/0}];let i=0,s=0;for(const t of e)for(let e=n.length-1;e>=0;e--){const r=n[e];if(!(t.w>r.w||t.h>r.h)){if(t.x=r.x,t.y=r.y,s=Math.max(s,t.y+t.h),i=Math.max(i,t.x+t.w),t.w===r.w&&t.h===r.h){const t=n.pop();t&&et.id?1:e.versiont.version?1:e.sxt.sx?1:e.syt.sy?1:0}function Mx(e){let t=0;for(let r=0;r0,Sx(e,r,this.iconDescriptors,i),Sx(t,r,this.patternDescriptors,i),this.iconDescriptors.sort(Ax),this.patternDescriptors.sort(Ax);let s=0;const o=n?n.data:"";o&&(s=Ix(s,Mx(o))),s=Ix(s,1);for(const e of this.iconDescriptors)s=Ix(s,Mx(e.id)),s=Ix(s,e.version),s=Ix(s,e.sx),s=Ix(s,e.sy);s=Ix(s,1);for(const e of this.patternDescriptors)s=Ix(s,Mx(e.id)),s=Ix(s,e.version),s=Ix(s,e.sx),s=Ix(s,e.sy);this.hash=s;}subsetOf(e){return this.isSubsetArray(this.iconDescriptors,e.iconDescriptors,Ax)&&this.isSubsetArray(this.patternDescriptors,e.patternDescriptors,Ax)}isSubsetArray(e,t,r){let n=0,i=0;if(e.length>t.length)return !1;for(;n{const r=e.variant.id.toString().localeCompare(t.variant.id.toString());return 0!==r?r:e.variant.sx!==t.variant.sx?e.variant.sx-t.variant.sx:e.variant.sy!==t.variant.sy?e.variant.sy-t.variant.sy:0});const n=new Map;for(const e of r)n.set(e.key,e.value);return n}class kx{constructor(e){this.sourceAtlasHash=e;}}class Vx{constructor(e,t,r,n){const i=new Map,s=new Map;this.haveRenderCallbacks=[];const o=[],a=void 0!==n,l=a?new Map:void 0,u=a?Tx(e,l):e,c=a?Tx(t,l):t;this.addImages(u,i,1,o),this.addImages(c,s,2,o);const{w:h,h:p}=_x(o),d=new Gh({width:h||1,height:p||1});for(const[e,t]of u.entries()){const r=i.get(e).paddedRect;Gh.copy(t.data,d,{x:0,y:0},{x:r.x+1,y:r.y+1},t.data,null,t.sdf);}for(const[e,t]of c.entries()){const n=s.get(e),i=n.paddedRect;let o=n.padding;const a=i.x+o,l=i.y+o,u=t.data.width,c=t.data.height;o=o>1?o-1:o,Gh.copy(t.data,d,{x:0,y:0},{x:a,y:l},t.data,r),Gh.copy(t.data,d,{x:0,y:c-o},{x:a,y:l-o},{width:u,height:o},r),Gh.copy(t.data,d,{x:0,y:0},{x:a,y:l+c},{width:u,height:o},r),Gh.copy(t.data,d,{x:u-o,y:0},{x:a-o,y:l},{width:o,height:c},r),Gh.copy(t.data,d,{x:0,y:0},{x:a+u,y:l},{width:o,height:c},r),Gh.copy(t.data,d,{x:u-o,y:c-o},{x:a-o,y:l-o},{width:o,height:o},r),Gh.copy(t.data,d,{x:0,y:c-o},{x:a+u,y:l-o},{width:o,height:o},r),Gh.copy(t.data,d,{x:0,y:0},{x:a+u,y:l+c},{width:o,height:o},r),Gh.copy(t.data,d,{x:u-o,y:0},{x:a-o,y:l+c},{width:o,height:o},r);}this.lut=r,this.image=d,this.iconPositions=i,this.patternPositions=s,a&&(this.contentDescriptor=new zx(u,c,n,r,l));}addImages(e,t,r,n){for(const[i,s]of e.entries()){const{bin:e,imagePosition:o,imageVariant:a}=Bx(i,s,r);t.set(i,o),n.push(e),s.hasRenderCallback&&this.haveRenderCallbacks.push(a.id);}}patchUpdatedImages(e,t,r,n){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(t=>e.hasImage(t,r)),e.dispatchRenderCallbacks(this.haveRenderCallbacks,r);for(const i of e.getUpdatedImages(r)){for(const n of this.iconPositions.keys()){const s=Cr.parse(n);if(nr.isEqual(s.id,i)){const s=e.getImage(i,r);this.patchUpdatedImage(this.iconPositions.get(n),s,t,null);}}for(const s of this.patternPositions.keys()){const o=Cr.parse(s);if(nr.isEqual(o.id,i)){const o=e.getImage(i,r);this.patchUpdatedImage(this.patternPositions.get(s),o,t,n||this.lut);}}}}patchUpdatedImage(e,t,r,n=null){if(!e||!t)return;if(e.version===t.version)return;e.version=t.version;const[i,s]=e.tl,o=e.sdf;if(this.lut||o){const e={width:t.data.width,height:t.data.height},a=new Gh(e);Gh.copy(t.data,a,{x:0,y:0},{x:0,y:0},e,n,o),r.update(a,{position:{x:i,y:s}});}else r.update(t.data,{position:{x:i,y:s}});}}Js(Px,"ImagePosition"),Js(Vx,"ImageAtlas",{omit:["lut"]}),Js(kx,"ImageAtlasReference");const Ex=1e20;function Fx(e,t,r,n,i,s,o,a,l){for(let u=t;u-1);l++,s[l]=a,o[l]=u,o[l+1]=Ex;}for(let a=0,l=0;a{let i=this.entries[e];i||(i=this.entries[e]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let s=i.glyphs[t];if(void 0!==s)return void r(null,{stack:e,id:t,glyph:s});if(s=this._tinySDF(i,e,t),s)return i.glyphs[t]=s,void r(null,{stack:e,id:t,glyph:s});const o=Math.floor(t/256);if(256*o>65535)return Ze("glyphs > 65535 not supported"),void r(null,{stack:e,id:t,glyph:s});if(i.ranges[o])return void r(null,{stack:e,id:t,glyph:s});let a=i.requests[o];a||(a=i.requests[o]=[],Rx.loadGlyphRange(e,o,n,this.requestManager,(e,t)=>{if(t){i.ascender=t.ascender,i.descender=t.descender;for(const e in t.glyphs)this._doesCharSupportLocalGlyph(+e)||(i.glyphs[+e]=t.glyphs[+e]);i.ranges[o]=!0;}for(const r of a)r(e,t);delete i.requests[o];})),a.push((n,i)=>{n?r(n):i&&r(null,{stack:e,id:t,glyph:i.glyphs[t]||null});});},(e,r)=>{if(e)t(e);else if(r){const e={};for(const{stack:t,id:n,glyph:i}of r)void 0===e[t]&&(e[t]={}),void 0===e[t].glyphs&&(e[t].glyphs={}),e[t].glyphs[n]=i&&{id:i.id,bitmap:i.bitmap.clone(),metrics:i.metrics},e[t].ascender=this.entries[t].ascender,e[t].descender=this.entries[t].descender;t(null,e);}});}_doesCharSupportLocalGlyph(e){return this.localGlyphMode!==Cx.none&&(this.localGlyphMode===Cx.all?!!this.localFontFamily:!!this.localFontFamily&&(xo(e)||wo(e)||lo(e)||uo(e)||ao(e)||go(e)||(t=e)>=131072&&t<=173791||(e=>e>=66736&&e<=66815)(e)));var t;}_tinySDF(e,t,r){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(r))return;let i=e.tinySDF;if(!i){let r="400";/bold/i.test(t)?r="900":/medium/i.test(t)?r="500":/light/i.test(t)&&(r="200"),i=e.tinySDF=new Rx.TinySDF({fontFamily:n,fontWeight:r,fontSize:48,buffer:6,radius:16}),i.fontWeight=r;}if(this.localGlyphs[i.fontWeight][r])return this.localGlyphs[i.fontWeight][r];const s=String.fromCodePoint(r),{data:o,width:a,height:l,glyphWidth:u,glyphHeight:c,glyphLeft:h,glyphTop:p,glyphAdvance:d}=i.draw(s);return this.localGlyphs[i.fontWeight][r]={id:r,bitmap:new jh({width:a,height:l},o),metrics:{width:u/2,height:c/2,left:h/2,top:p/2-27,advance:d/2,localGlyph:!0}}}}function Lx(e,t){return e+t[1]-t[0]}function Ox(e,t,r,n,i=1){const s=[],o=e.imagePrimary,a=o.pixelRatio,l=o.paddedRect.w-2,u=o.paddedRect.h-2,c=(e.right-e.left)*i,h=(e.bottom-e.top)*i,p=o.stretchX||[[0,l]],d=o.stretchY||[[0,u]],f=p.reduce(Lx,0),m=d.reduce(Lx,0),y=l-f,g=u-m;let x=0,v=f,b=0,w=m,_=0,A=y,M=0,I=g;if(o.content&&n){const e=o.content;x=Nx(p,0,e[0]),b=Nx(d,0,e[1]),v=Nx(p,e[0],e[2]),w=Nx(d,e[1],e[3]),_=e[0]-x,M=e[1]-b,A=e[2]-e[0]-v,I=e[3]-e[1]-w;}const S=(n,s,l,u)=>{const p=$x(n.stretch-x,v,c,e.left*i),d=qx(n.fixed-_,A,n.stretch,f),y=$x(s.stretch-b,w,h,e.top*i),g=qx(s.fixed-M,I,s.stretch,m),S=$x(l.stretch-x,v,c,e.left*i),z=qx(l.fixed-_,A,l.stretch,f),P=$x(u.stretch-b,w,h,e.top*i),B=qx(u.fixed-M,I,u.stretch,m),T=new Ie(p,y),k=new Ie(S,y),V=new Ie(S,P),E=new Ie(p,P),F=new Ie(d/a,g/a),D=new Ie(z/a,B/a),C=t*Math.PI/180;if(C){const e=Math.sin(C),t=Math.cos(C),r=[t,-e,e,t];T._matMult(r),k._matMult(r),E._matMult(r),V._matMult(r);}const R=n.stretch+n.fixed,L=l.stretch+l.fixed,O=s.stretch+s.fixed,U=u.stretch+u.fixed,N=e.imageSecondary;return {tl:T,tr:k,bl:E,br:V,texPrimary:{x:o.paddedRect.x+1+R,y:o.paddedRect.y+1+O,w:L-R,h:U-O},texSecondary:N?{x:N.paddedRect.x+1+R,y:N.paddedRect.y+1+O,w:L-R,h:U-O}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:F,pixelOffsetBR:D,minFontScaleX:A/a/c,minFontScaleY:I/a/h,isSDF:r}};if(o.stretchX||o.stretchY){const e=jx(p,y,f),t=jx(d,g,m);for(let r=0;r0?[t,-r]:n<0?[-t,r]:0===t?[r,t]:[r,-t]}(r);let d=Math.abs(t.top-t.bottom);for(const e of t.positionedLines)d-=e.lineOffset;const f=t.positionedLines.length,m=d/f;let y=t.top-r[1];for(let e=0;es)&&(s=t.x),(!e||t.y>o)&&(o=t.y);}const l=Math.min(s-n,o-i);let u=l/2;const c=new On([],Wx);if(0===l)return new Ie(n,i);for(let t=n;th.d||!h.d)&&(h=n,r&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,p)),n.max-h.d<=t||(u=n.h/2,c.push(new Yx(n.p.x-u,n.p.y-u,u,e)),c.push(new Yx(n.p.x+u,n.p.y-u,u,e)),c.push(new Yx(n.p.x-u,n.p.y+u,u,e)),c.push(new Yx(n.p.x+u,n.p.y+u,u,e)),p+=4);}return r&&(console.log(`num probes: ${p}`),console.log(`best distance: ${h.d}`)),h.p}function Wx(e,t){return t.max-e.max}Rx.loadGlyphRange=function(e,t,r,n,i){const s=256*t,o=s+255,a=n.transformRequest(n.normalizeGlyphsURL(r).replace("{fontstack}",e).replace("{range}",`${s}-${o}`),Dt.Glyphs);Ot(a,(e,t)=>{if(e)i(e);else if(t){const e={},r=function(e){return new Tg(e).readFields(jg,{})}(t);for(const t of r.glyphs)e[t.id]=t;i(null,{glyphs:e,ascender:r.ascender,descender:r.descender});}});},Rx.TinySDF=class{constructor({fontSize:e=24,buffer:t=3,radius:r=8,cutoff:n=.25,fontFamily:i="sans-serif",fontWeight:s="normal",fontStyle:o="normal",lang:a=null}={}){this.buffer=t,this.cutoff=n,this.radius=r,this.lang=a;const l=this.size=e+4*t,u=this._createCanvas(l),c=this.ctx=u.getContext("2d",{willReadFrequently:!0});c.font=`${o} ${s} ${e}px ${i}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(l*l),this.gridInner=new Float64Array(l*l),this.f=new Float64Array(l),this.z=new Float64Array(l+1),this.v=new Uint16Array(l);}_createCanvas(e){const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:r,actualBoundingBoxDescent:n,actualBoundingBoxLeft:i,actualBoundingBoxRight:s}=this.ctx.measureText(e),o=Math.ceil(r),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(s-i))),l=Math.min(this.size-this.buffer,o+Math.ceil(n)),u=a+2*this.buffer,c=l+2*this.buffer,h=Math.max(u*c,0),p=new Uint8ClampedArray(h),d={data:p,width:u,height:c,glyphWidth:a,glyphHeight:l,glyphTop:o,glyphLeft:0,glyphAdvance:t};if(0===a||0===l)return d;const{ctx:f,buffer:m,gridInner:y,gridOuter:g}=this;this.lang&&(f.lang=this.lang),f.clearRect(m,m,a,l),f.fillText(e,m,m+o);const x=f.getImageData(m,m,a,l);g.fill(Ex,0,h),y.fill(0,0,h);for(let e=0;e0?e*e:0,y[n]=e<0?e*e:0;}}Fx(g,0,0,u,c,u,this.f,this.v,this.z),Fx(y,m,m,a,l,u,this.f,this.v,this.z);for(let e=0;ee.y!=a.y>e.y&&e.x<(a.x-i.x)*(e.y-i.y)/(a.y-i.y)+i.x&&(r=!r),n=Math.min(n,Fc(e,i,a));}}return (r?1:-1)*Math.sqrt(n)}(this.p,n),this.max=this.d+this.h*Math.SQRT2;}}const Jx=Object.keys,Kx=Number.POSITIVE_INFINITY,Qx=Math.sqrt(2);function ev(e,t,r,n,i){const s=ix(e)&&e.collisionPadding?e.collisionPadding:[0,0,0,0],o={top:e.top-s[1],bottom:e.bottom+s[3],left:e.left-s[0],right:e.right+s[2],scaled:!1};return void 0!==n&&function(e,t){e.top*=t,e.bottom*=t,e.left*=t,e.right*=t,e.scaled=!0;}(o,n),r&&function(e,t){if(!t)return;const r=Be(t),n=new Ie(e.left,e.top),i=new Ie(e.right,e.top),s=new Ie(e.left,e.bottom),o=new Ie(e.right,e.bottom),a=new Ie(0,0);n._rotateAround(r,a),i._rotateAround(r,a),s._rotateAround(r,a),o._rotateAround(r,a),e.left=Math.min(n.x,i.x,s.x,o.x),e.right=Math.max(n.x,i.x,s.x,o.x),e.top=Math.min(n.y,i.y,s.y,o.y),e.bottom=Math.max(n.y,i.y,s.y,o.y);}(o,r),i&&(o.left+=i[0],o.right+=i[0],o.top+=i[1],o.bottom+=i[1]),t?{top:Math.min(t.top,o.top),bottom:Math.max(t.bottom,o.bottom),left:Math.min(t.left,o.left),right:Math.max(t.right,o.right),scaled:t.scaled||o.scaled}:o}function tv(e,[t,r]){let n=0,i=0;if(r===Kx){t<0&&(t=0);const r=t/Qx;switch(e){case "top-right":case "top-left":i=r-7;break;case "bottom-right":case "bottom-left":i=7-r;break;case "bottom":i=7-t;break;case "top":i=t-7;}switch(e){case "top-right":case "bottom-right":n=-r;break;case "top-left":case "bottom-left":n=r;break;case "left":n=t;break;case "right":n=-t;}}else {switch(t=Math.abs(t),r=Math.abs(r),e){case "top-right":case "top-left":case "top":i=r-7;break;case "bottom-right":case "bottom-left":case "bottom":i=7-r;}switch(e){case "top-right":case "bottom-right":case "right":n=-t;break;case "top-left":case "bottom-left":case "left":n=t;}}return [n,i]}function rv(e,t,r,n,i,s,o,a,l,u,c,h,p,d,f){const m=e.layers[0],y=m.appearances;if(0===y.length)return {iconBBox:null,iconVerticalBBox:null,textBBox:null,textVerticalBBox:null};const g={iconBBox:null,iconVerticalBBox:null},x={textBBox:null,textVerticalBBox:null},{baseIconRotate:v,baseTextRotate:b,iconScaleFactor:w}=function(e,t,r){const n=e.get("icon-rotate").evaluate(t,{},r),i=e.get("text-rotate").evaluate(t,{},r),[s,o]=e.get("icon-size-scale-range");return {baseIconRotate:n,baseTextRotate:i,iconScaleFactor:De(1,s,o)}}(n,i,s);t&&(g.iconBBox=ev(t,g.iconBBox,v,o),r)&&(g.iconVerticalBBox=ev(r,g.iconVerticalBBox,v+90,o));const _=_v(h.horizontal);_&&(x.textBBox=ev(_,x.textBBox,b,1,d)),h.vertical&&(x.textVerticalBBox=ev(h.vertical,x.textVerticalBBox,b+90,1,d));for(const r of y)r.hasIconProperties()&&nv(g,e,m,r,i,s,a,v,o,l,t,u,w,c,f),r.hasTextProperties()&&sv(x,m,r,i,s,d,b,p,_,h.vertical);return {iconBBox:g.iconBBox,iconVerticalBBox:g.iconVerticalBBox,textBBox:x.textBBox,textVerticalBBox:x.textVerticalBBox}}function nv(e,t,r,n,i,s,o,a,l,u,c,h,p,d,f){const{appearanceIconOffset:m,appearanceIconRotate:y,appearanceIconSize:g}=iv(n,r,i,s,o,a,l,u.iconScaleFactor);let x=null,v=null,b=null;n.hasProperty("icon-image")?b=function(e,t,r,n,i,s,o,a){let l=null;const u=t.getAppearanceValueAndResolveTokens(r,"icon-image",n,i,a);if(u){const t=e.getResolvedImageFromTokens(u),c=r.getUnevaluatedProperty("icon-size"),h=uv(t,hx(e.zoom,c,e.worldview,a),c,i,e.zoom,n,e.pixelRatio,o,e.worldview,a);l=s.get(h.iconPrimary.toString());}return l}(t,r,n,i,s,h,p,f):c&&(b=c.imagePrimary),b&&(x=sx(b,null,m,d),t.allowVerticalPlacement&&(v=sx(b,null,m,d))),x&&(e.iconBBox=ev(x,e.iconBBox,y,g)),v&&(e.iconVerticalBBox=ev(v,e.iconVerticalBBox,y+90,g));}function iv(e,t,r,n,i,s,o,a){const l=e.hasProperty("icon-offset")?t.getAppearanceValueAndResolveTokens(e,"icon-offset",r,n,[]):null,u=l&&Array.isArray(l)?l:i,c=e.hasProperty("icon-rotate")?t.getAppearanceValueAndResolveTokens(e,"icon-rotate",r,n,[]):null,h="number"==typeof c?c:s,p=e.hasProperty("icon-size")?t.getAppearanceValueAndResolveTokens(e,"icon-size",r,n,[]):null;return {appearanceIconOffset:u,appearanceIconRotate:h,appearanceIconSize:"number"==typeof p?p*a:o}}function sv(e,t,r,n,i,s,o,a,l,u){const{appearanceTextOffset:c,appearanceTextRotate:h,appearanceTextSize:p}=ov(r,t,n,i,s,o,a),d=p/a;l&&(e.textBBox=ev(l,e.textBBox,h,d,c)),u&&(e.textVerticalBBox=ev(u,e.textVerticalBBox,h+90,d,c));}function ov(e,t,r,n,i,s,o){const a=e.hasProperty("text-offset")?t.getAppearanceValueAndResolveTokens(e,"text-offset",r,n,[]):null,l=a&&Array.isArray(a)?[a[0]*_g,a[1]*_g]:i,u=e.hasProperty("text-rotate")?t.getAppearanceValueAndResolveTokens(e,"text-rotate",r,n,[]):null,c="number"==typeof u?u:s,h=e.hasProperty("text-size")?t.getAppearanceValueAndResolveTokens(e,"text-size",r,n,[]):null;return {appearanceTextOffset:l,appearanceTextRotate:c,appearanceTextSize:"number"==typeof h?h:o}}function av(e,t,r,n,i,s,o,a,l){if(!t||!t.usvg)return;const u=ux(n),c=ux(i),h="both"!==s&&"width"!==s||!ax(n)?1:c.width/u.width,p="both"!==s&&"height"!==s||!lx(n)?1:c.height/u.height;r.scaleSelf(h,p);const d=r.toString();o.set(d,r),a.set(d,t);const{imagePosition:f}=Bx(d,t,1);l.set(d,f);}function lv(e,t,r,n,i,s,o,a,l,u){if(!e)return;const c=function(e,t,r,n,i,s,o){if("camera"===e.kind)return e.maxSize;if("composite"===e.kind){const n=t.possiblyEvaluate(new Yo(e.maxZoom,{worldview:s}),r,o).evaluate(i,{},r,o),a=t.possiblyEvaluate(new Yo(e.minZoom,{worldview:s}),r,o).evaluate(i,{},r,o);return Math.max(n,a)}return t.possiblyEvaluate(new Yo(n,{worldview:s}),r,o).evaluate(i,{},r,o)}(t,r,n,i,s,l,u);return e.scaleSelf(c*a*o)}function uv(e,t,r,n,i,s,o,a,l,u){return {iconPrimary:lv(e.getPrimary(),t,r,n,i,s,o,a,l,u),iconSecondary:lv(e.getSecondary(),t,r,n,i,s,o,a,l,u)}}function cv(e,t,r){if(!t)return;const n=r.get(e.toString()),i=r.get(t.toString());n&&i&&(n.paddedRect.w===i.paddedRect.w&&n.paddedRect.h===i.paddedRect.h||Ze(`Mismatch in icon variant sizes: ${e.toString()} and ${t.toString()}`),n.usvg!==i.usvg&&Ze(`Mismatch in icon variant image types: ${e.id} and ${t.id}`));}function hv(e,t,r,n){if(!e)return;const i=t.get(r.toString());if(i&&(e.imagePrimary=i),n){const r=t.get(n.toString());e.imageSecondary=r;}}function pv(e,t){for(const r in e.horizontal)dv(e.horizontal[r],t);dv(e.vertical,t);}function dv(e,t){if(e)for(const r of e.positionedLines)for(const e of r.positionedGlyphs)if(null!==e.image){const r=e.image.toString();e.rect=t.get(r).paddedRect;}}function fv(e){switch(e){case "right":case "top-right":case "bottom-right":return "right";case "left":case "top-left":case "bottom-left":return "left"}return "center"}function mv(e,t,r,n,i,s,o,a,l){const u=_v(s.horizontal)||s.vertical,c=r.get("icon-text-fit-padding").evaluate(n,{},i);let h,p=t;return t&&"none"!==l&&(e.allowVerticalPlacement&&s.vertical&&(h=ox(t,s.vertical,l,c,a,o)),u&&(p=ox(t,u,l,c,a,o))),{defaultShapedIcon:p,verticallyShapedIcon:h}}function yv(e,t){return e*t/24}function gv(e,t,r,n,i,s,o,a,l,u,c,h,p,d,f,m,y,g,x,v,b,w,_,A){let M=o.textMaxSize.evaluate(t,{},p);void 0===M?M=a*o.textScaleFactor:M*=o.textScaleFactor;const I=e.layers[0].layout,S=yv(a,o.textScaleFactor),z=_v(r.horizontal)||r.vertical,P=e.hasAnyAppearanceProperty(["text-size","text-offset","text-rotate"]);if(("none"!==y||P)&&e.appearanceFeatureData&&e.featureToAppearanceIndex[t.index]18&&R>2&&(R>>=1),Math.max(Un/(512*R),1)*I.get("symbol-spacing")),V=I.get("text-padding")*e.tilePixelRatio,E=I.get("icon-padding")*e.tilePixelRatio,F=Be(I.get("text-max-angle")),D="map"===I.get("icon-rotation-alignment")&&"point"!==v,C=k/2;var R;!1===e.hasAnyIconTextFit&&"none"!==y&&(e.hasAnyIconTextFit=!0);const L=t.properties?+t.properties[ic]:null,O=L&&e.elevationFeatureIdToIndex?e.elevationFeatureIdToIndex.get(L):65535,U=(a,l,v)=>{if(l.x<0||l.x>=Un||l.y<0||l.y>=Un)return;let A=null;if(B){const{x:e,y:t,z:r}=d.projectTilePoint(l.x,l.y,v);A={anchor:new fx(e,t,r,0,void 0),up:d.upVector(v,l.x,l.y)};}!function(e,t,r,n,i,s,o,a,l,u,c,h,p,d,f,m,y,g,x,v,b,w,_,A,M,I,S,z,P,B,T,k){const V=e.addToLineVertexArray(t,n);let E,F,D,C,R,L,O,U=0,N=0,j=0,G=0,$=-1,q=-1;const X={};let H=Jt("");const Z=r?r.anchor:t,W="none"!==z;let Y=0,J=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")){const e=l.layout.get("text-offset").evaluate(b,{},M);Y=e[0]*_g,J=e[1]*_g;}else Y=l.layout.get("text-radial-offset").evaluate(b,{},M)*_g,J=Kx;if(e.allowVerticalPlacement&&i.vertical){const e=i.vertical;if(f)L=Mv(e),a&&(O=Mv(a));else {const r=l.layout.get("text-rotate").evaluate(b,{},M)+90;D=Av(u,Z,t,c,h,p,e,d,r,m,k),a&&(C=Av(u,Z,t,c,h,p,a,g,r,null,T));}}if(s){const n=l.layout.get("icon-rotate").evaluate(b,{},M),i=Ox(s,n,_,W,w.iconScaleFactor),o=a?Ox(a,n,_,W,w.iconScaleFactor):void 0;F=Av(u,Z,t,c,h,p,s,g,n,null,B);const d=function(e,t,r,n,i,s,o,a,l,u){const c=e.layers[0],h=c.appearances;let p=t.length;if(r&&(p=Math.max(p,r.length)),0===h.length)return p;const[d,f]=n.get("icon-size-scale-range"),m=De(1,d,f);for(const t of h){const r=t.getUnevaluatedProperties();if(void 0!==r._values["icon-image"].value){const n=c.getAppearanceValueAndResolveTokens(t,"icon-image",s,o,u);if(n){const l=e.getResolvedImageFromTokens(n);if(l){const n=t.hasProperty("icon-size")?r._values["icon-size"]:i._values["icon-size"],c=uv(l,hx(e.zoom,n,e.worldview,u),n,o,e.zoom,s,e.pixelRatio,m,e.worldview,u),h=a.get(c.iconPrimary.toString());h&&(p=Math.max(p,Ux(h)));}}}}return p}(e,i,o,l.layout,l._unevaluatedLayout,b,M,e.iconAtlasPositions,0,A);U=4*d;const f=l.layout.get("icon-size").evaluate(b,{},M,A),m=w.compositeIconSizes?w.compositeIconSizes[0].evaluate(b,{},M,A):0,y=w.compositeIconSizes?w.compositeIconSizes[1].evaluate(b,{},M,A):0,z=wv(e.layerIds[0],e.iconSizeData,f,w.iconScaleFactor,m,y);e.addSymbols(e.icon,i,z,v,x,b,void 0,r,t,V.lineStartIndex,V.lineLength,-1,A,M,I,S,e.symbolInstances.length,d),$=e.icon.placedSymbolArray.length-1,o&&(N=4*d,e.addSymbols(e.icon,o,z,v,x,b,qg.vertical,r,t,V.lineStartIndex,V.lineLength,-1,A,M,I,S,e.symbolInstances.length,d),q=e.icon.placedSymbolArray.length-1);}for(const n in i.horizontal){const s=n,a=i.horizontal[s];E||(H=Jt(a.text),f?R=Mv(a):E=Av(u,Z,t,c,h,p,a,d,l.layout.get("text-rotate").evaluate(b,{},M),m,k));const y=1===a.positionedLines.length;if(j+=bv(e,r,t,a,o,l,f,b,m,V,i.vertical?qg.horizontal:qg.horizontalOnly,y?Jx(i.horizontal):[s],X,$,w,A,M,e.symbolInstances.length,I),y)break}i.vertical&&(G+=bv(e,r,t,i.vertical,o,l,f,b,m,V,qg.vertical,["vertical"],X,q,w,A,M,e.symbolInstances.length,I));let K=-1;const Q=(e,t)=>e?Math.max(e,t):t;K=Q(R,K),K=Q(L,K),K=Q(O,K);const ee=K>-1?1:0;e.glyphOffsetArray.length>=65535&&Ze("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==b.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,b.sortKey),e.symbolInstances.emplaceBack(t.x,t.y,Z.x,Z.y,Z.z,X.right>=0?X.right:-1,X.center>=0?X.center:-1,X.left>=0?X.left:-1,X.vertical>=0?X.vertical:-1,$,q,H,void 0!==E?E:e.collisionBoxArray.length,void 0!==E?E+1:e.collisionBoxArray.length,void 0!==D?D:e.collisionBoxArray.length,void 0!==D?D+1:e.collisionBoxArray.length,void 0!==F?F:e.collisionBoxArray.length,void 0!==F?F+1:e.collisionBoxArray.length,C||e.collisionBoxArray.length,C?C+1:e.collisionBoxArray.length,c,j,G,U,N,ee,0,Y,J,K,0,W?1:0,P);}(e,l,A,a,r,n,s,i,e.layers[0],e.collisionBoxArray,t.index,t.sourceLayerIndex,e.index,V,x,u,0,E,D,g,t,o,c,h,p,f,m,y,O,b,w,_);};if("line"===v)for(const i of Tf(t.geometry,0,0,Un,Un)){const t=bx(i,k,F,r.vertical||z,n,24,T,e.overscaling,Un);for(const r of t)z&&Iv(e,z.text,C,r)||U(i,r,p);}else if("line-center"===v){for(const e of t.geometry)if(e.length>1){const t=vx(e,F,r.vertical||z,n,24,T);t&&U(e,t,p);}}else if("Polygon"===t.type)for(const e of _p(t.geometry,0)){const t=Zx(e,16);U(e[0],new fx(t.x,t.y,0,0,void 0),p);}else if("LineString"===t.type)for(const e of t.geometry)U(e,new fx(e[0].x,e[0].y,0,0,void 0),p);else if("Point"===t.type)for(const e of t.geometry)for(const t of e)U([t],new fx(t.x,t.y,0,0,void 0),p);}const xv=255,vv=xv*cx;function bv(e,t,r,n,i,s,o,a,l,u,c,h,p,d,f,m,y,g,x){const v=Hx(0,n,l,s,o,a,i,e.allowVerticalPlacement,void 0,f.textScaleFactor),b=s.layout.get("text-size").evaluate(a,{},y),w=f.compositeTextSizes?f.compositeTextSizes[0].evaluate(a,{},y):0,_=f.compositeTextSizes?f.compositeTextSizes[1].evaluate(a,{},y):0,A=wv(e.layerIds[0],e.textSizeData,b,f.textScaleFactor,w,_);e.addSymbols(e.text,v,A,l,o,a,c,t,r,u.lineStartIndex,u.lineLength,d,m,y,x,!1,g,v.length);for(const t of h)p[t]=e.text.placedSymbolArray.length-1;return 4*v.length}function wv(e,t,r,n,i,s){const o=t;let a=null;return "source"===o.kind?(a=[cx*r*n],a[0]>vv&&Ze(`${e}: Value for "text-size" is >= ${xv}. Reduce your "text-size".`)):"composite"===o.kind&&(a=[cx*i*n,cx*s*n],(a[0]>vv||a[1]>vv)&&Ze(`${e}: Value for "text-size" is >= ${xv}. Reduce your "text-size".`)),a}function _v(e){for(const t in e)return e[t];return null}function Av(e,t,r,n,i,s,o,a,l,u,c){let h,p,d,f;if(h=c?c.top:o.top,p=c?c.bottom:o.bottom,d=c?c.left:o.left,f=c?c.right:o.right,ix(o)&&o.collisionPadding){const e=o.collisionPadding;d-=e[0],h-=e[1],f+=e[2],p+=e[3];}if(l){const e=new Ie(d,h),t=new Ie(f,h),r=new Ie(d,p),n=new Ie(f,p),i=Be(l);let s=new Ie(0,0);u&&(s=new Ie(u[0],u[1])),e._rotateAround(i,s),t._rotateAround(i,s),r._rotateAround(i,s),n._rotateAround(i,s),d=Math.min(e.x,t.x,r.x,n.x),f=Math.max(e.x,t.x,r.x,n.x),h=Math.min(e.y,t.y,r.y,n.y),p=Math.max(e.y,t.y,r.y,n.y);}return e.emplaceBack(t.x,t.y,t.z,r.x,r.y,d,h,f,p,a,n,i,s),e.length-1}function Mv(e){ix(e)&&e.collisionPadding&&(e.top-=e.collisionPadding[1],e.bottom+=e.collisionPadding[3]);const t=e.bottom-e.top;return t>0?Math.max(10,t):null}function Iv(e,t,r,n){const i=e.compareText;if(t in i){const e=i[t];for(let t=e.length-1;t>=0;t--)if(n.dist(e[t])v&&(b(e,u,n,i,a,l),b(u,r,a,l,s,o));}b(h,p,n,s,i,s),b(p,d,i,s,i,o),b(d,f,i,o,n,o),b(f,h,n,o,n,s),m-=v,y-=v,g+=v,x+=v;const w=1/Math.max(g-m,x-y);return {scale:w,x:m*w,y:y*w,x2:g*w,y2:x*w,projection:t}}function Pv(e,{x:t,y:r},n=0){return new Ie(((t-n)*e.scale-e.x)*Un,(r*e.scale-e.y)*Un)}const Bv=u(new Float32Array(16));class Tv{constructor(e){this.spec=e,this.name=e.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7];}project(e,t){return {x:0,y:0,z:0}}unproject(e,t){return new zu(0,0)}projectTilePoint(e,t,r){return {x:e,y:t,z:0}}locationPoint(e,t,r,n=!0){return e._coordinatePoint(e.locationCoordinate(t,r),n)}pixelsPerMeter(e,t){return Vu(1,e)*t}pixelSpaceConversion(e,t,r){return 1}farthestPixelDistance(e){return Sv(e,e.pixelsPerMeter)}pointCoordinate(e,t,r,n){const i=e.horizonLineFromTop(!1),s=new Ie(t,Math.max(i,r));return e.rayIntersectionCoordinate(e.pointRayIntersection(s,n))}pointCoordinate3D(e,t,r){const n=new Ie(t,r);if(e.elevation)return e.elevation.pointCoordinate(n);{const t=this.pointCoordinate(e,n.x,n.y,0);return [t.x,t.y,t.z]}}isPointAboveHorizon(e,t){if(e.elevation&&e.elevation.visibleDemTiles.length)return !this.pointCoordinate3D(e,t.x,t.y);const r=e.horizonLineFromTop();return t.y0?t<-Ov+r&&(t=-Ov+r):t>Ov-r&&(t=Ov-r);const s=i/Math.pow(Uv(t),n);let o=s*Math.sin(n*e),a=i-s*Math.cos(n*e);return o=.5*(o/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:o,y:this.southernCenter?a:1-a,z:0}}unproject(e,t){e=(2*e-.5)*Math.PI,this.southernCenter&&(t=1-t),t=(2*(1-t)-.5)*Math.PI;const{n:r,f:n}=this,i=n-t,s=Math.sign(i),o=Math.sign(r)*Math.sqrt(e*e+i*i);let a=Math.atan2(e,Math.abs(i))*s;i*r<0&&(a-=Math.PI*Math.sign(e)*s);const l=De(Te(a/r)+this.center[0],-180,180),u=De(Te(2*Math.atan(Math.pow(n/o,1/r))-Ov),-85.051129,Cu);return new zu(l,this.southernCenter?-u:u)}}class jv extends Tv{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null;}project(e,t){return {x:Tu(e),y:ku(t),z:0}}unproject(e,t){const r=Eu(e),n=Fu(t);return new zu(r,n)}}const Gv=Be(Cu);class $v extends Tv{project(e,t){const r=(t=Be(t))*t,n=r*r;return {x:.5*((e=Be(e))*(.8707-.131979*r+n*(n*(.003971*r-.001529*n)-.013791))/Math.PI+.5),y:1-.5*(t*(1.007226+r*(.015085+n*(.028874*r-.044475-.005916*n)))/Math.PI+1),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI;let r=t=(2*(1-t)-1)*Math.PI,n=25,i=0,s=r*r;do{s=r*r;const e=s*s;i=(r*(1.007226+s*(.015085+e*(.028874*s-.044475-.005916*e)))-t)/(1.007226+s*(.045255+e*(.259866*s-.311325-.005916*11*e))),r=De(r-i,-Gv,Gv);}while(Math.abs(i)>1e-6&&--n>0);s=r*r;const o=De(Te(e/(.8707+s*(s*(s*s*s*(.003971-.001529*s)-.013791)-.131979))),-180,180),a=Te(r);return new zu(o,a)}}const qv=Be(Cu);class Xv extends Tv{project(e,t){t=Be(t),e=Be(e);const r=Math.cos(t),n=2/Math.PI,i=Math.acos(r*Math.cos(e/2)),s=Math.sin(i)/i,o=.5*(e*n+2*r*Math.sin(e/2)/s)||0,a=.5*(t+Math.sin(t)/s)||0;return {x:.5*(o/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(e,t){let r=e=(2*e-.5)*Math.PI,n=t=(2*(1-t)-1)*Math.PI,i=25;const s=1e-6;let o=0,a=0;do{const i=Math.cos(n),s=Math.sin(n),l=2*s*i,u=s*s,c=i*i,h=Math.cos(r/2),p=Math.sin(r/2),d=2*h*p,f=p*p,m=1-c*h*h,y=m?1/m:0,g=m?Math.acos(i*h)*Math.sqrt(1/m):0,x=.5*(2*g*i*p+2*r/Math.PI)-e,v=.5*(g*s+n)-t,b=.5*y*(c*f+g*i*h*u)+1/Math.PI,w=y*(d*l/4-g*s*p),_=.125*y*(l*p-g*s*c*d),A=.5*y*(u*h+g*f*i)+.5,M=w*_-A*b;o=(v*w-x*A)/M,a=(x*_-v*b)/M,r=De(r-o,-Math.PI,Math.PI),n=De(n-a,-qv,qv);}while((Math.abs(o)>s||Math.abs(a)>s)&&--i>0);return new zu(Te(r),Te(n))}}class Hv extends Tv{constructor(e){super(e),this.center=e.center||[0,0],this.parallels=e.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Be(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0;}project(e,t){const{scale:r,cosPhi:n}=this;return {x:Be(e)*n*r+.5,y:-Math.sin(Be(t))/n*r+.5,z:0}}unproject(e,t){const{scale:r,cosPhi:n}=this,i=-(t-.5)/r,s=De(Te((e-.5)/r)/n,-180,180),o=Math.asin(De(i*n,-1,1)),a=De(Te(o),-85.051129,Cu);return new zu(s,a)}}class Zv extends jv{constructor(e){super(e),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5];}projectTilePoint(e,t,r){const n=dh(e,t,r);return j(n,n,yh(ah(r))),{x:n[0],y:n[1],z:n[2]}}locationPoint(e,t,r){const n=Mu(t.lat,t.lng),i=L([],n),s=r?e._centerAltitude+r:e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(t),e._centerAltitude):e._centerAltitude;E(n,n,i,Vu(1,0)*Un*s);const o=u(new Float64Array(16));return h(o,e.pixelMatrix,e.globeMatrix),j(n,n,o),new Ie(n[0],n[1])}pixelsPerMeter(e,t){return Vu(1,0)*t}pixelSpaceConversion(e,t,r){const n=Vu(1,e)*t,i=hr(Vu(1,45)*t,n,r);return this.pixelsPerMeter(e,t)/i}createTileMatrix(e,t,r){const n=gh(ah(r.canonical));return h(new Float64Array(16),e.globeMatrix,n)}createInversionMatrix(e,t){const{center:r}=e,n=yh(ah(t));return m(n,n,Be(r.lng)),f(n,n,Be(r.lat)),d(n,n,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(n)}pointCoordinate(e,t,r,n){return ih(e,t,r,!0)||new Nu(0,0)}pointCoordinate3D(e,t,r){const n=this.pointCoordinate(e,t,r,0);return [n.x,n.y,n.z]}isPointAboveHorizon(e,t){return !ih(e,t.x,t.y,!1)}farthestPixelDistance(e){const t=function(e,t){const r=e.cameraToCenterDistance,n=e._centerAltitude*t,i=e._camera,s=e._camera.forward(),o=z([],V([],s,-r),[0,0,n]),a=e.worldSize/(2*Math.PI),l=[0,0,-a],u=e.width/e.height,c=Math.tan(e.fovAboveCenter),h=V([],i.up(),c),p=V([],i.right(),c*u),d=L([],z([],z([],s,h),p)),f=[];let m;if(new pc(o,d).closestPointOnSphere(l,a,f)){const t=z([],f,l),r=H([],t,o);m=Math.cos(e.fovAboveCenter)*M(r);}else {const e=H([],o,l),t=H([],l,o);L(t,t);const r=M(e)-a;m=Math.sqrt(r*(r+2*a));const n=Math.acos(m/(a+r))-Math.acos(O(s,t));m*=Math.cos(n);}return 1.01*m}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),r=wh(e.zoom);if(r>0){const n=Sv(e,Vu(1,e.center.lat)*e.worldSize),i=e.worldSize/(2*Math.PI),s=Math.max(e.width,e.height)/e.worldSize*Math.PI;return hr(t,n+i*(1-Math.cos(s)),Math.pow(r,10))}return t}upVector(e,t,r){return dh(t,r,e,1)}upVectorScale(e){return {metersToTile:rh(fh(ah(e)))}}}function Wv(e){const t=e.parallels,r=!!t&&Math.abs(t[0]+t[1])<.01;switch(e.name){case "mercator":return new jv(e);case "equirectangular":return new Lv(e);case "naturalEarth":return new $v(e);case "equalEarth":return new Rv(e);case "winkelTripel":return new Xv(e);case "albers":return r?new Hv(e):new kv(e);case "lambertConformalConic":return r?new Hv(e):new Nv(e);case "globe":return new Zv(e)}throw new Error(`Invalid projection name: ${e.name}`)}const Yv=Ju.types,Jv=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function Kv(e,t,r,n,i,s,o,a,l,u,c,h,p){const d=a?Math.min(vv,Math.round(a[0])):0,f=a?Math.min(vv,Math.round(a[1])):0;e.emplaceBack(t,r,Math.round(32*n),Math.round(32*i),s,o,(d<<1)+(l?1:0),0+(f<<1),16*u,16*c,256*h,256*p);}function Qv(e,t,r){e.emplaceBack(t,r);}function eb(e,t,r,n,i,s,o){e.emplaceBack(t,r,n,i,s,o);}const tb=(e,t,r,n)=>{for(let i=0;i0&&(this.iconTransitioningVertexBuffer=e.createVertexBuffer(this.iconTransitioningVertexArray,gg.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,dg.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||i)&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,mg.members,!0)),!this.orientationVertexBuffer&&this.orientationVertexArray&&this.orientationVertexArray.length>0&&(this.orientationVertexBuffer=e.createVertexBuffer(this.orientationVertexArray,yg.members,!0)),this.opacityVertexBuffer.itemSize=1),(r||n)&&this.programConfigurations.upload(e));}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.orientationVertexBuffer&&this.orientationVertexBuffer.destroy());}}Js(ib,"SymbolBuffers");class sb{constructor(e,t,r){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new r,this.segments=new Rl,this.collisionVertexArray=new sl,this.collisionVertexArrayExt=new Qa;}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,xg.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,vg.members,!0);}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy());}}Js(sb,"CollisionBuffers");class ob{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.fqid),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=u([]),this.placementViewportMatrix=u([]);const t=this.layers[0]._unevaluatedLayout._values;this.worldview=e.worldview,this.localizable=e.localizable,this.textSizeData=hx(this.zoom,t["text-size"],this.worldview,e.availableImages),this.iconSizeData=hx(this.zoom,t["icon-size"],this.worldview,e.availableImages);const r=this.layers[0].layout,n=r.get("symbol-sort-key"),i=r.get("symbol-z-order");this.lut=e.lut,this.canOverlap=r.get("text-allow-overlap")||r.get("icon-allow-overlap")||r.get("text-ignore-placement")||r.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==i&&void 0!==n.constantOr(1),this.sortFeaturesByY=("viewport-y"===i||"auto"===i&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=r.get("text-writing-mode").map(e=>qg[e]),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.sourceID=e.sourceID,this.projection=e.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=!1,this.elevationType="none",this.elevationStateComplete=!1,this.activeReplacements=[],this.replacementUpdateTime=0,this.hasAnySecondaryIcon=!1,this.hasAppearances=null,this.lastActiveApperance=null,this.featureToAppearanceIndex={};}hasAnyAppearanceProperty(e){const t=this.layers[0].getAppearances();if(!t||0===t.length)return !1;const r=Array.isArray(e)?e:[e];return t.some(e=>r.some(t=>null!=e.getProperty(t)))}createArrays(){this.text=new ib(new pu(this.layers,{zoom:this.zoom,lut:this.lut},e=>e.startsWith("text")||e.startsWith("symbol"))),this.icon=new ib(new pu(this.layers,{zoom:this.zoom,lut:this.lut},e=>e.startsWith("icon")||e.startsWith("symbol"))),this.glyphOffsetArray=new zl,this.lineVertexArray=new Pl,this.symbolInstances=new Sl;}calculateGlyphDependencies(e,t,r,n,i){for(const r of e){const e=r.codePointAt(0);if(void 0===e)break;if(t[e]=!0,n&&i&&e<=65535){const e=Mg[r];e&&(t[e.charCodeAt(0)]=!0);}}}calculateEffectiveAppearanceIconSize(e,t,r,n,i,s,o){if(!e.hasProperty("icon-size"))return o*s;let a=1;const l=e.getUnevaluatedProperties()._values["icon-size"],u=hx(this.zoom,l,this.worldview,i),c=dx(u,t);if("constant"!==u.kind&&"camera"!==u.kind||(a=c.uSize),"composite"===u.kind){const{minZoom:e,maxZoom:t}=u,s=l.possiblyEvaluate(new Yo(e,{worldview:this.worldview}),n),o=l.possiblyEvaluate(new Yo(t,{worldview:this.worldview}),n),h=s.evaluate(r,{},n,i);a=h+(o.evaluate(r,{},n,i)-h)*c.uSizeT;}return "source"===u.kind&&(a=l.possiblyEvaluate(new Yo(this.zoom,{worldview:this.worldview}),n).evaluate(r,{},n,i)),a*s}updateFootprints(e,t){}updateReplacement(e,t){if(t.updateTime===this.replacementUpdateTime)return !1;this.replacementUpdateTime=t.updateTime;const r=t.getReplacementRegionsForTile(e.toUnwrapped(),!0);return !Ld(this.activeReplacements,r)&&(this.activeReplacements=r,!0)}getResolvedImageFromTokens(e){return "string"==typeof e?Rr.build(e):e}populate(e,t,r,n){const i=this.layers[0],s=i.layout,o="globe"===this.projection.name,a=s.get("text-font"),l=s.get("text-field"),u=s.get("icon-image"),[c,h]=s.get("icon-size-scale-range"),p=De(t.scaleFactor||1,c,h),[d,f]=s.get("text-size-scale-range"),m=De(t.scaleFactor||1,d,f),y=("constant"!==l.value.kind||l.value.value instanceof Dr&&!l.value.value.isEmpty()||l.value.value.toString().length>0)&&("constant"!==a.value.kind||a.value.value.length>0),g="constant"!==u.value.kind||!!u.value.value||Object.keys(u.parameters).length>0,x=this.hasAnyAppearanceProperty("icon-image"),v=s.get("symbol-sort-key");if(this.features=[],this.appearanceFeatureData=[],!y&&!g&&!x)return;const b=t.iconDependencies,w=t.glyphDependencies,_=t.availableImages,A=new Yo(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),M=e=>{const t=e.id.toString();b.has(t)?b.get(t).push(e):b.set(t,[e]);};for(const t of e){const{feature:e,id:l,index:u,sourceLayerIndex:c}=t,h=i._featureFilter.needGeometry,d=Yu(e,h);if(!i._featureFilter.filter(A,d,r))continue;if(h||(d.geometry=Wu(e,r,n)),o&&1!==e.type&&r.z<=5){const e=d.geometry,t=.98078528056,n=(e,n)=>O(dh(e.x,e.y,r,1),dh(n.x,n.y,r,1)){if(!e.getProperty("icon-image"))return;const t=this.getCombinedIconPrimary(e,S,d,r,_,B,p);t&&M(t);}),f){const e=a.evaluate(d,{},r).join(","),t="map"===s.get("text-rotation-alignment")&&"point"!==s.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(qg.vertical)>=0;for(const r of f.sections)if(r.image){const e=r.image.getPrimary().scaleSelf(this.pixelRatio*m),t=e.id.toString(),n=b.get(t)||[];n.push(e),b.set(t,n);}else {const n=Bo(f.toString()),i=r.fontStack||e,s=w[i]=w[i]||{};this.calculateGlyphDependencies(r.text,s,t,this.allowVerticalPlacement,n);}}}if("line"===s.get("symbol-placement")&&(this.features=function(e){const t={},r={},n=[];let i=0;function s(t){n.push(e[t]),i++;}function o(e,t,i){const s=r[e];return delete r[e],r[t]=s,n[s].geometry[0].pop(),n[s].geometry[0]=n[s].geometry[0].concat(i[0]),s}function a(e,r,i){const s=t[r];return delete t[r],t[e]=s,n[s].geometry[0].shift(),n[s].geometry[0]=i[0].concat(n[s].geometry[0]),s}function l(e,t,r){const n=r?t[0][t[0].length-1]:t[0][0];return `${e}:${n.x}:${n.y}`}for(let u=0;ue.geometry)}(this.features)),"hd-road-markup"===s.get("symbol-elevation-reference")){if(this.elevationType="road",t.elevationFeatures){!this.elevationFeatures&&t.elevationFeatures.length>0&&(this.elevationFeatures=[],this.elevationFeatureIdToIndex=new Map);for(const e of t.elevationFeatures)this.elevationFeatureIdToIndex.set(e.id,this.elevationFeatures.length),this.elevationFeatures.push(e);}}else s.get("symbol-z-elevate")&&(this.elevationType="offset");"none"!==this.elevationType&&(this.zOffsetBuffersNeedUpload=!0),this.sortFeaturesByKey&&this.features.sort((e,t)=>e.sortKey-t.sortKey);}getCombinedIconPrimary(e,t,r,n,i,s,o){let a,l;const u=e.getUnevaluatedProperties();if(void 0!==u._values["icon-image"].value){const s=t.getAppearanceValueAndResolveTokens(e,"icon-image",r,n,i);a=this.getResolvedImageFromTokens(s);}else {const e=t.getValueAndResolveTokens("icon-image",r,n,i);a=this.getResolvedImageFromTokens(e);}if(a){const r=e.hasProperty("icon-size")?u._values["icon-size"]:t._unevaluatedLayout._values["icon-size"];l=uv(a,hx(this.zoom,r,this.worldview,i),r,n,this.zoom,s,this.pixelRatio,o,this.worldview,i).iconPrimary;}return l}updateSymbolInstanceIconVertices(e,t,r,n,i,s,o,a,l,u,c,h,p,d){if(e.placedIconSymbolIndex<0)return {vertexOffsetDelta:0,hasChanges:!1};if(t.activeAppearance===r)return {vertexOffsetDelta:e.numIconVertices,hasChanges:!1};if(r){const f=this.getCombinedIconPrimary(r,l,n,s,o,{sortKey:void 0,text:void 0,icon:null,index:e.featureIndex,sourceLayerIndex:e.featureIndex,geometry:[],properties:t.properties,type:"Point",id:t.id},u);if(!f)return {vertexOffsetDelta:0,hasChanges:!1};const m=f.toString(),y=this.iconAtlasPositions&&this.iconAtlasPositions.get(m);if(y){const{appearanceIconOffset:f,appearanceIconRotate:m}=iv(r,l,n,s,h,d,p,u);let g=sx(y,void 0,f,l.layout.get("icon-anchor").evaluate(n,c,s));const x=y.sdf,v=l.layout.get("icon-text-fit").constantOr("none");"none"!==v&&t.textShaping&&t.iconTextFitPadding&&t.fontScale&&(g=ox(g,t.textShaping,v,t.iconTextFitPadding,f,t.fontScale));const b=this.calculateEffectiveAppearanceIconSize(r,a.zoom,n,s,o,u,p),w=0,_=1+(Math.min(vv,Math.round(b*cx))<<1),A=Ox(g,m,x,"none"!==v,u);t.isUsingAppearanceIconVertexData||(t.isUsingAppearanceIconVertexData=!0,t.layoutBasedIconVertexData=this.icon.getSymbolVertexData(i,e.numIconVertices));let M=i;for(let r=0;r0)return this.icon.updateSymbolVertexData(i,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateSymbolVertexData(i+1,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateSymbolVertexData(i+2,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateSymbolVertexData(i+3,0,0,0,0,0,0,0,0,0,0,0,0),{vertexOffsetDelta:e.numIconVertices,hasChanges:!0}}else if(t.isUsingAppearanceIconVertexData){const e=12,r=t.layoutBasedIconVertexData.length/e;for(let n=0;n0||e.numVerticalGlyphVertices>0;if(!x)return {vertexOffsetDelta:x?e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices:0,hasChanges:!1};if(t.activeAppearance===r)return {vertexOffsetDelta:e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices,hasChanges:!1};if(r&&t.textShaping){const{appearanceTextOffset:x,appearanceTextRotate:v,appearanceTextSize:b}=ov(r,o,n,s,c,p,h);t.fontScale=yv(b,t.textScaleFactor);const w=r.getUnevaluatedProperty("text-size");let _=this.textSizeData,A=m,M=y;r.hasProperty("text-size")&&(_=hx(this.zoom,w,this.worldview,g),A="composite"===this.textSizeData.kind?this.textSizeData.minZoom:0,M="composite"===this.textSizeData.kind?this.textSizeData.maxZoom:0);const I=t.textShaping.bottom-c[1],S=t.textShaping.left-c[0],z=t.textShaping.right-c[0];t.textShaping.top=x[1]+(t.textShaping.top-c[1]),t.textShaping.bottom=x[1]+I,t.textShaping.left=x[0]+S,t.textShaping.right=x[0]+z;const P=Hx(0,t.textShaping,x,o,!1,n,l,this.allowVerticalPlacement,v),B=b&&"composite"===_.kind?w.possiblyEvaluate(new Yo(A,{}),s).evaluate(n,u,s):d,T=b&&"composite"===_.kind?w.possiblyEvaluate(new Yo(M,{}),s).evaluate(n,u,s):f,k=wv(r.name,_,b,a,B,T),V=Array.isArray(k)?k[1]:b,E=0,F=1+(Math.min(vv,Math.round(V*cx))<<1);t.isUsingAppearanceTextVertexData||(t.isUsingAppearanceTextVertexData=!0,t.layoutBasedTextVertexData=this.text.getSymbolVertexData(i,e.numHorizontalGlyphVertices+e.numVerticalGlyphVertices));for(let t=0;t0||c>0,f=h>0,m=this.elevationFeatures[o.elevationFeatureIndex];if(m){const e=new Ie(o.tileAnchorX,o.tileAnchorY),u=.075+m.pointElevation(e);o.zOffset!==u&&(t=!0,o.zOffset=u),0!==u&&(this.hasAnyZOffset=!0);const c=m.computeSlopeNormal(e,n),h=ue(te(),I(0,0,1),c);$(a,a,h),$(l,l,h),a[2]*=r,l[2]*=r,1===a[0]&&0===a[1]&&0===a[2]&&0===l[0]&&1===l[1]&&0===l[2]||(i=i||d,s=s||f);}if(d&&(tb(this.text.orientationVertexArray,u,a,l),tb(this.text.orientationVertexArray,c,a,l)),f){const{placedIconSymbolIndex:e,verticalPlacedIconSymbolIndex:t}=o;e>=0&&tb(this.icon.orientationVertexArray,h,a,l),t>=0&&tb(this.icon.orientationVertexArray,p,a,l);}}i||(this.text.orientationVertexArray=void 0),s||(this.icon.orientationVertexArray=void 0),t&&(this.zOffsetBuffersNeedUpload=!0,this.zOffsetSortDirty=!0);}updateZOffset(){const e=(e,t,n)=>{r+=t,r>e.length&&e.resize(r);for(let i=-t;i<0;i++)e.emplace(i+r,n);},t=(e,t,r)=>{n+=t,n>e.length&&e.resize(n);for(let i=-t;i<0;i++)e.emplace(i+n,r);};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let r=0,n=0;for(let r=0;r0;if((i>0||s>0)&&(e(this.text.zOffsetVertexArray,i,a),e(this.text.zOffsetVertexArray,s,a)),l){const{placedIconSymbolIndex:e,verticalPlacedIconSymbolIndex:r}=n;e>=0&&t(this.icon.zOffsetVertexArray,o,a),r>=0&&t(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,a);}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray);}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return !this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e,t,r,n,i){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload,this.hasAppearances),null===this.hasAppearances&&(this.hasAppearances=this.layers.some(e=>e.appearances&&e.appearances.length>0)),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload,this.hasAppearances),this.uploaded=!0;}updateAppearances(e,t,r,n,i){if(!(e&&t&&r&&this.appearanceFeatureData))return !1;const s=this.icon.layoutVertexArray&&this.icon.layoutVertexArray.length>0&&this.icon.layoutVertexArray.arrayBuffer,o=this.text.layoutVertexArray&&this.text.layoutVertexArray.length>0&&this.text.layoutVertexArray.arrayBuffer;if(!s&&!o)return !1;const a=this.layers[0],l=a.layout;let u=1,c=0,h=!1;if(s){const[e,t]=l.get("icon-size-scale-range");u=De(1,e,t);}let p=1,d=0,f=!1;if(o){const[e,t]=l.get("text-size-scale-range");p=De(1,e,t);}const m=new Map;if(i&&r)for(const e of r){const t=i.getImage(e,a.scope);if(t){const r=new Cr(e.toString());m.set(r.toString(),t);}}for(let i=0;it.isActive({globals:n,feature:w,canonical:e,featureState:b}));if(o){const t=l.get("text-size"),n=l.get("text-offset").evaluate(w,b,e),i=t.evaluate(w,b,e),s=l.get("text-rotate").evaluate(w,b,e),o="composite"===this.textSizeData.kind?this.textSizeData.minZoom:0,u="composite"===this.textSizeData.kind?this.textSizeData.maxZoom:0,c=t.evaluate(w,{zoom:o},e),h=t.evaluate(w,{zoom:u},e),g=this.updateSymbolInstanceTextVertices(y,x,_,w,d,e,a,p,m,b,n,i,s,c,h,o,u,r);d+=g.vertexOffsetDelta,f=f||g.hasChanges;}if(s){const t=l.get("icon-offset").evaluate(w,b,e),i=l.get("icon-size").evaluate(w,b,e,r),s=l.get("icon-rotate").evaluate(w,b,e),o=this.updateSymbolInstanceIconVertices(y,x,_,w,c,e,r,n,a,u,b,t,i,s);c+=o.vertexOffsetDelta,h=h||o.hasChanges;}x.activeAppearance=_;}return h&&this.icon.layoutVertexBuffer&&null!==this.icon.layoutVertexArray.arrayBuffer&&this.icon.layoutVertexArray.length===this.icon.layoutVertexBuffer.length&&this.icon.layoutVertexBuffer.updateData(this.icon.layoutVertexArray),f&&this.text.layoutVertexBuffer&&null!==this.text.layoutVertexArray.arrayBuffer&&this.text.layoutVertexArray.length===this.text.layoutVertexBuffer.length&&this.text.layoutVertexBuffer.updateData(this.text.layoutVertexArray),h||f}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy();}getProjection(){return this.projectionInstance||(this.projectionInstance=Wv(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData();}addToLineVertexArray(e,t){const r=this.lineVertexArray.length;if(void 0!==e.segment)for(const{x:e,y:r}of t)this.lineVertexArray.emplaceBack(e,r);return {lineStartIndex:r,lineLength:this.lineVertexArray.length-r}}addSymbols(e,t,r,n,i,s,o,a,l,u,c,h,p,d,f,m,y,g){const x=e.indexArray,v=e.layoutVertexArray,b=e.globeExtVertexArray,w=e.segments.prepareSegment(4*g,v,x,this.canOverlap?s.sortKey:void 0),_=this.glyphOffsetArray.length,A=w.vertexLength,M=this.allowVerticalPlacement&&o===qg.vertical?Math.PI/2:0,I=s.text&&s.text.sections;for(let n=0;n=0?t.rightJustifiedTextSymbolIndex:t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.leftJustifiedTextSymbolIndex>=0?t.leftJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex>=0?t.verticalPlacedTextSymbolIndex:n),s=px(this.textSizeData,e,i)/_g;return this.tilePixelRatio*s}getSymbolInstanceIconSize(e,t,r){const n=this.icon.placedSymbolArray.get(r),i=px(this.iconSizeData,e,n);return this.tilePixelRatio*i}_commitDebugCollisionVertexUpdate(e,t,r,n){e.emplaceBack(t,-r,-r,n),e.emplaceBack(t,r,-r,n),e.emplaceBack(t,r,r,n),e.emplaceBack(t,-r,r,n);}_updateTextDebugCollisionBoxes(e,t,r,n,i,s,o){for(let o=n;o0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(e,t){const r=e.placedSymbolArray.get(t),n=r.vertexStartIndex+4*r.numGlyphs;for(let t=r.vertexStartIndex;tn[e]-n[t]||i[t]-i[e]),s}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let e=0;ethis.symbolInstances.get(t).zOffset-this.symbolInstances.get(e).zOffset)}addToSortKeyRanges(e,t){const r=this.sortKeyRanges[this.sortKeyRanges.length-1];r&&r.sortKey===t?r.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:t,symbolInstanceStart:e,symbolInstanceEnd:e+1});}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e)if(this.text.segments.get().length>1||this.icon.segments.get().length>1)this.sortFeaturesByY=!1;else {this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const e of this.symbolInstanceIndexes){const t=this.symbolInstances.get(e);this.featureSortOrder.push(t.featureIndex);const{rightJustifiedTextSymbolIndex:r,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:i,verticalPlacedTextSymbolIndex:s,placedIconSymbolIndex:o,verticalPlacedIconSymbolIndex:a}=t;r>=0&&this.addIndicesForPlacedSymbol(this.text,r),n>=0&&n!==r&&this.addIndicesForPlacedSymbol(this.text,n),i>=0&&i!==n&&i!==r&&this.addIndicesForPlacedSymbol(this.text,i),s>=0&&this.addIndicesForPlacedSymbol(this.text,s),o>=0&&this.addIndicesForPlacedSymbol(this.icon,o),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a);}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray);}}getElevationFeatureForText(e){const t=this.symbolInstances.get(this.text.symbolInstanceIndices[e]).elevationFeatureIndex;let r;return this.elevationFeatures&&tr in e?String(e[r]):"")}let lb,ub,cb;Js(ob,"SymbolBucket",{omit:["layers","collisionBoxArray","compareText","features"]}),ob.addDynamicAttributes=rb;class hb{constructor(e){this.type=e.property.overrides?e.property.overrides.runtimeType:yr,this.defaultValue=e;}evaluate(e){if(e.formattedSection){const t=this.defaultValue.property.overrides;if(t&&t.hasOverride(e.formattedSection))return t.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression);}outputDefined(){return !1}serialize(){return null}}Js(hb,"FormatSectionOverride",{omit:["defaultValue"]});const pb=()=>cb||(cb={layout:lb||(lb=new la({"symbol-placement":new sa(ua.layout_symbol["symbol-placement"]),"symbol-spacing":new sa(ua.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new sa(ua.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new oa(ua.layout_symbol["symbol-sort-key"]),"symbol-z-order":new sa(ua.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new sa(ua.layout_symbol["symbol-z-elevate"]),"symbol-elevation-reference":new sa(ua.layout_symbol["symbol-elevation-reference"]),"icon-allow-overlap":new sa(ua.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new sa(ua.layout_symbol["icon-ignore-placement"]),"icon-optional":new sa(ua.layout_symbol["icon-optional"]),"icon-rotation-alignment":new sa(ua.layout_symbol["icon-rotation-alignment"]),"icon-size":new oa(ua.layout_symbol["icon-size"]),"icon-size-scale-range":new sa(ua.layout_symbol["icon-size-scale-range"]),"icon-text-fit":new oa(ua.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new oa(ua.layout_symbol["icon-text-fit-padding"]),"icon-image":new oa(ua.layout_symbol["icon-image"]),"icon-image-use-theme":new sa({type:"string",default:"default","property-type":"data-constant"}),"icon-rotate":new oa(ua.layout_symbol["icon-rotate"]),"icon-padding":new sa(ua.layout_symbol["icon-padding"]),"icon-keep-upright":new sa(ua.layout_symbol["icon-keep-upright"]),"icon-offset":new oa(ua.layout_symbol["icon-offset"]),"icon-anchor":new oa(ua.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new sa(ua.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new sa(ua.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new sa(ua.layout_symbol["text-rotation-alignment"]),"text-field":new oa(ua.layout_symbol["text-field"]),"text-font":new oa(ua.layout_symbol["text-font"]),"text-size":new oa(ua.layout_symbol["text-size"]),"text-size-scale-range":new sa(ua.layout_symbol["text-size-scale-range"]),"text-max-width":new oa(ua.layout_symbol["text-max-width"]),"text-line-height":new oa(ua.layout_symbol["text-line-height"]),"text-letter-spacing":new oa(ua.layout_symbol["text-letter-spacing"]),"text-justify":new oa(ua.layout_symbol["text-justify"]),"text-radial-offset":new oa(ua.layout_symbol["text-radial-offset"]),"text-variable-anchor":new sa(ua.layout_symbol["text-variable-anchor"]),"text-anchor":new oa(ua.layout_symbol["text-anchor"]),"text-max-angle":new sa(ua.layout_symbol["text-max-angle"]),"text-writing-mode":new sa(ua.layout_symbol["text-writing-mode"]),"text-rotate":new oa(ua.layout_symbol["text-rotate"]),"text-padding":new sa(ua.layout_symbol["text-padding"]),"text-keep-upright":new sa(ua.layout_symbol["text-keep-upright"]),"text-transform":new oa(ua.layout_symbol["text-transform"]),"text-offset":new oa(ua.layout_symbol["text-offset"]),"text-allow-overlap":new sa(ua.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new sa(ua.layout_symbol["text-ignore-placement"]),"text-optional":new sa(ua.layout_symbol["text-optional"]),visibility:new sa(ua.layout_symbol.visibility)})),paint:ub||(ub=new la({"icon-opacity":new oa(ua.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new oa(ua.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new oa(ua.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new oa(ua.paint_symbol["text-emissive-strength"]),"icon-color":new oa(ua.paint_symbol["icon-color"]),"icon-halo-color":new oa(ua.paint_symbol["icon-halo-color"]),"icon-halo-width":new oa(ua.paint_symbol["icon-halo-width"]),"icon-halo-blur":new oa(ua.paint_symbol["icon-halo-blur"]),"icon-translate":new sa(ua.paint_symbol["icon-translate"]),"icon-translate-anchor":new sa(ua.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new sa(ua.paint_symbol["icon-image-cross-fade"]),"text-opacity":new oa(ua.paint_symbol["text-opacity"]),"text-occlusion-opacity":new oa(ua.paint_symbol["text-occlusion-opacity"]),"text-color":new oa(ua.paint_symbol["text-color"],{runtimeType:br,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new oa(ua.paint_symbol["text-halo-color"]),"text-halo-width":new oa(ua.paint_symbol["text-halo-width"]),"text-halo-blur":new oa(ua.paint_symbol["text-halo-blur"]),"text-translate":new sa(ua.paint_symbol["text-translate"]),"text-translate-anchor":new sa(ua.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new sa(ua.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new sa(ua.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new sa(ua.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new sa(ua.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new oa(ua.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new oa({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new oa({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new oa({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new oa({type:"string",default:"default","property-type":"data-driven"})}))},cb);class db extends Va{constructor(e,t,r,n){super(e,pb(),t,r,n,e.layout?e.layout["icon-image-use-theme"]:null),this._colorAdjustmentMatrix=u([]),this.hasOcclusionOpacityProperties=void 0!==e.paint&&("icon-occlusion-opacity"in e.paint||"text-occlusion-opacity"in e.paint);}_handleSpecialPaintPropertyUpdate(e){"icon-occlusion-opacity"!==e&&"text-occlusion-opacity"!==e||(this.hasOcclusionOpacityProperties=!0);}recalculate(e,t){super.recalculate(e,t),this.appearances&&this.appearances.forEach(r=>{r.recalculate(e,t,this.iconImageUseTheme);}),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const r=this.layout.get("text-writing-mode");if(r){const e=[];for(const t of r)e.indexOf(t)<0&&e.push(t);this.layout._values["text-writing-mode"]=e;}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides();}getColorAdjustmentMatrix(e,t,r,n){return this._saturation===e&&this._contrast===t&&this._brightnessMin===r&&this._brightnessMax===n||(this._colorAdjustmentMatrix=function(e,t,r,n){e=st(e),t=it(t);const i=a(),s=e/3,o=1-2*s,l=[o,s,s,0,s,o,s,0,s,s,o,0,0,0,0,1],u=.5-.5*t,c=n-r;return h(i,[c,0,0,0,0,c,0,0,0,0,c,0,r,r,r,1],[t,0,0,0,0,t,0,0,0,0,t,0,u,u,u,1]),h(i,i,l),i}(e,t,r,n),this._saturation=e,this._contrast=t,this._brightnessMin=r,this._brightnessMax=n),this._colorAdjustmentMatrix}getValueAndResolveTokens(e,t,r,n){const i=this.layout.get(e).evaluate(t,{},r,n),s=this._unevaluatedLayout._values[e];return s.isDataDriven()||Os(s.value)||!i?i:ab(t.properties,i)}getAppearanceValueAndResolveTokens(e,t,r,n,i){const s=e.getProperty(t);if(!s)return;const o=s.evaluate(r,{},n,i),a=e.getUnevaluatedProperties()._values[t];return a.isDataDriven()||Os(a.value)||!o||"string"!=typeof o?o:ab(r.properties,o)}createBucket(e){return new ob(e)}queryRadius(){return 0}queryIntersectsFeature(){return !1}_setPaintOverrides(){for(const e of pb().paint.overridableProperties){if(!db.hasPaintOverride(this.layout,e))continue;const t=this.paint.get(e),r=new hb(t),n=new Ls(r,t.property.specification,this.scope,this.options,this.layout.get("icon-image-use-theme"));let i=null;i="constant"===t.value.kind||"source"===t.value.kind?new Ns("source",n):new js("composite",n,t.value.zoomStops,t.value.interpolationType),this.paint._values[e]=new na(t.property,i,t.parameters);}}_handleOverridablePaintPropertyUpdate(e,t,r){return !(!this.layout||t.isDataDriven()||r.isDataDriven())&&db.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,t){const r=e.get("text-field"),n=pb().paint.properties[t];let i=!1;const s=e=>{for(const t of e)if(n.overrides&&n.overrides.hasOverride(t))return void(i=!0)};if("constant"===r.value.kind&&r.value.value instanceof Dr)s(r.value.value.sections);else if("source"===r.value.kind){const e=t=>{i||(t instanceof jr&&Ur(t.value)===Mr?s(t.value.sections):t instanceof Xr?s(t.sections):t.eachChild(e));},t=r.value;t._styleExpression&&e(t._styleExpression.expression);}return i}getProgramIds(){return ["symbol"]}getDefaultProgramParams(e,t,r){return {config:new hu(this,{zoom:t,lut:r}),overrideFog:!1}}hasElevation(){return this.layout&&"hd-road-markup"===this.layout.get("symbol-elevation-reference")}}let fb,mb,yb,gb;var xb=Ra([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);function vb(e,t,r,n,i,a,l,u){const c=[e,t,1,r,n,1,i,a,1],h=[l,u,1],p=s([],c),[d,f,m]=G(h,h,p);return o(c,c,[d,0,0,0,f,0,0,0,m])}function bb(e,t,r,n,i,a,l,u){const c=function(e,t,r,n,i,a,l,u){const c=vb(0,0,1,0,1,1,0,1),h=vb(e,t,r,n,i,a,l,u);return o(h,h,s([],c))}(e,t,r,n,i,a,l,u);return [c[2]/c[8]/Un,c[5]/c[8]/Un]}function wb(e){return [e[0],Math.min(Math.max(e[1],-85.051129),Cu)]}class _b extends rr{constructor(e,t,r,n){super(),this.id=e,this.dispatcher=r,this.coordinates=t.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(n),this.options=t,this._dirty=!1;}load(e,t){if(this._loaded=t||!1,this.fire(new Kt("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return e&&(this.coordinates=e),this._loaded=!0,void this._finishLoading();this._imageRequest=Gt(this.map._requestManager.transformRequest(this.url,Dt.Image),(t,r)=>{this._imageRequest=null,this._loaded=!0,t?this.fire(new Qt(t)):r&&(this.image=r,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,e&&(this.coordinates=e),this._finishLoading());});}loaded(){return this._loaded}updateImage(e){return e.url?(this._imageRequest&&e.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=e.url,this.load(e.coordinates,this._loaded),this):this}setTexture(e){if(!(e.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new Fm(this.map.painter.context,e.handle),this.width=e.dimensions[0],this.height=e.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new Kt("data",{dataType:"source",sourceDataType:"metadata"})));}onAdd(e){this.map=e,this.load();}onRemove(e){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Fm||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy());}setCoordinates(e){if(this.coordinates=e,this._boundsArray=void 0,this._unsupportedCoords=!1,!e.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let t=e[0][1],r=e[0][1];for(const n of e)n[1]>r&&(r=n[1]),n[1]Cu?this.onNorthPole=!0:n<-85.051129&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const t=e.map(Nu.fromLngLat);this.tileID=function(e){let t=1/0,r=1/0,n=-1/0,i=-1/0;for(const s of e)t=Math.min(t,s.x),r=Math.min(r,s.y),n=Math.max(n,s.x),i=Math.max(i,s.y);const s=Math.max(n-t,i-r),o=Math.max(0,Math.floor(-Math.log2(s))),a=Math.pow(2,o);let l=Math.floor((t+n)/2*a);return l>1&&(l-=1),new Hc(o,l,Math.floor((r+i)/2*a))}(t),this.minzoom=this.maxzoom=this.tileID.z;}return this.fire(new Kt("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){!this.texture||this.texture instanceof Fm||(this.texture.destroy(),this._dirty=!0),this.texture=null,this._boundsArray=void 0,this._unsupportedCoords=!1;}_prepareData(e){for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture);}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const t=zv(new Hc(0,0,0),this.map.transform.projection),r=[t.projection.project(this.coordinates[0][0],this.coordinates[0][1]),t.projection.project(this.coordinates[1][0],this.coordinates[1][1]),t.projection.project(this.coordinates[2][0],this.coordinates[2][1]),t.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(e){const t=e[1].x-e[0].x,r=e[1].y-e[0].y,n=e[2].x-e[1].x,i=e[2].y-e[1].y,s=e[3].x-e[2].x,o=e[3].y-e[2].y,a=e[0].x-e[3].x,l=e[0].y-e[3].y,u=t*i-n*r,c=n*o-s*i,h=s*l-a*o,p=a*r-t*l;return u>0&&c>0&&h>0&&p>0||u<0&&c<0&&h<0&&p<0}(r))return console.warn("Image source coordinates are defining non-convex area in the Mercator projection"),void(this._unsupportedCoords=!0);const n=zv(this.tileID,this.map.transform.projection),[i,a,l,u]=this.coordinates.map(e=>{const t=n.projection.project(e[0],e[1]);return Pv(n,t)._round()});this.perspectiveTransform=bb(i.x,i.y,a.x,a.y,l.x,l.y,u.x,u.y);const c=this._boundsArray=new Na;c.emplaceBack(i.x,i.y,0,0),c.emplaceBack(a.x,a.y,Un,0),c.emplaceBack(u.x,u.y,0,Un),c.emplaceBack(l.x,l.y,Un,Un),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=e.createVertexBuffer(c,xb.members),this.boundsSegments=Rl.simpleSegment(0,0,4,2);const h=[],p=[wb((d=this.coordinates)[0]),wb(d[1]),wb(d[2]),wb(d[3])];var d;const[f,m,y,g]=function(e){let t=e[0][0],r=t,n=e[0][1],i=n;for(let s=1;sr&&(r=e[s][0]),e[s][1]i&&(i=e[s][1]);return [t,n,r-t,i-n]}(p);{const n=new Na,[i,a,l,u]=function(e){let t=e[0].x,r=t,n=e[0].y,i=n;for(let s=1;sr&&(r=e[s].x),e[s].yi&&(i=e[s].y);return [t,n,r-t,i-n]}(r),c=e=>[(e.x-i)/l,(e.y-a)/u],[p,d,x,v]=r.map(c),b=function(e,t,r,n,i,a,l,u){const c=vb(0,0,1,0,1,1,0,1);return o(c,c,s([],vb(e,t,r,n,i,a,l,u)))}(p[0],p[1],d[0],d[1],x[0],x[1],v[0],v[1]);this.elevatedGlobePerspectiveTransform=bb(p[0],p[1],d[0],d[1],x[0],x[1],v[0],v[1]);const w=(e,t)=>{h.push(e.lng);const r=Math.round((e.lng-f)/y*Un),i=Math.round((e.lat-m)/g*Un),s=c(t),o=G([],[s[0],s[1],1],b),a=Math.round(o[0]/o[2]*Un),l=Math.round(o[1]/o[2]*Un);n.emplaceBack(r,i,a,l);},_=r[3].x-r[0].x,A=r[3].y-r[0].y,M=r[2].x-r[1].x,I=r[2].y-r[1].y;for(let e=0;e<65;e++){const n=e/64,i=[r[0].x+n*_,r[0].y+n*A],s=[r[1].x+n*M,r[1].y+n*I],o=s[0]-i[0],a=s[1]-i[1];for(let e=0;e<65;e++){const r=e/64,n={x:i[0]+o*r,y:i[1]+a*r};w(t.projection.unproject(n.x,n.y),n);}}this.elevatedGlobeVertexBuffer=e.createVertexBuffer(n,xb.members);}{this.maxLongitudeTriangleSize=0;let t=[],r=new ol;const n=(e,n,i)=>{r.emplaceBack(e,n,i);const s=h[e],o=h[n],a=h[i],l=Math.min(Math.min(s,o),a),u=Math.max(Math.max(s,o),a)-l;u>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=u),t.push(l+u/2);};for(let e=0;e<64;e++)for(let t=0;t<64;t++){const r=65*e+t,i=r+1,s=r+65,o=s+1;n(r,s,i),n(i,s,o);}[t,r]=function(e,t){const r=Array.from({length:e.length},(e,t)=>t);r.sort((t,r)=>e[t]-e[r]);const n=[],i=new ol;for(let s=0;s{s.segments.push({vertexOffset:0,primitiveOffset:e,vertexLength:t.segments[0].vertexLength,primitiveLength:r,sortKey:void 0,vaos:{}});},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(r[0]-n)<=a){const e=nt(r,0,r.length,n+a);return e===r.length||o(e,rt(r,e+1,r.length,n+360-a)-e),s}n0}}let Sb,zb,Pb,Bb,Tb;class kb extends Va{constructor(e,t,r,n){super(e,{layout:Sb||(Sb=new la({visibility:new sa(ua["layout_raster-particle"].visibility)})),paint:zb||(zb=new la({"raster-particle-array-band":new sa(ua["paint_raster-particle"]["raster-particle-array-band"]),"raster-particle-count":new sa(ua["paint_raster-particle"]["raster-particle-count"]),"raster-particle-color":new aa(ua["paint_raster-particle"]["raster-particle-color"]),"raster-particle-max-speed":new sa(ua["paint_raster-particle"]["raster-particle-max-speed"]),"raster-particle-speed-factor":new sa(ua["paint_raster-particle"]["raster-particle-speed-factor"]),"raster-particle-fade-opacity-factor":new sa(ua["paint_raster-particle"]["raster-particle-fade-opacity-factor"]),"raster-particle-reset-rate-factor":new sa(ua["paint_raster-particle"]["raster-particle-reset-rate-factor"]),"raster-particle-elevation":new sa(ua["paint_raster-particle"]["raster-particle-elevation"]),"raster-particle-color-use-theme":new oa({type:"string",default:"default","property-type":"data-driven"})}))},t,r,n),this._updateColorRamp(),this.lastInvalidatedAt=gt.now();}_clear(){this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null),this.tileFramebuffer&&(this.tileFramebuffer.destroy(),this.tileFramebuffer=null),this.particleFramebuffer&&(this.particleFramebuffer.destroy(),this.particleFramebuffer=null);}onRemove(e){this.colorRampTexture&&this.colorRampTexture.destroy(),this.tileFramebuffer&&this.tileFramebuffer.destroy(),this.particleFramebuffer&&this.particleFramebuffer.destroy();}hasColorMap(){return !!this._transitionablePaint._values["raster-particle-color"].value.value}getProgramIds(){return ["rasterParticle"]}hasOffscreenPass(){return "none"!==this.visibility}isDraped(e){return !1}_handleSpecialPaintPropertyUpdate(e){"raster-particle-color"!==e&&"raster-particle-max-speed"!==e||(this._updateColorRamp(),this._invalidateAnimationState()),"raster-particle-count"===e&&this._invalidateAnimationState();}_updateColorRamp(){if(!this.hasColorMap())return;const e=this._transitionablePaint._values["raster-particle-color"].value.expression,t=this._transitionablePaint._values["raster-particle-max-speed"].value.expression.evaluate({zoom:0});this.colorRamp=qh({expression:e,evaluationKey:"rasterParticleSpeed",image:this.colorRamp,clips:[{start:0,end:t}],resolution:256}),this.colorRampTexture=null;}_invalidateAnimationState(){this.lastInvalidatedAt=gt.now();}tileCoverLift(){return this.paint.get("raster-particle-elevation")}}class Vb extends Va{constructor(e,t){super(e,{},t,null),this.implementation=e,e.slot&&(this.slot=e.slot);}is3D(e){return "3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}isDraped(e){return void 0!==this.implementation.renderToTile}shouldRedrape(){return !!this.implementation.shouldRerenderTiles&&this.implementation.shouldRerenderTiles()}recalculate(){}updateTransitions(){}hasTransition(){return !1}serialize(){}onAdd(e){this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl);}onRemove(e){this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl);}}function Eb(e,t,r){const n=[0,0,1],i=re([]);return ie(i,i,r?-Be(e)+Math.PI:Be(e)),ne(i,i,-Be(t)),$(n,n,i),L(n,n)}const Fb={None:0,Model:1,Symbol:2,FillExtrusion:4};class Db{constructor(e,t,r,n){this.message=(e?`${e}: `:"")+r,n&&(this.identifier=n),null!=t&&t.__line__&&(this.line=t.__line__);}}function Cb(e,t){const r=-1===e.indexOf("://");try{return new URL(e,r&&t?"http://example.com":void 0),!0}catch(e){return !1}}class Rb{constructor(e,t){this.feature=e,this.instancedDataOffset=t,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0];}}class Lb{constructor(){this.maxScale=1,this.maxXYTranslationDistance=0,this.instancedDataArray=new gl,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={};}colorForInstance(e){const t=16*e,r=this.instancedDataArray.float32;let n=Math.floor(r[t+2]);const i=1.05*(r[t+2]-n);return n/=100,[r[t]%1*1.05,r[t+1]%1*1.05,i,n]}tileCoordinatesForInstance(e){const t=16*e,r=this.instancedDataArray.float32;let n=r[t+0];return n=n>Un?n-Un:n,new Ie(Math.trunc(n),Math.trunc(r[t+1]))}translationForInstance(e){const t=16*e,r=this.instancedDataArray.float32;return [r[t+4],r[t+5],r[t+6]]}rotationScaleForInstance(e){const t=16*e,r=this.instancedDataArray.float32;return [r[t+7],r[t+8],r[t+9],r[t+10],r[t+11],r[t+12],r[t+13],r[t+14],r[t+15]]}transformForInstance(e){const t=16*e,r=this.instancedDataArray.float32;return [r[t+7],r[t+8],r[t+9],r[t+4],r[t+10],r[t+11],r[t+12],r[t+5],r[t+13],r[t+14],r[t+15],r[t+6],0,0,0,1]}}class Ob{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.overscaledZ=this.canonical.z+Math.log2(e.overscaling),this.layers=e.layers,this.layerIds=this.layers.map(e=>e.fqid),this.projection=e.projection,this.index=e.index,this.worldview=e.worldview,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z+1?0:this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0},this.modelUris=[],this.modelsRequested=!1,this.activeReplacements=[],this.replacementUpdateTime=0,this.styleDefinedModelURLs=e.styleDefinedModelURLs,this.hasAppearances=null;}updateFootprints(e,t){}updateAppearances(e,t,r,n){}populate(e,t,r,n){this.tileToMeter=Uu(r);const i=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);const s="hd-road-markup"===this.layers[0].paint.get("model-elevation-reference")?t.elevationFeatures:void 0;for(const{feature:o,id:a,index:l,sourceLayerIndex:u}of e){const e=null!=a?a:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,c=Yu(o,i);if(!this.layers[0]._featureFilter.filter(new Yo(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),c,r))continue;const h={id:e,sourceLayerIndex:u,index:l,geometry:i?c.geometry:Wu(o,r,n),properties:o.properties,type:o.type,patterns:{}},p=this.addFeature(h,h.geometry,c,s,r);p&&t.featureIndex.insert(o,h.geometry,l,u,this.index,this.instancesPerModel[p].instancedDataArray.length,256);}this.lookup=null;}evaluateQueryRenderedFeaturePadding(){const e=this.layers[0].modelManager,t=this.layers[0].scope;let r=0;for(const n of this.modelUris){const i=e.getModel(n,t);if(!i)continue;const s=this.instancesPerModel[n];if(s){const e=.5*F(i.aabb.max,i.aabb.min)*s.maxScale+s.maxXYTranslationDistance,t=Math.min(Un,Math.max(e/this.tileToMeter,256));r=Math.max(t,r);}}return r}update(e,t,r,n){for(const t in this.instancesPerModel){const r=this.instancesPerModel[t];for(const t in e)r.idToFeaturesIndex.hasOwnProperty(t)&&(this.evaluate(r.features[r.idToFeaturesIndex[t]],e[t],r,!0),this.uploaded=!1);}this.maxHeight=0;}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return !1;let e=!1;for(const t in this.instancesPerModel){const r=this.instancesPerModel[t];for(const t of r.features){const n=this.layers[0],i=t.feature,s=this.canonical,o=n.paint.get("model-rotation").evaluate(i,{},s),a=n.paint.get("model-scale").evaluate(i,{},s),l=n.paint.get("model-translation").evaluate(i,{},s);X(t.rotation,o)&&X(t.scale,a)&&X(t.translation,l)||(this.evaluate(t,t.featureStates,r,!0),e=!0);}}return e}updateReplacement(e,t,r,n){if(t.updateTime===this.replacementUpdateTime)return !1;this.replacementUpdateTime=t.updateTime;const i=t.getReplacementRegionsForTile(e.toUnwrapped(),!0);if(Ld(this.activeReplacements,i))return !1;this.activeReplacements=i;let s=!1;for(const t in this.instancesPerModel){const i=this.instancesPerModel[t],o=i.instancedDataArray;for(const t of i.features){const i=t.instancedDataOffset,a=t.instancedDataCount;for(let t=0;tUn;l=u?l-Un:l;const c=Math.floor(l),h=Math.floor(o.float32[a+1]);let p=!1;for(const t of this.activeReplacements)if(!Fd(t,r,Fb.Model,n)&&!(t.min.x>c||c>t.max.x||t.min.y>h||h>t.max.y)&&(p=$d(Gd(c,h,e.canonical,t.footprintTileId.canonical),t.footprint),p))break;o.float32[a]=p?l+Un:l,s=s||p!==u;}}}return s}isEmpty(){for(const e in this.instancesPerModel)if(0!==this.instancesPerModel[e].instancedDataArray.length)return !1;return !0}uploadPending(){return !this.uploaded}upload(e){if(!this.uploaded)for(const t in this.instancesPerModel){const r=this.instancesPerModel[t];r.instancedDataArray.length<0||0===r.instancedDataArray.length||(r.instancedDataBuffer?r.instancedDataBuffer.updateData(r.instancedDataArray):r.instancedDataBuffer=e.createVertexBuffer(r.instancedDataArray,Um.members,!0,void 0,this.instanceCount));}this.uploaded=!0;}destroy(e){for(const e in this.instancesPerModel){const t=this.instancesPerModel[e];0!==t.instancedDataArray.length&&t.instancedDataBuffer&&t.instancedDataBuffer.destroy();}const t=this.layers[0].modelManager;if(e&&t&&this.modelUris&&this.modelsRequested)for(const e of this.modelUris)t.removeModel(e,"",!0);}addFeature(e,t,r,n,i){const s=this.layers[0],o=s.layout.get("model-id"),a=s.layout.get("model-allow-density-reduction"),l=o.evaluate(r,{},this.canonical);if(!l)return Ze(`modelId is not evaluated for layer ${s.id} and it is not going to get rendered.`),l;(Cb(l,!1)||void 0!==this.styleDefinedModelURLs[l])&&(this.modelUris.includes(l)||this.modelUris.push(l)),this.instancesPerModel[l]||(this.instancesPerModel[l]=new Lb);const u=this.instancesPerModel[l],c=u.instancedDataArray,h=new Rb(r,c.length);let p;n&&(p=_c.getElevationFeature(e,n));for(const e of t)for(const t of e){if(t.x<0||t.x>=Un||t.y<0||t.y>=Un)continue;if(0!==this.lookupDim&&a){const e=(this.lookupDim-1)/Un,r=this.lookupDim*(t.y*e|0)+t.x*e|0;if(this.lookup){if(0!==this.lookup[r])continue;this.lookup[r]=1;}}this.instanceCount++;const e=c.length;if(c.resize(e+1),n){u.instancesRoadElevation||(u.instancesRoadElevation=[]);const e=p?p.pointElevation(new Ie(t.x,t.y)):0;u.instancesRoadElevation.push(e);}u.instancesEvaluatedElevation.push(0),c.float32[16*e]=t.x,c.float32[16*e+1]=t.y;}return h.instancedDataCount=u.instancedDataArray.length-h.instancedDataOffset,h.instancedDataCount>0&&(e.id&&(u.idToFeaturesIndex[e.id]=u.features.length),u.features.push(h),this.evaluate(h,{},u,!1)),l}getModelUris(){return this.modelUris}evaluate(e,t,r,n){const i=this.layers[0],s=e.feature,o=this.canonical,a=e.rotation=i.paint.get("model-rotation").evaluate(s,t,o),l=e.scale=i.paint.get("model-scale").evaluate(s,t,o),u=e.translation=i.paint.get("model-translation").evaluate(s,t,o),c=Object.assign({},i.paint.get("model-color").evaluate(s,t,o));c.a=i.paint.get("model-color-mix-intensity").evaluate(s,t,o);const h=[];this.maxVerticalOffset0?Math.sqrt(p):0;r.maxScale=Math.max(Math.max(r.maxScale,l[0]),Math.max(l[1],l[2])),r.maxXYTranslationDistance=Math.max(r.maxXYTranslationDistance,d),this.maxScale=Math.max(Math.max(this.maxScale,l[0]),Math.max(l[1],l[2])),Zm(h,a,l);const f=Math.round(100*c.a)+c.b/1.05;for(let t=0;t10?this.tileToMeter:Uu(o,p)),a[s+4]=u[0],a[s+5]=u[1],a[s+6]=u[2]+(r.instancesRoadElevation?r.instancesRoadElevation[i]:0)+l,a[s+7]=h[0],a[s+8]=h[1],a[s+9]=h[2],a[s+10]=h[4],a[s+11]=h[5],a[s+12]=h[6],a[s+13]=h[8],a[s+14]=h[9],a[s+15]=h[10],r.instancesEvaluatedElevation[i]=u[2];}}}let Ub,Nb;Js(Ob,"ModelBucket",{omit:["layers"]}),Js(Lb,"PerModelAttributes"),Js(Rb,"ModelFeature");class jb{constructor(e,t,r){this._demTile=e,this._dem=this._demTile.dem,this._scale=t,this._offset=r;}static create(e,t,r){const n=r||e.findDEMTileFor(t);if(!n||!n.dem)return;const i=n.dem,s=n.tileID,o=1<e.fqid),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.modelTraits|=Qm.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,n&&(this.modelTraits|=Qm.HasMapboxMeshFeatures),i&&(this.modelTraits|=Qm.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=s,this.worldview=a,this.dirty=!0,this.needsUpload=!1,this.filter=null,this.nodesInfo=[];for(const e of t)this.nodesInfo.push(new Zb(e)),Xb(e,o.featureIndexArray.length,o.grid),o.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,o.bucketLayerIDs.length-1,0);this.states={},this.hasAppearances=null;}updateFootprints(e,t){for(const r of this.getNodesInfo()){const n=r.node;n.footprint&&t.push({footprint:n.footprint,id:e});}}updateAppearances(e,t,r,n){}update(e){const t=0!==Object.keys(e).length;if(t&&!this.stateDependentLayers.length)return;const r=t?this.stateDependentLayers:this.layers;if(!Se(e,this.states))for(const t of r)this.evaluate(t,e);this.states=structuredClone(e);}populate(){console.log("populate 3D model bucket");}uploadPending(){return !this.uploaded||this.needsUpload}upload(e){if(!this.needsUpload)return;const t=this.getNodesInfo();for(const r of t){const t=r.node;this.uploaded?this.updatePbrBuffer(t):iy(t,e,!0);}for(const e of t)sy(e.node);this.uploaded=!0,this.needsUpload=!1;}updatePbrBuffer(e){let t=!1;if(!e.meshes)return t;for(const r of e.meshes)r.pbrBuffer&&(r.pbrBuffer.updateData(r.featureArray),t=!0);return t}needsReEvaluation(e,t,r){const n=e.transform.projectionOptions,i=e.style.getBrightness(),s=this.brightness!==i;if(!this.uploaded||this.dirty||n.name!==this.projection.name||Yb(r.paint.get("model-color").value,s)||Yb(r.paint.get("model-color-mix-intensity").value,s)||Yb(r.paint.get("model-roughness").value,s)||Yb(r.paint.get("model-emissive-strength").value,s)||Yb(r.paint.get("model-height-based-emissive-strength-multiplier").value,s)){this.projection=n,this.brightness=i;const e=this.getNodesInfo();for(const t of e)t.state=null;return !0}return !1}evaluateTransform(e,t){if(e.transform.zoom===this.zoom)return;this.zoom=e.transform.zoom;const r=this.getNodesInfo(),n=this.id.canonical;for(const e of r){const r=e.feature;e.evaluatedTranslation=t.paint.get("model-translation").evaluate(r,{},n),e.evaluatedScale=t.paint.get("model-scale").evaluate(r,{},n);}}evaluate(e,t){const r=this.getNodesInfo();for(const n of r){if(!n.node.meshes)continue;const r=n.feature,i=t&&t[r.id];if(Se(i,n.state))continue;n.state=structuredClone(i);const s=n.node.meshes&&n.node.meshes[0].featureData,o=n.evaluatedColor[2],a=n.evaluatedRMEA[2],l=this.id.canonical;if(n.hasTranslucentParts=!1,s){for(let t=0;t=e)continue;const h=Gb[u],p=Math.abs(h);p>a&&(o=h,a=p,l=i,c=t);}if(a>.1){const s=1-(e+.5*Math.abs(l*c))/u;let a=t._dem.get(n,r)+o*s;const h=t._dem.get(n+l,r+c),p=t._dem.get(n-l,r-c,!0);(a-h)*(a-p)>0&&(a=(h+p)/2),Gb[i]=t._dem.set(n,r,a),$b[i]=e;}}}}}o&&(t._demTile.needsDEMTextureUpload=!0,t._dem._timestamp=gt.now());}setFilter(e){this.filter=e?da(e):null;}getNodesInfo(){return this.filter?this.nodesInfo.filter(e=>this.filter.filter(new Yo(this.id.overscaledZ,{worldview:this.worldview}),e.feature,this.id.canonical)):this.nodesInfo}destroy(){const e=this.getNodesInfo();for(const t of e)sy(t.node),ay(t.node);}isEmpty(){return !this.nodesInfo.length}updateReplacement(e,t){if(t.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=t.updateTime;const r=t.getReplacementRegionsForTile(e.toUnwrapped());for(const e of this.getNodesInfo()){const t=e.node.footprint;e.hiddenByReplacement=!!t&&!r.find(e=>e.footprint===t);}}getHeightAtTileCoord(e,t){const r=[],n=[0,0,0],i=u([]);for(const s of this.getNodesInfo()){const o=s.node.meshes[0],a=o.transformedAabb;if(ea.max[0]||t>a.max[1])continue;if(!0===s.node.hidden)return {height:1/0,maxHeight:s.feature.properties.height,hidden:!1,verticalScale:s.evaluatedScale[2]};c(i,s.node.globalMatrix),n[0]=e,n[1]=t,j(n,n,i);const l=(n[0]-o.aabb.min[0])/(o.aabb.max[0]-o.aabb.min[0])*Km|0,u=Math.min(63,(n[1]-o.aabb.min[1])/(o.aabb.max[1]-o.aabb.min[1])*Km|0)*Km+Math.min(63,l),h=o.heightmap[u];if(!(h<0&&s.node.footprint)){if(s.hiddenByReplacement)return;return {height:h,maxHeight:s.feature.properties.height,hidden:!1,verticalScale:s.evaluatedScale[2]}}if(s.node.footprint.grid.query(new Ie(e,t),new Ie(e,t),r),r.length>0)return {height:void 0,maxHeight:s.feature.properties.height,hidden:s.hiddenByReplacement,verticalScale:s.evaluatedScale[2]}}}}function Yb(e,t){return e instanceof Ns&&!e.isLightConstant&&t}function Jb(e,t,r,n,i,s,o,a){let l=(61440&t|(61440&t)>>4)>>8,u=(3840&t|(3840&t)>>4)>>4,c=240&t|(240&t)>>4;r[3]>0&&(l=hr(l,255*r[0],r[3]),u=hr(u,255*r[1],r[3]),c=hr(c,255*r[2],r[3]));const h=l<<8|u,p=c<<8|Math.floor(255*n[3]),d=function(e){const t=De(e,0,2);return Math.min(Math.round(.5*t*255),255)}(n[2])<<8|15*n[0]<<4|15*n[1],f=De(i[0],0,1),m=De(i[1],0,1),y=De(i[2],0,1),g=De(i[3],0,1);let x,v,b,w;if(f!==m&&o!==s&&m!==f){const e=o-s;v=1/(e*(m-f)),b=-(s+e*f)/(e*(m-f));const t=De(i[4],-1,1);w=Math.pow(10,t),x=255*y<<8|255*g;}else x=65535,v=0,b=1,w=1;if(e.emplaceBack(h,p,d,x,v,b,w),a){const e=a.length;a.clear();for(let t=0;t>16&65535,a=s?t>>16&65535:65535&t,l=(15&a)<8?15&a:0,u=e.evaluatedRMEA[l],c=e.evaluatedColor[l],h=e.emissionHeightBasedParams[l];let p;if(o&&2===l&&n.lights&&(p=new xl,p.resize(10*n.lights.length)),Jb(r.featureArray,i,c,u,h,r.aabb.min[2],r.aabb.max[2],p),p&&o){o=!1;const e=n.meshes[n.lightMeshIndex];e.featureArray=p,e.featureArray._trim();}}r.featureArray._trim(),i++;}}Js(Wb,"Tiled3dModelBucket",{omit:["layers"]}),Js(Zb,"Tiled3dModelFeature");const Qb=["id","tile","layer","source","sourceLayer","state"];class ew{constructor(e,t,r,n,i){this.type="Feature",this._vectorTileFeature=e,this._z=t,this._x=r,this._y=n,this.properties=e?e.properties:{},this.id=i;}clone(){const e=new ew(this._vectorTileFeature,this._z,this._x,this._y,this.id);return this.state&&(e.state=Object.assign({},this.state)),this.layer&&(e.layer=Object.assign({},this.layer)),this.source&&(e.source=this.source),this.sourceLayer&&(e.sourceLayer=this.sourceLayer),e}get geometry(){return void 0===this._geometry&&this._vectorTileFeature&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(e){this._geometry=e;}toJSON(){const e={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};for(const t of Qb)void 0!==this[t]&&(e[t]=this[t]);return e}}class tw extends rr{constructor(e,t,r,n){super(),this.id=e,this.type="model",this.models=[],this._options=t,this._modelsInfo=new Map,this._abortController=null;}cancelModelRequests(){this._abortController&&(this._abortController.abort(),this._abortController=null);}loadGLTFFromURI(e,t){return Tm(this.map._requestManager.transformRequest(e,Dt.Model).url,t)}async loadModel(e,t,r){try{const n=await this.loadGLTFFromURI(t.uri,r);if(r.aborted)return;const i=this._modelsInfo.get(e);if(!i)return;const s=my(n),o=i.modelSpec,a=new ty(e,o.uri,o.position,o.orientation,s);tw.applyModelSpecification(a,o),a.computeBoundsAndApplyParent(),this.models.push(a),i.model=a;}catch(r){if(r instanceof Error&&"AbortError"===r.name)return;const n=r instanceof Error?r.message:"Unknown error";this.fire(new Qt(new Error(`Could not load model ${e} from ${t.uri}: ${n}`)));}}async load(){this._abortController||(this._abortController=new AbortController);const e=this._abortController.signal,t=[];for(const r in this._options.models){const n=this._options.models[r],i=this._modelsInfo.get(r);if(i&&i.model){i.modelSpec=n;const e=i.model;e.position=null!=n.position?new zu(n.position[0],n.position[1]):new zu(0,0),e.orientation=null!=n.orientation?n.orientation:[0,0,0],tw.applyModelSpecification(e,n),e.computeBoundsAndApplyParent(),this.models.push(e);}else i?i.modelSpec=n:(this._modelsInfo.set(r,{modelSpec:n,model:null}),t.push(this.loadModel(r,n,e)));}0!==t.length?(await Promise.allSettled(t),e.aborted||this.fire(new Kt("data",{dataType:"source",sourceDataType:"metadata"}))):this.loaded()&&this.fire(new Kt("data",{dataType:"source",sourceDataType:"metadata"}));}static applyModelSpecification(e,t){t.nodeOverrides&&tw.convertNodeOverrides(e,t.nodeOverrides),t.materialOverrides&&tw.convertMaterialOverrides(e,t.materialOverrides),t.nodeOverrideNames&&(e.nodeOverrideNames=[...t.nodeOverrideNames]),t.materialOverrideNames&&(e.materialOverrideNames=[...t.materialOverrideNames]),t.featureProperties&&(e.featureProperties=t.featureProperties);}static convertNodeOverrides(e,t){if(Array.isArray(t)&&t.every(e=>"string"==typeof e)){e.nodeOverrideNames=[];for(const r of t)e.nodeOverrideNames.push(r);}else Object.entries(t).forEach(([t,r])=>{const n={orientation:[0,0,0]};if(r.hasOwnProperty("orientation")){const e=r.orientation;e&&(n.orientation=e);}e.nodeOverrides.set(t,n);});}static convertMaterialOverrides(e,t){if(Array.isArray(t)&&t.every(e=>"string"==typeof e)){e.materialOverrideNames=[];for(const r of t)e.materialOverrideNames.push(r);}else Object.entries(t).forEach(([t,r])=>{const n={color:new ar(1,1,1),colorMix:0,emissionStrength:0,opacity:1},i=r["model-color"];void 0!==i&&(n.color.r=i[0],n.color.g=i[1],n.color.b=i[2]);const s=r["model-color-mix-intensity"];void 0!==s&&(n.colorMix=s);const o=r["model-emissive-strength"];void 0!==o&&(n.emissionStrength=o);const a=r["model-opacity"];void 0!==a&&(n.opacity=a),e.materialOverrides.set(t,n);});}onAdd(e){this.map=e,this.load();}hasTransition(){return !1}loaded(){if(0===this._modelsInfo.size)return !0;for(const e of this._modelsInfo.values())if(null==e.model)return !1;return !0}getModels(){return this.models}loadTile(e,t){}serialize(){return this._options}setProperty(e,t){return !1}reload(){this.cancelModelRequests();const e=Sa(this.id,this.scope);this.map.style.clearSource(e),this.models=[],this._modelsInfo.clear(),this.load();}onRemove(e){this.cancelModelRequests();}setModels(e){this.models=[];const t=new Map;for(const r in e){const n=e[r],i=this._modelsInfo.get(r);i&&i.modelSpec.uri===n.uri&&t.set(r,i);}if(this._modelsInfo.size!==t.size){this.cancelModelRequests();for(const[e,r]of t)r.model||t.delete(e);}this._modelsInfo=t,this._options.models=e,this.load();}}function rw(e,t,r,n){const i=1<e.polygon).flat());const y=d?a:null,[g,x]=Cf(s,n,h,c,u,o,y,p,f,s.center.lat,e.tileID.canonical),v=e.queryGeometry;return Df(g,x,v.isPointQuery()?v.screenBounds:v.screenGeometry)}},building:class extends Va{constructor(e,t,r,n){super(e,{layout:Ry||(Ry=new la({visibility:new sa(ua.layout_building.visibility),"building-facade":new oa(ua.layout_building["building-facade"]),"building-facade-floors":new oa(ua.layout_building["building-facade-floors"]),"building-facade-unit-width":new oa(ua.layout_building["building-facade-unit-width"]),"building-facade-window":new oa(ua.layout_building["building-facade-window"]),"building-roof-shape":new oa(ua.layout_building["building-roof-shape"]),"building-height":new oa(ua.layout_building["building-height"]),"building-base":new oa(ua.layout_building["building-base"]),"building-flood-light-wall-radius":new oa(ua.layout_building["building-flood-light-wall-radius"]),"building-flood-light-ground-radius":new oa(ua.layout_building["building-flood-light-ground-radius"]),"building-flip-roof-orientation":new oa(ua.layout_building["building-flip-roof-orientation"])})),paint:Ly||(Ly=new la({"building-opacity":new sa(ua.paint_building["building-opacity"]),"building-ambient-occlusion-intensity":new sa(ua.paint_building["building-ambient-occlusion-intensity"]),"building-ambient-occlusion-ground-intensity":new sa(ua.paint_building["building-ambient-occlusion-ground-intensity"]),"building-ambient-occlusion-ground-radius":new sa(ua.paint_building["building-ambient-occlusion-ground-radius"]),"building-ambient-occlusion-ground-attenuation":new sa(ua.paint_building["building-ambient-occlusion-ground-attenuation"]),"building-vertical-scale":new sa(ua.paint_building["building-vertical-scale"]),"building-cast-shadows":new sa(ua.paint_building["building-cast-shadows"]),"building-color":new oa(ua.paint_building["building-color"]),"building-emissive-strength":new oa(ua.paint_building["building-emissive-strength"]),"building-facade-emissive-chance":new sa(ua.paint_building["building-facade-emissive-chance"]),"building-cutoff-fade-range":new sa(ua.paint_building["building-cutoff-fade-range"]),"building-flood-light-color":new sa(ua.paint_building["building-flood-light-color"]),"building-flood-light-intensity":new sa(ua.paint_building["building-flood-light-intensity"]),"building-flood-light-ground-attenuation":new sa(ua.paint_building["building-flood-light-ground-attenuation"]),"building-color-use-theme":new oa({type:"string",default:"default","property-type":"data-driven"}),"building-flood-light-color-use-theme":new oa({type:"string",default:"default","property-type":"data-driven"})}))},t,r,n),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0};}createBucket(e){return new Fy(e)}cutoffRange(){return this.paint.get("building-cutoff-fade-range")}hasShadowPass(){return this.paint.get("building-cast-shadows")}hasLightBeamPass(){return !0}canCastShadows(){return !0}is3D(e){return !0}queryRadius(e){return 0}queryIntersectsFeature(e,t,r,n,i,s,o,a,l,u){let c=this.layout.get("building-height").evaluate(t,r);const h=this.layout.get("building-base").evaluate(t,r),p=e.tile.getBucket(this).getFootprint(t);if(p){if(0!==p.hiddenFlags)return !1;c=p.height;}const[d,f]=Cf(s,n,h,c,new Ie(0,0),o,null,[0,0],1,s.center.lat,e.tileID.canonical),m=e.queryGeometry;return Df(d,f,m.isPointQuery()?m.screenBounds:m.screenGeometry)}},line:class extends Va{constructor(e,t,r,n){const i=lg();super(e,i,t,r,n),i.layout&&(this.layout=new ia(i.layout)),this.gradientVersion=0,this.hasElevatedBuckets=!1,this.hasNonElevatedBuckets=!1;}_handleSpecialPaintPropertyUpdate(e){if("line-gradient"===e){const e=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=e._styleExpression&&e._styleExpression.expression instanceof Si,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER;}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}widthExpression(){return this._transitionablePaint._values["line-width"].value.expression}emissiveStrengthExpression(){return this._transitionablePaint._values["line-emissive-strength"].value.expression}recalculate(e,t){super.recalculate(e,t),this.paint._values["line-floorwidth"]=(()=>{if(cg)return cg;const e=lg();return cg=new ug(e.paint.properties["line-width"].specification),cg.useIntegerZoom=!0,cg})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e);}createBucket(e){return new Jy(e)}getProgramIds(){return [this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getDefaultProgramParams(e,t,r){const n=sg(this);return {config:new hu(this,{zoom:t,lut:r}),defines:n,overrideFog:!1}}queryRadius(e){const t=e,r=hg(Nc("line-width",this,t),Nc("line-gap-width",this,t)),n=Nc("line-offset",this,t);return r/2+Math.abs(n)+jc(this.paint.get("line-translate"))}queryIntersectsFeature(e,t,r,n,i,s){if(e.queryGeometry.isAboveHorizon)return !1;const o=Gc(e.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),s.angle,e.pixelToTileUnitsFactor),a=e.pixelToTileUnitsFactor/2*hg(this.paint.get("line-width").evaluate(t,r),this.paint.get("line-gap-width").evaluate(t,r)),l=this.paint.get("line-offset").evaluate(t,r);return l&&(n=function(e,t){const r=[],n=new Ie(0,0);for(let i=0;i=3)for(let t=0;t>16&255)/255,(e>>8&255)/255,(255&e)/255,1)}function _w(e,t,r){1===e?(t.rgb_color=ww(r.readVarint()),t.paint="rgb_color"):2===e?(t.linear_gradient_idx=r.readVarint(),t.paint="linear_gradient_idx"):3===e?(t.radial_gradient_idx=r.readVarint(),t.paint="radial_gradient_idx"):5===e?r.readPackedFloat(t.dasharray):6===e?t.dashoffset=r.readFloat():7===e?t.miterlimit=r.readFloat():8===e?t.opacity=r.readVarint():9===e?t.width=r.readFloat():10===e?t.linecap=r.readVarint():11===e&&(t.linejoin=r.readVarint());}function Aw(e,t,r){1===e?t.transform=gw(r,r.readVarint()+r.pos):2===e?t.spread_method=r.readVarint():3===e?t.stops.push(Mw(r,r.readVarint()+r.pos)):4===e?t.x1=r.readFloat():5===e?t.y1=r.readFloat():6===e?t.x2=r.readFloat():7===e&&(t.y2=r.readFloat());}function Mw(e,t){return e.readFields(Iw,{offset:0,opacity:255,rgb_color:sw},t)}function Iw(e,t,r){1===e?t.offset=r.readFloat():2===e?t.opacity=r.readVarint():3===e&&(t.rgb_color=ww(r.readVarint()));}function Sw(e,t,r){1===e?t.transform=gw(r,r.readVarint()+r.pos):2===e?t.spread_method=r.readVarint():3===e?t.stops.push(Mw(r,r.readVarint()+r.pos)):4===e?t.cx=r.readFloat():5===e?t.cy=r.readFloat():6===e?t.r=r.readFloat():7===e?t.fx=r.readFloat():8===e?t.fy=r.readFloat():9===e&&(t.fr=r.readFloat());}function zw(e,t,r){1===e?t.transform=gw(r,r.readVarint()+r.pos):2===e?t.clip_path_idx=r.readVarint():3===e&&t.children.push(fw(r,r.readVarint()+r.pos));}function Pw(e,t,r){1===e?t.left=t.top=r.readFloat():2===e?t.width=t.height=r.readFloat():3===e?t.top=r.readFloat():4===e?t.height=r.readFloat():5===e?t.mask_type=r.readVarint():6===e?t.mask_idx=r.readVarint():7===e&&t.children.push(fw(r,r.readVarint()+r.pos));}class Bw{static calculate(e={},t=[]){const r=new Map,n=new Map;if(0===Object.keys(e).length)return r;t.forEach(e=>{n.set(e.name,e.rgb_color||new ar(0,0,0));});for(const[t,i]of Object.entries(e))n.has(t)?r.set(n.get(t).toString(),i):console.warn(`Ignoring unknown image variable "${t}"`);return r}}function Tw(e,t=255,r){const n=t/255,i=e.toString(),s=r.has(i)?r.get(i).clone():e.clone();return s.a*=n,s.toString()}function kw(e,t){if(!yt()){const r=document.createElement("canvas");return r.width=e,r.height=t,r}return new OffscreenCanvas(e,t)}let Vw,Ew=null;function Fw(e,t,r,n,i){for(const s of n.children)Dw(e,t,r,s,i);}function Dw(e,t,r,n,i){n.group?(e.save(),function(e,t,r,n,i){const s=null!=n.mask_idx?r.masks[n.mask_idx]:null,o=null!=n.clip_path_idx?r.clip_paths[n.clip_path_idx]:null;if(n.transform&&(t=$w(n.transform).preMultiplySelf(t)),!function(e,t,r){return 255!==e.opacity||t||r}(n,null!=o,null!=s))return void Fw(e,t,r,n,i);const a=kw(e.canvas.width,e.canvas.height),l=a.getContext("2d");Fw(l,t,r,n,i),o&&jw(l,t,r,o),s&&Gw(l,t,r,s,i),e.globalAlpha=n.opacity/255,e.drawImage(a,0,0);}(e,t,r,n.group,i),e.restore()):n.path&&(e.save(),function(e,t,r,n,i){e.setTransform(t),1===n.paint_order?(Cw(e,r,n,i),Lw(e,r,n,i)):(Lw(e,r,n,i),Cw(e,r,n,i));}(e,t,r,n.path,i),e.restore());}function Cw(e,t,r,n){const i=r.fill;if(!i)return;const s=i.opacity/255;switch(e.save(),e.beginPath(),qw(r,e),i.paint){case "rgb_color":e.fillStyle=Tw(i.rgb_color,i.opacity,n);break;case "linear_gradient_idx":{const r=t.linear_gradients[i.linear_gradient_idx];r.transform&&e.setTransform($w(r.transform).preMultiplySelf(e.getTransform())),e.fillStyle=Ow(e,r,s,n);break}case "radial_gradient_idx":{const r=t.radial_gradients[i.radial_gradient_idx];r.transform&&e.setTransform($w(r.transform).preMultiplySelf(e.getTransform())),e.fillStyle=Uw(e,r,s,n);}}e.fill(Rw(r)),e.restore();}function Rw(e){return 1===e.rule?"nonzero":2===e.rule?"evenodd":void 0}function Lw(e,t,r,n){const i=r.stroke;if(!i)return;const s=Xw(r);e.lineWidth=i.width,e.miterLimit=i.miterlimit,e.setLineDash(i.dasharray),e.lineDashOffset=i.dashoffset;const o=i.opacity/255;switch(i.paint){case "rgb_color":e.strokeStyle=Tw(i.rgb_color,i.opacity,n);break;case "linear_gradient_idx":e.strokeStyle=Ow(e,t.linear_gradients[i.linear_gradient_idx],o,n,!0);break;case "radial_gradient_idx":e.strokeStyle=Uw(e,t.radial_gradients[i.radial_gradient_idx],o,n,!0);}switch(i.linejoin){case 2:case 1:e.lineJoin="miter";break;case 3:e.lineJoin="round";break;case 4:e.lineJoin="bevel";}switch(i.linecap){case 1:e.lineCap="butt";break;case 2:e.lineCap="round";break;case 3:e.lineCap="square";}e.stroke(s);}function Ow(e,t,r,n,i=!1){if(1===t.stops.length){const e=t.stops[0];return Tw(e.rgb_color,e.opacity*r,n)}const{x1:s,y1:o,x2:a,y2:l}=t;let u=new DOMPoint(s,o),c=new DOMPoint(a,l);if(i){const e=$w(t.transform);u=e.transformPoint(u),c=e.transformPoint(c);}const h=e.createLinearGradient(u.x,u.y,c.x,c.y);for(const e of t.stops)h.addColorStop(e.offset,Tw(e.rgb_color,e.opacity*r,n));return h}function Uw(e,t,r,n,i=!1){if(1===t.stops.length){const e=t.stops[0];return Tw(e.rgb_color,e.opacity*r,n)}const s=$w(t.transform),{fx:o,fy:a,fr:l,cx:u,cy:c,r:h}=t;let p=new DOMPoint(o,a),d=new DOMPoint(u,c),f=l,m=h;if(i){p=s.transformPoint(p),d=s.transformPoint(d);const e=(s.a+s.d)/2;f=l*e,m=t.r*e;}const y=e.createRadialGradient(p.x,p.y,f,d.x,d.y,m);for(const e of t.stops)y.addColorStop(e.offset,Tw(e.rgb_color,e.opacity*r,n));return y}function Nw(e,t,r,n){const i=n.transform?$w(n.transform).preMultiplySelf(t):t,s=kw(e.canvas.width,e.canvas.height),o=s.getContext("2d");for(const e of n.children)if(e.group)Nw(o,i,r,e.group);else if(e.path){const t=e.path,r=new Path2D;r.addPath(Xw(t),i),o.fill(r,Rw(t));}const a=null!=n.clip_path_idx?r.clip_paths[n.clip_path_idx]:null;a&&jw(o,i,r,a),e.globalCompositeOperation="source-over",e.drawImage(s,0,0);}function jw(e,t,r,n){const i=kw(e.canvas.width,e.canvas.height);Nw(i.getContext("2d"),t,r,n),e.globalCompositeOperation="destination-in",e.drawImage(i,0,0);}function Gw(e,t,r,n,i){if(0===n.children.length)return;const s=null!=n.mask_idx?r.masks[n.mask_idx]:null;s&&Gw(e,t,r,s,i);const o=e.canvas.width,a=e.canvas.height,l=kw(o,a),u=l.getContext("2d"),c=n.width,h=n.height,p=n.left,d=n.top,f=new Path2D,m=new Path2D;m.rect(p,d,c,h),f.addPath(m,t),u.clip(f);for(const e of n.children)Dw(u,t,r,e,i);const y=u.getImageData(0,0,o,a),g=y.data;if(1===n.mask_type)for(let e=0;et[o])return null}else {const a=1/n[o];let l=(e[o]-r[o])*a,u=(t[o]-r[o])*a;if(l>u){const e=l;l=u,u=e;}if(l>i&&(i=l),us)return null}return i}function Kw(e,t,r,n,i,s,o,a,l,u,c){const h=n-e,p=i-t,d=s-r,f=o-e,m=a-t,y=l-r,g=c[1]*y-c[2]*m,x=c[2]*f-c[0]*y,v=c[0]*m-c[1]*f,b=h*g+p*x+d*v;if(Math.abs(b)<1e-15)return null;const w=1/b,_=u[0]-e,A=u[1]-t,M=u[2]-r,I=(_*g+A*x+M*v)*w;if(I<0||I>1)return null;const S=A*d-M*p,z=M*h-_*d,P=_*p-A*h,B=(c[0]*S+c[1]*z+c[2]*P)*w;return B<0||I+B>1?null:(f*S+m*z+y*P)*w}function Qw(e,t,r){return (e-t)/(r-t)}function e_(e,t,r,n,i,s,o,a,l){const u=1<{const s=n?1:0,o=(e+1)*r-s,a=t*r,l=(t+1)*r-s;i[0]=e*r,i[1]=a,i[2]=o,i[3]=l;};let o=new Yw(n);const a=[];for(let t=0;t=1;n/=2){const e=r[r.length-1];o=new Yw(n);for(let t=0;t0;){const{idx:a,t:d,nodex:f,nodey:m,depth:y}=p.pop();if(this.leaves[a]){e_(f,m,y,e,t,r,n,c,h);const a=1<=e[2])return d}continue}let g=0;for(let p=0;p=l[u[r]]&&(u.splice(r,0,p),t=!0);t||(u[g]=p),g++;}}for(let e=0;e=this.dim+1||t<-1||t>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return (t+1)*this.stride+(e+1)}static pack(e,t){const r=[0,0,0,0],n=a_.getUnpackVector(t);let i=Math.floor((e+n[3])/n[2]);return r[2]=i%256,i=Math.floor(i/256),r[1]=i%256,i=Math.floor(i/256),r[0]=i,r}getPixels(){return new $h({width:this.stride,height:this.stride},this.pixels)}backfillBorder(e,t,r){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let n=t*this.dim,i=t*this.dim+this.dim,s=r*this.dim,o=r*this.dim+this.dim;switch(t){case -1:n=i-1;break;case 1:i=n+1;}switch(r){case -1:s=o-1;break;case 1:o=s+1;}const a=-t*this.dim,l=-r*this.dim;for(let t=s;t=1;n--){const i=1===n?1:0,s=2===n?1:0;for(let n=0;n>>1^-(1&e[t]);return e}function x_(e,t){switch(t){case "uint32":return e;case "uint16":for(let t=0;t>4|(61440&r)>>8|(240&n)<<4|61440&n,e[t+1]=15&r|(3840&r)>>4|(15&n)<<8|(3840&n)<<4;}return e;case "uint8":for(let t=0;t>6|(192&n)>>4|(192&i)>>2|192&s,e[t+1]=(48&r)>>4|(48&n)>>2|48&i|(48&s)<<2,e[t+2]=(12&r)>>2|12&n|(12&i)<<2|(12&s)<<4,e[t+3]=3&r|(3&n)<<2|(3&i)<<4|(3&s)<<6;}return e;default:throw new Error(`Invalid pixel format, "${t}"`)}}Js(a_,"DEMData"),Js(t_,"DemMinMaxQuadTree",{omit:["dem"]});var v_=Uint8Array,b_=Uint16Array,w_=Int32Array,__=new v_([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]),A_=new v_([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]),M_=new v_([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),I_=function(e,t){for(var r=new b_(31),n=0;n<31;++n)r[n]=t+=1<>1|(21845&k_)<<1;T_[k_]=((65280&(V_=(61680&(V_=(52428&V_)>>2|(13107&V_)<<2))>>4|(3855&V_)<<4))>>8|(255&V_)<<8)>>1;}var E_=function(e,t,r){for(var n=e.length,i=0,s=new b_(t);i>l]=u;return o},F_=new v_(288);for(k_=0;k_<144;++k_)F_[k_]=8;for(k_=144;k_<256;++k_)F_[k_]=9;for(k_=256;k_<280;++k_)F_[k_]=7;for(k_=280;k_<288;++k_)F_[k_]=8;var D_=new v_(32);for(k_=0;k_<32;++k_)D_[k_]=5;var C_=E_(F_,9),R_=E_(D_,5),L_=function(e){for(var t=e[0],r=1;rt&&(t=e[r]);return t},O_=function(e,t,r){var n=t/8|0;return (e[n]|e[n+1]<<8)>>(7&t)&r},U_=function(e,t){var r=t/8|0;return (e[r]|e[r+1]<<8|e[r+2]<<16)>>(7&t)},N_=function(e){return (e+7)/8|0},j_=["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"],G_=function(e,t,r){var n=new Error(t||j_[e]);if(n.code=e,Error.captureStackTrace&&Error.captureStackTrace(n,G_),!r)throw n;return n},$_=new v_(0);var q_="undefined"!=typeof TextDecoder&&new TextDecoder;try{q_.decode($_,{stream:!0});}catch(e){}const X_={gzip_data:"gzip"};class H_ extends Error{constructor(e){super(e),this.name="MRTError";}}const Z_={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},W_={uint32:1,uint16:2,uint8:4},Y_={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let J_;class K_{constructor(e=5){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=e;}getLayer(e){const t=this.layers[e];if(!t)throw new H_(`Layer '${e}' not found`);return t}getHeaderLength(e){const t=new Uint8Array(e),r=new DataView(e);if(13!==t[0])throw new H_("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} but got buffer of length ${t.length}`);const n=new J_(t.subarray(0,r)).readFields(l_,{headerLength:0,x:0,y:0,z:0,layers:[]},void 0);if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new H_(`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 Q_(e,{cacheSize:this._cacheSize});return this}createDecodingTask(e){const t=[],r=this.getLayer(e.layerName);for(let n of e.blockIndices){const i=r.dataIndex[n],s=i.firstByte-e.firstByte,o=i.lastByte-e.firstByte;if(r._blocksInProgress.has(n))continue;const a={layerName:r.name,firstByte:s,lastByte:o,pixelFormat:r.pixelFormat,blockIndex:n,blockShape:[i.bands.length].concat(r.bandShape),buffer:r.buffer,codec:i.codec.codec,filters:i.filters.map(e=>e.filter)};r._blocksInProgress.add(n),t.push(a);}return new eA(t,()=>{t.forEach(e=>r._blocksInProgress.delete(e.blockIndex));},(e,n)=>{if(t.forEach(e=>r._blocksInProgress.delete(e.blockIndex)),e)throw e;n.forEach(e=>{this.getLayer(e.layerName).processDecodedData(e);});})}}class Q_{constructor({version:e,name:t,units:r,tileSize:n,pixelFormat:i,buffer:s,dataIndex:o},a){if(this.version=e,1!==this.version)throw new H_(`Cannot parse raster layer encoded with MRT version ${e}`);this.name=t,this.units=r,this.tileSize=n,this.buffer=s,this.pixelFormat=Z_[i],this.dataIndex=o,this.bandShape=[n+2*s,n+2*s,W_[this.pixelFormat]],this._decodedBlocks=new Zw(a?a.cacheSize:5),this._blocksInProgress=new Set;}get dimension(){return W_[this.pixelFormat]}get cacheSize(){return this._decodedBlocks.capacity}getBandList(){return this.dataIndex.map(({bands:e})=>e).flat()}processDecodedData(e){const t=e.blockIndex.toString();this._decodedBlocks.get(t)||this._decodedBlocks.put(t,e.data);}getBlockForBand(e){let t=0;switch(typeof e){case "string":for(const[r,n]of this.dataIndex.entries()){for(const[i,s]of n.bands.entries())if(s===e)return {bandIndex:t+i,blockIndex:r,blockBandIndex:i};t+=n.bands.length;}break;case "number":for(const[r,n]of this.dataIndex.entries()){if(e>=t&&ethis.cacheSize)throw new H_(`Number of blocks to decode (${i.size}) exceeds cache size (${this.cacheSize}).`);return {layerName:this.name,firstByte:t,lastByte:r,blockIndices: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);if(t<0)throw new H_(`Band not found: ${JSON.stringify(e)}`);const n=this._decodedBlocks.get(t.toString());if(!n)throw new H_(`Data for band ${JSON.stringify(e)} of layer "${this.name}" not decoded.`);const i=this.dataIndex[t],s=this.bandShape.reduce((e,t)=>e*t,1),o=r*s,a=n.subarray(o,o+s);return {data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:i.offset,scale:i.scale}}}K_.setPbf=function(e){J_=e;};class eA{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);}}K_.performDecoding=function(e,t){const r=new Uint8Array(e);return Promise.all(t.tasks.map(e=>{const{layerName:t,firstByte:n,lastByte:i,pixelFormat:s,blockShape:o,blockIndex:a,filters:l,codec:u}=e,c=r.subarray(n,i+1),h=new Uint32Array(o[0]*o[1]*o[2]);let p;if("gzip_data"!==u)throw new H_(`Unhandled codec: ${u}`);return p=function(e,t){if(!globalThis.DecompressionStream&&"gzip_data"===t)return Promise.resolve((o=function(e){31==e[0]&&139==e[1]&&8==e[2]||G_(6,"invalid gzip data");var t=e[3],r=10;4&t&&(r+=2+(e[10]|e[11]<<8));for(var n=(t>>3&1)+(t>>4&1);n>0;n-=!e[r++]);return r+(2&t)}(r=e),o+8>r.length&&G_(6,"invalid gzip data"),function(e,t,r,n){var i=e.length;if(!i||t.f&&!t.l)return r||new v_(0);var s=!r,o=s||2!=t.i,a=t.i;s&&(r=new v_(3*i));var l=function(e){var t=r.length;if(e>t){var n=new v_(Math.max(2*t,e));n.set(r),r=n;}},u=t.f||0,c=t.p||0,h=t.b||0,p=t.l,d=t.d,f=t.m,m=t.n,y=8*i;do{if(!p){u=O_(e,c,1);var g=O_(e,c+1,3);if(c+=3,!g){var x=e[(B=N_(c)+4)-4]|e[B-3]<<8,v=B+x;if(v>i){a&&G_(0);break}o&&l(h+x),r.set(e.subarray(B,v),h),t.b=h+=x,t.p=c=8*v,t.f=u;continue}if(1==g)p=C_,d=R_,f=9,m=5;else if(2==g){var b=O_(e,c,31)+257,w=O_(e,c+10,15)+4,_=b+O_(e,c+5,31)+1;c+=14;for(var A=new v_(_),M=new v_(19),I=0;I>4)<16)A[I++]=B;else {var k=0,V=0;for(16==B?(V=3+O_(e,c,3),c+=2,k=A[I-1]):17==B?(V=3+O_(e,c,7),c+=3):18==B&&(V=11+O_(e,c,127),c+=7);V--;)A[I++]=k;}}var E=A.subarray(0,b),F=A.subarray(b);f=L_(E),m=L_(F),p=E_(E,f),d=E_(F,m);}else G_(1);if(c>y){a&&G_(0);break}}o&&l(h+131072);for(var D=(1<>4;if((c+=15&k)>y){a&&G_(0);break}if(k||G_(2),L<256)r[h++]=L;else {if(256==L){R=c,p=null;break}var O=L-254;L>264&&(O=O_(e,c,(1<<(j=__[I=L-257]))-1)+z_[I],c+=j);var U=d[U_(e,c)&C],N=U>>4;if(U||G_(3),c+=15&U,F=B_[N],N>3){var j=A_[N];F+=U_(e,c)&(1<y){a&&G_(0);break}o&&l(h+131072);var G=h+O;if(he.length)&&(r=e.length),new v_(e.subarray(0,r))}(r,0,h):r.subarray(0,h)}(r.subarray(o,-8),{i:2},new v_(((i=r)[(s=i.length)-4]|i[s-3]<<8|i[s-2]<<16|i[s-1]<<24)>>>0),n)));var r,n,i,s,o;const a=X_[t];if(!a)throw new Error(`Unhandled codec: ${t}`);const l=new globalThis.DecompressionStream(a);return new Response(new Blob([e]).stream().pipeThrough(l)).arrayBuffer().then(e=>new Uint8Array(e))}(c,u).then(e=>(function(e,t){e.readFields(f_,t);}(new J_(e),h),new(0,Y_[s])(h.buffer))),p.then(e=>{for(let t=l.length-1;t>=0;t--)switch(l[t]){case "delta_filter":y_(e,o);break;case "zigzag_filter":g_(e);break;case "bitshuffle_filter":x_(e,s);break;default:throw new H_(`Unhandled filter "${l[t]}"`)}return {layerName:t,blockIndex:a,data:e}}).catch(e=>{throw e})}))},Js(eA,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]}),Js(K_,"MapboxRasterTile"),Js(Q_,"MapboxRasterLayer",{omit:["_blocksInProgress"]});class tA{constructor(e){this._stringToNumber={},this._numberToString=[];for(let t=0;t=0&&n[3]>=0&&l.insert(a,n[0],n[1],n[2],n[3]);}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new rc(new Tg(this.rawTileData)).layers,this.sourceLayerCoder=new tA(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const e in this.vtLayers)this.vtFeatures[e]=[];}return this.vtLayers}query(e,t){const{tilespaceGeometry:r,transform:n,tileTransform:i,pixelPosMatrix:s,availableImages:o,worldview:a}=t;this.loadVTLayers(),this.serializedLayersCache.clear();const l=t.queryRadius?t.queryRadius:0,u=r.bufferedTilespaceBounds,c=this.grid.query(u.min.x,u.min.y,u.max.x,u.max.y,(e,t,n,i)=>Rc(r.bufferedTilespaceGeometry,e-l,t-l,n+l,i+l));c.sort(iA);let h=null;n.elevation&&c.length>0&&(h=jb.create(n.elevation,this.tileID));const p={};let d;for(let l=0;l(m||(m=Wu(e,this.tileID.canonical,i)),o.queryIntersectsFeature(r,e,a,m,this.z,n,s,h,l,t.scope)));}return p}loadMatchingFeature(e,t,r,n,i,s){const{featureIndex:o,bucketIndex:a,sourceLayerIndex:l,layoutVertexArrayOffset:u}=t,c=this.bucketLayerIDs[a],h=r.layers,p=Object.keys(h);if(p.length&&!Xe(p,c))return;const d=r.sourceCache,f=this.sourceLayerCoder.decode(l),m=this.vtLayers[f].feature(o),y=this.getId(m,f);for(let t=0;t`${e.key}: ${e.message}`).join(", ");return void Ze(`Failed to create expression for promoteId: ${t}`)}this.promoteIdExpression=e.value;}r=this.promoteIdExpression.evaluate({zoom:0},e);}else r=e.properties[n];"boolean"==typeof r&&(r=Number(r));}return r}}function nA(e,t,r,n,i){return Ge(e,(e,s)=>{const o=t instanceof ia?t.get(s):null;return o&&o.evaluate?o.evaluate(r,n,void 0,i):o})}function iA(e,t){return t-e}Js(rA,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const sA=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class oA{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 n=r>>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const i=sA[15&r];if(!i)throw new Error("Unrecognized array type.");const[s]=new Uint16Array(e,2,1),[o]=new Uint32Array(e,4,1);return new oA(o,s,i,e)}constructor(e,t=64,r=Float64Array,n){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 i=sA.indexOf(this.ArrayType),s=2*e*this.ArrayType.BYTES_PER_ELEMENT,o=e*this.IndexArrayType.BYTES_PER_ELEMENT,a=(8-o%8)%8;if(i<0)throw new Error(`Unexpected typed array class: ${r}.`);n&&n instanceof ArrayBuffer?(this.data=n,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+o+a,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+s+o+a),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+o+a,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+i]),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 aA(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,r,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:i,coords:s,nodeSize:o}=this,a=[0,i.length-1,0],l=[];for(;a.length;){const u=a.pop()||0,c=a.pop()||0,h=a.pop()||0;if(c-h<=o){for(let o=h;o<=c;o++){const a=s[2*o],u=s[2*o+1];a>=e&&a<=r&&u>=t&&u<=n&&l.push(i[o]);}continue}const p=h+c>>1,d=s[2*p],f=s[2*p+1];d>=e&&d<=r&&f>=t&&f<=n&&l.push(i[p]),(0===u?e<=d:t<=f)&&(a.push(h),a.push(p-1),a.push(1-u)),(0===u?r>=d:n>=f)&&(a.push(p+1),a.push(c),a.push(1-u));}return l}within(e,t,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:i,nodeSize:s}=this,o=[0,n.length-1,0],a=[],l=r*r;for(;o.length;){const u=o.pop()||0,c=o.pop()||0,h=o.pop()||0;if(c-h<=s){for(let r=h;r<=c;r++)hA(i[2*r],i[2*r+1],e,t)<=l&&a.push(n[r]);continue}const p=h+c>>1,d=i[2*p],f=i[2*p+1];hA(d,f,e,t)<=l&&a.push(n[p]),(0===u?e-r<=d:t-r<=f)&&(o.push(h),o.push(p-1),o.push(1-u)),(0===u?e+r>=d:t+r>=f)&&(o.push(p+1),o.push(c),o.push(1-u));}return a}}function aA(e,t,r,n,i,s){if(i-n<=r)return;const o=n+i>>1;lA(e,t,o,n,i,s),aA(e,t,r,n,o-1,1-s),aA(e,t,r,o+1,i,1-s);}function lA(e,t,r,n,i,s){for(;i>n;){if(i-n>600){const o=i-n+1,a=r-n+1,l=Math.log(o),u=.5*Math.exp(2*l/3),c=.5*Math.sqrt(l*u*(o-u)/o)*(a-o/2<0?-1:1);lA(e,t,r,Math.max(n,Math.floor(r-a*u/o+c)),Math.min(i,Math.floor(r+(o-a)*u/o+c)),s);}const o=t[2*r+s];let a=n,l=i;for(uA(e,t,n,r),t[2*i+s]>o&&uA(e,t,n,i);ao;)l--;}t[2*n+s]===o?uA(e,t,n,l):(l++,uA(e,t,l,i)),l<=r&&(n=l+1),r<=l&&(i=l-1);}}function uA(e,t,r,n){cA(e,r,n),cA(t,2*r,2*n),cA(t,2*r+1,2*n+1);}function cA(e,t,r){const n=e[t];e[t]=e[r],e[r]=n;}function hA(e,t,r,n){const i=e-r,s=t-n;return i*i+s*s}e.$=nn,e.A=Kt,e.B=Cr,e.C=Sa,e.D=qf,e.E=rr,e.F=2,e.G=Px,e.H=_x,e.I=nr,e.J=Wr,e.K=ca,e.L=Zr,e.M=Jr,e.N=Bs,e.O=Ss,e.P=Ie,e.Q=Ps,e.R=Dt,e.S=Os,e.T=Em,e.U=ha,e.V=Db,e.W=Us,e.X=Gs,e.Y=gi,e.Z=mi,e._=yi,e.a=function(e){return at.API_CDN_URL_REGEX.test(e)},e.a$=Eu,e.a0=Kr,e.a1=Yr,e.a2=or,e.a3=pa,e.a4=class extends Db{},e.a5=Ts,e.a6=zs,e.a7=ua,e.a8=function(e){const t=e.value;return t?Yr(t)?Cb(t,!0)?[]:[new Db(e.key,t,`invalid url "${t}"`)]:[new Db(e.key,t,`string expected, "${Zr(t)}" found`)]:[]},e.a9=Qo,e.aA=function(e){let t=1/0,r=1/0,n=-1/0,i=-1/0;for(const s of e)t=Math.min(t,s.x),r=Math.min(r,s.y),n=Math.max(n,s.x),i=Math.max(i,s.y);return {min:new Ie(t,r),max:new Ie(n,i)}},e.aB=De,e.aC=h,e.aD=ee,e.aE=xu,e.aF=Cc,e.aG=Tu,e.aH=Gu,e.aI=function(e,t){const r={};for(let n=0;n{n(e,r);},t):n(e,r),()=>{}}return i.callbacks.push(n),i.cancel||(i.cancel=r((r,n)=>{i.result=[r,n];for(const e of i.callbacks)this.scheduler?this.scheduler.add(()=>{e(r,n);},t):e(r,n);setTimeout(()=>delete this.entries[e],3e3);})),()=>{i.result||(i.callbacks=i.callbacks.filter(e=>e!==n),i.callbacks.length||(i.cancel(),delete this.entries[e]));}}},e.aM=function(e,t,r){const n=JSON.stringify(e.request);return e.data&&(this.deduped.entries[n]={result:[null,e.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:e.isSymbolTile,zoom:e.tileZoom},t=>{const n=Ot(e.request,(e,n,i)=>{e?t(e):n&&t(null,{rawData:n,vectorTile:r?void 0:new rc(new Tg(n)),responseHeaders:new Map(i.entries())});});return ()=>{n.cancel(),t();}},t)},e.aN=function(e){return e?{cacheControl:e.get("cache-control"),expires:e.get("expires")}:{cacheControl:void 0,expires:void 0}},e.aO=Ct,e.aP=function(e){zt++,zt>_t&&(e.getActor().send("enforceCacheSizeLimit",wt),zt=0);},e.aQ=function(e){return e<=1?1:Math.pow(2,Math.floor(Math.log2(e)))},e.aR=Wc,e.aS=Ib,e.aT=kb,e.aU=zu,e.aV=_b,e.aW=function(e,t){const r=document.createElement("video");r.muted=!0,r.onloadstart=function(){t(null,r);};for(let t=0;t{}}},e.aX=Fm,e.aY=tw,e.aZ=je,e.a_=zv,e.aa=la,e.ab=sa,e.ac=class{constructor(e){this.specification=e;}possiblyEvaluate(e,t){return Je(e.expression.evaluate(t))}interpolate(e,t,r){return {x:hr(e.x,t.x,r),y:hr(e.y,t.y,r),z:hr(e.z,t.z,r),azimuthal:hr(e.azimuthal,t.azimuthal,r),polar:hr(e.polar,t.polar,r)}}},e.ad=Yo,e.ae=js,e.af=Nu,e.ag=j,e.ah=M,e.ai=Ce,e.aj=ia,e.ak=wh,e.al=hr,e.am=Un,e.an=pr,e.ao=Be,e.ap=ar,e.aq=class{constructor(e){this.specification=e;}possiblyEvaluate(e,t){return function([e,t]){const r=Je([1,e,t]);return {x:r.x,y:r.y,z:r.z}}(e.expression.evaluate(t))}interpolate(e,t,r){return {x:hr(e.x,t.x,r),y:hr(e.y,t.y,r),z:hr(e.z,t.z,r)}}},e.ar=function(e,t,r=0,n=!0){const i=new Ie(r,r),s=e.sub(i),o=t.add(i),a=[s,new Ie(o.x,s.y),o,new Ie(s.x,o.y)];return n&&a.push(s.clone()),a},e.as=function(e,t){const r=[];for(let n=0;n1)return !1;const r=t.getSource().maxzoom,n=1<1)return t;const i=n.getSource().maxzoom,s=1<{const a=this.getAtTileOffset(e,i,s,o),l=n.upVector(e.canonical,i.x,i.y);return V(l,l,a*n.upVectorScale(e.canonical,t,r).metersToTile),l}}getForTilePoints(e,t,r,n){if(this.isUsingMockSource())return !1;const i=jb.create(this,e,n);return !!i&&(t.forEach(e=>{e[2]=this.exaggeration()*i.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,n=t.tileID,i=1<0&&r[0]<=e.width&&r[1]>0&&r[1]<=e.height&&!Ah(e,new zu(e.center.lat,90)),n[0]>0&&n[0]<=e.width&&n[1]>0&&n[1]<=e.height&&!Ah(e,new zu(e.center.lat,-90))]},e.cO=function(e,t){const{scale:r}=e.tileTransform,n=r*Un/(e.tileSize*Math.pow(2,t.zoom-e.tileID.overscaledZ+e.tileID.canonical.z));return function(e,t,r){var n=t[1],i=t[2],s=t[3],o=r[0],a=r[1];return e[0]=t[0]*o,e[1]=n*o,e[2]=i*a,e[3]=s*a,e}(new Float32Array(4),t.inverseAdjustmentMatrix,[n,n])},e.cP=$m,e.cQ=w,e.cR=jm,e.cS=function(e){const t=jm(e,!0);return n([],[t[0],t[1],t[4],t[5]])},e.cT=d,e.cU=dc,e.cV=f,e.cW=function(e){const{x:t,y:r}=e.point,{lng:n,lat:i}=e._center;return bh(t,r,e.worldSize,n,i)},e.cX=B,e.cY=Te,e.cZ=Yc,e.c_=Lc,e.ca=ne,e.cb=tt,e.cc=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},e.cd=b,e.ce=function(e,t,r,n,i){var s=1/Math.tan(t/2);if(e[0]=s/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=i&&i!==1/0){var o=1/(n-i);e[10]=(i+n)*o,e[14]=2*i*n*o;}else e[10]=-1,e[14]=-2*n;return e},e.cf=function(e,t,r,n,i,s,o){var a=1/(t-r),l=1/(n-i),u=1/(s-o);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*u,e[11]=0,e[12]=(t+r)*a,e[13]=(i+n)*l,e[14]=(o+s)*u,e[15]=1,e},e.cg=Vu,e.ch=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.ci=Hl,e.cj=Yl,e.ck=Zl,e.cl=Wl,e.cm=eu,e.cn=Wv,e.co=function(){var e=new r(4);return r!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e},e.cp=function(e,t,r){var n=t[0],i=t[1],s=t[2],o=t[3],a=Math.sin(r),l=Math.cos(r);return e[0]=n*l+s*a,e[1]=i*l+o*a,e[2]=n*-a+s*l,e[3]=i*-a+o*l,e},e.cq=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]},e.cr=X,e.cs=function(e){var t=e[0],r=e[1],n=e[2],i=e[3];return Math.sqrt(t*t+r*r+n*n+i*i)},e.ct=le,e.cu=$,e.cv=Zc,e.cw=3,e.cx=2,e.cy=7,e.cz=6,e.d=function(e){return at.API_TILEJSON_REGEX.test(e)},e.d$=il,e.d0=function(e,t,r){let n=0;for(let r=0;r<2;++r){const i=0;e[r]>i&&(n+=(e[r]-i)*(e[r]-i)),t[r]0?Math.acos(r/n)*Pe:0;let s=0!==e||0!==t?Math.atan2(-t,-e)*Pe+90:0;return s<0&&(s+=360),[n,s,i]},e.d6=I,e.d7=Je,e.d8=Uu,e.d9=z,e.dA=class extends ew{constructor(e,t){super(e._vectorTileFeature,e._z,e._x,e._y,e.id),e.state&&(this.state=Object.assign({},e.state)),this.target=t.target,this.namespace=t.namespace,t.properties&&(this.properties=t.properties),this.target&&("featuresetId"in this.target&&!this.target.importId||"layerId"in this.target)&&(this.source=e.source,this.sourceLayer=e.sourceLayer,this.layer=e.layer);}toJSON(){const e=super.toJSON();return e.target=this.target,e.namespace=this.namespace,e}},e.dB=Xo,e.dC=function(e){return e({pluginStatus:jo,pluginURL:Go}),Xo.on("pluginStateChange",e),e},e.dD=Kl,e.dE=class extends Xl{constructor(e){super(e),this.current=tu;}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.dF=Ve,e.dG=function(e,t,r){const n=wh(r.zoom),i=e.style.map._antialias,s=e.terrain&&e.terrain.exaggeration()>0;return 0===n&&!i&&!s},e.dH=function(e){const t=e.pixelsPerMeter,r=t/Vu(1,e.center.lat),n=u(new Float64Array(16));return p(n,n,[e.point.x,e.point.y,0]),d(n,n,[r,r,t]),Float32Array.from(n)},e.dI=hh,e.dJ=function(e){const t=80.051129;e=De(e,-80.051129,t)/t*90;const r=Math.pow(Math.abs(Math.sin(Be(e))),3);return Math.round(r*(bu.length-1))},e.dK=function(e,t,r,n){const i=t.getNorth(),s=t.getSouth(),a=t.getWest(),l=t.getEast(),u=1<0){const e=180/n;o(f,f,[e/c+1,0,0,0,e/h+1,0,-.5*e/p,.5*e/d,1]);}return f[2]=u,f[5]=e.x,f[8]=e.y,f},e.dL=ah,e.dM=function(e,t,r){const n=u(new Float64Array(16)),i=(t/(1<({u_matrix:new eu(e),u_texsize:new Wl(e),u_pixels_to_tile_units:new nu(e),u_device_pixel_ratio:new Zl(e),u_width_scale:new Zl(e),u_floor_width_scale:new Zl(e),u_image:new Hl(e),u_units_to_pixels:new Wl(e),u_tile_units_to_pixels:new Zl(e),u_alpha_discard_threshold:new Zl(e),u_trim_offset:new Wl(e),u_trim_fade_range:new Wl(e),u_trim_gradient_mix_range:new Wl(e),u_trim_color:new Jl(e),u_zbias_factor:new Zl(e),u_tile_to_meter:new Zl(e),u_ground_shadow_factor:new Yl(e),u_pattern_transition:new Zl(e)}),e.dZ=e=>({u_matrix:new eu(e),u_pixels_to_tile_units:new nu(e),u_device_pixel_ratio:new Zl(e),u_width_scale:new Zl(e),u_floor_width_scale:new Zl(e),u_units_to_pixels:new Wl(e),u_dash_image:new Hl(e),u_gradient_image:new Hl(e),u_image_height:new Zl(e),u_texsize:new Wl(e),u_tile_units_to_pixels:new Zl(e),u_alpha_discard_threshold:new Zl(e),u_trim_offset:new Wl(e),u_trim_fade_range:new Wl(e),u_trim_gradient_mix_range:new Wl(e),u_trim_color:new Jl(e),u_zbias_factor:new Zl(e),u_tile_to_meter:new Zl(e),u_ground_shadow_factor:new Yl(e)}),e.d_=e=>({u_camera_to_center_distance:new Zl(e),u_extrude_scale:new nu(e),u_device_pixel_ratio:new Zl(e),u_matrix:new eu(e),u_inv_rot_matrix:new eu(e),u_merc_center:new Wl(e),u_tile_id:new Yl(e),u_zoom_transition:new Zl(e),u_up_dir:new Yl(e),u_emissive_strength:new Zl(e)}),e.da=vc,e.db=P,e.dc=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.dd=Tm,e.de=my,e.df=ty,e.dg=Cb,e.dh=function(e,t){return e.readFields(ow,{icons:[]},t)},e.di=zc,e.dj=class{static calculate(e,t,r){const n=new Set,i=new Map,s=new Set,o=new Set;for(const r of Object.values(e))for(const[e,a]of Object.entries(r.floors)){s.add(e),a.isDefault&&o.add(e),a.conflicts&&i.set(e,a.conflicts);const r=e===t,l=a.connections&&t&&a.connections.has(t);(r||l)&&n.add(e);}const a=e=>{const t=i.get(e)||new Set;for(const r of n)if((i.get(r)||new Set).has(e)||t.has(r))return !0;return !1};if(r)for(const e of r)s.has(e)&&(a(e)||n.add(e));for(const e of o)n.has(e)||a(e)||n.add(e);return n}},e.dk=Zf,e.dl=Rx,e.dm=Cx,e.dn=Rt,e.dp=$o,e.dq=vt,e.dr=Jt,e.ds=qe,e.dt=function(e){const t=e.indexOf(Ia);return t>=0?e.slice(0,t):e},e.du=function(e){return e.indexOf(Ia)>=0},e.dv=function(e){const t=e.lastIndexOf(Ia);return t>=0?e.slice(t+1):""},e.dw=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.dx=function(e,t,r,n){return "custom"===e.type?new Vb(e,t):new iw[e.type](e,t,r,n)},e.dy=$e,e.dz=function(e){const t=e.indexOf(Ia);return t>=0?e.slice(t+1):""},e.e=at,e.e$=Z,e.e0=wg,e.e1=class{constructor(e,t,r,n){this.context=e,this.format=n,this.size=r,this.texture=e.gl.createTexture();const[i,s,o]=this.size,{gl:a}=e;a.bindTexture(a.TEXTURE_3D,this.texture),e.pixelStoreUnpackFlipY.set(!1),e.pixelStoreUnpack.set(1),e.pixelStoreUnpackPremultiplyAlpha.set(!1),"data"in t&&t.data&&a.texImage3D(a.TEXTURE_3D,0,this.format,i,s,o,0,km(this.format),Vm(this.format),t.data);}bind(e,t){const{context:r}=this,{gl:n}=r;n.bindTexture(n.TEXTURE_3D,this.texture),e!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,e),this.minFilter=e),t!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,t),this.wrapS=t);}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null;}},e.e2=Ph,e.e3=(e,t,r,n,i,s)=>{const o=e.transform,a="globe"===o.projection.name;let l;if("map"===s.paint.get("circle-pitch-alignment"))if(a){const e=vh(o.zoom,t.canonical)*o._pixelsPerMercatorPixel;l=Float32Array.from([e,0,0,e]);}else l=o.calculatePixelsToTileUnitsMatrix(r);else l=new Float32Array([o.pixelsToGLUnits[0],0,0,o.pixelsToGLUnits[1]]);const u={u_camera_to_center_distance:e.transform.getCameraToCenterDistance(o.projection),u_matrix:e.translatePosMatrix(t.projMatrix,r,s.paint.get("circle-translate"),s.paint.get("circle-translate-anchor")),u_device_pixel_ratio:gt.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:s.paint.get("circle-emissive-strength")};if(a){u.u_inv_rot_matrix=n,u.u_merc_center=i,u.u_tile_id=[t.canonical.x,t.canonical.y,1<{const c=e.transform,h=c.pitch<15?rg(.07,.7,De((14-c.zoom)/5,0,1)):.07,p="none"===r.paint.get("line-trim-color-use-theme").constantOr("default");return {u_matrix:ig(e,t,r,n),u_texsize:t.imageAtlasTexture?t.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:c.calculatePixelsToTileUnitsMatrix(t),u_device_pixel_ratio:i,u_width_scale:s,u_floor_width_scale:o,u_image:0,u_tile_units_to_pixels:ng(t,c),u_units_to_pixels:[1/c.pixelsToGLUnits[0],1/c.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:a,u_trim_fade_range:r.paint.get("line-trim-fade-range"),u_trim_gradient_mix_range:[1,1],u_trim_color:r.paint.get("line-trim-color").toPremultipliedRenderColor(p?null:r.lut).toArray01(),u_zbias_factor:h,u_tile_to_meter:Uu(t.tileID.canonical,0),u_ground_shadow_factor:l,u_pattern_transition:u}},e.e7=(e,t,r,n,i,s,o,a,l,u)=>{const c=e.transform,h=c.calculatePixelsToTileUnitsMatrix(t),p="none"===r.paint.get("line-trim-color-use-theme").constantOr("default"),d=c.pitch<15?rg(.07,.7,De((14-c.zoom)/5,0,1)):.07;return {u_matrix:ig(e,t,r,n),u_pixels_to_tile_units:h,u_device_pixel_ratio:s,u_width_scale:o,u_floor_width_scale:a,u_units_to_pixels:[1/c.pixelsToGLUnits[0],1/c.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:i,u_texsize:og(r)&&t.lineAtlasTexture?t.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:ng(t,e.transform),u_alpha_discard_threshold:0,u_trim_offset:l,u_trim_fade_range:r.paint.get("line-trim-fade-range"),u_trim_gradient_mix_range:[1,1],u_trim_color:r.paint.get("line-trim-color").toPremultipliedRenderColor(p?null:r.lut).toArray01(),u_zbias_factor:d,u_tile_to_meter:Uu(t.tileID.canonical,0),u_ground_shadow_factor:u}},e.e8=Ne,e.e9=qh,e.eA=te,e.eB=v,e.eC=function(e,t){var n=new r(3);v(n,t);var i=1/n[0],s=1/n[1],o=1/n[2],a=t[0]*i,l=t[1]*s,u=t[2]*o,c=t[4]*i,h=t[5]*s,p=t[6]*o,d=t[8]*i,f=t[9]*s,m=t[10]*o,y=a+h+m,g=0;return y>0?(g=2*Math.sqrt(y+1),e[3]=.25*g,e[0]=(p-f)/g,e[1]=(d-u)/g,e[2]=(l-c)/g):a>h&&a>m?(g=2*Math.sqrt(1+a-h-m),e[3]=(p-f)/g,e[0]=.25*g,e[1]=(l+c)/g,e[2]=(d+u)/g):h>m?(g=2*Math.sqrt(1+h-a-m),e[3]=(d-u)/g,e[0]=(l+c)/g,e[1]=.25*g,e[2]=(p+f)/g):(g=2*Math.sqrt(1+m-a-h),e[3]=(l-c)/g,e[0]=(d+u)/g,e[1]=(p+f)/g,e[2]=.25*g),e},e.eD=function(e,r){var n=2*Math.acos(r[3]),i=Math.sin(n/2);return i>t?(e[0]=r[0]/i,e[1]=r[1]/i,e[2]=r[2]/i):(e[0]=1,e[1]=0,e[2]=0),n},e.eE=rw,e.eF=ey,e.eG=Ym,e.eH=[1,1,1],e.eI=jb,e.eJ=Y,e.eK=function(e,t,r,n){var i=t[0],s=t[1],o=t[2],a=t[3];return e[0]=i+n*(r[0]-i),e[1]=s+n*(r[1]-s),e[2]=o+n*(r[2]-o),e[3]=a+n*(r[3]-a),e},e.eL=Qm,e.eM=tl,e.eN=fl,e.eO=function(e,t,n,i,s,o,a,l,u,c,h,p,d,f,m,y){var g=new r(16);return g[0]=e,g[1]=t,g[2]=n,g[3]=i,g[4]=s,g[5]=o,g[6]=a,g[7]=l,g[8]=u,g[9]=c,g[10]=h,g[11]=p,g[12]=d,g[13]=f,g[14]=m,g[15]=y,g},e.eP=Iu,e.eQ=dl,e.eR=pl,e.eS=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new Ie(1/0,1/0),max:new Ie(-1/0,-1/0)};}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[];}get updateTime(){return this._updateTime}getReplacementRegionsForTile(e,t=!1){const r=Od(new Ie(0,0),new Ie(Un,Un),e),n=[];if(t&&!Rd(r,this._globalClipBounds))return n;for(const t of this._activeRegions){if(t.hiddenByOverlap)continue;if(!Rd(r,t))continue;const i=Ud(t.min,t.max,e);n.push({min:i.min,max:i.max,sourceId:this._sourceIds[t.priority],footprint:t.footprint,footprintTileId:t.tileId,order:t.order,clipMask:t.clipMask,clipScope:t.clipScope});}return n}setSources(e){this._setSources(e.map(e=>({getSourceId:()=>e.cache.id,getFootprints:()=>{const t=[];for(const r of e.cache.getVisibleCoordinates()){const n=e.cache.getTile(r).buckets[e.layer];n&&n.updateFootprints(r.toUnwrapped(),t);}return t},getOrder:()=>e.order,getClipMask:()=>e.clipMask,getClipScope:()=>e.clipScope})));}_addSource(e){const t=e.getFootprints();if(0===t.length)return;const r=e.getOrder(),n=e.getClipMask(),i=e.getClipScope();for(const e of t){if(!e.footprint)continue;const t=Od(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,order:r,clipMask:n,clipScope:i});}this._sourceIds.push(e.getSourceId());}_computeReplacement(){this._activeRegions.sort((e,t)=>e.priority-t.priority||Dd(e.min,t.min)||Dd(e.max,t.max)||e.order-t.order||e.clipMask-t.clipMask||function(e,t){const r=(e,t)=>e+t;return e.length-t.length||e.reduce(r,"").localeCompare(t.reduce(r,""))}(e.clipScope,t.clipScope));let e=this._activeRegions.length!==this._prevRegions.length;if(!e){let t=0;for(;!e&&t!==this._activeRegions.length;){const r=this._activeRegions[t],n=this._prevRegions[t];e=r.priority!==n.priority||!Cd(r,n)||r.order!==n.order||r.clipMask!==n.clipMask||!Se(r.clipScope,n.clipScope),this._activeRegions[t].hiddenByOverlap=n.hiddenByOverlap,++t;}}if(e){++this._updateTime;for(const e of this._activeRegions)e.order!==Vd&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,e.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,e.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,e.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,e.max.y));const e=e=>{const t=this._activeRegions;if(e>=t.length)return e;const r=t[e].priority;for(;e1){let t=0,r=e(t);for(;t!==r;){let n=t;const i=t;for(;n!==r;){const e=this._activeRegions[n];e.hiddenByOverlap=!1;for(let t=0;t=0;t--)this._addSource(e[t]);this._computeReplacement();}},e.eT=Vd,e.eU=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 Oa,n=new ol,i=[],s=e+1+2,o=t[0]+1,a=t[0]+1+(1+t.length),l=(e,t,r)=>{let n=e===s-1?e-2:0===e?e:e-1;return n+=r?24575:0,[n,t]};for(let e=0;e>>=0,e=Math.imul(2747636419^e,2654435769)>>>0,e=Math.imul(e^e>>>16,2654435769)>>>0,(e=Math.imul(e^e>>>16,2654435769)>>>0)/4294967296},e.eo=gh,e.ep=Ha,e.eq=m,e.er=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[4],e[4]=t[5],e[5]=t[6],e[6]=t[8],e[7]=t[9],e[8]=t[10],e},e.es=cl,e.et=hl,e.eu=function(e,t,r,n,i){return De((e-t)/(r-t)*(i-n)+n,n,i)},e.ev=ie,e.ew=function(e,t){var r=t[0],n=t[1],i=t[2],s=t[3],o=t[4],a=t[5],l=t[6],u=t[7],c=t[8],h=c*o-a*u,p=-c*s+a*l,d=u*s-o*l,f=r*h+n*p+i*d;return f?(e[0]=h*(f=1/f),e[1]=(-c*n+i*u)*f,e[2]=(a*n-i*o)*f,e[3]=p*f,e[4]=(c*r-i*l)*f,e[5]=(-a*r+i*s)*f,e[6]=d*f,e[7]=(-u*r+n*l)*f,e[8]=(o*r-n*s)*f,e):null},e.ex=fs,e.ey=2,e.ez=R,e.f=function(e){return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(e,t)=>String.fromCharCode(Number("0x"+t))))},e.f0=Mu,e.f1=C,e.f2=S,e.f3=function([e,t,r]){const n=Math.hypot(e,t,r),i=Math.atan2(e,r),s=.5*Math.PI-Math.acos(-t/n);return new zu(Te(i),Te(s))},e.f4=K,e.f5=Xm,e.f6=function(e){const t=e.navigator?e.navigator.userAgent:null;return !!function(e){if(null==et){const t=e.navigator?e.navigator.userAgent:null;et=!!e.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")));}return et}(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.f7=function(e,t){wt=e,_t=t;},e.f8=Ah,e.f9=_h,e.fA=function(e,t,r,n,i,s,o,a=1,l,u,c,h){e.createArrays(),e.tilePixelRatio=Un/(512*e.overscaling),e.compareText={},e.iconsNeedLinear=!1;const p=e.layers[0].layout,d=e.layers[0]._unevaluatedLayout._values,f={};f.scaleFactor=a,f.textSizeScaleRange=p.get("text-size-scale-range"),f.iconSizeScaleRange=p.get("icon-size-scale-range");const[m,y]=f.textSizeScaleRange,[g,x]=f.iconSizeScaleRange;f.textScaleFactor=De(f.scaleFactor,m,y),f.iconScaleFactor=De(f.scaleFactor,g,x);const v=d["text-size"],b=d["icon-size"];if("composite"===e.textSizeData.kind){const{minZoom:t,maxZoom:r}=e.textSizeData;f.compositeTextSizes=[v.possiblyEvaluate(new Yo(t,{worldview:c}),s),v.possiblyEvaluate(new Yo(r,{worldview:c}),s)];}if("composite"===e.iconSizeData.kind){const{minZoom:t,maxZoom:r}=e.iconSizeData;f.compositeIconSizes=[b.possiblyEvaluate(new Yo(t,{worldview:c}),s,h),b.possiblyEvaluate(new Yo(r,{worldview:c}),s,h)];}f.layoutTextSize=v.possiblyEvaluate(new Yo(o+1,{worldview:c}),s),f.layoutIconSize=b.possiblyEvaluate(new Yo(o+1,{worldview:c}),s,h),f.textMaxSize=v.possiblyEvaluate(new Yo(18,{worldview:c}),s);const w=p.get("symbol-placement"),_="map"===p.get("text-rotation-alignment")&&"point"!==w,A=p.get("text-size");let M=!1;const I=[];for(const o of e.features){const a=p.get("text-font").evaluate(o,{},s).join(","),m=A.evaluate(o,{},s)*f.textScaleFactor,y=f.layoutTextSize.evaluate(o,{},s)*f.textScaleFactor,g=f.layoutIconSize.evaluate(o,{},s,h)*f.iconScaleFactor,x={horizontal:{},vertical:void 0},v=o.text;let b,S=[0,0];if(v){const n=v.toString(),u=p.get("text-letter-spacing").evaluate(o,{},s)*_g,c=p.get("text-line-height").evaluate(o,{},s)*_g,h=To(n)?u:0,d=p.get("text-anchor").evaluate(o,{},s),g=p.get("text-variable-anchor");if(!g){const e=p.get("text-radial-offset").evaluate(o,{},s);if(e)S=tv(d,[e*_g,Kx]);else {const e=p.get("text-offset").evaluate(o,{},s);S=[e[0]*_g,e[1]*_g];}}let b=_?"center":p.get("text-justify").evaluate(o,{},s);const A="point"===w,M=A?p.get("text-max-width").evaluate(o,{},s)*_g:1/0,I=s=>{e.allowVerticalPlacement&&Bo(n)&&(x.vertical=Zg(v,t,r,i,a,M,c,d,s,h,S,qg.vertical,!0,y,m,l,f.textScaleFactor));};if(!_&&g){const e="auto"===b?g.map(e=>fv(e)):[b];let n=!1;for(let s=0;s=0||!Bo(n)){const e=Zg(v,t,r,i,a,M,c,d,b,h,S,qg.horizontal,!1,y,m,l,f.textScaleFactor);e&&(x.horizontal[b]=e);}I(A?"left":b);}}let z,P,B,T,k,V,E=!1;const F=p.get("icon-text-fit").evaluate(o,{},s);if(o.icon&&o.icon.hasPrimary()){const t=uv(o.icon,e.iconSizeData,d["icon-size"],s,e.zoom,o,l,f.iconScaleFactor,c,h);z=t.iconPrimary,B=t.iconSecondary;const r=z.toString();if(P=n.get(r),P&&(k=p.get("icon-offset").evaluate(o,{},s),V=p.get("icon-anchor").evaluate(o,{},s),b=sx(i.get(r),B?i.get(B.toString()):void 0,k,V),E=P.sdf,void 0===e.sdfIcons?e.sdfIcons=P.sdf:e.sdfIcons!==P.sdf&&Ze("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(P.pixelRatio!==e.pixelRatio||0!==p.get("icon-rotate").constantOr(1))&&(e.iconsNeedLinear=!0)),B){const e=B.toString();T=n.get(e);}}M=M||!(!o.icon||!o.icon.hasSecondary());const D=_v(x.horizontal)||x.vertical;e.iconsInText||(e.iconsInText=!!D&&D.iconsInText);const C=y*f.textScaleFactor/_g,{defaultShapedIcon:R,verticallyShapedIcon:L}=mv(e,b,p,o,s,x,C,k,F);"none"!==F&&b&&(ax(b)||lx(b))&&(av(0,P,z,b,R,F,u,n,i),av(0,T,B,b,R,F,u,n,i),L&&(av(0,P,z,b,L,F,u,n,i),av(0,T,B,b,L,F,u,n,i))),b=R;const{iconBBox:O,iconVerticalBBox:U,textBBox:N,textVerticalBBox:j}=rv(e,b,L,p,o,s,g,k,f,i,V,x,y,S,h);I.push({feature:o,shapedTextOrientations:x,shapedText:D,shapedIcon:b,iconPrimary:z,iconSecondary:B,iconOffset:k,iconAnchor:V,verticallyShapedIcon:L,layoutTextSize:y,layoutIconSize:g,textOffset:S,isSDFIcon:E,iconTextFit:F,iconCollisionBounds:O,iconVerticalCollisionBounds:U,textCollisionBounds:N,textVerticalCollisionBounds:j});}return {featureData:I,sizes:f,hasAnySecondaryIcon:M,textAlongLine:_,symbolPlacement:w}},e.fB=Tx,e.fC=zx,e.fD=kx,e.fE=Vx,e.fF=function(e,t,r,n,i,s,o,a,l,u){e.iconAtlasPositions=u.iconPositions;const{featureData:c,hasAnySecondaryIcon:h,sizes:p,textAlongLine:d,symbolPlacement:f}=t;for(const t of c){const{shapedIcon:r,verticallyShapedIcon:s,feature:c,shapedTextOrientations:m,shapedText:y,layoutTextSize:g,textOffset:x,isSDFIcon:v,iconPrimary:b,iconSecondary:w,iconTextFit:_,iconOffset:A,iconCollisionBounds:M,iconVerticalCollisionBounds:I,textCollisionBounds:S}=t;hv(r,u.iconPositions,b,w),hv(s,u.iconPositions,b,w),pv(m,u.iconPositions),cv(b,w,u.iconPositions),(y||r)&&gv(e,c,m,r,s,l,p,g,0,x,v,n,i,o,a,h,_,A,d,f,M,I,S);}r&&e.generateCollisionDebugBuffers(s,e.collisionBoxArray,p.textScaleFactor);},e.fG=rc,e.fH=a_,e.fI=Ju,e.fJ=function(e){let t=0;if(new Uint32Array(e,0,1)[0]!==Am){const r=new Uint32Array(e,0,7),[,,n,i,s,o]=r;t=r.byteLength+i+s+o+s,(n!==e.byteLength||t>=e.byteLength)&&Ze("Invalid b3dm header information.");}return Bm(e,t)},e.fK=function(e,t){const r=my(e);for(const e of r){for(const t of e.meshes)yy(t);e.lights&&(e.lightMeshIndex=e.meshes.length,e.meshes.push(xy(e.lights,t)));}return r},e.fL=Wb,e.fM=Ke,e.fN=Uf,e.fO=Wo,e.fP=Uo,e.fQ=function(e){St(),null!=Mt&&Mt.then(t=>{t.keys().then(r=>{for(let n=0;nZe(e.message));}).catch(e=>Ze(e.message));}).catch(e=>Ze(e.message));},e.fa=function(e){const t=[0,0,0],r=u(new Float64Array(16));return h(r,e.pixelMatrix,e.globeMatrix),j(t,t,r),new Ie(t[0],t[1])},e.fb=function(){const e=Xf;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(Gf),Xf=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.fc=function(){Zf().acquire(Gf);},e.fd=Ho,e.fe=function(e,t,r=!1){if(jo===Uo.deferred||jo===Uo.loading||jo===Uo.loaded)throw new Error("setRTLTextPlugin cannot be called multiple times.");Go=gt.resolveURL(e),jo=Uo.deferred,No=t,qo(),r||Zo();},e.ff=function(e){em=gt.resolveURL(e),rm||(rm=new qf(Zf(),new rr)),rm.broadcast("setMeshoptUrl",em);},e.fg=am,e.fh=function(e){Kf=gt.resolveURL(e),rm||(rm=new qf(Zf(),new rr)),rm.broadcast("setDracoUrl",Kf);},e.fi=om,e.fj=Nf,e.fk=function(e){const t=It();if(!t)return;const r=t.delete(bt);e&&r.then(()=>e()).catch(e);},e.fl=$f,e.fm=Js,e.fn=jh,e.fo=2,e.fp=Jn,e.fq=tA,e.fr=rA,e.fs=Hy,e.ft=ic,e.fu="hd_road_elevation",e.fv=_c,e.fw=Ge,e.fx=zp,e.fy=Bx,e.fz=1,e.g=function(e,t){return Lt(Object.assign(e,{method:"GET"}),t)},e.h=function(e){return 0===e.indexOf("mapbox:")},e.i=function(e){return at.API_STYLE_REGEX.test(e)&&!ut(e)},e.j=lt,e.k=Pt,e.l=function(e){return decodeURIComponent(atob(e).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""))},e.m=function(e,t){return Lt(Object.assign(e,{type:"json"}),t)},e.n=Gt,e.o=gt,e.p=function(e,t){return Lt(Object.assign(e,{method:"POST"}),t)},e.q=Gh,e.r=class{constructor(e){this.cache=new Map,this.textures=new Map,this.textureAccessTimes=new Map,this.textureMemoryUsed=0,this.maxTextureMemory=1024*(e&&e.maxTextureMemoryMB?e.maxTextureMemoryMB:256)*1024,this.finalizationRegistry=new FinalizationRegistry(e=>{this.cache.delete(e),this.clearExpiredTextures();});}calculateTextureMemory(e){return e.image?Math.ceil(e.image.width*e.image.height*4*(e.patternPositions.size>0?1.33:1)):0}evictTexture(e){const t=this.textures.get(e);if(t){const r=this.calculateTextureMemory(e);t.destroy(),this.textures.delete(e),this.textureAccessTimes.delete(e),this.textureMemoryUsed-=r;}}evictTexturesIfNeeded(e){for(;this.textureMemoryUsed+e>this.maxTextureMemory&&this.textures.size>0;){let e=null,t=1/0;for(const[r]of this.textures.entries()){const n=this.textureAccessTimes.get(r)||0;n>t/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,e)}()},e.v=function(e){return !!e&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)},e.w=Ze,e.x=function(){return Hf||(Hf=new $f("ImageRasterizer")),Hf},e.y=Ww,e.z=Qt;}); define(["./shared"],function(e){function t(e){const t=e?e.url.toString():void 0;return t?performance.getEntriesByName(t):[]}function s(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+=`${s(i)},`;return `${t}]`}let t="{";for(const i of Object.keys(e).sort())t+=`${i}:${s(e[i])},`;return `${t}}`}function i(t){let i="";for(const o of e.by)i+=`/${s(t[o])}`;return i}function o(e,t){return function e(s){return "string"==typeof s&&s===t||(Array.isArray(s)?s.some(e):!(!s||"object"!=typeof s)&&Object.values(s).some(e))}(e)}class n{constructor(e){this.keyCache=Object.create(null),this._layers=Object.create(null),this._layerConfigs=Object.create(null),e&&this.replace(e);}replace(e,t){this._layerConfigs=Object.create(null),this._layers=Object.create(null),this.update(e,[],t);}update(t,n,r){this._options=r;for(const s of t)this._layerConfigs[s.id]=s,(this._layers[s.id]=e.dx(s,this.scope,null,this._options)).compileFilter(r),this.keyCache[s.id]&&delete this.keyCache[s.id];for(const e of n)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource=Object.create(null);const a=function(e,t){const n=Object.create(null);for(let r=0;rthis._layers[e.id]),s=t[0];if("none"===s.visibility)continue;const i=s.source||"";let o=this.familiesBySource[i];o||(o=this.familiesBySource[i]=Object.create(null));const n=s.sourceLayer||"_geojsonTileLayer";let r=o[n];r||(r=o[n]=[]),r.push(t);}}}const r=1*e.fo;class a{constructor(t){const s={},i=[];for(const e in t){const o=t[e],n=s[e]={};for(const e in o.glyphs){const t=o.glyphs[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const s=t.metrics.localGlyph?r:1,a={x:0,y:0,w:t.bitmap.width+2*s,h:t.bitmap.height+2*s};i.push(a),n[e]=a;}}const{w:o,h:n}=e.H(i),a=new e.fn({width:o||1,height:n||1});for(const i in t){const o=t[i];for(const t in o.glyphs){const n=o.glyphs[+t];if(!n||0===n.bitmap.width||0===n.bitmap.height)continue;const l=s[i][t],c=n.metrics.localGlyph?r:1;e.fn.copy(n.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},n.bitmap);}}this.image=a,this.positions=s;}}function l(e,t,s){e[t]?s&&(e[t].center=s):e[t]={floorIds:new Set,center:s||[0,0],floors:{}};}function c(e,t,s,i){for(const o of t)l(e,o),e[o].floors[s]=i,e[o].floorIds.add(s);}function h(e){return {id:e.properties.id.toString(),center:[e.properties.center_lon||0,e.properties.center_lat||0]}}function u(t,s){const i=t.properties.id.toString(),o=!!t.properties.is_default&&t.properties.is_default,n=t.properties.connected_floor_ids?new Set(t.properties.connected_floor_ids.toString().split(";")):new Set,r=t.properties.conflicted_floor_ids?new Set(t.properties.conflicted_floor_ids.toString().split(";")):new Set,a=t.properties.structure_ids?new Set(t.properties.structure_ids.toString().split(";")):new Set,l=t.properties.name.toString(),c=t.properties.z_index,h=function(t,s){const i=t.loadGeometry();if(!i||0===i.length)return;const o=i.map(i=>i.map(i=>e.fp(i,s,t.extent)));return 0===o.length?void 0:{type:"Polygon",coordinates:[o[0]]}}(t,s);return {id:i,isDefault:o,connections:n,conflicts:r,buildings:a,name:l,zIndex:c,geometry:h}}function d(e,t){return t.every(t=>e.properties&&null!=e.properties[t])}function f(e){return d(e,["type","id","name"])&&"structure"===e.properties.type}function p(e){return d(e,["type","id","name","z_index"])&&"floor"===e.properties.type}e.fm(a,"GlyphAtlas");class g{constructor(t){this.tileID=new e.aR(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.lut=t.lut,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.request&&t.request.collectResourceTiming,this.promoteId=t.promoteId,this.isSymbolTile=t.isSymbolTile,this.tileTransform=e.a_(t.tileID.canonical,t.projection),this.projection=t.projection,this.worldview=t.worldview,this.localizableLayerIds=t.localizableLayerIds,this.brightness=t.brightness,this.extraShadowCaster=!!t.extraShadowCaster,this.tessellationStep=t.tessellationStep,this.scaleFactor=t.scaleFactor,this.worldview=t.worldview,this.indoor=t.indoor;}parse(t,s,i,o,n,r){this.status="parsing",this.data=t,this.collisionBoxArray=new e.b4;const d=new e.fq(Object.keys(t.layers).sort()),g=new e.fr(this.tileID,this.promoteId);g.bucketLayerIDs=[];const y={},w=new e.fs(256,256),b={featureIndex:g,iconDependencies:new Map,patternDependencies:new Map,glyphDependencies:{},lineAtlas:w,availableImages:i,brightness:this.brightness,scaleFactor:this.scaleFactor,elevationFeatures:void 0,activeFloors:void 0};this.indoor&&(b.activeFloors=function(t,s,i,o){const n=s.indoorState.activeFloorsVisible;if(!s.sourceLayers)return n?s.indoorState.activeFloors:void 0;const r=function(t,s){if(!t)return e.w("No source layers defined in indoor specification"),s;if(0===t.size)return s;const i=t.difference(s);for(const t of i)e.w(`Missing source layer required in indoor specification: ${t}`);return s.intersection(s)}(s.sourceLayers,new Set(Object.keys(t.layers))),a=s.indoorState,d=function(t,s,i,o,n){const r={};for(const i of s){const s=t.layers[i];if(s)for(let e=0;e=s.maxzoom)continue;if("none"===s.visibility)continue;m(t,this.zoom,b.brightness,i,this.worldview,b.activeFloors);const n=y[s.id]=s.createBucket({index:g.bucketLayerIDs.length,layers:t,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:c,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep,styleDefinedModelURLs:o,worldview:this.worldview,localizable:u,availableImages:i});g.bucketLayerIDs.push(t.map(t=>e.C(t.id,t.scope)));let r=n.prepare?n.prepare():null;null!=r?(r=r.then(()=>n.populate(h,b,this.tileID.canonical,this.tileTransform)),v.push(r)):n.populate(h,b,this.tileID.canonical,this.tileTransform);}}const I=()=>{let s,o,l,c,h,u,f;w.trim();const p={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},v=()=>{if(s)return this.status="done",r(s);if(this.extraShadowCaster)this.status="done",r(null,{buckets:Object.values(y).filter(e=>!e.isEmpty()),featureIndex:g,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:b.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(o&&l&&c&&f){const t=void 0,s=new a(o),r=new Map;for(const[t,s]of l.entries()){const{imagePosition:i}=e.fy(t,s,e.fz);r.set(t,i);}const d={};for(const t in y){const n=y[t];n instanceof e.b5&&(m(n.layers,this.zoom,b.brightness,i,this.worldview,b.activeFloors),d[t]=e.fA(n,o,s.positions,l,r,this.tileID.canonical,this.tileZoom,this.scaleFactor,this.pixelRatio,h,this.worldview,i));}const p={iconsPending:!0,patternsPending:!0};this.rasterizeIfNeeded(n,l,h,()=>{p.iconsPending=!1,x(d,s,p,t,f);}),this.rasterizeIfNeeded(n,c,u,()=>{p.patternsPending=!1,x(d,s,p,t,f);});}},x=(t,s,o,a,h)=>{if(o.iconsPending||o.patternsPending)return;const u=l.size>0||c.size>0,d=Object.keys(t).length>0;if(!u&&!d)return this.status="done",void r(null,{buckets:Object.values(y).filter(e=>!e.isEmpty()),featureIndex:g,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:s.image,lineAtlas:w,imageAtlas:null,brightness:b.brightness});const f=(o,n)=>{for(const s in y){const o=y[s];if(s in t)e.fF(o,t[s],this.showCollisionBoxes,i,this.tileID.canonical,this.tileZoom,this.projection,this.brightness,l,n);else if(o.hasPattern&&(o instanceof e.bb||o instanceof e.bc||o instanceof e.ec)){m(o.layers,this.zoom,b.brightness,i,this.worldview,b.activeFloors);const e=Object.fromEntries(n.patternPositions);o.addFeatures(b,this.tileID.canonical,e,i,this.tileTransform,this.brightness);}}this.status="done",r(null,{buckets:Object.values(y).filter(e=>!e.isEmpty()),featureIndex:g,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:s.image,lineAtlas:w,imageAtlas:o,brightness:b.brightness});};if(u){const t=new Map,s=e.fB(l,t),i=e.fB(c,t),o=new e.fC(s,i,h,this.lut,t);n.send("checkAtlasCache",{descriptor:o,scope:this.scope},(t,s)=>{let i,o;if(t&&e.w(`[Worker] Error checking atlas cache: ${t.message}`),s)i=new e.fD(s.sourceHash),o=s;else {const t=new e.fE(l,c,this.lut,h);i=t,o=t;}f(i,o);});}else f(null,{iconPositions:new Map,patternPositions:new Map});};if(!this.extraShadowCaster){const t=e.fw(b.glyphDependencies,e=>Object.keys(e).map(Number));Object.keys(t).length?n.send("getGlyphs",{uid:this.uid,stacks:t},(e,t)=>{s||(s=e,o=t,v());},void 0,!1,p):o={},f=new Map;const i=Array.from(b.iconDependencies.keys()).map(t=>e.I.parse(t));i.length?n.send("getImages",{images:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},(e,t)=>{if(!s){s=e,l=new Map,h=this.updateImageMapAndGetImageTaskQueue(l,t.images,b.iconDependencies);for(const[e,s]of t.versions.entries())f.set(e,s);v();}},void 0,!1,p):(l=new Map,h=new Map);const r=Array.from(b.patternDependencies.keys()).map(t=>e.I.parse(t));r.length?n.send("getImages",{images:r,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},(e,t)=>{if(!s){s=e,c=new Map,u=this.updateImageMapAndGetImageTaskQueue(c,t.images,b.patternDependencies);for(const[e,s]of t.versions.entries())f.set(e,s);v();}},void 0,!1,p):(c=new Map,u=new Map);}if(b.elevationFeatures&&b.elevationFeatures.length>0){const s=[];for(const t of Object.values(y))if(t instanceof e.bc){const e=t.getUnevaluatedPortalGraph();e&&s.push(e);}const i=e.fx.evaluate(s);for(const s of Object.values(y))if(s instanceof e.bc){const e=t.layers[d.decode(s.sourceLayerIndex)];s.setEvaluatedPortalGraph(i,e,this.tileID.canonical,b.availableImages,b.brightness);}}v();};v.length>0?Promise.allSettled(v).then(I).catch(r):I();}updateParameters(t){this.scaleFactor=t.scaleFactor,this.showCollisionBoxes=t.showCollisionBoxes,this.projection=t.projection,this.brightness=t.brightness,this.tileTransform=e.a_(t.tileID.canonical,t.projection),this.extraShadowCaster=t.extraShadowCaster,this.lut=t.lut,this.worldview=t.worldview,this.indoor=t.indoor;}rasterizeIfNeeded(e,t,s,i){Array.from(t.values()).some(e=>e.usvg)?this.rasterize(e,t,s,i):i();}updateImageMapAndGetImageTaskQueue(e,t,s){const i=new Map;for(const o of t.keys()){const n=s.get(o)||[];for(const s of n){const o=s.toString(),n=t.get(s.id.toString());n.usvg?i.has(o)||(i.set(o,s),e.set(o,Object.assign({},n))):e.set(o,n);}}return i}rasterize(e,t,s,i){this.rasterizeTask=e.send("rasterizeImages",{scope:this.scope,tasks:s},(e,s)=>{if(!e)for(const[e,i]of s.entries()){const s=Object.assign(t.get(e),{data:i});t.set(e,s);}i();});}cancelRasterize(){this.rasterizeTask&&this.rasterizeTask.cancel();}}function m(t,s,i,o,n,r){const a=new e.ad(s,{brightness:i,worldview:n,activeFloors:r});for(const e of t)e.recalculate(a,o);}class y extends e.E{constructor({actor:t,layerIndex:s,availableImages:i,availableModels:o,isSpriteLoaded:n,loadTileData:r,brightness:a}){super(),this.actor=t,this.layerIndex=s,this.availableImages=i,this.availableModels=o,this.loadVectorData=r||e.aM,this.loading={},this.loaded={},this.deduped=new e.aL(t.scheduler),this.isSpriteLoaded=n,this.scheduler=t.scheduler,this.brightness=a;}loadTile(s,i){const o=s.uid,n=s&&s.request,r=n&&n.collectResourceTiming,a=this.loading[o]=new g(s);a.abort=this.loadVectorData(s,(l,c)=>{const h=!this.loading[o];if(delete this.loading[o],a.cancelRasterize(),h||l||!c)return a.status="done",h||(this.loaded[o]=a),i(l);const u=c.rawData,d={},f=e.aN(c.responseHeaders);f&&f.expires&&(d.expires=f.expires),f&&f.cacheControl&&(d.cacheControl=f.cacheControl),a.vectorTile=c.vectorTile||new e.fG(new e.bu(u));const p=()=>{a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,(e,s)=>{if(e||!s)return i(e);const o={};if(r){const e=t(n);e.length>0&&(o.resourceTiming=JSON.parse(JSON.stringify(e)));}i(null,Object.assign({rawTileData:u.slice(0),responseHeaders:c.responseHeaders},s,d,o));});};this.isSpriteLoaded?p():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(p,{type:"parseTile",isSymbolTile:s.isSymbolTile,zoom:s.tileZoom}):p();}),this.loaded=this.loaded||{},this.loaded[o]=a;});}reloadTile(e,t){const s=this.loaded,i=e.uid;if(s&&s[i]){const o=s[i];o.updateParameters(e);const n=(e,s)=>{const i=o.reloadCallback;i&&(delete o.reloadCallback,o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,i)),t(e,s);};"parsing"===o.status?o.reloadCallback=n:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,n):n());}else t(null,void 0);}abortTile(e,t){const s=e.uid,i=this.loading[s];i&&(i.abort&&i.abort(),delete this.loading[s]),t();}removeTile(e,t){const s=this.loaded,i=e.uid;s&&s[i]&&delete s[i],t();}}class w{loadTile(t,s){const{uid:i,encoding:o,rawImageData:n,padding:r}=t,a=ImageBitmap&&n instanceof ImageBitmap?this.getImageData(n,r):n;s(null,new e.fH(i,a,o,r<1));}reloadTile(e,t){t(null,null);}abortTile(e,t){t();}removeTile(e,t){t();}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 s=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),s}}e.bt.setPbf(e.bu);class b{constructor(t){this._mrt=new e.bt(t.partial?30:1/0),this._isHeaderLoaded=!1,this.uid=t.uid,this.tileID=t.tileID,this.source=t.source;}parse(t,s){const i=this._mrt;this.status="parsing",this._entireBuffer=t;try{i.parseHeader(t),this._isHeaderLoaded=!0;const o=[];for(const s in i.layers){const n=i.getLayer(s),r=n.getDataRange(n.getBandList()),a=i.createDecodingTask(r),l=t.slice(r.firstByte,r.lastByte+1),c=e.bt.performDecoding(l,a).then(e=>a.complete(null,e)).catch(e=>a.complete(e,null));o.push(c);}Promise.allSettled(o).then(()=>s(null,i)).catch(e=>s(e));}catch(e){s(e);}}}class v{constructor({actor:e}){this.actor=e,this.loading={},this.loaded={};}loadTile(t,s){const i=t.uid,o=t.request,n=this.loading[i]=new b(t),{cancel:r}=e.bv(o,(e,t,o)=>{const r=!this.loading[i];if(delete this.loading[i],r||e||!t)return n.status="done",r||(this.loaded[i]=n),s(e);n.parse(t,(e,t)=>{if(e||!t)return s(e);s(null,t,o);}),this.loaded[i]=n;});n.abort=r;}reloadTile(e,t){t(null,void 0);}abortTile(e,t){const s=e.uid,i=this.loading[s];i&&(i.abort&&i.abort(),delete this.loading[s]),t();}removeTile(e,t){const s=e.uid;this.loaded[s]&&delete this.loaded[s],t();}decodeRasterArray(t,s){e.bt.performDecoding(t.buffer,t.task).then(e=>s(null,e)).catch(e=>s(e));}}const x=e.fI.prototype.toGeoJSON;class I{constructor(t){this._feature=t,this.extent=e.am,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 s of this._feature.geometry)t.push([new e.P(s[0],s[1])]);return t}{const t=[];for(const s of this._feature.geometry){const i=[];for(const t of s)i.push(new e.P(t[0],t[1]));t.push(i);}return t}}toGeoJSON(e,t,s){return x.call(this,e,t,s)}}class S{constructor(t,s){this.name=t,this.extent=e.am,this.length=s.length,this._jsonFeatures=s;}feature(e){return new I(this._jsonFeatures[e])}}class M{constructor(t){this.layers={},this.extent=e.am;for(const e of Object.keys(t))this.layers[e]=new S(e,t[e]);}}const P=64/4096;class T{constructor(){this.features=new Map;}clear(){this.features.clear();}load(e=[],t){for(const s of e){const e=s.id;if(null==e)continue;let i=this.features.get(e);i&&this.updateCache(i,t),s.geometry?(i=k(s),this.updateCache(i,t),this.features.set(e,i)):this.features.delete(e),this.updateCache(i,t);}}updateCache(e,t){for(const{canonical:s,uid:i}of Object.values(t)){const{z:o,x:n,y:r}=s;_(e,Math.pow(2,o),n,r)&&delete t[i];}}getTile(e,t,s){const i=Math.pow(2,e),o=[];for(const e of this.features.values())_(e,i,t,s)&&o.push(j(e,i,t,s));return {features:o}}getFeatures(){return [...this.features.values()]}}function _({minX:e,minY:t,maxX:s,maxY:i},o,n,r){return e<(n+1+P)/o&&t<(r+1+P)/o&&s>(n-P)/o&&i>(r-P)/o}function k(e){const{id:t,geometry:s,properties:i}=e;if(!s)return;if("GeometryCollection"===s.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:o,coordinates:n}=s,r={id:t,type:1,geometry:[],tags:i,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=r.geometry;if("Point"===o)L(n,a,r);else if("MultiPoint"===o)for(const e of n)L(e,a,r);else if("LineString"===o)r.type=2,O(n,a,r);else if("MultiLineString"===o)r.type=2,z(n,a,r);else if("Polygon"===o)r.type=3,z(n,a,r,!0);else {if("MultiPolygon"!==o)throw new Error("Input data is not a valid GeoJSON object.");r.type=3;for(const e of n)z(e,a,r,!0);}return r}function L([t,s],i,o){const n=e.aG(t);let r=e.aK(s);r=r<0?0:r>1?1:r,i.push(n,r),o.minX=Math.min(o.minX,n),o.minY=Math.min(o.minY,r),o.maxX=Math.max(o.maxX,n),o.maxY=Math.max(o.maxY,r);}function O(e,t,s,i=!1,o=!1){const n=[];for(const t of e)L(t,n,s);t.push(n),i&&function(e,t){let s=0;for(let t=0,i=e.length,o=i-2;t0===t)for(let t=0,s=e.length;t=a&&d>=a||(h>=a?(u+=Math.round(g*((a-h)/p)),h=a):d>=a&&(f=u+Math.round(g*((a-h)/p)),d=a),u>=a&&f>=a||(u>=a?(h+=Math.round(p*((a-u)/g)),u=a):f>=a&&(d=h+Math.round(p*((a-u)/g)),f=a),l&&h===l[l.length-1][0]&&u===l[l.length-1][1]||(l=[[h,u]],n.push(l)),l.push([d,f])))));}}function D(t,s,i,o,n){const r=(i-P)/s,a=(o-P)/s,l=(i+1+P)/s,c=(o+1+P)/s;function h(e,t){let s=0;return el&&(s|=2),tc&&(s|=8),s}let u=[];for(let e=1;e<=8;e*=2){let s=t[t.length-2],i=t[t.length-1],o=!(h(s,i)&e);for(let n=0;n>31}function E(e,t){const{geometry:s,type:i}=e;let o=0,n=0;if(1===i){t.writeVarint(Z(1,s.length));for(const e of s){const s=e[0]-o,i=e[1]-n;t.writeVarint(R(s)),t.writeVarint(R(i)),o+=s,n+=i;}}else for(const e of s){if(0===e.length)continue;t.writeVarint(Z(1,1));const s=e.length-(3===i?1:0);for(let i=0;ie},X=Math.fround||(G=new Float32Array(1),e=>(G[0]=+e,G[0]));var G;class J{constructor(e){this.options=Object.assign(Object.create(Y),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[];}load(e){const{log:t,minZoom:s,maxZoom:i}=this.options;t&&console.time("total time");const o=`prepare ${e.length} points`;t&&console.time(o),this.points=e;const n=[];for(let t=0;t=s;e--){const s=+Date.now();r=this.trees[e]=this._createTree(this._cluster(r,e)),t&&console.log("z%d: %d clusters in %dms",e,r.numItems,+Date.now()-s);}return t&&console.timeEnd("total time"),this}getClusters(e,t){let s=((e[0]+180)%360+360)%360-180;const i=Math.max(-90,Math.min(90,e[1]));let o=180===e[2]?180:((e[2]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)s=-180,o=180;else if(s>o){const e=this.getClusters([s,i,180,n],t),r=this.getClusters([-180,i,o,n],t);return e.concat(r)}const r=this.trees[this._limitZoom(t)],a=r.range(W(s),U(n),W(o),U(i)),l=r.data,c=[];for(const e of a){const t=this.stride*e;c.push(l[t+5]>1?$(l,t,this.clusterProps):this.points[l[t+3]]);}return c}getChildren(e){const t=this._getOriginId(e),s=this._getOriginZoom(e),i="No cluster with the specified id.",o=this.trees[s];if(!o)throw new Error(i);const n=o.data;if(t*this.stride>=n.length)throw new Error(i);const r=this.options.radius/(this.options.extent*Math.pow(2,s-1)),a=o.within(n[t*this.stride],n[t*this.stride+1],r),l=[];for(const t of a){const s=t*this.stride;n[s+4]===e&&l.push(n[s+5]>1?$(n,s,this.clusterProps):this.points[n[s+3]]);}if(0===l.length)throw new Error(i);return l}getLeaves(e,t,s){const i=[];return this._appendLeaves(i,e,t=t||10,s=s||0,0),i}getTile(e,t,s){const i=this.trees[this._limitZoom(e)],o=Math.pow(2,e),{extent:n,radius:r}=this.options,a=r/n,l=(s-a)/o,c=(s+1+a)/o,h={features:[]};return this._addTileFeatures(i.range((t-a)/o,l,(t+1+a)/o,c),i.data,t,s,o,h),0===t&&this._addTileFeatures(i.range(1-a/o,l,1,c),i.data,o,s,o,h),t===o-1&&this._addTileFeatures(i.range(0,l,a/o,c),i.data,-1,s,o,h),h.features.length?h:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const s=this.getChildren(e);if(t++,1!==s.length)break;e=s[0].properties.cluster_id;}return t}_appendLeaves(e,t,s,i,o){const n=this.getChildren(t);for(const t of n){const n=t.properties;if(n&&n.cluster?o+n.point_count<=i?o+=n.point_count:o=this._appendLeaves(e,n.cluster_id,s,i,o):o1;let l,c,h;if(a)l=V(t,e,this.clusterProps),c=t[e],h=t[e+1];else {const s=this.points[t[e+3]];l=s.properties;const[i,o]=s.geometry.coordinates;c=W(i),h=U(o);}const u={type:1,geometry:[[Math.round(this.options.extent*(c*o-s)),Math.round(this.options.extent*(h*o-i))]],tags:l};let d;d=a||this.options.generateId?t[e+3]:this.points[t[e+3]].id,void 0!==d&&(u.id=d),n.features.push(u);}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,t){const{radius:s,extent:i,reduce:o,minPoints:n}=this.options,r=s/(i*Math.pow(2,t)),a=e.data,l=[],c=this.stride;for(let s=0;st&&(f+=a[s+5]);}if(f>d&&f>=n){let e,n=i*d,r=h*d,p=-1;const g=(s/c<<5)+(t+1)+this.points.length;for(const i of u){const l=i*c;if(a[l+2]<=t)continue;a[l+2]=t;const h=a[l+5];n+=a[l]*h,r+=a[l+1]*h,a[l+4]=g,o&&(e||(e=this._map(a,s,!0),p=this.clusterProps.length,this.clusterProps.push(e)),o(e,this._map(a,l)));}a[s+4]=g,l.push(n/f,r/f,1/0,g,-1,f),o&&l.push(p);}else {for(let e=0;e1)for(const e of u){const s=e*c;if(!(a[s+2]<=t)){a[s+2]=t;for(let e=0;e>5}_getOriginZoom(e){return (e-this.points.length)%32}_map(e,t,s){if(e[t+5]>1){const i=this.clusterProps[e[t+6]];return s?Object.assign({},i):i}const i=this.points[e[t+3]].properties,o=this.options.map(i);return s&&o===i?Object.assign({},o):o}}function $(e,t,s){return {type:"Feature",id:e[t+3],properties:V(e,t,s),geometry:{type:"Point",coordinates:[(i=e[t],360*(i-.5)),q(e[t+1])]}};var i;}function V(e,t,s){const i=e[t+5],o=i>=1e4?`${Math.round(i/1e3)}k`:i>=1e3?Math.round(i/100)/10+"k":i,n=e[t+6],r=-1===n?{}:Object.assign({},s[n]);return Object.assign(r,{cluster:!0,cluster_id:e[t+3],point_count:i,point_count_abbreviated:o})}function W(e){return e/360+.5}function U(e){const t=Math.sin(e*Math.PI/180),s=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return s<0?0:s>1?1:s}function q(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function H(e,t,s,i){let o=i;const n=t+(s-t>>1);let r,a=s-t;const l=e[t],c=e[t+1],h=e[s],u=e[s+1];for(let i=t+3;io)r=i,o=t;else if(t===o){const e=Math.abs(i-n);ei&&(r-t>3&&H(e,t,r,i),e[r+2]=o,s-r>3&&H(e,r,s,i));}function Q(e,t,s,i,o,n){let r=o-s,a=n-i;if(0!==r||0!==a){const l=((e-s)*r+(t-i)*a)/(r*r+a*a);l>1?(s=o,i=n):l>0&&(s+=r*l,i+=a*l);}return r=e-s,a=t-i,r*r+a*a}function K(e,t,s,i){const o={id:e??null,type:t,geometry:s,tags:i,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===t||"MultiPoint"===t||"LineString"===t)ee(o,s);else if("Polygon"===t)ee(o,s[0]);else if("MultiLineString"===t)for(const e of s)ee(o,e);else if("MultiPolygon"===t)for(const e of s)ee(o,e[0]);return o}function ee(e,t){for(let s=0;s0&&(r+=i?(o*l-a*n)/2:Math.sqrt(Math.pow(a-o,2)+Math.pow(l-n,2))),o=a,n=l;}const a=t.length-3;t[2]=1,H(t,0,a,s),t[a+2]=1,t.size=Math.abs(r),t.start=0,t.end=t.size;}function oe(e,t,s,i){for(let o=0;o1?1:s}function ae(e,t,s,i,o,n,r,a){if(i/=t,n>=(s/=t)&&r=i)return null;const l=[];for(const t of e){const e=t.geometry;let n=t.type;const r=0===o?t.minX:t.minY,c=0===o?t.maxX:t.maxY;if(r>=s&&c=i)continue;let h=[];if("Point"===n||"MultiPoint"===n)le(e,h,s,i,o);else if("LineString"===n)ce(e,h,s,i,o,!1,a.lineMetrics);else if("MultiLineString"===n)ue(e,h,s,i,o,!1);else if("Polygon"===n)ue(e,h,s,i,o,!0);else if("MultiPolygon"===n)for(const t of e){const e=[];ue(t,e,s,i,o,!0),e.length&&h.push(e);}if(h.length){if(a.lineMetrics&&"LineString"===n){for(const e of h)l.push(K(t.id,n,e,t.tags));continue}"LineString"!==n&&"MultiLineString"!==n||(1===h.length?(n="LineString",h=h[0]):n="MultiLineString"),"Point"!==n&&"MultiPoint"!==n||(n=3===h.length?"Point":"MultiPoint"),l.push(K(t.id,n,h,t.tags));}}return l.length?l:null}function le(e,t,s,i,o){for(let n=0;n=s&&r<=i&&de(t,e[n],e[n+1],e[n+2]);}}function ce(e,t,s,i,o,n,r){let a=he(e);const l=0===o?fe:pe;let c,h,u=e.start;for(let d=0;ds&&(h=l(a,f,p,m,y,s),r&&(a.start=u+c*h)):w>i?b=s&&(h=l(a,f,p,m,y,s),v=!0),b>i&&w<=i&&(h=l(a,f,p,m,y,i),v=!0),!n&&v&&(r&&(a.end=u+c*h),t.push(a),a=he(e)),r&&(u+=c);}let d=e.length-3;const f=e[d],p=e[d+1],g=0===o?f:p;g>=s&&g<=i&&de(a,f,p,e[d+2]),d=a.length-3,n&&d>=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&de(a,a[0],a[1],a[2]),a.length&&t.push(a);}function he(e){const t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function ue(e,t,s,i,o,n){for(const r of e)ce(r,t,s,i,o,n,!1);}function de(e,t,s,i){e.push(t,s,i);}function fe(e,t,s,i,o,n){const r=(n-t)/(i-t);return de(e,n,s+(o-s)*r,1),r}function pe(e,t,s,i,o,n){const r=(n-s)/(o-s);return de(e,t+(i-t)*r,n,1),r}function ge(e,t){const s=[];for(let i=0;i0&&t.size<(o?r:i))return void(s.numPoints+=t.length/3);const a=[];for(let e=0;er)&&(s.numSimplified++,a.push(t[e],t[e+1])),s.numPoints++;o&&function(e,t){let s=0;for(let t=0,i=e.length,o=i-2;t0===t)for(let t=0,s=e.length;t24)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.");let i=function(e,t){const s=[];if("FeatureCollection"===e.type)for(let i=0;i1&&console.time("creation"),d=this.tiles[u]=be(e,t,s,i,l),this.tileCoords.push({z:t,x:s,y:i}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,s,i,d.numFeatures,d.numPoints,d.numSimplified),console.timeEnd("creation"));const e=`z${t}`;this.stats[e]=(this.stats[e]||0)+1,this.total++;}if(d.source=e,null==o){if(t===l.indexMaxZoom||d.numPoints<=l.indexMaxPoints)continue}else {if(t===l.maxZoom||t===o)continue;if(null!=o){const e=o-t;if(s!==n>>e||i!==r>>e)continue}}if(d.source=null,0===e.length)continue;c>1&&console.time("clipping");const f=.5*l.buffer/l.extent,p=.5-f,g=.5+f,m=1+f;let y=null,w=null,b=null,v=null,x=ae(e,h,s-f,s+g,0,d.minX,d.maxX,l),I=ae(e,h,s+p,s+m,0,d.minX,d.maxX,l);e=null,x&&(y=ae(x,h,i-f,i+g,1,d.minY,d.maxY,l),w=ae(x,h,i+p,i+m,1,d.minY,d.maxY,l),x=null),I&&(b=ae(I,h,i-f,i+g,1,d.minY,d.maxY,l),v=ae(I,h,i+p,i+m,1,d.minY,d.maxY,l),I=null),c>1&&console.timeEnd("clipping"),a.push(y||[],t+1,2*s,2*i),a.push(w||[],t+1,2*s,2*i+1),a.push(b||[],t+1,2*s+1,2*i),a.push(v||[],t+1,2*s+1,2*i+1);}}getTile(e,t,s){e=+e,t=+t,s=+s;const i=this.options,{extent:o,debug:n}=i;if(e<0||e>24)return null;const r=1<1&&console.log("drilling down to z%d-%d-%d",e,t,s);let l,c=e,h=t,u=s;for(;!l&&c>0;)c--,h>>=1,u>>=1,l=this.tiles[Me(c,h,u)];return l&&l.source?(n>1&&(console.log("found parent tile z%d-%d-%d",c,h,u),console.time("drilling down")),this.splitTile(l.source,c,h,u,e,t,s),n>1&&console.timeEnd("drilling down"),this.tiles[a]?ye(this.tiles[a],o):null):null}}function Me(e,t,s){return 32*((1<e.tags&&"3d_elevation_id"in e.tags&&"source"in e.tags&&"elevation"===e.tags.source,r=o.features.filter(e=>n(e));let a={_geojsonTileLayer:o.features};r.length>0&&(a={_geojsonTileLayer:o.features.filter(e=>!n(e)),hd_road_elevation:r});const l=new M(a),c=function(t){const s=new e.bu;for(const e of Object.keys(t))s.writeMessage(3,F,{name:e,features:t[e]});return s.finish()}(a).buffer;s(null,{vectorTile:l,rawData:c});}class Te extends y{constructor({actor:e,layerIndex:t,availableImages:s,availableModels:i,isSpriteLoaded:o,brightness:n}){super({actor:e,layerIndex:t,availableImages:s,availableModels:i,isSpriteLoaded:o,loadTileData:Pe,brightness:n}),this._dynamicIndex=new T;}loadData(s,i){const o=s&&s.request,n=o&&o.collectResourceTiming;this._geoJSONIndex=null,this.loadGeoJSON(s,(r,a)=>{if(r||!a)return i(r);if("object"!=typeof a)return i(new Error(`Input data given to '${s.source}' is not a valid GeoJSON object.`));{try{if(s.filter){const t=e.W(s.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));}s.dynamic?("Feature"===a.type&&(a={type:"FeatureCollection",features:[a]}),s.append||(this._dynamicIndex.clear(),this.loaded={}),this._dynamicIndex.load(a.features,this.loaded),s.cluster&&(a.features=this._dynamicIndex.getFeatures())):this.loaded={},this._geoJSONIndex=s.cluster?new J(function({superclusterOptions:t,clusterProperties:s}){if(!s||!t)return t;const i={},o={},n={accumulated:null,zoom:0},r={properties:null},a=Object.keys(s);for(const t of a){const[n,r]=s[t],a=e.W(r),l=e.W("string"==typeof n?[n,["accumulated"],["get",t]]:n);i[t]=a.value,o[t]=l.value;}return t.map=e=>{r.properties=e;const t={};for(const e of a)t[e]=i[e].evaluate(n,r);return t},t.reduce=(e,t)=>{r.properties=t;for(const t of a)n.accumulated=e[t],e[t]=o[t].evaluate(n,r);},t}(s)).load(a.features):s.dynamic?this._dynamicIndex:function(e,t){return new Se(e,t)}(a,s.geojsonVtOptions);}catch(e){return i(e)}const r={};if(n){const e=t(o);e&&(r.resourceTiming={},r.resourceTiming[s.source]=JSON.parse(JSON.stringify(e)));}i(null,r);}});}reloadTile(e,t){const s=this.loaded;return s&&s[e.uid]?e.partial?t(null,void 0):super.reloadTile(e,t):this.loadTile(e,t)}loadGeoJSON(t,s){if(t.request)e.m(t.request,s);else {if("string"!=typeof t.data)return s(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));setTimeout(()=>{try{return s(null,JSON.parse(t.data))}catch(e){return s(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`))}},0);}}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 _e{constructor(t,s,i){this.tileID=new e.aR(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=s,this.worldview=i;}parse(t,s,i,o){this.status="parsing";const n=new e.aR(i.tileID.overscaledZ,i.tileID.wrap,i.tileID.canonical.z,i.tileID.canonical.x,i.tileID.canonical.y),r=[],a=s.familiesBySource[i.source],l=new e.fr(n,i.promoteId);l.bucketLayerIDs=[],l.is3DTile=!0,e.fJ(t).then(t=>{const s=t.json.extensionsUsed&&t.json.extensionsUsed.includes("MAPBOX_mesh_features")||t.json.asset.extras&&t.json.asset.extras.MAPBOX_mesh_features,c=t.json.extensionsUsed&&t.json.extensionsUsed.includes("EXT_meshopt_compression"),h=new e.ad(this.zoom,{brightness:this.brightness,worldview:this.worldview});for(const o in a)for(const u of a[o]){const o=u[0];l.bucketLayerIDs.push(u.map(t=>e.C(t.id,t.scope))),o.recalculate(h,[]);const a=e.fK(t,1/e.d8(i.tileID.canonical)),d=new e.fL(u,a,n,s,c,this.brightness,l,this.worldview);s||(d.needsUpload=!0),r.push(d),d.evaluate(o);}this.status="done",o(null,{buckets:r,featureIndex:l,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:null});}).catch(e=>o(new Error(e.message)));}}class ke{constructor({actor:e,layerIndex:t,availableImages:s,availableModels:i,brightness:o,worldview:n}){this.actor=e,this.layerIndex=t,this.availableImages=s,this.availableModels=i,this.brightness=o,this.loading={},this.loaded={},this.worldview=n;}loadTile(t,s){const i=t.uid,o=this.loading[i]=new _e(t,this.brightness,this.worldview);e.bv(t.request,(e,n)=>{const r=!this.loading[i];return delete this.loading[i],r||e?(o.status="done",r||(this.loaded[i]=o),s(e)):n&&0!==n.byteLength?void o.parse(n,this.layerIndex,t,(e,t)=>{o.status="done",this.loaded=this.loaded||{},this.loaded[i]=o,e||!t?s(e):s(null,t);}):(o.status="done",this.loaded[i]=o,s())});}reloadTile(e,t){const s=this.loaded,i=e.uid;if(s&&s[i]){const o=s[i];o.projection=e.projection,o.brightness=e.brightness;const n=(s,i)=>{o.reloadCallback&&(delete o.reloadCallback,this.loadTile(e,t)),t(s,i);};"parsing"===o.status?o.reloadCallback=n:"done"===o.status&&this.loadTile(e,t);}}abortTile(e,t){const s=e.uid;this.loading[s]&&delete this.loading[s],t();}removeTile(e,t){const s=this.loaded,i=e.uid;s&&s[i]&&delete s[i],t();}}class Le{constructor(t){this.self=t,this.actor=new e.fN(t,this),this.layerIndexes={},this.availableImages={},this.availableModels={},this.isSpriteLoaded={},this.imageRasterizer=new e.y,this.rtlPluginParsingListeners=[],this.projections={},this.defaultProjection=e.cn({name:"mercator"}),this.workerSourceTypes={vector:y,geojson:Te,"raster-dem":w,"raster-array":v,"batched-model":ke},this.workerSources={},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.fO.isParsed())throw new Error("RTL text plugin already registered.");e.fO.setState({pluginStatus:e.fP.parsed,pluginURL:e.fO.getPluginURL()}),e.fO.applyArabicShaping=t.applyArabicShaping,e.fO.processBidirectionalText=t.processBidirectionalText,e.fO.processStyledBidirectionalText=t.processStyledBidirectionalText;for(const e of this.rtlPluginParsingListeners)e(null,!0);this.rtlPluginParsingListeners=[];};}clearCaches(e,t,s){delete this.layerIndexes[e],delete this.availableImages[e],delete this.availableModels[e],delete this.workerSources[e],s();}checkIfReady(e,t,s){s();}setReferrer(e,t){this.referrer=t;}spriteLoaded(t,s){this.isSpriteLoaded[t]||(this.isSpriteLoaded[t]={});const{scope:i,isLoaded:o}=s;if(this.isSpriteLoaded[t][i]=o,this.workerSources[t]&&this.workerSources[t][i])for(const s in this.workerSources[t][i]){const n=this.workerSources[t][i][s];for(const t in n){const s=n[t];s instanceof y&&(s.isSpriteLoaded=o,s.fire(new e.A("isSpriteLoaded")));}}}setImages(e,t,s){this.availableImages[e]||(this.availableImages[e]={});const{scope:i,images:o}=t;if(this.availableImages[e][i]=o,this.workerSources[e]&&this.workerSources[e][i]){for(const t in this.workerSources[e][i]){const s=this.workerSources[e][i][t];for(const e in s)s[e].availableImages=o;}s();}else s();}setModels(e,{scope:t,models:s},i){if(this.availableModels[e]||(this.availableModels[e]={}),this.availableModels[e][t]=s,this.workerSources[e]&&this.workerSources[e][t]){for(const i in this.workerSources[e][t]){const o=this.workerSources[e][t][i];for(const e in o)o[e].availableModels=s;}i();}else i();}setProjection(t,s){this.projections[t]=e.cn(s);}setBrightness(e,t,s){this.brightness=t,s();}setWorldview(e,t,s){this.worldview=t,s();}setLayers(e,t,s){this.getLayerIndex(e,t.scope).replace(t.layers,t.options),s();}updateLayers(e,t,s){this.getLayerIndex(e,t.scope).update(t.layers,t.removedIds,t.options),s();}loadTile(e,t,s){t.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t.type,t.source,t.scope).loadTile(t,s);}decodeRasterArray(e,t,s){this.getWorkerSource(e,t.type,t.source,t.scope).decodeRasterArray(t,s);}reloadTile(e,t,s){t.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t.type,t.source,t.scope).reloadTile(t,s);}abortTile(e,t,s){this.getWorkerSource(e,t.type,t.source,t.scope).abortTile(t,s);}removeTile(e,t,s){this.getWorkerSource(e,t.type,t.source,t.scope).removeTile(t,s);}removeSource(e,t,s){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,s):s();}loadWorkerSource(e,t,s){try{this.self.importScripts(t.url),s();}catch(e){s(e);}}syncRTLPluginState(t,s,i){if(e.fO.isParsed())i(null,!0);else if(e.fO.isParsing())this.rtlPluginParsingListeners.push(i);else try{e.fO.setState(s);const t=e.fO.getPluginURL();!e.fO.isLoaded()||e.fO.isParsed()||e.fO.isParsing()||null==t||(e.fO.setState({pluginStatus:e.fP.parsing,pluginURL:e.fO.getPluginURL()}),this.self.importScripts(t),e.fO.isParsed()?i(null,!0):this.rtlPluginParsingListeners.push(i));}catch(e){i(e);}}setDracoUrl(e,t){this.dracoUrl=t;}getAvailableImages(e,t){this.availableImages[e]||(this.availableImages[e]={});let s=this.availableImages[e][t];return s||(s=[]),s}getAvailableModels(e,t){this.availableModels[e]||(this.availableModels[e]={});let s=this.availableModels[e][t];return s||(s={}),s}getLayerIndex(e,t){this.layerIndexes[e]||(this.layerIndexes[e]={});let s=this.layerIndexes[e][t];return s||(s=this.layerIndexes[e][t]=new n,s.scope=t),s}getWorkerSource(e,t,s,i){const o=this.workerSources;if(o[e]||(o[e]={}),o[e][i]||(o[e][i]={}),o[e][i][t]||(o[e][i][t]={}),this.isSpriteLoaded[e]||(this.isSpriteLoaded[e]={}),!o[e][i][t][s]){const n={send:(t,s,i,o,n,r)=>this.actor.send(t,s,i,e,n,r),scheduler:this.actor.scheduler},r=this.workerSourceTypes[t];if(!r)throw new Error(`Unknown worker source type "${t}".`);o[e][i][t][s]=new r({actor:n,layerIndex:this.getLayerIndex(e,i),availableImages:this.getAvailableImages(e,i),availableModels:this.getAvailableModels(e,i),isSpriteLoaded:this.isSpriteLoaded[e][i],loadTileData:void 0,brightness:this.brightness,worldview:this.worldview});}return o[e][i][t][s]}rasterizeImagesWorker(e,t,s){const i=new Map;for(const[s,{image:o,imageVariant:n}]of t.tasks.entries()){const r=this.imageRasterizer.rasterize(n,o,t.scope,e);i.set(s,r);}s(void 0,i);}removeRasterizedImages(e,t,s){this.imageRasterizer.removeImagesFromCacheByIds(t.imageIds,t.scope,e),s();}enforceCacheSizeLimit(t,s){e.fQ(s);}getWorkerPerformanceMetrics(e,t,s){s(void 0,void 0);}}return e.fM(self)&&(self.worker=new Le(self)),Le}); define(["./shared"],function(e){var t="3.20.0";const i={create:"create",load:"load",fullLoad:"fullLoad"},o={mark(e){performance.mark(e);},measure(e,t,i){performance.measure(e,t,i);}};function s(t){const i=t.name.split("?")[0];return e.a(i)&&i.includes("mapbox-gl.js")?"javascript":e.a(i)&&i.includes("mapbox-gl.css")?"css":e.b(i)?"fontRange":e.c(i)?"sprite":e.i(i)?"style":e.d(i)?"tilejson":"other"}var r,n={},a=function(){if(r)return n;function e(e){return !t(e)}function t(t){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,i=new Blob([""],{type:"text/javascript"}),o=URL.createObjectURL(i);try{t=new Worker(o),e=!0;}catch(t){e=!1;}return t&&t.terminate(),URL.revokeObjectURL(o),e}()?function(){var e=document.createElement("canvas");e.width=e.height=1;var t=e.getContext("2d");if(!t)return !1;var i=t.getImageData(0,0,1,1);return i&&i.width===e.width}()?(void 0===i[o=t&&t.failIfMajorPerformanceCaveat]&&(i[o]=function(t){var i,o=function(t){var i=document.createElement("canvas"),o=Object.create(e.webGLContextAttributes);return o.failIfMajorPerformanceCaveat=t,i.getContext("webgl2",o)}(t);if(!o)return !1;try{i=o.createShader(o.VERTEX_SHADER);}catch(e){return !1}return !(!i||o.isContextLost())&&(o.shaderSource(i,"void main() {}"),o.compileShader(i),!0===o.getShaderParameter(i,o.COMPILE_STATUS))}(o)),i[o]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL2 support"):"insufficient Canvas/getImageData support":"insufficient worker support";var o;}r=1,n.supported=e,n.notSupportedReason=t;var i={};return e.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0},n}();function l(e,t,i){const o=document.createElement(e);return null!=t&&(o.className=t),i&&i.appendChild(o),o}function c(e,t,i){const o=document.createElementNS("http://www.w3.org/2000/svg",e);for(const e of Object.keys(t))o.setAttributeNS(null,e,String(t[e]));return i&&i.appendChild(o),o}const h="undefined"!=typeof document?document.documentElement&&document.documentElement.style:null,d=h&&void 0!==h.userSelect?"userSelect":"WebkitUserSelect";let u;function _(){h&&d&&(u=h[d],h[d]="none");}function p(){h&&d&&(h[d]=u);}function f(e){e.preventDefault(),e.stopPropagation(),window.removeEventListener("click",f,!0);}function m(){window.addEventListener("click",f,!0),window.setTimeout(()=>{window.removeEventListener("click",f,!0);},0);}function g(e,t){const i=e.getBoundingClientRect();return x(e,i,t)}function v(e,t){const i=e.getBoundingClientRect(),o=[];for(let s=0;sthis._skuTokenExpiresAt}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}normalizeStyleURL(i,o){if(!e.h(i))return i;const s=S(i);return s.params.push(`sdk=js-${t}`),s.path=`/styles/v1${s.path}`,this._makeAPIURL(s,this._customAccessToken||o)}normalizeGlyphsURL(t,i){if(!e.h(t))return t;const o=S(t);return o.path=`/fonts/v1${o.path}`,this._makeAPIURL(o,this._customAccessToken||i)}normalizeModelURL(t,i){if(!e.h(t))return t;const o=S(t);return o.path=`/models/v1${o.path}`,this._makeAPIURL(o,this._customAccessToken||i)}normalizeSourceURL(t,i,o,s){if(!e.h(t))return t;const r=S(t);return r.path=`/v4/${r.authority}.json`,r.params.push("secure"),o&&r.params.push(`language=${o}`),s&&r.params.push(`worldview=${s}`),this._makeAPIURL(r,this._customAccessToken||i)}normalizeIconsetURL(t,i){const o=S(t);return e.h(t)?(o.path=`/styles/v1${o.path}/iconset.pbf`,this._makeAPIURL(o,this._customAccessToken||i)):I(o)}normalizeSpriteURL(t,i,o,s){const r=S(t);return e.h(t)?(r.path=`/styles/v1${r.path}/sprite${i}${o}`,this._makeAPIURL(r,this._customAccessToken||s)):(r.path+=`${i}${o}`,I(r))}normalizeTileURL(t,i,o){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!e.h(t))return t;const s=S(t);s.path=s.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${i||o&&"raster"!==s.authority&&512===o?"@2x":""}${e.k.supported?".webp":"$1"}`),"raster"===s.authority?s.path=`/${e.e.RASTER_URL_PREFIX}${s.path}`:"rasterarrays"===s.authority?s.path=`/${e.e.RASTERARRAYS_URL_PREFIX}${s.path}`:"3dtiles"===s.authority?s.path=`/${e.e.TILES3D_URL_PREFIX}${s.path}`:(s.path=s.path.replace(/^.+\/v4\//,"/"),s.path=`/${e.e.TILE_URL_VERSION}${s.path}`);const r=this._customAccessToken||function(e){for(const t of e){const e=t.match(/^access_token=(.*)$/);if(e)return e[1]}return null}(s.params)||e.e.ACCESS_TOKEN;return e.e.REQUIRE_ACCESS_TOKEN&&r&&this._skuToken&&s.params.push(`sku=${this._skuToken}`),this._makeAPIURL(s,r)}canonicalizeTileURL(t,i){const o=S(t);if(!o.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!o.path.match(/\.[\w]+$/))return t;let s="mapbox://";o.path.match(/^\/raster\/v1\//)?s+=`raster/${o.path.replace(`/${e.e.RASTER_URL_PREFIX}/`,"")}`:o.path.match(/^\/rasterarrays\/v1\//)?s+=`rasterarrays/${o.path.replace(`/${e.e.RASTERARRAYS_URL_PREFIX}/`,"")}`:s+=`tiles/${o.path.replace(`/${e.e.TILE_URL_VERSION}/`,"")}`;let r=o.params;return i&&(r=r.filter(e=>!e.match(/^access_token=/))),r.length&&(s+=`?${r.join("&")}`),s}canonicalizeTileset(t,i){const o=!!i&&e.h(i),s=[];for(const i of t.tiles||[])e.j(i)?s.push(this.canonicalizeTileURL(i,o)):s.push(i);return s}_makeAPIURL(t,i){const o="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",s=S(e.e.API_URL);if(t.protocol=s.protocol,t.authority=s.authority,"http"===t.protocol){const e=t.params.indexOf("secure");e>=0&&t.params.splice(e,1);}if("/"!==s.path&&(t.path=`${s.path}${t.path}`),!e.e.REQUIRE_ACCESS_TOKEN)return I(t);if(i=i||e.e.ACCESS_TOKEN,!this._silenceAuthErrors){if(!i)throw new Error(`An API access token is required to use Mapbox GL. ${o}`);if("s"===i[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${o}`)}return t.params=t.params.filter(e=>-1===e.indexOf("access_token")),t.params.push(`access_token=${i||""}`),I(t)}}const E=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function S(e){const t=e.match(E);if(!t)throw new Error("Unable to parse URL object");return {protocol:t[1],authority:t[2],path:t[3]||"/",params:t[4]?t[4].split("&"):[]}}function I(e){const t=e.params.length?`?${e.params.join("&")}`:"";return `${e.protocol}://${e.authority}${e.path}${t}`}const C="mapbox.eventData";function R(t){if(!t)return null;const i=t.split(".");if(!i||3!==i.length)return null;try{return JSON.parse(e.l(i[1]))}catch(e){return null}}class A{constructor(e){this.type=e,this.anonId=null,this.anonIdTimestamp=null,this.eventData={},this.queue=[],this.pendingRequest=null;}getStorageKey(t){const i=R(e.e.ACCESS_TOKEN);let o="";return o=i&&i.u?e.f(i.u):e.e.ACCESS_TOKEN||"",t?`${C}.${t}:${o}`:`${C}:${o}`}fetchEventData(){const t=e.s("localStorage"),i=this.getStorageKey(),o=this.getStorageKey("uuid"),s=this.getStorageKey("uuidTimestamp");if(t)try{const e=localStorage.getItem(i);e&&(this.eventData=JSON.parse(e));const t=localStorage.getItem(o);t&&(this.anonId=t);const r=localStorage.getItem(s);r&&(this.anonIdTimestamp=Number(r));const n=Date.now()-864e5;(!this.anonIdTimestamp||this.anonIdTimestamp=1&&localStorage.setItem(i,JSON.stringify(this.eventData)),n&&localStorage.setItem(s,n.toString());}catch(t){e.w("Unable to write to LocalStorage");}}processRequests(e){}postEvent(t,i,o,s){if(!e.e.EVENTS_URL)return;const r=S(e.e.EVENTS_URL);r.params.push(`access_token=${s||e.e.ACCESS_TOKEN||""}`);const n={event:this.type,created:new Date(t).toISOString()},a=i?Object.assign(n,i):n,l={url:I(r),headers:{"Content-Type":"text/plain"},body:JSON.stringify([a])};this.pendingRequest=e.p(l,e=>{this.pendingRequest=null,o(e),this.saveEventData(),this.processRequests(s);});}queueRequest(e,t){this.queue.push(e),this.processRequests(t);}}class D extends A{constructor(e){super("metrics"),e&&(this.data=e);}postMetricsEvent(t){if(!e.e.EVENTS_URL||!t&&!e.e.ACCESS_TOKEN)return;this.anonId||this.fetchEventData(),e.v(this.anonId)||this.refreshUUID();const i=Object.assign({},this.data,{sessionId:this.anonId});this.queueRequest({timestamp:Date.now(),payload:i},t);}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:t,payload:i}=this.queue.shift();this.postEvent(t,i,()=>{},e);}}const L=new class extends A{constructor(e){super("appUserTurnstile"),this._customAccessToken=e;}postTurnstileEvent(t,i){e.e.EVENTS_URL&&e.e.ACCESS_TOKEN&&Array.isArray(t)&&t.some(t=>e.h(t)||e.j(t))&&this.queueRequest(Date.now(),i);}processRequests(i){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.anonIdTimestamp&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const o=R(e.e.ACCESS_TOKEN),s=o?o.u:e.e.ACCESS_TOKEN;let r=s!==this.eventData.tokenU;e.v(this.anonId)||(this.refreshUUID(),r=!0);const n=this.queue.shift();if(this.eventData.lastSuccess){const e=new Date(this.eventData.lastSuccess),t=new Date(n),i=(n-this.eventData.lastSuccess)/864e5;r=r||i>=1||i<-1||e.getDate()!==t.getDate();}else r=!0;r?this.postEvent(n,{sdkIdentifier:"mapbox-gl-js",sdkVersion:t,skuId:b,"enabled.telemetry":!1,userId:this.anonId},e=>{e||(this.eventData.lastSuccess=n,this.eventData.tokenU=s);},i):this.processRequests();}},P=L.postTurnstileEvent.bind(L),O=new class extends A{constructor(){super("map.load"),this.success={},this.skuToken="";}postMapLoadEvent(t,i,o,s){this.skuToken=i,this.errorCb=s,e.e.EVENTS_URL&&(o||e.e.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},o):this.errorCb(new Error(w)));}processRequests(i){if(this.pendingRequest||0===this.queue.length)return;const{id:o,timestamp:s}=this.queue.shift();o&&this.success[o]||(this.anonId&&this.anonIdTimestamp||this.fetchEventData(),e.v(this.anonId)||this.refreshUUID(),this.postEvent(s,{sdkIdentifier:"mapbox-gl-js",sdkVersion:t,skuId:b,skuToken:this.skuToken,userId:this.anonId},e=>{e?this.errorCb(e):o&&(this.success[o]=!0);},i));}remove(){this.errorCb=null;}},z=O.postMapLoadEvent.bind(O),M=new class extends A{constructor(){super("style.load"),this.eventIdPerMapInstanceMap=new Map,this.mapInstanceIdMap=new WeakMap;}getMapInstanceId(t){let i=this.mapInstanceIdMap.get(t);return i||(i=e.u(),this.mapInstanceIdMap.set(t,i)),i}getEventId(e){const t=this.eventIdPerMapInstanceMap.get(e)||0;return this.eventIdPerMapInstanceMap.set(e,t+1),t}postStyleLoadEvent(t,i){const{map:o,style:s,importedStyles:r}=i;if(!e.e.EVENTS_URL||!t&&!e.e.ACCESS_TOKEN)return;const n=this.getMapInstanceId(o),a={mapInstanceId:n,eventId:this.getEventId(n),style:s};r.length&&(a.importedStyles=r),this.queueRequest({timestamp:Date.now(),payload:a},t);}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:t,payload:i}=this.queue.shift();this.postEvent(t,i,()=>{},e);}},F=M.postStyleLoadEvent.bind(M),k=new D({attributes:[{name:"maps/js/layer-animations/style-with-appearances"}]}),B=k.postMetricsEvent.bind(k),N=new D({attributes:[{name:"maps/js/layer-animations/runtime-appearances"}]}),U=N.postMetricsEvent.bind(N),j=new class extends A{constructor(){super("gljs.performance");}postPerformanceEvent(t,i){e.e.EVENTS_URL&&(t||e.e.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:i},t);}processRequests(o){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:r,performanceData:n}=this.queue.shift(),a=function(o){const r=performance.getEntriesByType("resource"),n=performance.getEntriesByType("mark"),a=function(e){const t={};if(e)for(const i in e)if("other"!==i)for(const o of e[i]){const e=`${i}ResolveRangeMin`,s=`${i}ResolveRangeMax`,r=`${i}RequestCount`,n=`${i}RequestCachedCount`;t[e]=Math.min(t[e]||1/0,o.startTime),t[s]=Math.max(t[s]||-1/0,o.responseEnd);const a=e=>{void 0===t[e]&&(t[e]=0),++t[e];};void 0!==o.transferSize&&0===o.transferSize&&a(n),a(r);}return t}(function(e,t){const i={};if(e)for(const o of e){const e=t(o);void 0===i[e]&&(i[e]=[]),i[e].push(o);}return i}(r,s)),l=window.devicePixelRatio,c=navigator.connection||navigator.mozConnection||navigator.webkitConnection,h=c?c.effectiveType:void 0,d={counters:[],metadata:[],attributes:[]},u=(e,t,i)=>{null!=i&&e.push({name:t,value:i.toString()});};for(const e in a)u(d.counters,e,a[e]);if(o.interactionRange[0]!==1/0&&o.interactionRange[1]!==-1/0&&(u(d.counters,"interactionRangeMin",o.interactionRange[0]),u(d.counters,"interactionRangeMax",o.interactionRange[1])),n)for(const e of Object.values(i)){const t=n.find(t=>t.name===e);t&&u(d.counters,e,t.startTime);}return u(d.counters,"visibilityHidden",o.visibilityHidden),u(d.attributes,"style",function(t){if(t)for(const i of t){const t=i.name.split("?")[0];if(e.i(t)){const e=t.split("/").slice(-2);if(2===e.length)return `mapbox://styles/${e[0]}/${e[1]}`}}}(r)),u(d.attributes,"terrainEnabled",o.terrainEnabled?"true":"false"),u(d.attributes,"fogEnabled",o.fogEnabled?"true":"false"),u(d.attributes,"projection",o.projection),u(d.attributes,"zoom",o.zoom),u(d.metadata,"devicePixelRatio",l),u(d.metadata,"connectionEffectiveType",h),u(d.metadata,"navigatorUserAgent",navigator.userAgent),u(d.metadata,"screenWidth",window.screen.width),u(d.metadata,"screenHeight",window.screen.height),u(d.metadata,"windowWidth",window.innerWidth),u(d.metadata,"windowHeight",window.innerHeight),u(d.metadata,"mapWidth",o.width/l),u(d.metadata,"mapHeight",o.height/l),u(d.metadata,"webglRenderer",o.renderer),u(d.metadata,"webglVendor",o.vendor),u(d.metadata,"sdkVersion",t),u(d.metadata,"sdkIdentifier","mapbox-gl-js"),d}(n);for(const e of a.metadata);for(const e of a.counters);for(const e of a.attributes);this.postEvent(r,a,()=>{},o);}},V=j.postPerformanceEvent.bind(j),G=new class extends A{constructor(){super("map.auth"),this.success={},this.skuToken="";}getSession(t,i,o,s){if(!e.e.API_URL||!e.e.SESSION_PATH)return;const r=S(e.e.API_URL+e.e.SESSION_PATH);r.params.push(`sku=${i||""}`),r.params.push(`access_token=${s||e.e.ACCESS_TOKEN||""}`);const n={url:I(r),headers:{"Content-Type":"text/plain"}};this.pendingRequest=e.g(n,e=>{this.pendingRequest=null,o(e),this.saveEventData(),this.processRequests(s);});}getSessionAPI(t,i,o,s){this.skuToken=i,this.errorCb=s,e.e.SESSION_PATH&&e.e.API_URL&&(o||e.e.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},o):this.errorCb(new Error(w)));}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{id:t,timestamp:i}=this.queue.shift();t&&this.success[t]||this.getSession(i,this.skuToken,e=>{e?this.errorCb(e):t&&(this.success[t]=!0);},e);}remove(){this.errorCb=null;}},H=G.getSessionAPI.bind(G),q=new Set;function Z(e,t){t?q.add(e):q.delete(e);}class W{constructor(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps=new Set,this._updatedImages={};}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(e){return this._updatedImages[e]?Array.from(this._updatedImages[e].values()):[]}updateImage(t,i){this._updatedImages[i]=this._updatedImages[i]||new Set,this._updatedImages[i].add(e.I.toString(t)),this.setDirty();}resetUpdatedImages(e){this._updatedImages[e]&&this._updatedImages[e].clear();}reset(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps.clear(),this._updatedImages={};}}function $(e){const{userImage:t}=e;return !!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}class X extends e.E{constructor(t){super(),this.imageProviders=new Map,this.images=new Map,this.updatedImages=new Map,this.callbackDispatchedThisFrame=new Map,this.imageVersions=new Map,this.loaded=new Map,this.requestors=[],this.patterns=new Map,this.patternsInFlight=new Set,this.atlasImage=new Map,this.atlasTexture=new Map,this.imageAtlasCache=new e.r,this.dirty=!0,this.spriteFormat=t,"raster"!==t&&e.t()&&(this.imageRasterizerDispatcher=new e.D(e.x(),this,"Image Rasterizer Worker",1));}addScope(t){this.loaded.set(t,!1),this.imageProviders.set(t,new Map),this.images.set(t,new Map),this.updatedImages.set(t,new Set),this.callbackDispatchedThisFrame.set(t,new Set),this.imageVersions.set(t,new Map),this.patterns.set(t,new Map),this.atlasImage.set(t,new e.q({width:1,height:1}));}removeScope(e){this.loaded.delete(e),this.imageProviders.delete(e),this.images.delete(e),this.updatedImages.delete(e),this.callbackDispatchedThisFrame.delete(e),this.imageVersions.delete(e),this.patterns.delete(e),this.atlasImage.delete(e);const t=this.atlasTexture.get(e);t&&(t.destroy(),this.atlasTexture.delete(e));}addImageProvider(e,t){this.imageProviders.has(t)||this.imageProviders.set(t,new Map),this.imageProviders.get(t).set(e.id,e);}removeImageProvider(e,t){this.imageProviders.has(t)&&this.imageProviders.get(t).delete(e);}getPendingImageProviders(){const e=[];for(const t of this.imageProviders.values())for(const i of t.values())i.hasPendingRequests()&&e.push(i);return e}get imageRasterizer(){return this._imageRasterizer||(this._imageRasterizer=new e.y),this._imageRasterizer}isLoaded(){for(const e of this.loaded.keys())if(!this.loaded.get(e))return !1;return !0}setLoaded(e,t){if(this.loaded.get(t)!==e&&(this.loaded.set(t,e),e)){for(const{ids:e,callback:i}of this.requestors)this._notify(e,t,i);this.requestors=[];}}hasImage(e,t){return !!this.getImage(e,t)}getImage(e,t){return this.images.get(t).get(e.toString())}addImage(e,t,i){if(this._validate(e,i)){this.images.get(t).set(e.toString(),i);const o=this.imageVersions.get(t),s=o.get(e.toString())||0;o.set(e.toString(),s+1);}}_validate(t,i){let o=!0;return this._validateStretch(i.stretchX,i.data&&i.data.width)||(this.fire(new e.z(new Error(`Image "${t.name}" has invalid "stretchX" value`))),o=!1),this._validateStretch(i.stretchY,i.data&&i.data.height)||(this.fire(new e.z(new Error(`Image "${t.name}" has invalid "stretchY" value`))),o=!1),this._validateContent(i.content,i)||(this.fire(new e.z(new Error(`Image "${t.name}" has invalid "content" value`))),o=!1),o}_validateStretch(e,t){if(!e)return !0;let i=0;for(const o of e){if(o[0]e.I.from(t))}getImageVersions(e){const t=this.imageVersions.get(e);if(t)return t}getImages(e,t,i){const o=[],s=[],r=this.imageProviders.get(t);for(const i of e){if(!i.iconsetId){o.push(i);continue}const e=r.get(i.iconsetId);e&&(this.getImage(i,t)?s.push(i):e.addPendingRequest(i));}if(0===o.length)return void this._notify(s,t,i);let n=!0;const a=!!this.loaded.get(t),l=this.images.get(t);if(!a)for(const e of o)l.has(e.toString())||(n=!1);a||n?this._notify(o,t,i):this.requestors.push({ids:o,scope:t,callback:i});}rasterizeImages(e,t){const i=new Map,{tasks:o,scope:s}=e;for(const[e,t]of o.entries()){const o=this.getImage(t.id,s);o&&i.set(e,{image:o,imageVariant:t});}this._rasterizeImages(s,i,t);}_rasterizeImages(t,i,o){if(e.t())this.imageRasterizerDispatcher.getActor().send("rasterizeImagesWorker",{tasks:i,scope:t},o);else {const e=new Map;for(const[o,{image:s,imageVariant:r}]of i.entries())e.set(o,this.imageRasterizer.rasterize(r,s,t,0));o(void 0,e);}}getUpdatedImages(e){return this.updatedImages.get(e)||new Set}_notify(t,i,o){const s=this.images.get(i),r=new Map;for(const i of t){if(!s.get(i.toString())){if(i.iconsetId)continue;this.fire(new e.A("styleimagemissing",{id:i.name}));}const t=s.get(i.toString());if(!t){e.w(`Image "${i.name}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`);continue}const o={data:t.usvg?null:t.data.clone(),pixelRatio:t.pixelRatio,sdf:t.sdf,usvg:t.usvg,stretchX:t.stretchX,stretchY:t.stretchY,content:t.content,hasRenderCallback:Boolean(t.userImage&&t.userImage.render)};t.usvg&&Object.assign(o,{width:t.icon.usvg_tree.width,height:t.icon.usvg_tree.height}),r.set(e.I.toString(i),o);}o(null,{images:r,versions:this.getImageVersions(i)});}getPixelSize(e){const{width:t,height:i}=this.atlasImage.get(e);return {width:t,height:i}}getPattern(t,i,o){const s=t.toString(),r=this.patterns.get(i),n=r.get(s),a=this.getImage(t,i);if(!a)return null;if(n){if(n.position.version===a.version)return n.position;n.position.version=a.version;}else {if(a.usvg&&!a.data){const r=this.getPatternInFlightId(s,i);if(this.patternsInFlight.has(r))return null;this.patternsInFlight.add(r);const n=new e.B(t).scaleSelf(e.o.devicePixelRatio),l=new Map([[n.toString(),{image:a,imageVariant:n}]]);return this._rasterizeImages(i,l,(e,t)=>this.storePatternImage(n,i,a,o,t)),null}this.storePattern(t,i,a);}return this._updatePatternAtlas(i,o),r.get(s).position}getPatternInFlightId(t,i){return e.C(t,i)}hasPatternsInFlight(){return 0!==this.patternsInFlight.size}storePatternImage(e,t,i,o,s){const r=e.toString(),n=s?s.get(r):void 0;n&&(i.data=n,this.storePattern(e.id,t,i),this._updatePatternAtlas(t,o),this.patternsInFlight.delete(this.getPatternInFlightId(e.id.toString(),t)));}storePattern(t,i,o){const s={w:o.data.width+2*e.F,h:o.data.height+2*e.F,x:0,y:0},r=new e.G(s,o,e.F);this.patterns.get(i).set(t.toString(),{bin:s,position:r});}destroyAtlasTextures(){for(const e of this.atlasTexture.values())e&&e.destroy();this.atlasTexture.clear();}bind(t,i){const o=t.gl;let s=this.atlasTexture.get(i);s?this.dirty&&(s.update(this.atlasImage.get(i)),this.dirty=!1):(s=new e.T(t,this.atlasImage.get(i),o.RGBA8),this.atlasTexture.set(i,s)),s.bind(o.LINEAR,o.CLAMP_TO_EDGE);}_updatePatternAtlas(t,i){const o=this.patterns.get(t),s=Array.from(o.values()).map(({bin:e})=>e),{w:r,h:n}=e.H(s),a=this.atlasImage.get(t);a.resize({width:r||1,height:n||1});const l=this.images.get(t);for(const[t,{bin:s,position:r}]of o.entries()){let o=r.padding;const n=s.x+o,c=s.y+o,h=l.get(t).data,d=h.width,u=h.height;o=o>1?o-1:o,e.q.copy(h,a,{x:0,y:0},{x:n,y:c},{width:d,height:u},i),e.q.copy(h,a,{x:0,y:u-o},{x:n,y:c-o},{width:d,height:o},i),e.q.copy(h,a,{x:0,y:0},{x:n,y:c+u},{width:d,height:o},i),e.q.copy(h,a,{x:d-o,y:0},{x:n-o,y:c},{width:o,height:u},i),e.q.copy(h,a,{x:0,y:0},{x:n+d,y:c},{width:o,height:u},i),e.q.copy(h,a,{x:d-o,y:u-o},{x:n-o,y:c-o},{width:o,height:o},i),e.q.copy(h,a,{x:0,y:u-o},{x:n+d,y:c-o},{width:o,height:o},i),e.q.copy(h,a,{x:0,y:0},{x:n+d,y:c+u},{width:o,height:o},i),e.q.copy(h,a,{x:d-o,y:0},{x:n-o,y:c+u},{width:o,height:o},i);}this.dirty=!0;}beginFrame(){for(const e of this.images.keys())this.callbackDispatchedThisFrame.set(e,new Set);}dispatchRenderCallbacks(e,t){const i=this.images.get(t);for(const o of e){if(this.callbackDispatchedThisFrame.get(t).has(o.toString()))continue;this.callbackDispatchedThisFrame.get(t).add(o.toString());const e=i.get(o.toString());$(e)&&this.updateImage(o,t,e);}}destroy(){this.imageRasterizerDispatcher&&this.imageRasterizerDispatcher.remove();}}function K(t){const i=t.value,o=t.valueSpec,s=t.style,r=t.styleSpec,n=t.key,a=t.arrayElementValidator||ve;if(!Array.isArray(i))return [new e.V(n,i,`array expected, ${e.L(i)} found`)];if(o.length&&i.length!==o.length)return [new e.V(n,i,`array length ${o.length} expected, length ${i.length} found`)];if(o["min-length"]&&i.lengthr)return [new e.V(i,o,`${o} is greater than the maximum value ${r}`)]}return []}function J(t){const i=t.key,o=t.value;if(!e.J(o))return [new e.V(i,o,`object expected, ${e.L(o)} found`)];const s=t.valueSpec,r=e.K(o.type);let n,a,l,c={};const h="categorical"!==r&&void 0===o.property,d=!h,u=function(t){const i=t.stops;return Array.isArray(i)&&Array.isArray(i[0])&&e.J(i[0][0])}(o),_=ye({key:t.key,value:t.value,valueSpec:t.styleSpec.function,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===r)return [new e.V(t.key,t.value,'identity function may not have a "stops" property')];let i=[];const o=t.value;return i=i.concat(K({key:t.key,value:o,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:p})),Array.isArray(o)&&0===o.length&&i.push(new e.V(t.key,o,"array must have at least one stop")),i},default:function(e){return ve({key:e.key,value:e.value,valueSpec:s,style:e.style,styleSpec:e.styleSpec})}}});return "identity"===r&&h&&_.push(new e.V(t.key,t.value,'missing required property "property"')),"identity"===r||o.stops||_.push(new e.V(t.key,t.value,'missing required property "stops"')),"exponential"===r&&s.expression&&!e.N(s)&&_.push(new e.V(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(d&&!e.O(s)?_.push(new e.V(t.key,t.value,"property functions not supported")):h&&!e.Q(s)&&_.push(new e.V(t.key,t.value,"zoom functions not supported"))),"categorical"!==r&&!u||void 0!==o.property||_.push(new e.V(t.key,t.value,'"property" property is required')),_;function p(t){let i=[];const o=t.value,r=t.key;if(!Array.isArray(o))return [new e.V(r,o,`array expected, ${e.L(o)} found`)];if(2!==o.length)return [new e.V(r,o,`array length 2 expected, length ${o.length} found`)];if(u){if(!e.J(o[0]))return [new e.V(r,o,`object expected, ${e.L(o[0])} found`)];const s=o[0];if(void 0===s.zoom)return [new e.V(r,o,"object stop key must have zoom")];if(void 0===s.value)return [new e.V(r,o,"object stop key must have value")];const n=e.K(s.zoom);if("number"!=typeof n)return [new e.V(r,s.zoom,"stop zoom values must be numbers")];if(l&&l>n)return [new e.V(r,s.zoom,"stop zoom values must appear in ascending order")];n!==l&&(l=n,a=void 0,c={}),i=i.concat(ye({key:`${r}[0]`,value:o[0],valueSpec:{zoom:{}},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:Y,value:f}}));}else i=i.concat(f({key:`${r}[0]`,value:o[0],style:t.style,styleSpec:t.styleSpec},o));return e.S(e.U(o[1]))?i.concat([new e.V(`${r}[1]`,o[1],"expressions are not allowed in function stops.")]):i.concat(ve({key:`${r}[1]`,value:o[1],valueSpec:s,style:t.style,styleSpec:t.styleSpec}))}function f(t,i){const o=e.L(t.value),l=e.K(t.value),h=null!==t.value?t.value:i;if(n){if(o!==n)return [new e.V(t.key,h,`${o} stop domain type must match previous stop domain type ${n}`)]}else n=o;if("number"!==o&&"string"!==o&&"boolean"!==o&&"number"!=typeof l&&"string"!=typeof l&&"boolean"!=typeof l)return [new e.V(t.key,h,"stop domain value must be a number, string, or boolean")];if("number"!==o&&"categorical"!==r){let i=`number expected, ${o} found`;return e.O(s)&&void 0===r&&(i+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new e.V(t.key,h,i)]}return "categorical"!==r||"number"!==o||"number"==typeof l&&isFinite(l)&&Math.floor(l)===l?"categorical"!==r&&"number"===o&&"number"==typeof l&&"number"==typeof a&&void 0!==a&&lnew e.V(`${t.key}${i.key}`,t.value,i.message));const o=i.value.expression||i.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!o.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._(o))return [new e.V(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext)return ee(o,t);if("appearance"===t.expressionContext)return te(o,t);if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!e.Y(o,["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.Z(o))return [new e.V(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return []}function ee(t,i){const o=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(i.valueSpec&&i.valueSpec.expression)for(const e of i.valueSpec.expression.parameters)o.delete(e);if(0===o.size)return [];const s=[];return t instanceof e.$&&o.has(t.name)?[new e.V(i.key,i.value,`["${t.name}"] expression is not supported in a filter for a ${i.object.type} layer with id: ${i.object.id}`)]:(t.eachChild(e=>{s.push(...ee(e,i));}),s)}function te(t,i){const o=new Set;if(i.valueSpec&&i.valueSpec.expression)for(const e of i.valueSpec.expression.parameters)o.add(e);if(0===o.size)return [];const s=[];return t instanceof e.$&&!o.has(t.name)?[new e.V(i.key,i.value,`["${t.name}"] is not an allowed parameter`)]:(t.eachChild(e=>{s.push(...te(e,i));}),s)}function ie(t){const i=t.key,o=t.value,s=t.valueSpec,r=[];return Array.isArray(s.values)?-1===s.values.indexOf(e.K(o))&&r.push(new e.V(i,o,`expected one of [${s.values.join(", ")}], ${JSON.stringify(o)} found`)):-1===Object.keys(s.values).indexOf(e.K(o))&&r.push(new e.V(i,o,`expected one of [${Object.keys(s.values).join(", ")}], ${JSON.stringify(o)} found`)),r}function oe(t){return e.a3(e.U(t.value))?Q(Object.assign({},t,{expressionContext:"filter",valueSpec:t.styleSpec[`filter_${t.layerType||"fill"}`]})):se(t)}function se(t){const i=t.value,o=t.key;if(!Array.isArray(i))return [new e.V(o,i,`array expected, ${e.L(i)} found`)];if(i.length<1)return [new e.V(o,i,"filter array must have at least 1 element")];const s=t.styleSpec;let r=ie({key:`${o}[0]`,value:i[0],valueSpec:s.filter_operator});const n=()=>{i.length>=2&&(e.a1(i[1])||r.push(new e.V(`${o}[1]`,i[1],`string expected, ${e.L(i[1])} found`)));for(let t=2;t":case ">=":i.length>=2&&"$type"===e.K(i[1])&&r.push(new e.V(o,i,`"$type" cannot be use with operator "${i[0]}"`)),3!==i.length&&r.push(new e.V(o,i,`filter array for operator "${i[0]}" must have 3 elements`)),n();break;case "==":case "!=":3!==i.length&&r.push(new e.V(o,i,`filter array for operator "${i[0]}" must have 3 elements`)),n();break;case "in":case "!in":n();break;case "any":case "all":case "none":for(let e=1;e{t in o&&i.push(new e.V(s,o[t],`"${t}" is prohibited for ref layers`));}),r.layers.forEach(i=>{e.K(i.id)===l&&(t=i);}),t?t.ref?i.push(new e.V(s,o.ref,"ref cannot reference another ref layer")):a=e.K(t.type):"string"==typeof l&&i.push(new e.V(s,o.ref,`ref layer "${l}" not found`));}else if("background"!==a&&"sky"!==a&&"slot"!==a)if(o.source)if(e.a1(o.source)){const t=r.sources&&r.sources[o.source],n=t&&e.K(t.type);t?"vector"===n&&"raster"===a?i.push(new e.V(s,o.source,`layer "${o.id}" requires a raster source`)):"raster"===n&&"raster"!==a?i.push(new e.V(s,o.source,`layer "${o.id}" requires a vector source`)):"vector"!==n||o["source-layer"]?"raster-dem"===n&&"hillshade"!==a?i.push(new e.V(s,o.source,"raster-dem source can only be used with layer type 'hillshade'.")):"raster-array"!==n||["raster","raster-particle"].includes(a)?"line"===a&&o.paint&&(o.paint["line-gradient"]||o.paint["line-trim-offset"])&&"geojson"===n&&!t.lineMetrics?i.push(new e.V(s,o,`layer "${o.id}" specifies a line-gradient, which requires the GeoJSON source to have \`lineMetrics\` enabled.`)):"raster-particle"===a&&"raster-array"!==n&&i.push(new e.V(s,o.source,`layer "${o.id}" requires a 'raster-array' source.`)):i.push(new e.V(s,o.source,"raster-array source can only be used with layer type 'raster'.")):i.push(new e.V(s,o,`layer "${o.id}" must specify a "source-layer"`)):i.push(new e.V(s,o.source,`source "${o.source}" not found`));}else i.push(new e.V(`${s}.source`,o.source,'"source" must be a string'));else i.push(new e.V(s,o,'missing required property "source"'));return i=i.concat(ye({key:s,value:o,valueSpec:n.layer,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":()=>[],type:()=>ve({key:`${s}.type`,value:o.type,valueSpec:n.layer.type,style:t.style,styleSpec:t.styleSpec,object:o,objectKey:"type"}),filter:e=>oe(Object.assign({layerType:a},e)),layout:e=>ye({layer:o,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>ae(Object.assign({layerType:a},e))}}),paint:e=>ye({layer:o,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>ne(Object.assign({layerType:a,layer:o},e))}}),appearances(t){const i=K({key:t.key,value:t.value,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:t=>function(t){const{key:i,layer:o,layerType:s}=t,r=e.K(t.value),n=e.K(r.name),a=e.K(r.condition),l=ye({key:i,value:r,valueSpec:t.styleSpec.appearance,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{condition:t=>function(t){const i=[];return i.push(...Q({key:t.key,value:t.object.condition,valueSpec:e.a7.appearance.condition,expressionContext:"appearance"})),i}(Object.assign({layer:o,layerType:s},t)),properties:t=>function(t){const i=[],{styleSpec:o,layer:s,layerType:r}=t,n=o[`paint_${r}`],a=o[`layout_${r}`],l=t.object[t.objectKey];for(const o in l){const c=o in n?"paint":o in a?"layout":void 0;if(!c){i.push(new e.V(t.key,o,`unknown property "${o}" for layer type "${r}"`));continue}const h=Object.assign({},t,{key:`${t.key}.${o}`,object:l,objectKey:o,layer:s,layerType:r,value:l[o],valueSpec:"paint"===c?n[o]:a[o]});i.push(...re(h,c));}return i}(Object.assign({layer:o,layerType:s},t))}});return "hidden"!==n&&void 0===a&&l.push(new e.V(t.key,"name",'Appearance with name different than "hidden" must have a condition')),l}(Object.assign({layerType:a,layer:o},t))}),s=Array.isArray(t.value)?t.value:[],r=new Set;return s.forEach((s,n)=>{const a=e.K(s.name);if(a)if(r.has(a)){const s=e.K(o.id);i.push(new e.V(t.key,a,`Duplicated appearance name "${a}" for layer "${s}"`));}else r.add(a);}),i}}})),i}function ce({key:t,value:i}){return e.a1(i)?[]:[new e.V(t,i,`string expected, ${e.L(i)} found`)]}const he={promoteId:function t({key:i,value:o}){if(e.a1(o))return ce({key:i,value:o});if(Array.isArray(o)){const t=[],s=e.U(o),r=e.W(s);return "error"===r.result&&r.value.forEach(o=>{t.push(new e.V(`${i}${o.key}`,null,`${o.message}`));}),e.Y(r.value.expression,["zoom","heatmap-density","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed"])||t.push(new e.V(`${i}`,null,"promoteId expression should be only feature dependent")),t}if(!e.J(o))return [new e.V(i,o,`string, expression or object expected, "${e.L(o)}" found`)];const s=[];for(const e in o)s.push(...t({key:`${i}.${e}`,value:o[e]}));return s}};function de(t){const i=t.value,o=t.key,s=t.styleSpec,r=t.style;if(!e.J(i))return [new e.V(o,i,`object expected, ${e.L(i)} found`)];if(!("type"in i))return [new e.V(o,i,'"type" is required')];const n=e.K(i.type);let a=[];switch(["vector","raster","raster-dem","raster-array"].includes(n)&&("url"in i||"tiles"in i||a.push(new e.a4(o,i,'Either "url" or "tiles" is required.'))),n){case "vector":case "raster":case "raster-dem":case "raster-array":return a=a.concat(ye({key:o,value:i,valueSpec:s[`source_${n.replace("-","_")}`],style:t.style,styleSpec:s,objectElementValidators:he})),a;case "geojson":if(a=ye({key:o,value:i,valueSpec:s.source_geojson,style:r,styleSpec:s,objectElementValidators:he}),"cluster"in i&&"clusterProperties"in i){if(!e.J(i.clusterProperties))return [new e.V(`${o}.clusterProperties`,i,`object expected, ${e.L(i)} found`)];for(const t in i.clusterProperties){const s=i.clusterProperties[t];if(!Array.isArray(s))return [new e.V(`${o}.clusterProperties.${t}`,s,"array expected")];const[r,n]=s,l="string"==typeof r?[r,["accumulated"],["get",t]]:r;a.push(...Q({key:`${o}.${t}.map`,value:n,expressionContext:"cluster-map"})),a.push(...Q({key:`${o}.${t}.reduce`,value:l,expressionContext:"cluster-reduce"}));}}return a;case "video":return ye({key:o,value:i,valueSpec:s.source_video,style:r,styleSpec:s});case "image":return ye({key:o,value:i,valueSpec:s.source_image,style:r,styleSpec:s});case "canvas":return [new e.V(o,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return ie({key:`${o}.type`,value:i.type,valueSpec:{values:ue(s)}})}}function ue(e){return e.source.reduce((t,i)=>{const o=e[i];return "enum"===o.type.type&&(t=t.concat(Object.keys(o.type.values||{}))),t},[])}function _e(t){const i=t.value,o=t.styleSpec,s=o.light,r=t.style;if(void 0===i)return [];if(!e.J(i))return [new e.V("light",i,`object expected, ${e.L(i)} found`)];let n=[];for(const t in i){const a=t.match(/^(.*)-transition$/),l=t.match(/^(.*)-use-theme$/);n=n.concat(l&&s[l[1]]?ve({key:t,value:i[t],valueSpec:{type:"string"},style:r,styleSpec:o}):a&&s[a[1]]&&s[a[1]].transition?ve({key:t,value:i[t],valueSpec:o.transition,style:r,styleSpec:o}):s[t]?ve({key:t,value:i[t],valueSpec:s[t],style:r,styleSpec:o}):[new e.V(t,i[t],`unknown property "${t}"`)]);}return n}function pe(t){const i=t.value;if(!i)return [];const o=t.key;if(!e.J(i))return [new e.V(o,i,`object expected, ${e.L(i)} found`)];let s=[];const r=t.styleSpec,n=r["light-3d"],a=t.style,l=t.style.lights;for(const t of ["type","id"])if(!(t in i))return s=s.concat([new e.V(o,i,`missing property "${t}"`)]),s;if(!e.a1(i.type))return s=s.concat([new e.V(`${o}.type`,i.type,"string expected")]),s;if(l)for(let r=0;r[],array:K,boolean:function(t){const i=t.value,o=t.key;return e.a0(i)?[]:[new e.V(o,i,`boolean expected, ${e.L(i)} found`)]},number:Y,color:function({key:t,value:i}){return e.a1(i)?null===e.a2.parseCSSColor(i)?[new e.V(t,i,`color expected, "${i}" found`)]:[]:[new e.V(t,i,`color expected, ${e.L(i)} found`)]},enum:ie,filter:oe,function:J,layer:le,object:ye,source:de,model:e.a8,light:_e,"light-3d":pe,terrain:fe,fog:me,string:ce,formatted:function(e){return 0===ce(e).length?[]:Q(e)},resolvedImage:function(e){return 0===ce(e).length?[]:Q(e)},projection:function(t){const i=t.value,o=t.styleSpec,s=o.projection,r=t.style;if(e.J(i)){let e=[];for(const t in i)e=e.concat(ve({key:t,value:i[t],valueSpec:s[t],style:r,styleSpec:o}));return e}return e.a1(i)?[]:[new e.V("projection",i,`object or string expected, ${e.L(i)} found`)]},import:function(t){const i=t.key,{value:o,styleSpec:s}=t;if(!e.J(o))return [new e.V(i,o,"import must be an object")];const{data:r,...n}=o;Object.defineProperty(n,"__line__",{value:o.__line__,enumerable:!1});let a=ye(Object.assign({},t,{value:n,valueSpec:s.import}));return ""===e.K(n.id)&&a.push(new e.V(`${t.key}.id`,n,"import id can't be an empty string")),r&&(a=a.concat(be(r,s,{key:`${t.key}.data`}))),a},iconset:function(t){const i=t.value,o=t.key,s=t.styleSpec,r=t.style;if(!e.J(i))return [new e.V(o,i,"object expected")];if(!i.type)return [new e.V(o,i,'"type" is required')];const n=e.K(i.type);let a=[];if(a=a.concat(ye({key:o,value:i,valueSpec:s[`iconset_${n}`],style:r,styleSpec:s})),function(e,t){return !("source"!==e||!t.source)}(n,i)){const t=r.sources&&r.sources[i.source],s=t&&e.K(t.type);t?"raster-array"!==s&&a.push(new e.V(o,i.source,`iconset cannot be used with a source of type ${String(s)}, it only be used with a "raster-array" source type`)):a.push(new e.V(o,i.source,`source "${i.source}" not found`));}return a}};function ve(t,i=!1){const o=t.value,s=t.valueSpec,r=t.styleSpec;if(s.expression){if(e.a5(e.K(o)))return J(t);if(e.S(e.U(o)))return Q(t)}if(s.type&&ge[s.type]){const e=ge[s.type](t);return !0===i&&e.length>0&&Array.isArray(t.value)?Q(t):e}return ye(Object.assign({},t,{valueSpec:s.type?r[s.type]:s}))}function ye(t){const i=t.key,o=t.value,s=t.valueSpec||{},r=t.objectElementValidators||{},n=t.style,a=t.styleSpec;if(!e.J(o))return [new e.V(i,o,`object expected, ${e.L(o)} found`)];let l=[];for(const t in o){const c=t.split(".")[0];let h;r[c]?h=r[c]:s[c]?h=ve:r["*"]?h=r["*"]:s["*"]&&(h=ve),h?l=l.concat(h({key:(i?`${i}.`:i)+t,value:o[t],valueSpec:s[c]||s["*"],style:n,styleSpec:a,object:o,objectKey:t},o)):l.push(new e.a4(i,o[t],`unknown property "${t}"`));}for(const t in s){if(r[t])continue;const n=s[t];n.required&&void 0===n.default&&void 0===o[t]&&l.push(new e.V(i,o,`missing required property "${t}"`));}return l}function xe({key:t,value:i}){const o=ce({key:t,value:i});if(o.length)return o;const s=i;return -1===s.indexOf("{fontstack}")&&o.push(new e.V(t,i,'"glyphs" url must include a "{fontstack}" token')),-1===s.indexOf("{range}")&&o.push(new e.V(t,i,'"glyphs" url must include a "{range}" token')),o}function be(t,i=e.a7,o={}){return ye({key:o.key||"",value:t,valueSpec:Object.assign(i.$root,{"*":{type:"*"}}),styleSpec:i,style:t,objectElementValidators:{glyphs:xe}})}function we(t,i=e.a7){return Me(be(t,i))}const Te=e=>Me(de(e)),Ee=e=>Me(_e(e)),Se=e=>Me(pe(e)),Ie=e=>Me(fe(e)),Ce=e=>Me(me(e)),Re=t=>Me(function(t){const i=t.value,o=t.style,s=t.styleSpec,r=s.snow;if(void 0===i)return [];if(!e.J(i))return [new e.V("snow",i,`object expected, ${e.L(i)} found`)];let n=[];for(const t in i){const a=t.match(/^(.*)-transition$/);n=n.concat(a&&r[a[1]]&&r[a[1]].transition?ve({key:t,value:i[t],valueSpec:s.transition,style:o,styleSpec:s}):r[t]?ve({key:t,value:i[t],valueSpec:r[t],style:o,styleSpec:s}):[new e.a4(t,i[t],`unknown property "${t}"`)]);}return n}(t)),Ae=t=>Me(function(t){const i=t.value,o=t.style,s=t.styleSpec,r=s.rain;if(void 0===i)return [];if(!e.J(i))return [new e.V("rain",i,`object expected, ${e.L(i)} found`)];let n=[];for(const t in i){const a=t.match(/^(.*)-transition$/);n=n.concat(a&&r[a[1]]&&r[a[1]].transition?ve({key:t,value:i[t],valueSpec:s.transition,style:o,styleSpec:s}):r[t]?ve({key:t,value:i[t],valueSpec:r[t],style:o,styleSpec:s}):[new e.a4(t,i[t],`unknown property "${t}"`)]);}return n}(t)),De=e=>Me(le(e)),Le=e=>Me(oe(e)),Pe=e=>Me(ne(e)),Oe=e=>Me(ae(e)),ze=t=>Me(e.a8(t));function Me(e){return e.slice().sort((e,t)=>e.line&&t.line?e.line-t.line:0)}function Fe(t,i){let o=!1;if(i&&i.length)for(const s of i)s instanceof e.a4?e.w(s.message):(t.fire(new e.z(new Error(s.message))),o=!0);return o}const ke=e.a7.light;let Be;class Ne extends e.E{constructor(t,i="flat"){super(),this._transitionable=new e.a9(Be||(Be=new e.aa({anchor:new e.ab(ke.anchor),position:new e.ac(ke.position),color:new e.ab(ke.color),intensity:new e.ab(ke.intensity)}))),this.setLight(t,i),this._transitioning=this._transitionable.untransitioned();}getLight(){return this._transitionable.serialize()}setLight(e,t,i={}){this._validate(Ee,e,i)||(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,i,o){return (!o||!1!==o.validate)&&Fe(this,t.call(we,Object.assign({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.a7})))}}const Ue=e.a7.terrain;let je=class extends e.E{constructor(t,i,o,s,r){super(),this.scope=o,this._transitionable=new e.a9(new e.aa({source:new e.ab(Ue.source),exaggeration:new e.ab(Ue.exaggeration)}),o,s),this._transitionable.setTransitionOrValue(t,s),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=i,this.worldview=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.ad(t,{worldview:this.worldview})).get("exaggeration")}getAttenuationRange(){if(!this.isZoomDependent())return null;const t=this._transitionable._values.exaggeration;if(!t)return null;const i=t.value.expression;if(!i)return null;let o=-1,s=-1,r=1;for(const t of i.zoomStops)r=i.evaluate(new e.ad(t,{worldview:this.worldview})),r>.01?(o=t,s=-1):s=t;return r<.01&&o>0&&s>o?[o,s]:null}isZoomDependent(){const t=this._transitionable._values.exaggeration;return null!=t&&null!=t.value&&null!=t.value.expression&&t.value.expression instanceof e.ae}};const Ve=.05;function Ge(t,i,o,s){const r=e.ai(45,65,o),[n,a]=He(t,s);let l=1-Math.min(1,Math.exp((i-n)/(a-n)*-6));return l*=l*l,l=Math.min(1,1.00747*l),l*r*t.alpha}function He(e,t){const i=.5/Math.tan(.5*t);return [e.range[0]+i,e.range[1]+i]}function qe(t,i,o,s,r){const n=e.ag([],[i,o,s],r.mercatorFogMatrix);return Ge(t,e.ah(n),r.pitch,r._fov)}function Ze(t,i,o,s,r,n,a){const l=[[o,s,0],[r,s,0],[r,n,0],[o,n,0]];let c=Number.MAX_VALUE,h=-Number.MAX_VALUE;for(const t of l){const o=e.ag([],t,i),s=e.ah(o);c=Math.min(c,s),h=Math.max(h,s);}return [Ge(t,c,a.pitch,a._fov),Ge(t,h,a.pitch,a._fov)]}const We=e.a7.fog;class $e extends e.E{constructor(t,i,o,s){super();const r=new e.aa({range:new e.ab(We.range),color:new e.ab(We.color),"color-use-theme":new e.ab({type:"string","property-type":"data-constant",default:"default"}),"high-color":new e.ab(We["high-color"]),"high-color-use-theme":new e.ab({type:"string","property-type":"data-constant",default:"default"}),"space-color":new e.ab(We["space-color"]),"space-color-use-theme":new e.ab({type:"string","property-type":"data-constant",default:"default"}),"horizon-blend":new e.ab(We["horizon-blend"]),"star-intensity":new e.ab(We["star-intensity"]),"vertical-range":new e.ab(We["vertical-range"])});this._transitionable=new e.a9(r,o,new Map(s)),this.set(t,s),this._transitioning=this._transitionable.untransitioned(),this._transform=i,this.properties=new e.aj(r),this.scope=o;}get state(){const t=this._transform,i="globe"===t.projection.name,o=e.ak(t.zoom),s=this.properties.get("range"),r=[.5,3];return {range:i?[e.al(r[0],s[0],o),e.al(r[1],s[1],o)]:s,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(e,t,i={}){if(this._validate(Ce,e,i))return;const o=Object.assign({},e);for(const e of Object.keys(We))void 0===o[e]&&(o[e]=We[e].default);this._options=o,this._transitionable.setTransitionOrValue(this._options,t);}getOpacity(t){if(!this._transform.projection.supportsFog)return 0;const i=this.properties&&this.properties.get("color")||1;return ("globe"===this._transform.projection.name?1:e.ai(45,65,t))*i.a}getOpacityAtLatLng(t,i){return this._transform.projection.supportsFog?function(t,i,o){const s=e.af.fromLngLat(i),r=o.elevation?o.elevation.getAtPointOrZero(s):0;return qe(t,s.x,s.y,r,o)}(this.state,t,i):0}getOpacityForTile(t){if(!this._transform.projection.supportsFog)return [1,1];const i=this._transform.calculateFogTileMatrix(t.toUnwrapped());return Ze(this.state,i,0,0,e.am,e.am,this._transform)}getOpacityForBounds(e,t,i,o,s){return this._transform.projection.supportsFog?Ze(this.state,e,t,i,o,s,this._transform):[1,1]}getFovAdjustedRange(e){return this._transform.projection.supportsFog?He(this.state,e):[0,1]}isVisibleOnFrustum(t){if(!this._transform.projection.supportsFog)return !1;const i=[4,5,6,7];for(const o of i){const i=t.points[o];let s;if(i[2]>=0)s=i;else {const r=t.points[o-4];s=e.an(r,i,r[2]/(r[2]-i[2]));}if(qe(this.state,s[0],s[1],0,this._transform)>=Ve)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,i,o){return (!o||!1!==o.validate)&&Fe(this,t.call(we,Object.assign({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.a7})))}}let Xe,Ke,Ye,Je=class extends e.E{constructor(t,i,o,s){super();const r=Xe||(Xe=new e.aa({density:new e.ab(e.a7.snow.density),intensity:new e.ab(e.a7.snow.intensity),color:new e.ab(e.a7.snow.color),opacity:new e.ab(e.a7.snow.opacity),vignette:new e.ab(e.a7.snow.vignette),"vignette-color":new e.ab(e.a7.snow["vignette-color"]),"center-thinning":new e.ab(e.a7.snow["center-thinning"]),direction:new e.ab(e.a7.snow.direction),"flake-size":new e.ab(e.a7.snow["flake-size"])}));this._transitionable=new e.a9(r,o,new Map(s)),this.set(t,s),this._transitioning=this._transitionable.untransitioned(),this.properties=new e.aj(r),this.scope=o;}get state(){const t=this.properties.get("opacity"),i=this.properties.get("color"),o=this.properties.get("direction"),s=e.ao(o[0]),r=-Math.max(e.ao(o[1]),.01),n=[Math.cos(s)*Math.cos(r),Math.sin(s)*Math.cos(r),Math.sin(r)],a=this.properties.get("vignette"),l=this.properties.get("vignette-color");return l.a=a,{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new e.ap(i.r,i.g,i.b,i.a*t),direction:n,centerThinning:this.properties.get("center-thinning"),flakeSize:this.properties.get("flake-size"),vignetteColor:l}}get(){return this._transitionable.serialize()}set(t,i,o={}){if(this._validate(Re,t,o))return;const s=Object.assign({},t),r=e.a7.snow;for(const e of Object.keys(r))void 0===s[e]&&(s[e]=r[e].default);this._options=s,this._transitionable.setTransitionOrValue(this._options,i);}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,i,o){return (!o||!1!==o.validate)&&Fe(this,t.call(we,Object.assign({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.a7})))}},Qe=class extends e.E{constructor(t,i,o,s){super();const r=Ke||(Ke=new e.aa({density:new e.ab(e.a7.rain.density),intensity:new e.ab(e.a7.rain.intensity),color:new e.ab(e.a7.rain.color),opacity:new e.ab(e.a7.rain.opacity),vignette:new e.ab(e.a7.rain.vignette),"vignette-color":new e.ab(e.a7.rain["vignette-color"]),"center-thinning":new e.ab(e.a7.rain["center-thinning"]),direction:new e.ab(e.a7.rain.direction),"droplet-size":new e.ab(e.a7.rain["droplet-size"]),"distortion-strength":new e.ab(e.a7.rain["distortion-strength"])}));this._transitionable=new e.a9(r,o,new Map(s)),this.set(t,s),this._transitioning=this._transitionable.untransitioned(),this.properties=new e.aj(r),this.scope=o;}get state(){const t=this.properties.get("opacity"),i=this.properties.get("color"),o=this.properties.get("direction"),s=e.ao(o[0]),r=-Math.max(e.ao(o[1]),.01),n=[Math.cos(s)*Math.cos(r),Math.sin(s)*Math.cos(r),Math.sin(r)],a=this.properties.get("vignette-color");return a.a=this.properties.get("vignette"),{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new e.ap(i.r,i.g,i.b,i.a*t),direction:n,centerThinning:this.properties.get("center-thinning"),dropletSize:this.properties.get("droplet-size"),distortionStrength:this.properties.get("distortion-strength"),vignetteColor:a}}get(){return this._transitionable.serialize()}set(t,i,o={}){if(this._validate(Ae,t,o))return;const s=Object.assign({},t),r=e.a7.rain;for(const e of Object.keys(r))void 0===s[e]&&(s[e]=r[e].default);this._options=s,this._transitionable.setTransitionOrValue(this._options,i);}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,i,o){return (!o||!1!==o.validate)&&Fe(this,t.call(we,Object.assign({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.a7})))}};class et extends e.E{constructor(t,i,o,s){super(),this.scope=o,this._options=t,this.properties=new e.aj(i),this._transitionable=new e.a9(i,o,new Map(s)),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 tt=()=>Ye||(Ye=new e.aa({color:new e.ab(e.a7.properties_light_ambient.color),"color-use-theme":new e.ab({type:"string",default:"default","property-type":"data-constant"}),intensity:new e.ab(e.a7.properties_light_ambient.intensity)}));let it;const ot=()=>it||(it=new e.aa({direction:new e.aq(e.a7.properties_light_directional.direction),color:new e.ab(e.a7.properties_light_directional.color),"color-use-theme":new e.ab({type:"string",default:"default","property-type":"data-constant"}),intensity:new e.ab(e.a7.properties_light_directional.intensity),"cast-shadows":new e.ab(e.a7.properties_light_directional["cast-shadows"]),"shadow-quality":new e.ab(e.a7.properties_light_directional["shadow-quality"]),"shadow-intensity":new e.ab(e.a7.properties_light_directional["shadow-intensity"]),"shadow-draw-before-layer":new e.ab(e.a7.properties_light_directional["shadow-draw-before-layer"])}));class st{constructor(e,t,i){this.screenBounds=e,this.cameraPoint=i.getCameraPoint(),this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=t,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,i);}static createFromScreenPoints(t,i){let o,s;if(t instanceof e.P||"number"==typeof t[0]){const r=e.P.convert(t);o=[r],s=i.isPointAboveHorizon(r);}else {const r=e.P.convert(t[0]),n=e.P.convert(t[1]),a=r.add(n)._div(2);o=[r,n],s=e.ar(r,n).every(e=>i.isPointAboveHorizon(e))&&i.isPointAboveHorizon(a);}return new st(o,s,i)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(t){return e.ar(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],t)}bufferedCameraGeometry(t){const i=this.screenBounds[0],o=1===this.screenBounds.length?this.screenBounds[0].add(new e.P(1,1)):this.screenBounds[1],s=e.ar(i,o,0,!1);return this.cameraPoint.y>o.y&&(this.cameraPoint.x>i.x&&this.cameraPoint.x=o.x?s[2]=this.cameraPoint:this.cameraPoint.x<=i.x&&(s[3]=this.cameraPoint)),e.as(s,t)}bufferedCameraGeometryGlobe(t){const i=this.screenBounds[0],o=1===this.screenBounds.length?this.screenBounds[0].add(new e.P(1,1)):this.screenBounds[1],s=e.ar(i,o,t),r=this.cameraPoint.clone();switch(3*((r.y>i.y)+(r.y>o.y))+((r.x>i.x)+(r.x>o.x))){case 0:s[0]=r,s[4]=r.clone();break;case 1:s.splice(1,0,r);break;case 2:s[1]=r;break;case 3:s.splice(4,0,r);break;case 5:s.splice(2,0,r);break;case 6:s[3]=r;break;case 7:s.splice(3,0,r);break;case 8:s[2]=r;}return s}containsTile(t,i,o,s=0){const r=Math.max(t.queryPadding,t.evaluateQueryRenderedFeaturePadding())/i._pixelsPerMercatorPixel+1,n=o?this._bufferedCameraMercator(r,i):this._bufferedScreenMercator(r,i);let a=t.tileID.wrap+(n.unwrapped?s:0);const l=n.polygon.map(i=>e.at(t.tileTransform,i,a));if(!e.au(l,0,0,e.am,e.am))return;a=t.tileID.wrap+(this.screenGeometryMercator.unwrapped?s:0);const c=this.screenGeometryMercator.polygon.map(i=>e.av(t.tileTransform,i,a)),h=c.map(t=>new e.P(t[0],t[1])),d=i.getFreeCameraOptions().position||new e.af(0,0,0),u=e.av(t.tileTransform,d,a),_=c.map(t=>{const i=e.aw(t,t,u);return e.ax(i,i),new e.ay(u,i)}),p=e.az(t,1,i.zoom)*i._pixelsPerMercatorPixel;return {queryGeometry:this,tilespaceGeometry:h,tilespaceRays:_,bufferedTilespaceGeometry:l,bufferedTilespaceBounds:(f=e.aA(l),f.min.x=e.aB(f.min.x,0,e.am),f.min.y=e.aB(f.min.y,0,e.am),f.max.x=e.aB(f.max.x,0,e.am),f.max.y=e.aB(f.max.y,0,e.am),f),tile:t,tileID:t.tileID,pixelToTileUnitsFactor:p};var f;}_bufferedScreenMercator(e,t){const i=at(e);if(this._screenRaycastCache[i])return this._screenRaycastCache[i];{let o;return o="globe"===t.projection.name?this._projectAndResample(this.bufferedScreenGeometry(e),t):{polygon:this.bufferedScreenGeometry(e).map(e=>t.pointCoordinate3D(e)),unwrapped:!0},this._screenRaycastCache[i]=o,o}}_bufferedCameraMercator(e,t){const i=at(e);if(this._cameraRaycastCache[i])return this._cameraRaycastCache[i];{let o;return o="globe"===t.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(e),t):{polygon:this.bufferedCameraGeometry(e).map(e=>t.pointCoordinate3D(e)),unwrapped:!0},this._cameraRaycastCache[i]=o,o}}_projectAndResample(t,i){const o=function(t,i){const o=e.aC([],i.pixelMatrix,i.globeMatrix),s=[0,-e.aE,0,1],r=[0,e.aE,0,1],n=[0,0,0,1];e.aD(s,s,o),e.aD(r,r,o),e.aD(n,n,o);const a=new e.P(s[0]/s[3],s[1]/s[3]),l=new e.P(r[0]/r[3],r[1]/r[3]),c=e.aF(t,a)&&s[3]1?rt(t.slice(0,u),i):[],f=unew e.P(nt(t.x),t.y)),f=f.map(t=>new e.P(nt(t.x),t.y));const m=[...p];0===m.length&&m.push(f[f.length-1]);const g=e.al(m[m.length-1].y,(0===f.length?p[0]:f[0]).y,_);let v;return v=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)],m.push(...v),0===f.length?m.push(p[0]):m.push(...f),{polygon:m.map(t=>new e.af(t.x,t.y)),unwrapped:!1}}(t,i);if(o)return o;const s=function(t,i){let o=!1,s=-1/0,r=0;for(let e=0;es&&(s=t[e].x,r=e);for(let e=0;e.5&&(s.x{e.x-=1;}),{polygon:t,unwrapped:o}}(rt(t,i).map(t=>new e.P(nt(t.x),t.y)),i);return {polygon:s.polygon.map(t=>new e.af(t.x,t.y)),unwrapped:s.unwrapped}}}function rt(t,i){return e.aH(t,e=>{const t=i.pointCoordinate3D(e);e.x=t.x,e.y=t.y;},1/256)}function nt(e){return e<0?1+e%1:e%1}function at(e){return 100*e|0}function lt(t,i,o,s,r){const n=function(o,s){if(o)return r(o);if(s){if(t.url&&s.tiles&&t.tiles&&delete t.tiles,s.variants){if(!Array.isArray(s.variants))return r(new Error("variants must be an array"));for(const e of s.variants){if(null==e||"object"!=typeof e||e.constructor!==Object)return r(new Error("variant must be an object"));if(!Array.isArray(e.capabilities))return r(new Error("capabilities must be an array"));if(1===e.capabilities.length&&"meshopt"===e.capabilities[0]){s=Object.assign(s,e);break}}}const o=e.aI(Object.assign({},s,t),["tilejson","tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","extra_bounds","scheme","tileSize","encoding","vector_layers","raster_layers","worldview_options","worldview_default","worldview"]);o.tiles=i.canonicalizeTileset(o,t.url),r(null,o);}},a=function(e,t,i){if(!e)return null;if(!t&&!i)return e;i=i||e.worldview_default;const o=Object.values(e.language||{});if(0===o.length)return null;const s=Object.values(e.worldview||{});if(0===s.length)return null;const r=o.every(e=>e===t),n=s.every(e=>e===i);return r&&n?e:t in(e.language_options||{})||i in(e.worldview_options||{})?null:e.language_options&&e.worldview_options?e:null}(t.data,o,s);return a?e.o.frame(()=>n(null,a)):t.url?e.m(i.transformRequest(i.normalizeSourceURL(t.url,null,o,s),e.R.Source),n):e.o.frame(()=>{const{data:e,...i}=t;n(null,i);})}function ct(t,i){const o=Math.pow(2,i.z),s=Math.floor(e.aG(t.getWest())*o),r=Math.floor(e.aK(t.getNorth())*o),n=Math.ceil(e.aG(t.getEast())*o),a=Math.ceil(e.aK(t.getSouth())*o);return i.x>=s&&i.x=r&&i.ythis.maxzoom||e.z{if(this._tileJSONRequest=null,this._loaded=!0,s)i&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${i}`),o&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${o}`),this.fire(new e.z(s));else if(r){if(Object.assign(this,r),this.hasWorldviews=!!r.worldview_options,r.worldview_default&&(this.worldviewDefault=r.worldview_default),r.vector_layers){this.vectorLayers=r.vector_layers,this.vectorLayerIds=[],this.localizableLayerIds=new Set;for(const e of r.vector_layers)this.vectorLayerIds.push(e.id),r.worldview&&r.worldview[e.source]&&this.localizableLayerIds.add(e.id);}this.tileBounds=ht.fromTileJSON(r),P(r.tiles,this.map._requestManager._customAccessToken),this.fire(new e.A("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.A("data",{dataType:"source",sourceDataType:"content"}));}t&&t(s);});}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.C(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(e){this.cancelTileJSONRequest();}serialize(){return Object.assign({},this._options)}loadTile(t,i){const o=t.tileID.canonical.url(this.tiles,this.scheme),s=this.map._requestManager.normalizeTileURL(o),r=this.map._requestManager.transformRequest(s,e.R.Tile),n=this.map.style?this.map.style.getLut(this.scope):null,a=n?{image:n.image.clone()}:null,l={request:r,data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,lut:a,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,pixelRatio:e.o.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:t.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:t.isExtraShadowCaster,tessellationStep:this.map._tessellationStep,scaleFactor:this.map.getScaleFactor(),worldview:this.map.getWorldview()||this.worldviewDefault,indoor:this.map.getIndoorTileOptions(this.id,this.scope)};if(this.hasWorldviews&&e.h(o)&&(l.localizableLayerIds=this.localizableLayerIds),l.request.collectResourceTiming=this._collectResourceTiming,t.actor&&"expired"!==t.state)"loading"===t.state?t.reloadCallback=i:t.request=t.actor.send("reloadTile",l,c.bind(this));else if(t.actor=this._tileWorkers[s]=this._tileWorkers[s]||this.dispatcher.getActor(),this.dispatcher.ready)t.request=t.actor.send("loadTile",l,c.bind(this),void 0,!0);else {const i=e.aM.call({deduped:this._deduped},l,(i,o)=>{if(i||!o)c.call(this,i);else {const i=e.aN(o.responseHeaders);l.data={rawData:o.rawData.slice(0),expires:i.expires,cacheControl:i.cacheControl},t.actor&&t.actor.send("loadTile",l,c.bind(this),void 0,!0);}},!0);t.request={cancel:i};}function c(o,s){return delete t.request,t.aborted?i(null):o&&o instanceof e.aO&&404!==o.status?i(o):(s&&s.resourceTiming&&(t.resourceTiming=s.resourceTiming),this.map._refreshExpiredTiles&&s&&t.setExpiryData(s),t.loadVectorData(s,this.map.painter),e.aP(this.dispatcher),i(null,s),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,t){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 ut extends e.E{constructor(t,i,o,s){super(),this.id=t,this.dispatcher=o,this.setEventedParent(s),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=Object.assign({type:"raster"},i),Object.assign(this,e.aI(i,["url","scheme","tileSize"]));}load(t){this._loaded=!1,this.fire(new e.A("dataloading",{dataType:"source"}));const i=this.map.getWorldview();this._tileJSONRequest=lt(this._options,this.map._requestManager,null,i,(i,o)=>{this._tileJSONRequest=null,this._loaded=!0,i?this.fire(new e.z(i)):o&&(Object.assign(this,o),o.raster_layers&&(this.rasterLayers=o.raster_layers,this.rasterLayerIds=this.rasterLayers.map(e=>e.id)),this.tileBounds=ht.fromTileJSON(o),P(o.tiles),this.fire(new e.A("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.A("data",{dataType:"source",sourceDataType:"content"}))),t&&t(i);});}loaded(){return this._loaded}onAdd(e){this.map=e,this.load();}reload(){this.cancelTileJSONRequest();const t=e.C(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(e){this.cancelTileJSONRequest();}serialize(){return Object.assign({},this._options)}hasTile(e){return !this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(t,i){const o=e.o.devicePixelRatio>=2,s=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),o,this.tileSize);t.request=e.n(this.map._requestManager.transformRequest(s,e.R.Tile),(o,s,r)=>{if(delete t.request,t.aborted)return t.state="unloaded",i(null);if(o)return t.state="errored",i(o);if(!s)return i(null);const n=e.aN(r);this.map._refreshExpiredTiles&&t.setExpiryData(n),t.setTexture(s,this.map.painter),t.state="loaded",e.aP(this.dispatcher),i(null);});}abortTile(e,t){e.request&&(e.request.cancel(),delete e.request),t&&t();}unloadTile(t,i){t.texture&&t.texture instanceof e.T?(t.destroy(!1),t.texture&&t.texture instanceof e.T&&this.map.painter.saveTileTexture(t.texture)):t.destroy(),i&&i();}hasTransition(){return !1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null);}}function _t([t,i],o,s,{scaled:r=!0}={}){const{tileSize:n,buffer:a}=s,{x:l,y:c,z:h}=o;if(!isFinite(l)||!isFinite(c)||!isFinite(h))throw new Error("Invalid MRT header");const d=2**h,u=d*e.aG(t),_=d*e.aK(i);return function([e,t],i,{scaled:o=!0}={}){if(!i)throw new Error("bandView is undefined");const{data:s,tileSize:r,buffer:n,offset:a,scale:l,dimension:c}=i;if(e<-n||e>r+n||t<-n||t>r+n)throw new Error(`Point (${e}, ${t}) out of bounds for tileSize=${r}, buffer=${n}`);const h=(t+n)*(r+2*n)+(e+n);if(4294967295===new Uint32Array(s.buffer)[h])return null;let d=[];d=o?[]:new(0,i.data.constructor)(c);for(let e=0;e{if(delete t.request,t.aborted)return t.state="unloaded",i(null);if(o){if("AbortError"===o.name)return;return t.state="errored",i(o)}if(this.map._refreshExpiredTiles&&s){const i=e.aN(r);t.setExpiryData(i);}if(this.partial&&"expired"!==t.state)t.state="empty";else if(!this.partial){if(!s)return i(null);t.state="loaded",t._isHeaderLoaded=!0,t._mrt=s;}i(null);};t.request=this.partial?t.fetchHeader(void 0,n.bind(this)):t.actor.send("loadTile",r,n.bind(this),void 0,!0);}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,t){const i=e.texturePerLayer;if(e.flushAllQueues(),i.size){e.destroy(!1);for(const e of i.values())this.map.painter.saveTileTexture(e);}else e.destroy();}prepareTile(t,i,o,s){t._isHeaderLoaded&&("empty"!==t.state&&(t.state="reloading"),t.fetchBandForRender(i,o,s,(i,s)=>{i?(t.state="errored",this.fire(new e.z(i))):s&&(t._isHeaderLoaded=!0,t.setTexturePerLayer(o,s,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),i=t&&t.fields,o=i&&i.bands&&i.bands;return o?o[0]:0}getTextureDescriptor(t,i,o){if(!t)return;const s=i.sourceLayer||this.rasterLayerIds&&this.rasterLayerIds[0];if(!s)return;let r=null;i instanceof e.aS?r=i.paint.get("raster-array-band"):i instanceof e.aT&&(r=i.paint.get("raster-particle-array-band"));const n=r||this.getInitialBand(s);if(null==n)return;if(!t.textureDescriptorPerLayer.get(i.id))return void this.prepareTile(t,s,i.id,n);if(t.updateNeeded(i.id,n)&&!o)return;const a=t.textureDescriptorPerLayer.get(i.id);return Object.assign({},a,{texture:t.texturePerLayer.get(i.id)})}getImages(t,i){const o=new Map;for(const s of t)for(const t of i){const[i,r]=t.split("/"),n=s.getLayer(i);if(!n)continue;if(!n.hasBand(r)||!n.hasDataForBand(r))continue;const{bytes:a,tileSize:l,buffer:c}=n.getBandView(r),h=l+2*c,d={data:new e.q({width:h,height:h},a),pixelRatio:2,sdf:!1,usvg:!1,version:0};o.set(t,d);}return o}queryRasterArrayValueByBandId(t,i,o){const s=i._mrt;return new Promise(r=>{const n={},a=new Set;for(const[l,c]of Object.entries(s.layers)){if(o.layerName&&l!==o.layerName)continue;const h={};n[l]=h;for(const{bands:d}of c.dataIndex)for(const u of d)o.bands&&!o.bands.includes(u)||(a.add(e.C(l,u)),i.fetchBand(l,null,u,i=>{e.o.frame(()=>{h[u]=i?null:_t([t.lng,t.lat],s,c.getBandView(u)),a.delete(e.C(l,u)),0===a.size&&r(n);});},!1));}0===a.size&&r(n);})}_loadTileForQuery(t,i){if(this._loadTileLoaded[t.uid])return void i(null,t._mrt);if(this._loadTilePending[t.uid])return void this._loadTilePending[t.uid].push(i);this._loadTilePending[t.uid]=[i];const o=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),s=this.map._requestManager.transformRequest(o,e.R.Tile);t.actor.send("loadTile",{request:s,uid:t.uid,tileID:t.tileID,type:this.type,source:this.id,scope:this.scope,partial:!1},(i,o,s)=>{if(i)return this._loadTilePending[t.uid].forEach(e=>e(i,null)),void delete this._loadTilePending[t.uid];if(!o)return this._loadTilePending[t.uid].forEach(e=>e(null,null)),void delete this._loadTilePending[t.uid];if(this.map._refreshExpiredTiles&&o){const i=e.aN(s);t.setExpiryData(i);}t._mrt=o,t._isHeaderLoaded=!0,t.state="loaded",this._loadTilePending[t.uid].forEach(e=>e(null,o)),this._loadTileLoaded[t.uid]=!0,delete this._loadTilePending[t.uid];},void 0,!0);}queryRasterArrayValueByAllBands(e,t,i){return new Promise((o,s)=>{this._loadTileForQuery(t,(r,n)=>{r?s(r):o(n?this.queryRasterArrayValueByBandId(e,t,i):null);});})}queryRasterArrayValue(t,i){const o=e.aU.convert(t),s=this.findLoadedParent(o);return s&&s._mrt?i.bands||!this.partial?this.queryRasterArrayValueByBandId(o,s,i):this.queryRasterArrayValueByAllBands(o,s,i):Promise.resolve(null)}findLoadedParent(t){const i=e.af.fromLngLat(t,this.map.transform.tileSize),o=this.maxzoom+1,s=1<0&&(l[new e.aR(t.overscaledZ,r,i.z,s,i.y-1).key]={backfilled:!1},l[new e.aR(t.overscaledZ,t.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new e.aR(t.overscaledZ,a,i.z,n,i.y-1).key]={backfilled:!1}),i.y+1{if(this._loaded=!0,this._pendingLoad=null,i)this.fire(new e.z(i));else {const i={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&o&&o.resourceTiming&&o.resourceTiming[this.id]&&(i.resourceTiming=o.resourceTiming[this.id]),t&&(this._partialReload=!0),this.fire(new e.A("data",i)),this._partialReload=!1,this._metadataFired=!0;}this._coalesce&&(this._updateWorkerData(t),this._coalesce=!1);});}loaded(){return this._loaded}reload(){const t=e.C(this.id,this.scope);this.map.style.clearSource(t),this._updateWorkerData();}loadTile(t,i){const o=t.actor?"reloadTile":"loadTile";t.actor=this.actor;const s=this.map.style?this.map.style.getLut(this.scope):null,r=s?{image:s.image.clone()}:null,n=this._partialReload,a={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,lut:r,scope:this.scope,pixelRatio:e.o.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:t.isExtraShadowCaster,scaleFactor:this.map.getScaleFactor(),partial:n,worldview:this.map.getWorldview(),indoor:this.map.getIndoorTileOptions(this.id,this.scope)};t.request=this.actor.send(o,a,(e,s)=>n&&!s?(t.state="loaded",i(null)):(delete t.request,t.destroy(!1),t.aborted?i(null):e?i(e):(t.loadVectorData(s,this.map.painter,"reloadTile"===o),i(null))),void 0,"loadTile"===o);}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.aborted=!0;}unloadTile(e,t){this.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope}),e.destroy();}onRemove(e){this._pendingLoad&&this._pendingLoad.cancel();}serialize(){return Object.assign({},this._options,{type:this.type,data:this._data})}hasTransition(){return !1}},video:class extends e.aV{constructor(e,t,i,o){super(e,t,i,o),this.roundZoom=!0,this.type="video",this.options=t;}load(){this._loaded=!1;const t=this.options;this.urls=[];for(const i of t.urls)this.urls.push(this.map._requestManager.transformRequest(i,e.R.Source).url);e.aW(this.urls,(t,i)=>{this._loaded=!0,t?this.fire(new e.z(t)):i&&(this.video=i,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",()=>{this.map.triggerRepaint();}),this.map&&this.video.play(),this._finishLoading());});}pause(){this.video&&this.video.pause();}play(){this.video&&this.video.play();}seek(t){if(this.video){const i=this.video.seekable;ti.end(0)?this.fire(new e.z(new e.V(`sources.${this.id}`,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.end(0)}-second mark.`))):this.video.currentTime=t;}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)));}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const t=this.map.painter.context,i=t.gl;this.texture?this.video.paused||(this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,this.video)):(this.texture=new e.T(t,this.video,i.RGBA8),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(t);}serialize(){return {type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:e.aV,model:e.aY,"batched-model":class extends e.E{constructor(e,t,i,o){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=i,this.reparseOverscaled=!1,this.scheme="xyz",this._loaded=!1,this.setEventedParent(o);}onAdd(e){this.map=e,this.load();}reload(){this.cancelTileJSONRequest();const t=e.C(this.id,this.scope);this.load(()=>this.map.style.clearSource(t));}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null);}load(t){this._loaded=!1,this.fire(new e.A("dataloading",{dataType:"source"}));const i=Array.isArray(this.map._language)?this.map._language.join():this.map._language,o=this.map.getWorldview();this._tileJSONRequest=lt(this._options,this.map._requestManager,i,o,(s,r)=>{this._tileJSONRequest=null,this._loaded=!0,s?(i&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${i}`),o&&2!==o.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${o}`),this.fire(new e.z(s))):r&&(Object.assign(this,r),r.bounds&&(this.tileBounds=new ht(r.bounds,this.minzoom,this.maxzoom)),P(r.tiles,this.map._requestManager._customAccessToken),this.fire(new e.A("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.A("data",{dataType:"source",sourceDataType:"content"}))),t&&t(s);});}hasTransition(){return !1}hasTile(e){return !this.tileBounds||this.tileBounds.contains(e.canonical)}loaded(){return this._loaded}loadTile(t,i){const o=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme)),s={request:this.map._requestManager.transformRequest(o,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,pixelRatio:e.o.devicePixelRatio,promoteId:this.promoteId};if(t.actor&&"expired"!==t.state)if("loading"===t.state)t.reloadCallback=i;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",s,r.bind(this));}else t.actor=this.dispatcher.getActor(),t.request=t.actor.send("loadTile",s,r.bind(this),void 0,!0);function r(e,o){return t.aborted?i(null):e&&404!==e.status?i(e):(this.map._refreshExpiredTiles&&o&&t.setExpiryData(o),t.loadModelData(o,this.map.painter),t.state="loaded",void i(null))}}serialize(){return Object.assign({},this._options)}},canvas:class extends e.aV{constructor(t,i,o,s){super(t,i,o,s),i.coordinates?Array.isArray(i.coordinates)&&4===i.coordinates.length&&!i.coordinates.some(e=>!Array.isArray(e)||2!==e.length||e.some(e=>"number"!=typeof e))||this.fire(new e.z(new e.V(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new e.z(new e.V(`sources.${t}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new e.z(new e.V(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof HTMLCanvasElement||this.fire(new e.z(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.z(new e.V(`sources.${t}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate;}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof 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.z(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(e){this.pause();}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const i=this.map.painter.context;this.texture?!t&&!this._playing||this.texture instanceof e.aX||this.texture.update(this.canvas,{premultiply:!0}):this.texture=new e.T(i,this.canvas,i.gl.RGBA8,{premultiply:!0}),this._prepareData(i);}serialize(){return {type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const e of [this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return !0;return !1}},custom:class extends e.E{constructor(t,i,o,s){super(),this.id=t,this.type="custom",this._dataType="raster",this._dispatcher=o,this._implementation=i,this.setEventedParent(s),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new e.z(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new e.z(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new ht(this._implementation.bounds,this.minzoom,this.maxzoom)),i.update=this._update.bind(this),i.clearTiles=this._clearTiles.bind(this),i.coveringTiles=this._coveringTiles.bind(this),Object.assign(this,e.aI(i,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]));}serialize(){return e.aI(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new e.A("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.A("data",{dataType:"source",sourceDataType:"content"}));}loaded(){return this._loaded}onAdd(t){this.map=t,this._loaded=!1,this.fire(new e.A("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(t),this.load();}onRemove(e){this._implementation.onRemove&&this._implementation.onRemove(e);}hasTile(e){if(this._implementation.hasTile){const{x:t,y:i,z:o}=e.canonical;return this._implementation.hasTile({x:t,y:i,z:o})}return !this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e,t){const{x:i,y:o,z:s}=e.tileID.canonical,r=new AbortController;e.request=Promise.resolve(this._implementation.loadTile({x:i,y:o,z:s},{signal:r.signal})).then(function(i){return delete e.request,e.aborted?(e.state="unloaded",t(null)):void 0===i?(e.state="errored",t(null)):null===i?(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}(i)?(this.loadTileData(e,i),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(i=>{"AbortError"!==i.name&&(e.state="errored",t(i));}),e.request.cancel=()=>r.abort();}loadTileData(e,t){e.setTexture(t,this.map.painter);}unloadTile(t,i){if(t.texture&&t.texture instanceof e.T?(t.destroy(!1),t.texture&&t.texture instanceof e.T&&this.map.painter.saveTileTexture(t.texture)):t.destroy(),this._implementation.unloadTile){const{x:e,y:i,z:o}=t.tileID.canonical;this._implementation.unloadTile({x:e,y:i,z:o});}i&&i();}abortTile(e,t){e.request&&e.request.cancel&&(e.request.cancel(),delete e.request),t&&t();}hasTransition(){return !1}_coveringTiles(){return this.map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map(e=>({x:e.canonical.x,y:e.canonical.y,z:e.canonical.z}))}_clearTiles(){const t=e.C(this.id,this.scope);this.map.style.clearSource(t);}_update(){this.fire(new e.A("data",{dataType:"source",sourceDataType:"content"}));}}},mt=function(t,i,o,s){const r=new ft[i.type](t,i,o,s);if(r.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${r.id}`);return e.aZ(["load","abort","unload","serialize","prepare"],r),r};function gt(e,t,i=""){return `${i}:${t.id||""}:${t.layer.id}:${function(e){if("layerId"in e)return `layer:${e.layerId}`;{const{featuresetId:t,importId:i}=e;return `featureset:${t}${i?`:import:${i}`:""}`}}(e.target)}`}function vt(e,t,i,o=""){if(e.uniqueFeatureID){const s=gt(e,t,o);if(i.has(s))return !0;i.add(s);}return !1}function yt(e,t,i,o,s=!1,r=void 0){const n=t.sourceCache.transform,a=t.sourceCache.tilesIn(e,t.has3DLayers,s);a.sort(wt);const l=[];for(const e of a){const a=e.tile.queryRenderedFeatures(t,e,i,o,n,s,r);Object.keys(a).length&&l.push({wrappedTileID:e.tile.tileID.wrapped().key,queryResults:a});}for(const i in t.layers){const s=t.layers[i];if(s.styleLayer){const i=s.styleLayer.queryRenderedFeatures(e,t.sourceCache,o);Object.keys(i).length&&l.push({wrappedTileID:0,queryResults:i});}}return 0===l.length?{}:function(e){const t={},i={};for(const o of e){const e=o.queryResults,s=o.wrappedTileID,r=i[s]=i[s]||{};for(const i in e){const o=e[i],s=r[i]=r[i]||{},n=t[i]=t[i]||[];for(const e of o)s[e.featureIndex]||(s[e.featureIndex]=!0,n.push(e));}}return t}(l)}function xt(e,t,i,o,s,r){const n={},a=o.queryRenderedSymbols(e),l=[];for(const e of Object.keys(a).map(Number))l.push(s[e]);l.sort(wt);for(const e of l){const o=e.featureIndex.lookupSymbolFeatures(a[e.bucketInstanceId],e.bucketIndex,e.sourceLayerIndex,t,i,r);for(const t in o){const i=n[t]=n[t]||[],s=o[t];s.sort((t,i)=>{const o=e.featureSortOrder;if(o){const e=o.indexOf(t.featureIndex);return o.indexOf(i.featureIndex)-e}return i.featureIndex-t.featureIndex});for(const e of s)i.push(e);}}return n}function bt(e,t){const i=e.getRenderableIds().map(t=>e.getTileByID(t)),o=[],s={};for(let e=0;et.getLayer(e)).filter(Boolean);if(0!==e.length){o.layers=e,o.stateDependentLayerIds&&(o.stateDependentLayers=o.stateDependentLayerIds.map(t=>e.filter(e=>e.id===t)[0]));for(const t of e)i[t.fqid]=o;}}return i}const Et=32,St=33,It=new Uint16Array(8184);for(let e=0;e<2046;e++){let t=e+2,i=0,o=0,s=0,r=0,n=0,a=0;for(1&t?s=r=n=Et:i=o=a=Et;(t>>=1)>1;){const e=i+s>>1,l=o+r>>1;1&t?(s=i,r=o,i=n,o=a):(i=s,o=r,s=n,r=a),n=e,a=l;}const l=4*e;It[l+0]=i,It[l+1]=o,It[l+2]=s,It[l+3]=r;}const Ct=new Uint16Array(2178),Rt=new Uint8Array(1089),At=new Uint16Array(1089);function Dt(e){return 0===e?-.03125:32===e?.03125:0}const Lt=(()=>({type:2,extent:e.am,loadGeometry:()=>[[new e.P(0,0),new e.P(e.am+1,0),new e.P(e.am+1,e.am+1),new e.P(0,e.am+1),new e.P(0,0)]]}))();class Pt{constructor(t,i,o,s,r,n){this.tileID=t,this.uid=e.b3(),this.uses=0,this.tileSize=i,this.tileZoom=o,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=r,s&&s.style&&(this._lastUpdatedBrightness=s.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",s&&s.transform&&(this.projection=s.transform.projection),this.worldview=n,this._hasAppearances=null;}registerFadeDuration(t){const i=t+this.timeAdded;ie)t=!1;else if(i)if(this.expirationTimee.appearances&&e.appearances.length>0))return !0;return !1}updateBuckets(t,i,o){if(!this.latestFeatureIndex)return;if(!t.style)return;const s=t.style.listImages(),r=t.style.getBrightness();for(const n in this.buckets){if(!t.style.hasLayer(n))continue;const a=this.buckets[n],l=a.layers[0],c=l.sourceLayer||"_geojsonTileLayer",h=t.style.getLayerSourceCache(l);let d=o&&o[c]||{};o||(d=h._state.getState(c,void 0));const u=this.imageAtlas?Object.fromEntries(this.imageAtlas.patternPositions):{},_=Object.keys(d).length>0&&!i;a.hasAppearances=a.layers.some(e=>e.appearances&&e.appearances.length>0);const p=_?a.stateDependentLayers:a.layers;if(_&&0!==a.stateDependentLayers.length||i){const e=this.latestFeatureIndex.loadVTLayers();a.update(d,e[c],s,u,p,i,r);}if(_&&0!==a.stateDependentLayers.length||i||a.hasAppearances){const e={zoom:t.transform.zoom,pitch:t.transform.pitch,brightness:t.style.getBrightness()||0,worldview:t.worldview};a.updateAppearances(this.tileID.canonical,d,s,e,t.imageManager);}(a instanceof e.bb||a instanceof e.bc)&&t._terrain&&t._terrain.enabled&&h&&a.uploadPending()&&t._terrain._clearRenderCacheForTile(h.id,this.tileID);const f=t&&t.style&&t.style.getOwnLayer(n);f&&(this.queryPadding=Math.max(this.queryPadding,f.queryRadius(a)));}}holdingForFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return !this.symbolFadeHoldUntil||this.symbolFadeHoldUntil=0;e--){const t=4*e,i=It[t+0],o=It[t+1],s=It[t+2],r=It[t+3],n=i+s>>1,a=o+r>>1,l=n+a-o,c=a+i-n,h=o*St+i,d=r*St+s,u=a*St+n,_=Math.hypot((Ct[2*h+0]+Ct[2*d+0])/2-Ct[2*u+0],(Ct[2*h+1]+Ct[2*d+1])/2-Ct[2*u+1])>=16;Rt[u]=Rt[u]||(_?1:0),e<1022&&(Rt[u]=Rt[u]||Rt[(o+c>>1)*St+(i+l>>1)]||Rt[(r+c>>1)*St+(s+l>>1)]);}const r=new e.b2,n=new e.b1;let a=0;function l(t,i){const o=i*St+t;return 0===At[o]&&(r.emplaceBack(Ct[2*o+0],Ct[2*o+1],t*e.am/Et,i*e.am/Et),At[o]=++a),At[o]-1}function c(e,t,i,o,s,r){const a=e+i>>1,h=t+o>>1;if(Math.abs(e-s)+Math.abs(t-r)>1&&Rt[h*St+a])c(s,r,e,t,a,h),c(i,o,s,r,a,h);else {const a=l(e,t),c=l(i,o),h=l(s,r);n.emplaceBack(a,c,h);}}return c(0,0,Et,Et,Et,0),c(Et,Et,0,0,0,Et),{vertices:r,indices:n}}(this.tileID.canonical,i);s=t.vertices,r=t.indices;}else {s=new e.b2,r=new e.b1;for(const{x:e,y:t}of o)s.emplaceBack(e,t,0,0);const t=e.bi(s.int16.subarray(0,4*s.length),void 0,4);for(let e=0;e0&&(l=e.bm(new Float64Array(16),i.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(t,s,i,n,l,a),this._makeGlobeTileDebugTextBuffer(t,s,i,n,l,a);}_globePoint(t,i,o,s,r,n,a){let l=e.bn(t,i,o);if(n){const r=1<.5?u=-1:d<-.5&&(u=1);let _=(t/e.am+o.x)/r+u,p=(i/e.am+o.y)/r;_=(_-c)*s._pixelsPerMercatorPixel+c,p=(p-h)*s._pixelsPerMercatorPixel+h;const f=[_*s.worldSize,p*s.worldSize,0];e.ag(f,f,n),l=e.bo(l,f,a);}return e.ag(l,l,r)}_makeGlobeTileDebugBorderBuffer(t,i,o,s,r,n){const a=new e.be,l=new e.bf,c=new e.bp,h=(e,t,h,d,u)=>{const _=(h-e)/(u-1),p=(d-t)/(u-1),f=a.length;for(let h=0;hd*e+t;for(let e=0;e{if(e)i(e);else try{const e=o.getHeaderLength(s);if(e>t)return void(this.request=this.fetchHeader(e,i));o.parseHeader(s),this._isHeaderLoaded=!0;let n=0;for(const e of Object.values(o.layers))n=Math.max(n,e.dataIndex[e.dataIndex.length-1].lastByte);s.byteLength>=n&&(this.entireBuffer=s),i(null,this.entireBuffer||s,r);}catch(e){i(e);}}),this.request}fetchBandForRender(e,t,i,o){this.fetchBand(e,t,i,s=>{if(s)return void o(s);this.updateTextureDescriptor(e,t,i);const r=this.textureDescriptorPerLayer.get(t);o(null,r?r.img:null);});}fetchBand(t,i,o,s,r=!0){const n=this._mrt;if(!this._isHeaderLoaded||!n)return void s(new Error("Tile header is not ready"));const a=this.actor;if(!a)return void s(new Error("Can't fetch tile band without an actor"));let l;const c=e.C(String(o),e.C(this.tileID.key,t));let h=this._taskQueue.get(c);h?h.add(s):(h=new Set,h.add(s),this._taskQueue.set(c,h));const d=(e,t)=>{l.complete(e,t),e?s(e):(h.forEach(e=>e(null,t)),this._taskQueue.delete(c));},u=(e,t)=>{if(e)return s(e);const o=a.send("decodeRasterArray",{type:"raster-array",source:this.source,scope:this.scope,tileID:this.tileID,uid:this.uid,buffer:t,task:l},d,void 0,!0);if(null!==i){const e=this._workQueuePerLayer.get(i)||[];e.push(()=>{o&&o.cancel(),l.cancel();}),this._workQueuePerLayer.has(i)||this._workQueuePerLayer.set(i,e);}};let _;try{_=n.getLayer(t);}catch(e){if("reloading"===this.state)return;throw e}if(!_)return void s(new Error(`Unknown sourceLayer "${t}"`));if(_.hasDataForBand(o))return h.forEach(e=>e(null,null)),void this._taskQueue.delete(c);const p=_.getDataRange([o]);if(l=n.createDecodingTask(p),!l||l.tasks.length)if(null!==i&&this.flushQueues(i),this.entireBuffer)u(null,this.entireBuffer.slice(p.firstByte,p.lastByte+1));else {const t=Object.assign({},this.requestParams,{headers:{Range:`bytes=${p.firstByte}-${p.lastByte}`}}),o=e.bv(t,u);if(null!==i){const e=this._fetchQueuePerLayer.get(i)||[];e.push(()=>{o.cancel(),l.cancel();}),this._fetchQueuePerLayer.has(i)||this._fetchQueuePerLayer.set(i,e);}}}updateNeeded(e,t){return (!this.textureDescriptorPerLayer.get(e)||this.textureDescriptorPerLayer.get(e).band!==t||this.refreshedUponExpiration)&&"errored"!==this.state}updateTextureDescriptor(t,i,o){if(!this._mrt)return;const s=this._mrt.getLayer(t);if(!s||!s.hasBand(o)||!s.hasDataForBand(o))return;const{bytes:r,tileSize:n,buffer:a,offset:l,scale:c}=s.getBandView(o),h=n+2*a,d=new e.q({width:h,height:h},r),u=this.texturePerLayer.get(i);u&&u instanceof e.T&&u.update(d,{premultiply:!1}),this.textureDescriptorPerLayer.set(i,{layer:t,band:o,img:d,buffer:a,offset:l,tileSize:n,format:s.pixelFormat,mix:[c,256*c,65536*c,16777216*c]});}destroy(t=!1){if(super.destroy(t),delete this._mrt,!t)for(const t of this.texturePerLayer.values())t&&t instanceof e.T&&t.destroy();this.texturePerLayer.clear(),this.textureDescriptorPerLayer.clear(),this.fbo&&(this.fbo.destroy(),delete this.fbo),delete this.request,delete this.requestParams,this._isHeaderLoaded=!1;}}class zt{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,i){const o=e.wrapped().key;void 0===this.data[o]&&(this.data[o]=[]);const s={value:t,timeout:void 0};if(void 0!==i&&(s.timeout=setTimeout(()=>{this.remove(e,s);},i)),this.data[o].push(s),this.order.push(o),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 i=e.wrapped().key,o=void 0===t?0:this.data[i].indexOf(t),s=this.data[i][o];return this.data[i].splice(o,1),s.timeout&&clearTimeout(s.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(s.value),this.order.splice(this.order.indexOf(i),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 i in this.data)for(const o of this.data[i])e(o.value)||t.push(o);for(const e of t)this.remove(e.value.tileID,e);}}class Mt{constructor(){this.state={},this.stateChanges={},this.deletedStates={};}updateState(e,t,i){const o=String(t);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][o]=this.stateChanges[e][o]||{},Object.assign(this.stateChanges[e][o],i),null===this.deletedStates[e]){this.deletedStates[e]={};for(const t in this.state[e])t!==o&&(this.deletedStates[e][t]=null);}else if(this.deletedStates[e]&&null===this.deletedStates[e][o]){this.deletedStates[e][o]={};for(const t in this.state[e][o])i[t]||(this.deletedStates[e][o][t]=null);}else for(const t in i)this.deletedStates[e]&&this.deletedStates[e][o]&&null===this.deletedStates[e][o][t]&&delete this.deletedStates[e][o][t];}removeFeatureState(e,t,i){if(null===this.deletedStates[e])return;const o=String(t);if(this.deletedStates[e]=this.deletedStates[e]||{},i&&void 0!==t)null!==this.deletedStates[e][o]&&(this.deletedStates[e][o]=this.deletedStates[e][o]||{},this.deletedStates[e][o][i]=null);else if(void 0!==t)if(this.stateChanges[e]&&this.stateChanges[e][o])for(i in this.deletedStates[e][o]={},this.stateChanges[e][o])this.deletedStates[e][o][i]=null;else this.deletedStates[e][o]=null;else this.deletedStates[e]=null;}getState(e,t){const i=this.state[e]||{},o=this.stateChanges[e]||{},s=this.deletedStates[e];if(null===s)return {};if(void 0!==t){const e=String(t),r=Object.assign({},i[e],o[e]);if(s){const e=s[t];if(null===e)return {};for(const t in e)delete r[t];}return r}const r=Object.assign({},i,o);if(s)for(const e in s)delete r[e];return r}initializeTileState(e,t){e.refreshFeatureState(t);}coalesceChanges(e,t){const i={};for(const e in this.stateChanges){this.state[e]=this.state[e]||{};const t={};for(const i in this.stateChanges[e])this.state[e][i]||(this.state[e][i]={}),Object.assign(this.state[e][i],this.stateChanges[e][i]),t[i]=this.state[e][i];i[e]=t;}for(const e in this.deletedStates){this.state[e]=this.state[e]||{};const t={};if(null===this.deletedStates[e])for(const i in this.state[e])t[i]={},this.state[e][i]={};else for(const i in this.deletedStates[e]){if(null===this.deletedStates[e][i])this.state[e][i]={};else if(this.state[e][i])for(const t of Object.keys(this.deletedStates[e][i]))delete this.state[e][i][t];t[i]=this.state[e][i];}i[e]=i[e]||{},Object.assign(i[e],t);}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(i).length)for(const o in e)e[o].refreshFeatureState(t,i);}}class Ft extends e.E{constructor(e,t,i){super(),this.id=e,this._onlySymbols=i,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 zt(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 Mt,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"raster-array"===this._source.type||"custom"===this._source.type&&"_dataType"in this._source&&"raster"===this._source._dataType,this._supportsFading="raster"===this._source.type||"raster-array"===this._source.type||"image"===this._source.type||"video"===this._source.type||"custom"===this._source.type,this._isRasterElevatedOverTerrain=!1;}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)if(!this._tiles[e].loaded())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 i=this._tiles[t];i.upload(e,this.map?this.map.painter:void 0),i.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope);}}getIds(){return Object.values(this._tiles).map(e=>e.tileID).sort(kt).map(e=>e.key)}getRenderableIds(t,i){const o=[];for(const e in this._tiles)this._isIdRenderable(+e,t,i)&&o.push(this._tiles[e]);return t?o.sort((t,i)=>{const o=t.tileID,s=i.tileID,r=new e.P(o.canonical.x,o.canonical.y)._rotate(this.transform.angle),n=new e.P(s.canonical.x,s.canonical.y)._rotate(this.transform.angle);return o.overscaledZ-s.overscaledZ||n.y-r.y||n.x-r.x}).map(e=>e.tileID.key):o.map(e=>e.tileID).sort(kt).map(e=>e.key)}hasRenderableParent(e){const t=this.findLoadedParent(e,0);return !!t&&this._isIdRenderable(t.tileID.key)}_isIdRenderable(e,t,i){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(t||!this._tiles[e].holdingForFade())&&(i||!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 i=this._tiles[e];i&&("loading"!==i.state&&(i.state=t),this._loadTile(i,this._tileLoaded.bind(this,i,e,t)));}_tileLoaded(t,i,o,s,r){if(s){if(t.state="errored",404!==s.status)this._source.fire(new e.z(s,{tile:t}));else {if(this._source.fire(new e.A("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id,tile:t})),!(t.tileID.key in this._loadedParentTiles))return;if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const e=this.map.painter.terrain;this.update(this.transform,e.getScaledDemTileSize(),!0),e.resetTileLookupCache(this.id);}else this.update(this.transform);}return}t.timeAdded=e.o.now(),"expired"===o&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(i,t),"raster-dem"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null);let n=new Map;r&&r.responseHeaders&&(n=r.responseHeaders),this._source.fire(new e.A("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id,responseHeaders:n}));}_backfillDEM(e){const t=this.getRenderableIds();for(let o=0;o1||(Math.abs(i)>1&&(1===Math.abs(i+s)?i+=s:1===Math.abs(i-s)&&(i-=s)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,i,o),e.neighboringTiles&&e.neighboringTiles[r]&&(e.neighboringTiles[r].backfilled=!0)));}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,t,i,o){for(const s in this._tiles){let r=this._tiles[s];if(o[s]||!r.hasData()||r.tileID.overscaledZ<=t||r.tileID.overscaledZ>i)continue;let n=r.tileID;for(;r&&r.tileID.overscaledZ>t+1;){const e=r.tileID.scaledTo(r.tileID.overscaledZ-1);r=this._tiles[e.key],r&&r.hasData()&&(n=e);}let a=n;for(;a.overscaledZ>t;)if(a=a.scaledTo(a.overscaledZ-1),e[a.key]){o[n.key]=n;break}}}findLoadedParent(e,t){if(e.key in this._loadedParentTiles){const i=this._loadedParentTiles[e.key];return i&&i.tileID.overscaledZ>=t?i:null}for(let i=e.overscaledZ-1;i>=t;i--){const t=e.scaledTo(i),o=this._getLoadedTile(t);if(o)return o}}_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 i=Math.ceil(e.width/t)+1,o=Math.ceil(e.height/t)+1,s=Math.floor(i*o*5),r="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,s):s,n="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,r):r;this._cache.setMaxSize(n);}handleWrapJump(e){const t=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);if(this._prevLng=e,t){const e={};for(const i in this._tiles){const o=this._tiles[i];o.tileID=o.tileID.unwrapTo(o.tileID.wrap+t),e[o.tileID.key]=o;}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,i,o,s,r){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!o)return;this.updateCacheSize(t,i),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={};const n="batched-model"===this._source.type;let a,l=this._source.maxzoom;const c=this.map&&this.map.painter?this.map.painter._terrain:null;if(c&&c.sourceCache===this&&c.attenuationRange()){const e=c.attenuationRange()[0],t=Math.floor(e)-Math.log2(c.getDemUpscale());l>t&&(l=t);}if(this.used||this.usedForTerrain){if(this._source.tileID)a=t.getVisibleUnwrappedCoordinates(this._source.tileID).map(t=>new e.aR(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y));else if(0!==this.tileCoverLift){const s=t.clone();s.tileCoverLift=this.tileCoverLift,a=s.coveringTiles({tileSize:i||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:l,roundZoom:this._source.roundZoom&&!o,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:n}),this._source.minzoom<=1&&"globe"===t.projection.name&&(a.push(new e.aR(1,0,1,0,0)),a.push(new e.aR(1,0,1,1,0)),a.push(new e.aR(1,0,1,0,1)),a.push(new e.aR(1,0,1,1,1)));}else if(a=t.coveringTiles({tileSize:i||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:l,roundZoom:this._source.roundZoom&&!o,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:n}),this._source.hasTile){const e=this._source.hasTile.bind(this._source);a=a.filter(t=>e(t));}}else a=[];if(a.length>0&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!this._supportsFading){const e=t.coveringZoomLevel({tileSize:i||this._source.tileSize,roundZoom:this._source.roundZoom&&!o}),l=Math.min(e,this._source.maxzoom);if(n){const e=t.extendTileCover(a,l);for(const t of e)a.push(t);}else if(r){const e=t.extendTileCoverToNearPlane(a,this.transform.getFrustum(l),l);for(const t of e)a.push(t);}else if(this.castsShadows&&s){const e=t.extendTileCover(a,l,s,16);for(const t of e)this._shadowCasterTiles[t.key]=!0,a.push(t);}}const h=this._updateRetainedTiles(a);if(this._supportsFading&&0!==a.length){const t={},i={},o=e.o.now(),s=Object.keys(h);for(const e of s){const s=h[e],r=this._tiles[e];if(!r||void 0!==r.fadeEndTime&&r.fadeEndTime<=o)continue;const n=this.findLoadedParent(s,Math.max(s.overscaledZ-Ft.maxOverzooming,this._source.minzoom));n&&(this._addTile(n.tileID),t[n.tileID.key]=n.tileID),i[e]=s;}const r=a[a.length-1].overscaledZ;for(const e in this._tiles){const t=this._tiles[e];if(h[e]||!t.hasData())continue;let o=t.tileID;for(;o.overscaledZ>r;){o=o.scaledTo(o.overscaledZ-1);const s=this._tiles[o.key];if(s&&s.hasData()&&i[o.key]){h[e]=t.tileID;break}}}for(const e in t)h[e]||(this._coveredTiles[e]=!0,h[e]=t[e]);}for(const e in h)this._tiles[e].clearFadeHold();const d=e.bw(this._tiles,h);for(const e of d){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 i={},o=e.reduce((e,t)=>Math.min(e,t.overscaledZ),1/0),s=e[0].overscaledZ,r=Math.max(s-Ft.maxOverzooming,this._source.minzoom),n=Math.max(s+Ft.maxUnderzooming,this._source.minzoom),a={};for(const i of e){const e=this._addTile(i);t[i.key]=i,e.hasData()||o=this._source.maxzoom){const e=o.children(this._source.maxzoom)[0],i=this.getTile(e);if(i&&i.hasData()){t[e.key]=e;continue}}else {const e=o.children(this._source.maxzoom);if(t[e[0].key]&&t[e[1].key]&&t[e[2].key]&&t[e[3].key])continue}let s=e.wasRequested();for(let n=o.overscaledZ-1;n>=r;--n){const r=o.scaledTo(n);if(i[r.key])break;if(i[r.key]=!0,e=this.getTile(r),!e&&s&&(e=this._addTile(r)),e&&(t[r.key]=r,s=e.wasRequested(),e.hasData()))break}}return t}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const t=[];let i,o=this._tiles[e].tileID;for(;o.overscaledZ>0;){if(o.key in this._loadedParentTiles){i=this._loadedParentTiles[o.key];break}t.push(o.key);const e=o.scaledTo(o.overscaledZ-1);if(i=this._getLoadedTile(e),i)break;o=e;}for(const e of t)this._loadedParentTiles[e]=i;}}_addTile(t){let i=this._tiles[t.key];if(i)return !0!==i.isExtraShadowCaster||!!this._shadowCasterTiles[t.key]||this._reloadTile(t.key,"reloading"),i;i=this._cache.getAndRemove(t),i&&(this._setTileReloadTimer(t.key,i),i.tileID=t,this._state.initializeTileState(i,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,i)));const o=Boolean(i);if(!o){const e=this.map?this.map.painter:null,o=this._source.tileSize*t.overscaleFactor();i="raster-array"===this._source.type?new Ot(t,o,this.transform.tileZoom,e,this._isRaster):new Pt(t,o,this.transform.tileZoom,e,this._isRaster,this._source.worldview),this._loadTile(i,this._tileLoaded.bind(this,i,t.key,i.state));}return i.uses++,this._tiles[t.key]=i,o||this._source.fire(new e.A("dataloading",{tile:i,coord:i.tileID,dataType:"source"})),i}_setTileReloadTimer(e,t){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const i=t.getExpiryTimeout();i&&(this._timers[e]=setTimeout(()=>{this._reloadTile(e,"expired"),delete this._timers[e];},i));}_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,i,o){const s=[],r=this.transform;if(!r)return s;const n="globe"===r.projection.name,a=e.aG(r.center.lng);for(const l in this._tiles){const c=this._tiles[l];if(o&&c.clearQueryDebugViz(),c.holdingForFade())continue;let h;if(n){const t=c.tileID.canonical;if(0===t.z){const i=[Math.abs(e.aB(a,...Bt(t,-1))-a),Math.abs(e.aB(a,...Bt(t,1))-a)];h=[0,2*i.indexOf(Math.min(...i))-1];}else {const i=[Math.abs(e.aB(a,...Bt(t,-1))-a),Math.abs(e.aB(a,...Bt(t,0))-a),Math.abs(e.aB(a,...Bt(t,1))-a)];h=[i.indexOf(Math.min(...i))-1];}}else h=[0];for(const e of h){const o=t.containsTile(c,r,i,e);o&&s.push(o);}}return s}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(e){return this._getRenderableCoordinates(e)}_getRenderableCoordinates(e,t){const i=this.getRenderableIds(e,t).map(e=>this._tiles[e].tileID),o="globe"===this.transform.projection.name;for(const e of i)e.projMatrix=this.transform.calculateProjMatrix(e.toUnwrapped()),e.expandedProjMatrix=o?this.transform.calculateProjMatrix(e.toUnwrapped(),!1,!0):e.projMatrix;return i}sortCoordinatesByDistance(e){const t=e.slice(),i=this.transform._camera.position,o=this.transform._camera.forward(),s={};for(const e of t){const t=1/(1<s[e.key]-s[t.key]),t}hasTransition(){if(this._source.hasTransition())return !0;if(this._supportsFading){const t=e.o.now();for(const e in this._tiles){const i=this._tiles[e];if(void 0!==i.fadeEndTime&&i.fadeEndTime>=t)return !0}}return !1}setFeatureState(e,t,i){this._state.updateState(e=e||"_geojsonTileLayer",t,i);}removeFeatureState(e,t,i){this._state.removeFeatureState(e=e||"_geojsonTileLayer",t,i);}getFeatureState(e,t){return this._state.getState(e=e||"_geojsonTileLayer",t)}setDependencies(e,t,i){const o=this._tiles[e];o&&o.setDependencies(t,i);}reloadTilesForDependencies(e,t){for(const i in this._tiles)this._tiles[i].hasDependency(e,t)&&this._reloadTile(+i,"reloading");this._cache.filter(i=>!i.hasDependency(e,t));}_preloadTiles(t,i){if(!this._sourceLoaded){const e=()=>{this._sourceLoaded&&(this._source.off("data",e),this._preloadTiles(t,i));};return void this._source.on("data",e)}const o=new Map,s=Array.isArray(t)?t:[t],r=this.map.painter.terrain,n=this.usedForTerrain&&r?r.getScaledDemTileSize():this._source.tileSize;for(const e of s){const t=e.coveringTiles({tileSize:n,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)o.set(e.key,e);this.usedForTerrain&&e.updateElevation(!1);}const a=Array.from(o.values());e.bx(a,(e,t)=>{const i=new Pt(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster,this._source.worldview);this._loadTile(i,e=>{"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),t(e,i);});},i);}}function kt(e,t){const i=Math.abs(2*e.wrap)-+(e.wrap<0),o=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||o-i||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function Bt(e,t){const i=1<0:"building"===i.type?o=!i.isHidden(e)&&i.paint.get("building-opacity")>0:"model"===i.type&&(o=!i.isHidden(e)&&i.paint.get("model-opacity").constantOr(1)>0),this.layersGotHidden=this.layersGotHidden||!o&&t.visible,t.visible=o;}}updateZOffset(e,t){this.currentBuildingBuckets=[];for(const e of this.layers){const i=e.layer,o=this.style.getLayerSourceCache(i);let s=1;"fill-extrusion"===i.type?s=e.visible?i.paint.get("fill-extrusion-vertical-scale"):0:"building"===i.type&&(s=e.visible?i.paint.get("building-vertical-scale"):0);let r=o?o.getTile(t):null;if(!r&&o)for(const e in o._tiles){const i=o._tiles[e];if(t.canonical.isChildOf(i.tileID.canonical)){r=i;break}}this.currentBuildingBuckets.push({bucket:r?r.getBucket(i):null,tileID:r?r.tileID:t,verticalScale:s});}e.hasAnyZOffset=!1;let i=!1;for(let o=0;o{e in i&&(o[e]=i[e]);}),o}function jt(e){e=e.slice();const t=Object.create(null);for(let i=0;i0?(s-n)/a:0;return this.points[r].mult(1-l).add(this.points[i].mult(l))}}class ei{constructor(e,t,i){const o=this.boxCells=[],s=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);for(let e=0;ethis.width||o<0||t>this.height)return !s&&[];const n=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=o){if(s)return !0;for(let e=0;e0:n}_queryCircle(e,t,i,o,s){const r=e-i,n=e+i,a=t-i,l=t+i;if(n<0||r>this.width||l<0||a>this.height)return !o&&[];const c=[];return this._forEachCell(r,a,n,l,this._queryCellCircle,c,{hitTest:o,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}},s),o?c.length>0:c}query(e,t,i,o,s){return this._query(e,t,i,o,!1,s)}hitTest(e,t,i,o,s){return this._query(e,t,i,o,!0,s)}hitTestCircle(e,t,i,o){return this._queryCircle(e,t,i,!0,o)}_queryCell(e,t,i,o,s,r,n,a){const l=n.seenUids,c=this.boxCells[s];if(null!==c){const s=this.bboxes;for(const h of c)if(!l.box[h]){l.box[h]=!0;const c=4*h;if(e<=s[c+2]&&t<=s[c+3]&&i>=s[c+0]&&o>=s[c+1]&&(!a||a(this.boxKeys[h]))){if(n.hitTest)return r.push(!0),!0;r.push({key:this.boxKeys[h],x1:s[c],y1:s[c+1],x2:s[c+2],y2:s[c+3]});}}}const h=this.circleCells[s];if(null!==h){const s=this.circles;for(const c of h)if(!l.circle[c]){l.circle[c]=!0;const h=3*c;if(this._circleAndRectCollide(s[h],s[h+1],s[h+2],e,t,i,o)&&(!a||a(this.circleKeys[c]))){if(n.hitTest)return r.push(!0),!0;{const e=s[h],t=s[h+1],i=s[h+2];r.push({key:this.circleKeys[c],x1:e-i,y1:t-i,x2:e+i,y2:t+i});}}}}}_queryCellCircle(e,t,i,o,s,r,n,a){const l=n.circle,c=n.seenUids,h=this.boxCells[s];if(null!==h){const e=this.bboxes;for(const t of h)if(!c.box[t]){c.box[t]=!0;const i=4*t;if(this._circleAndRectCollide(l.x,l.y,l.radius,e[i+0],e[i+1],e[i+2],e[i+3])&&(!a||a(this.boxKeys[t])))return r.push(!0),!0}}const d=this.circleCells[s];if(null!==d){const e=this.circles;for(const t of d)if(!c.circle[t]){c.circle[t]=!0;const i=3*t;if(this._circlesCollide(e[i],e[i+1],e[i+2],l.x,l.y,l.radius)&&(!a||a(this.circleKeys[t])))return r.push(!0),!0}}}_forEachCell(e,t,i,o,s,r,n,a){const l=this._convertToXCellCoord(e),c=this._convertToYCellCoord(t),h=this._convertToXCellCoord(i),d=this._convertToYCellCoord(o);for(let u=l;u<=h;u++)for(let l=c;l<=d;l++)if(s.call(this,e,t,i,o,this.xCellCount*l+u,r,n,a))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,t,i,o,s,r){const n=o-e,a=s-t,l=i+r;return l*l>n*n+a*a}_circleAndRectCollide(e,t,i,o,s,r,n){const a=(r-o)/2,l=Math.abs(e-(o+a));if(l>a+i)return !1;const c=(n-s)/2,h=Math.abs(t-(s+c));if(h>c+i)return !1;if(l<=a||h<=c)return !0;const d=l-a,u=h-c;return d*d+u*u<=i*i}}const ti=Math.tan(85*Math.PI/180);function ii(t,i,o,s,r,n,a){const l=e.bD();if(o)if("globe"===n.name){const t=e.bE(r,i);e.aC(l,l,t);}else {const t=e.bF([],a);l[0]=t[0],l[1]=t[1],l[4]=t[2],l[5]=t[3],s||e.bC(l,l,r.angle);}else e.aC(l,r.labelPlaneMatrix,t);return l}function oi(e,t,i,o,s,r,n){const a=ii(e,t,i,o,s,r,n);return "globe"===r.name&&i||(a[2]=a[6]=a[10]=a[14]=0),a}function si(t,i,o,s,r,n,a){if(o){if("globe"===n.name){const l=ii(t,i,o,s,r,n,a);return e.bm(l,l),e.aC(l,t,l),l}{const i=e.bA(t),o=e.bB([]);return o[0]=a[0],o[1]=a[1],o[4]=a[2],o[5]=a[3],e.aC(i,i,o),s||e.bC(i,i,-r.angle),i}}return r.glCoordMatrix}function ri(t,i,o,s){const r=[t,i,o,1];o?e.aD(r,r,s):mi(r,r,s);const n=r[3];return r[0]/=n,r[1]/=n,r[2]/=n,r}function ni(e,t){return Math.min(.5+e/t*.5,1.5)}function ai(e,t){const i=e[0]/e[3],o=e[1]/e[3];return i>=-t[0]&&i<=t[0]&&o>=-t[1]&&o<=t[1]}function li(t,i,o,s,r,n,a,l,c,h,d=1){const u=o.transform,_=s?t.textSizeData:t.iconSizeData,p=e.bL(_,o.transform.zoom,d),f="globe"===u.projection.name,m=[256/o.width*2+1,256/o.height*2+1],g=s?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;g.clear();let v=null;f&&(v=s?t.text.globeExtVertexArray:t.icon.globeExtVertexArray);const y=t.lineVertexArray,x=s?t.text.placedSymbolArray:t.icon.placedSymbolArray,b=o.transform.width/o.transform.height;let w,T=!1;for(let s=0;sMath.abs(o)?{useVertical:!0}:t===e.bM.vertical?s>0?{needsFlipping:!0}:null:0!==i&&function(e,t){return 0===e||Math.abs(t/e)>ti}(o,s)?1===i?{needsFlipping:!0}:null:o<0?{needsFlipping:!0}:null}function di(t,i,o,s,r,n,a,l,c,h,d,u,_,p,f,m,g,v,y,x){const b=i/24,w=t.lineOffsetX*b,T=t.lineOffsetY*b,{lineStartIndex:E,glyphStartIndex:S,numGlyphs:I,segment:C,writingMode:R,flipState:A}=t,D=E+t.lineLength,L=t=>{if(d){const[i,o,s]=t.up,r=h.length;e.bO(d,r+0,i,o,s),e.bO(d,r+1,i,o,s),e.bO(d,r+2,i,o,s),e.bO(d,r+3,i,o,s);}const[i,o,s]=t.point;e.bP(h,i,o,s,t.angle);};if(I>1){const e=ci(b,l,w,T,o,u,_,t,c,n,p,m,!1,g,v,y,x);if(!e)return {notEnoughRoom:!0};if(s&&!o){let[i,o,s]=e.first.point,[r,n,l]=e.last.point;[i,o]=ri(i,o,s,a),[r,n]=ri(r,n,l,a);const c=hi(R,A,(r-i)*f,n-o);if(t.flipState=c&&c.needsFlipping?1:2,c)return c}L(e.first);for(let e=S+1;e0?n:_i(_,s,i,1,r,void 0,g,v.canonical),l=hi(R,A,(a[0]-i[0])*f,a[1]-i[1]);if(t.flipState=l&&l.needsFlipping?1:2,l)return l}const i=pi(b*l.getoffsetX(S),w,T,o,u,_,C,E,D,c,n,p,m,!1,!1,g,v,y,x);if(!i)return {notEnoughRoom:!0};L(i);}return {}}function ui(e,t,i,o,s){const{x:r,y:n,z:a}=o.projectTilePoint(e.x,e.y,t);if(!s)return ri(r,n,a,i);const[l,c,h]=s.getElevation(e,s.elevation,s.elevationFeature);return ri(r+l,n+c,a+h,i)}function _i(t,i,o,s,r,n,a,l){const c=ui(t.sub(i)._unit()._add(t),l,r,a,n);return e.aw(c,o,c),e.ax(c,c),e.bI(c,o,c,s)}function pi(t,i,o,s,r,n,a,l,c,h,d,u,_,p,f,m,g,v,y){const x=s?t-i:t+i;let b=x>0?1:-1,w=0;s&&(b*=-1,w=Math.PI),b<0&&(w+=Math.PI);let T=l+a+(b>0?0:1)|0,E=r,S=r,I=0,C=0;const R=Math.abs(x),A=[],D=[];let L=n,P=L,O=e.bG([]);const z=()=>_i(P,L,S,R-I+1,d,_,m,g.canonical);for(;I+C<=R;){if(T+=b,T=c)return null;if(S=E,P=L,A.push(S),p&&D.push(P),L=new e.P(h.getx(T),h.gety(T)),E=u[T],!E){const e=ui(L,g.canonical,d,m,_);E=e[3]>0?u[T]=e:z();}I+=C;const t=e.aw([],E,S),i=e.bH(S,E);if(o&&i>0&&C>0&&e.bK(O,t)/(C*i)0,y),T=c*w.perspectiveRatio,E=(o.x1*i+a.x-o.padding)*T+w.point.x,S=(o.y1*i+a.y-o.padding)*T+w.point.y,I=(o.x2*i+a.x+o.padding)*T+w.point.x,C=(o.y2*i+a.y+o.padding)*T+w.point.y,R=w.perspectiveRatio<=.55||w.occluded;return !this.isInsideGrid(E,S,I,C)||!l&&this.grid.hitTest(E,S,I,C,d)||R?{box:[],offscreen:!1,occluded:w.occluded}:{box:[E,S,I,C],offscreen:this.isOffscreen(E,S,I,C),occluded:!1}}placeCollisionCircles(t,i,o,s,r,n,a,l,c,h,d,u,_,p,f,m){const g=[],v=this.transform.elevation,y=t.getProjection(),x="road"===t.elevationType,b=!!v||x,w=e.bW.getAtTileOffsetFunc(m,this.transform.center.lat,this.transform.worldSize,y),T=new e.P(o.tileAnchorX,o.tileAnchorY),E=new e.P(o.tileAnchorX,o.tileAnchorY);let{x:S,y:I,z:C}=y.projectTilePoint(E.x,E.y,m.canonical),R=null;if(b){const e=x?t.getElevationFeatureForText(s):null;R={getElevation:w,elevation:v,elevationFeature:e};const[i,o,r]=w(T,v,e);S+=i,I+=o,C+=r;}const A="globe"===y.name,D=this.projectAndGetPerspectiveRatio(l,S,I,C,m,A||!!v||this.transform.pitch>0,y),{perspectiveRatio:L}=D,P=(u?a/L:a*L)/e.bZ,O=ri(S,I,C,c),z=o.lineOffsetX*P,M=o.lineOffsetY*P,F=e.ao(t.layers[0].layout.get("text-max-angle")),k=Math.cos(F),B=D.signedDistanceFromCamera>0?ci(P,n,z,M,x&&1===o.flipState,O,E,o,r,c,{},b&&!u?R:null,u&&b,y,m,u,k):null;let N=!1,U=!1,j=!0;if(B&&!D.occluded){const t=.5*p*L+f,o=new e.P(-100,-100),s=new e.P(this.screenRightBoundary,this.screenBottomBoundary),r=new Qt,{first:n,last:a}=B,l=n.path.length;let c=[];for(let e=l-1;e>=1;e--)c.push(n.path[e]);for(let e=1;e(b&&!A&&(i=w(oe[3]<=0)&&(c=[]));let m=[];if(c.length>0){let t=1/0,i=-1/0,r=1/0,n=-1/0;for(const e of c)t=Math.min(t,e[0]),r=Math.min(r,e[1]),i=Math.max(i,e[0]),n=Math.max(n,e[1]);i>=o.x&&t<=s.x&&n>=o.y&&r<=s.y&&(m=[c.map(t=>new e.P(t[0],t[1]))],(ts.x||rs.y)&&(m=e.bX(m,o.x,o.y,s.x,s.y)));}for(const e of m){r.reset(e,.25*t);let o=0;o=r.length<=.5*t?1:Math.ceil(r.paddedLength/u)+1;for(let e=0;e0){if(e.aD(l,l,t),this.fogState&&r&&"globe"!==a.name){const t=function(t,i,o,s,r,n){const a=n.calculateFogTileMatrix(r),l=[i,o,s];return e.ag(l,l,a),Ge(t,e.ah(l),n.pitch,n._fov)}(this.fogState,i,o,s,r.toUnwrapped(),this.transform);c=t>.9;}}else mi(l,l,t);const h=l[3];return {point:new e.P((l[0]/h+1)/2*this.transform.width+gi,(-l[1]/h+1)/2*this.transform.height+gi),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(a)/h*.5,1.5),signedDistanceFromCamera:h,occluded:n&&l[2]>h||c}}isOffscreen(e,t,i,o){return i=this.screenRightBoundary||othis.screenBottomBoundary}isInsideGrid(e,t,i,o){return i>=0&&e=0&&te.collisionGroupID===t};}return this.collisionGroups[e]}}function Si(t,i,o,s,r){const{horizontalAlign:n,verticalAlign:a}=e.c2(t),l=-(n-.5)*i,c=-(a-.5)*o,h=e.c3(t,s);return new e.P(l+h[0]*r,c+h[1]*r)}function Ii(t,i,o,s,r){const n=new e.P(t,i);return o&&n._rotate(s?r:-r),n}class Ci{constructor(e,t,i,o,s,r){this.transform=e.clone(),this.projection=e.projection.name,this.collisionIndex=new vi(this.transform,s),this.buildingIndex=r,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=t,this.retainedQueryData={},this.collisionGroups=new Ei(i),this.collisionCircleArrays={},this.prevPlacement=o,o&&(o.prevPlacement=void 0),this.placedOrientations={},this.lastReplacementSourceUpdateTime=0;}getBucketParts(t,i,o,s,r=1){const n=o.getBucket(i),a=o.latestFeatureIndex;if(!n||!a||i.fqid!==n.layerIds[0])return;const l=n.layers[0].layout,c=n.layers[0].paint,h=o.collisionBoxArray,d=Math.pow(2,this.transform.zoom-o.tileID.overscaledZ),u=o.tileSize/e.am,_=o.tileID.toUnwrapped();this.transform.setProjection(n.projection);const p=(f=o.tileID,m=n.getProjection(),g=this.transform,m.name===this.projection?g.calculateProjMatrix(f.toUnwrapped()):Kt(g,m,f));var f,m,g;const v="map"===l.get("text-pitch-alignment"),y="map"===l.get("text-rotation-alignment");i.compileFilter(i.options);const x=i.dynamicFilter(),b=i.dynamicFilterNeedsFeature(),w=i.dynamicFilterNeedsGeometry(),T=this.transform.calculatePixelsToTileUnitsMatrix(o),E=oi(p,o.tileID.canonical,v,y,this.transform,n.getProjection(),T);let S=null;const I=n.getProjection().createInversionMatrix(this.transform,o.tileID.canonical);if(v){const t=si(p,o.tileID.canonical,v,y,this.transform,n.getProjection(),T);S=e.aC([],this.transform.labelPlaneMatrix,t);}let C=null;x&&o.latestFeatureIndex&&(C={unwrappedTileID:_,dynamicFilter:x,dynamicFilterNeedsFeature:b,needGeometry:w}),this.retainedQueryData[n.bucketInstanceId]=new Ti(n.bucketInstanceId,a,n.sourceLayerIndex,n.index,o.tileID);const[R,A]=n.layers[0].layout.get("text-size-scale-range"),D=e.aB(r,R,A),[L,P]=l.get("icon-size-scale-range"),O=e.aB(r,L,P),z={bucket:n,layout:l,paint:c,posMatrix:p,invMatrix:I,mercatorCenter:[e.aG(this.transform.center.lng),e.aK(this.transform.center.lat)],textLabelPlaneMatrix:E,labelToScreenMatrix:S,clippingData:C,scale:d,textPixelRatio:u,holdingForFade:o.holdingForFade(),collisionBoxArray:h,partiallyEvaluatedTextSize:e.bL(n.textSizeData,this.transform.zoom,D),partiallyEvaluatedIconSize:e.bL(n.iconSizeData,this.transform.zoom,O),collisionGroup:this.collisionGroups.get(n.sourceID),latestFeatureIndex:o.latestFeatureIndex};if(s)for(const e of n.sortKeyRanges){const{sortKey:i,symbolInstanceStart:o,symbolInstanceEnd:s}=e;t.push({sortKey:i,symbolInstanceStart:o,symbolInstanceEnd:s,parameters:z});}else t.push({symbolInstanceStart:0,symbolInstanceEnd:n.symbolInstances.length,parameters:z});}attemptAnchorPlacement(e,t,i,o,s,r,n,a,l,c,h,d,u,_,p,f,m,g,v,y,x){const{textOffset0:b,textOffset1:w,crossTileID:T}=p,E=[b,w],S=Si(e,r,n,E,a),I=this.collisionIndex.placeCollisionBox(m,a,t,i,o,s,Ii(S.x,S.y,l,c,this.transform.angle),_,h,d,u.predicate);if(v){const e=m.getSymbolInstanceIconSize(x,this.transform.zoom,p.placedIconSymbolIndex);if(0===this.collisionIndex.placeCollisionBox(m,e,v,i,o,s,Ii(S.x,S.y,l,c,this.transform.angle),_,h,d,u.predicate).box.length)return}if(I.box.length>0){let t;return this.prevPlacement&&this.prevPlacement.variableOffsets[T]&&this.prevPlacement.placements[T]&&this.prevPlacement.placements[T].text&&(t=this.prevPlacement.variableOffsets[T].anchor),this.variableOffsets[T]={textOffset:E,width:r,height:n,anchor:e,textScale:a,prevAnchor:t},this.markUsedJustification(m,e,p,g),m.allowVerticalPlacement&&(this.markUsedOrientation(m,g,p),this.placedOrientations[T]=g),{shift:S,placedGlyphBoxes:I}}}placeLayerBucketPart(t,i,o,s,r=1){const{bucket:n,layout:a,paint:l,posMatrix:c,textLabelPlaneMatrix:h,labelToScreenMatrix:d,clippingData:u,textPixelRatio:_,mercatorCenter:p,invMatrix:f,holdingForFade:m,collisionBoxArray:g,partiallyEvaluatedTextSize:v,partiallyEvaluatedIconSize:y,collisionGroup:x,latestFeatureIndex:b}=t.parameters,w=a.get("text-optional"),T=a.get("icon-optional"),E=a.get("text-allow-overlap"),S=a.get("icon-allow-overlap"),I="map"===a.get("text-rotation-alignment"),C="map"===a.get("icon-rotation-alignment"),R="map"===a.get("text-pitch-alignment"),A=l.get("symbol-z-offset"),D="sea"===a.get("symbol-elevation-reference"),L=a.get("symbol-placement"),[P,O]=a.get("text-size-scale-range"),[z,M]=a.get("icon-size-scale-range"),F=e.aB(r,P,O),k=e.aB(r,z,M),B=a.get("text-variable-anchor"),N=I&&"point"!==L,U=C&&"point"!==L,j=B&&n.hasTextData(),V=n.hasIconTextFit()&&j&&n.hasIconData();this.transform.setProjection(n.projection);const G=j||N,H=U||V;let q=E&&(S||!n.hasIconData()||T),Z=S&&(E||!n.hasTextData()||w);const W=!A.isConstant();!n.collisionArrays&&g&&n.deserializeCollisionBoxes(g),o&&s&&n.updateCollisionDebugBuffers(this.transform.zoom,g,F,k);const $=(t,s,r)=>{const{crossTileID:l,numVerticalGlyphVertices:g}=t;let C=null;if(u&&u.dynamicFilterNeedsFeature||W){const i=this.retainedQueryData[n.bucketInstanceId],o=b.loadFeature({featureIndex:t.featureIndex,bucketIndex:i.bucketIndex,sourceLayerIndex:i.sourceLayerIndex,layoutVertexArrayOffset:0}),s=o.properties?o.properties.worldview:null;if(n.localizable&&n.worldview&&"string"==typeof s)if("all"===s)o.properties.$localized=!0;else {if(!s.split(",").includes(n.worldview))return;o.properties.$localized=!0,o.properties.worldview=n.worldview;}C=u&&u.needGeometry?e.b8(o,!0):o;}if(u&&!(0,u.dynamicFilter)({zoom:this.transform.zoom,pitch:this.transform.pitch,worldview:n.worldview},C,this.retainedQueryData[n.bucketInstanceId].tileID.canonical,new e.P(t.tileAnchorX,t.tileAnchorY),this.transform.calculateDistanceTileData(u.unwrappedTileID)))return this.placements[l]=new bi(!1,!1,!1,!0),void i.add(l);const L=A.evaluate(C,{});if(i.has(l))return;if(m)return void(this.placements[l]=new bi(!1,!1,!1));let P=!1,O=!1,z=!0,M=!1,F=!1,k=null,N={box:null,offscreen:null,occluded:null},U={box:null},j=null,V=null,$=null,X=0,K=0,Y=0;r.textFeatureIndex?X=r.textFeatureIndex:t.useRuntimeCollisionCircles&&(X=t.featureIndex),r.verticalTextFeatureIndex&&(K=r.verticalTextFeatureIndex);const J=n.elevationFeatures?n.elevationFeatures[t.elevationFeatureIndex]:void 0,Q=i=>{i.tileID=this.retainedQueryData[n.bucketInstanceId].tileID;const o=this.transform.elevation;i.elevation=D?L:L+e.bW.getAtTileOffset(i.tileID,new e.P(i.tileAnchorX,i.tileAnchorY),o,J),i.elevation+=t.zOffset;},ee=r.textBox;if(ee){Q(ee);const i=i=>{let o=e.bM.horizontal;if(n.allowVerticalPlacement&&!i&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[l];e&&(this.placedOrientations[l]=e,o=e,this.markUsedOrientation(n,o,t));}return o},o=(t,i)=>{if(n.allowVerticalPlacement&&g>0&&r.verticalTextBox){for(const o of n.writingModes)if(o===e.bM.vertical?(N=i(),U=N):N=t(),N&&N.box&&N.box.length)break}else N=t();};if(B){let a=B;if(this.prevPlacement&&this.prevPlacement.variableOffsets[l]){const e=this.prevPlacement.variableOffsets[l];a.indexOf(e.anchor)>0&&(a=a.filter(t=>t!==e.anchor),a.unshift(e.anchor));}const h=(e,i,o)=>{const r=n.getSymbolInstanceTextSize(v,t,this.transform.zoom,s),l=(e.x2-e.x1)*r+2*e.padding,h=(e.y2-e.y1)*r+2*e.padding,d=t.hasIconTextFit&&!S?i:null;d&&Q(d);let u={box:[],offscreen:!1,occluded:!1};const m=E?2*a.length:a.length;for(let i=0;i=a.length,t,s,n,o,d,v,y);if(m&&(u=m.placedGlyphBoxes,u&&u.box&&u.box.length)){P=!0,k=m.shift;break}}return u};o(()=>h(ee,r.iconBox,e.bM.horizontal),()=>{const t=r.verticalTextBox;return t&&Q(t),n.allowVerticalPlacement&&!(N&&N.box&&N.box.length)&&g>0&&t?h(t,r.verticalIconBox,e.bM.vertical):{box:null,offscreen:null,occluded:null}}),N&&(P=N.box,z=N.offscreen,M=N.occluded);const d=i(!(!N||!N.box));if(!P&&this.prevPlacement){const e=this.prevPlacement.variableOffsets[l];e&&(this.variableOffsets[l]=e,this.markUsedJustification(n,e.anchor,t,d));}}else {const a=(i,o)=>{const r=n.getSymbolInstanceTextSize(v,t,this.transform.zoom,s),a=this.collisionIndex.placeCollisionBox(n,r,i,p,f,G,new e.P(0,0),E,_,c,x.predicate);return a&&a.box&&a.box.length&&(this.markUsedOrientation(n,o,t),this.placedOrientations[l]=o),a};o(()=>a(ee,e.bM.horizontal),()=>{const t=r.verticalTextBox;return n.allowVerticalPlacement&&g>0&&t?(Q(t),a(t,e.bM.vertical)):{box:null,offscreen:null,occluded:null}}),i(!!(N&&N.box&&N.box.length));}}if(j=N,P=j&&j.box&&j.box.length>0,z=j&&j.offscreen,M=j&&j.occluded,t.useRuntimeCollisionCircles){const i=t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex,s=n.text.placedSymbolArray.get(i),r=e.bN(n.textSizeData,v,s),l=a.get("text-padding");V=this.collisionIndex.placeCollisionCircles(n,E,s,i,n.lineVertexArray,n.glyphOffsetArray,r,c,h,d,o,R,x.predicate,t.collisionCircleDiameter*r/e.bZ,l,this.retainedQueryData[n.bucketInstanceId].tileID),P=E||V.circles.length>0&&!V.collisionDetected,z=z&&V.offscreen,M=V.occluded;}if(r.iconFeatureIndex&&(Y=r.iconFeatureIndex),r.iconBox){const i=i=>{Q(i);const o=t.hasIconTextFit&&k?Ii(k.x,k.y,I,R,this.transform.angle):new e.P(0,0),s=n.getSymbolInstanceIconSize(y,this.transform.zoom,t.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(n,s,i,p,f,H,o,S,_,c,x.predicate)};U&&U.box&&U.box.length&&r.verticalIconBox?($=i(r.verticalIconBox),O=$.box.length>0):($=i(r.iconBox),O=$.box.length>0),z=z&&$.offscreen,F=$.occluded;}const te=w||0===t.numHorizontalGlyphVertices&&0===g,ie=T||0===t.numIconVertices;if(te||ie?ie?te||(O=O&&P):P=O&&P:O=P=O&&P,P&&j&&j.box&&this.collisionIndex.insertCollisionBox(j.box,a.get("text-ignore-placement"),n.bucketInstanceId,U&&U.box&&K?K:X,x.ID),O&&$&&this.collisionIndex.insertCollisionBox($.box,a.get("icon-ignore-placement"),n.bucketInstanceId,Y,x.ID),V&&(P&&this.collisionIndex.insertCollisionCircles(V.circles,a.get("text-ignore-placement"),n.bucketInstanceId,X,x.ID),o)){const e=n.bucketInstanceId;let t=this.collisionCircleArrays[e];void 0===t&&(t=this.collisionCircleArrays[e]=new wi);for(let e=0;e=0;--e){const i=t[e];$(n.symbolInstances.get(i),i,n.collisionArrays[i]);}n.hasAnyZOffset&&e.w(`${n.layerIds[0]} layer symbol-z-elevate: symbols are not sorted by elevation if symbol-z-order is evaluated to viewport-y`);}else if(n.hasAnyZOffset){const e=n.getSortedIndexesByZOffset();for(let t=0;t=0&&(t.text.placedSymbolArray.get(r).crossTileID=d>=0&&r!==d?0:c),n>=0&&(t.text.placedSymbolArray.get(n).crossTileID=d>=0&&n!==d?0:c),a>=0&&(t.text.placedSymbolArray.get(a).crossTileID=d>=0&&a!==d?0:c),l>=0&&(t.text.placedSymbolArray.get(l).crossTileID=d>=0&&l!==d?0:c);}markUsedOrientation(t,i,o){const s=i===e.bM.horizontal||i===e.bM.horizontalOnly?i:0,r=i===e.bM.vertical?i:0,{leftJustifiedTextSymbolIndex:n,centerJustifiedTextSymbolIndex:a,rightJustifiedTextSymbolIndex:l,verticalPlacedTextSymbolIndex:c}=o,h=t.text.placedSymbolArray;n>=0&&(h.get(n).placedOrientation=s),a>=0&&(h.get(a).placedOrientation=s),l>=0&&(h.get(l).placedOrientation=s),c>=0&&(h.get(c).placedOrientation=r);}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const t=this.prevPlacement;let i=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;const o=t?t.symbolFadeChange(e):1,s=t?t.opacities:{},r=t?t.variableOffsets:{},n=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],r=s[e];r?(this.opacities[e]=new xi(r,o,t.text,t.icon,null,t.clipped),i=i||t.text!==r.text.placed||t.icon!==r.icon.placed):(this.opacities[e]=new xi(null,o,t.text,t.icon,t.skipFade,t.clipped),i=i||t.text||t.icon);}for(const e in s){const t=s[e];if(!this.opacities[e]){const s=new xi(t,o,!1,!1);s.isHidden()||(this.opacities[e]=s,i=i||t.text.placed||t.icon.placed);}}for(const e in r)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=r[e]);for(const e in n)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=n[e]);i?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e);}updateLayerOpacities(e,t,i,o){o&&(this.lastReplacementSourceUpdateTime=o.updateTime);const s=new Set;for(const r of t){const t=r.getBucket(e);t&&r.latestFeatureIndex&&e.fqid===t.layerIds[0]&&(this.updateBucketOpacities(t,s,r,r.collisionBoxArray,i,o,r.tileID,e.scope),"offset"===t.elevationType&&this.buildingIndex&&this.buildingIndex.updateZOffset(t,r.tileID),"road"===t.elevationType&&t.updateRoadElevation(r.tileID.canonical),t.updateZOffset());}}updateBucketOpacities(t,i,o,s,r,n,a,l){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 c=t.layers[0].layout,h=t.layers[0].paint,d=!!t.layers[0].dynamicFilter(),u=new xi(null,0,!1,!1,!0),_=c.get("text-allow-overlap"),p=c.get("icon-allow-overlap"),f=c.get("text-variable-anchor"),m="map"===c.get("text-rotation-alignment"),g="map"===c.get("text-pitch-alignment"),v=h.get("symbol-z-offset"),y="sea"===c.get("symbol-elevation-reference"),x=!v.isConstant(),b=new xi(null,0,_&&(p||!t.hasIconData()||c.get("icon-optional")),p&&(_||!t.hasTextData()||c.get("text-optional")),!0);!t.collisionArrays&&s&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(s);const w=(e,t,i)=>{for(let o=0;o0||_>0,O=E>0,z=this.placedOrientations[p],M=z===e.bM.vertical,F=z===e.bM.horizontal||z===e.bM.horizontalOnly;!P&&!O||L.isHidden()||T++;let k=!1;if((P||O)&&n)for(const i of t.activeReplacements){if(e.b_(i,r,e.b$.Symbol,l))continue;if(i.min.x>S||S>i.max.x||i.min.y>I||I>i.max.y)continue;const t=e.c0(S,I,a.canonical,i.footprintTileId.canonical);if(k=e.c1(t,i.footprint),k)break}if(P){const e=k?ki:Fi(L.text);w(t.text,h,M?ki:e),w(t.text,_,F?ki:e);const i=L.text.isHidden(),{leftJustifiedTextSymbolIndex:o,centerJustifiedTextSymbolIndex:s,rightJustifiedTextSymbolIndex:r,verticalPlacedTextSymbolIndex:n}=c,a=t.text.placedSymbolArray,l=i||M?1:0;o>=0&&(a.get(o).hidden=l),s>=0&&(a.get(s).hidden=l),r>=0&&(a.get(r).hidden=l),n>=0&&(a.get(n).hidden=i||F?1:0);const d=this.variableOffsets[p];d&&this.markUsedJustification(t,d.anchor,c,z);const u=this.placedOrientations[p];u&&(this.markUsedJustification(t,"left",c,u),this.markUsedOrientation(t,u,c));}if(O){const e=k?ki:Fi(L.icon),{placedIconSymbolIndex:i,verticalPlacedIconSymbolIndex:o}=c,s=t.icon.placedSymbolArray,r=L.icon.isHidden()?1:0;i>=0&&(w(t.icon,E,M?ki:e),s.get(i).hidden=r),o>=0&&(w(t.icon,c.numVerticalIconVertices,F?ki:e),s.get(o).hidden=r);}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const i=t.collisionArrays[s];if(i){let o=new e.P(0,0),s=!0;if(i.textBox||i.verticalTextBox){if(f){const e=this.variableOffsets[p];e?(o=Si(e.anchor,e.width,e.height,e.textOffset,e.textScale),m&&o._rotate(g?this.transform.angle:-this.transform.angle)):s=!1;}d&&(s=!L.clipped),i.textBox&&Ri(t.textCollisionBox.collisionVertexArray,L.text.placed,!s||M,A,y,o.x,o.y),i.verticalTextBox&&Ri(t.textCollisionBox.collisionVertexArray,L.text.placed,!s||F,A,y,o.x,o.y);}const r=s&&Boolean(!F&&i.verticalIconBox);i.iconBox&&Ri(t.iconCollisionBox.collisionVertexArray,L.icon.placed,r,A,y,c.hasIconTextFit?o.x:0,c.hasIconTextFit?o.y:0),i.verticalIconBox&&Ri(t.iconCollisionBox.collisionVertexArray,L.icon.placed,!r,A,y,c.hasIconTextFit?o.x:0,c.hasIconTextFit?o.y:0);}}}if(t.fullyClipped=0===T,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 e-this.lastPlacementChangeTimee}isStale(){return this.stale}setStale(){this.stale=!0;}}function Ri(e,t,i,o,s,r,n){e.emplaceBack(t?1:0,i?1:0,r||0,n||0,o,s?1:0),e.emplaceBack(t?1:0,i?1:0,r||0,n||0,o,s?1:0),e.emplaceBack(t?1:0,i?1:0,r||0,n||0,o,s?1:0),e.emplaceBack(t?1:0,i?1:0,r||0,n||0,o,s?1:0);}const Ai=Math.pow(2,25),Di=Math.pow(2,24),Li=Math.pow(2,17),Pi=Math.pow(2,16),Oi=Math.pow(2,9),zi=Math.pow(2,8),Mi=Math.pow(2,1);function Fi(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;const t=e.placed?1:0,i=Math.floor(127*e.opacity);return i*Ai+t*Di+i*Li+t*Pi+i*Oi+t*zi+i*Mi+t}const ki=0;class Bi{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,i,o,s,r){const n=this._bucketParts;for(;this._currentTileIndexe.sortKey-t.sortKey));this._currentPartIndex{const t=e.o.now()-n;return !this.isFullPlacementRequested()&&0!==this._fadeDuration&&t>2};for(;this._currentPlacementIndex>=0;){const n=i[t[this._currentPlacementIndex]],l=this.placement.collisionIndex.transform.zoom;if("symbol"===n.type&&"none"!==n.visibility&&(!n.minzoom||n.minzoom<=l)&&(!n.maxzoom||n.maxzoom>l)){const t=n,i=t.layout.get("symbol-z-elevate"),l=void 0!==t.layout.get("symbol-sort-key").constantOr(1),c=t.layout.get("symbol-z-order"),h="viewport-y"===c||"auto"===c&&!("viewport-y"!==c&&l),d=t.layout.get("text-allow-overlap")||t.layout.get("icon-allow-overlap")||t.layout.get("text-ignore-placement")||t.layout.get("icon-ignore-placement"),u=h&&d,_=this._inProgressLayer=this._inProgressLayer||new Bi(t),p=e.C(n.source,n.scope);if(_.continuePlacement(i||u?s[p]:o[p],this.placement,this._showCollisionBoxes,n,a,r))return;delete this._inProgressLayer;}this._currentPlacementIndex--;}this._forceFullPlacement=!1,this._done=!0;}commit(e){return this.placement.commit(e),this.placement}}const Ui=512/e.am/2;class ji{constructor(t,i,o){this.tileID=t,this.bucketInstanceId=o,this.index=new e.c5(i.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const s=t.canonical.x*e.am,r=t.canonical.y*e.am;for(let e=0;ee-t);for(const e of _){const t=this.crossTileIDs[e];if(this.keys[e]===l&&!o.has(t)){o.add(t),i.crossTileID=t;break}}}}}class Vi{constructor(){this.maxCrossTileID=0;}generate(){return ++this.maxCrossTileID}}class Gi{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 i=this.indexes[e],o={};for(const e in i){const s=i[e];s.tileID=s.tileID.unwrapTo(s.tileID.wrap+t),o[s.tileID.key]=s;}this.indexes[e]=o;}this.lng=e;}addBucket(e,t,i){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;ee.overscaledZ)for(const i in s){const r=s[i];r.tileID.isChildOf(e)&&r.findMatches(t.symbolInstances,e,o);}else {const r=s[e.scaledTo(Number(i)).key];r&&r.findMatches(t.symbolInstances,e,o);}}for(let e=0;e{t[e]=!0;});for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e];}}const qi=771;class Zi{constructor(e,t,i,o){this.blendFunction=e,this.blendColor=t.toNonPremultipliedRenderColor(null),this.mask=i,this.blendEquation=o;}}Zi.Replace=[1,0,1,0],Zi.disabled=new Zi(Zi.Replace,e.ap.transparent,[!1,!1,!1,!1]),Zi.unblended=new Zi(Zi.Replace,e.ap.transparent,[!0,!0,!0,!0]),Zi.alphaBlended=new Zi([1,qi,1,qi],e.ap.transparent,[!0,!0,!0,!0]),Zi.alphaBlendedNonPremultiplied=new Zi([770,qi,770,qi],e.ap.transparent,[!0,!0,!0,!0]),Zi.multiply=new Zi([774,0,774,0],e.ap.transparent,[!0,!0,!0,!0]),Zi.additive=new Zi([1,1,1,1],e.ap.transparent,[!0,!0,!0,!0]);class Wi{constructor(e,t,i){this.func=e,this.mask=t,this.range=i;}}Wi.ReadOnly=!1,Wi.ReadWrite=!0,Wi.disabled=new Wi(519,Wi.ReadOnly,[0,1]);const $i=7680;class Xi{constructor(e,t,i,o,s,r){this.test=e,this.ref=t,this.mask=i,this.fail=o,this.depthFail=s,this.pass=r;}}Xi.disabled=new Xi({func:519,mask:0},0,0,$i,$i,$i);const Ki=1029,Yi=2305;class Ji{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i;}}function Qi(t,i){const o=e.cb(t,3);e.cd(t,i),e.ch(t,3,o);}function eo(t,i){const o=e.c8([]);return e.c9(o,o,-i),e.ca(o,o,-t),o}function to(t,i){const o=[t[0],t[1],0],s=[i[0],i[1],0];if(e.ah(o)>=1e-15){const t=e.ax([],o);e.c6(s,t,e.bK(s,t)),i[0]=s[0],i[1]=s[1];}const r=e.bJ([],i,t);if(e.c7(r)<1e-15)return null;const n=Math.atan2(-r[1],r[0]);return eo(Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2]),n)}Ji.disabled=new Ji(!1,Ki,Yi),Ji.backCCW=new Ji(!0,Ki,Yi),Ji.backCW=new Ji(!0,Ki,2304),Ji.frontCW=new Ji(!0,1028,2304),Ji.frontCCW=new Ji(!0,1028,Yi);class io{constructor(e,t){this.position=e,this.orientation=t;}get position(){return this._position}set position(t){if(t){const i=t instanceof e.af?t:new e.af(t[0],t[1],t[2]);this._renderWorldCopies&&(i.x=e.bU(i.x,0,1)),this._position=i;}else this._position=null;}lookAtPoint(t,i,o){if(this.orientation=null,!this.position)return;const s=this.position,r=o||(this._elevation?this._elevation.getAtPointOrZero(e.af.fromLngLat(t)):0),n=e.af.fromLngLat(t,r),a=[n.x-s.x,n.y-s.y,n.z-s.z];i||(i=[0,0,1]),i[2]=Math.abs(i[2]),this.orientation=to(a,i);}setPitchBearing(t,i){this.orientation=eo(e.ao(t),e.ao(-i));}}class oo{constructor(t,i){this._transform=e.bB([]),this.orientation=i,this.position=t;}get mercatorPosition(){const t=this.position;return new e.af(t[0],t[1],t[2])}get position(){const t=e.cb(this._transform,3);return [t[0],t[1],t[2]]}set position(t){var i;t&&e.ch(this._transform,3,[(i=t)[0],i[1],i[2],1]);}get orientation(){return this._orientation}set orientation(t){this._orientation=t||e.c8([]),t&&Qi(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=eo(e,t),Qi(this._transform,this._orientation);}forward(){const t=e.cb(this._transform,2);return [-t[0],-t[1],-t[2]]}up(){const t=e.cb(this._transform,1);return [-t[0],-t[1],-t[2]]}right(){const t=e.cb(this._transform,0);return [t[0],t[1],t[2]]}getCameraToWorld(t,i){const o=new Float64Array(16);return e.bm(o,this.getWorldToCamera(t,i)),o}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(t,i,o){const s=this.position;e.c6(s,s,-t);const r=new Float64Array(16);return e.br(r,[o,o,o]),e.bs(r,r,s),r[10]*=i,r}getWorldToCamera(t,i){const o=new Float64Array(16),s=new Float64Array(4),r=this.position;return e.cc(s,this._orientation),e.c6(r,r,-t),e.cd(o,s),e.bs(o,o,r),o[1]*=-1,o[5]*=-1,o[9]*=-1,o[13]*=-1,o[8]*=i,o[9]*=i,o[10]*=i,o[11]*=i,o}getCameraToClipPerspective(t,i,o,s){const r=new Float64Array(16);return e.ce(r,t,i,o,s),r}getCameraToClipOrthographic(t,i,o,s,r,n){const a=new Float64Array(16);return e.cf(a,t,i,o,s,r,n),a}getDistanceToElevation(t,i=!1){const o=0===t?0:e.cg(t,i?e.b0(this.position[1]):this.position[1]),s=this.forward();return (o-this.position[2])/s[2]}clone(){return new oo([...this.position],[...this.orientation])}}const so=(e,t)=>({u_matrix:e,u_ground_shadow_factor:t});class ro{constructor(e=0,t=0,i=0,o=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(i)||i<0||isNaN(o)||o<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=i,this.right=o;}interpolate(t,i,o){return null!=i.top&&null!=t.top&&(this.top=e.al(t.top,i.top,o)),null!=i.bottom&&null!=t.bottom&&(this.bottom=e.al(t.bottom,i.bottom,o)),null!=i.left&&null!=t.left&&(this.left=e.al(t.left,i.left,o)),null!=i.right&&null!=t.right&&(this.right=e.al(t.right,i.right,o)),this}getCenter(t,i){const o=e.aB((this.left+t-this.right)/2,0,t),s=e.aB((this.top+i-this.bottom)/2,0,i);return new e.P(o,s)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new ro(this.top,this.bottom,this.left,this.right)}toJSON(){return {top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const no=15;class ao{constructor(t,i,o,s,r,n,a){this.tileSize=512,this._renderWorldCopies=void 0===r||r,this._minZoom=t||0,this._maxZoom=i||22,this._minPitch=o??0,this._maxPitch=s??60,this.setProjection(n),this.setMaxBounds(a),this.width=0,this.height=0,this._center=new e.aU(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._nearClipOffset=0,this._unmodified=!0,this._edgeInsets=new ro,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new oo,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._pixelsPerMercatorPixel=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._tileCoverLift=0,this.freezeTileCoverage=!1,this._horizonShift=.1,this._orthographicProjectionAtLowPitch=!1,this._allowWorldUnderZoom=!1;}clone(){const e=new ao(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection(),this.maxBounds);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._nearClipOffset=this._nearClipOffset,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._allowWorldUnderZoom=this._allowWorldUnderZoom,e}get isOrthographic(){return "globe"!==this.projection.name&&this._orthographicProjectionAtLowPitch&&this.pitch0&&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 i=this._elevation;t||this._centerAltitude&&this._centerAltitudeValidForExaggeration&&i.exaggeration()&&this._centerAltitudeValidForExaggeration!==i.exaggeration()?(this._centerAltitude=this._centerAltitude/this._centerAltitudeValidForExaggeration*i.exaggeration(),this._centerAltitudeValidForExaggeration=i.exaggeration()):(this._centerAltitude=e||0,this._centerAltitudeValidForExaggeration=i.exaggeration()),this._updateSeaLevelZoom();}_updateSeaLevelZoom(){if(void 0===this._centerAltitudeValidForExaggeration)return;const e=Math.max(0,(this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize);this._seaLevelZoom=this._zoomFromMercatorZ(e);}sampleAverageElevation(){if(!this._elevation)return 0;const t=this._elevation,i=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],o=this.horizonLineFromTop();let s=0,r=0;for(let n=0;n{const a=e.cZ(i,t,o,s,n);l.has(a)||(r.push(new e.aR(t,i,o,s,n)),l.add(a));};for(let e=0;er.canonical.z)continue;const l=r.canonical,h=r.overscaledZ,d=r.wrap,u=1<0,f=l.y+10,g=r.wrap-(p?0:1),v=r.wrap+(_?0:1),y=p?l.x-1:u-1,x=_?l.x+1:0;if(n)o[0]<0?(c(h,v,l.z,x,l.y),o[1]<0&&f&&(c(h,d,l.z,l.x,l.y+1),c(h,v,l.z,x,l.y+1)),o[1]>0&&m&&(c(h,d,l.z,l.x,l.y-1),c(h,v,l.z,x,l.y-1))):o[0]>0?(c(h,g,l.z,y,l.y),o[1]<0&&f&&(c(h,d,l.z,l.x,l.y+1),c(h,g,l.z,y,l.y+1)),o[1]>0&&m&&(c(h,d,l.z,l.x,l.y-1),c(h,g,l.z,y,l.y-1))):o[1]<0&&f?c(h,d,l.z,l.x,l.y+1):m&&c(h,d,l.z,l.x,l.y-1);else {const e=r.visibleQuadrants;1&e&&(c(h,g,l.z,y,l.y),m&&(c(h,d,l.z,l.x,l.y-1),c(h,g,l.z,y,l.y-1))),2&e&&(c(h,v,l.z,x,l.y),m&&(c(h,d,l.z,l.x,l.y-1),c(h,v,l.z,x,l.y-1))),4&e&&(c(h,g,l.z,y,l.y),f&&(c(h,d,l.z,l.x,l.y+1),c(h,g,l.z,y,l.y+1))),8&e&&(c(h,v,l.z,x,l.y),f&&(c(h,d,l.z,l.x,l.y+1),c(h,v,l.z,x,l.y+1)));}}const h=[];for(const e of r)r.some(t=>e.isChildOf(t))||h.push(e);if(r=h.filter(e=>!t.some(t=>!!(e.overscaledZ{const t=e.canonical.x+.5-o[0],i=e.canonical.y+.5-o[1];return t*t+i*i{const l=e.cZ(i,t,o,n,a);r.has(l)||(s.push(new e.aR(t,i,o,n,a)),r.add(l));},a=t.reduce((e,t)=>Math.max(e,t.overscaledZ),o),l=1<{const s=Math.floor(t[0]),r=Math.floor(t[1]),u=(t[0]-s)*e.am,_=(t[1]-r)*e.am,p=Math.floor(i[0]),f=Math.floor(i[1]),m=(i[0]-p)*e.am,g=(i[1]-f)*e.am;for(let t=-1;t<=1;t++){const i=s+t;if(!(i<0||i>=l)){h.x=u-t*e.am,d.x=m-(i-p)*e.am;for(let t=-1;t<=1;t++){const s=r+t;h.y=_-t*e.am,d.y=g-(s-f)*e.am,e.c_(h,d,c)&&n(a,0,o,i,s);}}}},_=i.points,p=_[e.cw],f=_[e.cx],m=this._projectToGround(p,_[e.cy]),g=this._projectToGround(f,_[e.cz]);return u(p,m),u(f,g),s}_projectToGround(t,i){return e.cA(e.cB(),t,i,t[2]/(t[2]-i[2]))}coveringTiles(t){let i=this.coveringZoomLevel(t);const o=i,s=this.elevation&&this.elevation.exaggeration(),r=s&&!t.isTerrainDEM,n="mercator"===this.projection.name;if(void 0!==t.minzoom&&it.maxzoom&&(i=t.maxzoom);const a=this.locationCoordinate(this.center),l=this.center.lat,c=1<{const i=1/4e4,o=new e.af(t.x+i,t.y,t.z),s=new e.af(t.x,t.y+i,t.z),r=t.toLngLat(),n=o.toLngLat(),a=s.toLngLat(),l=this.locationCoordinate(r),c=this.locationCoordinate(n),h=this.locationCoordinate(a),d=Math.hypot(c.x-l.x,c.y-l.y),u=Math.hypot(h.x-l.x,h.y-l.y);return Math.sqrt(d*u)*T/i},S=t=>{const i=b,o=w;return {aabb:e.cG(this,c,0,0,0,t,o,i,this.projection),zoom:0,x:0,y:0,minZ:o,maxZ:i,wrap:t,fullyVisible:!1}},I=[];let C=[];const R=i,A=t.reparseOverscaled?o:i,D=(m-this._centerAltitude)*f,L=e=>{if(!this._elevation||!e.tileID||!n)return;const t=this._elevation.getMinMaxForTile(e.tileID),i=e.aabb;t?(i.min[2]=t.min,i.max[2]=t.max,i.center[2]=(i.min[2]+i.max[2])/2):(e.shouldSplit=O(e),e.shouldSplit||(i.min[2]=i.max[2]=i.center[2]=this._centerAltitude));},P=(e,t)=>{if(.707*t{if(t.zoom=.9)return !0}else if(r&&(a=t.aabb.distanceZ(g)*f),this.projection.isReprojectedInTileSpace&&o<=5){const i=Math.pow(2,t.zoom),o=E(new e.af((t.x+.5)/i,(t.y+.5)/i));c=o>.85?1:o;}if(!n&&!d){const e=Math.sqrt(i*i+s*s+a*a);let o=(1<0;){const o=I.pop(),s=o.x,a=o.y;let l=o.fullyVisible;const u=()=>"globe"===this.projection.name&&(0===o.y||o.y===(1<r)continue;let n=0;if(!l){let i=v?o.aabb.intersectsPrecise(_):o.aabb.intersectsPreciseFlat(_);if(0===i&&u()){const t=new e.cE(o.zoom,s,a);i=e.cF(this,c,t,!0).intersectsPrecise(_);}if(0===i)continue;if(t.calculateQuadrantVisibility)if(_.containsPoint(o.aabb.center))n=15;else for(let e=0;e<4;e++)0!==o.aabb.quadrant(e).intersects(_)&&(n|=1<>1),u={aabb:n?o.aabb.quadrant(t):e.cG(this,c,o.zoom+1,i,h,o.wrap,o.minZ,o.maxZ,this.projection),zoom:o.zoom+1,x:i,y:h,wrap:o.wrap,fullyVisible:l,tileID:void 0,shouldSplit:void 0,minZ:o.minZ,maxZ:o.maxZ};r&&!d&&(u.tileID=new e.aR(o.zoom+1===R?A:o.zoom+1,o.wrap,o.zoom+1,i,h),L(u)),I.push(u);}}if(this.fogCullDistSq){const i=this.fogCullDistSq,o=this.horizonLineFromTop();C=C.filter(s=>{const r=[0,0,0,1],n=[e.am,e.am,0,1],a=this.calculateFogTileMatrix(s.tileID.toUnwrapped());e.aD(r,r,a),e.aD(n,n,a);const l=e.cH([],r,n),c=e.cI([],r,n),h=e.d0(l,c);if(0===h)return !0;let d=!1;const u=this._elevation;if(u&&h>i&&0!==o){const i=this.calculateProjMatrix(s.tileID.toUnwrapped());let r;t.isTerrainDEM||(r=u.getMinMaxForTile(s.tileID)),r||(r={min:w,max:b});const n=e.cJ(this.rotation),a=[n[0]*e.am,n[1]*e.am,r.max];e.ag(a,a,i),d=(1-a[1])*this.height*.5e.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.log2(e)}project(t){const i=e.aB(t.lat,-e.cK,e.cK),o=this.projection.project(t.lng,i);return new e.P(o.x*this.worldSize,o.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.cg(1,this.center.lat)/this.worldSize}setLocationAtPoint(t,i){let o,s;const r=this.centerPoint;if("globe"===this.projection.name){const e=this.worldSize;o=(i.x-r.x)/e,s=(i.y-r.y)/e;}else {const e=this.pointCoordinate(i),t=this.pointCoordinate(r);o=e.x-t.x,s=e.y-t.y;}const n=this.locationCoordinate(t);this.setLocation(new e.af(n.x-o,n.y-s));}setLocation(e){this.center=this.coordinateLocation(e),this.projection.wrap&&(this.center=this.center.wrap());}locationPoint(e,t){return this.projection.locationPoint(this,e,t)}locationPoint3D(e,t){return this.projection.locationPoint(this,e,t,!0)}pointLocation(e){return this.coordinateLocation(this.pointCoordinate(e))}pointLocation3D(e,t){return this.coordinateLocation(this.pointCoordinate3D(e,t))}locationCoordinate(t,i){const o=i?e.cg(i,t.lat):void 0,s=this.projection.project(t.lng,t.lat);return new e.af(s.x,s.y,o)}coordinateLocation(e){return this.projection.unproject(e.x,e.y)}pointRayIntersection(t,i){const o=null!=i?i:this._centerAltitude,s=[t.x,t.y,0,1],r=[t.x,t.y,1,1];e.aD(s,s,this.pixelMatrixInverse),e.aD(r,r,this.pixelMatrixInverse);const n=r[3];e.cL(s,s,1/s[3]),e.cL(r,r,1/n);const a=s[2],l=r[2];return {p0:s,p1:r,t:a===l?0:(o-a)/(l-a)}}screenPointToMercatorRay(t){const i=[t.x,t.y,0,1],o=[t.x,t.y,1,1];return e.aD(i,i,this.pixelMatrixInverse),e.aD(o,o,this.pixelMatrixInverse),e.cL(i,i,1/i[3]),e.cL(o,o,1/o[3]),i[2]=e.cg(i[2],this._center.lat)*this.worldSize,o[2]=e.cg(o[2],this._center.lat)*this.worldSize,e.cL(i,i,1/this.worldSize),e.cL(o,o,1/this.worldSize),new e.ay([i[0],i[1],i[2]],e.ax([],e.aw([],o,i)))}rayIntersectionCoordinate(t){const{p0:i,p1:o,t:s}=t,r=e.cg(i[2],this._center.lat),n=e.cg(o[2],this._center.lat);return new e.af(e.al(i[0],o[0],s)/this.worldSize,e.al(i[1],o[1],s)/this.worldSize,e.al(r,n,s))}pointCoordinate(e,t=this._centerAltitude){return this.projection.pointCoordinate(this,e.x,e.y,t)}pointCoordinate3D(t,i){if(!this.elevation)return this.pointCoordinate(t,i);let o=this.projection.pointCoordinate3D(this,t.x,t.y);if(o)return new e.af(o[0],o[1],o[2]);let s=0,r=this.horizonLineFromTop();if(t.y>r)return this.pointCoordinate(t,i);const n=.02*r,a=t.clone();for(let t=0;t<10&&r-s>n;t++){a.y=e.al(s,r,.66);const t=this.projection.pointCoordinate3D(this,a.x,a.y);t?(r=a.y,o=t):s=a.y;}return o?new e.af(o[0],o[1],o[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.cM)return !this.isPointAboveHorizon(t);const i=this.pointCoordinate(t);return i.y>=0&&i.y<=1}_coordinatePoint(t,i){const o=i&&this.elevation?this.elevation.getAtPointOrZero(t,this._centerAltitude):this._centerAltitude,s=[t.x*this.worldSize,t.y*this.worldSize,o+t.toAltitude(),1];return e.aD(s,s,this.pixelMatrix),s[3]>0?new e.P(s[0]/s[3],s[1]/s[3]):new e.P(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){const{top:t,left:i}=this._edgeInsets,o=this.height-this._edgeInsets.bottom,s=this.width-this._edgeInsets.right,r=this.pointLocation3D(new e.P(i,t)),n=this.pointLocation3D(new e.P(s,t)),a=this.pointLocation3D(new e.P(s,o)),l=this.pointLocation3D(new e.P(i,o));let c=Math.min(r.lng,n.lng,a.lng,l.lng),h=Math.max(r.lng,n.lng,a.lng,l.lng),d=Math.min(r.lat,n.lat,a.lat,l.lat),u=Math.max(r.lat,n.lat,a.lat,l.lat);const _=Math.pow(2,-this.zoom)/16*270,p="globe"===this.projection.name?1:4,f=(t,i,o,s,r)=>{const n=(t+o)/2,a=(i+s)/2,l=new e.P(n,a),{lng:m,lat:g}=this.pointLocation3D(l),v=Math.max(0,c-m,d-g,m-h,g-u);c=Math.min(c,m),h=Math.max(h,m),d=Math.min(d,g),u=Math.max(u,g),(r_)&&(f(t,i,n,a,r+1),f(n,a,o,s,r+1));};if(f(i,t,s,t,1),f(s,t,s,o,1),f(s,o,i,o,1),f(i,o,i,t,1),"globe"===this.projection.name){const[t,i]=e.cN(this);t?(u=90,h=180,c=-180):i&&(d=-90,h=180,c=-180);}return new e.aJ(new e.aU(c,d),new e.aU(h,u))}_getBoundsRectangular(t,i){const{top:o,left:s}=this._edgeInsets,r=this.height-this._edgeInsets.bottom,n=this.width-this._edgeInsets.right,a=new e.P(s,o),l=new e.P(n,o),c=new e.P(n,r),h=new e.P(s,r);let d=this.pointCoordinate(a,t),u=this.pointCoordinate(l,t);const _=this.pointCoordinate(c,i),p=this.pointCoordinate(h,i),f=(e,t)=>(t.y-e.y)/(t.x-e.x);return d.y>1&&u.y>=0?d=new e.af((1-p.y)/f(p,d)+p.x,1):d.y<0&&u.y<=1&&(d=new e.af(-p.y/f(p,d)+p.x,0)),u.y>1&&d.y>=0?u=new e.af((1-_.y)/f(_,u)+_.x,1):u.y<0&&d.y<=1&&(u=new e.af(-_.y/f(_,u)+_.x,0)),(new e.aJ).extend(this.coordinateLocation(d)).extend(this.coordinateLocation(u)).extend(this.coordinateLocation(p)).extend(this.coordinateLocation(_))}_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 i=t.dem.tree;e.min=Math.min(e.min,i.minimums[0]),e.max=Math.max(e.max,i.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,i=this.height/2-t*(1-this._horizonShift);return e?Math.max(0,i):i}getMaxBounds(){return this.maxBounds}setMaxBounds(t){this.maxBounds=t,this.minLat=-e.cK,this.maxLat=e.cK,this.minLng=-180,this.maxLng=180,t&&(this.minLat=t.getSouth(),this.maxLat=t.getNorth(),this.minLng=t.getWest(),this.maxLng=t.getEast(),this.maxLngd&&(a=d-c),d-ht&&(n=t-l),t-e{for(let r=0;r<16;r++)t[r]=e.al(i[r],o[r],s);})(a,a,l,e.d1(this.pitch>=no?1:this.pitch/no));}else a=l;const c=e.cQ([],l,n);let h=e.cQ([],a,n);if(this.projection.isReprojectedInTileSpace){const t=this.locationCoordinate(this.center),i=e.bB([]);e.bs(i,i,[t.x*this.worldSize,t.y*this.worldSize,0]),e.aC(i,i,e.cR(this)),e.bs(i,i,[-t.x*this.worldSize,-t.y*this.worldSize,0]),e.aC(h,h,i),e.aC(c,c,i),this.inverseAdjustmentMatrix=e.cS(this);}else this.inverseAdjustmentMatrix=[1,0,0,1];if(this.mercatorMatrix=e.cT([],h,[this.worldSize,this.worldSize,this.worldSize/r,1]),this.projMatrix=h,this.invProjMatrix=e.bm(new Float64Array(16),this.projMatrix),i){const i=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);i[8]=2*-t.x/this.width,i[9]=2*t.y/this.height,this.expandedFarZProjMatrix=e.cQ([],i,n);}else this.expandedFarZProjMatrix=this.projMatrix;const d=e.bm([],a);this.frustumCorners=e.cU.fromInvProjectionMatrix(d,this.horizonLineFromTop(),this.height),this.cameraFrustum=e.cC.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!i);const u=new Float32Array(16);e.bB(u),e.cT(u,u,[1,-1,1]),e.cV(u,u,this._pitch),e.bC(u,u,this.angle);const _=e.ce(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ);this.starsProjMatrix=e.bA(_);const p=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;_[8]=2*-t.x/this.width,_[9]=2*(t.y+p)/this.height,this.skyboxMatrix=e.aC(u,_,u);const f=this.point,m=f.x,g=f.y,v=this.width%2/2,y=this.height%2/2,x=Math.cos(this.angle),b=Math.sin(this.angle),w=m-Math.round(m)+x*v+b*y,T=g-Math.round(g)+x*y+b*v,E=new Float64Array(h);if(e.bs(E,E,[w>.5?w-1:w,T>.5?T-1:T,0]),this.alignedProjMatrix=E,h=e.bD(),e.cT(h,h,[this.width/2,-this.height/2,1]),e.bs(h,h,[1,-1,0]),this.labelPlaneMatrix=h,h=e.bD(),e.cT(h,h,[1,-1,1]),e.bs(h,h,[-1,-1,0]),e.cT(h,h,[2/this.width,2/this.height,1]),this.glCoordMatrix=h,this.pixelMatrix=e.aC(new Float64Array(16),this.labelPlaneMatrix,c),this._calcFogMatrices(),this._distanceTileDataCache={},h=e.bm(new Float64Array(16),this.pixelMatrix),!h)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=h,"globe"===this.projection.name||this.mercatorFromTransition){this.globeMatrix=e.cW(this);const t=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=e.ag(t,t,n),this.globeRadius=this.worldSize/2/Math.PI-1;}else this.globeMatrix=h;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={};}_calcFogMatrices(){this._fogTileMatrixCache={};const t=this.cameraWorldSizeForFog,i=this.cameraPixelsPerMeter,o=this._camera.position,s=1/this.height/this._pixelsPerMercatorPixel,r=[t,t,i];e.c6(r,r,s),e.c6(o,o,-1),e.cX(o,o,r);const n=e.bD();e.bs(n,n,o),e.cT(n,n,r),this.mercatorFogMatrix=n,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(t,i,s);}_computeCameraPosition(e){const t=(e=e||this.pixelsPerMeter)/this.pixelsPerMeter,i=this._camera.forward(),o=this.point,s=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*t-e/this.worldSize*this._centerAltitude;return [o.x/this.worldSize-i[0]*s,o.y/this.worldSize-i[1]*s,e/this.worldSize*this._centerAltitude-i[2]*s]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition());}_translateCameraConstrained(t){const i=this._maxCameraBoundsDistance()*Math.cos(this._pitch),o=this._camera.position[2],s=t[2];let r=1;this.projection.wrap&&(this.center=this.center.wrap()),s>0&&(r=Math.min((i-o)/s,1)),this._camera.position=e.bI([],this._camera.position,t,r),this._updateStateFromCamera();}_updateStateFromCamera(){const t=this._camera.position,i=this._camera.forward(),{pitch:o,bearing:s}=this._camera.getPitchBearing(),r=e.cg(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,n=this._mercatorZfromZoom(this._maxZoom)*Math.cos(e.ao(this._maxPitch)),a=Math.max((t[2]-r)/Math.cos(o),n),l=this._zoomFromMercatorZ(a);e.bI(t,t,i,a),this._pitch=e.aB(o,e.ao(this.minPitch),e.ao(this.maxPitch)),this.angle=e.bU(s,-Math.PI,Math.PI),this._setZoom(e.aB(l,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new e.af(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/(Math.max(0,e)*this.tileSize))}zoomFromMercatorZAdjusted(t){let i=0,o=e.cM,s=0,r=1/0;for(;o-i>1e-6&&o>i;){const e=i+.5*(o-i),n=this.tileSize*Math.pow(2,e),a=this.getCameraToCenterDistance(this.projection,e,n),l=this.scaleZoom(a/(Math.max(0,t)*this.tileSize)),c=Math.abs(e-l);cc||i.y>1)return !0}return !1}isHorizonVisible(){return this.pitch+e.cY(this.fovAboveCenter)>88||this.anyCornerOffEdge(new e.P(0,0),new e.P(this.width,this.height))}zoomDeltaToMovement(t,i){const o=e.ah(e.aw([],this._camera.position,t)),s=this._zoomFromMercatorZ(o)+i;return o-this._mercatorZfromZoom(s)}getCameraPoint(){if("globe"===this.projection.name){const t=function([t,i,o],s){const r=[t,i,o,1];e.aD(r,r,s);const n=r[3]=Math.max(r[3],1e-6);return r[0]/=n,r[1]/=n,r[2]/=n,r}([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,i=this.zoom,o=this.worldSize){const s=e.cP(t,i,this.width,this.height,1024),r=t.pixelSpaceConversion(this.center.lat,o,s);let n=.5/Math.tan(.5*this._fov)*this.height*r;return this.isOrthographic&&(n=e.al(1,n,e.d1(this.pitch>=no?1:this.pitch/no))),n}getWorldToCameraMatrix(){const t=this._camera.getWorldToCamera(this.worldSize,"meters"===this.projection.zAxisUnit?this.pixelsPerMeter:1);return "globe"===this.projection.name&&e.aC(t,t,this.globeMatrix),t}getFrustum(t){return e.cC.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,t,"meters"===this.projection.zAxisUnit)}}const lo=(t,i)=>{if(i>0&&t.terrain&&e.w("Cutoff is currently disabled on terrain"),i<=0||t.terrain)return {shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};const o=t.transform,s=Math.max(Math.abs(o._zoom-(t.minCutoffZoom-1)),1),r=o.isLODDisabled(!1)?e.ai(60,45,o.pitch):e.ai(30,15,o.pitch),n=o._farZ-o._nearZ,a=i*o.height,l=((1-(c=r))*o.cameraToCenterDistance+c*(o._farZ+a))*s;var c;return {shouldRenderCutoff:r<1,uniformValues:{u_cutoff_params:[o._nearZ,o._farZ,(l-o._nearZ)/n,(l-a-o._nearZ)/n]}}},co=2048;class ho{constructor(e,t){this.aabb=e,this.lastCascade=t;}}class uo{add(e,t){const i=this.receivers[e.key];void 0!==i?(i.aabb.min[0]=Math.min(i.aabb.min[0],t.min[0]),i.aabb.min[1]=Math.min(i.aabb.min[1],t.min[1]),i.aabb.min[2]=Math.min(i.aabb.min[2],t.min[2]),i.aabb.max[0]=Math.max(i.aabb.max[0],t.max[0]),i.aabb.max[1]=Math.max(i.aabb.max[1],t.max[1]),i.aabb.max[2]=Math.max(i.aabb.max[2],t.max[2])):this.receivers[e.key]=new ho(t,null);}clear(){this.receivers={};}get(e){return this.receivers[e.key]}computeRequiredCascades(t,i,o){const s=e.da.fromPoints(t.points);let r=0;for(const t in this.receivers){const n=this.receivers[t];if(!n)continue;if(!s.intersectsAabb(n.aabb))continue;n.aabb.min=s.closestPoint(n.aabb.min),n.aabb.max=s.closestPoint(n.aabb.max);const a=n.aabb.getCorners();for(let t=0;t1||n[1]<-1||n[1]>1){s=!1;break}}if(n.lastCascade=t,r=Math.max(r,t),s)break}}return r+1}}class _o{constructor(e){this.painter=e,this._enabled=!1,this._drawShadowAfterLayer=-1,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new uo,this._depthMode=new Wi(e.context.gl.LEQUAL,Wi.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;}destroy(){for(const e of this._cascades)e.texture.destroy(),e.framebuffer.destroy();this._cascades=[];}updateShadowParameters(t,i){const o=this.painter;if(this._enabled=!1,this._drawShadowAfterLayer=-1,this._receivers.clear(),!i||!i.properties)return;const s=i.properties.get("shadow-intensity"),r=i.properties.get("shadow-draw-before-layer");if(!i.shadowsEnabled()||s<=0)return;let n=-1,a=0;for(const e of o.style.order){const i=o.style._mergedLayers[e];i.hasShadowPass()&&!i.isHidden(t.zoom)&&(n=a),!r||r!==e&&r!==i.slot||(this._drawShadowAfterLayer=a>0?a-1:0),a+=1;}if(this._enabled=n>=0,!this.enabled)return;this._drawShadowAfterLayer<0&&(this._drawShadowAfterLayer=n);const l=o.context,c=co,h=co;if(0===this._cascades.length||co!==this._cascades[0].texture.size[0]){this._cascades=[];for(let t=0;t<2;++t){const t=o._shadowMapDebug,i=l.gl,s=l.createFramebuffer(c,h,t?1:0,"texture"),r=new e.T(l,{width:c,height:h,data:null},i.DEPTH_COMPONENT16);if(s.depthAttachment.set(r.texture),t){const t=new e.T(l,{width:c,height:h,data:null},i.RGBA8);s.colorAttachment0.set(t.texture);}this._cascades.push({framebuffer:s,texture:r,matrix:[],far:0,boundingSphereRadius:0,frustum:new e.cC,scale:0});}}this.shadowDirection=fo(i);let d=0;if(t.elevation){const e=t.elevation,i=[1e4,-1e4];e.visibleDemTiles.filter(e=>e.dem).forEach(e=>{const t=e.dem.tree;i[0]=Math.min(i[0],t.minimums[0]),i[1]=Math.max(i[1],t.maximums[0]);}),1e4!==i[0]&&(d=(i[1]-i[0])*e.exaggeration());}const u=1.5*t.cameraToCenterDistance,_=3*u,p=new Float64Array(16);for(let i=0;i=0)return {};const r=function(t,i,o){const s=o/(1<0&&(e.d9(r[1],r[1],[s[0]*n,0,0]),e.d9(r[2],r[2],[s[0]*n,0,0])),s[1]<0?(e.d9(r[0],r[0],[0,s[1]*n,0]),e.d9(r[1],r[1],[0,s[1]*n,0])):s[1]>0&&(e.d9(r[2],r[2],[0,s[1]*n,0]),e.d9(r[3],r[3],[0,s[1]*n,0]));const a={};return a.vertices=r,a.planes=[po(r[1],r[0],r[4]),po(r[2],r[1],r[5]),po(r[3],r[2],r[6]),po(r[0],r[3],r[7])],a}addShadowReceiver(t,i,o){this._receivers.add(t,e.da.fromTileIdAndHeight(t,i,o));}getMaxCascadeForTile(e){const t=this._receivers.get(e);return t&&t.lastCascade?t.lastCascade:0}}function po(t,i,o){const s=e.aw([],o,i),r=e.aw([],t,i),n=e.bJ([],s,r),a=e.ah(n);return 0===a?[0,0,1,0]:(e.c6(n,n,1/a),[n[0],n[1],n[2],-e.bK(n,i)])}function fo(t){const i=t.properties.get("direction"),o=e.d5(i.x,i.y,i.z);o[2]=e.aB(o[2],0,75);const s=e.d7([o[0],o[1],o[2]]);return e.d6(s.x,s.y,s.z)}function mo(t,i,o){const s="none"===i.properties.get("color-use-theme"),r=i.properties.get("color"),n=i.properties.get("intensity"),a=i.properties.get("direction"),l=[a.x,a.y,a.z],c="none"===o.properties.get("color-use-theme"),h=o.properties.get("color"),d=o.properties.get("intensity"),u=Math.max(e.bK([0,0,1],l),0),_=[0,0,0];e.c6(_,h.toPremultipliedRenderColor(c?null:t.getLut(i.scope)).toArray01Linear().slice(0,3),d);const p=[0,0,0];return e.c6(p,r.toPremultipliedRenderColor(s?null:t.getLut(o.scope)).toArray01Linear().slice(0,3),u*n),e.dc([_[0]>0?_[0]/(_[0]+p[0]):0,_[1]>0?_[1]/(_[1]+p[1]):0,_[2]>0?_[2]/(_[2]+p[2]):0])}function go(t,i,o,s,r,n){const a=t.zoom,l=t.scale,c=t.worldSize,h=1/c,d=t.aspect,u=Math.sqrt(1+d*d)*Math.tan(.5*t.fovX),_=u*u,p=s-o,f=s+o;let m,g;_>p/f?(m=s,g=s*u):(m=.5*f*(1+_),g=.5*Math.sqrt(p*p+2*(s*s+o*o)*_+f*f*_*_));const v=t.projection.pixelsPerMeter(t.center.lat,c),y=t._camera.getCameraToWorldMercator(),x=[0,0,-m*h];e.ag(x,x,y);let b=g*h;const w=function(i){return i[0]/=l,i[1]/=l,i[2]=e.cg(i[2],t._center.lat),i},T=t._edgeInsets;if(!(0===T.left&&0===T.top&&0===T.right&&0===T.bottom||T.left===T.right&&T.top===T.bottom)){const i=t._camera.getWorldToCamera(t.worldSize,"meters"===t.projection.zAxisUnit?v:1),r=t._camera.getCameraToClipPerspective(t._fov,t.width/t.height,o,s);r[8]=2*-t.centerOffset.x/t.width,r[9]=2*t.centerOffset.y/t.height;const n=new Float64Array(16);e.cQ(n,r,i);const l=new Float64Array(16);e.bm(l,n);const h=e.cC.fromInvProjectionMatrix(l,c,a,!0);for(const t of h.points){const i=w(t);b=Math.max(b,e.c7(e.db([],x,i)));}}b*=r/(r-1);const E=Math.acos(i[2]),S=Math.atan2(-i[0],-i[1]),I=new oo;I.position=x,I.setPitchBearing(E,S);const C=I.getWorldToCamera(c,v),R=b*c,A=Math.min(t._mercatorZfromZoom(17)*c*-2,-2*R),D=I.getCameraToClipOrthographic(-R,R,-R,R,A,(R+n*v)/i[2]),L=new Float64Array(16);e.aC(L,D,C);const P=e.d6(Math.floor(1e6*x[0])/1e6*c,Math.floor(1e6*x[1])/1e6*c,0),O=.5*r,z=[0,0,0];e.ag(z,P,L),e.c6(z,z,O);const M=[Math.floor(z[0]),Math.floor(z[1]),Math.floor(z[2])],F=[0,0,0];e.aw(F,z,M),e.c6(F,F,-1/O);const k=new Float64Array(16);return e.bB(k),e.bs(k,k,F),e.aC(L,k,L),[L,R]}class vo extends e.E{constructor(e){super(),this.requestManager=e,this.models={"":{}},this.modelUris={"":{}},this.modelByURL={},this.numModelsLoading={};}loadModel(t,i){return e.dd(this.requestManager.transformRequest(i,e.R.Model).url).then(o=>{const s=e.de(o),r=new e.df(t,i,void 0,void 0,s);return r.computeBoundsAndApplyParent(),r}).catch(o=>{if(o&&404===o.status)return null;this.fire(new e.z(new Error(`Could not load model ${t} from ${i}: ${o.message}`)));})}load(t,i,o={forceReload:!1}){this.models[i]||(this.models[i]={});const s=Object.keys(t),r=[],n=[];for(const e of s){const s=t[e];this.hasURLBeenRequested(s)&&!o.forceReload||(this.modelByURL[s]={modelId:e,scope:i},r.push(this.loadModel(e,s)),n.push(e)),this.models[i][e]||(this.models[i][e]={model:null,numReferences:1});}this.numModelsLoading[i]=(this.numModelsLoading[i]||0)+n.length,Promise.allSettled(r).then(t=>{for(let e=0;e{this.fire(new e.z(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,i={exactIdMatch:!1}){return !!(i.exactIdMatch?this.getModel(e,t):this.getModelByURL(this.modelUris[t][e]))}getModel(e,t){return this.models[t]||(this.models[t]={}),this.models[t][e]?this.models[t][e].model:void 0}getModelByURL(e){if(!e)return null;const t=this.modelByURL[e];return t?this.models[t.scope][t.modelId].model:null}hasModelBeenAdded(e,t){return this.models[t]&&void 0!==this.models[t][e]}getModelURIs(e){return this.modelUris[e]||{}}addModel(e,t,i){this.models[i]||(this.models[i]={}),this.modelUris[i]||(this.modelUris[i]={});const o=this.requestManager.normalizeModelURL(t);if((this.hasModel(e,i,{exactIdMatch:!0})||this.hasModelBeenAdded(e,i))&&this.modelUris[i][e]===o)this.models[i][e].numReferences++;else if(this.hasURLBeenRequested(o)){const{scope:e,modelId:t}=this.modelByURL[o];this.models[e][t].numReferences++;}else this.modelUris[i][e]=o,this.load({[e]:this.modelUris[i][e]},i);}addModelURLs(e,t){this.models[t]||(this.models[t]={}),this.modelUris[t]||(this.modelUris[t]={});const i=this.modelUris[t];for(const t in e)i[t]=this.requestManager.normalizeModelURL(e[t]);}reloadModels(e){this.load(this.modelUris[e],e,{forceReload:!0});}addModelsFromBucket(t,i){this.models[i]||(this.models[i]={}),this.modelUris[i]||(this.modelUris[i]={});const o={};for(const s of t)this.hasModel(s,i,{exactIdMatch:!0})||this.hasURLBeenRequested(s)?this.models[i][s].numReferences++:this.modelUris[i][s]&&!this.hasURLBeenRequested(s)?o[s]=this.modelUris[i][s]:!this.hasURLBeenRequested(s)&&e.dg(s,!1)&&(this.modelUris[i][s]=this.requestManager.normalizeModelURL(s),o[s]=this.modelUris[i][s]);this.load(o,i);}hasURLBeenRequested(e){return void 0!==this.modelByURL[e]}removeModel(e,t,i=!1,o=!1){if(this.models[t]&&this.models[t][e]&&(this.models[t][e].numReferences--,0===this.models[t][e].numReferences||o)){const o=this.modelUris[t][e];i||delete this.modelUris[t][e],delete this.modelByURL[o];const s=this.models[t][e].model;if(!s)return;delete this.models[t][e],s.destroy();}}destroy(){for(const e of Object.keys(this.models))for(const t of Object.keys(this.models[e])){const i=this.models[e][t].model;delete this.models[e][t],i&&i.destroy();}this.models={"":{}},this.modelUris={"":{}},this.modelByURL={},this.numModelsLoading={};}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 i in this.models[t])this.models[t][i].model&&this.models[t][i].model.upload(e.context);}}const yo=e.a7.colorTheme,xo=new e.aa({data:new e.ab(yo.data)});function bo(t){if(!t.metadata||!t.metadata.content_area)return;const i=e.o.devicePixelRatio,{left:o,top:s,width:r,height:n}=t.metadata.content_area,a=o*i,l=s*i;return [a,l,a+r*i,l+n*i]}function wo(t){if(t)return t.map(([t,i])=>[t*e.o.devicePixelRatio,i*e.o.devicePixelRatio])}class To{constructor(e,t,i){this.id=e,this.scope=t,this.sourceCache=i,this.pendingRequests=new Set,this.missingRequests=new Set;}addPendingRequest(e){this.missingRequests.has(e.name)||this.pendingRequests.has(e.name)||this.pendingRequests.add(e.name);}hasPendingRequests(){return this.pendingRequests.size>0}resolvePendingRequests(){const t=new Map;if(!this.sourceCache.loaded())return t;const i=this.sourceCache.getVisibleCoordinates();if(0===i.length)return t;const o=this.sourceCache.getSource();if(!(o instanceof pt))return t;const s=i.map(e=>this.sourceCache.getTile(e)),r=o.getImages(s,Array.from(this.pendingRequests));for(const[i,o]of r)t.set(e.I.from({name:i,iconsetId:this.id}),o),this.pendingRequests.delete(i);for(const e of this.pendingRequests)this.missingRequests.add(e);return this.pendingRequests.clear(),t}}class Eo{constructor(){this._previousClosestBuildingId=null,this._hysteresisRatio=.8,this._indoorMinimumZoom=16;}findClosestBuilding(e,t,i,o,s){if(ia*this._hysteresisRatio&&(r=this._previousClosestBuildingId):l&&!r&&(r=this._previousClosestBuildingId),this._previousClosestBuildingId=r,r}_calculateDistance(e,t){if(!t.center)return Number.MAX_VALUE;const i=e.lat-t.center[1],o=e.lng-t.center[0];return i*i+o*o}_isBuildingVisible(t,i,o){if(!o)return !1;for(const i of t.floorIds){const s=t.floors[i];if(!s.geometry)continue;const r=s.geometry;if("Polygon"===r.type){const t=this._convertRingToPoints(r.coordinates[0]);if(e.bY(t,o))return !0}else if("MultiPolygon"===r.type){const t=this._convertMultiPolygonToPoints(r.coordinates);if(e.di(o,t))return !0}}return !1}_convertRingToPoints(t){return t.map(t=>new e.P(t[0],t[1]))}_convertMultiPolygonToPoints(t){return t.map(t=>0===t.length?[]:t[0].map(t=>new e.P(t[0],t[1])))}}class So extends e.E{constructor(t){super(),this._style=t,this._buildings={},this._activeFloors=new Set,this._indoorState={selectedFloorId:null,activeFloorsVisible:!1,activeFloors:this._activeFloors},this._buildingDetectionStrategy=new Eo,e.aZ(["_updateUI"],this),this._style.on("style.load",()=>{this._style.isIndoorEnabled()&&(this._style.map.on("load",this._updateUI),this._style.map.on("move",this._updateUI),this._style.map.on("idle",this._updateUI),this._updateUI());});}destroy(){this._buildings={},this._activeFloors=new Set,this._indoorState=null;}selectFloor(e){e===this._selectedFloorId&&this._indoorState&&this._indoorState.activeFloorsVisible||(this._selectedFloorId=e,this._recalculateActiveFloors());}setActiveFloorsVisibility(e){this._updateActiveFloors(e),this._updateIndoorSelector();}setIndoorData(e){let t=!1;for(const[i,o]of Object.entries(e.buildings))if(this._buildings[i])for(const e of o.floorIds)this._buildings[i].floorIds.add(e),this._buildings[i].floors[e]?this._mergeFloors(this._buildings[i].floors[e],o.floors[e]):(this._buildings[i].floors[e]=o.floors[e],this._buildings[i].floorIds.add(e),t=!0);else this._buildings[i]=o,t=!0;t&&this._recalculateActiveFloors(),this._updateIndoorSelector();}_mergeFloors(e,t){t.geometry&&(e.geometry?("Polygon"===e.geometry.type&&(e.geometry={type:"MultiPolygon",coordinates:[e.geometry.coordinates]}),"Polygon"===t.geometry.type?e.geometry.coordinates.push(t.geometry.coordinates):"MultiPolygon"===t.geometry.type&&e.geometry.coordinates.push(...t.geometry.coordinates)):e.geometry=t.geometry);}getIndoorTileOptions(e,t){return this._indoorState?{sourceLayers:this._style.getIndoorSourceLayers(e,t),indoorState:this._indoorState}:null}_updateUI(){const e=this._style.map.transform,t=this._buildingDetectionStrategy.findClosestBuilding(this._buildings,e.center,e.zoom,e.getBounds(),this._makeViewportPolygon());if(t!==this._closestBuildingId){const e=this._closestBuildingId;this._closestBuildingId=t,this._updateIndoorSelector();const i=!e&&this._indoorState;(!t&&this._indoorState||i)&&(this._indoorState.activeFloors=i?this._activeFloors:new Set,this._indoorState.activeFloorsVisible=!!i,this._style.updateIndoorDependentLayers());}}getControlState(){const e=this._buildings,t=this._closestBuildingId,i=t&&e?e[t]:void 0;if(!i)return {selectedFloorId:null,activeFloorsVisible:!!this._indoorState&&this._indoorState.activeFloorsVisible,floors:[]};let o=null;for(const e of i.floorIds)if(this._activeFloors&&this._activeFloors.has(e)){o=e;break}const s=Array.from(i.floorIds).map(e=>({id:e,name:i.floors[e].name,zIndex:i.floors[e].zIndex})).sort((e,t)=>t.zIndex-e.zIndex).filter((e,t,i)=>0===t||e.zIndex!==i[t-1].zIndex);return {selectedFloorId:o,activeFloorsVisible:!!this._indoorState&&this._indoorState.activeFloorsVisible,floors:s}}_updateIndoorSelector(){this.fire(new e.A("selector-update",this.getControlState()));}_updateActiveFloors(e){this._indoorState={selectedFloorId:this._selectedFloorId,activeFloorsVisible:e,activeFloors:this._activeFloors},this._style.updateIndoorDependentLayers();}_makeViewportPolygon(){const t=this._style.map.transform,i=t.width,o=t.height;return [t.pointLocation(new e.P(0,0)),t.pointLocation(new e.P(i,0)),t.pointLocation(new e.P(i,o)),t.pointLocation(new e.P(0,o))].map(t=>new e.P(t.lng,t.lat))}_recalculateActiveFloors(){if(!this._buildings)return;const t=e.dj.calculate(this._buildings,this._selectedFloorId,this._activeFloors);this._activeFloors=t,this._updateActiveFloors(!!this._indoorState&&this._indoorState.activeFloorsVisible),this._updateIndoorSelector();}}const Io=(e,t)=>Fe(e,t&&t.filter(e=>"source.canvas"!==e.identifier)),Co=e.aI(Vt,["addLayer","removeLayer","setLights","setPaintProperty","setLayoutProperty","setLayerProperty","setSlot","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setSnow","setRain","setProjection","setCamera","addImport","removeImport","updateImport","addIconset","removeIconset"]),Ro=e.aI(Vt,["setCenter","setZoom","setBearing","setPitch"]),Ao=new Set(["background","sky","slot","custom"]),Do={version:8,layers:[],sources:{}},Lo={duration:300,delay:0};class Po extends e.E{constructor(t,i={}){super(),this.map=t,this.scope=i.scope||"",this.globalId=null,this.fragments=[],this.importDepth=i.importDepth||0,this.importsCache=i.importsCache||new Map,this.resolvedImports=i.resolvedImports||new Set,this.transition=Object.assign({},Lo),this._buildingIndex=new Nt(this),this.crossTileSymbolIndex=new Hi,this._mergedOrder=[],this._drapedFirstOrder=[],this._mergedLayers={},this._mergedIndoor={},this._mergedSourceCaches={},this._mergedOtherSourceCaches={},this._mergedSymbolSourceCaches={},this._clipLayerPresent=!1,this._hasAppearances=!1,this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this._importedAsBasemap=!1,this._changes=i.styleChanges||new W,this._hasDataDrivenEmissive=!1,this.indoorManager=new So(this),this.dispatcher=i.dispatcher?i.dispatcher:new e.D(e.dk(),this),i.imageManager?this.imageManager=i.imageManager:(this.imageManager=new X(this.map._spriteFormat),this.imageManager.setEventedParent(this)),this.imageManager.addScope(this.scope),this.glyphManager=i.glyphManager?i.glyphManager:new e.dl(t._requestManager,i.localFontFamily?e.dm.all:i.localIdeographFontFamily?e.dm.ideographs:e.dm.none,i.localFontFamily||i.localIdeographFontFamily),i.modelManager?this.modelManager=i.modelManager:(this.modelManager=new vo(t._requestManager),this.modelManager.setEventedParent(this)),this._layers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this._loaded=!1,this._precompileDone=!1,this._shouldPrecompile=!1,this._availableImages=[],this._availableModels={},this._order=[],this._markersNeedUpdate=!1,this.options=i.configOptions?i.configOptions:new Map,this._configDependentLayers=i.configDependentLayers?i.configDependentLayers:new Set,this._indoorDependentLayers=i.indoorDependentLayers?i.indoorDependentLayers:new Set,this._config=i.config,this._styleColorTheme={lut:null,lutLoading:!1,lutLoadingCorrelationID:0,colorTheme:null,colorThemeOverride:i.colorThemeOverride},this._styleColorThemeForScope={},this._initialConfig=i.initialConfig,this.dispatcher.broadcast("setReferrer",e.dn());const o=this;this._rtlTextPluginCallback=Po.registerForPluginStateChange(t=>{o.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:t.pluginStatus,pluginURL:t.pluginURL},(t,i)=>{if(e.dp(t),i&&i.every(e=>e))for(const e in o._sourceCaches){const t=o._sourceCaches[e],i=t.getSource().type;"vector"!==i&&"geojson"!==i||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 i=this._layers[e];i.source===t.id&&this._validateLayer(i);}});}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.h(t))return t;const i=e.dq(t);if(!i.startsWith("http"))try{return new URL(i,location.href).toString()}catch(e){return i}return i}return `json://${e.dr(JSON.stringify(t))}`}_diffStyle(t,i,o){this.globalId=this._getGlobalId(t);const s=(e,t)=>{try{t(null,this.setState(e,o));}catch(e){t(e,!1);}};if("string"==typeof t){const o=this.map._requestManager.normalizeStyleURL(t),r=this.map._requestManager.transformRequest(o,e.R.Style);e.m(r,(t,o)=>{t?this.fire(new e.z(t)):o&&s(o,i);});}else "object"==typeof t&&s(t,i);}loadURL(t,i={}){this.fire(new e.A("dataloading",{dataType:"style"}));const o="boolean"==typeof i.validate?i.validate:!e.h(t);this.globalId=this._getGlobalId(t),t=this.map._requestManager.normalizeStyleURL(t,i.accessToken),this.resolvedImports.add(t);const s=this.importsCache.get(t);if(s)return this._load(s,o);const r=this.map._requestManager.transformRequest(t,e.R.Style);this._request=e.m(r,(i,s)=>{if(this._request=null,i)this.fire(new e.z(i));else if(s)return this.importsCache.set(t,s),this._load(s,o)});}loadJSON(t,i={}){this.fire(new e.A("dataloading",{dataType:"style"})),this.globalId=this._getGlobalId(t),this._request=e.o.frame(()=>{this._request=null,this._load(t,!1!==i.validate);});}loadEmpty(){this.fire(new e.A("dataloading",{dataType:"style"})),this._load(Do,!1);}_loadImports(t,i,o){if(this.importDepth>=4)return e.w("Style doesn't support nesting deeper than 5"),Promise.resolve();const s=[];for(const e of t){const t=this._createFragmentStyle(e),r=new Promise(e=>{t.once("style.import.load",e),t.once("error",e);}).then(()=>this.mergeAll());if(s.push(r),this.resolvedImports.has(e.url)){t.loadEmpty();continue}const n=e.data||this.importsCache.get(e.url);n?(t.loadJSON(n,{validate:i}),this._isInternalStyle(n)&&(t.globalId=null)):e.url?t.loadURL(e.url,{validate:i}):t.loadEmpty();const a={style:t,id:e.id,config:e.config};if(o){const e=this.fragments.findIndex(({id:e})=>e===o);this.fragments=this.fragments.slice(0,e).concat(a).concat(this.fragments.slice(e));}else this.fragments.push(a);}return Promise.allSettled(s)}getImportGlobalIds(e=this,t=new Set){for(const i of e.fragments)i.style.globalId&&t.add(i.style.globalId),this.getImportGlobalIds(i.style,t);return [...t.values()]}_createFragmentStyle(t){const i=this.scope?e.C(t.id,this.scope):t.id;let o;const s=this._initialConfig&&this._initialConfig[i];(t.config||s)&&(o=Object.assign({},t.config,s));const r=new Po(this.map,{scope:i,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:o,configOptions:this.options,colorThemeOverride:t["color-theme"],configDependentLayers:this._configDependentLayers,indoorDependentLayers:this._indoorDependentLayers});return r.setEventedParent(this.map,{style:r}),r}_reloadImports(){this.mergeAll(),this._updateMapProjection(),this.updateConfigDependencies(),this._updateLayers(this._indoorDependentLayers),this.map._triggerCameraUpdate(this.camera),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),this._shouldPrecompile=this.map._precompilePrograms&&this.isRootStyle();}_isInternalStyle(e){return this.isRootStyle()&&(e.fragment||!!e.schema&&!1!==e.fragment)}_load(t,i){if(this._isInternalStyle(t)){const e=Object.assign({},Do,{imports:[{id:"basemap",data:t,url:""}]},t.center?{center:t.center}:{},t.bearing?{bearing:t.bearing}:{},t.pitch?{pitch:t.pitch}:{},t.zoom?{zoom:t.zoom}:{},t.light?{light:t.light}:{});return this._importedAsBasemap=!0,void this._load(e,i)}if(this.updateConfig(this._config,t.schema),i&&Io(this,we(t)))return;this._loaded=!0,this.stylesheet=e.ds(t);const o=()=>{for(const e in t.sources)this.addSource(e,t.sources[e],{validate:!1,isInitialLoad:!0});if(t.iconsets)for(const e in t.iconsets)this.addIconset(e,t.iconsets[e]);t.sprite?this._loadIconset(t.sprite):(this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0})),!this.glyphManager.url&&t.glyphs&&this.glyphManager.setURL(t.glyphs);const o=jt(this.stylesheet.layers);if(this._order=o.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 Ne(e.properties,e.id);}else this.setLights(this.stylesheet.lights);this.light||(this.light=new Ne(this.stylesheet.light)),this._layers={};for(const t of o){const i=e.dx(t,this.scope,this._styleColorTheme.lut,this.options);0!==i.expressionDependencies.configDependencies.size&&this._configDependentLayers.add(i.fqid),i.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(i.fqid),this._hasAppearances=this._hasAppearances||0!==i.getAppearances().length,i.setEventedParent(this,{layer:{id:i.id}}),this._layers[i.id]=i;const o=this.getOwnLayerSourceCache(i),s=!!this.directionalLight&&this.directionalLight.shadowsEnabled();o&&i.canCastShadows()&&s&&(o.castsShadows=!0);}this.stylesheet.featuresets&&this.setFeaturesetSelectors(this.stylesheet.featuresets),this.stylesheet.models&&this.addModelURLs(this.stylesheet.models);const s=this.stylesheet.terrain;s&&(this.checkCanvasFingerprintNoise(),this.disableElevatedTerrain||this.terrainSetForDrapingOnly()||this._createTerrain(s,1)),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this.stylesheet.snow&&this._createSnow(this.stylesheet.snow),this.stylesheet.rain&&this._createRain(this.stylesheet.rain),this.stylesheet.transition&&this.setTransition(this.stylesheet.transition),this.fire(new e.A("data",{dataType:"style"}));const r=this.isRootStyle();t.imports?this._loadImports(t.imports,i).then(()=>{this._reloadImports(),this.fire(new e.A(r?"style.load":"style.import.load"));}).catch(t=>{this.fire(new e.z(new Error("Failed to load imports",t))),this.fire(new e.A(r?"style.load":"style.import.load"));}):(this._reloadImports(),this.fire(new e.A(r?"style.load":"style.import.load")));};this._styleColorTheme.colorTheme=this.stylesheet["color-theme"];const s=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(s){const t=this._evaluateColorThemeData(s);this._loadColorTheme(t).then(()=>{o();}).catch(t=>{e.w(`Couldn't load color theme from the stylesheet: ${t}`),o();});}else this._styleColorTheme.lut=null,o();}isRootStyle(){return 0===this.importDepth}hasAppearances(){return this._hasAppearances||this.fragments.some(e=>e.style.hasAppearances())}mergeAll(){let e,t,i,o,s,r,n,a,l,c;const h={};this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(d=>{if(d.stylesheet){if(null!=d.light&&(e=d.light),d.stylesheet.lights)for(const e of d.stylesheet.lights)"ambient"===e.type&&null!=d.ambientLight&&(t=d.ambientLight),"directional"===e.type&&null!=d.directionalLight&&(i=d.directionalLight);o=this._prioritizeTerrain(o,d.terrain,d.stylesheet.terrain),d.stylesheet.fog&&null!=d.fog&&(s=d.fog),d.stylesheet.snow&&null!=d.snow&&(r=d.snow),d.stylesheet.rain&&null!=d.rain&&(n=d.rain),null!=d.stylesheet.camera&&(c=d.stylesheet.camera),null!=d.stylesheet.projection&&(a=d.stylesheet.projection),null!=d.stylesheet.transition&&(l=d.stylesheet.transition),h[d.scope]=d._styleColorTheme;}}),this.light=e,this.ambientLight=t,this.directionalLight=i,this.fog=s,this.snow=r,this.rain=n,this._styleColorThemeForScope=h,null===o?delete this.terrain:this.terrain=o,this.camera=c||{"camera-projection":"perspective"},this.projection=a||{name:"mercator"},this.transition=Object.assign({},Lo,l),this.mergeSources(),this.mergeLayers(),this.mergeIndoor();}forEachFragmentStyle(e){const t=i=>{for(const e of i.fragments)t(e.style);e(i);};t(this);}_prioritizeTerrain(e,t,i){const o=e&&0===e.drapeRenderMode;return null===i?t&&0===t.drapeRenderMode?t:o?e:null:null!=t&&(!e||o||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={},i={},o={};this.forEachFragmentStyle(s=>{for(const i in s._sourceCaches){const o=e.C(i,s.scope);t[o]=s._sourceCaches[i];}for(const t in s._otherSourceCaches){const o=e.C(t,s.scope);i[o]=s._otherSourceCaches[t];}for(const t in s._symbolSourceCaches){const i=e.C(t,s.scope);o[i]=s._symbolSourceCaches[t];}}),this._mergedSourceCaches=t,this._mergedOtherSourceCaches=i,this._mergedSymbolSourceCaches=o;}mergeIndoor(){this.forEachFragmentStyle(t=>{if(t.stylesheet&&t.stylesheet.indoor)for(const i of Object.values(t.stylesheet.indoor)){const o=i,s=e.C(o.sourceId,t.scope);this._mergedIndoor[s]=new Set(o.sourceLayers||[]);}});}mergeLayers(){const t={},i=[],o={};this._mergedSlots=[],this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle(o=>{for(const s of o._order){const r=o._layers[s];if("slot"===r.type){const i=e.dt(s);if(t[i])continue;t[i]=[];}r.slot&&t[r.slot]?t[r.slot].push(r):i.push(r);}}),this._mergedOrder=[];let s=-1;const r=(i=[])=>{for(const n of i)if("slot"===n.type){const i=e.dt(n.id);t[i]&&r(t[i]),this._mergedSlots.push(i);}else {const t=e.C(n.id,n.scope);this._mergedOrder.push(t),o[t]=n,n.is3D(!!this.terrain)&&(this._has3DLayers=!0,s=this._mergedOrder.length-1),"circle"===n.type&&(this._hasCircleLayers=!0),"symbol"===n.type&&(this._hasSymbolLayers=!0),"clip"===n.type&&(this._clipLayerPresent=!0);}};if(r(i),this._has3DLayers){const e={};for(let t=0;te[t]-e[i]);}this._mergedLayers=o,this.updateDrapeFirstLayers(),this._buildingIndex.processLayersChanged(),this._updateDataDrivenEmissiveStrength();}terrainSetForDrapingOnly(){return !!this.terrain&&0===this.terrain.drapeRenderMode}getCamera(){return this.stylesheet.camera}setCamera(e){return this.stylesheet.camera=Object.assign({},this.stylesheet.camera,e),this.camera=this.stylesheet.camera,this}_evaluateColorThemeData(t){return t.data?function(t,i,o){const s=Object.assign({},i);for(const e of Object.keys(yo))void 0===s[e]&&(s[e]=yo[e].default);const r=new e.a9(xo,t,new Map(o));return r.setTransitionOrValue(s,o),r.untransitioned().possiblyEvaluate(new e.ad(0,{worldview:void 0}))}(this.scope,t,this.options).get("data"):null}_loadColorTheme(t){this._styleColorTheme.lutLoading=!0,this._styleColorTheme.lutLoadingCorrelationID+=1;const i=this._styleColorTheme.lutLoadingCorrelationID;return new Promise((o,s)=>{const r="data:image/png;base64,";if(!t||0===t.length)return this._styleColorTheme.lut=null,this._styleColorTheme.lutLoading=!1,void o();let n=t;n.startsWith(r)||(n=r+n);const a=e.I.from("mapbox-reserved-lut"),l=new Image;l.src=n,l.onerror=()=>{this._styleColorTheme.lutLoading=!1,s(new Error("Failed to load image data"));},l.onload=()=>{if(this._styleColorTheme.lutLoadingCorrelationID!==i)return void o();this._styleColorTheme.lutLoading=!1;const{width:r,height:n,data:c}=e.o.getImageData(l);if(n>32)return void s(new Error("The height of the image must be less than or equal to 32 pixels."));if(r!==n*n)return void s(new Error("The width of the image must be equal to the height squared."));this.getImage(a)&&this.removeImage(a),this.addImage(a,{data:new e.q({width:r,height:n},c),pixelRatio:1,sdf:!1,usvg:!1,version:0});const h=this.imageManager.getImage(a,this.scope);h?(this._styleColorTheme.lut={image:h.data,data:t},o()):s(new Error("Missing LUT image."));};})}getLut(e){const t=this._styleColorThemeForScope[e];return t?t.lut:null}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,i,o){let s,r,n;const a=e.o.devicePixelRatio>1?"@2x":"";let l=e.m(i.transformRequest(i.normalizeSpriteURL(t,a,".json"),e.R.SpriteJSON),(e,t)=>{l=null,n||(n=e,s=t,h());}),c=e.n(i.transformRequest(i.normalizeSpriteURL(t,a,".png"),e.R.SpriteImage),(e,t)=>{c=null,n||(n=e,r=t,h());});function h(){if(n)o(n);else if(s&&r){const t=e.o.getImageData(r),i={};for(const o in s){const{width:r,height:n,x:a,y:l,sdf:c,pixelRatio:h,stretchX:d,stretchY:u,content:_}=s[o],p=new e.q({width:r,height:n});e.q.copy(t,p,{x:a,y:l},{x:0,y:0},{width:r,height:n},null),i[o]={data:p,pixelRatio:void 0!==h?h:1,sdf:void 0!==c&&c,stretchX:d,stretchY:u,content:_,usvg:!1,version:0};}o(null,i);}}return {cancel(){l&&(l.cancel(),l=null),c&&(c.cancel(),c=null);}}}(t,this.map._requestManager,(t,i)=>{if(this._spriteRequest=null,t)this.fire(new e.z(t));else if(i){const t=new Map;for(const o in i)t.set(e.I.from(o),i[o]);this.addImages(t);}this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new e.A("data",{dataType:"style"}));});}addIconset(t,i){if("sprite"===i.type)return void this._loadSprite(i.url);const o=this.getOwnSourceCache(i.source);if(!o)return void this.fire(new e.z(new Error(`Source "${i.source}" as specified by iconset "${t}" does not exist and cannot be used as an iconset source`)));const s=o.getSource();if("raster-array"!==s.type)return void this.fire(new e.z(new Error(`Source "${i.source}" as specified by iconset "${t}" is not a "raster-array" source and cannot be used as an iconset source`)));s.partial=!1;const r=new To(t,this.scope,o);this.imageManager.addImageProvider(r,this.scope);}removeIconset(e){this.imageManager.removeImageProvider(e,this.scope);}_loadIconset(t){if(!e.h(t)&&"icon_set"!==this.map._spriteFormat||"raster"===this.map._spriteFormat)return void this._loadSprite(t);const i="auto"===this.map._spriteFormat;var o,s;this._spriteRequest=(s=(o,s)=>{if(this._spriteRequest=null,o)i?this._loadSprite(t):this.fire(new e.z(o));else if(s){const t=new Map;for(const i in s)t.set(e.I.from(i),s[i]);this.addImages(t);}this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new e.A("data",{dataType:"style"}));},e.bv((o=this.map._requestManager).transformRequest(o.normalizeIconsetURL(t),e.R.Iconset),(t,i)=>{if(t)return void s(t);const o={},r=e.dh(new e.bu(i));for(const t of r.icons){const i={version:1,pixelRatio:e.o.devicePixelRatio,content:bo(t),stretchX:t.metadata?wo(t.metadata.stretch_x_areas):void 0,stretchY:t.metadata?wo(t.metadata.stretch_y_areas):void 0,sdf:!1,usvg:!0,icon:t};o[t.name]=i;}s(null,o);}));}_validateLayer(t){const i=this.getOwnSource(t.source);if(!i)return;const o=t.sourceLayer;o&&("geojson"===i.type||i.vectorLayerIds&&-1===i.vectorLayerIds.indexOf(o))&&this.fire(new e.z(new Error(`Source layer "${o}" does not exist on source "${i.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.imageManager.hasPatternsInFlight())return !1;if(!this.modelManager.isLoaded())return !1;if(this._styleColorTheme.lutLoading)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 i=this.fragments[t];return i&&i.style&&(e.data=i.style.serialize()),e})}_serializeSources(){const e={};for(const t in this._sourceCaches){const i=this._sourceCaches[t].getSource();e[i.id]||(e[i.id]=i.serialize());}return e}_serializeLayers(e){const t=[];for(const i of e){const e=this._layers[i];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()}hasSnowTransition(){return !!this.snow&&this.snow.hasTransition()}hasRainTransition(){return !!this.rain&&this.rain.hasTransition()}hasTransitions(){if(this.hasLightTransitions())return !0;if(this.hasFogTransition())return !0;if(this.hasSnowTransition())return !0;if(this.hasRainTransition())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}_updateDataDrivenEmissiveStrength(){for(const e in this._mergedLayers){const t=this._mergedLayers[e];if(t._transitionablePaint&&t._transitionablePaint._values){const e=t._transitionablePaint._values["line-emissive-strength"];if(e&&e.value&&e.value.isDataDriven())return void(this._hasDataDrivenEmissive=!0)}}this._hasDataDrivenEmissive=!1;}hasDataDrivenEmissiveStrength(){return this._hasDataDrivenEmissive}get order(){return this.terrain?this._drapedFirstOrder:this._mergedOrder}_getOrder(e){return e?this.order: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 i=this.getOwnLayer(t);if(i)return i;this.fire(new e.z(new Error(`The layer '${t}' does not exist in the map's style.`)));}_checkSource(t){const i=this.getOwnSource(t);if(i)return i;this.fire(new e.z(new Error(`The source '${t}' does not exist in the map's style.`)));}precompilePrograms(e,t){const i=this.map.painter;if(i)for(let o=e.minzoom||0;o<(e.maxzoom||25.5);o++){const o=e.getProgramIds();if(o)for(const s of o){const o=e.getDefaultProgramParams(s,t.zoom,this._styleColorTheme.lut);o&&(i.style=this,this.fog&&(i._fogVisible=!0,o.overrideFog=!0,i.getOrCreateProgram(s,o)),i._fogVisible=!1,o.overrideFog=!1,i.getOrCreateProgram(s,o),(this.stylesheet.terrain||this.stylesheet.projection&&"globe"===this.stylesheet.projection.name)&&(o.overrideRtt=!0,i.getOrCreateProgram(s,o)));}}}update(t){if(!this._loaded)return;this.ambientLight&&this.ambientLight.recalculate(t),this.directionalLight&&this.directionalLight.recalculate(t);const i=this.calculateLightsBrightness();t.brightness=i||0,i!==this._brightness&&(this._brightness=i,this.dispatcher.broadcast("setBrightness",i)),t.worldview!==this._worldview&&(this._worldview=t.worldview,this.dispatcher.broadcast("setWorldview",this._worldview));const o=this._changes.isDirty();let s=!1;if(this._changes.isDirty()){const e=this._changes.getLayerUpdatesByScope();for(const t in e){const{updatedIds:i,removedIds:o}=e[t];(i||o)&&(this._updateWorkerLayers(t,i,o),s=!0);}this.updateSourceCaches(),this._updateTilesForChangedImages(),this.updateLayers(t),this.light&&this.light.updateTransitions(t),this.ambientLight&&this.ambientLight.updateTransitions(t),this.directionalLight&&this.directionalLight.updateTransitions(t),this.fog&&this.fog.updateTransitions(t),this.snow&&this.snow.updateTransitions(t),this.rain&&this.rain.updateTransitions(t),this._changes.reset();}const r={};for(const e in this._mergedSourceCaches){const t=this._mergedSourceCaches[e];r[e]=t.used,t.used=!1,t.tileCoverLift=0;}for(const e of this._mergedOrder){const i=this._mergedLayers[e];if(("none"!==i.visibility||i.hasTransition())&&i.recalculate(t,this._availableImages),!i.isHidden(t.zoom)){const e=this.getLayerSourceCache(i);e&&(e.used=!0,e.tileCoverLift=Math.max(e.tileCoverLift,i.tileCoverLift()));}!this._precompileDone&&this._shouldPrecompile&&("requestIdleCallback"in window?requestIdleCallback(()=>{this.precompilePrograms(i,t);}):this.precompilePrograms(i,t));}this._shouldPrecompile&&(this._precompileDone=!0),this.terrain&&s&&this.mergeLayers();const n=this.imageManager.getPendingImageProviders();for(const e of n)e.sourceCache.used=!0;for(const t in r){const i=this._mergedSourceCaches[t];r[t]!==i.used&&i.getSource().fire(new e.A("data",{sourceDataType:"visibility",dataType:"source",sourceId:i.getSource().id}));}this.light&&this.light.recalculate(t),this.terrain&&this.terrain.recalculate(t),this.fog&&this.fog.recalculate(t),this.snow&&this.snow.recalculate(t),this.rain&&this.rain.recalculate(t),this.z=t.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),this.imageManager.clearUpdatedImages(this.scope),o&&this.fire(new e.A("data",{dataType:"style"}));}updateImageProviders(){const e=this.imageManager.getPendingImageProviders();for(const t of e){const e=t.resolvePendingRequests(),i=this.getFragmentStyle(t.scope);i&&i.addImages(e);}}_updateTilesForChangedImages(){const e={};for(const t in this._mergedSourceCaches){const i=this._mergedSourceCaches[t].getSource().scope;e[i]=e[i]||this._changes.getUpdatedImages(i),0!==e[i].length&&this._mergedSourceCaches[t].reloadTilesForDependencies(["icons","patterns"],e[i]);}for(const t in e)this._changes.resetUpdatedImages(t);}_updateWorkerLayers(e,t,i){const o=this.getFragmentStyle(e);o&&this.dispatcher.broadcast("updateLayers",{layers:t?o._serializeLayers(t):[],scope:e,removedIds:i||[],options:o.options});}setState(t,i){if(this._checkLoaded(),Io(this,we(t)))return !1;(t=e.ds(t)).layers=jt(t.layers);const o=function(t,i){if(!t)return [{command:Vt.setStyle,args:[i]}];let o=[];try{if(!e.bz(t.version,i.version))return [{command:Vt.setStyle,args:[i]}];if(e.bz(t.center,i.center)||o.push({command:Vt.setCenter,args:[i.center]}),e.bz(t.zoom,i.zoom)||o.push({command:Vt.setZoom,args:[i.zoom]}),e.bz(t.bearing,i.bearing)||o.push({command:Vt.setBearing,args:[i.bearing]}),e.bz(t.pitch,i.pitch)||o.push({command:Vt.setPitch,args:[i.pitch]}),e.bz(t.sprite,i.sprite)||o.push({command:Vt.setSprite,args:[i.sprite]}),e.bz(t.glyphs,i.glyphs)||o.push({command:Vt.setGlyphs,args:[i.glyphs]}),e.bz(t.imports,i.imports)||function(t=[],i=[],o){i=i||[];const s=(t=t||[]).map($t),r=i.map($t),n=t.reduce(Xt,{}),a=i.reduce(Xt,{}),l=s.slice();let c,h,d,u;for(c=0,h=0;c{e.source&&s[e.source]?o.push({command:Vt.removeLayer,args:[e.id]}):n.push(e);});let a=t.terrain;a&&s[a.source]&&(o.push({command:Vt.setTerrain,args:[void 0]}),a=void 0),o=o.concat(r),e.bz(a,i.terrain)||o.push({command:Vt.setTerrain,args:[i.terrain]}),function(t,i,o){i=i||[];const s=(t=t||[]).map($t),r=i.map($t),n=t.reduce(Xt,{}),a=i.reduce(Xt,{}),l=s.slice(),c=Object.create(null);let h,d,u,_,p,f,m;for(h=0,d=0;h!(e.command in Ro));if(0===o.length)return !1;const s=o.filter(e=>!(e.command in Co));if(s.length>0)throw new Error(`Unimplemented: ${s.map(e=>e.command).join(", ")}.`);const r=[];return o.forEach(e=>{r.push(this[e.command](...e.args));}),i&&Promise.all(r).then(i).catch(i),this.stylesheet=t,this.mergeAll(),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),!0}_updateWorkerImages(){this._availableImages=this.imageManager.listImages(this.scope),this.dispatcher.broadcast("setImages",{scope:this.scope,images:this._availableImages});}_updateWorkerModels(){this._availableModels=this.modelManager.getModelURIs(this.scope),this.dispatcher.broadcast("setModels",{scope:this.scope,models:this._availableModels});}addImages(t){if(0===t.size)return this;for(const[i,o]of t.entries()){if(this.getImage(i))return this.fire(new e.z(new Error(`An image with the name "${i.name}" already exists.`)));this.imageManager.addImage(i,this.scope,o),this._changes.updateImage(i,this.scope);}return this._updateWorkerImages(),this.fire(new e.A("data",{dataType:"style"})),this}addImage(t,i){return this.getImage(t)?this.fire(new e.z(new Error(`An image with the name "${t.name}" already exists.`))):(this.imageManager.addImage(t,this.scope,i),this._changes.updateImage(t,this.scope),this._updateWorkerImages(),this.fire(new e.A("data",{dataType:"style"})),this)}updateImage(t,i,o=!1){this.imageManager.updateImage(t,this.scope,i),o&&(this._changes.updateImage(t,this.scope),this._updateWorkerImages(),this.fire(new e.A("data",{dataType:"style"})));}getImage(e){return this.imageManager.getImage(e,this.scope)}removeImage(t){return this.getImage(t)?(this.imageManager.removeImage(t,this.scope),this._changes.updateImage(t,this.scope),this._updateWorkerImages(),this.fire(new e.A("data",{dataType:"style"})),this):this.fire(new e.z(new Error("No image with this name exists.")))}listImages(){return this._checkLoaded(),this._availableImages.slice()}getActualScope(){return this._importedAsBasemap?"basemap":this.scope}addModelURLs(t){return this.modelManager.addModelURLs(t,this.getActualScope()),this._updateWorkerModels(),this.fire(new e.A("data",{dataType:"style"})),this}addModel(t,i,o={}){return this._checkLoaded(),this._validate(ze,`models.${t}`,i,null,o)||(this.modelManager.addModel(t,i,this.getActualScope()),this.fire(new e.A("data",{dataType:"style"}))),this}hasModel(e){return this.modelManager.hasModel(e,this.getActualScope())}removeModel(t){return this.hasModel(t)?(this.modelManager.removeModel(t,this.getActualScope(),!1,!0),this.fire(new e.A("data",{dataType:"style"})),this):this.fire(new e.z(new Error("No model with this ID exists.")))}listModels(){return this._checkLoaded(),this.modelManager.listModels(this.getActualScope())}addSource(t,i,o={}){if(this._checkLoaded(),void 0!==this.getOwnSource(t))throw new Error(`There is already a source with ID "${t}".`);if(!i.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(i).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(i.type)>=0&&this._validate(Te,`sources.${t}`,i,null,o))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const s=mt(t,i,this.dispatcher,this);s.scope=this.scope,s.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(s.id),source:s.serialize(),sourceId:s.id}));const r=t=>{const i=(t?"symbol:":"other:")+s.id,o=e.C(i,this.scope),r=this._sourceCaches[i]=new Ft(o,s,t);(t?this._symbolSourceCaches:this._otherSourceCaches)[s.id]=r,r.onAdd(this.map);};r(!1),"vector"!==i.type&&"geojson"!==i.type||r(!0),s.onAdd&&s.onAdd(this.map),o.isInitialLoad||(this.mergeSources(),this._changes.setDirty());}removeSource(t){this._checkLoaded();const i=this.getOwnSource(t);if(!i)throw new Error("There is no source with this ID");for(const i in this._layers)if(this._layers[i].source===t)return this.fire(new e.z(new Error(`Source "${t}" cannot be removed while layer "${i}" is using it.`)));if(this.terrain&&this.terrain.scope===this.scope&&this.terrain.get().source===t)return this.fire(new e.z(new Error(`Source "${t}" cannot be removed while terrain is using it.`)));if(this.stylesheet.iconsets){const i=Object.entries(this.stylesheet.iconsets).find(([e,i])=>"source"===i.type&&i.source===t);if(i)return this.fire(new e.z(new Error(`Source "${t}" cannot be removed while iconset "${i[0]}" is using it.`)))}const o=this.getOwnSourceCaches(t);for(const t of o){const i=e.dt(t.id);delete this._sourceCaches[i],this._changes.discardSourceCacheUpdate(t.id),t.fire(new e.A("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(),i.setEventedParent(null),i.onRemove&&i.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 i=this.getOwnSourceCache(t);i&&e.push(i.getSource());}return e}areTilesLoaded(){const e=this._mergedSourceCaches;for(const t in e){const i=e[t]._tiles;for(const e in i){const t=i[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 i=this._getTransitionParameters();for(const e of t){if(this._validate(Se,"lights",e))return;switch(e.type){case "ambient":if(this.ambientLight){const t=this.ambientLight;t.set(e),t.updateTransitions(i);}else this.ambientLight=new et(e,tt(),this.scope,this.options);break;case "directional":if(this.directionalLight){const t=this.directionalLight;t.set(e),t.updateTransitions(i);}else this.directionalLight=new et(e,ot(),this.scope,this.options);}}const o=Object.assign(i,{worldview:this.map.getWorldview()}),s=new e.ad(this.z||0,o);this.ambientLight&&this.ambientLight.recalculate(s),this.directionalLight&&this.directionalLight.recalculate(s),this._brightness=this.calculateLightsBrightness(),this.dispatcher.broadcast("setBrightness",this._brightness);}calculateLightsBrightness(){const t=this.directionalLight,i=this.ambientLight;if(!t||!i)return;const o=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)),s=t.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),r=t.properties.get("intensity"),n=t.properties.get("direction"),a=1-e.d5(n.x,n.y,n.z)[2]/90,l=o(s)*r*a,c=i.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),h=i.properties.get("intensity"),d=o(c)*h;return Number(((l+d)/2).toFixed(6))}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(null==t||""===t&&this.isRootStyle())return this;if(e.du(t)){const i=e.dv(t),o=this.fragments.find(({id:e})=>e===i);if(!o)return;const s=e.dt(t);return o.style.getFragmentStyle(s)}{const e=this.fragments.find(({id:e})=>e===t);return e?e.style:void 0}}setFeaturesetSelectors(t){if(!t)return;const i=(e,t="")=>`${e}::${t}`;this._featuresetSelectors={};for(const o in t){const s={},r=this._featuresetSelectors[o]=[];for(const n of t[o].selectors){if(n.featureNamespace){const t=this.getOwnLayer(n.layer);if(!t){e.w(`Layer is undefined for selector: ${n.layer}`);continue}const r=i(t.source,t.sourceLayer);if(r in s&&s[r]!==n.featureNamespace){e.w(`"featureNamespace ${n.featureNamespace} of featureset ${o}'s selector is not associated to the same source, skip this selector`);continue}s[r]=n.featureNamespace;}let t;if(n.properties)for(const i in n.properties){const o=e.W(n.properties[i]);"success"===o.result&&(t=t||{},t[i]=o.value);}r.push({layerId:n.layer,namespace:n.featureNamespace,properties:t,uniqueFeatureID:n._uniqueFeatureID});}}}getFeaturesetDescriptors(e){const t=this.getFragmentStyle(e);if(!t||!t.stylesheet.featuresets)return [];const i=[];for(const e in t.stylesheet.featuresets)i.push({featuresetId:e,importId:t.scope?t.scope:void 0});return i}getFeaturesetLayers(t,i){const o=this.getFragmentStyle(i),s=o.stylesheet.featuresets;if(!s||!s[t])return this.fire(new e.z(new Error(`The featureset '${t}' does not exist in the map's style and cannot be queried.`))),[];const r=[];for(const e of s[t].selectors){const t=o.getOwnLayer(e.layer);t&&r.push(t);}return r}getConfigProperty(t,i){const o=this.getFragmentStyle(t);if(!o)return null;const s=e.C(i,o.scope),r=o.options.get(s),n=r?r.value||r.default:null;return n?n.serialize():null}isIndoorEnabled(){return Object.keys(this._mergedIndoor).length>0}getIndoorSourceLayers(t,i){const o=e.C(t,i);return this._mergedIndoor[o]}setIndoorData(e,t){this.indoorManager.setIndoorData(t);}updateIndoorDependentLayers(){this._updateLayers(this._indoorDependentLayers),this.map._styleDirty=!0,this.map.triggerRepaint();}setConfigProperty(t,i,o){const s=this.getFragmentStyle(t);if(!s)return;const r=s.stylesheet.schema;if(!r||!r[i])return;const n=e.W(o);if("success"!==n.result)return void Io(this,n.value);const a=n.value.expression,l=e.C(i,s.scope),c=s.options.get(l);if(!c)return;let h;const{minValue:d,maxValue:u,stepValue:_,type:p,values:f}=r[i],m=e.W(r[i].default);"success"===m.result&&(h=m.value.expression),h?(this.options.set(l,Object.assign({},c,{value:a,default:h,minValue:d,maxValue:u,stepValue:_,type:p,values:f})),this.updateConfigDependencies(i)):this.fire(new e.z(new Error(`No schema defined for the config option "${i}" in the "${t}" fragment.`)));}getConfig(t){const i=this.getFragmentStyle(t);if(!i)return null;const o=i.stylesheet.schema;if(!o)return null;const s={};for(const t in o){const o=e.C(t,i.scope),r=i.options.get(o),n=r?r.value||r.default:null;s[t]=n?n.serialize():null;}return s}setConfig(e,t){const i=this.getFragmentStyle(e);i&&(i.updateConfig(t,i.stylesheet.schema),this.updateConfigDependencies());}getSchema(e){const t=this.getFragmentStyle(e);return t?t.stylesheet.schema:null}setSchema(e,t){const i=this.getFragmentStyle(e);i&&(i.stylesheet.schema=t,i.updateConfig(i._config,t),this.updateConfigDependencies());}updateConfig(t,i){if(this._config=t,t||i)if(i)for(const o in i){let s,r;const n=e.W(i[o].default);if("success"===n.result&&(s=n.value.expression),t&&void 0!==t[o]){const i=e.W(t[o]);"success"===i.result&&(r=i.value.expression);}const{minValue:a,maxValue:l,stepValue:c,type:h,values:d}=i[o];if(s){const t=e.C(o,this.scope);this.options.set(t,{default:s,value:r,minValue:a,maxValue:l,stepValue:c,type:h,values:d});}else this.fire(new e.z(new Error(`No schema defined for config option "${o}".`)));}else this.fire(new e.z(new Error("Attempting to set config for a style without schema.")));}_updateLayers(e,t=()=>!0){for(const i of e){const e=this.getLayer(i);e&&t(e)&&(e.possiblyEvaluateVisibility(),this._updateLayer(e),this._changes.setDirty());}}updateConfigDependencies(e){this._updateLayers(this._configDependentLayers,t=>!e||t.expressionDependencies.configDependencies.has(e)),this.ambientLight&&this.ambientLight.updateConfig(this.options),this.directionalLight&&this.directionalLight.updateConfig(this.options),this.fog&&this.fog.updateConfig(this.options),this.snow&&this.snow.updateConfig(this.options),this.rain&&this.rain.updateConfig(this.options),this.forEachFragmentStyle(e=>{const t=e._styleColorTheme.colorThemeOverride?e._styleColorTheme.colorThemeOverride:e._styleColorTheme.colorTheme;if(t){const i=e._evaluateColorThemeData(t);(!e._styleColorTheme.lut&&""!==i||e._styleColorTheme.lut&&i!==e._styleColorTheme.lut.data)&&e.setColorTheme(t);}}),this._changes.setDirty();}addLayer(t,i,o={}){this._checkLoaded();const s=t.id;if(this._layers[s])return void this.fire(new e.z(new Error(`Layer with id "${s}" already exists on this map`)));let r;if("custom"===t.type){if(Io(this,e.dw(t)))return;r=e.dx(t,this.scope,this._styleColorTheme.lut,this.options);}else {if("object"==typeof t.source&&(this.addSource(s,t.source),t=e.ds(t),t=Object.assign(t,{source:s})),this._validate(De,`layers.${s}`,t,{arrayIndex:-1},o))return;r=e.dx(t,this.scope,this._styleColorTheme.lut,this.options),this._validateLayer(r),r.setEventedParent(this,{layer:{id:s}});}const n=e.C(r.source,r.scope);0!==r.expressionDependencies.configDependencies.size&&this._configDependentLayers.add(n),r.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(n);let a=this._order.length;if(i){const t=this._order.indexOf(i);if(-1===t)return void this.fire(new e.z(new Error(`Layer with id "${i}" does not exist on this map.`)));r.slot&&r.slot!==this._layers[i].slot?e.w(`Layer with id "${i}" has a different slot. Layers can only be rearranged within the same slot.`):a=t;}this._order.splice(a,0,s),this._handleLayerOrderChange(),this._layers[s]=r;const l=this.getOwnLayerSourceCache(r),c=!!this.directionalLight&&this.directionalLight.shadowsEnabled();l&&r.canCastShadows()&&c&&(l.castsShadows=!0);const h=this._changes.getRemovedLayer(r);if(h&&r.source&&l&&"custom"!==r.type){this._changes.discardLayerRemoval(r);const t=e.C(r.source,r.scope);h.type!==r.type?this._changes.updateSourceCache(t,"clear"):(this._changes.updateSourceCache(t,"reload"),l.pause());}this._updateLayer(r),r.onAdd&&r.onAdd(this.map),r.scope=this.scope,this.mergeLayers();}moveLayer(t,i){this._checkLoaded();const o=this._checkLayer(t);if(!o)return;if(t===i)return;const s=this._order.indexOf(t);this._order.splice(s,1);let r=this._order.length;if(i){const t=this._order.indexOf(i);if(-1===t)return void this.fire(new e.z(new Error(`Layer with id "${i}" does not exist on this map.`)));o.slot&&o.slot!==this._layers[i].slot?e.w(`Layer with id "${i}" has a different slot. Layers can only be rearranged within the same slot.`):r=t;}this._order.splice(r,0,t),this._changes.setDirty(),this._handleLayerOrderChange(),this.mergeLayers();}removeLayer(e){this._checkLoaded();const t=this._checkLayer(e);if(!t)return;t.setEventedParent(null);const i=this._order.indexOf(e);this._order.splice(i,1),delete this._layers[e],this._changes.setDirty(),this._handleLayerOrderChange(),this._configDependentLayers.delete(t.fqid),this._indoorDependentLayers.delete(t.fqid),this._changes.removeLayer(t);const o=this.getOwnLayerSourceCache(t);if(o&&o.castsShadows){let e=!1;for(const i in this._layers)if(this._layers[i].source===t.source&&this._layers[i].canCastShadows()){e=!0;break}o.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,i){this._checkLoaded();const o=this._checkLayer(e);o&&(o.minzoom===t&&o.maxzoom===i||(null!=t&&(o.minzoom=t),null!=i&&(o.maxzoom=i),this._updateLayer(o)));}getSlots(){return this._checkLoaded(),this._mergedSlots}setSlot(e,t){this._checkLoaded();const i=this._checkLayer(e);i&&i.slot!==t&&(i.slot=t,this._updateLayer(i));}setFilter(t,i,o={}){this._checkLoaded();const s=this._checkLayer(t);if(s&&!e.bz(s.filter,i))return null==i?(s.filter=void 0,void this._updateLayer(s)):void(this._validate(Le,`layers.${s.id}.filter`,i,{layerType:s.type},o)||(s.filter=e.ds(i),this._updateLayer(s)))}getFilter(t){const i=this._checkLayer(t);if(i)return e.ds(i.filter)}setLayoutProperty(t,i,o,s={}){this._checkLoaded();const r=this._checkLayer(t);if(r&&!e.bz(r.getLayoutProperty(i),o)){if(null!=o&&(!s||!1!==s.validate)&&Io(r,Oe.call(we,{key:`layers.${t}.layout.${i}`,layerType:r.type,objectKey:i,value:o,styleSpec:e.a7,style:{glyphs:!0,sprite:!0}})))return;r.setLayoutProperty(i,o),0!==r.expressionDependencies.configDependencies.size&&this._configDependentLayers.add(r.fqid),r.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(r.fqid),this._updateLayer(r);}}setLayerProperty(e,t,i,o={}){this._checkLoaded();const s=this._checkLayer(e);s&&("appearances"===t?(s.setAppearances(i),this._updateLayer(s)):s.isPaintProperty(t)?this.setPaintProperty(e,t,i,o):this.setLayoutProperty(e,t,i,o));}getLayoutProperty(e,t){const i=this._checkLayer(e);if(i)return i.getLayoutProperty(t)}setPaintProperty(t,i,o,s={}){this._checkLoaded();const r=this._checkLayer(t);if(!r)return;if(e.bz(r.getPaintProperty(i),o))return;if(null!=o&&(!s||!1!==s.validate)&&Io(r,Pe.call(we,{key:`layers.${t}.paint.${i}`,layerType:r.type,objectKey:i,value:o,styleSpec:e.a7})))return;const n=r.setPaintProperty(i,o);0!==r.expressionDependencies.configDependencies.size&&this._configDependentLayers.add(r.fqid),r.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(r.fqid),n&&this._updateLayer(r),this._changes.updatePaintProperties(r);}getPaintProperty(e,t){const i=this._checkLayer(e);if(i)return i.getPaintProperty(t)}setFeatureState(t,i){if(this._checkLoaded(),"target"in t){if("featuresetId"in t.target){const{featuresetId:e,importId:o}=t.target,s=this.getFragmentStyle(o),r=s.getFeaturesetLayers(e);for(const{source:e,sourceLayer:o}of r)s.setFeatureState({id:t.id,source:e,sourceLayer:o},i);}else if("layerId"in t.target){const{layerId:e}=t.target,o=this.getLayer(e);this.setFeatureState({id:t.id,source:o.source,sourceLayer:o.sourceLayer},i);}return}const o=t.source,s=t.sourceLayer,r=this._checkSource(o);if(!r)return;const n=r.type;if("geojson"===n&&s)return void this.fire(new e.z(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===n&&!s)return void this.fire(new e.z(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===t.id&&this.fire(new e.z(new Error("The feature id parameter must be provided.")));const a=this.getOwnSourceCaches(o);for(const e of a)e.setFeatureState(s,t.id,i);}removeFeatureState(t,i){if(this._checkLoaded(),"target"in t){if("featuresetId"in t.target){const{featuresetId:e,importId:o}=t.target,s=this.getFragmentStyle(o),r=s.getFeaturesetLayers(e);for(const{source:e,sourceLayer:o}of r)s.removeFeatureState({id:t.id,source:e,sourceLayer:o},i);}else if("layerId"in t.target){const{layerId:e}=t.target,o=this.getLayer(e);this.removeFeatureState({id:t.id,source:o.source,sourceLayer:o.sourceLayer},i);}return}const o=t.source,s=this._checkSource(o);if(!s)return;const r=s.type,n="vector"===r?t.sourceLayer:void 0;if("vector"===r&&!n)return void this.fire(new e.z(new Error("The sourceLayer parameter must be provided for vector source types.")));if(i&&"string"!=typeof t.id&&"number"!=typeof t.id)return void this.fire(new e.z(new Error("A feature id is required to remove its specific state property.")));const a=this.getOwnSourceCaches(o);for(const e of a)e.removeFeatureState(n,t.id,i);}getFeatureState(t){if(this._checkLoaded(),"target"in t){let i;if("featuresetId"in t.target){const{featuresetId:o,importId:s}=t.target,r=this.getFragmentStyle(s),n=r.getFeaturesetLayers(o);for(const{source:o,sourceLayer:s}of n){const n=r.getFeatureState({id:t.id,source:o,sourceLayer:s});if(n&&!i)i=n;else if(!e.bz(i,n))return void this.fire(new e.z(new Error("The same feature id exists in multiple sources in the featureset, but their feature states are not consistent through the sources.")))}}else if("layerId"in t.target){const{layerId:e}=t.target,o=this.getLayer(e);i=this.getFeatureState({id:t.id,source:o.source,sourceLayer:o.sourceLayer});}return i}const i=t.source,o=t.sourceLayer,s=this._checkSource(i);if(s){if("vector"!==s.type||o)return void 0===t.id&&this.fire(new e.z(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(i)[0].getFeatureState(o,t.id);this.fire(new e.z(new Error("The sourceLayer parameter must be provided for vector source types.")));}}setTransition(e){return this.stylesheet.transition=Object.assign({},this.stylesheet.transition,e),this.transition=this.stylesheet.transition,this}getTransition(){return Object.assign({},this.stylesheet.transition)}serialize(){this._checkLoaded();const t=this.getTerrain(),i=t&&this.terrain&&this.terrain.scope===this.scope?t:this.stylesheet.terrain;return e.dy({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,fragment:this.stylesheet.fragment,iconsets:this.stylesheet.iconsets,featuresets:this.stylesheet.featuresets,imports:this._serializeImports(),schema:this.stylesheet.schema,camera:this.stylesheet.camera,light:this.stylesheet.light,lights:this.stylesheet.lights,terrain:i,fog:this.stylesheet.fog,snow:this.stylesheet.snow,rain:this.stylesheet.rain,indoor:this.stylesheet.indoor,center:this.stylesheet.center,"color-theme":this.stylesheet["color-theme"],zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,projection:this.stylesheet.projection,sources:this._serializeSources(),layers:this._serializeLayers(this._order)},e=>void 0!==e)}_updateFilteredLayers(e){for(const t of Object.values(this._mergedLayers))e(t)&&this._updateLayer(t);}_updateLayer(t){this._changes.updateLayer(t);const i=this.getLayerSourceCache(t),o=e.C(t.source,t.scope),s=this._changes.getUpdatedSourceCaches();t.source&&!s[o]&&i&&"raster"!==i.getSource().type&&(this._changes.updateSourceCache(o,"reload"),i.pause()),t.invalidateCompiledFilter();}_flattenAndSortRenderedFeatures(e){const t=e=>this._mergedLayers[e].is3D(!!this.terrain),i=this.order,o={},s=[];for(let r=i.length-1;r>=0;r--){const n=i[r];if(t(n)){o[n]=r;for(const t of e){const e=t[n];if(e)for(const t of e)s.push(t);}}}s.sort((e,t)=>t.intersectionZ-e.intersectionZ);const r=[];for(let n=i.length-1;n>=0;n--){const a=i[n];if(t(a))for(let e=s.length-1;e>=0;e--){const t=s[e].feature;if(t.layer&&o[t.layer.id]{if(Ao.has(e.type))return;const t=this.getOwnLayerSourceCache(e),i=r[t.id]=r[t.id]||{sourceCache:t,layers:{},has3DLayers:!1};e.is3D(!!this.terrain)&&(i.has3DLayers=!0),i.layers[e.fqid]=i.layers[e.fqid]||{styleLayer:e,targets:[]},i.layers[e.fqid].targets.push({filter:s});};if(i&&i.layers){if(!Array.isArray(i.layers))return this.fire(new e.z(new Error("parameters.layers must be an Array."))),[];for(const t of i.layers){const i=this._layers[t];if(!i)return this.fire(new e.z(new Error(`The layer '${t}' does not exist in the map's style and cannot be queried for features.`))),[];n(i);}}else for(const e in this._layers)n(this._layers[e]);const a=this._queryRenderedFeatures(t,r,o),l=this._flattenAndSortRenderedFeatures(a),c=[];for(const t of l)e.dz(t.layer.id)===this.scope&&c.push(t);return c}queryRenderedFeatureset(t,i,o){let s;i&&!Array.isArray(i)&&i.filter&&(this._validate(Le,"queryRenderedFeatures.filter",i.filter,null,i),s=e.b7(i.filter));const r="mock",n=[];if(i&&i.target)n.push(Object.assign({},i,{targetId:r,filter:s}));else {const e=this.getFeaturesetDescriptors();for(const t of e)n.push({targetId:r,filter:s,target:t});for(const{style:e}of this.fragments){const t=e.getFeaturesetDescriptors();for(const e of t)n.push({targetId:r,filter:s,target:e});}}const a=this.queryRenderedTargets(t,n,o),l=[],c=new Set;for(const t of a)for(const i of t.variants[r])vt(i,t,c)||l.push(new e.dA(t,i));return l}queryRenderedTargets(t,i,o){const s={},r=(e,t,i,o)=>{const r=s[t.id]=s[t.id]||{sourceCache:t,layers:{},has3DLayers:!1};if(r.layers[e.fqid]=r.layers[e.fqid]||{styleLayer:e,targets:[]},e.is3D(!!this.terrain)&&(r.has3DLayers=!0),!o)return i.uniqueFeatureID=!1,void r.layers[e.fqid].targets.push(i);r.layers[e.fqid].targets.push(Object.assign({},i,{namespace:o.namespace,properties:o.properties,uniqueFeatureID:o.uniqueFeatureID}));};for(const t of i)if("featuresetId"in t.target){const{featuresetId:i,importId:o}=t.target,s=this.getFragmentStyle(o);if(!s||!s._featuresetSelectors)continue;const n=s._featuresetSelectors[i];if(!n){this.fire(new e.z(new Error(`The featureset '${i}' does not exist in the map's style and cannot be queried for features.`)));continue}for(const e of n){const i=s.getOwnLayer(e.layerId);i&&!Ao.has(i.type)&&r(i,s.getOwnLayerSourceCache(i),t,e);}}else if("layerId"in t.target){const{layerId:e}=t.target,i=this.getLayer(e);if(!i||Ao.has(i.type))continue;r(i,this.getLayerSourceCache(i),t);}const n=this._queryRenderedFeatures(t,s,o);return this._flattenAndSortRenderedFeatures(n)}_queryRenderedFeatures(e,t,i){const o=[],s=!!this.map._showQueryGeometry,r=st.createFromScreenPoints(e,i);for(const e in t){const n=yt(r,t[e],this._availableImages,i,s,this.getActualScope());Object.keys(n).length&&o.push(n);}if(this.placement)for(const e in t){if(!t[e].sourceCache._onlySymbols)continue;const i=xt(r.screenGeometry,t[e],this._availableImages,this.placement.collisionIndex,this.placement.retainedQueryData,this.map.getWorldview());Object.keys(i).length&&o.push(i);}return o}querySourceFeatures(e,t){const i=t&&t.filter;i&&this._validate(Le,"querySourceFeatures.filter",i,null,t);let o=[];const s=this.getOwnSourceCaches(e);for(const e of s)o=o.concat(bt(e,t));return o}addSourceType(e,t,i){return Po.getSourceType(e)?i(new Error(`A source type called "${e}" already exists.`)):(Po.setSourceType(e,t),t.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:e,url:t.workerSourceURL},i):i(null,null))}getFlatLight(){return this.light.getLight()}setFlatLight(t,i,o={}){this._checkLoaded();const s=this.light.getLight();let r=!1;for(const i in t)if(!e.bz(t[i],s[i])){r=!0;break}if(!r)return;const n=this._getTransitionParameters();this.light.setLight(t,i,o),this.light.updateTransitions(n);}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0);}checkCanvasFingerprintNoise(){void 0===this.disableElevatedTerrain&&(this.disableElevatedTerrain=e.o.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)."));}setTerrain(t,i=1){if(this._checkLoaded(),!t)return this.terrainSetForDrapingOnly()||(delete this.terrain,this.map.transform.projection.requiresDraping&&this.setTerrainForDraping()),0===i&&delete this.terrain,null===t?this.stylesheet.terrain=null:delete this.stylesheet.terrain,this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);this.checkCanvasFingerprintNoise();let o=t;const s=!("source"in t)||null==t.source;if(1===i){if(this.disableElevatedTerrain)return;if("source"in o&&"object"==typeof o.source){const t="terrain-dem-src";this.addSource(t,o.source),o=e.ds(o),o=Object.assign(o,{source:t});}const t=Object.assign({},o),i={};if(this.terrain&&s){t.source=this.terrain.get().source;const e=this.terrain?this.getFragmentStyle(this.terrain.scope):null;e&&(i.style=e.serialize());}if(this._validate(Ie,"terrain",t,i))return}if(!this.terrain||this.terrain.scope!==this.scope&&!s||this.terrain&&i!==this.terrain.drapeRenderMode){if(!o)return;this._createTerrain(o,i),this.fire(new e.A("data",{dataType:"style"}));}else {const i=this.terrain,s=i.get();for(const t of Object.keys(e.a7.terrain))!o.hasOwnProperty(t)&&e.a7.terrain[t].default&&(o[t]=e.a7.terrain[t].default);for(const o in t)if(!e.bz(t[o],s[o])){i.set(t,this.options),this.stylesheet.terrain=t;const o=this._getTransitionParameters({duration:0});i.updateTransitions(o),this.fire(new e.A("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0;}_createFog(e){const t=this.fog=new $e(e,this.map.transform,this.scope,this.options);this.stylesheet.fog=t.get();const i=this._getTransitionParameters({duration:0});t.updateTransitions(i);}_createSnow(e){const t=this.snow=new Je(e,this.map.transform,this.scope,this.options);this.stylesheet.snow=t.get();const i=this._getTransitionParameters({duration:0});t.updateTransitions(i);}_createRain(e){const t=this.rain=new Qe(e,this.map.transform,this.scope,this.options);this.stylesheet.rain=t.get();const i=this._getTransitionParameters({duration:0});t.updateTransitions(i);}_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(t){if(this._checkLoaded(),!t)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const i=this.fog;if(!e.bz(i.get(),t)){i.set(t,this.options),this.stylesheet.fog=i.get();const e=this._getTransitionParameters({duration:0});i.updateTransitions(e);}}else this._createFog(t);this._markersNeedUpdate=!0;}getSnow(){return this.snow?this.snow.get():null}setSnow(t){if(this._checkLoaded(),!t)return delete this.snow,void delete this.stylesheet.snow;if(this.snow){const i=this.snow;if(!e.bz(i.get(),t)){i.set(t,this.options),this.stylesheet.snow=i.get();const e=this._getTransitionParameters({duration:0});i.updateTransitions(e);}}else this._createSnow(t);this._markersNeedUpdate=!0;}getRain(){return this.rain?this.rain.get():null}setRain(t){if(this._checkLoaded(),!t)return delete this.rain,void delete this.stylesheet.rain;if(this.rain){const i=this.rain;if(!e.bz(i.get(),t)){i.set(t,this.options),this.stylesheet.rain=i.get();const e=this._getTransitionParameters({duration:0});i.updateTransitions(e);}}else this._createRain(t);this._markersNeedUpdate=!0;}_reloadColorTheme(){const t=()=>{for(const e in this._layers)this._layers[e].lut=this._styleColorTheme.lut;for(const e in this._sourceCaches)this._sourceCaches[e].clearTiles();},i=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(!i)return this._styleColorTheme.lut=null,void t();const o=this._evaluateColorThemeData(i);this._loadColorTheme(o).then(()=>{this.fire(new e.A("colorthemeset")),t();}).catch(t=>{e.w(`Couldn't set color theme: ${t}`);});}setColorTheme(t){this._checkLoaded(),this._styleColorTheme.colorThemeOverride&&e.w("Note: setColorTheme is called on a style with a color-theme override, the passed color-theme won't be visible."),this._styleColorTheme.colorTheme=t,this._reloadColorTheme();}setImportColorTheme(e,t){const i=this.getFragmentStyle(e);i&&(i._styleColorTheme.colorThemeOverride=t,i._reloadColorTheme());}_getTransitionParameters(t){return {now:e.o.now(),transition:Object.assign(this.transition,t)}}updateDrapeFirstLayers(){if(!this.terrain)return;const e=[],t=[];for(const i of this._mergedOrder)this.isLayerDraped(this._mergedLayers[i])?e.push(i):t.push(i);this._drapedFirstOrder=[],this._drapedFirstOrder.push(...e),this._drapedFirstOrder.push(...t);}_createTerrain(e,t){const i=this.terrain=new je(e,t,this.scope,this.options,this.map.getWorldview());1===t&&(this.stylesheet.terrain=e),this.mergeTerrain(),this.updateDrapeFirstLayers(),this._force3DLayerUpdate();const o=this._getTransitionParameters({duration:0});i.updateTransitions(o);}_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,i,o,s,r={}){if(r&&!1===r.validate)return !1;const n=Object.assign({},this.serialize());return Io(this,t.call(we,Object.assign({key:i,style:n,value:o,styleSpec:e.a7},s)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),e.dB.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.imageManager.removeScope(this.scope),this.imageManager.imageAtlasCache.clear(),this.setEventedParent(null),delete this.fog,delete this.snow,delete this.rain,delete this.terrain,delete this.ambientLight,delete this.directionalLight,this.indoorManager.destroy(),this.isRootStyle()&&(this.imageManager.setEventedParent(null),this.imageManager.destroy(),this.modelManager.setEventedParent(null),this.modelManager.destroy(),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();}clearLayers(){for(const e in this._mergedLayers){const t=this._mergedLayers[e];t._clear&&t._clear();}}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();}reloadModels(){this.modelManager.reloadModels(""),this.forEachFragmentStyle(e=>{e.modelManager.reloadModels(e.scope);});}updateSources(e){let t;this.directionalLight&&(t=fo(this.directionalLight));const i=new Set,o=new Set,s=new Set;for(const e in this._mergedLayers){const t=this._mergedLayers[e];"building"===t.type?i.add(t.source):"raster"===t.type&&t.paint&&"ground"===t.paint.get("raster-elevation-reference")&&s.add(t.source),t.hasElevation()&&!o.has(t.source)&&o.add(t.source);}for(const r in this._mergedSourceCaches){const n=this._mergedSourceCaches[r],a=o.has(n._source.id);n._isRasterElevatedOverTerrain=s.has(n._source.id),i.has(n._source.id)&&(n._source.reparseOverscaled=!1),n.update(e,void 0,void 0,t,a);}}_generateCollisionBoxes(){for(const e in this._sourceCaches){const t=this._sourceCaches[e];t.resume(),t.reload();}}_handleLayerOrderChange(){this._requestFullLabelPlacement(),this.fire(new e.A("neworder"));}_requestFullLabelPlacement(){this.pauseablePlacement||(this.pauseablePlacement=new Ni),this.pauseablePlacement.requestFullPlacement();}_setLabelPlacementStale(){this.placement&&this.placement.setStale();}_updatePlacement(t,i,o,s,r){this.pauseablePlacement||(this.pauseablePlacement=new Ni);let n=!1,a=!1;const l={},c={};for(const i of this._mergedOrder){const o=this._mergedLayers[i];if("symbol"!==o.type)continue;const s=e.C(o.source,o.scope);let r=l[s];if(!r){const e=this.getLayerSourceCache(o);if(!e)continue;const t=e.getRenderableIds(!0).map(t=>e.getTileByID(t));c[s]=t.slice(),r=l[s]=t.sort((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1));}const a=this.crossTileSymbolIndex.addLayer(o,r,t.center.lng,t.projection);n=n||a;}this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder);const h=Boolean(this.placement&&!t.equals(this.placement.transform)),d=Boolean(this.placement&&(0!==this.placement.lastReplacementSourceUpdateTime&&!r||this.placement.lastReplacementSourceUpdateTime!==r.updateTime)),u=h||d||n,_=(u||this.pauseablePlacement.isStale())&&0===o,p=this.pauseablePlacement.isDone()&&!this.placement.stillRecent(e.o.now(),t.zoom)&&0!==o;if((this.pauseablePlacement.isFullPlacementRequested()||!this.pauseablePlacement.placement||_||p)&&(this.pauseablePlacement=this.pauseablePlacement.startNewPlacement(t,this._mergedOrder,i,o,s,this.placement,this.fog&&t.projection.supportsFog?this.fog.state:null,this._buildingIndex)),this.pauseablePlacement.isDone()?u&&0!==o&&this.pauseablePlacement.setStale():(this.pauseablePlacement.continuePlacement(this._mergedOrder,this._mergedLayers,l,c,this.map.painter.scaleFactor),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(e.o.now()),a=!0),n&&this.pauseablePlacement.setStale()),a||n){this._buildingIndex.onNewFrame(t.zoom);for(let t=0;te===t.id))return void this.fire(new e.z(new Error(`Import with id '${t.id}' already exists in the map's style.`)));if(!i)return o.push(t),this._loadImports([t],!0);const s=o.findIndex(({id:e})=>e===i);return -1===s&&this.fire(new e.z(new Error(`Import with id "${i}" does not exist on this map.`))),this.stylesheet.imports=o.slice(0,s).concat(t).concat(o.slice(s)),this._loadImports([t],!0,i)}updateImport(t,i){this._checkLoaded();const o=this.stylesheet.imports||[],s=this.getImportIndex(t);return -1===s?this:"string"==typeof i?(this.setImportUrl(t,i),this):(i.url&&i.url!==o[s].url&&this.setImportUrl(t,i.url),e.bz(i.config,o[s].config)||this.setImportConfig(t,i.config,i.data.schema),e.bz(i.data,o[s].data)||this.setImportData(t,i.data),this)}moveImport(e,t){this._checkLoaded();let i=this.stylesheet.imports||[];const o=this.getImportIndex(e);if(-1===o)return this;const s=this.getImportIndex(t);if(-1===s)return this;const r=i[o],n=this.fragments[o];return i=i.filter(({id:t})=>t!==e),this.fragments=this.fragments.filter(({id:t})=>t!==e),this.stylesheet.imports=i.slice(0,s).concat(r).concat(i.slice(s)),this.fragments=this.fragments.slice(0,s).concat(n).concat(this.fragments.slice(s)),this.mergeLayers(),this}setImportUrl(e,t){this._checkLoaded();const i=this.stylesheet.imports||[],o=this.getImportIndex(e);if(-1===o)return this;i[o].url=t;const s=this.fragments[o];return s.style=this._createFragmentStyle(i[o]),s.style.on("style.import.load",()=>this.mergeAll()),s.style.loadURL(t),this}setImportData(e,t){this._checkLoaded();const i=this.getImportIndex(e),o=this.stylesheet.imports||[];return -1===i?this:t?(this.fragments[i].style.setState(t),this._reloadImports(),this):(delete o[i].data,this.setImportUrl(e,o[i].url))}setImportConfig(e,t,i){this._checkLoaded();const o=this.getImportIndex(e),s=this.stylesheet.imports||[];if(-1===o)return this;t?s[o].config=t:delete s[o].config;const r=this.fragments[o];i&&r.style.stylesheet&&(r.style.stylesheet.schema=i);const n=r.style.stylesheet&&r.style.stylesheet.schema;return r.config=t,r.style.updateConfig(t,n),this.updateConfigDependencies(),this}removeImport(e){this._checkLoaded();const t=this.stylesheet.imports||[],i=this.getImportIndex(e);-1!==i&&(t.splice(i,1),this.fragments[i].style._remove(),this.fragments.splice(i,1),this._reloadImports());}getImportIndex(t){const i=(this.stylesheet.imports||[]).findIndex(e=>e.id===t);return -1===i&&this.fire(new e.z(new Error(`Import '${t}' does not exist in the map's style and cannot be updated.`))),i}getLayer(e){return this._mergedLayers[e]}getSources(){const e=[];for(const t in this._mergedOtherSourceCaches){const i=this._mergedOtherSourceCaches[t];i&&e.push(i.getSource());}return e}getSource(e,t){const i=this.getSourceCache(e,t);return i&&i.getSource()}getLayerSource(e){const t=this.getLayerSourceCache(e);return t&&t.getSource()}getSourceCache(t,i){const o=e.C(t,i);return this._mergedOtherSourceCaches[o]}getLayerSourceCache(t){const i=e.C(t.source,t.scope);return "symbol"===t.type?this._mergedSymbolSourceCaches[i]:this._mergedOtherSourceCaches[i]}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 i=e[t];"reload"===i?this.reloadSource(t):"clear"===i&&this.clearSource(t);}}updateLayers(e){const t=this._changes.getUpdatedPaintProperties();for(const i of t){const t=this.getLayer(i);t&&t.updateTransitions(e);}}getGlyphsUrl(){return this.stylesheet.glyphs}setGlyphsUrl(e){this.stylesheet.glyphs=e,this.glyphManager.setURL(e);}getImages(t,i,o){this.imageManager.getImages(i.images,i.scope,o),this._updateTilesForChangedImages();const s=t=>{if(t){const o=i.images.map(t=>e.I.toString(t));t.setDependencies(i.tileID.key,i.type,o);}},r=e.C(i.source,i.scope);s(this._mergedOtherSourceCaches[r]),s(this._mergedSymbolSourceCaches[r]),i.images.some(e=>e.iconsetId)&&this.fire(new e.A("data",{dataType:"style"}));}rasterizeImages(e,t,i){this.imageManager.rasterizeImages(t,i);}checkAtlasCache(e,t,i){const o=this.imageManager.imageAtlasCache.findCachedAtlas(t.descriptor);i(null,o&&o.contentDescriptor?{iconPositions:o.iconPositions,patternPositions:o.patternPositions,sourceHash:o.contentDescriptor.hash}:null);}getGlyphs(e,t,i){this.glyphManager.getGlyphs(t.stacks,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 i=this.getOwnSourceCaches(t);return 0===i.length?(this.fire(new e.z(new Error(`There is no source with ID '${t}'`))),!1):i.every(e=>e.loaded())}has3DLayers(){return this._has3DLayers}hasSymbolLayers(){return this._hasSymbolLayers}hasCircleLayers(){return this._hasCircleLayers}isLayerClipped(e,t){if(!this._clipLayerPresent&&"fill-extrusion"!==e.type&&"building"!==e.type)return !1;const i="fill-extrusion"===e.type&&("building"===e.sourceLayer||"procedural_buildings"===e.sourceLayer),o="building"===e.type;if(e.is3D(!!this.terrain)){if(i||o||t&&"batched-model"===t.type)return !0;if("model"===e.type)return !0}else if("symbol"===e.type)return !0;return !1}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches");}getBOMObject(){}destroy(){this._clearWorkerCaches(),this.imageManager.imageAtlasCache.clear(),this.fragments.forEach(e=>{e.style._remove();}),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain);}}Po.getSourceType=function(e){return ft[e]},Po.setSourceType=function(e,t){ft[e]=t;},Po.registerForPluginStateChange=e.dC;var Oo="\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",zo="\n#ifdef DUAL_SOURCE_BLENDING\nlayout(location=0,index=0) out vec4 glFragColor;layout(location=0,index=1) out vec4 glFragColorSrc1;\n#else\nlayout(location=0) out vec4 glFragColor;\n#endif\n#ifdef USE_MRT1\nlayout(location=1) out vec4 out_Target1;\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;}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 vec3 u_indicator_cutout_centers;uniform vec4 u_indicator_cutout_params;\n#endif\nvec4 applyCutout(vec4 color,float height) {\n#ifdef INDICATOR_CUTOUT\nfloat verticalFadeRange=u_indicator_cutout_centers.z*0.25;float holeMinOpacity=mix(1.0,u_indicator_cutout_params.x,smoothstep(u_indicator_cutout_centers.z,u_indicator_cutout_centers.z+verticalFadeRange,height));float holeRadius=max(u_indicator_cutout_params.y,0.0);float holeAspectRatio=u_indicator_cutout_params.z;float fadeStart=u_indicator_cutout_params.w;float distA=distance(vec2(gl_FragCoord.x,gl_FragCoord.y*holeAspectRatio),vec2(u_indicator_cutout_centers[0],u_indicator_cutout_centers[1]*holeAspectRatio));return color*min(smoothstep(fadeStart,holeRadius,distA)+holeMinOpacity,1.0);\n#else\nreturn color;\n#endif\n}\n#ifdef DEBUG_WIREFRAME\n#define HANDLE_WIREFRAME_DEBUG \\\nglFragColor=vec4(0.7,0.0,0.0,0.7); \\\ngl_FragDepth=gl_FragCoord.z-0.0001;\n#else\n#define HANDLE_WIREFRAME_DEBUG\n#endif\n#ifdef RENDER_CUTOFF\nuniform highp vec4 u_cutoff_params;in float v_cutoff_opacity;\n#endif\nvec4 textureLodCustom(sampler2D image,highp vec2 pos,highp vec2 lod_coord) {highp vec2 size=vec2(textureSize(image,0));highp vec2 dx=dFdx(lod_coord.xy*size);highp vec2 dy=dFdy(lod_coord.xy*size);highp float delta_max_sqr=max(dot(dx,dx),dot(dy,dy));highp float lod=0.5*log2(delta_max_sqr);return textureLod(image,pos,lod);}vec4 applyLUT(highp sampler3D lut,vec4 col) {vec3 size=vec3(textureSize(lut,0));vec3 uvw=(col.rbg*float(size-1.0)+0.5)/size;return vec4(texture(lut,uvw).rgb*col.a,col.a);}vec3 applyLUT(highp sampler3D lut,vec3 col) {return applyLUT(lut,vec4(col,1.0)).rgb;}",Mo="\n#define EXTENT 8192.0\n#define RAD_TO_DEG 180.0/PI\n#define DEG_TO_RAD PI/180.0\n#define GLOBE_RADIUS EXTENT/PI/2.0\nfloat wrap(float n,float min,float max) {float d=max-min;float w=mod(mod(n-min,d)+d,d)+min;return (w==min) ? max : w;}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {\n#ifndef PROJECTED_POS_ON_VIEWPORT\nfloat tiles=tile_id.z;vec2 mercator=(tile_anchor/EXTENT+tile_id.xy)/tiles;mercator-=mercator_center;mercator.x=wrap(mercator.x,-0.5,0.5);vec4 mercator_tile=vec4(mercator.xy*EXTENT,EXTENT/(2.0*PI),1.0);mercator_tile=matrix*mercator_tile;return mercator_tile.xyz;\n#else\nreturn vec3(0.0);\n#endif\n}vec3 mix_globe_mercator(vec3 globe,vec3 mercator,float t) {return mix(globe,mercator,t);}mat3 globe_mercator_surface_vectors(vec3 pos_normal,vec3 up_dir,float zoom_transition) {vec3 normal=zoom_transition==0.0 ? pos_normal : normalize(mix(pos_normal,up_dir,zoom_transition));vec3 xAxis=normalize(vec3(normal.z,0.0,-normal.x));vec3 yAxis=normalize(cross(normal,xAxis));return mat3(xAxis,yAxis,normal);}\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(\nunpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const vec2 units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (units_to_pixels*pos+offset)/pattern_size;}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {return get_pattern_pos(pixel_coord_upper,pixel_coord_lower,pattern_size,vec2(tile_units_to_pixels),pos);}float mercatorXfromLng(float lng) {return (180.0+lng)/360.0;}float mercatorYfromLat(float lat) {return (180.0-(RAD_TO_DEG*log(tan(PI/4.0+lat/2.0*DEG_TO_RAD))))/360.0;}vec3 latLngToECEF(vec2 latLng) {latLng=DEG_TO_RAD*latLng;float cosLat=cos(latLng[0]);float sinLat=sin(latLng[0]);float cosLng=cos(latLng[1]);float sinLng=sin(latLng[1]);float sx=cosLat*sinLng*GLOBE_RADIUS;float sy=-sinLat*GLOBE_RADIUS;float sz=cosLat*cosLng*GLOBE_RADIUS;return vec3(sx,sy,sz);}\n#ifdef RENDER_CUTOFF\nuniform vec4 u_cutoff_params;out float v_cutoff_opacity;\n#endif\nconst vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);const float skirtOffset=24575.0;vec3 decomposeToPosAndSkirt(vec2 posWithComposedSkirt)\n{float skirt=float(posWithComposedSkirt.x >=skirtOffset);vec2 pos=posWithComposedSkirt-vec2(skirt*skirtOffset,0.0);return vec3(pos,skirt);}\n#ifndef HAS_SHADER_STORAGE_BLOCK_material_buffer\n#define GET_ATTRIBUTE_float(attrib,matInfo,attrib_id) attrib\n#define GET_ATTRIBUTE_vec4(attrib,matInfo,attrib_id) attrib\n#define GET_ATTRIBUTE_vec2(attrib,matInfo,attrib_id) attrib\n#define DECLARE_MATERIAL_TABLE_INFO\n#endif",Fo="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;}",ko="\n#define ELEVATION_SCALE 7.0\n#define ELEVATION_OFFSET 450.0\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix(\nmix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;}\n#else\nvec3 elevationVector(vec2 pos) { return vec3(0,0,1); }\n#endif\n#ifdef TERRAIN\nuniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;uniform vec2 u_dem_tl;uniform vec2 u_dem_tl_prev;uniform float u_dem_scale;uniform float u_dem_scale_prev;uniform float u_dem_size;uniform float u_dem_lerp;uniform float u_exaggeration;uniform float u_meter_to_dem;uniform mat4 u_label_plane_matrix_inv;vec4 tileUvToDemSample(vec2 uv,float dem_size,float dem_scale,vec2 dem_tl) {vec2 pos=dem_size*(uv*dem_scale+dem_tl)+1.0;vec2 f=fract(pos);return vec4((pos-f+0.5)/(dem_size+2.0),f);}float currentElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale+u_dem_tl)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture(u_dem,pos).r;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale,u_dem_tl);vec2 pos=r.xy;vec2 f=r.zw;float tl=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(dd,0)).r;float bl=texture(u_dem,pos+vec2(0,dd)).r;float br=texture(u_dem,pos+vec2(dd,dd)).r;return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}float prevElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale_prev+u_dem_tl_prev)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture(u_dem_prev,pos).r;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale_prev,u_dem_tl_prev);vec2 pos=r.xy;vec2 f=r.zw;float tl=texture(u_dem_prev,pos).r;float tr=texture(u_dem_prev,pos+vec2(dd,0)).r;float bl=texture(u_dem_prev,pos+vec2(0,dd)).r;float br=texture(u_dem_prev,pos+vec2(dd,dd)).r;return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}\n#ifdef TERRAIN_VERTEX_MORPHING\nfloat elevation(vec2 apos) {\n#ifdef ZERO_EXAGGERATION\nreturn 0.0;\n#endif\nfloat nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}\n#else\nfloat elevation(vec2 apos) {\n#ifdef ZERO_EXAGGERATION\nreturn 0.0;\n#endif\nreturn currentElevation(apos);}\n#endif\nvec4 fourSample(vec2 pos,vec2 off) {float tl=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(off.x,0.0)).r;float bl=texture(u_dem,pos+vec2(0.0,off.y)).r;float br=texture(u_dem,pos+off).r;return vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);}\n#else\nfloat elevation(vec2 pos) { return 0.0; }\n#endif\n#ifdef DEPTH_OCCLUSION\nuniform highp sampler2D u_depth;uniform highp vec2 u_depth_size_inv;uniform highp vec2 u_depth_range_unpack;uniform highp float u_occluder_half_size;uniform highp float u_occlusion_depth_offset;\n#ifdef DEPTH_D24\nfloat unpack_depth(float depth) {return depth*u_depth_range_unpack.x+u_depth_range_unpack.y;}vec4 unpack_depth4(vec4 depth) {return depth*u_depth_range_unpack.x+vec4(u_depth_range_unpack.y);}\n#else\nhighp float unpack_depth_rgba(vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}\n#endif\nbool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;\n#ifdef CLIP_ZERO_TO_ONE\ncoord.z=-1.0+2.0*coord.z; \n#endif\n#ifdef DEPTH_D24\nfloat depth=unpack_depth(texture(u_depth,(coord.xy+1.0)*0.5).r);\n#else\nfloat depth=unpack_depth_rgba(texture(u_depth,(coord.xy+1.0)*0.5));\n#endif\nreturn coord.z+u_occlusion_depth_offset > depth;}highp vec4 getCornerDepths(vec2 coord) {highp vec3 df=vec3(u_occluder_half_size*u_depth_size_inv,0.0);highp vec2 uv=0.5*coord.xy+0.5;\n#ifdef DEPTH_D24\nhighp vec4 depth=vec4(\ntexture(u_depth,uv-df.xz).r,texture(u_depth,uv+df.xz).r,texture(u_depth,uv-df.zy).r,texture(u_depth,uv+df.zy).r\n);depth=unpack_depth4(depth);\n#else\nhighp vec4 depth=vec4(\nunpack_depth_rgba(texture(u_depth,uv-df.xz)),unpack_depth_rgba(texture(u_depth,uv+df.xz)),unpack_depth_rgba(texture(u_depth,uv-df.zy)),unpack_depth_rgba(texture(u_depth,uv+df.zy))\n);\n#endif\nreturn depth;}highp float occlusionFadeMultiSample(vec4 frag) {highp vec3 coord=frag.xyz/frag.w;highp vec2 uv=0.5*coord.xy+0.5;\n#ifdef CLIP_ZERO_TO_ONE\ncoord.z=-1.0+2.0*coord.z; \n#endif\nint NX=3;int NY=4;highp vec2 df=u_occluder_half_size*u_depth_size_inv;highp vec2 oneStep=2.0*u_occluder_half_size*u_depth_size_inv/vec2(NX-1,NY-1);highp float res=0.0;for (int y=0; y < NY;++y) {for (int x=0; x < NX;++x) {\n#ifdef DEPTH_D24\nhighp float depth=unpack_depth(texture(u_depth,uv-df+vec2(float(x)*oneStep.x,float(y)*oneStep.y)).r);\n#else\nhighp float depth=unpack_depth_rgba(texture(u_depth,uv-df+vec2(float(x)*oneStep.x,float(y)*oneStep.y)));\n#endif\nres+=1.0-clamp(300.0*(coord.z+u_occlusion_depth_offset-depth),0.0,1.0);}}res=clamp(2.0*res/float(NX*NY)-0.5,0.0,1.0);return res;}highp float occlusionFade(vec4 frag) {highp vec3 coord=frag.xyz/frag.w;\n#ifdef CLIP_ZERO_TO_ONE\ncoord.z=-1.0+2.0*coord.z; \n#endif\nhighp vec4 depth=getCornerDepths(coord.xy);return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z+u_occlusion_depth_offset)-depth),0.0,1.0));}\n#else\nbool isOccluded(vec4 frag) { return false; }highp float occlusionFade(vec4 frag) { return 1.0; }highp float occlusionFadeMultiSample(vec4 frag) { return 1.0; }\n#endif",Bo="#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",No="#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;\n#ifdef FLIP_Y\nuv.y=1.0-uv.y;\n#endif\nhighp 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) {return color;}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}\n#endif",Uo="#ifdef RASTER_ARRAY\nuniform highp sampler2D u_image0;uniform sampler2D u_image1;const vec4 NODATA=vec4(1);ivec4 _raTexLinearCoord(highp vec2 texCoord,highp vec2 texResolution,out highp vec2 fxy) {texCoord=texCoord*texResolution-0.5;fxy=fract(texCoord);texCoord-=fxy;return ivec4(texCoord.xxyy+vec2(1.5,0.5).xyxy);}vec2 _raTexLinearMix(highp vec2 fxy,highp vec4 colorMix,highp float colorOffset,highp vec4 t00,highp vec4 t10,highp vec4 t01,highp vec4 t11) {vec2 c00=t00==NODATA ? vec2(0) : vec2(colorOffset+dot(t00,colorMix),1);vec2 c10=t10==NODATA ? vec2(0) : vec2(colorOffset+dot(t10,colorMix),1);vec2 c01=t01==NODATA ? vec2(0) : vec2(colorOffset+dot(t01,colorMix),1);vec2 c11=t11==NODATA ? vec2(0) : vec2(colorOffset+dot(t11,colorMix),1);return mix(mix(c01,c11,fxy.x),mix(c00,c10,fxy.x),fxy.y);}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",jo="#ifdef RASTER_ARRAY\nuniform sampler2D u_velocity;uniform mediump vec2 u_velocity_res;uniform mediump float u_max_speed;const vec4 NO_DATA=vec4(1);const vec2 INVALID_VELOCITY=vec2(-1);uniform highp vec2 u_uv_offset;uniform highp float u_data_offset;uniform highp vec2 u_data_scale;ivec4 rasterArrayLinearCoord(highp vec2 texCoord,highp vec2 texResolution,out highp vec2 fxy) {texCoord=texCoord*texResolution-0.5;fxy=fract(texCoord);texCoord-=fxy;return ivec4(texCoord.xxyy+vec2(1.5,0.5).xyxy);}highp vec2 lookup_velocity(highp vec2 uv) {uv=u_uv_offset.x+u_uv_offset.y*uv;highp vec2 fxy;ivec4 c=rasterArrayLinearCoord(uv,u_velocity_res,fxy);highp vec4 tl=texelFetch(u_velocity,c.yz,0);highp vec4 tr=texelFetch(u_velocity,c.xz,0);highp vec4 bl=texelFetch(u_velocity,c.yw,0);highp vec4 br=texelFetch(u_velocity,c.xw,0);if (tl==NO_DATA) {return INVALID_VELOCITY;}if (tr==NO_DATA) {return INVALID_VELOCITY;}if (bl==NO_DATA) {return INVALID_VELOCITY;}if (br==NO_DATA) {return INVALID_VELOCITY;}highp vec4 t=mix(mix(bl,br,fxy.x),mix(tl,tr,fxy.x),fxy.y);highp vec2 velocity=u_data_offset+vec2(dot(t.rg,u_data_scale),dot(t.ba,u_data_scale));velocity.y=-velocity.y;velocity/=max(u_max_speed,length(velocity));return velocity;}\n#endif\nuniform highp float u_particle_pos_scale;uniform highp vec2 u_particle_pos_offset;highp vec4 pack_pos_to_rgba(highp vec2 p) {highp vec2 v=(p+u_particle_pos_offset)/u_particle_pos_scale;highp vec4 r=vec4(v.x,fract(v.x*255.0),v.y,fract(v.y*255.0));return vec4(r.x-r.y/255.0,r.y,r.z-r.w/255.0,r.w);}highp vec2 unpack_pos_from_rgba(highp vec4 v) {v=floor(v*255.0+0.5)/255.0;highp vec2 p=vec2(v.x+(v.y/255.0),v.z+(v.w/255.0));return u_particle_pos_scale*p-u_particle_pos_offset;}",Vo="#ifdef RENDER_SHADOWS\nuniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_normal_offset;vec3 shadow_normal_offset(vec3 normal) {float tileInMeters=u_shadow_normal_offset[0];vec3 n=vec3(-normal.xy,tileInMeters*normal.z);float dotScale=min(1.0-dot(normal,u_shadow_direction),1.0)*0.5+0.5;return n*dotScale;}vec3 shadow_normal_offset_model(vec3 normal) {vec3 transformed_normal=vec3(-normal.xy,normal.z);float NDotL=dot(normalize(transformed_normal),u_shadow_direction);float dotScale=min(1.0-NDotL,1.0)*0.5+0.5;return normal*dotScale;}float shadow_normal_offset_multiplier0() {return u_shadow_normal_offset[1];}float shadow_normal_offset_multiplier1() {return u_shadow_normal_offset[2];}\n#endif",Go="#ifdef RENDER_SHADOWS\nprecision highp sampler2DShadow;uniform sampler2DShadow u_shadowmap_0;uniform sampler2DShadow u_shadowmap_1;uniform float u_shadow_intensity;uniform float u_shadow_map_resolution;uniform float u_shadow_texel_size;uniform highp vec3 u_shadow_normal_offset;uniform vec2 u_fade_range;uniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_bias;float shadow_sample(sampler2DShadow shadowmap,highp vec3 pos,highp float bias) {\n#ifdef CLIP_ZERO_TO_ONE\nhighp vec3 coord=vec3(pos.xy*0.5+0.5,pos.z-bias);\n#else\nhighp vec3 coord=vec3(pos.xy*0.5+0.5,pos.z*0.5+0.5-bias);\n#endif\nreturn texture(shadowmap,coord);}float shadow_occlusion(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,highp float bias) {light_view_pos0.xyz/=light_view_pos0.w;\n#ifdef SHADOWS_SINGLE_CASCADE\nvec2 abs_bounds=abs(light_view_pos0.xy);if (abs_bounds.x >=1.0 || abs_bounds.y >=1.0) {return 0.0;}return shadow_sample(u_shadowmap_0,light_view_pos0.xyz,bias);\n#else\nlight_view_pos1.xyz/=light_view_pos1.w;vec4 abs_bounds=abs(vec4(light_view_pos0.xy,light_view_pos1.xy));if (abs_bounds.x < 1.0 && abs_bounds.y < 1.0) {return shadow_sample(u_shadowmap_0,light_view_pos0.xyz,bias);}if (abs_bounds.z >=1.0 || abs_bounds.w >=1.0) {return 0.0;}float occlusion1=shadow_sample(u_shadowmap_1,light_view_pos1.xyz,bias);return clamp(mix(occlusion1,0.0,smoothstep(u_fade_range.x,u_fade_range.y,view_depth)),0.0,1.0);\n#endif\n}highp float calculate_shadow_bias(float NDotL) {\n#ifdef NORMAL_OFFSET\nreturn 0.5*u_shadow_bias.x;\n#else\nreturn 0.5*(u_shadow_bias.x+clamp(u_shadow_bias.y*tan(acos(NDotL)),0.0,u_shadow_bias.z));\n#endif\n}float shadowed_light_factor_normal(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=calculate_shadow_bias(NDotL);float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor_normal_opacity(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,float shadow_opacity) {float NDotL=dot(N,u_shadow_direction);float bias=calculate_shadow_bias(NDotL);float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias)*shadow_opacity;return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor_normal_unbiased(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}highp vec2 compute_receiver_plane_depth_bias(highp vec3 pos_dx,highp vec3 pos_dy)\n{highp vec2 biasUV=vec2(\npos_dy.y*pos_dx.z-pos_dx.y*pos_dy.z,pos_dx.x*pos_dy.z-pos_dy.x*pos_dx.z);biasUV*=1.0/((pos_dx.x*pos_dy.y)-(pos_dx.y*pos_dy.x));return biasUV;}float shadowed_light_factor_plane_bias(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {highp vec3 light_view_pos0_xyz=light_view_pos0.xyz/light_view_pos0.w*0.5+0.5;highp vec3 light_view_pos0_ddx=dFdx(light_view_pos0_xyz);highp vec3 light_view_pos0_ddy=dFdy(light_view_pos0_xyz);highp vec2 plane_depth_bias=compute_receiver_plane_depth_bias(light_view_pos0_ddx,light_view_pos0_ddy);highp float bias=dot(vec2(u_shadow_texel_size,u_shadow_texel_size),plane_depth_bias)+0.0001;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return 1.0-(u_shadow_intensity*occlusion);}float shadowed_light_factor(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return 1.0-(u_shadow_intensity*occlusion);}float shadow_occlusion(float ndotl,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=calculate_shadow_bias(ndotl);return shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);}\n#endif";const Ho=/#include\s+"([^"]+)"/g,qo=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g,Zo=/\b[A-Za-z_][A-Za-z0-9_]*\b/g,Wo=new Set(["ifdef","ifndef","elif","if","defined"]),$o=new Set;is(Oo,$o),is(Mo,$o),is(zo,$o);const Xo={"_prelude_fog.vertex.glsl":Bo,"_prelude_terrain.vertex.glsl":ko,"_prelude_shadow.vertex.glsl":Vo,"_prelude_material_table.vertex.glsl":"#ifdef HAS_SHADER_STORAGE_BLOCK_material_buffer\n#define MATERIAL_TABLE_DEBUG 0\nuniform int u_material_offset;uniform int u_vertex_offset;layout(std140,binding=0)readonly buffer material_buffer{uvec4 material_data[];};struct MaterialInfo{uint dataOffset;\n#if MATERIAL_TABLE_DEBUG\nvec4 colorDebug;\n#endif\n};uint read_buf_no_offset(uint iDword) {return material_data[iDword/4u][iDword % 4u];}uint read_buf(uint iDword) {iDword+=uint(u_material_offset/4);return read_buf_no_offset(iDword);}float read_buf_float(uint iDword){return uintBitsToFloat(read_buf(iDword));}uint read_buf_uint8(uint iDword,uint iUint8){uint dwordOffset=iDword+(iUint8/4u);uint byteOffset=iUint8 & 3u;uint bitOffset=8u*byteOffset;uint mask=0xffu << bitOffset;uint dwordVal=read_buf(dwordOffset);return (dwordVal & mask) >> bitOffset;}uint read_buf_uint16(uint iDword,uint iUint16){uint dwordOffset=iDword+(iUint16 >> 1u);uint bitOffset=(iUint16 & 1u)*16u;uint mask=0xffffu << bitOffset;uint dwordVal=read_buf(dwordOffset);return (dwordVal & mask) >> bitOffset;}uint nrDwordsForVertexIdEntries(uint nrMaterialLookupEntries) {return nrMaterialLookupEntries;}uint nrDwordsForMaterialIdEntries(uint nrMaterialLookupEntries) {return (nrMaterialLookupEntries*2u+3u)/4u;}uint findRangeBinarySearch(uint vertexId,uint numRanges,uint dwordOffset) {uint left=0u;uint right=numRanges-1u;for (uint i=0u; i < 16u; i++) { \nif (left > right) {break;}uint mid=(left+right)/2u;uint start=read_buf(dwordOffset+mid);uint nextStart=(mid+1u < numRanges) ? read_buf(dwordOffset+mid+1u) : 0xffffffffu;if (vertexId >=start && vertexId < nextStart) {return mid;} else if (vertexId < start) {if (mid==0u) {break;}right=mid-1u;} else {left=mid+1u;}}return 0u; \n}uint readVertexId(uint dwordOffset,uint iMaterialLookupEntry) {return read_buf(dwordOffset+iMaterialLookupEntry);}uint findRange(uint vertexId,uint numRanges,uint dwordOffset) {uint iRange;if(numRanges <=64u){uint vertexBegin;for(iRange=0u; iRange < numRanges;++iRange) {vertexBegin=readVertexId(dwordOffset,iRange);if(vertexBegin > vertexId) {break;}}iRange=iRange==0u? 0u : iRange-1u;} else { \niRange=findRangeBinarySearch(vertexId,numRanges,dwordOffset);}return iRange;}MaterialInfo read_material_info(uint vertex_id) {MaterialInfo info;\n#if MATERIAL_TABLE_DEBUG\nconst vec4 red=vec4(1.0,0.0,0.0,1.0);const vec4 orange=vec4(1.0,0.5,0.0,1.0);const vec4 yellow=vec4(1.0,1.0,0.0,1.0);const vec4 green=vec4(0.0,1.0,0.0,1.0);const vec4 indigo=vec4(0.294,0.0,0.510,1.0);const vec4 blue=vec4(0.0,0.0,1.0,1.0);const vec4 purple=vec4(0.5,0.0,0.5,1.0);const vec4 pink=vec4(1.0,0.0,1.0,1.0);info.colorDebug=green;\n#endif\nuint offset=0u;\n#if MATERIAL_TABLE_DEBUG\nbool keepFinding=true;uint magic=read_buf(offset);if(magic !=0xCAFEBABEu) {info.colorDebug=red;keepFinding=false;return info;}\n#endif\noffset++;\n#if MATERIAL_TABLE_DEBUG\nuint nrMaterials=read_buf(offset);uint nrVertices=read_buf(offset+1u);if(keepFinding && vertex_id >=nrVertices) {info.colorDebug=red;keepFinding=false;}\n#endif\noffset+=2u;uint nrMaterialLookupEntries=read_buf(offset++);uint perMaterialEntrySizeDwords=read_buf(offset++);\n#if MATERIAL_TABLE_DEBUG\nif(keepFinding && perMaterialEntrySizeDwords !=1u) {info.colorDebug=red;keepFinding=false;}\n#endif\nuint iMaterialLookup=findRange(vertex_id,nrMaterialLookupEntries,offset);\n#if MATERIAL_TABLE_DEBUG\nif(keepFinding)\n{uint vertexBeginCheck=readVertexId(offset,iMaterialLookup);if(vertexBeginCheck > vertex_id) {info.colorDebug=red;keepFinding=false;}if(iMaterialLookup < nrMaterialLookupEntries-1u) {uint vertexEndCheck=readVertexId(offset,iMaterialLookup+1u);if(vertexEndCheck <=vertex_id) {info.colorDebug=red;keepFinding=false;}}}\n#endif\noffset+=nrDwordsForVertexIdEntries(nrMaterialLookupEntries);uint materialId=iMaterialLookup;\n#if MATERIAL_TABLE_DEBUG\nif(keepFinding) {if(materialId >=nrMaterialLookupEntries) {info.colorDebug=red;}}\n#endif\ninfo.dataOffset=offset+materialId*perMaterialEntrySizeDwords;return info;}uint get_data_location(const MaterialInfo matInfo,uint attribOffsetBytes)\n{uint attribFieldOffsetDwords=attribOffsetBytes/4u;return matInfo.dataOffset+attribFieldOffsetDwords;}vec4 read_material_vec4(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return vec4(read_buf_float(loc),read_buf_float(loc+1u),read_buf_float(loc+2u),read_buf_float(loc+3u));}vec2 read_material_vec2(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return vec2(read_buf_float(loc),read_buf_float(loc+1u));}float read_material_float(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return read_buf_float(loc);}\n#define GET_ATTRIBUTE_float(attrib,matInfo,attrib_offset) read_material_float(matInfo,attrib_offset)\n#define GET_ATTRIBUTE_vec4(attrib,matInfo,attrib_offset) read_material_vec4(matInfo,attrib_offset)\n#define GET_ATTRIBUTE_vec2(attrib,matInfo,attrib_offset) read_material_vec2(matInfo,attrib_offset)\n#define DECLARE_MATERIAL_TABLE_INFO MaterialInfo materialInfo=read_material_info(uint(gl_VertexID));\n#define DECLARE_MATERIAL_TABLE_INFO_DEBUG(dbgColor) MaterialInfo materialInfo=read_material_info(uint(gl_VertexID)); dbgColor=materialInfo.colorDebug;\n#endif","_prelude_fog.fragment.glsl":No,"_prelude_shadow.fragment.glsl":Go,"_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","_prelude_raster_array.glsl":Uo,"_prelude_raster_particle.glsl":jo},Ko={};os("",ko),os(No,Bo),os(Go,Vo),os(Uo,""),os(jo,"");const Yo=os(zo,Mo),Jo=Oo,Qo=["\n#if defined(GL_EXT_blend_func_extended) && defined(DUAL_SOURCE_BLENDING)\n#extension GL_EXT_blend_func_extended : require\n#endif","precision mediump float;",Jo,Yo.fragmentSource].join("\n"),es=["precision highp float;",Jo,Yo.vertexSource].join("\n");var ts={background:os('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec4 u_color;uniform float u_opacity;uniform mediump float u_emissive_strength;\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 USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\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;uniform mediump float u_emissive_strength;\n#ifdef LIGHTING_3D_MODE\nuniform mediump vec4 u_color;out vec4 v_color;\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:os('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_pattern_tl;uniform vec2 u_pattern_br;uniform vec2 u_texsize;uniform float u_opacity;uniform float u_emissive_strength;uniform sampler2D u_image;in highp vec2 v_pos;void main() {highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(u_pattern_tl/u_texsize,u_pattern_br/u_texsize,imagecoord);vec4 out_color=textureLodCustom(u_image,pos,v_pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*u_opacity;\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\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 vec2 u_pattern_size;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec2 u_pattern_units_to_pixels;in vec2 a_pos;out highp vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_pattern_size,u_pattern_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),building:os('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nconst float window_depth=0.5;const float ao_radius=0.2;in vec4 v_color;in highp vec3 v_normal;in highp vec3 v_pos;\n#ifdef BUILDING_FAUX_FACADE\nin lowp float v_faux_facade;in highp float v_faux_facade_ed;in highp vec2 v_faux_facade_window;in highp vec2 v_faux_facade_floor;in highp vec2 v_faux_facade_range;in highp float v_aspect;in highp vec3 v_tbn_0;in highp vec3 v_tbn_1;in highp vec3 v_tbn_2;in highp vec4 v_faux_color_emissive;uniform float u_faux_facade_ao_intensity;\n#endif\n#ifdef RENDER_SHADOWS\nin highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;\n#endif\n#ifdef FLOOD_LIGHT\nin highp float v_flood_radius;in float v_has_flood_light;\n#endif\nuniform lowp float u_opacity;uniform vec3 u_camera_pos;uniform highp float u_tile_to_meter;uniform float u_facade_emissive_chance;uniform vec3 u_flood_light_color;uniform float u_flood_light_intensity;vec3 linearTosRGB(in vec3 color) {return pow(color,vec3(1./2.2));}\n#ifdef BUILDING_FAUX_FACADE\nfloat hash12(in vec2 p) {vec3 p3 =fract(vec3(p.xyx)*0.1031);p3+=dot(p3,p3.yzx+33.33);return fract((p3.x+p3.y)*p3.z);}float min3(in vec3 v) {return min(min(v.x,v.y),v.z);}vec2 get_uv_mask_id(in vec2 q,out float mask,out vec2 id) {vec2 p=q;mask=step(v_faux_facade_range.x,p.y)*step(p.y,v_faux_facade_range.y);p.y=p.y-v_faux_facade_range.x;vec2 uv=modf(p/v_faux_facade_floor,id);vec4 d=(v_faux_facade_floor.xyxy+vec4(-v_faux_facade_window,v_faux_facade_window))*0.5;vec4 edge=d/v_faux_facade_floor.xyxy;vec2 m=step(edge.xy,uv)*step(uv,edge.zw);mask*=m.x*m.y;uv-=vec2(0.5);uv*=vec2(0.5)/(vec2(0.5)-edge.xy);uv+=vec2(0.5);return uv;}float ray_unit_box(in vec3 ray_o,in vec3 ray_d,in vec3 bmin,in vec3 bmax) {vec3 planes=mix(bmin,bmax,step(0.0,ray_d));vec3 t=(planes-ray_o)/ray_d;return min3(t);}float get_emissive(in vec2 id) {if (u_facade_emissive_chance > 0.0) {return (step(hash12(id),u_facade_emissive_chance)+0.05)*v_faux_color_emissive.a;}return 0.0;}vec3 get_shade_info(in vec3 v,in vec3 v_normalized,in vec3 color,in vec2 id,in mat3 tbn,inout vec3 out_normal,inout float out_emissive) {vec3 out_color=color;vec3 abs_v=abs(v_normalized);bool x_major=abs_v.x >=abs_v.y && abs_v.x >=abs_v.z;bool y_major=abs_v.y >=abs_v.x && abs_v.y >=abs_v.z;bool z_major=abs_v.z >=abs_v.x && abs_v.z >=abs_v.y;\n#if 0\nif (x_major) {out_color=v.x > 0.0 ? vec3(1.0,0.0,0.0) : vec3(0.0,1.0,1.0);} else if (y_major) {out_color=v.y > 0.0 ? vec3(0.0,1.0,0.0) : vec3(1.0,0.0,1.0);} else if (z_major) {out_color=v.z > 0.0 ? vec3(0.0,0.0,1.0) : vec3(1.0,1.0,0.0);}out_emissive=1.0;\n#else\nif (x_major) {out_normal=-sign(v.x)*tbn[0];} else if (y_major) {out_normal=vec3(0.0,0.0,-sign(v.y));} else if (z_major) {out_color=v_faux_color_emissive.rgb;out_emissive=v.z <=0.0 ? get_emissive(id) : out_emissive;}float ao=1.0;if (u_faux_facade_ao_intensity > 0.0) {vec4 ao_range=v_faux_facade_window.xxyy*0.5-vec4(0,ao_radius,0,ao_radius);vec2 ao_range_z=vec2(window_depth*0.5)-vec2(0.0,ao_radius);if (x_major || y_major) {ao*=smoothstep(-ao_range_z.x,-ao_range_z.y,v.z);} else if (z_major) {ao*=smoothstep(-ao_range.x,-ao_range.y,v.x)*(1.0-smoothstep(ao_range.y,ao_range.x,v.x));ao*=smoothstep(-ao_range.z,-ao_range.w,v.y)*(1.0-smoothstep(ao_range.w,ao_range.z,v.y));}ao=mix(1.0,min(1.0,ao+0.25),u_faux_facade_ao_intensity);}out_color*=ao;\n#endif\nreturn out_color;}\n#endif\nvec3 apply_lighting_linear(in vec3 color,in vec3 normal,in float dir_factor) {float ambient_directional_factor=calculate_ambient_directional_factor(normal);vec3 ambient_contrib=ambient_directional_factor*u_lighting_ambient_color;vec3 directional_contrib=u_lighting_directional_color*dir_factor;return color*(ambient_contrib+directional_contrib);}void main() {vec3 normal=normalize(v_normal);vec3 base_color=v_color.rgb;float emissive=v_color.a;\n#ifdef BUILDING_FAUX_FACADE\nif (v_faux_facade > 0.0) {mat3 tbn=mat3(v_tbn_0,v_tbn_1,v_tbn_2);vec3 v=vec3(v_pos.xy,v_pos.z/u_tile_to_meter)-u_camera_pos;vec3 view_tangent=transpose(tbn)*v;vec2 q=vec2(v_faux_facade_ed,v_pos.z);float mask=0.0;vec2 id=vec2(0.0);vec2 uv=get_uv_mask_id(q,mask,id);uv*=v_faux_facade_window;vec3 bmin=vec3(0.0,0.0,-window_depth);vec3 bmax=bmin+vec3(v_faux_facade_window,window_depth);vec3 ray_o=vec3(uv,0.0);vec3 ray_d=normalize(view_tangent);float t_min=ray_unit_box(ray_o,ray_d,bmin,bmax);vec3 hit=ray_o+t_min*ray_d;vec3 r=vec3(v_faux_facade_window,-window_depth);hit-=r*0.5;vec3 normalized=hit/r;vec3 out_normal=normal;float out_emissive=emissive;vec3 room_color=get_shade_info(hit,normalized,base_color,id,tbn,out_normal,out_emissive);base_color=mix(base_color,room_color,mask);normal=mix(normal,out_normal,mask);emissive=mix(emissive,out_emissive,mask);}\n#endif\nvec4 color=vec4(base_color,1.0);vec3 xy_flipped_normal=vec3(-normal.xy,normal.z);float shadowed_lighting_factor=0.0;\n#ifdef RENDER_SHADOWS\n#ifdef RENDER_CUTOFF\nshadowed_lighting_factor=shadowed_light_factor_normal_opacity(xy_flipped_normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,v_cutoff_opacity);if (v_cutoff_opacity==0.0) {discard;}\n#else\nshadowed_lighting_factor=shadowed_light_factor_normal(xy_flipped_normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);\n#endif\n#else\nshadowed_lighting_factor=max(0.0,dot(xy_flipped_normal,u_lighting_directional_dir));\n#endif\ncolor.rgb=apply_lighting_linear(color.rgb,xy_flipped_normal,shadowed_lighting_factor);color.rgb=linearTosRGB(color.rgb);\n#ifdef FLOOD_LIGHT\nfloat flood_radiance=(1.0-min(v_pos.z/v_flood_radius,1.0))*u_flood_light_intensity*v_has_flood_light;color.rgb=mix(color.rgb,u_flood_light_color,flood_radiance);\n#endif\ncolor.rgb=mix(color.rgb,linearTosRGB(base_color.rgb),emissive);\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos,v_pos.z));\n#endif\ncolor*=u_opacity;\n#ifdef INDICATOR_CUTOUT\ncolor=applyCutout(color,v_pos.z);\n#endif\n#ifdef FEATURE_CUTOUT\ncolor=apply_feature_cutout(color,gl_FragCoord);\n#endif\nglFragColor=color; \n#ifdef DEBUG_SHOW_NORMALS\ncolor.rgb=xy_flipped_normal*0.5+vec3(0.5,0.5,0.5);color.a=1.0;glFragColor=color;\n#endif\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;in vec3 a_normal_3;in vec3 a_centroid_3;in float a_flood_light_wall_radius_1i16;in vec4 a_faux_facade_data;in vec2 a_faux_facade_vertical_range;uniform mat4 u_matrix;uniform mat4 u_normal_matrix;uniform highp float u_tile_to_meter;out vec4 v_color;out vec3 v_normal;out highp vec3 v_pos;\n#ifdef BUILDING_FAUX_FACADE\nout lowp float v_faux_facade;out highp float v_faux_facade_ed;out highp vec2 v_faux_facade_window;out highp vec2 v_faux_facade_floor;out highp vec2 v_faux_facade_range;out highp float v_aspect;out highp vec3 v_tbn_0;out highp vec3 v_tbn_1;out highp vec3 v_tbn_2;out highp vec4 v_faux_color_emissive;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;\n#endif\n#ifdef FLOOD_LIGHT\nout highp float v_flood_radius;out float v_has_flood_light;\n#endif\nconst float MAX_UINT_16=65535.0;const float MAX_INT_16=32767.0;const float MAX_UINT_8=255.0;const float TWO_POW_8=256.0;const float FLOOD_LIGHT_MAX_RADIUS_METER=2048.0;vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}\n#ifdef BUILDING_FAUX_FACADE\nmat3 get_tbn(in vec3 normal) {const vec3 bitangent=vec3(0.0,0.0,1.0);vec3 tangent=normalize(vec3(normal.y,-normal.x,0.0));return mat3(tangent,bitangent,normal);}\n#endif\n#pragma mapbox: define-attribute-vertex-shader-only highp vec2 part_color_emissive\n#pragma mapbox: define-attribute-vertex-shader-only highp vec2 faux_facade_color_emissive\nvoid main() {\n#pragma mapbox: initialize-attribute-custom highp vec2 part_color_emissive\n#pragma mapbox: initialize-attribute-custom highp vec2 faux_facade_color_emissive\n#ifdef FLOOD_LIGHT\nv_flood_radius=(a_flood_light_wall_radius_1i16/MAX_INT_16*FLOOD_LIGHT_MAX_RADIUS_METER);v_has_flood_light=step(0.0,v_flood_radius);\n#endif\nvec4 color_emissive=decode_color(part_color_emissive);v_color=vec4(sRGBToLinear(color_emissive.rgb),color_emissive.a);vec3 a_normal_3f=a_normal_3/MAX_INT_16;v_normal=vec3(u_normal_matrix*vec4(a_normal_3f,0.0));float hidden=0.0;float depth_offset=0.0;\n#ifdef BUILDING_FAUX_FACADE\nv_faux_facade=a_faux_facade_data.x;if (v_faux_facade > 0.0) {v_faux_facade_ed=a_faux_facade_data.x *u_tile_to_meter;float window_x_perc=floor(a_faux_facade_data.y/TWO_POW_8);float window_y_perc=a_faux_facade_data.y-TWO_POW_8*window_x_perc;vec2 window_perc=vec2(window_x_perc,window_y_perc)/MAX_UINT_8;v_faux_facade_floor=(a_faux_facade_data.zw/MAX_UINT_16*EXTENT)*u_tile_to_meter;v_faux_facade_window=window_perc*v_faux_facade_floor;v_faux_facade_range=(a_faux_facade_vertical_range/MAX_UINT_16*EXTENT)*u_tile_to_meter;v_aspect=v_faux_facade_window.x/v_faux_facade_window.y;mat3 tbn=get_tbn(normalize(v_normal));v_tbn_0=tbn[0];v_tbn_1=tbn[1];v_tbn_2=tbn[2];v_faux_color_emissive=decode_color(faux_facade_color_emissive);v_faux_color_emissive.rgb=sRGBToLinear(v_faux_color_emissive.rgb);float height=a_centroid_3.z;depth_offset=min(1000.0,height)*0.0000002;}\n#endif\nv_pos=a_pos_3f;\n#ifdef RENDER_CUTOFF\nvec4 ground=u_matrix*vec4(a_centroid_3,1.0);v_cutoff_opacity=cutoff_opacity(u_cutoff_params,ground.z);hidden=float(v_cutoff_opacity==0.0);v_pos.z*=v_cutoff_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nvec3 shadow_pos=v_pos;\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset_model(v_normal);shadow_pos+=offset*shadow_normal_offset_multiplier0();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shadow_pos,1.0);v_pos_light_view_1=u_light_matrix_1*vec4(shadow_pos,1.0);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(v_pos);\n#endif\ngl_Position=mix(u_matrix*vec4(v_pos,1),AWAY,hidden);gl_Position.z-=depth_offset*gl_Position.w;}'),buildingBloom:os("in vec4 v_color_emissive;\n#pragma mapbox: define-attribute highp vec4 bloom_attenuation\n#pragma mapbox: initialize-attribute highp vec4 bloom_attenuation\nfloat saturate(float val) {return clamp(val,0.0,1.0);}void main() {float emission=v_color_emissive.a;float opacity=1.0;\n#ifdef HAS_ATTRIBUTE_a_bloom_attenuation\nfloat distance=length(vec2(1.3*max(0.0,abs(bloom_attenuation.x)-bloom_attenuation.z),bloom_attenuation.y));distance+= mix(0.5,0.0,clamp(emission-1.0,0.0,1.0));opacity*=saturate(1.0-distance*distance);\n#endif\n#ifdef RENDER_CUTOFF\nopacity*=v_cutoff_opacity;\n#endif\nglFragColor=vec4(v_color_emissive.rgb,1.0)*opacity;}","in vec3 a_pos_3f;\n#pragma mapbox: define-attribute-vertex-shader-only highp vec2 part_color_emissive\n#pragma mapbox: define-attribute highp vec4 bloom_attenuation\nout vec4 v_color_emissive;uniform mat4 u_matrix;vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() {\n#pragma mapbox: initialize-attribute-custom highp vec2 part_color_emissive\n#pragma mapbox: initialize-attribute highp vec4 bloom_attenuation\n#ifdef HAS_ATTRIBUTE_a_part_color_emissive\nvec4 color_emissive=decode_color(part_color_emissive);float part_emissive=color_emissive.a*5.0;v_color_emissive=vec4(sRGBToLinear(color_emissive.rgb),part_emissive);\n#else\nv_color_emissive=vec4(1.0);\n#endif\ngl_Position=u_matrix*vec4(a_pos_3f,1.0);\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n}"),buildingDepth:os("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;void main() {gl_Position=u_matrix*vec4(a_pos_3f,1.0);v_depth=gl_Position.z/gl_Position.w;}"),circle:os('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nin vec3 v_data;in float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nuniform float u_emissive_strength;void main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float blur_positive=blur < 0.0 ? 0.0 : 1.0;lowp float antialiasblur=v_data.z;float extrude_length=length(extrude)+antialiasblur*(1.0-blur_positive);float antialiased_blur=-max(abs(blur),antialiasblur);float antialiase_blur_opacity=smoothstep(0.0,antialiasblur,extrude_length-1.0);float opacity_t=blur_positive==1.0 ? \nsmoothstep(0.0,-antialiased_blur,1.0-extrude_length) : \nsmoothstep(antialiased_blur,0.0,extrude_length-1.0)-antialiase_blur_opacity;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\n#ifdef ELEVATED_ROADS\nin float a_circle_z_offset;\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() {\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\n#ifdef ELEVATED_ROADS\nworld_center.z+=a_circle_z_offset+ELEVATION_BIAS;\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:os("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:os('#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() {\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:os("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:os("in float v_placed;in float v_notUsed;void main() {vec4 red =vec4(1.0,0.0,0.0,1.0);vec4 blue=vec4(0.0,0.0,1.0,0.5);glFragColor =mix(red,blue,step(0.5,v_placed))*0.5;glFragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}",'#include "_prelude_terrain.vertex.glsl"\nin vec3 a_pos;in vec2 a_anchor_pos;in vec2 a_extrude;in vec2 a_placed;in vec2 a_shift;in vec2 a_elevation_from_sea;in float a_size_scale;in vec2 a_padding;in float a_auto_z_offset;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform float u_zoom_transition;\n#endif\nout float v_placed;out float v_notUsed;void main() {float feature_elevation=a_elevation_from_sea.x+a_auto_z_offset;float terrain_elevation=(a_elevation_from_sea.y==1.0 ? 0.0 : elevation(a_anchor_pos));vec3 proj_pos=a_pos+elevationVector(a_anchor_pos)*(feature_elevation+terrain_elevation);\n#ifdef PROJECTION_GLOBE_VIEW\n#ifndef PROJECTED_POS_ON_VIEWPORT\nvec3 globe_pos=proj_pos;vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,a_anchor_pos,u_tile_id,u_merc_center);proj_pos=mix_globe_mercator(globe_pos,mercator_pos,u_zoom_transition);\n#endif\n#endif\nvec4 projectedPoint=u_matrix*vec4(proj_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:os("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:os("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}'),elevatedStructuresDepth:os("void main() {\n#ifndef DEPTH_TEXTURE\nglFragColor=vec4(0.);\n#endif\n}","in vec2 a_pos;in float a_height;uniform mat4 u_matrix;uniform float u_depth_bias;void main() {gl_Position=u_matrix*vec4(a_pos,a_height,1);gl_Position.z=gl_Position.z+u_depth_bias;}"),elevatedStructuresDepthReconstruct:os("#ifdef DEPTH_RECONSTRUCTION\nin float v_height;\n#endif\nvoid main() {\n#ifdef DEPTH_RECONSTRUCTION\nif (v_height >=0.0)\ndiscard;\n#else\n#ifdef FEATURE_CUTOUT\napply_feature_cutout(vec4(0.0,0.0,0.0,1.0),gl_FragCoord);\n#endif\n#endif\nglFragColor=vec4(1.0,0.0,0.0,1.0);}","in vec2 a_pos;in float a_height;uniform mat4 u_matrix;uniform vec3 u_camera_pos;uniform highp float u_depth_bias;uniform lowp float u_height_scale;uniform lowp float u_reset_depth;\n#ifdef DEPTH_RECONSTRUCTION\nout float v_height;\n#endif\nvoid main() {vec3 vpos=vec3(a_pos,a_height*u_height_scale);\n#ifdef DEPTH_RECONSTRUCTION\nif (u_camera_pos.z > vpos.z) {vpos-=(u_camera_pos-vpos)*(vpos.z/(u_camera_pos.z-vpos.z));}v_height=a_height;\n#endif\ngl_Position=u_matrix*vec4(vpos,1);gl_Position.z=u_reset_depth==1.0 ? gl_Position.w : gl_Position.z+u_depth_bias;}"),elevatedStructures:os('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nin vec3 v_normal;in float v_height;\n#ifdef RENDER_SHADOWS\nin highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in float v_depth;\n#endif\nvec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}vec3 compute_view_dependent_emissive_color(float ndotl,float emissive_strength,vec3 color)\n{color=sRGBToLinear(color);color=color*(ndotl+(1.0-min(ndotl*57.29,1.0))*emissive_strength);color=linearTosRGB(color.rgb);return color;}uniform float u_emissive_strength;\n#pragma mapbox: define highp vec4 structure_color\nvoid main() {\n#pragma mapbox: initialize highp vec4 structure_color\nvec3 color=structure_color.xyz;\n#ifdef LIGHTING_3D_MODE\nvec3 normal=normalize(v_normal);vec3 transformed_normal=vec3(-normal.xy,normal.z);float ndotl=calculate_NdotL(transformed_normal);float emissive_strength=u_emissive_strength;emissive_strength=0.0;vec3 emissive_color=compute_view_dependent_emissive_color(ndotl,emissive_strength,color.xyz);\n#ifdef RENDER_SHADOWS\nfloat shadowed_lighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth);color.rgb=apply_lighting(color.rgb,transformed_normal,shadowed_lighting_factor);\n#else\ncolor=apply_lighting(color,transformed_normal);\n#endif\ncolor=mix(color,emissive_color,emissive_strength);if (v_height < 0.0) {float penetration=max(v_height+7.5,0.0);float occlusion=1.0-1.0/PI*acos(1.0-penetration/4.0);color=color*(1.0-pow(occlusion,2.0)*0.3);}\n#endif\n#ifdef FOG\ncolor=fog_apply(color,v_fog_pos);\n#endif\nvec4 out_color=vec4(color,1.0);\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color,v_height);\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord);\n#endif\nglFragColor=out_color;HANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin vec2 a_pos;in float a_height;in vec3 a_pos_normal_3;uniform mat4 u_matrix;out vec3 v_normal;out float v_height;\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out float v_depth;\n#endif\n#pragma mapbox: define highp vec4 structure_color\nvoid main() {\n#pragma mapbox: initialize highp vec4 structure_color\nv_normal=a_pos_normal_3/16384.0;v_height=a_height;vec3 pos=vec3(a_pos,a_height);gl_Position=u_matrix*vec4(pos,1);\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=pos;vec3 shd_pos1=pos;\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(vec3(-v_normal.xy,v_normal.z));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\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);v_depth=gl_Position.w;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fill:os('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nuniform float u_emissive_strength;\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\n#ifdef ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\n#ifdef INDICATOR_CUTOUT\nin highp float v_z_offset;\n#endif\nvoid 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#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nout_color*=opacity;\n#ifdef INDICATOR_CUTOUT\nif (v_z_offset >=0.0) {out_color=applyCutout(out_color,v_z_offset);}\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord);\n#endif\nglFragColor=out_color;\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\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 vec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;out highp float v_road_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\n#ifdef INDICATOR_CUTOUT\nout highp float v_z_offset;\n#endif\nuniform mat4 u_matrix;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp float z_offset\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;v_road_z_offset=z_offset;\n#endif\nfloat hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset);\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\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);v_depth=gl_Position.w;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n#ifdef INDICATOR_CUTOUT\nv_z_offset=z_offset;\n#endif\n}'),fillOutline:os('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nin highp vec2 v_pos;uniform float u_emissive_strength;\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\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#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord);\n#endif\nglFragColor=out_color*(alpha*opacity);\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\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 vec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\nuniform mat4 u_matrix;uniform vec2 u_world;out highp vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp float z_offset\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;\n#endif\nfloat hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);\n#ifdef FLIP_Y\nv_pos=(vec2(gl_Position.x,-gl_Position.y)/gl_Position.w+1.0)/2.0*u_world;\n#else\nv_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#endif\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset);\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\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);v_depth=gl_Position.w;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillOutlinePattern:os('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;\n#ifdef FILL_PATTERN_TRANSITION\nuniform float u_pattern_transition;\n#endif\nuniform float u_emissive_strength;\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\nin highp vec2 v_pos;in highp vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 pattern_b\n#endif\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump vec4 pattern_b\n#endif\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);float dist=length(v_pos_world-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef APPLY_LUT_ON_GPU\nout_color=applyLUT(u_lutTexture,out_color);\n#endif\n#ifdef FILL_PATTERN_TRANSITION\nvec2 pattern_b_tl=pattern_b.xy;vec2 pattern_b_br=pattern_b.zw;highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord);\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 USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in vec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\nout highp vec2 v_pos;out highp vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 pattern_b\n#endif\n#pragma mapbox: define lowp float pixel_ratio\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump vec4 pattern_b\n#endif\n#pragma mapbox: initialize lowp float pixel_ratio\n#pragma mapbox: initialize highp float z_offset\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;\n#endif\nfloat hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);\n#ifdef FLIP_Y\nv_pos_world=(vec2(gl_Position.x,-gl_Position.y)/gl_Position.w+1.0)/2.0*u_world;\n#else\nv_pos_world=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#endif\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset);\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\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);v_depth=gl_Position.w;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillPattern:os('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;\n#ifdef FILL_PATTERN_TRANSITION\nuniform float u_pattern_transition;\n#endif\nin highp vec2 v_pos;uniform float u_emissive_strength;\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\n#ifdef ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 pattern_b\n#endif\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump vec4 pattern_b\n#endif\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef APPLY_LUT_ON_GPU\nout_color=applyLUT(u_lutTexture,out_color);\n#endif\n#ifdef FILL_PATTERN_TRANSITION\nvec2 pattern_b_tl=pattern_b.xy;vec2 pattern_b_br=pattern_b.zw;highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);\n#ifdef ELEVATED_ROADS\nout_color.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);\n#else\nout_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord);\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 USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in vec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;out highp float v_road_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\nout highp vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 pattern_b\n#endif\n#pragma mapbox: define lowp float pixel_ratio\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\n#pragma mapbox: initialize highp float z_offset\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump vec4 pattern_b\n#endif\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;v_road_z_offset=z_offset;\n#endif\nfloat hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset);\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\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);v_depth=gl_Position.w;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillExtrusion:os('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nin vec4 v_color;in vec4 v_flat;\n#ifdef RENDER_SHADOWS\nin highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;\n#endif\nuniform lowp float u_opacity;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;in vec2 v_ao;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nin vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nin highp vec3 v_normal;\n#endif\nuniform vec3 u_flood_light_color;uniform highp float u_vertical_scale;uniform float u_flood_light_intensity;uniform vec3 u_ground_shadow_factor;\n#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)\nin float v_flood_radius;in float v_has_floodlight;\n#endif\nin float v_height;\n#pragma mapbox: define highp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize highp float emissive_strength\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nvec3 normal=normalize(v_normal);\n#endif\nfloat z;vec4 color=v_color;\n#ifdef ZERO_ROOF_RADIUS\nz=float(normal.z > 0.00001);\n#ifdef LIGHTING_3D_MODE\nnormal=mix(normal,vec3(0.0,0.0,1.0),z);\n#else\ncolor=mix(v_color,v_roof_color,z);\n#endif\n#endif\nfloat h=max(0.0,v_height);float ao_shade=1.0;\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h_floors=h/(u_ao[1]*u_vertical_scale);float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);ao_shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;\n#ifdef ZERO_ROOF_RADIUS\nconcave*=(1.0-z);\n#endif\nfloat x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);ao_shade*=mix(1.0,x_shade*x_shade*x_shade,concave);\n#ifdef LIGHTING_3D_MODE\n#ifdef FLOOD_LIGHT\ncolor.rgb*=mix(ao_shade,1.0,v_has_floodlight);\n#else\ncolor.rgb*=ao_shade;\n#endif\n#else\ncolor.rgb*=ao_shade;\n#endif\n#endif\n#ifdef LIGHTING_3D_MODE\nfloat flood_radiance=0.0;\n#ifdef FLOOD_LIGHT\nflood_radiance=(1.0-min(h/v_flood_radius,1.0))*u_flood_light_intensity*v_has_floodlight;\n#endif\n#ifdef RENDER_SHADOWS\n#ifdef FLOOD_LIGHT\nfloat ndotl_unclamped=dot(normal,u_shadow_direction);float ndotl=max(0.0,ndotl_unclamped);float occlusion=ndotl_unclamped < 0.0 ? 1.0 : shadow_occlusion(ndotl,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);vec3 litColor=apply_lighting(color.rgb,normal,(1.0-u_shadow_intensity*occlusion)*ndotl);vec3 floodLitColor=compute_flood_lighting(u_flood_light_color*u_opacity,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=mix(litColor,floodLitColor,flood_radiance);\n#else\nfloat shadowed_lighting_factor;\n#ifdef RENDER_CUTOFF\nshadowed_lighting_factor=shadowed_light_factor_normal_opacity(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,v_cutoff_opacity);if (v_cutoff_opacity==0.0) {discard;}\n#else\nshadowed_lighting_factor=shadowed_light_factor_normal(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);\n#endif\ncolor.rgb=apply_lighting(color.rgb,normal,shadowed_lighting_factor);\n#endif\n#else\ncolor.rgb=apply_lighting(color.rgb,normal);\n#ifdef FLOOD_LIGHT\ncolor.rgb=mix(color.rgb,u_flood_light_color*u_opacity,flood_radiance);\n#endif\n#endif\ncolor.rgb=mix(color.rgb,v_flat.rgb,emissive_strength);color*=u_opacity;\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos,h));\n#endif\n#ifdef INDICATOR_CUTOUT\ncolor=applyCutout(color,h);\n#endif\n#ifdef FEATURE_CUTOUT\ncolor=apply_feature_cutout(color,gl_FragCoord);\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"\n#include "_prelude_material_table.vertex.glsl"\nuniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_edge_radius;uniform float u_width_scale;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#ifdef RENDER_WALL_MODE\nin vec3 a_join_normal_inside;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\n#ifdef TERRAIN\nuniform int u_height_type;uniform int u_base_type;\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;vec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define highp float flood_light_wall_radius\n#pragma mapbox: define highp float line_width\n#pragma mapbox: define highp float emissive_strength\nvoid main() {DECLARE_MATERIAL_TABLE_INFO\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize highp float flood_light_wall_radius\n#pragma mapbox: initialize highp float line_width\n#pragma mapbox: initialize highp float emissive_strength\nbase*=u_vertical_scale;height*=u_vertical_scale;vec4 pos_nx=floor(a_pos_normal_ed*0.5);vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nv_normal=normal;\n#endif\nbase=max(0.0,base);float attr_height=height;height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\nfloat ele=0.0;float h=0.0;float c_ele=0.0;vec3 pos;\n#ifdef TERRAIN\nbool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;ele=elevation(pos_nx.xy);c_ele=is_flat_height || is_flat_base ? (centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);h=t > 0.0 ? max(h_base,h_height) : h_base;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);\n#ifdef CLIP_ZERO_TO_ONE\ncutoff=cutoff_opacity(u_cutoff_params,ground.z*2.0-ground.w);\n#else\ncutoff=cutoff_opacity(u_cutoff_params,ground.z);\n#endif\nif (centroid_pos.y !=0.0 && centroid_pos.x !=0.0) {vec3 g=floor(ground_pos);vec3 mod_=centroid_random-g*8.0;float seed=min(1.0,0.1*(min(3.5,max(mod_.x+mod_.y,0.2*attr_height))*0.35+mod_.z));if (cutoff < 0.8-seed) {cutoff=0.0;}}float cutoff_scale=cutoff;v_cutoff_opacity=cutoff;scaled_pos.z=mix(c_ele,h,cutoff_scale);\n#endif\nfloat hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (cutoff==0.0 && centroid_pos.x !=0.0) || (color.a==0.0));\n#ifdef RENDER_WALL_MODE\nvec2 wall_offset=u_width_scale*line_width*(a_join_normal_inside.xy/EXTENT);scaled_pos.xy+=(1.0-a_join_normal_inside.z)*wall_offset*0.5;scaled_pos.xy-=a_join_normal_inside.z*wall_offset*0.5;\n#endif\ngl_Position=mix(u_matrix*vec4(scaled_pos,1),AWAY,hidden);h=h-ele;v_height=h;\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=pos;vec3 shd_pos1=pos;\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(normal);shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);\n#endif\nfloat NdotL=0.0;float colorvalue=0.0;\n#ifndef LIGHTING_3D_MODE\ncolorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),NdotL);if (normal.y !=0.0) {float r=0.84;r=mix(0.7,0.98,1.0-u_lightintensity);NdotL*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}\n#endif\n#ifdef FAUX_AO\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\n#ifdef TERRAIN\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\n#endif\nv_ao=vec2(mix(concave,-concave,start),y_ground);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\n#ifdef LIGHTING_3D_MODE\n#ifdef FLOOD_LIGHT\nfloat is_wall=1.0-float(t > 0.0 && top_up_ny.y > 0.0);v_has_floodlight=float(flood_light_wall_radius > 0.0 && is_wall > 0.0);v_flood_radius=flood_light_wall_radius*u_vertical_scale;\n#endif\nv_color=vec4(color.rgb,1.0);float ndotl=calculate_NdotL(normal);v_flat.rgb=sRGBToLinear(color.rgb);v_flat.rgb=v_flat.rgb*(ndotl+(1.0-min(ndotl*57.29,1.0))*emissive_strength);v_flat=vec4(linearTosRGB(v_flat.rgb),1.0);\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:os("in highp float v_depth;void main() {\n#ifndef DEPTH_TEXTURE\nglFragColor=pack_depth(v_depth);\n#endif\n}",'#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_material_table.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_edge_radius;uniform float u_width_scale;uniform float u_vertical_scale;\n#ifdef TERRAIN\nuniform int u_height_type;uniform int u_base_type;\n#endif\nin vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#ifdef RENDER_WALL_MODE\nin vec3 a_join_normal_inside;\n#endif\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp float line_width\n#pragma mapbox: define highp vec4 color\nout highp float v_depth;void main() {DECLARE_MATERIAL_TABLE_INFO\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp float line_width\n#pragma mapbox: initialize highp vec4 color\nbase*=u_vertical_scale;height*=u_vertical_scale;vec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;base=max(0.0,base);height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\nvec3 pos;\n#ifdef TERRAIN\nbool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;float ele=elevation(pos_nx.xy);float c_ele=is_flat_height || is_flat_base ? (centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);float h=t > 0.0 ? max(h_base,h_height) : h_base;pos=vec3(pos_nx.xy,h);\n#else\npos=vec3(pos_nx.xy,t > 0.0 ? height : base);\n#endif\n#ifdef RENDER_WALL_MODE\nvec2 wall_offset=u_width_scale*line_width*(a_join_normal_inside.xy/EXTENT);pos.xy+=(1.0-a_join_normal_inside.z)*wall_offset*0.5;pos.xy-=a_join_normal_inside.z*wall_offset*0.5;\n#endif\nfloat hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (color.a==0.0));gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);v_depth=gl_Position.z/gl_Position.w;}'),fillExtrusionPattern:os('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\nuniform float u_pattern_transition;\n#endif\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\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\nin highp vec2 v_pos;in vec4 v_lighting;uniform lowp float u_opacity;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define mediump vec4 pattern\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 pattern_b\n#endif\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#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump vec4 pattern_b\n#endif\n#pragma mapbox: initialize highp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef APPLY_LUT_ON_GPU\nout_color=applyLUT(u_lutTexture,out_color);\n#endif\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\nvec2 pattern_b_tl=pattern_b.xy;vec2 pattern_b_br=pattern_b.zw;highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;\n#endif\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,height);\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"\n#include "_prelude_material_table.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform float u_tile_units_to_pixels;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_width_scale;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#ifdef RENDER_WALL_MODE\nin vec3 a_join_normal_inside;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\n#ifdef TERRAIN\nuniform int u_height_type;uniform int u_base_type;\n#endif\nout highp vec2 v_pos;out vec4 v_lighting;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;out vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nout vec3 v_normal;\n#endif\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump vec4 pattern\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 pattern_b\n#endif\n#pragma mapbox: define highp float pixel_ratio\n#pragma mapbox: define highp float line_width\nvoid main() {DECLARE_MATERIAL_TABLE_INFO\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 mediump vec4 pattern\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump vec4 pattern_b\n#endif\n#pragma mapbox: initialize highp float pixel_ratio\n#pragma mapbox: initialize highp float line_width\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec4 pos_nx=floor(a_pos_normal_ed*0.5);mediump vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;mediump vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=a_pos_normal_ed.w;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\nfloat ele=0.0;float h=z;vec3 p;float c_ele;\n#ifdef TERRAIN\nbool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;ele=elevation(pos_nx.xy);c_ele=is_flat_height || is_flat_base ? (centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);h=t > 0.0 ? max(h_base,h_height) : h_base;p=vec3(pos_nx.xy,h);\n#else\np=vec3(pos_nx.xy,z);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\n#ifdef RENDER_WALL_MODE\nvec2 wall_offset=u_width_scale*line_width*(a_join_normal_inside.xy/EXTENT);p.xy+=(1.0-a_join_normal_inside.z)*wall_offset*0.5;p.xy-=a_join_normal_inside.z*wall_offset*0.5;\n#endif\nfloat hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (color.a==0.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:os('#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_plane_bias(v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);vec3 shadow=mix(u_ground_shadow_factor,vec3(1.0),light);\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),0.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:os("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\n#ifdef USE_MRT1\nout_Target1=vec4(1.0-texture(u_fb,gl_FragCoord.xy/vec2(u_fb_size)).a,0.0,0.0,0.0);\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\n#endif\nHANDLE_WIREFRAME_DEBUG;\n#endif\n}",'#include "_prelude_fog.vertex.glsl"\nin highp vec4 a_pos_end;in highp float a_angular_offset_factor;in highp float a_hidden_by_landmark;\n#ifdef SDF_SUBPASS\nout highp vec2 v_pos;out highp vec4 v_line_segment;out highp float v_flood_light_radius_tile;out highp vec2 v_ao;\n#ifdef FOG\nout highp float v_fog;\n#endif\n#endif\nuniform highp float u_flood_light_intensity;uniform highp mat4 u_matrix;uniform highp float u_ao_pass;uniform highp float u_meter_to_tile;uniform highp float u_edge_radius;uniform highp float u_dynamic_offset;uniform highp vec2 u_ao;\n#pragma mapbox: define highp float flood_light_ground_radius\nconst float TANGENT_CUTOFF=4.0;const float NORM=32767.0;void main() {\n#pragma mapbox: initialize highp float flood_light_ground_radius\nvec2 p=a_pos_end.xy;vec2 q=floor(a_pos_end.zw*0.5);vec2 start_bottom=a_pos_end.zw-q*2.0;float fl_ground_radius=flood_light_ground_radius;fl_ground_radius=abs(flood_light_ground_radius);float direction=flood_light_ground_radius < 0.0 ?-1.0 : 1.0;float flood_radius_tile=fl_ground_radius*u_meter_to_tile;vec2 v=normalize(q-p);float ao_radius=u_ao.y/3.5;float effect_radius=mix(flood_radius_tile,ao_radius,u_ao_pass)+u_edge_radius;float angular_offset_factor=a_angular_offset_factor/NORM*TANGENT_CUTOFF;float angular_offset=direction*angular_offset_factor*effect_radius;float top=1.0-start_bottom.y;float side=(0.5-start_bottom.x)*2.0;vec2 extrusion_parallel=v*side*mix(u_dynamic_offset,angular_offset,top);vec2 perp=vec2(v.y,-v.x);vec2 extrusion_perp=direction*perp*effect_radius*top;vec3 pos=vec3(mix(q,p,start_bottom.x),0.0);pos.xy+=extrusion_parallel+extrusion_perp;\n#ifdef SDF_SUBPASS\nv_pos=pos.xy;v_line_segment=vec4(p,q)+perp.xyxy*u_edge_radius;v_flood_light_radius_tile=flood_radius_tile;v_ao=vec2(u_ao.x,ao_radius);\n#ifdef FOG\nv_fog_pos=fog_position(pos);v_fog=1.0-fog(v_fog_pos);\n#endif\n#endif\nfloat hidden_by_landmark=0.0;\n#ifdef HAS_CENTROID\nhidden_by_landmark=a_hidden_by_landmark;\n#endif\nfloat isFloodlit=float(fl_ground_radius > 0.0 && u_flood_light_intensity > 0.0);float hidden=mix(1.0-isFloodlit,isFloodlit,u_ao_pass);hidden+=hidden_by_landmark;gl_Position=mix(u_matrix*vec4(pos,1.0),AWAY,float(hidden > 0.0));\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n}'),hillshadePrepare:os("precision highp float;uniform highp sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;float getElevation(vec2 coord) {return texture(u_image,coord).r/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y));float b=getElevation(v_pos+vec2(0,-epsilon.y));float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y));float d=getElevation(v_pos+vec2(-epsilon.x,0));float e=getElevation(v_pos+vec2(epsilon.x,0));float f=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float g=getElevation(v_pos+vec2(0,epsilon.y));float h=getElevation(v_pos+vec2(epsilon.x,epsilon.y));float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2(\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:os('#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 USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\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:os('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nuniform lowp float u_device_pixel_ratio;uniform highp float u_width_scale;uniform highp float u_floor_width_scale;uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;uniform highp vec2 u_trim_fade_range;uniform highp vec2 u_trim_gradient_mix_range;uniform lowp vec4 u_trim_color;uniform bool u_emissive_in_shadows;in vec4 v_width2_dilute;in vec2 v_normal;in float v_gamma_scale;in highp vec3 v_uv;\n#ifdef ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\n#ifdef VARIABLE_LINE_WIDTH\nin float stub_side;\n#endif\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\n#ifdef INDICATOR_CUTOUT\nin highp float v_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\nfloat luminance(vec3 c) {return (c.r+c.r+c.b+c.g+c.g+c.g)*0.1667;}\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 side_z_offset\n#pragma mapbox: define lowp float border_width\n#pragma mapbox: define lowp vec4 border_color\n#pragma mapbox: define lowp float emissive_strength\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 mediump float side_z_offset\n#pragma mapbox: initialize lowp float border_width\n#pragma mapbox: initialize lowp vec4 border_color\n#pragma mapbox: initialize lowp float emissive_strength\nfloat dist=length(v_normal)*v_width2_dilute.x;\n#ifdef VARIABLE_LINE_WIDTH\nblur=mix(blur,0.0,stub_side);\n#endif\nfloat diluted_opacity=opacity*v_width2_dilute.z;float blur2=(u_width_scale*blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2_dilute.y-blur2),v_width2_dilute.x-dist)/blur2,0.0,1.0);\n#ifdef VARIABLE_LINE_WIDTH\nalpha=mix(alpha,1.0,stub_side);\n#endif\nalpha=side_z_offset > 0.0 ? 1.0-alpha : alpha;\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;float scaled_floorwidth=(floorwidth*u_floor_width_scale);alpha*=linearstep(0.5-sdfgamma/scaled_floorwidth,0.5+sdfgamma/scaled_floorwidth,sdfdist);\n#endif\nhighp vec4 out_color;\n#ifdef RENDER_LINE_GRADIENT\nout_color=texture(u_gradient_image,v_uv.xy);\n#else\nout_color=color;\n#endif\nfloat trim_alpha=1.0;\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=v_uv[2];if (trim_end > trim_start) {highp float start_transition=max(0.0,min(1.0,(line_progress-trim_start)/max(u_trim_fade_range[0],1.0e-9)));highp float end_transition=max(0.0,min(1.0,(trim_end-line_progress)/max(u_trim_fade_range[1],1.0e-9)));highp float transition_factor=min(start_transition,end_transition);highp float gradient_trim_color_mix_factor=0.0;\n#ifdef RENDER_LINE_GRADIENT\ngradient_trim_color_mix_factor=smoothstep(u_trim_gradient_mix_range.x,u_trim_gradient_mix_range.y,line_progress);\n#endif\nhighp vec4 trim_color=mix(u_trim_color,out_color,gradient_trim_color_mix_factor);out_color=mix(u_trim_gradient_mix_range.x < 1.0 ? color : out_color,trim_color,transition_factor);trim_alpha=1.0-transition_factor;}\n#endif\nif (u_alpha_discard_threshold !=0.0) {if (alpha < u_alpha_discard_threshold) {discard;}}\n#ifdef RENDER_LINE_BORDER\n#ifndef VARIABLE_LINE_WIDTH\nfloat edgeBlur=((border_width*u_width_scale)+1.0/u_device_pixel_ratio);float alpha2=clamp(min(dist-(v_width2_dilute.y-edgeBlur),v_width2_dilute.x-dist)/edgeBlur,0.0,1.0);if (alpha2 < 1.) {float smoothAlpha=smoothstep(0.6,1.0,alpha2);if (border_color.a==0.0) {float Y=(out_color.a > 0.01) ? luminance(out_color.rgb/out_color.a) : 1.;float adjustment=(Y > 0.) ? 0.5/Y : 0.45;if (out_color.a > 0.25 && Y < 0.25) {vec3 borderColor=(Y > 0.) ? out_color.rgb : vec3(1,1,1)*out_color.a;out_color.rgb=out_color.rgb+borderColor*(adjustment*(1.0-smoothAlpha));} else {out_color.rgb*=(0.6 +0.4*smoothAlpha);}} else {out_color=mix(border_color*trim_alpha,out_color,smoothAlpha);}out_color*=v_width2_dilute.w;}\n#endif\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);light=u_emissive_in_shadows ? mix(light,1.0,emissive_strength) : light;\n#ifdef ELEVATED_ROADS\nout_color.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);\n#else\nout_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nout_color*=(alpha*diluted_opacity);\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color,v_z_offset);\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord);\n#endif\nglFragColor=out_color;\n#ifdef DUAL_SOURCE_BLENDING\nglFragColorSrc1=vec4(vec3(0.0),emissive_strength);\n#else\n#ifdef USE_MRT1\nout_Target1=vec4(emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#define EXTRUDE_SCALE 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS) || defined(VARIABLE_LINE_WIDTH)\nin vec3 a_z_offset_width;\n#endif\n#ifdef ELEVATION_GROUND_SCALE\nin float a_elevation_ground_scale;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET) || defined(RENDER_LINE_CURVE)\nin highp vec3 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;uniform float u_width_scale;uniform highp float u_floor_width_scale;\n#ifdef RENDER_LINE_CURVE\nuniform mat3 u_curve_points_x;uniform mat3 u_curve_points_y;uniform mat3 u_curve_points_z;uniform float u_curve_point_count;\n#endif\n#ifdef ELEVATED\nuniform lowp float u_zbias_factor;uniform lowp float u_tile_to_meter;float sample_elevation(vec2 apos) {\n#ifdef ELEVATION_REFERENCE_SEA\nreturn 0.0;\n#else\nreturn elevation(apos);\n#endif\n}\n#endif\nout vec2 v_normal;out vec4 v_width2_dilute;out float v_gamma_scale;out highp vec3 v_uv;\n#ifdef ELEVATED_ROADS\nout highp float v_road_z_offset;\n#endif\n#ifdef VARIABLE_LINE_WIDTH\nout float stub_side;\n#endif\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#ifdef INDICATOR_CUTOUT\nout highp float v_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\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 mediump float side_z_offset\n#pragma mapbox: define lowp float border_width\n#pragma mapbox: define lowp vec4 border_color\n#pragma mapbox: define lowp float emissive_strength\n#ifdef RENDER_LINE_CURVE\nvec3 getCurvePoint(int index) {int row=index/3;int col=index-row*3;float x=u_curve_points_x[row][col];float y=u_curve_points_y[row][col];float z=u_curve_points_z[row][col];return vec3(x,y,z);}vec3 catmullRom(vec3 p0,vec3 p1,vec3 p2,vec3 p3,float t) {float t2=t*t;float t3=t2*t;return 0.5*(\n2.0*p1+(-p0+p2)*t+(2.0*p0-5.0*p1+4.0*p2-p3)*t2+(-p0+3.0*p1-3.0*p2+p3)*t3\n);}vec2 catmullRomTangent(vec2 p0,vec2 p1,vec2 p2,vec2 p3,float t) {float t2=t*t;return 0.5*(\n(-p0+p2)+(2.0*p0-5.0*p1+4.0*p2-p3)*2.0*t+(-p0+3.0*p1-3.0*p2+p3)*3.0*t2\n);}struct CurveResult {vec3 point;vec2 tangent;};CurveResult calculateCurve(float line_progress) {float curve_progress=line_progress*(u_curve_point_count-1.0);float curve_progress_local=fract(curve_progress);float curve_segment=floor(curve_progress);int seg=int(curve_segment);vec3 p1=getCurvePoint(seg);vec3 p2=getCurvePoint(seg+1);float is_first_seg=step(curve_segment,0.5);vec3 p0_extrapolated=p1-(p2-p1);vec3 p0_fetched=getCurvePoint(max(seg-1,0));vec3 p0=mix(p0_fetched,p0_extrapolated,is_first_seg);int last_seg=int(u_curve_point_count)-2;float is_last_seg=step(float(last_seg)-0.5,curve_segment);vec3 p3_extrapolated=p2+(p2-p1);vec3 p3_fetched=getCurvePoint(min(seg+2,int(u_curve_point_count)-1));vec3 p3=mix(p3_fetched,p3_extrapolated,is_last_seg);vec3 point=catmullRom(p0,p1,p2,p3,curve_progress_local);vec2 tangent=catmullRomTangent(p0.xy,p1.xy,p2.xy,p3.xy,curve_progress_local)*(u_curve_point_count-1.0);CurveResult result;result.point=point;result.tangent=tangent;return result;}\n#endif\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 mediump float side_z_offset\n#pragma mapbox: initialize lowp float border_width\n#pragma mapbox: initialize lowp vec4 border_color\n#pragma mapbox: initialize lowp float emissive_strength\nfloat a_z_offset;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS)\na_z_offset=a_z_offset_width.x;\n#endif\nhighp float line_progress=0.0;\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET) || defined(RENDER_LINE_CURVE)\nline_progress=a_packed[2];\n#endif\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;offset=-1.0*offset*u_width_scale;bool left=normal.y==1.0;\n#ifdef RENDER_LINE_CURVE\nCurveResult curve=calculateCurve(line_progress);pos=curve.point.xy*8192.0;a_extrude=length(a_extrude)*normalize(curve.tangent);a_extrude=left ? vec2(-a_extrude.y,a_extrude.x) : vec2(a_extrude.y,-a_extrude.x);a_z_offset+=curve.point.z;\n#endif\ngapwidth=gapwidth/2.0;float halfwidth;float dilute_scale=1.0;float dilute_border_scale=1.0;\n#ifdef VARIABLE_LINE_WIDTH\nfloat left_width=a_z_offset_width.y;float right_width=a_z_offset_width.z;halfwidth=(u_width_scale*(left ? left_width : right_width))/2.0;if (side_z_offset !=0.0) {float left_f=step(1.0,normal.y);float is_negative=step(side_z_offset,0.0);float apply=mix(1.0-left_f,left_f,is_negative);a_extrude*=apply;a_z_offset+=abs(side_z_offset)*apply;v_normal*=left_f;}offset=border_width > 0.0 ? (left_width+right_width)*u_width_scale*0.5 : offset;halfwidth=border_width > 0.0 ? border_width*u_width_scale*0.5 : halfwidth;bool zero_right_width=border_width==0.0 && right_width==0.0;stub_side=zero_right_width ?-normal.y : 0.0;v_normal=!left && zero_right_width ? vec2(0.0) : v_normal;ANTIALIASING=!left && zero_right_width ? 0.0 : ANTIALIASING;\n#else\nhalfwidth=(u_width_scale*width)/2.0;\n#endif\nfloat inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*EXTRUDE_SCALE;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*EXTRUDE_SCALE*normal.y*mat2(t,-u,u,t);float hidden=float(opacity==0.0);vec2 extrude=dist*u_pixels_to_tile_units;vec4 projected_extrude=u_matrix*vec4(extrude,0.0,0.0);vec2 projected_extrude_xy=projected_extrude.xy;\n#ifdef ELEVATED_ROADS\nv_road_z_offset=a_z_offset;gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,a_z_offset,1.0);\n#else\n#ifdef ELEVATED\nvec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 offset_pos=pos+offsetTile;float ele=0.0;float scaled_z_offset=a_z_offset;\n#ifdef ELEVATION_GROUND_SCALE\nscaled_z_offset=a_z_offset*mix(1.0,u_exaggeration,a_elevation_ground_scale);\n#endif\n#ifdef CROSS_SLOPE_VERTICAL\nfloat top=a_pos_normal.y-2.0*floor(a_pos_normal.y*0.5);float line_height=2.0*u_tile_to_meter*outset*top*u_pixels_to_tile_units[1][1]+scaled_z_offset;ele=sample_elevation(offset_pos)+line_height;projected_extrude=vec4(0);\n#else\n#ifdef CROSS_SLOPE_HORIZONTAL\nfloat ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,max(ele1,ele2));ele=ele_max+scaled_z_offset;\n#else\nfloat ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,0.5*(ele1+ele2));ele=ele_max-ele0+ele1+scaled_z_offset;\n#endif\n#endif\ngl_Position=u_matrix*vec4(offset_pos,ele,1.0)+projected_extrude;float z=clamp(gl_Position.z/gl_Position.w,0.5,1.0);float zbias=max(0.00005,(pow(z,0.8)-z)*u_zbias_factor*u_exaggeration);gl_Position.z-=(gl_Position.w*zbias);gl_Position=mix(gl_Position,AWAY,hidden);\n#else\ngl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0);\n#endif\n#endif\n#ifndef ELEVATED\n#ifndef VARIABLE_LINE_WIDTH\n#ifndef RENDER_TO_TEXTURE\nfloat base_w=gl_Position.w;vec2 screen_width=abs(projected_extrude.xy/base_w*u_units_to_pixels);float max_extrude_component=max(screen_width.x,screen_width.y);if (base_w > 0.0 && max_extrude_component > 0.0001) {float min_pixel=1.05;if (max_extrude_component < min_pixel) {vec2 abs_pos=abs(gl_Position.xy);float is_out=max(abs_pos.x,abs_pos.y)/base_w;dilute_scale=mix(max_extrude_component/min_pixel,1.0,smoothstep(2.5,4.5,is_out));projected_extrude/=dilute_scale;}else\n{\n#ifdef RENDER_LINE_BORDER\nfloat border_ratio=(border_width*u_width_scale+ANTIALIASING)/outset;screen_width*=border_ratio;float max_border_component=max(screen_width.x,screen_width.y);dilute_border_scale=min(1.0,max_border_component/min_pixel);\n#endif\n}}\n#endif\n#endif\n#ifdef ELEVATED_ROADS\ngl_Position=gl_Position+projected_extrude;\n#else\ngl_Position=mix(gl_Position+projected_extrude,AWAY,hidden);\n#endif\n#endif\n#ifdef ELEVATED_ROADS\n#ifdef RENDER_SHADOWS\nvec3 shd_pos=vec3(pos+(offset2+dist)*u_pixels_to_tile_units,a_z_offset);vec3 shd_pos0=shd_pos;vec3 shd_pos1=shd_pos;\n#ifdef NORMAL_OFFSET\nvec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_offset*shadow_normal_offset_multiplier1();\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);v_depth=gl_Position.w;\n#endif\n#endif\n#ifndef RENDER_TO_TEXTURE\nfloat epsilon=0.0001;float extrude_length_without_perspective=max(length(dist),epsilon);float extrude_length_with_perspective=max(length(projected_extrude_xy/gl_Position.w*u_units_to_pixels),epsilon);v_gamma_scale=mix(extrude_length_without_perspective/extrude_length_with_perspective,1.0,step(0.01,blur));\n#else\nv_gamma_scale=1.0;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nhighp float a_uv_x=a_packed[0];float a_split_index=a_packed[1];\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=vec3(a_uv_x,a_split_index*texel_height-half_texel_height,line_progress);\n#else\nv_uv=vec3(a_uv_x,0.0,line_progress);\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*u_floor_width_scale),(-normal.y*height+dash.x+0.5)/u_texsize.y);\n#endif\nv_width2_dilute=vec4(outset,inset,dilute_scale,dilute_border_scale);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n#ifdef INDICATOR_CUTOUT\nv_z_offset=a_z_offset;\n#endif\n}'),linePattern:os('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nuniform highp float u_device_pixel_ratio;uniform highp float u_width_scale;uniform highp float u_alpha_discard_threshold;uniform highp vec2 u_texsize;uniform highp float u_tile_units_to_pixels;uniform highp vec2 u_trim_offset;uniform highp vec2 u_trim_fade_range;uniform lowp vec4 u_trim_color;uniform sampler2D u_image;\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\n#ifdef LINE_PATTERN_TRANSITION\nuniform float u_pattern_transition;\n#endif\nin vec2 v_normal;in vec2 v_width2;in highp float v_linesofar;in float v_gamma_scale;in float v_width;\n#ifdef RENDER_LINE_TRIM_OFFSET\nin highp vec3 v_uv;\n#endif\n#ifdef ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\n#ifdef LINE_JOIN_NONE\nin vec2 v_pattern_data;\n#endif\n#ifdef INDICATOR_CUTOUT\nin highp float v_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\n#pragma mapbox: define mediump vec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 pattern_b\n#endif\n#pragma mapbox: define mediump float pixel_ratio\n#pragma mapbox: define mediump float blur\n#pragma mapbox: define mediump float opacity\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump vec4 pattern_b\n#endif\n#pragma mapbox: initialize mediump float pixel_ratio\n#pragma mapbox: initialize mediump float blur\n#pragma mapbox: initialize mediump float opacity\n#pragma mapbox: initialize lowp float emissive_strength\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;highp float pattern_size=display_size.x/u_tile_units_to_pixels;float aspect=display_size.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(u_width_scale*blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);highp float pattern_x=v_linesofar/pattern_size*aspect;highp float x=mod(pattern_x,1.0);highp float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;highp vec2 pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(x,y));highp vec2 lod_pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(pattern_x,y));vec4 color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef APPLY_LUT_ON_GPU\ncolor=applyLUT(u_lutTexture,color);\n#endif\n#ifdef LINE_PATTERN_TRANSITION\nvec2 pattern_b_tl=pattern_b.xy;vec2 pattern_b_br=pattern_b.zw;highp vec2 pos_b=mix(pattern_b_tl*texel_size-texel_size,pattern_b_br*texel_size+texel_size,vec2(x,y));vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);color=color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=v_uv[2];if (trim_end > trim_start) {highp float start_transition=max(0.0,min(1.0,(line_progress-trim_start)/max(u_trim_fade_range[0],1.0e-9)));highp float end_transition=max(0.0,min(1.0,(trim_end-line_progress)/max(u_trim_fade_range[1],1.0e-9)));highp float transition_factor=min(start_transition,end_transition);color=mix(color,color.a*u_trim_color,transition_factor);}\n#endif\n#ifdef LINE_JOIN_NONE\nhighp float pattern_len=pattern_size/aspect;highp float segment_phase=pattern_len-mod(v_linesofar-v_pattern_data.x+pattern_len,pattern_len);highp float visible_start=segment_phase-step(pattern_len*0.5,segment_phase)*pattern_len;highp float visible_end=floor((v_pattern_data.y-segment_phase)/pattern_len)*pattern_len+segment_phase;visible_end+=step(pattern_len*0.5,v_pattern_data.y-visible_end)*pattern_len;if (v_pattern_data.x < visible_start || v_pattern_data.x >=visible_end) {color=vec4(0.0);}\n#endif\n#ifdef LIGHTING_3D_MODE\ncolor=apply_lighting_with_emission_ground(color,emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);\n#ifdef ELEVATED_ROADS\ncolor.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);\n#else\ncolor.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ncolor*=(alpha*opacity);if (u_alpha_discard_threshold !=0.0) {if (color.a < u_alpha_discard_threshold) {discard;}}\n#ifdef INDICATOR_CUTOUT\ncolor=applyCutout(color,v_z_offset);\n#endif\nglFragColor=color;\n#ifdef DUAL_SOURCE_BLENDING\nglFragColorSrc1=vec4(vec3(0.0),emissive_strength);\n#else\n#ifdef USE_MRT1\nout_Target1=vec4(emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS)\nin vec3 a_z_offset_width;\n#endif\n#ifdef ELEVATION_GROUND_SCALE\nin float a_elevation_ground_scale;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nin highp vec3 a_packed;\n#endif\nin highp float a_linesofar;\n#ifdef LINE_JOIN_NONE\nin highp vec3 a_pattern_data;out vec2 v_pattern_data;\n#endif\n#ifdef INDICATOR_CUTOUT\nout highp float v_z_offset;\n#endif\nuniform mat4 u_matrix;uniform float u_tile_units_to_pixels;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform float u_device_pixel_ratio;uniform float u_width_scale;uniform float u_floor_width_scale;\n#ifdef ELEVATED\nuniform lowp float u_zbias_factor;uniform lowp float u_tile_to_meter;float sample_elevation(vec2 apos) {\n#ifdef ELEVATION_REFERENCE_SEA\nreturn 0.0;\n#else\nreturn elevation(apos);\n#endif\n}\n#endif\nout vec2 v_normal;out vec2 v_width2;out highp float v_linesofar;out float v_gamma_scale;out float v_width;\n#ifdef RENDER_LINE_TRIM_OFFSET\nout highp vec3 v_uv;\n#endif\n#ifdef ELEVATED_ROADS\nout highp float v_road_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\n#pragma mapbox: define mediump float blur\n#pragma mapbox: define mediump float opacity\n#pragma mapbox: define mediump float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define mediump float floorwidth\n#pragma mapbox: define mediump vec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 pattern_b\n#endif\n#pragma mapbox: define mediump float pixel_ratio\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize mediump float blur\n#pragma mapbox: initialize mediump float opacity\n#pragma mapbox: initialize mediump float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize mediump float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump vec4 pattern_b\n#endif\n#pragma mapbox: initialize mediump float pixel_ratio\n#pragma mapbox: initialize lowp float emissive_strength\nfloat a_z_offset;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS)\na_z_offset=a_z_offset_width.x;\n#endif\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=(u_width_scale*width)/2.0;offset=-1.0*offset*u_width_scale;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);vec2 dist=outset*a_extrude*scale;float u=0.5*a_direction;float t=1.0-abs(u);vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float hidden=float(opacity==0.0);vec2 extrude=dist*u_pixels_to_tile_units;vec4 projected_extrude=u_matrix*vec4(extrude,0.0,0.0);vec2 projected_extrude_xy=projected_extrude.xy;\n#ifdef ELEVATED_ROADS\nv_road_z_offset=a_z_offset;gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,a_z_offset,1.0)+projected_extrude;\n#else\n#ifdef ELEVATED\nvec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 offset_pos=pos+offsetTile;float ele=0.0;float scaled_z_offset=a_z_offset;\n#ifdef ELEVATION_GROUND_SCALE\nscaled_z_offset=a_z_offset*mix(1.0,u_exaggeration,a_elevation_ground_scale);\n#endif\n#ifdef CROSS_SLOPE_VERTICAL\nfloat top=a_pos_normal.y-2.0*floor(a_pos_normal.y*0.5);float line_height=2.0*u_tile_to_meter*outset*top*u_pixels_to_tile_units[1][1]+scaled_z_offset;ele=sample_elevation(offset_pos)+line_height;projected_extrude=vec4(0);\n#else\n#ifdef CROSS_SLOPE_HORIZONTAL\nfloat ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,max(ele1,ele2));ele=ele_max+scaled_z_offset;\n#else\nfloat ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,0.5*(ele1+ele2));ele=ele_max-ele0+ele1+scaled_z_offset;\n#endif\n#endif\ngl_Position=u_matrix*vec4(offset_pos,ele,1.0)+projected_extrude;float z=clamp(gl_Position.z/gl_Position.w,0.5,1.0);float zbias=max(0.00005,(pow(z,0.8)-z)*u_zbias_factor*u_exaggeration);gl_Position.z-=(gl_Position.w*zbias);gl_Position=mix(gl_Position,AWAY,hidden);\n#else\ngl_Position=mix(u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude,AWAY,hidden);\n#endif\n#endif\n#ifdef ELEVATED_ROADS\n#ifdef RENDER_SHADOWS\nvec3 shd_pos=vec3(pos+(offset2+dist)*u_pixels_to_tile_units,a_z_offset);vec3 shd_pos0=shd_pos;vec3 shd_pos1=shd_pos;\n#ifdef NORMAL_OFFSET\nvec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_offset*shadow_normal_offset_multiplier1();\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);v_depth=gl_Position.w;\n#endif\n#endif\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude_xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=mix(extrude_length_without_perspective/extrude_length_with_perspective,1.0,step(0.01,blur));\n#else\nv_gamma_scale=1.0;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float a_uv_x=a_packed[0];highp float line_progress=a_packed[2];v_uv=vec3(a_uv_x,0.0,line_progress);\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=(floorwidth*u_floor_width_scale);\n#ifdef LINE_JOIN_NONE\nv_width=(floorwidth*u_floor_width_scale)+ANTIALIASING;mediump float pixels_to_tile_units=1.0/u_tile_units_to_pixels;mediump float pixel_ratio_inverse=1.0/pixel_ratio;mediump float aspect=v_width/((pattern.w-pattern.y)*pixel_ratio_inverse);highp float subt_multiple=(pattern.z-pattern.x)*pixel_ratio_inverse*pixels_to_tile_units*aspect*32.0;highp float subt=floor(a_pattern_data.z/subt_multiple)*subt_multiple;float offset_sign=(fract(a_pattern_data.x)-0.5)*4.0;float line_progress_offset=offset_sign*v_width*0.5*pixels_to_tile_units;v_linesofar=(a_pattern_data.z-subt)+a_linesofar+line_progress_offset;v_pattern_data=vec2(a_pattern_data.x+line_progress_offset,a_pattern_data.y);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n#ifdef INDICATOR_CUTOUT\nv_z_offset=a_z_offset;\n#endif\n}'),raster:os('#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 highp 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\n#ifdef USE_MRT1\nout_Target1=vec4(u_emissive_strength*glFragColor.a,0.0,0.0,glFragColor.a);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.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#ifdef ELEVATED\nuniform lowp float u_zbias_factor;\n#endif\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;uv=a_uv;float ele=u_raster_elevation;\n#ifdef ELEVATION_REFERENCE_GROUND\nele+=elevation(uv*EXTENT);\n#endif\nglobe_pos+=normalize(globe_pos)*ele*GLOBE_UPSCALE;gl_Position=u_matrix*u_globe_matrix*vec4(globe_pos ,1.0);\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(a_globe_pos,1.0)).xyz);\n#endif\n#else\nvec4 world_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nuv=a_texture_pos/8192.0;vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float mercatorX=mercatorXfromLng(latLng[1]); \nfloat 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);}float ele=u_raster_elevation;\n#ifdef ELEVATION_REFERENCE_GROUND\nele+=elevation(uv*EXTENT)-decomposed_pos_and_skirt.z;\n#endif\nvec4 merc_world_pos=vec4(0.0); \nv_split_fade=0.0;if (u_zoom_transition > 0.0) {vec2 merc_pos=vec2(mercatorX,mercatorY);merc_world_pos=vec4(merc_pos,ele,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;float opposite_merc_center=mod(u_merc_center.x+0.5,1.0);float dist_from_poles=(abs(mercatorY-0.5)*2.0);float range=0.1;v_split_fade=abs(opposite_merc_center-mercatorX);v_split_fade=clamp(1.0-v_split_fade,0.0,1.0);v_split_fade=max(smoothstep(1.0-range,1.0,dist_from_poles),max(smoothstep(1.0-range,1.0,v_split_fade),smoothstep(1.0-range,1.0,1.0-v_split_fade)));}vec3 globe_pos=latLngToECEF(latLng.xy);globe_pos+=normalize(globe_pos)*ele*GLOBE_UPSCALE;vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);world_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0);\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n#else\nfloat ele=0.0;vec2 decodedPos=a_pos;\n#ifdef ELEVATION_REFERENCE_GROUND\nvec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;decodedPos=decomposedPosAndSkirt.xy;uv=decodedPos/8192.0;ele=elevation(decodedPos)-skirt;\n#else\nuv=a_texture_pos/8192.0;\n#endif\nworld_pos=vec4(decodedPos,(u_raster_elevation+ele),1.0);\n#ifdef FOG\nv_fog_pos=fog_position(decodedPos);\n#endif\n#endif\nfloat w=1.0+dot(uv*EXTENT,u_perspective_transform);gl_Position=u_matrix*world_pos*w;\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 ELEVATED\nfloat z=clamp(gl_Position.z/gl_Position.w,0.5,1.0);float zbias=max(0.00005,(pow(z,0.8)-z)*u_zbias_factor);gl_Position.z-=(gl_Position.w*zbias);\n#endif\n#ifdef RENDER_CUTOFF\nv_depth=gl_Position.z;\n#endif\n}'),rasterParticle:os('#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),1.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:os("uniform sampler2D u_color_ramp;in float v_particle_speed;void main() {glFragColor=texture(u_color_ramp,vec2(v_particle_speed,0.5));}",'#include "_prelude_raster_particle.glsl"\nin float a_index;uniform sampler2D u_particle_texture;uniform float u_particle_texture_side_len;uniform vec2 u_tile_offset;out float v_particle_speed;void main() {ivec2 pixel_coord=ivec2(\nmod(a_index,u_particle_texture_side_len),a_index/u_particle_texture_side_len);vec4 pixel=texelFetch(u_particle_texture,pixel_coord,0);vec2 pos=unpack_pos_from_rgba(pixel)+u_tile_offset;vec2 tex_coord=fract(pos);vec2 velocity=lookup_velocity(tex_coord);if (velocity==INVALID_VELOCITY) {gl_Position=AWAY;v_particle_speed=0.0;} else {gl_Position=vec4(2.0*pos-1.0,0,1);v_particle_speed=length(velocity);}gl_PointSize=1.0;}'),rasterParticleTexture:os("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:os('#include "_prelude_raster_particle.glsl"\nuniform sampler2D u_particle_texture;uniform mediump float u_particle_texture_side_len;uniform mediump float u_speed_factor;uniform highp float u_reset_rate;uniform highp float u_rand_seed;in highp vec2 v_tex_coord;vec2 linearstep(vec2 edge0,vec2 edge1,vec2 x) {return clamp((x-edge0)/(edge1-edge0),vec2(0),vec2(1));}const highp vec3 rand_constants=vec3(12.9898,78.233,4375.85453);highp float rand(const highp vec2 co) {highp float t=dot(rand_constants.xy,co);return fract(sin(t)*(rand_constants.z+t));}void main() {ivec2 pixel_coord=ivec2(v_tex_coord*u_particle_texture_side_len);highp vec4 pixel=texelFetch(u_particle_texture,pixel_coord,0);highp vec2 pos=unpack_pos_from_rgba(pixel);highp vec2 velocity=lookup_velocity(clamp(pos,0.0,1.0));highp vec2 dp=velocity==INVALID_VELOCITY ? vec2(0) : velocity*u_speed_factor;pos=pos+dp;highp vec2 seed=(pos+v_tex_coord)*u_rand_seed;highp vec2 random_pos=vec2(rand(seed+1.3),rand(seed+2.1));highp vec2 persist_rate=pow(\nlinearstep(vec2(-u_particle_pos_offset),vec2(0),pos)*linearstep(vec2(1.0+u_particle_pos_offset),vec2(1),pos),vec2(4)\n);highp vec2 per_frame_persist=pow(persist_rate,abs(dp)/u_particle_pos_offset);highp float drop_rate=1.0-per_frame_persist.x*per_frame_persist.y;drop_rate=any(greaterThanEqual(abs(pos-0.5),vec2(0.5+u_particle_pos_offset))) ? 1.0 : drop_rate;highp float drop=step(1.0-drop_rate-u_reset_rate,rand(seed));highp vec2 next_pos=mix(pos,random_pos,drop);glFragColor=pack_pos_to_rgba(next_pos);}',"in vec2 a_pos;out vec2 v_tex_coord;void main() {v_tex_coord=0.5*(a_pos+vec2(1.0));gl_Position=vec4(a_pos,0.0,1.0);}"),symbol:os('#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;uniform bool u_is_halo;uniform lowp float u_scale_factor;\n#ifdef ICON_TRANSITION\nuniform float u_icon_transition;\n#endif\n#ifdef COLOR_ADJUSTMENT\nuniform mat4 u_color_adj_mat;\n#endif\n#ifdef INDICATOR_CUTOUT\nin highp float v_z_offset;\n#else\n#ifdef RENDER_SHADOWS\nin highp float v_z_offset;\n#endif\n#endif\nin vec2 v_tex_a;\n#ifdef ICON_TRANSITION\nin vec2 v_tex_b;\n#endif\nin float v_draw_halo;in vec3 v_gamma_scale_size_fade_opacity;\n#ifdef RENDER_TEXT_AND_SYMBOL\nin float is_sdf;in vec2 v_tex_a_icon;\n#endif\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\n#pragma mapbox: initialize lowp float emissive_strength\nvec4 out_color;float fade_opacity=v_gamma_scale_size_fade_opacity[2];\n#ifdef RENDER_TEXT_AND_SYMBOL\nif (is_sdf==ICON) {vec2 tex_icon=v_tex_a_icon;lowp float alpha=opacity*fade_opacity;glFragColor=texture(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nreturn;}\n#endif\n#ifdef RENDER_SDF\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_gamma_scale_size_fade_opacity.x;float size=v_gamma_scale_size_fade_opacity.y;float fontScale=u_is_text ? size/24.0 : size;out_color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;bool draw_halo=v_draw_halo > 0.0;if (draw_halo) {out_color=halo_color;gamma=(halo_blur*u_scale_factor*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width*u_scale_factor/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,v_tex_a).r;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);out_color*=alpha;\n#else\n#ifdef ICON_TRANSITION\nvec4 a=texture(u_texture,v_tex_a)*(1.0-u_icon_transition);vec4 b=texture(u_texture,v_tex_b)*u_icon_transition;out_color=(a+b);\n#else\nout_color=texture(u_texture,v_tex_a);\n#endif\n#ifdef APPLY_LUT_ON_GPU\nout_color=applyLUT(u_lutTexture,out_color);\n#endif\n#ifdef COLOR_ADJUSTMENT\nout_color=u_color_adj_mat*out_color;\n#endif\n#endif\nout_color*=opacity*fade_opacity;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);\n#ifdef TERRAIN\nout_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#else\nout_color.rgb*=mix(v_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);\n#endif\n#endif\n#endif\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color,v_z_offset);\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\n#define USING_APPEARANCE 1.0\nin vec4 a_pos_offset;in vec4 a_tex_size;in vec4 a_pixeloffset;in vec4 a_projected_pos;in float a_fade_opacity;\n#ifdef Z_OFFSET\nin float a_auto_z_offset;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_globe_anchor;in vec3 a_globe_normal;\n#endif\n#ifdef ICON_TRANSITION\nin vec2 a_texb;\n#endif\n#ifdef OCCLUSION_QUERIES\nin float a_occlusion_query_opacity;\n#endif\n#ifdef ELEVATED_ROADS\nin vec3 a_x_axis;in vec3 a_y_axis;uniform float u_normal_scale;\n#endif\n#ifdef INDICATOR_CUTOUT\nout highp float v_z_offset;\n#else\n#ifdef RENDER_SHADOWS\nout highp float v_z_offset;\n#endif\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_inv_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_elevation_from_sea;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;uniform vec2 u_texsize_icon;uniform bool u_is_halo;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nout vec2 v_tex_a;\n#ifdef ICON_TRANSITION\nout vec2 v_tex_b;\n#endif\nout float v_draw_halo;out vec3 v_gamma_scale_size_fade_opacity;\n#ifdef RENDER_TEXT_AND_SYMBOL\nout float is_sdf;out vec2 v_tex_a_icon;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out highp float v_depth;\n#endif\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n#pragma mapbox: define lowp float emissive_strength\n#pragma mapbox: define lowp float occlusion_opacity\n#pragma mapbox: define lowp float z_offset\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\n#pragma mapbox: initialize lowp float emissive_strength\n#pragma mapbox: initialize lowp float occlusion_opacity\n#pragma mapbox: initialize lowp float z_offset\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);float a_size_max= floor(a_size[1]*0.5);float a_apperance=a_size[1]-2.0*a_size_max;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 (a_apperance==USING_APPEARANCE) {size=a_size_max/128.0;} else if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size_max,u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;float e=u_elevation_from_sea ? z_offset : z_offset+elevation(tile_anchor);\n#ifdef Z_OFFSET\ne+=a_auto_z_offset;\n#endif\nvec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;vec3 world_pos_globe;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos_globe=a_globe_anchor+h;world_pos=mix_globe_mercator(world_pos_globe,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nworld_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetprojected_point;vec2 a;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetprojected_point=u_matrix*vec4(a_globe_anchor+displacement,1);vec4 projected_point_globe=u_matrix*vec4(world_pos_globe,1);a=projected_point_globe.xy/projected_point_globe.w;\n#else\noffsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);a=projected_point.xy/projected_point.w;\n#endif\nvec2 b=offsetprojected_point.xy/offsetprojected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\n#ifdef PROJECTED_POS_ON_VIEWPORT\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xyz+h,1.0);\n#else\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz,mercator_pos,u_zoom_transition)+h;projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0); \n#endif\n#else\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*max(a_min_font_scale,font_scale)+a_pxoffset/16.0);\n#ifdef TERRAIN\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\n#endif\n#ifdef Z_OFFSET\nz+=u_pitch_with_map ? a_auto_z_offset+z_offset : 0.0;\n#else\nz+=u_pitch_with_map ? z_offset : 0.0;\n#endif\nfloat occlusion_fade=globe_occlusion_fade;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float out_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));\n#ifdef DEPTH_OCCLUSION\nfloat depth_occlusion=occlusionFadeMultiSample(projected_point);float depth_occlusion_multplier=mix(occlusion_opacity,1.0,depth_occlusion);out_fade_opacity*=depth_occlusion_multplier;\n#endif\n#ifdef OCCLUSION_QUERIES\nfloat occludedFadeMultiplier=mix(occlusion_opacity,1.0,a_occlusion_query_opacity);out_fade_opacity*=occludedFadeMultiplier;\n#endif\n#ifdef Z_TEST_OCCLUSION\nout_fade_opacity*=occlusion_opacity;\n#endif\nfloat alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);vec3 pos;\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);pos=projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y;\n#else\n#ifdef ELEVATED_ROADS\nvec3 xAxis=vec3(a_x_axis.xy,a_x_axis.z*u_normal_scale);vec3 yAxis=vec3(a_y_axis.xy,a_y_axis.z*u_normal_scale);pos=projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y;\n#else\npos=vec3(projected_pos.xy/projected_pos.w+offset,z);\n#endif\n#endif\ngl_Position=mix(u_coord_matrix*vec4(pos,1.0),AWAY,hidden);float gamma_scale=gl_Position.w;v_draw_halo=(u_is_halo && float(gl_InstanceID)==0.0) ? 1.0 : 0.0;v_gamma_scale_size_fade_opacity=vec3(gamma_scale,size,out_fade_opacity);v_tex_a=a_tex/u_texsize;\n#ifdef RENDER_TEXT_AND_SYMBOL\nis_sdf=a_size[0]-2.0*a_size_min;v_tex_a_icon=a_tex/u_texsize_icon;\n#endif\n#ifdef ICON_TRANSITION\nv_tex_b=a_texb/u_texsize;\n#endif\n#ifdef RENDER_SHADOWS\nvec4 shd_pos=u_inv_matrix*vec4(pos,1.0);vec3 shd_pos0=shd_pos.xyz;vec3 shd_pos1=shd_pos.xyz;\n#ifdef NORMAL_OFFSET\nvec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_offset*shadow_normal_offset_multiplier1();\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);v_depth=gl_Position.w;\n#endif\n#ifdef INDICATOR_CUTOUT\nv_z_offset=e;\n#else\n#ifdef RENDER_SHADOWS\nv_z_offset=e;\n#endif\n#endif\n}'),terrainRaster:os('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image0;\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nuniform sampler2D u_image1;uniform float u_emissive_texture_available;\n#endif\nin 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\nfloat emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : image_color.a;vec3 unlit_base=image_color.rgb*(1.0-emissive_strength);vec3 emissive_base=image_color.rgb*emissive_strength;float ndotl=u_shadow_direction.z;float occlusion=ndotl < 0.0 ? 1.0 : shadow_occlusion(v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,0.0);ndotl=max(0.0,ndotl);vec3 lit=apply_lighting(unlit_base,normal,mix(1.0,(1.0-(u_shadow_intensity*occlusion))*ndotl,cutoffOpacity));vec3 emissive=compute_emissive_draped(emissive_base,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=lit+emissive;color.a=1.0;\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\nfloat emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : image_color.a;color.rgb=mix(color.rgb,image_color.rgb,emissive_strength);color.a=1.0;\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;\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:os("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:os('#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+=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}',Fo),skyboxGradient:os('#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;glFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}',Fo),skyboxCapture:os("\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:os('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image0;\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nuniform sampler2D u_image1;uniform float u_emissive_texture_available;\n#endif\nuniform 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\nhighp vec2 uv=gl_FragCoord.xy/u_viewport;\n#ifdef FLIP_Y\nuv.y=1.0-uv.y;\n#endif\nhighp 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 norm_dist_from_center=1.0-length(closest_point-u_globe_pos)/u_globe_radius;const float antialias_pixel=2.0;highp float antialias_factor=antialias_pixel*fwidth(norm_dist_from_center);highp float antialias=smoothstep(0.0,antialias_factor,norm_dist_from_center);vec4 raster=texture(u_image0,v_pos0);\n#ifdef LIGHTING_3D_MODE\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nfloat emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : raster.a;raster=apply_lighting_with_emission_ground(raster,emissive_strength);color=vec4(clamp(raster.rgb,vec3(0),vec3(1))*antialias,antialias);\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\nfloat emissive_strength=u_emissive_texture_available > 0.5 ? texture(u_image1,v_pos0).r : color.a;color=apply_lighting_with_emission_ground(color,emissive_strength);color.a=1.0;\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:os('#include "_prelude_fog.fragment.glsl"\nuniform float u_transition;uniform highp float u_fadeout_range;uniform highp float u_temporal_offset;uniform vec4 u_atmosphere_fog_color;uniform vec4 u_high_color;uniform vec4 u_space_color;uniform float u_horizon_angle;in highp vec3 v_ray_dir;in highp vec3 v_horizon_dir;void main() {highp vec3 dir=normalize(v_ray_dir);float globe_pos_dot_dir;\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_atmosphere_fog_color.a;float alpha_1=u_high_color.a;float alpha_2=u_space_color.a;vec3 color_stop_0=u_atmosphere_fog_color.rgb;vec3 color_stop_1=u_high_color.rgb;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;glFragColor=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:os('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform float u_opacity;\n#ifdef DITHERED_DISCARD\nuniform float u_dithered_discard_threshold;\n#endif\nuniform vec3 u_lightcolor;uniform vec3 u_lightpos;uniform float u_lightintensity;uniform vec4 u_baseColorFactor;uniform vec4 u_emissiveFactor;uniform float u_metallicFactor;uniform float u_roughnessFactor;uniform float u_emissive_strength;in highp vec4 v_position_height;in lowp vec4 v_color_mix;\n#ifdef RENDER_SHADOWS\nin highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in float v_depth_shadows;\n#endif\n#ifdef OCCLUSION_TEXTURE_TRANSFORM\nuniform vec4 u_occlusionTextureTransform;\n#endif\n#pragma mapbox: define-attribute highp vec3 normal_3f\n#pragma mapbox: define-attribute highp vec3 color_3f\n#pragma mapbox: define-attribute highp vec4 color_4f\n#pragma mapbox: define-attribute highp vec2 uv_2f\n#pragma mapbox: initialize-attribute highp vec3 normal_3f\n#pragma mapbox: initialize-attribute highp vec3 color_3f\n#pragma mapbox: initialize-attribute highp vec4 color_4f\n#pragma mapbox: initialize-attribute highp vec2 uv_2f\n#ifdef HAS_ATTRIBUTE_a_pbr\nin lowp vec4 v_roughness_metallic_emissive_alpha;in mediump vec4 v_height_based_emission_params;\n#endif\n#ifdef HAS_TEXTURE_u_baseColorTexture\nuniform sampler2D u_baseColorTexture;uniform bool u_baseTextureIsAlpha;uniform bool u_alphaMask;uniform float u_alphaCutoff;\n#endif\n#ifdef HAS_TEXTURE_u_metallicRoughnessTexture\nuniform sampler2D u_metallicRoughnessTexture;\n#endif\n#ifdef HAS_TEXTURE_u_occlusionTexture\nuniform sampler2D u_occlusionTexture;uniform float u_aoIntensity;\n#endif\n#ifdef HAS_TEXTURE_u_normalTexture\nuniform sampler2D u_normalTexture;\n#endif\n#ifdef HAS_TEXTURE_u_emissionTexture\nuniform sampler2D u_emissionTexture;\n#endif\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nin highp float v_depth;uniform highp sampler2D u_depthTexture;uniform highp vec2 u_inv_depth_size;uniform highp vec2 u_depth_range_unpack;\n#ifdef DEPTH_D24\nhighp float unpack_depth(highp float depth) {return depth*u_depth_range_unpack.x+u_depth_range_unpack.y;}\n#else\nhighp float unpack_depth_rgba(highp vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}\n#endif\nbool isOccluded() {highp vec2 coord=gl_FragCoord.xy*u_inv_depth_size;\n#ifdef FLIP_Y\ncoord.y=1.0-coord.y;\n#endif\n#ifdef DEPTH_D24\nhighp float depth=unpack_depth(texture(u_depthTexture,coord).r);\n#else\nhighp float depth=unpack_depth_rgba(texture(u_depthTexture,coord));\n#endif\nreturn v_depth > depth+0.0005;}\n#endif\n#define saturate(_x) clamp(_x,0.,1.)\nvec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}float calculate_NdotL(vec3 normal,vec3 lightDir) {const float ext=0.70710678118;return (clamp(dot(normal,lightDir),-ext,1.0)+ext)/(1.0+ext);}vec3 getDiffuseShadedColor(vec3 albedo,vec3 normal,vec3 lightDir,vec3 lightColor)\n{\n#ifdef LIGHTING_3D_MODE\nvec3 transformed_normal=vec3(-normal.xy,normal.z);float lighting_factor;\n#ifdef RENDER_SHADOWS\nlighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);\n#else\nlighting_factor=saturate(dot(transformed_normal,u_lighting_directional_dir));\n#endif\nreturn apply_lighting(albedo,transformed_normal,lighting_factor);\n#else\nvec3 n=normal;float colorvalue=((albedo.x*0.2126)+(albedo.y*0.7152))+(albedo.z*0.0722);vec3 c=vec3(0.03,0.03,0.03);float directional=clamp(dot(n,vec3(lightDir)),0.0,1.0);directional=mix(1.0-u_lightintensity,max((1.0-colorvalue)+u_lightintensity,1.0),directional);vec3 c3=c+clamp((albedo*directional)*lightColor,mix(vec3(0.0),vec3(0.3),vec3(1.0)-lightColor),vec3(1.0));return c3;\n#endif\n}vec4 getBaseColor() {vec4 albedo=u_baseColorFactor;\n#ifdef HAS_ATTRIBUTE_a_color_3f\nalbedo*=vec4(color_3f,1.0);\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\n#else\n#ifdef HAS_ATTRIBUTE_a_color_4f\nalbedo*=color_4f;\n#endif\n#endif\n#if defined (HAS_TEXTURE_u_baseColorTexture) && defined (HAS_ATTRIBUTE_a_uv_2f)\nvec4 texColor=texture(u_baseColorTexture,uv_2f);if(u_alphaMask) {if (texColor.w < u_alphaCutoff) {discard;}}\n#ifdef UNPREMULT_TEXTURE_IN_SHADER\nif(texColor.w > 0.0) {texColor.rgb/=texColor.w;}texColor.w=1.0;\n#endif\nif(u_baseTextureIsAlpha) {if (texColor.r < 0.5) {discard;}} else {texColor.rgb=sRGBToLinear(texColor.rgb);albedo*=texColor;}\n#endif\nvec4 color=vec4(mix(albedo.rgb,v_color_mix.rgb,v_color_mix.a),albedo.a);\n#ifdef APPLY_LUT_ON_GPU\ncolor=applyLUT(u_lutTexture,color);\n#endif\nreturn color;}highp mat3 cotangentFrame(highp vec3 N,highp vec3 p,highp vec2 uv ) {\n#ifdef HAS_TEXTURE_u_normalTexture\nhighp vec3 dp1=vec3(dFdx(p.x),dFdx(p.y),dFdx(p.z));highp vec3 dp2=vec3(dFdy(p.x),dFdy(p.y),dFdy(p.z));highp vec2 duv1=vec2(dFdx(uv.x),dFdx(uv.y));highp vec2 duv2=vec2(dFdy(uv.x),dFdy(uv.y));highp vec3 dp2perp=cross( dp2,N );highp vec3 dp1perp=cross( N,dp1 );highp vec3 T=dp2perp*duv1.x+dp1perp*duv2.x;highp vec3 B=dp2perp*duv1.y+dp1perp*duv2.y;\n#ifdef FLIP_Y\nT=-T;B=-B;\n#endif\nhighp 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#ifdef FLIP_Y\nn=normalize(cross(fdx,fdy));\n#else\nn=normalize(cross(fdx,fdy))*-1.0;\n#endif\n#endif\n#if defined(HAS_TEXTURE_u_normalTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\nvec3 nMap=texture( u_normalTexture,uv_2f).xyz;nMap=normalize(2.0*nMap-vec3(1.0));highp vec3 v=normalize(-v_position_height.xyz);highp mat3 TBN=cotangentFrame(n,v,uv_2f);n=normalize(TBN*nMap);\n#endif\nreturn n;}struct Material {float perceptualRoughness;float alphaRoughness;float metallic;vec3 f90;vec4 baseColor;vec3 diffuseColor;vec3 specularColor;highp vec3 normal;};Material getPBRMaterial() {Material mat;mat.baseColor=getBaseColor();mat.perceptualRoughness=u_roughnessFactor;mat.metallic=u_metallicFactor;\n#ifdef HAS_ATTRIBUTE_a_pbr\nmat.perceptualRoughness=v_roughness_metallic_emissive_alpha.x;mat.metallic=v_roughness_metallic_emissive_alpha.y;mat.baseColor.w*=v_roughness_metallic_emissive_alpha.w;\n#endif\n#if defined(HAS_TEXTURE_u_metallicRoughnessTexture) && defined(HAS_ATTRIBUTE_a_uv_2f) \nvec4 mrSample=texture(u_metallicRoughnessTexture,uv_2f);mat.perceptualRoughness*=mrSample.g;mat.metallic*=mrSample.b;\n#endif\nconst float c_minRoughness=0.04;mat.perceptualRoughness=clamp(mat.perceptualRoughness,c_minRoughness,1.0);mat.metallic=saturate(mat.metallic);mat.alphaRoughness=mat.perceptualRoughness*mat.perceptualRoughness;const vec3 f0=vec3(0.04);mat.diffuseColor=mat.baseColor.rgb*(vec3(1.0)-f0);mat.diffuseColor*=1.0-mat.metallic;mat.specularColor=mix(f0,mat.baseColor.rgb,mat.metallic);highp float reflectance=max(max(mat.specularColor.r,mat.specularColor.g),mat.specularColor.b);highp float reflectance90=saturate(reflectance*25.0);mat.f90=vec3(reflectance90);mat.normal=getNormal();return mat;}float V_GGX(float NdotL,float NdotV,float roughness)\n{float a2=roughness*roughness;float GGXV=NdotL*sqrt(NdotV*NdotV*(1.0-a2)+a2);float GGXL=NdotV*sqrt(NdotL*NdotL*(1.0-a2)+a2);return 0.5/(GGXV+GGXL);}float V_GGXFast(float NdotL,float NdotV,float roughness) {float a=roughness;float GGXV=NdotL*(NdotV*(1.0-a)+a);float GGXL=NdotV*(NdotL*(1.0-a)+a);return 0.5/(GGXV+GGXL);}vec3 F_Schlick(vec3 specularColor,vec3 f90,float VdotH)\n{return specularColor+(f90-specularColor)*pow(clamp(1.0-VdotH,0.0,1.0),5.0);}vec3 F_SchlickFast(vec3 specularColor,float VdotH)\n{float x=1.0-VdotH;float x4=x*x*x*x;return specularColor+(1.0-specularColor)*x4*x;}float D_GGX(highp float NdotH,float alphaRoughness)\n{highp float a4=alphaRoughness*alphaRoughness;highp float f=(NdotH*a4-NdotH)*NdotH+1.0;return a4/(PI*f*f);}vec3 diffuseBurley(Material mat,float LdotH,float NdotL,float NdotV)\n{float f90=2.0*LdotH*LdotH*mat.alphaRoughness-0.5;return (mat.diffuseColor/PI)*(1.0+f90*pow((1.0-NdotL),5.0))*(1.0+f90*pow((1.0-NdotV),5.0));}vec3 diffuseLambertian(Material mat)\n{\n#ifdef LIGHTING_3D_MODE\nreturn mat.diffuseColor;\n#else\nreturn mat.diffuseColor/PI;\n#endif\n}vec3 EnvBRDFApprox(vec3 specularColor,float roughness,highp float NdotV)\n{vec4 c0=vec4(-1,-0.0275,-0.572,0.022);vec4 c1=vec4(1,0.0425,1.04,-0.04);highp vec4 r=roughness*c0+c1;highp float a004=min(r.x*r.x,exp2(-9.28*NdotV))*r.x+r.y;vec2 AB=vec2(-1.04,1.04)*a004+r.zw;return specularColor*AB.x+AB.y;}vec3 computeIndirectLightContribution(Material mat,float NdotV,vec3 normal)\n{vec3 env_light=vec3(0.65,0.65,0.65);\n#ifdef LIGHTING_3D_MODE\nfloat ambient_factor=calculate_ambient_directional_factor(normal);env_light=u_lighting_ambient_color*ambient_factor;\n#endif\nvec3 envBRDF=EnvBRDFApprox(mat.specularColor,mat.perceptualRoughness,NdotV);vec3 indirectSpecular= envBRDF*env_light;vec3 indirectDiffuse=mat.diffuseColor*env_light;return indirectSpecular+indirectDiffuse;}vec3 computeLightContribution(Material mat,vec3 lightPosition,vec3 lightColor)\n{highp vec3 n=mat.normal;highp vec3 v=normalize(-v_position_height.xyz);highp vec3 l=normalize(lightPosition);highp vec3 h=normalize(v+l);float NdotV=clamp(abs(dot(n,v)),0.001,1.0);float NdotL=saturate(dot(n,l));highp float NdotH=saturate(dot(n,h));float VdotH=saturate(dot(v,h));vec3 f=F_SchlickFast(mat.specularColor,VdotH);float g=V_GGXFast(NdotL,NdotV,mat.alphaRoughness);float d=D_GGX(NdotH,mat.alphaRoughness);vec3 diffuseTerm=(1.0-f)*diffuseLambertian(mat);vec3 specularTerm=f*g*d;vec3 transformed_normal=vec3(-n.xy,n.z);float lighting_factor;\n#ifdef RENDER_SHADOWS\nlighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);\n#else\nlighting_factor=NdotL;\n#endif\nvec3 directLightColor=(specularTerm+diffuseTerm)*lighting_factor*lightColor;vec3 indirectLightColor=computeIndirectLightContribution(mat,NdotV,transformed_normal);vec3 color=(saturate(directLightColor)+indirectLightColor);float intensityFactor=1.0;\n#if !defined(LIGHTING_3D_MODE)\nconst vec3 luminosityFactor=vec3(0.2126,0.7152,0.0722);float luminance=dot(diffuseTerm,luminosityFactor);intensityFactor=mix((1.0-u_lightintensity),max((1.0-luminance+u_lightintensity),1.0),NdotL);\n#endif\ncolor*=intensityFactor;return color;}void main() {\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nif (isOccluded()) {discard;}\n#endif\nvec3 lightDir=u_lightpos;vec3 lightColor=u_lightcolor;\n#ifdef LIGHTING_3D_MODE\nlightDir=u_lighting_directional_dir;lightDir.xy=-lightDir.xy;lightColor=u_lighting_directional_color;\n#endif\nvec4 finalColor;\n#ifdef DIFFUSE_SHADED\nvec3 N=getNormal();vec3 baseColor=getBaseColor().rgb;vec3 diffuse=getDiffuseShadedColor(baseColor,N,lightDir,lightColor);\n#ifdef HAS_TEXTURE_u_occlusionTexture\nfloat ao=(texture(u_occlusionTexture,uv_2f).r-1.0)*u_aoIntensity+1.0;diffuse*=ao;\n#endif\nfinalColor=vec4(mix(diffuse,baseColor,u_emissive_strength),1.0)*u_opacity;\n#else\nMaterial mat=getPBRMaterial();vec3 color=computeLightContribution(mat,lightDir,lightColor);float ao=1.0;\n#if defined (HAS_TEXTURE_u_occlusionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\n#ifdef OCCLUSION_TEXTURE_TRANSFORM\nvec2 uv=uv_2f.xy*u_occlusionTextureTransform.zw+u_occlusionTextureTransform.xy;\n#else\nvec2 uv=uv_2f;\n#endif\nao=(texture(u_occlusionTexture,uv).x-1.0)*u_aoIntensity+1.0;color*=ao;\n#endif\nvec4 emissive=u_emissiveFactor;\n#if defined(HAS_TEXTURE_u_emissionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\nemissive.rgb*=sRGBToLinear(texture(u_emissionTexture,uv_2f).rgb);\n#endif\n#ifdef APPLY_LUT_ON_GPU\nfloat emissiveFactorLength=max(length(u_emissiveFactor.rgb),0.001);emissive.rgb=sRGBToLinear(applyLUT(u_lutTexture,linearTosRGB(emissive.rgb/emissiveFactorLength).rbg))*emissiveFactorLength;\n#endif\ncolor+=emissive.rgb;float opacity=mat.baseColor.w*u_opacity;\n#ifdef HAS_ATTRIBUTE_a_pbr\nfloat resEmission=v_roughness_metallic_emissive_alpha.z;resEmission*=v_height_based_emission_params.z+v_height_based_emission_params.w*pow(clamp(v_height_based_emission_params.x,0.0,1.0),v_height_based_emission_params.y);vec3 color_mix=v_color_mix.rgb;\n#ifdef APPLY_LUT_ON_GPU\ncolor_mix=applyLUT(u_lutTexture,color_mix);\n#endif\ncolor=mix(color,color_mix,min(1.0,resEmission));\n#ifdef HAS_ATTRIBUTE_a_color_4f\nfloat distance=length(vec2(1.3*max(0.0,abs(color_4f.x)-color_4f.z),color_4f.y));distance+= mix(0.5,0.0,clamp(resEmission-1.0,0.0,1.0));opacity*=v_roughness_metallic_emissive_alpha.w*saturate(1.0-distance*distance);\n#endif\n#endif\nvec3 unlitColor=mat.baseColor.rgb*ao+emissive.rgb;color=mix(color,unlitColor,u_emissive_strength);color=linearTosRGB(color);color*=opacity;finalColor=vec4(color,opacity);\n#endif\n#ifdef DITHERED_DISCARD\nif (abs(u_dithered_discard_threshold) < 1.0) {float ditherValue=fract(52.9829189*fract(0.06711056*gl_FragCoord.x+0.00583715*gl_FragCoord.y));float compareValue=mix(1.0-ditherValue,ditherValue,step(0.0,u_dithered_discard_threshold));if (abs(u_dithered_discard_threshold) < compareValue) {discard;}}\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,v_position_height.w);\n#endif\n#ifdef FEATURE_CUTOUT\nfinalColor=apply_feature_cutout(finalColor,gl_FragCoord);\n#endif\nglFragColor=finalColor;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin vec3 a_pos_3f;\n#pragma mapbox: define-attribute highp vec3 normal_3f\n#pragma mapbox: define-attribute highp vec2 uv_2f\n#pragma mapbox: define-attribute highp vec3 color_3f\n#pragma mapbox: define-attribute highp vec4 color_4f\n#pragma mapbox: define-attribute-vertex-shader-only highp vec4 pbr\n#pragma mapbox: define-attribute-vertex-shader-only highp vec3 heightBasedEmissiveStrength\nuniform mat4 u_matrix;uniform mat4 u_node_matrix;uniform mat4 u_lighting_matrix;uniform vec3 u_camera_pos;uniform vec4 u_color_mix;\n#ifdef INSTANCED_ARRAYS\nin vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3;\n#else\nuniform highp mat4 u_normal_matrix;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out float v_depth_shadows;\n#endif\nout vec4 v_position_height;out lowp vec4 v_color_mix;\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nout highp float v_depth;\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\nout lowp vec4 v_roughness_metallic_emissive_alpha;out mediump vec4 v_height_based_emission_params;\n#endif\nvec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() {\n#pragma mapbox: initialize-attribute highp vec3 normal_3f\n#pragma mapbox: initialize-attribute highp vec2 uv_2f\n#pragma mapbox: initialize-attribute highp vec3 color_3f\n#pragma mapbox: initialize-attribute highp vec4 color_4f\n#pragma mapbox: initialize-attribute-custom highp vec4 pbr\n#pragma mapbox: initialize-attribute-custom highp vec3 heightBasedEmissiveStrength\nhighp mat4 normal_matrix;\n#ifdef INSTANCED_ARRAYS\nnormal_matrix=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3);\n#else\nnormal_matrix=u_normal_matrix;\n#endif\nvec3 local_pos;mat3 rs;\n#ifdef MODEL_POSITION_ON_GPU\nvec3 pos_color=normal_matrix[0].xyz;vec4 translate=normal_matrix[1];vec3 pos_a=floor(pos_color);vec3 rgb=1.05*(pos_color-pos_a);float hidden=float(pos_a.x > EXTENT);float color_mix=pos_a.z/100.0;v_color_mix=vec4(sRGBToLinear(rgb),color_mix);float meter_to_tile=normal_matrix[0].w;vec4 pos=vec4(pos_a.xy,translate.z,1.0);rs[0].x=normal_matrix[1].w;rs[0].yz=normal_matrix[2].xy;rs[1].xy=normal_matrix[2].zw;rs[1].z=normal_matrix[3].x;rs[2].xyz=normal_matrix[3].yzw;vec4 pos_node=u_lighting_matrix*vec4(a_pos_3f,1.0);vec3 rotated_pos_node=rs*pos_node.xyz;vec3 pos_model_tile=(rotated_pos_node+vec3(translate.xy,0.0))*vec3(meter_to_tile,meter_to_tile,1.0);pos.xyz+=pos_model_tile;local_pos=pos.xyz;gl_Position=mix(u_matrix*pos,AWAY,hidden);pos.z*=meter_to_tile;v_position_height.xyz=pos.xyz-u_camera_pos;\n#else\nlocal_pos=a_pos_3f;gl_Position=u_matrix*vec4(a_pos_3f,1);v_position_height.xyz=vec3(u_lighting_matrix*vec4(a_pos_3f,1));v_color_mix=vec4(sRGBToLinear(u_color_mix.rgb),u_color_mix.a);\n#endif\nv_position_height.w=a_pos_3f.z;\n#ifdef HAS_ATTRIBUTE_a_pbr\nvec4 albedo_c=decode_color(pbr.xy);vec2 e_r_m=unpack_float(pbr.z);vec2 r_m= unpack_float(e_r_m.y*16.0);r_m.r=r_m.r*16.0;v_color_mix=vec4(albedo_c.rgb,1.0);v_roughness_metallic_emissive_alpha=vec4(vec3(r_m,e_r_m.x)/255.0,albedo_c.a);v_roughness_metallic_emissive_alpha.z*=2.0;float heightBasedRelativeIntepolation=a_pos_3f.z*heightBasedEmissiveStrength.x+heightBasedEmissiveStrength.y;v_height_based_emission_params.x=heightBasedRelativeIntepolation;v_height_based_emission_params.y=heightBasedEmissiveStrength.z;vec2 emissionMultiplierValues=unpack_float(pbr.w)/256.0;v_height_based_emission_params.z=emissionMultiplierValues.x;v_height_based_emission_params.w=emissionMultiplierValues.y-emissionMultiplierValues.x;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(local_pos);\n#endif\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nv_depth=gl_Position.z/gl_Position.w;\n#ifdef CLIP_ZERO_TO_ONE\nv_depth=-1.0+2.0*v_depth; \n#endif\n#endif\n#ifdef HAS_ATTRIBUTE_a_normal_3f\n#ifdef MODEL_POSITION_ON_GPU\nfloat x_squared_scale=dot(rs[0],rs[0]);float y_squared_scale=dot(rs[1],rs[1]);float z_squared_scale=dot(rs[2],rs[2]);vec3 squared_scale=vec3(x_squared_scale,y_squared_scale,z_squared_scale);normal_3f=rs*((u_lighting_matrix*vec4(normal_3f,0.0)).xyz/squared_scale);normal_3f=normalize(normal_3f);\n#else\nnormal_3f=vec3(normal_matrix*vec4(normal_3f,0));\n#endif\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\n#ifdef HAS_ATTRIBUTE_a_color_4f\nv_roughness_metallic_emissive_alpha.w=clamp(color_4f.a*v_roughness_metallic_emissive_alpha.w*(v_roughness_metallic_emissive_alpha.z-1.0),0.0,1.0);\n#endif\n#endif\n#ifdef RENDER_SHADOWS\nvec4 shadow_pos=u_node_matrix*vec4(local_pos,1.0);\n#ifdef NORMAL_OFFSET\n#ifdef HAS_ATTRIBUTE_a_normal_3f\n#ifdef MODEL_POSITION_ON_GPU\nvec3 offset=shadow_normal_offset(vec3(-normal_3f.xy,normal_3f.z));shadow_pos.xyz+=offset*shadow_normal_offset_multiplier0();\n#else\nvec3 offset=shadow_normal_offset_model(normal_3f);shadow_pos.xyz+=offset*shadow_normal_offset_multiplier0();\n#endif\n#endif\n#endif\nv_pos_light_view_0=u_light_matrix_0*shadow_pos;v_pos_light_view_1=u_light_matrix_1*shadow_pos;v_depth_shadows=gl_Position.w;\n#endif\n}'),modelDepth:os("in highp float v_depth;void main() {\n#ifndef DEPTH_TEXTURE\nglFragColor=pack_depth(v_depth);\n#endif\n}","in vec3 a_pos_3f;uniform mat4 u_matrix;out highp float v_depth;\n#ifdef MODEL_POSITION_ON_GPU\n#ifdef INSTANCED_ARRAYS\nin vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3;\n#else\nuniform highp mat4 u_instance;\n#endif\nuniform highp mat4 u_node_matrix;\n#endif\nvoid main() {\n#ifdef MODEL_POSITION_ON_GPU\nhighp mat4 instance;\n#ifdef INSTANCED_ARRAYS\ninstance=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3);\n#else\ninstance=u_instance;\n#endif\nvec3 pos_color=instance[0].xyz;vec4 translate=instance[1];vec3 pos_a=floor(pos_color);float hidden=float(pos_a.x > EXTENT);float meter_to_tile=instance[0].w;vec4 pos=vec4(pos_a.xy,translate.z,1.0);mat3 rs;rs[0].x=instance[1].w;rs[0].yz=instance[2].xy;rs[1].xy=instance[2].zw;rs[1].z=instance[3].x;rs[2].xyz=instance[3].yzw;vec4 pos_node=u_node_matrix*vec4(a_pos_3f,1.0);vec3 rotated_pos_node=rs*pos_node.xyz;vec3 pos_model_tile=(rotated_pos_node+vec3(translate.xy,0.0))*vec3(meter_to_tile,meter_to_tile,1.0);pos.xyz+=pos_model_tile;gl_Position=mix(u_matrix*pos,AWAY,hidden);\n#else\ngl_Position=u_matrix*vec4(a_pos_3f,1);\n#endif\nv_depth=gl_Position.z/gl_Position.w;}"),stars:os("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);}"),snowParticle:os("in highp vec2 uv;in highp float alphaMultiplier;uniform vec4 u_particleColor;uniform vec2 u_simpleShapeParameters;void main() {float t=clamp((length(uv)-u_simpleShapeParameters.x)/(1.0-u_simpleShapeParameters.x),0.0,1.0);float alpha=1.0-pow(t,pow(10.0,u_simpleShapeParameters.y));alpha*=alphaMultiplier;alpha*=u_particleColor.a;vec3 color=u_particleColor.rgb*alpha;glFragColor=vec4(color,alpha) ;HANDLE_WIREFRAME_DEBUG;}","\nin highp vec3 a_pos_3f;in highp vec2 a_uv;in highp vec4 a_snowParticleData;in highp vec4 a_snowParticleDataHorizontalOscillation;uniform mat4 u_modelview;uniform mat4 u_projection;uniform vec3 u_cam_pos;uniform vec2 u_screenSize;uniform float u_time;uniform float u_boxSize;uniform float u_velocityConeAperture; \nuniform float u_velocity;uniform vec3 u_direction;uniform float u_horizontalOscillationRadius; \nuniform float u_horizontalOscillationRate; \nuniform float u_billboardSize;uniform vec2 u_thinningCenterPos;uniform vec3 u_thinningShape;uniform float u_thinningAffectedRatio;uniform float u_thinningParticleOffset;out highp vec2 uv;out highp float alphaMultiplier;void main() {vec3 pos=a_pos_3f;float halfBoxSize=0.5*u_boxSize;pos.xyz*=halfBoxSize;pos+=u_cam_pos;float velocityConeApertureRad=radians(u_velocityConeAperture*0.5);float coneAnglePichRad=velocityConeApertureRad*a_snowParticleData.z;float coneAngleHeadingRad=a_snowParticleData.w*radians(360.0);vec3 localZ=normalize(u_direction);vec3 localX=normalize(cross(localZ,vec3(1,0,0)));vec3 localY=normalize(cross(localZ,localX));vec3 direction;direction.x=cos(coneAngleHeadingRad)*sin(coneAnglePichRad);direction.y=sin(coneAngleHeadingRad)*sin(coneAnglePichRad);direction.z=cos(coneAnglePichRad);direction=normalize(direction);vec3 simPosLocal=vec3(0,0,0);float velocityScale=(1.0+3.0*a_snowParticleData.y)*u_velocity;simPosLocal+=direction*velocityScale*u_time;float horizontalOscillationRadius=u_horizontalOscillationRadius*a_snowParticleDataHorizontalOscillation.x;float horizontalOscillationAngle=u_horizontalOscillationRate*u_time*(-1.0+2.0*a_snowParticleDataHorizontalOscillation.y);simPosLocal.xy+=horizontalOscillationRadius*vec2(cos(horizontalOscillationAngle),sin(horizontalOscillationAngle));vec3 simPos=localX*simPosLocal.x+\nlocalY*simPosLocal.y+localZ*simPosLocal.z;pos+=simPos;pos=fract((pos+vec3(halfBoxSize))/vec3(u_boxSize))*u_boxSize-vec3(halfBoxSize);float clipZ=-u_cam_pos.z+pos.z;vec4 posView=u_modelview*vec4(pos,1.0);float size=u_billboardSize;alphaMultiplier=1.0;vec4 posScreen=u_projection*posView;posScreen/=posScreen.w;posScreen.xy=vec2(0.5)+posScreen.xy*0.5;posScreen.xy*=u_screenSize;vec2 thinningCenterPos=u_thinningCenterPos.xy;thinningCenterPos.y=u_screenSize.y-thinningCenterPos.y;float screenDist=length((thinningCenterPos-posScreen.xy)/(0.5*u_screenSize));screenDist+=a_snowParticleData.x*u_thinningParticleOffset;float scaleFactorMode=0.0;float thinningShapeDist=u_thinningShape.x+u_thinningShape.y;if (screenDist < thinningShapeDist) {float thinningFadeRatio=clamp((screenDist-u_thinningShape.x)/u_thinningShape.y,0.0,1.0);thinningFadeRatio=pow(thinningFadeRatio,u_thinningShape.z);if (a_snowParticleData.x < u_thinningAffectedRatio) {scaleFactorMode=1.0-thinningFadeRatio;alphaMultiplier=thinningFadeRatio;}}vec4 posScreen1=u_projection*vec4(posView.x-size,posView.yzw);posScreen1/=posScreen1.w;vec4 posScreen2=u_projection*vec4(posView.x+size,posView.yzw);posScreen2/=posScreen2.w;posScreen1.xy=vec2(0.5)+posScreen1.xy*0.5;posScreen1.xy*=u_screenSize;posScreen2.xy=vec2(0.5)+posScreen2.xy*0.5;posScreen2.xy*=u_screenSize;float screenLength=length(posScreen1.xy-posScreen2.xy);float screenEpsilon=3.0;float scaleFactor=1.0;if (screenLength < screenEpsilon) {scaleFactor=screenEpsilon/max(screenLength,0.01);scaleFactor=mix(scaleFactor,1.0,scaleFactorMode);}float screenEpsilon2=15.0;if (screenLength > screenEpsilon2) {scaleFactor=screenEpsilon2/max(screenLength,0.01);}size*=scaleFactor;vec2 right=size*vec2(1,0);vec2 up=size*vec2(0,1);posView.xy+=right*a_uv.x;posView.xy+=up*a_uv.y;uv=a_uv;gl_Position=u_projection*posView;}"),rainParticle:os("in highp vec2 uv;in highp float particleRandomValue;uniform sampler2D u_texScreen;uniform float u_distortionStrength;uniform vec4 u_color;uniform vec2 u_thinningCenterPos;uniform vec3 u_thinningShape;uniform float u_thinningAffectedRatio;uniform float u_thinningParticleOffset;uniform float u_shapeDirectionalPower;uniform float u_mode;void main() {vec2 st=uv*0.5+vec2(0.5);vec2 uvm=uv;uvm.y=-1.0+2.0*pow(st.y,u_shapeDirectionalPower);float shape=clamp(1.0-length(uvm),0.0,1.0);float alpha=abs(shape)*u_color.a;vec2 screenSize=vec2(textureSize(u_texScreen,0));vec2 thinningCenterPos=u_thinningCenterPos.xy;thinningCenterPos.y=screenSize.y-thinningCenterPos.y;float screenDist=length((thinningCenterPos-gl_FragCoord.xy)/(0.5*screenSize));screenDist+=(0.5+0.5*particleRandomValue)*u_thinningParticleOffset;float thinningShapeDist=u_thinningShape.x+u_thinningShape.y;float thinningAlpha=1.0;if (screenDist < thinningShapeDist) {float thinningFadeRatio=clamp((screenDist-u_thinningShape.x)/u_thinningShape.y,0.0,1.0);thinningFadeRatio=pow(thinningFadeRatio,u_thinningShape.z);thinningAlpha*=thinningFadeRatio;}vec2 offsetXY=normalize(uvm)*abs(shape);vec2 stScreen=(gl_FragCoord.xy+offsetXY*u_distortionStrength*thinningAlpha)/screenSize;vec3 colorScreen=texture(u_texScreen,stScreen).rgb;alpha*=thinningAlpha;glFragColor=mix(vec4(colorScreen,1.0),vec4(u_color.rgb*alpha,alpha),u_mode);HANDLE_WIREFRAME_DEBUG;}","\nin highp vec3 a_pos_3f;in highp vec2 a_uv;in highp vec4 a_rainParticleData;uniform mat4 u_modelview;uniform mat4 u_projection;uniform vec3 u_cam_pos;uniform float u_time;uniform float u_boxSize;uniform float u_velocityConeAperture; \nuniform float u_velocity; \nuniform vec2 u_rainDropletSize;uniform vec3 u_rainDirection;out highp vec2 uv;out highp float particleRandomValue;void main() {vec3 pos=a_pos_3f;float halfBoxSize=0.5*u_boxSize;pos*=halfBoxSize; \npos+=u_cam_pos;float velocityConeApertureRad=radians(u_velocityConeAperture*0.5);float coneAnglePichRad=velocityConeApertureRad*a_rainParticleData.z;float coneAngleHeadingRad=a_rainParticleData.w*radians(360.0);vec3 localZ=normalize(u_rainDirection);vec3 localX=normalize(cross(localZ,vec3(1,0,0)));vec3 localY=normalize(cross(localZ,localX));vec3 directionLocal;directionLocal.x=cos(coneAngleHeadingRad)*sin(coneAnglePichRad);directionLocal.y=sin(coneAngleHeadingRad)*sin(coneAnglePichRad);directionLocal.z=cos(coneAnglePichRad);directionLocal=normalize(directionLocal);vec3 directionWorld=localX*directionLocal.x+localY*directionLocal.y+localZ*directionLocal.z;float velocityScale=(1.0+3.0*a_rainParticleData.y)*u_velocity;vec3 simPosLocal=vec3(0,0,0);simPosLocal+=directionLocal*velocityScale*u_time;vec3 simPos=localX*simPosLocal.x+\nlocalY*simPosLocal.y+localZ*simPosLocal.z;pos+=simPos;pos=fract((pos+vec3(halfBoxSize))/vec3(u_boxSize))*u_boxSize-vec3(halfBoxSize);vec4 posView=u_modelview*vec4(pos,1.0);vec3 directionView=normalize((u_modelview*vec4(directionWorld,0.0)).xyz);vec3 side=cross(directionView,normalize(posView.xyz));posView.xyz+=side*a_uv.x*u_rainDropletSize.x;posView.xyz+=directionView*a_uv.y*u_rainDropletSize.y;uv=a_uv;particleRandomValue=a_rainParticleData.x;gl_Position=u_projection*posView;}"),vignette:os("uniform vec3 u_vignetteShape;uniform vec4 u_vignetteColor;in vec2 st;void main() {float screenDist=length(st);float alpha=clamp((screenDist-u_vignetteShape.x)/u_vignetteShape.y,0.0,1.0);alpha=pow(alpha,u_vignetteShape.z)*u_vignetteColor.a;vec3 color=u_vignetteColor.rgb;glFragColor=vec4(color*alpha,alpha) ;}","in vec2 a_pos_2f;out vec2 st;void main() {st=a_pos_2f;gl_Position=vec4(a_pos_2f,0,1);}"),occlusion:os("uniform vec4 u_color;void main() {glFragColor=u_color;}",'#include "_prelude_terrain.vertex.glsl"\nin highp vec2 a_offset_xy;uniform highp vec3 u_anchorPos;uniform mat4 u_matrix;uniform vec2 u_screenSizePx;uniform vec2 u_occluderSizePx;void main() {vec3 world_pos=u_anchorPos;\n#ifdef TERRAIN\nfloat e=elevation(world_pos.xy);world_pos.z+=e;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1.0);projected_point.xy+=projected_point.w*a_offset_xy*0.5*u_occluderSizePx/u_screenSizePx;gl_Position=projected_point;}')};function is(e,t){const i=e.split("\n");for(let e of i){if(e=e.trimStart(),"#"!==e[0])continue;if(!e.includes("if"))continue;if(e.startsWith("#endif"))continue;const i=e.match(Zo);if(i)for(const e of i)Wo.has(e)||t.add(e);}}function os(e,t){const i=new Set,o=[],s=[];e=e.replace(Ho,(e,t)=>(s.push(t),"")),t=t.replace(Ho,(e,t)=>(o.push(t),""));let r=new Set($o);is(e,r),is(t,r);for(const e of [...o,...s])Ko[e]||(Ko[e]=new Set,is(Xo[e],Ko[e])),r=new Set([...r,...Ko[e]]);return {fragmentSource:e=e.replace(qo,(e,t,o,s,r)=>(i.add(r),"define"===t?`\n#ifndef HAS_UNIFORM_u_${r}\nin ${o} ${s} ${r};\n#else\nuniform ${o} ${s} u_${r};\n#endif\n`:"initialize"===t?`\n#ifdef HAS_UNIFORM_u_${r}\n ${o} ${s} ${r} = u_${r};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${r}\n in ${o} ${s} ${r};\n#endif\n`:"initialize-attribute"===t?"":void 0)),vertexSource:t=t.replace(qo,(e,t,o,s,r)=>{const n=`MATERIAL_ATTRIBUTE_OFFSET_${r}`,a="float"===s?"vec2":s,l=`GET_ATTRIBUTE_${a}(a_${r}, materialInfo, ${n})`,c=r.match(/color/)?"color":a;return "define-attribute-vertex-shader-only"===t?`\n#ifdef HAS_ATTRIBUTE_a_${r}\nin ${o} ${s} a_${r};\n#endif\n`:i.has(r)?"define"===t?`\n#ifndef HAS_UNIFORM_u_${r}\nuniform lowp float u_${r}_t;\n #if !defined(${n})\n in ${o} ${a} a_${r};\n #endif\nout ${o} ${s} ${r};\n#else\nuniform ${o} ${s} u_${r};\n#endif\n`:"initialize"===t?"vec4"===c?`\n#ifndef HAS_UNIFORM_u_${r}\n ${r} = a_${r};\n#else\n ${o} ${s} ${r} = u_${r};\n#endif\n`:`\n#if !defined(HAS_UNIFORM_u_${r})\n #ifdef ${n}\n ${r} = unpack_mix_${c}(${l}, u_${r}_t);\n #else\n ${r} = unpack_mix_${c}(a_${r}, u_${r}_t);\n #endif\n#else\n ${o} ${s} ${r} = u_${r};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${r}\n in ${o} ${s} a_${r};\n out ${o} ${s} ${r};\n#endif\n`:"initialize-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${r}\n ${r} = a_${r};\n#endif\n`:void 0:"define"===t?`\n#ifndef HAS_UNIFORM_u_${r}\nuniform lowp float u_${r}_t;\n #if !defined(${n})\n in ${o} ${a} a_${r};\n #endif\n#else\nuniform ${o} ${s} u_${r};\n#endif\n`:"define-instanced"===t?"mat4"===c?`\n#ifdef INSTANCED_ARRAYS\nin vec4 a_${r}0;\nin vec4 a_${r}1;\nin vec4 a_${r}2;\nin vec4 a_${r}3;\n#else\nuniform ${o} ${s} u_${r};\n#endif\n`:`\n#ifdef INSTANCED_ARRAYS\nin ${o} ${a} a_${r};\n#else\nuniform ${o} ${s} u_${r};\n#endif\n`:"initialize-attribute-custom"===t?`\n#ifdef HAS_ATTRIBUTE_a_${r}\n ${o} ${s} ${r} = a_${r};\n#endif\n`:"vec4"===c?`\n#ifndef HAS_UNIFORM_u_${r}\n #ifdef ${n}\n ${o} ${s} ${r} = ${l};\n #else\n ${o} ${s} ${r} = a_${r};\n #endif\n#else\n ${o} ${s} ${r} = u_${r};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${r}\n #ifdef ${n}\n ${o} ${s} ${r} = unpack_mix_${c}(${l}, u_${r}_t);\n #else\n ${o} ${s} ${r} = unpack_mix_${c}(a_${r}, u_${r}_t);\n #endif\n#else\n ${o} ${s} ${r} = u_${r};\n#endif\n`}),usedDefines:r,vertexIncludes:o,fragmentIncludes:s}}class ss{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null;}bind(e,t,i,o,s,r,n,a){this.context=e;let l=this.boundPaintVertexBuffers.length!==o.length;for(let e=0;!l&&e{const r=o.paint.get("hillshade-shadow-color"),n="none"===o.paint.get("hillshade-shadow-color-use-theme").constantOr("default"),a=o.paint.get("hillshade-highlight-color"),l="none"===o.paint.get("hillshade-highlight-color-use-theme").constantOr("default"),c=o.paint.get("hillshade-accent-color"),h="none"===o.paint.get("hillshade-accent-color-use-theme").constantOr("default"),d=o.paint.get("hillshade-emissive-strength");let u=e.ao(o.paint.get("hillshade-illumination-direction"));if("viewport"===o.paint.get("hillshade-illumination-anchor"))u-=t.transform.angle;else if(t.style&&t.style.enable3dLights()&&t.style.directionalLight){const i=t.style.directionalLight.properties.get("direction"),o=e.d5(i.x,i.y,i.z);u=e.ao(o[1]);}const _=!t.options.moving;return {u_matrix:s||t.transform.calculateProjMatrix(i.tileID.toUnwrapped(),_),u_image:0,u_latrange:rs(0,i.tileID),u_light:[o.paint.get("hillshade-exaggeration"),u],u_shadow:r.toPremultipliedRenderColor(n?null:o.lut),u_highlight:a.toPremultipliedRenderColor(l?null:o.lut),u_emissive_strength:d,u_accent:c.toPremultipliedRenderColor(h?null:o.lut)}})(t,o,s,t.terrain?i.projMatrix:null);t.uploadCommonUniforms(l,_,i.toUnwrapped());const{tileBoundsBuffer:f,tileBoundsIndexBuffer:m,tileBoundsSegments:g}=t.getTileBoundsBuffers(o);_.draw(t,c.TRIANGLES,r,n,a,Ji.disabled,p,s.id,f,m,g);}function as(t,i,o){if(!i.needsDEMTextureUpload)return;const s=t.context,r=s.gl;s.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture=i.demTexture||t.getTileTexture(o.stride);const n=o.getPixels();i.demTexture?i.demTexture.update(n,{premultiply:!1}):i.demTexture=new e.T(s,n,r.R32F,{premultiply:!1}),i.needsDEMTextureUpload=!1;}function ls(t,i,o){const s=t.context,r=s.gl;if(!i.dem)return;const n=i.dem;if(s.activeTexture.set(r.TEXTURE1),as(t,i,n),!i.demTexture)return;i.demTexture.bind(r.NEAREST,r.CLAMP_TO_EDGE);const a=n.dim;s.activeTexture.set(r.TEXTURE0);let l=i.hillshadeFBO;if(!l){const t=new e.T(s,{width:a,height:a,data:null},r.RGBA8);t.bind(r.LINEAR,r.CLAMP_TO_EDGE),l=i.hillshadeFBO=s.createFramebuffer(a,a,1,"renderbuffer"),l.colorAttachment0.set(t.texture);}s.bindFramebuffer.set(l.framebuffer),s.viewport.set([0,0,a,a]);const{tileBoundsBuffer:c,tileBoundsIndexBuffer:h,tileBoundsSegments:d}=t.getMercatorTileBoundsBuffers(),u=[];t.linearFloatFilteringSupported()&&u.push("TERRAIN_DEM_FLOAT_FORMAT"),t.terrain&&t.terrain.renderingToTexture&&"mrt-fallback"===t.emissiveMode&&u.push("USE_MRT1"),t.getOrCreateProgram("hillshadePrepare",{defines:u}).draw(t,r.TRIANGLES,Wi.disabled,Xi.disabled,Zi.unblended,Ji.disabled,((t,i)=>{const o=i.stride,s=e.bD();return e.cf(s,0,e.am,-e.am,0,0,1),e.bs(s,s,[0,-e.am,0]),{u_matrix:s,u_image:1,u_dimension:[o,o],u_zoom:t.overscaledZ}})(i.tileID,n),o.id,c,h,d),i.needsHillshadePrepare=!1;}class cs{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 hs extends cs{getDefault(){return e.ap.transparent.toNonPremultipliedRenderColor(null)}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 ds extends cs{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1);}}class us extends cs{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1);}}class _s extends cs{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 ps extends cs{getDefault(){return !0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1);}}class fs extends cs{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1);}}class ms extends cs{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 gs extends cs{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 vs extends cs{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 ys extends cs{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 xs extends cs{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 bs extends cs{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1);}}class ws extends cs{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 Ts extends cs{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 Es extends cs{getDefault(){return e.ap.transparent.toNonPremultipliedRenderColor(null)}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 Ss extends cs{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 Is extends cs{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 Cs extends cs{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1);}}class Rs extends cs{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1);}}let As=class extends cs{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1);}};class Ds extends cs{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1);}}class Ls extends cs{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 Ps extends cs{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 Os extends cs{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 zs extends cs{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 Ms extends cs{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 Fs extends cs{getDefault(){return null}set(e){const t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1;}}class ks extends cs{getDefault(){return null}set(e){this.gl&&(e!==this.current||this.dirty)&&(this.gl.bindVertexArray(e),this.current=e,this.dirty=!1);}}class Bs extends cs{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 Ns extends cs{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 Us extends cs{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 js extends cs{constructor(e,t){super(e),this.context=e,this.parent=t;}getDefault(){return null}}class Vs extends js{constructor(e,t,i=0){super(e,t),this.attachmentPoint=e.gl.COLOR_ATTACHMENT0+i;}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,this.attachmentPoint,t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1;}}class Gs extends js{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 Hs extends js{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 qs extends Gs{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}const Zs=(e,t,i,o)=>({u_matrix:e,u_image0:0,u_image1:1,u_skirt_height:t,u_ground_shadow_factor:i,u_emissive_texture_available:o}),Ws=(e,t,i,o,s,r,n,a,l,c,h,d,u,_,p,f,m)=>({u_proj_matrix:Float32Array.from(e),u_globe_matrix:t,u_normalize_matrix:Float32Array.from(o),u_merc_matrix:i,u_zoom_transition:s,u_merc_center:r,u_image0:0,u_image1:1,u_frustum_tl:n,u_frustum_tr:a,u_frustum_br:l,u_frustum_bl:c,u_globe_pos:h,u_globe_radius:d,u_viewport:u,u_grid_matrix:m?Float32Array.from(m):new Float32Array(9),u_skirt_height:_,u_far_z_cutoff:p,u_emissive_texture_available:f});function $s(e,t){return null!=e&&null!=t&&!(!e.hasData()||!t.hasData())&&null!=e.demTexture&&null!=t.demTexture&&e.tileID.key!==t.tileID.key}const Xs=new class{constructor(){this.operations={};}newMorphing(e,t,i,o,s){if(e in this.operations){const t=this.operations[e];t.to.tileID.key!==i.tileID.key&&(t.queued=i);}else this.operations[e]={startTime:o,phase:0,duration:s,from:t,to:i,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 i=this.operations[t];for(i.phase=(e-i.startTime)/i.duration;i.phase>=1||!this._validOp(i);)if(!this._nextOp(i,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()}},Ks={0:null,1:"TERRAIN_VERTEX_MORPHING"};function Ys(e,t,i){if(0===t)return 0;const o=t<1&&514===i?.25/t:1;return 6*Math.pow(1.5,22-e)*Math.max(t,1)*o}function Js(e,t){const i=1<({u_matrix:e});function tr(t,i,o,s,r){if(r>0){const n=e.o.now(),a=(n-t.timeAdded)/r,l=i?(n-i.timeAdded)/r:-1,c=o.getSource(),h=s.coveringZoomLevel({tileSize:c.tileSize,roundZoom:c.roundZoom}),d=!i||Math.abs(i.tileID.overscaledZ-h)>Math.abs(t.tileID.overscaledZ-h),u=d&&t.refreshedUponExpiration?1:e.aB(d?a:1-l,0,1);return i?{opacity:1,mix:1-u,isFading:a<1}:{opacity:u,mix:0,isFading:a<1}}return {opacity:1,mix:0,isFading:!1}}class ir extends Ft{constructor(e){const t={type:"raster-dem",maxzoom:Math.ceil(e.transform.maxZoom)},i=mt("mock-dem",t,e.style.dispatcher,e.style);super("mock-dem",i,!1),i.setEventedParent(this),this._sourceLoaded=!0;}_loadTile(e,t){e.state="loaded",t(null);}}class or extends Ft{constructor(e){const t=mt("proxy",{type:"geojson",maxzoom:Math.ceil(e.transform.maxZoom)},e.style.dispatcher,e.style);super("proxy",t,!1),t.setEventedParent(this),this.map=this.getSource().map=e,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={};}update(e,t,i){if(e.freezeTileCoverage)return;this.transform=e;const o=e.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((t,i)=>{if(t[i.key]="",!this._tiles[i.key]){const t=new Pt(i,this._source.tileSize*i.overscaleFactor(),e.tileZoom,void 0,void 0,this._source.worldview);t.state="loaded",this._tiles[i.key]=t;}return t},{});for(const e in this._tiles)e in o||(this.freeFBO(e),this._tiles[e].unloadVectorData(),delete this._tiles[e]);}freeFBO(e){const t=this.proxyCachedFBO[e];if(void 0!==t){const i=Object.values(t);this.renderCachePool.push(...i),delete this.proxyCachedFBO[e];}}deallocRenderCache(){this.renderCache.forEach(e=>e.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={};}}class sr extends e.aR{constructor(e,t,i){super(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y),this.proxyTileKey=t,this.projMatrix=i;}}class rr extends e.bW{constructor(t,i){super(),this._debugParams={sortTilesHiZFirst:!0,disableRenderCache:!1},this.painter=t,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[o,s,r]=function(){const t=new e.be,i=new e.b1,o=131;t.reserve(17161),i.reserve(33800);const s=e.am/128,r=e.am+s/2,n=r+s;for(let i=-s;ir||i<0||i>r?24575:0,n=e.aB(Math.round(o),0,e.am),a=e.aB(Math.round(i),0,e.am);t.emplaceBack(n+s,a);}const a=(e,t)=>{const s=t*o+e;i.emplaceBack(s+1,s,s+o),i.emplaceBack(s+o,s+o+1,s+1);};for(let e=1;e<129;e++)for(let t=1;t<129;t++)a(t,e);return [0,129].forEach(e=>{for(let t=0;t<130;t++)a(t,e),a(e,t);}),[t,i,32768]}(),n=t.context;this.gridBuffer=n.createVertexBuffer(o,e.bg.members),this.gridIndexBuffer=n.createIndexBuffer(s),this.gridSegments=e.bh.simpleSegment(0,0,o.length,s.length),this.gridNoSkirtSegments=e.bh.simpleSegment(0,0,o.length,r),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new or(i.map),this.orthoMatrix=e.bD(),e.cf(this.orthoMatrix,"globe"===this.painter.transform.projection.name?.015:0,e.am,0,e.am,0,1);const a=n.gl;this._overlapStencilMode=new Xi({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=i,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new ir(i.map),this._pendingGroundEffectLayers=[],this._emissiveTexture=!1;}set style(e){e.on("data",this._onStyleDataEvent.bind(this)),this._style=e,this._style.map.on("moveend",()=>{this._clearLineLayersFromRenderCache();});}update(t,i,o){if(t&&t.terrain){this._style!==t&&(this.style=t,this._evaluationZoom=void 0);const s=t.terrain.properties,r=0===t.terrain.drapeRenderMode,n=t.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=e.o.now();const a=t.terrain&&t.terrain.scope,l=s.get("source"),c=r?this._mockSourceCache:t.getSourceCache(l,a);if(!c)return void e.w(`Couldn't find terrain source "${l}".`);if(this.sourceCache=c,this._attenuationRange=t.terrain.getAttenuationRange(),this._exaggeration=n?this.calculateExaggeration(i):s.get("exaggeration"),!i.projection.requiresDraping&&n&&0===this._exaggeration)return void this._disable();this.enabled=!0;const h=()=>{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(i,t,!0),this.resetTileLookupCache(this.sourceCache.id);};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,h(),this._initializing=!0),h(),i.updateElevation(!0,o),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(i),this._emptyDEMTextureDirty=!0,this._previousZoom=i.zoom;}else this._disable();}calculateExaggeration(t){if(this._attenuationRange&&t.zoom>=Math.ceil(this._attenuationRange[1]))return this._style.terrain.getExaggeration(t.zoom);const i=this._previousCameraAltitude,o=t.getFreeCameraOptions().position.z/t.pixelsPerMeter*t.worldSize;this._previousCameraAltitude=o;const s=null!=i?o-i:Number.MAX_VALUE;if(Math.abs(s)<2)return this._exaggeration;const r=t.zoom,n=this._style.terrain;if(!this._previousUpdateTimestamp)return n.getExaggeration(r);let a=r-this._previousZoom;const l=this._previousUpdateTimestamp;let c=r;null!=this._evaluationZoom&&(c=this._evaluationZoom,Math.abs(r-c)>.5&&(a=.5*(r-c+a)),a*s<0&&(c+=a)),this._evaluationZoom=c;const h=n.getExaggeration(c),d=h===n.getExaggeration(Math.max(0,c-.1));if(d&&Math.abs(h-this._exaggeration)<.01)return h;let u=Math.min(.1,.00375*(this._updateTimestamp-l));return (d||h<.1||Math.abs(a)<1e-4)&&(u=Math.min(.2,4*u)),e.al(this._exaggeration,h,u)}resetTileLookupCache(e){this._findCoveringTileCache[e]={};}attenuationRange(){return this._attenuationRange}getDemUpscale(){return this.proxySourceCache.getSource().tileSize/128}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_onStyleDataEvent(e){"source"===e.dataType&&e.coord?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._emptyDEMTextureDirty=!0,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.pool.forEach(e=>e.fb.destroy()),this.pool=[],this.framebufferCopyTexture&&this.framebufferCopyTexture.destroy();}_source(){return this.enabled?this.sourceCache:null}isUsingMockSource(){return this.sourceCache===this._mockSourceCache}exaggeration(){return this.enabled?this._exaggeration:0}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const 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 i=this.proxySourceCache,o=this.painter.transform;this._initializing&&(this._initializing=0===o._centerAltitude&&-1===this.getAtPointOrZero(e.af.fromLngLat(o.center),-1),this._emptyDEMTextureDirty=!this._initializing);const s=this.proxyCoords=i.getIds().map(e=>{const t=i.getTileByID(e).tileID;return t.projMatrix=o.calculateProjMatrix(t.toUnwrapped()),t});!function(t,i){const o=i.transform.pointCoordinate(i.transform.getCameraPoint()),s=new e.P(o.x,o.y);t.sort((t,i)=>{if(i.overscaledZ-t.overscaledZ)return i.overscaledZ-t.overscaledZ;const o=new e.P(t.canonical.x+(1<{this.proxyToSource[e.key]={};}),this.terrainTileForTile={};const n=this._style._mergedSourceCaches;for(const e in n){const i=n[e];if(!i.used)continue;if(i!==this.sourceCache&&this.resetTileLookupCache(i.id),this._setupProxiedCoordsForOrtho(i,t[e],r),i.usedForTerrain)continue;const o=t[e];(i.getSource().reparseOverscaled||i._isRasterElevatedOverTerrain)&&this._assignTerrainTiles(o);}this.proxiedCoords[i.id]=s.map(e=>new sr(e,e.key,this.orthoMatrix)),this._assignTerrainTiles(s),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(r),this.renderingToTexture=!1;const a={};this._visibleDemTiles=[];for(const e of this.proxyCoords){const t=this.terrainTileForTile[e.key];if(!t)continue;const i=t.tileID.key;i in a||(this._visibleDemTiles.push(t),a[i]=i);}}_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 i in this.terrainTileForTile){const o=this.terrainTileForTile[i],s=o.dem;!s||o.demTexture&&!o.needsDEMTextureUpload||(e.activeTexture.set(t.TEXTURE1),as(this.painter,o,s));}}_prepareDemTileUniforms(e,t,i,o){if(!t||null==t.demTexture)return !1;const s=e.tileID.canonical,r=Math.pow(2,t.tileID.canonical.z-s.z),n=o||"";return i[`u_dem_tl${n}`]=[s.x*r%1,s.y*r%1],i[`u_dem_scale${n}`]=r,!0}get emptyDEMTexture(){return !this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}_getLoadedAreaMinimum(){if(!this.enabled)return 0;let e=0;const t=this._visibleDemTiles.reduce((t,i)=>{if(!i.dem)return t;const o=i.dem.tree.minimums[0];return o>0&&e++,t+o},0);return e?t/e:0}_updateEmptyDEMTexture(){const t=this.painter.context,i=t.gl;t.activeTexture.set(i.TEXTURE2);const o=this._getLoadedAreaMinimum(),s=new e.dN({width:1,height:1},new Float32Array([o]));this._emptyDEMTextureDirty=!1;let r=this._emptyDEMTexture;return r?r.update(s,{premultiply:!1}):r=this._emptyDEMTexture=new e.T(t,s,i.R32F,{premultiply:!1}),r}setupElevationDraw(t,i,o){const s=this.painter.context,r=s.gl,n={u_dem:2,u_dem_prev:4,u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_depth_range_unpack:[0,1],u_occluder_half_size:16,u_occlusion_depth_offset:-1e-4,u_exaggeration:0};n.u_exaggeration=this.exaggeration();let a=null,l=null,c=1;if(o&&o.morphing&&this._useVertexMorphing){const e=o.morphing.srcDemTile,i=o.morphing.dstDemTile;c=o.morphing.phase,e&&i&&(this._prepareDemTileUniforms(t,e,n,"_prev")&&(l=e),this._prepareDemTileUniforms(t,i,n)&&(a=i));}const h=e=>e&&e.demTexture&&this.painter.linearFloatFilteringSupported()?r.LINEAR:r.NEAREST;let d=null;var u;if(this.enabled?l&&a?(d=a.demTexture,s.activeTexture.set(r.TEXTURE4),l.demTexture.bind(h(l),r.CLAMP_TO_EDGE),n.u_dem_lerp=c):(a=this.terrainTileForTile[t.tileID.key],d=this._prepareDemTileUniforms(t,a,n)?a.demTexture:this.emptyDEMTexture):d=this.emptyDEMTexture,s.activeTexture.set(r.TEXTURE2),d&&(n.u_dem_size=1===(u=d).size[0]?1:u.size[0]-2,d.bind(h(a),r.CLAMP_TO_EDGE)),this.painter.setupDepthForOcclusion(o&&o.useDepthForOcclusion,i,n),o&&o.useMeterToDem&&a){const t=(1<{if(c===i)return;const o=[Ks[i],"PROJECTION_GLOBE_VIEW"];d&&o.push("CUSTOM_ANTIALIASING");const s=t.isTileAffectedByFog(e);l=t.getOrCreateProgram("globeRaster",{defines:o,overrideFog:s}),c=i;},_=t.colorModeForRenderPass(),p=new Wi(a.LEQUAL,Wi.ReadWrite,t.depthRangeFor3D);Xs.update(r);const f=e.dH(h),m=[e.aG(h.center.lng),e.aK(h.center.lat)],g=t.globeSharedBuffers,v=[h.width*e.o.devicePixelRatio,h.height*e.o.devicePixelRatio],y=Float32Array.from(h.globeMatrix),x={useDenormalizedUpVectorScale:!0};{const h=t.transform,d=Ys(h.zoom,i.exaggeration(),i.sourceCache._source.tileSize);c=-1;const b=a.TRIANGLES;for(const c of s){const s=o.getTile(c),w=Xi.disabled,T=i.prevTerrainTileForTile[c.key],E=i.terrainTileForTile[c.key];$s(T,E)&&Xs.newMorphing(c.key,T,E,r,250),Qs(t,s.emissiveTexture),n.activeTexture.set(a.TEXTURE0),s.texture&&s.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const S=Xs.getMorphValuesForProxy(c.key),I=S?1:0;S&&Object.assign(x,{morphing:{srcDemTile:S.from,dstDemTile:S.to,phase:e.dF(S.phase)}});const C=e.dI(c.canonical),R=e.dJ(C.getCenter().lat),A=e.dK(c.canonical,C,R,h.worldSize/h._pixelsPerMercatorPixel),D=e.bl(e.dL(c.canonical)),L="mrt-fallback"===t.emissiveMode?1:0,P=Ws(h.expandedFarZProjMatrix,y,f,D,e.ak(h.zoom),m,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,v,d,h._farZ,L,A);if(u(c,I),l&&(i.setupElevationDraw(s,l,x),t.uploadCommonUniforms(n,l,c.toUnwrapped()),g)){const[e,i,o]=g.getGridBuffers(R,0!==d);l.draw(t,b,p,w,_,Ji.backCCW,P,"globe_raster",e,i,o);}}}if(g&&(t.renderDefaultNorthPole||t.renderDefaultSouthPole)){const r=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];d&&r.push("CUSTOM_ANTIALIASING"),l=t.getOrCreateProgram("globeRaster",{defines:r});for(const r of s){const{x:s,y:c,z:d}=r.canonical,u=0===c,f=c===(1<e.draw(t,a.TRIANGLES,p,Xi.disabled,_,Ji.disabled,Ws(h.expandedFarZProjMatrix,g,g,E,0,m,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,v,0,h._farZ,S),"globe_pole_raster",i,w,T);i.setupElevationDraw(c,l,x),t.uploadCommonUniforms(n,l,r.toUnwrapped()),u&&t.renderDefaultNorthPole&&I(l,y),f&&t.renderDefaultSouthPole&&(g=e.cT(e.bD(),g,[1,-1,1]),I(l,b));}}}}(t,i,o,s,r);else {const n=t.context,a=n.gl;let l,c;const h=t.shadowRenderer,d=lo(t,t.longestCutoffRange),u=e=>{if(c===e)return;const i=[];i.push(Ks[e]),d.shouldRenderCutoff&&i.push("RENDER_CUTOFF"),h&&(i.push("RENDER_SHADOWS","DEPTH_TEXTURE"),h.useNormalOffset&&i.push("NORMAL_OFFSET")),l=t.getOrCreateProgram("terrainRaster",{defines:i}),c=e;},_=t.colorModeForRenderPass(),p=new Wi(a.LEQUAL,Wi.ReadWrite,t.depthRangeFor3D);Xs.update(r);const f=t.transform,m=Ys(f.zoom,i.exaggeration(),i.sourceCache._source.tileSize);let g=[0,0,0];if(h){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(g=mo(t.style,e,i));}{c=-1;const v=a.TRIANGLES,[y,x]=[i.gridIndexBuffer,i.gridSegments];for(const c of s){const s=o.getTile(c),b=Xi.disabled,w=i.prevTerrainTileForTile[c.key],T=i.terrainTileForTile[c.key];$s(w,T)&&Xs.newMorphing(c.key,w,T,r,250),Qs(t,s.emissiveTexture),n.activeTexture.set(a.TEXTURE0),s.texture&&s.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const E=Xs.getMorphValuesForProxy(c.key),S=E?1:0;let I;E&&(I={morphing:{srcDemTile:E.from,dstDemTile:E.to,phase:e.dF(E.phase)}});const C="mrt-fallback"===t.emissiveMode?1:0,R=Zs(c.projMatrix,Js(c.canonical,f.renderWorldCopies)?m/10:m,g,C);if(u(S),!l)continue;i.setupElevationDraw(s,l,I);const A=c.toUnwrapped();h&&h.setupShadows(A,l),t.uploadCommonUniforms(n,l,A,null,d),l.draw(t,v,p,b,_,Ji.backCCW,R,"terrain_raster",i.gridBuffer,y,x);}}}}(i,this,this.proxySourceCache,t,this._updateTimestamp),this.renderingToTexture=!0,i.gpuTimingDeferredRenderEnd(),t.splice(0,t.length));}renderBatch(t){if(0===this._drapedRenderBatches.length)return t+1;this.renderingToTexture=!0;const i=this.painter,o=this.painter.context,s=this.proxySourceCache,r=this.proxiedCoords[s.id],n=this._drapedRenderBatches.shift(),a=i.style.order,l=[];this._updateFBOs("mrt-fallback"===i.emissiveMode);let c=0;for(const h of r){const r=s.getTileByID(h.proxyTileKey),d=s.proxyCachedFBO[h.key]?s.proxyCachedFBO[h.key][t]:void 0,u=void 0!==d?s.renderCache[d]:this.pool[c++],_=void 0!==d;if(r.texture=u.tex,r.emissiveTexture=u.emissiveTex,_&&!u.dirty){l.push(r.tileID);continue}o.bindFramebuffer.set(u.fb.framebuffer);const p=o.gl;let f;p.drawBuffers("mrt-fallback"===i.emissiveMode?[p.COLOR_ATTACHMENT0,p.COLOR_ATTACHMENT1]:[p.COLOR_ATTACHMENT0]),this.renderedToTile=!1,u.dirty&&(o.clear({color:e.ap.transparent,stencil:0}),u.dirty=!1);for(let e=n.start;e<=n.end;++e){const t=i.style._mergedLayers[a[e]];if(t.isHidden(i.transform.zoom))continue;const s=i.style.getLayerSourceCache(t),r=s?this.proxyToSource[h.key][s.id]:[h];if(!r)continue;const n=r;o.viewport.set([0,0,u.fb.width,u.fb.height]),f!==(s?s.id:null)&&(this._setupStencil(u,r,t,s),f=s?s.id:null),i.renderLayer(i,s,t,n);}if(p.drawBuffers([p.COLOR_ATTACHMENT0]),0===this._drapedRenderBatches.length)for(const e of this._pendingGroundEffectLayers){const t=i.style._mergedLayers[a[e]];if(t.isHidden(i.transform.zoom))continue;const s=i.style.getLayerSourceCache(t),r=s?this.proxyToSource[h.key][s.id]:[h];if(!r)continue;const n=r;o.viewport.set([0,0,u.fb.width,u.fb.height]),f!==(s?s.id:null)&&(this._setupStencil(u,r,t,s),f=s?s.id:null),i.renderLayer(i,s,t,n);}this.renderedToTile?(u.dirty=!0,l.push(r.tileID)):_||--c,5===c&&(c=0,this.renderToBackBuffer(l));}return this.renderToBackBuffer(l),this.renderingToTexture=!1,o.bindFramebuffer.set(null),o.viewport.set([0,0,i.width,i.height]),n.end+1}postRender(){}isLayerOrderingCorrect(e){const t=e.order.length;let i=-1,o=t;for(let s=0;si}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,i){if(!this._visibleDemTiles)return null;const o=this._visibleDemTiles.filter(e=>e.dem).map(o=>{const s=o.tileID,r=1<(null!==e.t?e.t:Number.MAX_VALUE)-(null!==t.t?t.t:Number.MAX_VALUE));for(const s of o){if(null==s.t)return null;const o=s.tile.dem.tree.raycast(s.minx,s.miny,s.maxx,s.maxy,e,t,i);if(null!=o)return o}return null}_createFBO(){const t=this.painter.context,i=t.gl,o=this.drapeBufferSize;t.activeTexture.set(i.TEXTURE0);const s=new e.T(t,{width:o[0],height:o[1],data:null},i.RGBA8);s.bind(i.LINEAR,i.CLAMP_TO_EDGE);const r=t.createFramebuffer(o[0],o[1],1,null);let n;return r.colorAttachment0.set(s.texture),this._emissiveTexture&&(n=new e.T(t,{width:o[0],height:o[1],data:null},i.R8),n.bind(i.LINEAR,i.CLAMP_TO_EDGE),r.createColorAttachment(t,1),r.colorAttachment1.set(n.texture)),r.depthAttachment=new qs(t,r.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=t.createRenderbuffer(t.gl.DEPTH_STENCIL,o[0],o[1]),this._stencilRef=0,r.depthAttachment.set(this._sharedDepthStencil),t.clear({stencil:0})):r.depthAttachment.set(this._sharedDepthStencil),t.extTextureFilterAnisotropic&&i.texParameterf(i.TEXTURE_2D,t.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,t.extTextureFilterAnisotropicMax),{fb:r,tex:s,emissiveTex:n,dirty:!1}}_updateFBOs(e){if(this._emissiveTexture!==e){for(const t of this.pool)this._updateFBO(t,e);for(const t of this.proxySourceCache.renderCache)this._updateFBO(t,e);this._emissiveTexture=e;}}_updateFBO(t,i){const o=t.fb,s=this.painter.context,r=s.gl,n=this.drapeBufferSize;if(i){const i=new e.T(s,{width:n[0],height:n[1],data:null},r.R8);i.bind(r.LINEAR,r.CLAMP_TO_EDGE),t.emissiveTex=i,o.createColorAttachment(s,1),o.colorAttachment1.set(i.texture);}else t.emissiveTex=void 0,o.removeColorAttachment(s,1);t.dirty=!0;}_initFBOPool(){for(;this.pool.length{const t=this._style._mergedLayers[e],i=t.isHidden(this.painter.transform.zoom);return "hillshade"===t.type||"custom"===t.type?!i&&t.shouldRedrape():!i&&t.hasTransition()})}_clearLineLayersFromRenderCache(){let t=!1;for(const e of this._style.getSources())if(e instanceof dt){t=!0;break}if(!t)return;const i={};for(let t=0;te>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=o;}_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 i=0;i=0;s--){const r=i[s];if(t.getTileByID(r.key),void 0!==t.proxyCachedFBO[r.key]){const i=e[r.key],s=this.proxyToSource[r.key];let n=0;for(const e in s){const t=s[e],r=i[e];if(!r||r.length!==t.length||t.some((t,i)=>t!==r[i]||o[e]&&o[e].hasOwnProperty(t.key))){n=-1;break}++n;}for(const e in t.proxyCachedFBO[r.key])t.renderCache[t.proxyCachedFBO[r.key][e]].dirty=n<0||n!==Object.values(i).length;}}const s=[...this._drapedRenderBatches];s.sort((e,t)=>t.end-t.start-(e.end-e.start));for(const e of s)for(const o of i){if(t.proxyCachedFBO[o.key])continue;let i=t.renderCachePool.pop();void 0===i&&t.renderCache.length<50&&(i=t.renderCache.length,t.renderCache.push(this._createFBO())),void 0!==i&&(t.proxyCachedFBO[o.key]={},t.proxyCachedFBO[o.key][e.start]=i,t.renderCache[i].dirty=!0);}this._tilesDirty={};}_setupStencil(e,t,i,o){if(!o||!this._sourceTilesOverlap[o.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const s=this.painter.context,r=s.gl;if(t.length<=1)return void(this._overlapStencilType=!1);let n;if(i.isTileClipped())n=t.length,this._overlapStencilMode.test={func:r.EQUAL,mask:255},this._overlapStencilType="Clip";else {if(!(t[0].overscaledZ>t[t.length-1].overscaledZ))return void(this._overlapStencilType=!1);n=1,this._overlapStencilMode.test={func:r.GREATER,mask:255},this._overlapStencilType="Mask";}this._stencilRef+n>255&&(s.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=n,this._overlapStencilMode.ref=this._stencilRef,i.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):Xi.disabled}_renderTileClippingMasks(e,t){const i=this.painter,o=this.painter.context,s=o.gl;i._tileClippingMaskIDs={},o.setColorMode(Zi.disabled),o.setDepthMode(Wi.disabled);const r=i.getOrCreateProgram("clippingMask");for(const o of e){const e=i._tileClippingMaskIDs[o.key]=--t;r.draw(i,s.TRIANGLES,Wi.disabled,new Xi({func:s.ALWAYS,mask:0},e,255,s.KEEP,s.KEEP,s.REPLACE),Zi.disabled,Ji.disabled,er(o.projMatrix),"$clipping",i.tileExtentBuffer,i.quadTriangleIndexBuffer,i.tileExtentSegments);}}pointCoordinate(t){const i=this.painter.transform;if(t.x<0||t.x>i.width||t.y<0||t.y>i.height)return null;const o=[t.x,t.y,1,1];e.aD(o,o,i.pixelMatrixInverse),e.cL(o,o,1/o[3]),o[0]/=i.worldSize,o[1]/=i.worldSize;const s=i._camera.position,r=e.cg(1,i.center.lat),n=[s[0],s[1],s[2]/r,0],a=e.db([],o.slice(0,3),n);e.ax(a,a);const l=this.raycast(n,a,this._exaggeration);return null!==l&&l?(e.bI(n,n,a,l),n[3]=n[2],n[2]*=r,n):null}_setupProxiedCoordsForOrtho(t,i,o){if(t.getSource()instanceof e.aV)return this._setupProxiedCoordsForImageSource(t,i,o);this._findCoveringTileCache[t.id]=this._findCoveringTileCache[t.id]||{};const s=this.proxiedCoords[t.id]=[],r=this.proxyCoords;for(let e=0;et.overscaledZ-e.overscaledZ);}_setupProxiedCoordsForImageSource(t,i,o){if(!t.getSource().loaded())return;const s=this.proxiedCoords[t.id]=[],r=this.proxyCoords,n=t.getSource(),a=n.tileID;if(!a)return;const l=new e.P(a.x,a.y)._div(1<(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)}),h=(t,i)=>{const o=t.wrap+t.canonical.x/(1<n+c.max.x||s+ra+c.max.y};for(let e=0;ee.key===i.tileID.key);if(e)return e}if(i.tileID.key!==t.key){const o=t.canonical.z-i.tileID.canonical.z;let r,n,a;s=e.bD();const l=i.tileID.wrap-t.wrap<0?(r=e.am>>o,n=r*((i.tileID.canonical.x<=s){const o=t.canonical.z-s;i.getSource().reparseOverscaled?(a=Math.max(t.canonical.z+2,i.transform.tileZoom),n=new e.aR(a,t.wrap,s,t.canonical.x>>o,t.canonical.y>>o)):0!==o&&(a=s,n=new e.aR(a,t.wrap,s,t.canonical.x>>o,t.canonical.y>>o));}n.key!==t.key&&(c.push(n.key),o=i.getTile(n));}const h=e=>{c.forEach(t=>{s[t]=e;}),c.length=0;};for(a-=1;a>=l&&(!o||!o.hasData());a--){o&&h(o.tileID.key);const e=n.calculateScaledKey(a);if(o=i.getTileByID(e),o&&o.hasData())break;const t=s[e];if(null===t)break;void 0===t?c.push(e):o=i.getTileByID(t);}return h(o?o.tileID.key:null),o&&o.hasData()?o:null}findDEMTileFor(e){return this.enabled?this._findTileCoveringTileID(e,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0;}_clearRenderCacheForTile(e,t){let i=this._tilesDirty[e];i||(i=this._tilesDirty[e]={}),i[t.key]=!0;}}function nr(t,i,o){const s=function(t,i,o){const s=e.bK(i,t),r=e.bK(o,[.2126,.7152,.0722]),n=(e,t,i)=>(1-i)*e+i*t,a=n(1-.3*Math.min(r,1),1,Math.min(s+1,1));return n(.92,1,Math.asin(e.aB(i[2],-1,1))/Math.PI+.5)*a}(t,[0,0,1],i),r=[0,0,0];e.c6(r,o.slice(0,3),s);const n=[0,0,0];e.c6(n,i.slice(0,3),t[2]);const a=[0,0,0];return e.d9(a,r,n),e.dc(a)}const ar=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],lr=["stars","rainParticle","snowParticle","fillExtrusion","fillExtrusionGroundEffect","building","buildingBloom","elevatedStructures","model","symbol"];class cr{static cacheKey(e,t,i,o){const s=[t];o&&s.push(o.cacheKey);for(const t of i)e.usedDefines.has(t)&&s.push(t);return s.join("/")}constructor(t,i,o,s,r,n){const a=t.gl;this.program=a.createProgram(),this.configuration=s,this.name=i,this.fixedDefines=[...n];const l=`#version 300 es\n${(s?s.defines():[]).concat(n.map(e=>`#define ${e}`)).join("\n")}`,c=[l,Qo];for(const e of o.fragmentIncludes)c.push(Xo[e]);c.push(o.fragmentSource);const h=c.join("\n"),d=[l,es];for(const e of o.vertexIncludes)d.push(Xo[e]);this.forceManualRenderingForInstanceIDShaders=t.forceManualRenderingForInstanceIDShaders&&o.vertexSource.includes("gl_InstanceID"),this.forceManualRenderingForInstanceIDShaders&&d.push("uniform int u_instanceID;"),d.push(o.vertexSource);let u=d.join("\n");this.forceManualRenderingForInstanceIDShaders&&(u=u.replaceAll("gl_InstanceID","u_instanceID"));const _=a.createShader(a.FRAGMENT_SHADER);if(a.isContextLost())return void(this.failedToCreate=!0);a.shaderSource(_,h),a.compileShader(_),a.attachShader(this.program,_);const p=a.createShader(a.VERTEX_SHADER);a.isContextLost()?this.failedToCreate=!0:(a.shaderSource(p,u),a.compileShader(p),a.attachShader(this.program,p),this.attributes={},a.linkProgram(this.program),a.deleteShader(p),a.deleteShader(_),this.fixedUniforms=r(t),this.fixedUniformsEntries=Object.entries(this.fixedUniforms),this.binderUniforms=s?s.getUniforms(t):[],this.forceManualRenderingForInstanceIDShaders&&(this.instancingUniforms=(t=>({u_instanceID:new e.ci(t)}))(t)),(n.includes("TERRAIN")||n.includes("ELEVATED")||i.includes("symbol")||i.includes("circle"))&&(this.terrainUniforms=(t=>({u_dem:new e.ci(t),u_dem_prev:new e.ci(t),u_dem_tl:new e.cl(t),u_dem_scale:new e.ck(t),u_dem_tl_prev:new e.cl(t),u_dem_scale_prev:new e.ck(t),u_dem_size:new e.ck(t),u_dem_lerp:new e.ck(t),u_exaggeration:new e.ck(t),u_depth:new e.ci(t),u_depth_size_inv:new e.cl(t),u_depth_range_unpack:new e.cl(t),u_occluder_half_size:new e.ck(t),u_occlusion_depth_offset:new e.ck(t),u_meter_to_dem:new e.ck(t),u_label_plane_matrix_inv:new e.cm(t)}))(t)),n.includes("GLOBE")&&(this.globeUniforms=(t=>({u_tile_tl_up:new e.cj(t),u_tile_tr_up:new e.cj(t),u_tile_br_up:new e.cj(t),u_tile_bl_up:new e.cj(t),u_tile_up_scale:new e.ck(t)}))(t)),n.includes("FOG")&&(this.fogUniforms=(t=>({u_fog_matrix:new e.cm(t),u_fog_range:new e.cl(t),u_fog_color:new e.d4(t),u_fog_horizon_blend:new e.ck(t),u_fog_vertical_limit:new e.cl(t),u_fog_temporal_offset:new e.ck(t),u_frustum_tl:new e.cj(t),u_frustum_tr:new e.cj(t),u_frustum_br:new e.cj(t),u_frustum_bl:new e.cj(t),u_globe_pos:new e.cj(t),u_globe_radius:new e.ck(t),u_globe_transition:new e.ck(t),u_is_globe:new e.ci(t),u_viewport:new e.cl(t)}))(t)),n.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(t=>({u_cutoff_params:new e.d4(t)}))(t)),n.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(t=>({u_lighting_ambient_color:new e.cj(t),u_lighting_directional_dir:new e.cj(t),u_lighting_directional_color:new e.cj(t),u_ground_radiance:new e.cj(t)}))(t)),n.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(t=>({u_light_matrix_0:new e.cm(t),u_light_matrix_1:new e.cm(t),u_fade_range:new e.cl(t),u_shadow_normal_offset:new e.cj(t),u_shadow_intensity:new e.ck(t),u_shadow_texel_size:new e.ck(t),u_shadow_map_resolution:new e.ck(t),u_shadow_direction:new e.cj(t),u_shadow_bias:new e.cj(t),u_shadowmap_0:new e.ci(t),u_shadowmap_1:new e.ci(t)}))(t)));}getAttributeLocation(e,t){let i=this.attributes[t];return void 0===i&&(i=this.attributes[t]=e.getAttribLocation(this.program,t)),i}setTerrainUniformValues(e,t){if(!this.terrainUniforms)return;const i=this.terrainUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e]&&i[e].set(this.program,e,t[e]);}}setGlobeUniformValues(e,t){if(!this.globeUniforms)return;const i=this.globeUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e]&&i[e].set(this.program,e,t[e]);}}setFogUniformValues(e,t){if(!this.fogUniforms)return;const i=this.fogUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e]);}}setCutoffUniformValues(e,t){if(!this.cutoffUniforms)return;const i=this.cutoffUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e]);}}setLightsUniformValues(e,t){if(!this.lightsUniforms)return;const i=this.lightsUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e]);}}setShadowUniformValues(e,t){if(this.failedToCreate||!this.shadowUniforms)return;const i=this.shadowUniforms;e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e]);}_drawDebugWireframe(t,i,o,s,r,n,a,l,c,h){const d=t.options.wireframe;if(!1===d.terrain&&!1===d.layers2D&&!1===d.layers3D)return;const u=t.context;if(!(()=>!(!d.terrain||"terrainRaster"!==this.name&&"globeRaster"!==this.name)||!(!d.layers2D||t._terrain&&t._terrain.renderingToTexture||!ar.includes(this.name))||!(!d.layers3D||!lr.includes(this.name)))())return;const _=u.gl,p=t.wireframeDebugCache.getLinesFromTrianglesBuffer(t.frameCounter,r,u);if(!p)return;const f=[...this.fixedDefines,"DEBUG_WIREFRAME"],m=t.getOrCreateProgram(this.name,{config:this.configuration,defines:f});u.program.set(m.program);const g=(e,t,i)=>{if(t[e]&&i[e])for(const o in t[e])i[e][o]&&i[e][o].set(i.program,o,t[e][o].current);};c&&c.setUniforms(m.program,u,m.binderUniforms,a,{zoom:l}),g("fixedUniforms",this,m),g("terrainUniforms",this,m),g("globeUniforms",this,m),g("fogUniforms",this,m),g("lightsUniforms",this,m),g("shadowUniforms",this,m),p.bind(),u.setColorMode(new Zi([_.ONE,_.ONE_MINUS_SRC_ALPHA,_.ZERO,_.ONE],e.ap.transparent,[!0,!0,!0,!1])),u.setDepthMode(new Wi(i.func===_.LESS?_.LEQUAL:i.func,Wi.ReadOnly,i.range)),u.setStencilMode(Xi.disabled);const v=3*n.primitiveLength*2,y=3*n.primitiveOffset*2*2;if(this.forceManualRenderingForInstanceIDShaders){const e=h||1;for(let t=0;t1?_.drawElementsInstanced(_.LINES,v,_.UNSIGNED_SHORT,y,h):_.drawElements(_.LINES,v,_.UNSIGNED_SHORT,y);r.bind(),u.program.set(this.program),u.setDepthMode(i),u.setStencilMode(o),u.setColorMode(s);}checkUniforms(e,t,i){if(this.fixedDefines.includes(t))for(const o of Object.keys(i))if(!i[o].initialized)throw new Error(`Program '${this.name}', from draw '${e}': uniform ${o} not set but required by ${t} being defined`)}draw(e,t,i,o,s,r,n,a,l,c,h,d,u,_,p,f){const m=e.context,g=m.gl;if(this.failedToCreate)return;m.program.set(this.program),m.setDepthMode(i),m.setStencilMode(o),m.setColorMode(s),m.setCullFace(r);for(const[e,t]of this.fixedUniformsEntries)t.set(this.program,e,n[e]);_&&_.setUniforms(this.program,m,this.binderUniforms,d,{zoom:u});const v={[g.POINTS]:1,[g.LINES]:2,[g.TRIANGLES]:3,[g.LINE_STRIP]:1}[t];this.checkUniforms(a,"RENDER_SHADOWS",this.shadowUniforms);const y=p||[],x=_?_.getPaintVertexBuffers():[],b=t===g.TRIANGLES&&c,w=f&&f>0?1:void 0;for(const r of h.get()){const n=r.vaos||(r.vaos={});if((n[a]||(n[a]=new ss)).bind(m,this,l,x,c,r.vertexOffset,y,w),this.forceManualRenderingForInstanceIDShaders){const e=f||1;for(let i=0;i1?g.drawElementsInstanced(t,r.primitiveLength*v,g.UNSIGNED_SHORT,r.primitiveOffset*v*2,f):c?g.drawElements(t,r.primitiveLength*v,g.UNSIGNED_SHORT,r.primitiveOffset*v*2):g.drawArrays(t,r.vertexOffset,r.vertexLength);b&&this._drawDebugWireframe(e,i,o,s,c,r,d,u,_,f);}}}function hr(t,i,o=0){const s=Math.pow(2,i.tileID.overscaledZ),r=i.tileSize*Math.pow(2,t.transform.tileZoom)/s,n=r*(i.tileID.canonical.x+i.tileID.wrap*s),a=r*i.tileID.canonical.y;return {u_image:0,u_texsize:i.imageAtlasTexture?i.imageAtlasTexture.size:[0,0],u_tile_units_to_pixels:1/e.az(i,1,t.transform.tileZoom),u_pixel_coord_upper:[n>>16,a>>16],u_pixel_coord_lower:[65535&n,65535&a],u_pattern_transition:o}}const dr={terrain:0,flat:1},ur=e.bD(),_r=(t,i,o,s,r,n,a,l,c,h,d,u,_,p,f,m,g,v)=>{const y=i.style.light,x=y.properties.get("position"),b=[x.x,x.y,x.z],w=e.dQ();"viewport"===y.properties.get("anchor")&&(e.dR(w,-i.transform.angle),e.dS(b,b,w));const T=y.properties.get("color").toPremultipliedRenderColor(null),E=i.transform,S={u_matrix:t,u_lightpos:b,u_lightintensity:y.properties.get("intensity"),u_lightcolor:[T.r,T.g,T.b],u_vertical_gradient:+o,u_opacity:s,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:ur,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_height_type:dr[h],u_base_type:dr[d],u_ao:r,u_edge_radius:n,u_width_scale:a,u_flood_light_color:f,u_vertical_scale:m,u_flood_light_intensity:g,u_ground_shadow_factor:v};return "globe"===E.projection.name&&(S.u_tile_id=[l.canonical.x,l.canonical.y,1<({u_matrix:e,u_edge_radius:t,u_width_scale:i,u_vertical_scale:o,u_height_type:dr[s],u_base_type:dr[r]}),fr=(e,t,i,o,s,r,n,a,l,c,h,d,u,_,p,f,m,g)=>{const v=_r(e,t,i,o,s,r,n,a,c,h,d,u,_,p,f,m,1,[0,0,0]),y={u_height_factor:-Math.pow(2,a.overscaledZ)/l.tileSize/8};return Object.assign(v,hr(t,l,g),y)},mr=(e,t,i)=>({u_matrix:e,u_emissive_strength:t,u_ground_shadow_factor:i}),gr=(e,t,i,o,s,r=0)=>Object.assign(mr(e,t,s),hr(i,o,r)),vr=(e,t,i,o)=>({u_matrix:e,u_world:i,u_emissive_strength:t,u_ground_shadow_factor:o}),yr=(e,t,i,o,s,r,n=0)=>Object.assign(gr(e,t,i,o,r,n),{u_world:s}),xr=(e,t)=>({u_matrix:e,u_depth_bias:t}),br=(e,t)=>({u_matrix:e,u_ground_shadow_factor:t}),wr=(e,t,i,o,s)=>({u_matrix:e,u_camera_pos:[t[0],t[1],t[2]],u_depth_bias:i,u_height_scale:o,u_reset_depth:s}),Tr=(e,t,i,o,s,r,n,a,l)=>({u_matrix:e,u_normal_matrix:t,u_opacity:i,u_faux_facade_ao_intensity:o,u_camera_pos:s,u_tile_to_meter:r,u_facade_emissive_chance:n,u_flood_light_color:a,u_flood_light_intensity:l}),Er=e=>({u_matrix:e}),Sr=e=>({u_matrix:e}),Ir=(t,i,o,s,r,n,a,l)=>{const c=e.am/n.tileSize;return {u_matrix:t,u_inv_rot_matrix:i,u_camera_to_center_distance:o.getCameraToCenterDistance(l),u_extrude_scale:[o.pixelsToGLUnits[0]/c,o.pixelsToGLUnits[1]/c],u_zoom_transition:s,u_tile_id:a,u_merc_center:r}},Cr=(e,t,i,o)=>({u_matrix:e,u_inv_matrix:t,u_camera_to_center_distance:i.getCameraToCenterDistance(o),u_viewport_size:[i.width,i.height]}),Rr=(e,t,i=1)=>({u_matrix:e,u_color:t,u_overlay:0,u_overlay_scale:i}),Ar=e.bD(),Dr=(t,i,o,s,r,n,a)=>{const l=t.transform,c="globe"===l.projection.name,h=c?e.dT(l.zoom,i.canonical)*l._pixelsPerMercatorPixel:e.az(o,1,n),d={u_matrix:i.projMatrix,u_extrude_scale:h,u_intensity:a,u_inv_rot_matrix:Ar,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(c){d.u_inv_rot_matrix=s,d.u_merc_center=r,d.u_tile_id=[i.canonical.x,i.canonical.y,1<({u_matrix:i,u_normalize_matrix:o,u_globe_matrix:s,u_merc_matrix:r,u_grid_matrix:n,u_tl_parent:a,u_scale_parent:d,u_fade_t:u.mix,u_opacity:u.opacity*_.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:_.paint.get("raster-brightness-min"),u_brightness_high:_.paint.get("raster-brightness-max"),u_saturation_factor:e.dV(_.paint.get("raster-saturation")),u_contrast_factor:e.dU(_.paint.get("raster-contrast")),u_spin_weights:Mr(_.paint.get("raster-hue-rotate")),u_perspective_transform:p,u_raster_elevation:f,u_zoom_transition:l,u_merc_center:c,u_cutoff_params:h,u_colorization_mix:Lr(e.dW,g,y),u_colorization_offset:Pr(e.dW,v,y),u_color_ramp:m,u_texture_offset:[b/(x+2*b),x/(x+2*b)],u_texture_res:[x+2*b,x+2*b],u_emissive_strength:w,u_zbias_factor:Or(t)});function Mr(e){e*=Math.PI/180;const t=Math.sin(e),i=Math.cos(e);return [(2*i+1)/3,(-Math.sqrt(3)*t-i+1)/3,(Math.sqrt(3)*t-i+1)/3]}const Fr=.05,kr=(e,t,i,o,s,r,n,a,l,c,h,d)=>({u_matrix:e,u_normalize_matrix:t,u_globe_matrix:i,u_merc_matrix:o,u_grid_matrix:s,u_tl_parent:r,u_scale_parent:c,u_fade_t:h.mix,u_opacity:h.opacity,u_image0:0,u_image1:1,u_raster_elevation:d,u_zoom_transition:n,u_merc_center:a,u_cutoff_params:l}),Br=(e,t,i,o,s,r,n,a,l,c)=>({u_particle_texture:e,u_particle_texture_side_len:t,u_tile_offset:i,u_velocity:o,u_color_ramp:r,u_velocity_res:s,u_max_speed:n,u_uv_offset:a,u_data_scale:[255*l[0],255*l[1]],u_data_offset:c,u_particle_pos_scale:1.1,u_particle_pos_offset:[Fr,Fr]}),Nr=(e,t,i,o,s,r,n,a,l,c)=>({u_particle_texture:e,u_particle_texture_side_len:t,u_velocity:i,u_velocity_res:o,u_max_speed:s,u_speed_factor:r,u_reset_rate:n,u_rand_seed:Math.random(),u_uv_offset:a,u_data_scale:[255*l[0],255*l[1]],u_data_offset:c,u_particle_pos_scale:1.1,u_particle_pos_offset:[Fr,Fr]}),Ur=e.bD(),jr=(t,i,o,s,r,n,a,l,c,h,d,u,_,p,f,m,g,v,y,x,b,w,T,E)=>{const S=r.transform,I={u_is_size_zoom_constant:+("constant"===t||"source"===t),u_is_size_feature_constant:+("constant"===t||"camera"===t),u_size_t:i?i.uSizeT:0,u_size:i?i.uSize:0,u_camera_to_center_distance:S.getCameraToCenterDistance(y),u_rotate_symbol:+o,u_aspect_ratio:S.width/S.height,u_fade_change:r.options.fadeDuration?r.symbolFadeChange:1,u_matrix:n,u_label_plane_matrix:a,u_coord_matrix:l,u_is_text:+h,u_elevation_from_sea:c?1:0,u_pitch_with_map:+s,u_texsize:d,u_texsize_icon:u,u_texture:0,u_texture_icon:1,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Ur,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:Ur,u_up_vector:[0,-1,0],u_color_adj_mat:w,u_icon_transition:T||0,u_gamma_scale:s?r.transform.getCameraToCenterDistance(y)*Math.cos(r.terrain?0:r.transform._pitch):1,u_device_pixel_ratio:e.o.devicePixelRatio,u_is_halo:1,u_scale_factor:E||1,u_ground_shadow_factor:x,u_inv_matrix:e.bm(e.bD(),a),u_normal_scale:b,u_lutTexture:10};return "globe"===y.name&&(I.u_tile_id=[p.canonical.x,p.canonical.y,1<({u_matrix:e,u_emissive_strength:t,u_opacity:i,u_color:o}),Gr=(t,i,o,s,r,n,a,l,c)=>Object.assign(function(t,i,o,s,r,n){const{width:a,height:l}=s.imageManager.getPixelSize(i),c=Math.pow(2,n.tileID.overscaledZ),h=n.tileSize*Math.pow(2,s.transform.tileZoom)/c,d=h*(n.tileID.canonical.x+n.tileID.wrap*c),u=h*n.tileID.canonical.y;return {u_image:0,u_pattern_tl:o.tl,u_pattern_br:o.br,u_texsize:[a,l],u_pattern_size:o.displaySize,u_pattern_units_to_pixels:r?[s.transform.width,-1*s.transform.height]:[1/e.az(n,1,s.transform.tileZoom),1/e.az(n,1,s.transform.tileZoom)],u_pixel_coord_upper:[d>>16,u>>16],u_pixel_coord_lower:[65535&d,65535&u]}}(0,n,a,s,l,c),{u_matrix:t,u_emissive_strength:i,u_opacity:o}),Hr=new Float32Array(e.bB([])),qr=(t,i,o,s,r,n,a,l,c,h,d,u,_,p=[0,0,0],f,m,g)=>{const v=r.style.light,y=v.properties.get("position"),x=[-y.x,-y.y,y.z],b=e.dQ();"viewport"===v.properties.get("anchor")&&(e.dR(b,-r.transform.angle),e.dS(x,x,b));const w="MASK"===d.alphaMode,T=v.properties.get("color").toNonPremultipliedRenderColor(null),E=_.paint.get("model-ambient-occlusion-intensity"),S=_.paint.get("model-color").constantOr(e.ap.white).toNonPremultipliedRenderColor(null);return S.a=_.paint.get("model-color-mix-intensity").constantOr(0),g&&(S.r=g[0],S.g=g[1],S.b=g[2],S.a=g[3]),m&&(S.r=m.color.r,S.g=m.color.g,S.b=m.color.b,S.a=m.colorMix,u=m.emissionStrength,n*=m.opacity),{u_matrix:t,u_lighting_matrix:i,u_normal_matrix:o,u_node_matrix:s||Hr,u_lightpos:x,u_lightintensity:v.properties.get("intensity"),u_lightcolor:[T.r,T.g,T.b],u_camera_pos:p,u_opacity:n,u_baseTextureIsAlpha:0,u_alphaMask:+w,u_alphaCutoff:d.alphaCutoff,u_baseColorFactor:a.toNonPremultipliedRenderColor(null).toArray01(),u_emissiveFactor:l.toNonPremultipliedRenderColor(null).toArray01(),u_metallicFactor:c,u_roughnessFactor:h,u_baseColorTexture:5,u_metallicRoughnessTexture:6,u_normalTexture:7,u_occlusionTexture:8,u_emissionTexture:9,u_lutTexture:10,u_color_mix:S.toArray01(),u_aoIntensity:E,u_emissive_strength:u,u_occlusionTextureTransform:f||[0,0,0,0]}},Zr=(e,t=Hr,i=Hr)=>({u_matrix:e,u_instance:t,u_node_matrix:i}),Wr={fillExtrusion:t=>({u_matrix:new e.cm(t),u_lightpos:new e.cj(t),u_lightintensity:new e.ck(t),u_lightcolor:new e.cj(t),u_vertical_gradient:new e.ck(t),u_opacity:new e.ck(t),u_edge_radius:new e.ck(t),u_width_scale:new e.ck(t),u_ao:new e.cl(t),u_height_type:new e.ci(t),u_base_type:new e.ci(t),u_tile_id:new e.cj(t),u_zoom_transition:new e.ck(t),u_inv_rot_matrix:new e.cm(t),u_merc_center:new e.cl(t),u_up_dir:new e.cj(t),u_height_lift:new e.ck(t),u_flood_light_color:new e.cj(t),u_vertical_scale:new e.ck(t),u_flood_light_intensity:new e.ck(t),u_ground_shadow_factor:new e.cj(t)}),fillExtrusionDepth:t=>({u_matrix:new e.cm(t),u_edge_radius:new e.ck(t),u_width_scale:new e.ck(t),u_vertical_scale:new e.ck(t),u_height_type:new e.ci(t),u_base_type:new e.ci(t)}),fillExtrusionPattern:t=>({u_matrix:new e.cm(t),u_lightpos:new e.cj(t),u_lightintensity:new e.ck(t),u_lightcolor:new e.cj(t),u_vertical_gradient:new e.ck(t),u_height_factor:new e.ck(t),u_edge_radius:new e.ck(t),u_width_scale:new e.ck(t),u_ao:new e.cl(t),u_height_type:new e.ci(t),u_base_type:new e.ci(t),u_tile_id:new e.cj(t),u_zoom_transition:new e.ck(t),u_inv_rot_matrix:new e.cm(t),u_merc_center:new e.cl(t),u_up_dir:new e.cj(t),u_height_lift:new e.ck(t),u_image:new e.ci(t),u_texsize:new e.cl(t),u_pixel_coord_upper:new e.cl(t),u_pixel_coord_lower:new e.cl(t),u_tile_units_to_pixels:new e.ck(t),u_opacity:new e.ck(t),u_pattern_transition:new e.ck(t)}),fillExtrusionGroundEffect:t=>({u_matrix:new e.cm(t),u_opacity:new e.ck(t),u_ao_pass:new e.ck(t),u_meter_to_tile:new e.ck(t),u_ao:new e.cl(t),u_flood_light_intensity:new e.ck(t),u_flood_light_color:new e.cj(t),u_attenuation:new e.ck(t),u_edge_radius:new e.ck(t),u_fb:new e.ci(t),u_fb_size:new e.ck(t),u_dynamic_offset:new e.ck(t)}),fill:t=>({u_matrix:new e.cm(t),u_emissive_strength:new e.ck(t),u_ground_shadow_factor:new e.cj(t)}),fillPattern:t=>({u_matrix:new e.cm(t),u_emissive_strength:new e.ck(t),u_image:new e.ci(t),u_texsize:new e.cl(t),u_pixel_coord_upper:new e.cl(t),u_pixel_coord_lower:new e.cl(t),u_tile_units_to_pixels:new e.ck(t),u_ground_shadow_factor:new e.cj(t),u_pattern_transition:new e.ck(t)}),fillOutline:t=>({u_matrix:new e.cm(t),u_emissive_strength:new e.ck(t),u_world:new e.cl(t),u_ground_shadow_factor:new e.cj(t)}),fillOutlinePattern:t=>({u_matrix:new e.cm(t),u_emissive_strength:new e.ck(t),u_world:new e.cl(t),u_image:new e.ci(t),u_texsize:new e.cl(t),u_pixel_coord_upper:new e.cl(t),u_pixel_coord_lower:new e.cl(t),u_tile_units_to_pixels:new e.ck(t),u_ground_shadow_factor:new e.cj(t),u_pattern_transition:new e.ck(t)}),building:t=>({u_matrix:new e.cm(t),u_normal_matrix:new e.cm(t),u_opacity:new e.ck(t),u_faux_facade_ao_intensity:new e.ck(t),u_camera_pos:new e.cj(t),u_tile_to_meter:new e.ck(t),u_facade_emissive_chance:new e.ck(t),u_flood_light_color:new e.cj(t),u_flood_light_intensity:new e.ck(t)}),buildingBloom:t=>({u_matrix:new e.cm(t)}),buildingDepth:t=>({u_matrix:new e.cm(t)}),elevatedStructuresDepth:t=>({u_matrix:new e.cm(t),u_depth_bias:new e.ck(t)}),elevatedStructures:t=>({u_matrix:new e.cm(t),u_ground_shadow_factor:new e.cj(t)}),elevatedStructuresDepthReconstruct:t=>({u_matrix:new e.cm(t),u_camera_pos:new e.cj(t),u_depth_bias:new e.ck(t),u_height_scale:new e.ck(t),u_reset_depth:new e.ck(t)}),circle:e.d_,collisionBox:t=>({u_matrix:new e.cm(t),u_inv_rot_matrix:new e.cm(t),u_camera_to_center_distance:new e.ck(t),u_extrude_scale:new e.cl(t),u_zoom_transition:new e.ck(t),u_merc_center:new e.cl(t),u_tile_id:new e.cj(t)}),collisionCircle:t=>({u_matrix:new e.cm(t),u_inv_matrix:new e.cm(t),u_camera_to_center_distance:new e.ck(t),u_viewport_size:new e.cl(t)}),debug:t=>({u_color:new e.dD(t),u_matrix:new e.cm(t),u_overlay:new e.ci(t),u_overlay_scale:new e.ck(t)}),clippingMask:t=>({u_matrix:new e.cm(t)}),heatmap:t=>({u_extrude_scale:new e.ck(t),u_intensity:new e.ck(t),u_matrix:new e.cm(t),u_inv_rot_matrix:new e.cm(t),u_merc_center:new e.cl(t),u_tile_id:new e.cj(t),u_zoom_transition:new e.ck(t),u_up_dir:new e.cj(t)}),heatmapTexture:t=>({u_image:new e.ci(t),u_color_ramp:new e.ci(t),u_opacity:new e.ck(t)}),hillshade:t=>({u_matrix:new e.cm(t),u_image:new e.ci(t),u_latrange:new e.cl(t),u_light:new e.cl(t),u_shadow:new e.dD(t),u_highlight:new e.dD(t),u_emissive_strength:new e.ck(t),u_accent:new e.dD(t)}),hillshadePrepare:t=>({u_matrix:new e.cm(t),u_image:new e.ci(t),u_dimension:new e.cl(t),u_zoom:new e.ck(t)}),line:e.dZ,linePattern:e.dY,raster:t=>({u_matrix:new e.cm(t),u_normalize_matrix:new e.cm(t),u_globe_matrix:new e.cm(t),u_merc_matrix:new e.cm(t),u_grid_matrix:new e.dE(t),u_tl_parent:new e.cl(t),u_scale_parent:new e.ck(t),u_fade_t:new e.ck(t),u_opacity:new e.ck(t),u_image0:new e.ci(t),u_image1:new e.ci(t),u_brightness_low:new e.ck(t),u_brightness_high:new e.ck(t),u_saturation_factor:new e.ck(t),u_contrast_factor:new e.ck(t),u_spin_weights:new e.cj(t),u_perspective_transform:new e.cl(t),u_raster_elevation:new e.ck(t),u_zoom_transition:new e.ck(t),u_merc_center:new e.cl(t),u_cutoff_params:new e.d4(t),u_colorization_mix:new e.d4(t),u_colorization_offset:new e.ck(t),u_color_ramp:new e.ci(t),u_texture_offset:new e.cl(t),u_texture_res:new e.cl(t),u_emissive_strength:new e.ck(t),u_zbias_factor:new e.ck(t)}),rasterParticle:t=>({u_matrix:new e.cm(t),u_normalize_matrix:new e.cm(t),u_globe_matrix:new e.cm(t),u_merc_matrix:new e.cm(t),u_grid_matrix:new e.dE(t),u_tl_parent:new e.cl(t),u_scale_parent:new e.ck(t),u_fade_t:new e.ck(t),u_opacity:new e.ck(t),u_image0:new e.ci(t),u_image1:new e.ci(t),u_raster_elevation:new e.ck(t),u_zoom_transition:new e.ck(t),u_merc_center:new e.cl(t),u_cutoff_params:new e.d4(t)}),rasterParticleTexture:t=>({u_texture:new e.ci(t),u_opacity:new e.ck(t)}),rasterParticleDraw:t=>({u_particle_texture:new e.ci(t),u_particle_texture_side_len:new e.ck(t),u_tile_offset:new e.cl(t),u_velocity:new e.ci(t),u_color_ramp:new e.ci(t),u_velocity_res:new e.cl(t),u_max_speed:new e.ck(t),u_uv_offset:new e.cl(t),u_data_scale:new e.cl(t),u_data_offset:new e.ck(t),u_particle_pos_scale:new e.ck(t),u_particle_pos_offset:new e.cl(t)}),rasterParticleUpdate:t=>({u_particle_texture:new e.ci(t),u_particle_texture_side_len:new e.ck(t),u_velocity:new e.ci(t),u_velocity_res:new e.cl(t),u_max_speed:new e.ck(t),u_speed_factor:new e.ck(t),u_reset_rate:new e.ck(t),u_rand_seed:new e.ck(t),u_uv_offset:new e.cl(t),u_data_scale:new e.cl(t),u_data_offset:new e.ck(t),u_particle_pos_scale:new e.ck(t),u_particle_pos_offset:new e.cl(t)}),symbol:t=>({u_is_size_zoom_constant:new e.ci(t),u_is_size_feature_constant:new e.ci(t),u_size_t:new e.ck(t),u_size:new e.ck(t),u_camera_to_center_distance:new e.ck(t),u_rotate_symbol:new e.ci(t),u_aspect_ratio:new e.ck(t),u_fade_change:new e.ck(t),u_matrix:new e.cm(t),u_label_plane_matrix:new e.cm(t),u_coord_matrix:new e.cm(t),u_is_text:new e.ci(t),u_elevation_from_sea:new e.ci(t),u_pitch_with_map:new e.ci(t),u_texsize:new e.cl(t),u_texsize_icon:new e.cl(t),u_texture:new e.ci(t),u_texture_icon:new e.ci(t),u_gamma_scale:new e.ck(t),u_device_pixel_ratio:new e.ck(t),u_tile_id:new e.cj(t),u_zoom_transition:new e.ck(t),u_inv_rot_matrix:new e.cm(t),u_merc_center:new e.cl(t),u_camera_forward:new e.cj(t),u_tile_matrix:new e.cm(t),u_up_vector:new e.cj(t),u_ecef_origin:new e.cj(t),u_is_halo:new e.ci(t),u_icon_transition:new e.ck(t),u_color_adj_mat:new e.cm(t),u_scale_factor:new e.ck(t),u_ground_shadow_factor:new e.cj(t),u_inv_matrix:new e.cm(t),u_normal_scale:new e.ck(t),u_lutTexture:new e.ci(t)}),background:t=>({u_matrix:new e.cm(t),u_emissive_strength:new e.ck(t),u_opacity:new e.ck(t),u_color:new e.dD(t)}),backgroundPattern:t=>({u_matrix:new e.cm(t),u_emissive_strength:new e.ck(t),u_opacity:new e.ck(t),u_image:new e.ci(t),u_pattern_tl:new e.cl(t),u_pattern_br:new e.cl(t),u_texsize:new e.cl(t),u_pattern_size:new e.cl(t),u_pixel_coord_upper:new e.cl(t),u_pixel_coord_lower:new e.cl(t),u_pattern_units_to_pixels:new e.cl(t)}),terrainRaster:t=>({u_matrix:new e.cm(t),u_image0:new e.ci(t),u_image1:new e.ci(t),u_skirt_height:new e.ck(t),u_ground_shadow_factor:new e.cj(t),u_emissive_texture_available:new e.ck(t)}),skybox:t=>({u_matrix:new e.cm(t),u_sun_direction:new e.cj(t),u_cubemap:new e.ci(t),u_opacity:new e.ck(t),u_temporal_offset:new e.ck(t)}),skyboxGradient:t=>({u_matrix:new e.cm(t),u_color_ramp:new e.ci(t),u_center_direction:new e.cj(t),u_radius:new e.ck(t),u_opacity:new e.ck(t),u_temporal_offset:new e.ck(t)}),skyboxCapture:t=>({u_matrix_3f:new e.dE(t),u_sun_direction:new e.cj(t),u_sun_intensity:new e.ck(t),u_color_tint_r:new e.d4(t),u_color_tint_m:new e.d4(t),u_luminance:new e.ck(t)}),globeRaster:t=>({u_proj_matrix:new e.cm(t),u_globe_matrix:new e.cm(t),u_normalize_matrix:new e.cm(t),u_merc_matrix:new e.cm(t),u_zoom_transition:new e.ck(t),u_merc_center:new e.cl(t),u_image0:new e.ci(t),u_image1:new e.ci(t),u_grid_matrix:new e.dE(t),u_skirt_height:new e.ck(t),u_far_z_cutoff:new e.ck(t),u_frustum_tl:new e.cj(t),u_frustum_tr:new e.cj(t),u_frustum_br:new e.cj(t),u_frustum_bl:new e.cj(t),u_globe_pos:new e.cj(t),u_globe_radius:new e.ck(t),u_viewport:new e.cl(t),u_emissive_texture_available:new e.ck(t)}),globeAtmosphere:t=>({u_frustum_tl:new e.cj(t),u_frustum_tr:new e.cj(t),u_frustum_br:new e.cj(t),u_frustum_bl:new e.cj(t),u_horizon:new e.ck(t),u_transition:new e.ck(t),u_fadeout_range:new e.ck(t),u_atmosphere_fog_color:new e.d4(t),u_high_color:new e.d4(t),u_space_color:new e.d4(t),u_temporal_offset:new e.ck(t),u_horizon_angle:new e.ck(t)}),model:t=>({u_matrix:new e.cm(t),u_lighting_matrix:new e.cm(t),u_normal_matrix:new e.cm(t),u_node_matrix:new e.cm(t),u_lightpos:new e.cj(t),u_lightintensity:new e.ck(t),u_lightcolor:new e.cj(t),u_camera_pos:new e.cj(t),u_opacity:new e.ck(t),u_baseColorFactor:new e.d4(t),u_emissiveFactor:new e.d4(t),u_metallicFactor:new e.ck(t),u_roughnessFactor:new e.ck(t),u_baseTextureIsAlpha:new e.ci(t),u_alphaMask:new e.ci(t),u_alphaCutoff:new e.ck(t),u_baseColorTexture:new e.ci(t),u_metallicRoughnessTexture:new e.ci(t),u_normalTexture:new e.ci(t),u_occlusionTexture:new e.ci(t),u_emissionTexture:new e.ci(t),u_lutTexture:new e.ci(t),u_color_mix:new e.d4(t),u_aoIntensity:new e.ck(t),u_emissive_strength:new e.ck(t),u_occlusionTextureTransform:new e.d4(t)}),modelDepth:t=>({u_matrix:new e.cm(t),u_instance:new e.cm(t),u_node_matrix:new e.cm(t)}),groundShadow:t=>({u_matrix:new e.cm(t),u_ground_shadow_factor:new e.cj(t)}),stars:t=>({u_matrix:new e.cm(t),u_up:new e.cj(t),u_right:new e.cj(t),u_intensity_multiplier:new e.ck(t)}),snowParticle:t=>({u_modelview:new e.cm(t),u_projection:new e.cm(t),u_time:new e.ck(t),u_cam_pos:new e.cj(t),u_velocityConeAperture:new e.ck(t),u_velocity:new e.ck(t),u_horizontalOscillationRadius:new e.ck(t),u_horizontalOscillationRate:new e.ck(t),u_boxSize:new e.ck(t),u_billboardSize:new e.ck(t),u_simpleShapeParameters:new e.cl(t),u_screenSize:new e.cl(t),u_thinningCenterPos:new e.cl(t),u_thinningShape:new e.cj(t),u_thinningAffectedRatio:new e.ck(t),u_thinningParticleOffset:new e.ck(t),u_particleColor:new e.d4(t),u_direction:new e.cj(t)}),rainParticle:t=>({u_modelview:new e.cm(t),u_projection:new e.cm(t),u_time:new e.ck(t),u_cam_pos:new e.cj(t),u_texScreen:new e.ci(t),u_velocityConeAperture:new e.ck(t),u_velocity:new e.ck(t),u_boxSize:new e.ck(t),u_rainDropletSize:new e.cl(t),u_distortionStrength:new e.ck(t),u_rainDirection:new e.cj(t),u_color:new e.d4(t),u_screenSize:new e.cl(t),u_thinningCenterPos:new e.cl(t),u_thinningShape:new e.cj(t),u_thinningAffectedRatio:new e.ck(t),u_thinningParticleOffset:new e.ck(t),u_shapeDirectionalPower:new e.ck(t),u_shapeNormalPower:new e.ck(t),u_mode:new e.ck(t)}),vignette:t=>({u_vignetteShape:new e.cj(t),u_vignetteColor:new e.d4(t)}),occlusion:t=>({u_matrix:new e.cm(t),u_anchorPos:new e.cj(t),u_screenSizePx:new e.cl(t),u_occluderSizePx:new e.cl(t),u_color:new e.d4(t)})};class $r{constructor(e,t,i,o){this.id=$r.uniqueIdxCounter,$r.uniqueIdxCounter++,this.context=e;const s=e.gl;this.buffer=s.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),s.bufferData(s.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?s.DYNAMIC_DRAW:s.STATIC_DRAW),this.dynamicDraw||o||t.destroy();}bind(){this.context.bindElementBuffer.set(this.buffer);}updateData(e){this.id=$r.uniqueIdxCounter,$r.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);}}$r.uniqueIdxCounter=0;const Xr={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Kr{constructor(e,t,i,o,s,r){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=o,this.instanceCount=r,this.context=e;const n=e.gl;this.buffer=n.createBuffer(),e.bindVertexBuffer.set(this.buffer),n.bufferData(n.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?n.DYNAMIC_DRAW:n.STATIC_DRAW),this.dynamicDraw||s||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 i=0;i0&&e.vertexAttribDivisor(s,i);}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer);}}class Yr{constructor(e,t,i,o,s){this.context=e,this.width=t,this.height=i;const r=this.framebuffer=e.gl.createFramebuffer();o>0&&(this.colorAttachment0=new Vs(e,r,0)),o>1&&(this.colorAttachment1=new Vs(e,r,1)),s&&(this.depthAttachmentType=s,this.depthAttachment="renderbuffer"===s?new Gs(e,r):new Hs(e,r));}createColorAttachment(e,t){0===t?this.colorAttachment0=new Vs(e,this.framebuffer,0):1===t&&(this.colorAttachment1=new Vs(e,this.framebuffer,1));}removeColorAttachment(e,t){const i=this.context.gl;let o;0===t?(o=this.colorAttachment0.get(),this.colorAttachment0=void 0):1===t&&(o=this.colorAttachment1.get(),this.colorAttachment1=void 0),o&&i.deleteTexture(o);}destroy(){const e=this.context.gl;if(this.colorAttachment0){const t=this.colorAttachment0.get();t&&e.deleteTexture(t);}if(this.colorAttachment1){const t=this.colorAttachment1.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 Jr{constructor(e,t){this.gl=e,this.clearColor=new hs(this),this.clearDepth=new ds(this),this.clearStencil=new us(this),this.colorMask=new _s(this),this.depthMask=new ps(this),this.stencilMask=new fs(this),this.stencilFunc=new ms(this),this.stencilOp=new gs(this),this.stencilTest=new vs(this),this.depthRange=new ys(this),this.depthTest=new xs(this),this.depthFunc=new bs(this),this.blend=new ws(this),this.blendFunc=new Ts(this),this.blendColor=new Es(this),this.blendEquation=new Ss(this),this.cullFace=new Is(this),this.cullFaceSide=new Cs(this),this.frontFace=new Rs(this),this.program=new As(this),this.activeTexture=new Ds(this),this.viewport=new Ls(this),this.bindFramebuffer=new Ps(this),this.bindRenderbuffer=new Os(this),this.bindTexture=new zs(this),this.bindVertexBuffer=new Ms(this),this.bindElementBuffer=new Fs(this),this.bindVertexArrayOES=new ks(this),this.pixelStoreUnpack=new Bs(this),this.pixelStoreUnpackPremultiplyAlpha=new Ns(this),this.pixelStoreUnpackFlipY=new Us(this),this.options=t?Object.assign({},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.forceManualRenderingForInstanceIDShaders=t&&!!t.forceManualRenderingForInstanceIDShaders||this.renderer&&-1!==this.renderer.indexOf("PowerVR"),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.extBlendFuncExtended=e.getExtension("WEBGL_blend_func_extended");}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,i){return new $r(this,e,t,i)}createVertexBuffer(e,t,i,o,s){return new Kr(this,e,t,i,o,s)}createRenderbuffer(e,t,i){const o=this.gl,s=o.createRenderbuffer();return this.bindRenderbuffer.set(s),o.renderbufferStorage(o.RENDERBUFFER,e,t,i),this.bindRenderbuffer.set(null),s}createFramebuffer(e,t,i,o){return new Yr(this,e,t,i,o)}clear({color:e,depth:t,stencil:i,colorMask:o}){const s=this.gl;let r=0;e&&(r|=s.COLOR_BUFFER_BIT,this.clearColor.set(e.toNonPremultipliedRenderColor(null)),this.colorMask.set(o||[!0,!0,!0,!0])),void 0!==t&&(r|=s.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(t),this.depthMask.set(!0)),void 0!==i&&(r|=s.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),s.clear(r);}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(t){e.bz(t.blendFunction,Zi.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(t.blendFunction),this.blendColor.set(t.blendColor),t.blendEquation?this.blendEquation.set(t.blendEquation):this.blendEquation.setDefault()),this.colorMask.set(t.mask);}unbindVAO(){this.bindVertexArrayOES.set(null);}}let Qr;function en(t,i,o,s,r,n,a){const l=t.context,c=l.gl,h=t.transform,d=[e.aG(h.center.lng),e.aK(h.center.lat)],u=o.layout.get("symbol-placement"),_=o.layout.get("text-variable-anchor"),p="map"===o.layout.get("icon-rotation-alignment"),f="map"===o.layout.get("text-rotation-alignment"),m="point"!==u,g=[];let v=0,y=0;for(let l=0;l0){const t=e.bD(),i=O;e.cQ(t,b.placementInvProjMatrix,h.glCoordMatrix),e.cQ(t,t,b.placementViewportMatrix),g.push({circleArray:M,circleOffset:y,transform:i,invTransform:t,projection:b.getProjection()}),v+=M.length/4,y=v;}if(!z)continue;t.terrain&&t.terrain.setupElevationDraw(x,P);const F=D?[u.canonical.x,u.canonical.y,1<=0&&(p[y.associatedIconIndex]={x:I,y:C,z:R,angle:O});}else fi(w,u);}if(h){_.clear();const i=t.icon.placedSymbolArray;for(let t=0;t{let i=[0,0,0];if(e){const e=t.style.directionalLight,o=t.style.ambientLight;e&&o&&(i=mo(t.style,e,o));}return i},q=e=>{I.depthOcclusionForSymbolsAndCircles&&(o.hasOcclusionOpacityProperties||t.terrain)&&(e.push("DEPTH_D24"),e.push("DEPTH_OCCLUSION"));},Z=i=>{o.lut&&!T&&(o.lut.texture||(o.lut.texture=new e.e1(t.context,o.lut.image,[o.lut.image.height,o.lut.image.height,o.lut.image.height],E.gl.RGBA8)),E.activeTexture.set(E.gl.TEXTURE0+10),o.lut.texture&&o.lut.texture.bind(E.gl.LINEAR,E.gl.CLAMP_TO_EDGE),i.push("APPLY_LUT_ON_GPU"));},W=()=>{const i=C&&"point"!==o.layout.get("symbol-placement"),a=[];q(a),Z(a);const c=i||j,d="road"===n.elevationType,g=t.shadowRenderer,T=d&&A&&!!g&&g.enabled,E=H(T),R=d&&A&&!t.terrain?z:O,D=o.paint.get("icon-image-cross-fade");t.terrainRenderModeElevated()&&A&&a.push("PITCH_WITH_MAP_TERRAIN"),u&&(a.push("PROJECTION_GLOBE_VIEW"),c&&a.push("PROJECTED_POS_ON_VIEWPORT")),D>0&&n.hasAnySecondaryIcon&&a.push("ICON_TRANSITION"),!n.icon.zOffsetVertexBuffer||d&&t.terrain||a.push("Z_OFFSET"),0===v&&0===y&&0===x&&1===b||a.push("COLOR_ADJUSTMENT"),n.sdfIcons&&a.push("RENDER_SDF"),T&&a.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),d&&A&&!t.terrain&&n.icon.orientationVertexBuffer&&a.push("ELEVATED_ROADS");const L=n.icon.programConfigurations.get(o.id),P=t.getOrCreateProgram("symbol",{config:L,defines:a}),F=s.imageAtlasTexture?s.imageAtlasTexture.size:[0,0],B=n.iconSizeData,U=e.bL(B,I.zoom),W=A||!I.isOrthographic,$=ii(p,s.tileID.canonical,A,C,I,n.getProjection(),f),X=si(p,s.tileID.canonical,A,C,I,n.getProjection(),f),K=t.translatePosMatrix(X,s,l,h,!0),Y=t.translatePosMatrix(p,s,l,h),J=c?tn:$,Q=C&&!A&&!i;let ee=N;!k&&!I.mercatorFromTransition||C||(ee=on(I));const te=u?ee:N,ie=o.getColorAdjustmentMatrix(v,y,x,b),oe=jr(B.kind,U,Q,A,t,Y,J,K,w,!1,F,[0,0],0,r,_,M,V,te,n.getProjection(),E,G,ie,D,null),se=s.imageAtlasTexture?s.imageAtlasTexture:null,re=1!==o.layout.get("icon-size").constantOr(0)||n.iconsNeedLinear,ne=n.sdfIcons||t.options.rotating||t.options.zooming||re||W?S.LINEAR:S.NEAREST,ae=n.sdfIcons&&0!==o.paint.get("icon-halo-width").constantOr(1),le=t.terrain&&A&&i?e.bm(e.bD(),$):tn;if(i&&n.icon){const i=e.bW.getAtTileOffsetFunc(r,I.center.lat,I.worldSize,n.getProjection()),a=oi(p,s.tileID.canonical,A,C,I,n.getProjection(),f),l=o.layout.get("icon-size-scale-range"),c=e.aB(t.scaleFactor,l[0],l[1]);li(n,p,t,!1,a,X,A,m,i,r,c);}return {program:P,buffers:n.icon,uniformValues:oe,atlasTexture:se,atlasTextureIcon:null,atlasInterpolation:ne,atlasInterpolationIcon:null,isSDF:n.sdfIcons,hasHalo:ae,depthMode:R,tile:s,renderWithShadows:T,labelPlaneMatrixInv:le}},$=()=>{const i=R&&"point"!==o.layout.get("symbol-placement"),a=[],l=i||F||j,h="road"===n.elevationType,m=t.shadowRenderer,v=h&&D&&!!m&&m.enabled,y=H(v),x=h&&D&&!t.terrain?z:O;t.terrainRenderModeElevated()&&D&&a.push("PITCH_WITH_MAP_TERRAIN"),u&&(a.push("PROJECTION_GLOBE_VIEW"),l&&a.push("PROJECTED_POS_ON_VIEWPORT")),!n.text.zOffsetVertexBuffer||h&&t.terrain||a.push("Z_OFFSET"),n.iconsInText&&a.push("RENDER_TEXT_AND_SYMBOL"),a.push("RENDER_SDF"),v&&a.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),h&&D&&!t.terrain&&n.text.orientationVertexBuffer&&a.push("ELEVATED_ROADS"),q(a);const b=n.text.programConfigurations.get(o.id),T=t.getOrCreateProgram("symbol",{config:b,defines:a});let E,C=[0,0],A=null;const L=n.textSizeData;n.iconsInText&&(C=s.imageAtlasTexture?s.imageAtlasTexture.size:[0,0],A=s.imageAtlasTexture?s.imageAtlasTexture:null,E=D||!I.isOrthographic||t.options.rotating||t.options.zooming||"composite"===L.kind||"camera"===L.kind?S.LINEAR:S.NEAREST);const P=s.glyphAtlasTexture?s.glyphAtlasTexture.size:[0,0],B=o.layout.get("text-size-scale-range"),U=e.aB(t.scaleFactor,B[0],B[1]),Z=e.bL(L,I.zoom,U),W=ii(p,s.tileID.canonical,D,R,I,n.getProjection(),f),$=si(p,s.tileID.canonical,D,R,I,n.getProjection(),f),X=t.translatePosMatrix($,s,c,d,!0),K=t.translatePosMatrix(p,s,c,d),Y=l?tn:W,J=R&&!D&&!i;let Q=N;!k&&!I.mercatorFromTransition||R||(Q=on(I));const ee=jr(L.kind,Z,J,D,t,K,Y,X,w,!0,P,C,0,r,_,M,V,u?Q:N,n.getProjection(),y,G,null,null,U),te=s.glyphAtlasTexture?s.glyphAtlasTexture:null,ie=S.LINEAR,oe=0!==o.paint.get("text-halo-width").constantOr(1),se=t.terrain&&D&&i?e.bm(e.bD(),W):tn;if(i&&n.text){const i=e.bW.getAtTileOffsetFunc(r,I.center.lat,I.worldSize,n.getProjection()),o=oi(p,s.tileID.canonical,D,R,I,n.getProjection(),f);li(n,p,t,!0,o,$,D,g,i,r,U);}return {program:T,buffers:n.text,uniformValues:ee,atlasTexture:te,atlasTextureIcon:A,atlasInterpolation:ie,atlasInterpolationIcon:E,isSDF:!0,hasHalo:oe,depthMode:x,tile:s,renderWithShadows:v,labelPlaneMatrixInv:se}},X=n.icon.segments.get().length,K=n.text.segments.get().length,Y=X&&!a.onlyText?W():null,J=K&&!a.onlyIcons?$():null,Q=o.paint.get("icon-opacity").constantOr(1),ee=o.paint.get("text-opacity").constantOr(1);if(L&&n.canOverlap){P=!0;const t=Q&&!a.onlyText?n.icon.segments.get():[],i=ee&&!a.onlyIcons?n.text.segments.get():[];for(const i of t)B.push({segments:new e.bh([i]),sortKey:i.sortKey,state:Y});for(const t of i)B.push({segments:new e.bh([t]),sortKey:t.sortKey,state:J});}else a.onlyText||B.push({segments:Q?n.icon.segments:new e.bh([]),sortKey:0,state:Y}),a.onlyIcons||B.push({segments:ee?n.text.segments:new e.bh([]),sortKey:0,state:J});}P&&B.sort((e,t)=>e.sortKey-t.sortKey);for(const e of B){const i=e.state;if(i)if(t.terrain?t.terrain.setupElevationDraw(i.tile,i.program,{useDepthForOcclusion:I.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:i.labelPlaneMatrixInv}):t.setupDepthForOcclusion(I.depthOcclusionForSymbolsAndCircles,i.program),E.activeTexture.set(S.TEXTURE0),i.atlasTexture&&i.atlasTexture.bind(i.atlasInterpolation,S.CLAMP_TO_EDGE,!0),i.atlasTextureIcon&&(E.activeTexture.set(S.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,S.CLAMP_TO_EDGE,!0)),i.renderWithShadows&&t.shadowRenderer.setupShadows(i.tile.tileID.toUnwrapped(),i.program,"vector-tile"),t.uploadCommonLightUniforms(t.context,i.program),i.hasHalo){const s=i.uniformValues;s.u_is_halo=1,an(i.buffers,e.segments,o,t,i.program,i.depthMode,r,n,s,2),s.u_is_halo=0;}else {if(i.isSDF){const s=i.uniformValues;i.hasHalo&&(s.u_is_halo=1,an(i.buffers,e.segments,o,t,i.program,i.depthMode,r,n,s,1)),s.u_is_halo=0;}an(i.buffers,e.segments,o,t,i.program,i.depthMode,r,n,i.uniformValues,1);}}}function an(e,t,i,o,s,r,n,a,l,c){const h=[e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer,e.iconTransitioningVertexBuffer,e.globeExtVertexBuffer,e.zOffsetVertexBuffer,e.orientationVertexBuffer];s.draw(o,o.context.gl.TRIANGLES,r,n,a,Ji.disabled,l,i.id,e.layoutVertexBuffer,e.indexBuffer,t,i.paint,o.transform.zoom,e.programConfigurations.get(i.id),h,c);}function ln(t,i){const o=1<=no?1:t.pitch/no))),2*i}(t.transform),h=t.transform.getFreeCameraOptions().position,d="elevatedStructuresDepthReconstruct",u=t.getOrCreateProgram(d,{defines:["DEPTH_RECONSTRUCTION"]}),_=t.getOrCreateProgram(d);for(const e of s){const s=i.getTile(e),d=s.getBucket(o);if(!d)continue;const p=d.elevatedStructures;if(!p)continue;const f=d.elevationBufferData.heightRange,m=ln(e.toUnwrapped(),h),g=t.translatePosMatrix(e.projMatrix,s,o.paint.get("fill-translate"),o.paint.get("fill-translate-anchor"));let v,y,x,b;if("initialize"===r){if(!f||f.min>=1||0===p.depthSegments.segments[0].primitiveLength)continue;v=wr(g,m,c,1,0),y=a,x=p.depthSegments,b=u;}else if("reset"===r){if(!f||f.min>=0||0===p.maskSegments.segments[0].primitiveLength)continue;v=wr(g,m,0,0,1),y=l,x=p.maskSegments,b=u;}else if("geometry"===r){if(0===p.depthSegments.segments[0].primitiveLength)continue;v=wr(g,m,c,1,0),y=a,x=p.depthSegments,b=_;}b.draw(t,n.TRIANGLES,y,Xi.disabled,Zi.disabled,Ji.disabled,v,o.id,p.vertexBuffer,p.indexBuffer,x,o.paint,t.transform.zoom);}}function hn(t,i,o,s){const{painter:r,sourceCache:n,layer:a,coords:l,colorMode:c,elevationType:h,terrainEnabled:d,pass:u}=t,_=r.context.gl,p=a.paint.get("fill-pattern"),f=a.paint.get("fill-pattern-cross-fade"),m=p.constantOr(null);let g=h;"road"!==h||i&&!d||(g="none");const v="road"===g,y=t.painter.shadowRenderer,x=v&&!!y&&y.enabled,b=new Wi(r.context.gl.LEQUAL,Wi.ReadOnly,r.depthRangeFor3D);let w=[0,0,0];if(x){const e=r.style.directionalLight,t=r.style.ambientLight;e&&t&&(w=mo(r.style,e,t));}const T=p&&p.constantOr(1),E=r.terrain&&r.terrain.renderingToTexture,S=(t,u)=>{let p,g,S,I,C;u?(p=T&&!a.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",S=_.LINES):(p=T?"fillPattern":"fill",S=_.TRIANGLES);for(const R of l){const l=n.getTile(R);if(T&&!l.patternsLoaded())continue;const A=l.getBucket(a);if(!A)continue;const D=i?A.elevationBufferData:A.bufferData;if(D.isEmpty())continue;r.prepareDrawTile();const L=D.programConfigurations.get(a.id),P=r.isTileAffectedByFog(R),O=[],z=[];v&&(O.push("ELEVATED_ROADS"),z.push(D.elevatedLayoutVertexBuffer)),x&&O.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),E&&o&&O.push("USE_MRT1"),T&&(r.context.activeTexture.set(_.TEXTURE0),l.imageAtlasTexture&&l.imageAtlasTexture.bind(_.LINEAR,_.CLAMP_TO_EDGE),L.updatePaintBuffers());let M=!1;if(m&&l.imageAtlas){const t=l.imageAtlas,i=e.e5.from(m),o=i.getPrimary().scaleSelf(e.o.devicePixelRatio).toString(),s=i.getSecondary(),r=t.patternPositions.get(o),n=s?t.patternPositions.get(s.scaleSelf(e.o.devicePixelRatio).toString()):null;M=!!r&&!!n,r&&L.setConstantPatternPositions(r,n);}f>0&&(M||L.getPatternTransitionVertexBuffer("fill-pattern"))&&O.push("FILL_PATTERN_TRANSITION");const F=r.getOrCreateProgram(p,{config:L,overrideFog:P,defines:O}),k=r.translatePosMatrix(R.projMatrix,l,a.paint.get("fill-translate"),a.paint.get("fill-translate-anchor"));x&&y.setupShadows(l.tileID.toUnwrapped(),F,"vector-tile");const B=a.paint.get("fill-emissive-strength");if(u){I=D.lineIndexBuffer,C=D.lineSegments;const e=r.terrain&&r.terrain.renderingToTexture?r.terrain.drapeBufferSize:[_.drawingBufferWidth,_.drawingBufferHeight];g="fillOutlinePattern"===p&&T?yr(k,B,r,l,e,w,f):vr(k,B,e,w);}else I=D.indexBuffer,C=D.triangleSegments,g=T?gr(k,B,r,l,w,f):mr(k,B,w);r.uploadCommonUniforms(r.context,F,R.toUnwrapped());let N=t;("road"===h&&!d||"offset"===h)&&(N=b),F.draw(r,S,N,s||r.stencilModeForClipping(R),c,Ji.disabled,g,a.id,D.layoutVertexBuffer,I,C,a.paint,r.transform.zoom,L,z);}};r.renderPass===u&&S(r.depthModeForSublayer(1,"opaque"===r.renderPass?Wi.ReadWrite:Wi.ReadOnly),!1),"none"===g&&"translucent"===r.renderPass&&a.paint.get("fill-antialias")&&S(r.depthModeForSublayer(a.getPaintProperty("fill-outline-color")?2:0,Wi.ReadOnly),!0);}function dn(t,i,o,s,r,n,a,l){o.resetLayerRenderingStats(t);const c=t.context,h=c.gl,d=t.transform,u=o.paint.get("fill-extrusion-pattern"),_=o.paint.get("fill-extrusion-pattern-cross-fade"),p=u.constantOr(null),f=u.constantOr(1),m=o.paint.get("fill-extrusion-opacity"),g=t.style.enable3dLights(),v=o.paint.get(g&&!f?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),y=[o.paint.get("fill-extrusion-ambient-occlusion-intensity"),v],x=o.layout.get("fill-extrusion-edge-radius"),b=x>0&&!o.paint.get("fill-extrusion-rounded-roof"),w=b?0:x,T="globe"===d.projection.name?e.ed():0,E="globe"===d.projection.name,S=E?e.ak(d.zoom):0,I=[e.aG(d.center.lng),e.aK(d.center.lat)],C="none"===o.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default"),R=o.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(C?null:o.lut).toArray01().slice(0,3),A=o.paint.get("fill-extrusion-flood-light-intensity"),D=o.paint.get("fill-extrusion-vertical-scale"),L=0!==o.paint.get("fill-extrusion-line-width").constantOr(1),P=o.paint.get("fill-extrusion-height-alignment"),O=o.paint.get("fill-extrusion-base-alignment"),z=lo(t,o.paint.get("fill-extrusion-cutoff-fade-range")),M=[];let F;E&&M.push("PROJECTION_GLOBE_VIEW"),y[0]>0&&M.push("FAUX_AO"),b&&M.push("ZERO_ROOF_RADIUS"),l&&M.push("HAS_CENTROID"),A>0&&M.push("FLOOD_LIGHT"),z.shouldRenderCutoff&&M.push("RENDER_CUTOFF"),L&&M.push("RENDER_WALL_MODE");const k="shadow"===t.renderPass,B=t.shadowRenderer,N=k&&!!B,U=k?Ji.disabled:Ji.backCCW;t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!0);let j=[0,0,0];if(B){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(j=mo(t.style,e,i)),k||(M.push("RENDER_SHADOWS","DEPTH_TEXTURE"),B.useNormalOffset&&M.push("NORMAL_OFFSET")),F=M.concat(["SHADOWS_SINGLE_CASCADE"]);}const V=N?"fillExtrusionDepth":f?"fillExtrusionPattern":"fillExtrusion",G=o.getLayerRenderingStats();for(const u of s){const s=i.getTile(u),g=s.getBucket(o);if(!g||g.projection.name!==d.projection.name)continue;let v=!1;B&&(v=0===B.getMaxCascadeForTile(u.toUnwrapped()));const x=t.isTileAffectedByFog(u),b=g.programConfigurations.get(o.id);let C=!1;if(p&&s.imageAtlas){const t=s.imageAtlas,i=e.e5.from(p),o=i.getPrimary().scaleSelf(e.o.devicePixelRatio).toString(),r=i.getSecondary(),n=t.patternPositions.get(o),a=r?t.patternPositions.get(r.scaleSelf(e.o.devicePixelRatio).toString()):null;C=!!n&&!!a,n&&b.setConstantPatternPositions(n,a);}_>0&&(C||b.getPatternTransitionVertexBuffer("fill-extrusion-pattern"))&&M.push("FILL_EXTRUSION_PATTERN_TRANSITION");const N=t.getOrCreateProgram(V,{config:b,defines:v?F:M,overrideFog:x});if(t.terrain&&t.terrain.setupElevationDraw(s,N,{useMeterToDem:!0}),!g.centroidVertexBuffer){const e=N.getAttributeLocation(h,"a_centroid_pos");-1!==e&&h.vertexAttrib2f(e,0,0);}!k&&B&&B.setupShadows(s.tileID.toUnwrapped(),N,"vector-tile"),f&&(t.context.activeTexture.set(h.TEXTURE0),s.imageAtlasTexture&&s.imageAtlasTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),b.updatePaintBuffers());const H=o.paint.get("fill-extrusion-vertical-gradient"),q=1/g.tileToMeter;let Z;if(k&&B){if(vn(s.tileID,g.maxHeight,t))continue;const e=B.calculateShadowPassMatrixFromTile(s.tileID.toUnwrapped());Z=pr(e,w,q,D,P,O);}else {const e=t.translatePosMatrix(u.expandedProjMatrix,s,o.paint.get("fill-extrusion-translate"),o.paint.get("fill-extrusion-translate-anchor")),i=d.projection.createInversionMatrix(d,u.canonical);Z=f?fr(e,t,H,m,y,w,q,u,s,T,P,O,S,I,i,R,D,_):_r(e,t,H,m,y,w,q,u,T,P,O,S,I,i,R,D,A,j);}t.uploadCommonUniforms(c,N,u.toUnwrapped(),null,z);let W=g.segments;if("mercator"===d.projection.name&&!k&&(W=g.getVisibleSegments(s.tileID,t.terrain,t.transform.getFrustum(0)),!W.get().length))continue;if(G)if(k)for(const e of W.get())G.numRenderedVerticesInShadowPass+=e.primitiveLength;else for(const e of W.get())G.numRenderedVerticesInTransparentPass+=e.primitiveLength;const $=[];(t.terrain||l)&&$.push(g.centroidVertexBuffer),E&&$.push(g.layoutVertexExtBuffer),L&&$.push(g.wallVertexBuffer),N.draw(t,c.gl.TRIANGLES,r,n,a,U,Z,o.id,g.layoutVertexBuffer,g.indexBuffer,W,o.paint,t.transform.zoom,b,$);}t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!1);}class un{constructor(){this.translate=[0,0],this.translateAnchor="map",this.edgeRadius=0,this.cutoffFadeRange=0;}}function _n(t,i,o,s,r,n,a,l,c,h,d,u,_,p,f,m,g,v,y,x){const b=i.context,w=b.gl,T=i.transform,E=i.transform.zoom,S=[],I=t.translate,C=t.translateAnchor,R=t.edgeRadius,A=lo(i,t.cutoffFadeRange);"clear"===d?(S.push("CLEAR_SUBPASS"),x&&(S.push("CLEAR_FROM_TEXTURE"),b.activeTexture.set(w.TEXTURE0),x.bind(w.LINEAR,w.CLAMP_TO_EDGE))):"sdf"===d?S.push("SDF_SUBPASS"):"emissive"===d&&(S.push("USE_MRT1"),b.activeTexture.set(w.TEXTURE0),x.bind(w.LINEAR,w.CLAMP_TO_EDGE)),v&&S.push("HAS_CENTROID"),A.shouldRenderCutoff&&S.push("RENDER_CUTOFF");const D=(e,t,o,r,d)=>{let y=S;null!=t.groundRadiusBuffer&&(y=S.concat("HAS_ATTRIBUTE_a_flood_light_ground_radius"));const w=t.programConfigurations.get(s.id),T=i.isTileAffectedByFog(e),I=i.getOrCreateProgram("fillExtrusionGroundEffect",{config:w,defines:y,overrideFog:T}),C=((e,t,i,o,s,r,n,a,l,c,h)=>({u_matrix:t,u_opacity:i,u_ao_pass:o?1:0,u_meter_to_tile:s,u_ao:r,u_flood_light_intensity:n,u_flood_light_color:a,u_attenuation:l,u_edge_radius:c,u_fb:0,u_fb_size:h,u_dynamic_offset:1}))(0,r,u,h,d,[_,p*d],f,m,g,E>=17?0:R*d,x?x.size[0]:0),D=[];v&&D.push(t.hiddenByLandmarkVertexBuffer),null!=t.groundRadiusBuffer&&D.push(t.groundRadiusBuffer),i.uploadCommonUniforms(b,I,e.toUnwrapped(),null,A),I.draw(i,b.gl.TRIANGLES,n,a,l,c,C,s.id,t.vertexBuffer,t.indexBuffer,o,s.paint,E,w,D);};for(const t of r){const r=o.getTile(t),n=r.getBucket(s);if(!n||n.projection.name!==T.projection.name||!n.groundEffect||n.groundEffect&&!n.groundEffect.hasData())continue;const a=n.groundEffect,l=1/n.tileToMeter;{const e=i.translatePosMatrix(t.projMatrix,r,I,C),o=a.getDefaultSegment();D(t,a,o,e,l);}if(y)for(let n=0;n<4;n++){const a=e.eb[n](t),c=o.getTile(a);if(!c)continue;const h=c.getBucket(s);if(!h||h.projection.name!==T.projection.name||!h.groundEffect||h.groundEffect&&!h.groundEffect.hasData())continue;const d=h.groundEffect;let u,_;0===n?(u=[-e.am,0,0],_=1):1===n?(u=[e.am,0,0],_=0):2===n?(u=[0,-e.am,0],_=3):(u=[0,e.am,0],_=2);const p=d.regionSegments[_];if(!p)continue;const f=new Float32Array(16);e.bs(f,t.projMatrix,u),D(t,d,p,i.translatePosMatrix(f,r,I,C),l);}}}function pn(t,i,o,s,r,n,a){0===s.centroidVertexArray.length&&s.createCentroidsBuffer();const l=n?n.findDEMTileFor(o):null;if(!(l&&l.dem||a))return;n&&l&&l.dem&&s.selfDEMTileTimestamp!==l.dem._timestamp&&(s.borderDoneWithNeighborZ=[-1,-1,-1,-1],s.selfDEMTileTimestamp=l.dem._timestamp);const c=(t,i)=>{(t.flags|i.flags)&e.ee?(t.flags|=e.ee,i.flags|=e.ee):(t.flags&=~e.ee,i.flags&=~e.ee);},h=t=>new e.P(Math.ceil((t+e.ef)*e.eg),0),d=e=>{const t=i.getSource().minzoom,o=e=>{const t=i.getTileByID(e);if(t&&t.hasData())return t.getBucket(r)},s=[0,-1,1];for(const i of s){if(e.overscaledZ+i(u[0]=Math.min(t.min.y,i.min.y),u[1]=Math.max(t.max.y,i.max.y),u[2]=e.am-i.min.x>t.max.x?i.min.x-e.am:t.max.x,u),p=(t,i)=>(u[0]=Math.min(t.min.x,i.min.x),u[1]=Math.max(t.max.x,i.max.x),u[2]=e.am-i.min.y>t.max.y?i.min.y-e.am:t.max.y,u),f=[(e,t)=>_(e,t),(e,t)=>_(t,e),(e,t)=>p(e,t),(e,t)=>p(t,e)],m=(t,i,s,r,a,c,h)=>{if(!n)return 0;const d=[[c?s:t,c?t:s,0],[c?s:i,c?i:s,0]],u=h<0?e.am+h:h,_=[c?u:(t+i)/2,c?(t+i)/2:u,0];return 0===s&&h<0||0!==s&&h>0?n.getForTilePoints(a,[_],!0,r):d.push(_),n.getForTilePoints(o,d,!0,l),Math.max(d[0][2],d[1][2],_[2])/n.exaggeration()};for(let t=0;t<4;t++){const i=s.borderFeatureIndices[t];if(0===i.length)continue;const r=e.eb[t](o),l=d(r);if(!(l&&l instanceof e.ec))continue;const u=n?n.findDEMTileFor(r):null;if(!(u&&u.dem||a))continue;if(n&&u&&u.dem&&s.borderDEMTileTimestamp[t]!==u.dem._timestamp&&(s.borderDoneWithNeighborZ[t]=-1,s.borderDEMTileTimestamp[t]=u.dem._timestamp),s.borderDoneWithNeighborZ[t]===l.canonical.z)continue;0===l.centroidVertexArray.length&&l.createCentroidsBuffer();const _=(t<2?1:5)-t,p=l.borderDoneWithNeighborZ[_]!==s.canonical.z,g=l.borderFeatureIndices[_];let v=0;if(s.canonical.z!==l.canonical.z){for(const e of i)s.showCentroid(s.featuresOnBorder[e]);if(p)for(const e of g)l.showCentroid(l.featuresOnBorder[e]);s.borderDoneWithNeighborZ[t]=l.canonical.z,l.borderDoneWithNeighborZ[_]=s.canonical.z;}for(const o of i){const i=s.featuresOnBorder[o],n=s.centroidData[i.centroidDataIndex],d=i.borders[t];let p;for(;vd[0]+3||e[0]>d[0]-3)break;l.showCentroid(p),v++;}if(p&&vd[1]-3)&&(y++,++v!==g.length);)p=l.featuresOnBorder[g[v]];p=l.featuresOnBorder[g[o]];let x=!1;if(y>=1){const e=p.borders[_];Math.abs(d[0]-e[0])<3&&Math.abs(d[1]-e[1])<3&&(y=1,x=!0,v=o+1);}else if(0===y){s.showCentroid(i);continue}const b=l.centroidData[p.centroidDataIndex];a&&x&&c(n,b);const w=i.intersectsCount()>1||p.intersectsCount()>1;if(y>1)v=o,n.centroidXY=b.centroidXY=new e.P(0,0);else if(u&&u.dem&&!w){const i=f[t](n,b),o=t%2?e.am-1:0,s=m(i[0],Math.min(e.am-1,i[1]),o,u,r,t<2,i[2]);n.centroidXY=b.centroidXY=h(s);}else w?n.centroidXY=b.centroidXY=new e.P(0,0):(n.centroidXY=s.encodeBorderCentroid(i),b.centroidXY=l.encodeBorderCentroid(p));s.writeCentroidToBuffer(n),l.writeCentroidToBuffer(b);}else s.showCentroid(i);}s.borderDoneWithNeighborZ[t]=l.canonical.z,l.borderDoneWithNeighborZ[_]=s.canonical.z;}(s.needsCentroidUpdate||!s.centroidVertexBuffer&&0!==s.centroidVertexArray.length)&&s.uploadCentroid(t);}const fn=[1,0,0],mn=[0,1,0],gn=[0,0,1];function vn(t,i,o){const s=o.transform,r=o.shadowRenderer;if(!r)return !0;const n=t.toUnwrapped(),a=s.tileSize*r._cascades[o.currentShadowCascade].scale;let l=i;if(s.elevation){const e=s.elevation.getMinMaxForTile(t);e&&(l+=e.max);}const c=[...r.shadowDirection];c[2]=-c[2];const h=r.computeSimplifiedTileShadowVolume(n,l,a,c);if(!h)return !1;const d=[fn,mn,gn,c,[c[0],0,c[2]],[0,c[1],c[2]]],u="globe"===s.projection.name,_=s.scaleZoom(a),p=e.cC.fromInvProjectionMatrix(s.invProjMatrix,s.worldSize,_,!u),f=r.getCurrentCascadeFrustum();return 0===p.intersectsPrecise(h.vertices,h.planes,d)||0===f.intersectsPrecise(h.vertices,h.planes,d)}function yn(t){const{painter:i,source:o,layer:s,coords:r}=t;let n=t.defines;const a=i.context,l="shadow"===i.renderPass,c="light-beam"===i.renderPass,h=i.shadowRenderer,d=e.eh(i.transform.center.lat,i.transform.zoom),u=lo(i,s.paint.get("building-cutoff-fade-range"));u.shouldRenderCutoff&&(n=n.concat("RENDER_CUTOFF")),t.floodLightIntensity>0&&(n=n.concat("FLOOD_LIGHT"));for(const _ of r){const r=o.getTile(_),p=r.getBucket(s);if(!p)continue;h&&0===h.getMaxCascadeForTile(_.toUnwrapped())&&(n=n.concat("SHADOWS_SINGLE_CASCADE"));const f=p.programConfigurations.get(s.id);let m,g,v,y=i.translatePosMatrix(_.expandedProjMatrix,r,[0,0],"map");if(y=e.cT(e.bD(),y,[1,1,t.verticalScale]),l&&h){if(vn(r.tileID,p.maxHeight*d,i))continue;let o=h.calculateShadowPassMatrixFromTile(r.tileID.toUnwrapped());o=e.cT(e.bD(),o,[1,1,t.verticalScale]),v=Sr(o),m=g=i.getOrCreateProgram("buildingDepth",{config:f,defines:n,overrideFog:!1});}else if(c)m=g=i.getOrCreateProgram("buildingBloom",{config:f,defines:n,overrideFog:!1}),v=Er(y);else {const o=i.transform.calculatePosMatrix(_.toUnwrapped(),i.transform.worldSize);e.cT(o,o,[1,1,t.verticalScale]);const s=e.bD();e.cT(s,o,[1,-1,1/d]),e.bm(s,s),e.ei(s,s);const r=i.transform.getFreeCameraOptions().position,a=1<<_.canonical.z;if(v=Tr(y,s,t.opacity,t.facadeAOIntensity,[((r.x-_.wrap)*a-_.canonical.x)*e.am,(r.y*a-_.canonical.y)*e.am,r.z*a*e.am],p.tileToMeter,t.facadeEmissiveChance,t.floodLightColor,t.floodLightIntensity),g=i.getOrCreateProgram("building",{config:f,defines:n,overrideFog:!1}),!0===t.depthOnly)m=g;else {const e=n.concat(["BUILDING_FAUX_FACADE","HAS_ATTRIBUTE_a_faux_facade_color_emissive"]);m=i.getOrCreateProgram("building",{config:f,defines:e,overrideFog:!1});}h&&(h.setupShadowsFromMatrix(o,g,!0),m!==g&&h.setupShadowsFromMatrix(o,m,!0));}const x=(e,o)=>{if(c){const r=e.entranceBloom;o.draw(i,a.gl.TRIANGLES,t.depthMode,Xi.disabled,t.blendMode,Ji.disabled,v,s.id,r.layoutVertexBuffer,r.indexBuffer,r.segmentsBucket,s.paint,i.transform.zoom,f,[r.layoutAttenuationBuffer,r.layoutColorBuffer]);}else {const r=e.segmentsBucket;let n=[e.layoutNormalBuffer,e.layoutCentroidBuffer,e.layoutColorBuffer,e.layoutFloodLightDataBuffer];e.layoutFacadePaintBuffer&&(n=n.concat([e.layoutFacadeDataBuffer,e.layoutFacadeVerticalRangeBuffer,e.layoutFacadePaintBuffer])),o.draw(i,a.gl.TRIANGLES,t.depthMode,Xi.disabled,t.blendMode,l?Ji.disabled:Ji.backCW,v,s.id,e.layoutVertexBuffer,e.indexBuffer,r,s.paint,i.transform.zoom,f,n);}};i.uploadCommonUniforms(a,g,_.toUnwrapped(),null,u),p.buildingWithoutFacade&&x(p.buildingWithoutFacade,g),p.buildingWithFacade&&(m!==g&&i.uploadCommonUniforms(a,m,_.toUnwrapped(),null,u),x(p.buildingWithFacade,m));}}function xn(t,i,o,s,r,n,a,l,c,h,d,u,_){const p=t.context.gl,f=t.depthModeForSublayer(1,Wi.ReadOnly,p.LEQUAL,!0),m=.1*(1-(g=d))+3*g;var g;const v=t._showOverdrawInspector,y=u,x=new un;v||_n(x,t,i,o,s,f,new Xi({func:p.ALWAYS,mask:255},255,255,p.KEEP,p.KEEP,p.REPLACE),new Zi([p.ONE,p.ONE,p.ONE,p.ONE],e.ap.transparent,[!1,!1,!1,!0],p.MIN),Ji.disabled,r,"sdf",n,a,l,c,h,m,y,!1);{const d=v?Xi.disabled:new Xi({func:p.EQUAL,mask:255},255,255,p.KEEP,p.DECR,p.DECR),u=v?t.colorModeForRenderPass():new Zi([p.ONE_MINUS_DST_ALPHA,p.DST_ALPHA,p.ONE,p.ONE],e.ap.transparent,[!0,!0,!0,!0]);_n(x,t,i,o,s,f,d,u,Ji.disabled,r,"color",n,a,l,c,h,m,y,!1);}}function bn(t){return [t[0]*e.ej,t[1]*e.ej,t[2]*e.ej,0]}function wn(t,i,o,s,r,n,a,l,c){const h=s.getSource(),d=o.globeSharedBuffers;if(!d)return;let u,_,p;if(i&&(u=s.getTile(i)),h instanceof e.aV?(_=h.texture,p=e.dM(0,0,o.transform)):u&&i&&(_=u.texture,p=e.dM(i.canonical.z,i.canonical.x,o.transform)),!_||!p)return;t||(p=e.cT(e.bD(),p,[1,-1,1]));const f=o.context,m=f.gl,g="nearest"===r.paint.get("raster-resampling")?m.NEAREST:m.LINEAR,v=o.colorModeForDrapableLayerRenderPass(n),y=a.defines;y.push("GLOBE_POLES");const x=new Wi(m.LEQUAL,Wi.ReadWrite,o.depthRangeFor3D),b=Float32Array.from(o.transform.expandedFarZProjMatrix),w=Float32Array.from(e.bl(e.dL(new e.cE(0,0,0))));o.terrain&&o.terrain.prepareDrawTile(),f.activeTexture.set(m.TEXTURE0),_.bind(g,m.CLAMP_TO_EDGE),f.activeTexture.set(m.TEXTURE1),_.bind(g,m.CLAMP_TO_EDGE),"useMipmap"in _&&f.extTextureFilterAnisotropic&&o.transform.pitch>20&&m.texParameterf(m.TEXTURE_2D,f.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,f.extTextureFilterAnisotropicMax);const[T,E,S,I]=i?d.getPoleBuffers(i.canonical.z,!1):d.getPoleBuffers(0,!0),C=r.paint.get("raster-elevation");let R;t?(R=T,o.renderDefaultNorthPole=0!==C):(R=E,o.renderDefaultSouthPole=0!==C);const A=bn(a.mix),D=((e,t,i,o,s,r,n,a,l,c,h,d,u,_)=>zr(e,t,i,o,new Float32Array(16),new Float32Array(9),[0,0],s,[0,0],[0,0,0,0],1,{opacity:1,mix:0},n,[0,0]||[0,0],l,2,h,d,u,1,0,_))(o,b,w,p,e.ak(o.transform.zoom),0,r,0,C,0,A,a.offset,a.range,n),L=o.getOrCreateProgram("raster",{defines:y});o.uploadCommonUniforms(f,L,null),L.draw(o,m.TRIANGLES,x,c,v,l,D,r.id,R,S,I);}function Tn(e){if(e.isOrthographic)return [0,0,0,0];const t=e._nearZ,i=e.projection.farthestPixelDistance(e),o=i-t,s=.2*e.height,r=t+s;return [t,i,(r-s-t)/o,(r-t)/o]}function En(e,t,i,o){if(e)return t instanceof pt&&e instanceof Ot?t.getTextureDescriptor(e,i,!0):{texture:e.texture,mix:bn(o.mix),offset:o.offset,buffer:0,tileSize:1}}var Sn=e.ek([{name:"a_index",type:"Int16",components:1}]);class In{constructor(t,i,o,s){const r={width:o[0],height:o[1],data:null},n=t.gl;this.targetColorTexture=new e.T(t,r,n.RGBA8,{useMipmap:!1}),this.backgroundColorTexture=new e.T(t,r,n.RGBA8,{useMipmap:!1}),this.context=t,this.updateParticleTexture(i,s),this.lastInvalidatedAt=0;}updateParticleTexture(t,i){if(this.particleTextureDimension===i.width)return;(this.particleTexture0||this.particleTexture1||this.particleIndexBuffer||this.particleSegment)&&(this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleIndexBuffer.destroy(),this.particleSegment.destroy());const o=this.context.gl,s=i.width*i.height;this.particleTexture0=new e.T(this.context,i,o.RGBA8,{premultiply:!1,useMipmap:!1}),this.particleTexture1=new e.T(this.context,i,o.RGBA8,{premultiply:!1,useMipmap:!1});const r=new e.el;r.reserve(s);for(let e=0;e0){const t=e.bk(o.canonical,c),i=e.eo(t);_=e.aC(new Float32Array(16),c.globeMatrix,i),e.aC(_,c.projMatrix,_);}const p=e.bD();p[12]+=2*r/(e.o.devicePixelRatio*c.width),p[13]+=2*n/(e.o.devicePixelRatio*c.height),e.aC(_,p,_);const f=t.getOrCreateProgram("debug",{defines:u}),m=i.getTileByID(o.key);t.terrain&&t.terrain.setupElevationDraw(m,f);const g=Wi.disabled,v=Xi.disabled,y=t.colorModeForRenderPass(),x="$debug";l.activeTexture.set(h.TEXTURE0),t.emptyTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),d?m._makeGlobeTileDebugBuffers(t.context,c):m._makeDebugTileBoundsBuffers(t.context,c.projection);const b=m._tileDebugBuffer||t.debugBuffer,w=m._tileDebugIndexBuffer||t.debugIndexBuffer,T=m._tileDebugSegments||t.debugSegments;if(f.draw(t,h.LINE_STRIP,g,v,y,Ji.disabled,Rr(_,s.toPremultipliedRenderColor(null)),x,b,w,T,null,null,null,[m._globeTileDebugBorderBuffer]),a){const e=m.latestRawTileData,i=Math.floor((e&&e.byteLength||0)/1024);let s=o.canonical.toString();o.overscaledZ!==o.canonical.z&&(s+=` => ${o.overscaledZ}`),s+=` ${m.state}`,s+=` ${i}kb`,function(e,t){e.initDebugOverlayCanvas();const i=e.debugOverlayCanvas,o=e.context.gl,s=e.debugOverlayCanvas.getContext("2d");s.clearRect(0,0,i.width,i.height),s.shadowColor="white",s.shadowBlur=2,s.lineWidth=1.5,s.strokeStyle="white",s.textBaseline="top",s.font="bold 36px Open Sans, sans-serif",s.fillText(t,5,5),s.strokeText(t,5,5),e.debugOverlayTexture.update(i),e.debugOverlayTexture.bind(o.LINEAR,o.CLAMP_TO_EDGE);}(t,s);}const E=i.getTile(o).tileSize,S=512/Math.min(E,512)*(o.overscaledZ/c.zoom)*.5,I=m._tileDebugTextBuffer||t.debugBuffer,C=m._tileDebugTextIndexBuffer||t.quadTriangleIndexBuffer,R=m._tileDebugTextSegments||t.debugSegments;f.draw(t,h.TRIANGLES,g,v,Zi.alphaBlended,Ji.disabled,Rr(_,e.ap.transparent.toPremultipliedRenderColor(null),S),x,I,C,R,null,null,null,[m._globeTileDebugTextBuffer]);}function Fn(e,t,i,o){Bn(e,0,t+i/2,e.transform.width,i,o);}function kn(e,t,i,o){Bn(e,t-i/2,0,i,e.transform.height,o);}function Bn(t,i,o,s,r,n){const a=t.context,l=a.gl;l.enable(l.SCISSOR_TEST),l.scissor(i*e.o.devicePixelRatio,o*e.o.devicePixelRatio,s*e.o.devicePixelRatio,r*e.o.devicePixelRatio),a.clear({color:n}),l.disable(l.SCISSOR_TEST);}const Nn=e.ek([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:Un}=Nn;function jn(e,t,i,o){e.emplaceBack(t,i,o);}class Vn{constructor(t){this.vertexArray=new e.ep,this.indices=new e.b1,jn(this.vertexArray,-1,-1,1),jn(this.vertexArray,1,-1,1),jn(this.vertexArray,-1,1,1),jn(this.vertexArray,1,1,1),jn(this.vertexArray,-1,-1,-1),jn(this.vertexArray,1,-1,-1),jn(this.vertexArray,-1,1,-1),jn(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,Un),this.indexBuffer=t.createIndexBuffer(this.indices),this.segment=e.bh.simpleSegment(0,0,36,12);}}function Gn(t,i,o,s,r,n){const a=t.context.gl,l=i.paint.get("sky-atmosphere-color"),c=i.paint.get("sky-atmosphere-halo-color"),h=i.paint.get("sky-atmosphere-sun-intensity"),d=((e,t,i,o,s)=>({u_matrix_3f:e,u_sun_direction:t,u_sun_intensity:i,u_color_tint_r:[o.r,o.g,o.b,o.a],u_color_tint_m:[s.r,s.g,s.b,s.a],u_luminance:5e-5}))(e.er(e.dQ(),s),r,h,l.toPremultipliedRenderColor(null),c.toPremultipliedRenderColor(null));a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+n,i.skyboxTexture,0),o.draw(t,a.TRIANGLES,Wi.disabled,Xi.disabled,Zi.unblended,Ji.frontCW,d,"skyboxCapture",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment);}const Hn=e.ek([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class qn{constructor(t){const i=new e.es;i.emplaceBack(-1,1,1,0,0),i.emplaceBack(1,1,1,1,0),i.emplaceBack(1,-1,1,1,1),i.emplaceBack(-1,-1,1,0,1);const o=new e.b1;o.emplaceBack(0,1,2),o.emplaceBack(2,3,0),this.vertexBuffer=t.createVertexBuffer(i,Hn.members),this.indexBuffer=t.createIndexBuffer(o),this.segments=e.bh.simpleSegment(0,0,4,2);}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy();}}const Zn=e.ek([{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 Wn{constructor(){this.starsCount=16e3,this.sizeMultiplier=.15,this.sizeRange=100,this.intensityRange=200;}}class $n{constructor(t){this.colorModeAlphaBlendedWriteRGB=new Zi([1,qi,1,qi],e.ap.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new Zi([1,0,1,0],e.ap.transparent,[!1,!1,!1,!0]),this.params=new Wn,this.updateNeeded=!0;}update(t){const i=t.context;if(!this.atmosphereBuffer||this.updateNeeded){this.updateNeeded=!1,this.atmosphereBuffer=new qn(i);const t=this.params.sizeRange,o=this.params.intensityRange,s=function(t){const i=e.ex(30),o=[];for(let s=0;s{const i="globe"===r.projection.name?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];e&&i.push("ALPHA_PASS");const l=t.getOrCreateProgram("globeAtmosphere",{defines:i}),c=((e,t,i,o,s,r,n,a,l,c,h,d)=>({u_frustum_tl:e,u_frustum_tr:t,u_frustum_br:i,u_frustum_bl:o,u_horizon:s,u_transition:r,u_fadeout_range:n,u_atmosphere_fog_color:a.toArray01(),u_high_color:l.toArray01(),u_space_color:c.toArray01(),u_temporal_offset:h,u_horizon_angle:d}))(r.frustumCorners.TL,r.frustumCorners.TR,r.frustumCorners.BR,r.frustumCorners.BL,r.frustumCorners.horizon,a,m,h,u,p,v,b);t.uploadCommonUniforms(o,l);const d=this.atmosphereBuffer;d&&l.draw(t,s.TRIANGLES,n,Xi.disabled,e?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,Ji.backCW,c,e?"atmosphere_glow_alpha":"atmosphere_glow",d.vertexBuffer,d.indexBuffer,d.segments);};w(!1),w(!0);}drawStars(t,i){const o=e.aB(i.properties.get("star-intensity"),0,1);if(0===o)return;const s=t.context,r=s.gl,n=t.transform,a=t.getOrCreateProgram("stars"),l=e.c8([]);e.ca(l,l,-n._pitch),e.c9(l,l,-n.angle),e.ca(l,l,e.ao(n._center.lat)),e.ev(l,l,-e.ao(n._center.lng));const c=e.cd(new Float32Array(16),l),h=e.aC([],n.starsProjMatrix,c),d=e.er([],c),u=e.ew([],d),_=[0,1,0];e.dS(_,_,u),e.c6(_,_,this.params.sizeMultiplier);const p=[1,0,0];e.dS(p,p,u),e.c6(p,p,this.params.sizeMultiplier);const f=(m=_,g=p,v=o,{u_matrix:Float32Array.from(h),u_up:m,u_right:g,u_intensity_multiplier:v});var m,g,v;t.uploadCommonUniforms(s,a),this.starsVx&&this.starsIdx&&a.draw(t,r.TRIANGLES,Wi.disabled,Xi.disabled,this.colorModeAlphaBlendedWriteRGB,Ji.disabled,f,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments);}}class Xn{constructor(){this.visibleTiles=[];}updateBorders(t,i){const o=[],s=[],r=t._getRenderableCoordinates(!1,!0);for(const e of r){const r=t.getTile(e);if(!r.hasData())continue;const n=r.getBucket(i);n&&(n.isEmpty()||(o.push(e.key),s.push({bucket:n,tileID:e.canonical})));}let n=o.length!==this.visibleTiles.length;if(!n){o.sort();for(let e=0;ee.tileID.z-t.tileID.z||e.tileID.x-t.tileID.x||e.tileID.y-t.tileID.y);for(const t of s){const i=new Array,o=new Array,s=t.bucket;for(const e of s.featuresOnBorder)a.has(e.featureId)?o.push(e.footprintIndex):(a.add(e.featureId),i.push(e.footprintIndex));s.updateFootprintHiddenFlags(i,e.ey,!1),s.updateFootprintHiddenFlags(o,e.ey,!0);}}}function Kn(t,i){const o=[...t],s=i.cameraWorldSizeForFog/i.worldSize,r=e.bB([]);return e.cT(r,r,[s,s,1]),e.aC(o,r,o),e.aC(o,i.worldToFogMatrix,o),o}function Yn(t,i,o,s,r){const n=o.material,a=s.context,{baseColorTexture:l,metallicRoughnessTexture:c}=n.pbrMetallicRoughness,{normalTexture:h,occlusionTexture:d,emissionTexture:u}=n;function _(e,i,o){if(e&&(t.push(i),a.activeTexture.set(a.gl.TEXTURE0+o),e.gfxTexture)){const{minFilter:t,magFilter:i,wrapS:o,wrapT:s}=e.sampler;e.gfxTexture.bindExtraParam(t,i,o,s);}}_(l,"HAS_TEXTURE_u_baseColorTexture",5),_(c,"HAS_TEXTURE_u_metallicRoughnessTexture",6),_(h,"HAS_TEXTURE_u_normalTexture",7),_(d,"HAS_TEXTURE_u_occlusionTexture",8),_(u,"HAS_TEXTURE_u_emissionTexture",9),r&&(r.texture||(r.texture=new e.e1(s.context,r.image,[r.image.height,r.image.height,r.image.height],a.gl.RGBA8)),a.activeTexture.set(a.gl.TEXTURE0+10),r.texture&&r.texture.bind(a.gl.LINEAR,a.gl.CLAMP_TO_EDGE),t.push("APPLY_LUT_ON_GPU")),o.texcoordBuffer&&(t.push("HAS_ATTRIBUTE_a_uv_2f"),i.push(o.texcoordBuffer)),o.colorBuffer&&(t.push(12===o.colorBuffer.itemSize?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),i.push(o.colorBuffer)),o.normalBuffer&&(t.push("HAS_ATTRIBUTE_a_normal_3f"),i.push(o.normalBuffer)),o.pbrBuffer&&(t.push("HAS_ATTRIBUTE_a_pbr"),t.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),i.push(o.pbrBuffer)),"OPAQUE"!==n.alphaMode&&"MASK"!==n.alphaMode||t.push("UNPREMULT_TEXTURE_IN_SHADER"),n.defined||t.push("DIFFUSE_SHADED");const p=s.shadowRenderer;p&&(t.push("RENDER_SHADOWS","DEPTH_TEXTURE"),p.useNormalOffset&&t.push("NORMAL_OFFSET"));}function Jn(t,i,o,s,r,n){const a=t.modelOpacity,l=i.context,c=new Wi(i.context.gl.LEQUAL,t.isLightMesh?Wi.ReadOnly:Wi.ReadWrite,i.depthRangeFor3D),h=i.transform,d=t.mesh,u=d.material,_=u.pbrMetallicRoughness,p=i.style.fog;let f;f="pixels"===i.transform.projection.zAxisUnit?[...t.nodeModelMatrix]:e.aC([],s.zScaleMatrix,t.nodeModelMatrix),e.aC(f,s.negCameraPosMatrix,f);const m=e.bm([],f);e.ei(m,m);const g="none"===o.paint.get("model-color-use-theme").constantOr("default"),v=o.paint.get("model-emissive-strength").constantOr(0),y=qr(new Float32Array(t.worldViewProjection),new Float32Array(f),new Float32Array(m),null,i,a,_.baseColorFactor,u.emissiveFactor,_.metallicFactor,_.roughnessFactor,u,v,o,void 0,void 0,t.materialOverride,t.modelColor),x={defines:[]},b=[],w=i.shadowRenderer;w&&(w.useNormalOffset=!1),Yn(x.defines,b,d,i,g?null:o.lut);let T=null;if(p){const e=Kn(t.nodeModelMatrix,i.transform);if(T=new Float32Array(e),"globe"!==h.projection.name){const t=d.aabb.min,i=d.aabb.max,[o,s]=p.getOpacityForBounds(e,t[0],t[1],i[0],i[1]);x.overrideFog=o>=Ve||s>=Ve;}}const E=lo(i,o.paint.get("model-cutoff-fade-range"));E.shouldRenderCutoff&&x.defines.push("RENDER_CUTOFF");const S=i.getOrCreateProgram("model",x);i.uploadCommonUniforms(l,S,null,T,E),"shadow"!==i.renderPass&&w&&w.setupShadowsFromMatrix(t.nodeModelMatrix,S),S.draw(i,l.gl.TRIANGLES,c,r,n,d.material.doubleSided?Ji.disabled:Ji.backCCW,y,o.id,d.vertexBuffer,d.indexBuffer,d.segments,o.paint,i.transform.zoom,void 0,b);}function Qn(e,t){return e.style._importedAsBasemap?"basemap":t.scope}function ea(t,i,o,s,r,n,a,l,c,h){const d=t.transform,u=!!i.isGeometryBloom&&i.isGeometryBloom;if(u&&"shadow"===t.renderPass)return;const _="globe"===d.projection.name?e.eG(o,d):[...o];e.aC(_,_,i.globalMatrix);const p=e.aC([],s,_);if(i.meshes)for(const t of i.meshes){const s=l.get(t.material.name);if(s&&s.opacity<=0)continue;if("BLEND"!==t.material.alphaMode){a.push({mesh:t,depth:0,modelIndex:r,worldViewProjection:p,nodeModelMatrix:_,isLightMesh:u,materialOverride:s,modelOpacity:c,modelColor:h,node:i,modelMatrix:o});continue}const f=e.ag([],t.centroid,p);!d.isOrthographic&&f[2]<=0||n.push({mesh:t,depth:f[2],modelIndex:r,worldViewProjection:p,nodeModelMatrix:_,isLightMesh:u,materialOverride:s,modelOpacity:c,modelColor:h,node:i,modelMatrix:o});}if(i.children)for(const e of i.children)ea(t,e,o,s,r,n,a,l,c,h);}function ta(e,t,i,o){const s=i.shadowRenderer;if(!s)return;const r=s.getShadowPassDepthMode(),n=s.getShadowPassColorMode(),a=s.calculateShadowPassMatrixFromMatrix(t),l=Zr(a);i.getOrCreateProgram("modelDepth",{defines:i._shadowMapDebug?[]:["DEPTH_TEXTURE"]}).draw(i,i.context.gl.TRIANGLES,r,Xi.disabled,n,Ji.disabled,l,o.id,e.vertexBuffer,e.indexBuffer,e.segments,o.paint,i.transform.zoom,void 0,void 0);}function ia(t,i,o,s){const r=function(t,i){if(i.footprintDebugMesh)return i.footprintDebugMesh;if(!i.footprint)return null;const o=t.context,s=i.footprint.vertices,r=i.footprint.indices,n=new e.be;n.reserve(s.length);for(const e of s)n.emplaceBack(e.x,e.y);const a=new e.b1;a.reserve(r.length);for(let e=0;e0){const i=t.terrain,r=i.findDEMTileFor(o);r&&r.dem?s=e.eI.create(i,o,r):a=0;}if(0===a&&(i.terrainElevationMin=0,i.terrainElevationMax=0),a===i.validForExaggeration&&(0===a||s&&s._demTile&&s._demTile.tileID===i.validForDEMTile.id&&s._dem._timestamp===i.validForDEMTile.timestamp))return !1;for(const e in i.instancesPerModel){const t=i.instancesPerModel[e];for(let e=0;eh&&(h=e.max);}const d=e.aB(s.x,n,a)-s.x,u=e.aB(s.y,l,c)-s.y,_=e.cg(h,i.center.lat)-s.z;return i._zoomFromMercatorZ(Math.sqrt(d*d+u*u+_*_))}function ca(e,t,i,o,s,r,n){const a=e.context,l="shadow"===e.renderPass,c=e.shadowRenderer,h=l&&c?c.getShadowPassDepthMode():new Wi(a.gl.LEQUAL,Wi.ReadWrite,e.depthRangeFor3D),d=e.isTileAffectedByFog(r),u="globe"===e.transform.projection.name;if(i.meshes)for(const _ of i.meshes){const p=u?[]:["MODEL_POSITION_ON_GPU"],f=[];let m,g,v;const y=!u&&o.instancedDataArray.length>20;y&&p.push("INSTANCED_ARRAYS");const x=lo(e,t.paint.get("model-cutoff-fade-range"));if(x.shouldRenderCutoff&&p.push("RENDER_CUTOFF"),l&&c)m=e.getOrCreateProgram("modelDepth",{defines:p}),g=Zr(n.shadowTileMatrix,n.shadowTileMatrix,Float32Array.from(i.globalMatrix)),v=c.getShadowPassColorMode();else {Yn(p,f,_,e,"none"===t.paint.get("model-color-use-theme").constantOr("default")?null:t.lut),m=e.getOrCreateProgram("model",{defines:p,overrideFog:d});const o=_.material,l=o.pbrMetallicRoughness,h=t.paint.get("model-opacity").constantOr(1),u=t.paint.get("model-emissive-strength").constantOr(0);g=qr(r.expandedProjMatrix,Float32Array.from(i.globalMatrix),new Float32Array(16),null,e,h,l.baseColorFactor,o.emissiveFactor,l.metallicFactor,l.roughnessFactor,o,u,t,s),c&&(n.shadowUniformsInitialized?m.setShadowUniformValues(a,c.getShadowUniformValues()):(c.setupShadows(r.toUnwrapped(),m,"model-tile"),n.shadowUniformsInitialized=!0)),v=x.shouldRenderCutoff||h<1||"OPAQUE"!==o.alphaMode?Zi.alphaBlended:Zi.unblended;}e.uploadCommonUniforms(a,m,r.toUnwrapped(),null,x);const b=_.material.doubleSided?Ji.disabled:Ji.backCCW;if(y)f.push(o.instancedDataBuffer),m.draw(e,a.gl.TRIANGLES,h,Xi.disabled,v,b,g,t.id,_.vertexBuffer,_.indexBuffer,_.segments,t.paint,e.transform.zoom,void 0,f,o.instancedDataArray.length);else {const i=l?"u_instance":"u_normal_matrix";for(let s=0;sc[1]?a:c,n[0]=o.max[0],a=e.aD(e.eJ(),n,r),l=a[1]c[1]?a:c,n[1]=o.min[1],a=e.aD(e.eJ(),n,r),l=a[1]c[1]?a:c;const h=e.aB(s[0],0,1),d=100*i.pixelsPerMeter*e.aB(s[1],0,1),u=e.aB(s[2],0,1),_=e.eK(e.eJ(),l,c,h),p=Math.tan(.5*i.fovX),f=-_[2]*p;if(0===d)return _[1]<-Math.abs(f)?u:1;const m=(-Math.abs(f)-_[1])/d,g=(e,t,i)=>(1-i)*e+i*t,v=e.aB(g(1,u,m),u,1);return g(1,v,e.aB((i.pitch-20)/20,0,1))}class pa{}class fa{constructor(){this._storage=new Map;}getLinesFromTrianglesBuffer(t,i,o){{const e=this._storage.get(i.id);if(e)return e.lastUsedFrameIdx=t,e.buf}const s=o.gl,r=s.getBufferParameter(s.ELEMENT_ARRAY_BUFFER,s.BUFFER_SIZE),n=new ArrayBuffer(r),a=new Int16Array(n);s.getBufferSubData(s.ELEMENT_ARRAY_BUFFER,0,new Int16Array(n));const l=new e.eM;for(let e=0;e30&&(i.buf.destroy(),this._storage.delete(t));}destroy(){for(const[e,t]of this._storage)t.buf.destroy(),this._storage.delete(e);}}class ma{constructor(){this.occluderSize=30,this.depthOffset=-1e-4;}}const ga=e.ek([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_rainParticleData",components:4}]);class va{constructor(e){this.revealStart=11,this.revealRange=2;}}const ya=e.ek([{type:"Float32",name:"a_pos_2f",components:2}]);class xa{destroy(){this.vignetteVx&&this.vignetteVx.destroy(),this.vignetteIdx&&this.vignetteIdx.destroy();}draw(t,i){const o=t.getOrCreateProgram("vignette");if(!this.vignetteVx||!this.vignetteIdx){const i=new e.eN,o=new e.b1;i.emplaceBack(-1,-1),i.emplaceBack(1,-1),i.emplaceBack(1,1),i.emplaceBack(-1,1),o.emplaceBack(0,1,2),o.emplaceBack(0,2,3),this.vignetteVx=t.context.createVertexBuffer(i,ya.members),this.vignetteIdx=t.context.createIndexBuffer(o);}const s=e.bh.simpleSegment(0,0,4,6);if(this.vignetteVx&&this.vignetteIdx){t.uploadCommonUniforms(t.context,o);const e={u_vignetteShape:(r={vignetteShape:[i.start,i.range,Math.pow(10,i.fadePower)],vignetteColor:[i.color.r,i.color.g,i.color.b,i.color.a*i.strength]}).vignetteShape,u_vignetteColor:r.vignetteColor};o.draw(t,t.context.gl.TRIANGLES,Wi.disabled,Xi.disabled,Zi.alphaBlended,Ji.disabled,e,"vignette",this.vignetteVx,this.vignetteIdx,s);}var r;}}class ba{constructor(){this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0;}update(t,i){const o=t.getFreeCameraOptions().position,s=o.toAltitude(),r=o.toLngLat(),n=e.ao(r.lng),a=e.ao(r.lat),l=t.pixelsPerMeter/i,c=n*e.eP,h=e.eP*Math.log(Math.tan(Math.PI/4+a/2));if(void 0===this._offsetXPrev)this._offsetXPrev=0,this._offsetYPrev=0,this._elevationPrev=0,this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0;else {const e=-this._offsetYPrev+h,t=-this._elevationPrev+s;this._accumulatedOffsetX+=(-this._offsetXPrev+c)*l,this._accumulatedOffsetY+=e*l,this._accumulatedElevation+=t*l,this._offsetXPrev=c,this._offsetYPrev=h,this._elevationPrev=s;}}getPosition(){return [this._accumulatedOffsetX,this._accumulatedOffsetY,this._accumulatedElevation]}}function wa(e,t){return [-(e[0]-Math.floor(e[0]/t)*t),-(e[1]-Math.floor(e[1]/t)*t),-(e[2]-Math.floor(e[2]/t)*t)]}function Ta(t){const i=e.ex(1323123451230),o=[];for(let s=0;s Rain"),this._vignetteParams={strength:1,start:.7,range:1,fadePower:.4,color:{r:.27,g:.27,b:.27,a:1}},this.particlesCount=16e3;}update(t){const i=t.context;if(!this.particlesVx){const t=Ta(this.particlesCount),o=new e.eQ,s=new e.b1;let r=0;const n=e.ex(1323123451230);for(let e=0;eo)return;const s=Ea(0,1,i.revealStart,i.revealStart+i.revealRange,o);if(!this.particlesVx||!this.particlesIdx)return;const r=structuredClone(this._params);let n=[-r.direction.x,r.direction.y,-100];e.ax(n,n);const a=structuredClone(this._vignetteParams);a.strength*=s,r.overrideStyleParameters||(r.intensity=t.style.rain.state.density,r.timeFactor=t.style.rain.state.intensity,r.color=structuredClone(t.style.rain.state.color),n=structuredClone(t.style.rain.state.direction),r.screenThinning.intensity=t.style.rain.state.centerThinning,r.dropletSizeX=t.style.rain.state.dropletSize[0],r.dropletSizeYScale=t.style.rain.state.dropletSize[1]/t.style.rain.state.dropletSize[0],r.distortionStrength=100*t.style.rain.state.distortionStrength,a.strength=1,a.color=structuredClone(t.style.rain.state.vignetteColor));const l=this.updateOnRender(t,r.timeFactor),c=t.context,h=c.gl,d=t.transform;this.screenTexture&&this.screenTexture.size[0]===t.width&&this.screenTexture.size[1]===t.height||(this.screenTexture=new e.T(c,{width:t.width,height:t.height,data:null},h.RGBA8)),r.distortionStrength>0&&(c.activeTexture.set(h.TEXTURE0),this.screenTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),h.copyTexSubImage2D(h.TEXTURE_2D,0,0,0,0,0,t.width,t.height));const u=t.getOrCreateProgram("rainParticle");t.uploadCommonUniforms(c,u),c.activeTexture.set(h.TEXTURE0),this.screenTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE);const _=[r.color.r,r.color.g,r.color.b,r.color.a],p=(i,o)=>{const s=wa(this._movement.getPosition(),i),a=r.dropletSizeX,c=r.dropletSizeX*r.dropletSizeYScale,p=t.width/2,f=t.height/2,m=Ea(0,r.screenThinning.start,0,1,r.screenThinning.intensity),g=Ea(.001,r.screenThinning.range,0,1,r.screenThinning.intensity),v=Ea(0,r.screenThinning.particleOffset,0,1,r.screenThinning.intensity),y=(x={modelview:l.modelviewMatrix,projection:l.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:s,velocityConeAperture:r.velocityConeAperture,velocity:r.velocity,boxSize:i,rainDropletSize:[a,c],distortionStrength:r.distortionStrength,rainDirection:n,color:_,screenSize:[d.width,d.height],thinningCenterPos:[p,f],thinningShape:[m,g,Math.pow(10,r.screenThinning.fadePower)],thinningAffectedRatio:r.screenThinning.affectedRatio,thinningParticleOffset:v,shapeDirectionalPower:r.shapeDirPower,shapeNormalPower:r.shapeNormalPower,mode:o?0:1},{u_modelview:Float32Array.from(x.modelview),u_projection:Float32Array.from(x.projection),u_time:x.time,u_cam_pos:x.camPos,u_texScreen:0,u_velocityConeAperture:x.velocityConeAperture,u_velocity:x.velocity,u_boxSize:x.boxSize,u_rainDropletSize:x.rainDropletSize,u_distortionStrength:x.distortionStrength,u_rainDirection:x.rainDirection,u_color:x.color,u_screenSize:x.screenSize,u_thinningCenterPos:x.thinningCenterPos,u_thinningShape:x.thinningShape,u_thinningAffectedRatio:x.thinningAffectedRatio,u_thinningParticleOffset:x.thinningParticleOffset,u_shapeDirectionalPower:x.shapeDirectionalPower,u_shapeNormalPower:x.shapeNormalPower,u_mode:x.mode});var x;const b=Math.round(r.intensity*this.particlesCount),w=e.bh.simpleSegment(0,0,4*b,2*b);u.draw(t,h.TRIANGLES,Wi.disabled,Xi.disabled,Zi.alphaBlended,Ji.disabled,y,"rain_particles",this.particlesVx,this.particlesIdx,w);};r.distortionStrength>0&&p(r.boxSize,!0),p(r.boxSize,!1),this._vignette.draw(t,a);}}const Ca=e.ek([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_snowParticleData",components:4},{type:"Float32",name:"a_snowParticleDataHorizontalOscillation",components:2}]);class Ra extends Sa{constructor(e){super(2.25),this._params={overrideStyleParameters:!1,intensity:.85,timeFactor:.75,velocityConeAperture:70,velocity:40,horizontalOscillationRadius:4,horizontalOscillationRate:1.5,boxSize:2e3,billboardSize:2,shapeFadeStart:.27,shapeFadePower:.21,screenThinning:{intensity:.4,start:.15,range:1.4,fadePower:.24,affectedRatio:1,particleOffset:-.2},color:{r:1,g:1,b:1,a:1},direction:{x:-50,y:-35}},this._revealParams=new va("Precipitation > Snow"),this._vignetteParams={strength:.3,start:.78,range:.46,fadePower:.2,color:{r:1,g:1,b:1,a:1}},this.particlesCount=16e3;}update(t){const i=t.context;if(!this.particlesVx){const t=Ta(this.particlesCount),o=new e.eR,s=new e.b1;let r=0;const n=e.ex(1323123451230);for(let e=0;en)return;const a=Ea(0,1,r.revealStart,r.revealStart+r.revealRange,n);s.strength*=a,i.overrideStyleParameters||(i.intensity=t.style.snow.state.density,i.timeFactor=t.style.snow.state.intensity,i.color=structuredClone(t.style.snow.state.color),o=structuredClone(t.style.snow.state.direction),i.screenThinning.intensity=t.style.snow.state.centerThinning,i.billboardSize=2.79*t.style.snow.state.flakeSize,s.strength=1,s.color=structuredClone(t.style.snow.state.vignetteColor));const l=this.updateOnRender(t,i.timeFactor);if(!this.particlesVx||!this.particlesIdx)return;const c=t.context,h=c.gl,d=t.transform,u=t.getOrCreateProgram("snowParticle");t.uploadCommonUniforms(c,u),((i,s,r)=>{const n=wa(this._movement.getPosition(),i),a=d.width/2,c=d.height/2,_=Ea(0,r.screenThinning.start,0,1,r.screenThinning.intensity),p=Ea(.001,r.screenThinning.range,0,1,r.screenThinning.intensity),f=Ea(0,r.screenThinning.particleOffset,0,1,r.screenThinning.intensity),m=(g={modelview:l.modelviewMatrix,projection:l.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:n,velocityConeAperture:r.velocityConeAperture,velocity:r.velocity,horizontalOscillationRadius:r.horizontalOscillationRadius,horizontalOscillationRate:r.horizontalOscillationRate,boxSize:i,billboardSize:1*r.billboardSize,simpleShapeParameters:[r.shapeFadeStart,r.shapeFadePower],screenSize:[d.width,d.height],thinningCenterPos:[a,c],thinningShape:[_,p,Math.pow(10,r.screenThinning.fadePower)],thinningAffectedRatio:r.screenThinning.affectedRatio,thinningParticleOffset:f,color:[r.color.r,r.color.g,r.color.b,r.color.a],direction:o},{u_modelview:Float32Array.from(g.modelview),u_projection:Float32Array.from(g.projection),u_time:g.time,u_cam_pos:g.camPos,u_velocityConeAperture:g.velocityConeAperture,u_velocity:g.velocity,u_horizontalOscillationRadius:g.horizontalOscillationRadius,u_horizontalOscillationRate:g.horizontalOscillationRate,u_boxSize:g.boxSize,u_billboardSize:g.billboardSize,u_simpleShapeParameters:g.simpleShapeParameters,u_screenSize:g.screenSize,u_thinningCenterPos:g.thinningCenterPos,u_thinningShape:g.thinningShape,u_thinningAffectedRatio:g.thinningAffectedRatio,u_thinningParticleOffset:g.thinningParticleOffset,u_particleColor:g.color,u_direction:g.direction});var g;const v=Math.round(r.intensity*this.particlesCount),y=e.bh.simpleSegment(0,0,4*v,2*v);this.particlesVx&&this.particlesIdx&&u.draw(t,h.TRIANGLES,Wi.disabled,Xi.disabled,Zi.alphaBlended,Ji.disabled,m,"snow_particles",this.particlesVx,this.particlesIdx,y);})(i.boxSize,0,i),this._vignette.draw(t,s);}}const Aa={symbol:function(t,i,o,s,r){if("translucent"!==t.renderPass)return;const n=Xi.disabled,a=t.colorModeForRenderPass(),l=o.layout.get("text-variable-anchor"),c=o.layout.get("text-size-scale-range"),h=e.aB(t.scaleFactor,c[0],c[1]);l&&function(t,i,o,s,r,n,a,l){const c=i.transform,h="map"===r,d="map"===n;for(const i of t){const t=s.getTile(i),r=t.getBucket(o);if(!r||!r.text||!r.text.segments.get().length)continue;const n=e.bL(r.textSizeData,c.zoom,l),u=Jt(i,r.getProjection(),c),_=c.calculatePixelsToTileUnitsMatrix(t),p=ii(u,t.tileID.canonical,d,h,c,r.getProjection(),_),f=r.hasIconTextFit()&&r.hasIconData();n&&rn(r,h,d,a,c,p,i,Math.pow(2,c.zoom-t.tileID.overscaledZ),n,f);}}(s,t,o,i,o.layout.get("text-rotation-alignment"),o.layout.get("text-pitch-alignment"),r,h);const d=0!==o.paint.get("icon-opacity").constantOr(1),u=0!==o.paint.get("text-opacity").constantOr(1);void 0!==o.layout.get("symbol-sort-key").constantOr(1)&&(d||u)?nn(t,i,o,s,n,a):(d&&nn(t,i,o,s,n,a,{onlyIcons:!0}),u&&nn(t,i,o,s,n,a,{onlyText:!0})),i.map.showCollisionBoxes&&(en(t,i,o,s,o.paint.get("text-translate"),o.paint.get("text-translate-anchor"),!0),en(t,i,o,s,o.paint.get("icon-translate"),o.paint.get("icon-translate-anchor"),!1));},circle:function(t,i,o,s){if("translucent"!==t.renderPass)return;const r=o.paint.get("circle-opacity"),n=o.paint.get("circle-stroke-width"),a=o.paint.get("circle-stroke-opacity"),l=void 0!==o.layout.get("circle-sort-key").constantOr(1),c=o.paint.get("circle-emissive-strength");if(0===r.constantOr(1)&&(0===n.constantOr(1)||0===a.constantOr(1)))return;const h=t.context,d=h.gl,u=t.transform,_=!(!t.terrain||!t.terrain.enabled),p=o.layout.get("circle-elevation-reference"),f=t.depthModeForSublayer(0,Wi.ReadOnly),m=new Wi(t.context.gl.LEQUAL,Wi.ReadOnly,t.depthRangeFor3D),g="none"===p||_?f:m,v=Xi.disabled,y=t.colorModeForDrapableLayerRenderPass(c),x="globe"===u.projection.name,b=[e.aG(u.center.lng),e.aK(u.center.lat)],w=[];for(let r=0;re.sortKey-t.sortKey);const T={useDepthForOcclusion:u.depthOcclusionForSymbolsAndCircles};for(const e of w){const{programConfiguration:i,program:s,layoutVertexBuffer:r,dynamicBuffers:n,indexBuffer:a,uniformValues:l,tile:c}=e.state,_=e.segments;t.terrain&&t.terrain.setupElevationDraw(c,s,T),t.uploadCommonUniforms(h,s,c.tileID.toUnwrapped()),s.draw(t,d.TRIANGLES,g,v,y,Ji.disabled,l,o.id,r,a,_,o.paint,u.zoom,i,n);}},heatmap:function(t,i,o,s){if(0!==o.paint.get("heatmap-opacity"))if("offscreen"===t.renderPass){const r=t.context,n=r.gl,a=Xi.disabled,l=new Zi([n.ONE,n.ONE,n.ONE,n.ONE],e.ap.transparent,[!0,!0,!0,!0]);!function(e,t,i,o){const s=e.gl,r=t.width*o,n=t.height*o;e.activeTexture.set(s.TEXTURE1),e.viewport.set([0,0,r,n]);let a=i.heatmapFbo;if(!a||a&&(a.width!==r||a.height!==n)){a&&a.destroy();const t=s.createTexture();s.bindTexture(s.TEXTURE_2D,t),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR),a=i.heatmapFbo=e.createFramebuffer(r,n,1,null),function(e,t,i,o,s,r){const n=e.gl;n.texImage2D(n.TEXTURE_2D,0,e.extRenderToTextureHalfFloat?n.RGBA16F:n.RGBA,s,r,0,n.RGBA,e.extRenderToTextureHalfFloat?n.HALF_FLOAT:n.UNSIGNED_BYTE,null),o.colorAttachment0.set(i);}(e,0,t,a,r,n);}else s.bindTexture(s.TEXTURE_2D,a.colorAttachment0.get()),e.bindFramebuffer.set(a.framebuffer);}(r,t,o,"globe"===t.transform.projection.name?.5:.25),r.clear({color:e.ap.transparent});const c=t.transform,h="globe"===c.projection.name,d=h?["PROJECTION_GLOBE_VIEW"]:[],u=h?Ji.frontCCW:Ji.disabled,_=[e.aG(c.center.lng),e.aK(c.center.lat)];for(let e=0;e({u_image:0,u_color_ramp:1,u_opacity:t.paint.get("heatmap-opacity")}))(0,i),i.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,i.paint,t.transform.zoom);}(t,o));},line:function(t,i,o,s){if("translucent"!==t.renderPass)return;const r=o.paint.get("line-opacity"),n=o.paint.get("line-width");if(0===r.constantOr(1)||0===n.constantOr(1))return;const a=o.paint.get("line-emissive-strength").isConstant(),l=o.paint.get("line-emissive-strength").constantOr(0),c=o.paint.get("line-occlusion-opacity"),h=o.layout.get("line-elevation-reference"),d="meters"===o.layout.get("line-width-unit"),u="sea"===h,_=!(!t.terrain||!t.terrain.enabled),p=t.context,f=p.gl;if(o.hasElevatedBuckets&&"globe"===t.transform.projection.name)return;const m=o.layout.get("line-cross-slope"),g=void 0!==m,v=m<1,y=t.colorModeForDrapableLayerRenderPass(a?l:null),x=t.terrain&&t.terrain.renderingToTexture,b=x?1:e.o.devicePixelRatio,w=o.paint.get("line-dasharray"),T=w.constantOr(1),E=o.layout.get("line-cap"),S=w.constantOr(null),I=E.constantOr(null),C=o.paint.get("line-pattern"),R=C.constantOr(1),A=o.paint.get("line-pattern-cross-fade"),D=C.constantOr(null),L=o.paint.get("line-opacity").constantOr(1);let P=!R&&1!==L||t.depthOcclusion&&c>0&&c<1;const O=o.paint.get("line-gradient"),z=R?"linePattern":"line",M=e.e4(o);let F;if(x&&t.terrain&&t.terrain.clipOrMaskOverlapStencilType()&&(P=!1),0!==c&&t.depthOcclusion){const t=o.paint._values["line-opacity"];t&&t.value&&"constant"===t.value.kind?F=t.value:e.w(`Occlusion opacity for layer ${o.id} is supported only when line-opacity isn't data-driven.`);}"constant"!==n.value.kind&&!1===n.value.isLineProgressConstant&&M.push("VARIABLE_LINE_WIDTH"),x&&("dual-source-blending"!==t.emissiveMode||a?"mrt-fallback"===t.emissiveMode&&M.push("USE_MRT1"):M.push("DUAL_SOURCE_BLENDING"));const k={},B=(s,r,n,a,l,h)=>{for(const u of s){const s=i.getTile(u);if(R&&!s.patternsLoaded())continue;const _=s.getBucket(o);if(!_)continue;if("none"!==_.elevationType&&!l||"none"===_.elevationType&&l)continue;t.prepareDrawTile();const m=[...r],g=t.shadowRenderer,v="road"===_.elevationType&&!!g&&g.enabled;let w=[0,0,0];if(v){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(w=mo(t.style,e,i)),m.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET");}const E=_.programConfigurations.get(o.id);let C=!1;if(D&&s.imageAtlas){const t=e.e5.from(D),i=t.getPrimary().scaleSelf(b).toString(),o=s.imageAtlas.patternPositions.get(i),r=t.getSecondary(),n=r?s.imageAtlas.patternPositions.get(r.scaleSelf(b).toString()):null;C=!!o&&!!n,o&&E.setConstantPatternPositions(o,n);}A>0&&(C||E.getPatternTransitionVertexBuffer("line-pattern"))&&m.push("LINE_PATTERN_TRANSITION"),_.elevationGroundScaleVertexBuffer&&m.push("ELEVATION_GROUND_SCALE");const M=t.isTileAffectedByFog(u),B=t.getOrCreateProgram(z,{config:E,defines:m,overrideFog:M});if(!R&&S&&I&&s.lineAtlas){const e=s.lineAtlas.getDash(S,I);e&&E.setConstantPatternPositions(e);}v&&g.setupShadows(s.tileID.toUnwrapped(),B,"vector-tile");let[N,U]=o.paint.get("line-trim-offset");if("round"===I||"square"===I){const e=1;N!==U&&(0===N&&(N-=e),1===U&&(U+=e));}const j=x?u.projMatrix:null,V=d?1/_.tileToMeter/e.az(s,1,t.transform.zoom):1,G=d?1/_.tileToMeter/e.az(s,1,Math.floor(t.transform.zoom)):1,H=T?o.paint._values["line-floorwidth"]:null;let q;if(H&&"constant"===H.value.kind){const e=_.zoom;e in k||(k[e]=Math.max(.01,o.widthExpression().evaluate({zoom:e}))),q=H.value.value;const i=Math.floor(t.transform.zoom);H.value.value=k[e]*Math.pow(2,i-s.tileID.overscaledZ);}const Z=R?e.e6(t,s,o,j,b,V,G,[N,U],w,A):e.e7(t,s,o,j,_.lineClipsArray.length,b,V,G,[N,U],w);if(O){const s=_.gradients[o.id];let r=s.texture;if(o.gradientVersion!==s.version){let n=256;if(o.stepInterpolant){const o=i.getSource().maxzoom,s=u.canonical.z===o?Math.ceil(1<{null!=F&&(F.value=L*c),B.draw(t,f.TRIANGLES,n,e,y,Ji.disabled,Z,o.id,_.layoutVertexBuffer,_.indexBuffer,_.segments,o.paint,t.transform.zoom,E,[_.layoutVertexBuffer2,_.patternVertexBuffer,_.zOffsetVertexBuffer,_.elevationGroundScaleVertexBuffer]),null!=F&&(F.value=L);};if(P&&!l){const e=t.stencilModeForClipping(u).ref;0===e&&x&&p.clear({stencil:0});const i={func:f.EQUAL,mask:255};Z.u_alpha_discard_threshold=.8,W(new Xi(i,e,255,f.KEEP,f.KEEP,f.INVERT)),Z.u_alpha_discard_threshold=0,W(new Xi(i,e,255,f.KEEP,f.KEEP,f.KEEP));}else Z.u_alpha_discard_threshold=P&&l&&h?.8:0,W(l?a:t.stencilModeForClipping(u));void 0!==q&&(H.value.value=q);}};let N=t.depthModeForSublayer(0,Wi.ReadOnly);const U=new Wi(t.depthOcclusion?f.GREATER:f.LEQUAL,Wi.ReadOnly,t.depthRangeFor3D);if(o.hasNonElevatedBuckets){const i=!x&&t.terrain;0!==c&&i?e.w(`Occlusion opacity for layer ${o.id} is supported on terrain only if the layer has line-z-offset enabled.`):i?e.w(`Cannot render non-elevated lines in immediate mode when terrain is enabled. Layer: ${o.id}.`):B(s,M,N,Xi.disabled,!1,!0);}if(o.hasElevatedBuckets){"hd-road-markup"===h?_||(N=U,M.push("ELEVATED_ROADS")):(M.push("ELEVATED"),N=U,g&&M.push(v?"CROSS_SLOPE_HORIZONTAL":"CROSS_SLOPE_VERTICAL"),u&&M.push("ELEVATION_REFERENCE_SEA"));const e=P?t.stencilModeFor3D():Xi.disabled;t.forceTerrainMode=!0,B(s,M,N,e,!0,!0),P&&B(s,M,N,e,!0,!1),t.forceTerrainMode=!1;}P&&(t.resetStencilClippingMasks(),x&&p.clear({stencil:0})),0===c||t.depthOcclusion||x||t.layersWithOcclusionOpacity.push(t.currentLayer);},fill:function(t,i,o,s){const r=o.paint.get("fill-color"),n=o.paint.get("fill-opacity");if(0===n.constantOr(1))return;const a=o.paint.get("fill-emissive-strength"),l=t.colorModeForDrapableLayerRenderPass(a),c=o.paint.get("fill-pattern"),h=t.opaquePassEnabledForLayer()&&!c.constantOr(1)&&1===r.constantOr(e.ap.transparent).a&&1===n.constantOr(0)?"opaque":"translucent";let d="none";"none"!==o.layout.get("fill-elevation-reference")?d="road":0!==o.paint.get("fill-z-offset").constantOr(1)&&(d="offset");const u=!(!t.terrain||!t.terrain.enabled),_={painter:t,sourceCache:i,layer:o,coords:s,colorMode:l,elevationType:d,terrainEnabled:u,pass:h};if("shadow"===t.renderPass)return void(t.shadowRenderer&&"road"===d&&!u&&function(e){const{painter:t,sourceCache:i,layer:o,coords:s}=e,r=t.context.gl,n=e.painter.shadowRenderer;for(const e of s){const s=i.getTile(e),a=s.getBucket(o);if(!a)continue;const l=a.elevatedStructures;if(!l)continue;if(!l.shadowCasterSegments||0===l.shadowCasterSegments.segments[0].primitiveLength)continue;t.prepareDrawTile();const c=a.bufferData.programConfigurations.get(o.id),h=t.isTileAffectedByFog(e),d=t.getOrCreateProgram("elevatedStructuresDepth",{config:c,overrideFog:h}),u=n.calculateShadowPassMatrixFromTile(s.tileID.toUnwrapped());t.uploadCommonUniforms(t.context,d,e.toUnwrapped());const _=xr(u,0);d.draw(t,r.TRIANGLES,n.getShadowPassDepthMode(),Xi.disabled,n.getShadowPassColorMode(),Ji.disabled,_,o.id,l.vertexBuffer,l.indexBuffer,l.shadowCasterSegments,o.paint,t.transform.zoom,c);}}(_));const p="mrt-fallback"===t.emissiveMode;if("offset"!==d){if(hn(_,!1,p),"road"===d){const e=!u&&"translucent"===t.renderPass;e&&cn(t,i,o,s,"geometry"),hn(_,!0,p,Xi.disabled),e&&function(e){const{painter:t,sourceCache:i,layer:o,coords:s,colorMode:r}=e,n=t.context.gl,a=e.painter.shadowRenderer,l=!!a&&a.enabled,c=new Wi(t.context.gl.LEQUAL,Wi.ReadOnly,t.depthRangeFor3D);let h=[0,0,0];if(l){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(h=mo(t.style,e,i));}const d=e=>{for(const d of s){const s=i.getTile(d),u=s.getBucket(o);if(!u)continue;const _=u.elevatedStructures;if(!_)continue;let p,f;if(e?(p=_.renderableBridgeSegments,f=_.bridgeProgramConfigurations.get(o.id)):(p=_.renderableTunnelSegments,f=_.tunnelProgramConfigurations.get(o.id)),!p||0===p.segments[0].primitiveLength)continue;f.updatePaintBuffers(),t.prepareDrawTile();const m=t.isTileAffectedByFog(d),g=[];l&&g.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET");const v=t.getOrCreateProgram("elevatedStructures",{config:f,overrideFog:m,defines:g}),y=t.translatePosMatrix(d.projMatrix,s,o.paint.get("fill-translate"),o.paint.get("fill-translate-anchor"));l&&a.setupShadows(s.tileID.toUnwrapped(),v,"vector-tile");const x=br(y,h);t.uploadCommonUniforms(t.context,v,d.toUnwrapped()),v.draw(t,n.TRIANGLES,c,Xi.disabled,r,Ji.backCCW,x,o.id,_.vertexBuffer,_.indexBuffer,p,o.paint,t.transform.zoom,f,[_.vertexBufferNormal]);}};d(!0),d(!1);}(_);}}else hn(_,!1,p,t.stencilModeFor3D());},"fill-extrusion":function(t,i,o,s){const r=o.paint.get("fill-extrusion-opacity"),n=t.context,a=n.gl,l=t.terrain,c=l&&l.renderingToTexture;if(0===r)return;const h="mrt-fallback"===t.emissiveMode,d=t.conflationActive&&t.style.isLayerClipped(o,i.getSource()),u=t.style.order.indexOf(o.fqid);if(d&&function(e,t,i,o,s){for(const r of o){const o=t.getTile(r).getBucket(i);o&&(o.updateReplacement(r,e.replacementSource,s),o.uploadCentroid(e.context));}}(t,i,o,s,u),l||d)for(const e of s){const s=i.getTile(e).getBucket(o);s&&pn(t.context,i,e,s,o,l,d);}if("shadow"===t.renderPass&&t.shadowRenderer){const n=t.shadowRenderer;if(l&&r<.65&&o._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof e.ae)return;const a=n.getShadowPassDepthMode(),c=n.getShadowPassColorMode();dn(t,i,o,s,a,Xi.disabled,c,d);}else if("translucent"===t.renderPass){const u=!o.paint.get("fill-extrusion-pattern").constantOr(1),_=o.paint.get("fill-extrusion-color").constantOr(e.ap.white);if(!c&&0!==_.a){const e=new Wi(t.context.gl.LEQUAL,Wi.ReadWrite,t.depthRangeFor3D);1===r&&u?dn(t,i,o,s,e,Xi.disabled,Zi.unblended,d):(dn(t,i,o,s,e,Xi.disabled,Zi.disabled,d),dn(t,i,o,s,e,t.stencilModeFor3D(),t.colorModeForRenderPass(),d),t.resetStencilClippingMasks());}if(t.style.enable3dLights()&&u&&(!l&&"globe"!==t.transform.projection.name||c)){const r=o.paint.get("fill-extrusion-opacity"),u=o.paint.get("fill-extrusion-ambient-occlusion-intensity"),_=o.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),p=o.paint.get("fill-extrusion-flood-light-intensity"),f="none"===o.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default"),m=o.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(f?null:o.lut).toArray01().slice(0,3),g=u>0&&_>0,v=p>0,y=(e,t,i)=>(1-i)*e+i*t,x=new un;x.translate=o.paint.get("fill-extrusion-translate"),x.translateAnchor=o.paint.get("fill-extrusion-translate-anchor"),x.edgeRadius=o.layout.get("fill-extrusion-edge-radius"),x.cutoffFadeRange=o.paint.get("fill-extrusion-cutoff-fade-range");const b=n=>{const l=t.depthModeForSublayer(1,Wi.ReadOnly,a.LEQUAL,!0),c=o.paint.get(n?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),h=y(.1,3,c),f=t._showOverdrawInspector;if(!f){const c=new Xi({func:a.ALWAYS,mask:255},255,255,a.KEEP,a.KEEP,a.REPLACE),f=new Zi([a.ONE,a.ONE,a.ONE,a.ONE],e.ap.transparent,[!1,!1,!1,!0],a.MIN);_n(x,t,i,o,s,l,c,f,Ji.disabled,n,"sdf",r,u,_,p,m,h,d,!1);}{const c=f?Xi.disabled:new Xi({func:a.EQUAL,mask:255},255,255,a.KEEP,a.DECR,a.DECR),g=f?t.colorModeForRenderPass():new Zi([a.ONE_MINUS_DST_ALPHA,a.DST_ALPHA,a.ONE,a.ONE],e.ap.transparent,[!0,!0,!0,!0]);_n(x,t,i,o,s,l,c,g,Ji.disabled,n,"color",r,u,_,p,m,h,d,!1);}};if(c){const c=()=>{const t=l.drapeBufferSize[0],i=l.drapeBufferSize[1];let o=l.framebufferCopyTexture;return o&&(!o||o.size[0]===t&&o.size[1]===i)||(o&&o.destroy(),o=l.framebufferCopyTexture=new e.T(n,new e.q({width:t,height:i}),a.RGBA8)),o.bind(a.LINEAR,a.CLAMP_TO_EDGE),a.copyTexSubImage2D(a.TEXTURE_2D,0,0,0,0,0,t,i),o},f=(n,l,f)=>{const g=t.depthModeForSublayer(1,Wi.ReadOnly,a.LEQUAL,!1),v=o.paint.get(n?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),b=y(.1,3,v);{const c=new Zi([a.ONE,a.ONE,a.ONE,a.ONE],e.ap.transparent,[!1,!1,!1,!0]);_n(x,t,i,o,s,g,Xi.disabled,c,Ji.disabled,n,"clear",r,u,_,p,m,b,d,l);}{const c=new Xi({func:a.ALWAYS,mask:255},255,255,a.KEEP,a.KEEP,a.REPLACE),h=new Zi([a.ONE,a.ONE,a.ONE,a.ONE],e.ap.transparent,[!1,!1,!1,!0],a.MIN);_n(x,t,i,o,s,g,c,h,Ji.disabled,n,"sdf",r,u,_,p,m,b,d,l);}h&&!n&&(f=c());{const c=n?a.ZERO:a.ONE_MINUS_DST_ALPHA,h=new Xi({func:a.EQUAL,mask:255},255,255,a.KEEP,a.DECR,a.DECR),f=new Zi([c,a.DST_ALPHA,a.ONE_MINUS_DST_ALPHA,a.ZERO],e.ap.transparent,[!0,!0,!0,!0]);_n(x,t,i,o,s,g,h,f,Ji.disabled,n,"color",r,u,_,p,m,b,d,l);}if(!h||n){const c=new Zi([a.ONE,a.ONE,a.ONE,n?a.ZERO:a.ONE],e.ap.transparent,[!1,!1,!1,!0],n?a.FUNC_ADD:a.MAX);_n(x,t,i,o,s,g,Xi.disabled,c,Ji.disabled,n,"clear",r,u,_,p,m,b,d,l,f);}else {a.drawBuffers([a.NONE,a.COLOR_ATTACHMENT1]);const c=new Xi({func:a.EQUAL,mask:255},254,255,a.KEEP,a.DECR,a.DECR),h=new Zi([a.ONE,a.ONE,a.ONE,a.ONE],e.ap.transparent,[!0,!1,!1,!1],a.MAX);_n(x,t,i,o,s,g,c,h,Ji.disabled,n,"emissive",r,u,_,p,m,b,d,l,f),a.drawBuffers([a.COLOR_ATTACHMENT0]);}};if(g||v){let e;t.prepareDrawTile(),h&&!g||(e=c()),g&&f(!0,!1,e),v&&f(!1,!0,e);}}else g&&b(!0),v&&b(!1),(g||v)&&t.resetStencilClippingMasks();}}},building:function(e,t,i,o){e.currentLayer0&&r>0,c=!0;const h=i.paint.get("building-vertical-scale");if(h<=0)return;e.shadowRenderer||(c=!1);const d=e.conflationActive&&e.style.isLayerClipped(i,t.getSource()),u=e.style.order.indexOf(i.fqid);if(function(e,t,i,o,s,r){for(const n of r){const r=t.getTile(n).getBucket(i);r&&(s&&r.updateReplacement(n,e.replacementSource,o),r.uploadUpdatedIndexBuffer(e.context));}}(e,t,i,u,d,o),function(e,t,i,o){for(const s of o){const o=t.getTile(s).getBucket(i);o&&o.needsEvaluation()&&o.uploadUpdatedColorBuffer(e.context);}}(e,t,i,o),i.resetLayerRenderingStats(e),e.shadowRenderer&&(e.shadowRenderer.useNormalOffset=!0),"shadow"===e.renderPass&&e.shadowRenderer){const s=e.shadowRenderer,r=[],n=s.getShadowPassDepthMode();yn({painter:e,source:t,layer:i,coords:o,defines:r,blendMode:s.getShadowPassColorMode(),depthMode:n,opacity:a,verticalScale:h,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]});}else if("translucent"===e.renderPass){let u=["HAS_ATTRIBUTE_a_part_color_emissive","LIGHTING_3D_MODE"];c&&(u=u.concat("RENDER_SHADOWS","DEPTH_TEXTURE")),e.shadowRenderer&&e.shadowRenderer.useNormalOffset&&(u=u.concat("NORMAL_OFFSET"));const _=i.paint.get("building-facade-emissive-chance"),p=i.paint.get("building-ambient-occlusion-intensity"),f=i.paint.get("building-flood-light-intensity"),m="none"===i.paint.get("building-flood-light-color-use-theme").constantOr("default"),g=i.paint.get("building-flood-light-color").toNonPremultipliedRenderColor(m?null:i.lut).toArray01().slice(0,3),v=i.paint.get("building-flood-light-ground-attenuation"),y=f>0,x=new Wi(e.context.gl.LEQUAL,Wi.ReadWrite,e.depthRangeFor3D);a<1&&yn({painter:e,source:t,layer:i,coords:o,defines:u,blendMode:Zi.disabled,depthMode:x,opacity:a,verticalScale:h,facadeEmissiveChance:_,facadeAOIntensity:p,floodLightIntensity:f,floodLightColor:g,depthOnly:!0});const b=e.colorModeForRenderPass();yn({painter:e,source:t,layer:i,coords:o,defines:u,blendMode:b,depthMode:x,opacity:a,verticalScale:h,facadeEmissiveChance:_,facadeAOIntensity:p,floodLightIntensity:f,floodLightColor:g}),l&&xn(e,t,i,o,!0,a,s,r,f,g,n,d),y&&xn(e,t,i,o,!1,a,s,r,f,g,v,d);}else if("light-beam"===e.renderPass){const s=["HAS_ATTRIBUTE_a_part_color_emissive","HAS_ATTRIBUTE_a_bloom_attenuation"],r=new Wi(e.context.gl.LEQUAL,Wi.ReadOnly,e.depthRangeFor3D);yn({painter:e,source:t,layer:i,coords:o,defines:s,blendMode:Zi.alphaBlended,depthMode:r,opacity:a,verticalScale:h,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]});}e.shadowRenderer&&(e.shadowRenderer.useNormalOffset=!1),e.resetStencilClippingMasks();},hillshade:function(e,t,i,o){if("offscreen"!==e.renderPass&&"translucent"!==e.renderPass)return;if(e.style.disableElevatedTerrain)return;const s=e.context,r=e.terrain&&e.terrain.renderingToTexture,[n,a]="translucent"!==e.renderPass||r?[{},o]:e.stencilConfigForOverlap(o);for(const o of a){const s=t.getTile(o);if(s.needsHillshadePrepare&&"offscreen"===e.renderPass)ls(e,s,i);else if("translucent"===e.renderPass){const t=e.depthModeForSublayer(0,Wi.ReadOnly),a=i.paint.get("hillshade-emissive-strength"),l=e.colorModeForDrapableLayerRenderPass(a),c=r&&e.terrain?e.terrain.stencilModeForRTTOverlap(o):n[o.overscaledZ];ns(e,o,s,i,t,c,l);}}s.viewport.set([0,0,e.width,e.height]),e.resetStencilClippingMasks();},raster:function(t,i,o,s,r,n){if("translucent"!==t.renderPass)return;const a=o.paint.get("raster-opacity");if(0===a)return;const l="globe"===t.transform.projection.name,c=0!==o.paint.get("raster-elevation"),h=c&&l,d=t.terrain&&t.terrain.exaggeration()>0&&c&&"ground"===o.paint.get("raster-elevation-reference"),u=!l&&d;if(t.renderElevatedRasterBackface&&!h)return;const _=t.context,p=_.gl,f=i.getSource(),m=function(t,i,o,s,r){const n=i.paint.get("raster-color"),a="raster-array"===t.type,l=[],c=i.paint.get("raster-resampling"),h=i.paint.get("raster-color-mix");let d=i.paint.get("raster-color-range");const u=[h[0],h[1],h[2],0],_=h[3];let p="nearest"===c?s.NEAREST:s.LINEAR;if(a&&(l.push("RASTER_ARRAY"),n||l.push("RASTER_COLOR"),"linear"===c&&l.push("RASTER_ARRAY_LINEAR"),p=s.NEAREST,!d&&t.rasterLayers)){const e=t.rasterLayers.find(({id:e})=>e===i.sourceLayer);e&&e.fields&&e.fields.range&&(d=e.fields.range);}if(d=d||[0,1],n){l.push("RASTER_COLOR"),o.activeTexture.set(s.TEXTURE2),i.updateColorRamp(d);let t=i.colorRampTexture;t||(t=i.colorRampTexture=new e.T(o,i.colorRamp,s.RGBA8)),t.bind(p,s.CLAMP_TO_EDGE);}return r&&l.push("USE_MRT1"),{mix:u,range:d,offset:_,defines:l,resampling:p}}(f,o,_,p,t.terrain&&t.terrain.renderingToTexture&&"mrt-fallback"===t.emissiveMode);if(f instanceof e.aV&&!s.length&&!l)return;const g=o.paint.get("raster-emissive-strength"),v=t.colorModeForDrapableLayerRenderPass(g),y=t.terrain&&t.terrain.renderingToTexture,x=!t.options.moving,b="nearest"===o.paint.get("raster-resampling")?p.NEAREST:p.LINEAR;if(f instanceof e.aV&&!s.length&&(f.onNorthPole||f.onSouthPole)){const e=c?t.stencilModeFor3D():Xi.disabled;return void wn(!!f.onNorthPole,null,t,i,o,g,m,Ji.disabled,e)}if(!s.length)return;const[w,T]=f instanceof e.aV||y?[{},s]:t.stencilConfigForOverlap(s),E=T[T.length-1].overscaledZ;h&&m.defines.push("PROJECTION_GLOBE_VIEW"),c&&m.defines.push("RENDER_CUTOFF","ELEVATED"),d&&m.defines.push("ELEVATION_REFERENCE_GROUND");const S=(s,r,T)=>{for(const S of s){const s=S.toUnwrapped(),I=i.getTile(S);if(y&&(!I||!I.hasData()))continue;_.activeTexture.set(p.TEXTURE0);const C=En(I,f,o,m);if(!C||!C.texture)continue;const{texture:R,mix:A,offset:D,tileSize:L,buffer:P}=C;let O,z;y?(O=Wi.disabled,z=S.projMatrix):c?(O=new Wi(p.LEQUAL,Wi.ReadWrite,t.depthRangeFor3D),z=l?Float32Array.from(t.transform.expandedFarZProjMatrix):t.transform.calculateProjMatrix(s,x)):(O=t.depthModeForSublayer(S.overscaledZ-E,1===a?Wi.ReadWrite:Wi.ReadOnly,p.LESS),z=t.transform.calculateProjMatrix(s,x));const M=t.terrain&&y?t.terrain.stencilModeForRTTOverlap(S):w[S.overscaledZ],F=n?0:o.paint.get("raster-fade-duration");I.registerFadeDuration(F);const k=i.findLoadedParent(S,0),B=tr(I,k,i,t.transform,F);let N,U;!B.isFading&&I.refreshedUponExpiration&&(I.refreshedUponExpiration=!1),t.terrain&&t.terrain.prepareDrawTile(),_.activeTexture.set(p.TEXTURE0),R.bind(b,p.CLAMP_TO_EDGE),_.activeTexture.set(p.TEXTURE1),k?(k.texture&&k.texture.bind(b,p.CLAMP_TO_EDGE),N=Math.pow(2,k.tileID.overscaledZ-I.tileID.overscaledZ),U=[I.tileID.canonical.x*N%1,I.tileID.canonical.y*N%1]):R.bind(b,p.CLAMP_TO_EDGE),"useMipmap"in R&&_.extTextureFilterAnisotropic&&t.transform.pitch>20&&p.texParameterf(p.TEXTURE_2D,_.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,_.extTextureFilterAnisotropicMax);const j=t.transform;let V;const G=c?Tn(j):[0,0,0,0];let H,q,Z,W,$,X=0;if(h&&f instanceof e.aV&&f.coordinates.length>3)H=Float32Array.from(e.bl(e.dL(new e.cE(0,0,0)))),q=Float32Array.from(j.globeMatrix),Z=Float32Array.from(e.dH(j)),W=[e.aG(j.center.lng),e.aK(j.center.lat)],V=f.elevatedGlobePerspectiveTransform,$=f.elevatedGlobeGridMatrix||new Float32Array(9);else if(h){const t=e.dI(S.canonical);X=e.dJ(t.getCenter().lat),H=Float32Array.from(e.bl(e.dL(S.canonical))),q=Float32Array.from(j.globeMatrix),Z=Float32Array.from(e.dH(j)),W=[e.aG(j.center.lng),e.aK(j.center.lat)],V=[0,0],$=Float32Array.from(e.dK(S.canonical,t,X,j.worldSize/j._pixelsPerMercatorPixel));}else V=f instanceof e.aV?f.perspectiveTransform:[0,0],H=new Float32Array(16),q=new Float32Array(9),Z=new Float32Array(16),W=[0,0],$=new Float32Array(9);const K=zr(t,z,H,q,Z,$,U||[0,0],e.ak(t.transform.zoom),W,G,N||1,B,o,V,c?o.paint.get("raster-elevation"):0,2,A,D,m.range,L,P,g),Y=t.isTileAffectedByFog(S),J=t.getOrCreateProgram("raster",{defines:m.defines,overrideFog:Y});if(t.uploadCommonUniforms(_,J,s),f instanceof e.aV){const i=f.elevatedGlobeVertexBuffer,s=f.elevatedGlobeIndexBuffer;if(y||!l)f.boundsBuffer&&f.boundsSegments&&J.draw(t,p.TRIANGLES,O,Xi.disabled,v,Ji.disabled,K,o.id,f.boundsBuffer,t.quadTriangleIndexBuffer,f.boundsSegments);else if(i&&s){const n=j.zoom<=e.c$?f.elevatedGlobeSegments:f.getSegmentsForLongitude(j.center.lng);n&&J.draw(t,p.TRIANGLES,O,Xi.disabled,v,r,K,o.id,i,s,n);}}else if(h){O=new Wi(p.LEQUAL,Wi.ReadOnly,t.depthRangeFor3D);const e=t.globeSharedBuffers;if(e){d&&(t.terrain.setupElevationDraw(I,J),t.uploadCommonUniforms(_,J,I.tileID.toUnwrapped()));const[i,s,n]=e.getGridBuffers(X,!1);J.draw(t,p.TRIANGLES,O,T||M,t.colorModeForRenderPass(),r,K,o.id,i,s,n);}}else if(u)O=new Wi(p.LEQUAL,Wi.ReadWrite,t.depthRangeFor3D),t.terrain.setupElevationDraw(I,J),t.uploadCommonUniforms(_,J,I.tileID.toUnwrapped()),j.pitch>20&&J.draw(t,p.TRIANGLES,O,Xi.disabled,Zi.disabled,Ji.frontCCW,K,o.id,t.terrain.gridBuffer,t.terrain.gridIndexBuffer,t.terrain.gridSegments),J.draw(t,p.TRIANGLES,O,M,v,Ji.backCCW,K,o.id,t.terrain.gridBuffer,t.terrain.gridIndexBuffer,t.terrain.gridSegments);else {const{tileBoundsBuffer:e,tileBoundsIndexBuffer:i,tileBoundsSegments:s}=t.getTileBoundsBuffers(I);J.draw(t,p.TRIANGLES,O,M,v,Ji.disabled,K,o.id,e,i,s);}}if(!(f instanceof e.aV)&&h)for(const e of s){const s=e.canonical.y===(1<e.eb[t](s));p.push(s);const f=s.canonical.x,m=s.canonical.y;for(const e of p){const r=i.getTile(l?e.wrapped():e);if(!r)continue;const a=r.rasterParticleState;if(!a)continue;const h=e.canonical.x+(1<e.tileID)),p&&(h.activeTexture.set(d.TEXTURE0),t.imageManager.bind(t.context,o.scope));const T=[];if(t.terrain&&t.terrain.renderingToTexture&&"mrt-fallback"===t.emissiveMode&&T.push("USE_MRT1"),c){const i=t.getOrCreateProgram(x,{overrideFog:!1,overrideRtt:!0,defines:T}),s=new Float32Array(e.bB([])),h=new e.aR(0,0,0,0,0),u=p?Gr(s,l,a,t,0,o.scope,f,c,{tileID:h,tileSize:_}):Vr(s,l,a,r.toPremultipliedRenderColor(n?null:o.lut));return void i.draw(t,d.TRIANGLES,v,g,y,Ji.disabled,u,o.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments)}for(const e of w){const m=t.isTileAffectedByFog(e),w=t.getOrCreateProgram(x,{overrideFog:m,defines:T}),E=e.toUnwrapped(),S=s?e.projMatrix:t.transform.calculateProjMatrix(E);t.prepareDrawTile();const I=i?i.getTile(e):b?b[e.key]:new Pt(e,_,u.zoom,t),C=p?Gr(S,l,a,t,0,o.scope,f,c,{tileID:e,tileSize:_}):Vr(S,l,a,r.toPremultipliedRenderColor(n?null:o.lut));t.uploadCommonUniforms(h,w,E);const{tileBoundsBuffer:R,tileBoundsIndexBuffer:A,tileBoundsSegments:D}=t.getTileBoundsBuffers(I);w.draw(t,d.TRIANGLES,v,g,y,Ji.disabled,C,o.id,R,A,D);}},sky:function(t,i,o){const s=t._atmosphere?e.ak(t.transform.zoom):1,r=o.paint.get("sky-opacity")*s;if(0===r)return;const n=t.context,a=o.paint.get("sky-type"),l=new Wi(n.gl.LEQUAL,Wi.ReadOnly,[0,1]),c=t.frameCounter/1e3%1;"atmosphere"===a?"offscreen"===t.renderPass?o.needsSkyboxCapture(t)&&(function(t,i){const o=t.context,s=o.gl;let r=i.skyboxFbo;if(!r){r=i.skyboxFbo=o.createFramebuffer(32,32,1,null),i.skyboxGeometry=new Vn(o),i.skyboxTexture=o.gl.createTexture(),s.bindTexture(s.TEXTURE_CUBE_MAP,i.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(r.framebuffer),o.viewport.set([0,0,32,32]);const n=i.getCenter(t,!0),a=t.getOrCreateProgram("skyboxCapture"),l=new Float64Array(16);e.bB(l),e.eq(l,l,.5*-Math.PI),Gn(t,i,a,l,n,0),e.bB(l),e.eq(l,l,.5*Math.PI),Gn(t,i,a,l,n,1),e.bB(l),e.cV(l,l,.5*-Math.PI),Gn(t,i,a,l,n,2),e.bB(l),e.cV(l,l,.5*Math.PI),Gn(t,i,a,l,n,3),e.bB(l),Gn(t,i,a,l,n,4),e.bB(l),e.eq(l,l,Math.PI),Gn(t,i,a,l,n,5),o.viewport.set([0,0,t.width,t.height]);}(t,o),o.markSkyboxValid(t)):"sky"===t.renderPass&&function(e,t,i,o,s){const r=e.context,n=r.gl,a=e.transform,l=e.getOrCreateProgram("skybox");r.activeTexture.set(n.TEXTURE0),n.bindTexture(n.TEXTURE_CUBE_MAP,t.skyboxTexture);const c=((e,t,i,o,s)=>({u_matrix:e,u_sun_direction:t,u_cubemap:0,u_opacity:o,u_temporal_offset:s}))(a.skyboxMatrix,t.getCenter(e,!1),0,o,s);e.uploadCommonUniforms(r,l),l.draw(e,n.TRIANGLES,i,Xi.disabled,e.colorModeForRenderPass(),Ji.backCW,c,"skybox",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment);}(t,o,l,r,c):"gradient"===a&&"sky"===t.renderPass&&function(t,i,o,s,r){const n=t.context,a=n.gl,l=t.transform,c=t.getOrCreateProgram("skyboxGradient");i.skyboxGeometry||(i.skyboxGeometry=new Vn(n)),n.activeTexture.set(a.TEXTURE0);let h=i.colorRampTexture;h||(h=i.colorRampTexture=new e.T(n,i.colorRamp,a.RGBA8)),h.bind(a.LINEAR,a.CLAMP_TO_EDGE);const d=((t,i,o,s,r)=>({u_matrix:t,u_color_ramp:0,u_center_direction:i,u_radius:e.ao(o),u_opacity:s,u_temporal_offset:r}))(l.skyboxMatrix,i.getCenter(t,!1),i.paint.get("sky-gradient-radius"),s,r);t.uploadCommonUniforms(n,c),c.draw(t,a.TRIANGLES,o,Xi.disabled,t.colorModeForRenderPass(),Ji.backCW,d,"skyboxGradient",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment);}(t,o,l,r,c);},custom:function(t,i,o,s){const r=t.context,n=o.implementation;if(!t.transform.projection.unsupportedLayers||!t.transform.projection.unsupportedLayers.includes("custom")||t.terrain&&(t.terrain.renderingToTexture||"offscreen"===t.renderPass)&&o.isDraped(i)){if("offscreen"===t.renderPass){const i=n.prerender;if(i){if(t.setCustomLayerDefaults(),r.setColorMode(t.colorModeForRenderPass()),"globe"===t.transform.projection.name){const o=t.transform.pointMerc;i.call(n,r.gl,t.transform.customLayerMatrix(),t.transform.getProjection(),t.transform.globeToMercatorMatrix(),e.ak(t.transform.zoom),[o.x,o.y],t.transform.pixelsPerMeterRatio);}else i.call(n,r.gl,t.transform.customLayerMatrix());r.setDirty(),t.setBaseState();}}else if("translucent"===t.renderPass){if(t.terrain&&t.terrain.renderingToTexture){const e=n.renderToTile;if(e){const i=s[0].canonical,o={x:i.x+s[0].wrap*(n.wrapTileId?0:1<{h&&(h.useNormalOffset=!0,d||(h.enabled=!0));},_=i.getSource();if("light-beam"===t.renderPass&&"batched-model"!==_.type)return;if("vector"===_.type||"geojson"===_.type)return function(t,i,o,s,r){const n=t.transform,a="globe"===n.projection.name,l=n.getFreeCameraOptions().position;if(!t.modelManager)return;const c=t.modelManager;o.modelManager=c;const h=t.shadowRenderer;if(!o._unevaluatedLayout._values.hasOwnProperty("model-id"))return;const d=o._unevaluatedLayout._values["model-id"],u=Object.assign({},o.layout.get("model-id").parameters),_=t.style.order.indexOf(o.fqid),p=o.paint.get("model-opacity").constantOr(1);for(const f of s){const s=i.getTile(f).getBucket(o);if(!s||s.projection.name!==n.projection.name)continue;const m=s.getModelUris();if(m&&!s.modelsRequested&&(c.addModelsFromBucket(m,r),s.modelsRequested=!0),a)u.zoom=f.overscaledZ;else {const e=la(f,n);u.zoom=e;}const g=d.possiblyEvaluate(u);if(na(t,s,f),aa.shadowUniformsInitialized=!1,aa.useSingleShadowCascade=!!h&&0===h.getMaxCascadeForTile(f.toUnwrapped()),"shadow"===t.renderPass&&h){if(1===t.currentShadowCascade&&s.isInsideFirstShadowMapFrustum)continue;const i=n.calculatePosMatrix(f.toUnwrapped(),n.worldSize);if(aa.tileMatrix.set(i),aa.shadowTileMatrix=Float32Array.from(h.calculateShadowPassMatrixFromMatrix(i)),aa.aabb.min=[0,0,0],aa.aabb.max[0]=aa.aabb.max[1]=e.am,aa.aabb.max[2]=0,da(s,aa,t,o.scope))continue}const v=1<0&&t.style.isLayerClipped(o,i.getSource())&&s.updateReplacement(f,t.replacementSource,_,o.scope)&&(s.uploaded=!1,s.upload(t.context));let x=0;const b=new Array,w=new Array,T=new Array;for(let i in s.instancesPerModel){const n=s.instancesPerModel[i];n.features.length>0&&!a&&(i=g.evaluate(n.features[0].feature,{}));const h=c.getModel(i,r);if(h||c.hasURLBeenRequested(i)||s.modelUris.includes(i)||(s.modelUris.push(i),s.modelsRequested=!1),h&&h.uploaded)if(a){const i=e.c6([],[l.x,l.y,l.z],t.transform.worldSize);e.ez(i,i);for(let o=0;o0&&o.elevationUpdate(e.terrain,s,n,i.source),o.needsReEvaluation(e,r,i)&&o.evaluate(i));}}))(t,i,o,s),function(){const c=new Map;let d,S,I;w?(d=s.length-1,S=-1,I=-1):(d=0,S=s.length,I=1);const C=new Float64Array(16),R=e.cB(),A=new e.P(0,0);for(let D=d;D!==S;D+=I){const d=s[D],S=i.getTile(d).getBucket(o);if(!S||!S.uploaded)continue;let I=!1;l&&(I=0===l.getMaxCascadeForTile(d.toUnwrapped()));const L=n.calculatePosMatrix(d.toUnwrapped(),n.worldSize),P=S.modelTraits;!y&&w&&(e.bm(C,L),e.ag(R,h,C),A.x=R[0],A.y=R[1]);const O=[];S.setFilter(o.filter);for(const i of S.getNodesInfo()){if(i.hiddenByReplacement)continue;if(!i.node.meshes)continue;const o=i.node;let s=0;t.terrain&&o.elevation&&(s=o.elevation*t.terrain.exaggeration());const r=(()=>{const t=i.aabb;return v.min=[...t.min],v.max=[...t.max],v.min[2]+=s,v.max[2]+=s,e.ag(v.min,v.min,L),e.ag(v.max,v.max,L),v})(),a=i.evaluatedScale;if(a[0]<=1&&a[1]<=1&&a[2]<=1&&0===r.intersects(x))continue;if(!y&&w){const t=1/6;i.cameraCollisionOpacity=h[0]>r.min[0]&&h[0]r.min[1]&&h[1]!w||1===e.opacity&&1===t.opacity?e.deptht.depth?-1:1);for(const i of O){const s=i.nodeInfo,h=s.node;if(t._debugParams.show3DModelFootprints&&h.footprint){const e=h.id||h.name||"footprint";c.has(e)||c.set(e,{node:h,mvp:i.wvpForTile});}let d=e.aC([],p,i.tileModelMatrix);e.aC(d,u,d);const _=e.bm([],d);e.ei(_,_),e.cT(_,_,ha),d=e.aC(d,d,h.globalMatrix);const f="light-beam"===t.renderPass,v="none"===o.paint.get("model-color-use-theme").constantOr("default"),x=P&e.eL.HasMapboxMeshFeatures,b=x?0:s.evaluatedRMEA[0][2];for(let e=0;e=Ve||s>=Ve;}}const C=c.material;let R;C.occlusionTexture&&C.occlusionTexture.offsetScale&&(R=C.occlusionTexture.offsetScale,w.defines.push("OCCLUSION_TEXTURE_TRANSFORM"));const A=t.getOrCreateProgram("model",w);!y&&l&&l.setupShadowsFromMatrix(i.tileModelMatrix,A,l.useNormalOffset),t.uploadCommonUniforms(r,A,null,S);const D=C.pbrMetallicRoughness;D.metallicFactor=.9,D.roughnessFactor=.5;const L=qr(new Float32Array(p),new Float32Array(d),new Float32Array(_),new Float32Array(h.globalMatrix),t,i.opacity,D.baseColorFactor,C.emissiveFactor,D.metallicFactor,D.roughnessFactor,C,b,o,[0,0,0],R);!u&&(s.hasTranslucentParts||i.opacity<1)&&A.draw(t,r.gl.TRIANGLES,m,Xi.disabled,Zi.disabled,Ji.backCCW,L,o.id,c.vertexBuffer,c.indexBuffer,c.segments,o.paint,t.transform.zoom,void 0,T),A.draw(t,r.gl.TRIANGLES,u?g:m,Xi.disabled,u||i.opacity<1||s.hasTranslucentParts?Zi.alphaBlended:Zi.unblended,Ji.backCCW,L,o.id,c.vertexBuffer,c.indexBuffer,c.segments,o.paint,t.transform.zoom,void 0,T);}}}if(t._debugParams.show3DModelFootprints&&c.size>0){const e=Array.from(c.keys()).sort();for(const i of e){const{node:e,mvp:o}=c.get(i);ia(t,0,e,o);}}}();}(t,i,o,s),void u();if("model"!==_.type)return;const p=_.getModels(),f=[],m=t.transform.getFreeCameraOptions().position,g=e.c6([],[m.x,m.y,m.z],t.transform.worldSize);e.ez(g,g);const v=[],y=[];let x=0;for(const s of p){const r=i.getFeatureState("",s.id),n={type:"Unknown",id:s.id,properties:s.featureProperties},c=o.paint.get("model-rotation").evaluate(n,r),h=o.paint.get("model-scale").evaluate(n,r),d=o.paint.get("model-translation").evaluate(n,r),u=o.paint.get("model-opacity").evaluate(n,r);oa(o,s.id,r,s.featureProperties,s.nodeOverrideNames,s.nodeOverrides),sa(o,s.id,r,s.featureProperties,s.materialOverrideNames,s.materialOverrides),s.nodeOverrides.size>0&&s.computeBoundsAndApplyParent(),s.computeModelMatrix(t,c,h,d,l,a,!1);const _=e.bB([]),p=e.eh(s.position.lat,t.transform.zoom),m=e.br([],[1,1,1/p]);e.bs(_,_,g),f.push({zScaleMatrix:m,negCameraPosMatrix:_});for(const e of s.nodes)ea(t,e,s.matrix,t.transform.expandedFarZProjMatrix,x,v,y,s.materialOverrides,u);x++;}if(v.sort((e,t)=>t.depth-e.depth),"shadow"!==t.renderPass){if(t._debugParams.show3DModelFootprints){const i=t.transform.projMatrix,o=new Map,s=(t,s)=>{if(t.footprint){const r=t.id||t.name||"footprint";if(!o.has(r)){const n=e.aC([],i,s);o.set(r,{node:t,mvp:n});}}};for(const e of y)s(e.node,e.modelMatrix);for(const e of v)s(e.node,e.modelMatrix);const r=Array.from(o.keys()).sort();for(const e of r){const{node:i,mvp:s}=o.get(e);ia(t,0,i,s);}}ra(t,o,v,y,f),u();}else {for(const e of y)ta(e.mesh,e.nodeModelMatrix,t,o);for(const e of v)ta(e.mesh,e.nodeModelMatrix,t,o);u();}}},Da={line:function(e,t,i){if(e.hasElevatedBuckets=!1,e.hasNonElevatedBuckets=!1,void 0!==e._unevaluatedLayout.getValue("line-elevation-reference")||void 0!==e._unevaluatedLayout.getValue("line-z-offset")){if(t){const i=t.getVisibleCoordinates();for(const o of i){const i=t.getTile(o).getBucket(e);if(i&&("none"!==i.elevationType?e.hasElevatedBuckets=!0:e.hasNonElevatedBuckets=!0,e.hasElevatedBuckets&&e.hasNonElevatedBuckets))break}}}else e.hasNonElevatedBuckets=!0;},model:function(e,t,i){const o=t.getSource();if(!o.loaded())return;if("vector"===o.type||"geojson"===o.type)return void(i.modelManager&&i.modelManager.upload(i,Qn(i,e)));if("batched-model"===o.type)return;if("model"!==o.type)return;const s=o.getModels();for(const e of s)e.upload(i.context);},raster:function(e,t,i){const o=t.getSource();if(!(o instanceof pt&&o.loaded()))return;const s=e.sourceLayer||o.rasterLayerIds&&o.rasterLayerIds[0];if(!s)return;const r=e.paint.get("raster-array-band")||o.getInitialBand(s);if(null==r)return;const n=t.getIds().map(e=>t.getTileByID(e));for(const t of n)t.updateNeeded(e.id,r)&&o.prepareTile(t,s,e.id,r);},"raster-particle":function(e,t,i){const o=t.getSource();if(!(o instanceof pt&&o.loaded()))return;const s=e.sourceLayer||o.rasterLayerIds&&o.rasterLayerIds[0];if(!s)return;const r=e.paint.get("raster-particle-array-band")||o.getInitialBand(s);if(null==r)return;const n=t.getIds().map(e=>t.getTileByID(e));for(const t of n)t.updateNeeded(e.id,r)&&o.prepareTile(t,s,e.id,r);}},La={fill:cn},Pa={fill:function(e,t,i,o){if(!i.layout||"none"===i.layout.get("fill-elevation-reference")||0===i.paint.get("fill-opacity").constantOr(1))return;const s=e.context.gl,r=new Wi(s.LEQUAL,Wi.ReadOnly,e.depthRangeFor3D),n=new Xi({func:s.ALWAYS,mask:255},255,255,s.KEEP,s.KEEP,s.REPLACE),a=e.transform.getFreeCameraOptions().position,l=e.getOrCreateProgram("elevatedStructuresDepthReconstruct");for(const c of o){const o=t.getTile(c),h=o.getBucket(i);if(!h)continue;const d=h.elevatedStructures;if(!d||0===d.depthSegments.segments[0].primitiveLength)continue;const u=ln(c.toUnwrapped(),a),_=e.translatePosMatrix(c.projMatrix,o,i.paint.get("fill-translate"),i.paint.get("fill-translate-anchor")),p=wr(_,u,0,1,0);l.draw(e,s.TRIANGLES,r,n,Zi.disabled,Ji.disabled,p,i.id,d.vertexBuffer,d.indexBuffer,d.depthSegments,i.paint,e.transform.zoom);}}};class Oa{constructor(t,i,o,s,r){this.context=new Jr(t,i),this.transform=o,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this._timeStamp=e.o.now(),this._averageFPS=0,this._fpsHistory=[],this._dt=0,this._debugParams={forceEnablePrecipitation:!1,showTerrainProxyTiles:!1,fpsWindow:30,continousRedraw:!1,show3DModelFootprints:!1,enabledLayers:{}};const n=["fill","line","symbol","circle","heatmap","fill-extrusion","building","raster","raster-particle","hillshade","model","background","sky"];for(const e of n)this._debugParams.enabledLayers[e]=!0;for(const e of n);this.occlusionParams=new ma,this.setup(),this.numSublayers=Ft.maxUnderzooming+Ft.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.eS,this.longestCutoffRange=0,this.minCutoffZoom=0,this._fogVisible=!1,this._cachedTileFogOpacities={},this._shadowRenderer=new _o(this),this._wireframeDebugCache=new fa,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0,this.layersWithOcclusionOpacity=[];const a=new e.q({width:1,height:1},Uint8Array.of(0,0,0,0));this.emptyDepthTexture=new e.T(this.context,a,t.RGBA8),this._clippingActiveLastFrame=!1,this.scaleFactor=s,this.worldview=r,this._forceEmissiveMode=!1,this.emissiveMode="constant";}updateTerrain(e,t){const i=!!e&&!!e.terrain&&this.transform.projection.supportsTerrain;if(!(i||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new rr(this,e));const o=this._terrain;this.transform.elevation=i?o:null,o.update(e,this.transform,t),this.transform.elevation&&!o.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[i,o]=t.getFovAdjustedRange(this.transform._fov);if(i>o)return void(this.transform.fogCullDistSq=null);const s=i+.78*(o-i);this.transform.fogCullDistSq=s*s;}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled||this._forceTerrainMode?this._terrain:null}get forceTerrainMode(){return this._forceTerrainMode}set forceTerrainMode(e){e&&!this._terrain&&(this._terrain=new rr(this,this.style)),this._forceTerrainMode=e;}get shadowRenderer(){return this._shadowRenderer&&this._shadowRenderer.enabled?this._shadowRenderer:null}get wireframeDebugCache(){return this._wireframeDebugCache}resize(t,i){if(this.width=t*e.o.devicePixelRatio,this.height=i*e.o.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,i=new e.be;i.emplaceBack(0,0),i.emplaceBack(e.am,0),i.emplaceBack(0,e.am),i.emplaceBack(e.am,e.am),this.tileExtentBuffer=t.createVertexBuffer(i,e.bg.members),this.tileExtentSegments=e.bh.simpleSegment(0,0,4,2);const o=new e.be;o.emplaceBack(0,0),o.emplaceBack(e.am,0),o.emplaceBack(0,e.am),o.emplaceBack(e.am,e.am),this.debugBuffer=t.createVertexBuffer(o,e.bg.members),this.debugSegments=e.bh.simpleSegment(0,0,4,5);const s=new e.be;s.emplaceBack(-1,-1),s.emplaceBack(1,-1),s.emplaceBack(-1,1),s.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(s,e.bg.members),this.viewportSegments=e.bh.simpleSegment(0,0,4,2);const r=new e.b2;r.emplaceBack(0,0,0,0),r.emplaceBack(e.am,0,e.am,0),r.emplaceBack(0,e.am,0,e.am),r.emplaceBack(e.am,e.am,e.am,e.am),this.mercatorBoundsBuffer=t.createVertexBuffer(r,e.bj.members),this.mercatorBoundsSegments=e.bh.simpleSegment(0,0,4,2);const n=new e.b1;n.emplaceBack(0,1,2),n.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(n);const a=new e.bf;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.q({width:1,height:1},Uint8Array.of(0,0,0,0)),t.gl.RGBA8),this.identityMat=e.bD();const l=this.context.gl;this.stencilClearMode=new Xi({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,Wi.disabled,this.stencilClearMode,Zi.disabled,Ji.disabled,er(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments);}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={});}_renderTileClippingMasks(e,t,i){if(!t||this.currentStencilSource===t.id||!e.isTileClipped()||!i||0===i.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let e=!1;for(const t of i)if(void 0===this._tileClippingMaskIDs[t.key]){e=!0;break}if(!e)return}this.currentStencilSource=t.id;const o=this.context,s=o.gl;this.nextStencilID+i.length>256&&this.clearStencil(),o.setColorMode(Zi.disabled),o.setDepthMode(Wi.disabled);const r=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const e of i){const i=t.getTile(e),o=this._tileClippingMaskIDs[e.key]=this.nextStencilID++,{tileBoundsBuffer:n,tileBoundsIndexBuffer:a,tileBoundsSegments:l}=this.getTileBoundsBuffers(i);r.draw(this,s.TRIANGLES,Wi.disabled,new Xi({func:s.ALWAYS,mask:0},o,255,s.KEEP,s.KEEP,s.REPLACE),Zi.disabled,Ji.disabled,er(e.projMatrix),"$clipping",n,a,l);}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,t=this.context.gl;return new Xi({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 Xi({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}stencilConfigForOverlap(e){const t=this.context.gl,i=e.sort((e,t)=>t.overscaledZ-e.overscaledZ),o=i[i.length-1].overscaledZ,s=i[0].overscaledZ-o+1;if(s>1){this.currentStencilSource=void 0,this.nextStencilID+s>256&&this.clearStencil();const e={};for(let i=0;ithis.style&&this.style.enable3dLights()&&this.terrain&&this.terrain.renderingToTexture)()&&"translucent"===this.renderPass?null!=t&&"mrt-fallback"!==this.emissiveMode||"constant"===this.emissiveMode?new Zi([i.ONE,i.ONE_MINUS_SRC_ALPHA,i.CONSTANT_ALPHA,i.ONE_MINUS_SRC_ALPHA],new e.ap(0,0,0,null!=t?t:0),[!0,!0,!0,!0]):"dual-source-blending"===this.emissiveMode?new Zi([i.ONE,i.ONE_MINUS_SRC_ALPHA,this.context.extBlendFuncExtended.SRC1_ALPHA_WEBGL,i.ONE_MINUS_SRC_ALPHA],e.ap.transparent,[!0,!0,!0,!0]):this.colorModeForRenderPass():this.colorModeForRenderPass()}depthModeForSublayer(e,t,i,o=!1){if(this.depthOcclusion)return new Wi(this.context.gl.GREATER,Wi.ReadOnly,this.depthRangeFor3D);if(!this.opaquePassEnabledForLayer()&&!o)return Wi.disabled;const s=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new Wi(i||this.context.gl.LEQUAL,t,[s,s])}opaquePassEnabledForLayer(){return this.currentLayerthis._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,i){const o=e.o.now();this._dt=o-this._timeStamp,this._timeStamp=o,this._wireframeDebugCache.update(this.frameCounter),this._debugParams.continousRedraw=t.map.repaint,this.style=t,this.options=i;const s=this.style._mergedLayers,r=!(!this.terrain||!this.terrain.enabled),n=()=>this.style._getOrder(r).filter(e=>{const t=s[e];return !(t.type in this._debugParams.enabledLayers)||this._debugParams.enabledLayers[t.type]});let a=n(),l=!1,c=!1,h=null,d=0,u=!1;for(const e of a){const t=s[e];"none"!==t.visibility&&("circle"===t.type?l=!0:"building"===t.type?(h=t,++d):"symbol"===t.type&&(t.hasOcclusionOpacityProperties?c=!0:l=!0));}this.updateEmissiveMode();let _=a.map(e=>s[e]);const p=this.style._mergedSourceCaches;this.imageManager=t.imageManager,this.modelManager=t.modelManager,this.symbolFadeChange=t.placement.symbolFadeChange(e.o.now()),this.imageManager.beginFrame();for(const e in p){const t=p[e];t.used&&(t.prepare(this.context),t.getSource().usedInConflation&&++d);}let f=!1;for(const e of _)e.isHidden(this.transform.zoom)||("clip"===e.type&&(f=!0),this.prepareLayer(e));const m={},g={},v={},y={},x={};for(const e in p){const t=p[e];m[e]=t.getVisibleCoordinates(),g[e]=m[e].slice().reverse(),v[e]=t.getVisibleCoordinates(!0).reverse(),y[e]=t.getShadowCasterCoordinates(),x[e]=t.sortCoordinatesByDistance(m[e]);}const b=e=>{const t=this.style.getLayerSourceCache(e);return t&&t.used?t.getSource():null};if(d||f||this._clippingActiveLastFrame){const t=[],i=[];let o=0;for(const e of _)this.isSourceForClippingOrConflation(e,b(e))&&(t.push(e),i.push(o)),o++;if(t&&(f||t.length>1)||this._clippingActiveLastFrame){f=!1;const o=[];for(let s=0;s0){const e=b(t);e&&(this.minCutoffZoom=Math.max(e.minzoom,this.minCutoffZoom)),t.minzoom&&(this.minCutoffZoom=Math.max(t.minzoom,this.minCutoffZoom));}t.is3D(r)&&(this.opaquePassCutoff===1/0&&(this.opaquePassCutoff=e),this._lastOcclusionLayer=e);}const w=this.style&&this.style.fog;w?(this._fogVisible=0!==w.getOpacity(this.transform.pitch),this._fogVisible&&"globe"!==this.transform.projection.name&&(this._fogVisible=w.isVisibleOnFrustum(this.transform.cameraFrustum))):this._fogVisible=!1,this._cachedTileFogOpacities={},this.terrain&&(this.terrain.updateTileBinding(v),this.opaquePassCutoff=0,a=n(),_=a.map(e=>s[e]));const T=this._shadowRenderer;if(T){T.updateShadowParameters(this.transform,this.style.directionalLight);for(const e in p)for(const t of m[e]){let e={min:0,max:0};this.terrain&&(e=this.terrain.getMinMaxForTile(t)||e),T.addShadowReceiver(t.toUnwrapped(),e.min,e.max);}}"globe"!==this.transform.projection.name||this.globeSharedBuffers||(this.globeSharedBuffers=new e.eU(this.context)),this.style.fog&&this.transform.projection.supportsFog?(this._atmosphere||(this._atmosphere=new $n(this)),this._atmosphere.update(this)):this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0);const E=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.snow),S=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.rain);if(E&&!this._snow&&(this._snow=new Ra(this)),!E&&this._snow&&(this._snow.destroy(),delete this._snow),S&&!this._rain&&(this._rain=new Ia(this)),!S&&this._rain&&(this._rain.destroy(),delete this._rain),this._snow&&this._snow.update(this),this._rain&&this._rain.update(this),h){this.buildingTileBorderManager||(this.buildingTileBorderManager=new Xn);const e=this.style.getLayerSourceCache(h);this.buildingTileBorderManager.updateBorders(e,h);}if(!q.has(this.context.gl))return;this.renderPass="offscreen";for(const e of _){const i=t.getLayerSourceCache(e);if(!e.hasOffscreenPass()||e.isHidden(this.transform.zoom))continue;const o=i?g[i.id]:void 0;("custom"===e.type||"raster"===e.type||"raster-particle"===e.type||e.isSky()||o&&o.length)&&this.renderLayer(this,i,e,o);}this.depthRangeFor3D=[0,1-(_.length+2)*this.numSublayers*this.depthEpsilon],this._shadowRenderer&&(this.renderPass="shadow",this._shadowRenderer.drawShadowPass(this.style,y)),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]);const I="globe"===this.transform.projection.name||this.transform.isHorizonVisible(),C=(()=>{if(i.showOverdrawInspector)return e.ap.black;const t=this.style.fog;if(t&&this.transform.projection.supportsFog){const i=this.style.getLut(t.scope);if(!I){const o="none"===t.properties.get("color-use-theme"),s=t.properties.get("color").toNonPremultipliedRenderColor(o?null:i).toArray01();return new e.ap(...s)}if(I){const o="none"===t.properties.get("space-color-use-theme"),s=t.properties.get("space-color").toNonPremultipliedRenderColor(o?null:i).toArray01();return new e.ap(...s)}}return e.ap.transparent})();if(this.context.clear({color:C,depth:1}),this.clearStencil(),this._showOverdrawInspector=i.showOverdrawInspector,this.renderPass="opaque",this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&I&&this._atmosphere.drawStars(this,this.style.fog),!this.terrain)for(this.currentLayer=a.length-1;this.currentLayer>=0;this.currentLayer--){const e=_[this.currentLayer],i=t.getLayerSourceCache(e);if(e.isSky())continue;const o=i?(e.is3D(r)?x:g)[i.id]:void 0;this._renderTileClippingMasks(e,i,o),this.renderLayer(this,i,e,o);}if(this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&I&&this._atmosphere.drawAtmosphereGlow(this,this.style.fog),this.renderPass="sky",(!this._atmosphere||e.ak(this.transform.zoom)>0)&&("globe"===this.transform.projection.name||this.transform.isHorizonVisible()))for(this.currentLayer=0;this.currentLayer{for(this.currentLayer=0;this.currentLayer<_.length;this.currentLayer++){const t=_[this.currentLayer];if(La[t.type]){const i=this.style.getLayerSourceCache(t);La[t.type](this,i,t,R(t,i),e);}}};t("initialize"),t("reset"),this.currentLayer=e,P=!0;}if(l&&!D&&this.terrain&&!this.transform.isOrthographic&&(D=!0,this.blitDepth()),c&&-1!==L&&this.currentLayer===L+1&&!this.transform.isOrthographic&&this.blitDepth(),this.terrain||this._renderTileClippingMasks(e,i,i?m[i.id]:void 0),this.renderLayer(this,i,e,R(e,i)),!this.terrain&&T&&this.currentLayer===A){{this.clearStencil(),this.resetStencilClippingMasks();const e=this.currentLayer;for(this.currentLayer=0;this.currentLayer<_.length;this.currentLayer++){const e=_[this.currentLayer];if(Pa[e.type]){const t=this.style.getLayerSourceCache(e);Pa[e.type](this,t,e,R(e,t));}}this.currentLayer=e;}if(T.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=_[this.currentLayer];if(!e.hasLightBeamPass())continue;const i=t.getLayerSourceCache(e);this.renderLayer(this,i,e,i?g[i.id]:void 0);}this.currentLayer=e,this.renderPass="translucent";}}if(this.currentLayer>=this._lastOcclusionLayer&&this.layersWithOcclusionOpacity.length>0){const e=this.currentLayer;this.depthOcclusion=!0;for(const e of this.layersWithOcclusionOpacity){this.currentLayer=e;const i=_[this.currentLayer],o=t.getLayerSourceCache(i),s=o?g[o.id]:void 0;this.terrain||this._renderTileClippingMasks(i,o,o?m[o.id]:void 0),this.renderLayer(this,o,i,s);}this.depthOcclusion=!1,this.currentLayer=e,this.renderPass="translucent",this.layersWithOcclusionOpacity=[];}++this.currentLayer;}}if(this.terrain&&this.terrain.postRender(),this._snow&&this._snow.draw(this),this._rain&&this._rain.draw(this),this.options.showTileBoundaries||this.options.showQueryGeometry||this.options.showTileAABBs){let i=null;_.forEach(e=>{const o=t.getLayerSourceCache(e);o&&!e.isHidden(this.transform.zoom)&&o.getVisibleCoordinates().length&&(!i||i.getSource().maxzoom0?t.pop():null}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture||this.forceTerrainMode}linearFloatFilteringSupported(){return null!=this.context.extTextureFloatLinear}currentGlobalDefines(e,t,i){const o=void 0===i?this.terrain&&this.terrain.renderingToTexture:i,s=[];return this.style&&this.style.enable3dLights()&&("globeRaster"===e||"terrainRaster"===e?(s.push("LIGHTING_3D_MODE"),s.push("LIGHTING_3D_ALPHA_EMISSIVENESS")):o||s.push("LIGHTING_3D_MODE")),"shadow"===this.renderPass&&(this._shadowMapDebug||s.push("DEPTH_TEXTURE")),this.terrainRenderModeElevated()&&(s.push("TERRAIN"),this.linearFloatFilteringSupported()&&s.push("TERRAIN_DEM_FLOAT_FORMAT")),"globe"===this.transform.projection.name&&s.push("GLOBE"),!this._fogVisible||o||void 0!==t&&!t||s.push("FOG"),o&&s.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&s.push("OVERDRAW_INSPECTOR"),s}getOrCreateProgram(e,t){this.cache=this.cache||{};const i=t&&t.defines||[],o=t&&t.config,s=this.currentGlobalDefines(e,t&&t.overrideFog,t&&t.overrideRtt).concat(i),r=cr.cacheKey(ts[e],e,s,o);return this.cache[r]||(this.cache[r]=new cr(this.context,e,ts[e],o,Wr[e],s)),this.cache[r]}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.RGBA8));}destroy(){this._terrain&&this._terrain.destroy(),this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this._wireframeDebugCache.destroy(),this.depthFBO&&(this.depthFBO.destroy(),this.depthFBO=void 0,this.depthTexture=void 0),this.emptyDepthTexture&&this.emptyDepthTexture.destroy();}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile();}uploadCommonLightUniforms(t,i){if(this.style.enable3dLights()){const o=this.style.directionalLight,s=this.style.ambientLight;if(o&&s){const r=((t,i,o)=>{const s=t.properties.get("direction"),r="none"===t.properties.get("color-use-theme"),n=t.properties.get("color").toNonPremultipliedRenderColor(r?null:o.getLut(t.scope)).toArray01(),a=t.properties.get("intensity"),l="none"===i.properties.get("color-use-theme"),c=i.properties.get("color").toNonPremultipliedRenderColor(l?null:o.getLut(i.scope)).toArray01(),h=i.properties.get("intensity"),d=[s.x,s.y,s.z],u=e.dP(c,h),_=e.dP(n,a);return {u_lighting_ambient_color:u,u_lighting_directional_dir:d,u_lighting_directional_color:_,u_ground_radiance:nr(d,_,u)}})(o,s,this.style);i.setLightsUniformValues(t,r);}}}uploadCommonUniforms(t,i,o,s,r){if(this.uploadCommonLightUniforms(t,i),this.terrain&&this.terrain.renderingToTexture)return;const n=this.style.fog;if(n){const r=n.getOpacity(this.transform.pitch),a=((t,i,o,s,r,n,a,l,c,h,d,u)=>{const _=t.transform,p="none"===i.properties.get("color-use-theme"),f=i.properties.get("color").toNonPremultipliedRenderColor(p?null:t.style.getLut(i.scope)).toArray01();f[3]=s;const m=t.frameCounter/1e3%1,[g,v]=i.properties.get("vertical-range");return {u_fog_matrix:o?_.calculateFogTileMatrix(o):u||t.identityMat,u_fog_range:i.getFovAdjustedRange(_._fov),u_fog_color:f,u_fog_horizon_blend:i.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(g,v),v],u_fog_temporal_offset:m,u_frustum_tl:r,u_frustum_tr:n,u_frustum_br:a,u_frustum_bl:l,u_globe_pos:c,u_globe_radius:h,u_viewport:d,u_globe_transition:e.ak(_.zoom),u_is_globe:+("globe"===_.projection.name)}})(this,n,o,r,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.o.devicePixelRatio,this.transform.height*e.o.devicePixelRatio],s);i.setFogUniformValues(t,a);}r&&i.setCutoffUniformValues(t,r.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={},i=this.transform.coveringTiles({tileSize:512});for(const o of i)t[o.key]=e[o.key]||new Pt(o,512,this.transform.tileZoom,this,void 0,this.worldview);return t}clearBackgroundTiles(){this._backgroundTiles={};}isSourceForClippingOrConflation(e,t){return !(!e.is3D(!(!this.terrain||!this.terrain.enabled))||"clip"!==e.type&&"building"!==e.type&&(e.minzoom&&e.minzoom>this.transform.zoom||(this.style._clipLayerPresent||"building"!==e.sourceLayer&&"procedural_buildings"!==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]>=Ve||t[1]>=Ve}setupDepthForOcclusion(e,t,i){const o=this.context,s=o.gl,r=!!i;var n;i||(i={u_dem:2,u_dem_prev:4,u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_depth_range_unpack:[0,1],u_occluder_half_size:16,u_occlusion_depth_offset:-1e-4,u_exaggeration:0}),o.activeTexture.set(s.TEXTURE3),e&&this.depthFBO&&this.depthTexture?(this.depthTexture.bind(s.NEAREST,s.CLAMP_TO_EDGE),i.u_depth_size_inv=[1/this.depthFBO.width,1/this.depthFBO.height],i.u_depth_range_unpack=[2/((n=this.depthRangeFor3D)[1]-n[0]),-1-2*n[0]/(n[1]-n[0])],i.u_occluder_half_size=.5*this.occlusionParams.occluderSize,i.u_occlusion_depth_offset=this.occlusionParams.depthOffset):this.emptyDepthTexture.bind(s.NEAREST,s.CLAMP_TO_EDGE),o.activeTexture.set(s.TEXTURE0),r||t.setTerrainUniformValues(o,i);}updateEmissiveMode(){if(this._forceEmissiveMode)return;const e=this.style.hasDataDrivenEmissiveStrength();this.emissiveMode=e?this.context.extBlendFuncExtended?"dual-source-blending":"mrt-fallback":"constant";}}function za(e,t){let i=!1,o=null;const s=()=>{o=null,i&&(e(),o=setTimeout(s,t),i=!1);};return ()=>(i=!0,o||s(),o)}class Ma{constructor(t){this._hashName=t&&encodeURIComponent(t),e.aZ(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=za(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=Fa(e);if(this._hashName){const e=this._hashName;let i=!1;const o=location.hash.slice(1).split("&").map(o=>{const s=o.split("=")[0];return s===e?(i=!0,`${s}=${t}`):o}).filter(e=>e);return i||o.push(`${e}=${t}`),`#${o.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(Number(e)))){const i=e.dragRotate.isEnabled()&&e.touchZoomRotate.isEnabled()?+(t[3]||0):e.getBearing();return e.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:i,pitch:+(t[4]||0)}),!0}return !1}_updateHashUnthrottled(){history.replaceState(history.state,"",location.href.replace(/(#.+)?$/,this.getHashString()));}}function Fa(e,t){const i=e.getCenter(),o=Math.round(100*e.getZoom())/100,s=Math.ceil((o*Math.LN2+Math.log(512/360/.5))/Math.LN10),r=Math.pow(10,s),n=Math.round(i.lng*r)/r,a=Math.round(i.lat*r)/r,l=e.getBearing(),c=e.getPitch();let h=t?`/${n}/${a}/${o}`:`${o}/${a}/${n}`;return (l||c)&&(h+="/"+Math.round(10*l)/10),c&&(h+=`/${Math.round(c)}`),h}const ka={linearity:.3,easing:e.eW(0,0,.3,1)},Ba=Object.assign({deceleration:2500,maxSpeed:1400},ka),Na=Object.assign({deceleration:20,maxSpeed:1400},ka),Ua=Object.assign({deceleration:1e3,maxSpeed:360},ka),ja=Object.assign({deceleration:1e3,maxSpeed:90},ka);class Va{constructor(e){this._map=e,this.clear();}clear(){this._inertiaBuffer=[];}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:e.o.now(),settings:t});}_drainInertiaBuffer(){const t=this._inertiaBuffer,i=e.o.now();for(;t.length>0&&i-t[0].time>160;)t.shift();}_onMoveEnd(t){if(this._map._prefersReducedMotion())return;if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const i={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)i.zoom+=e.zoomDelta||0,i.bearing+=e.bearingDelta||0,i.pitch+=e.pitchDelta||0,e.panDelta&&i.pan._add(e.panDelta),e.around&&(i.around=e.around),e.pinchAround&&(i.pinchAround=e.pinchAround);const o=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,s={};if(i.pan.mag()){const e=Ha(i.pan.mag(),o,Object.assign({},Ba,t||{}));s.offset=i.pan.mult(e.amount/i.pan.mag()),s.center=this._map.transform.center,Ga(s,e);}if(i.zoom){const e=Ha(i.zoom,o,Na);s.zoom=this._map.transform.zoom+e.amount,Ga(s,e);}if(i.bearing){const t=Ha(i.bearing,o,Ua);s.bearing=this._map.transform.bearing+e.aB(t.amount,-179,179),Ga(s,t);}if(i.pitch){const e=Ha(i.pitch,o,ja);s.pitch=this._map.transform.pitch+e.amount,Ga(s,e);}if(s.zoom||s.bearing){const e=void 0===i.pinchAround?i.around:i.pinchAround;s.around=e?this._map.unproject(e):this._map.getCenter();}return this.clear(),s.noMoveStart=!0,s}}function Ga(e,t){(!e.duration||e.durationi.unproject(e)),a=r.reduce((e,t,i,o)=>e.add(t.div(o.length)),new e.P(0,0));super(t,{points:r,point:a,lngLats:n,lngLat:i.unproject(a),originalEvent:o}),this._defaultPrevented=!1;}}class Wa extends e.A{preventDefault(){this._defaultPrevented=!0;}get defaultPrevented(){return this._defaultPrevented}constructor(e,t){super("wheel",{originalEvent:t}),this._defaultPrevented=!1;}}class $a{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance;}reset(){this._mousedownPos=void 0;}wheel(e){return this._firePreventable(new Wa(this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new qa(e.type,this._map,e))}mouseup(e){this._map.fire(new qa(e.type,this._map,e));}preclick(e){const t=new MouseEvent("preclick",e);this._map.fire(new qa(t.type,this._map,t));}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||(this.preclick(e),this._map.fire(new qa(e.type,this._map,e)));}dblclick(e){return this._firePreventable(new qa(e.type,this._map,e))}mouseover(e){this._map.fire(new qa(e.type,this._map,e));}mouseout(e){this._map.fire(new qa(e.type,this._map,e));}touchstart(e){return this._firePreventable(new Za(e.type,this._map,e))}touchmove(e){this._map.fire(new Za(e.type,this._map,e));}touchend(e){this._map.fire(new Za(e.type,this._map,e));}touchcancel(e){this._map.fire(new Za(e.type,this._map,e));}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return {}}isEnabled(){return !0}isActive(){return !1}enable(){}disable(){}}class Xa{constructor(e){this._map=e;}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0;}mousemove(e){this._map.fire(new qa(e.type,this._map,e));}mousedown(){this._delayContextMenu=!0;}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new qa("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent);}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._map.fire(new qa(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault();}isEnabled(){return !0}isActive(){return !1}enable(){}disable(){}}class Ka{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&&(_(),this._startPos=this._lastPos=t,this._active=!0);}mousemoveWindow(e,t){if(!this._active)return;const i=t,o=this._startPos,s=this._lastPos;if(!o||!s||s.equals(i)||!this._box&&i.dist(o){this._box&&(this._box.style.transform=`translate(${r}px,${a}px)`,this._box.style.width=n-r+"px",this._box.style.height=c-a+"px");});}mouseupWindow(t,i){if(!this._active)return;const o=this._startPos,s=i;if(o&&0===t.button){if(this.reset(),m(),o.x!==s.x||o.y!==s.y)return this._map.fire(new e.A("boxzoomend",{originalEvent:t})),{cameraAnimation:e=>e.fitScreenCoordinates(o,s,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),p(),delete this._startPos,delete this._lastPos;}_fireEvent(t,i){return this._map.fire(new e.A(t,{originalEvent:i}))}}function Ya(e,t){const i={};for(let o=0;othis.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=t.timeStamp),o.length===this.numTouches&&(this.centroid=function(t){const i=new e.P(0,0);for(const e of t)i._add(e);return i.div(t.length)}(i),this.touches=Ya(o,i)));}touchmove(e,t,i){if(this.aborted||!this.centroid)return;const o=Ya(i,t);for(const e in this.touches){const t=o[e];(!t||t.dist(this.touches[e])>30)&&(this.aborted=!0);}}touchend(e,t,i){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){const e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class Qa{constructor(e){this.singleTap=new Ja(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,i){this.singleTap.touchstart(e,t,i);}touchmove(e,t,i){this.singleTap.touchmove(e,t,i);}touchend(e,t,i){const o=this.singleTap.touchend(e,t,i);if(o){const t=e.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(o)<30;if(t&&i||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=o,this.count===this.numTaps)return this.reset(),o}}}class el{constructor(){this._zoomIn=new Qa({numTouches:1,numTaps:2}),this._zoomOut=new Qa({numTouches:2,numTaps:1}),this.reset();}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset();}touchstart(e,t,i){this._zoomIn.touchstart(e,t,i),this._zoomOut.touchstart(e,t,i);}touchmove(e,t,i){this._zoomIn.touchmove(e,t,i),this._zoomOut.touchmove(e,t,i);}touchend(e,t,i){const o=this._zoomIn.touchend(e,t,i),s=this._zoomOut.touchend(e,t,i);return o?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()+1,around:t.unproject(o)},{originalEvent:e})}):s?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()-1,around:t.unproject(s)},{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 tl=0,il=2,ol={[tl]:1,[il]:2},sl={Control:"ctrlKey",Alt:"altKey",Shift:"shiftKey",Meta:"metaKey"};class rl{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 i=y(e);this._correctButton(e,i)&&(this._lastPoint=t,this._eventButton=i);}mousemoveWindow(e,t){const i=this._lastPoint;if(i)if(e.preventDefault(),null!=this._eventButton&&function(e,t){const i=ol[t];return void 0===e.buttons||(e.buttons&i)!==i}(e,this._eventButton))this.reset();else if(this._moved||!(t.dist(i)0&&(this._active=!0);const s=Ya(o,i),r=new e.P(0,0),n=new e.P(0,0);let a=0;for(const e in s){const t=s[e],i=this._touches[e];i&&(r._add(t),n._add(t.sub(i)),a++,s[e]=t);}if(this._touches=s,a{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.removeAttribute("role");},500);}}class hl{constructor(){this.reset();}reset(){this._active=!1,this._firstTwoTouches=void 0;}_start(e){}_move(e,t,i){return {}}touchstart(e,t,i){this._firstTwoTouches||i.length<2||(this._firstTwoTouches=[i[0].identifier,i[1].identifier],this._start([t[0],t[1]]));}touchmove(e,t,i){const o=this._firstTwoTouches;if(!o)return;e.preventDefault();const[s,r]=o,n=dl(i,t,s),a=dl(i,t,r);if(!n||!a)return;const l=this._aroundCenter?null:n.add(a).div(2);return this._move([n,a],l,e)}touchend(e,t,i){if(!this._firstTwoTouches)return;const[o,s]=this._firstTwoTouches,r=dl(i,t,o),n=dl(i,t,s);r&&n||(this._active&&m(),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 dl(e,t,i){for(let o=0;oMath.abs(e.x)}class gl extends hl{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,ml(e[0].sub(e[1]))&&(this._valid=!1);}_move(t,i,o){const s=this._lastPoints;if(!s)return;const r=t[0].sub(s[0]),n=t[1].sub(s[1]);return this._map._cooperativeGestures&&!e.eX()&&o.touches.length<3||(this._valid=this.gestureBeginsVertically(r,n,o.timeStamp),!this._valid)?void 0:(this._lastPoints=t,this._active=!0,{pitchDelta:(r.y+n.y)/2*-.5})}gestureBeginsVertically(e,t,i){if(void 0!==this._valid)return this._valid;const o=e.mag()>=2,s=t.mag()>=2;if(!o&&!s)return;if(!o||!s)return null==this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const r=e.y>0==t.y>0;return ml(e)&&ml(t)&&r}}const vl={panStep:100,bearingStep:15,pitchStep:10};class yl{constructor(){const e=vl;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,i=0,o=0,s=0,r=0;switch(e.keyCode){case 61:case 107:case 171:case 187:t=1;break;case 189:case 109:case 173:t=-1;break;case 37:e.shiftKey?i=-1:(e.preventDefault(),s=-1);break;case 39:e.shiftKey?i=1:(e.preventDefault(),s=1);break;case 38:e.shiftKey?o=1:(e.preventDefault(),r=-1);break;case 40:e.shiftKey?o=-1:(e.preventDefault(),r=1);break;default:return}return this._rotationDisabled&&(i=0,o=0),{cameraAnimation:n=>{const a=n.getZoom();n.easeTo({duration:300,easeId:"keyboardHandler",easing:xl,zoom:t?Math.round(a)+t*(e.shiftKey?2:1):a,bearing:n.getBearing()+i*this._bearingStep,pitch:n.getPitch()+o*this._pitchStep,offset:[-s*this._panStep,-r*this._panStep],center:n.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 xl(e){return e*(2-e)}const bl=4.000244140625,wl=1/450;class Tl{constructor(t,i){this._map=t,this._el=t.getCanvasContainer(),this._handler=i,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=wl,e.aZ(["_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.eX()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer));}let i=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const o=e.o.now(),s=o-(this._lastWheelEventTime||0);this._lastWheelEventTime=o,0!==i&&i%bl===0?this._type="wheel":0!==i&&Math.abs(i)<4?this._type="trackpad":s>400?(this._type=null,this._lastValue=i,this._timeout=window.setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(s*i)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,i+=this._lastValue)),t.shiftKey&&i&&(i/=4),this._type&&(this._lastWheelEvent=t,this._delta-=i,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=g(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 i=()=>t._terrainEnabled()&&this._aroundCoord?t.computeZoomRelativeTo(this._aroundCoord):t.zoom;if(0!==this._delta){const e="wheel"===this._type&&Math.abs(this._delta)>bl?this._wheelZoomRate:this._defaultZoomRate;let o=2/(1+Math.exp(-Math.abs(this._delta*e)));this._delta<0&&0!==o&&(o=1/o);const s=i(),r=Math.pow(2,s),n="number"==typeof this._targetZoom?t.zoomScale(this._targetZoom):r;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(n*o))),"wheel"===this._type&&(this._startZoom=s,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0;}const o="number"==typeof this._targetZoom?this._targetZoom:i(),s=this._startZoom,r=this._easing;let n,a=!1;if("wheel"===this._type&&s&&r){const t=Math.min((e.o.now()-this._lastWheelEventTime)/200,1),i=r(t);n=e.al(s,o,i),t<1?this._frameId||(this._frameId=!0):a=!0;}else n=o,a=!0;this._active=!0,a&&(this._active=!1,this._finishTimeout=window.setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout;},200));let l=n-i();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 i=e.eY;if(this._prevEase){const t=this._prevEase,o=(e.o.now()-t.start)/t.duration,s=t.easing(o+.01)-t.easing(o),r=.27/Math.sqrt(s*s+1e-4)*.01,n=Math.sqrt(.0729-r*r);i=e.eW(r,n,.25,1);}return this._prevEase={start:e.o.now(),duration:t,easing:i},i}blur(){this.reset();}reset(){this._active=!1;}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=l("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`);}_showBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=window.setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.removeAttribute("role");},200);}}class El{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 Sl{constructor(){this.reset();}reset(){this._active=!1;}blur(){this.reset();}dblclick(e,t){return e.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:i.getZoom()+(e.shiftKey?-1:1),around:i.unproject(t)},{originalEvent:e});}}}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class Il{constructor(){this._tap=new Qa({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,i){this._swipePoint||(this._tapTime&&e.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?i.length>0&&(this._swipePoint=t[0],this._swipeTouch=i[0].identifier):this._tap.touchstart(e,t,i));}touchmove(e,t,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const o=t[0],s=o.y-this._swipePoint.y;return this._swipePoint=o,e.preventDefault(),this._active=!0,{zoomDelta:s/128}}}else this._tap.touchmove(e,t,i);}touchend(e,t,i){this._tapTime?this._swipePoint&&0===i.length&&this.reset():this._tap.touchend(e,t,i)&&(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 Cl{constructor(e,t,i){this._el=e,this._mousePan=t,this._touchPan=i;}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("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 Rl{constructor(e,t,i){this._pitchWithRotate=e.pitchWithRotate,this._mouseRotate=t,this._mousePitch=i;}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 Al{constructor(e,t,i,o){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=o,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 Dl=e=>e.zoom||e.drag||e.pitch||e.rotate;class Ll extends e.A{}class Pl{constructor(){this.constants=[1,1,.01],this.radius=0;}setup(t,i){const o=e.aw([],i,t);this.radius=e.ah(o[2]<0?e.e_([],o,this.constants):[o[0],o[1],0]);}projectRay(t){e.e_(t,t,this.constants),e.ax(t,t),e.e$(t,t,this.constants);const i=e.c6([],t,this.radius);if(i[2]>0){const t=e.c6([],[0,0,1],e.bK(i,[0,0,1])),o=e.c6([],e.ax([],[i[0],i[1],0]),this.radius),s=e.d9([],i,e.c6([],e.aw([],e.d9([],o,t),i),2));i[0]=s[0],i[1]=s[1];}return i}}function Ol(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta}class zl{constructor(t,i){this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Va(t),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new Pl,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(i),e.aZ(["handleEvent","handleWindowEvent"],this);const o=this._el;this._listeners=[[o,"touchstart",{passive:!0}],[o,"touchmove",{passive:!1}],[o,"touchend",void 0],[o,"touchcancel",void 0],[o,"mousedown",void 0],[o,"mousemove",void 0],[o,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[o,"mouseover",void 0],[o,"mouseout",void 0],[o,"dblclick",void 0],[o,"click",void 0],[o,"keydown",{capture:!1}],[o,"keyup",void 0],[o,"wheel",{passive:!1}],[o,"contextmenu",void 0],[window,"blur",void 0]];for(const[e,t,i]of this._listeners){const o=e===document?this.handleWindowEvent:this.handleEvent;e.addEventListener(t,o,i);}}destroy(){for(const[e,t,i]of this._listeners){const o=e===document?this.handleWindowEvent:this.handleEvent;e.removeEventListener(t,o,i);}}_addDefaultHandlers(e){const t=this._map,i=t.getCanvasContainer();this._add("mapEvent",new $a(t,e));const o=t.boxZoom=new Ka(t,e);this._add("boxZoom",o);const s=new el,r=new Sl;t.doubleClickZoom=new El(r,s),this._add("tapZoom",s),this._add("clickZoom",r);const n=new Il;this._add("tapDragZoom",n);const a=t.touchPitch=new gl(t);this._add("touchPitch",a);const l=new al(e),c=new ll(e);t.dragRotate=new Rl(e,l,c),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",c,["mouseRotate"]);const h=new nl(e),d=new cl(t,e);t.dragPan=new Cl(i,h,d),this._add("mousePan",h),this._add("touchPan",d,["touchZoom","touchRotate"]);const u=new fl,_=new _l;t.touchZoomRotate=new Al(i,_,u,n),this._add("touchRotate",u,["touchPan","touchZoom"]),this._add("touchZoom",_,["touchPan","touchRotate"]),this._add("blockableMapEvent",new Xa(t));const p=t.scrollZoom=new Tl(t,this);this._add("scrollZoom",p,["mousePan"]);const f=t.keyboard=new yl;this._add("keyboard",f);for(const i of ["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])e.interactive&&e[i]&&t[i].enable(e[i]);}_add(e,t,i){this._handlers.push({handlerName:e,handler:t,allowed:i}),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 !!Dl(this._eventsInProgress)||this.isZooming()}_isDragging(){return !!this._eventsInProgress.drag}_blockedByActive(e,t,i){for(const o in e)if(o!==i&&(!t||t.indexOf(o)<0))return !0;return !1}handleWindowEvent(e){this.handleEvent(e,`${e.type}Window`);}_getMapTouches(e){const t=[];for(const i of e)this._el.contains(i.target)&&t.push(i);return t}handleEvent(e,t){this._updatingCamera=!0;const i="renderFrame"===e.type,o=i?void 0:e,s={needsRenderFrame:!1},r={},n={},a=e.touches?this._getMapTouches(e.touches):void 0,l=a?v(this._el,a):i?void 0:g(this._el,e);for(const{handlerName:i,handler:c,allowed:h}of this._handlers){if(!c.isEnabled())continue;let d;this._blockedByActive(n,h,i)?c.reset():c[t||e.type]&&(d=c[t||e.type](e,l,a),this.mergeHandlerResult(s,r,d,i,o),d&&d.needsRenderFrame&&this._triggerRenderFrame()),(d||c.isActive())&&(n[i]=c);}const c={};for(const e in this._previousActiveHandlers)n[e]||(c[e]=o);this._previousActiveHandlers=n,(Object.keys(c).length||Ol(s))&&(this._changes.push([s,r,c]),this._triggerRenderFrame()),(Object.keys(n).length||Ol(s))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:h}=s;h&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],h(this._map));}mergeHandlerResult(e,t,i,o,s){if(!i)return;Object.assign(e,i);const r={handlerName:o,originalEvent:i.originalEvent||s};void 0!==i.zoomDelta&&(t.zoom=r),void 0!==i.panDelta&&(t.drag=r),void 0!==i.pitchDelta&&(t.pitch=r),void 0!==i.bearingDelta&&(t.rotate=r);}_applyChanges(){const t={},i={},o={};for(const[s,r,n]of this._changes)s.panDelta&&(t.panDelta=(t.panDelta||new e.P(0,0))._add(s.panDelta)),s.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+s.zoomDelta),s.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+s.bearingDelta),s.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+s.pitchDelta),void 0!==s.around&&(t.around=s.around),void 0!==s.aroundCoord&&(t.aroundCoord=s.aroundCoord),void 0!==s.pinchAround&&(t.pinchAround=s.pinchAround),s.noInertia&&(t.noInertia=s.noInertia),Object.assign(i,r),Object.assign(o,n);this._updateMapTransform(t,i,o),this._changes=[];}_updateMapTransform(t,i,o){const s=this._map,r=s.transform,n=e=>[e.x,e.y,e.z];if((()=>{const e=this._eventsInProgress.drag;return e&&!this._handlersById[e.handlerName].isActive()})()&&!Ol(t)){const e=r.zoom;r.cameraElevationReference="sea",null!=this._originalZoom&&r._orthographicProjectionAtLowPitch&&"globe"!==r.projection.name&&0===r.pitch?(r.cameraElevationReference="ground",r.zoom=this._originalZoom):(r.recenterOnTerrain(),r.cameraElevationReference="ground"),e!==r.zoom&&this._map._update(!0);}if(r._isCameraConstrained&&s._stop(!0),!Ol(t))return void this._fireEvents(i,o,!0);let{panDelta:a,zoomDelta:l,bearingDelta:c,pitchDelta:h,around:d,aroundCoord:u,pinchAround:_}=t;r._isCameraConstrained&&(l>0&&(l=0),r._isCameraConstrained=!1),void 0!==_&&(d=_),(l||(e=>i[e]&&!this._eventsInProgress[e])("drag"))&&d&&(this._dragOrigin=n(r.pointCoordinate3D(d)),this._originalZoom=r.zoom,this._trackingEllipsoid.setup(r._camera.position,this._dragOrigin)),r.cameraElevationReference="sea",s._stop(!0),d=d||s.transform.centerPoint,c&&(r.bearing+=c),h&&(r.pitch+=h),r._updateCameraState();const p=[0,0,0];if(a)if("mercator"===r.projection.name){const e=this._trackingEllipsoid.projectRay(r.screenPointToMercatorRay(d).dir),t=this._trackingEllipsoid.projectRay(r.screenPointToMercatorRay(d.sub(a)).dir);p[0]=t[0]-e[0],p[1]=t[1]-e[1];}else {const t=r.pointCoordinate(d);if("globe"===r.projection.name){a=a.rotate(-r.angle);const i=r._pixelsPerMercatorPixel/r.worldSize;p[0]=-a.x*e.eZ(e.b0(t.y))*i,p[1]=-a.y*e.eZ(r.center.lat)*i;}else {const e=r.pointCoordinate(d.sub(a));t&&e&&(p[0]=e.x-t.x,p[1]=e.y-t.y);}}const f=r.zoom,m=[0,0,0];if(l){const t=n(u||r.pointCoordinate3D(d)),i={dir:e.ax([],e.aw([],t,r._camera.position))};if(i.dir[2]<0){const o=r.zoomDeltaToMovement(t,l);e.c6(m,i.dir,o);}}const g=e.d9(p,p,m);r._translateCameraConstrained(g),l&&Math.abs(r.zoom-f)>1e-4&&r.recenterOnTerrain(),r.cameraElevationReference="ground",this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(i,o,!0);}_fireEvents(t,i,o){const s=Dl(this._eventsInProgress),r=Dl(t),n={};for(const e in t){const{originalEvent:i}=t[e];this._eventsInProgress[e]||(n[`${e}start`]=i),this._eventsInProgress[e]=t[e];}!s&&r&&this._fireEvent("movestart",r.originalEvent);for(const e in n)this._fireEvent(e,n[e]);r&&this._fireEvent("move",r.originalEvent);for(const e in t){const{originalEvent:i}=t[e];this._fireEvent(e,i);}const a={};let l;for(const e in this._eventsInProgress){const{handlerName:t,originalEvent:o}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],l=i[t]||o,a[`${e}end`]=l);}for(const e in a)this._fireEvent(e,a[e]);const c=Dl(this._eventsInProgress);if(o&&(s||r)&&!c){this._updatingCamera=!0;const t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=e=>0!==e&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new Ll("renderFrame",{timeStamp:e})),this._applyChanges();})}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame());}}const Ml="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class Fl extends e.E{constructor(t,i){super(),this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=i.bearingSnap,this._respectPrefersReducedMotion=!1!==i.respectPrefersReducedMotion,e.aZ(["_renderFrameCallback"],this);}getCenter(){return new e.aU(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}panBy(t,i,o){return t=e.P.convert(t).mult(-1),this.panTo(this.transform.center,Object.assign({offset:t},i),o)}panTo(e,t,i){return this.easeTo(Object.assign({center:e},t),i)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(e,t,i){return this.easeTo(Object.assign({zoom:e},t),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(e,t,i){return this.easeTo(Object.assign({bearing:e},t),i)}resetNorth(e,t){return this.rotateTo(0,Object.assign({duration:1e3},e),t),this}resetNorthPitch(e,t){return this.easeTo(Object.assign({bearing:0,pitch:0,duration:1e3},e),t),this}snapToNorth(e,t){return Math.abs(this.getBearing())e.aspect?i/(2*Math.tan(.5*e.fovX)*e.aspect):o/(2*Math.tan(.5*e.fovY)*e.aspect)}_cameraForBoundsOnGlobe(t,i,o,s,r,n){const a=t.clone(),l=this._extendCameraOptions(n);a.bearing=s,a.pitch=r;const c=e.aU.convert(i),h=e.aU.convert(o),d=.5*(c.lat+h.lat),u=.5*(c.lng+h.lng),_=e.f0(d,u),p=e.ax([],_),f=e.ax([],e.bJ([],p,[0,1,0])),m=e.bJ([],f,p),g=[f[0],f[1],f[2],0,m[0],m[1],m[2],0,p[0],p[1],p[2],0,0,0,0,1],v=[_,e.f0(c.lat,c.lng),e.f0(h.lat,c.lng),e.f0(h.lat,h.lng),e.f0(c.lat,h.lng),e.f0(d,c.lng),e.f0(d,h.lng),e.f0(c.lat,u),e.f0(h.lat,u)];let y=e.da.fromPoints(v.map(t=>[e.bK(f,t),e.bK(m,t),e.bK(p,t)]));const x=e.ag([],y.center,g);0===e.f1(x)&&e.f2(x,0,0,1),e.ax(x,x),e.c6(x,x,e.aE),a.center=e.f3(x);const b=a.getWorldToCameraMatrix(),w=e.bm(new Float64Array(16),b);y=e.da.applyTransform(y,e.aC([],b,g));const T=this._extendAABB(y,a,l,s);if(!T)return void e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");y=T,e.ag(x,x,b);const E=.5*(y.max[2]-y.min[2]),S=this._minimumAABBFrustumDistance(a,y),I=e.c6([],[0,0,1],E),C=e.d9(I,x,I),R=S+(0===a.pitch?0:e.bH(x,C)),A=a.globeCenterInViewSpace,D=e.aw([],x,[A[0],A[1],A[2]]);e.ax(D,D),e.c6(D,D,R);const L=e.d9([],x,D);e.ag(L,L,w);const P=e.eP/e.aE,O=e.ah(L),z=e.cg(Math.max(O*P-e.eP,Number.EPSILON),0),M=Math.min(a.zoomFromMercatorZAdjusted(z),l.maxZoom);return M>.5*(e.c$+e.cM)?(a.setProjection({name:"mercator"}),a.zoom=M,this._cameraForBounds(a,i,o,s,r,n)):{center:a.center,zoom:M,bearing:s,pitch:r}}_extendAABB(t,i,o,s){const r=.5*((o.padding.left||0)+(o.padding.right||0)),n=.5*((o.padding.top||0)+(o.padding.bottom||0)),a=n,l=r,c=r,h=n,d=i.width-(l+c),u=i.height-(a+h),_=e.aw([],t.max,t.min),p=Math.min(d/_[0],u/_[1]),f=Math.min(i.scaleZoom(i.scale*p),o.maxZoom);if(isNaN(f))return null;const m=i.scale/i.zoomScale(f),g=new e.da([t.min[0]-l*m,t.min[1]-h*m,t.min[2]],[t.max[0]+c*m,t.max[1]+a*m,t.max[2]]),v=("number"==typeof o.offset.x&&"number"==typeof o.offset.y?new e.P(o.offset.x,o.offset.y):e.P.convert(o.offset)).rotate(-e.ao(s));return g.center[0]-=v.x*m,g.center[1]+=v.y*m,g}queryTerrainElevation(t,i){const o=this.transform.elevation;return o?(i=Object.assign({},{exaggerated:!0},i),o.getAtPoint(e.af.fromLngLat(t),null,i.exaggerated)):null}_cameraForBounds(t,i,o,s,r,n){if("globe"===t.projection.name)return this._cameraForBoundsOnGlobe(t,i,o,s,r,n);const a=t.clone(),l=this._extendCameraOptions(n);a.bearing=s,a.pitch=r;const c=e.aU.convert(i),h=e.aU.convert(o),d=new e.aU(c.lng,h.lat),u=new e.aU(h.lng,c.lat),_=a.project(c),p=a.project(h),f=this.queryTerrainElevation(c),m=this.queryTerrainElevation(h),g=this.queryTerrainElevation(d),v=this.queryTerrainElevation(u),y=[[_.x,_.y,Math.min(f||0,m||0,g||0,v||0)],[p.x,p.y,Math.max(f||0,m||0,g||0,v||0)]];let x=e.da.fromPoints(y);const b=a.getWorldToCameraMatrix(),w=e.bm(new Float64Array(16),b);x=e.da.applyTransform(x,b);const T=this._extendAABB(x,a,l,s);if(!T)return void e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");x=T;const E=.5*e.aw([],x.max,x.min)[2],S=this._minimumAABBFrustumDistance(a,x),I=[0,0,1,0];e.aD(I,I,b),e.f4(I,I);const C=e.c6([],I,S+E),R=e.d9([],x.center,C);e.ag(x.center,x.center,w),e.ag(R,R,w);const A=a.unproject(new e.P(x.center[0],x.center[1])),D=e.f5(a.projection,A),L=Math.pow(2,D),P=Math.min(a._zoomFromMercatorZ(R[2]*a.pixelsPerMeter*L/a.worldSize),l.maxZoom);return a.mercatorFromTransition&&P<.5*(e.c$+e.cM)?(a.setProjection({name:"globe"}),a.zoom=P,this._cameraForBounds(a,i,o,s,r,n)):{center:A,zoom:P,bearing:s,pitch:r}}fitBounds(e,t,i){const o=this.cameraForBounds(e,t);return this._fitInternal(o,t,i)}fitScreenCoordinates(t,i,o,s,r){const n=e.P.convert(t),a=e.P.convert(i),l=new e.P(Math.min(n.x,a.x),Math.min(n.y,a.y)),c=new e.P(Math.max(n.x,a.x),Math.max(n.y,a.y));if("mercator"===this.transform.projection.name&&this.transform.anyCornerOffEdge(n,a))return this;const h=this.transform.pointLocation3D(l),d=this.transform.pointLocation3D(c),u=this.transform.pointLocation3D(new e.P(l.x,c.y)),_=this.transform.pointLocation3D(new e.P(c.x,l.y)),p=[Math.min(h.lng,d.lng,u.lng,_.lng),Math.min(h.lat,d.lat,u.lat,_.lat)],f=[Math.max(h.lng,d.lng,u.lng,_.lng),Math.max(h.lat,d.lat,u.lat,_.lat)],m=s&&s.pitch?s.pitch:this.getPitch(),g=this._cameraForBounds(this.transform,p,f,o,m,s);return this._fitInternal(g,s,r)}_fitInternal(e,t,i){return e?(t=Object.assign(e,t)).linear?this.easeTo(t,i):this.flyTo(t,i):this}jumpTo(t,i){this.stop();const o=t.preloadOnly?this.transform.clone():this.transform;let s=!1,r=!1,n=!1;"zoom"in t&&o.zoom!==+t.zoom&&(s=!0,o.zoom=+t.zoom),void 0!==t.center&&(o.center=e.aU.convert(t.center)),"bearing"in t&&o.bearing!==+t.bearing&&(r=!0,o.bearing=+t.bearing),"pitch"in t&&o.pitch!==+t.pitch&&(n=!0,o.pitch=+t.pitch);const a="number"==typeof t.padding?this._extendPadding(t.padding):t.padding;if(null!=t.padding&&!o.isPaddingEqual(a))if(!1===t.retainPadding){const e=o.clone();e.padding=a,o.setLocationAtPoint(o.center,e.centerPoint);}else o.padding=a;return t.preloadOnly?(this._preloadTiles(o),this):(this.fire(new e.A("movestart",i)).fire(new e.A("move",i)),s&&this.fire(new e.A("zoomstart",i)).fire(new e.A("zoom",i)).fire(new e.A("zoomend",i)),r&&this.fire(new e.A("rotatestart",i)).fire(new e.A("rotate",i)).fire(new e.A("rotateend",i)),n&&this.fire(new e.A("pitchstart",i)).fire(new e.A("pitch",i)).fire(new e.A("pitchend",i)),this.fire(new e.A("moveend",i)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||e.w(Ml),this.transform.getFreeCameraOptions()}setFreeCameraOptions(t,i){const o=this.transform;if(!o.projection.supportsFreeCamera)return e.w(Ml),this;this.stop();const s=o.zoom,r=o.pitch,n=o.bearing;o.setFreeCameraOptions(t);const a=s!==o.zoom,l=r!==o.pitch,c=n!==o.bearing;return this.fire(new e.A("movestart",i)).fire(new e.A("move",i)),a&&this.fire(new e.A("zoomstart",i)).fire(new e.A("zoom",i)).fire(new e.A("zoomend",i)),c&&this.fire(new e.A("rotatestart",i)).fire(new e.A("rotate",i)).fire(new e.A("rotateend",i)),l&&this.fire(new e.A("pitchstart",i)).fire(new e.A("pitch",i)).fire(new e.A("pitchend",i)),this.fire(new e.A("moveend",i)),this}easeTo(t,i){this._stop(!1,t.easeId),(!1===(t=Object.assign({offset:[0,0],duration:500,easing:e.eY},t)).animate||this._prefersReducedMotion(t))&&(t.duration=0);const o=this.transform,s=this.getZoom(),r=this.getBearing(),n=this.getPitch(),a=this.getPadding(),l="zoom"in t?+t.zoom:s,c="bearing"in t?this._normalizeBearing(t.bearing,r):r,h="pitch"in t?+t.pitch:n,d=this._extendPadding(t.padding),u=e.P.convert(t.offset);let _,p,f;if("globe"===o.projection.name){const i=e.af.fromLngLat(o.center),s=u.rotate(-o.angle);i.x+=s.x/o.worldSize,i.y+=s.y/o.worldSize;const r=i.toLngLat(),n=e.aU.convert(t.center||r);this._normalizeCenter(n),_=o.centerPoint.add(s),p=new e.P(i.x,i.y).mult(o.worldSize),f=new e.P(e.aG(n.lng),e.aK(n.lat)).mult(o.worldSize).sub(p);}else {_=o.centerPoint.add(u);const i=o.pointLocation(_),s=e.aU.convert(t.center||i);this._normalizeCenter(s),p=o.project(i),f=o.project(s).sub(p);}const m=o.zoomScale(l-s);let g,v;t.around&&(g=e.aU.convert(t.around),v=o.locationPoint(g));const y=this._zooming||l!==s,x=this._rotating||r!==c,b=this._pitching||h!==n,w=!o.isPaddingEqual(d),T=!1===t.retainPadding?o.clone():o,E=o=>E=>{if(y&&(o.zoom=e.al(s,l,E)),x&&(o.bearing=e.al(r,c,E)),b&&(o.pitch=e.al(n,h,E)),w&&(T.interpolatePadding(a,d,E),_=T.centerPoint.add(u)),g)o.setLocationAtPoint(g,v);else {const e=o.zoomScale(o.zoom-s),t=l>s?Math.min(2,m):Math.max(.5,m),i=Math.pow(t,1-E),r=o.unproject(p.add(f.mult(E*i)).mult(e));o.setLocationAtPoint(o.renderWorldCopies?r.wrap():r,_);}return t.preloadOnly||this._fireMoveEvents(i),o};if(t.preloadOnly){const e=this._emulate(E,t.duration,o);return this._preloadTiles(e),this}const S={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=y,this._rotating=x,this._pitching=b,this._padding=w,this._easeId=t.easeId,this._prepareEase(i,t.noMoveStart,S),this._ease(E(o),e=>{"sea"===o.cameraElevationReference&&o.recenterOnTerrain(),this._afterEase(i,e);},t),this}_prepareEase(t,i,o={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&0===this.transform.pitch&&"globe"!==this.transform.projection.name&&(this.transform.cameraElevationReference="ground"),i||o.moving||this.fire(new e.A("movestart",t)),this._zooming&&!o.zooming&&this.fire(new e.A("zoomstart",t)),this._rotating&&!o.rotating&&this.fire(new e.A("rotatestart",t)),this._pitching&&!o.pitching&&this.fire(new e.A("pitchstart",t));}_fireMoveEvents(t){this.fire(new e.A("move",t)),this._zooming&&this.fire(new e.A("zoom",t)),this._rotating&&this.fire(new e.A("rotate",t)),this._pitching&&this.fire(new e.A("pitch",t));}_afterEase(t,i){if(this._easeId&&i&&this._easeId===i)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const o=this._zooming,s=this._rotating,r=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,o&&this.fire(new e.A("zoomend",t)),s&&this.fire(new e.A("rotateend",t)),r&&this.fire(new e.A("pitchend",t)),this.fire(new e.A("moveend",t));}flyTo(t,i){if(this._prefersReducedMotion(t)){const o=e.aI(t,["center","zoom","bearing","pitch","around","padding","retainPadding"]);return this.jumpTo(o,i)}this.stop(),t=Object.assign({offset:[0,0],speed:1.2,curve:1.42,easing:e.eY},t);const o=this.transform,s=this.getZoom(),r=this.getBearing(),n=this.getPitch(),a=this.getPadding(),l="zoom"in t?e.aB(+t.zoom,o.minZoom,o.maxZoom):s,c="bearing"in t?this._normalizeBearing(t.bearing,r):r,h="pitch"in t?+t.pitch:n,d=this._extendPadding(t.padding),u=o.zoomScale(l-s),_=e.P.convert(t.offset);let p=o.centerPoint.add(_);const f=o.pointLocation(p),m=e.aU.convert(t.center||f);this._normalizeCenter(m);const g=o.project(f),v=o.project(m).sub(g);let y=t.curve;const x=Math.max(o.width,o.height),b=x/u,w=v.mag();if("minZoom"in t){const i=e.aB(Math.min(t.minZoom,s,l),o.minZoom,o.maxZoom),r=x/o.zoomScale(i-s);y=Math.sqrt(r/w*2);}const T=y*y;function E(e){const t=(b*b-x*x+(e?-1:1)*T*T*w*w)/(2*(e?b:x)*T*w);return Math.log(Math.sqrt(t*t+1)-t)}function S(e){return (Math.exp(e)-Math.exp(-e))/2}function I(e){return (Math.exp(e)+Math.exp(-e))/2}const C=E(0);let R=function(e){return I(C)/I(C+y*e)},A=function(e){return x*((I(C)*(S(t=C+y*e)/I(t))-S(C))/T)/w;var t;},D=(E(1)-C)/y;if(Math.abs(w)<1e-6||!isFinite(D)){if(Math.abs(x-b)<1e-6)return this.easeTo(t,i);const e=bt.maxDuration&&(t.duration=0);const L=r!==c,P=h!==n,O=!o.isPaddingEqual(d),z=!1===t.retainPadding?o.clone():o,M=o=>u=>{const f=u*D,y=1/R(f);o.zoom=1===u?l:s+o.scaleZoom(y),L&&(o.bearing=e.al(r,c,u)),P&&(o.pitch=e.al(n,h,u)),O&&(z.interpolatePadding(a,d,u),p=z.centerPoint.add(_));const x=1===u?m:o.unproject(g.add(v.mult(A(f))).mult(y));return o.setLocationAtPoint(o.renderWorldCopies?x.wrap():x,p),o._updateCameraOnTerrain(),t.preloadOnly||this._fireMoveEvents(i),o};if(t.preloadOnly){const e=this._emulate(M,t.duration,o);return this._preloadTiles(e),this}return this._zooming=!0,this._rotating=L,this._pitching=P,this._padding=O,this._prepareEase(i,!1),this._ease(M(o),()=>this._afterEase(i),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,i,o){!1===o.animate||0===o.duration?(t(1),i()):(this._easeStart=e.o.now(),this._easeOptions=o,this._onEaseFrame=t,this._onEaseEnd=i,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback));}_renderFrameCallback(){const t=Math.min((e.o.now()-this._easeStart)/this._easeOptions.duration,1),i=this._onEaseFrame;i&&i(this._easeOptions.easing(t)),t<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop();}_normalizeBearing(t,i){t=e.bU(t,-180,180);const o=Math.abs(t-i);return Math.abs(t-360-i)180?-360:i<-180?360:0;}_prefersReducedMotion(t){return this._respectPrefersReducedMotion&&e.o.prefersReducedMotion&&!(t&&t.essential)}_emulate(e,t,i){const o=Math.ceil(15*t/1e3),s=[],r=e(i.clone());for(let e=0;e<=o;e++){const t=r(e/o);s.push(t.clone());}return s}_preloadTiles(e,t){}}class kl{constructor(t={}){this.options=t,e.aZ(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this);}getDefaultPosition(){return "bottom-right"}onAdd(e){const t=this.options&&this.options.compact,i=e._getUIString("AttributionControl.ToggleAttribution");this._map=e,this._container=l("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=l("button","mapboxgl-ctrl-attrib-button",this._container),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._compactButton.setAttribute("aria-label",i);const o=l("span","mapboxgl-ctrl-icon",this._compactButton);return o.setAttribute("aria-hidden","true"),o.setAttribute("title",i),this._innerContainer=l("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;}_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 i=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||e.e.ACCESS_TOKEN}];if(t){const o=i.reduce((e,t,o)=>(t.value&&(e+=`${t.key}=${t.value}${oe.length-t.length),e=e.filter((t,i)=>{for(let o=i+1;o=0)return !1;return !0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=[...this.options.customAttribution,...e]:e.unshift(this.options.customAttribution));const i=e.map(e=>function(e){const t=(new DOMParser).parseFromString(e,"text/html");return Array.from(t.body.querySelectorAll("*")).reverse().forEach(e=>{const i=e.textContent||"";if("A"!==e.tagName)return void e.replaceWith(...e.childNodes);const o=e.getAttribute("href");if(!o||!/^(https?:|mailto:)/i.test(o))return void e.replaceWith(t.createTextNode(i));const s=t.createElement("a");s.href=o,s.textContent=i,s.rel="noopener nofollow";const r=e.getAttribute("class");r&&(s.className=r),e.replaceWith(s);}),t.body.innerHTML}(e)).join(" | ");i!==this._attribHTML&&(this._attribHTML=i,e.length?(this._innerContainer.innerHTML=i,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 Bl{constructor(){e.aZ(["_updateLogo","_updateCompact"],this);}onAdd(e){this._map=e,this._container=l("div","mapboxgl-ctrl");const t=l("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 i=e[t].getSource();if(i.hasOwnProperty("mapbox_logo")&&!i.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 Nl{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,i=t?this._queue.concat(t):this._queue;for(const t of i)if(t.id===e)return void(t.cancelled=!0)}run(e=0){const t=this._currentlyRunning=this._queue;this._queue=[];for(const i of t)if(!i.cancelled&&(i.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1;}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[];}}class Ul{constructor(e){this.jumpTo(e);}getValue(t){if(t<=this._startTime)return this._start;if(t>=this._endTime)return this._end;const i=e.dF((t-this._startTime)/(this._endTime-this._startTime));return this._start*(1-i)+this._end*i}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,i){this._start=this.getValue(t),this._end=e,this._startTime=t,this._endTime=t+i;}}const jl={"AttributionControl.ToggleAttribution":"Toggle attribution","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox homepage","Map.Title":"Map","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use ⌘ + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"};class Vl extends e.A{constructor(e,t,i,o){const{point:s,lngLat:r,originalEvent:n,target:a}=e;super(e.type,{point:s,lngLat:r,originalEvent:n,target:a}),this.preventDefault=()=>{e.preventDefault();},this.id=t,this.interaction=i,this.feature=o;}}class Gl{constructor(e){this.map=e,this.interactionsByType=new Map,this.delegatedInteractions=new Map,this.typeById=new Map,this.filters=new Map,this.handleType=this.handleType.bind(this),this.handleMove=this.handleMove.bind(this),this.handleOut=this.handleOut.bind(this),this.hoveredFeatures=new Map,this.prevHoveredFeatures=new Map;}add(t,i){if(this.typeById.has(t))throw new Error(`Interaction id "${t}" already exists.`);const o=i.filter;let s=i.type;o&&this.filters.set(t,e.b7(o)),"mouseover"===s&&(s="mouseenter"),"mouseout"===s&&(s="mouseleave");const r=this.interactionsByType.get(s)||new Map;"mouseenter"===s||"mouseleave"===s?(0===this.delegatedInteractions.size&&(this.map.on("mousemove",this.handleMove),this.map.on("mouseout",this.handleOut)),this.delegatedInteractions.set(t,i)):0===r.size&&this.map.on(s,this.handleType),0===r.size&&this.interactionsByType.set(s,r),r.set(t,i),this.typeById.set(t,s);}get(e){const t=this.typeById.get(e);if(!t)return;const i=this.interactionsByType.get(t);return i?i.get(e):void 0}remove(e){const t=this.typeById.get(e);if(!t)return;this.typeById.delete(e),this.filters.delete(e);const i=this.interactionsByType.get(t);i&&(i.delete(e),"mouseenter"===t||"mouseleave"===t?(this.delegatedInteractions.delete(e),0===this.delegatedInteractions.size&&(this.map.off("mousemove",this.handleMove),this.map.off("mouseout",this.handleOut))):0===i.size&&this.map.off(t,this.handleType));}queryTargets(e,t){const i=[];for(const[e,o]of t)o.target&&i.push({targetId:e,target:o.target,filter:this.filters.get(e)});return this.map.style.queryRenderedTargets(e,i,this.map.transform)}handleMove(e){this.prevHoveredFeatures=this.hoveredFeatures,this.hoveredFeatures=new Map;const t=this.queryTargets(e.point,Array.from(this.delegatedInteractions).reverse());t.length&&(e.type="mouseenter",this.handleType(e,t));const i=new Map;for(const[e,{feature:t}]of this.prevHoveredFeatures)this.hoveredFeatures.has(e)||i.set(t.id,t);i.size&&(e.type="mouseleave",this.handleType(e,Array.from(i.values())));}handleOut(e){const t=Array.from(this.hoveredFeatures.values()).map(({feature:e})=>e);t.length&&(e.type="mouseleave",this.handleType(e,t)),this.hoveredFeatures.clear();}handleType(t,i){const o="mouseenter"===t.type;if(o&&!this.interactionsByType.has(t.type))return void e.w("mouseenter interaction required for mouseleave to work.");const s=Array.from(this.interactionsByType.get(t.type)).reverse(),r=!!i;i=i||this.queryTargets(t.point,s);let n=!1;const a=new Set;for(const l of i){for(const[i,c]of s){if(!c.target)continue;const s=l.variants?l.variants[i]:null;if(s){for(const h of s){if(vt(h,l,a,i))continue;const s=new e.dA(l,h),d=gt(h,l,i);r&&void 0!==s.id&&(s.state=this.map.getFeatureState(s));const u=o?this.prevHoveredFeatures.get(d):null,_=new Vl(t,i,c,s),p=u?u.stop:c.handler(_);if(o&&this.hoveredFeatures.set(d,{feature:l,stop:p}),!1!==p){n=!0;break}}if(n)break}}if(n)break}if(!n)for(const[e,i]of s){const{handler:o,target:s}=i;if(!s&&!1!==o(new Vl(t,e,i,null)))break}}}function Hl(t,i){if(Array.isArray(t)&&Array.isArray(i)){const e=new Set(t),o=new Set(i);return e.size===o.size&&t.every(e=>o.has(e))}return e.bz(t,i)}const ql={center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:85,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,performanceMetricsCollection:!0,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,antialias:!1,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,minTileCacheSize:null,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,transformRequest:null,accessToken:null,fadeDuration:300,respectPrefersReducedMotion:!0,crossSourceCollisions:!0,collectResourceTiming:!1,testMode:!1,precompilePrograms:!0,scaleFactor:1,spriteFormat:"auto"},Zl={showCompass:!0,showZoom:!0,visualizePitch:!1};class Wl{constructor(t,i,o=!1){this._clickTolerance=10,this.element=i,this.mouseRotate=new al({clickTolerance:t.dragRotate._mouseRotate._clickTolerance}),this.map=t,o&&(this.mousePitch=new ll({clickTolerance:t.dragRotate._mousePitch._clickTolerance})),e.aZ(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),i.addEventListener("mousedown",this.mousedown),i.addEventListener("touchstart",this.touchstart,{passive:!1}),i.addEventListener("touchmove",this.touchmove),i.addEventListener("touchend",this.touchend),i.addEventListener("touchcancel",this.reset);}down(e,t){this.mouseRotate.mousedown(e,t),this.mousePitch&&this.mousePitch.mousedown(e,t),_();}move(e,t){const i=this.map,o=this.mouseRotate.mousemoveWindow(e,t),s=o&&o.bearingDelta;if(s&&i.setBearing(i.getBearing()+s),this.mousePitch){const o=this.mousePitch.mousemoveWindow(e,t),s=o&&o.pitchDelta;s&&i.setPitch(i.getPitch()+s);}}off(){const e=this.element;e.removeEventListener("mousedown",this.mousedown),e.removeEventListener("touchstart",this.touchstart),e.removeEventListener("touchmove",this.touchmove),e.removeEventListener("touchend",this.touchend),e.removeEventListener("touchcancel",this.reset),this.offTemp();}offTemp(){p(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup);}mousedown(e){this.down(Object.assign({},e,{type:e.type,ctrlKey:!0,preventDefault:()=>e.preventDefault()}),g(this.element,e)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup);}mousemove(e){this.move(e,g(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=v(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=v(this.element,e.targetTouches)[0],this.move({buttons:1,preventDefault:()=>e.preventDefault()},this._lastPos));}touchend(e){0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)o.width||i.y>o.height;o.locationPoint3D(s).distSqr(i)180;){const e=o.locationPoint3D(t);if(e.x>=0&&e.y>=0&&e.x<=o.width&&e.y<=o.height)break;t.lng>o.center.lng?t.lng-=360:t.lng+=360;}return t}const Xl={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%)"},Kl={rotation:0,rotationAlignment:"auto",pitchAlignment:"auto",occludedOpacity:.2,altitude:0};class Yl extends e.E{constructor(t,i){super(),(t instanceof HTMLElement||i)&&(t=Object.assign({element:t},i)),e.aZ(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this);const{anchor:o="center",color:s="#3FB1CE",scale:r=1,draggable:n=!1,clickTolerance:a=0,rotation:l=Kl.rotation,rotationAlignment:c=Kl.rotationAlignment,pitchAlignment:h=Kl.pitchAlignment,occludedOpacity:d=Kl.occludedOpacity,altitude:u=Kl.altitude}=t||{};this._anchor=o,this._color=s,this._scale=r,this._draggable=n,this._clickTolerance=a,this._rotation=l,this._rotationAlignment=c,this._pitchAlignment=h,this._occludedOpacity=d,this._altitude=u,this._state="inactive",this._isDragging=!1,this._updateMoving=()=>this._update(!0),t&&t.element?(this._element=t.element,this._offset=e.P.convert(t&&t.offset||[0,0])):(this._defaultMarker=!0,this._element=this._createDefaultMarker(),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 _=this._element.classList;for(const e in Xl)_.remove(`mapboxgl-marker-anchor-${e}`);_.add(`mapboxgl-marker-anchor-${this._anchor}`);const p=t&&t.className?t.className.trim().split(/\s+/):[];_.add(...p),this._popup=null;}_createDefaultMarker(){const e=l("div"),t=c("svg",{display:"block",height:41*this._scale+"px",width:27*this._scale+"px",viewBox:"0 0 27 41"},e);if(0===this._altitude){const e=c("radialGradient",{id:"shadowGradient"},c("defs",{},t));c("stop",{offset:"10%","stop-opacity":.4},e),c("stop",{offset:"100%","stop-opacity":.05},e),c("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},t);}return c("path",{fill:this._color,d:"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z"},t),c("path",{opacity:.25,d:"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z"},t),c("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},t),e}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.aU.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}setAltitude(e){return e===this._altitude||(this._defaultMarker&&(0===this._altitude&&0!==e||0!==this._altitude&&0===e)&&(this._element=this._createDefaultMarker()),this._altitude=e||Kl.altitude,this._update()),this}getAltitude(){return this._altitude}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,i=13.5,o=Math.sqrt(Math.pow(i,2)/2);e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-t],"bottom-left":[o,-1*(t-i+o)],"bottom-right":[-o,-1*(t-i+o)],left:[i,-1*(t-i)],right:[-i,-1*(t-i)]}:this._offset;}this._popup=e,e._marker=this,e._altitude=this._altitude,this._lngLat&&this._popup.setLngLat(this._lngLat),this._element.setAttribute("role","button"),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress),this._element.setAttribute("aria-expanded","false");}return this}_onKeyPress(e){const t=e.code,i=e.charCode||e.keyCode;"Space"!==t&&"Enter"!==t&&32!==i&&13!==i||this.togglePopup();}_onMapClick(e){const t=e.originalEvent.target,i=this._element;this._popup&&(t===i||i.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 i=e.unproject(t,this._altitude),o=e.getFreeCameraOptions();if(!o.position)return !1;const s=o.position.toLngLat();return s.distanceTo(i)<.9*s.distanceTo(this._lngLat)}_evaluateOpacity(){const t=this._map;if(!t)return;const i=this._pos;if(!i||i.x<0||i.x>t.transform.width||i.y<0||i.y>t.transform.height)return void this._clearFadeTimer();const o=t.unproject(i,this._altitude);let s;t._showingGlobe()&&e.f8(t.transform,this._lngLat)?s=0:(s=1-t._queryFogOpacity(o),t.transform._terrainEnabled()&&t.getTerrain()&&this._behindTerrain()&&(s*=this._occludedOpacity)),this._element.style.opacity=`${s}`,this._element.style.pointerEvents=s>0?"auto":"none",this._popup&&this._popup._setOpacity(s),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 ${Xl[this._anchor]}\n ${this._calculateXYTransform()} ${this._calculateZTransform()}\n translate(${t.x}px,${t.y}px)\n `;}_calculateXYTransform(){const t=this._pos,i=this._map,o=this.getPitchAlignment();if(!i||!t||"map"!==o)return "";if(!i._showingGlobe()){const e=i.getPitch();return e?`rotateX(${e}deg)`:""}const s=e.cY(e.f9(i.transform,this._lngLat)),r=t.sub(e.fa(i.transform)),n=Math.abs(r.x)+Math.abs(r.y);if(0===n)return "";const a=s/n;return `rotateX(${-r.y*a}deg) rotateY(${r.x*a}deg)`}_calculateZTransform(){const t=this._pos,i=this._map;if(!i||!t)return "";let o=0;const s=this.getRotationAlignment();if("map"===s)if(i._showingGlobe()){const t=i.project(new e.aU(this._lngLat.lng,this._lngLat.lat+.001),this._altitude),s=i.project(new e.aU(this._lngLat.lng,this._lngLat.lat-.001),this._altitude).sub(t);o=e.cY(Math.atan2(s.y,s.x))-90;}else o=-i.getBearing();else if("horizon"===s){const s=e.ai(4,6,i.getZoom()),r=e.fa(i.transform);r.y+=s*i.transform.height;const n=t.sub(r),a=e.cY(Math.atan2(n.y,n.x));o=(a>90?a-270:a+90)*(1-s);}return o+=this._rotation,o?`rotateZ(${o}deg)`:""}_update(e){cancelAnimationFrame(this._updateFrameId);const t=this._map;t&&(t.transform.renderWorldCopies&&(this._lngLat=$l(this._lngLat,this._pos,t.transform)),this._pos=t.project(this._lngLat,this._altitude),!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=window.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 i=this._map;if(!i)return;const o=this._pointerdownPos,s=this._positionDelta;if(o&&s){if(!this._isDragging){const e=this._clickTolerance||i._clickTolerance;if(t.point.dist(o)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.f6(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 ao(t.minZoom,t.maxZoom,t.minPitch,t.maxPitch,t.renderWorldCopies,null,null),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 Nl,this._domRenderTaskQueue=new Nl,this._controls=[],this._markers=[],this._popups=[],this._mapId=e.b3(),this._locale=Object.assign({},jl,t.locale),this._clickTolerance=t.clickTolerance,this._cooperativeGestures=t.cooperativeGestures,this._performanceMetricsCollection=t.performanceMetricsCollection,this._tessellationStep=t.tessellationStep,this._containerWidth=0,this._containerHeight=0,this._showParseStatus=!0,this._precompilePrograms=t.precompilePrograms,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new Ul(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._frameId=0,this._scaleFactor=t.scaleFactor,this._requestManager=new T(t.transformRequest,t.accessToken,t.testMode),this._silenceAuthErrors=!!t.testMode,this._contextCreateOptions=t.contextCreateOptions?Object.assign({},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),this._spriteFormat=t.spriteFormat,e.aZ(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),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 zl(this,t),this._localFontFamily=t.localFontFamily,this._localIdeographFontFamily=t.localIdeographFontFamily,(t.style||!t.testMode)&&this.setStyle(t.style||e.e.DEFAULT_STYLE,{config:t.config,localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),t.projection&&this.setProjection(t.projection),t.hash&&(this._hash=new Ma("string"==typeof t.hash&&t.hash||void 0).addTo(this)),!this._hash||!this._hash._onHashChange()){null==s.center&&null==s.zoom||(this.transform._unmodified=!1),this.jumpTo({center:t.center,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch});const e=t.bounds;e&&(this.resize(),this.fitBounds(e,Object.assign({},t.fitBoundsOptions,{duration:0})));}this.resize(),t.attributionControl&&this.addControl(new kl({customAttribution:t.customAttribution})),this._logoControl=new Bl,this.addControl(this._logoControl,t.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet),this._postStyleLoadEvent(),this._postStyleWithAppearanceEvent();}),this.on("data",t=>{this._update("style"===t.dataType),this.fire(new e.A(`${t.dataType}data`,t));}),this.on("dataloading",t=>{this.fire(new e.A(`${t.dataType}dataloading`,t));}),this._interactions=new Gl(this);}_getMapId(){return this._mapId}addControl(t,i){if(void 0===i&&(i=t.getDefaultPosition?t.getDefaultPosition():"top-right"),!t||!t.onAdd)return this.fire(new e.z(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const o=t.onAdd(this);this._controls.push(t);const s=this._controlPositions[i];return -1!==i.indexOf("bottom")?s.insertBefore(o,s.firstChild):s.appendChild(o),this}removeControl(t){if(!t||!t.onRemove)return this.fire(new e.z(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const i=this._controls.indexOf(t);return i>-1&&this._controls.splice(i,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 i=!this._moving;return i&&this.fire(new e.A("movestart",t)).fire(new e.A("move",t)),this.fire(new e.A("resize",t)),i&&this.fire(new e.A("moveend",t)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(t){return this.transform.setMaxBounds(e.aJ.convert(t)),this._update()}setMinZoom(t){if((t=t??-2)>=-2&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t?this.setZoom(t):this.fire(new e.A("zoomstart")).fire(new e.A("zoom")).fire(new e.A("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(t){if((t=t??0)<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()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.A("pitchstart")).fire(new e.A("pitch")).fire(new e.A("pitchend")),this;throw new Error("maxPitch must be greater than or equal to minPitch")}getMaxPitch(){return this.transform.maxPitch}getScaleFactor(){return this._scaleFactor}setScaleFactor(e){return this._scaleFactor=e,this.painter.scaleFactor=e,this.style&&this.style._setLabelPlacementStale(),this.style._updateFilteredLayers(e=>"symbol"===e.type),this._update(!0),this}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._styleDirty=!0,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,i=t.projection.name;let o;"globe"===i&&t.zoom>=e.cM?(t.setMercatorFromTransition(),o=!0):"mercator"===i&&t.zoom=e.cM?this.transform.setMercatorFromTransition():this.transform.setProjection(t),this.style.applyProjectionUpdate();const s="mercator"===this.transform.getProjection().name&&o!==this.transform.mercatorFromTransition;return (i||s)&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}project(t,i){return this.transform.locationPoint3D(e.aU.convert(t),i)}unproject(t,i){return this.transform.pointLocation3D(e.P.convert(t),i)}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,i){const o=e=>{let i=[];if(Array.isArray(t)){const o=t.filter(e=>this.getLayer(e));i=o.length?this.queryRenderedFeatures(e,{layers:o}):[];}else i=this.queryRenderedFeatures(e,{target:t});return i};if("mouseenter"===e||"mouseover"===e){let s=!1;const r=t=>{const r=o(t.point);r.length?s||(s=!0,i.call(this,new qa(e,this,t.originalEvent,{features:r}))):s=!1;};return {listener:i,targets:t,delegates:{mousemove:r,mouseout:()=>{s=!1;}}}}if("mouseleave"===e||"mouseout"===e){let s=!1;const r=t=>{o(t.point).length?s=!0:s&&(s=!1,i.call(this,new qa(e,this,t.originalEvent)));},n=t=>{s&&(s=!1,i.call(this,new qa(e,this,t.originalEvent)));};return {listener:i,targets:t,delegates:{mousemove:r,mouseout:n}}}{const s=e=>{const t=o(e.point);t.length&&(e.features=t,i.call(this,e),delete e.features);};return {listener:i,targets:t,delegates:{[e]:s}}}}on(e,t,i){if("function"==typeof t||void 0===i)return super.on(e,t);if("string"==typeof t&&(t=[t]),!this._areTargetsValid(t))return this;const o=this._createDelegatedListener(e,t,i);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(o);for(const e in o.delegates)this.on(e,o.delegates[e]);return this}once(e,t,i){if("function"==typeof t||void 0===i)return super.once(e,t);if("string"==typeof t&&(t=[t]),!this._areTargetsValid(t))return this;const o=this._createDelegatedListener(e,t,i);for(const e in o.delegates)this.once(e,o.delegates[e]);return this}off(e,t,i){if("function"==typeof t||void 0===i)return super.off(e,t);if("string"==typeof t&&(t=[t]),!this._areTargetsValid(t))return this;const o=this._delegatedListeners?this._delegatedListeners[e]:void 0;return o&&(e=>{for(let o=0;o{if(o){const s="string"==typeof o?o:o instanceof Error?o.message:o.error;e.w(`Unable to perform style diff: ${s}. Rebuilding the style from scratch.`),this._updateStyle(t,i);}else s&&this._update(!0);},()=>this._postStyleLoadEvent()),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._localFontFamily=i.localFontFamily,this._updateStyle(t,i))}_getUIString(e){const t=this._locale[e];if(null==t)throw new Error(`Missing UI string '${e}'`);return t}_updateStyle(e,t){if(this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),e){const i=Object.assign({},t);t&&t.config&&(i.initialConfig=t.config,delete i.config),this.style=new Po(this,i).load(e),this.style.setEventedParent(this,{style:this.style});}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new Po(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.z(new Error("IDs can't be empty."))),!1):!e.du(t)||(this.fire(new e.z(new Error(`IDs can't contain special symbols: "${t}".`))),!1)}_isTargetValid(e){return "featuresetId"in e?this._isValidId("importId"in e?e.importId:e.featuresetId):"layerId"in e&&this._isValidId(e.layerId)}_areTargetsValid(e){if(Array.isArray(e)){for(const t of e)if(!this._isValidId(t))return !1;return !0}return this._isTargetValid(e)}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,i){this._lazyInitEmptyStyle(),this.style.addSourceType(e,t,i);}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,i,{pixelRatio:o=1,sdf:s=!1,stretchX:r,stretchY:n,content:a}={}){this._lazyInitEmptyStyle();const l=e.I.from(t);if(i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap){const{width:t,height:c,data:h}=e.o.getImageData(i);this.style.addImage(l,{data:new e.q({width:t,height:c},h),pixelRatio:o,stretchX:r,stretchY:n,content:a,sdf:s,version:0,usvg:!1});}else if(void 0===i.width||void 0===i.height)this.fire(new e.z(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:c,height:h}=i,d=i;this.style.addImage(l,{data:new e.q({width:c,height:h},new Uint8Array(d.data)),pixelRatio:o,stretchX:r,stretchY:n,content:a,sdf:s,usvg:!1,version:0,userImage:d}),d.onAdd&&d.onAdd(this,t);}}updateImage(t,i){this._lazyInitEmptyStyle();const o=e.I.from(t),s=this.style.getImage(o);if(!s)return void this.fire(new e.z(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const r=i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap?e.o.getImageData(i):i,{width:n,height:a,data:l}=r;if(void 0===n||void 0===a)return void this.fire(new e.z(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(n!==(s.usvg?s.icon.usvg_tree.width:s.data.width)||a!==(s.usvg?s.icon.usvg_tree.height:s.data.height))return void this.fire(new e.z(new Error(`The width and height of the updated image (${n}, ${a})\n must be that same as the previous version of the image\n (${s.data.width}, ${s.data.height})`)));const c=!(i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap);let h=!1;s.usvg?(s.data=new e.q({width:n,height:a},new Uint8Array(l)),s.usvg=!1,s.icon=void 0,h=!0):s.data.replace(l,c),this.style.updateImage(o,s,h);}hasImage(t){return t?!!this.style&&!!this.style.getImage(e.I.from(t)):(this.fire(new e.z(new Error("Missing required image id"))),!1)}removeImage(t){this.style.removeImage(e.I.from(t));}loadImage(t,i){e.n(this._requestManager.transformRequest(t,e.R.Image),(e,t)=>{i(e,t);});}listImages(){return this.style.listImages().map(e=>e.name)}addModel(e,t){this._lazyInitEmptyStyle(),this.style.addModel(e,t);}hasModel(t){return t?this.style.hasModel(t):(this.fire(new e.z(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(t,i){return this.style.addImport(t,i).catch(t=>this.fire(new e.z(new Error("Failed to add import",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){if(!this._isValidId(e))return null;const t=this.style.getOwnLayer(e);return t?"custom"===t.type?t.implementation:t.serialize():void 0}getSlots(){return this.style.getSlots()}setLayerZoomRange(e,t,i){return this._isValidId(e)?(this.style.setLayerZoomRange(e,t,i),this._update(!0)):this}setFilter(e,t,i={}){return this._isValidId(e)?(this.style.setFilter(e,t,i),this._update(!0)):this}getFilter(e){return this._isValidId(e)?this.style.getFilter(e):null}setPaintProperty(e,t,i,o={}){return this._isValidId(e)?(this.style.setPaintProperty(e,t,i,o),this._update(!0)):this}getPaintProperty(e,t){return this._isValidId(e)?this.style.getPaintProperty(e,t):null}setLayoutProperty(e,t,i,o={}){return this._isValidId(e)?(this.style.setLayoutProperty(e,t,i,o),this._update(!0)):this}getLayoutProperty(e,t){return this._isValidId(e)?this.style.getLayoutProperty(e,t):null}setLayerProperty(e,t,i,o={}){return this._isValidId(e)?("appearances"===t&&this._postAddingAppearancesToStyleEvent(),this.style.setLayerProperty(e,t,i,o),this._update(!0)):this}getGlyphsUrl(){return this.style.getGlyphsUrl()}setGlyphsUrl(e){return this.style.setGlyphsUrl(e),this._update(!0)}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,i){return this.style.setConfigProperty(e,t,i),this._update(!0)}getFeaturesetDescriptors(e){return this.style.getFeaturesetDescriptors(e)}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}setSnow(e){return this._lazyInitEmptyStyle(),this.style.setSnow(e),this._update(!0)}getSnow(){return this.style?this.style.getSnow():null}setRain(e){return this._lazyInitEmptyStyle(),this.style.setRain(e),this._update(!0)}getRain(){return this.style?this.style.getRain():null}setColorTheme(e){return this._lazyInitEmptyStyle(),this.style.setColorTheme(e),this._update(!0)}setImportColorTheme(e,t){return this._lazyInitEmptyStyle(),this.style.setImportColorTheme(e,t),this._update(!0)}setCamera(e){return this.style.setCamera(e),this._triggerCameraUpdate(e)}getNearClipOffset(){return this.transform.nearClipOffset}setNearClipOffset(e){const t=this.transform.nearClipOffset!==e;return this.transform.nearClipOffset=e,this._update(t)}_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.aU.convert(t),this.transform):0}setFeatureState(e,t){return e.source&&!this._isValidId(e.source)?this:(this.style.setFeatureState(e,t),this._update())}removeFeatureState(e,t){return e.source&&!this._isValidId(e.source)?this:(this.style.removeFeatureState(e,t),this._update())}getFeatureState(e){return e.source&&!this._isValidId(e.source)?null:this.style.getFeatureState(e)}_selectIndoorFloor(e){this.style.indoorManager.selectFloor(e);}_setIndoorActiveFloorsVisibility(e){this.style.indoorManager.setActiveFloorsVisibility(e);}getIndoorTileOptions(e,t){return this.style.isIndoorEnabled()?this.style.indoorManager.getIndoorTileOptions(e,t):null}_updateContainerDimensions(){if(!this._container)return;const e=this._container.getBoundingClientRect().width||400,t=this._container.getBoundingClientRect().height||300;let i,o,s,r=this._container;for(;r&&(!o||!s);){const e=window.getComputedStyle(r).transform;e&&"none"!==e&&(i=e.match(/matrix.*\((.+)\)/)[1].split(", "),i[0]&&"0"!==i[0]&&"1"!==i[0]&&(o=i[0]),i[3]&&"0"!==i[3]&&"1"!==i[3]&&(s=i[3])),r=r.parentElement;}this._containerWidth=o?Math.abs(e/o):e,this._containerHeight=s?Math.abs(t/s):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=l("div","mapboxgl-canary",e)).style.visibility="hidden",this._detectMissingCSS();const t=this._canvasContainer=l("div","mapboxgl-canvas-container",e);this._canvas=l("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 i=this._controlContainer=l("div","mapboxgl-control-container",e),o=this._controlPositions={};["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"].forEach(e=>{o[e]=l("div",`mapboxgl-ctrl-${e}`,i);}),this._container.addEventListener("scroll",this._onMapScroll,!1);}_resizeCanvas(t,i){const o=e.o.devicePixelRatio||1;this._canvas.width=o*Math.ceil(t),this._canvas.height=o*Math.ceil(i),this._canvas.style.width=`${t}px`,this._canvas.style.height=`${i}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=Object.assign({},a.supported.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),i=this._canvas.getContext("webgl2",t);i?(Z(i,!0),this.painter=new Oa(i,this._contextCreateOptions,this.transform,this._scaleFactor,this._worldview),this.on("data",e=>{if("source"===e.dataType){const t=this.transform.elevation?this.transform.elevation._source():null;t&&e.sourceCacheId===t.id&&this.style&&this.style._setLabelPlacementStale(),this.painter.setTileLoadedFlag(!0);}}),e.k.testSupport(i)):this.fire(new e.z(new Error("Failed to initialize WebGL")));}_contextLost(t){t.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new e.A("webglcontextlost",{originalEvent:t}));}_contextRestored(t){this._setupPainter(),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight)),this._updateTerrain(),this.style&&(this.style.clearLayers(),this.style.imageManager.destroyAtlasTextures(),this.style.imageManager.imageAtlasCache.destroyTextures(),this.style.reloadModels(),this.style.clearSources()),this._update(),this.fire(new e.A("webglcontextrestored",{originalEvent:t}));}_onMapScroll(e){if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}idle(){return !this.isMoving()&&this.loaded()}loaded(){return !this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}frameReady(){return this.loaded()&&!this._placementDirty}_update(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 s;this.fire(new e.A("renderstart")),++this._frameId;const r=this.painter.context.extTimerQuery,n=e.o.now(),a=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(s=a.createQuery(),a.beginQuery(r.TIME_ELAPSED_EXT,s)),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 l=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const t=this.transform.zoom,i=this.transform.pitch,o=e.o.now(),s=new e.ad(t,{now:o,fadeDuration:l,pitch:i,transition:this.style.transition,worldview:this._worldview});this.style.update(s);}this.style&&this.style.hasFogTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let c=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),c=this._updateAverageElevation(n),this.style.updateSources(this.transform),this.style.updateImageProviders(),this.isMoving()||this._forceMarkerAndPopupUpdate()):c=this._updateAverageElevation(n),this.style&&(this._placementDirty=this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,l,this._crossSourceCollisions,this.painter.replacementSource)),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:l,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.A("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,o.mark(i.load),this.fire(new e.A("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&(this.style.snow||this.style.rain)&&(this._styleDirty=!0),this.style&&this.style.imageManager.hasPatternsInFlight()&&(this._styleDirty=!0),this.style&&!this.style.modelManager.isLoaded()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),s){const t=e.o.now()-n;a.endQuery(r.TIME_ELAPSED_EXT),setTimeout(()=>{const i=a.getQueryParameter(s,a.QUERY_RESULT)/1e6;a.deleteQuery(s),this.fire(new e.A("gpu-timing-frame",{cpuTime:t,gpuTime:i}));},50);}if(this.listens("gpu-timing-layer")){const t=this.painter.collectGpuTimers();setTimeout(()=>{const i=this.painter.queryGpuTimers(t);this.fire(new e.A("gpu-timing-layer",{layerTimes:i}));},50);}if(this.listens("gpu-timing-deferred-render")){const t=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{const i=this.painter.queryGpuTimeDeferredRender(t);this.fire(new e.A("gpu-timing-deferred-render",{gpuTime:i}));},50);}const h=this._sourcesDirty||this._styleDirty||this._placementDirty||c;if(h||this._repaint)this.triggerRepaint();else {const t=this.idle();if(t&&(c=this._updateAverageElevation(n,!0)),c)this.triggerRepaint();else if(this._triggerFrame(!1),t&&(this.fire(new e.A("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const t=this._calculateSpeedIndex();this.fire(new e.A("speedindexcompleted",{speedIndex:t})),this.speedIndexTiming=!1;}}!this._loaded||this._fullyLoaded||h||(this._fullyLoaded=!0,o.mark(i.fullLoad),this._performanceMetricsCollection&&V(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 i=e=>(this.transform.averageElevation=e,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&i(0);const o=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(o||(t||e-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(e)){const t=this.transform.averageElevation;let s=this.transform.sampleAverageElevation();null!=this.transform.elevation&&(this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(s)?s=0:this._averageElevationLastSampledAt=e;const r=Math.abs(t-s);if(r>1){if(this._isInitialLoad||o)return this._averageElevation.jumpTo(s),i(s);this._averageElevation.easeTo(s,e,300);}else if(r>1e-4)return this._averageElevation.jumpTo(s),i(s)}return !!this._averageElevation.isEasing(e)&&i(this._averageElevation.getValue(e))}_authenticate(){H(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,t=>{if(t&&(t.message===w||401===t.status)){const t=this.painter.context.gl;Z(t,!1),this._logoControl instanceof Bl&&this._logoControl._updateLogo(),t&&t.clear(t.DEPTH_BUFFER_BIT|t.COLOR_BUFFER_BIT|t.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new e.z(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/")));}}),z(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{});}_postStyleLoadEvent(){this.style.globalId&&F(this._requestManager._customAccessToken,{map:this,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()});}_postStyleWithAppearanceEvent(){this.style.globalId&&this.style.hasAppearances()&&B(this._requestManager._customAccessToken);}_postAddingAppearancesToStyleEvent(){U(this._requestManager._customAccessToken);}_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 i=this.painter.context.gl,o=i.createFramebuffer();function s(e){i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,e,0);const t=new Uint8Array(i.drawingBufferWidth*i.drawingBufferHeight*4);return i.readPixels(0,0,i.drawingBufferWidth,i.drawingBufferHeight,i.RGBA,i.UNSIGNED_BYTE,t),t}return i.bindFramebuffer(i.FRAMEBUFFER,o),this._canvasPixelComparison(s(e),t.canvasCopies.map(s),t.timeStamps)}_canvasPixelComparison(e,t,i){let o=i[1]-i[0];const s=e.length/4;for(let r=0;r{const t=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,t&&this._render(e);}));}_preloadTiles(t){const i=this.style?this.style.getSourceCaches():[];return e.bx(i,(e,i)=>e._preloadTiles(t,i),()=>{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._update());}get showParseStatus(){return !!this._showParseStatus}set showParseStatus(e){this._showParseStatus!==e&&(this._showParseStatus=e,this._update());}get showTerrainWireframe(){return !!this._showTerrainWireframe}set showTerrainWireframe(e){this._showTerrainWireframe!==e&&(this._showTerrainWireframe=e,this._update());}get showLayers2DWireframe(){return !!this._showLayers2DWireframe}set showLayers2DWireframe(e){this._showLayers2DWireframe!==e&&(this._showLayers2DWireframe=e,this._update());}get showLayers3DWireframe(){return !!this._showLayers3DWireframe}set showLayers3DWireframe(e){this._showLayers3DWireframe!==e&&(this._showLayers3DWireframe=e,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._update());}get showCollisionBoxes(){return !!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,this.style&&e?this.style._generateCollisionBoxes():this._update());}get showOverdrawInspector(){return !!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._update());}get repaint(){return !!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this.triggerRepaint());}get vertices(){return !!this._vertices}set vertices(e){this._vertices=e,this._update();}get showTileAABBs(){return !!this._showTileAABBs}set showTileAABBs(e){this._showTileAABBs!==e&&(this._showTileAABBs=e,e&&this._update());}_setCacheLimits(t,i){e.f7(t,i);}get version(){return t}},NavigationControl:class{constructor(t={}){this.options=Object.assign({},Zl,t),this._container=l("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",e=>e.preventDefault()),this.options.showZoom&&(e.aZ(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",e=>{this._map&&this._map.zoomIn({},{originalEvent:e});}),l("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});}),l("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(e.aZ(["_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=l("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"));}_updateZoomButtons(){const e=this._map;if(!e)return;const t=e.getZoom(),i=t===e.getMaxZoom(),o=t===e.getMinZoom();this._zoomInButton.disabled=i,this._zoomOutButton.disabled=o,this._zoomInButton.setAttribute("aria-disabled",i.toString()),this._zoomOutButton.setAttribute("aria-disabled",o.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 Wl(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 i=l("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}_setButtonTitle(e,t){if(!this._map)return;const i=this._map._getUIString(`NavigationControl.${t}`);e.setAttribute("aria-label",i),e.firstElementChild&&e.firstElementChild.setAttribute("title",i);}},GeolocateControl:class extends e.E{constructor(t={}){super();const i=navigator.geolocation;this.options=Object.assign({geolocation:i},Jl,t),e.aZ(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=za(this._updateMarkerRotation,20),this._numberOfWatches=0;}onAdd(e){return this._map=e,this._container=l("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){this._clearRequestTimeout(),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(),i=e.coords;return !!t&&(i.longitudet.getEast()||i.latitudet.getNorth())}_setErrorState(){switch(this._watchState){case "WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case "ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");break;case "BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");}}_onSuccess(t){if(this._map){if(this._clearRequestTimeout(),this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new e.A("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._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this.options.followUserLocation?(this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active")):(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"));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.followUserLocation&&(!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.A("geolocate",Object.assign({coords:t.coords,timestamp:t.timestamp},t.toJSON?{toJSON:t.toJSON.bind(t)}:{}))),this._finish();}}_updateCamera(t){const i=new e.aU(t.coords.longitude,t.coords.latitude),o=t.coords.accuracy,s=this._map.getBearing(),r=Object.assign({bearing:s},this.options.fitBoundsOptions);this._map.fitBounds(i.toBounds(o),r,{geolocateSource:!0});}_updateMarker(t){if(t){const i=new e.aU(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=t.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius();}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove();}_updateCircleRadius(){const t=this._map.transform,i=e.cg(1,t._center.lat)*t.worldSize,o=Math.ceil(2*this._accuracy*i);this._circleElement.style.width=`${o}px`,this._circleElement.style.height=`${o}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._clearRequestTimeout(),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.A("error",{code:t.code,message:t.message,PERMISSION_DENIED:t.PERMISSION_DENIED,POSITION_UNAVAILABLE:t.POSITION_UNAVAILABLE,TIMEOUT:t.TIMEOUT})),this._finish();}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0;}_startRequestTimeout(){this._clearRequestTimeout();const e=this.options.positionOptions.timeout;e&&(this._requestTimeoutId=window.setTimeout(()=>{this._onError({code:3,message:"Geolocation request timed out"});},e));}_clearRequestTimeout(){void 0!==this._requestTimeoutId&&(clearTimeout(this._requestTimeoutId),this._requestTimeoutId=void 0);}_setupUI(t){if(void 0!==this._map){if(this._container.addEventListener("contextmenu",e=>e.preventDefault()),this._geolocateButton=l("button","mapboxgl-ctrl-geolocate",this._container),l("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=l("div","mapboxgl-user-location"),this._dotElement.appendChild(l("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(l("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new Yl({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=l("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Yl({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.showButton||(this._container.style.display="none"),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.A("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.A("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.A("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.A("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._startRequestTimeout(),this.options.showUserHeading&&this._addDeviceOrientationListener();}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._startRequestTimeout(),this._timeoutId=window.setTimeout(this._finish,1e4);return !0}setFollowUserLocation(t){return this.options.followUserLocation=null!=t?t:Jl.followUserLocation,this.options.trackUserLocation&&"OFF"!==this._watchState&&(this.options.followUserLocation?"BACKGROUND"!==this._watchState&&"BACKGROUND_ERROR"!==this._watchState||(this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new e.A("trackuserlocationstart"))):"ACTIVE_LOCK"!==this._watchState&&"ACTIVE_ERROR"!==this._watchState||(this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this.fire(new e.A("trackuserlocationend")))),this}_addDeviceOrientationListener(){const e=()=>{const e="ondeviceorientationabsolute"in window?"deviceorientationabsolute":"deviceorientation";window.addEventListener(e,this._onDeviceOrientation);};"function"==typeof DeviceOrientationEvent.requestPermission?DeviceOrientationEvent.requestPermission().then(t=>{"granted"===t&&e();}).catch(console.error):e();}_clearWatch(){this._clearRequestTimeout(),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:kl,ScaleControl:class{constructor(t={}){this.options=Object.assign({},Ql,t),e.aZ(["_update","_setScale","setUnit"],this);}getDefaultPosition(){return "bottom-left"}_update(){const e=this.options.maxWidth||100,t=this._map,i=t._containerHeight/2,o=t._containerWidth/2-e/2,s=t.unproject([o,i]),r=t.unproject([o+e,i]),n=s.distanceTo(r);if("imperial"===this.options.unit){const t=3.2808*n;t>5280?this._setScale(e,t/5280,"mile"):this._setScale(e,t,"foot");}else "nautical"===this.options.unit?this._setScale(e,n/1852,"nautical-mile"):n>=1e3?this._setScale(e,n/1e3,"kilometer"):this._setScale(e,n,"meter");}_setScale(e,t,i){this._map._requestDomTask(()=>{const o=function(e){const t=Math.pow(10,`${Math.floor(e)}`.length-1);let i=e/t;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(e){const t=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*t)/t}(i),t*i}(t),s=o/t;this._container.innerHTML="nautical-mile"!==i?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:i}).format(o):`${o} ${ec[i]}`,this._container.style.width=e*s+"px";});}onAdd(e){return this._map=e,this._language=e.getLanguage(),this._container=l("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.aZ(["_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=l("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=l("button","mapboxgl-ctrl-fullscreen",this._controlContainer);l("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();}},IndoorControl:class{constructor(){e.aZ(["_onIndoorUpdate","_onStyleData","_scrollUp","_scrollDown","_toggleIndoor"],this),this._visibleFloorStart=0,this._lastSelectedFloorId=null;}onAdd(e){return this._map=e,this._container=l("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.style.display="none",this._map.on("styledata",this._onStyleData),this._updateConnection(),this._container}_onStyleData(){this._updateConnection();}_updateConnection(){if(this._map&&this._map.style&&this._map.style.indoorManager){const e=this._map.style.indoorManager;e.off("selector-update",this._onIndoorUpdate),e.on("selector-update",this._onIndoorUpdate),this._onIndoorUpdate(e.getControlState());}}_createButton(e,t){const i=l("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}_setButtonTitle(e,t){e.setAttribute("aria-label",t),e.textContent=t;}onRemove(){this._container&&this._container.remove(),this._map&&(this._map.off("styledata",this._onStyleData),this._map.style&&this._map.style.indoorManager.off("selector-update",this._onIndoorUpdate),this._map=null);}getDefaultPosition(){return "top-right"}_onIndoorUpdate(e){if(!e||!e.floors||0===e.floors.length)return this._model=e,void(this._container.style.display="none");const t=this._model;this._model=e,this._container.style.display="inline-block";const i=!t||t.floors.length!==e.floors.length||t.floors.some((t,i)=>t.id!==e.floors[i].id);if(i&&(this._visibleFloorStart=0,this._lastSelectedFloorId=null),e.selectedFloorId){if(e.selectedFloorId!==this._lastSelectedFloorId||i){const t=e.floors.findIndex(t=>t.id===e.selectedFloorId);if(-1!==t){const i=e.floors.length;let o,s;i<=5?(o=0,s=i-1):0===this._visibleFloorStart?(o=0,s=3):this._visibleFloorStart>=i-3?(o=i-3-1,s=i-1):(o=this._visibleFloorStart,s=this._visibleFloorStart+3-1),ts&&(this._visibleFloorStart=t-2);}}this._lastSelectedFloorId=e.selectedFloorId;}this._render();}_render(){if(!this._container||!this._model||!this._model.floors)return;this._container.innerHTML="";const e=this._createButton("mapboxgl-ctrl-indoor-toggle",this._toggleIndoor);l("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),this._model.activeFloorsVisible||e.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.appendChild(e);const t=this._model.floors,i=t.length;if(i<=5)return void t.forEach(e=>this._createFloorButton(e));const o=0===this._visibleFloorStart,s=this._visibleFloorStart>=i-3;if(o)this._createFloorButton(t[0]);else {const e=this._createButton("mapboxgl-ctrl-arrow-up",this._scrollUp);l("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),this._container.appendChild(e);}let r=[];if(r=o?t.slice(1,4):s?t.slice(this._visibleFloorStart-1,this._visibleFloorStart+3-1):t.slice(this._visibleFloorStart,this._visibleFloorStart+3),r.forEach(e=>this._createFloorButton(e)),s)this._createFloorButton(t[i-1]);else {const e=this._createButton("mapboxgl-ctrl-arrow-down",this._scrollDown);l("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),this._container.appendChild(e);}}_createFloorButton(e){const t=this._createButton("mapboxgl-ctrl-level-button",()=>{const t=e.id;this._model&&this._model.selectedFloorId===t&&this._model.activeFloorsVisible||this._map&&(this._model&&!this._model.activeFloorsVisible&&this._map.style&&this._map.style.indoorManager&&this._map.style.indoorManager.setActiveFloorsVisibility(!0),this._map._selectIndoorFloor(t));}),i=(e.name||"").trim(),o=e.zIndex.toString(),s=i?Array.from(i).slice(0,3).join(""):o;this._setButtonTitle(t,s),this._model&&this._model.activeFloorsVisible&&e.id===this._model.selectedFloorId&&t.classList.add("mapboxgl-ctrl-level-button-selected"),this._container&&this._container.appendChild(t);}_toggleIndoor(){this._map&&this._map.style&&this._map.style.indoorManager&&this._model&&this._model.activeFloorsVisible&&this._map.style.indoorManager.setActiveFloorsVisibility(!1);}_scrollUp(){if(this._visibleFloorStart>0){this._visibleFloorStart--,1===this._visibleFloorStart&&(this._visibleFloorStart=0);const e=this._model&&this._model.floors||[];if(e.length>3){const t=e.length-3;this._visibleFloorStart===t-1&&(this._visibleFloorStart=t-2);}this._render();}}_scrollDown(){if(this._model&&this._model.floors){const e=this._model.floors.length-3;this._visibleFloorStarte&&(this._visibleFloorStart=e),this._render());}}},Popup:class extends e.E{constructor(t){super(),this.options=Object.assign(Object.create(tc),t),this._altitude=this.options.altitude,e.aZ(["_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.A("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.A("close")),this}getLngLat(){return this._lngLat}setLngLat(t){this._lngLat=e.aU.convert(t),this._pos=null,this._trackPointer=!1,this._update();const i=this._map;return i&&(i.on("move",this._update),i.off("mousemove",this._onMouseEvent),i._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}getAltitude(){return this._altitude}setAltitude(e){return this._altitude=e,this._update(),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(),i=document.createElement("body");let o;for(i.innerHTML=e;o=i.firstChild,o;)t.appendChild(o);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=l("div","mapboxgl-popup-content",this._container||void 0);if(t.appendChild(e),this.options.closeButton){const e=this._closeButton=l("button","mapboxgl-popup-close-button",t);e.type="button",e.setAttribute("aria-label","Close popup"),e.innerHTML='',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,i=this._container,o=this._pos;if(!t||!i||!o)return "bottom";const s=i.offsetWidth,r=i.offsetHeight,n=o.xt.transform.width-s/2;if(o.y+et.transform.height-r){if(n)return "bottom-left";if(a)return "bottom-right"}return n?"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 i=this._map,o=this._content;if(!i||!this._lngLat&&!this._trackPointer||!o)return;let s=this._container;if(s||(s=this._container=l("div","mapboxgl-popup",i.getContainer()),this._tip=l("div","mapboxgl-popup-tip",s),s.appendChild(o)),this.options.maxWidth&&s.style.maxWidth!==this.options.maxWidth&&(s.style.maxWidth=this.options.maxWidth),i.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=$l(this._lngLat,this._pos,i.transform)),!this._trackPointer||t){const o=this._pos=this._trackPointer&&t instanceof e.P?t:i.project(this._lngLat,this._altitude),s=oc(this.options.offset),r=this._anchor=this._getAnchor(s.y),n=oc(this.options.offset,r),a=o.add(n).round();i._requestDomTask(()=>{this._container&&r&&(this._container.style.transform=`${Xl[r]} translate(${a.x}px,${a.y}px)`);});}if(!this._marker&&i._showingGlobe()){const t=e.f8(i.transform,this._lngLat)?0:1;this._setOpacity(t);}this._updateClassList();}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(ic);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:Yl,Style:Po,LngLat:e.aU,LngLatBounds:e.aJ,Point:e.P,MercatorCoordinate:e.af,FreeCameraOptions:io,Evented:e.E,config:e.e,prewarm:e.fc,clearPrewarmedResources:e.fb,get accessToken(){return e.e.ACCESS_TOKEN},set accessToken(t){e.e.ACCESS_TOKEN=t;},get baseApiUrl(){return e.e.API_URL},set baseApiUrl(t){e.e.API_URL=t;},get workerCount(){return e.fl.workerCount},set workerCount(t){e.fl.workerCount=t;},get maxParallelImageRequests(){return e.e.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(t){e.e.MAX_PARALLEL_IMAGE_REQUESTS=t;},clearStorage(t){e.fk(t);},get workerUrl(){return e.fj.workerUrl},set workerUrl(t){e.fj.workerUrl=t;},get workerClass(){return e.fj.workerClass},set workerClass(t){e.fj.workerClass=t;},get workerParams(){return e.fj.workerParams},set workerParams(t){e.fj.workerParams=t;},get dracoUrl(){return e.fi()},set dracoUrl(t){e.fh(t);},get meshoptUrl(){return e.fg()},set meshoptUrl(t){e.ff(t);},setNow:e.o.setNow,restoreNow:e.o.restoreNow};return sc}); // // Our custom intro provides a specialized "define()" function, called by the // AMD modules below, that sets up the worker blob URL and then executes the // main module, storing its exported value as 'mapboxgl' var mapboxgl$1 = mapboxgl; return mapboxgl$1; })); //# sourceMappingURL=mapbox-gl.js.map