| 1 |
/* Mapbox GL JS is Copyright © 2020 Mapbox and subject to the Mapbox Terms of Service ((https://www.mapbox.com/legal/tos/). */ |
| 2 |
(function (global, factory) { |
| 3 |
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : |
| 4 |
typeof define === 'function' && define.amd ? define(factory) : |
| 5 |
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.mapboxgl = factory()); |
| 6 |
})(this, (function () { 'use strict'; |
| 7 |
|
| 8 |
/* eslint-disable */ |
| 9 |
|
| 10 |
var shared, worker, mapboxgl; |
| 11 |
// define gets called three times: one for each chunk. we rely on the order |
| 12 |
// they're imported to know which is which |
| 13 |
function define(_, chunk) { |
| 14 |
if (!shared) { |
| 15 |
shared = chunk; |
| 16 |
} else if (!worker) { |
| 17 |
worker = chunk; |
| 18 |
} else { |
| 19 |
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;" |
| 20 |
|
| 21 |
var sharedChunk = {}; |
| 22 |
shared(sharedChunk); |
| 23 |
mapboxgl = chunk(sharedChunk); |
| 24 |
if (typeof window !== 'undefined' && window && window.URL && window.URL.createObjectURL) { |
| 25 |
mapboxgl.workerUrl = window.URL.createObjectURL(new Blob([workerBundleString], { type: 'text/javascript' })); |
| 26 |
} |
| 27 |
} |
| 28 |
} |
| 29 |
|
| 30 |
|
| 31 |
define(["exports"],(function(t){function e(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var r,n={},i={};function a(){if(r)return i;r=1,Object.defineProperty(i,"__esModule",{value:!0}),i.setMatrixArrayType=function(t){i.ARRAY_TYPE=e=t;},i.toRadian=function(t){return t*a},i.equals=function(e,r){return Math.abs(e-r)<=t*Math.max(1,Math.abs(e),Math.abs(r))},i.RANDOM=i.ARRAY_TYPE=i.EPSILON=void 0;var t=1e-6;i.EPSILON=t;var e="undefined"!=typeof Float32Array?Float32Array:Array;i.ARRAY_TYPE=e;var n=Math.random;i.RANDOM=n;var a=Math.PI/180;return Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)}),i}var s,o={};function l(){if(s)return o;function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}s=1,Object.defineProperty(o,"__esModule",{value:!0}),o.create=function(){var t=new e.ARRAY_TYPE(4);return e.ARRAY_TYPE!=Float32Array&&(t[1]=0,t[2]=0),t[0]=1,t[3]=1,t},o.clone=function(t){var r=new e.ARRAY_TYPE(4);return r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[3],r},o.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},o.identity=function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t},o.fromValues=function(t,r,n,i){var a=new e.ARRAY_TYPE(4);return a[0]=t,a[1]=r,a[2]=n,a[3]=i,a},o.set=function(t,e,r,n,i){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t},o.transpose=function(t,e){if(t===e){var r=e[1];t[1]=e[2],t[2]=r;}else t[0]=e[0],t[1]=e[2],t[2]=e[1],t[3]=e[3];return t},o.invert=function(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],s=r*a-i*n;return s?(t[0]=a*(s=1/s),t[1]=-n*s,t[2]=-i*s,t[3]=r*s,t):null},o.adjoint=function(t,e){var r=e[0];return t[0]=e[3],t[1]=-e[1],t[2]=-e[2],t[3]=r,t},o.determinant=function(t){return t[0]*t[3]-t[2]*t[1]},o.multiply=n,o.rotate=function(t,e,r){var n=e[0],i=e[1],a=e[2],s=e[3],o=Math.sin(r),l=Math.cos(r);return t[0]=n*l+a*o,t[1]=i*l+s*o,t[2]=n*-o+a*l,t[3]=i*-o+s*l,t},o.scale=function(t,e,r){var n=e[1],i=e[2],a=e[3],s=r[0],o=r[1];return t[0]=e[0]*s,t[1]=n*s,t[2]=i*o,t[3]=a*o,t},o.fromRotation=function(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=r,t[2]=-r,t[3]=n,t},o.fromScaling=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=e[1],t},o.str=function(t){return "mat2("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"},o.frob=function(t){return Math.hypot(t[0],t[1],t[2],t[3])},o.LDU=function(t,e,r,n){return t[2]=n[2]/n[0],r[0]=n[0],r[1]=n[1],r[3]=n[3]-t[2]*r[1],[t,e,r]},o.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t},o.subtract=i,o.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]},o.equals=function(t,r){var n=t[0],i=t[1],a=t[2],s=t[3],o=r[0],l=r[1],u=r[2],c=r[3];return Math.abs(n-o)<=e.EPSILON*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(i-l)<=e.EPSILON*Math.max(1,Math.abs(i),Math.abs(l))&&Math.abs(a-u)<=e.EPSILON*Math.max(1,Math.abs(a),Math.abs(u))&&Math.abs(s-c)<=e.EPSILON*Math.max(1,Math.abs(s),Math.abs(c))},o.multiplyScalar=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t},o.multiplyScalarAndAdd=function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t},o.sub=o.mul=void 0;var e=function(e,n){if(e&&e.__esModule)return e;if(null===e||"object"!==t(e)&&"function"!=typeof e)return {default:e};var i=r(void 0);if(i&&i.has(e))return i.get(e);var a={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var l=s?Object.getOwnPropertyDescriptor(e,o):null;l&&(l.get||l.set)?Object.defineProperty(a,o,l):a[o]=e[o];}return a.default=e,i&&i.set(e,a),a}(a());function r(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,n=new WeakMap;return (r=function(t){return t?n:e})(t)}function n(t,e,r){var n=e[0],i=e[1],a=e[2],s=e[3],o=r[0],l=r[1],u=r[2],c=r[3];return t[0]=n*o+a*l,t[1]=i*o+s*l,t[2]=n*u+a*c,t[3]=i*u+s*c,t}function i(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t}return o.mul=n,o.sub=i,o}var u,c={};function h(){if(u)return c;function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}u=1,Object.defineProperty(c,"__esModule",{value:!0}),c.create=function(){var t=new e.ARRAY_TYPE(6);return e.ARRAY_TYPE!=Float32Array&&(t[1]=0,t[2]=0,t[4]=0,t[5]=0),t[0]=1,t[3]=1,t},c.clone=function(t){var r=new e.ARRAY_TYPE(6);return r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[3],r[4]=t[4],r[5]=t[5],r},c.copy=function(t,e){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},c.identity=function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t},c.fromValues=function(t,r,n,i,a,s){var o=new e.ARRAY_TYPE(6);return o[0]=t,o[1]=r,o[2]=n,o[3]=i,o[4]=a,o[5]=s,o},c.set=function(t,e,r,n,i,a,s){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t[4]=a,t[5]=s,t},c.invert=function(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],s=e[4],o=e[5],l=r*a-n*i;return l?(t[0]=a*(l=1/l),t[1]=-n*l,t[2]=-i*l,t[3]=r*l,t[4]=(i*o-a*s)*l,t[5]=(n*s-r*o)*l,t):null},c.determinant=function(t){return t[0]*t[3]-t[1]*t[2]},c.multiply=n,c.rotate=function(t,e,r){var n=e[0],i=e[1],a=e[2],s=e[3],o=e[4],l=e[5],u=Math.sin(r),c=Math.cos(r);return t[0]=n*c+a*u,t[1]=i*c+s*u,t[2]=n*-u+a*c,t[3]=i*-u+s*c,t[4]=o,t[5]=l,t},c.scale=function(t,e,r){var n=e[1],i=e[2],a=e[3],s=e[4],o=e[5],l=r[0],u=r[1];return t[0]=e[0]*l,t[1]=n*l,t[2]=i*u,t[3]=a*u,t[4]=s,t[5]=o,t},c.translate=function(t,e,r){var n=e[0],i=e[1],a=e[2],s=e[3],o=e[4],l=e[5],u=r[0],c=r[1];return t[0]=n,t[1]=i,t[2]=a,t[3]=s,t[4]=n*u+a*c+o,t[5]=i*u+s*c+l,t},c.fromRotation=function(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=r,t[2]=-r,t[3]=n,t[4]=0,t[5]=0,t},c.fromScaling=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=e[1],t[4]=0,t[5]=0,t},c.fromTranslation=function(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=e[0],t[5]=e[1],t},c.str=function(t){return "mat2d("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+")"},c.frob=function(t){return Math.hypot(t[0],t[1],t[2],t[3],t[4],t[5],1)},c.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t},c.subtract=i,c.multiplyScalar=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t},c.multiplyScalarAndAdd=function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t[4]=e[4]+r[4]*n,t[5]=e[5]+r[5]*n,t},c.exactEquals=function(t,e){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]},c.equals=function(t,r){var n=t[0],i=t[1],a=t[2],s=t[3],o=t[4],l=t[5],u=r[0],c=r[1],h=r[2],p=r[3],f=r[4],d=r[5];return Math.abs(n-u)<=e.EPSILON*Math.max(1,Math.abs(n),Math.abs(u))&&Math.abs(i-c)<=e.EPSILON*Math.max(1,Math.abs(i),Math.abs(c))&&Math.abs(a-h)<=e.EPSILON*Math.max(1,Math.abs(a),Math.abs(h))&&Math.abs(s-p)<=e.EPSILON*Math.max(1,Math.abs(s),Math.abs(p))&&Math.abs(o-f)<=e.EPSILON*Math.max(1,Math.abs(o),Math.abs(f))&&Math.abs(l-d)<=e.EPSILON*Math.max(1,Math.abs(l),Math.abs(d))},c.sub=c.mul=void 0;var e=function(e,n){if(e&&e.__esModule)return e;if(null===e||"object"!==t(e)&&"function"!=typeof e)return {default:e};var i=r(void 0);if(i&&i.has(e))return i.get(e);var a={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var l=s?Object.getOwnPropertyDescriptor(e,o):null;l&&(l.get||l.set)?Object.defineProperty(a,o,l):a[o]=e[o];}return a.default=e,i&&i.set(e,a),a}(a());function r(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,n=new WeakMap;return (r=function(t){return t?n:e})(t)}function n(t,e,r){var n=e[0],i=e[1],a=e[2],s=e[3],o=e[4],l=e[5],u=r[0],c=r[1],h=r[2],p=r[3],f=r[4],d=r[5];return t[0]=n*u+a*c,t[1]=i*u+s*c,t[2]=n*h+a*p,t[3]=i*h+s*p,t[4]=n*f+a*d+o,t[5]=i*f+s*d+l,t}function i(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t[4]=e[4]-r[4],t[5]=e[5]-r[5],t}return c.mul=n,c.sub=i,c}var p,f={};function d(){if(p)return f;function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}p=1,Object.defineProperty(f,"__esModule",{value:!0}),f.create=function(){var t=new e.ARRAY_TYPE(9);return e.ARRAY_TYPE!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t},f.fromMat4=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t},f.clone=function(t){var r=new e.ARRAY_TYPE(9);return r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[3],r[4]=t[4],r[5]=t[5],r[6]=t[6],r[7]=t[7],r[8]=t[8],r},f.copy=function(t,e){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},f.fromValues=function(t,r,n,i,a,s,o,l,u){var c=new e.ARRAY_TYPE(9);return c[0]=t,c[1]=r,c[2]=n,c[3]=i,c[4]=a,c[5]=s,c[6]=o,c[7]=l,c[8]=u,c},f.set=function(t,e,r,n,i,a,s,o,l,u){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t[4]=a,t[5]=s,t[6]=o,t[7]=l,t[8]=u,t},f.identity=function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},f.transpose=function(t,e){if(t===e){var r=e[1],n=e[2],i=e[5];t[1]=e[3],t[2]=e[6],t[3]=r,t[5]=e[7],t[6]=n,t[7]=i;}else t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8];return t},f.invert=function(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],s=e[4],o=e[5],l=e[6],u=e[7],c=e[8],h=c*s-o*u,p=-c*a+o*l,f=u*a-s*l,d=r*h+n*p+i*f;return d?(t[0]=h*(d=1/d),t[1]=(-c*n+i*u)*d,t[2]=(o*n-i*s)*d,t[3]=p*d,t[4]=(c*r-i*l)*d,t[5]=(-o*r+i*a)*d,t[6]=f*d,t[7]=(-u*r+n*l)*d,t[8]=(s*r-n*a)*d,t):null},f.adjoint=function(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],s=e[4],o=e[5],l=e[6],u=e[7],c=e[8];return t[0]=s*c-o*u,t[1]=i*u-n*c,t[2]=n*o-i*s,t[3]=o*l-a*c,t[4]=r*c-i*l,t[5]=i*a-r*o,t[6]=a*u-s*l,t[7]=n*l-r*u,t[8]=r*s-n*a,t},f.determinant=function(t){var e=t[3],r=t[4],n=t[5],i=t[6],a=t[7],s=t[8];return t[0]*(s*r-n*a)+t[1]*(-s*e+n*i)+t[2]*(a*e-r*i)},f.multiply=n,f.translate=function(t,e,r){var n=e[0],i=e[1],a=e[2],s=e[3],o=e[4],l=e[5],u=e[6],c=e[7],h=e[8],p=r[0],f=r[1];return t[0]=n,t[1]=i,t[2]=a,t[3]=s,t[4]=o,t[5]=l,t[6]=p*n+f*s+u,t[7]=p*i+f*o+c,t[8]=p*a+f*l+h,t},f.rotate=function(t,e,r){var n=e[0],i=e[1],a=e[2],s=e[3],o=e[4],l=e[5],u=e[6],c=e[7],h=e[8],p=Math.sin(r),f=Math.cos(r);return t[0]=f*n+p*s,t[1]=f*i+p*o,t[2]=f*a+p*l,t[3]=f*s-p*n,t[4]=f*o-p*i,t[5]=f*l-p*a,t[6]=u,t[7]=c,t[8]=h,t},f.scale=function(t,e,r){var n=r[0],i=r[1];return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=i*e[3],t[4]=i*e[4],t[5]=i*e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t},f.fromTranslation=function(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=e[0],t[7]=e[1],t[8]=1,t},f.fromRotation=function(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=r,t[2]=0,t[3]=-r,t[4]=n,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},f.fromScaling=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=e[1],t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},f.fromMat2d=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=0,t[3]=e[2],t[4]=e[3],t[5]=0,t[6]=e[4],t[7]=e[5],t[8]=1,t},f.fromQuat=function(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],s=r+r,o=n+n,l=i+i,u=r*s,c=n*s,h=n*o,p=i*s,f=i*o,d=i*l,m=a*s,y=a*o,g=a*l;return t[0]=1-h-d,t[3]=c-g,t[6]=p+y,t[1]=c+g,t[4]=1-u-d,t[7]=f-m,t[2]=p-y,t[5]=f+m,t[8]=1-u-h,t},f.normalFromMat4=function(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],s=e[4],o=e[5],l=e[6],u=e[7],c=e[8],h=e[9],p=e[10],f=e[11],d=e[12],m=e[13],y=e[14],g=e[15],x=r*o-n*s,v=r*l-i*s,b=r*u-a*s,w=n*l-i*o,_=n*u-a*o,M=i*u-a*l,A=c*m-h*d,S=c*y-p*d,I=c*g-f*d,z=h*y-p*m,P=h*g-f*m,k=p*g-f*y,T=x*k-v*P+b*z+w*I-_*S+M*A;return T?(t[0]=(o*k-l*P+u*z)*(T=1/T),t[1]=(l*I-s*k-u*S)*T,t[2]=(s*P-o*I+u*A)*T,t[3]=(i*P-n*k-a*z)*T,t[4]=(r*k-i*I+a*S)*T,t[5]=(n*I-r*P-a*A)*T,t[6]=(m*M-y*_+g*w)*T,t[7]=(y*b-d*M-g*v)*T,t[8]=(d*_-m*b+g*x)*T,t):null},f.projection=function(t,e,r){return t[0]=2/e,t[1]=0,t[2]=0,t[3]=0,t[4]=-2/r,t[5]=0,t[6]=-1,t[7]=1,t[8]=1,t},f.str=function(t){return "mat3("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+", "+t[8]+")"},f.frob=function(t){return Math.hypot(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8])},f.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t[6]=e[6]+r[6],t[7]=e[7]+r[7],t[8]=e[8]+r[8],t},f.subtract=i,f.multiplyScalar=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*r,t},f.multiplyScalarAndAdd=function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t[4]=e[4]+r[4]*n,t[5]=e[5]+r[5]*n,t[6]=e[6]+r[6]*n,t[7]=e[7]+r[7]*n,t[8]=e[8]+r[8]*n,t},f.exactEquals=function(t,e){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]},f.equals=function(t,r){var n=t[0],i=t[1],a=t[2],s=t[3],o=t[4],l=t[5],u=t[6],c=t[7],h=t[8],p=r[0],f=r[1],d=r[2],m=r[3],y=r[4],g=r[5],x=r[6],v=r[7],b=r[8];return Math.abs(n-p)<=e.EPSILON*Math.max(1,Math.abs(n),Math.abs(p))&&Math.abs(i-f)<=e.EPSILON*Math.max(1,Math.abs(i),Math.abs(f))&&Math.abs(a-d)<=e.EPSILON*Math.max(1,Math.abs(a),Math.abs(d))&&Math.abs(s-m)<=e.EPSILON*Math.max(1,Math.abs(s),Math.abs(m))&&Math.abs(o-y)<=e.EPSILON*Math.max(1,Math.abs(o),Math.abs(y))&&Math.abs(l-g)<=e.EPSILON*Math.max(1,Math.abs(l),Math.abs(g))&&Math.abs(u-x)<=e.EPSILON*Math.max(1,Math.abs(u),Math.abs(x))&&Math.abs(c-v)<=e.EPSILON*Math.max(1,Math.abs(c),Math.abs(v))&&Math.abs(h-b)<=e.EPSILON*Math.max(1,Math.abs(h),Math.abs(b))},f.sub=f.mul=void 0;var e=function(e,n){if(e&&e.__esModule)return e;if(null===e||"object"!==t(e)&&"function"!=typeof e)return {default:e};var i=r(void 0);if(i&&i.has(e))return i.get(e);var a={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var l=s?Object.getOwnPropertyDescriptor(e,o):null;l&&(l.get||l.set)?Object.defineProperty(a,o,l):a[o]=e[o];}return a.default=e,i&&i.set(e,a),a}(a());function r(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,n=new WeakMap;return (r=function(t){return t?n:e})(t)}function n(t,e,r){var n=e[0],i=e[1],a=e[2],s=e[3],o=e[4],l=e[5],u=e[6],c=e[7],h=e[8],p=r[0],f=r[1],d=r[2],m=r[3],y=r[4],g=r[5],x=r[6],v=r[7],b=r[8];return t[0]=p*n+f*s+d*u,t[1]=p*i+f*o+d*c,t[2]=p*a+f*l+d*h,t[3]=m*n+y*s+g*u,t[4]=m*i+y*o+g*c,t[5]=m*a+y*l+g*h,t[6]=x*n+v*s+b*u,t[7]=x*i+v*o+b*c,t[8]=x*a+v*l+b*h,t}function i(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t[4]=e[4]-r[4],t[5]=e[5]-r[5],t[6]=e[6]-r[6],t[7]=e[7]-r[7],t[8]=e[8]-r[8],t}return f.mul=n,f.sub=i,f}var m,y={};function g(){if(m)return y;function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}m=1,Object.defineProperty(y,"__esModule",{value:!0}),y.create=function(){var t=new e.ARRAY_TYPE(16);return e.ARRAY_TYPE!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t},y.clone=function(t){var r=new e.ARRAY_TYPE(16);return r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[3],r[4]=t[4],r[5]=t[5],r[6]=t[6],r[7]=t[7],r[8]=t[8],r[9]=t[9],r[10]=t[10],r[11]=t[11],r[12]=t[12],r[13]=t[13],r[14]=t[14],r[15]=t[15],r},y.copy=function(t,e){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},y.fromValues=function(t,r,n,i,a,s,o,l,u,c,h,p,f,d,m,y){var g=new e.ARRAY_TYPE(16);return g[0]=t,g[1]=r,g[2]=n,g[3]=i,g[4]=a,g[5]=s,g[6]=o,g[7]=l,g[8]=u,g[9]=c,g[10]=h,g[11]=p,g[12]=f,g[13]=d,g[14]=m,g[15]=y,g},y.set=function(t,e,r,n,i,a,s,o,l,u,c,h,p,f,d,m,y){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t[4]=a,t[5]=s,t[6]=o,t[7]=l,t[8]=u,t[9]=c,t[10]=h,t[11]=p,t[12]=f,t[13]=d,t[14]=m,t[15]=y,t},y.identity=n,y.transpose=function(t,e){if(t===e){var r=e[1],n=e[2],i=e[3],a=e[6],s=e[7],o=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=n,t[9]=a,t[11]=e[14],t[12]=i,t[13]=s,t[14]=o;}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t},y.invert=function(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],s=e[4],o=e[5],l=e[6],u=e[7],c=e[8],h=e[9],p=e[10],f=e[11],d=e[12],m=e[13],y=e[14],g=e[15],x=r*o-n*s,v=r*l-i*s,b=r*u-a*s,w=n*l-i*o,_=n*u-a*o,M=i*u-a*l,A=c*m-h*d,S=c*y-p*d,I=c*g-f*d,z=h*y-p*m,P=h*g-f*m,k=p*g-f*y,T=x*k-v*P+b*z+w*I-_*S+M*A;return T?(t[0]=(o*k-l*P+u*z)*(T=1/T),t[1]=(i*P-n*k-a*z)*T,t[2]=(m*M-y*_+g*w)*T,t[3]=(p*_-h*M-f*w)*T,t[4]=(l*I-s*k-u*S)*T,t[5]=(r*k-i*I+a*S)*T,t[6]=(y*b-d*M-g*v)*T,t[7]=(c*M-p*b+f*v)*T,t[8]=(s*P-o*I+u*A)*T,t[9]=(n*I-r*P-a*A)*T,t[10]=(d*_-m*b+g*x)*T,t[11]=(h*b-c*_-f*x)*T,t[12]=(o*S-s*z-l*A)*T,t[13]=(r*z-n*S+i*A)*T,t[14]=(m*v-d*w-y*x)*T,t[15]=(c*w-h*v+p*x)*T,t):null},y.adjoint=function(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],s=e[4],o=e[5],l=e[6],u=e[7],c=e[8],h=e[9],p=e[10],f=e[11],d=e[12],m=e[13],y=e[14],g=e[15];return t[0]=o*(p*g-f*y)-h*(l*g-u*y)+m*(l*f-u*p),t[1]=-(n*(p*g-f*y)-h*(i*g-a*y)+m*(i*f-a*p)),t[2]=n*(l*g-u*y)-o*(i*g-a*y)+m*(i*u-a*l),t[3]=-(n*(l*f-u*p)-o*(i*f-a*p)+h*(i*u-a*l)),t[4]=-(s*(p*g-f*y)-c*(l*g-u*y)+d*(l*f-u*p)),t[5]=r*(p*g-f*y)-c*(i*g-a*y)+d*(i*f-a*p),t[6]=-(r*(l*g-u*y)-s*(i*g-a*y)+d*(i*u-a*l)),t[7]=r*(l*f-u*p)-s*(i*f-a*p)+c*(i*u-a*l),t[8]=s*(h*g-f*m)-c*(o*g-u*m)+d*(o*f-u*h),t[9]=-(r*(h*g-f*m)-c*(n*g-a*m)+d*(n*f-a*h)),t[10]=r*(o*g-u*m)-s*(n*g-a*m)+d*(n*u-a*o),t[11]=-(r*(o*f-u*h)-s*(n*f-a*h)+c*(n*u-a*o)),t[12]=-(s*(h*y-p*m)-c*(o*y-l*m)+d*(o*p-l*h)),t[13]=r*(h*y-p*m)-c*(n*y-i*m)+d*(n*p-i*h),t[14]=-(r*(o*y-l*m)-s*(n*y-i*m)+d*(n*l-i*o)),t[15]=r*(o*p-l*h)-s*(n*p-i*h)+c*(n*l-i*o),t},y.determinant=function(t){var e=t[0],r=t[1],n=t[2],i=t[3],a=t[4],s=t[5],o=t[6],l=t[7],u=t[8],c=t[9],h=t[10],p=t[11],f=t[12],d=t[13],m=t[14],y=t[15];return (e*s-r*a)*(h*y-p*m)-(e*o-n*a)*(c*y-p*d)+(e*l-i*a)*(c*m-h*d)+(r*o-n*s)*(u*y-p*f)-(r*l-i*s)*(u*m-h*f)+(n*l-i*o)*(u*d-c*f)},y.multiply=i,y.translate=function(t,e,r){var n,i,a,s,o,l,u,c,h,p,f,d,m=r[0],y=r[1],g=r[2];return e===t?(t[12]=e[0]*m+e[4]*y+e[8]*g+e[12],t[13]=e[1]*m+e[5]*y+e[9]*g+e[13],t[14]=e[2]*m+e[6]*y+e[10]*g+e[14],t[15]=e[3]*m+e[7]*y+e[11]*g+e[15]):(i=e[1],a=e[2],s=e[3],o=e[4],l=e[5],u=e[6],c=e[7],h=e[8],p=e[9],f=e[10],d=e[11],t[0]=n=e[0],t[1]=i,t[2]=a,t[3]=s,t[4]=o,t[5]=l,t[6]=u,t[7]=c,t[8]=h,t[9]=p,t[10]=f,t[11]=d,t[12]=n*m+o*y+h*g+e[12],t[13]=i*m+l*y+p*g+e[13],t[14]=a*m+u*y+f*g+e[14],t[15]=s*m+c*y+d*g+e[15]),t},y.scale=function(t,e,r){var n=r[0],i=r[1],a=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*a,t[9]=e[9]*a,t[10]=e[10]*a,t[11]=e[11]*a,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},y.rotate=function(t,r,n,i){var a,s,o,l,u,c,h,p,f,d,m,y,g,x,v,b,w,_,M,A,S,I,z,P,k=i[0],T=i[1],E=i[2],B=Math.hypot(k,T,E);return B<e.EPSILON?null:(k*=B=1/B,T*=B,E*=B,a=Math.sin(n),s=Math.cos(n),u=r[1],c=r[2],h=r[3],f=r[5],d=r[6],m=r[7],g=r[9],x=r[10],v=r[11],b=k*k*(o=1-s)+s,M=k*T*o-E*a,A=T*T*o+s,S=E*T*o+k*a,I=k*E*o+T*a,z=T*E*o-k*a,P=E*E*o+s,t[0]=(l=r[0])*b+(p=r[4])*(w=T*k*o+E*a)+(y=r[8])*(_=E*k*o-T*a),t[1]=u*b+f*w+g*_,t[2]=c*b+d*w+x*_,t[3]=h*b+m*w+v*_,t[4]=l*M+p*A+y*S,t[5]=u*M+f*A+g*S,t[6]=c*M+d*A+x*S,t[7]=h*M+m*A+v*S,t[8]=l*I+p*z+y*P,t[9]=u*I+f*z+g*P,t[10]=c*I+d*z+x*P,t[11]=h*I+m*z+v*P,r!==t&&(t[12]=r[12],t[13]=r[13],t[14]=r[14],t[15]=r[15]),t)},y.rotateX=function(t,e,r){var n=Math.sin(r),i=Math.cos(r),a=e[4],s=e[5],o=e[6],l=e[7],u=e[8],c=e[9],h=e[10],p=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=a*i+u*n,t[5]=s*i+c*n,t[6]=o*i+h*n,t[7]=l*i+p*n,t[8]=u*i-a*n,t[9]=c*i-s*n,t[10]=h*i-o*n,t[11]=p*i-l*n,t},y.rotateY=function(t,e,r){var n=Math.sin(r),i=Math.cos(r),a=e[0],s=e[1],o=e[2],l=e[3],u=e[8],c=e[9],h=e[10],p=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=a*i-u*n,t[1]=s*i-c*n,t[2]=o*i-h*n,t[3]=l*i-p*n,t[8]=a*n+u*i,t[9]=s*n+c*i,t[10]=o*n+h*i,t[11]=l*n+p*i,t},y.rotateZ=function(t,e,r){var n=Math.sin(r),i=Math.cos(r),a=e[0],s=e[1],o=e[2],l=e[3],u=e[4],c=e[5],h=e[6],p=e[7];return e!==t&&(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[0]=a*i+u*n,t[1]=s*i+c*n,t[2]=o*i+h*n,t[3]=l*i+p*n,t[4]=u*i-a*n,t[5]=c*i-s*n,t[6]=h*i-o*n,t[7]=p*i-l*n,t},y.fromTranslation=function(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t},y.fromScaling=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},y.fromRotation=function(t,r,n){var i,a,s,o=n[0],l=n[1],u=n[2],c=Math.hypot(o,l,u);return c<e.EPSILON?null:(o*=c=1/c,l*=c,u*=c,i=Math.sin(r),a=Math.cos(r),t[0]=o*o*(s=1-a)+a,t[1]=l*o*s+u*i,t[2]=u*o*s-l*i,t[3]=0,t[4]=o*l*s-u*i,t[5]=l*l*s+a,t[6]=u*l*s+o*i,t[7]=0,t[8]=o*u*s+l*i,t[9]=l*u*s-o*i,t[10]=u*u*s+a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t)},y.fromXRotation=function(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=n,t[6]=r,t[7]=0,t[8]=0,t[9]=-r,t[10]=n,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},y.fromYRotation=function(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=0,t[2]=-r,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=r,t[9]=0,t[10]=n,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},y.fromZRotation=function(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=r,t[2]=0,t[3]=0,t[4]=-r,t[5]=n,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},y.fromRotationTranslation=s,y.fromQuat2=function(t,r){var n=new e.ARRAY_TYPE(3),i=-r[0],a=-r[1],o=-r[2],l=r[3],u=r[4],c=r[5],h=r[6],p=r[7],f=i*i+a*a+o*o+l*l;return f>0?(n[0]=2*(u*l+p*i+c*o-h*a)/f,n[1]=2*(c*l+p*a+h*i-u*o)/f,n[2]=2*(h*l+p*o+u*a-c*i)/f):(n[0]=2*(u*l+p*i+c*o-h*a),n[1]=2*(c*l+p*a+h*i-u*o),n[2]=2*(h*l+p*o+u*a-c*i)),s(t,r,n),t},y.getTranslation=function(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t},y.getScaling=o,y.getRotation=function(t,r){var n=new e.ARRAY_TYPE(3);o(n,r);var i=1/n[0],a=1/n[1],s=1/n[2],l=r[0]*i,u=r[1]*a,c=r[2]*s,h=r[4]*i,p=r[5]*a,f=r[6]*s,d=r[8]*i,m=r[9]*a,y=r[10]*s,g=l+p+y,x=0;return g>0?(x=2*Math.sqrt(g+1),t[3]=.25*x,t[0]=(f-m)/x,t[1]=(d-c)/x,t[2]=(u-h)/x):l>p&&l>y?(x=2*Math.sqrt(1+l-p-y),t[3]=(f-m)/x,t[0]=.25*x,t[1]=(u+h)/x,t[2]=(d+c)/x):p>y?(x=2*Math.sqrt(1+p-l-y),t[3]=(d-c)/x,t[0]=(u+h)/x,t[1]=.25*x,t[2]=(f+m)/x):(x=2*Math.sqrt(1+y-l-p),t[3]=(u-h)/x,t[0]=(d+c)/x,t[1]=(f+m)/x,t[2]=.25*x),t},y.fromRotationTranslationScale=function(t,e,r,n){var i=e[0],a=e[1],s=e[2],o=e[3],l=i+i,u=a+a,c=s+s,h=i*l,p=i*u,f=i*c,d=a*u,m=a*c,y=s*c,g=o*l,x=o*u,v=o*c,b=n[0],w=n[1],_=n[2];return t[0]=(1-(d+y))*b,t[1]=(p+v)*b,t[2]=(f-x)*b,t[3]=0,t[4]=(p-v)*w,t[5]=(1-(h+y))*w,t[6]=(m+g)*w,t[7]=0,t[8]=(f+x)*_,t[9]=(m-g)*_,t[10]=(1-(h+d))*_,t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t},y.fromRotationTranslationScaleOrigin=function(t,e,r,n,i){var a=e[0],s=e[1],o=e[2],l=e[3],u=a+a,c=s+s,h=o+o,p=a*u,f=a*c,d=a*h,m=s*c,y=s*h,g=o*h,x=l*u,v=l*c,b=l*h,w=n[0],_=n[1],M=n[2],A=i[0],S=i[1],I=i[2],z=(1-(m+g))*w,P=(f+b)*w,k=(d-v)*w,T=(f-b)*_,E=(1-(p+g))*_,B=(y+x)*_,V=(d+v)*M,C=(y-x)*M,R=(1-(p+m))*M;return t[0]=z,t[1]=P,t[2]=k,t[3]=0,t[4]=T,t[5]=E,t[6]=B,t[7]=0,t[8]=V,t[9]=C,t[10]=R,t[11]=0,t[12]=r[0]+A-(z*A+T*S+V*I),t[13]=r[1]+S-(P*A+E*S+C*I),t[14]=r[2]+I-(k*A+B*S+R*I),t[15]=1,t},y.fromQuat=function(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],s=r+r,o=n+n,l=i+i,u=r*s,c=n*s,h=n*o,p=i*s,f=i*o,d=i*l,m=a*s,y=a*o,g=a*l;return t[0]=1-h-d,t[1]=c+g,t[2]=p-y,t[3]=0,t[4]=c-g,t[5]=1-u-d,t[6]=f+m,t[7]=0,t[8]=p+y,t[9]=f-m,t[10]=1-u-h,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},y.frustum=function(t,e,r,n,i,a,s){var o=1/(r-e),l=1/(i-n),u=1/(a-s);return t[0]=2*a*o,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=2*a*l,t[6]=0,t[7]=0,t[8]=(r+e)*o,t[9]=(i+n)*l,t[10]=(s+a)*u,t[11]=-1,t[12]=0,t[13]=0,t[14]=s*a*2*u,t[15]=0,t},y.perspectiveNO=l,y.perspectiveZO=function(t,e,r,n,i){var a,s=1/Math.tan(e/2);return t[0]=s/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=s,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=i&&i!==1/0?(t[10]=i*(a=1/(n-i)),t[14]=i*n*a):(t[10]=-1,t[14]=-n),t},y.perspectiveFromFieldOfView=function(t,e,r,n){var i=Math.tan(e.upDegrees*Math.PI/180),a=Math.tan(e.downDegrees*Math.PI/180),s=Math.tan(e.leftDegrees*Math.PI/180),o=Math.tan(e.rightDegrees*Math.PI/180),l=2/(s+o),u=2/(i+a);return t[0]=l,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=u,t[6]=0,t[7]=0,t[8]=-(s-o)*l*.5,t[9]=(i-a)*u*.5,t[10]=n/(r-n),t[11]=-1,t[12]=0,t[13]=0,t[14]=n*r/(r-n),t[15]=0,t},y.orthoNO=u,y.orthoZO=function(t,e,r,n,i,a,s){var o=1/(e-r),l=1/(n-i),u=1/(a-s);return t[0]=-2*o,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=u,t[11]=0,t[12]=(e+r)*o,t[13]=(i+n)*l,t[14]=a*u,t[15]=1,t},y.lookAt=function(t,r,i,a){var s,o,l,u,c,h,p,f,d,m,y=r[0],g=r[1],x=r[2],v=a[0],b=a[1],w=a[2],_=i[0],M=i[1],A=i[2];return Math.abs(y-_)<e.EPSILON&&Math.abs(g-M)<e.EPSILON&&Math.abs(x-A)<e.EPSILON?n(t):(p=y-_,f=g-M,d=x-A,s=b*(d*=m=1/Math.hypot(p,f,d))-w*(f*=m),o=w*(p*=m)-v*d,l=v*f-b*p,(m=Math.hypot(s,o,l))?(s*=m=1/m,o*=m,l*=m):(s=0,o=0,l=0),u=f*l-d*o,c=d*s-p*l,h=p*o-f*s,(m=Math.hypot(u,c,h))?(u*=m=1/m,c*=m,h*=m):(u=0,c=0,h=0),t[0]=s,t[1]=u,t[2]=p,t[3]=0,t[4]=o,t[5]=c,t[6]=f,t[7]=0,t[8]=l,t[9]=h,t[10]=d,t[11]=0,t[12]=-(s*y+o*g+l*x),t[13]=-(u*y+c*g+h*x),t[14]=-(p*y+f*g+d*x),t[15]=1,t)},y.targetTo=function(t,e,r,n){var i=e[0],a=e[1],s=e[2],o=n[0],l=n[1],u=n[2],c=i-r[0],h=a-r[1],p=s-r[2],f=c*c+h*h+p*p;f>0&&(c*=f=1/Math.sqrt(f),h*=f,p*=f);var d=l*p-u*h,m=u*c-o*p,y=o*h-l*c;return (f=d*d+m*m+y*y)>0&&(d*=f=1/Math.sqrt(f),m*=f,y*=f),t[0]=d,t[1]=m,t[2]=y,t[3]=0,t[4]=h*y-p*m,t[5]=p*d-c*y,t[6]=c*m-h*d,t[7]=0,t[8]=c,t[9]=h,t[10]=p,t[11]=0,t[12]=i,t[13]=a,t[14]=s,t[15]=1,t},y.str=function(t){return "mat4("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+", "+t[8]+", "+t[9]+", "+t[10]+", "+t[11]+", "+t[12]+", "+t[13]+", "+t[14]+", "+t[15]+")"},y.frob=function(t){return Math.hypot(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15])},y.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t[6]=e[6]+r[6],t[7]=e[7]+r[7],t[8]=e[8]+r[8],t[9]=e[9]+r[9],t[10]=e[10]+r[10],t[11]=e[11]+r[11],t[12]=e[12]+r[12],t[13]=e[13]+r[13],t[14]=e[14]+r[14],t[15]=e[15]+r[15],t},y.subtract=c,y.multiplyScalar=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*r,t[9]=e[9]*r,t[10]=e[10]*r,t[11]=e[11]*r,t[12]=e[12]*r,t[13]=e[13]*r,t[14]=e[14]*r,t[15]=e[15]*r,t},y.multiplyScalarAndAdd=function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t[4]=e[4]+r[4]*n,t[5]=e[5]+r[5]*n,t[6]=e[6]+r[6]*n,t[7]=e[7]+r[7]*n,t[8]=e[8]+r[8]*n,t[9]=e[9]+r[9]*n,t[10]=e[10]+r[10]*n,t[11]=e[11]+r[11]*n,t[12]=e[12]+r[12]*n,t[13]=e[13]+r[13]*n,t[14]=e[14]+r[14]*n,t[15]=e[15]+r[15]*n,t},y.exactEquals=function(t,e){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]},y.equals=function(t,r){var n=t[0],i=t[1],a=t[2],s=t[3],o=t[4],l=t[5],u=t[6],c=t[7],h=t[8],p=t[9],f=t[10],d=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],M=r[4],A=r[5],S=r[6],I=r[7],z=r[8],P=r[9],k=r[10],T=r[11],E=r[12],B=r[13],V=r[14],C=r[15];return Math.abs(n-v)<=e.EPSILON*Math.max(1,Math.abs(n),Math.abs(v))&&Math.abs(i-b)<=e.EPSILON*Math.max(1,Math.abs(i),Math.abs(b))&&Math.abs(a-w)<=e.EPSILON*Math.max(1,Math.abs(a),Math.abs(w))&&Math.abs(s-_)<=e.EPSILON*Math.max(1,Math.abs(s),Math.abs(_))&&Math.abs(o-M)<=e.EPSILON*Math.max(1,Math.abs(o),Math.abs(M))&&Math.abs(l-A)<=e.EPSILON*Math.max(1,Math.abs(l),Math.abs(A))&&Math.abs(u-S)<=e.EPSILON*Math.max(1,Math.abs(u),Math.abs(S))&&Math.abs(c-I)<=e.EPSILON*Math.max(1,Math.abs(c),Math.abs(I))&&Math.abs(h-z)<=e.EPSILON*Math.max(1,Math.abs(h),Math.abs(z))&&Math.abs(p-P)<=e.EPSILON*Math.max(1,Math.abs(p),Math.abs(P))&&Math.abs(f-k)<=e.EPSILON*Math.max(1,Math.abs(f),Math.abs(k))&&Math.abs(d-T)<=e.EPSILON*Math.max(1,Math.abs(d),Math.abs(T))&&Math.abs(m-E)<=e.EPSILON*Math.max(1,Math.abs(m),Math.abs(E))&&Math.abs(y-B)<=e.EPSILON*Math.max(1,Math.abs(y),Math.abs(B))&&Math.abs(g-V)<=e.EPSILON*Math.max(1,Math.abs(g),Math.abs(V))&&Math.abs(x-C)<=e.EPSILON*Math.max(1,Math.abs(x),Math.abs(C))},y.sub=y.mul=y.ortho=y.perspective=void 0;var e=function(e,n){if(e&&e.__esModule)return e;if(null===e||"object"!==t(e)&&"function"!=typeof e)return {default:e};var i=r(void 0);if(i&&i.has(e))return i.get(e);var a={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var l=s?Object.getOwnPropertyDescriptor(e,o):null;l&&(l.get||l.set)?Object.defineProperty(a,o,l):a[o]=e[o];}return a.default=e,i&&i.set(e,a),a}(a());function r(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,n=new WeakMap;return (r=function(t){return t?n:e})(t)}function n(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function i(t,e,r){var n=e[0],i=e[1],a=e[2],s=e[3],o=e[4],l=e[5],u=e[6],c=e[7],h=e[8],p=e[9],f=e[10],d=e[11],m=e[12],y=e[13],g=e[14],x=e[15],v=r[0],b=r[1],w=r[2],_=r[3];return t[0]=v*n+b*o+w*h+_*m,t[1]=v*i+b*l+w*p+_*y,t[2]=v*a+b*u+w*f+_*g,t[3]=v*s+b*c+w*d+_*x,t[4]=(v=r[4])*n+(b=r[5])*o+(w=r[6])*h+(_=r[7])*m,t[5]=v*i+b*l+w*p+_*y,t[6]=v*a+b*u+w*f+_*g,t[7]=v*s+b*c+w*d+_*x,t[8]=(v=r[8])*n+(b=r[9])*o+(w=r[10])*h+(_=r[11])*m,t[9]=v*i+b*l+w*p+_*y,t[10]=v*a+b*u+w*f+_*g,t[11]=v*s+b*c+w*d+_*x,t[12]=(v=r[12])*n+(b=r[13])*o+(w=r[14])*h+(_=r[15])*m,t[13]=v*i+b*l+w*p+_*y,t[14]=v*a+b*u+w*f+_*g,t[15]=v*s+b*c+w*d+_*x,t}function s(t,e,r){var n=e[0],i=e[1],a=e[2],s=e[3],o=n+n,l=i+i,u=a+a,c=n*o,h=n*l,p=n*u,f=i*l,d=i*u,m=a*u,y=s*o,g=s*l,x=s*u;return t[0]=1-(f+m),t[1]=h+x,t[2]=p-g,t[3]=0,t[4]=h-x,t[5]=1-(c+m),t[6]=d+y,t[7]=0,t[8]=p+g,t[9]=d-y,t[10]=1-(c+f),t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function o(t,e){var r=e[4],n=e[5],i=e[6],a=e[8],s=e[9],o=e[10];return t[0]=Math.hypot(e[0],e[1],e[2]),t[1]=Math.hypot(r,n,i),t[2]=Math.hypot(a,s,o),t}function l(t,e,r,n,i){var a,s=1/Math.tan(e/2);return t[0]=s/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=s,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=i&&i!==1/0?(t[10]=(i+n)*(a=1/(n-i)),t[14]=2*i*n*a):(t[10]=-1,t[14]=-2*n),t}function u(t,e,r,n,i,a,s){var o=1/(e-r),l=1/(n-i),u=1/(a-s);return t[0]=-2*o,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*u,t[11]=0,t[12]=(e+r)*o,t[13]=(i+n)*l,t[14]=(s+a)*u,t[15]=1,t}function c(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t[4]=e[4]-r[4],t[5]=e[5]-r[5],t[6]=e[6]-r[6],t[7]=e[7]-r[7],t[8]=e[8]-r[8],t[9]=e[9]-r[9],t[10]=e[10]-r[10],t[11]=e[11]-r[11],t[12]=e[12]-r[12],t[13]=e[13]-r[13],t[14]=e[14]-r[14],t[15]=e[15]-r[15],t}return y.perspective=l,y.ortho=u,y.mul=i,y.sub=c,y}var x,v={},b={};function w(){if(x)return b;function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}x=1,Object.defineProperty(b,"__esModule",{value:!0}),b.create=n,b.clone=function(t){var r=new e.ARRAY_TYPE(3);return r[0]=t[0],r[1]=t[1],r[2]=t[2],r},b.length=i,b.fromValues=function(t,r,n){var i=new e.ARRAY_TYPE(3);return i[0]=t,i[1]=r,i[2]=n,i},b.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},b.set=function(t,e,r,n){return t[0]=e,t[1]=r,t[2]=n,t},b.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t},b.subtract=s,b.multiply=o,b.divide=l,b.ceil=function(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t},b.floor=function(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t},b.min=function(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t},b.max=function(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t},b.round=function(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t[2]=Math.round(e[2]),t},b.scale=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t},b.scaleAndAdd=function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t},b.distance=u,b.squaredDistance=c,b.squaredLength=h,b.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t},b.inverse=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t},b.normalize=function(t,e){var r=e[0],n=e[1],i=e[2],a=r*r+n*n+i*i;return a>0&&(a=1/Math.sqrt(a)),t[0]=e[0]*a,t[1]=e[1]*a,t[2]=e[2]*a,t},b.dot=p,b.cross=function(t,e,r){var n=e[0],i=e[1],a=e[2],s=r[0],o=r[1],l=r[2];return t[0]=i*l-a*o,t[1]=a*s-n*l,t[2]=n*o-i*s,t},b.lerp=function(t,e,r,n){var i=e[0],a=e[1],s=e[2];return t[0]=i+n*(r[0]-i),t[1]=a+n*(r[1]-a),t[2]=s+n*(r[2]-s),t},b.hermite=function(t,e,r,n,i,a){var s=a*a,o=s*(2*a-3)+1,l=s*(a-2)+a,u=s*(a-1),c=s*(3-2*a);return t[0]=e[0]*o+r[0]*l+n[0]*u+i[0]*c,t[1]=e[1]*o+r[1]*l+n[1]*u+i[1]*c,t[2]=e[2]*o+r[2]*l+n[2]*u+i[2]*c,t},b.bezier=function(t,e,r,n,i,a){var s=1-a,o=s*s,l=a*a,u=o*s,c=3*a*o,h=3*l*s,p=l*a;return t[0]=e[0]*u+r[0]*c+n[0]*h+i[0]*p,t[1]=e[1]*u+r[1]*c+n[1]*h+i[1]*p,t[2]=e[2]*u+r[2]*c+n[2]*h+i[2]*p,t},b.random=function(t,r){r=r||1;var n=2*e.RANDOM()*Math.PI,i=2*e.RANDOM()-1,a=Math.sqrt(1-i*i)*r;return t[0]=Math.cos(n)*a,t[1]=Math.sin(n)*a,t[2]=i*r,t},b.transformMat4=function(t,e,r){var n=e[0],i=e[1],a=e[2],s=r[3]*n+r[7]*i+r[11]*a+r[15];return t[0]=(r[0]*n+r[4]*i+r[8]*a+r[12])/(s=s||1),t[1]=(r[1]*n+r[5]*i+r[9]*a+r[13])/s,t[2]=(r[2]*n+r[6]*i+r[10]*a+r[14])/s,t},b.transformMat3=function(t,e,r){var n=e[0],i=e[1],a=e[2];return t[0]=n*r[0]+i*r[3]+a*r[6],t[1]=n*r[1]+i*r[4]+a*r[7],t[2]=n*r[2]+i*r[5]+a*r[8],t},b.transformQuat=function(t,e,r){var n=r[0],i=r[1],a=r[2],s=e[0],o=e[1],l=e[2],u=i*l-a*o,c=a*s-n*l,h=n*o-i*s,p=i*h-a*c,f=a*u-n*h,d=n*c-i*u,m=2*r[3];return c*=m,h*=m,f*=2,d*=2,t[0]=s+(u*=m)+(p*=2),t[1]=o+c+f,t[2]=l+h+d,t},b.rotateX=function(t,e,r,n){var i=[],a=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],a[0]=i[0],a[1]=i[1]*Math.cos(n)-i[2]*Math.sin(n),a[2]=i[1]*Math.sin(n)+i[2]*Math.cos(n),t[0]=a[0]+r[0],t[1]=a[1]+r[1],t[2]=a[2]+r[2],t},b.rotateY=function(t,e,r,n){var i=[],a=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],a[0]=i[2]*Math.sin(n)+i[0]*Math.cos(n),a[1]=i[1],a[2]=i[2]*Math.cos(n)-i[0]*Math.sin(n),t[0]=a[0]+r[0],t[1]=a[1]+r[1],t[2]=a[2]+r[2],t},b.rotateZ=function(t,e,r,n){var i=[],a=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],a[0]=i[0]*Math.cos(n)-i[1]*Math.sin(n),a[1]=i[0]*Math.sin(n)+i[1]*Math.cos(n),a[2]=i[2],t[0]=a[0]+r[0],t[1]=a[1]+r[1],t[2]=a[2]+r[2],t},b.angle=function(t,e){var r=t[0],n=t[1],i=t[2],a=e[0],s=e[1],o=e[2],l=Math.sqrt(r*r+n*n+i*i)*Math.sqrt(a*a+s*s+o*o),u=l&&p(t,e)/l;return Math.acos(Math.min(Math.max(u,-1),1))},b.zero=function(t){return t[0]=0,t[1]=0,t[2]=0,t},b.str=function(t){return "vec3("+t[0]+", "+t[1]+", "+t[2]+")"},b.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]},b.equals=function(t,r){var n=t[0],i=t[1],a=t[2],s=r[0],o=r[1],l=r[2];return Math.abs(n-s)<=e.EPSILON*Math.max(1,Math.abs(n),Math.abs(s))&&Math.abs(i-o)<=e.EPSILON*Math.max(1,Math.abs(i),Math.abs(o))&&Math.abs(a-l)<=e.EPSILON*Math.max(1,Math.abs(a),Math.abs(l))},b.forEach=b.sqrLen=b.len=b.sqrDist=b.dist=b.div=b.mul=b.sub=void 0;var e=function(e,n){if(e&&e.__esModule)return e;if(null===e||"object"!==t(e)&&"function"!=typeof e)return {default:e};var i=r(void 0);if(i&&i.has(e))return i.get(e);var a={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var l=s?Object.getOwnPropertyDescriptor(e,o):null;l&&(l.get||l.set)?Object.defineProperty(a,o,l):a[o]=e[o];}return a.default=e,i&&i.set(e,a),a}(a());function r(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,n=new WeakMap;return (r=function(t){return t?n:e})(t)}function n(){var t=new e.ARRAY_TYPE(3);return e.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function i(t){return Math.hypot(t[0],t[1],t[2])}function s(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function o(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t}function l(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t}function u(t,e){return Math.hypot(e[0]-t[0],e[1]-t[1],e[2]-t[2])}function c(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2];return r*r+n*n+i*i}function h(t){var e=t[0],r=t[1],n=t[2];return e*e+r*r+n*n}function p(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}b.sub=s,b.mul=o,b.div=l,b.dist=u,b.sqrDist=c,b.len=i,b.sqrLen=h;var f,d=(f=n(),function(t,e,r,n,i,a){var s,o;for(e||(e=3),r||(r=0),o=n?Math.min(n*e+r,t.length):t.length,s=r;s<o;s+=e)f[0]=t[s],f[1]=t[s+1],f[2]=t[s+2],i(f,f,a),t[s]=f[0],t[s+1]=f[1],t[s+2]=f[2];return t});return b.forEach=d,b}var _,M,A={};function S(){if(_)return A;function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}_=1,Object.defineProperty(A,"__esModule",{value:!0}),A.create=n,A.clone=function(t){var r=new e.ARRAY_TYPE(4);return r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[3],r},A.fromValues=function(t,r,n,i){var a=new e.ARRAY_TYPE(4);return a[0]=t,a[1]=r,a[2]=n,a[3]=i,a},A.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},A.set=function(t,e,r,n,i){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t},A.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t},A.subtract=i,A.multiply=s,A.divide=o,A.ceil=function(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t[3]=Math.ceil(e[3]),t},A.floor=function(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t[3]=Math.floor(e[3]),t},A.min=function(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t[3]=Math.min(e[3],r[3]),t},A.max=function(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t[3]=Math.max(e[3],r[3]),t},A.round=function(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t[2]=Math.round(e[2]),t[3]=Math.round(e[3]),t},A.scale=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t},A.scaleAndAdd=function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t},A.distance=l,A.squaredDistance=u,A.length=c,A.squaredLength=h,A.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=-e[3],t},A.inverse=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t[3]=1/e[3],t},A.normalize=function(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],s=r*r+n*n+i*i+a*a;return s>0&&(s=1/Math.sqrt(s)),t[0]=r*s,t[1]=n*s,t[2]=i*s,t[3]=a*s,t},A.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]},A.cross=function(t,e,r,n){var i=r[0]*n[1]-r[1]*n[0],a=r[0]*n[2]-r[2]*n[0],s=r[0]*n[3]-r[3]*n[0],o=r[1]*n[2]-r[2]*n[1],l=r[1]*n[3]-r[3]*n[1],u=r[2]*n[3]-r[3]*n[2],c=e[0],h=e[1],p=e[2],f=e[3];return t[0]=h*u-p*l+f*o,t[1]=-c*u+p*s-f*a,t[2]=c*l-h*s+f*i,t[3]=-c*o+h*a-p*i,t},A.lerp=function(t,e,r,n){var i=e[0],a=e[1],s=e[2],o=e[3];return t[0]=i+n*(r[0]-i),t[1]=a+n*(r[1]-a),t[2]=s+n*(r[2]-s),t[3]=o+n*(r[3]-o),t},A.random=function(t,r){var n,i,a,s,o,l;r=r||1;do{o=(n=2*e.RANDOM()-1)*n+(i=2*e.RANDOM()-1)*i;}while(o>=1);do{l=(a=2*e.RANDOM()-1)*a+(s=2*e.RANDOM()-1)*s;}while(l>=1);var u=Math.sqrt((1-o)/l);return t[0]=r*n,t[1]=r*i,t[2]=r*a*u,t[3]=r*s*u,t},A.transformMat4=function(t,e,r){var n=e[0],i=e[1],a=e[2],s=e[3];return t[0]=r[0]*n+r[4]*i+r[8]*a+r[12]*s,t[1]=r[1]*n+r[5]*i+r[9]*a+r[13]*s,t[2]=r[2]*n+r[6]*i+r[10]*a+r[14]*s,t[3]=r[3]*n+r[7]*i+r[11]*a+r[15]*s,t},A.transformQuat=function(t,e,r){var n=e[0],i=e[1],a=e[2],s=r[0],o=r[1],l=r[2],u=r[3],c=u*n+o*a-l*i,h=u*i+l*n-s*a,p=u*a+s*i-o*n,f=-s*n-o*i-l*a;return t[0]=c*u+f*-s+h*-l-p*-o,t[1]=h*u+f*-o+p*-s-c*-l,t[2]=p*u+f*-l+c*-o-h*-s,t[3]=e[3],t},A.zero=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t},A.str=function(t){return "vec4("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"},A.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]},A.equals=function(t,r){var n=t[0],i=t[1],a=t[2],s=t[3],o=r[0],l=r[1],u=r[2],c=r[3];return Math.abs(n-o)<=e.EPSILON*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(i-l)<=e.EPSILON*Math.max(1,Math.abs(i),Math.abs(l))&&Math.abs(a-u)<=e.EPSILON*Math.max(1,Math.abs(a),Math.abs(u))&&Math.abs(s-c)<=e.EPSILON*Math.max(1,Math.abs(s),Math.abs(c))},A.forEach=A.sqrLen=A.len=A.sqrDist=A.dist=A.div=A.mul=A.sub=void 0;var e=function(e,n){if(e&&e.__esModule)return e;if(null===e||"object"!==t(e)&&"function"!=typeof e)return {default:e};var i=r(void 0);if(i&&i.has(e))return i.get(e);var a={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var l=s?Object.getOwnPropertyDescriptor(e,o):null;l&&(l.get||l.set)?Object.defineProperty(a,o,l):a[o]=e[o];}return a.default=e,i&&i.set(e,a),a}(a());function r(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,n=new WeakMap;return (r=function(t){return t?n:e})(t)}function n(){var t=new e.ARRAY_TYPE(4);return e.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function i(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t}function s(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t[3]=e[3]*r[3],t}function o(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t[3]=e[3]/r[3],t}function l(t,e){return Math.hypot(e[0]-t[0],e[1]-t[1],e[2]-t[2],e[3]-t[3])}function u(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2],a=e[3]-t[3];return r*r+n*n+i*i+a*a}function c(t){return Math.hypot(t[0],t[1],t[2],t[3])}function h(t){var e=t[0],r=t[1],n=t[2],i=t[3];return e*e+r*r+n*n+i*i}A.sub=i,A.mul=s,A.div=o,A.dist=l,A.sqrDist=u,A.len=c,A.sqrLen=h;var p,f=(p=n(),function(t,e,r,n,i,a){var s,o;for(e||(e=4),r||(r=0),o=n?Math.min(n*e+r,t.length):t.length,s=r;s<o;s+=e)p[0]=t[s],p[1]=t[s+1],p[2]=t[s+2],p[3]=t[s+3],i(p,p,a),t[s]=p[0],t[s+1]=p[1],t[s+2]=p[2],t[s+3]=p[3];return t});return A.forEach=f,A}function I(){if(M)return v;function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}M=1,Object.defineProperty(v,"__esModule",{value:!0}),v.create=l,v.identity=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t},v.setAxisAngle=u,v.getAxisAngle=function(t,r){var n=2*Math.acos(r[3]),i=Math.sin(n/2);return i>e.EPSILON?(t[0]=r[0]/i,t[1]=r[1]/i,t[2]=r[2]/i):(t[0]=1,t[1]=0,t[2]=0),n},v.getAngle=function(t,e){var r=g(t,e);return Math.acos(2*r*r-1)},v.multiply=c,v.rotateX=function(t,e,r){r*=.5;var n=e[0],i=e[1],a=e[2],s=e[3],o=Math.sin(r),l=Math.cos(r);return t[0]=n*l+s*o,t[1]=i*l+a*o,t[2]=a*l-i*o,t[3]=s*l-n*o,t},v.rotateY=function(t,e,r){r*=.5;var n=e[0],i=e[1],a=e[2],s=e[3],o=Math.sin(r),l=Math.cos(r);return t[0]=n*l-a*o,t[1]=i*l+s*o,t[2]=a*l+n*o,t[3]=s*l-i*o,t},v.rotateZ=function(t,e,r){r*=.5;var n=e[0],i=e[1],a=e[2],s=e[3],o=Math.sin(r),l=Math.cos(r);return t[0]=n*l+i*o,t[1]=i*l-n*o,t[2]=a*l+s*o,t[3]=s*l-a*o,t},v.calculateW=function(t,e){var r=e[0],n=e[1],i=e[2];return t[0]=r,t[1]=n,t[2]=i,t[3]=Math.sqrt(Math.abs(1-r*r-n*n-i*i)),t},v.exp=h,v.ln=p,v.pow=function(t,e,r){return p(t,e),y(t,t,r),h(t,t),t},v.slerp=f,v.random=function(t){var r=e.RANDOM(),n=e.RANDOM(),i=e.RANDOM(),a=Math.sqrt(1-r),s=Math.sqrt(r);return t[0]=a*Math.sin(2*Math.PI*n),t[1]=a*Math.cos(2*Math.PI*n),t[2]=s*Math.sin(2*Math.PI*i),t[3]=s*Math.cos(2*Math.PI*i),t},v.invert=function(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],s=r*r+n*n+i*i+a*a,o=s?1/s:0;return t[0]=-r*o,t[1]=-n*o,t[2]=-i*o,t[3]=a*o,t},v.conjugate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t},v.fromMat3=m,v.fromEuler=function(t,e,r,n){var i=.5*Math.PI/180;e*=i,r*=i,n*=i;var a=Math.sin(e),s=Math.cos(e),o=Math.sin(r),l=Math.cos(r),u=Math.sin(n),c=Math.cos(n);return t[0]=a*l*c-s*o*u,t[1]=s*o*c+a*l*u,t[2]=s*l*u-a*o*c,t[3]=s*l*c+a*o*u,t},v.str=function(t){return "quat("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"},v.setAxes=v.sqlerp=v.rotationTo=v.equals=v.exactEquals=v.normalize=v.sqrLen=v.squaredLength=v.len=v.length=v.lerp=v.dot=v.scale=v.mul=v.add=v.set=v.copy=v.fromValues=v.clone=void 0;var e=o(a()),r=o(d()),n=o(w()),i=o(S());function s(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,r=new WeakMap;return (s=function(t){return t?r:e})(t)}function o(e,r){if(e&&e.__esModule)return e;if(null===e||"object"!==t(e)&&"function"!=typeof e)return {default:e};var n=s(r);if(n&&n.has(e))return n.get(e);var i={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var l=a?Object.getOwnPropertyDescriptor(e,o):null;l&&(l.get||l.set)?Object.defineProperty(i,o,l):i[o]=e[o];}return i.default=e,n&&n.set(e,i),i}function l(){var t=new e.ARRAY_TYPE(4);return e.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function u(t,e,r){r*=.5;var n=Math.sin(r);return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=Math.cos(r),t}function c(t,e,r){var n=e[0],i=e[1],a=e[2],s=e[3],o=r[0],l=r[1],u=r[2],c=r[3];return t[0]=n*c+s*o+i*u-a*l,t[1]=i*c+s*l+a*o-n*u,t[2]=a*c+s*u+n*l-i*o,t[3]=s*c-n*o-i*l-a*u,t}function h(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],s=Math.sqrt(r*r+n*n+i*i),o=Math.exp(a),l=s>0?o*Math.sin(s)/s:0;return t[0]=r*l,t[1]=n*l,t[2]=i*l,t[3]=o*Math.cos(s),t}function p(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],s=Math.sqrt(r*r+n*n+i*i),o=s>0?Math.atan2(s,a)/s:0;return t[0]=r*o,t[1]=n*o,t[2]=i*o,t[3]=.5*Math.log(r*r+n*n+i*i+a*a),t}function f(t,r,n,i){var a,s,o,l,u,c=r[0],h=r[1],p=r[2],f=r[3],d=n[0],m=n[1],y=n[2],g=n[3];return (s=c*d+h*m+p*y+f*g)<0&&(s=-s,d=-d,m=-m,y=-y,g=-g),1-s>e.EPSILON?(a=Math.acos(s),o=Math.sin(a),l=Math.sin((1-i)*a)/o,u=Math.sin(i*a)/o):(l=1-i,u=i),t[0]=l*c+u*d,t[1]=l*h+u*m,t[2]=l*p+u*y,t[3]=l*f+u*g,t}function m(t,e){var r,n=e[0]+e[4]+e[8];if(n>0)r=Math.sqrt(n+1),t[3]=.5*r,t[0]=(e[5]-e[7])*(r=.5/r),t[1]=(e[6]-e[2])*r,t[2]=(e[1]-e[3])*r;else {var i=0;e[4]>e[0]&&(i=1),e[8]>e[3*i+i]&&(i=2);var a=(i+1)%3,s=(i+2)%3;r=Math.sqrt(e[3*i+i]-e[3*a+a]-e[3*s+s]+1),t[i]=.5*r,t[3]=(e[3*a+s]-e[3*s+a])*(r=.5/r),t[a]=(e[3*a+i]+e[3*i+a])*r,t[s]=(e[3*s+i]+e[3*i+s])*r;}return t}v.clone=i.clone,v.fromValues=i.fromValues,v.copy=i.copy,v.set=i.set,v.add=i.add,v.mul=c;var y=i.scale;v.scale=y;var g=i.dot;v.dot=g,v.lerp=i.lerp;var x=i.length;v.length=x,v.len=x;var b=i.squaredLength;v.squaredLength=b,v.sqrLen=b;var _=i.normalize;v.normalize=_,v.exactEquals=i.exactEquals,v.equals=i.equals;var A,I,z,P=(A=n.create(),I=n.fromValues(1,0,0),z=n.fromValues(0,1,0),function(t,e,r){var i=n.dot(e,r);return i<-.999999?(n.cross(A,I,e),n.len(A)<1e-6&&n.cross(A,z,e),n.normalize(A,A),u(t,A,Math.PI),t):i>.999999?(t[0]=0,t[1]=0,t[2]=0,t[3]=1,t):(n.cross(A,e,r),t[0]=A[0],t[1]=A[1],t[2]=A[2],t[3]=1+i,_(t,t))});v.rotationTo=P;var k,T,E=(k=l(),T=l(),function(t,e,r,n,i,a){return f(k,e,i,a),f(T,r,n,a),f(t,k,T,2*a*(1-a)),t});v.sqlerp=E;var B,V=(B=r.create(),function(t,e,r,n){return B[0]=r[0],B[3]=r[1],B[6]=r[2],B[1]=n[0],B[4]=n[1],B[7]=n[2],B[2]=-e[0],B[5]=-e[1],B[8]=-e[2],_(t,m(t,B))});return v.setAxes=V,v}var z,P={};function k(){if(z)return P;function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}z=1,Object.defineProperty(P,"__esModule",{value:!0}),P.create=function(){var t=new e.ARRAY_TYPE(8);return e.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[4]=0,t[5]=0,t[6]=0,t[7]=0),t[3]=1,t},P.clone=function(t){var r=new e.ARRAY_TYPE(8);return r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[3],r[4]=t[4],r[5]=t[5],r[6]=t[6],r[7]=t[7],r},P.fromValues=function(t,r,n,i,a,s,o,l){var u=new e.ARRAY_TYPE(8);return u[0]=t,u[1]=r,u[2]=n,u[3]=i,u[4]=a,u[5]=s,u[6]=o,u[7]=l,u},P.fromRotationTranslationValues=function(t,r,n,i,a,s,o){var l=new e.ARRAY_TYPE(8);l[0]=t,l[1]=r,l[2]=n,l[3]=i;var u=.5*a,c=.5*s,h=.5*o;return l[4]=u*i+c*n-h*r,l[5]=c*i+h*t-u*n,l[6]=h*i+u*r-c*t,l[7]=-u*t-c*r-h*n,l},P.fromRotationTranslation=o,P.fromTranslation=function(t,e){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t[4]=.5*e[0],t[5]=.5*e[1],t[6]=.5*e[2],t[7]=0,t},P.fromRotation=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=0,t[5]=0,t[6]=0,t[7]=0,t},P.fromMat4=function(t,i){var a=r.create();n.getRotation(a,i);var s=new e.ARRAY_TYPE(3);return n.getTranslation(s,i),o(t,a,s),t},P.copy=l,P.identity=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t[6]=0,t[7]=0,t},P.set=function(t,e,r,n,i,a,s,o,l){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t[4]=a,t[5]=s,t[6]=o,t[7]=l,t},P.getDual=function(t,e){return t[0]=e[4],t[1]=e[5],t[2]=e[6],t[3]=e[7],t},P.setDual=function(t,e){return t[4]=e[0],t[5]=e[1],t[6]=e[2],t[7]=e[3],t},P.getTranslation=function(t,e){var r=e[4],n=e[5],i=e[6],a=e[7],s=-e[0],o=-e[1],l=-e[2],u=e[3];return t[0]=2*(r*u+a*s+n*l-i*o),t[1]=2*(n*u+a*o+i*s-r*l),t[2]=2*(i*u+a*l+r*o-n*s),t},P.translate=function(t,e,r){var n=e[0],i=e[1],a=e[2],s=e[3],o=.5*r[0],l=.5*r[1],u=.5*r[2],c=e[4],h=e[5],p=e[6],f=e[7];return t[0]=n,t[1]=i,t[2]=a,t[3]=s,t[4]=s*o+i*u-a*l+c,t[5]=s*l+a*o-n*u+h,t[6]=s*u+n*l-i*o+p,t[7]=-n*o-i*l-a*u+f,t},P.rotateX=function(t,e,n){var i=-e[0],a=-e[1],s=-e[2],o=e[3],l=e[4],u=e[5],c=e[6],h=e[7],p=l*o+h*i+u*s-c*a,f=u*o+h*a+c*i-l*s,d=c*o+h*s+l*a-u*i,m=h*o-l*i-u*a-c*s;return r.rotateX(t,e,n),t[4]=p*(o=t[3])+m*(i=t[0])+f*(s=t[2])-d*(a=t[1]),t[5]=f*o+m*a+d*i-p*s,t[6]=d*o+m*s+p*a-f*i,t[7]=m*o-p*i-f*a-d*s,t},P.rotateY=function(t,e,n){var i=-e[0],a=-e[1],s=-e[2],o=e[3],l=e[4],u=e[5],c=e[6],h=e[7],p=l*o+h*i+u*s-c*a,f=u*o+h*a+c*i-l*s,d=c*o+h*s+l*a-u*i,m=h*o-l*i-u*a-c*s;return r.rotateY(t,e,n),t[4]=p*(o=t[3])+m*(i=t[0])+f*(s=t[2])-d*(a=t[1]),t[5]=f*o+m*a+d*i-p*s,t[6]=d*o+m*s+p*a-f*i,t[7]=m*o-p*i-f*a-d*s,t},P.rotateZ=function(t,e,n){var i=-e[0],a=-e[1],s=-e[2],o=e[3],l=e[4],u=e[5],c=e[6],h=e[7],p=l*o+h*i+u*s-c*a,f=u*o+h*a+c*i-l*s,d=c*o+h*s+l*a-u*i,m=h*o-l*i-u*a-c*s;return r.rotateZ(t,e,n),t[4]=p*(o=t[3])+m*(i=t[0])+f*(s=t[2])-d*(a=t[1]),t[5]=f*o+m*a+d*i-p*s,t[6]=d*o+m*s+p*a-f*i,t[7]=m*o-p*i-f*a-d*s,t},P.rotateByQuatAppend=function(t,e,r){var n=r[0],i=r[1],a=r[2],s=r[3],o=e[0],l=e[1],u=e[2],c=e[3];return t[0]=o*s+c*n+l*a-u*i,t[1]=l*s+c*i+u*n-o*a,t[2]=u*s+c*a+o*i-l*n,t[3]=c*s-o*n-l*i-u*a,t[4]=(o=e[4])*s+(c=e[7])*n+(l=e[5])*a-(u=e[6])*i,t[5]=l*s+c*i+u*n-o*a,t[6]=u*s+c*a+o*i-l*n,t[7]=c*s-o*n-l*i-u*a,t},P.rotateByQuatPrepend=function(t,e,r){var n=e[0],i=e[1],a=e[2],s=e[3],o=r[0],l=r[1],u=r[2],c=r[3];return t[0]=n*c+s*o+i*u-a*l,t[1]=i*c+s*l+a*o-n*u,t[2]=a*c+s*u+n*l-i*o,t[3]=s*c-n*o-i*l-a*u,t[4]=n*(c=r[7])+s*(o=r[4])+i*(u=r[6])-a*(l=r[5]),t[5]=i*c+s*l+a*o-n*u,t[6]=a*c+s*u+n*l-i*o,t[7]=s*c-n*o-i*l-a*u,t},P.rotateAroundAxis=function(t,r,n,i){if(Math.abs(i)<e.EPSILON)return l(t,r);var a=Math.hypot(n[0],n[1],n[2]);i*=.5;var s=Math.sin(i),o=s*n[0]/a,u=s*n[1]/a,c=s*n[2]/a,h=Math.cos(i),p=r[0],f=r[1],d=r[2],m=r[3];t[0]=p*h+m*o+f*c-d*u,t[1]=f*h+m*u+d*o-p*c,t[2]=d*h+m*c+p*u-f*o,t[3]=m*h-p*o-f*u-d*c;var y=r[4],g=r[5],x=r[6],v=r[7];return t[4]=y*h+v*o+g*c-x*u,t[5]=g*h+v*u+x*o-y*c,t[6]=x*h+v*c+y*u-g*o,t[7]=v*h-y*o-g*u-x*c,t},P.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t[6]=e[6]+r[6],t[7]=e[7]+r[7],t},P.multiply=u,P.scale=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t},P.lerp=function(t,e,r,n){var i=1-n;return c(e,r)<0&&(n=-n),t[0]=e[0]*i+r[0]*n,t[1]=e[1]*i+r[1]*n,t[2]=e[2]*i+r[2]*n,t[3]=e[3]*i+r[3]*n,t[4]=e[4]*i+r[4]*n,t[5]=e[5]*i+r[5]*n,t[6]=e[6]*i+r[6]*n,t[7]=e[7]*i+r[7]*n,t},P.invert=function(t,e){var r=p(e);return t[0]=-e[0]/r,t[1]=-e[1]/r,t[2]=-e[2]/r,t[3]=e[3]/r,t[4]=-e[4]/r,t[5]=-e[5]/r,t[6]=-e[6]/r,t[7]=e[7]/r,t},P.conjugate=function(t,e){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},P.normalize=function(t,e){var r=p(e);if(r>0){r=Math.sqrt(r);var n=e[0]/r,i=e[1]/r,a=e[2]/r,s=e[3]/r,o=e[4],l=e[5],u=e[6],c=e[7],h=n*o+i*l+a*u+s*c;t[0]=n,t[1]=i,t[2]=a,t[3]=s,t[4]=(o-n*h)/r,t[5]=(l-i*h)/r,t[6]=(u-a*h)/r,t[7]=(c-s*h)/r;}return t},P.str=function(t){return "quat2("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+")"},P.exactEquals=function(t,e){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]},P.equals=function(t,r){var n=t[0],i=t[1],a=t[2],s=t[3],o=t[4],l=t[5],u=t[6],c=t[7],h=r[0],p=r[1],f=r[2],d=r[3],m=r[4],y=r[5],g=r[6],x=r[7];return Math.abs(n-h)<=e.EPSILON*Math.max(1,Math.abs(n),Math.abs(h))&&Math.abs(i-p)<=e.EPSILON*Math.max(1,Math.abs(i),Math.abs(p))&&Math.abs(a-f)<=e.EPSILON*Math.max(1,Math.abs(a),Math.abs(f))&&Math.abs(s-d)<=e.EPSILON*Math.max(1,Math.abs(s),Math.abs(d))&&Math.abs(o-m)<=e.EPSILON*Math.max(1,Math.abs(o),Math.abs(m))&&Math.abs(l-y)<=e.EPSILON*Math.max(1,Math.abs(l),Math.abs(y))&&Math.abs(u-g)<=e.EPSILON*Math.max(1,Math.abs(u),Math.abs(g))&&Math.abs(c-x)<=e.EPSILON*Math.max(1,Math.abs(c),Math.abs(x))},P.sqrLen=P.squaredLength=P.len=P.length=P.dot=P.mul=P.setReal=P.getReal=void 0;var e=s(a()),r=s(I()),n=s(g());function i(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,r=new WeakMap;return (i=function(t){return t?r:e})(t)}function s(e,r){if(e&&e.__esModule)return e;if(null===e||"object"!==t(e)&&"function"!=typeof e)return {default:e};var n=i(r);if(n&&n.has(e))return n.get(e);var a={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var l=s?Object.getOwnPropertyDescriptor(e,o):null;l&&(l.get||l.set)?Object.defineProperty(a,o,l):a[o]=e[o];}return a.default=e,n&&n.set(e,a),a}function o(t,e,r){var n=.5*r[0],i=.5*r[1],a=.5*r[2],s=e[0],o=e[1],l=e[2],u=e[3];return t[0]=s,t[1]=o,t[2]=l,t[3]=u,t[4]=n*u+i*l-a*o,t[5]=i*u+a*s-n*l,t[6]=a*u+n*o-i*s,t[7]=-n*s-i*o-a*l,t}function l(t,e){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}function u(t,e,r){var n=e[0],i=e[1],a=e[2],s=e[3],o=r[4],l=r[5],u=r[6],c=r[7],h=e[4],p=e[5],f=e[6],d=e[7],m=r[0],y=r[1],g=r[2],x=r[3];return t[0]=n*x+s*m+i*g-a*y,t[1]=i*x+s*y+a*m-n*g,t[2]=a*x+s*g+n*y-i*m,t[3]=s*x-n*m-i*y-a*g,t[4]=n*c+s*o+i*u-a*l+h*x+d*m+p*g-f*y,t[5]=i*c+s*l+a*o-n*u+p*x+d*y+f*m-h*g,t[6]=a*c+s*u+n*l-i*o+f*x+d*g+h*y-p*m,t[7]=s*c-n*o-i*l-a*u+d*x-h*m-p*y-f*g,t}P.getReal=r.copy,P.setReal=r.copy,P.mul=u;var c=r.dot;P.dot=c;var h=r.length;P.length=h,P.len=h;var p=r.squaredLength;return P.squaredLength=p,P.sqrLen=p,P}var T,E,B={};function V(){if(T)return B;function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}T=1,Object.defineProperty(B,"__esModule",{value:!0}),B.create=n,B.clone=function(t){var r=new e.ARRAY_TYPE(2);return r[0]=t[0],r[1]=t[1],r},B.fromValues=function(t,r){var n=new e.ARRAY_TYPE(2);return n[0]=t,n[1]=r,n},B.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t},B.set=function(t,e,r){return t[0]=e,t[1]=r,t},B.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t},B.subtract=i,B.multiply=s,B.divide=o,B.ceil=function(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t},B.floor=function(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t},B.min=function(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t},B.max=function(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t},B.round=function(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t},B.scale=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t},B.scaleAndAdd=function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t},B.distance=l,B.squaredDistance=u,B.length=c,B.squaredLength=h,B.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t},B.inverse=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t},B.normalize=function(t,e){var r=e[0],n=e[1],i=r*r+n*n;return i>0&&(i=1/Math.sqrt(i)),t[0]=e[0]*i,t[1]=e[1]*i,t},B.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]},B.cross=function(t,e,r){var n=e[0]*r[1]-e[1]*r[0];return t[0]=t[1]=0,t[2]=n,t},B.lerp=function(t,e,r,n){var i=e[0],a=e[1];return t[0]=i+n*(r[0]-i),t[1]=a+n*(r[1]-a),t},B.random=function(t,r){r=r||1;var n=2*e.RANDOM()*Math.PI;return t[0]=Math.cos(n)*r,t[1]=Math.sin(n)*r,t},B.transformMat2=function(t,e,r){var n=e[0],i=e[1];return t[0]=r[0]*n+r[2]*i,t[1]=r[1]*n+r[3]*i,t},B.transformMat2d=function(t,e,r){var n=e[0],i=e[1];return t[0]=r[0]*n+r[2]*i+r[4],t[1]=r[1]*n+r[3]*i+r[5],t},B.transformMat3=function(t,e,r){var n=e[0],i=e[1];return t[0]=r[0]*n+r[3]*i+r[6],t[1]=r[1]*n+r[4]*i+r[7],t},B.transformMat4=function(t,e,r){var n=e[0],i=e[1];return t[0]=r[0]*n+r[4]*i+r[12],t[1]=r[1]*n+r[5]*i+r[13],t},B.rotate=function(t,e,r,n){var i=e[0]-r[0],a=e[1]-r[1],s=Math.sin(n),o=Math.cos(n);return t[0]=i*o-a*s+r[0],t[1]=i*s+a*o+r[1],t},B.angle=function(t,e){var r=t[0],n=t[1],i=e[0],a=e[1],s=Math.sqrt(r*r+n*n)*Math.sqrt(i*i+a*a);return Math.acos(Math.min(Math.max(s&&(r*i+n*a)/s,-1),1))},B.zero=function(t){return t[0]=0,t[1]=0,t},B.str=function(t){return "vec2("+t[0]+", "+t[1]+")"},B.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]},B.equals=function(t,r){var n=t[0],i=t[1],a=r[0],s=r[1];return Math.abs(n-a)<=e.EPSILON*Math.max(1,Math.abs(n),Math.abs(a))&&Math.abs(i-s)<=e.EPSILON*Math.max(1,Math.abs(i),Math.abs(s))},B.forEach=B.sqrLen=B.sqrDist=B.dist=B.div=B.mul=B.sub=B.len=void 0;var e=function(e,n){if(e&&e.__esModule)return e;if(null===e||"object"!==t(e)&&"function"!=typeof e)return {default:e};var i=r(void 0);if(i&&i.has(e))return i.get(e);var a={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var l=s?Object.getOwnPropertyDescriptor(e,o):null;l&&(l.get||l.set)?Object.defineProperty(a,o,l):a[o]=e[o];}return a.default=e,i&&i.set(e,a),a}(a());function r(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,n=new WeakMap;return (r=function(t){return t?n:e})(t)}function n(){var t=new e.ARRAY_TYPE(2);return e.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0),t}function i(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t}function s(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t}function o(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t}function l(t,e){return Math.hypot(e[0]-t[0],e[1]-t[1])}function u(t,e){var r=e[0]-t[0],n=e[1]-t[1];return r*r+n*n}function c(t){return Math.hypot(t[0],t[1])}function h(t){var e=t[0],r=t[1];return e*e+r*r}B.len=c,B.sub=i,B.mul=s,B.div=o,B.dist=l,B.sqrDist=u,B.sqrLen=h;var p,f=(p=n(),function(t,e,r,n,i,a){var s,o;for(e||(e=2),r||(r=0),o=n?Math.min(n*e+r,t.length):t.length,s=r;s<o;s+=e)p[0]=t[s],p[1]=t[s+1],i(p,p,a),t[s]=p[0],t[s+1]=p[1];return t});return B.forEach=f,B}function C(){if(E)return n;function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}E=1,Object.defineProperty(n,"__esModule",{value:!0}),n.vec4=n.vec3=n.vec2=n.quat2=n.quat=n.mat4=n.mat3=n.mat2d=n.mat2=n.glMatrix=void 0;var e=x(a());n.glMatrix=e;var r=x(l());n.mat2=r;var i=x(h());n.mat2d=i;var s=x(d());n.mat3=s;var o=x(g());n.mat4=o;var u=x(I());n.quat=u;var c=x(k());n.quat2=c;var p=x(V());n.vec2=p;var f=x(w());n.vec3=f;var m=x(S());function y(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,r=new WeakMap;return (y=function(t){return t?r:e})(t)}function x(e,r){if(e&&e.__esModule)return e;if(null===e||"object"!==t(e)&&"function"!=typeof e)return {default:e};var n=y(r);if(n&&n.has(e))return n.get(e);var i={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in e)if("default"!==s&&Object.prototype.hasOwnProperty.call(e,s)){var o=a?Object.getOwnPropertyDescriptor(e,s):null;o&&(o.get||o.set)?Object.defineProperty(i,s,o):i[s]=e[s];}return i.default=e,n&&n.set(e,i),i}return n.vec4=m,n}var R,D,L,F,O=C(),U=function(){if(D)return R;function t(t,e,r,n){this.cx=3*t,this.bx=3*(r-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(n-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=r,this.p2y=n;}return D=1,R=t,t.prototype={sampleCurveX:function(t){return ((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return ((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return (3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,e){if(void 0===e&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var r=t,n=0;n<8;n++){var i=this.sampleCurveX(r)-t;if(Math.abs(i)<e)return r;var a=this.sampleCurveDerivativeX(r);if(Math.abs(a)<1e-6)break;r-=i/a;}var s=0,o=1;for(r=t,n=0;n<20&&(i=this.sampleCurveX(r),!(Math.abs(i-t)<e));n++)t>i?s=r:o=r,r=.5*(o-s)+s;return r},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}},R}(),j=e(U);function N(){if(F)return L;function t(t,e){this.x=t,this.y=e;}return F=1,L=t,t.prototype={clone:function(){return new t(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,r=t.y-this.y;return e*e+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=e,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),r=Math.sin(t),n=r*this.x+e*this.y;return this.x=e*this.x-r*this.y,this.y=n,this},_rotateAround:function(t,e){var r=Math.cos(t),n=Math.sin(t),i=e.y+n*(this.x-e.x)+r*(this.y-e.y);return this.x=e.x+r*(this.x-e.x)-n*(this.y-e.y),this.y=i,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},t.convert=function(e){return e instanceof t?e:Array.isArray(e)?new t(e[0],e[1]):e},L}var q=e(N());function $(t,e){if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return !1;for(let r=0;r<t.length;r++)if(!$(t[r],e[r]))return !1;return !0}if("object"==typeof t&&null!==t&&null!==e){if("object"!=typeof e)return !1;if(Object.keys(t).length!==Object.keys(e).length)return !1;for(const r in t)if(!$(t[r],e[r]))return !1;return !0}return t===e}const G=Math.PI/180,X=180/Math.PI;function Y(t){return t*G}function Z(t){return t*X}const W=[[0,0],[1,0],[1,1],[0,1]];function H(t){if(t<=0)return 0;if(t>=1)return 1;const e=t*t,r=e*t;return 4*(t<.5?r:3*(t-e)+r-.75)}function K(t,e,r,n){const i=new j(t,e,r,n);return function(t){return i.solve(t)}}const J=K(.25,.1,.25,1);function Q(t,e,r){return Math.min(r,Math.max(e,t))}function tt(t,e,r){return (r=Q((r-t)/(e-t),0,1))*r*(3-2*r)}function et(t,e,r){const n=r-e,i=((t-e)%n+n)%n+e;return i===e?r:i}function rt(t,e,r){if(!t.length)return r(null,[]);let n=t.length;const i=new Array(t.length);let a=null;t.forEach(((t,s)=>{e(t,((t,e)=>{t&&(a=t),i[s]=e,0==--n&&r(a,i);}));}));}function nt(t,...e){for(const r of e)for(const e in r)t[e]=r[e];return t}let it=1;function at(){return it++}function st(t){return t<=1?1:Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function ot(t,e){t.forEach((t=>{e[t]&&(e[t]=e[t].bind(e));}));}function lt(t,e){return -1!==t.indexOf(e,t.length-e.length)}function ut(t,e,r){const n={};for(const r in t)n[r]=e.call(this,t[r],r,t);return n}function ct(t,e,r){const n={};for(const r in t)e.call(this,t[r],r,t)&&(n[r]=t[r]);return n}function ht(t){return Array.isArray(t)?t.map(ht):"object"==typeof t&&t?ut(t,ht):t}const pt={};function ft(t){pt[t]||("undefined"!=typeof console&&console.warn(t),pt[t]=!0);}function dt(t,e,r){return (r.y-t.y)*(e.x-t.x)>(e.y-t.y)*(r.x-t.x)}function mt(t){let e=0;for(let r,n,i=0,a=t.length,s=a-1;i<a;s=i++)r=t[i],n=t[s],e+=(n.x-r.x)*(r.y+n.y);return e}function yt([t,e,r]){const n=Y(e+90),i=Y(r);return {x:t*Math.cos(n)*Math.sin(i),y:t*Math.sin(n)*Math.sin(i),z:t*Math.cos(i),azimuthal:e,polar:r}}function gt(){return "undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope}function xt(t){const e={};if(t.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((t,r,n,i)=>{const a=n||i;return e[r]=!a||a.toLowerCase(),""})),e["max-age"]){const t=parseInt(e["max-age"],10);isNaN(t)?delete e["max-age"]:e["max-age"]=t;}return e}let vt=null;function bt(t,e){return [t[4*e],t[4*e+1],t[4*e+2],t[4*e+3]]}function wt(t,e,r,n){for(;e<r;){const i=e+r>>1;t[i]<n?e=i+1:r=i;}return e}function _t(t,e,r,n){for(;e<r;){const i=e+r>>1;t[i]<=n?e=i+1:r=i;}return e}function Mt(t){return t>0?1/(1.001-t):1+t}function At(t){return t>0?1-1/(1.001-t):-t}const St={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(!St.API_URL)return null;try{const t=new URL(St.API_URL);return "api.mapbox.cn"===t.hostname?"https://events.mapbox.cn/events/v2":"api.mapbox.com"===t.hostname?"https://events.mapbox.com/events/v2":null}catch(t){return null}},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",RASTERARRAYS_URL_PREFIX:"rasterarrays/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,DEFAULT_STYLE:"mapbox://styles/mapbox/standard",MAX_PARALLEL_IMAGE_REQUESTS:16,DRACO_URL:"https://api.mapbox.com/mapbox-gl-js/draco_decoder_gltf_v1.5.6.wasm",MESHOPT_URL:"https://api.mapbox.com/mapbox-gl-js/meshopt_base_v0.20.wasm",MESHOPT_SIMD_URL:"https://api.mapbox.com/mapbox-gl-js/meshopt_simd_v0.20.wasm",GLYPHS_URL:"mapbox://fonts/mapbox/{fontstack}/{range}.pbf",TILES3D_URL_PREFIX:"3dtiles/v1"};function It(t){return St.API_URL_REGEX.test(t)}function zt(t){return St.API_SPRITE_REGEX.test(t)}let Pt,kt,Tt,Et,Bt,Vt;function Ct(){return null==Pt&&(Pt=self.OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof self.createImageBitmap),Pt}const Rt={now:()=>void 0!==Et?Et:performance.now(),setNow(t){Et=t;},restoreNow(){Et=void 0;},frame(t){const e=requestAnimationFrame(t);return {cancel:()=>cancelAnimationFrame(e)}},getImageData(t,e=0){const{width:r,height:n}=t;Bt||(Bt=document.createElement("canvas"));const i=Bt.getContext("2d",{willReadFrequently:!0});if(!i)throw new Error("failed to create canvas 2d context");return (r>Bt.width||n>Bt.height)&&(Bt.width=r,Bt.height=n),i.clearRect(-e,-e,r+2*e,n+2*e),i.drawImage(t,0,0,r,n),i.getImageData(-e,-e,r+2*e,n+2*e)},resolveURL:t=>(kt||(kt=document.createElement("a")),kt.href=t,kt.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return !!window.matchMedia&&(null==Tt&&(Tt=window.matchMedia("(prefers-reduced-motion: reduce)")),Tt.matches)},hasCanvasFingerprintNoise(){if(void 0!==Vt)return Vt;if(!Ct())return Vt=!1,!1;const t=new OffscreenCanvas(85,1),e=t.getContext("2d",{willReadFrequently:!0});let r=0;for(let n=0;n<t.width;++n)e.fillStyle=`rgba(${r++},${r++},${r++}, 255)`,e.fillRect(n,0,1,1);const n=e.getImageData(0,0,t.width,t.height);r=0;for(let t=0;t<n.data.length;++t)if(t%4!=3&&r++!==n.data[t])return Vt=!0,!0;return Vt=!1,!1}};function Dt(t,e){const r=t.indexOf("?");if(r<0)return `${t}?${new URLSearchParams(e).toString()}`;const n=new URLSearchParams(t.slice(r));for(const t in e)n.set(t,e[t]);return `${t.slice(0,r)}?${n.toString()}`}function Lt(t,e={persistentParams:[]}){const r=t.indexOf("?");if(r<0)return t;const n=new URLSearchParams,i=new URLSearchParams(t.slice(r));for(const t of e.persistentParams){const e=i.get(t);e&&n.set(t,e);}const a=n.toString();return `${t.slice(0,r)}${a.length>0?`?${a}`:""}`}const Ft="mapbox-tiles";let Ot=500,Ut=50;const jt=["language","worldview","jobid"];let Nt,qt;function $t(){try{return caches}catch(t){}}function Gt(){const t=$t();t&&null==Nt&&(Nt=t.open(Ft));}let Xt=1/0;const Yt={supported:!1,testSupport:function(t){!Ht&&Wt&&(Kt?Qt(t):Zt=t);}};let Zt,Wt,Ht=!1,Kt=!1;const Jt="undefined"!=typeof self?self:{};function Qt(t){const e=t.createTexture();t.bindTexture(t.TEXTURE_2D,e);try{if(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,Wt),t.isContextLost())return;Yt.supported=!0;}catch(t){}t.deleteTexture(e),Ht=!0;}Jt.document&&(Wt=Jt.document.createElement("img"),Wt.onload=function(){Zt&&Qt(Zt),Zt=null,Kt=!0;},Wt.onerror=function(){Ht=!0,Zt=null;},Wt.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const te={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image",Model:"Model"};"function"==typeof Object.freeze&&Object.freeze(te);class ee extends Error{constructor(t,e,r){401===e&&It(r)&&(t+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),super(t),this.status=e,this.url=r;}toString(){return `${this.name}: ${this.message} (${this.status}): ${this.url}`}}const re=gt()?()=>self.worker&&self.worker.referrer:()=>("blob:"===location.protocol?parent:self).location.href;const ne=function(t,e){if(!(/^file:/.test(r=t.url)||/^file:/.test(re())&&!/^\w+:/.test(r))){if(self.fetch&&self.Request&&self.AbortController&&Request.prototype.hasOwnProperty("signal"))return function(t,e){const r=new AbortController,n=new Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,referrer:re(),referrerPolicy:t.referrerPolicy,signal:r.signal});let i=!1,a=!1;const s=(o=n.url).indexOf("sku=")>0&&It(o);var o;"json"===t.type&&n.headers.set("Accept","application/json");const l=(r,i,o)=>{if(a)return;if(r&&"SecurityError"!==r.message&&ft(r.toString()),i&&o)return u(i);const l=Date.now();fetch(n).then((r=>{if(r.ok){const t=s?r.clone():null;return u(r,t,l)}return e(new ee(r.statusText,r.status,t.url))})).catch((r=>{"AbortError"!==r.name&&e(new Error(`${r.message} ${t.url}`));}));},u=(r,s,o)=>{("arrayBuffer"===t.type?r.arrayBuffer():"json"===t.type?r.json():r.text()).then((t=>{a||(s&&o&&function(t,e,r){if(Gt(),null==Nt)return;const n=xt(e.headers.get("Cache-Control")||"");if(n["no-store"])return;const i={status:e.status,statusText:e.statusText,headers:new Headers};e.headers.forEach(((t,e)=>i.headers.set(e,t))),n["max-age"]&&i.headers.set("Expires",new Date(r+1e3*n["max-age"]).toUTCString());const a=i.headers.get("Expires");if(!a)return;if(new Date(a).getTime()-r<42e4)return;let s=Lt(t.url,{persistentParams:jt});if(206===e.status){const e=t.headers.get("Range");if(!e)return;i.status=200,s=Dt(s,{range:e});}!function(t,e){if(void 0===qt)try{new Response(new ReadableStream),qt=!0;}catch(t){qt=!1;}qt?e(t.body):t.blob().then(e);}(e,(t=>{const r=new Response(200!==(n=e.status)&&404!==n&&[101,103,204,205,304].includes(n)?null:t,i);var n;Gt(),null!=Nt&&Nt.then((t=>t.put(s,r))).catch((t=>ft(t.message)));}));}(n,s,o),i=!0,e(null,t,r.headers.get("Cache-Control"),r.headers.get("Expires")));})).catch((t=>{a||e(new Error(t.message));}));};return s?function(t,e){if(Gt(),null==Nt)return e(null);Nt.then((r=>{let n=Lt(t.url,{persistentParams:jt});const i=t.headers.get("Range");i&&(n=Dt(n,{range:i})),r.match(n).then((t=>{const i=function(t){if(!t)return !1;const e=new Date(t.headers.get("Expires")||0),r=xt(t.headers.get("Cache-Control")||"");return e>Date.now()&&!r["no-cache"]}(t);r.delete(n),i&&r.put(n,t.clone()),e(null,t,i);})).catch(e);})).catch(e);}(n,l):l(null,null),{cancel:()=>{a=!0,i||r.abort();}}}(t,e);if(gt()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",t,e,void 0,!0)}var r;return function(t,e){const r=new XMLHttpRequest;r.open(t.method||"GET",t.url,!0),"arrayBuffer"===t.type&&(r.responseType="arraybuffer");for(const e in t.headers)r.setRequestHeader(e,t.headers[e]);return "json"===t.type&&(r.responseType="text",r.setRequestHeader("Accept","application/json")),r.withCredentials="include"===t.credentials,r.onerror=()=>{e(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"===t.type)try{n=JSON.parse(r.response);}catch(t){return e(t)}e(null,n,r.getResponseHeader("Cache-Control"),r.getResponseHeader("Expires"));}else e(new ee(r.statusText,r.status,t.url));},r.send(t.body),{cancel:()=>r.abort()}}(t,e)},ie=function(t,e){return ne(nt(t,{type:"arrayBuffer"}),e)};function ae(t){const e=document.createElement("a");return e.href=t,e.protocol===location.protocol&&e.host===location.host}const se="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let oe,le;oe=[],le=0;const ue=function(t,e){if(Yt.supported&&(t.headers||(t.headers={}),t.headers.accept="image/webp,*/*"),le>=St.MAX_PARALLEL_IMAGE_REQUESTS){const r={requestParameters:t,callback:e,cancelled:!1,cancel(){this.cancelled=!0;}};return oe.push(r),r}le++;let r=!1;const n=()=>{if(!r)for(r=!0,le--;oe.length&&le<St.MAX_PARALLEL_IMAGE_REQUESTS;){const t=oe.shift(),{requestParameters:e,callback:r,cancelled:n}=t;n||(t.cancel=ue(e,r).cancel);}},i=ie(t,((t,r,i,a)=>{n(),t?e(t):r&&(self.createImageBitmap?function(t,e){const r=new Blob([new Uint8Array(t)],{type:"image/png"});createImageBitmap(r).then((t=>{e(null,t);})).catch((t=>{e(new Error(`Could not load image because of ${t.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`));}));}(r,((t,r)=>e(t,r,i,a))):function(t,e){const r=new Image;r.onload=()=>{e(null,r),URL.revokeObjectURL(r.src),r.onload=null,requestAnimationFrame((()=>{r.src=se;}));},r.onerror=()=>e(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const n=new Blob([new Uint8Array(t)],{type:"image/png"});r.src=t.byteLength?URL.createObjectURL(n):se;}(r,((t,r)=>e(t,r,i,a))));}));return {cancel:()=>{i.cancel(),n();}}};var ce,he,pe,fe={exports:{}},de={exports:{}},me={exports:{}},ye=function(){if(pe)return fe.exports;pe=1;var t=(ce||(ce=1,de.exports=function(t,e){var r,n,i,a,s,o,l,u;for(n=t.length-(r=3&t.length),i=e,s=3432918353,o=461845907,u=0;u<n;)l=255&t.charCodeAt(u)|(255&t.charCodeAt(++u))<<8|(255&t.charCodeAt(++u))<<16|(255&t.charCodeAt(++u))<<24,++u,i=27492+(65535&(a=5*(65535&(i=(i^=l=(65535&(l=(l=(65535&l)*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*o+(((l>>>16)*o&65535)<<16)&4294967295)<<13|i>>>19))+((5*(i>>>16)&65535)<<16)&4294967295))+((58964+(a>>>16)&65535)<<16);switch(l=0,r){case 3:l^=(255&t.charCodeAt(u+2))<<16;case 2:l^=(255&t.charCodeAt(u+1))<<8;case 1:i^=l=(65535&(l=(l=(65535&(l^=255&t.charCodeAt(u)))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*o+(((l>>>16)*o&65535)<<16)&4294967295;}return i^=t.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}),de.exports),e=(he||(he=1,me.exports=function(t,e){for(var r,n=t.length,i=e^n,a=0;n>=4;)r=1540483477*(65535&(r=255&t.charCodeAt(a)|(255&t.charCodeAt(++a))<<8|(255&t.charCodeAt(++a))<<16|(255&t.charCodeAt(++a))<<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,++a;switch(n){case 3:i^=(255&t.charCodeAt(a+2))<<16;case 2:i^=(255&t.charCodeAt(a+1))<<8;case 1:i=1540483477*(65535&(i^=255&t.charCodeAt(a)))+((1540483477*(i>>>16)&65535)<<16);}return i=1540483477*(65535&(i^=i>>>13))+((1540483477*(i>>>16)&65535)<<16),(i^=i>>>15)>>>0}),me.exports);return fe.exports=t,fe.exports.murmur3=t,fe.exports.murmur2=e,fe.exports}(),ge=e(ye);class xe{constructor(t,...e){nt(this,e[0]||{}),this.type=t;}}class ve extends xe{constructor(t,e={}){super("error",nt({error:t},e));}}function be(t,e,r){r[t]&&-1!==r[t].indexOf(e)||(r[t]=r[t]||[],r[t].push(e));}function we(t,e,r){if(r&&r[t]){const n=r[t].indexOf(e);-1!==n&&r[t].splice(n,1);}}class _e{on(t,e){return this._listeners=this._listeners||{},be(t,e,this._listeners),this}off(t,e){return we(t,e,this._listeners),we(t,e,this._oneTimeListeners),this}once(t,e){return e?(this._oneTimeListeners=this._oneTimeListeners||{},be(t,e,this._oneTimeListeners),this):new Promise((e=>this.once(t,e)))}fire(t,e){const r="string"==typeof t?new xe(t,e):t,n=r.type;if(this.listens(n)){r.target=this;const t=this._listeners&&this._listeners[n]?this._listeners[n].slice():[];for(const e of t)e.call(this,r);const e=this._oneTimeListeners&&this._oneTimeListeners[n]?this._oneTimeListeners[n].slice():[];for(const t of e)we(n,t,this._oneTimeListeners),t.call(this,r);const i=this._eventedParent;i&&(nt(r,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),i.fire(r));}else r instanceof ve&&console.error(r.error);return this}listens(t){return !!(this._listeners&&this._listeners[t]&&this._listeners[t].length>0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t))}setEventedParent(t,e){return this._eventedParent=t,this._eventedParentData=e,this}}var Me,Ae={},Se=function(){if(Me)return Ae;Me=1;var t={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function e(t){return (t=Math.round(t))<0?0:t>255?255:t}function r(t){return e("%"===t[t.length-1]?parseFloat(t)/100*255:parseInt(t))}function n(t){return (e="%"===t[t.length-1]?parseFloat(t)/100:parseFloat(t))<0?0:e>1?1:e;var e;}function i(t,e,r){return r<0?r+=1:r>1&&(r-=1),6*r<1?t+(e-t)*r*6:2*r<1?e:3*r<2?t+(e-t)*(2/3-r)*6:t}try{Ae.parseCSSColor=function(a){var s,o=a.replace(/ /g,"").toLowerCase();if(o in t)return t[o].slice();if("#"===o[0])return 4===o.length?(s=parseInt(o.substr(1),16))>=0&&s<=4095?[(3840&s)>>4|(3840&s)>>8,240&s|(240&s)>>4,15&s|(15&s)<<4,1]:null:7===o.length&&(s=parseInt(o.substr(1),16))>=0&&s<=16777215?[(16711680&s)>>16,(65280&s)>>8,255&s,1]:null;var l=o.indexOf("("),u=o.indexOf(")");if(-1!==l&&u+1===o.length){var c=o.substr(0,l),h=o.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 f=(parseFloat(h[0])%360+360)%360/360,d=n(h[1]),m=n(h[2]),y=m<=.5?m*(d+1):m+d-m*d,g=2*m-y;return [e(255*i(g,y,f+1/3)),e(255*i(g,y,f)),e(255*i(g,y,f-1/3)),p];default:return null}}return null};}catch(t){}return Ae}();class Ie{constructor(t,e,r,n=1){this.r=t,this.g=e,this.b=r,this.a=n;}static parse(t){if(!t)return;if(t instanceof Ie)return t;if("string"!=typeof t)return;const e=Se.parseCSSColor(t);return e?new Ie(e[0]/255*e[3],e[1]/255*e[3],e[2]/255*e[3],e[3]):void 0}toString(){const[t,e,r,n]=0===this.a?[0,0,0,0]:[255*this.r/this.a,255*this.g/this.a,255*this.b/this.a,this.a];return `rgba(${Math.round(t)},${Math.round(e)},${Math.round(r)},${n})`}toRenderColor(t){const{r:e,g:r,b:n,a:i}=this;return new ze(t,e,r,n,i)}}class ze{constructor(t,e,r,n,i){if(t){const a=t.image.height,s=a*a;e=0===i?0:e/i*(a-1),r=0===i?0:r/i*(a-1),n=0===i?0:n/i*(a-1);const o=Math.floor(e),l=Math.floor(r),u=Math.floor(n),c=Math.ceil(e),h=Math.ceil(r),p=Math.ceil(n),f=e-o,d=r-l,m=n-u,y=t.image.data,g=4*(o+l*s+u*a),x=4*(o+l*s+p*a),v=4*(o+h*s+u*a),b=4*(o+h*s+p*a),w=4*(c+l*s+u*a),_=4*(c+l*s+p*a),M=4*(c+h*s+u*a),A=4*(c+h*s+p*a);if(g<0||A>=y.length)throw new Error("out of range");this.r=Pe(Pe(Pe(y[g],y[x],m),Pe(y[v],y[b],m),d),Pe(Pe(y[w],y[_],m),Pe(y[M],y[A],m),d),f)/255*i,this.g=Pe(Pe(Pe(y[g+1],y[x+1],m),Pe(y[v+1],y[b+1],m),d),Pe(Pe(y[w+1],y[_+1],m),Pe(y[M+1],y[A+1],m),d),f)/255*i,this.b=Pe(Pe(Pe(y[g+2],y[x+2],m),Pe(y[v+2],y[b+2],m),d),Pe(Pe(y[w+2],y[_+2],m),Pe(y[M+2],y[A+2],m),d),f)/255*i,this.a=i;}else this.r=e,this.g=r,this.b=n,this.a=i;}toArray(){const{r:t,g:e,b:r,a:n}=this;return 0===n?[0,0,0,0]:[255*t/n,255*e/n,255*r/n,n]}toArray01(){const{r:t,g:e,b:r,a:n}=this;return 0===n?[0,0,0,0]:[t/n,e/n,r/n,n]}toArray01Scaled(t){const{r:e,g:r,b:n,a:i}=this;return 0===i?[0,0,0]:[e/i*t,r/i*t,n/i*t]}toArray01PremultipliedAlpha(){const{r:t,g:e,b:r,a:n}=this;return [t,e,r,n]}toArray01Linear(){const{r:t,g:e,b:r,a:n}=this;return 0===n?[0,0,0,0]:[Math.pow(t/n,2.2),Math.pow(e/n,2.2),Math.pow(r/n,2.2),n]}}function Pe(t,e,r){return t*(1-r)+e*r}function ke(t,e,r){return t.map(((t,n)=>Pe(t,e[n],r)))}Ie.black=new Ie(0,0,0,1),Ie.white=new Ie(1,1,1,1),Ie.transparent=new Ie(0,0,0,0),Ie.red=new Ie(1,0,0,1),Ie.blue=new Ie(0,0,1,1);var Te=Object.freeze({__proto__:null,array:ke,color:function(t,e,r){return new Ie(Pe(t.r,e.r,r),Pe(t.g,e.g,r),Pe(t.b,e.b,r),Pe(t.a,e.a,r))},number:Pe});function Ee(t,...e){for(const r of e)for(const e in r)t[e]=r[e];return t}class Be extends Error{constructor(t,e){super(e),this.message=e,this.key=t;}}class Ve{constructor(t,e=[]){this.parent=t,this.bindings={};for(const[t,r]of e)this.bindings[t]=r;}concat(t){return new Ve(this,t)}get(t){if(this.bindings[t])return this.bindings[t];if(this.parent)return this.parent.get(t);throw new Error(`${t} not found in scope.`)}has(t){return !!this.bindings[t]||!!this.parent&&this.parent.has(t)}}const Ce={kind:"null"},Re={kind:"number"},De={kind:"string"},Le={kind:"boolean"},Fe={kind:"color"},Oe={kind:"object"},Ue={kind:"value"},je={kind:"collator"},Ne={kind:"formatted"},qe={kind:"resolvedImage"};function $e(t,e){return {kind:"array",itemType:t,N:e}}function Ge(t){if("array"===t.kind){const e=Ge(t.itemType);return "number"==typeof t.N?`array<${e}, ${t.N}>`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}const Xe=[Ce,Re,De,Le,Fe,Ne,Oe,$e(Ue),qe];function Ye(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!Ye(t.itemType,e.itemType))&&("number"!=typeof t.N||t.N===e.N))return null}else {if(t.kind===e.kind)return null;if("value"===t.kind)for(const t of Xe)if(!Ye(t,e))return null}return `Expected ${Ge(t)} but found ${Ge(e)} instead.`}function Ze(t,e){return e.some((e=>e.kind===t.kind))}function We(t,e){return e.some((e=>"null"===e?null===t:"array"===e?Array.isArray(t):"object"===e?t&&!Array.isArray(t)&&"object"==typeof t:e===typeof t))}class He{constructor(t,e,r){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=r,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"});}compare(t,e){return this.collator.compare(t,e)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class Ke{constructor(t,e,r,n,i){this.text=t.normalize?t.normalize():t,this.image=e,this.scale=r,this.fontStack=n,this.textColor=i;}}class Je{constructor(t){this.sections=t;}static fromString(t){return new Je([new Ke(t,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((t=>0!==t.text.length||t.image&&0!==t.image.namePrimary.length))}static factory(t){return t instanceof Je?t:Je.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map((t=>t.text)).join("")}serialize(){const t=["format"];for(const e of this.sections){if(e.image){t.push(["image",e.image.namePrimary]);continue}t.push(e.text);const r={};e.fontStack&&(r["text-font"]=["literal",e.fontStack.split(",")]),e.scale&&(r["font-scale"]=e.scale),e.textColor&&(r["text-color"]=["rgba"].concat(e.textColor.toRenderColor(null).toArray())),t.push(r);}return t}}class Qe{constructor(t){this.namePrimary=t.namePrimary,t.nameSecondary&&(this.nameSecondary=t.nameSecondary),this.available=t.available;}toString(){return this.nameSecondary?`[${this.namePrimary},${this.nameSecondary}]`:this.namePrimary}static fromString(t,e){return t?new Qe({namePrimary:t,nameSecondary:e,available:!1}):null}serialize(){return this.nameSecondary?["image",this.namePrimary,this.nameSecondary]:["image",this.namePrimary]}}function tr(t,e,r,n){return "number"==typeof t&&t>=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof r&&r>=0&&r<=255?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid rgba value [${[t,e,r,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof n?[t,e,r,n]:[t,e,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function er(t){if(null===t)return !0;if("string"==typeof t)return !0;if("boolean"==typeof t)return !0;if("number"==typeof t)return !0;if(t instanceof Ie)return !0;if(t instanceof He)return !0;if(t instanceof Je)return !0;if(t instanceof Qe)return !0;if(Array.isArray(t)){for(const e of t)if(!er(e))return !1;return !0}if("object"==typeof t){for(const e in t)if(!er(t[e]))return !1;return !0}return !1}function rr(t){if(null===t)return Ce;if("string"==typeof t)return De;if("boolean"==typeof t)return Le;if("number"==typeof t)return Re;if(t instanceof Ie)return Fe;if(t instanceof He)return je;if(t instanceof Je)return Ne;if(t instanceof Qe)return qe;if(Array.isArray(t)){const e=t.length;let r;for(const e of t){const t=rr(e);if(r){if(r===t)continue;r=Ue;break}r=t;}return $e(r||Ue,e)}return Oe}function nr(t){const e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof Ie||t instanceof Je||t instanceof Qe?t.toString():JSON.stringify(t)}class ir{constructor(t,e){this.type=t,this.value=e;}static parse(t,e){if(2!==t.length)return e.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!er(t[1]))return e.error("invalid value");const r=t[1];let n=rr(r);const i=e.expectedType;return "array"!==n.kind||0!==n.N||!i||"array"!==i.kind||"number"==typeof i.N&&0!==i.N||(n=i),new ir(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 Ie?["rgba"].concat(this.value.toRenderColor(null).toArray()):this.value instanceof Je?this.value.serialize():this.value}}class ar{constructor(t){this.name="ExpressionEvaluationError",this.message=t;}toJSON(){return this.message}}const sr={string:De,number:Re,boolean:Le,object:Oe};class or{constructor(t,e){this.type=t,this.args=e;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");let r,n=1;const i=t[0];if("array"===i){let i,a;if(t.length>2){const r=t[1];if("string"!=typeof r||!(r in sr)||"object"===r)return e.error('The item type argument of "array" must be one of string, number, boolean',1);i=sr[r],n++;}else i=Ue;if(t.length>3){if(null!==t[2]&&("number"!=typeof t[2]||t[2]<0||t[2]!==Math.floor(t[2])))return e.error('The length argument to "array" must be a positive integer literal',2);a=t[2],n++;}r=$e(i,a);}else r=sr[i];const a=[];for(;n<t.length;n++){const r=e.parse(t[n],n,Ue);if(!r)return null;a.push(r);}return new or(r,a)}evaluate(t){for(let e=0;e<this.args.length;e++){const r=this.args[e].evaluate(t);if(!Ye(this.type,rr(r)))return r;if(e===this.args.length-1)throw new ar(`The expression ${JSON.stringify(this.args[e].serialize())} evaluated to ${Ge(rr(r))} but was expected to be of type ${Ge(this.type)}.`)}return null}eachChild(t){this.args.forEach(t);}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){const t=this.type,e=[t.kind];if("array"===t.kind){const r=t.itemType;if("string"===r.kind||"number"===r.kind||"boolean"===r.kind){e.push(r.kind);const n=t.N;("number"==typeof n||this.args.length>1)&&e.push(n);}}return e.concat(this.args.map((t=>t.serialize())))}}class lr{constructor(t){this.type=Ne,this.sections=t;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const r=t[1];if(!Array.isArray(r)&&"object"==typeof r)return e.error("First argument must be an image or text section.");const n=[];let i=!1;for(let r=1;r<=t.length-1;++r){const a=t[r];if(i&&"object"==typeof a&&!Array.isArray(a)){i=!1;let t=null;if(a["font-scale"]&&(t=e.parseObjectValue(a["font-scale"],r,"font-scale",Re),!t))return null;let s=null;if(a["text-font"]&&(s=e.parseObjectValue(a["text-font"],r,"text-font",$e(De)),!s))return null;let o=null;if(a["text-color"]&&(o=e.parseObjectValue(a["text-color"],r,"text-color",Fe),!o))return null;const l=n[n.length-1];l.scale=t,l.font=s,l.textColor=o;}else {const a=e.parse(t[r],r,Ue);if(!a)return null;const s=a.type.kind;if("string"!==s&&"value"!==s&&"null"!==s&&"resolvedImage"!==s)return e.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");i=!0,n.push({content:a,scale:null,font:null,textColor:null});}}return new lr(n)}evaluate(t){return new Je(this.sections.map((e=>{const r=e.content.evaluate(t);return rr(r)===qe?new Ke("",r,null,null,null):new Ke(nr(r),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null)})))}eachChild(t){for(const e of this.sections)t(e.content),e.scale&&t(e.scale),e.font&&t(e.font),e.textColor&&t(e.textColor);}outputDefined(){return !1}serialize(){const t=["format"];for(const e of this.sections){t.push(e.content.serialize());const r={};e.scale&&(r["font-scale"]=e.scale.serialize()),e.font&&(r["text-font"]=e.font.serialize()),e.textColor&&(r["text-color"]=e.textColor.serialize()),t.push(r);}return t}}class ur{constructor(t,e){this.type=qe,this.inputPrimary=t,this.inputSecondary=e;}static parse(t,e){if(t.length<2)return e.error("Expected two or more arguments.");const r=e.parse(t[1],1,De);if(!r)return e.error("No image name provided.");if(2===t.length)return new ur(r);const n=e.parse(t[2],1,De);return n?new ur(r,n):e.error("Secondary image variant is not a string.")}evaluate(t){const e=Qe.fromString(this.inputPrimary.evaluate(t),this.inputSecondary?this.inputSecondary.evaluate(t):void 0);return e&&t.availableImages&&(e.available=t.availableImages.indexOf(e.namePrimary)>-1,e.nameSecondary&&e.available&&t.availableImages&&(e.available=t.availableImages.indexOf(e.nameSecondary)>-1)),e}eachChild(t){t(this.inputPrimary),this.inputSecondary&&t(this.inputSecondary);}outputDefined(){return !1}serialize(){return this.inputSecondary?["image",this.inputPrimary.serialize(),this.inputSecondary.serialize()]:["image",this.inputPrimary.serialize()]}}function cr(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}const hr={"to-boolean":Le,"to-color":Fe,"to-number":Re,"to-string":De};class pr{constructor(t,e){this.type=t,this.args=e;}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const r=t[0],n=[];let i=Ce;if("to-array"===r){if(!Array.isArray(t[1]))return null;const r=t[1].length;if(e.expectedType){if("array"!==e.expectedType.kind)return e.error(`Expected ${e.expectedType.kind} but found array.`);i=$e(e.expectedType.itemType,r);}else {if(!(r>0&&er(t[1][0])))return null;i=$e(rr(t[1][0]),r);}for(let a=0;a<r;a++){const r=t[1][a];let s;if("array"===cr(r))s=e.parse(r,void 0,i.itemType);else {const t=cr(r);if(t!==i.itemType.kind)return e.error(`Expected ${i.itemType.kind} but found ${t}.`);s=e.registry.literal.parse(["literal",void 0===r?null:r],e);}if(!s)return null;n.push(s);}}else {if(("to-boolean"===r||"to-string"===r)&&2!==t.length)return e.error("Expected one argument.");i=hr[r];for(let r=1;r<t.length;r++){const i=e.parse(t[r],r,Ue);if(!i)return null;n.push(i);}}return new pr(i,n)}evaluate(t){if("boolean"===this.type.kind)return Boolean(this.args[0].evaluate(t));if("color"===this.type.kind){let e,r;for(const n of this.args){if(e=n.evaluate(t),r=null,e instanceof Ie)return e;if("string"==typeof e){const r=t.parseColor(e);if(r)return r}else if(Array.isArray(e)&&(r=e.length<3||e.length>4?`Invalid rbga value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:tr(e[0],e[1],e[2],e[3]),!r))return new Ie(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new ar(r||`Could not parse color from value '${"string"==typeof e?e:String(JSON.stringify(e))}'`)}if("number"===this.type.kind){let e=null;for(const r of this.args){if(e=r.evaluate(t),null===e)return 0;const n=Number(e);if(!isNaN(n))return n}throw new ar(`Could not convert ${JSON.stringify(e)} to number.`)}return "formatted"===this.type.kind?Je.fromString(nr(this.args[0].evaluate(t))):"resolvedImage"===this.type.kind?Qe.fromString(nr(this.args[0].evaluate(t))):"array"===this.type.kind?this.args.map((e=>e.evaluate(t))):nr(this.args[0].evaluate(t))}eachChild(t){this.args.forEach(t);}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){if("formatted"===this.type.kind)return new lr([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new ur(this.args[0]).serialize();const t="array"===this.type.kind?[]:[`to-${this.type.kind}`];return this.eachChild((e=>{t.push(e.serialize());})),t}}const fr=["Unknown","Point","LineString","Polygon"];class dr{constructor(t,e){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=t,this.options=e;}id(){return this.feature&&void 0!==this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?fr[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(t){return this.globals.brightness||0}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const t=this.featureDistanceData.center,e=this.featureDistanceData.scale,{x:r,y:n}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(r*e-t[0])+this.featureDistanceData.bearing[1]*(n*e-t[1])}return 0}parseColor(t){let e=this._parseColorCache[t];return e||(e=this._parseColorCache[t]=Ie.parse(t)),e}getConfig(t){return this.options?this.options.get(t):null}}class mr{constructor(t,e,r,n,i){this.name=t,this.type=e,this._evaluate=r,this.args=n,this._overloadIndex=i;}evaluate(t){if(!this._evaluate){const t=mr.definitions[this.name];this._evaluate=Array.isArray(t)?t[2]:t.overloads[this._overloadIndex][1];}return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t);}outputDefined(){return !1}serialize(){return [this.name].concat(this.args.map((t=>t.serialize())))}static parse(t,e){const r=t[0],n=mr.definitions[r];if(!n)return e.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0);const i=Array.isArray(n)?n[0]:n.type,a=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,s=[];let o=null,l=-1;for(const[n,u]of a){if(Array.isArray(n)&&n.length!==t.length-1)continue;s.push(n),l++,o=new Dn(e.registry,e.path,null,e.scope,void 0,e._scope,e.options);const a=[];let c=!1;for(let e=1;e<t.length;e++){const r=t[e],i=Array.isArray(n)?n[e-1]:n.type,s=o.parse(r,1+a.length,i);if(!s){c=!0;break}a.push(s);}if(!c)if(Array.isArray(n)&&n.length!==a.length)o.error(`Expected ${n.length} arguments, but found ${a.length} instead.`);else {for(let t=0;t<a.length;t++){const e=Array.isArray(n)?n[t]:n.type,r=a[t];o.concat(t+1).checkSubtype(e,r.type);}if(0===o.errors.length)return new mr(r,i,u,a,l)}}if(1===s.length)e.errors.push(...o.errors);else {const r=(s.length?s:a.map((([t])=>t))).map(yr).join(" | "),n=[];for(let r=1;r<t.length;r++){const i=e.parse(t[r],1+n.length);if(!i)return null;n.push(Ge(i.type));}e.error(`Expected arguments of type ${r}, but found (${n.join(", ")}) instead.`);}return null}static register(t,e){mr.definitions=e;for(const r in e)t[r]=mr;}}function yr(t){return Array.isArray(t)?`(${t.map(Ge).join(", ")})`:`(${Ge(t.type)}...)`}class gr{constructor(t,e,r){this.type=je,this.locale=r,this.caseSensitive=t,this.diacriticSensitive=e;}static parse(t,e){if(2!==t.length)return e.error("Expected one argument.");const r=t[1];if("object"!=typeof r||Array.isArray(r))return e.error("Collator options argument must be an object.");const n=void 0===r["case-sensitive"]?e.parse(!1,1,Le):e.parseObjectValue(r["case-sensitive"],1,"case-sensitive",Le);if(!n)return null;const i=void 0===r["diacritic-sensitive"]?e.parse(!1,1,Le):e.parseObjectValue(r["diacritic-sensitive"],1,"diacritic-sensitive",Le);if(!i)return null;let a=null;return r.locale&&(a=e.parseObjectValue(r.locale,1,"locale",De),!a)?null:new gr(n,i,a)}evaluate(t){return new He(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)}eachChild(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale);}outputDefined(){return !1}serialize(){const t={};return t["case-sensitive"]=this.caseSensitive.serialize(),t["diacritic-sensitive"]=this.diacriticSensitive.serialize(),this.locale&&(t.locale=this.locale.serialize()),["collator",t]}}function xr(t,e,r=0,n=t.length-1,i=br){for(;n>r;){if(n-r>600){const a=n-r+1,s=e-r+1,o=Math.log(a),l=.5*Math.exp(2*o/3),u=.5*Math.sqrt(o*l*(a-l)/a)*(s-a/2<0?-1:1);xr(t,e,Math.max(r,Math.floor(e-s*l/a+u)),Math.min(n,Math.floor(e+(a-s)*l/a+u)),i);}const a=t[e];let s=r,o=n;for(vr(t,r,e),i(t[n],a)>0&&vr(t,r,n);s<o;){for(vr(t,s,o),s++,o--;i(t[s],a)<0;)s++;for(;i(t[o],a)>0;)o--;}0===i(t[r],a)?vr(t,r,o):(o++,vr(t,o,n)),o<=e&&(r=o+1),e<=o&&(n=o-1);}}function vr(t,e,r){const n=t[e];t[e]=t[r],t[r]=n;}function br(t,e){return t<e?-1:t>e?1:0}function wr(t){let e=0;for(let r,n,i=0,a=t.length,s=a-1;i<a;s=i++)r=t[i],n=t[s],e+=(n.x-r.x)*(r.y+n.y);return e}function _r(t,e){t[0]=Math.min(t[0],e[0]),t[1]=Math.min(t[1],e[1]),t[2]=Math.max(t[2],e[0]),t[3]=Math.max(t[3],e[1]);}function Mr(t,e){return !(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function Ar(t,e,r){const n=t[0]-e[0],i=t[1]-e[1],a=t[0]-r[0],s=t[1]-r[1];return n*s-a*i==0&&n*a<=0&&i*s<=0}function Sr(t,e,r=!1){let n=!1;for(let o=0,l=e.length;o<l;o++){const l=e[o];for(let e=0,o=l.length,u=o-1;e<o;u=e++){const o=l[u],c=l[e];if(Ar(t,o,c))return r;(a=o)[1]>(i=t)[1]!=(s=c)[1]>i[1]&&i[0]<(s[0]-a[0])*(i[1]-a[1])/(s[1]-a[1])+a[0]&&(n=!n);}}var i,a,s;return n}function Ir(t,e,r,n){const i=n[0]-r[0],a=n[1]-r[1],s=(t[0]-r[0])*a-i*(t[1]-r[1]),o=(e[0]-r[0])*a-i*(e[1]-r[1]);return s>0&&o<0||s<0&&o>0}function zr(t,e,r,n){return 0!=(i=[n[0]-r[0],n[1]-r[1]])[0]*(a=[e[0]-t[0],e[1]-t[1]])[1]-i[1]*a[0]&&!(!Ir(t,e,r,n)||!Ir(r,n,t,e));var i,a;}const Pr=8192;function kr(t,e){const r=(180+t[0])/360,n=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,i=Math.pow(2,e.z);return [Math.round(r*i*Pr),Math.round(n*i*Pr)]}function Tr(t,e){for(let r=0;r<e.length;r++)if(Sr(t,e[r]))return !0;return !1}function Er(t,e,r){for(const n of r)for(let r=0,i=n.length,a=i-1;r<i;a=r++)if(zr(t,e,n[a],n[r]))return !0;return !1}function Br(t,e){for(let r=0;r<t.length;++r)if(!Sr(t[r],e))return !1;for(let r=0;r<t.length-1;++r)if(Er(t[r],t[r+1],e))return !1;return !0}function Vr(t,e){for(let r=0;r<e.length;r++)if(Br(t,e[r]))return !0;return !1}function Cr(t,e,r){const n=[];for(let i=0;i<t.length;i++){const a=[];for(let n=0;n<t[i].length;n++){const s=kr(t[i][n],r);_r(e,s),a.push(s);}n.push(a);}return n}function Rr(t,e,r){const n=[];for(let i=0;i<t.length;i++){const a=Cr(t[i],e,r);n.push(a);}return n}function Dr(t,e,r,n){if(t[0]<r[0]||t[0]>r[2]){const e=.5*n;let i=t[0]-r[0]>e?-n:r[0]-t[0]>e?n:0;0===i&&(i=t[0]-r[2]>e?-n:r[2]-t[0]>e?n:0),t[0]+=i;}_r(e,t);}function Lr(t,e,r,n){const i=Math.pow(2,n.z)*Pr,a=[n.x*Pr,n.y*Pr],s=[];if(!t)return s;for(const n of t)for(const t of n){const n=[t.x+a[0],t.y+a[1]];Dr(n,e,r,i),s.push(n);}return s}function Fr(t,e,r,n){const i=Math.pow(2,n.z)*Pr,a=[n.x*Pr,n.y*Pr],s=[];if(!t)return s;for(const r of t){const t=[];for(const n of r){const r=[n.x+a[0],n.y+a[1]];_r(e,r),t.push(r);}s.push(t);}if(e[2]-e[0]<=i/2){(o=e)[0]=o[1]=1/0,o[2]=o[3]=-1/0;for(const t of s)for(const n of t)Dr(n,e,r,i);}var o;return s}class Or{constructor(t,e){this.type=Le,this.geojson=t,this.geometries=e;}static parse(t,e){if(2!==t.length)return e.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(er(t[1])){const e=t[1];if("FeatureCollection"===e.type)for(let t=0;t<e.features.length;++t){const r=e.features[t].geometry.type;if("Polygon"===r||"MultiPolygon"===r)return new Or(e,e.features[t].geometry)}else if("Feature"===e.type){const t=e.geometry.type;if("Polygon"===t||"MultiPolygon"===t)return new Or(e,e.geometry)}else if("Polygon"===e.type||"MultiPolygon"===e.type)return new Or(e,e)}return e.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){const r=[1/0,1/0,-1/0,-1/0],n=[1/0,1/0,-1/0,-1/0],i=t.canonicalID();if(!i)return !1;if("Polygon"===e.type){const a=Cr(e.coordinates,n,i),s=Lr(t.geometry(),r,n,i);if(!Mr(r,n))return !1;for(const t of s)if(!Sr(t,a))return !1}if("MultiPolygon"===e.type){const a=Rr(e.coordinates,n,i),s=Lr(t.geometry(),r,n,i);if(!Mr(r,n))return !1;for(const t of s)if(!Tr(t,a))return !1}return !0}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){const r=[1/0,1/0,-1/0,-1/0],n=[1/0,1/0,-1/0,-1/0],i=t.canonicalID();if(!i)return !1;if("Polygon"===e.type){const a=Cr(e.coordinates,n,i),s=Fr(t.geometry(),r,n,i);if(!Mr(r,n))return !1;for(const t of s)if(!Br(t,a))return !1}if("MultiPolygon"===e.type){const a=Rr(e.coordinates,n,i),s=Fr(t.geometry(),r,n,i);if(!Mr(r,n))return !1;for(const t of s)if(!Vr(t,a))return !1}return !0}(t,this.geometries)}return !1}eachChild(){}outputDefined(){return !0}serialize(){return ["within",this.geojson]}}const Ur={kilometers:1,miles:1e3/1609.344,nauticalmiles:1e3/1852,meters:1e3,metres:1e3,yards:1e3/.9144,feet:1e3/.3048,inches:1e3/.0254},jr=1/298.257223563,Nr=jr*(2-jr),qr=Math.PI/180;class $r{static fromTile(t,e,r){const n=Math.PI*(1-2*(t+.5)/Math.pow(2,e)),i=Math.atan(.5*(Math.exp(n)-Math.exp(-n)))/qr;return new $r(i,r)}static get units(){return Ur}constructor(t,e){if(void 0===t)throw new Error("No latitude given.");if(e&&!Ur[e])throw new Error(`Unknown unit ${e}. Use one of: ${Object.keys(Ur).join(", ")}`);const r=6378.137*qr*(e?Ur[e]:1),n=Math.cos(t*qr),i=1/(1-Nr*(1-n*n)),a=Math.sqrt(i);this.kx=r*a*n,this.ky=r*a*i*(1-Nr);}distance(t,e){const r=Yr(t[0]-e[0])*this.kx,n=(t[1]-e[1])*this.ky;return Math.sqrt(r*r+n*n)}bearing(t,e){const r=Yr(e[0]-t[0])*this.kx;return Math.atan2(r,(e[1]-t[1])*this.ky)/qr}destination(t,e,r){const n=r*qr;return this.offset(t,Math.sin(n)*e,Math.cos(n)*e)}offset(t,e,r){return [t[0]+e/this.kx,t[1]+r/this.ky]}lineDistance(t){let e=0;for(let r=0;r<t.length-1;r++)e+=this.distance(t[r],t[r+1]);return e}area(t){let e=0;for(let r=0;r<t.length;r++){const n=t[r];for(let t=0,i=n.length,a=i-1;t<i;a=t++)e+=Yr(n[t][0]-n[a][0])*(n[t][1]+n[a][1])*(r?-1:1);}return Math.abs(e)/2*this.kx*this.ky}along(t,e){let r=0;if(e<=0)return t[0];for(let n=0;n<t.length-1;n++){const i=t[n],a=t[n+1],s=this.distance(i,a);if(r+=s,r>e)return Xr(i,a,(e-(r-s))/s)}return t[t.length-1]}pointToSegmentDistance(t,e,r){let[n,i]=e,a=Yr(r[0]-n)*this.kx,s=(r[1]-i)*this.ky;if(0!==a||0!==s){const e=(Yr(t[0]-n)*this.kx*a+(t[1]-i)*this.ky*s)/(a*a+s*s);e>1?(n=r[0],i=r[1]):e>0&&(n+=a/this.kx*e,i+=s/this.ky*e);}return a=Yr(t[0]-n)*this.kx,s=(t[1]-i)*this.ky,Math.sqrt(a*a+s*s)}pointOnLine(t,e){let r=1/0,n=t[0][0],i=t[0][1],a=0,s=0;for(let o=0;o<t.length-1;o++){let l=t[o][0],u=t[o][1],c=Yr(t[o+1][0]-l)*this.kx,h=(t[o+1][1]-u)*this.ky,p=0;0===c&&0===h||(p=(Yr(e[0]-l)*this.kx*c+(e[1]-u)*this.ky*h)/(c*c+h*h),p>1?(l=t[o+1][0],u=t[o+1][1]):p>0&&(l+=c/this.kx*p,u+=h/this.ky*p)),c=Yr(e[0]-l)*this.kx,h=(e[1]-u)*this.ky;const f=c*c+h*h;f<r&&(r=f,n=l,i=u,a=o,s=p);}return {point:[n,i],index:a,t:Math.max(0,Math.min(1,s))}}lineSlice(t,e,r){let n=this.pointOnLine(r,t),i=this.pointOnLine(r,e);if(n.index>i.index||n.index===i.index&&n.t>i.t){const t=n;n=i,i=t;}const a=[n.point],s=n.index+1,o=i.index;!Gr(r[s],a[0])&&s<=o&&a.push(r[s]);for(let t=s+1;t<=o;t++)a.push(r[t]);return Gr(r[o],i.point)||a.push(i.point),a}lineSliceAlong(t,e,r){let n=0;const i=[];for(let a=0;a<r.length-1;a++){const s=r[a],o=r[a+1],l=this.distance(s,o);if(n+=l,n>t&&0===i.length&&i.push(Xr(s,o,(t-(n-l))/l)),n>=e)return i.push(Xr(s,o,(e-(n-l))/l)),i;n>t&&i.push(o);}return i}bufferPoint(t,e){const r=e/this.ky,n=e/this.kx;return [t[0]-n,t[1]-r,t[0]+n,t[1]+r]}bufferBBox(t,e){const r=e/this.ky,n=e/this.kx;return [t[0]-n,t[1]-r,t[2]+n,t[3]+r]}insideBBox(t,e){return Yr(t[0]-e[0])>=0&&Yr(t[0]-e[2])<=0&&t[1]>=e[1]&&t[1]<=e[3]}}function Gr(t,e){return t[0]===e[0]&&t[1]===e[1]}function Xr(t,e,r){const n=Yr(e[0]-t[0]);return [t[0]+n*r,t[1]+(e[1]-t[1])*r]}function Yr(t){for(;t<-180;)t+=360;for(;t>180;)t-=360;return t}class Zr{constructor(t=[],e=((t,e)=>t<e?-1:t>e?1:0)){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t);}push(t){this.data.push(t),this._up(this.length++);}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return --this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:r}=this,n=e[t];for(;t>0;){const i=t-1>>1,a=e[i];if(r(n,a)>=0)break;e[t]=a,t=i;}e[t]=n;}_down(t){const{data:e,compare:r}=this,n=this.length>>1,i=e[t];for(;t<n;){let n=1+(t<<1);const a=n+1;if(a<this.length&&r(e[a],e[n])<0&&(n=a),r(e[n],i)>=0)break;e[t]=e[n],t=n;}e[t]=i;}}var Wr=8192;function Hr(t,e){return e.dist-t.dist}const Kr=100,Jr=50;function Qr(t){const e=[1/0,1/0,-1/0,-1/0];if(e.length!==t.length)return !1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return !1;return !0}function tn(t){return t[1]-t[0]+1}function en(t,e){const r=t[1]>=t[0]&&t[1]<e;return r||console.warn("Distance Expression: Index is out of range"),r}function rn(t,e){if(t[0]>t[1])return [null,null];const r=tn(t);if(e){if(2===r)return [t,null];const e=Math.floor(r/2);return [[t[0],t[0]+e],[t[0]+e,t[1]]]}{if(1===r)return [t,null];const e=Math.floor(r/2)-1;return [[t[0],t[0]+e],[t[0]+e+1,t[1]]]}}function nn(t,e){const r=[1/0,1/0,-1/0,-1/0];if(!en(e,t.length))return r;for(let n=e[0];n<=e[1];++n)_r(r,t[n]);return r}function an(t){const e=[1/0,1/0,-1/0,-1/0];for(let r=0;r<t.length;++r)for(let n=0;n<t[r].length;++n)_r(e,t[r][n]);return e}function sn(t,e,r){if(Qr(t)||Qr(e))return NaN;let n=0,i=0;return t[2]<e[0]&&(n=e[0]-t[2]),t[0]>e[2]&&(n=t[0]-e[2]),t[1]>e[3]&&(i=t[1]-e[3]),t[3]<e[1]&&(i=e[1]-t[3]),r.distance([0,0],[n,i])}function on(t){return 360*t-180}function ln(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}function un(t,e){const r=Math.pow(2,e.z),n=(t.y/Wr+e.y)/r;return [on((t.x/Wr+e.x)/r),ln(n)]}function cn(t,e){const r=[];for(let n=0;n<t.length;++n)r.push(un(t[n],e));return r}function hn(t,e,r){const n=r.pointOnLine(e,t).point;return r.distance(t,n)}function pn(t,e,r,n,i){const a=r.slice(n[0],n[1]+1);let s=1/0;for(let r=e[0];r<=e[1];++r)if(0===(s=Math.min(s,hn(t[r],a,i))))return 0;return s}function fn(t,e,r,n,i){const a=Math.min(i.pointToSegmentDistance(t,r,n),i.pointToSegmentDistance(e,r,n)),s=Math.min(i.pointToSegmentDistance(r,t,e),i.pointToSegmentDistance(n,t,e));return Math.min(a,s)}function dn(t,e,r,n,i){if(!en(e,t.length)||!en(n,r.length))return NaN;let a=1/0;for(let s=e[0];s<e[1];++s)for(let e=n[0];e<n[1];++e){if(zr(t[s],t[s+1],r[e],r[e+1]))return 0;a=Math.min(a,fn(t[s],t[s+1],r[e],r[e+1],i));}return a}function mn(t,e,r,n,i){if(!en(e,t.length)||!en(n,r.length))return NaN;let a=1/0;for(let s=e[0];s<=e[1];++s)for(let e=n[0];e<=n[1];++e)if(0===(a=Math.min(a,i.distance(t[s],r[e]))))return a;return a}function yn(t,e,r){if(Sr(t,e,!0))return 0;let n=1/0;for(const i of e){const e=i.length;if(e<2)return console.warn("Distance Expression: Invalid polygon!"),NaN;if(i[0]!==i[e-1]&&0===(n=Math.min(n,r.pointToSegmentDistance(t,i[e-1],i[0]))))return n;if(0===(n=Math.min(n,hn(t,i,r))))return n}return n}function gn(t,e,r,n){if(!en(e,t.length))return NaN;for(let n=e[0];n<=e[1];++n)if(Sr(t[n],r,!0))return 0;let i=1/0;for(let a=e[0];a<e[1];++a)for(const e of r)for(let r=0,s=e.length,o=s-1;r<s;o=r++){if(zr(t[a],t[a+1],e[o],e[r]))return 0;i=Math.min(i,fn(t[a],t[a+1],e[o],e[r],n));}return i}function xn(t,e){for(const r of t)for(let t=0;t<=r.length-1;++t)if(Sr(r[t],e,!0))return !0;return !1}function vn(t,e,r,n=1/0){const i=an(t),a=an(e);if(n!==1/0&&sn(i,a,r)>=n)return n;if(Mr(i,a)){if(xn(t,e))return 0}else if(xn(e,t))return 0;let s=n;for(const n of t)for(let t=0,i=n.length,a=i-1;t<i;a=t++)for(const i of e)for(let e=0,o=i.length,l=o-1;e<o;l=e++){if(zr(n[a],n[t],i[l],i[e]))return 0;s=Math.min(s,fn(n[a],n[t],i[l],i[e],r));}return s}function bn(t,e,r,n,i,a,s){if(null===a||null===s)return;const o=sn(nn(n,a),nn(i,s),r);o<e&&t.push({dist:o,range1:a,range2:s});}function wn(t,e,r,n,i=1/0){let a=Math.min(n.distance(t[0],r[0][0]),i);if(0===a)return a;const s=new Zr([{dist:0,range1:[0,t.length-1],range2:[0,0]}],Hr),o=e?Jr:Kr,l=an(r);for(;s.length;){const i=s.pop();if(i.dist>=a)continue;const u=i.range1;if(tn(u)<=o){if(!en(u,t.length))return NaN;if(e){const e=gn(t,u,r,n);if(0===(a=Math.min(a,e)))return a}else for(let e=u[0];e<=u[1];++e){const i=yn(t[e],r,n);if(0===(a=Math.min(a,i)))return a}}else {const r=rn(u,e);if(null!==r[0]){const e=sn(nn(t,r[0]),l,n);e<a&&s.push({dist:e,range1:r[0],range2:[0,0]});}if(null!==r[1]){const e=sn(nn(t,r[1]),l,n);e<a&&s.push({dist:e,range1:r[1],range2:[0,0]});}}}return a}function _n(t,e,r,n,i,a=1/0){let s=Math.min(a,i.distance(t[0],r[0]));if(0===s)return s;const o=new Zr([{dist:0,range1:[0,t.length-1],range2:[0,r.length-1]}],Hr),l=e?Jr:Kr,u=n?Jr:Kr;for(;o.length;){const a=o.pop();if(a.dist>=s)continue;const c=a.range1,h=a.range2;if(tn(c)<=l&&tn(h)<=u){if(!en(c,t.length)||!en(h,r.length))return NaN;if(e&&n?s=Math.min(s,dn(t,c,r,h,i)):e||n?e&&!n?s=Math.min(s,pn(r,h,t,c,i)):!e&&n&&(s=Math.min(s,pn(t,c,r,h,i))):s=Math.min(s,mn(t,c,r,h,i)),0===s)return s}else {const a=rn(c,e),l=rn(h,n);bn(o,s,i,t,r,a[0],l[0]),bn(o,s,i,t,r,a[0],l[1]),bn(o,s,i,t,r,a[1],l[0]),bn(o,s,i,t,r,a[1],l[1]);}}return s}function Mn(t,e,r,n,i=1/0){let a=i;const s=nn(t,[0,t.length-1]);for(const i of r)if(!(a!==1/0&&sn(s,nn(i,[0,i.length-1]),n)>=a)&&(a=Math.min(a,_n(t,e,i,!0,n,a)),0===a))return a;return a}function An(t,e,r,n,i=1/0){let a=i;const s=nn(t,[0,t.length-1]);for(const i of r){if(a!==1/0&&sn(s,an(i),n)>=a)continue;const r=wn(t,e,i,n,a);if(isNaN(r))return r;if(0===(a=Math.min(a,r)))return a}return a}function Sn(t){return "Point"===t||"MultiPoint"===t||"LineString"===t||"MultiLineString"===t||"Polygon"===t||"MultiPolygon"===t}class In{constructor(t,e){this.type=Re,this.geojson=t,this.geometries=e;}static parse(t,e){if(2!==t.length)return e.error(`'distance' expression requires either one argument, but found ' ${t.length-1} instead.`);if(er(t[1])){const e=t[1];if("FeatureCollection"===e.type){for(let t=0;t<e.features.length;++t)if(Sn(e.features[t].geometry.type))return new In(e,e.features[t].geometry)}else if("Feature"===e.type){if(Sn(e.geometry.type))return new In(e,e.geometry)}else if(Sn(e.type))return new In(e,e)}return e.error("'distance' expression needs to be an array with format ['Distance', GeoJSONObj].")}evaluate(t){const e=t.geometry(),r=t.canonicalID();if(null!=e&&null!=r){if("Point"===t.geometryType())return function(t,e,r){const n=[];for(const r of t)for(const t of r)n.push(un(t,e));const i=new $r(n[0][1],"meters");return "Point"===r.type||"MultiPoint"===r.type||"LineString"===r.type?_n(n,!1,"Point"===r.type?[r.coordinates]:r.coordinates,"LineString"===r.type,i):"MultiLineString"===r.type?Mn(n,!1,r.coordinates,i):"Polygon"===r.type||"MultiPolygon"===r.type?An(n,!1,"Polygon"===r.type?[r.coordinates]:r.coordinates,i):null}(e,r,this.geometries);if("LineString"===t.geometryType())return function(t,e,r){const n=[];for(const r of t){const t=[];for(const n of r)t.push(un(n,e));n.push(t);}const i=new $r(n[0][0][1],"meters");if("Point"===r.type||"MultiPoint"===r.type||"LineString"===r.type)return Mn("Point"===r.type?[r.coordinates]:r.coordinates,"LineString"===r.type,n,i);if("MultiLineString"===r.type){let t=1/0;for(let e=0;e<r.coordinates.length;e++){const a=Mn(r.coordinates[e],!0,n,i,t);if(isNaN(a))return a;if(0===(t=Math.min(t,a)))return t}return t}if("Polygon"===r.type||"MultiPolygon"===r.type){let t=1/0;for(let e=0;e<n.length;e++){const a=An(n[e],!0,"Polygon"===r.type?[r.coordinates]:r.coordinates,i,t);if(isNaN(a))return a;if(0===(t=Math.min(t,a)))return t}return t}return null}(e,r,this.geometries);if("Polygon"===t.geometryType())return function(t,e,r){const n=[];for(const r of function(t,e){const r=t.length;if(r<=1)return [t];const n=[];let i,a;for(let e=0;e<r;e++){const r=wr(t[e]);0!==r&&(t[e].area=Math.abs(r),void 0===a&&(a=r<0),a===r<0?(i&&n.push(i),i=[t[e]]):i.push(t[e]));}return i&&n.push(i),n}(t)){const t=[];for(let n=0;n<r.length;++n)t.push(cn(r[n],e));n.push(t);}const i=new $r(n[0][0][0][1],"meters");if("Point"===r.type||"MultiPoint"===r.type||"LineString"===r.type)return An("Point"===r.type?[r.coordinates]:r.coordinates,"LineString"===r.type,n,i);if("MultiLineString"===r.type){let t=1/0;for(let e=0;e<r.coordinates.length;e++){const a=An(r.coordinates[e],!0,n,i,t);if(isNaN(a))return a;if(0===(t=Math.min(t,a)))return t}return t}return "Polygon"===r.type||"MultiPolygon"===r.type?function(t,e,r){let n=1/0;for(const i of t)for(const t of e){const e=vn(i,t,r,n);if(isNaN(e))return e;if(0===(n=Math.min(n,e)))return n}return n}("Polygon"===r.type?[r.coordinates]:r.coordinates,n,i):null}(e,r,this.geometries);console.warn("Distance Expression: currently only evaluates valid Point/LineString/Polygon geometries.");}else console.warn("Distance Expression: requirs valid feature and canonical information.");return null}eachChild(){}outputDefined(){return !0}serialize(){return ["distance",this.geojson]}}function zn(t,e){switch(t){case"string":return nr(e);case"number":return +e;case"boolean":return !!e;case"color":return Ie.parse(e);case"formatted":return Je.fromString(nr(e));case"resolvedImage":return Qe.fromString(nr(e))}return e}function Pn(t,e,r,n){return void 0!==n&&(t=n*Math.round(t/n)),void 0!==e&&t<e&&(t=e),void 0!==r&&t>r&&(t=r),t}class kn{constructor(t,e,r){this.type=t,this.key=e,this.scope=r;}static parse(t,e){let r=e.expectedType;if(null==r&&(r=Ue),t.length<2||t.length>3)return e.error("Invalid number of arguments for 'config' expression.");const n=e.parse(t[1],1);if(!(n instanceof ir))return e.error("Key name of 'config' expression must be a string literal.");if(t.length>=3){const i=e.parse(t[2],2);return i instanceof ir?new kn(r,nr(n.value),nr(i.value)):e.error("Scope of 'config' expression must be a string literal.")}return new kn(r,nr(n.value))}evaluate(t){const e=[this.key,this.scope,t.scope].filter(Boolean).join(""),r=t.getConfig(e);if(!r)return null;const{type:n,value:i,values:a,minValue:s,maxValue:o,stepValue:l}=r,u=r.default.evaluate(t);let c=u;if(i){const e=t.scope;t.scope=(e||"").split("").slice(1).join(""),c=i.evaluate(t),t.scope=e;}return n&&(c=zn(n,c)),void 0===c||void 0===s&&void 0===o&&void 0===l||("number"==typeof c?c=Pn(c,s,o,l):Array.isArray(c)&&(c=c.map((t=>"number"==typeof t?Pn(t,s,o,l):t)))),void 0!==i&&void 0!==c&&a&&!a.includes(c)&&(c=u,n&&(c=zn(n,c))),(n&&n!==this.type||void 0!==c&&rr(c)!==this.type)&&(c=zn(this.type.kind,c)),c}eachChild(){}outputDefined(){return !1}serialize(){const t=["config",this.key];return this.scope&&t.concat(this.key),t}}function Tn(t){if(t instanceof mr){if("get"===t.name&&1===t.args.length)return !1;if("feature-state"===t.name)return !1;if("has"===t.name&&1===t.args.length)return !1;if("properties"===t.name||"geometry-type"===t.name||"id"===t.name)return !1;if(/^filter-/.test(t.name))return !1}if(t instanceof Or)return !1;if(t instanceof In)return !1;let e=!0;return t.eachChild((t=>{e&&!Tn(t)&&(e=!1);})),e}function En(t){if(t instanceof mr&&"feature-state"===t.name)return !1;let e=!0;return t.eachChild((t=>{e&&!En(t)&&(e=!1);})),e}function Bn(t){if(t instanceof kn)return new Set([t.key]);let e=new Set;return t.eachChild((t=>{e=new Set([...e,...Bn(t)]);})),e}function Vn(t,e){if(t instanceof mr&&e.indexOf(t.name)>=0)return !1;let r=!0;return t.eachChild((t=>{r&&!Vn(t,e)&&(r=!1);})),r}class Cn{constructor(t,e){this.type=e.type,this.name=t,this.boundExpression=e;}static parse(t,e){if(2!==t.length||"string"!=typeof t[1])return e.error("'var' expression requires exactly one string literal argument.");const r=t[1];return e.scope.has(r)?new Cn(r,e.scope.get(r)):e.error(`Unknown variable "${r}". Make sure "${r}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return !1}serialize(){return ["var",this.name]}}class Rn{constructor(t,e=[],r,n=new Ve,i=[],a,s){this.registry=t,this.path=e,this.key=e.map((t=>"string"==typeof t?`['${t}']`:`[${t}]`)).join(""),this.scope=n,this.errors=i,this.expectedType=r,this._scope=a,this.options=s;}parse(t,e,r,n,i={}){return e||r?this.concat(e,null,r,n)._parse(t,i):this._parse(t,i)}parseObjectValue(t,e,r,n,i,a={}){return this.concat(e,r,n,i)._parse(t,a)}_parse(t,e){function r(t,e,r){return "assert"===r?new or(e,[t]):"coerce"===r?new pr(e,[t]):t}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const n="string"==typeof t[0]?this.registry[t[0]]:void 0;if(n){let i=n.parse(t,this);if(!i)return null;if(this.expectedType){const t=this.expectedType,n=i.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==n.kind)if("color"!==t.kind&&"formatted"!==t.kind&&"resolvedImage"!==t.kind||"value"!==n.kind&&"string"!==n.kind){if(this.checkSubtype(t,n))return null}else i=r(i,t,e.typeAnnotation||"coerce");else i=r(i,t,e.typeAnnotation||"assert");}if(!(i instanceof ir)&&"resolvedImage"!==i.type.kind&&Ln(i)){const t=new dr(this._scope,this.options);try{i=new ir(i.type,i.evaluate(t));}catch(t){return this.error(t.message),null}}return i}return pr.parse(["to-array",t],this)}return this.error(void 0===t?"'undefined' value invalid. Use null instead.":"object"==typeof t?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,e,r,n){let i="number"==typeof t?this.path.concat(t):this.path;i="string"==typeof e?i.concat(e):i;const a=n?this.scope.concat(n):this.scope;return new Rn(this.registry,i,r||null,a,this.errors,this._scope,this.options)}error(t,...e){const r=`${this.key}${e.map((t=>`[${t}]`)).join("")}`;this.errors.push(new Be(r,t));}checkSubtype(t,e){const r=Ye(t,e);return r&&this.error(r),r}}var Dn=Rn;function Ln(t){if(t instanceof Cn)return Ln(t.boundExpression);if(t instanceof mr&&"error"===t.name)return !1;if(t instanceof gr)return !1;if(t instanceof Or)return !1;if(t instanceof In)return !1;if(t instanceof kn)return !1;const e=t instanceof pr||t instanceof or;let r=!0;return t.eachChild((t=>{r=e?r&&Ln(t):r&&t instanceof ir;})),!!r&&Tn(t)&&Vn(t,["zoom","heatmap-density","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed"])}function Fn(t,e){const r=t.length-1;let n,i,a=0,s=r,o=0;for(;a<=s;)if(o=Math.floor((a+s)/2),n=t[o],i=t[o+1],n<=e){if(o===r||e<i)return o;a=o+1;}else {if(!(n>e))throw new ar("Input is not a number.");s=o-1;}return 0}class On{constructor(t,e,r){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[t,e]of r)this.labels.push(t),this.outputs.push(e);}static parse(t,e){if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");const r=e.parse(t[1],1,Re);if(!r)return null;const n=[];let i=null;e.expectedType&&"value"!==e.expectedType.kind&&(i=e.expectedType);for(let r=1;r<t.length;r+=2){const a=1===r?-1/0:t[r],s=t[r+1],o=r,l=r+1;if("number"!=typeof a)return e.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',o);if(n.length&&n[n.length-1][0]>=a)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',o);const u=e.parse(s,l,i);if(!u)return null;i=i||u.type,n.push([a,u]);}return new On(i,r,n)}evaluate(t){const e=this.labels,r=this.outputs;if(1===e.length)return r[0].evaluate(t);const n=this.input.evaluate(t);if(n<=e[0])return r[0].evaluate(t);const i=e.length;return n>=e[i-1]?r[i-1].evaluate(t):r[Fn(e,n)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e);}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){const t=["step",this.input.serialize()];for(let e=0;e<this.labels.length;e++)e>0&&t.push(this.labels[e]),t.push(this.outputs[e].serialize());return t}}const Un=.95047,jn=1.08883,Nn=4/29,qn=6/29,$n=3*qn*qn,Gn=qn*qn*qn,Xn=Math.PI/180,Yn=180/Math.PI;function Zn(t){return t>Gn?Math.pow(t,1/3):t/$n+Nn}function Wn(t){return t>qn?t*t*t:$n*(t-Nn)}function Hn(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function Kn(t){return (t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Jn(t){const e=Kn(t.r),r=Kn(t.g),n=Kn(t.b),i=Zn((.4124564*e+.3575761*r+.1804375*n)/Un),a=Zn((.2126729*e+.7151522*r+.072175*n)/1);return {l:116*a-16,a:500*(i-a),b:200*(a-Zn((.0193339*e+.119192*r+.9503041*n)/jn)),alpha:t.a}}function Qn(t){let e=(t.l+16)/116,r=isNaN(t.a)?e:e+t.a/500,n=isNaN(t.b)?e:e-t.b/200;return e=1*Wn(e),r=Un*Wn(r),n=jn*Wn(n),new Ie(Hn(3.2404542*r-1.5371385*e-.4985314*n),Hn(-.969266*r+1.8760108*e+.041556*n),Hn(.0556434*r-.2040259*e+1.0572252*n),t.alpha)}function ti(t,e,r){const n=e-t;return t+r*(n>180||n<-180?n-360*Math.round(n/360):n)}const ei={forward:Jn,reverse:Qn,interpolate:function(t,e,r){return {l:Pe(t.l,e.l,r),a:Pe(t.a,e.a,r),b:Pe(t.b,e.b,r),alpha:Pe(t.alpha,e.alpha,r)}}},ri={forward:function(t){const{l:e,a:r,b:n}=Jn(t),i=Math.atan2(n,r)*Yn;return {h:i<0?i+360:i,c:Math.sqrt(r*r+n*n),l:e,alpha:t.a}},reverse:function(t){const e=t.h*Xn,r=t.c;return Qn({l:t.l,a:Math.cos(e)*r,b:Math.sin(e)*r,alpha:t.alpha})},interpolate:function(t,e,r){return {h:ti(t.h,e.h,r),c:Pe(t.c,e.c,r),l:Pe(t.l,e.l,r),alpha:Pe(t.alpha,e.alpha,r)}}};var ni=Object.freeze({__proto__:null,hcl:ri,lab:ei});class ii{constructor(t,e,r,n,i){this.type=t,this.operator=e,this.interpolation=r,this.input=n,this.labels=[],this.outputs=[];for(const[t,e]of i)this.labels.push(t),this.outputs.push(e);}static interpolationFactor(t,e,r,n){let i=0;if("exponential"===t.name)i=ai(e,t.base,r,n);else if("linear"===t.name)i=ai(e,1,r,n);else if("cubic-bezier"===t.name){const a=t.controlPoints;i=new j(a[0],a[1],a[2],a[3]).solve(ai(e,1,r,n));}return i}static parse(t,e){let[r,n,i,...a]=t;if(!Array.isArray(n)||0===n.length)return e.error("Expected an interpolation type expression.",1);if("linear"===n[0])n={name:"linear"};else if("exponential"===n[0]){const t=n[1];if("number"!=typeof t)return e.error("Exponential interpolation requires a numeric base.",1,1);n={name:"exponential",base:t};}else {if("cubic-bezier"!==n[0])return e.error(`Unknown interpolation type ${String(n[0])}`,1,0);{const t=n.slice(1);if(4!==t.length||t.some((t=>"number"!=typeof t||t<0||t>1)))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);n={name:"cubic-bezier",controlPoints:t};}}if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");if(i=e.parse(i,2,Re),!i)return null;const s=[];let o=null;"interpolate-hcl"===r||"interpolate-lab"===r?o=Fe:e.expectedType&&"value"!==e.expectedType.kind&&(o=e.expectedType);for(let t=0;t<a.length;t+=2){const r=a[t],n=a[t+1],i=t+3,l=t+4;if("number"!=typeof r)return e.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',i);if(s.length&&s[s.length-1][0]>=r)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',i);const u=e.parse(n,l,o);if(!u)return null;o=o||u.type,s.push([r,u]);}return "number"===o.kind||"color"===o.kind||"array"===o.kind&&"number"===o.itemType.kind&&"number"==typeof o.N?new ii(o,r,n,i,s):e.error(`Type ${Ge(o)} is not interpolatable.`)}evaluate(t){const e=this.labels,r=this.outputs;if(1===e.length)return r[0].evaluate(t);const n=this.input.evaluate(t);if(n<=e[0])return r[0].evaluate(t);const i=e.length;if(n>=e[i-1])return r[i-1].evaluate(t);const a=Fn(e,n),s=ii.interpolationFactor(this.interpolation,n,e[a],e[a+1]),o=r[a].evaluate(t),l=r[a+1].evaluate(t);return "interpolate"===this.operator?Te[this.type.kind.toLowerCase()](o,l,s):"interpolate-hcl"===this.operator?ri.reverse(ri.interpolate(ri.forward(o),ri.forward(l),s)):ei.reverse(ei.interpolate(ei.forward(o),ei.forward(l),s))}eachChild(t){t(this.input);for(const e of this.outputs)t(e);}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){let t;t="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const e=[this.operator,t,this.input.serialize()];for(let t=0;t<this.labels.length;t++)e.push(this.labels[t],this.outputs[t].serialize());return e}}function ai(t,e,r,n){const i=n-r,a=t-r;return 0===i?0:1===e?a/i:(Math.pow(e,a)-1)/(Math.pow(e,i)-1)}class si{constructor(t,e){this.type=t,this.args=e;}static parse(t,e){if(t.length<2)return e.error("Expectected at least one argument.");let r=null;const n=e.expectedType;n&&"value"!==n.kind&&(r=n);const i=[];for(const n of t.slice(1)){const t=e.parse(n,1+i.length,r,void 0,{typeAnnotation:"omit"});if(!t)return null;r=r||t.type,i.push(t);}const a=n&&i.some((t=>Ye(n,t.type)));return new si(a?Ue:r,i)}evaluate(t){let e,r=null,n=0;for(const i of this.args){if(n++,r=i.evaluate(t),r&&r instanceof Qe&&!r.available&&(e||(e=r),r=null,n===this.args.length))return e;if(null!==r)break}return r}eachChild(t){this.args.forEach(t);}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){const t=["coalesce"];return this.eachChild((e=>{t.push(e.serialize());})),t}}class oi{constructor(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e;}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const e of this.bindings)t(e[1]);t(this.result);}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);const r=[];for(let n=1;n<t.length-1;n+=2){const i=t[n];if("string"!=typeof i)return e.error(`Expected string, but found ${typeof i} instead.`,n);if(/[^a-zA-Z0-9_]/.test(i))return e.error("Variable names must contain only alphanumeric characters or '_'.",n);const a=e.parse(t[n+1],n+1);if(!a)return null;r.push([i,a]);}const n=e.parse(t[t.length-1],t.length-1,e.expectedType,r);return n?new oi(r,n):null}outputDefined(){return this.result.outputDefined()}serialize(){const t=["let"];for(const[e,r]of this.bindings)t.push(e,r.serialize());return t.push(this.result.serialize()),t}}class li{constructor(t,e,r){this.type=t,this.index=e,this.input=r;}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,Re),n=e.parse(t[2],2,$e(e.expectedType||Ue));return r&&n?new li(n.type.itemType,r,n):null}evaluate(t){const e=this.index.evaluate(t),r=this.input.evaluate(t);if(e<0)throw new ar(`Array index out of bounds: ${e} < 0.`);if(e>r.length-1)throw new ar(`Array index out of bounds: ${e} > ${r.length-1}.`);if(e===Math.floor(e))return r[e];const n=Math.floor(e),i=Math.ceil(e),a=r[n],s=r[i];if("number"!=typeof a||"number"!=typeof s)throw new ar(`Cannot interpolate between non-number values at index ${e}.`);const o=e-n;return a*(1-o)+s*o}eachChild(t){t(this.index),t(this.input);}outputDefined(){return !1}serialize(){return ["at",this.index.serialize(),this.input.serialize()]}}class ui{constructor(t,e){this.type=Le,this.needle=t,this.haystack=e;}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,Ue),n=e.parse(t[2],2,Ue);return r&&n?Ze(r.type,[Le,De,Re,Ce,Ue])?new ui(r,n):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ge(r.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(null==r)return !1;if(!We(e,["boolean","string","number","null"]))throw new ar(`Expected first argument to be of type boolean, string, number or null, but found ${Ge(rr(e))} instead.`);if(!We(r,["string","array"]))throw new ar(`Expected second argument to be of type array or string, but found ${Ge(rr(r))} instead.`);return r.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack);}outputDefined(){return !0}serialize(){return ["in",this.needle.serialize(),this.haystack.serialize()]}}class ci{constructor(t,e,r){this.type=Re,this.needle=t,this.haystack=e,this.fromIndex=r;}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,Ue),n=e.parse(t[2],2,Ue);if(!r||!n)return null;if(!Ze(r.type,[Le,De,Re,Ce,Ue]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ge(r.type)} instead`);if(4===t.length){const i=e.parse(t[3],3,Re);return i?new ci(r,n,i):null}return new ci(r,n)}evaluate(t){const e=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(!We(e,["boolean","string","number","null"]))throw new ar(`Expected first argument to be of type boolean, string, number or null, but found ${Ge(rr(e))} instead.`);if(!We(r,["string","array"]))throw new ar(`Expected second argument to be of type array or string, but found ${Ge(rr(r))} instead.`);if(this.fromIndex){const n=this.fromIndex.evaluate(t);return r.indexOf(e,n)}return r.indexOf(e)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex);}outputDefined(){return !1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const t=this.fromIndex.serialize();return ["index-of",this.needle.serialize(),this.haystack.serialize(),t]}return ["index-of",this.needle.serialize(),this.haystack.serialize()]}}class hi{constructor(t,e,r,n,i,a){this.inputType=t,this.type=e,this.input=r,this.cases=n,this.outputs=i,this.otherwise=a;}static parse(t,e){if(t.length<5)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return e.error("Expected an even number of arguments.");let r,n;e.expectedType&&"value"!==e.expectedType.kind&&(n=e.expectedType);const i={},a=[];for(let s=2;s<t.length-1;s+=2){let o=t[s];const l=t[s+1];Array.isArray(o)||(o=[o]);const u=e.concat(s);if(0===o.length)return u.error("Expected at least one branch label.");for(const t of o){if("number"!=typeof t&&"string"!=typeof t)return u.error("Branch labels must be numbers or strings.");if("number"==typeof t&&Math.abs(t)>Number.MAX_SAFE_INTEGER)return u.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof t&&Math.floor(t)!==t)return u.error("Numeric branch labels must be integer values.");if(r){if(u.checkSubtype(r,rr(t)))return null}else r=rr(t);if(void 0!==i[String(t)])return u.error("Branch labels must be unique.");i[String(t)]=a.length;}const c=e.parse(l,s,n);if(!c)return null;n=n||c.type,a.push(c);}const s=e.parse(t[1],1,Ue);if(!s)return null;const o=e.parse(t[t.length-1],t.length-1,n);return o?"value"!==s.type.kind&&e.concat(1).checkSubtype(r,s.type)?null:new hi(r,n,s,i,a,o):null}evaluate(t){const e=this.input.evaluate(t);return (rr(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise);}outputDefined(){return this.outputs.every((t=>t.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=["match",this.input.serialize()],e=Object.keys(this.cases).sort(),r=[],n={};for(const t of e){const e=n[this.cases[t]];void 0===e?(n[this.cases[t]]=r.length,r.push([this.cases[t],[t]])):r[e][1].push(t);}const i=t=>"number"===this.inputType.kind?Number(t):t;for(const[e,n]of r)t.push(1===n.length?i(n[0]):n.map(i)),t.push(this.outputs[e].serialize());return t.push(this.otherwise.serialize()),t}}class pi{constructor(t,e,r){this.type=t,this.branches=e,this.otherwise=r;}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return e.error("Expected an odd number of arguments.");let r;e.expectedType&&"value"!==e.expectedType.kind&&(r=e.expectedType);const n=[];for(let i=1;i<t.length-1;i+=2){const a=e.parse(t[i],i,Le);if(!a)return null;const s=e.parse(t[i+1],i+1,r);if(!s)return null;n.push([a,s]),r=r||s.type;}const i=e.parse(t[t.length-1],t.length-1,r);return i?new pi(r,n,i):null}evaluate(t){for(const[e,r]of this.branches)if(e.evaluate(t))return r.evaluate(t);return this.otherwise.evaluate(t)}eachChild(t){for(const[e,r]of this.branches)t(e),t(r);t(this.otherwise);}outputDefined(){return this.branches.every((([t,e])=>e.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=["case"];return this.eachChild((e=>{t.push(e.serialize());})),t}}class fi{constructor(t,e,r,n){this.type=t,this.input=e,this.beginIndex=r,this.endIndex=n;}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,Ue),n=e.parse(t[2],2,Re);if(!r||!n)return null;if(!Ze(r.type,[$e(Ue),De,Ue]))return e.error(`Expected first argument to be of type array or string, but found ${Ge(r.type)} instead`);if(4===t.length){const i=e.parse(t[3],3,Re);return i?new fi(r.type,r,n,i):null}return new fi(r.type,r,n)}evaluate(t){const e=this.input.evaluate(t),r=this.beginIndex.evaluate(t);if(!We(e,["string","array"]))throw new ar(`Expected first argument to be of type array or string, but found ${Ge(rr(e))} instead.`);if(this.endIndex){const n=this.endIndex.evaluate(t);return e.slice(r,n)}return e.slice(r)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex);}outputDefined(){return !1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const t=this.endIndex.serialize();return ["slice",this.input.serialize(),this.beginIndex.serialize(),t]}return ["slice",this.input.serialize(),this.beginIndex.serialize()]}}function di(t,e){return "=="===t||"!="===t?"boolean"===e.kind||"string"===e.kind||"number"===e.kind||"null"===e.kind||"value"===e.kind:"string"===e.kind||"number"===e.kind||"value"===e.kind}function mi(t,e,r,n){return 0===n.compare(e,r)}function yi(t,e,r){const n="=="!==t&&"!="!==t;return class i{constructor(t,e,r){this.type=Le,this.lhs=t,this.rhs=e,this.collator=r,this.hasUntypedArgument="value"===t.type.kind||"value"===e.type.kind;}static parse(t,e){if(3!==t.length&&4!==t.length)return e.error("Expected two or three arguments.");const r=t[0];let a=e.parse(t[1],1,Ue);if(!a)return null;if(!di(r,a.type))return e.concat(1).error(`"${r}" comparisons are not supported for type '${Ge(a.type)}'.`);let s=e.parse(t[2],2,Ue);if(!s)return null;if(!di(r,s.type))return e.concat(2).error(`"${r}" comparisons are not supported for type '${Ge(s.type)}'.`);if(a.type.kind!==s.type.kind&&"value"!==a.type.kind&&"value"!==s.type.kind)return e.error(`Cannot compare types '${Ge(a.type)}' and '${Ge(s.type)}'.`);n&&("value"===a.type.kind&&"value"!==s.type.kind?a=new or(s.type,[a]):"value"!==a.type.kind&&"value"===s.type.kind&&(s=new or(a.type,[s])));let o=null;if(4===t.length){if("string"!==a.type.kind&&"string"!==s.type.kind&&"value"!==a.type.kind&&"value"!==s.type.kind)return e.error("Cannot use collator to compare non-string types.");if(o=e.parse(t[3],3,je),!o)return null}return new i(a,s,o)}evaluate(i){const a=this.lhs.evaluate(i),s=this.rhs.evaluate(i);if(n&&this.hasUntypedArgument){const e=rr(a),r=rr(s);if(e.kind!==r.kind||"string"!==e.kind&&"number"!==e.kind)throw new ar(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${r.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const t=rr(a),r=rr(s);if("string"!==t.kind||"string"!==r.kind)return e(i,a,s)}return this.collator?r(i,a,s,this.collator.evaluate(i)):e(i,a,s)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator);}outputDefined(){return !0}serialize(){const e=[t];return this.eachChild((t=>{e.push(t.serialize());})),e}}}const gi=yi("==",(function(t,e,r){return e===r}),mi),xi=yi("!=",(function(t,e,r){return e!==r}),(function(t,e,r,n){return !mi(0,e,r,n)})),vi=yi("<",(function(t,e,r){return e<r}),(function(t,e,r,n){return n.compare(e,r)<0})),bi=yi(">",(function(t,e,r){return e>r}),(function(t,e,r,n){return n.compare(e,r)>0})),wi=yi("<=",(function(t,e,r){return e<=r}),(function(t,e,r,n){return n.compare(e,r)<=0})),_i=yi(">=",(function(t,e,r){return e>=r}),(function(t,e,r,n){return n.compare(e,r)>=0}));class Mi{constructor(t,e,r,n,i,a){this.type=De,this.number=t,this.locale=e,this.currency=r,this.unit=n,this.minFractionDigits=i,this.maxFractionDigits=a;}static parse(t,e){if(3!==t.length)return e.error("Expected two arguments.");const r=e.parse(t[1],1,Re);if(!r)return null;const n=t[2];if("object"!=typeof n||Array.isArray(n))return e.error("NumberFormat options argument must be an object.");let i=null;if(n.locale&&(i=e.parseObjectValue(n.locale,2,"locale",De),!i))return null;let a=null;if(n.currency&&(a=e.parseObjectValue(n.currency,2,"currency",De),!a))return null;let s=null;if(n.unit&&(s=e.parseObjectValue(n.unit,2,"unit",De),!s))return null;let o=null;if(n["min-fraction-digits"]&&(o=e.parseObjectValue(n["min-fraction-digits"],2,"min-fraction-digits",Re),!o))return null;let l=null;return n["max-fraction-digits"]&&(l=e.parseObjectValue(n["max-fraction-digits"],2,"max-fraction-digits",Re),!l)?null:new Mi(r,i,a,s,o,l)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(t):void 0,unit:this.unit?this.unit.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.unit&&t(this.unit),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits);}outputDefined(){return !1}serialize(){const t={};return this.locale&&(t.locale=this.locale.serialize()),this.currency&&(t.currency=this.currency.serialize()),this.unit&&(t.unit=this.unit.serialize()),this.minFractionDigits&&(t["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(t["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),t]}}class Ai{constructor(t){this.type=Re,this.input=t;}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const r=e.parse(t[1],1);return r?"array"!==r.type.kind&&"string"!==r.type.kind&&"value"!==r.type.kind?e.error(`Expected argument of type string or array, but found ${Ge(r.type)} instead.`):new Ai(r):null}evaluate(t){const e=this.input.evaluate(t);if("string"==typeof e)return e.length;if(Array.isArray(e))return e.length;throw new ar(`Expected value to be of type string or array, but found ${Ge(rr(e))} instead.`)}eachChild(t){t(this.input);}outputDefined(){return !1}serialize(){const t=["length"];return this.eachChild((e=>{t.push(e.serialize());})),t}}function Si(t){return function(){t=1831565813+(t|=0)|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}const Ii={"==":gi,"!=":xi,">":bi,"<":vi,">=":_i,"<=":wi,array:or,at:li,boolean:or,case:pi,coalesce:si,collator:gr,format:lr,image:ur,in:ui,"index-of":ci,interpolate:ii,"interpolate-hcl":ii,"interpolate-lab":ii,length:Ai,let:oi,literal:ir,match:hi,number:or,"number-format":Mi,object:or,slice:fi,step:On,string:or,"to-boolean":pr,"to-color":pr,"to-number":pr,"to-string":pr,var:Cn,within:Or,distance:In,config:kn};function zi(t,[e,r,n,i]){e=e.evaluate(t),r=r.evaluate(t),n=n.evaluate(t);const a=i?i.evaluate(t):1,s=tr(e,r,n,a);if(s)throw new ar(s);return new Ie(e/255*a,r/255*a,n/255*a,a)}function Pi(t,[e,r,n,i]){e=e.evaluate(t),r=r.evaluate(t),n=n.evaluate(t);const a=i?i.evaluate(t):1,s=function(t,e,r,n){return "number"==typeof t&&t>=0&&t<=360?"number"==typeof e&&e>=0&&e<=100&&"number"==typeof r&&r>=0&&r<=100?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid hsla value [${[t,e,r,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${("number"==typeof n?[t,e,r,n]:[t,e,r]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${("number"==typeof n?[t,e,r,n]:[t,e,r]).join(", ")}]: 'h' must be between 0 and 360.`}(e,r,n,a);if(s)throw new ar(s);const o=`hsla(${e}, ${r}%, ${n}%, ${a})`,l=Ie.parse(o);if(!l)throw new ar(`Failed to parse HSLA color: ${o}`);return l}function ki(t,e){return t in e}function Ti(t,e){const r=e[t];return void 0===r?null:r}function Ei(t){return {type:t}}function Bi(t){return {result:"success",value:t}}function Vi(t){return {result:"error",value:t}}function Ci(t,e){return !!t&&!!t.parameters&&t.parameters.indexOf(e)>-1}function Ri(t){return "data-driven"===t["property-type"]}function Di(t){return Ci(t.expression,"measure-light")}function Li(t){return Ci(t.expression,"zoom")}function Fi(t){return !!t.expression&&t.expression.interpolated}function Oi(t){return "object"==typeof t&&null!==t&&!Array.isArray(t)}function Ui(t){return t}function ji(t,e){const r="color"===e.type,n=t.stops&&"object"==typeof t.stops[0][0],i=n||!(n||void 0!==t.property),a=t.type||(Fi(e)?"exponential":"interval");if(r&&((t=Ee({},t)).stops&&(t.stops=t.stops.map((t=>[t[0],Ie.parse(t[1])]))),t.default=Ie.parse(t.default?t.default:e.default)),t.colorSpace&&"rgb"!==t.colorSpace&&!ni[t.colorSpace])throw new Error(`Unknown color space: ${t.colorSpace}`);let s,o,l;if("exponential"===a)s=Gi;else if("interval"===a)s=$i;else if("categorical"===a){s=qi,o=Object.create(null);for(const e of t.stops)o[e[0]]=e[1];l=typeof t.stops[0][0];}else {if("identity"!==a)throw new Error(`Unknown function type "${a}"`);s=Xi;}if(n){const r={},n=[];for(let e=0;e<t.stops.length;e++){const i=t.stops[e],a=i[0].zoom;void 0===r[a]&&(r[a]={zoom:a,type:t.type,property:t.property,default:t.default,stops:[]},n.push(a)),r[a].stops.push([i[0].value,i[1]]);}const i=[];for(const t of n)i.push([r[t].zoom,ji(r[t],e)]);const a={name:"linear"};return {kind:"composite",interpolationType:a,interpolationFactor:ii.interpolationFactor.bind(void 0,a),zoomStops:i.map((t=>t[0])),evaluate:({zoom:r},n)=>Gi({stops:i,base:t.base},e,r).evaluate(r,n)}}if(i){const r="exponential"===a?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return {kind:"camera",interpolationType:r,interpolationFactor:ii.interpolationFactor.bind(void 0,r),zoomStops:t.stops.map((t=>t[0])),evaluate:({zoom:r})=>s(t,e,r,o,l)}}return {kind:"source",evaluate(r,n){const i=n&&n.properties?n.properties[t.property]:void 0;return void 0===i?Ni(t.default,e.default):s(t,e,i,o,l)}}}function Ni(t,e,r){return void 0!==t?t:void 0!==e?e:void 0!==r?r:void 0}function qi(t,e,r,n,i){return Ni(typeof r===i?n[r]:void 0,t.default,e.default)}function $i(t,e,r){if("number"!==cr(r))return Ni(t.default,e.default);const n=t.stops.length;if(1===n)return t.stops[0][1];if(r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[n-1][0])return t.stops[n-1][1];const i=Fn(t.stops.map((t=>t[0])),r);return t.stops[i][1]}function Gi(t,e,r){const n=void 0!==t.base?t.base:1;if("number"!==cr(r))return Ni(t.default,e.default);const i=t.stops.length;if(1===i)return t.stops[0][1];if(r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[i-1][0])return t.stops[i-1][1];const a=Fn(t.stops.map((t=>t[0])),r),s=function(t,e,r,n){const i=n-r,a=t-r;return 0===i?0:1===e?a/i:(Math.pow(e,a)-1)/(Math.pow(e,i)-1)}(r,n,t.stops[a][0],t.stops[a+1][0]),o=t.stops[a][1],l=t.stops[a+1][1];let u=Te[e.type]||Ui;if(t.colorSpace&&"rgb"!==t.colorSpace){const e=ni[t.colorSpace];u=(t,r)=>e.reverse(e.interpolate(e.forward(t),e.forward(r),s));}return "function"==typeof o.evaluate?{evaluate(...t){const e=o.evaluate.apply(void 0,t),r=l.evaluate.apply(void 0,t);if(void 0!==e&&void 0!==r)return u(e,r,s)}}:u(o,l,s)}function Xi(t,e,r){return "color"===e.type?r=Ie.parse(r):"formatted"===e.type?r=Je.fromString(r.toString()):"resolvedImage"===e.type?r=Qe.fromString(r.toString()):cr(r)===e.type||"enum"===e.type&&e.values[r]||(r=void 0),Ni(r,t.default,e.default)}mr.register(Ii,{error:[{kind:"error"},[De],(t,[e])=>{throw new ar(e.evaluate(t))}],typeof:[De,[Ue],(t,[e])=>Ge(rr(e.evaluate(t)))],"to-rgba":[$e(Re,4),[Fe],(t,[e])=>e.evaluate(t).toRenderColor(null).toArray()],rgb:[Fe,[Re,Re,Re],zi],rgba:[Fe,[Re,Re,Re,Re],zi],hsl:[Fe,[Re,Re,Re],Pi],hsla:[Fe,[Re,Re,Re,Re],Pi],has:{type:Le,overloads:[[[De],(t,[e])=>ki(e.evaluate(t),t.properties())],[[De,Oe],(t,[e,r])=>ki(e.evaluate(t),r.evaluate(t))]]},get:{type:Ue,overloads:[[[De],(t,[e])=>Ti(e.evaluate(t),t.properties())],[[De,Oe],(t,[e,r])=>Ti(e.evaluate(t),r.evaluate(t))]]},"feature-state":[Ue,[De],(t,[e])=>Ti(e.evaluate(t),t.featureState||{})],properties:[Oe,[],t=>t.properties()],"geometry-type":[De,[],t=>t.geometryType()],id:[Ue,[],t=>t.id()],zoom:[Re,[],t=>t.globals.zoom],pitch:[Re,[],t=>t.globals.pitch||0],"distance-from-center":[Re,[],t=>t.distanceFromCenter()],"measure-light":[Re,[De],(t,[e])=>t.measureLight(e.evaluate(t))],"heatmap-density":[Re,[],t=>t.globals.heatmapDensity||0],"line-progress":[Re,[],t=>t.globals.lineProgress||0],"raster-value":[Re,[],t=>t.globals.rasterValue||0],"raster-particle-speed":[Re,[],t=>t.globals.rasterParticleSpeed||0],"sky-radial-progress":[Re,[],t=>t.globals.skyRadialProgress||0],accumulated:[Ue,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[Re,Ei(Re),(t,e)=>{let r=0;for(const n of e)r+=n.evaluate(t);return r}],"*":[Re,Ei(Re),(t,e)=>{let r=1;for(const n of e)r*=n.evaluate(t);return r}],"-":{type:Re,overloads:[[[Re,Re],(t,[e,r])=>e.evaluate(t)-r.evaluate(t)],[[Re],(t,[e])=>-e.evaluate(t)]]},"/":[Re,[Re,Re],(t,[e,r])=>e.evaluate(t)/r.evaluate(t)],"%":[Re,[Re,Re],(t,[e,r])=>e.evaluate(t)%r.evaluate(t)],ln2:[Re,[],()=>Math.LN2],pi:[Re,[],()=>Math.PI],e:[Re,[],()=>Math.E],"^":[Re,[Re,Re],(t,[e,r])=>Math.pow(e.evaluate(t),r.evaluate(t))],sqrt:[Re,[Re],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[Re,[Re],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[Re,[Re],(t,[e])=>Math.log(e.evaluate(t))],log2:[Re,[Re],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[Re,[Re],(t,[e])=>Math.sin(e.evaluate(t))],cos:[Re,[Re],(t,[e])=>Math.cos(e.evaluate(t))],tan:[Re,[Re],(t,[e])=>Math.tan(e.evaluate(t))],asin:[Re,[Re],(t,[e])=>Math.asin(e.evaluate(t))],acos:[Re,[Re],(t,[e])=>Math.acos(e.evaluate(t))],atan:[Re,[Re],(t,[e])=>Math.atan(e.evaluate(t))],min:[Re,Ei(Re),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[Re,Ei(Re),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[Re,[Re],(t,[e])=>Math.abs(e.evaluate(t))],round:[Re,[Re],(t,[e])=>{const r=e.evaluate(t);return r<0?-Math.round(-r):Math.round(r)}],floor:[Re,[Re],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[Re,[Re],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[Le,[De,Ue],(t,[e,r])=>t.properties()[e.value]===r.value],"filter-id-==":[Le,[Ue],(t,[e])=>t.id()===e.value],"filter-type-==":[Le,[De],(t,[e])=>t.geometryType()===e.value],"filter-<":[Le,[De,Ue],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n<i}],"filter-id-<":[Le,[Ue],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r<n}],"filter->":[Le,[De,Ue],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n>i}],"filter-id->":[Le,[Ue],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r>n}],"filter-<=":[Le,[De,Ue],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n<=i}],"filter-id-<=":[Le,[Ue],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r<=n}],"filter->=":[Le,[De,Ue],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n>=i}],"filter-id->=":[Le,[Ue],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r>=n}],"filter-has":[Le,[Ue],(t,[e])=>e.value in t.properties()],"filter-has-id":[Le,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[Le,[$e(De)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[Le,[$e(Ue)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[Le,[De,$e(Ue)],(t,[e,r])=>r.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[Le,[De,$e(Ue)],(t,[e,r])=>function(t,e,r,n){for(;r<=n;){const i=r+n>>1;if(e[i]===t)return !0;e[i]>t?n=i-1:r=i+1;}return !1}(t.properties()[e.value],r.value,0,r.value.length-1)],all:{type:Le,overloads:[[[Le,Le],(t,[e,r])=>e.evaluate(t)&&r.evaluate(t)],[Ei(Le),(t,e)=>{for(const r of e)if(!r.evaluate(t))return !1;return !0}]]},any:{type:Le,overloads:[[[Le,Le],(t,[e,r])=>e.evaluate(t)||r.evaluate(t)],[Ei(Le),(t,e)=>{for(const r of e)if(r.evaluate(t))return !0;return !1}]]},"!":[Le,[Le],(t,[e])=>!e.evaluate(t)],"is-supported-script":[Le,[De],(t,[e])=>{const r=t.globals&&t.globals.isSupportedScript;return !r||r(e.evaluate(t))}],upcase:[De,[De],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[De,[De],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[De,Ei(Ue),(t,e)=>e.map((e=>nr(e.evaluate(t)))).join("")],"resolved-locale":[De,[je],(t,[e])=>e.evaluate(t).resolvedLocale()],random:[Re,[Re,Re,Ue],(t,e)=>{const[r,n,i]=e.map((e=>e.evaluate(t)));if(r>n)return r;if(r===n)return r;let a;if("string"==typeof i)a=function(t){let e=0;if(0===t.length)return e;for(let r=0;r<t.length;r++)e=(e<<5)-e+t.charCodeAt(r),e|=0;return e}(i);else {if("number"!=typeof i)throw new ar(`Invalid seed input: ${i}`);a=i;}return r+Si(a)()*(n-r)}]});class Yi{constructor(t,e,r,n){this.expression=t,this._warningHistory={},this._evaluator=new dr(r,n),this._defaultValue=e?function(t){return "color"===t.type&&(Oi(t.default)||Array.isArray(t.default))?new Ie(0,0,0,0):"color"===t.type?Ie.parse(t.default)||null:void 0===t.default?null:t.default}(e):null,this._enumValues=e&&"enum"===e.type?e.values:null,this.configDependencies=Bn(t);}evaluateWithoutErrorHandling(t,e,r,n,i,a,s,o){return this._evaluator.globals=t,this._evaluator.feature=e,this._evaluator.featureState=r,this._evaluator.canonical=n||null,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=a,this._evaluator.featureTileCoord=s||null,this._evaluator.featureDistanceData=o||null,this.expression.evaluate(this._evaluator)}evaluate(t,e,r,n,i,a,s,o){this._evaluator.globals=t,this._evaluator.feature=e||null,this._evaluator.featureState=r||null,this._evaluator.canonical=n||null,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=a||null,this._evaluator.featureTileCoord=s||null,this._evaluator.featureDistanceData=o||null;try{const t=this.expression.evaluate(this._evaluator);if(null==t||"number"==typeof t&&t!=t)return this._defaultValue;if(this._enumValues&&!(t in this._enumValues))throw new ar(`Expected value to be one of ${Object.keys(this._enumValues).map((t=>JSON.stringify(t))).join(", ")}, but found ${JSON.stringify(t)} instead.`);return t}catch(t){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 Zi(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in Ii}function Wi(t,e,r,n){const i=new Dn(Ii,[],e?function(t){const e={color:Fe,string:De,number:Re,enum:De,boolean:Le,formatted:Ne,resolvedImage:qe};return "array"===t.type?$e(e[t.value]||Ue,t.length):e[t.type]}(e):void 0,void 0,void 0,r,n),a=i.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return a?Bi(new Yi(a,e,r,n)):Vi(i.errors)}class Hi{constructor(t,e,r){this.kind=t,this._styleExpression=e,this.isLightConstant=r,this.isStateDependent="constant"!==t&&!En(e.expression),this.configDependencies=Bn(e.expression);}evaluateWithoutErrorHandling(t,e,r,n,i,a){return this._styleExpression.evaluateWithoutErrorHandling(t,e,r,n,i,a)}evaluate(t,e,r,n,i,a){return this._styleExpression.evaluate(t,e,r,n,i,a)}}class Ki{constructor(t,e,r,n,i){this.kind=t,this.zoomStops=r,this._styleExpression=e,this.isStateDependent="camera"!==t&&!En(e.expression),this.isLightConstant=i,this.configDependencies=Bn(e.expression),this.interpolationType=n;}evaluateWithoutErrorHandling(t,e,r,n,i,a){return this._styleExpression.evaluateWithoutErrorHandling(t,e,r,n,i,a)}evaluate(t,e,r,n,i,a){return this._styleExpression.evaluate(t,e,r,n,i,a)}interpolationFactor(t,e,r){return this.interpolationType?ii.interpolationFactor(this.interpolationType,t,e,r):0}}function Ji(t,e,r,n){if("error"===(t=Wi(t,e,r,n)).result)return t;const i=t.value.expression,a=Tn(i);if(!a&&!Ri(e))return Vi([new Be("","data expressions not supported")]);const s=Vn(i,["zoom","pitch","distance-from-center"]);if(!s&&!Li(e))return Vi([new Be("","zoom expressions not supported")]);const o=Vn(i,["measure-light"]);if(!o&&!Di(e))return Vi([new Be("","measure-light expression not supported")]);const l=Vn(i,["line-progress"]);if(!l&&!function(t){return Ci(t.expression,"line-progress")}(e))return Vi([new Be("","line-progress expression not supported")]);const u=e.expression&&e.expression.relaxZoomRestriction,c=ta(i);return c||s||u?c instanceof Be?Vi([c]):c instanceof ii&&!Fi(e)?Vi([new Be("",'"interpolate" expressions cannot be used with this property')]):Bi(c?new Ki(a&&l?"camera":"composite",t.value,c.labels,c instanceof ii?c.interpolation:void 0,o):new Hi(a&&l?"constant":"source",t.value,o)):Vi([new Be("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class Qi{constructor(t,e){this._parameters=t,this._specification=e,Ee(this,ji(this._parameters,this._specification));}static deserialize(t){return new Qi(t._parameters,t._specification)}static serialize(t){return {_parameters:t._parameters,_specification:t._specification}}}function ta(t){let e=null;if(t instanceof oi)e=ta(t.result);else if(t instanceof si){for(const r of t.args)if(e=ta(r),e)break}else (t instanceof On||t instanceof ii)&&t.input instanceof mr&&"zoom"===t.input.name&&(e=t);return e instanceof Be||t.eachChild((t=>{const r=ta(t);r instanceof Be?e=r:e&&r&&e!==r&&(e=new Be("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'));})),e}var ea,ra,na=function(){if(ra)return ea;ra=1,ea=e;var t=3;function e(e,r,n){var i=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;var a=new Int32Array(this.arrayBuffer);e=a[0],this.d=(r=a[1])+2*(n=a[2]);for(var s=0;s<this.d*this.d;s++){var o=a[t+s],l=a[t+s+1];i.push(o===l?null:a.subarray(o,l));}var u=a[t+i.length+1];this.keys=a.subarray(a[t+i.length],u),this.bboxes=a.subarray(u),this.insert=this._insertReadonly;}else {this.d=r+2*n;for(var c=0;c<this.d*this.d;c++)i.push([]);this.keys=[],this.bboxes=[];}this.n=r,this.extent=e,this.padding=n,this.scale=r/e,this.uid=0;var h=n/r*e;this.min=-h,this.max=e+h;}return e.prototype.insert=function(t,e,r,n,i){this._forEachCell(e,r,n,i,this._insertCell,this.uid++),this.keys.push(t),this.bboxes.push(e),this.bboxes.push(r),this.bboxes.push(n),this.bboxes.push(i);},e.prototype._insertReadonly=function(){throw "Cannot insert into a GridIndex created from an ArrayBuffer."},e.prototype._insertCell=function(t,e,r,n,i,a){this.cells[i].push(a);},e.prototype.query=function(t,e,r,n,i){var a=this.min,s=this.max;if(t<=a&&e<=a&&s<=r&&s<=n&&!i)return Array.prototype.slice.call(this.keys);var o=[];return this._forEachCell(t,e,r,n,this._queryCell,o,{},i),o},e.prototype._queryCell=function(t,e,r,n,i,a,s,o){var l=this.cells[i];if(null!==l)for(var u=this.keys,c=this.bboxes,h=0;h<l.length;h++){var p=l[h];if(void 0===s[p]){var f=4*p;(o?o(c[f+0],c[f+1],c[f+2],c[f+3]):t<=c[f+2]&&e<=c[f+3]&&r>=c[f+0]&&n>=c[f+1])?(s[p]=!0,a.push(u[p])):s[p]=!1;}}},e.prototype._forEachCell=function(t,e,r,n,i,a,s,o){for(var l=this._convertToCellCoord(t),u=this._convertToCellCoord(e),c=this._convertToCellCoord(r),h=this._convertToCellCoord(n),p=l;p<=c;p++)for(var f=u;f<=h;f++){var d=this.d*f+p;if((!o||o(this._convertFromCellCoord(p),this._convertFromCellCoord(f),this._convertFromCellCoord(p+1),this._convertFromCellCoord(f+1)))&&i.call(this,t,e,r,n,d,a,s,o))return}},e.prototype._convertFromCellCoord=function(t){return (t-this.padding)/this.scale},e.prototype._convertToCellCoord=function(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))},e.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var e=this.cells,r=t+this.cells.length+1+1,n=0,i=0;i<this.cells.length;i++)n+=this.cells[i].length;var a=new Int32Array(r+n+this.keys.length+this.bboxes.length);a[0]=this.extent,a[1]=this.n,a[2]=this.padding;for(var s=r,o=0;o<e.length;o++){var l=e[o];a[t+o]=s,a.set(l,s),s+=l.length;}return a[t+e.length]=s,a.set(this.keys,s),a[t+e.length+1]=s+=this.keys.length,a.set(this.bboxes,s),s+=this.bboxes.length,a.buffer},ea}(),ia=e(na);const aa={};function sa(t,e,r={}){Object.defineProperty(t,"_classRegistryKey",{value:e,writable:!1}),aa[e]={klass:t,omit:r.omit||[]};}sa(Object,"Object"),ia.serialize=function(t,e){const r=t.toArrayBuffer();return e&&e.add(r),{buffer:r}},ia.deserialize=function(t){return new ia(t.buffer)},Object.defineProperty(ia,"name",{value:"Grid"}),sa(ia,"Grid"),sa(Ie,"Color"),sa(Error,"Error"),sa(Je,"Formatted"),sa(Ke,"FormattedSection"),sa(ee,"AJAXError"),sa(Qe,"ResolvedImage"),sa(Qi,"StylePropertyFunction"),sa(Yi,"StyleExpression",{omit:["_evaluator"]}),sa(Ki,"ZoomDependentExpression"),sa(Hi,"ZoomConstantExpression"),sa(mr,"CompoundExpression",{omit:["_evaluate"]});for(const t in Ii)aa[Ii[t]._classRegistryKey]||sa(Ii[t],`Expression${t}`);function oa(t){return t&&"undefined"!=typeof ArrayBuffer&&(t instanceof ArrayBuffer||t.constructor&&"ArrayBuffer"===t.constructor.name)}function la(t){return self.ImageBitmap&&t instanceof ImageBitmap}function ua(t,e){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp)return t;if(oa(t)||la(t))return e&&e.add(t),t;if(ArrayBuffer.isView(t)){const r=t;return e&&e.add(r.buffer),r}if(t instanceof ImageData)return e&&e.add(t.data.buffer),t;if(Array.isArray(t)){const r=[];for(const n of t)r.push(ua(n,e));return r}if(t instanceof Map){const e={$name:"Map"};for(const[r,n]of t.entries())e[r]=ua(n);return e}if(t instanceof Set){const e={$name:"Set"};let r=0;for(const n of t.values())e[++r]=ua(n);return e}if("object"==typeof t){const r=t.constructor,n=r._classRegistryKey;if(!n)throw new Error(`can't serialize object of unregistered class ${n}`);const i=r.serialize?r.serialize(t,e):{};if(!r.serialize){for(const r in t)t.hasOwnProperty(r)&&(aa[n].omit.indexOf(r)>=0||(i[r]=ua(t[r],e)));t instanceof Error&&(i.message=t.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 t)}function ca(t){if(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||oa(t)||la(t)||ArrayBuffer.isView(t)||t instanceof ImageData)return t;if(Array.isArray(t))return t.map(ca);if("object"==typeof t){const e=t.$name||"Object";if("Map"===e){const e=new Map;for(const r of Object.keys(t))"$name"!==r&&e.set(r,ca(t[r]));return e}if("Set"===e){const e=new Set;for(const r of Object.keys(t))"$name"!==r&&e.add(ca(t[r]));return e}const{klass:r}=aa[e];if(!r)throw new Error(`can't deserialize unregistered class ${e}`);if(r.deserialize)return r.deserialize(t);const n=Object.create(r.prototype);for(const e of Object.keys(t))"$name"!==e&&(n[e]=ca(t[e]));return n}throw new Error("can't deserialize object of type "+typeof t)}const ha={"Latin-1 Supplement":t=>t>=128&&t<=255,Arabic:t=>t>=1536&&t<=1791,"Arabic Supplement":t=>t>=1872&&t<=1919,"Arabic Extended-A":t=>t>=2208&&t<=2303,"Hangul Jamo":t=>t>=4352&&t<=4607,"Unified Canadian Aboriginal Syllabics":t=>t>=5120&&t<=5759,Khmer:t=>t>=6016&&t<=6143,"Unified Canadian Aboriginal Syllabics Extended":t=>t>=6320&&t<=6399,"General Punctuation":t=>t>=8192&&t<=8303,"Letterlike Symbols":t=>t>=8448&&t<=8527,"Number Forms":t=>t>=8528&&t<=8591,"Miscellaneous Technical":t=>t>=8960&&t<=9215,"Control Pictures":t=>t>=9216&&t<=9279,"Optical Character Recognition":t=>t>=9280&&t<=9311,"Enclosed Alphanumerics":t=>t>=9312&&t<=9471,"Geometric Shapes":t=>t>=9632&&t<=9727,"Miscellaneous Symbols":t=>t>=9728&&t<=9983,"Miscellaneous Symbols and Arrows":t=>t>=11008&&t<=11263,"CJK Radicals Supplement":t=>t>=11904&&t<=12031,"Kangxi Radicals":t=>t>=12032&&t<=12255,"Ideographic Description Characters":t=>t>=12272&&t<=12287,"CJK Symbols and Punctuation":t=>t>=12288&&t<=12351,Hiragana:t=>t>=12352&&t<=12447,Katakana:t=>t>=12448&&t<=12543,Bopomofo:t=>t>=12544&&t<=12591,"Hangul Compatibility Jamo":t=>t>=12592&&t<=12687,Kanbun:t=>t>=12688&&t<=12703,"Bopomofo Extended":t=>t>=12704&&t<=12735,"CJK Strokes":t=>t>=12736&&t<=12783,"Katakana Phonetic Extensions":t=>t>=12784&&t<=12799,"Enclosed CJK Letters and Months":t=>t>=12800&&t<=13055,"CJK Compatibility":t=>t>=13056&&t<=13311,"CJK Unified Ideographs Extension A":t=>t>=13312&&t<=19903,"Yijing Hexagram Symbols":t=>t>=19904&&t<=19967,"CJK Unified Ideographs":t=>t>=19968&&t<=40959,"Yi Syllables":t=>t>=40960&&t<=42127,"Yi Radicals":t=>t>=42128&&t<=42191,"Hangul Jamo Extended-A":t=>t>=43360&&t<=43391,"Hangul Syllables":t=>t>=44032&&t<=55215,"Hangul Jamo Extended-B":t=>t>=55216&&t<=55295,"Private Use Area":t=>t>=57344&&t<=63743,"CJK Compatibility Ideographs":t=>t>=63744&&t<=64255,"Arabic Presentation Forms-A":t=>t>=64336&&t<=65023,"Vertical Forms":t=>t>=65040&&t<=65055,"CJK Compatibility Forms":t=>t>=65072&&t<=65103,"Small Form Variants":t=>t>=65104&&t<=65135,"Arabic Presentation Forms-B":t=>t>=65136&&t<=65279,"Halfwidth and Fullwidth Forms":t=>t>=65280&&t<=65519,Osage:t=>t>=66736&&t<=66815,"CJK Unified Ideographs Extension B":t=>t>=131072&&t<=173791};function pa(t){for(const e of t)if(ma(e.charCodeAt(0)))return !0;return !1}function fa(t){for(const e of t)if(!da(e.charCodeAt(0)))return !1;return !0}function da(t){return !(ha.Arabic(t)||ha["Arabic Supplement"](t)||ha["Arabic Extended-A"](t)||ha["Arabic Presentation Forms-A"](t)||ha["Arabic Presentation Forms-B"](t))}function ma(t){return !(746!==t&&747!==t&&(t<4352||!(ha["Bopomofo Extended"](t)||ha.Bopomofo(t)||ha["CJK Compatibility Forms"](t)&&!(t>=65097&&t<=65103)||ha["CJK Compatibility Ideographs"](t)||ha["CJK Compatibility"](t)||ha["CJK Radicals Supplement"](t)||ha["CJK Strokes"](t)||!(!ha["CJK Symbols and Punctuation"](t)||t>=12296&&t<=12305||t>=12308&&t<=12319||12336===t)||ha["CJK Unified Ideographs Extension A"](t)||ha["CJK Unified Ideographs"](t)||ha["Enclosed CJK Letters and Months"](t)||ha["Hangul Compatibility Jamo"](t)||ha["Hangul Jamo Extended-A"](t)||ha["Hangul Jamo Extended-B"](t)||ha["Hangul Jamo"](t)||ha["Hangul Syllables"](t)||ha.Hiragana(t)||ha["Ideographic Description Characters"](t)||ha.Kanbun(t)||ha["Kangxi Radicals"](t)||ha["Katakana Phonetic Extensions"](t)||ha.Katakana(t)&&12540!==t||!(!ha["Halfwidth and Fullwidth Forms"](t)||65288===t||65289===t||65293===t||t>=65306&&t<=65310||65339===t||65341===t||65343===t||t>=65371&&t<=65503||65507===t||t>=65512&&t<=65519)||!(!ha["Small Form Variants"](t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||ha["Unified Canadian Aboriginal Syllabics"](t)||ha["Unified Canadian Aboriginal Syllabics Extended"](t)||ha["Vertical Forms"](t)||ha["Yijing Hexagram Symbols"](t)||ha["Yi Syllables"](t)||ha["Yi Radicals"](t))))}function ya(t){return !(ma(t)||function(t){return !!(ha["Latin-1 Supplement"](t)&&(167===t||169===t||174===t||177===t||188===t||189===t||190===t||215===t||247===t)||ha["General Punctuation"](t)&&(8214===t||8224===t||8225===t||8240===t||8241===t||8251===t||8252===t||8258===t||8263===t||8264===t||8265===t||8273===t)||ha["Letterlike Symbols"](t)||ha["Number Forms"](t)||ha["Miscellaneous Technical"](t)&&(t>=8960&&t<=8967||t>=8972&&t<=8991||t>=8996&&t<=9e3||9003===t||t>=9085&&t<=9114||t>=9150&&t<=9165||9167===t||t>=9169&&t<=9179||t>=9186&&t<=9215)||ha["Control Pictures"](t)&&9251!==t||ha["Optical Character Recognition"](t)||ha["Enclosed Alphanumerics"](t)||ha["Geometric Shapes"](t)||ha["Miscellaneous Symbols"](t)&&!(t>=9754&&t<=9759)||ha["Miscellaneous Symbols and Arrows"](t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||ha["CJK Symbols and Punctuation"](t)||ha.Katakana(t)||ha["Private Use Area"](t)||ha["CJK Compatibility Forms"](t)||ha["Small Form Variants"](t)||ha["Halfwidth and Fullwidth Forms"](t)||8734===t||8756===t||8757===t||t>=9984&&t<=10087||t>=10102&&t<=10131||65532===t||65533===t)}(t))}function ga(t){return t>=1424&&t<=2303||ha["Arabic Presentation Forms-A"](t)||ha["Arabic Presentation Forms-B"](t)}function xa(t,e){return !(!e&&ga(t)||t>=2304&&t<=3583||t>=3840&&t<=4255||ha.Khmer(t))}function va(t){for(const e of t)if(ga(e.charCodeAt(0)))return !0;return !1}const ba="deferred",wa="loading",_a="loaded";let Ma=null,Aa="unavailable",Sa=null;const Ia=function(t){t&&"string"==typeof t&&t.indexOf("NetworkError")>-1&&(Aa="error"),Ma&&Ma(t);};function za(){Pa.fire(new xe("pluginStateChange",{pluginStatus:Aa,pluginURL:Sa}));}const Pa=new _e,ka=function(){return Aa},Ta=function(){if(Aa!==ba||!Sa)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Aa=wa,za(),Sa&&ie({url:Sa},(t=>{t?Ia(t):(Aa=_a,za());}));},Ea={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Aa===_a||null!=Ea.applyArabicShaping,isLoading:()=>Aa===wa,setState(t){Aa=t.pluginStatus,Sa=t.pluginURL;},isParsed:()=>null!=Ea.applyArabicShaping&&null!=Ea.processBidirectionalText&&null!=Ea.processStyledBidirectionalText,getPluginURL:()=>Sa};class Ba{constructor(t,e){this.zoom=t,e?(this.now=e.now,this.fadeDuration=e.fadeDuration,this.transition=e.transition,this.pitch=e.pitch,this.brightness=e.brightness):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0);}isSupportedScript(t){return function(t,e){for(const r of t)if(!xa(r.charCodeAt(0),e))return !1;return !0}(t,Ea.isLoaded())}}class Va{constructor(t,e,r,n){this.property=t,this.value=e,this.expression=function(t,e,r,n){if(Oi(t))return new Qi(t,e);if(Zi(t)||Array.isArray(t)&&t.length>0){const i=Ji(t,e,r,n);if("error"===i.result)throw new Error(i.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return i.value}{let r=t;return "string"==typeof t&&"color"===e.type&&(r=Ie.parse(t)),{kind:"constant",configDependencies:new Set,evaluate:()=>r}}}(void 0===e?t.specification.default:e,t.specification,r,n);}isDataDriven(){return "source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(t,e,r){return this.property.possiblyEvaluate(this,t,e,r)}}class Ca{constructor(t,e,r){this.property=t,this.value=new Va(t,void 0,e,r);}transitioned(t,e){return new Da(this.property,this.value,e,nt({},t.transition,this.transition),t.now)}untransitioned(){return new Da(this.property,this.value,null,{},0)}}class Ra{constructor(t,e,r){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues),this._scope=e,this._options=r,this.configDependencies=new Set;}getValue(t){return ht(this._values[t].value.value)}setValue(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new Ca(this._values[t].property,this._scope,this._options)),this._values[t].value=new Va(this._values[t].property,null===e?void 0:ht(e),this._scope,this._options),this._values[t].value.expression.configDependencies&&(this.configDependencies=new Set([...this.configDependencies,...this._values[t].value.expression.configDependencies]));}setTransitionOrValue(t,e){e&&(this._options=e);const r=this._properties.properties;if(t)for(const e in t){const n=t[e];if(lt(e,"-transition")){const t=e.slice(0,-11);r[t]&&this.setTransition(t,n);}else r.hasOwnProperty(e)&&this.setValue(e,n);}}getTransition(t){return ht(this._values[t].transition)}setTransition(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new Ca(this._values[t].property)),this._values[t].transition=ht(e)||void 0;}serialize(){const t={};for(const e of Object.keys(this._values)){const r=this.getValue(e);void 0!==r&&(t[e]=r);const n=this.getTransition(e);void 0!==n&&(t[`${e}-transition`]=n);}return t}transitioned(t,e){const r=new La(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].transitioned(t,e._values[n]);return r}untransitioned(){const t=new La(this._properties);for(const e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}}class Da{constructor(t,e,r,n,i){const a=n.delay||0,s=n.duration||0;i=i||0,this.property=t,this.value=e,this.begin=i+a,this.end=this.begin+s,t.specification.transition&&(n.delay||n.duration)&&(this.prior=r);}possiblyEvaluate(t,e,r){const n=t.now||0,i=this.value.possiblyEvaluate(t,e,r),a=this.prior;if(a){if(n>this.end)return this.prior=null,i;if(this.value.isDataDriven())return this.prior=null,i;if(n<this.begin)return a.possiblyEvaluate(t,e,r);{const s=(n-this.begin)/(this.end-this.begin);return this.property.interpolate(a.possiblyEvaluate(t,e,r),i,H(s))}}return i}}class La{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues);}possiblyEvaluate(t,e,r){const n=new Ua(this._properties);for(const i of Object.keys(this._values))n._values[i]=this._values[i].possiblyEvaluate(t,e,r);return n}hasTransition(){for(const t of Object.keys(this._values))if(this._values[t].prior)return !0;return !1}}class Fa{constructor(t,e,r){this._properties=t,this._values=Object.create(t.defaultPropertyValues),this._scope=e,this._options=r,this.configDependencies=new Set;}getValue(t){return ht(this._values[t].value)}setValue(t,e){this._values[t]=new Va(this._values[t].property,null===e?void 0:ht(e),this._scope,this._options),this._values[t].expression.configDependencies&&(this.configDependencies=new Set([...this.configDependencies,...this._values[t].expression.configDependencies]));}serialize(){const t={};for(const e of Object.keys(this._values)){const r=this.getValue(e);void 0!==r&&(t[e]=r);}return t}possiblyEvaluate(t,e,r){const n=new Ua(this._properties);for(const i of Object.keys(this._values))n._values[i]=this._values[i].possiblyEvaluate(t,e,r);return n}}class Oa{constructor(t,e,r){this.property=t,this.value=e,this.parameters=r;}isConstant(){return "constant"===this.value.kind}constantOr(t){return "constant"===this.value.kind?this.value.value:t}evaluate(t,e,r,n){return this.property.evaluate(this.value,this.parameters,t,e,r,n)}}class Ua{constructor(t){this._properties=t,this._values=Object.create(t.defaultPossiblyEvaluatedValues);}get(t){return this._values[t]}}class ja{constructor(t){this.specification=t;}possiblyEvaluate(t,e){return t.expression.evaluate(e)}interpolate(t,e,r){const n=Te[this.specification.type];return n?n(t,e,r):t}}class Na{constructor(t,e){this.specification=t,this.overrides=e;}possiblyEvaluate(t,e,r,n){return new Oa(this,"constant"===t.expression.kind||"camera"===t.expression.kind?{kind:"constant",value:t.expression.evaluate(e,null,{},r,n)}:t.expression,e)}interpolate(t,e,r){if("constant"!==t.value.kind||"constant"!==e.value.kind)return t;if(void 0===t.value.value||void 0===e.value.value)return new Oa(this,{kind:"constant",value:void 0},t.parameters);const n=Te[this.specification.type];return n?new Oa(this,{kind:"constant",value:n(t.value.value,e.value.value,r)},t.parameters):t}evaluate(t,e,r,n,i,a){return "constant"===t.kind?t.value:t.evaluate(e,r,n,i,a)}}class qa{constructor(t){this.specification=t;}possiblyEvaluate(t,e,r,n){return !!t.expression.evaluate(e,null,{},r,n)}interpolate(){return !1}}class $a{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];const e=new Ba(0,{});for(const r in t){const n=t[r];n.specification.overridable&&this.overridableProperties.push(r);const i=this.defaultPropertyValues[r]=new Va(n,void 0),a=this.defaultTransitionablePropertyValues[r]=new Ca(n);this.defaultTransitioningPropertyValues[r]=a.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=i.possiblyEvaluate(e);}}}sa(Na,"DataDrivenProperty"),sa(ja,"DataConstantProperty"),sa(qa,"ColorRampProperty");var Ga=JSON.parse('{"$version":8,"$root":{"version":{"required":true,"type":"enum","values":[8]},"fragment":{"type":"boolean"},"name":{"type":"string"},"metadata":{"type":"*"},"center":{"type":"array","value":"number"},"zoom":{"type":"number"},"bearing":{"type":"number","default":0,"period":360},"pitch":{"type":"number","default":0},"light":{"type":"light"},"lights":{"required":false,"type":"array","value":"light-3d"},"terrain":{"type":"terrain","optional":true},"fog":{"type":"fog"},"camera":{"type":"camera"},"color-theme":{"type":"colorTheme"},"imports":{"type":"array","value":"import"},"schema":{"type":"schema"},"sources":{"required":true,"type":"sources"},"sprite":{"type":"string"},"glyphs":{"type":"string","default":"mapbox://fonts/mapbox/{fontstack}/{range}.pbf"},"transition":{"type":"transition"},"projection":{"type":"projection"},"layers":{"required":true,"type":"array","value":"layer"},"models":{"type":"models"},"featuresets":{"experimental":true,"type":"featuresets"}},"featuresets":{"experimental":true,"*":{"type":"featureset"}},"featureset":{"experimental":true,"metadata":{"type":"*"},"selectors":{"type":"array","value":"selector"}},"selector":{"experimental":true,"layer":{"type":"string","required":true},"properties":{"type":"selectorProperty","required":false},"featureNamespace":{"type":"string","required":false}},"selectorProperty":{"experimental":true,"*":{"type":"*"}},"model":{"type":"string","required":true},"import":{"id":{"type":"string","required":true},"url":{"type":"string","required":true},"config":{"type":"config"},"data":{"type":"$root"}},"config":{"*":{"type":"*"}},"schema":{"*":{"type":"option"}},"option":{"default":{"type":"*","property-type":"data-constant","expression":{},"required":true},"type":{"type":"enum","values":{"string":1,"number":1,"boolean":1,"color":1}},"array":{"type":"boolean"},"minValue":{"type":"number"},"maxValue":{"type":"number"},"stepValue":{"type":"number"},"values":{"type":"array","value":"*"},"metadata":{"type":"*"}},"models":{"*":{"type":"model"}},"light-3d":{"id":{"type":"string","required":true},"properties":{"type":"properties"},"type":{"type":"enum","values":{"ambient":{},"directional":{},"flat":{}}}},"properties":["properties_light_directional","properties_light_ambient","properties_light_flat"],"properties_light_directional":{"direction":{"type":"array","default":[210,30],"minimum":[0,0],"maximum":[360,90],"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"cast-shadows":{"type":"boolean","default":false,"property-type":"data-constant"},"shadow-intensity":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"properties_light_ambient":{"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"properties_light_flat":{"anchor":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"property-type":"data-constant","expression":{"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"sources":{"*":{"type":"source"}},"source":["source_vector","source_raster","source_raster_dem","source_raster_array","source_geojson","source_video","source_image","source_model"],"source_vector":{"type":{"required":true,"type":"enum","values":{"vector":1}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"scheme":{"type":"enum","values":{"xyz":1,"tms":1},"default":"xyz"},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"attribution":{"type":"string"},"promoteId":{"type":"promoteId"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster":{"type":{"required":true,"type":"enum","values":{"raster":1}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512},"scheme":{"type":"enum","values":{"xyz":1,"tms":1},"default":"xyz"},"attribution":{"type":"string"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_dem":{"type":{"required":true,"type":"enum","values":{"raster-dem":1}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512},"attribution":{"type":"string"},"encoding":{"type":"enum","values":{"terrarium":1,"mapbox":1},"default":"mapbox"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_array":{"experimental":true,"type":{"required":true,"type":"enum","values":{"raster-array":1}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512},"attribution":{"type":"string"},"rasterLayers":{"type":"*"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_geojson":{"type":{"required":true,"type":"enum","values":{"geojson":1}},"data":{"type":"*"},"maxzoom":{"type":"number","default":18},"minzoom":{"type":"number","default":0},"attribution":{"type":"string"},"buffer":{"type":"number","default":128,"maximum":512,"minimum":0},"filter":{"type":"*"},"tolerance":{"type":"number","default":0.375},"cluster":{"type":"boolean","default":false},"clusterRadius":{"type":"number","default":50,"minimum":0},"clusterMaxZoom":{"type":"number"},"clusterMinPoints":{"type":"number"},"clusterProperties":{"type":"*"},"lineMetrics":{"type":"boolean","default":false},"generateId":{"type":"boolean","default":false},"promoteId":{"type":"promoteId"},"dynamic":{"type":"boolean","default":false}},"source_video":{"type":{"required":true,"type":"enum","values":{"video":1}},"urls":{"required":true,"type":"array","value":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"source_image":{"type":{"required":true,"type":"enum","values":{"image":1}},"url":{"required":false,"type":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"source_model":{"type":{"required":true,"type":"enum","values":{"model":1,"batched-model":1}},"maxzoom":{"type":"number","default":18},"minzoom":{"type":"number","default":0},"tiles":{"type":"array","value":"string"}},"layer":{"id":{"type":"string","required":true},"type":{"type":"enum","values":{"fill":{},"line":{},"symbol":{},"circle":{},"heatmap":{},"fill-extrusion":{},"raster":{},"raster-particle":{"experimental":true},"hillshade":{},"model":{"experimental":true},"background":{},"sky":{},"slot":{},"clip":{}},"required":true},"metadata":{"type":"*"},"source":{"type":"string"},"source-layer":{"type":"string"},"slot":{"type":"string"},"minzoom":{"type":"number","minimum":0,"maximum":24},"maxzoom":{"type":"number","minimum":0,"maximum":24},"filter":{"type":"filter"},"layout":{"type":"layout"},"paint":{"type":"paint"}},"layout":["layout_clip","layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_raster-particle","layout_hillshade","layout_background","layout_sky","layout_model"],"layout_background":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_sky":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_model":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"},"model-id":{"type":"string","default":"","property-type":"data-driven","expression":{"parameters":["zoom","feature"]}}},"layout_clip":{"clip-layer-types":{"type":"array","value":"enum","values":{"model":1,"symbol":1},"default":[],"expression":{},"property-type":"data-constant","experimental":true},"clip-layer-scope":{"type":"array","value":"string","default":[],"expression":{},"property-type":"data-constant","experimental":true}},"layout_fill":{"fill-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"},"fill-elevation-reference":{"type":"enum","values":{"none":1,"hd-road-base":1,"hd-road-markup":1},"default":"none","experimental":true,"private":true,"expression":{},"property-type":"data-constant"}},"layout_circle":{"circle-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_heatmap":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_fill-extrusion":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"},"fill-extrusion-edge-radius":{"type":"number","experimental":true,"default":0,"minimum":0,"maximum":1,"expression":{},"property-type":"constant"}},"layout_line":{"line-cap":{"type":"enum","values":{"butt":1,"round":1,"square":1},"default":"butt","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-join":{"type":"enum","values":{"bevel":1,"round":1,"miter":1,"none":1},"default":"miter","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{"type":"number","default":2,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-round-limit":{"type":"number","default":1.05,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-z-offset":{"type":"number","experimental":true,"default":0,"expression":{"parameters":["zoom","feature","line-progress"]},"property-type":"data-driven"},"line-elevation-reference":{"type":"enum","values":{"none":1,"sea":1,"ground":1,"hd-road-markup":1},"default":"none","experimental":true,"expression":{},"property-type":"data-constant"},"line-cross-slope":{"type":"number","experimental":true,"expression":{},"property-type":"constant"},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_symbol":{"symbol-placement":{"type":"enum","values":{"point":1,"line":1,"line-center":1},"default":"point","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"symbol-spacing":{"type":"number","default":250,"minimum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{"type":"enum","values":{"auto":1,"viewport-y":1,"source":1},"default":"auto","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"symbol-z-elevate":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"symbol-elevation-reference":{"type":"enum","values":{"sea":1,"ground":1,"hd-road-markup":1},"default":"ground","experimental":true,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-optional":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{"type":"enum","values":{"map":1,"viewport":1,"auto":1},"default":"auto","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-size":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-size-scale-range":{"type":"array","value":"number","length":2,"default":[0.8,2],"minimum":0.1,"maximum":10,"experimental":true,"private":true,"expression":{},"property-type":"data-constant"},"icon-text-fit":{"type":"enum","values":{"none":1,"width":1,"height":1,"both":1},"default":"none","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit-padding":{"type":"array","value":"number","length":4,"default":[0,0,0,0],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-image":{"type":"resolvedImage","tokens":true,"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{"type":"number","default":0,"period":360,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{"type":"number","default":2,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-keep-upright":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-offset":{"type":"array","value":"number","length":2,"default":[0,0],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{"type":"enum","values":{"center":1,"left":1,"right":1,"top":1,"bottom":1,"top-left":1,"top-right":1,"bottom-left":1,"bottom-right":1},"default":"center","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1,"auto":1},"default":"auto","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1,"auto":1},"default":"auto","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{"type":"enum","values":{"map":1,"viewport":1,"auto":1},"default":"auto","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-field":{"type":"formatted","default":"","tokens":true,"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-font":{"type":"array","value":"string","default":["Open Sans Regular","Arial Unicode MS Regular"],"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size":{"type":"number","default":16,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size-scale-range":{"type":"array","value":"number","length":2,"default":[0.8,2],"minimum":0.1,"maximum":10,"experimental":true,"private":true,"expression":{},"property-type":"data-constant"},"text-max-width":{"type":"number","default":10,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{"type":"number","default":1.2,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-letter-spacing":{"type":"number","default":0,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-justify":{"type":"enum","values":{"auto":1,"left":1,"center":1,"right":1},"default":"center","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{"type":"number","default":0,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["zoom","feature"]}},"text-variable-anchor":{"type":"array","value":"enum","values":{"center":1,"left":1,"right":1,"top":1,"bottom":1,"top-left":1,"top-right":1,"bottom-left":1,"bottom-right":1},"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-anchor":{"type":"enum","values":{"center":1,"left":1,"right":1,"top":1,"bottom":1,"top-left":1,"top-right":1,"bottom-left":1,"bottom-right":1},"default":"center","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{"type":"number","default":45,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-writing-mode":{"type":"array","value":"enum","values":{"horizontal":1,"vertical":1},"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-rotate":{"type":"number","default":0,"period":360,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-padding":{"type":"number","default":2,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-keep-upright":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-transform":{"type":"enum","values":{"none":1,"uppercase":1,"lowercase":1},"default":"none","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-offset":{"type":"array","value":"number","length":2,"default":[0,0],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-optional":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_raster":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_raster-particle":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_hillshade":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"filter":{"type":"array","value":"*"},"filter_symbol":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature","pitch","distance-from-center"]}},"filter_fill":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_hillshade":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_raster":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_raster-particle":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_clip":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_model":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_line":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_circle":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_fill-extrusion":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_heatmap":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_operator":{"type":"enum","values":{"==":1,"!=":1,">":1,">=":1,"<":1,"<=":1,"in":1,"!in":1,"all":1,"any":1,"none":1,"has":1,"!has":1}},"geometry_type":{"type":"enum","values":{"Point":1,"LineString":1,"Polygon":1}},"function":{"expression":{"type":"expression"},"stops":{"type":"array","value":"function_stop"},"base":{"type":"number","default":1,"minimum":0},"property":{"type":"string","default":"$zoom"},"type":{"type":"enum","values":{"identity":1,"exponential":1,"interval":1,"categorical":1},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":1,"lab":1,"hcl":1},"default":"rgb"},"default":{"type":"*","required":false}},"function_stop":{"type":"array","minimum":0,"maximum":24,"value":["number","color"],"length":2},"expression":{"type":"array","value":"*","minimum":1},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"high-color":{"type":"color","property-type":"data-constant","default":"#245cdf","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"space-color":{"type":"color","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"horizon-blend":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,0.2,7,0.1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"star-intensity":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],5,0.35,6,0],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vertical-range":{"type":"array","default":[0,0],"minimum":0,"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}}},"snow":{"density":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1,"experimental":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1,"experimental":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","experimental":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"opacity":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1,"experimental":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette":{"type":"number","property-type":"data-constant","default":0,"minimum":0,"maximum":1,"experimental":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"centerThinning":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1,"experimental":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"direction":{"type":"array","default":[0,90],"minimum":0,"maximum":360,"length":2,"value":"number","property-type":"data-constant","transition":true,"experimental":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}}},"rain":{"density":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1,"experimental":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1,"experimental":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","experimental":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"opacity":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1,"experimental":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette":{"type":"number","property-type":"data-constant","default":0,"minimum":0,"maximum":1,"experimental":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"centerThinning":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1,"experimental":true,"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","property-type":"data-constant","transition":true,"experimental":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}}},"camera":{"camera-projection":{"type":"enum","values":{"perspective":1,"orthographic":1},"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"default":"perspective","property-type":"data-constant"}},"colorTheme":{"data":{"type":"string","property-type":"data-constant","expression":{}}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"property-type":"data-constant","expression":{"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":1,"equalEarth":1,"equirectangular":1,"lambertConformalConic":1,"mercator":1,"naturalEarth":1,"winkelTripel":1,"globe":1},"default":"mercator","required":true},"center":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-180,-90],"maximum":[180,90]},"parallels":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-90,-90],"maximum":[90,90]}},"terrain":{"source":{"type":"string","required":true},"exaggeration":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_raster-particle","paint_hillshade","paint_background","paint_sky","paint_model"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"fill-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"fill-z-offset":{"type":"number","default":0,"minimum":0,"transition":true,"experimental":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-height-alignment":{"type":"enum","experimental":true,"values":{"terrain":1,"flat":1},"default":"flat","property-type":"data-constant"},"fill-extrusion-base-alignment":{"type":"enum","experimental":true,"values":{"terrain":1,"flat":1},"default":"terrain","property-type":"data-constant"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-ambient-occlusion-intensity":{"property-type":"data-constant","type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-radius":{"property-type":"data-constant","type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-wall-radius":{"property-type":"data-constant","type":"number","experimental":true,"default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-radius":{"property-type":"data-constant","type":"number","experimental":true,"default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-attenuation":{"property-type":"data-constant","type":"number","experimental":true,"default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-flood-light-color":{"property-type":"data-constant","type":"color","experimental":true,"default":"#ffffff","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-intensity":{"property-type":"data-constant","type":"number","experimental":true,"default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-wall-radius":{"property-type":"data-driven","type":"number","experimental":true,"default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-radius":{"property-type":"data-driven","type":"number","experimental":true,"default":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-attenuation":{"property-type":"data-constant","type":"number","experimental":true,"default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-vertical-scale":{"property-type":"data-constant","type":"number","experimental":true,"default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-rounded-roof":{"property-type":"data-constant","type":"boolean","default":true,"experimental":true,"expression":{"parameters":["zoom"]}},"fill-extrusion-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{},"property-type":"data-constant"},"fill-extrusion-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"property-type":"data-driven"},"fill-extrusion-line-width":{"type":"number","default":0,"minimum":0,"transition":true,"experimental":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-extrusion-cast-shadows":{"type":"boolean","default":true,"property-type":"data-constant"}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-gradient":{"type":"color","expression":{"interpolated":true,"parameters":["line-progress"]},"property-type":"color-ramp"},"line-trim-offset":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1],"property-type":"constant"},"line-trim-fade-range":{"type":"array","value":"number","experimental":true,"length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1],"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"line-trim-color":{"type":"color","experimental":true,"default":"transparent","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"line-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"line-border-width":{"type":"number","private":true,"default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-border-color":{"type":"color","private":true,"default":"rgba(0, 0, 0, 0)","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-occlusion-opacity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true,"property-type":"data-constant"}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"heatmap-color":{"type":"color","default":["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"],"expression":{"interpolated":true,"parameters":["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-occlusion-opacity":{"type":"number","minimum":0,"maximum":1,"default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"property-type":"data-driven"},"text-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-image-cross-fade":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"transition":true},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-occlusion-opacity":{"type":"number","minimum":0,"maximum":1,"default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","transition":true,"overridable":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-color-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{},"property-type":"data-constant"},"icon-color-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{},"property-type":"data-constant"},"icon-color-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{},"property-type":"data-constant"},"icon-color-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{},"property-type":"data-constant"},"symbol-z-offset":{"type":"number","default":0,"minimum":0,"transition":true,"experimental":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-color":{"type":"color","expression":{"interpolated":true,"parameters":["raster-value"]},"property-type":"color-ramp"},"raster-color-mix":{"type":"array","default":[0.2126,0.7152,0.0722,0],"length":4,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-color-range":{"type":"array","length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-resampling":{"type":"enum","values":{"linear":1,"nearest":1},"default":"linear","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"raster-array-band":{"type":"string","required":false,"experimental":true,"property-type":"data-constant"},"raster-elevation":{"type":"number","default":0,"minimum":0,"transition":true,"experimental":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_raster-particle":{"raster-particle-array-band":{"type":"string","required":false,"property-type":"data-constant"},"raster-particle-count":{"type":"number","default":512,"minimum":1,"property-type":"data-constant"},"raster-particle-color":{"type":"color","expression":{"interpolated":true,"parameters":["raster-particle-speed"]},"property-type":"color-ramp"},"raster-particle-max-speed":{"type":"number","default":1,"minimum":1,"property-type":"data-constant"},"raster-particle-speed-factor":{"type":"number","default":0.2,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-particle-fade-opacity-factor":{"type":"number","default":0.98,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-particle-reset-rate-factor":{"type":"number","default":0.8,"minimum":0,"maximum":1,"property-type":"data-constant"},"raster-particle-elevation":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"hillshade-accent-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"hillshade-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"}},"paint_background":{"background-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":[]},"property-type":"data-constant"},"background-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":1,"atmosphere":1},"default":"atmosphere","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun-intensity":{"type":"number","default":10,"minimum":0,"maximum":100,"property-type":"data-constant"},"sky-gradient-center":{"type":"array","value":"number","default":[0,0],"length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient-radius":{"type":"number","default":90,"minimum":0,"maximum":180,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"expression":{"interpolated":true,"parameters":["sky-radial-progress"]},"property-type":"color-ramp"},"sky-atmosphere-halo-color":{"type":"color","default":"white","property-type":"data-constant"},"sky-atmosphere-color":{"type":"color","default":"white","property-type":"data-constant"},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_model":{"model-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"model-rotation":{"type":"array","value":"number","length":3,"default":[0,0,0],"period":360,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-scale":{"type":"array","value":"number","length":3,"default":[1,1,1],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-translation":{"type":"array","value":"number","length":3,"default":[0,0,0],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-color":{"type":"color","default":"#ffffff","property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":true},"model-color-mix-intensity":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-type":{"type":"enum","values":{"common-3d":1,"location-indicator":1},"default":"common-3d","property-type":"data-constant"},"model-cast-shadows":{"type":"boolean","default":true,"property-type":"data-constant"},"model-receive-shadows":{"type":"boolean","default":true,"property-type":"data-constant"},"model-ambient-occlusion-intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant","transition":true},"model-emissive-strength":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-roughness":{"type":"number","default":1,"minimum":0,"maximum":1,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state"]},"transition":true},"model-height-based-emissive-strength-multiplier":{"type":"array","default":[1,1,1,1,0],"length":5,"value":"number","property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{},"property-type":"data-constant"},"model-front-cutoff":{"type":"array","private":true,"value":"number","property-type":"data-constant","expression":{"interpolated":true,"parameters":["zoom"]},"length":3,"default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1]}},"transition":{"duration":{"type":"number","default":300,"minimum":0},"delay":{"type":"number","default":0,"minimum":0}},"property-type":{"data-driven":{"type":"property-type"},"color-ramp":{"type":"property-type"},"data-constant":{"type":"property-type"},"constant":{"type":"property-type"}},"promoteId":{"*":{"type":"string"}}}');function Xa(t){return t instanceof Number||t instanceof String||t instanceof Boolean?t.valueOf():t}function Ya(t){if(Array.isArray(t))return t.map(Ya);if(t instanceof Object&&!(t instanceof Number||t instanceof String||t instanceof Boolean)){const e={};for(const r in t)e[r]=Ya(t[r]);return e}return Xa(t)}function Za(t){if(!0===t||!1===t)return !0;if(!Array.isArray(t)||0===t.length)return !1;switch(t[0]){case"has":return t.length>=2&&"$id"!==t[1]&&"$type"!==t[1];case"in":return t.length>=3&&("string"!=typeof t[1]||Array.isArray(t[2]));case"!in":case"!has":case"none":return !1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==t.length||Array.isArray(t[1])||Array.isArray(t[2]);case"any":case"all":for(const e of t.slice(1))if(!Za(e)&&"boolean"!=typeof e)return !1;return !0;default:return !0}}function Wa(t,e="",r=null,n="fill"){if(null==t)return {filter:()=>!0,needGeometry:!1,needFeature:!1};Za(t)||(t=rs(t));const i=t;let a=!0;try{a=function(t){if(!Ja(t))return t;let e=Ya(t);return Ka(e),e=Ha(e),e}(i);}catch(t){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 s=null,o=null;if("background"!==n&&"sky"!==n&&"slot"!==n){o=Ga[`filter_${n}`];const t=Wi(a,o,e,r);if("error"===t.result)throw new Error(t.value.map((t=>`${t.key}: ${t.message}`)).join(", "));s=(e,r,n)=>t.value.evaluate(e,r,{},n);}let l=null,u=null;if(a!==i){const t=Wi(i,o,e,r);if("error"===t.result)throw new Error(t.value.map((t=>`${t.key}: ${t.message}`)).join(", "));l=(e,r,n,i,a)=>t.value.evaluate(e,r,{},n,void 0,void 0,i,a),u=!Tn(t.value.expression);}return {filter:s,dynamicFilter:l||void 0,needGeometry:es(a),needFeature:!!u}}function Ha(t){if(!Array.isArray(t))return t;const e=function(t){if(Qa.has(t[0]))for(let e=1;e<t.length;e++)if(Ja(t[e]))return !0;return t}(t);return !0===e?e:e.map((t=>Ha(t)))}function Ka(t){let e=!1;const r=[];if("case"===t[0]){for(let n=1;n<t.length-1;n+=2)e=e||Ja(t[n]),r.push(t[n+1]);r.push(t[t.length-1]);}else if("match"===t[0]){e=e||Ja(t[1]);for(let e=2;e<t.length-1;e+=2)r.push(t[e+1]);r.push(t[t.length-1]);}else if("step"===t[0]){e=e||Ja(t[1]);for(let e=1;e<t.length-1;e+=2)r.push(t[e+1]);}e&&(t.length=0,t.push("any",...r));for(let e=1;e<t.length;e++)Ka(t[e]);}function Ja(t){if(!Array.isArray(t))return !1;if("pitch"===(e=t[0])||"distance-from-center"===e)return !0;var e;for(let e=1;e<t.length;e++)if(Ja(t[e]))return !0;return !1}const Qa=new Set(["in","==","!=",">",">=","<","<=","to-boolean"]);function ts(t,e){return t<e?-1:t>e?1:0}function es(t){if(!Array.isArray(t))return !1;if("within"===t[0]||"distance"===t[0])return !0;for(let e=1;e<t.length;e++)if(es(t[e]))return !0;return !1}function rs(t){if(!t)return !0;const e=t[0];return t.length<=1?"any"!==e:"=="===e?ns(t[1],t[2],"=="):"!="===e?ss(ns(t[1],t[2],"==")):"<"===e||">"===e||"<="===e||">="===e?ns(t[1],t[2],e):"any"===e?(r=t.slice(1),["any"].concat(r.map(rs))):"all"===e?["all"].concat(t.slice(1).map(rs)):"none"===e?["all"].concat(t.slice(1).map(rs).map(ss)):"in"===e?is(t[1],t.slice(2)):"!in"===e?ss(is(t[1],t.slice(2))):"has"===e?as(t[1]):"!has"!==e||ss(as(t[1]));var r;}function ns(t,e,r){switch(t){case"$type":return [`filter-type-${r}`,e];case"$id":return [`filter-id-${r}`,e];default:return [`filter-${r}`,t,e]}}function is(t,e){if(0===e.length)return !1;switch(t){case"$type":return ["filter-type-in",["literal",e]];case"$id":return ["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((t=>typeof t!=typeof e[0]))?["filter-in-large",t,["literal",e.sort(ts)]]:["filter-in-small",t,["literal",e]]}}function as(t){switch(t){case"$type":return !0;case"$id":return ["filter-has-id"];default:return ["filter-has",t]}}function ss(t){return ["!",t]}const os="";function ls(t,e){return e?`${t}${os}${e}`:t}const us="-transition",cs=new Set(["fill","line","background","hillshade","raster"]);class hs extends _e{constructor(t,e,r,n,i){if(super(),this.id=t.id,this.fqid=ls(this.id,r),this.type=t.type,this.scope=r,this.lut=n,this.options=i,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,this.configDependencies=new Set,"custom"!==t.type){if(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,t.type&&"background"!==t.type&&"sky"!==t.type&&"slot"!==t.type){this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter;const e=Wi(this.filter,Ga[`filter_${t.type}`]);"error"!==e.result&&(this.configDependencies=new Set([...this.configDependencies,...e.value.configDependencies]));}if(t.slot&&(this.slot=t.slot),e.layout&&(this._unevaluatedLayout=new Fa(e.layout,this.scope,i),this.configDependencies=new Set([...this.configDependencies,...this._unevaluatedLayout.configDependencies])),e.paint){this._transitionablePaint=new Ra(e.paint,this.scope,i);for(const e in t.paint)this.setPaintProperty(e,t.paint[e]);for(const e in t.layout)this.setLayoutProperty(e,t.layout[e]);this.configDependencies=new Set([...this.configDependencies,...this._transitionablePaint.configDependencies]),this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Ua(e.paint);}}}onAdd(t){}onRemove(t){}isDraped(t){return !this.is3D()&&cs.has(this.type)}getLayoutProperty(t){return "visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,e){if("custom"===this.type&&"visibility"===t)return void(this.visibility=e);const r=this._unevaluatedLayout;r._properties.properties[t]&&(r.setValue(t,e),this.configDependencies=new Set([...this.configDependencies,...r.configDependencies]),"visibility"===t&&this.possiblyEvaluateVisibility());}possiblyEvaluateVisibility(){this._unevaluatedLayout._values.visibility&&(this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0}));}getPaintProperty(t){return lt(t,us)?this._transitionablePaint.getTransition(t.slice(0,-11)):this._transitionablePaint.getValue(t)}setPaintProperty(t,e){const r=this._transitionablePaint,n=r._properties.properties;if(lt(t,us)){const i=t.slice(0,-11);return n[i]&&r.setTransition(i,e||void 0),!1}if(!n[t])return !1;const i=r._values[t],a=i.value.isDataDriven(),s=i.value;r.setValue(t,e),this.configDependencies=new Set([...this.configDependencies,...r.configDependencies]),this._handleSpecialPaintPropertyUpdate(t);const o=r._values[t].value,l=o.isDataDriven(),u=lt(t,"pattern")||"line-dasharray"===t;return l||a||u||this._handleOverridablePaintPropertyUpdate(t,s,o)}_handleSpecialPaintPropertyUpdate(t){}getProgramIds(){return null}getDefaultProgramParams(t,e,r){return null}_handleOverridablePaintPropertyUpdate(t,e,r){return !1}isHidden(t){return !!(this.minzoom&&t<this.minzoom)||!!(this.maxzoom&&t>=this.maxzoom)||"none"===this.visibility}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint);}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,e){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,e)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,e);}serialize(){return ct({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()},((t,e)=>!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)))}is3D(){return !1}isSky(){return !1}isTileClipped(){return !1}hasOffscreenPass(){return !1}hasShadowPass(){return !1}canCastShadows(){return !1}hasLightBeamPass(){return !1}cutoffRange(){return 0}tileCoverLift(){return 0}resize(){}isStateDependent(){for(const t in this.paint._values){const e=this.paint.get(t);if(e instanceof Oa&&Ri(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return !0}return !1}compileFilter(t){this._filterCompiled||(this._featureFilter=Wa(this.filter,this.scope,t),this._filterCompiled=!0);}invalidateCompiledFilter(){this._filterCompiled=!1;}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}getLayerRenderingStats(){return this._stats}resetLayerRenderingStats(t){this._stats&&("shadow"===t.renderPass?this._stats.numRenderedVerticesInShadowPass=0:this._stats.numRenderedVerticesInTransparentPass=0);}queryRadius(t){}queryIntersectsFeature(t,e,r,n,i,a,s,o,l){}queryIntersectsMatchingFeature(t,e,r,n){}}const ps={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class fs{constructor(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8;}}class ds{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0);}static serialize(t,e){return t._trim(),e&&(t.isTransferred=!0,e.add(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e}_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(t){this.reserve(t),this.length=t;}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const e=this.uint8;this._refreshViews(),e&&this.uint8.set(e);}}_refreshViews(){throw new Error("StructArray#_refreshViews() must be implemented by each concrete StructArray layout")}emplace(...t){throw new Error("StructArray#emplace() must be implemented by each concrete StructArray layout")}emplaceBack(...t){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 ms(t,e=1){let r=0,n=0;return {members:t.map((t=>{const i=ps[t.type].BYTES_PER_ELEMENT,a=r=ys(r,Math.max(e,i)),s=t.components||1;return n=Math.max(n,i),r+=i*s,{name:t.name,type:t.type,components:s,offset:a}})),size:ys(r,Math.max(n,e)),alignment:e}}function ys(t,e){return Math.ceil(t/e)*e}class gs extends ds{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.int16[n+0]=e,this.int16[n+1]=r,t}}gs.prototype.bytesPerElement=4,sa(gs,"StructArrayLayout2i4");class xs extends ds{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.int16[i+0]=e,this.int16[i+1]=r,this.int16[i+2]=n,t}}xs.prototype.bytesPerElement=6,sa(xs,"StructArrayLayout3i6");class vs extends ds{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const a=4*t;return this.int16[a+0]=e,this.int16[a+1]=r,this.int16[a+2]=n,this.int16[a+3]=i,t}}vs.prototype.bytesPerElement=8,sa(vs,"StructArrayLayout4i8");class bs extends ds{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i)}emplace(t,e,r,n,i,a){const s=5*t;return this.int16[s+0]=e,this.int16[s+1]=r,this.int16[s+2]=n,this.int16[s+3]=i,this.int16[s+4]=a,t}}bs.prototype.bytesPerElement=10,sa(bs,"StructArrayLayout5i10");class ws extends ds{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,a,s){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,r,n,i,a,s)}emplace(t,e,r,n,i,a,s,o){const l=6*t,u=12*t,c=3*t;return this.int16[l+0]=e,this.int16[l+1]=r,this.uint8[u+4]=n,this.uint8[u+5]=i,this.uint8[u+6]=a,this.uint8[u+7]=s,this.float32[c+2]=o,t}}ws.prototype.bytesPerElement=12,sa(ws,"StructArrayLayout2i4ub1f12");class _s extends ds{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const a=4*t;return this.float32[a+0]=e,this.float32[a+1]=r,this.float32[a+2]=n,this.float32[a+3]=i,t}}_s.prototype.bytesPerElement=16,sa(_s,"StructArrayLayout4f16");class Ms extends ds{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.float32[i+0]=e,this.float32[i+1]=r,this.float32[i+2]=n,t}}Ms.prototype.bytesPerElement=12,sa(Ms,"StructArrayLayout3f12");class As extends ds{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i)}emplace(t,e,r,n,i,a){const s=6*t,o=3*t;return this.uint16[s+0]=e,this.uint16[s+1]=r,this.uint16[s+2]=n,this.uint16[s+3]=i,this.float32[o+2]=a,t}}As.prototype.bytesPerElement=12,sa(As,"StructArrayLayout4ui1f12");class Ss extends ds{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const a=4*t;return this.uint16[a+0]=e,this.uint16[a+1]=r,this.uint16[a+2]=n,this.uint16[a+3]=i,t}}Ss.prototype.bytesPerElement=8,sa(Ss,"StructArrayLayout4ui8");class Is extends ds{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,a){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,r,n,i,a)}emplace(t,e,r,n,i,a,s){const o=6*t;return this.int16[o+0]=e,this.int16[o+1]=r,this.int16[o+2]=n,this.int16[o+3]=i,this.int16[o+4]=a,this.int16[o+5]=s,t}}Is.prototype.bytesPerElement=12,sa(Is,"StructArrayLayout6i12");class zs extends ds{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,a,s,o,l,u,c,h){const p=this.length;return this.resize(p+1),this.emplace(p,t,e,r,n,i,a,s,o,l,u,c,h)}emplace(t,e,r,n,i,a,s,o,l,u,c,h,p){const f=12*t;return this.int16[f+0]=e,this.int16[f+1]=r,this.int16[f+2]=n,this.int16[f+3]=i,this.uint16[f+4]=a,this.uint16[f+5]=s,this.uint16[f+6]=o,this.uint16[f+7]=l,this.int16[f+8]=u,this.int16[f+9]=c,this.int16[f+10]=h,this.int16[f+11]=p,t}}zs.prototype.bytesPerElement=24,sa(zs,"StructArrayLayout4i4ui4i24");class Ps extends ds{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,a){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,r,n,i,a)}emplace(t,e,r,n,i,a,s){const o=10*t,l=5*t;return this.int16[o+0]=e,this.int16[o+1]=r,this.int16[o+2]=n,this.float32[l+2]=i,this.float32[l+3]=a,this.float32[l+4]=s,t}}Ps.prototype.bytesPerElement=20,sa(Ps,"StructArrayLayout3i3f20");class ks extends ds{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint32[1*t+0]=e,t}}ks.prototype.bytesPerElement=4,sa(ks,"StructArrayLayout1ul4");class Ts extends ds{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.uint16[n+0]=e,this.uint16[n+1]=r,t}}Ts.prototype.bytesPerElement=4,sa(Ts,"StructArrayLayout2ui4");class Es extends ds{_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(t,e,r,n,i,a,s,o,l,u,c,h,p){const f=this.length;return this.resize(f+1),this.emplace(f,t,e,r,n,i,a,s,o,l,u,c,h,p)}emplace(t,e,r,n,i,a,s,o,l,u,c,h,p,f){const d=20*t,m=10*t;return this.int16[d+0]=e,this.int16[d+1]=r,this.int16[d+2]=n,this.int16[d+3]=i,this.int16[d+4]=a,this.float32[m+3]=s,this.float32[m+4]=o,this.float32[m+5]=l,this.float32[m+6]=u,this.int16[d+14]=c,this.uint32[m+8]=h,this.uint16[d+18]=p,this.uint16[d+19]=f,t}}Es.prototype.bytesPerElement=40,sa(Es,"StructArrayLayout5i4f1i1ul2ui40");class Bs extends ds{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,a,s){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,r,n,i,a,s)}emplace(t,e,r,n,i,a,s,o){const l=8*t;return this.int16[l+0]=e,this.int16[l+1]=r,this.int16[l+2]=n,this.int16[l+4]=i,this.int16[l+5]=a,this.int16[l+6]=s,this.int16[l+7]=o,t}}Bs.prototype.bytesPerElement=16,sa(Bs,"StructArrayLayout3i2i2i16");class Vs extends ds{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i)}emplace(t,e,r,n,i,a){const s=4*t,o=8*t;return this.float32[s+0]=e,this.float32[s+1]=r,this.float32[s+2]=n,this.int16[o+6]=i,this.int16[o+7]=a,t}}Vs.prototype.bytesPerElement=16,sa(Vs,"StructArrayLayout2f1f2i16");class Cs extends ds{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,a){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,r,n,i,a)}emplace(t,e,r,n,i,a,s){const o=20*t,l=5*t;return this.uint8[o+0]=e,this.uint8[o+1]=r,this.float32[l+1]=n,this.float32[l+2]=i,this.float32[l+3]=a,this.float32[l+4]=s,t}}Cs.prototype.bytesPerElement=20,sa(Cs,"StructArrayLayout2ub4f20");class Rs extends ds{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.uint16[i+0]=e,this.uint16[i+1]=r,this.uint16[i+2]=n,t}}Rs.prototype.bytesPerElement=6,sa(Rs,"StructArrayLayout3ui6");class Ds extends ds{_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(t,e,r,n,i,a,s,o,l,u,c,h,p,f,d,m,y,g,x,v,b){const w=this.length;return this.resize(w+1),this.emplace(w,t,e,r,n,i,a,s,o,l,u,c,h,p,f,d,m,y,g,x,v,b)}emplace(t,e,r,n,i,a,s,o,l,u,c,h,p,f,d,m,y,g,x,v,b,w){const _=30*t,M=15*t,A=60*t;return this.int16[_+0]=e,this.int16[_+1]=r,this.int16[_+2]=n,this.float32[M+2]=i,this.float32[M+3]=a,this.uint16[_+8]=s,this.uint16[_+9]=o,this.uint32[M+5]=l,this.uint32[M+6]=u,this.uint32[M+7]=c,this.uint16[_+16]=h,this.uint16[_+17]=p,this.uint16[_+18]=f,this.float32[M+10]=d,this.float32[M+11]=m,this.uint8[A+48]=y,this.uint8[A+49]=g,this.uint8[A+50]=x,this.uint32[M+13]=v,this.int16[_+28]=b,this.uint8[A+58]=w,t}}Ds.prototype.bytesPerElement=60,sa(Ds,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class Ls extends ds{_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(t,e,r,n,i,a,s,o,l,u,c,h,p,f,d,m,y,g,x,v,b,w,_,M,A,S,I,z,P,k,T,E){const B=this.length;return this.resize(B+1),this.emplace(B,t,e,r,n,i,a,s,o,l,u,c,h,p,f,d,m,y,g,x,v,b,w,_,M,A,S,I,z,P,k,T,E)}emplace(t,e,r,n,i,a,s,o,l,u,c,h,p,f,d,m,y,g,x,v,b,w,_,M,A,S,I,z,P,k,T,E,B){const V=20*t,C=40*t,R=80*t;return this.float32[V+0]=e,this.float32[V+1]=r,this.int16[C+4]=n,this.int16[C+5]=i,this.int16[C+6]=a,this.int16[C+7]=s,this.int16[C+8]=o,this.int16[C+9]=l,this.int16[C+10]=u,this.int16[C+11]=c,this.int16[C+12]=h,this.uint16[C+13]=p,this.uint16[C+14]=f,this.uint16[C+15]=d,this.uint16[C+16]=m,this.uint16[C+17]=y,this.uint16[C+18]=g,this.uint16[C+19]=x,this.uint16[C+20]=v,this.uint16[C+21]=b,this.uint16[C+22]=w,this.uint16[C+23]=_,this.uint16[C+24]=M,this.uint16[C+25]=A,this.uint16[C+26]=S,this.uint16[C+27]=I,this.uint32[V+14]=z,this.float32[V+15]=P,this.float32[V+16]=k,this.float32[V+17]=T,this.float32[V+18]=E,this.uint8[R+76]=B,t}}Ls.prototype.bytesPerElement=80,sa(Ls,"StructArrayLayout2f9i15ui1ul4f1ub80");class Fs extends ds{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.float32[1*t+0]=e,t}}Fs.prototype.bytesPerElement=4,sa(Fs,"StructArrayLayout1f4");class Os extends ds{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i)}emplace(t,e,r,n,i,a){const s=5*t;return this.float32[s+0]=e,this.float32[s+1]=r,this.float32[s+2]=n,this.float32[s+3]=i,this.float32[s+4]=a,t}}Os.prototype.bytesPerElement=20,sa(Os,"StructArrayLayout5f20");class Us extends ds{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,a,s){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,r,n,i,a,s)}emplace(t,e,r,n,i,a,s,o){const l=7*t;return this.float32[l+0]=e,this.float32[l+1]=r,this.float32[l+2]=n,this.float32[l+3]=i,this.float32[l+4]=a,this.float32[l+5]=s,this.float32[l+6]=o,t}}Us.prototype.bytesPerElement=28,sa(Us,"StructArrayLayout7f28");class js extends ds{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,a,s,o,l,u,c){const h=this.length;return this.resize(h+1),this.emplace(h,t,e,r,n,i,a,s,o,l,u,c)}emplace(t,e,r,n,i,a,s,o,l,u,c,h){const p=11*t;return this.float32[p+0]=e,this.float32[p+1]=r,this.float32[p+2]=n,this.float32[p+3]=i,this.float32[p+4]=a,this.float32[p+5]=s,this.float32[p+6]=o,this.float32[p+7]=l,this.float32[p+8]=u,this.float32[p+9]=c,this.float32[p+10]=h,t}}js.prototype.bytesPerElement=44,sa(js,"StructArrayLayout11f44");class Ns extends ds{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,a,s,o,l){const u=this.length;return this.resize(u+1),this.emplace(u,t,e,r,n,i,a,s,o,l)}emplace(t,e,r,n,i,a,s,o,l,u){const c=9*t;return this.float32[c+0]=e,this.float32[c+1]=r,this.float32[c+2]=n,this.float32[c+3]=i,this.float32[c+4]=a,this.float32[c+5]=s,this.float32[c+6]=o,this.float32[c+7]=l,this.float32[c+8]=u,t}}Ns.prototype.bytesPerElement=36,sa(Ns,"StructArrayLayout9f36");class qs extends ds{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const a=6*t;return this.uint32[3*t+0]=e,this.uint16[a+2]=r,this.uint16[a+3]=n,this.uint16[a+4]=i,t}}qs.prototype.bytesPerElement=12,sa(qs,"StructArrayLayout1ul3ui12");class $s extends ds{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint16[1*t+0]=e,t}}$s.prototype.bytesPerElement=2,sa($s,"StructArrayLayout1ui2");class Gs extends ds{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.float32[n+0]=e,this.float32[n+1]=r,t}}Gs.prototype.bytesPerElement=8,sa(Gs,"StructArrayLayout2f8");class Xs extends ds{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,a,s,o,l,u,c,h,p,f,d,m){const y=this.length;return this.resize(y+1),this.emplace(y,t,e,r,n,i,a,s,o,l,u,c,h,p,f,d,m)}emplace(t,e,r,n,i,a,s,o,l,u,c,h,p,f,d,m,y){const g=16*t;return this.float32[g+0]=e,this.float32[g+1]=r,this.float32[g+2]=n,this.float32[g+3]=i,this.float32[g+4]=a,this.float32[g+5]=s,this.float32[g+6]=o,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]=f,this.float32[g+13]=d,this.float32[g+14]=m,this.float32[g+15]=y,t}}Xs.prototype.bytesPerElement=64,sa(Xs,"StructArrayLayout16f64");class Ys extends ds{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,a,s){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,r,n,i,a,s)}emplace(t,e,r,n,i,a,s,o){const l=10*t,u=5*t;return this.uint16[l+0]=e,this.uint16[l+1]=r,this.uint16[l+2]=n,this.uint16[l+3]=i,this.float32[u+2]=a,this.float32[u+3]=s,this.float32[u+4]=o,t}}Ys.prototype.bytesPerElement=20,sa(Ys,"StructArrayLayout4ui3f20");class Zs extends ds{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.int16[1*t+0]=e,t}}Zs.prototype.bytesPerElement=2,sa(Zs,"StructArrayLayout1i2");class Ws extends ds{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint8[1*t+0]=e,t}}Ws.prototype.bytesPerElement=1,sa(Ws,"StructArrayLayout1ub1");class Hs extends fs{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]}}Hs.prototype.size=40;class Ks extends Es{get(t){return new Hs(this,t)}}sa(Ks,"CollisionBoxArray");class Js extends fs{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(t){this._structArray.uint8[this._pos1+49]=t;}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(t){this._structArray.uint8[this._pos1+50]=t;}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(t){this._structArray.uint32[this._pos4+13]=t;}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(t){this._structArray.uint8[this._pos1+58]=t;}}Js.prototype.size=60;class Qs extends Ds{get(t){return new Js(this,t)}}sa(Qs,"PlacedSymbolArray");class to extends fs{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(t){this._structArray.uint32[this._pos4+14]=t;}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(t){this._structArray.float32[this._pos4+18]=t;}get hasIconTextFit(){return this._structArray.uint8[this._pos1+76]}}to.prototype.size=80;class eo extends Ls{get(t){return new to(this,t)}}sa(eo,"SymbolInstanceArray");class ro extends Fs{getoffsetX(t){return this.float32[1*t+0]}}sa(ro,"GlyphOffsetArray");class no extends gs{getx(t){return this.int16[2*t+0]}gety(t){return this.int16[2*t+1]}}sa(no,"SymbolLineVertexArray");class io extends fs{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]}}io.prototype.size=12;class ao extends qs{get(t){return new io(this,t)}}sa(ao,"FeatureIndexArray");class so extends Ts{geta_centroid_pos0(t){return this.uint16[2*t+0]}geta_centroid_pos1(t){return this.uint16[2*t+1]}}sa(so,"FillExtrusionCentroidArray");class oo extends fs{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]}}oo.prototype.size=6;class lo extends xs{get(t){return new oo(this,t)}}sa(lo,"FillExtrusionWallArray");const uo=ms([{name:"a_pos",components:2,type:"Int16"}],4),co=ms([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class ho{constructor(t=[]){this.segments=t;}_prepareSegment(t,e,r,n){let i=this.segments[this.segments.length-1];return t>ho.MAX_VERTEX_ARRAY_LENGTH&&ft(`Max vertices per segment is ${ho.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}`),(!i||i.vertexLength+t>ho.MAX_VERTEX_ARRAY_LENGTH||i.sortKey!==n)&&(i={vertexOffset:e,primitiveOffset:r,vertexLength:0,primitiveLength:0},void 0!==n&&(i.sortKey=n),this.segments.push(i)),i}prepareSegment(t,e,r,n){return this._prepareSegment(t,e.length,r.length,n)}get(){return this.segments}destroy(){for(const t of this.segments)for(const e in t.vaos)t.vaos[e].destroy();}static simpleSegment(t,e,r,n){return new ho([{vertexOffset:t,primitiveOffset:e,vertexLength:r,primitiveLength:n,vaos:{},sortKey:0}])}}function po(t,e){return 256*(t=Q(Math.floor(t),0,255))+Q(Math.floor(e),0,255)}ho.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,sa(ho,"SegmentVector");const fo=ms([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),mo=ms([{name:"a_dash",components:4,type:"Uint16"}]);class yo{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1;}add(t,e,r,n){this.ids.push(go(t)),this.positions.push(e,r,n);}eachPosition(t,e){const r=go(t);let n=0,i=this.ids.length-1;for(;n<i;){const t=n+i>>1;this.ids[t]>=r?i=t:n=t+1;}for(;this.ids[n]===r;)e(this.positions[3*n],this.positions[3*n+1],this.positions[3*n+2]),n++;}static serialize(t,e){const r=new Float64Array(t.ids),n=new Uint32Array(t.positions);return xo(r,n,0,r.length-1),e&&(e.add(r.buffer),e.add(n.buffer)),{ids:r,positions:n}}static deserialize(t){const e=new yo;let r;e.ids=t.ids,e.positions=t.positions;for(const t of e.ids)t!==r&&e.uniqueIds.push(t),r=t;return e.indexed=!0,e}}function go(t){const e=+t;return !isNaN(e)&&Number.MIN_SAFE_INTEGER<=e&&e<=Number.MAX_SAFE_INTEGER?e:ge(String(t))}function xo(t,e,r,n){for(;r<n;){const i=t[r+n>>1];let a=r-1,s=n+1;for(;;){do{a++;}while(t[a]<i);do{s--;}while(t[s]>i);if(a>=s)break;vo(t,a,s),vo(e,3*a,3*s),vo(e,3*a+1,3*s+1),vo(e,3*a+2,3*s+2);}s-r<n-s?(xo(t,e,r,s),r=s+1):(xo(t,e,s+1,n),n=s);}}function vo(t,e,r){const n=t[e];t[e]=t[r],t[r]=n;}sa(yo,"FeaturePositionMap");class bo{constructor(t){this.gl=t.gl,this.initialized=!1;}fetchUniformLocation(t,e){return this.location||this.initialized||(this.location=this.gl.getUniformLocation(t,e),this.initialized=!0),!!this.location}set(t,e,r){throw new Error("Uniform#set() must be implemented by each concrete Uniform")}}class wo extends bo{constructor(t){super(t),this.current=0;}set(t,e,r){this.fetchUniformLocation(t,e)&&this.current!==r&&(this.current=r,this.gl.uniform1i(this.location,r));}}class _o extends bo{constructor(t){super(t),this.current=0;}set(t,e,r){this.fetchUniformLocation(t,e)&&this.current!==r&&(this.current=r,this.gl.uniform1f(this.location,r));}}class Mo extends bo{constructor(t){super(t),this.current=[0,0];}set(t,e,r){this.fetchUniformLocation(t,e)&&(r[0]===this.current[0]&&r[1]===this.current[1]||(this.current=r,this.gl.uniform2f(this.location,r[0],r[1])));}}class Ao extends bo{constructor(t){super(t),this.current=[0,0,0];}set(t,e,r){this.fetchUniformLocation(t,e)&&(r[0]===this.current[0]&&r[1]===this.current[1]&&r[2]===this.current[2]||(this.current=r,this.gl.uniform3f(this.location,r[0],r[1],r[2])));}}class So extends bo{constructor(t){super(t),this.current=[0,0,0,0];}set(t,e,r){this.fetchUniformLocation(t,e)&&(r[0]===this.current[0]&&r[1]===this.current[1]&&r[2]===this.current[2]&&r[3]===this.current[3]||(this.current=r,this.gl.uniform4f(this.location,r[0],r[1],r[2],r[3])));}}class Io extends bo{constructor(t){super(t),this.current=Ie.transparent.toRenderColor(null);}set(t,e,r){this.fetchUniformLocation(t,e)&&(r.r===this.current.r&&r.g===this.current.g&&r.b===this.current.b&&r.a===this.current.a||(this.current=r,this.gl.uniform4f(this.location,r.r,r.g,r.b,r.a)));}}const zo=new Float32Array(16);class Po extends bo{constructor(t){super(t),this.current=zo;}set(t,e,r){if(this.fetchUniformLocation(t,e)){if(r[12]!==this.current[12]||r[0]!==this.current[0])return this.current=r,void this.gl.uniformMatrix4fv(this.location,!1,r);for(let t=1;t<16;t++)if(r[t]!==this.current[t]){this.current=r,this.gl.uniformMatrix4fv(this.location,!1,r);break}}}}const ko=new Float32Array(9),To=new Float32Array(4);class Eo extends bo{constructor(t){super(t),this.current=To;}set(t,e,r){if(this.fetchUniformLocation(t,e))for(let t=0;t<4;t++)if(r[t]!==this.current[t]){this.current=r,this.gl.uniformMatrix2fv(this.location,!1,r);break}}}function Bo(t){return [po(255*t.r,255*t.g),po(255*t.b,255*t.a)]}class Vo{constructor(t,e,r,n){this.value=t,this.uniformNames=e.map((t=>`u_${t}`)),this.type=r,this.context=n;}setUniform(t,e,r,n,i){const a=n.constantOr(this.value);e.set(t,i,a instanceof Ie?a.toRenderColor(this.context.lut):a);}getBinding(t,e){return "color"===this.type?new Io(t):new _o(t)}}class Co{constructor(t,e){this.uniformNames=e.map((t=>`u_${t}`)),this.pattern=null,this.pixelRatio=1;}setConstantPatternPositions(t){this.pixelRatio=t.pixelRatio||1,this.pattern=t.tl.concat(t.br);}setUniform(t,e,r,n,i){const a="u_pattern"===i||"u_dash"===i?this.pattern:"u_pixel_ratio"===i?this.pixelRatio:null;a&&e.set(t,i,a);}getBinding(t,e){return "u_pattern"===e||"u_dash"===e?new So(t):new _o(t)}}class Ro{constructor(t,e,r,n){this.expression=t,this.type=r,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===r?2:1,offset:0}))),this.paintVertexArray=new n;}populatePaintArray(t,e,r,n,i,a,s){const o=this.paintVertexArray.length,l=this.expression.evaluate(new Ba(0,{brightness:a}),e,{},i,n,s);this.paintVertexArray.resize(t),this._setPaintValue(o,t,l,this.context);}updatePaintArray(t,e,r,n,i,a,s){const o=this.expression.evaluate({zoom:0,brightness:s},r,n,void 0,i);this._setPaintValue(t,e,o,this.context);}_setPaintValue(t,e,r,n){if("color"===this.type){const i=Bo(r.toRenderColor(n.lut));for(let r=t;r<e;r++)this.paintVertexArray.emplace(r,i[0],i[1]);}else {for(let n=t;n<e;n++)this.paintVertexArray.emplace(n,r);this.maxValue=Math.max(this.maxValue,Math.abs(r));}}upload(t){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent||!this.expression.isLightConstant));}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy();}}class Do{constructor(t,e,r,n,i,a){this.expression=t,this.uniformNames=e.map((t=>`u_${t}_t`)),this.type=r,this.useIntegerZoom=n,this.context=i,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===r?4:2,offset:0}))),this.paintVertexArray=new a;}populatePaintArray(t,e,r,n,i,a,s){const o=this.expression.evaluate(new Ba(this.context.zoom,{brightness:a}),e,{},i,n,s),l=this.expression.evaluate(new Ba(this.context.zoom+1,{brightness:a}),e,{},i,n,s),u=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(u,t,o,l,this.context);}updatePaintArray(t,e,r,n,i,a,s){const o=this.expression.evaluate({zoom:this.context.zoom,brightness:s},r,n,void 0,i),l=this.expression.evaluate({zoom:this.context.zoom+1,brightness:s},r,n,void 0,i);this._setPaintValue(t,e,o,l,this.context);}_setPaintValue(t,e,r,n,i){if("color"===this.type){const n=Bo(r.toRenderColor(i.lut)),a=Bo(r.toRenderColor(i.lut));for(let r=t;r<e;r++)this.paintVertexArray.emplace(r,n[0],n[1],a[0],a[1]);}else {for(let i=t;i<e;i++)this.paintVertexArray.emplace(i,r,n);this.maxValue=Math.max(this.maxValue,Math.abs(r),Math.abs(n));}}upload(t){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent||!this.expression.isLightConstant));}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy();}setUniform(t,e,r,n,i){const a=this.useIntegerZoom?Math.floor(r.zoom):r.zoom,s=Q(this.expression.interpolationFactor(a,this.context.zoom,this.context.zoom+1),0,1);e.set(t,i,s);}getBinding(t,e){return new _o(t)}}class Lo{constructor(t,e,r,n,i){this.expression=t,this.layerId=i,this.paintVertexAttributes=("array"===r?mo:fo).members;for(let t=0;t<e.length;++t);this.paintVertexArray=new n;}populatePaintArray(t,e,r,n){const i=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValues(i,t,e.patterns&&e.patterns[this.layerId],r);}updatePaintArray(t,e,r,n,i,a,s){this._setPaintValues(t,e,r.patterns&&r.patterns[this.layerId],a);}_setPaintValues(t,e,r,n){if(!n||!r)return;const i=n[r];if(!i)return;const{tl:a,br:s,pixelRatio:o}=i;for(let r=t;r<e;r++)this.paintVertexArray.emplace(r,a[0],a[1],s[0],s[1],o);}upload(t){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent||!this.expression.isLightConstant));}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy();}}class Fo{constructor(t,e,r=(()=>!0)){this.binders={},this._buffers=[],this.context=e;const n=[];for(const i in t.paint._values){const a=t.paint.get(i);if(!r(i))continue;if(!(a instanceof Oa&&Ri(a.property.specification)))continue;const s=jo(i,t.type),o=a.value,l=a.property.specification.type,u=!!a.property.useIntegerZoom,c="line-dasharray"===i||i.endsWith("pattern"),h="line-dasharray"===i&&"constant"!==t.layout.get("line-cap").value.kind;if("constant"!==o.kind||h)if("source"===o.kind||h||c){const e=$o(i,l,"source");this.binders[i]=c?new Lo(o,s,l,e,t.id):new Ro(o,s,l,e),n.push(`/a_${i}`);}else {const t=$o(i,l,"composite");this.binders[i]=new Do(o,s,l,u,e,t),n.push(`/z_${i}`);}else this.binders[i]=c?new Co(o.value,s):new Vo(o.value,s,l,e),n.push(`/u_${i}`);}this.cacheKey=n.sort().join("");}getMaxValue(t){const e=this.binders[t];return e instanceof Ro||e instanceof Do?e.maxValue:0}populatePaintArrays(t,e,r,n,i,a,s){for(const o in this.binders){const l=this.binders[o];l.context=this.context,(l instanceof Ro||l instanceof Do||l instanceof Lo)&&l.populatePaintArray(t,e,r,n,i,a,s);}}setConstantPatternPositions(t){for(const e in this.binders){const r=this.binders[e];r instanceof Co&&r.setConstantPatternPositions(t);}}updatePaintArrays(t,e,r,n,i,a,s,o){let l=!1;const u=Object.keys(t),c=0!==u.length,h=c?u:e.uniqueIds;this.context.lut=i.lut;for(const u in this.binders){const p=this.binders[u];if(p.context=this.context,(p instanceof Ro||p instanceof Do||p instanceof Lo)&&(!0===p.expression.isStateDependent||!1===p.expression.isLightConstant)){const f=i.paint.get(u);p.expression=f.value;for(const r of h){const i=t[r.toString()];e.eachPosition(r,((t,e,r)=>{const l=n.feature(t);p.updatePaintArray(e,r,l,i,a,s,o);}));}if(!c)for(const e of r.uniqueIds){const i=t[e.toString()];r.eachPosition(e,((t,e,r)=>{const l=n.feature(t);p.updatePaintArray(e,r,l,i,a,s,o);}));}l=!0;}}return l}defines(){const t=[];for(const e in this.binders){const r=this.binders[e];(r instanceof Vo||r instanceof Co)&&t.push(...r.uniformNames.map((t=>`#define HAS_UNIFORM_${t}`)));}return t}getBinderAttributes(){const t=[];for(const e in this.binders){const r=this.binders[e];if(r instanceof Ro||r instanceof Do||r instanceof Lo)for(let e=0;e<r.paintVertexAttributes.length;e++)t.push(r.paintVertexAttributes[e].name);}return t}getBinderUniforms(){const t=[];for(const e in this.binders){const r=this.binders[e];if(r instanceof Vo||r instanceof Co||r instanceof Do)for(const e of r.uniformNames)t.push(e);}return t}getPaintVertexBuffers(){return this._buffers}getUniforms(t){const e=[];for(const r in this.binders){const n=this.binders[r];if(n instanceof Vo||n instanceof Co||n instanceof Do)for(const i of n.uniformNames)e.push({name:i,property:r,binding:n.getBinding(t,i)});}return e}setUniforms(t,e,r,n,i){for(const{name:e,property:a,binding:s}of r)this.binders[a].setUniform(t,s,i,n.get(a),e);}updatePaintBuffers(){this._buffers=[];for(const t in this.binders){const e=this.binders[t];(e instanceof Ro||e instanceof Do||e instanceof Lo)&&e.paintVertexBuffer&&this._buffers.push(e.paintVertexBuffer);}}upload(t){for(const e in this.binders){const r=this.binders[e];(r instanceof Ro||r instanceof Do||r instanceof Lo)&&r.upload(t);}this.updatePaintBuffers();}destroy(){for(const t in this.binders){const e=this.binders[t];(e instanceof Ro||e instanceof Do||e instanceof Lo)&&e.destroy();}}}class Oo{constructor(t,e,r=(()=>!0)){this.programConfigurations={};for(const n of t)this.programConfigurations[n.id]=new Fo(n,e,r);this.needsUpload=!1,this._featureMap=new yo,this._featureMapWithoutIds=new yo,this._bufferOffset=0,this._idlessCounter=0;}populatePaintArrays(t,e,r,n,i,a,s,o){for(const r in this.programConfigurations)this.programConfigurations[r].populatePaintArrays(t,e,n,i,a,s,o);void 0!==e.id?this._featureMap.add(e.id,r,this._bufferOffset,t):(this._featureMapWithoutIds.add(this._idlessCounter,r,this._bufferOffset,t),this._idlessCounter+=1),this._bufferOffset=t,this.needsUpload=!0;}updatePaintArrays(t,e,r,n,i,a){for(const s of r)this.needsUpload=this.programConfigurations[s.id].updatePaintArrays(t,this._featureMap,this._featureMapWithoutIds,e,s,n,i,a||0)||this.needsUpload;}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const e in this.programConfigurations)this.programConfigurations[e].upload(t);this.needsUpload=!1;}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy();}}const Uo={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-occlusion-opacity":["occlusion_opacity"],"icon-occlusion-opacity":["occlusion_opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-emissive-strength":["emissive_strength"],"icon-emissive-strength":["emissive_strength"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"symbol-z-offset":["z_offset"],"line-gap-width":["gapwidth"],"line-pattern":["pattern","pixel_ratio"],"fill-pattern":["pattern","pixel_ratio"],"fill-extrusion-pattern":["pattern","pixel_ratio"],"line-dasharray":["dash"]};function jo(t,e){return Uo[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}const No={"line-pattern":{source:As,composite:As},"fill-pattern":{source:As,composite:As},"fill-extrusion-pattern":{source:As,composite:As},"line-dasharray":{source:Ss,composite:Ss}},qo={color:{source:Gs,composite:_s},number:{source:Fs,composite:Gs}};function $o(t,e,r){const n=No[t];return n&&n[r]||qo[e][r]}sa(Vo,"ConstantBinder"),sa(Co,"PatternConstantBinder"),sa(Ro,"SourceExpressionBinder"),sa(Lo,"PatternCompositeBinder"),sa(Do,"CompositeExpressionBinder"),sa(Fo,"ProgramConfiguration",{omit:["_buffers"]}),sa(Oo,"ProgramConfigurationSet");const Go=Wr/Math.PI/2,Xo=5,Yo=6,Zo=16383,Wo=64,Ho=[Wo,32,16],Ko=-Go,Jo=Go;function Qo(t,e,r,n=Go){return r=Y(r),[t*Math.sin(r)*n,-e*n,t*Math.cos(r)*n]}function tl(t,e,r){return Qo(Math.cos(Y(t)),Math.sin(Y(t)),e,r)}const el=6371008.8,rl=2*Math.PI*el;class nl{constructor(t,e){if(isNaN(t)||isNaN(e))throw new Error(`Invalid LngLat object: (${t}, ${e})`);if(this.lng=+t,this.lat=+e,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new nl(et(this.lng,-180,180),this.lat)}toArray(){return [this.lng,this.lat]}toString(){return `LngLat(${this.lng}, ${this.lat})`}distanceTo(t){const e=Math.PI/180,r=this.lat*e,n=t.lat*e,i=Math.sin(r)*Math.sin(n)+Math.cos(r)*Math.cos(n)*Math.cos((t.lng-this.lng)*e);return el*Math.acos(Math.min(i,1))}toBounds(t=0){const e=360*t/40075017,r=e/Math.cos(Math.PI/180*this.lat);return new il({lng:this.lng-r,lat:this.lat-e},{lng:this.lng+r,lat:this.lat+e})}toEcef(t){return tl(this.lat,this.lng,Go+t*Go/el)}static convert(t){if(t instanceof nl)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new nl(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new nl(Number("lng"in t?t.lng:t.lon),Number(t.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}class il{constructor(t,e){if(t)if(e)this.setSouthWest(t).setNorthEast(e);else if(4===t.length){const e=t;this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]);}else {const e=t;this.setSouthWest(e[0]).setNorthEast(e[1]);}}setNorthEast(t){return this._ne=t instanceof nl?new nl(t.lng,t.lat):nl.convert(t),this}setSouthWest(t){return this._sw=t instanceof nl?new nl(t.lng,t.lat):nl.convert(t),this}extend(t){const e=this._sw,r=this._ne;let n,i;if(t instanceof nl)n=t,i=t;else {if(!(t instanceof il))return Array.isArray(t)?4===t.length||t.every(Array.isArray)?this.extend(il.convert(t)):this.extend(nl.convert(t)):"object"==typeof t&&null!==t&&t.hasOwnProperty("lat")&&(t.hasOwnProperty("lon")||t.hasOwnProperty("lng"))?this.extend(nl.convert(t)):this;if(n=t._sw,i=t._ne,!n||!i)return this}return e||r?(e.lng=Math.min(n.lng,e.lng),e.lat=Math.min(n.lat,e.lat),r.lng=Math.max(i.lng,r.lng),r.lat=Math.max(i.lat,r.lat)):(this._sw=new nl(n.lng,n.lat),this._ne=new nl(i.lng,i.lat)),this}getCenter(){return new nl((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 nl(this.getWest(),this.getNorth())}getSouthEast(){return new nl(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return [this._sw.toArray(),this._ne.toArray()]}toString(){return `LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return !(this._sw&&this._ne)}contains(t){const{lng:e,lat:r}=nl.convert(t);let n=this._sw.lng<=e&&e<=this._ne.lng;return this._sw.lng>this._ne.lng&&(n=this._sw.lng>=e&&e>=this._ne.lng),this._sw.lat<=r&&r<=this._ne.lat&&n}static convert(t){if(t)return t instanceof il?t:new il(t)}}const al=0,sl=25.5;function ol(t){return rl*Math.cos(t*Math.PI/180)}function ll(t){return (180+t)/360}function ul(t){return (180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function cl(t,e){return t/ol(e)}function hl(t){return 360*t-180}function pl(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}function fl(t,e){return t*ol(pl(e))}const dl=85.051129;function ml(t){return Math.cos(Y(Q(t,-dl,dl)))}function yl(t,e){const r=Q(e,al,sl),n=Math.pow(2,r);return ml(t)*rl/(512*n)}function gl(t){return 1/Math.cos(t*Math.PI/180)}function xl(t,e=0){const r=Math.exp(Math.PI*(1-(t.y+e/Wr)/(1<<t.z)*2));return 80150034*r/(r*r+1)/Wr/(1<<t.z)}class vl{constructor(t,e,r=0){this.x=+t,this.y=+e,this.z=+r;}static fromLngLat(t,e=0){const r=nl.convert(t);return new vl(ll(r.lng),ul(r.lat),cl(e,r.lat))}toLngLat(){return new nl(hl(this.x),pl(this.y))}toAltitude(){return fl(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/rl*gl(pl(this.y))}}function bl(t,e,r,n,i,a,s,o,l){const u=(e+n)/2,c=(r+i)/2,h=new q(u,c);o(h),function(t,e,r,n,i,a){const s=r-i,o=n-a;return Math.abs((n-e)*s-(r-t)*o)/Math.hypot(s,o)}(h.x,h.y,a.x,a.y,s.x,s.y)>=l?(bl(t,e,r,u,c,a,h,o,l),bl(t,u,c,n,i,h,s,o,l)):t.push(s);}function wl(t,e,r){let n=t[0],i=n.x,a=n.y;e(n);const s=[n];for(let o=1;o<t.length;o++){const l=t[o],{x:u,y:c}=l;e(l),bl(s,i,a,u,c,n,l,e,r),i=u,a=c,n=l;}return s}function _l(t,e,r,n){if(n(e,r)){const i=e.add(r)._mult(.5);_l(t,e,i,n),_l(t,i,r,n);}else t.push(r);}function Ml(t,e){let r=t[0];const n=[r];for(let i=1;i<t.length;i++){const a=t[i];_l(n,r,a,e),r=a;}return n}const Al=Math.pow(2,14)-1,Sl=-Al-1;function Il(t,e){const r=Math.round(t.x*e),n=Math.round(t.y*e);return t.x=Q(r,Sl,Al),t.y=Q(n,Sl,Al),(r<t.x||r>t.x+1||n<t.y||n>t.y+1)&&ft("Geometry exceeds allowed extent, reduce your vector tile buffer size"),t}function zl(t,e,r){const n=t.loadGeometry(),i=t.extent,a=Wr/i;if(e&&r&&r.projection.isReprojectedInTileSpace){const a=1<<e.z,{scale:s,x:o,y:l,projection:u}=r,c=t=>{const r=hl((e.x+t.x/i)/a),n=pl((e.y+t.y/i)/a),c=u.project(r,n);t.x=(c.x*s-o)*i,t.y=(c.y*s-l)*i;};for(let e=0;e<n.length;e++)if(1!==t.type)n[e]=wl(n[e],c,1);else {const t=[];for(const r of n[e])r.x<0||r.x>=i||r.y<0||r.y>=i||(c(r),t.push(r));n[e]=t;}}for(const t of n)for(const e of t)Il(e,a);return n}function Pl(t,e){return {type:t.type,id:t.id,properties:t.properties,geometry:e?zl(t):[]}}function kl(t,e,r,n,i){t.emplaceBack(2*e+(n+1)/2,2*r+(i+1)/2);}function Tl(t,e,r){const n=16384;t.emplaceBack(e.x,e.y,e.z,r[0]*n,r[1]*n,r[2]*n);}class El{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=t.index,this.hasPattern=!1,this.projection=t.projection,this.layoutVertexArray=new gs,this.indexArray=new Rs,this.segments=new ho,this.programConfigurations=new Oo(t.layers,{zoom:t.zoom,lut:t.lut}),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}updateFootprints(t,e){}populate(t,e,r,n){const i=this.layers[0],a=[];let s=null;"circle"===i.type&&(s=i.layout.get("circle-sort-key"));for(const{feature:e,id:i,index:o,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,u=Pl(e,t);if(!this.layers[0]._featureFilter.filter(new Ba(this.zoom),u,r))continue;const c=s?s.evaluate(u,{},r):void 0,h={id:i,properties:e.properties,type:e.type,sourceLayerIndex:l,index:o,geometry:t?u.geometry:zl(e,r,n),patterns:{},sortKey:c};a.push(h);}s&&a.sort(((t,e)=>t.sortKey-e.sortKey));let o=null;"globe"===n.projection.name&&(this.globeExtVertexArray=new Is,o=n.projection);for(const n of a){const{geometry:i,index:a,sourceLayerIndex:s}=n,l=t[a].feature;this.addFeature(n,i,a,e.availableImages,r,o,e.brightness),e.featureIndex.insert(l,i,a,s,this.index);}}update(t,e,r,n,i){const a=0!==Object.keys(t).length;a&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,a?this.stateDependentLayers:this.layers,r,n,i);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,uo.members),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,co.members))),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy());}addFeature(t,e,r,n,i,a,s){for(const r of e)for(const e of r){const r=e.x,n=e.y;if(r<0||r>=Wr||n<0||n>=Wr)continue;if(a){const t=a.projectTilePoint(r,n,i),e=a.upVector(i,r,n),s=this.globeExtVertexArray;Tl(s,t,e),Tl(s,t,e),Tl(s,t,e),Tl(s,t,e);}const s=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,t.sortKey),o=s.vertexLength;kl(this.layoutVertexArray,r,n,-1,-1),kl(this.layoutVertexArray,r,n,1,-1),kl(this.layoutVertexArray,r,n,1,1),kl(this.layoutVertexArray,r,n,-1,1),this.indexArray.emplaceBack(o,o+1,o+2),this.indexArray.emplaceBack(o,o+2,o+3),s.vertexLength+=4,s.primitiveLength+=2;}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,{},n,i,s);}}function Bl(t,e){for(let r=0;r<t.length;r++)if(jl(e,t[r]))return !0;for(let r=0;r<e.length;r++)if(jl(t,e[r]))return !0;return !!Dl(t,e)}function Vl(t,e,r){return !!jl(t,e)||!!Fl(e,t,r)}function Cl(t,e){if(1===t.length)return Ul(e,t[0]);for(let r=0;r<e.length;r++){const n=e[r];for(let e=0;e<n.length;e++)if(jl(t,n[e]))return !0}for(let r=0;r<t.length;r++)if(Ul(e,t[r]))return !0;for(let r=0;r<e.length;r++)if(Dl(t,e[r]))return !0;return !1}function Rl(t,e,r){if(t.length>1){if(Dl(t,e))return !0;for(let n=0;n<e.length;n++)if(Fl(e[n],t,r))return !0}for(let n=0;n<t.length;n++)if(Fl(t[n],e,r))return !0;return !1}function Dl(t,e){if(0===t.length||0===e.length)return !1;for(let r=0;r<t.length-1;r++){const n=t[r],i=t[r+1];for(let t=0;t<e.length-1;t++)if(Ll(n,i,e[t],e[t+1]))return !0}return !1}function Ll(t,e,r,n){return dt(t,r,n)!==dt(e,r,n)&&dt(t,e,r)!==dt(t,e,n)}function Fl(t,e,r){const n=r*r;if(1===e.length)return t.distSqr(e[0])<n;for(let r=1;r<e.length;r++)if(Ol(t,e[r-1],e[r])<n)return !0;return !1}function Ol(t,e,r){const n=e.distSqr(r);if(0===n)return t.distSqr(e);const i=((t.x-e.x)*(r.x-e.x)+(t.y-e.y)*(r.y-e.y))/n;return t.distSqr(i<0?e:i>1?r:r.sub(e)._mult(i)._add(e))}function Ul(t,e){let r,n,i,a=!1;for(let s=0;s<t.length;s++){r=t[s];for(let t=0,s=r.length-1;t<r.length;s=t++)n=r[t],i=r[s],n.y>e.y!=i.y>e.y&&e.x<(i.x-n.x)*(e.y-n.y)/(i.y-n.y)+n.x&&(a=!a);}return a}function jl(t,e){let r=!1;for(let n=0,i=t.length-1;n<t.length;i=n++){const a=t[n],s=t[i];a.y>e.y!=s.y>e.y&&e.x<(s.x-a.x)*(e.y-a.y)/(s.y-a.y)+a.x&&(r=!r);}return r}function Nl(t,e,r,n,i){for(const a of t)if(e<=a.x&&r<=a.y&&n>=a.x&&i>=a.y)return !0;const a=[new q(e,r),new q(e,i),new q(n,i),new q(n,r)];if(t.length>2)for(const e of a)if(jl(t,e))return !0;for(let e=0;e<t.length-1;e++)if(ql(t[e],t[e+1],a))return !0;return !1}function ql(t,e,r){const n=r[0],i=r[2];if(t.x<n.x&&e.x<n.x||t.x>i.x&&e.x>i.x||t.y<n.y&&e.y<n.y||t.y>i.y&&e.y>i.y)return !1;const a=dt(t,e,r[0]);return a!==dt(t,e,r[1])||a!==dt(t,e,r[2])||a!==dt(t,e,r[3])}function $l(t,e,r,n,i,a){let s=e.y-t.y,o=t.x-e.x;if(a=a||0){const t=s*s+o*o;if(0===t)return !0;const e=Math.sqrt(t);s/=e,o/=e;}return !((r.x-t.x)*s+(r.y-t.y)*o-a<0||(n.x-t.x)*s+(n.y-t.y)*o-a<0||(i.x-t.x)*s+(i.y-t.y)*o-a<0)}function Gl(t,e,r,n,i,a,s){return !($l(t,e,n,i,a,s)||$l(e,r,n,i,a,s)||$l(r,t,n,i,a,s)||$l(n,i,t,e,r,s)||$l(i,a,t,e,r,s)||$l(a,n,t,e,r,s))}function Xl(t,e,r){const n=e.paint.get(t).value;return "constant"===n.kind?n.value:r.programConfigurations.get(e.id).getMaxValue(t)}function Yl(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function Zl(t,e,r,n,i){if(!e[0]&&!e[1])return t;const a=q.convert(e)._mult(i);"viewport"===r&&a._rotate(-n);const s=[];for(let e=0;e<t.length;e++)s.push(t[e].sub(a));return s}function Wl(t,e,r,n){const i=q.convert(t)._mult(n);return "viewport"===e&&i._rotate(-r),i}let Hl,Kl;sa(El,"CircleBucket",{omit:["layers"]});var Jl,Ql={exports:{}},tu=(Jl||(Jl=1,function(t,e){!function(t){function e(t,e,n){var i=r(256*t,256*(e=Math.pow(2,n)-e-1),n),a=r(256*(t+1),256*(e+1),n);return i[0]+","+i[1]+","+a[0]+","+a[1]}function r(t,e,r){var n=2*Math.PI*6378137/256/Math.pow(2,r);return [t*n-2*Math.PI*6378137/2,e*n-2*Math.PI*6378137/2]}t.getURL=function(t,r,n,i,a,s){return s=s||{},t+"?"+["bbox="+e(n,i,a),"format="+(s.format||"image/png"),"service="+(s.service||"WMS"),"version="+(s.version||"1.1.1"),"request="+(s.request||"GetMap"),"srs="+(s.srs||"EPSG:3857"),"width="+(s.width||256),"height="+(s.height||256),"layers="+r].join("&")},t.getTileBBox=e,t.getMercCoords=r,Object.defineProperty(t,"__esModule",{value:!0});}(e);}(0,Ql.exports)),Ql.exports);class eu{constructor(t,e,r){this.z=t,this.x=e,this.y=r,this.key=iu(0,t,t,e,r);}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,e){const r=tu.getTileBBox(this.x,this.y,this.z),n=function(t,e,r){let n,i="";for(let a=t;a>0;a--)n=1<<a-1,i+=(e&n?1:0)+(r&n?2:0);return i}(this.z,this.x,this.y);return t[(this.x+this.y)%t.length].replace("{prefix}",(this.x%16).toString(16)+(this.y%16).toString(16)).replace(/{z}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String("tms"===e?Math.pow(2,this.z)-this.y-1:this.y)).replace("{quadkey}",n).replace("{bbox-epsg-3857}",r)}toString(){return `${this.z}/${this.x}/${this.y}`}}class ru{constructor(t,e){this.wrap=t,this.canonical=e,this.key=iu(t,e.z,e.z,e.x,e.y);}}class nu{constructor(t,e,r,n,i){this.overscaledZ=t,this.wrap=e,this.canonical=new eu(r,+n,+i),this.key=0===e&&t===r?this.canonical.key:iu(e,t,r,n,i);}equals(t){return this.overscaledZ===t.overscaledZ&&this.wrap===t.wrap&&this.canonical.equals(t.canonical)}scaledTo(t){const e=this.canonical.z-t;return t>this.canonical.z?new nu(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new nu(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)}calculateScaledKey(t,e=!0){if(this.overscaledZ===t&&e)return this.key;if(t>this.canonical.z)return iu(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y);{const r=this.canonical.z-t;return iu(this.wrap*+e,t,t,this.canonical.x>>r,this.canonical.y>>r)}}isChildOf(t){if(t.wrap!==this.wrap)return !1;const e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ<this.overscaledZ&&t.canonical.z<this.canonical.z&&t.canonical.x===this.canonical.x>>e&&t.canonical.y===this.canonical.y>>e}children(t){if(this.overscaledZ>=t)return [new nu(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const e=this.canonical.z+1,r=2*this.canonical.x,n=2*this.canonical.y;return [new nu(e,this.wrap,e,r,n),new nu(e,this.wrap,e,r+1,n),new nu(e,this.wrap,e,r,n+1),new nu(e,this.wrap,e,r+1,n+1)]}isLessThan(t){return this.wrap<t.wrap||!(this.wrap>t.wrap)&&(this.overscaledZ<t.overscaledZ||!(this.overscaledZ>t.overscaledZ)&&(this.canonical.x<t.canonical.x||!(this.canonical.x>t.canonical.x)&&this.canonical.y<t.canonical.y))}wrapped(){return new nu(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(t){return new nu(this.overscaledZ,t,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new ru(this.wrap,this.canonical)}toString(){return `${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}}function iu(t,e,r,n,i){const a=1<<Math.min(r,22);let s=a*(i%a)+n%a;return t&&r<22&&(s+=a*a*((t<0?-2*t-1:2*t)%(1<<2*(22-r)))),16*(32*s+r)+(e-r)}const au=[t=>{let e=t.canonical.x-1,r=t.wrap;return e<0&&(e=(1<<t.canonical.z)-1,r--),new nu(t.overscaledZ,r,t.canonical.z,e,t.canonical.y)},t=>{let e=t.canonical.x+1,r=t.wrap;return e===1<<t.canonical.z&&(e=0,r++),new nu(t.overscaledZ,r,t.canonical.z,e,t.canonical.y)},t=>new nu(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,(0===t.canonical.y?1<<t.canonical.z:t.canonical.y)-1),t=>new nu(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y===(1<<t.canonical.z)-1?0:t.canonical.y+1)];sa(eu,"CanonicalTileID"),sa(nu,"OverscaledTileID",{omit:["projMatrix","expandedProjMatrix"]});const su=ms([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_uv",components:2}]),{members:ou}=su,lu=ms([{name:"a_pos_3",components:3,type:"Int16"}]);var uu=ms([{name:"a_pos",type:"Int16",components:2}]);class cu{constructor(t,e){this.pos=t,this.dir=e;}intersectsPlane(t,e,r){const n=O.vec3.dot(e,this.dir);if(Math.abs(n)<1e-6)return !1;const i=((t[0]-this.pos[0])*e[0]+(t[1]-this.pos[1])*e[1]+(t[2]-this.pos[2])*e[2])/n;return r[0]=this.pos[0]+this.dir[0]*i,r[1]=this.pos[1]+this.dir[1]*i,r[2]=this.pos[2]+this.dir[2]*i,!0}closestPointOnSphere(t,e,r){if(O.vec3.equals(this.pos,t)||0===e)return r[0]=r[1]=r[2]=0,!1;const[n,i,a]=this.dir,s=this.pos[0]-t[0],o=this.pos[1]-t[1],l=this.pos[2]-t[2],u=n*n+i*i+a*a,c=2*(s*n+o*i+l*a),h=c*c-4*u*(s*s+o*o+l*l-e*e);if(h<0){const t=Math.max(-c/2,0),u=s+n*t,h=o+i*t,p=l+a*t,f=Math.hypot(u,h,p);return r[0]=u*e/f,r[1]=h*e/f,r[2]=p*e/f,!1}{const t=(-c-Math.sqrt(h))/(2*u);if(t<0){const t=Math.hypot(s,o,l);return r[0]=s*e/t,r[1]=o*e/t,r[2]=l*e/t,!1}return r[0]=s+n*t,r[1]=o+i*t,r[2]=l+a*t,!0}}}class hu{constructor(t,e,r,n,i){this.TL=t,this.TR=e,this.BR=r,this.BL=n,this.horizon=i;}static fromInvProjectionMatrix(t,e,r){const n=[-1,1,1],i=[1,1,1],a=[1,-1,1],s=[-1,-1,1],o=O.vec3.transformMat4(n,n,t),l=O.vec3.transformMat4(i,i,t),u=O.vec3.transformMat4(a,a,t),c=O.vec3.transformMat4(s,s,t);return new hu(o,l,u,c,e/r)}}function pu(t,e,r){let n=1/0,i=-1/0;const a=[];for(const s of t){O.vec3.sub(a,s,e);const t=O.vec3.dot(a,r);n=Math.min(n,t),i=Math.max(i,t);}return [n,i]}function fu(t,e){let r=!0;for(let n=0;n<t.planes.length;n++){const i=t.planes[n];let a=0;for(let t=0;t<e.length;t++)a+=O.vec3.dot(i,e[t])+i[3]>=0;if(0===a)return 0;a!==e.length&&(r=!1);}return r?2:1}function du(t,e){for(const r of t.projections){const n=pu(e,t.points[0],r.axis);if(r.projection[1]<n[0]||r.projection[0]>n[1])return 0}return 1}function mu(t,e){let r=0;const n=[0,0,0,0];for(let i=0;i<t.length;i++)n[0]=t[i][0],n[1]=t[i][1],n[2]=t[i][2],n[3]=1,O.vec4.dot(n,e)>=0&&r++;return r}class yu{constructor(t,e){this.points=t||new Array(8).fill([0,0,0]),this.planes=e||new Array(6).fill([0,0,0,0]),this.bounds=gu.fromPoints(this.points),this.projections=[],this.frustumEdges=[O.vec3.sub([],this.points[2],this.points[3]),O.vec3.sub([],this.points[0],this.points[3]),O.vec3.sub([],this.points[4],this.points[0]),O.vec3.sub([],this.points[5],this.points[1]),O.vec3.sub([],this.points[6],this.points[2]),O.vec3.sub([],this.points[7],this.points[3])];for(const t of this.frustumEdges){const e=[0,-t[2],t[1]],r=[t[2],0,-t[0]];this.projections.push({axis:e,projection:pu(this.points,this.points[0],e)}),this.projections.push({axis:r,projection:pu(this.points,this.points[0],r)});}}static fromInvProjectionMatrix(t,e,r,n){const i=Math.pow(2,r),a=[[-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 a=O.vec4.transformMat4([],r,t),s=1/a[3]/e*i;return O.vec4.mul(a,a,[s,s,n?1/a[3]:s,s])})),s=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((t=>{const e=O.vec3.sub([],a[t[0]],a[t[1]]),r=O.vec3.sub([],a[t[2]],a[t[1]]),n=O.vec3.normalize([],O.vec3.cross([],e,r)),i=-O.vec3.dot(n,a[t[1]]);return n.concat(i)})),o=[];for(let t=0;t<a.length;t++)o.push([a[t][0],a[t][1],a[t][2]]);return new yu(o,s)}intersectsPrecise(t,e,r){for(let r=0;r<e.length;r++)if(!mu(t,e[r]))return 0;for(let e=0;e<this.planes.length;e++)if(!mu(t,this.planes[e]))return 0;for(const e of r)for(const r of this.frustumEdges){const n=O.vec3.cross([],e,r),i=O.vec3.length(n);if(0===i)continue;O.vec3.scale(n,n,1/i);const a=pu(this.points,this.points[0],n),s=pu(t,this.points[0],n);if(a[0]>s[1]||s[0]>a[1])return 0}return 1}containsPoint(t){for(const e of this.planes){const r=e[3];if(O.vec3.dot([e[0],e[1],e[2]],t)+r<0)return !1}return !0}}class gu{static fromPoints(t){const e=[1/0,1/0,1/0],r=[-1/0,-1/0,-1/0];for(const n of t)O.vec3.min(e,e,n),O.vec3.max(r,r,n);return new gu(e,r)}static fromTileIdAndHeight(t,e,r){const n=1<<t.canonical.z,i=t.canonical.x,a=t.canonical.y;return new gu([i/n,a/n,e],[(i+1)/n,(a+1)/n,r])}static applyTransform(t,e){const r=t.getCorners();for(let t=0;t<r.length;++t)O.vec3.transformMat4(r[t],r[t],e);return gu.fromPoints(r)}static applyTransformFast(t,e){const r=[e[12],e[13],e[14]],n=[...r];for(let i=0;i<3;i++)for(let a=0;a<3;a++){const s=e[4*a+i],o=s*t.min[a],l=s*t.max[a];r[i]+=Math.min(o,l),n[i]+=Math.max(o,l);}return new gu(r,n)}static projectAabbCorners(t,e){const r=t.getCorners();for(let t=0;t<r.length;++t)O.vec3.transformMat4(r[t],r[t],e);return r}constructor(t,e){this.min=t,this.max=e,this.center=O.vec3.scale([],O.vec3.add([],this.min,this.max),.5);}quadrant(t){const e=[t%2==0,t<2],r=O.vec3.clone(this.min),n=O.vec3.clone(this.max);for(let t=0;t<e.length;t++)r[t]=e[t]?this.min[t]:this.center[t],n[t]=e[t]?this.center[t]:this.max[t];return n[2]=this.max[2],new gu(r,n)}distanceX(t){return Math.max(Math.min(this.max[0],t[0]),this.min[0])-t[0]}distanceY(t){return Math.max(Math.min(this.max[1],t[1]),this.min[1])-t[1]}distanceZ(t){return Math.max(Math.min(this.max[2],t[2]),this.min[2])-t[2]}getCorners(){const t=this.min,e=this.max;return [[t[0],t[1],t[2]],[e[0],t[1],t[2]],[e[0],e[1],t[2]],[t[0],e[1],t[2]],[t[0],t[1],e[2]],[e[0],t[1],e[2]],[e[0],e[1],e[2]],[t[0],e[1],e[2]]]}intersects(t){return this.intersectsAabb(t.bounds)?fu(t,this.getCorners()):0}intersectsFlat(t){return this.intersectsAabb(t.bounds)?fu(t,[[this.min[0],this.min[1],0],[this.max[0],this.min[1],0],[this.max[0],this.max[1],0],[this.min[0],this.max[1],0]]):0}intersectsPrecise(t,e){return e||this.intersects(t)?du(t,this.getCorners()):0}intersectsPreciseFlat(t,e){return e||this.intersectsFlat(t)?du(t,[[this.min[0],this.min[1],0],[this.max[0],this.min[1],0],[this.max[0],this.max[1],0],[this.min[0],this.max[1],0]]):0}intersectsAabb(t){for(let e=0;e<3;++e)if(this.min[e]>t.max[e]||t.min[e]>this.max[e])return !1;return !0}intersectsAabbXY(t){return !(this.min[0]>t.max[0]||t.min[0]>this.max[0]||this.min[1]>t.max[1]||t.min[1]>this.max[1])}encapsulate(t){for(let e=0;e<3;e++)this.min[e]=Math.min(this.min[e],t.min[e]),this.max[e]=Math.max(this.max[e],t.max[e]);}encapsulatePoint(t){for(let e=0;e<3;e++)this.min[e]=Math.min(this.min[e],t[e]),this.max[e]=Math.max(this.max[e],t[e]);}closestPoint(t){return [Math.max(Math.min(this.max[0],t[0]),this.min[0]),Math.max(Math.min(this.max[1],t[1]),this.min[1]),Math.max(Math.min(this.max[2],t[2]),this.min[2])]}}function xu(t){return t*Go/el}sa(gu,"Aabb");const vu=[new gu([Ko,Ko,Ko],[Jo,Jo,Jo]),new gu([Ko,Ko,Ko],[0,0,Jo]),new gu([0,Ko,Ko],[Jo,0,Jo]),new gu([Ko,0,Ko],[0,Jo,Jo]),new gu([0,0,Ko],[Jo,Jo,Jo])];function bu(t,e,r,n=!0){const i=O.vec3.scale([],t._camera.position,t.worldSize),a=[e,r,1,1];O.vec4.transformMat4(a,a,t.pixelMatrixInverse),O.vec4.scale(a,a,1/a[3]);const s=O.vec3.sub([],a,i),o=O.vec3.normalize([],s),l=t.globeMatrix,u=[l[12],l[13],l[14]],c=O.vec3.sub([],u,i),h=O.vec3.length(c),p=O.vec3.normalize([],c),f=t.worldSize/(2*Math.PI),d=O.vec3.dot(p,o),m=Math.asin(f/h);if(m<Math.acos(d)){if(!n)return null;const t=[],e=[];O.vec3.scale(t,o,h/d),O.vec3.normalize(e,O.vec3.sub(e,t,c)),O.vec3.normalize(o,O.vec3.add(o,c,O.vec3.scale(o,e,Math.tan(m)*h)));}const y=[];new cu(i,o).closestPointOnSphere(u,f,y);const g=O.vec3.normalize([],bt(l,0)),x=O.vec3.normalize([],bt(l,1)),v=O.vec3.normalize([],bt(l,2)),b=O.vec3.dot(g,y),w=O.vec3.dot(x,y),_=O.vec3.dot(v,y),M=Z(Math.asin(-w/f));let A=Z(Math.atan2(b,_));A=t.center.lng+function(t,e){const r=(e-t+180)%360-180;return r<-180?r+360:r}(t.center.lng,A);const S=ll(A),I=Q(ul(M),0,1);return new vl(S,I)}class wu{constructor(t,e,r){this.a=O.vec3.sub([],t,r),this.b=O.vec3.sub([],e,r),this.center=r;const n=O.vec3.normalize([],this.a),i=O.vec3.normalize([],this.b);this.angle=Math.acos(O.vec3.dot(n,i));}}function _u(t,e){if(0===t.angle)return null;let r;return r=0===t.a[e]?1/t.angle*.5*Math.PI:1/t.angle*Math.atan(t.b[e]/t.a[e]/Math.sin(t.angle)-1/Math.tan(t.angle)),r<0||r>1?null:function(t,e,r,n){const i=Math.sin(r);return t*(Math.sin((1-n)*r)/i)+e*(Math.sin(n*r)/i)}(t.a[e],t.b[e],t.angle,Q(r,0,1))+t.center[e]}function Mu(t){if(t.z<=1)return vu[t.z+2*t.y+t.x];const e=Pu(zu(t));return gu.fromPoints(e)}function Au(t,e,r){return O.vec3.scale(t,t,1-r),O.vec3.scaleAndAdd(t,t,e,r)}function Su(t,e,r){for(const n of t)O.vec3.transformMat4(n,n,e),O.vec3.scale(n,n,r);}function Iu(t,e,r,n){const i=e/t.worldSize,a=t.globeMatrix;if(r.z<=1){const t=Mu(r).getCorners();return Su(t,a,i),gu.fromPoints(t)}const s=zu(r,n),o=Pu(s,Go+xu(t._tileCoverLift));Su(o,a,i);const l=Number.MAX_VALUE,u=[-l,-l,-l],c=[l,l,l];if(s.contains(t.center)){for(const t of o)O.vec3.min(c,c,t),O.vec3.max(u,u,t);u[2]=0;const e=t.point,r=[e.x*i,e.y*i,0];return O.vec3.min(c,c,r),O.vec3.max(u,u,r),new gu(c,u)}if(t._tileCoverLift>0){for(const t of o)O.vec3.min(c,c,t),O.vec3.max(u,u,t);return new gu(c,u)}const h=[a[12]*i,a[13]*i,a[14]*i],p=s.getCenter(),f=Q(t.center.lat,-dl,dl),d=Q(p.lat,-dl,dl),m=ll(t.center.lng),y=ul(f);let g=m-ll(p.lng);const x=y-ul(d);g>.5?g-=1:g<-.5&&(g+=1);let v=0;if(Math.abs(g)>Math.abs(x))v=g>=0?1:3;else {v=x>=0?0:2;const t=[a[4]*i,a[5]*i,a[6]*i],e=-Math.sin(Y(x>=0?s.getSouth():s.getNorth()))*Go;O.vec3.scaleAndAdd(h,h,t,e);}const b=o[v],w=o[(v+1)%4],_=new wu(b,w,h),M=[_u(_,0)||b[0],_u(_,1)||b[1],_u(_,2)||b[2]],A=Lu(t.zoom);if(A>0){const n=function({x:t,y:e,z:r},n,i,a,s){const o=1/(1<<r);let l=t*o,u=l+o,c=e*o,h=c+o,p=0;const f=(l+u)/2-a;return f>.5?p=-1:f<-.5&&(p=1),l=((l+p)*n-(a*=n))*i+a,u=((u+p)*n-a)*i+a,c=(c*n-(s*=n))*i+s,h=(h*n-s)*i+s,[[l,h,0],[u,h,0],[u,c,0],[l,c,0]]}(r,e,t._pixelsPerMercatorPixel,m,y);for(let t=0;t<o.length;t++)Au(o[t],n[t],A);const i=O.vec3.add([],n[v],n[(v+1)%4]);O.vec3.scale(i,i,.5),Au(M,i,A);}for(const t of o)O.vec3.min(c,c,t),O.vec3.max(u,u,t);return c[2]=Math.min(b[2],w[2]),O.vec3.min(c,c,M),O.vec3.max(u,u,M),new gu(c,u)}function zu({x:t,y:e,z:r},n=!1){const i=1/(1<<r),a=new nl(hl(t*i),e===(1<<r)-1&&n?-90:pl((e+1)*i)),s=new nl(hl((t+1)*i),0===e&&n?90:pl(e*i));return new il(a,s)}function Pu(t,e=Go){const r=Y(t.getNorth()),n=Y(t.getSouth()),i=Math.cos(r),a=Math.cos(n),s=Math.sin(r),o=Math.sin(n),l=t.getWest(),u=t.getEast();return [Qo(a,o,l,e),Qo(a,o,u,e),Qo(i,s,u,e),Qo(i,s,l,e)]}function ku(t,e,r,n){const i=1<<r.z,a=(t/Wr+r.x)/i;return tl(pl((e/Wr+r.y)/i),hl(a),n)}function Tu({min:t,max:e}){return Zo/Math.max(e[0]-t[0],e[1]-t[1],e[2]-t[2])}const Eu=new Float64Array(16);function Bu(t){const e=Tu(t),r=O.mat4.fromScaling(Eu,[e,e,e]);return O.mat4.translate(r,r,O.vec3.negate([],t.min))}function Vu(t){const e=O.mat4.fromTranslation(Eu,t.min),r=1/Tu(t);return O.mat4.scale(e,e,[r,r,r])}function Cu(t){const e=Wr/(2*Math.PI);return t/(2*Math.PI)/e}function Ru(t,e){return Wr/(512*Math.pow(2,t))*Tu(Mu(e))}function Du(t,e,r,n,i){const a=Cu(r),s=[t,e,-r/(2*Math.PI)],o=O.mat4.identity(new Float64Array(16));return O.mat4.translate(o,o,s),O.mat4.scale(o,o,[a,a,a]),O.mat4.rotateX(o,o,Y(-i)),O.mat4.rotateY(o,o,Y(-n)),o}function Lu(t){return tt(Xo,Yo,t)}function Fu(t,e){const r=tl(e.lat,e.lng),n=function(t){const e=tl(t._center.lat,t._center.lng),r=O.vec3.fromValues(0,1,0);let n=O.vec3.cross([],r,e);const i=O.mat4.fromRotation([],-t.angle,e);n=O.vec3.transformMat4(n,n,i),O.mat4.fromRotation(i,-t._pitch,n);const a=O.vec3.normalize([],e);return O.vec3.scale(a,a,xu(t.cameraToCenterDistance/t.pixelsPerMeter)),O.vec3.transformMat4(a,a,i),O.vec3.add([],e,a)}(t),i=O.vec3.subtract([],n,r);return O.vec3.angle(i,r)}function Ou(t,e){return Fu(t,e)>Math.PI/2*1.01}const Uu=Y(85),ju=Math.cos(Uu),Nu=Math.sin(Uu),qu=O.mat4.create(),$u=t=>{const e=[];return "map"===t.paint.get("circle-pitch-alignment")&&e.push("PITCH_WITH_MAP"),"map"===t.paint.get("circle-pitch-scale")&&e.push("SCALE_WITH_MAP"),e};function Gu(t,e,r,n,i,a,s,o,l){if(a&&t.queryGeometry.isAboveHorizon)return !1;a&&(l*=t.pixelToTileUnitsFactor);const u=t.tileID.canonical,c=r.projection.upVectorScale(u,r.center.lat,r.worldSize).metersToTile;for(const h of e)for(const e of h){const h=e.add(o),p=i&&r.elevation?r.elevation.exaggeration()*i.getElevationAt(h.x,h.y,!0):0,f=r.projection.projectTilePoint(h.x,h.y,u);if(p>0){const t=r.projection.upVector(u,h.x,h.y);f.x+=t[0]*c*p,f.y+=t[1]*c*p,f.z+=t[2]*c*p;}const d=a?h:Xu(f.x,f.y,f.z,n),m=a?t.tilespaceRays.map((t=>Wu(t,p))):t.queryGeometry.screenGeometry,y=O.vec4.transformMat4([],[f.x,f.y,f.z,1],n);if(!s&&a?l*=y[3]/r.cameraToCenterDistance:s&&!a&&(l*=r.cameraToCenterDistance/y[3]),a){const t=pl((e.y/Wr+u.y)/(1<<u.z));l/=r.projection.pixelsPerMeter(t,1)/cl(1,t);}if(Vl(m,d,l))return !0}return !1}function Xu(t,e,r,n){const i=O.vec4.transformMat4([],[t,e,r,1],n);return new q(i[0]/i[3],i[1]/i[3])}const Yu=O.vec3.fromValues(0,0,0),Zu=O.vec3.fromValues(0,0,1);function Wu(t,e){const r=O.vec3.create();return Yu[2]=e,t.intersectsPlane(Yu,Zu,r),new q(r[0],r[1])}class Hu extends El{}let Ku,Ju,Qu,tc;function ec(t,{width:e,height:r},n,i){if(i){if(i instanceof Uint8ClampedArray)i=new Uint8Array(i.buffer);else if(i.length!==e*r*n)throw new RangeError("mismatched image size")}else i=new Uint8Array(e*r*n);return t.width=e,t.height=r,t.data=i,t}function rc(t,e,r){const{width:n,height:i}=e;n===t.width&&i===t.height||(nc(t,e,{x:0,y:0},{x:0,y:0},{width:Math.min(t.width,n),height:Math.min(t.height,i)},r,null),t.width=n,t.height=i,t.data=e.data);}function nc(t,e,r,n,i,a,s,o){if(0===i.width||0===i.height)return e;if(i.width>t.width||i.height>t.height||r.x>t.width-i.width||r.y>t.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>e.width||i.height>e.height||n.x>e.width-i.width||n.y>e.height-i.height)throw new RangeError("out of range destination coordinates for image copy");const l=t.data,u=e.data,c=4===a&&o;for(let o=0;o<i.height;o++){const h=((r.y+o)*t.width+r.x)*a,p=((n.y+o)*e.width+n.x)*a;if(c)for(let t=0;t<i.width;t++){const e=h+t*a+3,r=p+t*a;u[r+0]=255,u[r+1]=255,u[r+2]=255,u[r+3]=l[e];}else if(s)for(let t=0;t<i.width;t++){const e=h+t*a,r=p+t*a,n=l[e+3],i=new Ie(l[e+0]/255*n,l[e+1]/255*n,l[e+2]/255*n,n).toRenderColor(s).toArray();u[r+0]=i[0],u[r+1]=i[1],u[r+2]=i[2],u[r+3]=i[3];}else for(let t=0;t<i.width*a;t++)u[p+t]=l[h+t];}return e}sa(Hu,"HeatmapBucket",{omit:["layers"]});class ic{constructor(t,e){ec(this,t,1,e);}resize(t){rc(this,new ic(t),1);}clone(){return new ic({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,e,r,n,i){nc(t,e,r,n,i,1,null);}}class ac{constructor(t,e){ec(this,t,4,e);}resize(t){rc(this,new ac(t),4);}replace(t,e){e?this.data.set(t):this.data=t instanceof Uint8ClampedArray?new Uint8Array(t.buffer):t;}clone(){return new ac({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,e,r,n,i,a,s){nc(t,e,r,n,i,4,a,s);}}class sc{constructor(t,e){this.width=t.width,this.height=t.height,this.data=e instanceof Uint8Array?new Float32Array(e.buffer):e;}}function oc(t){const e={},r=t.resolution||256,n=t.clips?t.clips.length:1,i=t.image||new ac({width:r,height:n}),a=(r,n,a)=>{e[t.evaluationKey]=a;const s=t.expression.evaluate(e);s&&(i.data[r+n+0]=Math.floor(255*s.r/s.a),i.data[r+n+1]=Math.floor(255*s.g/s.a),i.data[r+n+2]=Math.floor(255*s.b/s.a),i.data[r+n+3]=Math.floor(255*s.a));};if(t.clips)for(let e=0,i=0;e<n;++e,i+=4*r)for(let n=0,s=0;n<r;n++,s+=4){const o=n/(r-1),{start:l,end:u}=t.clips[e];a(i,s,l*(1-o)+u*o);}else for(let t=0,e=0;t<r;t++,e+=4)a(0,e,t/(r-1));return i}sa(ic,"AlphaImage"),sa(ac,"RGBAImage");const lc=ms([{name:"a_pos",components:2,type:"Int16"}],4),{members:uc}=lc;function cc(t,e,r=2){const n=e&&e.length,i=n?e[0]*r:t.length;let a=hc(t,0,i,r,!0);const s=[];if(!a||a.next===a.prev)return s;let o,l,u;if(n&&(a=function(t,e,r,n){const i=[];for(let r=0,a=e.length;r<a;r++){const s=hc(t,e[r]*n,r<a-1?e[r+1]*n:t.length,n,!1);s===s.next&&(s.steiner=!0),i.push(_c(s));}i.sort(xc);for(let t=0;t<i.length;t++)r=vc(i[t],r);return r}(t,e,a,r)),t.length>80*r){o=1/0,l=1/0;let e=-1/0,n=-1/0;for(let a=r;a<i;a+=r){const r=t[a],i=t[a+1];r<o&&(o=r),i<l&&(l=i),r>e&&(e=r),i>n&&(n=i);}u=Math.max(e-o,n-l),u=0!==u?32767/u:0;}return fc(a,s,r,o,l,u,0),s}function hc(t,e,r,n,i){let a;if(i===function(t,e,r,n){let i=0;for(let a=e,s=r-n;a<r;a+=n)i+=(t[s]-t[a])*(t[a+1]+t[s+1]),s=a;return i}(t,e,r,n)>0)for(let i=e;i<r;i+=n)a=Bc(i/n|0,t[i],t[i+1],a);else for(let i=r-n;i>=e;i-=n)a=Bc(i/n|0,t[i],t[i+1],a);return a&&Ic(a,a.next)&&(Vc(a),a=a.next),a}function pc(t,e){if(!t)return t;e||(e=t);let r,n=t;do{if(r=!1,n.steiner||!Ic(n,n.next)&&0!==Sc(n.prev,n,n.next))n=n.next;else {if(Vc(n),n=e=n.prev,n===n.next)break;r=!0;}}while(r||n!==e);return e}function fc(t,e,r,n,i,a,s){if(!t)return;!s&&a&&function(t,e,r,n){let i=t;do{0===i.z&&(i.z=wc(i.x,i.y,e,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){let e,r=1;do{let n,i=t;t=null;let a=null;for(e=0;i;){e++;let s=i,o=0;for(let t=0;t<r&&(o++,s=s.nextZ,s);t++);let l=r;for(;o>0||l>0&&s;)0!==o&&(0===l||!s||i.z<=s.z)?(n=i,i=i.nextZ,o--):(n=s,s=s.nextZ,l--),a?a.nextZ=n:t=n,n.prevZ=a,a=n;i=s;}a.nextZ=null,r*=2;}while(e>1)}(i);}(t,n,i,a);let o=t;for(;t.prev!==t.next;){const l=t.prev,u=t.next;if(a?mc(t,n,i,a):dc(t))e.push(l.i,t.i,u.i),Vc(t),t=u.next,o=u.next;else if((t=u)===o){s?1===s?fc(t=yc(pc(t),e),e,r,n,i,a,2):2===s&&gc(t,e,r,n,i,a):fc(pc(t),e,r,n,i,a,1);break}}}function dc(t){const e=t.prev,r=t,n=t.next;if(Sc(e,r,n)>=0)return !1;const i=e.x,a=r.x,s=n.x,o=e.y,l=r.y,u=n.y,c=i<a?i<s?i:s:a<s?a:s,h=o<l?o<u?o:u:l<u?l:u,p=i>a?i>s?i:s:a>s?a:s,f=o>l?o>u?o:u:l>u?l:u;let d=n.next;for(;d!==e;){if(d.x>=c&&d.x<=p&&d.y>=h&&d.y<=f&&Mc(i,o,a,l,s,u,d.x,d.y)&&Sc(d.prev,d,d.next)>=0)return !1;d=d.next;}return !0}function mc(t,e,r,n){const i=t.prev,a=t,s=t.next;if(Sc(i,a,s)>=0)return !1;const o=i.x,l=a.x,u=s.x,c=i.y,h=a.y,p=s.y,f=o<l?o<u?o:u:l<u?l:u,d=c<h?c<p?c:p:h<p?h:p,m=o>l?o>u?o:u:l>u?l:u,y=c>h?c>p?c:p:h>p?h:p,g=wc(f,d,e,r,n),x=wc(m,y,e,r,n);let v=t.prevZ,b=t.nextZ;for(;v&&v.z>=g&&b&&b.z<=x;){if(v.x>=f&&v.x<=m&&v.y>=d&&v.y<=y&&v!==i&&v!==s&&Mc(o,c,l,h,u,p,v.x,v.y)&&Sc(v.prev,v,v.next)>=0)return !1;if(v=v.prevZ,b.x>=f&&b.x<=m&&b.y>=d&&b.y<=y&&b!==i&&b!==s&&Mc(o,c,l,h,u,p,b.x,b.y)&&Sc(b.prev,b,b.next)>=0)return !1;b=b.nextZ;}for(;v&&v.z>=g;){if(v.x>=f&&v.x<=m&&v.y>=d&&v.y<=y&&v!==i&&v!==s&&Mc(o,c,l,h,u,p,v.x,v.y)&&Sc(v.prev,v,v.next)>=0)return !1;v=v.prevZ;}for(;b&&b.z<=x;){if(b.x>=f&&b.x<=m&&b.y>=d&&b.y<=y&&b!==i&&b!==s&&Mc(o,c,l,h,u,p,b.x,b.y)&&Sc(b.prev,b,b.next)>=0)return !1;b=b.nextZ;}return !0}function yc(t,e){let r=t;do{const n=r.prev,i=r.next.next;!Ic(n,i)&&zc(n,r,r.next,i)&&Tc(n,i)&&Tc(i,n)&&(e.push(n.i,r.i,i.i),Vc(r),Vc(r.next),r=t=i),r=r.next;}while(r!==t);return pc(r)}function gc(t,e,r,n,i,a){let s=t;do{let t=s.next.next;for(;t!==s.prev;){if(s.i!==t.i&&Ac(s,t)){let o=Ec(s,t);return s=pc(s,s.next),o=pc(o,o.next),fc(s,e,r,n,i,a,0),void fc(o,e,r,n,i,a,0)}t=t.next;}s=s.next;}while(s!==t)}function xc(t,e){return t.x-e.x}function vc(t,e){const r=function(t,e){let r=e;const n=t.x,i=t.y;let a,s=-1/0;do{if(i<=r.y&&i>=r.next.y&&r.next.y!==r.y){const t=r.x+(i-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(t<=n&&t>s&&(s=t,a=r.x<r.next.x?r:r.next,t===n))return a}r=r.next;}while(r!==e);if(!a)return null;const o=a,l=a.x,u=a.y;let c=1/0;r=a;do{if(n>=r.x&&r.x>=l&&n!==r.x&&Mc(i<u?n:s,i,l,u,i<u?s:n,i,r.x,r.y)){const e=Math.abs(i-r.y)/(n-r.x);Tc(r,t)&&(e<c||e===c&&(r.x>a.x||r.x===a.x&&bc(a,r)))&&(a=r,c=e);}r=r.next;}while(r!==o);return a}(t,e);if(!r)return e;const n=Ec(r,t);return pc(n,n.next),pc(r,r.next)}function bc(t,e){return Sc(t.prev,t,e.prev)<0&&Sc(e.next,t,t.next)<0}function wc(t,e,r,n,i){return (t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function _c(t){let e=t,r=t;do{(e.x<r.x||e.x===r.x&&e.y<r.y)&&(r=e),e=e.next;}while(e!==t);return r}function Mc(t,e,r,n,i,a,s,o){return (i-s)*(e-o)>=(t-s)*(a-o)&&(t-s)*(n-o)>=(r-s)*(e-o)&&(r-s)*(a-o)>=(i-s)*(n-o)}function Ac(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&zc(r,r.next,t,e))return !0;r=r.next;}while(r!==t);return !1}(t,e)&&(Tc(t,e)&&Tc(e,t)&&function(t,e){let r=t,n=!1;const i=(t.x+e.x)/2,a=(t.y+e.y)/2;do{r.y>a!=r.next.y>a&&r.next.y!==r.y&&i<(r.next.x-r.x)*(a-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next;}while(r!==t);return n}(t,e)&&(Sc(t.prev,t,e.prev)||Sc(t,e.prev,e))||Ic(t,e)&&Sc(t.prev,t,t.next)>0&&Sc(e.prev,e,e.next)>0)}function Sc(t,e,r){return (e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function Ic(t,e){return t.x===e.x&&t.y===e.y}function zc(t,e,r,n){const i=kc(Sc(t,e,r)),a=kc(Sc(t,e,n)),s=kc(Sc(r,n,t)),o=kc(Sc(r,n,e));return i!==a&&s!==o||!(0!==i||!Pc(t,r,e))||!(0!==a||!Pc(t,n,e))||!(0!==s||!Pc(r,t,n))||!(0!==o||!Pc(r,e,n))}function Pc(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function kc(t){return t>0?1:t<0?-1:0}function Tc(t,e){return Sc(t.prev,t,t.next)<0?Sc(t,e,t.next)>=0&&Sc(t,t.prev,e)>=0:Sc(t,e,t.prev)<0||Sc(t,t.next,e)<0}function Ec(t,e){const r=Cc(t.i,t.x,t.y),n=Cc(e.i,e.x,e.y),i=t.next,a=e.prev;return t.next=e,e.prev=t,r.next=i,i.prev=r,n.next=r,r.prev=n,a.next=n,n.prev=a,n}function Bc(t,e,r,n){const i=Cc(t,e,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 Vc(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ);}function Cc(t,e,r){return {i:t,x:e,y:r,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Rc(t,e){const r=t.length;if(r<=1)return [t];const n=[];let i,a;for(let e=0;e<r;e++){const r=mt(t[e]);0!==r&&(t[e].area=Math.abs(r),void 0===a&&(a=r<0),a===r<0?(i&&n.push(i),i=[t[e]]):i.push(t[e]));}if(i&&n.push(i),e>1)for(let t=0;t<n.length;t++)n[t].length<=e||(xr(n[t],e,1,n[t].length-1,Dc),n[t]=n[t].slice(0,e));return n}function Dc(t,e){return e.area-t.area}function Lc(t,e,r){const n=r.patternDependencies;let i=!1;for(const r of e){const e=r.paint.get(`${t}-pattern`);e.isConstant()||(i=!0);const a=e.constantOr(null);a&&(i=!0,n[a]=!0);}return i}function Fc(t,e,r,n,i){const a=i.patternDependencies;for(const s of e){const e=s.paint.get(`${t}-pattern`).value;if("constant"!==e.kind){let t=e.evaluate({zoom:n},r,{},i.availableImages);t=t&&t.name?t.name:t,a[t]=!0,r.patterns[s.id]=t;}}return r}class Oc{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new gs,this.indexArray=new Rs,this.indexArray2=new Ts,this.programConfigurations=new Oo(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new ho,this.segments2=new ho,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.projection=t.projection;}updateFootprints(t,e){}populate(t,e,r,n){this.hasPattern=Lc("fill",this.layers,e);const i=this.layers[0].layout.get("fill-sort-key"),a=[];for(const{feature:s,id:o,index:l,sourceLayerIndex:u}of t){const t=this.layers[0]._featureFilter.needGeometry,c=Pl(s,t);if(!this.layers[0]._featureFilter.filter(new Ba(this.zoom),c,r))continue;const h=i?i.evaluate(c,{},r,e.availableImages):void 0,p={id:o,properties:s.properties,type:s.type,sourceLayerIndex:u,index:l,geometry:t?c.geometry:zl(s,r,n),patterns:{},sortKey:h};a.push(p);}i&&a.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of a){const{geometry:i,index:a,sourceLayerIndex:s}=n;if(this.hasPattern){const t=Fc("fill",this.layers,n,this.zoom,e);this.patternFeatures.push(t);}else this.addFeature(n,i,a,r,{},e.availableImages,e.brightness);e.featureIndex.insert(t[a].feature,i,a,s,this.index);}}update(t,e,r,n,i){const a=0!==Object.keys(t).length;a&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,a?this.stateDependentLayers:this.layers,r,n,i);}addFeatures(t,e,r,n,i,a){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,r,n,a);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,uc),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy());}addFeature(t,e,r,n,i,a=[],s){for(const t of Rc(e,500)){let e=0;for(const r of t)e+=r.length;const r=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray),n=r.vertexLength,i=[],a=[];for(const e of t){if(0===e.length)continue;e!==t[0]&&a.push(i.length/2);const r=this.segments2.prepareSegment(e.length,this.layoutVertexArray,this.indexArray2),n=r.vertexLength;this.layoutVertexArray.emplaceBack(e[0].x,e[0].y),this.indexArray2.emplaceBack(n+e.length-1,n),i.push(e[0].x),i.push(e[0].y);for(let t=1;t<e.length;t++)this.layoutVertexArray.emplaceBack(e[t].x,e[t].y),this.indexArray2.emplaceBack(n+t-1,n+t),i.push(e[t].x),i.push(e[t].y);r.vertexLength+=e.length,r.primitiveLength+=e.length;}const s=cc(i,a);for(let t=0;t<s.length;t+=3)this.indexArray.emplaceBack(n+s[t],n+s[t+1],n+s[t+2]);r.vertexLength+=e,r.primitiveLength+=s.length/3;}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,i,a,n,s);}}let Uc,jc,Nc,qc;sa(Oc,"FillBucket",{omit:["layers","patternFeatures"]});class $c{constructor(t,e,r,n){if(this.triangleCount=e.length/3,this.min=new q(0,0),this.max=new q(0,0),this.xScale=0,this.yScale=0,this.cellsX=0,this.cellsY=0,this.cells=[],this.payload=[],0===this.triangleCount||0===t.length)return;const[i,a]=[t[0].clone(),t[0].clone()];for(let e=1;e<t.length;++e){const r=t[e];i.x=Math.min(i.x,r.x),i.y=Math.min(i.y,r.y),a.x=Math.max(a.x,r.x),a.y=Math.max(a.y,r.y);}if(n){const t=Math.ceil(Math.max(a.x-i.x,a.y-i.y)/n);r=Math.max(r,t);}if(0===r)return;this.min=i,this.max=a;const s=this.max.sub(this.min);s.x=Math.max(s.x,1),s.y=Math.max(s.y,1);const o=Math.max(s.x,s.y)/r;this.cellsX=Math.max(1,Math.ceil(s.x/o)),this.cellsY=Math.max(1,Math.ceil(s.y/o)),this.xScale=1/o,this.yScale=1/o;const l=[];for(let r=0;r<this.triangleCount;r++){const n=t[e[3*r+0]].sub(this.min),i=t[e[3*r+1]].sub(this.min),a=t[e[3*r+2]].sub(this.min),s=Gc(Math.floor(Math.min(n.x,i.x,a.x)),this.xScale,this.cellsX),u=Gc(Math.floor(Math.max(n.x,i.x,a.x)),this.xScale,this.cellsX),c=Gc(Math.floor(Math.min(n.y,i.y,a.y)),this.yScale,this.cellsY),h=Gc(Math.floor(Math.max(n.y,i.y,a.y)),this.yScale,this.cellsY),p=new q(0,0),f=new q(0,0),d=new q(0,0),m=new q(0,0);for(let t=c;t<=h;++t){p.y=f.y=t*o,d.y=m.y=(t+1)*o;for(let e=s;e<=u;++e)p.x=d.x=e*o,f.x=m.x=(e+1)*o,(Gl(n,i,a,p,f,m)||Gl(n,i,a,p,m,d))&&l.push({cellIdx:t*this.cellsX+e,triIdx:r});}}if(0===l.length)return;l.sort(((t,e)=>t.cellIdx-e.cellIdx||t.triIdx-e.triIdx));let u=0;for(;u<l.length;){const t=l[u].cellIdx,e={start:this.payload.length,len:0};for(;u<l.length&&l[u].cellIdx===t;)++e.len,this.payload.push(l[u++].triIdx);this.cells[t]=e;}}_lazyInitLookup(){this.lookup||(this.lookup=new Uint8Array(Math.ceil(this.triangleCount/8))),this.lookup.fill(0);}queryPoint(t,e){if(0===this.triangleCount||0===this.cells.length)return;if(t.x>this.max.x||this.min.x>t.x||t.y>this.max.y||this.min.y>t.y)return;const r=Gc(t.x-this.min.x,this.xScale,this.cellsX),n=Gc(t.y-this.min.y,this.yScale,this.cellsY),i=this.cells[n*this.cellsX+r];if(i){this._lazyInitLookup();for(let t=0;t<i.len;t++){const r=this.payload[i.start+t],n=Math.floor(r/8),a=1<<r%8;if(!(this.lookup[n]&a)&&(this.lookup[n]|=a,e.push(r),e.length===this.triangleCount))return}}}query(t,e,r){if(0===this.triangleCount||0===this.cells.length)return;if(t.x>this.max.x||this.min.x>e.x)return;if(t.y>this.max.y||this.min.y>e.y)return;this._lazyInitLookup();const n=Gc(t.x-this.min.x,this.xScale,this.cellsX),i=Gc(e.x-this.min.x,this.xScale,this.cellsX),a=Gc(t.y-this.min.y,this.yScale,this.cellsY),s=Gc(e.y-this.min.y,this.yScale,this.cellsY);for(let t=a;t<=s;t++)for(let e=n;e<=i;e++){const n=this.cells[t*this.cellsX+e];if(n)for(let t=0;t<n.len;t++){const e=this.payload[n.start+t],i=Math.floor(e/8),a=1<<e%8;if(!(this.lookup[i]&a)&&(this.lookup[i]|=a,r.push(e),r.length===this.triangleCount))return}}}}function Gc(t,e,r){return Math.max(0,Math.min(r-1,Math.floor(t*e)))}sa($c,"TriangleGridIndex");class Xc{constructor(t){this.zoom=t.zoom,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=t.index,this.hasPattern=!1,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.footprints=[];}updateFootprints(t,e){for(const r of this.footprints)e.push({footprint:r,id:t});}populate(t,e,r,n){const i=[];for(const{feature:e,id:a,index:s,sourceLayerIndex:o}of t){const t=this.layers[0]._featureFilter.needGeometry,l=Pl(e,t);if(!this.layers[0]._featureFilter.filter(new Ba(this.zoom),l,r))continue;const u={id:a,properties:e.properties,type:e.type,sourceLayerIndex:o,index:s,geometry:t?l.geometry:zl(e,r,n),patterns:{}};i.push(u);}for(const n of i){const{geometry:i,index:a,sourceLayerIndex:s}=n;this.addFeature(n,i,a,r,{},e.availableImages,e.brightness),e.featureIndex.insert(t[a].feature,i,a,s,this.index);}}isEmpty(){return 0===this.footprints.length}uploadPending(){return !1}upload(t){}update(t,e,r,n,i){}destroy(){}addFeature(t,e,r,n,i,a=[],s){for(const t of Rc(e,2)){const e=[],r=[],n=[],i=new q(1/0,1/0),a=new q(-1/0,-1/0);for(const s of t)if(0!==s.length){s!==t[0]&&n.push(r.length/2);for(let t=0;t<s.length;t++)r.push(s[t].x),r.push(s[t].y),e.push(s[t]),i.x=Math.min(i.x,s[t].x),i.y=Math.min(i.y,s[t].y),a.x=Math.max(a.x,s[t].x),a.y=Math.max(a.y,s[t].y);}const s=cc(r,n),o=new $c(e,s,8,256);this.footprints.push({vertices:e,indices:s,grid:o,min:i,max:a});}}}sa(Xc,"ClipBucket",{omit:["layers"]});const Yc=ms([{name:"a_pos_normal_ed",components:4,type:"Int16"}]),Zc=ms([{name:"a_pos_end",components:4,type:"Int16"},{name:"a_angular_offset_factor",components:1,type:"Int16"}]),Wc=ms([{name:"a_centroid_pos",components:2,type:"Uint16"}]),Hc=ms([{name:"a_join_normal_inside",components:3,type:"Int16"}]),Kc=ms([{name:"a_hidden_by_landmark",components:1,type:"Uint8"}]),Jc=ms([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]),{members:Qc}=Yc;var th,eh,rh,nh,ih,ah,sh,oh={};function lh(){if(eh)return th;eh=1;var t=N();function e(t,e,n,i,a){this.properties={},this.extent=n,this.type=0,this._pbf=t,this._geometry=-1,this._keys=i,this._values=a,t.readFields(r,this,e);}function r(t,e,r){1==t?e.id=r.readVarint():2==t?function(t,e){for(var r=t.readVarint()+t.pos;t.pos<r;){var n=e._keys[t.readVarint()],i=e._values[t.readVarint()];e.properties[n]=i;}}(r,e):3==t?e.type=r.readVarint():4==t&&(e._geometry=r.pos);}function n(t){for(var e,r,n=0,i=0,a=t.length,s=a-1;i<a;s=i++)n+=((r=t[s]).x-(e=t[i]).x)*(e.y+r.y);return n}return th=e,e.types=["Unknown","Point","LineString","Polygon"],e.prototype.loadGeometry=function(){var e=this._pbf;e.pos=this._geometry;for(var r,n=e.readVarint()+e.pos,i=1,a=0,s=0,o=0,l=[];e.pos<n;){if(a<=0){var u=e.readVarint();i=7&u,a=u>>3;}if(a--,1===i||2===i)s+=e.readSVarint(),o+=e.readSVarint(),1===i&&(r&&l.push(r),r=[]),r.push(new t(s,o));else {if(7!==i)throw new Error("unknown command "+i);r&&r.push(r[0].clone());}}return r&&l.push(r),l},e.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,r=1,n=0,i=0,a=0,s=1/0,o=-1/0,l=1/0,u=-1/0;t.pos<e;){if(n<=0){var c=t.readVarint();r=7&c,n=c>>3;}if(n--,1===r||2===r)(i+=t.readSVarint())<s&&(s=i),i>o&&(o=i),(a+=t.readSVarint())<l&&(l=a),a>u&&(u=a);else if(7!==r)throw new Error("unknown command "+r)}return [s,l,o,u]},e.prototype.toGeoJSON=function(t,r,i){var a,s,o=this.extent*Math.pow(2,i),l=this.extent*t,u=this.extent*r,c=this.loadGeometry(),h=e.types[this.type];function p(t){for(var e=0;e<t.length;e++){var r=t[e];t[e]=[360*(r.x+l)/o-180,360/Math.PI*Math.atan(Math.exp((180-360*(r.y+u)/o)*Math.PI/180))-90];}}switch(this.type){case 1:var f=[];for(a=0;a<c.length;a++)f[a]=c[a][0];p(c=f);break;case 2:for(a=0;a<c.length;a++)p(c[a]);break;case 3:for(c=function(t){var e=t.length;if(e<=1)return [t];for(var r,i,a=[],s=0;s<e;s++){var o=n(t[s]);0!==o&&(void 0===i&&(i=o<0),i===o<0?(r&&a.push(r),r=[t[s]]):r.push(t[s]));}return r&&a.push(r),a}(c),a=0;a<c.length;a++)for(s=0;s<c[a].length;s++)p(c[a][s]);}1===c.length?c=c[0]:h="Multi"+h;var d={type:"Feature",geometry:{type:h,coordinates:c},properties:this.properties};return "id"in this&&(d.id=this.id),d},th}function uh(){if(nh)return rh;nh=1;var t=lh();function e(t,e){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(r,this,e),this.length=this._features.length;}function r(t,e,r){15===t?e.version=r.readVarint():1===t?e.name=r.readString():5===t?e.extent=r.readVarint():2===t?e._features.push(r.pos):3===t?e._keys.push(r.readString()):4===t&&e._values.push(function(t){for(var e=null,r=t.readVarint()+t.pos;t.pos<r;){var n=t.readVarint()>>3;e=1===n?t.readString():2===n?t.readFloat():3===n?t.readDouble():4===n?t.readVarint64():5===n?t.readVarint():6===n?t.readSVarint():7===n?t.readBoolean():null;}return e}(r));}return rh=e,e.prototype.feature=function(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];var r=this._pbf.readVarint()+this._pbf.pos;return new t(this._pbf,r,this.extent,this._keys,this._values)},rh}function ch(){return sh||(sh=1,oh.VectorTile=function(){if(ah)return ih;ah=1;var t=uh();function e(e,r,n){if(3===e){var i=new t(n,n.readVarint()+n.pos);i.length&&(r[i.name]=i);}}return ih=function(t,r){this.layers=t.readFields(e,{},r);},ih}(),oh.VectorTileFeature=lh(),oh.VectorTileLayer=uh()),oh}var hh=ch();class ph extends q{constructor(t,e,r){super(t,e),this.z=r;}}class fh extends ph{constructor(t,e,r,n){super(t,e,r),this.w=n;}}function dh(t,e,r,n){const i=[],a=0===n?(t,e,r,n,i,a)=>{t.push(new q(a,r+(a-e)/(n-e)*(i-r)));}:(t,e,r,n,i,a)=>{t.push(new q(e+(a-r)/(i-r)*(n-e),a));};for(const s of t){const t=[];for(const i of s){if(i.length<=2)continue;const s=[];for(let t=0;t<i.length-1;t++){const o=i[t].x,l=i[t].y,u=i[t+1].x,c=i[t+1].y,h=0===n?o:l,p=0===n?u:c;h<e?p>e&&a(s,o,l,u,c,e):h>r?p<r&&a(s,o,l,u,c,r):s.push(i[t]),p<e&&h>=e&&a(s,o,l,u,c,e),p>r&&h<=r&&a(s,o,l,u,c,r);}let o=i[i.length-1];const l=0===n?o.x:o.y;l>=e&&l<=r&&s.push(o),s.length&&(o=s[s.length-1],s[0].x===o.x&&s[0].y===o.y||s.push(s[0]),t.push(s));}t.length&&i.push(t);}return i}function mh(t,e,r,n){const i="x"===r?"y":"x",a=(n-t[r])/(e[r]-t[r]);t[i]=t[i]+(e[i]-t[i])*a,t[r]=n,t.hasOwnProperty("z")&&(t.z=Pe(t.z,e.z,a)),t.hasOwnProperty("w")&&(t.w=Pe(t.w,e.w,a));}function yh(t,e,r,n){const i=r,a=n;for(const r of ["x","y"]){let n=t,s=e;n[r]>=s[r]&&(n=e,s=t),n[r]<i&&s[r]>i&&mh(n,s,r,i),n[r]<a&&s[r]>a&&mh(s,n,r,a);}}const gh=Number.MAX_SAFE_INTEGER;function xh(t,e,r,n){return t.order<e||t.order===gh||!(t.clipMask&r)||function(t,e){return 0!==e.length&&void 0===e.find((e=>e===t))}(n,t.clipScope)}function vh(t,e){return t.x-e.x||t.y-e.y}function bh(t,e){return 0===vh(t.min,e.min)&&0===vh(t.max,e.max)}function wh(t,e){return !(t.min.x>e.max.x||t.max.x<e.min.x||t.min.y>e.max.y||t.max.y<e.min.y)}function _h(t,e){if(t.length!==e.length)return !1;for(let r=0;r<t.length;r++)if(t[r].sourceId!==e[r].sourceId||!bh(t[r],e[r])||t[r].order!==e[r].order||t[r].clipMask!==e[r].clipMask||!$(t[r].clipScope,e[r].clipScope))return !1;return !0}function Mh(t,e,r){const n=1/Wr,i=1/(1<<r.canonical.z),a=(e.x*n+r.canonical.x)*i+r.wrap,s=(e.y*n+r.canonical.y)*i;return {min:new q((t.x*n+r.canonical.x)*i+r.wrap,(t.y*n+r.canonical.y)*i),max:new q(a,s)}}function Ah(t,e,r){const n=1<<r.canonical.z,i=((e.x-r.wrap)*n-r.canonical.x)*Wr,a=(e.y*n-r.canonical.y)*Wr;return {min:new q(((t.x-r.wrap)*n-r.canonical.x)*Wr,(t.y*n-r.canonical.y)*Wr),max:new q(i,a)}}function Sh(t,e,r,n,i,a,s){const o=t.indices,l=t.vertices,u=[];for(let c=n;c<n+i;c+=3){const n=e[r[c+0]+a],i=e[r[c+1]+a],h=e[r[c+2]+a],p=Math.min(n.x,i.x,h.x),f=Math.max(n.x,i.x,h.x),d=Math.min(n.y,i.y,h.y),m=Math.max(n.y,i.y,h.y);u.length=0,t.grid.query(new q(p,d),new q(f,m),u);for(let t=0;t<u.length;t++){const e=u[t];if(Gl(l[o[3*e+0]],l[o[3*e+1]],l[o[3*e+2]],n,i,h,s))return !0}}return !1}function Ih(t,e,r,n){if(!t||!r)return !1;let i=t.vertices;if(!e.canonical.equals(n.canonical)||e.wrap!==n.wrap){if(r.vertices.length<t.vertices.length)return Ih(r,n,t,e);const a=e.canonical,s=n.canonical,o=Math.pow(2,s.z-a.z);i=t.vertices.map((t=>new q((t.x+a.x*Wr)*o-s.x*Wr,(t.y+a.y*Wr)*o-s.y*Wr)));}return Sh(r,i,t.indices,0,t.indices.length,0,0)}function zh(t,e,r,n){const i=Math.pow(2,n.z-r.z);return new q((t+r.x*Wr)*i-n.x*Wr,(e+r.y*Wr)*i-n.y*Wr)}function Ph(t,e){const r=[];e.grid.queryPoint(t,r);const n=e.indices,i=e.vertices;for(let e=0;e<r.length;e++){const a=r[e];if(jl([i[n[3*a+0]],i[n[3*a+1]],i[n[3*a+2]]],t))return !0}return !1}const kh=[new q(0,0),new q(Wr,0),new q(Wr,Wr),new q(0,Wr)];function Th(t,e){const r=[];let n=[];if(!e||t.length<2)return [t];if(2===t.length)return ql(t[0],t[1],kh)?[t]:[];for(let e=0;e<t.length+2;e++){const i=t[e%t.length],a=t[(e+1)%t.length],s=ql(0===e?t[t.length-1]:t[(e-1)%t.length],i,kh),o=ql(i,a,kh),l=s||o;l&&n.push(i),l&&o||n.length>0&&(n.length>1&&r.push(n),n=[]);}return n.length>1&&r.push(n),r}const Eh=hh.VectorTileFeature.types,Bh=["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"],Vh=["fill-extrusion-flood-light-ground-radius"],Ch=Math.pow(2,13),Rh=Math.pow(2,15)-1,Dh=new q(0,1),Lh=2147483648;function Fh(t,e,r,n,i,a,s,o){t.emplaceBack((e<<1)+s,(r<<1)+a,(Math.floor(n*Ch)<<1)+i,Math.round(o));}function Oh(t,e,r){t.emplaceBack(e.x*Wr,e.y*Wr,r?1:0);}function Uh(t,e,r,n,i,a){t.emplaceBack(e.x,e.y,(r.x<<1)+n,(r.y<<1)+i,a);}function jh(t,e,r){const n=16384;t.emplaceBack(e.x,e.y,e.z,r[0]*n,r[1]*n,r[2]*n);}class Nh{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0;}}class qh{constructor(){this.centroidXY=new q(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 q(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new q(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0;}span(){return new q(this.max.x-this.min.x,this.max.y-this.min.y)}}class $h{constructor(){this.acc=new q(0,0),this.accCount=0,this.centroidDataIndex=0;}startRing(t,e){t.min.x===Number.MAX_VALUE&&(t.min.x=t.max.x=e.x,t.min.y=t.max.y=e.y);}appendEdge(t,e,r){this.accCount++,this.acc._add(e);let n=!!this.borders;e.x<t.min.x?(t.min.x=e.x,n=!0):e.x>t.max.x&&(t.max.x=e.x,n=!0),e.y<t.min.y?(t.min.y=e.y,n=!0):e.y>t.max.y&&(t.max.y=e.y,n=!0),((0===e.x||e.x===Wr)&&e.x===r.x)!=((0===e.y||e.y===Wr)&&e.y===r.y)&&this.processBorderOverlap(e,r),n&&this.checkBorderIntersection(e,r);}checkBorderIntersection(t,e){e.x<0!=t.x<0&&this.addBorderIntersection(0,Pe(e.y,t.y,(0-e.x)/(t.x-e.x))),e.x>Wr!=t.x>Wr&&this.addBorderIntersection(1,Pe(e.y,t.y,(Wr-e.x)/(t.x-e.x))),e.y<0!=t.y<0&&this.addBorderIntersection(2,Pe(e.x,t.x,(0-e.y)/(t.y-e.y))),e.y>Wr!=t.y>Wr&&this.addBorderIntersection(3,Pe(e.x,t.x,(Wr-e.y)/(t.y-e.y)));}addBorderIntersection(t,e){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[t];e<r[0]&&(r[0]=e),e>r[1]&&(r[1]=e);}processBorderOverlap(t,e){if(t.x===e.x){if(t.y===e.y)return;const r=0===t.x?0:1;this.addBorderIntersection(r,e.y),this.addBorderIntersection(r,t.y);}else {const r=0===t.y?2:3;this.addBorderIntersection(r,e.x),this.addBorderIntersection(r,t.x);}}centroid(){return 0===this.accCount?new q(0,0):new q(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(((t,e)=>t+ +(e[0]!==Number.MAX_VALUE)),0):0}}function Gh(t,e){const r=t.add(e)._unit(),n=Q(t.x*r.x+t.y*r.y,-1,1);var i,a,s;return s=Math.acos(n),Math.min(4,Math.max(-4,Math.tan(s)))/4*Rh*((i=t).x*(a=e).y-i.y*a.x<0?-1:1)}const Xh=[t=>t.x<0,t=>t.x>Wr,t=>t.y<0,t=>t.y>Wr];function Yh(t,e,r,n){const i=[4];if(0===n)return i;r._mult(n);const a=t.sub(r),s=e.sub(r),o=[t,e,a,s];for(let t=0;t<4;t++)for(const e of o)if(Xh[t](e)){i.push(t);break}return i}class Zh{constructor(t){this.vertexArray=new bs,this.indexArray=new Rs,this.programConfigurations=new Oo(t.layers,{zoom:t.zoom,lut:t.lut},(t=>Vh.includes(t))),this._segments=new ho,this.hiddenByLandmarkVertexArray=new Ws,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new ho;}getDefaultSegment(){return this.regionSegments[4]}hasData(){return 0!==this.vertexArray.length}addData(t,e,r,n=!1){const i=t.length;if(i>2){let a=Math.max(0,this._segments.get().length-1);const s=this._segments._prepareSegment(4*i,this.vertexArray.length,2*this._segmentToGroundQuads[a].length);let o;a!==this._segments.get().length-1&&(a++,this._segmentToGroundQuads[a]=[],this._segmentToRegionTriCounts[a]=[0,0,0,0,0]);{const e=t[0],r=t[1];o=Gh(e.sub(t[i-1])._perp()._unit(),r.sub(e)._perp()._unit());}for(let l=0;l<i;l++){const u=l===i-1?0:l+1,c=t[l],h=t[u],p=t[u===i-1?0:u+1],f=h.sub(c)._perp()._unit(),d=Gh(f,p.sub(h)._perp()._unit()),m=o,y=d;if(Qh(c,h,e)||n&&tp(c,e)&&tp(h,e)){o=d;continue}const g=s.vertexLength;Uh(this.vertexArray,c,h,1,1,m),Uh(this.vertexArray,c,h,1,0,m),Uh(this.vertexArray,c,h,0,1,y),Uh(this.vertexArray,c,h,0,0,y),s.vertexLength+=4;const x=Yh(c,h,f,r);for(const t of x)this._segmentToGroundQuads[a].push({id:g,region:t}),this._segmentToRegionTriCounts[a][t]+=2,s.primitiveLength+=2;o=d;}}}prepareBorderSegments(){if(!this.hasData())return;const t=this._segments.get(),e=t.length;for(let t=0;t<e;t++)this._segmentToGroundQuads[t].sort(((t,e)=>t.region-e.region));for(let r=0;r<e;r++){const e=this._segmentToGroundQuads[r],n=t[r],i=this._segmentToRegionTriCounts[r];i.reduce(((t,e)=>t+e),0);let a=0;for(let t=0;t<=4;t++){const e=i[t];if(0!==e){let r=this.regionSegments[t];r||(r=this.regionSegments[t]=new ho);const i={vertexOffset:n.vertexOffset,primitiveOffset:n.primitiveOffset+a,vertexLength:n.vertexLength,primitiveLength:e};r.get().push(i);}a+=e;}for(let t=0;t<e.length;t++){const r=e[t].id;this.indexArray.emplaceBack(r,r+1,r+3),this.indexArray.emplaceBack(r,r+3,r+2);}}this._segmentToGroundQuads=null,this._segmentToRegionTriCounts=null,this._segments.destroy(),this._segments=null;}addPaintPropertiesData(t,e,r,n,i,a){this.hasData()&&this.programConfigurations.populatePaintArrays(this.vertexArray.length,t,e,r,n,i,a);}upload(t){this.hasData()&&(this.vertexBuffer=t.createVertexBuffer(this.vertexArray,Zc.members),this.indexBuffer=t.createIndexBuffer(this.indexArray));}uploadPaintProperties(t){this.hasData()&&this.programConfigurations.upload(t);}update(t,e,r,n,i,a){this.hasData()&&this.programConfigurations.updatePaintArrays(t,e,r,n,i,a);}updateHiddenByLandmark(t){if(!this.hasData())return;const e=t.groundVertexCount+t.groundVertexArrayOffset;if(0===t.groundVertexCount)return;const r=t.flags&Lh?1:0;for(let n=t.groundVertexArrayOffset;n<e;++n)this.hiddenByLandmarkVertexArray.emplace(n,r);this._needsHiddenByLandmarkUpdate=!0;}uploadHiddenByLandmark(t){this.hasData()&&this._needsHiddenByLandmarkUpdate&&(!this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexArray.length>0?this.hiddenByLandmarkVertexBuffer=t.createVertexBuffer(this.hiddenByLandmarkVertexArray,Kc.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1);}destroy(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let t=0;t<=4;t++){const e=this.regionSegments[t];e&&e.destroy();}}}}class Wh{constructor(t){this.zoom=t.zoom,this.canonical=t.canonical,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=t.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=t.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=[],this.footprintIndices=new Rs,this.footprintVertices=new gs,this.footprintSegments=[],this.layoutVertexArray=new vs,this.centroidVertexArray=new so,this.wallVertexArray=new lo,this.indexArray=new Rs,this.programConfigurations=new Oo(t.layers,{zoom:t.zoom,lut:t.lut},(t=>Bh.includes(t))),this.segments=new ho,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.groundEffect=new Zh(t),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[];}updateFootprints(t,e){}populate(t,e,r,n){this.features=[],this.hasPattern=Lc("fill-extrusion",this.layers,e),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=xl(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:a,index:s,sourceLayerIndex:o}of t){const t=this.layers[0]._featureFilter.needGeometry,l=Pl(i,t);if(!this.layers[0]._featureFilter.filter(new Ba(this.zoom),l,r))continue;const u={id:a,sourceLayerIndex:o,index:s,geometry:t?l.geometry:zl(i,r,n),properties:i.properties,type:i.type,patterns:{}},c=this.layoutVertexArray.length,h="Polygon"===Eh[u.type];if(this.hasPattern)this.features.push(Fc("fill-extrusion",this.layers,u,this.zoom,e));else if(this.wallMode)for(const t of u.geometry)for(const i of Th(t,h))this.addFeature(u,[i],s,r,{},e.availableImages,n,e.brightness);else this.addFeature(u,u.geometry,s,r,{},e.availableImages,n,e.brightness);e.featureIndex.insert(i,u.geometry,s,o,this.index,c);}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0;}addFeatures(t,e,r,n,i,a){for(const t of this.features){const s="Polygon"===Eh[t.type],{geometry:o}=t;if(this.wallMode)for(const l of o)for(const o of Th(l,s))this.addFeature(t,[o],t.index,e,r,n,i,a);else this.addFeature(t,o,t.index,e,r,n,i,a);}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles();}update(t,e,r,n,i){const a=0!==Object.keys(t).length;if(a&&!this.stateDependentLayers.length)return;const s=a?this.stateDependentLayers:this.layers;this.programConfigurations.updatePaintArrays(t,e,s,r,n,i),this.groundEffect.update(t,e,s,r,n,i);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Qc),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.wallVertexBuffer=t.createVertexBuffer(this.wallVertexArray,Hc.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=t.createVertexBuffer(this.layoutVertexExtArray,Jc.members,!0)),this.groundEffect.upload(t)),this.groundEffect.uploadPaintProperties(t),this.programConfigurations.upload(t),this.uploaded=!0;}uploadCentroid(t){this.groundEffect.uploadHiddenByLandmark(t),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,Wc.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(t,e,r,n,i,a,s,o){const l=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(t,{})/this.tileToMeter,u=[new q(0,0),new q(Wr,Wr)],c=s.projection,h="globe"===c.name,p=this.wallMode||"Polygon"===Eh[t.type],f=new $h;f.centroidDataIndex=this.centroidData.length;const d=new qh,m=this.layers[0].paint.get("fill-extrusion-base").evaluate(t,{},n)<=0,y=this.layers[0].paint.get("fill-extrusion-height").evaluate(t,{},n);let g;if(d.height=y,d.vertexArrayOffset=this.layoutVertexArray.length,d.groundVertexArrayOffset=this.groundEffect.vertexArray.length,h&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new Is),this.wallMode){if(h)return void ft("Non zero fill-extrusion-line-width is not yet supported on globe.");if(1!==e.length)return;g=function(t){const e=t[0].x===t[t.length-1].x&&t[0].y===t[t.length-1].y,r=function(t){let e=0;const r=t.length;for(let n=0;n<r;n++)e+=(t[(n+1)%r].x-t[n].x)*(t[(n+1)%r].y+t[n].y);return e>=0}(t);r||(t=t.reverse());const n={geometry:[],joinNormals:[],indices:[]},i=[],a=[],s=[];let o=t.length;if(o<(e?3:2))return n;for(;o>=2&&t[o-1].equals(t[o-2]);)o--;let l,u,c,h,p,f=0;for(;f<o-1&&t[f].equals(t[f+1]);)f++;e&&(l=t[o-2],p=t[f].sub(l)._unit()._perp());for(let r=f;r<o;r++){if(c=r===o-1?e?t[f+1]:void 0:t[r+1],c&&t[r].equals(c))continue;p&&(h=p),l&&(u=l),l=t[r],p=c?c.sub(l)._unit()._perp():h,h=h||p;let n=h.add(p);0===n.x&&0===n.y||n._unit();const d=n.x*p.x+n.y*p.y,m=0!==d?1/d:1/0,y=h.x*p.y-h.y*p.x>0;let g="miter";const x=2;"miter"===g&&m>x&&(g="bevel"),"bevel"===g&&(m>100&&(g="flipbevel"),m<x&&(g="miter"));const v=(t,e,r,n)=>{const o=new q(t.x,t.y),l=new q(t.x,t.y);o.x+=e.x*n,o.y+=e.y*n,l.x-=e.x*Math.max(r,1),l.y-=e.y*Math.max(r,1),s.push(e),i.push(o),a.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 t=-Math.sqrt(m*m-1),e=y?t:0,r=y?0:t;u&&v(l,h,e,r),c&&v(l,p,e,r);}}n.geometry=[...i,...a.reverse(),i[0]],n.joinNormals=[...s,...s.reverse(),s[s.length-1]];const d=n.geometry.length-1;for(let t=0;t<d/2;t++)if(t+1<d/2){let e=t,r=t+1,i=d-1-t,a=d-2-t;e=0===e?d-1:e-1,r=0===r?d-1:r-1,i=0===i?d-1:i-1,a=0===a?d-1:a-1,n.indices.push(i),n.indices.push(r),n.indices.push(e),n.indices.push(i),n.indices.push(a),n.indices.push(r);}return n}(e[0]),e=[g.geometry];}const x=(t,e)=>t<(e.length-1)/2||t===e.length-1,v=this.wallMode?[e]:Rc(e,500);for(let t=v.length-1;t>=0;t--){const e=v[t];(0===e.length||(b=e[0]).every((t=>t.x<=0))||b.every((t=>t.x>=Wr))||b.every((t=>t.y<=0))||b.every((t=>t.y>=Wr)))&&v.splice(t,1);}var b;let w;if(h)w=ip(v,u,n);else {w=[];for(const t of v)w.push({polygon:t,bounds:u});}const _=p?this.edgeRadius:0,M=_>0&&this.zoom<17,A=(t,e)=>{if(0===t.length)return !1;const r=t[t.length-1];return e.x===r.x&&e.y===r.y};for(const{polygon:t,bounds:e}of w){let r=0,i=0;for(const e of t)p&&!e[0].equals(e[e.length-1])&&e.push(e[0]),i+=p?e.length-1:e.length;const a=this.segments.prepareSegment((p?5:4)*i,this.layoutVertexArray,this.indexArray);d.footprintSegIdx<0&&(d.footprintSegIdx=this.footprintSegments.length),d.polygonSegIdx<0&&(d.polygonSegIdx=this.polygonSegments.length);const s={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},o=new Nh;if(o.vertexOffset=this.footprintVertices.length,o.indexOffset=3*this.footprintIndices.length,o.ringIndices=[],p){const i=[],s=[];r=a.vertexLength;for(let r=0;r<t.length;r++){const u=t[r];u.length&&0!==r&&s.push(i.length/2);const p=[];let f,d;f=u[1].sub(u[0])._perp()._unit(),o.ringIndices.push(u.length-1);for(let t=1;t<u.length;t++){const e=u[t],r=u[t===u.length-1?1:t+1],s=e.clone();if(_){d=r.sub(e)._perp()._unit();const t=f.add(d)._unit(),n=_*Math.min(4,1/(f.x*t.x+f.y*t.y));s.x+=n*t.x,s.y+=n*t.y,s.x=Math.round(s.x),s.y=Math.round(s.y),f=d;}if(!m||0!==_&&!M||A(p,s)||p.push(s),Fh(this.layoutVertexArray,s.x,s.y,0,0,1,1,0),this.wallMode){const e=x(t,u);Oh(this.wallVertexArray,g.joinNormals[t],!e);}a.vertexLength++,this.footprintVertices.emplaceBack(e.x,e.y),i.push(e.x,e.y),h&&jh(this.layoutVertexExtArray,c.projectTilePoint(s.x,s.y,n),c.upVector(n,s.x,s.y));}m&&(0===_||M)&&(0!==p.length&&A(p,p[0])&&p.pop(),this.groundEffect.addData(p,e,l));}const u=this.wallMode?g.indices:cc(i,s);for(let t=0;t<u.length;t+=3)this.footprintIndices.emplaceBack(o.vertexOffset+u[t+0],o.vertexOffset+u[t+1],o.vertexOffset+u[t+2]),this.indexArray.emplaceBack(r+u[t],r+u[t+2],r+u[t+1]),a.primitiveLength++;o.indexCount+=u.length,o.vertexCount+=this.footprintVertices.length-o.vertexOffset;}for(let i=0;i<t.length;i++){const s=t[i];f.startRing(d,s[0]);let o=s.length>4&&ep(s[s.length-2],s[0],s[1]),u=_?Kh(s[s.length-2],s[0],s[1],_):0;const y=[];let v,b,w;b=s[1].sub(s[0])._perp()._unit();let M=!0;for(let t=1,i=0;t<s.length;t++){let l=s[t-1],p=s[t];const S=s[t===s.length-1?1:t+1];if(f.appendEdge(d,p,l),Qh(p,l,e)){_&&(b=S.sub(p)._perp()._unit(),M=!M);continue}const I=p.sub(l)._perp(),z=I.x/(Math.abs(I.x)+Math.abs(I.y)),P=I.y>0?1:0,k=l.dist(p);if(i+k>32768&&(i=0),_){w=S.sub(p)._perp()._unit();let t=Jh(l,p,S,Hh(b,w),_);isNaN(t)&&(t=0);const e=p.sub(l)._unit();l=l.add(e.mult(u))._round(),p=p.add(e.mult(-t))._round(),u=t,b=w,m&&this.zoom>=17&&(A(y,l)||y.push(l),A(y,p)||y.push(p));}const T=a.vertexLength,E=s.length>4&&ep(l,p,S);let B=rp(i,o,M);if(Fh(this.layoutVertexArray,l.x,l.y,z,P,0,0,B),Fh(this.layoutVertexArray,l.x,l.y,z,P,0,1,B),this.wallMode){const e=x(t-1,s),r=g.joinNormals[t-1];Oh(this.wallVertexArray,r,e),Oh(this.wallVertexArray,r,e);}if(i+=k,B=rp(i,E,!M),o=E,Fh(this.layoutVertexArray,p.x,p.y,z,P,0,0,B),Fh(this.layoutVertexArray,p.x,p.y,z,P,0,1,B),this.wallMode){const e=x(t,s),r=g.joinNormals[t];Oh(this.wallVertexArray,r,e),Oh(this.wallVertexArray,r,e);}if(a.vertexLength+=4,this.indexArray.emplaceBack(T+0,T+1,T+2),this.indexArray.emplaceBack(T+1,T+3,T+2),a.primitiveLength+=2,_){const n=r+(1===t?s.length-2:t-2),i=1===t?r:n+1;if(this.indexArray.emplaceBack(T+1,n,T+3),this.indexArray.emplaceBack(n,i,T+3),a.primitiveLength+=2,void 0===v&&(v=T),!Qh(S,s[t],e)){const e=t===s.length-1?v:a.vertexLength;this.indexArray.emplaceBack(T+2,T+3,e),this.indexArray.emplaceBack(T+3,e+1,e),this.indexArray.emplaceBack(T+3,i,e+1),a.primitiveLength+=3;}M=!M;}if(h){const t=this.layoutVertexExtArray,e=c.projectTilePoint(l.x,l.y,n),r=c.projectTilePoint(p.x,p.y,n),i=c.upVector(n,l.x,l.y),a=c.upVector(n,p.x,p.y);jh(t,e,i),jh(t,e,i),jh(t,r,a),jh(t,r,a);}}p&&(r+=s.length-1),m&&_&&this.zoom>=17&&(0!==y.length&&A(y,y[0])&&y.pop(),this.groundEffect.addData(y,e,l,_>0));}this.footprintSegments.push(o),s.triangleCount=this.indexArray.length-s.triangleArrayOffset,this.polygonSegments.push(s),++d.footprintSegLen,++d.polygonSegLen;}if(d.vertexCount=this.layoutVertexArray.length-d.vertexArrayOffset,d.groundVertexCount=this.groundEffect.vertexArray.length-d.groundVertexArrayOffset,0!==d.vertexCount){if(d.centroidXY=f.borders?Dh:this.encodeCentroid(f,d),this.centroidData.push(d),f.borders){this.featuresOnBorder.push(f);const t=this.featuresOnBorder.length-1;for(let e=0;e<f.borders.length;e++)f.borders[e][0]!==Number.MAX_VALUE&&this.borderFeatureIndices[e].push(t);}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,i,a,n,o),this.groundEffect.addPaintPropertiesData(t,r,i,a,n,o),this.maxHeight=Math.max(this.maxHeight,y);}}sortBorders(){for(let t=0;t<this.borderFeatureIndices.length;t++)this.borderFeatureIndices[t].sort(((e,r)=>this.featuresOnBorder[e].borders[t][0]-this.featuresOnBorder[r].borders[t][0]));}splitToSubtiles(){const t=[];for(let e=0;e<this.centroidData.length;e++){const r=this.centroidData[e],n=+(r.min.y+r.max.y>Wr),i=2*n+(+(r.min.x+r.max.x>Wr)^n);for(let n=0;n<r.polygonSegLen;n++){const a=r.polygonSegIdx+n;t.push({centroidIdx:e,subtile:i,polygonSegmentIdx:a,triangleSegmentIdx:this.polygonSegments[a].triangleSegIdx});}}const e=new Rs;t.sort(((t,e)=>t.triangleSegmentIdx===e.triangleSegmentIdx?t.subtile-e.subtile:t.triangleSegmentIdx-e.triangleSegmentIdx));let r=0,n=0,i=0;for(const e of t){if(e.triangleSegmentIdx!==r)break;i++;}const a=t.length;for(;n!==t.length;){r=t[n].triangleSegmentIdx;let s=0,o=n,l=n;for(let e=o;e<i&&t[e].subtile===s;e++)l++;for(;o!==i;){const n=t[o];s=n.subtile;const a=this.centroidData[n.centroidIdx].min.clone(),u=this.centroidData[n.centroidIdx].max.clone(),c={vertexOffset:this.segments.segments[r].vertexOffset,primitiveOffset:e.length,vertexLength:this.segments.segments[r].vertexLength,primitiveLength:0,sortKey:void 0,vaos:{}};for(let r=o;r<l;r++){const n=t[r],i=this.polygonSegments[n.polygonSegmentIdx],s=this.centroidData[n.centroidIdx].min,o=this.centroidData[n.centroidIdx].max,l=this.indexArray.uint16;for(let t=i.triangleArrayOffset;t<i.triangleArrayOffset+i.triangleCount;t++)e.emplaceBack(l[3*t],l[3*t+1],l[3*t+2]);c.primitiveLength+=i.triangleCount,a.x=Math.min(a.x,s.x),a.y=Math.min(a.y,s.y),u.x=Math.max(u.x,o.x),u.y=Math.max(u.y,o.y);}c.primitiveLength>0&&this.triangleSubSegments.push({segment:c,min:a,max:u}),o=l;for(let e=o;e<i&&t[e].subtile===t[o].subtile;e++)l++;}n=i;for(let e=n;e<a&&t[e].triangleSegmentIdx===t[n].triangleSegmentIdx;e++)i++;}e._trim(),this.indexArray=e;}getVisibleSegments(t,e,r){const n=new ho;if(this.wallMode){for(const t of this.triangleSubSegments)n.segments.push(t.segment);return n}let i=0,a=0;const s=1<<t.canonical.z;if(e){const r=e.getMinMaxForTile(t);r&&(i=r.min,a=r.max);}a+=this.maxHeight;const o=t.toUnwrapped();let l;const u=[o.canonical.x/s+o.wrap,o.canonical.y/s],c=[(o.canonical.x+1)/s+o.wrap,(o.canonical.y+1)/s],h=(t,e,r)=>[t[0]*(1-r[0])+e[0]*r[0],t[1]*(1-r[1])+e[1]*r[1]],p=[],f=[];for(const t of this.triangleSubSegments){p[0]=t.min.x/Wr,p[1]=t.min.y/Wr,f[0]=t.max.x/Wr,f[1]=t.max.y/Wr;const e=h(u,c,p),s=h(u,c,f);if(0===new gu([e[0],e[1],i],[s[0],s[1],a]).intersectsPrecise(r)){l&&(n.segments.push(l),l=void 0);continue}const o=t.segment;l&&l.vertexOffset!==o.vertexOffset&&(n.segments.push(l),l=void 0),l?(l.vertexLength+=o.vertexLength,l.primitiveLength+=o.primitiveLength):l={vertexOffset:o.vertexOffset,primitiveLength:o.primitiveLength,vertexLength:o.vertexLength,primitiveOffset:o.primitiveOffset,sortKey:void 0,vaos:{}};}return l&&n.segments.push(l),n}encodeCentroid(t,e){const r=t.centroid(),n=e.span(),i=Math.min(7,Math.round(n.x*this.tileToMeter/10)),a=Math.min(7,Math.round(n.y*this.tileToMeter/10));return new q(Q(r.x,1,Wr-1)<<3|i,Q(r.y,1,Wr-1)<<3|a)}encodeBorderCentroid(t){if(!t.borders)return new q(0,0);const e=t.borders,r=Number.MAX_VALUE;if(e[0][0]!==r||e[1][0]!==r){const t=e[0][0]!==r?0:1;return new q(6|(e[0][0]!==r?0:65528),(e[t][0]+e[t][1])/2<<3|6)}{const t=e[2][0]!==r?2:3;return new q((e[t][0]+e[t][1])/2<<3|6,6|(e[2][0]!==r?0:65528))}}showCentroid(t){const e=this.centroidData[t.centroidDataIndex];e.flags&=Lh,e.centroidXY.x=0,e.centroidXY.y=0,this.writeCentroidToBuffer(e);}writeCentroidToBuffer(t){this.groundEffect.updateHiddenByLandmark(t);const e=t.vertexArrayOffset,r=t.vertexCount+t.vertexArrayOffset,n=t.flags&Lh?Dh:t.centroidXY,i=this.centroidVertexArray.geta_centroid_pos0(e);if(this.centroidVertexArray.geta_centroid_pos1(e)!==n.y||i!==n.x){for(let t=e;t<r;++t)this.centroidVertexArray.emplace(t,n.x,n.y);this.needsCentroidUpdate=!0;}}createCentroidsBuffer(){this.centroidVertexArray.resize(this.layoutVertexArray.length),this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const t of this.centroidData)this.writeCentroidToBuffer(t);}updateReplacement(t,e,r){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const n=e.getReplacementRegionsForTile(t.toUnwrapped());if(_h(this.activeReplacements,n))return;if(this.activeReplacements=n,0===this.centroidVertexArray.length)this.createCentroidsBuffer();else for(const t of this.centroidData)t.flags&=2147483647;const i=[];for(const e of this.activeReplacements){if(e.order<r)continue;const n=Math.max(1,Math.pow(2,e.footprintTileId.canonical.z-t.canonical.z));for(const r of this.centroidData)if(!(r.flags&Lh||e.min.x>r.max.x||r.min.x>e.max.x||e.min.y>r.max.y||r.min.y>e.max.y))for(let a=0;a<r.footprintSegLen;a++){const s=this.footprintSegments[r.footprintSegIdx+a];if(i.length=0,ap(this.footprintVertices,s.vertexOffset,s.vertexCount,e.footprintTileId.canonical,t.canonical,i),Sh(e.footprint,i,this.footprintIndices.uint16,s.indexOffset,s.indexCount,-s.vertexOffset,-n)){r.flags|=Lh;break}}}for(const t of this.centroidData)this.writeCentroidToBuffer(t);this.borderDoneWithNeighborZ=[-1,-1,-1,-1];}footprintContainsPoint(t,e,r){let n=!1;for(let i=0;i<r.footprintSegLen;i++){const a=this.footprintSegments[r.footprintSegIdx+i];let s=0;for(const r of a.ringIndices){for(let i=s,o=r+s-1;i<r+s;o=i++){const r=this.footprintVertices.int16[2*(i+a.vertexOffset)+0],s=this.footprintVertices.int16[2*(i+a.vertexOffset)+1],l=this.footprintVertices.int16[2*(o+a.vertexOffset)+1];s>e!=l>e&&t<(this.footprintVertices.int16[2*(o+a.vertexOffset)+0]-r)*(e-s)/(l-s)+r&&(n=!n);}s=r;}}return n}getHeightAtTileCoord(t,e){let r=Number.NEGATIVE_INFINITY,n=!0;const i=4*(t+Wr)*Wr+(e+Wr);if(this.partLookup.hasOwnProperty(i)){const t=this.partLookup[i];return t?{height:t.height,hidden:!!(t.flags&Lh)}:void 0}for(const a of this.centroidData)t>a.max.x||a.min.x>t||e>a.max.y||a.min.y>e||this.footprintContainsPoint(t,e,a)&&a&&a.height>r&&(r=a.height,this.partLookup[i]=a,n=!!(a.flags&Lh));if(r!==Number.NEGATIVE_INFINITY)return {height:r,hidden:n};this.partLookup[i]=void 0;}}function Hh(t,e){const r=t.add(e)._unit();return t.x*r.x+t.y*r.y}function Kh(t,e,r,n){const i=e.sub(t)._perp()._unit(),a=r.sub(e)._perp()._unit();return Jh(t,e,r,Hh(i,a),n)}function Jh(t,e,r,n,i){const a=Math.sqrt(1-n*n);return Math.min(t.dist(e)/3,e.dist(r)/3,i*a/n)}function Qh(t,e,r){return t.x<r[0].x&&e.x<r[0].x||t.x>r[1].x&&e.x>r[1].x||t.y<r[0].y&&e.y<r[0].y||t.y>r[1].y&&e.y>r[1].y}function tp(t,e){return t.x<e[0].x||t.x>e[1].x||t.y<e[0].y||t.y>e[1].y}function ep(t,e,r){if(t.x<0||t.x>=Wr||e.x<0||e.x>=Wr||r.x<0||r.x>=Wr)return !1;const n=r.sub(e),i=n.perp(),a=t.sub(e);return (n.x*a.x+n.y*a.y)/Math.sqrt((n.x*n.x+n.y*n.y)*(a.x*a.x+a.y*a.y))>-.866&&i.x*a.x+i.y*a.y<0}function rp(t,e,r){const n=e?2|t:-3&t;return r?1|n:-2&n}function np(){const t=Math.PI/32,e=Math.tan(t),r=el;return r*Math.sqrt(1+2*e*e)-r}function ip(t,e,r){const n=1<<r.z,i=hl(r.x/n),a=hl((r.x+1)/n),s=pl(r.y/n),o=pl((r.y+1)/n);return function(t,e,r,n,i=0,a){const s=[];if(!t.length||!r||!n)return s;const o=(t,e)=>{for(const r of t)s.push({polygon:r,bounds:e});},l=Math.ceil(Math.log2(r)),u=Math.ceil(Math.log2(n)),c=l-u,h=[];for(let t=0;t<Math.abs(c);t++)h.push(c>0?0:1);for(let t=0;t<Math.min(l,u);t++)h.push(0),h.push(1);let p=t;if(p=dh(p,e[0].y-i,e[1].y+i,1),p=dh(p,e[0].x-i,e[1].x+i,0),!p.length)return s;const f=[];for(h.length?f.push({polygons:p,bounds:e,depth:0}):o(p,e);f.length;){const t=f.pop(),e=t.depth,r=h[e],n=t.bounds[0],s=t.bounds[1],l=0===r?n.x:n.y,u=0===r?s.x:s.y,c=a?a(r,l,u):.5*(l+u),p=dh(t.polygons,l-i,c+i,r),d=dh(t.polygons,c-i,u+i,r);if(p.length){const t=[n,new q(0===r?c:s.x,1===r?c:s.y)];h.length>e+1?f.push({polygons:p,bounds:t,depth:e+1}):o(p,t);}if(d.length){const t=[new q(0===r?c:n.x,1===r?c:n.y),s];h.length>e+1?f.push({polygons:d,bounds:t,depth:e+1}):o(d,t);}}return s}(t,e,Math.ceil((a-i)/11.25),Math.ceil((s-o)/11.25),1,((t,e,i)=>{if(0===t)return .5*(e+i);{const t=pl((r.y+e/Wr)/n);return (ul(.5*(pl((r.y+i/Wr)/n)+t))*n-r.y)*Wr}}))}function ap(t,e,r,n,i,a){const s=Math.pow(2,n.z-i.z);for(let o=0;o<r;o++){let r=t.int16[2*(o+e)+0],l=t.int16[2*(o+e)+1];r=(r+i.x*Wr)*s-n.x*Wr,l=(l+i.y*Wr)*s-n.y*Wr,a.push(new q(r,l));}}let sp,op;function lp(t,e){return t.x*e.x+t.y*e.y}function up(t,e){if(1===t.length){let r=0;const n=e[r++];let i;for(;!i||n.equals(i);)if(i=e[r++],!i)return 1/0;for(;r<e.length;r++){const a=e[r],s=t[0],o=i.sub(n),l=a.sub(n),u=s.sub(n),c=lp(o,o),h=lp(o,l),p=lp(l,l),f=lp(u,o),d=lp(u,l),m=c*p-h*h,y=(p*f-h*d)/m,g=(c*d-h*f)/m,x=n.z*(1-y-g)+i.z*y+a.z*g;if(isFinite(x))return x}return 1/0}{let t=1/0;for(const r of e)t=Math.min(t,r.z);return t}}function cp(t,e,r,n,i,a,s,o){const l=s*i.getElevationAt(t,e,!0,!0),u=0!==a[0],c=u?0===a[1]?s*(a[0]/7-450):s*function(t,e,r){const n=Math.floor(e[0]/8),i=Math.floor(e[1]/8),a=10*(e[0]-8*n),s=10*(e[1]-8*i),o=t.getElevationAt(n,i,!0,!0),l=t.getMeterToDEM(r),u=Math.floor(.5*(a*l-1)),c=Math.floor(.5*(s*l-1)),h=t.tileCoordToPixel(n,i),p=2*u+1,f=2*c+1,d=function(t,e,r,n,i){return [t.getElevationAtPixel(e,r,!0),t.getElevationAtPixel(e+i,r,!0),t.getElevationAtPixel(e,r+i,!0),t.getElevationAtPixel(e+n,r+i,!0)]}(t,h.x-u,h.y-c,p,f),m=Math.abs(d[0]-d[1]),y=Math.abs(d[2]-d[3]),g=Math.abs(d[0]-d[2])+Math.abs(d[1]-d[3]),x=Math.min(.25,.5*l*(m+y)/p),v=Math.min(.25,.5*l*g/f);return o+Math.max(x*a,v*s)}(i,a,o):l;return {base:l+(0===r?-1:r),top:u?Math.max(c+n,l+r+2):l+n}}sa(Wh,"FillExtrusionBucket",{omit:["layers","features"]}),sa(qh,"PartData"),sa(Nh,"FootprintSegment"),sa($h,"BorderCentroidData"),sa(Zh,"GroundEffect");const hp=ms([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_linesofar",components:1,type:"Float32"}],4),pp=ms([{name:"a_z_offset",components:1,type:"Float32"}],4),{members:fp}=hp,dp=ms([{name:"a_packed",components:4,type:"Float32"}]),{members:mp}=dp,yp=ms([{name:"a_pattern_data",components:3,type:"Float32"}]),{members:gp}=yp;class xp{constructor(t,e){this.width=t,this.height=e,this.nextRow=0,this.image=new ic({width:t,height:e}),this.positions={},this.uploaded=!1;}getDash(t,e){const r=this.getKey(t,e);return this.positions[r]}trim(){const t=this.width,e=this.height=st(this.nextRow);this.image.resize({width:t,height:e});}getKey(t,e){return t.join(",")+e}getDashRanges(t,e,r){const n=[];let i=t.length%2==1?-t[t.length-1]*r:0,a=t[0]*r,s=!0;n.push({left:i,right:a,isDash:s,zeroLength:0===t[0]});let o=t[0];for(let e=1;e<t.length;e++){s=!s;const l=t[e];i=o*r,o+=l,a=o*r,n.push({left:i,right:a,isDash:s,zeroLength:0===l});}return n}addRoundDash(t,e,r){const n=e/2;for(let e=-r;e<=r;e++){const i=this.width*(this.nextRow+r+e);let a=0,s=t[a];for(let o=0;o<this.width;o++){o/s.right>1&&(s=t[++a]);const l=Math.abs(o-s.left),u=Math.abs(o-s.right),c=Math.min(l,u);let h;const p=e/r*(n+1);if(s.isDash){const t=n-Math.abs(p);h=Math.sqrt(c*c+t*t);}else h=n-Math.sqrt(c*c+p*p);this.image.data[i+o]=Math.max(0,Math.min(255,h+128));}}}addRegularDash(t,e){for(let e=t.length-1;e>=0;--e){const r=t[e],n=t[e+1];r.zeroLength?t.splice(e,1):n&&n.isDash===r.isDash&&(n.left=r.left,t.splice(e,1));}const r=t[0],n=t[t.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 a=0,s=t[a];for(let r=0;r<this.width;r++){r/s.right>1&&(s=t[++a]);const n=Math.abs(r-s.left),o=Math.abs(r-s.right),l=Math.min(n,o);this.image.data[i+r]=Math.max(0,Math.min(255,(s.isDash?l:-l)+e+128));}}addDash(t,e){const r=this.getKey(t,e);if(this.positions[r])return this.positions[r];const n="round"===e,i=n?7:0,a=2*i+1;if(this.nextRow+a>this.height)return ft("LineAtlas out of space"),null;0===t.length&&t.push(1);let s=0;for(let e=0;e<t.length;e++)t[e]<0&&(ft("Negative value is found in line dasharray, replacing values with 0"),t[e]=0),s+=t[e];if(0!==s){const r=this.width/s,a=this.getDashRanges(t,this.width,r);n?this.addRoundDash(a,r,i):this.addRegularDash(a,"square"===e?.5*r:0);}const o=this.nextRow+i;this.nextRow+=a;const l={tl:[o,i],br:[s,0]};return this.positions[r]=l,l}}sa(xp,"LineAtlas");const vp=hh.VectorTileFeature.types,bp=Math.cos(Math.PI/180*37.5),wp=Math.cos(Math.PI/180*5);class _p{constructor(t){this.evaluationGlobals={zoom:0,lineProgress:void 0},this.zoom=t.zoom,this.evaluationGlobals.zoom=this.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=t.index,this.projection=t.projection,this.hasPattern=!1,this.hasZOffset=!1,this.hasCrossSlope=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={};})),this.layoutVertexArray=new ws,this.layoutVertexArray2=new _s,this.patternVertexArray=new Ms,this.indexArray=new Rs,this.programConfigurations=new Oo(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new ho,this.maxLineLength=0,this.zOffsetVertexArray=new Fs,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.tessellationStep=t.tessellationStep?t.tessellationStep:Wr/64;}updateFootprints(t,e){}populate(t,e,r,n){this.hasPattern=Lc("line",this.layers,e);const i=this.layers[0].layout.get("line-sort-key");this.hasZOffset=!this.layers[0].isDraped();const a=this.layers[0].layout.get("line-elevation-reference");this.hasZOffset&&"none"===a&&ft(`line-elevation-reference: ground is used for the layer ${this.layerIds[0]} because non-zero line-z-offset value was found.`);const s=this.layers[0].layout.get("line-cross-slope");this.hasCrossSlope=this.hasZOffset&&void 0!==s;const o=[];for(const{feature:e,id:a,index:s,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,u=Pl(e,t);if(!this.layers[0]._featureFilter.filter(new Ba(this.zoom),u,r))continue;const c=i?i.evaluate(u,{},r):void 0,h={id:a,properties:e.properties,type:e.type,sourceLayerIndex:l,index:s,geometry:t?u.geometry:zl(e,r,n),patterns:{},sortKey:c};o.push(h);}i&&o.sort(((t,e)=>t.sortKey-e.sortKey));const{lineAtlas:l,featureIndex:u}=e,c=this.addConstantDashes(l);for(const n of o){const{geometry:i,index:a,sourceLayerIndex:s}=n;if(c&&this.addFeatureDashes(n,l),this.hasPattern){const t=Fc("line",this.layers,n,this.zoom,e);this.patternFeatures.push(t);}else this.addFeature(n,i,a,r,l.positions,e.availableImages,e.brightness);u.insert(t[a].feature,i,a,s,this.index);}}addConstantDashes(t){let e=!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)e=!0;else {const e=i.value,r=n.value;if(!r)continue;t.addDash(r,e);}}return e}addFeatureDashes(t,e){const r=this.zoom;for(const n of this.layers){const i=n.paint.get("line-dasharray").value,a=n.layout.get("line-cap").value;if("constant"===i.kind&&"constant"===a.kind)continue;let s,o;if("constant"===i.kind){if(s=i.value,!s)continue}else s=i.evaluate({zoom:r},t);o="constant"===a.kind?a.value:a.evaluate({zoom:r},t),e.addDash(s,o),t.patterns[n.id]=e.getKey(s,o);}}update(t,e,r,n,i){const a=0!==Object.keys(t).length;a&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,a?this.stateDependentLayers:this.layers,r,n,i);}addFeatures(t,e,r,n,i,a){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,r,n,a);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,mp)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=t.createVertexBuffer(this.patternVertexArray,gp)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,pp.members,!0)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,fp),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy());}lineFeatureClips(t){if(t.properties&&t.properties.hasOwnProperty("mapbox_clip_start")&&t.properties.hasOwnProperty("mapbox_clip_end"))return {start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,r,n,i,a,s){const o=this.layers[0].layout,l=o.get("line-join").evaluate(t,{}),u=o.get("line-cap").evaluate(t,{}),c=o.get("line-miter-limit"),h=o.get("line-round-limit");this.lineClips=this.lineFeatureClips(t),this.lineFeature=t,this.zOffsetValue=o.get("line-z-offset").value;for(const r of e)this.addLine(r,t,n,l,u,c,h);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,i,a,n,s);}addLine(t,e,r,n,i,a,s){this.distance=0,this.prevDistance=0,this.scaledDistance=0,this.totalDistance=0,this.totalFeatureLength=0,this.lineSoFar=0,this.currentVertex=void 0;const o="none"===n;if(this.patternJoinNone=this.hasPattern&&o,this.segmentStart=0,this.segmentStartf32=0,this.segmentPoints=[],this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e<t.length-1;e++)this.totalDistance+=t[e].dist(t[e+1]);this.totalFeatureLength=this.totalDistance/(this.lineClips.end-this.lineClips.start),this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance);}const l="Polygon"===vp[e.type];let u=t.length;for(;u>=2&&t[u-1].equals(t[u-2]);)u--;let c=0;for(;c<u-1&&t[c].equals(t[c+1]);)c++;if(u<(l?3:2))return;"bevel"===n&&(a=1.05);const h=this.segments.prepareSegment(10*u,this.layoutVertexArray,this.indexArray);let p,f,d,m,y,g;this.e1=this.e2=-1,l&&(p=t[u-2],y=t[c].sub(p)._unit()._perp());for(let e=c;e<u;e++){if(d=e===u-1?l?t[c+1]:void 0:t[e+1],d&&t[e].equals(d))continue;y&&(m=y),p&&(f=p),p=t[e],g=this.hasZOffset?this.evaluateElevationValue(f?f.dist(p):0):null,y=d?d.sub(p)._unit()._perp():m,m=m||y;const r=f&&d;let x=r?n:l||o?"butt":i;const v=m.x*y.x+m.y*y.y;if(o){const t=function(t){if(t.patternJoinNone){const e=t.segmentPoints.length/2,r=t.lineSoFar-t.segmentStart;for(let n=0;n<e;++n){const e=t.segmentPoints[2*n+1],i=Math.round(t.segmentPoints[2*n])+.5+.25*e;t.patternVertexArray.emplaceBack(i,r,t.segmentStart),t.patternVertexArray.emplaceBack(i,r,t.segmentStart);}t.segmentPoints.length=0;}t.e1=t.e2=-1;};if(r&&v<wp){this.updateDistance(f,p),this.addCurrentVertex(p,m,1,1,h,g),t(this),this.addCurrentVertex(p,y,-1,-1,h,g);continue}if(f){if(!d){this.updateDistance(f,p),this.addCurrentVertex(p,m,1,1,h,g),t(this);continue}x="miter";}}let b=m.add(y);0===b.x&&0===b.y||b._unit();const w=b.x*y.x+b.y*y.y,_=0!==w?1/w:1/0,M=2*Math.sqrt(2-2*w),A=w<bp&&f&&d,S=m.x*y.y-m.y*y.x>0,I=this.overscaling<=16?15*Wr/(512*this.overscaling):0;if(r&&"round"===x)if(_<s)x="miter";else if(_<=2){const t=Mp(p,-10,Wr+10);x=this.hasZOffset&&(t||this.hasCrossSlope)?"miter":"fakeround";}if("miter"===x&&_>a&&(x="bevel"),"bevel"===x&&(_>2&&(x="flipbevel"),_<a&&(x="miter")),f&&!("miter"===x&&A)&&this.updateDistance(f,p),"miter"===x)if(A){const t=p.dist(f);if(t>2*I){const e=p.sub(p.sub(f)._mult(I/t)._round());this.updateDistance(f,e),this.addCurrentVertex(e,m,0,0,h,g),f=e;}this.updateDistance(f,p),b._mult(_),this.addCurrentVertex(p,b,0,0,h,g);const e=p.dist(d);if(e>2*I){const t=p.add(d.sub(p)._mult(I/e)._round());this.updateDistance(p,t),this.addCurrentVertex(t,y,0,0,h,g),p=t;}}else b._mult(_),this.addCurrentVertex(p,b,0,0,h,g);else if("flipbevel"===x){if(_>100)b=y.mult(-1);else {const t=_*m.add(y).mag()/m.sub(y).mag();b._perp()._mult(t*(S?-1:1));}this.addCurrentVertex(p,b,0,0,h,g),this.addCurrentVertex(p,b.mult(-1),0,0,h,g);}else if("bevel"===x||"fakeround"===x){null!=g&&f&&this.addCurrentVertex(p,m,-1,-1,h,g);const t=p.dist(f)<=2*I&&"bevel"!==x,e=b.mult(S?1:-1);e._mult(_);const r=y.mult(S?-1:1),n=m.mult(S?-1:1),i=this.evaluateElevationValue(this.distance);if(null==g&&(this.addHalfVertex(p,e.x,e.y,!1,!S,0,h,i),t||this.addHalfVertex(p,e.x+2*n.x,e.y+2*n.y,!1,S,0,h,i)),"fakeround"===x){const t=Math.round(180*M/Math.PI/20);this.addHalfVertex(p,n.x,n.y,!1,S,0,h,i);for(let e=0;e<t;e++){let a=e/t;if(.5!==a){const t=a-.5;a+=a*t*(a-1)*((1.0904+v*(v*(3.55645-1.43519*v)-3.2452))*t*t+(.848013+v*(.215638*v-1.06021)));}const s=r.sub(n)._mult(a)._add(n)._unit();this.addHalfVertex(p,s.x,s.y,!1,S,0,h,i);}this.addHalfVertex(p,r.x,r.y,!1,S,0,h,i);}t||null!=g||this.addHalfVertex(p,e.x+2*r.x,e.y+2*r.y,!1,S,0,h,i),null!=g&&d&&this.addCurrentVertex(p,y,1,1,h,g);}else "butt"===x?this.addCurrentVertex(p,b,0,0,h,g):"square"===x?(f||this.addCurrentVertex(p,b,-1,-1,h,g),this.addCurrentVertex(p,b,0,0,h,g),f&&this.addCurrentVertex(p,b,1,1,h,g)):"round"===x&&(f&&(this.addCurrentVertex(p,m,0,0,h,g),this.addCurrentVertex(p,m,1,1,h,g,!0)),d&&(this.addCurrentVertex(p,y,-1,-1,h,g,!0),this.addCurrentVertex(p,y,0,0,h,g)));}}addVerticesTo(t,e,r,n,i,a,s,o,l,u){const c=(e.w-t.w)/this.tessellationStep|0;let h=0;const p=this.scaledDistance;if(c>1){this.lineSoFar=t.w;const p=(e.x-t.x)/c,f=(e.y-t.y)/c,d=(e.z-t.z)/c,m=(e.w-t.w)/c;for(let e=1;e<c;++e){t.x+=p,t.y+=f,t.z+=d,this.lineSoFar+=m,h+=m;const e=this.evaluateElevationValue(this.prevDistance+h);this.scaledDistance=(this.prevDistance+h)/this.totalDistance,this.addHalfVertex(t,r,n,u,!1,s,l,e),this.addHalfVertex(t,i,a,u,!0,-o,l,e);}}this.lineSoFar=e.w,this.scaledDistance=p;const f=this.evaluateElevationValue(this.distance);this.addHalfVertex(e,r,n,u,!1,s,l,f),this.addHalfVertex(e,i,a,u,!0,-o,l,f);}evaluateElevationValue(t){return this.hasZOffset?"constant"===this.zOffsetValue.kind?this.zOffsetValue.value:(this.evaluationGlobals.lineProgress=0,this.lineClips?this.evaluationGlobals.lineProgress=Math.min(1,(this.totalFeatureLength*this.lineClips.start+t)/this.totalFeatureLength):ft(`line-z-offset evaluation for ${this.layerIds[0]} requires enabling 'lineMetrics' for the source.`),this.zOffsetValue.evaluate(this.evaluationGlobals,this.lineFeature)||0):void 0}addCurrentVertex(t,e,r,n,i,a,s=!1){const o=e.x+e.y*r,l=e.y-e.x*r,u=e.y*n-e.x,c=-e.y-e.x*n;if(null!=a){const e=-10,h=Wr+10,p=a,f=new fh(t.x,t.y,p,this.lineSoFar),d=Mp(t,e,h),m=this.lineSoFar,y=this.distance;if(this.currentVertex)if(d){const a=this.currentVertexIsOutside,d=this.currentVertex,m=new fh(t.x,t.y,p,this.lineSoFar);if(yh(d,m,e,h),!Mp(m,e,h)){if(a){this.e1=this.e2=-1,this.distance-=d.dist(f),this.lineSoFar=d.w;const t=this.evaluateElevationValue(d.w-this.totalFeatureLength*(this.lineClips?this.lineClips.start:0));this.addHalfVertex(d,o,l,s,!1,r,i,t),this.addHalfVertex(d,u,c,s,!0,-n,i,t),this.prevDistance=this.distance;}this.distance=this.prevDistance+d.dist(m),this.scaledDistance=this.distance/this.totalDistance,this.addVerticesTo(d,m,o,l,u,c,r,n,i,s),this.distance=y,this.scaledDistance=this.distance/this.totalDistance;}}else {const t=this.currentVertex;if(this.currentVertexIsOutside){yh(t,f,e,h),this.e1=this.e2=-1,this.distance-=t.dist(f),this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=t.w;const a=this.evaluateElevationValue(t.w-this.totalFeatureLength*(this.lineClips?this.lineClips.start:0));this.addHalfVertex(t,o,l,s,!1,r,i,a),this.addHalfVertex(t,u,c,s,!0,-n,i,a),this.prevDistance=this.distance,this.distance=y,this.scaledDistance=this.distance/this.totalDistance;}this.addVerticesTo(t,f,o,l,u,c,r,n,i,s);}else d||(this.addHalfVertex(t,o,l,s,!1,r,i,a),this.addHalfVertex(t,u,c,s,!0,-n,i,a));this.currentVertex=f,this.currentVertexIsOutside=d,this.lineSoFar=m;}else this.addHalfVertex(t,o,l,s,!1,r,i,a),this.addHalfVertex(t,u,c,s,!0,-n,i,a);}addHalfVertex({x:t,y:e},r,n,i,a,s,o,l){this.patternJoinNone&&(0===this.segmentPoints.length&&(this.segmentStart=this.lineSoFar,this.segmentStartf32=Math.fround(this.lineSoFar)),a||this.segmentPoints.push(this.lineSoFar-this.segmentStart,s)),this.layoutVertexArray.emplaceBack((t<<1)+(i?1:0),(e<<1)+(a?1:0),Math.round(63*r)+128,Math.round(63*n)+128,1+(0===s?0:s<0?-1:1),0,this.lineSoFar-this.segmentStartf32),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineClips.start,this.lineClips.end);const u=o.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,u),o.primitiveLength++),a?this.e2=u:this.e1=u,null!=l&&this.zOffsetVertexArray.emplaceBack(l);}updateScaledDistance(){this.lineClips?(this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=this.totalFeatureLength*this.lineClips.start+this.distance):this.lineSoFar=this.distance;}updateDistance(t,e){this.prevDistance=this.distance,this.distance+=t.dist(e),this.updateScaledDistance();}}function Mp(t,e,r){return t.x<e||t.x>r||t.y<e||t.y>r}let Ap,Sp;function Ip(t,e,r){return e*(Wr/(t.tileSize*Math.pow(2,r-t.tileID.overscaledZ)))}sa(_p,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const zp=(t,e,r)=>(1-r)*t+r*e;function Pp(t,e){return 1/Ip(t,1,e.tileZoom)}function kp(t,e,r,n){return t.translatePosMatrix(n||e.tileID.projMatrix,e,r.paint.get("line-translate"),r.paint.get("line-translate-anchor"))}const Tp=t=>{const e=[];Ep(t)&&e.push("RENDER_LINE_DASH"),t.paint.get("line-gradient")&&e.push("RENDER_LINE_GRADIENT");const r=t.paint.get("line-trim-offset");0===r[0]&&0===r[1]||e.push("RENDER_LINE_TRIM_OFFSET"),0!==t.paint.get("line-border-width").constantOr(1)&&e.push("RENDER_LINE_BORDER");const n="none"===t.layout.get("line-join").constantOr("miter"),i=!!t.paint.get("line-pattern").constantOr(1);return n&&i&&e.push("LINE_JOIN_NONE"),e};function Ep(t){const e=t.paint.get("line-dasharray").value;return e.value||"constant"!==e.kind}let Bp;const Vp=()=>Bp||(Bp={layout:Ap||(Ap=new $a({"line-cap":new Na(Ga.layout_line["line-cap"]),"line-join":new Na(Ga.layout_line["line-join"]),"line-miter-limit":new ja(Ga.layout_line["line-miter-limit"]),"line-round-limit":new ja(Ga.layout_line["line-round-limit"]),"line-sort-key":new Na(Ga.layout_line["line-sort-key"]),"line-z-offset":new Na(Ga.layout_line["line-z-offset"]),"line-elevation-reference":new ja(Ga.layout_line["line-elevation-reference"]),"line-cross-slope":new ja(Ga.layout_line["line-cross-slope"]),visibility:new ja(Ga.layout_line.visibility)})),paint:Sp||(Sp=new $a({"line-opacity":new Na(Ga.paint_line["line-opacity"]),"line-color":new Na(Ga.paint_line["line-color"]),"line-translate":new ja(Ga.paint_line["line-translate"]),"line-translate-anchor":new ja(Ga.paint_line["line-translate-anchor"]),"line-width":new Na(Ga.paint_line["line-width"]),"line-gap-width":new Na(Ga.paint_line["line-gap-width"]),"line-offset":new Na(Ga.paint_line["line-offset"]),"line-blur":new Na(Ga.paint_line["line-blur"]),"line-dasharray":new Na(Ga.paint_line["line-dasharray"]),"line-pattern":new Na(Ga.paint_line["line-pattern"]),"line-gradient":new qa(Ga.paint_line["line-gradient"]),"line-trim-offset":new ja(Ga.paint_line["line-trim-offset"]),"line-trim-fade-range":new ja(Ga.paint_line["line-trim-fade-range"]),"line-trim-color":new ja(Ga.paint_line["line-trim-color"]),"line-emissive-strength":new ja(Ga.paint_line["line-emissive-strength"]),"line-border-width":new Na(Ga.paint_line["line-border-width"]),"line-border-color":new Na(Ga.paint_line["line-border-color"]),"line-occlusion-opacity":new ja(Ga.paint_line["line-occlusion-opacity"])}))},Bp);class Cp extends Na{possiblyEvaluate(t,e){return e=new Ba(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,r,n){return e=nt({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,r,n)}}let Rp;function Dp(t,e){return e>0?e+2*t:t}const Lp=ms([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Fp=ms([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),Op=ms([{name:"a_projected_pos",components:4,type:"Float32"}],4);ms([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Up=ms([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),jp=ms([{name:"a_texb",components:2,type:"Uint16"}]),Np=ms([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),qp=ms([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);ms([{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 $p=ms([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Gp=ms([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);ms([{name:"triangle",components:3,type:"Uint16"}]),ms([{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"}]),ms([{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"}]),ms([{type:"Float32",name:"offsetX"}]),ms([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var Xp=24;const Yp=128;function Zp(t,e){const{expression:r}=e;if("constant"===r.kind)return {kind:"constant",layoutSize:r.evaluate(new Ba(t+1))};if("source"===r.kind)return {kind:"source"};{const{zoomStops:e,interpolationType:n}=r;let i=0;for(;i<e.length&&e[i]<=t;)i++;i=Math.max(0,i-1);let a=i;for(;a<e.length&&e[a]<t+1;)a++;a=Math.min(e.length-1,a);const s=e[i],o=e[a];return "composite"===r.kind?{kind:"composite",minZoom:s,maxZoom:o,interpolationType:n}:{kind:"camera",minZoom:s,maxZoom:o,minSize:r.evaluate(new Ba(s)),maxSize:r.evaluate(new Ba(o)),interpolationType:n}}}function Wp(t,{uSize:e,uSizeT:r},{lowerSize:n,upperSize:i}){return "source"===t.kind?n/Yp:"composite"===t.kind?Pe(n/Yp,i/Yp,r):e}function Hp(t,e,r=1){let n=0,i=0;if("constant"===t.kind)i=t.layoutSize*r;else if("source"!==t.kind){const{interpolationType:a,minZoom:s,maxZoom:o}=t,l=a?Q(ii.interpolationFactor(a,e,s,o),0,1):0;"camera"===t.kind?i=Pe(t.minSize,t.maxSize,l)*r:n=l*r;}return {uSizeT:n,uSize:i}}var Kp=Object.freeze({__proto__:null,SIZE_PACK_FACTOR:Yp,evaluateSizeForFeature:Wp,evaluateSizeForZoom:Hp,getSizeData:Zp});function Jp(t,e,r){return t.sections.forEach((t=>{t.text=function(t,e,r){const n=e.layout.get("text-transform").evaluate(r,{});return "uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),Ea.applyArabicShaping&&(t=Ea.applyArabicShaping(t)),t}(t.text,e,r);})),t}const Qp={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function tf(t){return "︶"===t||"﹈"===t||"︸"===t||"﹄"===t||"﹂"===t||"︾"===t||"︼"===t||"︺"===t||"︘"===t||"﹀"===t||"︐"===t||"︓"===t||"︔"===t||"`"===t||" ̄"===t||"︑"===t||"︒"===t}function ef(t){return "︵"===t||"﹇"===t||"︷"===t||"﹃"===t||"﹁"===t||"︽"===t||"︻"===t||"︹"===t||"︗"===t||"︿"===t}var rf,nf,af,sf={}; |
| 32 |
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */function of(){return rf||(rf=1,sf.read=function(t,e,r,n,i){var a,s,o=8*i-n-1,l=(1<<o)-1,u=l>>1,c=-7,h=r?i-1:0,p=r?-1:1,f=t[e+h];for(h+=p,a=f&(1<<-c)-1,f>>=-c,c+=o;c>0;a=256*a+t[e+h],h+=p,c-=8);for(s=a&(1<<-c)-1,a>>=-c,c+=n;c>0;s=256*s+t[e+h],h+=p,c-=8);if(0===a)a=1-u;else {if(a===l)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,n),a-=u;}return (f?-1:1)*s*Math.pow(2,a-n)},sf.write=function(t,e,r,n,i,a){var s,o,l,u=8*a-i-1,c=(1<<u)-1,h=c>>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:a-1,d=n?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(o=isNaN(e)?1:0,s=c):(s=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-s))<1&&(s--,l*=2),(e+=s+h>=1?p/l:p*Math.pow(2,1-h))*l>=2&&(s++,l/=2),s+h>=c?(o=0,s=c):s+h>=1?(o=(e*l-1)*Math.pow(2,i),s+=h):(o=e*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;t[r+f]=255&o,f+=d,o/=256,i-=8);for(s=s<<i|o,u+=i;u>0;t[r+f]=255&s,f+=d,s/=256,u-=8);t[r+f-d]|=128*m;}),sf}function lf(){if(af)return nf;af=1,nf=e;var t=of();function e(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length;}e.Varint=0,e.Fixed64=1,e.Bytes=2,e.Fixed32=5;var r=4294967296,n=1/r,i="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function a(t){return t.type===e.Bytes?t.readVarint()+t.pos:t.pos+1}function s(t,e,r){return r?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function o(t,e,r){var n=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));r.realloc(n);for(var i=r.pos-1;i>=t;i--)r.buf[i+n]=r.buf[i];}function l(t,e){for(var r=0;r<t.length;r++)e.writeVarint(t[r]);}function u(t,e){for(var r=0;r<t.length;r++)e.writeSVarint(t[r]);}function c(t,e){for(var r=0;r<t.length;r++)e.writeFloat(t[r]);}function h(t,e){for(var r=0;r<t.length;r++)e.writeDouble(t[r]);}function p(t,e){for(var r=0;r<t.length;r++)e.writeBoolean(t[r]);}function f(t,e){for(var r=0;r<t.length;r++)e.writeFixed32(t[r]);}function d(t,e){for(var r=0;r<t.length;r++)e.writeSFixed32(t[r]);}function m(t,e){for(var r=0;r<t.length;r++)e.writeFixed64(t[r]);}function y(t,e){for(var r=0;r<t.length;r++)e.writeSFixed64(t[r]);}function g(t,e){return (t[e]|t[e+1]<<8|t[e+2]<<16)+16777216*t[e+3]}function x(t,e,r){t[r]=e,t[r+1]=e>>>8,t[r+2]=e>>>16,t[r+3]=e>>>24;}function v(t,e){return (t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}return e.prototype={destroy:function(){this.buf=null;},readFields:function(t,e,r){for(r=r||this.length;this.pos<r;){var n=this.readVarint(),i=n>>3,a=this.pos;this.type=7&n,t(i,e,this),this.pos===a&&this.skip(n);}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=g(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=v(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=g(this.buf,this.pos)+g(this.buf,this.pos+4)*r;return this.pos+=8,t},readSFixed64:function(){var t=g(this.buf,this.pos)+v(this.buf,this.pos+4)*r;return this.pos+=8,t},readFloat:function(){var e=t.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=t.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(t){var e,r,n=this.buf;return e=127&(r=n[this.pos++]),r<128?e:(e|=(127&(r=n[this.pos++]))<<7,r<128?e:(e|=(127&(r=n[this.pos++]))<<14,r<128?e:(e|=(127&(r=n[this.pos++]))<<21,r<128?e:function(t,e,r){var n,i,a=r.buf;if(n=(112&(i=a[r.pos++]))>>4,i<128)return s(t,n,e);if(n|=(127&(i=a[r.pos++]))<<3,i<128)return s(t,n,e);if(n|=(127&(i=a[r.pos++]))<<10,i<128)return s(t,n,e);if(n|=(127&(i=a[r.pos++]))<<17,i<128)return s(t,n,e);if(n|=(127&(i=a[r.pos++]))<<24,i<128)return s(t,n,e);if(n|=(1&(i=a[r.pos++]))<<31,i<128)return s(t,n,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(r=n[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&i?function(t,e,r){return i.decode(t.subarray(e,r))}(this.buf,e,t):function(t,e,r){for(var n="",i=e;i<r;){var a,s,o,l=t[i],u=null,c=l>239?4:l>223?3:l>191?2:1;if(i+c>r)break;1===c?l<128&&(u=l):2===c?128==(192&(a=t[i+1]))&&(u=(31&l)<<6|63&a)<=127&&(u=null):3===c?(s=t[i+2],128==(192&(a=t[i+1]))&&128==(192&s)&&((u=(15&l)<<12|(63&a)<<6|63&s)<=2047||u>=55296&&u<=57343)&&(u=null)):4===c&&(s=t[i+2],o=t[i+3],128==(192&(a=t[i+1]))&&128==(192&s)&&128==(192&o)&&((u=(15&l)<<18|(63&a)<<12|(63&s)<<6|63&o)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,c=1):u>65535&&(u-=65536,n+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),n+=String.fromCharCode(u),i+=c;}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,r){if(this.type!==e.Bytes)return t.push(this.readVarint(r));var n=a(this);for(t=t||[];this.pos<n;)t.push(this.readVarint(r));return t},readPackedSVarint:function(t){if(this.type!==e.Bytes)return t.push(this.readSVarint());var r=a(this);for(t=t||[];this.pos<r;)t.push(this.readSVarint());return t},readPackedBoolean:function(t){if(this.type!==e.Bytes)return t.push(this.readBoolean());var r=a(this);for(t=t||[];this.pos<r;)t.push(this.readBoolean());return t},readPackedFloat:function(t){if(this.type!==e.Bytes)return t.push(this.readFloat());var r=a(this);for(t=t||[];this.pos<r;)t.push(this.readFloat());return t},readPackedDouble:function(t){if(this.type!==e.Bytes)return t.push(this.readDouble());var r=a(this);for(t=t||[];this.pos<r;)t.push(this.readDouble());return t},readPackedFixed32:function(t){if(this.type!==e.Bytes)return t.push(this.readFixed32());var r=a(this);for(t=t||[];this.pos<r;)t.push(this.readFixed32());return t},readPackedSFixed32:function(t){if(this.type!==e.Bytes)return t.push(this.readSFixed32());var r=a(this);for(t=t||[];this.pos<r;)t.push(this.readSFixed32());return t},readPackedFixed64:function(t){if(this.type!==e.Bytes)return t.push(this.readFixed64());var r=a(this);for(t=t||[];this.pos<r;)t.push(this.readFixed64());return t},readPackedSFixed64:function(t){if(this.type!==e.Bytes)return t.push(this.readSFixed64());var r=a(this);for(t=t||[];this.pos<r;)t.push(this.readSFixed64());return t},skip:function(t){var r=7&t;if(r===e.Varint)for(;this.buf[this.pos++]>127;);else if(r===e.Bytes)this.pos=this.readVarint()+this.pos;else if(r===e.Fixed32)this.pos+=4;else {if(r!==e.Fixed64)throw new Error("Unimplemented type: "+r);this.pos+=8;}},writeTag:function(t,e){this.writeVarint(t<<3|e);},realloc:function(t){for(var e=this.length||16;e<this.pos+t;)e*=2;if(e!==this.length){var r=new Uint8Array(e);r.set(this.buf),this.buf=r,this.length=e;}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(t){this.realloc(4),x(this.buf,t,this.pos),this.pos+=4;},writeSFixed32:function(t){this.realloc(4),x(this.buf,t,this.pos),this.pos+=4;},writeFixed64:function(t){this.realloc(8),x(this.buf,-1&t,this.pos),x(this.buf,Math.floor(t*n),this.pos+4),this.pos+=8;},writeSFixed64:function(t){this.realloc(8),x(this.buf,-1&t,this.pos),x(this.buf,Math.floor(t*n),this.pos+4),this.pos+=8;},writeVarint:function(t){(t=+t||0)>268435455||t<0?function(t,e){var r,n;if(t>=0?(r=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(r=~(-t%4294967296))?r=r+1|0:(r=0,n=n+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,r){r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,r.buf[r.pos]=127&(t>>>=7);}(r,0,e),function(t,e){var r=(7&t)<<4;e.buf[e.pos++]|=r|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))));}(n,e);}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))));},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t);},writeBoolean:function(t){this.writeVarint(Boolean(t));},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,r){for(var n,i,a=0;a<e.length;a++){if((n=e.charCodeAt(a))>55295&&n<57344){if(!i){n>56319||a+1===e.length?(t[r++]=239,t[r++]=191,t[r++]=189):i=n;continue}if(n<56320){t[r++]=239,t[r++]=191,t[r++]=189,i=n;continue}n=i-55296<<10|n-56320|65536,i=null;}else i&&(t[r++]=239,t[r++]=191,t[r++]=189,i=null);n<128?t[r++]=n:(n<2048?t[r++]=n>>6|192:(n<65536?t[r++]=n>>12|224:(t[r++]=n>>18|240,t[r++]=n>>12&63|128),t[r++]=n>>6&63|128),t[r++]=63&n|128);}return r}(this.buf,t,this.pos);var r=this.pos-e;r>=128&&o(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r;},writeFloat:function(e){this.realloc(4),t.write(this.buf,e,this.pos,!0,23,4),this.pos+=4;},writeDouble:function(e){this.realloc(8),t.write(this.buf,e,this.pos,!0,52,8),this.pos+=8;},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var r=0;r<e;r++)this.buf[this.pos++]=t[r];},writeRawMessage:function(t,e){this.pos++;var r=this.pos;t(e,this);var n=this.pos-r;n>=128&&o(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n;},writeMessage:function(t,r,n){this.writeTag(t,e.Bytes),this.writeRawMessage(r,n);},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,l,e);},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,u,e);},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,p,e);},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,c,e);},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,h,e);},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,f,e);},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,d,e);},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,m,e);},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,y,e);},writeBytesField:function(t,r){this.writeTag(t,e.Bytes),this.writeBytes(r);},writeFixed32Field:function(t,r){this.writeTag(t,e.Fixed32),this.writeFixed32(r);},writeSFixed32Field:function(t,r){this.writeTag(t,e.Fixed32),this.writeSFixed32(r);},writeFixed64Field:function(t,r){this.writeTag(t,e.Fixed64),this.writeFixed64(r);},writeSFixed64Field:function(t,r){this.writeTag(t,e.Fixed64),this.writeSFixed64(r);},writeVarintField:function(t,r){this.writeTag(t,e.Varint),this.writeVarint(r);},writeSVarintField:function(t,r){this.writeTag(t,e.Varint),this.writeSVarint(r);},writeStringField:function(t,r){this.writeTag(t,e.Bytes),this.writeString(r);},writeFloatField:function(t,r){this.writeTag(t,e.Fixed32),this.writeFloat(r);},writeDoubleField:function(t,r){this.writeTag(t,e.Fixed64),this.writeDouble(r);},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e));}},nf}var uf=e(lf());const cf=3;function hf(t,e,r){e.glyphs=[],1===t&&r.readMessage(pf,e);}function pf(t,e,r){if(3===t){const{id:t,bitmap:n,width:i,height:a,left:s,top:o,advance:l}=r.readMessage(ff,{});e.glyphs.push({id:t,bitmap:new ic({width:i+2*cf,height:a+2*cf},n),metrics:{width:i,height:a,left:s,top:o,advance:l}});}else 4===t?e.ascender=r.readSVarint():5===t&&(e.descender=r.readSVarint());}function ff(t,e,r){1===t?e.id=r.readVarint():2===t?e.bitmap=r.readBytes():3===t?e.width=r.readVarint():4===t?e.height=r.readVarint():5===t?e.left=r.readSVarint():6===t?e.top=r.readSVarint():7===t&&(e.advance=r.readVarint());}const df=cf,mf={horizontal:1,vertical:2,horizontalOnly:3};class yf{constructor(){this.scale=1,this.fontStack="",this.imageName=null;}static forText(t,e){const r=new yf;return r.scale=t||1,r.fontStack=e,r}static forImage(t){const e=new yf;return e.imageName=t,e}}class gf{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null;}static fromFeature(t,e){const r=new gf;for(let n=0;n<t.sections.length;n++){const i=t.sections[n];i.image?r.addImageSection(i):r.addTextSection(i,e);}return r}length(){return this.text.length}getSection(t){return this.sections[this.sectionIndex[t]]}getSections(){return this.sections}getSectionIndex(t){return this.sectionIndex[t]}getCodePoint(t){return this.text.codePointAt(t)}verticalizePunctuation(t){this.text=function(t,e){let r="";for(let n=0;n<t.length;n++){const i=t.charCodeAt(n+1)||null,a=t.charCodeAt(n-1)||null;r+=!e&&(i&&ya(i)&&!Qp[t[n+1]]||a&&ya(a)&&!Qp[t[n-1]])||!Qp[t[n]]?t[n]:Qp[t[n]];}return r}(this.text,t);}trim(){let t=0;for(let e=0;e<this.text.length&&vf[this.text.charCodeAt(e)];e++)t++;let e=this.text.length;for(let r=this.text.length-1;r>=0&&r>=t&&vf[this.text.charCodeAt(r)];r--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e);}substring(t,e){const r=new gf;return r.text=this.text.substring(t,e),r.sectionIndex=this.sectionIndex.slice(t,e),r.sections=this.sections,r}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(yf.forText(t.scale,t.fontStack||e));const r=this.sections.length-1;for(let e=0;e<t.text.length;++e)this.sectionIndex.push(r);}addImageSection(t){const e=t.image?t.image.namePrimary:"";if(0===e.length)return void ft("Can't add FormattedSection with an empty image.");const r=this.getNextImageSectionCharCode();r?(this.text+=String.fromCodePoint(r),this.sections.push(yf.forImage(e)),this.sectionIndex.push(this.sections.length-1)):ft("Reached maximum number of images 6401");}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function xf(t,e,r,n,i,a,s,o,l,u,c,h,p,f,d){const m=gf.fromFeature(t,i);h===mf.vertical&&m.verticalizePunctuation(p);let y=[];const g=function(t,e,r,n,i,a){if(!t)return [];const s=[],o=function(t,e,r,n,i,a){let s=0;for(let r=0;r<t.length();r++){const o=t.getSection(r);s+=wf(t.getCodePoint(r),o,n,i,e,a);}return s/Math.max(1,Math.ceil(s/r))}(t,e,r,n,i,a),l=t.text.indexOf("")>=0;let u=0;for(let r=0;r<t.length();r++){const h=t.getSection(r),p=t.getCodePoint(r);if(vf[p]||(u+=wf(p,h,n,i,e,a)),r<t.length()-1){const e=!((c=p)<11904||!(ha["Bopomofo Extended"](c)||ha.Bopomofo(c)||ha["CJK Compatibility Forms"](c)||ha["CJK Compatibility Ideographs"](c)||ha["CJK Compatibility"](c)||ha["CJK Radicals Supplement"](c)||ha["CJK Strokes"](c)||ha["CJK Symbols and Punctuation"](c)||ha["CJK Unified Ideographs Extension A"](c)||ha["CJK Unified Ideographs"](c)||ha["Enclosed CJK Letters and Months"](c)||ha["Halfwidth and Fullwidth Forms"](c)||ha.Hiragana(c)||ha["Ideographic Description Characters"](c)||ha["Kangxi Radicals"](c)||ha["Katakana Phonetic Extensions"](c)||ha.Katakana(c)||ha["Vertical Forms"](c)||ha["Yi Radicals"](c)||ha["Yi Syllables"](c)));(bf[p]||e||h.imageName)&&s.push(Af(r+1,u,o,s,Mf(p,t.getCodePoint(r+1),e&&l),!1));}}var c;return Sf(Af(t.length(),u,o,s,0,!0))}(m,u,a,e,n,f),{processBidirectionalText:x,processStyledBidirectionalText:v}=Ea;if(x&&1===m.sections.length){const t=x(m.toString(),g);for(const e of t){const t=new gf;t.text=e,t.sections=m.sections;for(let r=0;r<e.length;r++)t.sectionIndex.push(0);y.push(t);}}else if(v){const t=v(m.text,m.sectionIndex,g);for(const e of t){const t=new gf;t.text=e[0],t.sectionIndex=e[1],t.sections=m.sections,y.push(t);}}else y=function(t,e){const r=[],n=t.text;let i=0;for(const n of e)r.push(t.substring(i,n)),i=n;return i<n.length&&r.push(t.substring(i,n.length)),r}(m,g);const b=[],w={positionedLines:b,text:m.toString(),top:c[1],bottom:c[1],left:c[0],right:c[0],writingMode:h,iconsInText:!1,verticalizable:!1,hasBaseline:!1};return function(t,e,r,n,i,a,s,o,l,u,c,h){let p=0,f=0,d=0;const m="right"===o?1:"left"===o?0:.5;let y=!1;for(const t of i){const r=t.getSections();for(const t of r){if(t.imageName)continue;const r=e[t.fontStack];if(r&&(y=void 0!==r.ascender&&void 0!==r.descender,!y))break}if(!y)break}let g=0;for(const s of i){s.trim();const i=s.getMaxScale(),o=(i-1)*Xp,v={positionedGlyphs:[],lineOffset:0};t.positionedLines[g]=v;const b=v.positionedGlyphs;let w=0;if(!s.length()){f+=a,++g;continue}let _=0,M=0;for(let a=0;a<s.length();a++){const o=s.getSection(a),d=s.getSectionIndex(a),m=s.getCodePoint(a);let g=o.scale,v=null,A=null,S=null,I=Xp,z=0;const P=!(l===mf.horizontal||!c&&!ma(m)||c&&(vf[m]||(x=m,ha.Arabic(x)||ha["Arabic Supplement"](x)||ha["Arabic Extended-A"](x)||ha["Arabic Presentation Forms-A"](x)||ha["Arabic Presentation Forms-B"](x))));if(o.imageName){const e=n[o.imageName];if(!e)continue;S=o.imageName,t.iconsInText=t.iconsInText||!0,A=e.paddedRect;const r=e.displaySize;g=g*Xp/h,v={width:r[0],height:r[1],left:0,top:-df,advance:P?r[1]:r[0],localGlyph:!1},z=y?-v.height*g:i*Xp-17-r[1]*g,I=v.advance;const a=(P?r[0]:r[1])*g-Xp*i;a>0&&a>w&&(w=a);}else {const t=r[o.fontStack];if(!t)continue;t[m]&&(A=t[m]);const n=e[o.fontStack];if(!n)continue;const a=n.glyphs[m];if(!a)continue;if(v=a.metrics,I=8203!==m?Xp:0,y){const t=void 0!==n.ascender?Math.abs(n.ascender):0,e=void 0!==n.descender?Math.abs(n.descender):0,r=(t+e)*g;_<r&&(_=r,M=(t-e)/2*g),z=-t*g;}else z=(i-g)*Xp-17;}P?(t.verticalizable=!0,b.push({glyph:m,imageName:S,x:p,y:f+z,vertical:P,scale:g,localGlyph:v.localGlyph,fontStack:o.fontStack,sectionIndex:d,metrics:v,rect:A}),p+=I*g+u):(b.push({glyph:m,imageName:S,x:p,y:f+z,vertical:P,scale:g,localGlyph:v.localGlyph,fontStack:o.fontStack,sectionIndex:d,metrics:v,rect:A}),p+=v.advance*g+u);}0!==b.length&&(d=Math.max(p-u,d),y?zf(b,m,w,M,a*i/2):zf(b,m,w,0,a/2)),p=0;const A=a*i+w;v.lineOffset=Math.max(w,o),f+=A,++g;}var x;const v=f,{horizontalAlign:b,verticalAlign:w}=If(s);((function(t,e,r,n,i,a){const s=(e-r)*i,o=-a*n;for(const e of t)for(const t of e.positionedGlyphs)t.x+=s,t.y+=o;}))(t.positionedLines,m,b,w,d,v),t.top+=-w*v,t.bottom=t.top+v,t.left+=-b*d,t.right=t.left+d,t.hasBaseline=y;}(w,e,r,n,y,s,o,l,h,u,p,d),!function(t){for(const e of t)if(0!==e.positionedGlyphs.length)return !1;return !0}(b)&&w}const vf={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},bf={10:!0,32:!0,38:!0,40:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0};function wf(t,e,r,n,i,a){if(e.imageName){const t=n[e.imageName];return t?t.displaySize[0]*e.scale*Xp/a+i:0}{const n=r[e.fontStack],a=n&&n.glyphs[t];return a?a.metrics.advance*e.scale+i:0}}function _f(t,e,r,n){const i=Math.pow(t-e,2);return n?t<e?i/2:2*i:i+Math.abs(r)*r}function Mf(t,e,r){let n=0;return 10===t&&(n-=1e4),r&&(n+=150),40!==t&&65288!==t||(n+=50),41!==e&&65289!==e||(n+=50),n}function Af(t,e,r,n,i,a){let s=null,o=_f(e,r,i,a);for(const t of n){const n=_f(e-t.x,r,i,a)+t.badness;n<=o&&(s=t,o=n);}return {index:t,x:e,priorBreak:s,badness:o}}function Sf(t){return t?Sf(t.priorBreak).concat(t.index):[]}function If(t){let e=.5,r=.5;switch(t){case"right":case"top-right":case"bottom-right":e=1;break;case"left":case"top-left":case"bottom-left":e=0;}switch(t){case"bottom":case"bottom-right":case"bottom-left":r=1;break;case"top":case"top-right":case"top-left":r=0;}return {horizontalAlign:e,verticalAlign:r}}function zf(t,e,r,n,i){if(!(e||r||n||i))return;const a=t.length-1,s=t[a],o=(s.x+s.metrics.advance*s.scale)*e;for(let e=0;e<=a;e++)t[e].x-=o,t[e].y+=r+n+i;}function Pf(t,e,r,n){const{horizontalAlign:i,verticalAlign:a}=If(n),s=r[0]-t.displaySize[0]*i,o=r[1]-t.displaySize[1]*a;return {imagePrimary:t,imageSecondary:e,top:o,bottom:o+t.displaySize[1],left:s,right:s+t.displaySize[0]}}function kf(t,e,r,n,i,a){const s=t.imagePrimary;let o;if(s.content){const t=s.content,e=s.pixelRatio||1;o=[t[0]/e,t[1]/e,s.displaySize[0]-t[2]/e,s.displaySize[1]-t[3]/e];}const l=e.left*a,u=e.right*a;let c,h,p,f;"width"===r||"both"===r?(f=i[0]+l-n[3],h=i[0]+u+n[1]):(f=i[0]+(l+u-s.displaySize[0])/2,h=f+s.displaySize[0]);const d=e.top*a,m=e.bottom*a;return "height"===r||"both"===r?(c=i[1]+d-n[0],p=i[1]+m+n[2]):(c=i[1]+(d+m-s.displaySize[1])/2,p=c+s.displaySize[1]),{imagePrimary:s,imageSecondary:void 0,top:c,right:h,bottom:p,left:f,collisionPadding:o}}class Tf extends q{constructor(t,e,r,n,i){super(t,e),this.angle=n,this.z=r,void 0!==i&&(this.segment=i);}clone(){return new Tf(this.x,this.y,this.z,this.angle,this.segment)}}function Ef(t,e,r,n,i){if(void 0===e.segment)return !0;let a=e,s=e.segment+1,o=0;for(;o>-r/2;){if(s--,s<0)return !1;o-=t[s].dist(a),a=t[s];}o+=t[s].dist(t[s+1]),s++;const l=[];let u=0;for(;o<r/2;){const e=t[s],r=t[s+1];if(!r)return !1;let a=t[s-1].angleTo(e)-e.angleTo(r);for(a=Math.abs((a+3*Math.PI)%(2*Math.PI)-Math.PI),l.push({distance:o,angleDelta:a}),u+=a;o-l[0].distance>n;)u-=l.shift().angleDelta;if(u>i)return !1;s++,o+=e.dist(r);}return !0}function Bf(t){let e=0;for(let r=0;r<t.length-1;r++)e+=t[r].dist(t[r+1]);return e}function Vf(t,e,r){return t?.6*e*r:0}function Cf(t,e){return Math.max(t?t.right-t.left:0,e?e.right-e.left:0)}function Rf(t,e,r,n,i,a){const s=Vf(r,i,a),o=Cf(r,n)*a;let l=0;const u=Bf(t)/2;for(let r=0;r<t.length-1;r++){const n=t[r],i=t[r+1],a=n.dist(i);if(l+a>u){const c=(u-l)/a,h=Pe(n.x,i.x,c),p=Pe(n.y,i.y,c),f=new Tf(h,p,0,i.angleTo(n),r);return !s||Ef(t,f,o,s,e)?f:void 0}l+=a;}}function Df(t,e,r,n,i,a,s,o,l){const u=Vf(n,a,s),c=Cf(n,i),h=c*s,p=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-h<e/4&&(e=h+e/4),Lf(t,p?e/2*o%e:(c/2+2*a)*s*o%e,e,u,r,h,p,!1,l)}function Lf(t,e,r,n,i,a,s,o,l){const u=a/2,c=Bf(t);let h=0,p=e-r,f=[];for(let e=0;e<t.length-1;e++){const s=t[e],o=t[e+1],d=s.dist(o),m=o.angleTo(s);for(;p+r<h+d;){p+=r;const y=(p-h)/d,g=Pe(s.x,o.x,y),x=Pe(s.y,o.y,y);if(g>=0&&g<l&&x>=0&&x<l&&p-u>=0&&p+u<=c){const r=new Tf(g,x,0,m,e);n&&!Ef(t,r,a,n,i)||f.push(r);}}h+=d;}return o||f.length||s||(f=Lf(t,h/2,r,n,i,a,s,!0,l)),f}function Ff(t,e,r,n,i){const a=[];for(let s=0;s<t.length;s++){const o=t[s];let l;for(let t=0;t<o.length-1;t++){let s=o[t],u=o[t+1];s.x<e&&u.x<e||(s.x<e?s=new q(e,s.y+(e-s.x)/(u.x-s.x)*(u.y-s.y))._round():u.x<e&&(u=new q(e,s.y+(e-s.x)/(u.x-s.x)*(u.y-s.y))._round()),s.y<r&&u.y<r||(s.y<r?s=new q(s.x+(r-s.y)/(u.y-s.y)*(u.x-s.x),r)._round():u.y<r&&(u=new q(s.x+(r-s.y)/(u.y-s.y)*(u.x-s.x),r)._round()),s.x>=n&&u.x>=n||(s.x>=n?s=new q(n,s.y+(n-s.x)/(u.x-s.x)*(u.y-s.y))._round():u.x>=n&&(u=new q(n,s.y+(n-s.x)/(u.x-s.x)*(u.y-s.y))._round()),s.y>=i&&u.y>=i||(s.y>=i?s=new q(s.x+(i-s.y)/(u.y-s.y)*(u.x-s.x),i)._round():u.y>=i&&(u=new q(s.x+(i-s.y)/(u.y-s.y)*(u.x-s.x),i)._round()),l&&s.equals(l[l.length-1])||(l=[s],a.push(l)),l.push(u)))));}}return a}function Of(t){let e=0,r=0;for(const n of t)e+=n.w*n.h,r=Math.max(r,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),r),h:1/0}];let i=0,a=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const r=n[t];if(!(e.w>r.w||e.h>r.h)){if(e.x=r.x,e.y=r.y,a=Math.max(a,e.y+e.h),i=Math.max(i,e.x+e.w),e.w===r.w&&e.h===r.h){const e=n.pop();t<n.length&&(n[t]=e);}else e.h===r.h?(r.x+=e.w,r.w-=e.w):e.w===r.w?(r.y+=e.h,r.h-=e.h):(n.push({x:r.x+e.w,y:r.y,w:r.w-e.w,h:e.h}),r.y+=e.h,r.h-=e.h);break}}return {w:i,h:a,fill:e/(i*a)||0}}sa(Tf,"Anchor");const Uf=1;class jf{constructor(t,{pixelRatio:e,version:r,stretchX:n,stretchY:i,content:a},s){this.paddedRect=t,this.pixelRatio=e,this.stretchX=n,this.stretchY=i,this.content=a,this.version=r,this.padding=s;}get tl(){return [this.paddedRect.x+this.padding,this.paddedRect.y+this.padding]}get br(){return [this.paddedRect.x+this.paddedRect.w-this.padding,this.paddedRect.y+this.paddedRect.h-this.padding]}get displaySize(){return [(this.paddedRect.w-2*this.padding)/this.pixelRatio,(this.paddedRect.h-2*this.padding)/this.pixelRatio]}}class Nf{constructor(t,e,r){const n={},i={};this.haveRenderCallbacks=[];const a=[];this.addImages(t,n,Uf,a),this.addImages(e,i,2,a);const{w:s,h:o}=Of(a),l=new ac({width:s||1,height:o||1});for(const e in t){const i=t[e],a=n[e].paddedRect;ac.copy(i.data,l,{x:0,y:0},{x:a.x+Uf,y:a.y+Uf},i.data,r,i.sdf);}for(const t in e){const n=e[t],a=i[t].paddedRect;let s=i[t].padding;const o=a.x+s,u=a.y+s,c=n.data.width,h=n.data.height;s=s>1?s-1:s,ac.copy(n.data,l,{x:0,y:0},{x:o,y:u},n.data,r),ac.copy(n.data,l,{x:0,y:h-s},{x:o,y:u-s},{width:c,height:s},r),ac.copy(n.data,l,{x:0,y:0},{x:o,y:u+h},{width:c,height:s},r),ac.copy(n.data,l,{x:c-s,y:0},{x:o-s,y:u},{width:s,height:h},r),ac.copy(n.data,l,{x:0,y:0},{x:o+c,y:u},{width:s,height:h},r),ac.copy(n.data,l,{x:c-s,y:h-s},{x:o-s,y:u-s},{width:s,height:s},r),ac.copy(n.data,l,{x:0,y:h-s},{x:o+c,y:u-s},{width:s,height:s},r),ac.copy(n.data,l,{x:0,y:0},{x:o+c,y:u+h},{width:s,height:s},r),ac.copy(n.data,l,{x:c-s,y:0},{x:o-s,y:u+h},{width:s,height:s},r);}this.image=l,this.iconPositions=n,this.patternPositions=i;}addImages(t,e,r,n){for(const i in t){const a=t[i],s={x:0,y:0,w:a.data.width+2*r,h:a.data.height+2*r};n.push(s),e[i]=new jf(s,a,r),a.hasRenderCallback&&this.haveRenderCallbacks.push(i);}}patchUpdatedImages(t,e,r){this.haveRenderCallbacks=this.haveRenderCallbacks.filter((e=>t.hasImage(e,r))),t.dispatchRenderCallbacks(this.haveRenderCallbacks,r);for(const n in t.getUpdatedImages(r))this.patchUpdatedImage(this.iconPositions[n],t.getImage(n,r),e),this.patchUpdatedImage(this.patternPositions[n],t.getImage(n,r),e);}patchUpdatedImage(t,e,r){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[n,i]=t.tl;r.update(e.data,{position:{x:n,y:i}});}}sa(jf,"ImagePosition"),sa(Nf,"ImageAtlas");const qf=1e20;function $f(t,e,r,n,i,a,s,o,l){for(let u=e;u<e+n;u++)Gf(t,r*a+u,a,i,s,o,l);for(let u=r;u<r+i;u++)Gf(t,u*a+e,1,n,s,o,l);}function Gf(t,e,r,n,i,a,s){a[0]=0,s[0]=-qf,s[1]=qf,i[0]=t[e];for(let o=1,l=0,u=0;o<n;o++){i[o]=t[e+o*r];const n=o*o;do{const t=a[l];u=(i[o]-i[t]+n-t*t)/(o-t)/2;}while(u<=s[l]&&--l>-1);l++,a[l]=o,s[l]=u,s[l+1]=qf;}for(let o=0,l=0;o<n;o++){for(;s[l+1]<o;)l++;const n=a[l],u=o-n;t[e+o*r]=i[n]+u*u;}}const Xf=2,Yf={none:0,ideographs:1,all:2};class Zf{constructor(t,e,r){this.requestManager=t,this.localGlyphMode=e,this.localFontFamily=r,this.urls={},this.entries={},this.localGlyphs={200:{},400:{},500:{},900:{}};}setURL(t,e){this.urls[e]=t;}getGlyphs(t,e,r){const n=[],i=this.urls[e]||St.GLYPHS_URL;for(const e in t)for(const r of t[e])n.push({stack:e,id:r});rt(n,(({stack:t,id:e},r)=>{let n=this.entries[t];n||(n=this.entries[t]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let a=n.glyphs[e];if(void 0!==a)return void r(null,{stack:t,id:e,glyph:a});if(a=this._tinySDF(n,t,e),a)return n.glyphs[e]=a,void r(null,{stack:t,id:e,glyph:a});const s=Math.floor(e/256);if(256*s>65535)return ft("glyphs > 65535 not supported"),void r(null,{stack:t,id:e,glyph:a});if(n.ranges[s])return void r(null,{stack:t,id:e,glyph:a});let o=n.requests[s];o||(o=n.requests[s]=[],Zf.loadGlyphRange(t,s,i,this.requestManager,((t,e)=>{if(e){n.ascender=e.ascender,n.descender=e.descender;for(const t in e.glyphs)this._doesCharSupportLocalGlyph(+t)||(n.glyphs[+t]=e.glyphs[+t]);n.ranges[s]=!0;}for(const r of o)r(t,e);delete n.requests[s];}))),o.push(((n,i)=>{n?r(n):i&&r(null,{stack:t,id:e,glyph:i.glyphs[e]||null});}));}),((t,e)=>{if(t)r(t);else if(e){const t={};for(const{stack:r,id:n,glyph:i}of e)void 0===t[r]&&(t[r]={}),void 0===t[r].glyphs&&(t[r].glyphs={}),t[r].glyphs[n]=i&&{id:i.id,bitmap:i.bitmap.clone(),metrics:i.metrics},t[r].ascender=this.entries[r].ascender,t[r].descender=this.entries[r].descender;r(null,t);}}));}_doesCharSupportLocalGlyph(t){return this.localGlyphMode!==Yf.none&&(this.localGlyphMode===Yf.all?!!this.localFontFamily:!!this.localFontFamily&&(ha["CJK Unified Ideographs"](t)||ha["Hangul Syllables"](t)||ha.Hiragana(t)||ha.Katakana(t)||ha["CJK Symbols and Punctuation"](t)||ha["CJK Unified Ideographs Extension A"](t)||ha["CJK Unified Ideographs Extension B"](t)||ha.Osage(t)))}_tinySDF(t,e,r){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(r))return;let i=t.tinySDF;if(!i){let r="400";/bold/i.test(e)?r="900":/medium/i.test(e)?r="500":/light/i.test(e)&&(r="200"),i=t.tinySDF=new Zf.TinySDF({fontFamily:n,fontWeight:r,fontSize:24*Xf,buffer:3*Xf,radius:8*Xf}),i.fontWeight=r;}if(this.localGlyphs[i.fontWeight][r])return this.localGlyphs[i.fontWeight][r];const a=String.fromCodePoint(r),{data:s,width:o,height:l,glyphWidth:u,glyphHeight:c,glyphLeft:h,glyphTop:p,glyphAdvance:f}=i.draw(a);return this.localGlyphs[i.fontWeight][r]={id:r,bitmap:new ic({width:o,height:l},s),metrics:{width:u/Xf,height:c/Xf,left:h/Xf,top:p/Xf-27,advance:f/Xf,localGlyph:!0}}}}Zf.loadGlyphRange=function(t,e,r,n,i){const a=256*e,s=a+255,o=n.transformRequest(n.normalizeGlyphsURL(r).replace("{fontstack}",t).replace("{range}",`${a}-${s}`),te.Glyphs);ie(o,((t,e)=>{if(t)i(t);else if(e){const t={},r=function(t){return new uf(t).readFields(hf,{})}(e);for(const e of r.glyphs)t[e.id]=e;i(null,{glyphs:t,ascender:r.ascender,descender:r.descender});}}));},Zf.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:r=8,cutoff:n=.25,fontFamily:i="sans-serif",fontWeight:a="normal",fontStyle:s="normal"}={}){this.buffer=e,this.cutoff=n,this.radius=r;const o=this.size=t+4*e,l=this._createCanvas(o),u=this.ctx=l.getContext("2d",{willReadFrequently:!0});u.font=`${s} ${a} ${t}px ${i}`,u.textBaseline="alphabetic",u.textAlign="left",u.fillStyle="black",this.gridOuter=new Float64Array(o*o),this.gridInner=new Float64Array(o*o),this.f=new Float64Array(o),this.z=new Float64Array(o+1),this.v=new Uint16Array(o);}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:r,actualBoundingBoxDescent:n,actualBoundingBoxLeft:i,actualBoundingBoxRight:a}=this.ctx.measureText(t),s=Math.ceil(r),o=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(a-i))),l=Math.min(this.size-this.buffer,s+Math.ceil(n)),u=o+2*this.buffer,c=l+2*this.buffer,h=Math.max(u*c,0),p=new Uint8ClampedArray(h),f={data:p,width:u,height:c,glyphWidth:o,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:e};if(0===o||0===l)return f;const{ctx:d,buffer:m,gridInner:y,gridOuter:g}=this;d.clearRect(m,m,o,l),d.fillText(t,m,m+s);const x=d.getImageData(m,m,o,l);g.fill(qf,0,h),y.fill(0,0,h);for(let t=0;t<l;t++)for(let e=0;e<o;e++){const r=x.data[4*(t*o+e)+3]/255;if(0===r)continue;const n=(t+m)*u+e+m;if(1===r)g[n]=0,y[n]=qf;else {const t=.5-r;g[n]=t>0?t*t:0,y[n]=t<0?t*t:0;}}$f(g,0,0,u,c,u,this.f,this.v,this.z),$f(y,m,m,o,l,u,this.f,this.v,this.z);for(let t=0;t<h;t++){const e=Math.sqrt(g[t])-Math.sqrt(y[t]);p[t]=Math.round(255-255*(e/this.radius+this.cutoff));}return f}};const Wf=Uf;function Hf(t,e,r,n,i=1){const a=[],s=t.imagePrimary,o=s.pixelRatio,l=s.paddedRect.w-2*Wf,u=s.paddedRect.h-2*Wf,c=(t.right-t.left)*i,h=(t.bottom-t.top)*i,p=s.stretchX||[[0,l]],f=s.stretchY||[[0,u]],d=(t,e)=>t+e[1]-e[0],m=p.reduce(d,0),y=f.reduce(d,0),g=l-m,x=u-y;let v=0,b=m,w=0,_=y,M=0,A=g,S=0,I=x;if(s.content&&n){const t=s.content;v=Kf(p,0,t[0]),w=Kf(f,0,t[1]),b=Kf(p,t[0],t[2]),_=Kf(f,t[1],t[3]),M=t[0]-v,S=t[1]-w,A=t[2]-t[0]-b,I=t[3]-t[1]-_;}const z=(n,a,l,u)=>{const p=Qf(n.stretch-v,b,c,t.left*i),f=td(n.fixed-M,A,n.stretch,m),d=Qf(a.stretch-w,_,h,t.top*i),g=td(a.fixed-S,I,a.stretch,y),x=Qf(l.stretch-v,b,c,t.left*i),z=td(l.fixed-M,A,l.stretch,m),P=Qf(u.stretch-w,_,h,t.top*i),k=td(u.fixed-S,I,u.stretch,y),T=new q(p,d),E=new q(x,d),B=new q(x,P),V=new q(p,P),C=new q(f/o,g/o),R=new q(z/o,k/o),D=e*Math.PI/180;if(D){const t=Math.sin(D),e=Math.cos(D),r=[e,-t,t,e];T._matMult(r),E._matMult(r),V._matMult(r),B._matMult(r);}const L=n.stretch+n.fixed,F=l.stretch+l.fixed,O=a.stretch+a.fixed,U=u.stretch+u.fixed,j=t.imageSecondary;return {tl:T,tr:E,bl:V,br:B,texPrimary:{x:s.paddedRect.x+Wf+L,y:s.paddedRect.y+Wf+O,w:F-L,h:U-O},texSecondary:j?{x:j.paddedRect.x+Wf+L,y:j.paddedRect.y+Wf+O,w:F-L,h:U-O}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:C,pixelOffsetBR:R,minFontScaleX:A/o/c,minFontScaleY:I/o/h,isSDF:r}};if(n&&(s.stretchX||s.stretchY)){const t=Jf(p,g,m),e=Jf(f,x,y);for(let r=0;r<t.length-1;r++){const n=t[r],i=t[r+1];for(let t=0;t<e.length-1;t++)a.push(z(n,e[t],i,e[t+1]));}}else a.push(z({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:l+1},{fixed:0,stretch:u+1}));return a}function Kf(t,e,r){let n=0;for(const i of t)n+=Math.max(e,Math.min(r,i[1]))-Math.max(e,Math.min(r,i[0]));return n}function Jf(t,e,r){const n=[{fixed:-Wf,stretch:0}];for(const[e,r]of t){const t=n[n.length-1];n.push({fixed:e-t.stretch,stretch:t.stretch}),n.push({fixed:e-t.stretch,stretch:t.stretch+(r-e)});}return n.push({fixed:e+Wf,stretch:r}),n}function Qf(t,e,r,n){return t/e*r+n}function td(t,e,r,n){return t-e*r/n}function ed(t,e,r,n){const i=e+t.positionedLines[n].lineOffset;return 0===n?r+i/2:r+(i+(e+t.positionedLines[n-1].lineOffset))/2}function rd(t,e=1,r=!1){let n=1/0,i=1/0,a=-1/0,s=-1/0;const o=t[0];for(let t=0;t<o.length;t++){const e=o[t];(!t||e.x<n)&&(n=e.x),(!t||e.y<i)&&(i=e.y),(!t||e.x>a)&&(a=e.x),(!t||e.y>s)&&(s=e.y);}const l=Math.min(a-n,s-i);let u=l/2;const c=new Zr([],nd);if(0===l)return new q(n,i);for(let e=n;e<a;e+=l)for(let r=i;r<s;r+=l)c.push(new id(e+u,r+u,u,t));let h=function(t){let e=0,r=0,n=0;const i=t[0];for(let t=0,a=i.length,s=a-1;t<a;s=t++){const a=i[t],o=i[s],l=a.x*o.y-o.x*a.y;r+=(a.x+o.x)*l,n+=(a.y+o.y)*l,e+=3*l;}return new id(r/e,n/e,0,t)}(t),p=c.length;for(;c.length;){const n=c.pop();(n.d>h.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<=e||(u=n.h/2,c.push(new id(n.p.x-u,n.p.y-u,u,t)),c.push(new id(n.p.x+u,n.p.y-u,u,t)),c.push(new id(n.p.x-u,n.p.y+u,u,t)),c.push(new id(n.p.x+u,n.p.y+u,u,t)),p+=4);}return r&&(console.log(`num probes: ${p}`),console.log(`best distance: ${h.d}`)),h.p}function nd(t,e){return e.max-t.max}class id{constructor(t,e,r,n){this.p=new q(t,e),this.h=r,this.d=function(t,e){let r=!1,n=1/0;for(let i=0;i<e.length;i++){const a=e[i];for(let e=0,i=a.length,s=i-1;e<i;s=e++){const i=a[e],o=a[s];i.y>t.y!=o.y>t.y&&t.x<(o.x-i.x)*(t.y-i.y)/(o.y-i.y)+i.x&&(r=!r),n=Math.min(n,Ol(t,i,o));}}return (r?1:-1)*Math.sqrt(n)}(this.p,n),this.max=this.d+this.h*Math.SQRT2;}}const ad=Number.POSITIVE_INFINITY,sd=Math.sqrt(2);function od(t,[e,r]){let n=0,i=0;if(r===ad){e<0&&(e=0);const r=e/sd;switch(t){case"top-right":case"top-left":i=r-7;break;case"bottom-right":case"bottom-left":i=7-r;break;case"bottom":i=7-e;break;case"top":i=e-7;}switch(t){case"top-right":case"bottom-right":n=-r;break;case"top-left":case"bottom-left":n=r;break;case"left":n=e;break;case"right":n=-e;}}else {switch(e=Math.abs(e),r=Math.abs(r),t){case"top-right":case"top-left":case"top":i=r-7;break;case"bottom-right":case"bottom-left":case"bottom":i=7-r;}switch(t){case"top-right":case"bottom-right":case"right":n=-e;break;case"top-left":case"bottom-left":case"left":n=e;}}return [n,i]}function ld(t){switch(t){case"right":case"top-right":case"bottom-right":return "right";case"left":case"top-left":case"bottom-left":return "left"}return "center"}function ud(t,e,r,n,i,a,s,o,l,u,c,h,p,f,d){let m=a.textMaxSize.evaluate(e,{},h);void 0===m?m=s*a.textScaleFactor:m*=a.textScaleFactor;const y=t.layers[0].layout,g=y.get("icon-offset").evaluate(e,{},h),x=fd(r.horizontal)||r.vertical,v="globe"===p.name,b=Xp,w=s*a.textScaleFactor/b,_=t.tilePixelRatio*m/b,M=(E=t.overscaling,t.zoom>18&&E>2&&(E>>=1),Math.max(Wr/(512*E),1)*y.get("symbol-spacing")),A=y.get("text-padding")*t.tilePixelRatio,S=y.get("icon-padding")*t.tilePixelRatio,I=Y(y.get("text-max-angle")),z="map"===y.get("text-rotation-alignment")&&"point"!==y.get("symbol-placement"),P="map"===y.get("icon-rotation-alignment")&&"point"!==y.get("symbol-placement"),k=y.get("symbol-placement"),T=M/2;var E;const B=y.get("icon-text-fit").evaluate(e,{},h),V=y.get("icon-text-fit-padding").evaluate(e,{},h),C="none"!==B;let R;!1===t.hasAnyIconTextFit&&C&&(t.hasAnyIconTextFit=!0),n&&C&&(t.allowVerticalPlacement&&r.vertical&&(R=kf(n,r.vertical,B,V,g,w)),x&&(n=kf(n,x,B,V,g,w)));const D=(s,o,m)=>{if(o.x<0||o.x>=Wr||o.y<0||o.y>=Wr)return;let y=null;if(v){const{x:t,y:e,z:r}=p.projectTilePoint(o.x,o.y,m);y={anchor:new Tf(t,e,r,0,void 0),up:p.upVector(m,o.x,o.y)};}!function(t,e,r,n,i,a,s,o,l,u,c,h,p,f,d,m,y,g,x,v,b,w,_,M,A,S,I){const z=t.addToLineVertexArray(e,n);let P,k,T,E,B,V,C,R=0,D=0,L=0,F=0,O=-1,U=-1;const j={};let N=ge("");const q=r?r.anchor:e,$="none"!==l.layout.get("icon-text-fit").evaluate(b,{},A);let G=0,X=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[G,X]=l.layout.get("text-offset").evaluate(b,{},A).map((t=>t*Xp)):(G=l.layout.get("text-radial-offset").evaluate(b,{},A)*Xp,X=ad),t.allowVerticalPlacement&&i.vertical){const t=i.vertical;if(d)V=md(t),o&&(C=md(o));else {const r=l.layout.get("text-rotate").evaluate(b,{},A)+90;T=dd(u,q,e,c,h,p,t,f,r,m),o&&(E=dd(u,q,e,c,h,p,o,g,r));}}if(a){const n=l.layout.get("icon-rotate").evaluate(b,{},A),i=Hf(a,n,_,$,w.iconScaleFactor),s=o?Hf(o,n,_,$,w.iconScaleFactor):void 0;k=dd(u,q,e,c,h,p,a,g,n),R=4*i.length;const f=t.iconSizeData;let d=null;"source"===f.kind?(d=[Yp*l.layout.get("icon-size").evaluate(b,{},A)*w.iconScaleFactor],d[0]>hd&&ft(`${t.layerIds[0]}: Value for "icon-size" is >= ${cd}. Reduce your "icon-size".`)):"composite"===f.kind&&(d=[Yp*w.compositeIconSizes[0].evaluate(b,{},A)*w.iconScaleFactor,Yp*w.compositeIconSizes[1].evaluate(b,{},A)*w.iconScaleFactor],(d[0]>hd||d[1]>hd)&&ft(`${t.layerIds[0]}: Value for "icon-size" is >= ${cd}. Reduce your "icon-size".`)),t.addSymbols(t.icon,i,d,v,x,b,!1,r,e,z.lineStartIndex,z.lineLength,-1,M,A,S,I),O=t.icon.placedSymbolArray.length-1,s&&(D=4*s.length,t.addSymbols(t.icon,s,d,v,x,b,mf.vertical,r,e,z.lineStartIndex,z.lineLength,-1,M,A,S,I),U=t.icon.placedSymbolArray.length-1);}for(const n in i.horizontal){const a=i.horizontal[n];P||(N=ge(a.text),d?B=md(a):P=dd(u,q,e,c,h,p,a,f,l.layout.get("text-rotate").evaluate(b,{},A),m));const o=1===a.positionedLines.length;if(L+=pd(t,r,e,a,s,l,d,b,m,z,i.vertical?mf.horizontal:mf.horizontalOnly,o?Object.keys(i.horizontal):[n],j,O,w,M,A,S),o)break}i.vertical&&(F+=pd(t,r,e,i.vertical,s,l,d,b,m,z,mf.vertical,["vertical"],j,U,w,M,A,S));let Y=-1;const Z=(t,e)=>t?Math.max(t,e):e;Y=Z(B,Y),Y=Z(V,Y),Y=Z(C,Y);const W=Y>-1?1:0;t.glyphOffsetArray.length>=65535&&ft("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==b.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,b.sortKey),t.symbolInstances.emplaceBack(e.x,e.y,q.x,q.y,q.z,j.right>=0?j.right:-1,j.center>=0?j.center:-1,j.left>=0?j.left:-1,j.vertical>=0?j.vertical:-1,O,U,N,void 0!==P?P:t.collisionBoxArray.length,void 0!==P?P+1:t.collisionBoxArray.length,void 0!==T?T:t.collisionBoxArray.length,void 0!==T?T+1:t.collisionBoxArray.length,void 0!==k?k:t.collisionBoxArray.length,void 0!==k?k+1:t.collisionBoxArray.length,E||t.collisionBoxArray.length,E?E+1:t.collisionBoxArray.length,c,L,F,R,D,W,0,G,X,Y,0,$?1:0);}(t,o,y,s,r,n,i,R,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,A,z,l,0,S,P,g,e,a,u,c,h,f,d);};if("line"===k)for(const i of Ff(e.geometry,0,0,Wr,Wr)){const e=Df(i,M,I,r.vertical||x,n,b,_,t.overscaling,Wr);for(const r of e)x&&yd(t,x.text,T,r)||D(i,r,h);}else if("line-center"===k){for(const t of e.geometry)if(t.length>1){const e=Rf(t,I,r.vertical||x,n,b,_);e&&D(t,e,h);}}else if("Polygon"===e.type)for(const t of Rc(e.geometry,0)){const e=rd(t,16);D(t[0],new Tf(e.x,e.y,0,0,void 0),h);}else if("LineString"===e.type)for(const t of e.geometry)D(t,new Tf(t[0].x,t[0].y,0,0,void 0),h);else if("Point"===e.type)for(const t of e.geometry)for(const e of t)D([e],new Tf(e.x,e.y,0,0,void 0),h);}const cd=255,hd=cd*Yp;function pd(t,e,r,n,i,a,s,o,l,u,c,h,p,f,d,m,y,g){const x=function(t,e,r,n,i,a,s,o){const l=[];if(0===e.positionedLines.length)return l;const u=n.layout.get("text-rotate").evaluate(a,{})*Math.PI/180,c=function(t){const e=t[0],r=t[1],n=e*r;return n>0?[e,-r]:n<0?[-e,r]:0===e?[r,e]:[r,-e]}(r);let h=Math.abs(e.top-e.bottom);for(const t of e.positionedLines)h-=t.lineOffset;const p=e.positionedLines.length,f=h/p;let d=e.top-r[1];for(let t=0;t<p;++t){const n=e.positionedLines[t];d=ed(e,f,d,t);for(const t of n.positionedGlyphs){if(!t.rect)continue;const n=t.rect||{};let a=df+1,h=!0,p=1,f=0;if(t.imageName){const e=s[t.imageName];if(!e)continue;if(e.sdf){ft("SDF images are not supported in formatted text and will be ignored.");continue}h=!1,p=e.pixelRatio,a=Uf/p;}const m=(i||o)&&t.vertical,y=t.metrics.advance*t.scale/2,g=t.metrics,x=t.rect;if(null===x)continue;o&&e.verticalizable&&(f=t.imageName?y-t.metrics.width*t.scale/2:0);const v=i?[t.x+y,t.y]:[0,0];let b=[0,0],w=[0,0],_=!1;i||(m?(w=[t.x+y+c[0],t.y+c[1]-f],_=!0):b=[t.x+y+r[0],t.y+r[1]-f]);const M=x.w*t.scale/(p*(t.localGlyph?Xf:1)),A=x.h*t.scale/(p*(t.localGlyph?Xf:1));let S,I,z,P;if(m){const e=t.y-d,r=new q(-y,y-e),n=-Math.PI/2,i=new q(...w);S=new q(-y+b[0],b[1]),S._rotateAround(n,r)._add(i),S.x+=-e+y,S.y-=(g.left-a)*t.scale;const s=t.imageName?g.advance*t.scale:Xp*t.scale,o=String.fromCodePoint(t.glyph);tf(o)?S.x+=(1-a)*t.scale:ef(o)?S.x+=s-g.height*t.scale+(-a-1)*t.scale:S.x+=t.imageName||g.width+2*a===x.w&&g.height+2*a===x.h?(s-A)/2:(s-(g.height+2*a)*t.scale)/2,I=new q(S.x,S.y-M),z=new q(S.x+A,S.y),P=new q(S.x+A,S.y-M);}else {const e=(g.left-a)*t.scale-y+b[0],r=(-g.top-a)*t.scale+b[1],n=e+M,i=r+A;S=new q(e,r),I=new q(n,r),z=new q(e,i),P=new q(n,i);}if(u){let t;t=i?new q(0,0):_?new q(c[0],c[1]):new q(r[0],r[1]),S._rotateAround(u,t),I._rotateAround(u,t),z._rotateAround(u,t),P._rotateAround(u,t);}const k=new q(0,0),T=new q(0,0);l.push({tl:S,tr:I,bl:z,br:P,texPrimary:n,texSecondary:void 0,writingMode:e.writingMode,glyphOffset:v,sectionIndex:t.sectionIndex,isSDF:h,pixelOffsetTL:k,pixelOffsetBR:T,minFontScaleX:0,minFontScaleY:0});}}return l}(0,n,l,a,s,o,i,t.allowVerticalPlacement),v=t.textSizeData;let b=null;"source"===v.kind?(b=[Yp*a.layout.get("text-size").evaluate(o,{},y)*d.textScaleFactor],b[0]>hd&&ft(`${t.layerIds[0]}: Value for "text-size" is >= ${cd}. Reduce your "text-size".`)):"composite"===v.kind&&(b=[Yp*d.compositeTextSizes[0].evaluate(o,{},y)*d.textScaleFactor,Yp*d.compositeTextSizes[1].evaluate(o,{},y)*d.textScaleFactor],(b[0]>hd||b[1]>hd)&&ft(`${t.layerIds[0]}: Value for "text-size" is >= ${cd}. Reduce your "text-size".`)),t.addSymbols(t.text,x,b,l,s,o,c,e,r,u.lineStartIndex,u.lineLength,f,m,y,g,!1);for(const e of h)p[e]=t.text.placedSymbolArray.length-1;return 4*x.length}function fd(t){for(const e in t)return t[e];return null}function dd(t,e,r,n,i,a,s,o,l,u){let c=s.top,h=s.bottom,p=s.left,f=s.right;const d=s.collisionPadding;if(d&&(p-=d[0],c-=d[1],f+=d[2],h+=d[3]),l){const t=new q(p,c),e=new q(f,c),r=new q(p,h),n=new q(f,h),i=Y(l);let a=new q(0,0);u&&(a=new q(u[0],u[1])),t._rotateAround(i,a),e._rotateAround(i,a),r._rotateAround(i,a),n._rotateAround(i,a),p=Math.min(t.x,e.x,r.x,n.x),f=Math.max(t.x,e.x,r.x,n.x),c=Math.min(t.y,e.y,r.y,n.y),h=Math.max(t.y,e.y,r.y,n.y);}return t.emplaceBack(e.x,e.y,e.z,r.x,r.y,p,c,f,h,o,n,i,a),t.length-1}function md(t){t.collisionPadding&&(t.top-=t.collisionPadding[1],t.bottom+=t.collisionPadding[3]);const e=t.bottom-t.top;return e>0?Math.max(10,e):null}function yd(t,e,r,n){const i=t.compareText;if(e in i){const t=i[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])<r)return !0}else i[e]=[];return i[e].push(n),!1}function gd(t,e){const r=t.fovAboveCenter,n=t.elevation?t.elevation.getMinElevationBelowMSL()*e:0,i=(t._camera.position[2]*t.worldSize-n)/Math.cos(t._pitch),a=Math.sin(r)*i/Math.sin(Math.max(Math.PI/2-t._pitch-r,.01));let s=Math.sin(t._pitch)*a+i;const o=i*(1/t._horizonShift);return t.elevation&&0!==t.elevation.exaggeration()||(s*=1+Math.max(t.zoom-17,0)),Math.min(1.01*s,o)}function xd(t,e){if(!e.isReprojectedInTileSpace)return {scale:1<<t.z,x:t.x,y:t.y,x2:t.x+1,y2:t.y+1,projection:e};const r=Math.pow(2,-t.z),n=t.x*r,i=(t.x+1)*r,a=t.y*r,s=(t.y+1)*r,o=hl(n),l=hl(i),u=pl(a),c=pl(s),h=e.project(o,u),p=e.project(l,u),f=e.project(l,c),d=e.project(o,c);let m=Math.min(h.x,p.x,f.x,d.x),y=Math.min(h.y,p.y,f.y,d.y),g=Math.max(h.x,p.x,f.x,d.x),x=Math.max(h.y,p.y,f.y,d.y);const v=r/16;function b(t,r,n,i,a,s){const o=(n+a)/2,l=(i+s)/2,u=e.project(hl(o),pl(l)),c=Math.max(0,m-u.x,y-u.y,u.x-g,u.y-x);m=Math.min(m,u.x),g=Math.max(g,u.x),y=Math.min(y,u.y),x=Math.max(x,u.y),c>v&&(b(t,u,n,i,o,l),b(u,r,o,l,a,s));}b(h,p,n,a,i,a),b(p,f,i,a,i,s),b(f,d,i,s,n,s),b(d,h,n,s,n,a),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:e}}function vd(t,{x:e,y:r},n=0){return new q(((e-n)*t.scale-t.x)*Wr,(r*t.scale-t.y)*Wr)}const bd=O.mat4.identity(new Float32Array(16));class wd{constructor(t){this.spec=t,this.name=t.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(t,e){return {x:0,y:0,z:0}}unproject(t,e){return new nl(0,0)}projectTilePoint(t,e,r){return {x:t,y:e,z:0}}locationPoint(t,e,r=!0){return t._coordinatePoint(t.locationCoordinate(e),r)}pixelsPerMeter(t,e){return cl(1,t)*e}pixelSpaceConversion(t,e,r){return 1}farthestPixelDistance(t){return gd(t,t.pixelsPerMeter)}pointCoordinate(t,e,r,n){const i=t.horizonLineFromTop(!1),a=new q(e,Math.max(i,r));return t.rayIntersectionCoordinate(t.pointRayIntersection(a,n))}pointCoordinate3D(t,e,r){const n=new q(e,r);if(t.elevation)return t.elevation.pointCoordinate(n);{const e=this.pointCoordinate(t,n.x,n.y,0);return [e.x,e.y,e.z]}}isPointAboveHorizon(t,e){if(t.elevation&&t.elevation.visibleDemTiles.length)return !this.pointCoordinate3D(t,e.x,e.y);const r=t.horizonLineFromTop();return e.y<r}createInversionMatrix(t,e){return bd}createTileMatrix(t,e,r){let n,i,a;const s=r.canonical,o=O.mat4.identity(new Float64Array(16));if(this.isReprojectedInTileSpace){const l=xd(s,this);n=1,i=l.x+r.wrap*l.scale,a=l.y,O.mat4.scale(o,o,[n/l.scale,n/l.scale,t.pixelsPerMeter/e]);}else n=e/t.zoomScale(s.z),i=(s.x+Math.pow(2,s.z)*r.wrap)*n,a=s.y*n;return O.mat4.translate(o,o,[i,a,0]),O.mat4.scale(o,o,[n/Wr,n/Wr,1]),o}upVector(t,e,r){return [0,0,1]}upVectorScale(t,e,r){return {metersToTile:1}}}class _d extends wd{constructor(t){super(t),this.range=[4,7],this.center=t.center||[-96,37.5];const[e,r]=this.parallels=t.parallels||[29.5,45.5],n=Math.sin(Y(e));this.n=(n+Math.sin(Y(r)))/2,this.c=1+n*(2*this.n-n),this.r0=Math.sqrt(this.c)/this.n;}project(t,e){const{n:r,c:n,r0:i}=this,a=Y(t-this.center[0]),s=Y(e),o=Math.sqrt(n-2*r*Math.sin(s))/r;return {x:o*Math.sin(a*r),y:o*Math.cos(a*r)-i,z:0}}unproject(t,e){const{n:r,c:n,r0:i}=this,a=i+e;let s=Math.atan2(t,Math.abs(a))*Math.sign(a);a*r<0&&(s-=Math.PI*Math.sign(t)*Math.sign(a));const o=Y(this.center[0])*r;s=et(s,-Math.PI-o,Math.PI-o);const l=Q(Z(s/r)+this.center[0],-180,180),u=Math.asin(Q((n-(t*t+a*a)*r*r)/(2*r),-1,1)),c=Q(Z(u),-dl,dl);return new nl(l,c)}}const Md=1.340264,Ad=-.081106,Sd=893e-6,Id=.003796,zd=Math.sqrt(3)/2;class Pd extends wd{project(t,e){e=e/180*Math.PI,t=t/180*Math.PI;const r=Math.asin(zd*Math.sin(e)),n=r*r,i=n*n*n;return {x:.5*(t*Math.cos(r)/(zd*(Md+3*Ad*n+i*(7*Sd+9*Id*n)))/Math.PI+.5),y:1-.5*(r*(Md+Ad*n+i*(Sd+Id*n))/Math.PI+1),z:0}}unproject(t,e){t=(2*t-.5)*Math.PI;let r=e=(2*(1-e)-1)*Math.PI,n=r*r,i=n*n*n;for(let t,a,s,o=0;o<12&&(a=r*(Md+Ad*n+i*(Sd+Id*n))-e,s=Md+3*Ad*n+i*(7*Sd+9*Id*n),t=a/s,r=Q(r-t,-Math.PI/3,Math.PI/3),n=r*r,i=n*n*n,!(Math.abs(t)<1e-12));++o);const a=zd*t*(Md+3*Ad*n+i*(7*Sd+9*Id*n))/Math.cos(r),s=Math.asin(Math.sin(r)/zd),o=Q(180*a/Math.PI,-180,180),l=Q(180*s/Math.PI,-dl,dl);return new nl(o,l)}}class kd extends wd{constructor(t){super(t),this.wrap=!0,this.supportsWorldCopies=!0;}project(t,e){return {x:.5+t/360,y:.5-e/360,z:0}}unproject(t,e){const r=360*(t-.5),n=Q(360*(.5-e),-dl,dl);return new nl(r,n)}}const Td=Math.PI/2;function Ed(t){return Math.tan((Td+t)/2)}class Bd extends wd{constructor(t){super(t),this.center=t.center||[0,30];const[e,r]=this.parallels=t.parallels||[30,30];let n=Y(e),i=Y(r);this.southernCenter=n+i<0,this.southernCenter&&(n=-n,i=-i);const a=Math.cos(n),s=Ed(n);this.n=n===i?Math.sin(n):Math.log(a/Math.cos(i))/Math.log(Ed(i)/s),this.f=a*Math.pow(Ed(n),this.n)/this.n;}project(t,e){e=Y(e),this.southernCenter&&(e=-e),t=Y(t-this.center[0]);const r=1e-6,{n,f:i}=this;i>0?e<-Td+r&&(e=-Td+r):e>Td-r&&(e=Td-r);const a=i/Math.pow(Ed(e),n);let s=a*Math.sin(n*t),o=i-a*Math.cos(n*t);return s=.5*(s/Math.PI+.5),o=.5*(o/Math.PI+.5),{x:s,y:this.southernCenter?o:1-o,z:0}}unproject(t,e){t=(2*t-.5)*Math.PI,this.southernCenter&&(e=1-e),e=(2*(1-e)-.5)*Math.PI;const{n:r,f:n}=this,i=n-e,a=Math.sign(i),s=Math.sign(r)*Math.sqrt(t*t+i*i);let o=Math.atan2(t,Math.abs(i))*a;i*r<0&&(o-=Math.PI*Math.sign(t)*a);const l=Q(Z(o/r)+this.center[0],-180,180),u=Q(Z(2*Math.atan(Math.pow(n/s,1/r))-Td),-dl,dl);return new nl(l,this.southernCenter?-u:u)}}class Vd extends wd{constructor(t){super(t),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null;}project(t,e){return {x:ll(t),y:ul(e),z:0}}unproject(t,e){const r=hl(t),n=pl(e);return new nl(r,n)}}const Cd=Y(dl);class Rd extends wd{project(t,e){const r=(e=Y(e))*e,n=r*r;return {x:.5*((t=Y(t))*(.8707-.131979*r+n*(n*(.003971*r-.001529*n)-.013791))/Math.PI+.5),y:1-.5*(e*(1.007226+r*(.015085+n*(.028874*r-.044475-.005916*n)))/Math.PI+1),z:0}}unproject(t,e){t=(2*t-.5)*Math.PI;let r=e=(2*(1-e)-1)*Math.PI,n=25,i=0,a=r*r;do{a=r*r;const t=a*a;i=(r*(1.007226+a*(.015085+t*(.028874*a-.044475-.005916*t)))-e)/(1.007226+a*(.045255+t*(.259866*a-.311325-.005916*11*t))),r=Q(r-i,-Cd,Cd);}while(Math.abs(i)>1e-6&&--n>0);a=r*r;const s=Q(Z(t/(.8707+a*(a*(a*a*a*(.003971-.001529*a)-.013791)-.131979))),-180,180),o=Z(r);return new nl(s,o)}}const Dd=Y(dl);class Ld extends wd{project(t,e){e=Y(e),t=Y(t);const r=Math.cos(e),n=2/Math.PI,i=Math.acos(r*Math.cos(t/2)),a=Math.sin(i)/i,s=.5*(t*n+2*r*Math.sin(t/2)/a)||0,o=.5*(e+Math.sin(e)/a)||0;return {x:.5*(s/Math.PI+.5),y:1-.5*(o/Math.PI+1),z:0}}unproject(t,e){let r=t=(2*t-.5)*Math.PI,n=e=(2*(1-e)-1)*Math.PI,i=25;const a=1e-6;let s=0,o=0;do{const i=Math.cos(n),a=Math.sin(n),l=2*a*i,u=a*a,c=i*i,h=Math.cos(r/2),p=Math.sin(r/2),f=2*h*p,d=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)-t,v=.5*(g*a+n)-e,b=.5*y*(c*d+g*i*h*u)+1/Math.PI,w=y*(f*l/4-g*a*p),_=.125*y*(l*p-g*a*c*f),M=.5*y*(u*h+g*d*i)+.5,A=w*_-M*b;s=(v*w-x*M)/A,o=(x*_-v*b)/A,r=Q(r-s,-Math.PI,Math.PI),n=Q(n-o,-Dd,Dd);}while((Math.abs(s)>a||Math.abs(o)>a)&&--i>0);return new nl(Z(r),Z(n))}}class Fd extends wd{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Y(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0;}project(t,e){const{scale:r,cosPhi:n}=this;return {x:Y(t)*n*r+.5,y:-Math.sin(Y(e))/n*r+.5,z:0}}unproject(t,e){const{scale:r,cosPhi:n}=this,i=-(e-.5)/r,a=Q(Z((t-.5)/r)/n,-180,180),s=Math.asin(Q(i*n,-1,1)),o=Q(Z(s),-dl,dl);return new nl(a,o)}}class Od extends Vd{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5];}projectTilePoint(t,e,r){const n=ku(t,e,r),i=Bu(Mu(r));return O.vec3.transformMat4(n,n,i),{x:n[0],y:n[1],z:n[2]}}locationPoint(t,e){const r=tl(e.lat,e.lng),n=O.vec3.normalize([],r),i=t.elevation?t.elevation.getAtPointOrZero(t.locationCoordinate(e),t._centerAltitude):t._centerAltitude,a=cl(1,0)*Wr*i;O.vec3.scaleAndAdd(r,r,n,a);const s=O.mat4.identity(new Float64Array(16));return O.mat4.multiply(s,t.pixelMatrix,t.globeMatrix),O.vec3.transformMat4(r,r,s),new q(r[0],r[1])}pixelsPerMeter(t,e){return cl(1,0)*e}pixelSpaceConversion(t,e,r){const n=cl(1,t)*e,i=Pe(cl(1,45)*e,n,r);return this.pixelsPerMeter(t,e)/i}createTileMatrix(t,e,r){const n=Vu(Mu(r.canonical));return O.mat4.multiply(new Float64Array(16),t.globeMatrix,n)}createInversionMatrix(t,e){const{center:r}=t,n=Bu(Mu(e));return O.mat4.rotateY(n,n,Y(r.lng)),O.mat4.rotateX(n,n,Y(r.lat)),O.mat4.scale(n,n,[t._pixelsPerMercatorPixel,t._pixelsPerMercatorPixel,1]),Float32Array.from(n)}pointCoordinate(t,e,r,n){return bu(t,e,r,!0)||new vl(0,0)}pointCoordinate3D(t,e,r){const n=this.pointCoordinate(t,e,r,0);return [n.x,n.y,n.z]}isPointAboveHorizon(t,e){return !bu(t,e.x,e.y,!1)}farthestPixelDistance(t){const e=function(t,e){const r=t.cameraToCenterDistance,n=t._centerAltitude*e,i=t._camera,a=t._camera.forward(),s=O.vec3.add([],O.vec3.scale([],a,-r),[0,0,n]),o=t.worldSize/(2*Math.PI),l=[0,0,-o],u=t.width/t.height,c=Math.tan(t.fovAboveCenter),h=O.vec3.scale([],i.up(),c),p=O.vec3.scale([],i.right(),c*u),f=O.vec3.normalize([],O.vec3.add([],O.vec3.add([],a,h),p)),d=[];let m;if(new cu(s,f).closestPointOnSphere(l,o,d)){const e=O.vec3.add([],d,l),r=O.vec3.sub([],e,s);m=Math.cos(t.fovAboveCenter)*O.vec3.length(r);}else {const t=O.vec3.sub([],s,l),e=O.vec3.sub([],l,s);O.vec3.normalize(e,e);const r=O.vec3.length(t)-o;m=Math.sqrt(r*(r+2*o));const n=Math.acos(m/(o+r))-Math.acos(O.vec3.dot(a,e));m*=Math.cos(n);}return 1.01*m}(t,this.pixelsPerMeter(t.center.lat,t.worldSize)),r=Lu(t.zoom);if(r>0){const n=gd(t,cl(1,t.center.lat)*t.worldSize),i=t.worldSize/(2*Math.PI),a=Math.max(t.width,t.height)/t.worldSize*Math.PI;return Pe(e,n+i*(1-Math.cos(a)),Math.pow(r,10))}return e}upVector(t,e,r){return ku(e,r,t,1)}upVectorScale(t){return {metersToTile:xu(Tu(Mu(t)))}}}function Ud(t){const e=t.parallels,r=!!e&&Math.abs(e[0]+e[1])<.01;switch(t.name){case"mercator":return new Vd(t);case"equirectangular":return new kd(t);case"naturalEarth":return new Rd(t);case"equalEarth":return new Pd(t);case"winkelTripel":return new Ld(t);case"albers":return r?new Fd(t):new _d(t);case"lambertConformalConic":return r?new Fd(t):new Bd(t);case"globe":return new Od(t)}throw new Error(`Invalid projection name: ${t.name}`)}const jd=hh.VectorTileFeature.types,Nd=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function qd(t,e,r,n,i,a,s,o,l,u,c,h,p){const f=o?Math.min(hd,Math.round(o[0])):0,d=o?Math.min(hd,Math.round(o[1])):0;t.emplaceBack(e,r,Math.round(32*n),Math.round(32*i),a,s,(f<<1)+(l?1:0),d,16*u,16*c,256*h,256*p);}function $d(t,e,r){t.emplaceBack(e,r);}function Gd(t,e,r,n,i,a,s){t.emplaceBack(e,r,n,i,a,s);}function Xd(t,e,r,n,i){t.emplaceBack(e,r,n,i),t.emplaceBack(e,r,n,i),t.emplaceBack(e,r,n,i),t.emplaceBack(e,r,n,i);}function Yd(t){for(const e of t.sections)if(va(e.text))return !0;return !1}class Zd{constructor(t){this.layoutVertexArray=new zs,this.indexArray=new Rs,this.programConfigurations=t,this.segments=new ho,this.dynamicLayoutVertexArray=new _s,this.opacityVertexArray=new ks,this.placedSymbolArray=new Qs,this.iconTransitioningVertexArray=new Ts,this.globeExtVertexArray=new Ps,this.zOffsetVertexArray=new Fs;}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length&&0===this.iconTransitioningVertexArray.length}upload(t,e,r,n,i){this.isEmpty()||(r&&(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Lp.members),this.indexBuffer=t.createIndexBuffer(this.indexArray,e),this.dynamicLayoutVertexBuffer=t.createVertexBuffer(this.dynamicLayoutVertexArray,Op.members,!0),this.opacityVertexBuffer=t.createVertexBuffer(this.opacityVertexArray,Nd,!0),this.iconTransitioningVertexArray.length>0&&(this.iconTransitioningVertexBuffer=t.createVertexBuffer(this.iconTransitioningVertexArray,jp.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,Fp.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||i)&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,Up.members,!0)),this.opacityVertexBuffer.itemSize=1),(r||n)&&this.programConfigurations.upload(t));}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());}}sa(Zd,"SymbolBuffers");class Wd{constructor(t,e,r){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new r,this.segments=new ho,this.collisionVertexArray=new Cs,this.collisionVertexArrayExt=new _s;}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Np.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,qp.members,!0);}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy());}}sa(Wd,"CollisionBuffers");class Hd{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.lut=t.lut,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=O.mat4.identity([]),this.placementViewportMatrix=O.mat4.identity([]);const e=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Zp(this.zoom,e["text-size"]),this.iconSizeData=Zp(this.zoom,e["icon-size"]);const r=this.layers[0].layout,n=r.get("symbol-sort-key"),i=r.get("symbol-z-order");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((t=>mf[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=t.sourceID,this.projection=t.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=r.get("symbol-z-elevate"),this.activeReplacements=[],this.replacementUpdateTime=0;}createArrays(){this.text=new Zd(new Oo(this.layers,{zoom:this.zoom,lut:this.lut},(t=>t.startsWith("text")||t.startsWith("symbol")))),this.icon=new Zd(new Oo(this.layers,{zoom:this.zoom,lut:this.lut},(t=>t.startsWith("icon")||t.startsWith("symbol")))),this.glyphOffsetArray=new ro,this.lineVertexArray=new no,this.symbolInstances=new eo;}calculateGlyphDependencies(t,e,r,n,i){for(const r of t){const t=r.codePointAt(0);if(void 0===t)break;if(e[t]=!0,n&&i&&t<=65535){const t=Qp[r];t&&(e[t.charCodeAt(0)]=!0);}}}updateFootprints(t,e){}updateReplacement(t,e){if(e.updateTime===this.replacementUpdateTime)return !1;this.replacementUpdateTime=e.updateTime;const r=e.getReplacementRegionsForTile(t.toUnwrapped(),!0);return !_h(this.activeReplacements,r)&&(this.activeReplacements=r,!0)}populate(t,e,r,n){const i=this.layers[0],a=i.layout,s="globe"===this.projection.name,o=a.get("text-font"),l=a.get("text-field"),u=a.get("icon-image"),c=("constant"!==l.value.kind||l.value.value instanceof Je&&!l.value.value.isEmpty()||l.value.value.toString().length>0)&&("constant"!==o.value.kind||o.value.value.length>0),h="constant"!==u.value.kind||!!u.value.value||Object.keys(u.parameters).length>0,p=a.get("symbol-sort-key");if(this.features=[],!c&&!h)return;const f=e.iconDependencies,d=e.glyphDependencies,m=e.availableImages,y=new Ba(this.zoom);for(const{feature:e,id:l,index:u,sourceLayerIndex:g}of t){const t=i._featureFilter.needGeometry,x=Pl(e,t);if(!i._featureFilter.filter(y,x,r))continue;if(t||(x.geometry=zl(e,r,n)),s&&1!==e.type&&r.z<=5){const t=x.geometry,e=.98078528056,n=(t,n)=>{const i=ku(t.x,t.y,r,1),a=ku(n.x,n.y,r,1);return O.vec3.dot(i,a)<e};for(let e=0;e<t.length;e++)t[e]=Ml(t[e],n);}let v,b;if(c){const t=i.getValueAndResolveTokens("text-field",x,r,m),e=Je.factory(t);Yd(e)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===ka()||this.hasRTLText&&Ea.isParsed())&&(v=Jp(e,i,x));}if(h){const t=i.getValueAndResolveTokens("icon-image",x,r,m);b=t instanceof Qe?t:Qe.fromString(t);}if(!v&&!b)continue;const w=this.sortFeaturesByKey?p.evaluate(x,{},r):void 0;if(this.features.push({id:l,text:v,icon:b,index:u,sourceLayerIndex:g,geometry:x.geometry,properties:e.properties,type:jd[e.type],sortKey:w}),b&&(f[b.namePrimary]=!0,b.nameSecondary&&(f[b.nameSecondary]=!0)),v){const t=o.evaluate(x,{},r).join(","),e="map"===a.get("text-rotation-alignment")&&"point"!==a.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(mf.vertical)>=0;for(const r of v.sections)if(r.image)f[r.image.namePrimary]=!0;else {const n=pa(v.toString()),i=r.fontStack||t,a=d[i]=d[i]||{};this.calculateGlyphDependencies(r.text,a,e,this.allowVerticalPlacement,n);}}}"line"===a.get("symbol-placement")&&(this.features=function(t){const e={},r={},n=[];let i=0;function a(e){n.push(t[e]),i++;}function s(t,e,i){const a=r[t];return delete r[t],r[e]=a,n[a].geometry[0].pop(),n[a].geometry[0]=n[a].geometry[0].concat(i[0]),a}function o(t,r,i){const a=e[r];return delete e[r],e[t]=a,n[a].geometry[0].shift(),n[a].geometry[0]=i[0].concat(n[a].geometry[0]),a}function l(t,e,r){const n=r?e[0][e[0].length-1]:e[0][0];return `${t}:${n.x}:${n.y}`}for(let u=0;u<t.length;u++){const c=t[u],h=c.geometry,p=c.text?c.text.toString():null;if(!p){a(u);continue}const f=l(p,h),d=l(p,h,!0);if(f in r&&d in e&&r[f]!==e[d]){const t=o(f,d,h),i=s(f,d,n[t].geometry);delete e[f],delete r[d],r[l(p,n[i].geometry,!0)]=i,n[t].geometry=null;}else f in r?s(f,d,h):d in e?o(f,d,h):(a(u),e[f]=i-1,r[d]=i-1);}return n.filter((t=>t.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey));}update(t,e,r,n,i){const a=0!==Object.keys(t).length;if(a&&!this.stateDependentLayers.length)return;const s=a?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(t,e,s,r,n,i),this.icon.programConfigurations.updatePaintArrays(t,e,s,r,n,i);}updateZOffset(){const t=(t,e,n)=>{r+=e,r>t.length&&t.resize(r);for(let i=-e;i<0;i++)t.emplace(i+r,n);},e=(t,e,r)=>{n+=e,n>t.length&&t.resize(n);for(let i=-e;i<0;i++)t.emplace(i+n,r);};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let r=0,n=0;for(let r=0;r<this.symbolInstances.length;r++){const n=this.symbolInstances.get(r),{numHorizontalGlyphVertices:i,numVerticalGlyphVertices:a,numIconVertices:s}=n,o=n.zOffset,l=s>0;if((i>0||a>0)&&(t(this.text.zOffsetVertexArray,i,o),t(this.text.zOffsetVertexArray,a,o)),l){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:r}=n;t>=0&&e(this.icon.zOffsetVertexArray,s,o),r>=0&&e(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,o);}}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(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.uploaded=!0;}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy();}getProjection(){return this.projectionInstance||(this.projectionInstance=Ud(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData();}addToLineVertexArray(t,e){const r=this.lineVertexArray.length;if(void 0!==t.segment)for(const{x:t,y:r}of e)this.lineVertexArray.emplaceBack(t,r);return {lineStartIndex:r,lineLength:this.lineVertexArray.length-r}}addSymbols(t,e,r,n,i,a,s,o,l,u,c,h,p,f,d,m){const y=t.indexArray,g=t.layoutVertexArray,x=t.globeExtVertexArray,v=t.segments.prepareSegment(4*e.length,g,y,this.canOverlap?a.sortKey:void 0),b=this.glyphOffsetArray.length,w=v.vertexLength,_=this.allowVerticalPlacement&&s===mf.vertical?Math.PI/2:0,M=a.text&&a.text.sections;for(let n=0;n<e.length;n++){const{tl:i,tr:s,bl:u,br:c,texPrimary:h,texSecondary:b,pixelOffsetTL:w,pixelOffsetBR:A,minFontScaleX:S,minFontScaleY:I,glyphOffset:z,isSDF:P,sectionIndex:k}=e[n],T=v.vertexLength,E=z[1];if(qd(g,l.x,l.y,i.x,E+i.y,h.x,h.y,r,P,w.x,w.y,S,I),qd(g,l.x,l.y,s.x,E+s.y,h.x+h.w,h.y,r,P,A.x,w.y,S,I),qd(g,l.x,l.y,u.x,E+u.y,h.x,h.y+h.h,r,P,w.x,A.y,S,I),qd(g,l.x,l.y,c.x,E+c.y,h.x+h.w,h.y+h.h,r,P,A.x,A.y,S,I),o){const{x:e,y:r,z:n}=o.anchor,[i,a,s]=o.up;Gd(x,e,r,n,i,a,s),Gd(x,e,r,n,i,a,s),Gd(x,e,r,n,i,a,s),Gd(x,e,r,n,i,a,s),Xd(t.dynamicLayoutVertexArray,e,r,n,_);}else Xd(t.dynamicLayoutVertexArray,l.x,l.y,l.z,_);if(m){const e=b||h;$d(t.iconTransitioningVertexArray,e.x,e.y),$d(t.iconTransitioningVertexArray,e.x+e.w,e.y),$d(t.iconTransitioningVertexArray,e.x,e.y+e.h),$d(t.iconTransitioningVertexArray,e.x+e.w,e.y+e.h);}y.emplaceBack(T,T+1,T+2),y.emplaceBack(T+1,T+2,T+3),v.vertexLength+=4,v.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(z[0]),n!==e.length-1&&k===e[n+1].sectionIndex||t.programConfigurations.populatePaintArrays(g.length,a,a.index,{},p,f,d,M&&M[k]);}const A=o?o.anchor:l;t.placedSymbolArray.emplaceBack(A.x,A.y,A.z,l.x,l.y,b,this.glyphOffsetArray.length-b,w,u,c,l.segment,r?r[0]:0,r?r[1]:0,n[0],n[1],s,0,!1,0,h,0);}_commitLayoutVertex(t,e,r,n,i,a,s){t.emplaceBack(e,r,n,i,a,Math.round(s.x),Math.round(s.y));}_addCollisionDebugVertices(t,e,r,n,i,a,s){const o=r.segments.prepareSegment(4,r.layoutVertexArray,r.indexArray),l=o.vertexLength,u=s.tileAnchorX,c=s.tileAnchorY;for(let t=0;t<4;t++)r.collisionVertexArray.emplaceBack(0,0,0,0,0,0);this._commitDebugCollisionVertexUpdate(r.collisionVertexArrayExt,e,t.padding,s.zOffset),this._commitLayoutVertex(r.layoutVertexArray,n,i,a,u,c,new q(t.x1,t.y1)),this._commitLayoutVertex(r.layoutVertexArray,n,i,a,u,c,new q(t.x2,t.y1)),this._commitLayoutVertex(r.layoutVertexArray,n,i,a,u,c,new q(t.x2,t.y2)),this._commitLayoutVertex(r.layoutVertexArray,n,i,a,u,c,new q(t.x1,t.y2)),o.vertexLength+=4;const h=r.indexArray;h.emplaceBack(l,l+1),h.emplaceBack(l+1,l+2),h.emplaceBack(l+2,l+3),h.emplaceBack(l+3,l),o.primitiveLength+=4;}_addTextDebugCollisionBoxes(t,e,r,n,i,a){for(let s=n;s<i;s++){const n=r.get(s),i=this.getSymbolInstanceTextSize(t,a,e,s);this._addCollisionDebugVertices(n,i,this.textCollisionBox,n.projectedAnchorX,n.projectedAnchorY,n.projectedAnchorZ,a);}}_addIconDebugCollisionBoxes(t,e,r,n,i,a){for(let s=n;s<i;s++){const n=r.get(s),i=this.getSymbolInstanceIconSize(t,e,a.placedIconSymbolIndex);this._addCollisionDebugVertices(n,i,this.iconCollisionBox,n.projectedAnchorX,n.projectedAnchorY,n.projectedAnchorZ,a);}}generateCollisionDebugBuffers(t,e,r){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new Wd(Bs,$p.members,Ts),this.iconCollisionBox=new Wd(Bs,$p.members,Ts);const n=Hp(this.iconSizeData,t),i=Hp(this.textSizeData,t,r);for(let r=0;r<this.symbolInstances.length;r++){const a=this.symbolInstances.get(r);this._addTextDebugCollisionBoxes(i,t,e,a.textBoxStartIndex,a.textBoxEndIndex,a),this._addTextDebugCollisionBoxes(i,t,e,a.verticalTextBoxStartIndex,a.verticalTextBoxEndIndex,a),this._addIconDebugCollisionBoxes(n,t,e,a.iconBoxStartIndex,a.iconBoxEndIndex,a),this._addIconDebugCollisionBoxes(n,t,e,a.verticalIconBoxStartIndex,a.verticalIconBoxEndIndex,a);}}getSymbolInstanceTextSize(t,e,r,n){const i=this.text.placedSymbolArray.get(e.rightJustifiedTextSymbolIndex>=0?e.rightJustifiedTextSymbolIndex:e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.leftJustifiedTextSymbolIndex>=0?e.leftJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex>=0?e.verticalPlacedTextSymbolIndex:n),a=Wp(this.textSizeData,t,i)/Xp;return this.tilePixelRatio*a}getSymbolInstanceIconSize(t,e,r){const n=this.icon.placedSymbolArray.get(r),i=Wp(this.iconSizeData,t,n);return this.tilePixelRatio*i}_commitDebugCollisionVertexUpdate(t,e,r,n){t.emplaceBack(e,-r,-r,n),t.emplaceBack(e,r,-r,n),t.emplaceBack(e,r,r,n),t.emplaceBack(e,-r,r,n);}_updateTextDebugCollisionBoxes(t,e,r,n,i,a,s){for(let s=n;s<i;s++){const n=r.get(s),i=this.getSymbolInstanceTextSize(t,a,e,s);this._commitDebugCollisionVertexUpdate(this.textCollisionBox.collisionVertexArrayExt,i,n.padding,a.zOffset);}}_updateIconDebugCollisionBoxes(t,e,r,n,i,a,s){for(let s=n;s<i;s++){const n=r.get(s),i=this.getSymbolInstanceIconSize(t,e,a.placedIconSymbolIndex);this._commitDebugCollisionVertexUpdate(this.iconCollisionBox.collisionVertexArrayExt,i,n.padding,a.zOffset);}}updateCollisionDebugBuffers(t,e,r,n){if(!this.hasDebugData())return;this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexArrayExt.clear(),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexArrayExt.clear();const i=Hp(this.iconSizeData,t,n),a=Hp(this.textSizeData,t,r);for(let s=0;s<this.symbolInstances.length;s++){const o=this.symbolInstances.get(s);this._updateTextDebugCollisionBoxes(a,t,e,o.textBoxStartIndex,o.textBoxEndIndex,o,r),this._updateTextDebugCollisionBoxes(a,t,e,o.verticalTextBoxStartIndex,o.verticalTextBoxEndIndex,o,r),this._updateIconDebugCollisionBoxes(i,t,e,o.iconBoxStartIndex,o.iconBoxEndIndex,o,n),this._updateIconDebugCollisionBoxes(i,t,e,o.verticalIconBoxStartIndex,o.verticalIconBoxEndIndex,o,n);}this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexBufferExt&&this.textCollisionBox.collisionVertexBufferExt.updateData(this.textCollisionBox.collisionVertexArrayExt),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexBufferExt&&this.iconCollisionBox.collisionVertexBufferExt.updateData(this.iconCollisionBox.collisionVertexArrayExt);}_deserializeCollisionBoxesForSymbol(t,e,r,n,i,a,s,o,l){const u={};if(e<r){const{x1:r,y1:n,x2:i,y2:a,padding:s,projectedAnchorX:o,projectedAnchorY:l,projectedAnchorZ:c,tileAnchorX:h,tileAnchorY:p,featureIndex:f}=t.get(e);u.textBox={x1:r,y1:n,x2:i,y2:a,padding:s,projectedAnchorX:o,projectedAnchorY:l,projectedAnchorZ:c,tileAnchorX:h,tileAnchorY:p},u.textFeatureIndex=f;}if(n<i){const{x1:e,y1:r,x2:i,y2:a,padding:s,projectedAnchorX:o,projectedAnchorY:l,projectedAnchorZ:c,tileAnchorX:h,tileAnchorY:p,featureIndex:f}=t.get(n);u.verticalTextBox={x1:e,y1:r,x2:i,y2:a,padding:s,projectedAnchorX:o,projectedAnchorY:l,projectedAnchorZ:c,tileAnchorX:h,tileAnchorY:p},u.verticalTextFeatureIndex=f;}if(a<s){const{x1:e,y1:r,x2:n,y2:i,padding:s,projectedAnchorX:o,projectedAnchorY:l,projectedAnchorZ:c,tileAnchorX:h,tileAnchorY:p,featureIndex:f}=t.get(a);u.iconBox={x1:e,y1:r,x2:n,y2:i,padding:s,projectedAnchorX:o,projectedAnchorY:l,projectedAnchorZ:c,tileAnchorX:h,tileAnchorY:p},u.iconFeatureIndex=f;}if(o<l){const{x1:e,y1:r,x2:n,y2:i,padding:a,projectedAnchorX:s,projectedAnchorY:l,projectedAnchorZ:c,tileAnchorX:h,tileAnchorY:p,featureIndex:f}=t.get(o);u.verticalIconBox={x1:e,y1:r,x2:n,y2:i,padding:a,projectedAnchorX:s,projectedAnchorY:l,projectedAnchorZ:c,tileAnchorX:h,tileAnchorY:p},u.verticalIconFeatureIndex=f;}return u}deserializeCollisionBoxes(t){this.collisionArrays=[];for(let e=0;e<this.symbolInstances.length;e++){const r=this.symbolInstances.get(e);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(t,r.textBoxStartIndex,r.textBoxEndIndex,r.verticalTextBoxStartIndex,r.verticalTextBoxEndIndex,r.iconBoxStartIndex,r.iconBoxEndIndex,r.verticalIconBoxStartIndex,r.verticalIconBoxEndIndex));}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(t,e){const r=t.placedSymbolArray.get(e),n=r.vertexStartIndex+4*r.numGlyphs;for(let e=r.vertexStartIndex;e<n;e+=4)t.indexArray.emplaceBack(e,e+1,e+2),t.indexArray.emplaceBack(e+1,e+2,e+3);}getSortedSymbolIndexes(t){if(this.sortedAngle===t&&void 0!==this.symbolInstanceIndexes)return this.symbolInstanceIndexes;const e=Math.sin(t),r=Math.cos(t),n=[],i=[],a=[];for(let t=0;t<this.symbolInstances.length;++t){a.push(t);const s=this.symbolInstances.get(t);n.push(0|Math.round(e*s.tileAnchorX+r*s.tileAnchorY)),i.push(s.featureIndex);}return a.sort(((t,e)=>n[t]-n[e]||i[e]-i[t])),a}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let t=0;t<this.symbolInstances.length;++t)this.symbolInstanceIndexesSortedZOffset.push(t);}return this.zOffsetSortDirty=!1,this.symbolInstanceIndexesSortedZOffset.sort(((t,e)=>this.symbolInstances.get(e).zOffset-this.symbolInstances.get(t).zOffset))}addToSortKeyRanges(t,e){const r=this.sortKeyRanges[this.sortKeyRanges.length-1];r&&r.sortKey===e?r.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1});}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex);const{rightJustifiedTextSymbolIndex:r,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:i,verticalPlacedTextSymbolIndex:a,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:o}=e;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),a>=0&&this.addIndicesForPlacedSymbol(this.text,a),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),o>=0&&this.addIndicesForPlacedSymbol(this.icon,o);}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray);}}}let Kd,Jd,Qd;sa(Hd,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Hd.addDynamicAttributes=Xd;class tm{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:Ce,this.defaultValue=t;}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression);}outputDefined(){return !1}serialize(){return null}}sa(tm,"FormatSectionOverride",{omit:["defaultValue"]});const em=()=>Qd||(Qd={layout:Kd||(Kd=new $a({"symbol-placement":new ja(Ga.layout_symbol["symbol-placement"]),"symbol-spacing":new ja(Ga.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new ja(Ga.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Na(Ga.layout_symbol["symbol-sort-key"]),"symbol-z-order":new ja(Ga.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new ja(Ga.layout_symbol["symbol-z-elevate"]),"symbol-elevation-reference":new ja(Ga.layout_symbol["symbol-elevation-reference"]),"icon-allow-overlap":new ja(Ga.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new ja(Ga.layout_symbol["icon-ignore-placement"]),"icon-optional":new ja(Ga.layout_symbol["icon-optional"]),"icon-rotation-alignment":new ja(Ga.layout_symbol["icon-rotation-alignment"]),"icon-size":new Na(Ga.layout_symbol["icon-size"]),"icon-size-scale-range":new ja(Ga.layout_symbol["icon-size-scale-range"]),"icon-text-fit":new Na(Ga.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Na(Ga.layout_symbol["icon-text-fit-padding"]),"icon-image":new Na(Ga.layout_symbol["icon-image"]),"icon-rotate":new Na(Ga.layout_symbol["icon-rotate"]),"icon-padding":new ja(Ga.layout_symbol["icon-padding"]),"icon-keep-upright":new ja(Ga.layout_symbol["icon-keep-upright"]),"icon-offset":new Na(Ga.layout_symbol["icon-offset"]),"icon-anchor":new Na(Ga.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new ja(Ga.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new ja(Ga.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new ja(Ga.layout_symbol["text-rotation-alignment"]),"text-field":new Na(Ga.layout_symbol["text-field"]),"text-font":new Na(Ga.layout_symbol["text-font"]),"text-size":new Na(Ga.layout_symbol["text-size"]),"text-size-scale-range":new ja(Ga.layout_symbol["text-size-scale-range"]),"text-max-width":new Na(Ga.layout_symbol["text-max-width"]),"text-line-height":new Na(Ga.layout_symbol["text-line-height"]),"text-letter-spacing":new Na(Ga.layout_symbol["text-letter-spacing"]),"text-justify":new Na(Ga.layout_symbol["text-justify"]),"text-radial-offset":new Na(Ga.layout_symbol["text-radial-offset"]),"text-variable-anchor":new ja(Ga.layout_symbol["text-variable-anchor"]),"text-anchor":new Na(Ga.layout_symbol["text-anchor"]),"text-max-angle":new ja(Ga.layout_symbol["text-max-angle"]),"text-writing-mode":new ja(Ga.layout_symbol["text-writing-mode"]),"text-rotate":new Na(Ga.layout_symbol["text-rotate"]),"text-padding":new ja(Ga.layout_symbol["text-padding"]),"text-keep-upright":new ja(Ga.layout_symbol["text-keep-upright"]),"text-transform":new Na(Ga.layout_symbol["text-transform"]),"text-offset":new Na(Ga.layout_symbol["text-offset"]),"text-allow-overlap":new ja(Ga.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new ja(Ga.layout_symbol["text-ignore-placement"]),"text-optional":new ja(Ga.layout_symbol["text-optional"]),visibility:new ja(Ga.layout_symbol.visibility)})),paint:Jd||(Jd=new $a({"icon-opacity":new Na(Ga.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new Na(Ga.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new Na(Ga.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new Na(Ga.paint_symbol["text-emissive-strength"]),"icon-color":new Na(Ga.paint_symbol["icon-color"]),"icon-halo-color":new Na(Ga.paint_symbol["icon-halo-color"]),"icon-halo-width":new Na(Ga.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Na(Ga.paint_symbol["icon-halo-blur"]),"icon-translate":new ja(Ga.paint_symbol["icon-translate"]),"icon-translate-anchor":new ja(Ga.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new Na(Ga.paint_symbol["icon-image-cross-fade"]),"text-opacity":new Na(Ga.paint_symbol["text-opacity"]),"text-occlusion-opacity":new Na(Ga.paint_symbol["text-occlusion-opacity"]),"text-color":new Na(Ga.paint_symbol["text-color"],{runtimeType:Fe,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new Na(Ga.paint_symbol["text-halo-color"]),"text-halo-width":new Na(Ga.paint_symbol["text-halo-width"]),"text-halo-blur":new Na(Ga.paint_symbol["text-halo-blur"]),"text-translate":new ja(Ga.paint_symbol["text-translate"]),"text-translate-anchor":new ja(Ga.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new ja(Ga.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new ja(Ga.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new ja(Ga.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new ja(Ga.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new Na(Ga.paint_symbol["symbol-z-offset"])}))},Qd);class rm extends hs{constructor(t,e,r,n){super(t,em(),e,r,n),this._colorAdjustmentMatrix=O.mat4.identity([]),this.hasInitialOcclusionOpacityProperties=void 0!==t.paint&&("icon-occlusion-opacity"in t.paint||"text-occlusion-opacity"in t.paint);}recalculate(t,e){super.recalculate(t,e),"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 t=[];for(const e of r)t.indexOf(e)<0&&t.push(e);this.layout._values["text-writing-mode"]=t;}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides();}getColorAdjustmentMatrix(t,e,r,n){return this._saturation===t&&this._contrast===e&&this._brightnessMin===r&&this._brightnessMax===n||(this._colorAdjustmentMatrix=function(t,e,r,n){t=At(t),e=Mt(e);const i=O.mat4.create(),a=t/3,s=1-2*a,o=[s,a,a,0,a,s,a,0,a,a,s,0,0,0,0,1],l=.5-.5*e,u=n-r;return O.mat4.multiply(i,[u,0,0,0,0,u,0,0,0,0,u,0,r,r,r,1],[e,0,0,0,0,e,0,0,0,0,e,0,l,l,l,1]),O.mat4.multiply(i,i,o),i}(t,e,r,n),this._saturation=t,this._contrast=e,this._brightnessMin=r,this._brightnessMax=n),this._colorAdjustmentMatrix}getValueAndResolveTokens(t,e,r,n){const i=this.layout.get(t).evaluate(e,{},r,n),a=this._unevaluatedLayout._values[t];return a.isDataDriven()||Zi(a.value)||!i?i:function(t,e){return e.replace(/{([^{}]+)}/g,((e,r)=>r in t?String(t[r]):""))}(e.properties,i)}createBucket(t){return new Hd(t)}queryRadius(){return 0}queryIntersectsFeature(){return !1}_setPaintOverrides(){for(const t of em().paint.overridableProperties){if(!rm.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),r=new tm(e),n=new Yi(r,e.property.specification,this.scope,this.options);let i=null;i="constant"===e.value.kind||"source"===e.value.kind?new Hi("source",n):new Ki("composite",n,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new Oa(e.property,i,e.parameters);}}_handleOverridablePaintPropertyUpdate(t,e,r){return !(!this.layout||e.isDataDriven()||r.isDataDriven())&&rm.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const r=t.get("text-field"),n=em().paint.properties[e];let i=!1;const a=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(i=!0)};if("constant"===r.value.kind&&r.value.value instanceof Je)a(r.value.value.sections);else if("source"===r.value.kind){const t=e=>{i||(e instanceof ir&&rr(e.value)===Ne?a(e.value.sections):e instanceof lr?a(e.sections):e.eachChild(t));},e=r.value;e._styleExpression&&t(e._styleExpression.expression);}return i}getProgramIds(){return ["symbol"]}getDefaultProgramParams(t,e,r){return {config:new Fo(this,{zoom:e,lut:r}),overrideFog:!1}}}let nm,im,am,sm;var om=ms([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);function lm(t){switch(t){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 um(t){switch(t){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 cm{constructor(t,e,r,n){this.context=t,this.format=r,this.useMipmap=n&&n.useMipmap,this.texture=t.gl.createTexture(),this.update(e,{premultiply:n&&n.premultiply});}update(t,e){const r=t&&t instanceof HTMLVideoElement&&0===t.width?t.videoWidth:t.width,n=t&&t instanceof HTMLVideoElement&&0===t.height?t.videoHeight:t.height,{context:i}=this,{gl:a}=i,{x:s,y:o}=e&&e.position?e.position:{x:0,y:0},l=Math.max(s+r,this.size?this.size[0]:0),u=Math.max(o+n,this.size?this.size[1]:0);!this.size||this.size[0]===l&&this.size[1]===u||(a.bindTexture(a.TEXTURE_2D,null),a.deleteTexture(this.texture),this.texture=a.createTexture(),this.size=null),a.bindTexture(a.TEXTURE_2D,this.texture),i.pixelStoreUnpackFlipY.set(!1),i.pixelStoreUnpack.set(1),i.pixelStoreUnpackPremultiplyAlpha.set(this.format===a.RGBA8&&(!e||!1!==e.premultiply));const c=t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap;if(!this.size&&l>0&&u>0){const t=this.useMipmap?Math.floor(Math.log2(Math.max(l,u)))+1:1;a.texStorage2D(a.TEXTURE_2D,t,this.format,l,u),this.size=[l,u];}if(this.size)if(c)a.texSubImage2D(a.TEXTURE_2D,0,s,o,lm(this.format),um(this.format),t);else {const e=t.data;e&&a.texSubImage2D(a.TEXTURE_2D,0,s,o,r,n,lm(this.format),um(this.format),e);}this.useMipmap&&a.generateMipmap(a.TEXTURE_2D);}bind(t,e,r=!1){const{context:n}=this,{gl:i}=n;i.bindTexture(i.TEXTURE_2D,this.texture),t!==this.minFilter&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,this.useMipmap&&!r?t===i.NEAREST?i.NEAREST_MIPMAP_NEAREST:i.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),e!==this.wrapS&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,e),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,e),this.wrapS=e);}bindExtraParam(t,e,r,n){const{context:i}=this,{gl:a}=i;a.bindTexture(a.TEXTURE_2D,this.texture),e!==this.magFilter&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,e),this.magFilter=e),t!==this.minFilter&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,this.useMipmap?t===a.NEAREST?a.NEAREST_MIPMAP_NEAREST:a.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),r!==this.wrapS&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,r),this.wrapS=r),n!==this.wrapT&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,n),this.wrapT=n);}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null;}}class hm{constructor(t,e){this.context=t,this.texture=e;}bind(t,e){const{context:r}=this,{gl:n}=r;n.bindTexture(n.TEXTURE_2D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,e),this.wrapS=e);}}function pm(t,e,r,n,i,a,s,o){const l=[t,e,1,r,n,1,i,a,1],u=[s,o,1],c=O.mat3.adjoint([],l),[h,p,f]=O.vec3.transformMat3(u,u,c);return O.mat3.multiply(l,l,[h,0,0,0,p,0,0,0,f])}function fm(t,e,r,n,i,a,s,o){const l=function(t,e,r,n,i,a,s,o){const l=pm(0,0,1,0,1,1,0,1),u=pm(t,e,r,n,i,a,s,o),c=O.mat3.adjoint([],l);return O.mat3.multiply(u,u,c)}(t,e,r,n,i,a,s,o);return [l[2]/l[8]/Wr,l[5]/l[8]/Wr]}function dm(t){return [t[0],Math.min(Math.max(t[1],-dl),dl)]}class mm extends _e{constructor(t,e,r,n){super(),this.id=t,this.dispatcher=r,this.coordinates=e.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=e,this._dirty=!1;}load(t,e){if(this._loaded=e||!1,this.fire(new xe("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return t&&(this.coordinates=t),this._loaded=!0,void this._finishLoading();this._imageRequest=ue(this.map._requestManager.transformRequest(this.url,te.Image),((e,r)=>{this._imageRequest=null,this._loaded=!0,e?this.fire(new ve(e)):r&&(this.image=r instanceof HTMLImageElement?Rt.getImageData(r):r,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,t&&(this.coordinates=t),this._finishLoading());}));}loaded(){return this._loaded}updateImage(t){return t.url?(this._imageRequest&&t.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=t.url,this.load(t.coordinates,this._loaded),this):this}setTexture(t){if(!(t.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new hm(this.map.painter.context,t.handle),this.width=t.dimensions[0],this.height=t.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new xe("data",{dataType:"source",sourceDataType:"metadata"})));}onAdd(t){this.map=t,this.load();}onRemove(t){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof hm||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy());}setCoordinates(t){if(this.coordinates=t,this._boundsArray=void 0,this._unsupportedCoords=!1,!t.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let e=t[0][1],r=t[0][1];for(const n of t)n[1]>r&&(r=n[1]),n[1]<e&&(e=n[1]);const n=(r+e)/2;if(n>dl?this.onNorthPole=!0:n<-dl&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const e=t.map(vl.fromLngLat);this.tileID=function(t){let e=1/0,r=1/0,n=-1/0,i=-1/0;for(const a of t)e=Math.min(e,a.x),r=Math.min(r,a.y),n=Math.max(n,a.x),i=Math.max(i,a.y);const a=Math.max(n-e,i-r),s=Math.max(0,Math.floor(-Math.log(a)/Math.LN2)),o=Math.pow(2,s);let l=Math.floor((e+n)/2*o);return l>1&&(l-=1),new eu(s,l,Math.floor((r+i)/2*o))}(e),this.minzoom=this.maxzoom=this.tileID.z;}return this.fire(new xe("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1;}_prepareData(t){for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture);}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const e=xd(new eu(0,0,0),this.map.transform.projection),r=[e.projection.project(this.coordinates[0][0],this.coordinates[0][1]),e.projection.project(this.coordinates[1][0],this.coordinates[1][1]),e.projection.project(this.coordinates[2][0],this.coordinates[2][1]),e.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(t){const e=t[1].x-t[0].x,r=t[1].y-t[0].y,n=t[2].x-t[1].x,i=t[2].y-t[1].y,a=t[3].x-t[2].x,s=t[3].y-t[2].y,o=t[0].x-t[3].x,l=t[0].y-t[3].y,u=e*i-n*r,c=n*s-a*i,h=a*l-o*s,p=o*r-e*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=xd(this.tileID,this.map.transform.projection),[i,a,s,o]=this.coordinates.map((t=>{const e=n.projection.project(t[0],t[1]);return vd(n,e)._round()}));this.perspectiveTransform=fm(i.x,i.y,a.x,a.y,s.x,s.y,o.x,o.y);const l=this._boundsArray=new vs;l.emplaceBack(i.x,i.y,0,0),l.emplaceBack(a.x,a.y,Wr,0),l.emplaceBack(o.x,o.y,0,Wr),l.emplaceBack(s.x,s.y,Wr,Wr),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=t.createVertexBuffer(l,om.members),this.boundsSegments=ho.simpleSegment(0,0,4,2);const u=[],c=[dm((h=this.coordinates)[0]),dm(h[1]),dm(h[2]),dm(h[3])];var h;const[p,f,d,m]=function(t){let e=t[0][0],r=e,n=t[0][1],i=n;for(let a=1;a<t.length;a++)t[a][0]<e?e=t[a][0]:t[a][0]>r&&(r=t[a][0]),t[a][1]<n?n=t[a][1]:t[a][1]>i&&(i=t[a][1]);return [e,n,r-e,i-n]}(c);{const n=new vs,[i,a,s,o]=function(t){let e=t[0].x,r=e,n=t[0].y,i=n;for(let a=1;a<t.length;a++)t[a].x<e?e=t[a].x:t[a].x>r&&(r=t[a].x),t[a].y<n?n=t[a].y:t[a].y>i&&(i=t[a].y);return [e,n,r-e,i-n]}(r),l=t=>[(t.x-i)/s,(t.y-a)/o],[c,h,y,g]=r.map(l),x=function(t,e,r,n,i,a,s,o){const l=pm(0,0,1,0,1,1,0,1),u=pm(t,e,r,n,i,a,s,o),c=O.mat3.adjoint([],u);return O.mat3.multiply(l,l,c)}(c[0],c[1],h[0],h[1],y[0],y[1],g[0],g[1]);this.elevatedGlobePerspectiveTransform=fm(c[0],c[1],h[0],h[1],y[0],y[1],g[0],g[1]);const v=(t,e)=>{u.push(t.lng);const r=Math.round((t.lng-p)/d*Wr),i=Math.round((t.lat-f)/m*Wr),a=l(e),s=O.vec3.transformMat3([],[a[0],a[1],1],x),o=Math.round(s[0]/s[2]*Wr),c=Math.round(s[1]/s[2]*Wr);n.emplaceBack(r,i,o,c);},b=r[3].x-r[0].x,w=r[3].y-r[0].y,_=r[2].x-r[1].x,M=r[2].y-r[1].y;for(let t=0;t<65;t++){const n=t/64,i=[r[0].x+n*b,r[0].y+n*w],a=[r[1].x+n*_,r[1].y+n*M],s=a[0]-i[0],o=a[1]-i[1];for(let t=0;t<65;t++){const r=t/64,n={x:i[0]+s*r,y:i[1]+o*r,z:0};v(e.projection.unproject(n.x,n.y),n);}}this.elevatedGlobeVertexBuffer=t.createVertexBuffer(n,om.members);}{this.maxLongitudeTriangleSize=0;let e=[],r=new Rs;const n=(t,n,i)=>{r.emplaceBack(t,n,i);const a=u[t],s=u[n],o=u[i],l=Math.min(Math.min(a,s),o),c=Math.max(Math.max(a,s),o)-l;c>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=c),e.push(l+c/2);};for(let t=0;t<64;t++)for(let e=0;e<64;e++){const r=65*t+e,i=r+1,a=r+65,s=a+1;n(r,a,i),n(i,a,s);}[e,r]=function(t,e){const r=Array.from({length:t.length},((t,e)=>e));r.sort(((e,r)=>t[e]-t[r]));const n=[],i=new Rs;for(let a=0;a<r.length;a++){const s=r[a];n.push(t[s]);const o=3*s,l=o+1;i.emplaceBack(e.uint16[o],e.uint16[l],e.uint16[l+1]);}return [n,i]}(e,r),this.elevatedGlobeTrianglesCenterLongitudes=e,this.elevatedGlobeIndexBuffer=t.createIndexBuffer(r);}this.elevatedGlobeSegments=ho.simpleSegment(0,0,4225,8192),this.elevatedGlobeGridMatrix=new Float32Array([0,d/Wr,0,m/Wr,0,0,f,p,0]);}prepare(){const t=0!==Object.keys(this.tiles).length;if(this.tileID&&!t)return;const e=this.map.painter.context,r=e.gl;!this._dirty||this.texture instanceof hm||(this.texture?this.texture.update(this.image):(this.texture=new cm(e,this.image,r.RGBA8),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE)),this._dirty=!1),t&&this._prepareData(e);}loadTile(t,e){this.tileID&&this.tileID.equals(t.tileID.canonical)?(this.tiles[String(t.tileID.wrap)]=t,t.buckets={},e(null)):(t.state="errored",e(null));}serialize(){return {type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return !1}getSegmentsForLongitude(t){const e=this.elevatedGlobeSegments;if(!this.elevatedGlobeTrianglesCenterLongitudes||!e)return null;const r=this.elevatedGlobeTrianglesCenterLongitudes;let n=(i=t+180)+360*Math.round((r[0]-i)/360);var i;const a=new ho,s=(t,r)=>{a.segments.push({vertexOffset:0,primitiveOffset:t,vertexLength:e.segments[0].vertexLength,primitiveLength:r,sortKey:void 0,vaos:{}});},o=.51*this.maxLongitudeTriangleSize;if(Math.abs(r[0]-n)<=o){const t=_t(r,0,r.length,n+o);return t===r.length||s(t,wt(r,t+1,r.length,n+360-o)-t),a}n<r[0]&&(n+=360);const l=wt(r,0,r.length,n-o);if(l===r.length)return s(0,r.length),a;s(0,l-0);const u=_t(r,l+1,r.length,n+o);return u!==r.length&&s(u,r.length-u),a}}const ym=(Math.pow(256,2)-1)/16907520;class gm extends hs{constructor(t,e,r,n){super(t,{layout:am||(am=new $a({visibility:new ja(Ga.layout_raster.visibility)})),paint:sm||(sm=new $a({"raster-opacity":new ja(Ga.paint_raster["raster-opacity"]),"raster-color":new qa(Ga.paint_raster["raster-color"]),"raster-color-mix":new ja(Ga.paint_raster["raster-color-mix"]),"raster-color-range":new ja(Ga.paint_raster["raster-color-range"]),"raster-hue-rotate":new ja(Ga.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new ja(Ga.paint_raster["raster-brightness-min"]),"raster-brightness-max":new ja(Ga.paint_raster["raster-brightness-max"]),"raster-saturation":new ja(Ga.paint_raster["raster-saturation"]),"raster-contrast":new ja(Ga.paint_raster["raster-contrast"]),"raster-resampling":new ja(Ga.paint_raster["raster-resampling"]),"raster-fade-duration":new ja(Ga.paint_raster["raster-fade-duration"]),"raster-emissive-strength":new ja(Ga.paint_raster["raster-emissive-strength"]),"raster-array-band":new ja(Ga.paint_raster["raster-array-band"]),"raster-elevation":new ja(Ga.paint_raster["raster-elevation"])}))},e,r,n),this.updateColorRamp(),this._curRampRange=[NaN,NaN];}getProgramIds(){return ["raster"]}hasColorMap(){return !!this._transitionablePaint._values["raster-color"].value.value}tileCoverLift(){return this.paint.get("raster-elevation")}isDraped(t){return !(t&&t._source instanceof mm&&(t._source.onNorthPole||t._source.onSouthPole))&&0===this.paint.get("raster-elevation")}_handleSpecialPaintPropertyUpdate(t){"raster-color"!==t&&"raster-color-range"!==t||(this._curRampRange=[NaN,NaN],this.updateColorRamp());}updateColorRamp(t){if(!this.hasColorMap())return;if(!this._curRampRange)return;const e=this._transitionablePaint._values["raster-color"].value.expression,[r,n]=t||this._transitionablePaint._values["raster-color-range"].value.expression.evaluate({zoom:0})||[NaN,NaN];isNaN(r)&&isNaN(n)||r===this._curRampRange[0]&&n===this._curRampRange[1]||(this.colorRamp=oc({expression:e,evaluationKey:"rasterValue",image:this.colorRamp,clips:[{start:r,end:n}],resolution:256}),this.colorRampTexture=null,this._curRampRange=[r,n]);}}let xm,vm,bm,wm,_m;class Mm extends hs{constructor(t,e,r,n){super(t,{layout:xm||(xm=new $a({visibility:new ja(Ga["layout_raster-particle"].visibility)})),paint:vm||(vm=new $a({"raster-particle-array-band":new ja(Ga["paint_raster-particle"]["raster-particle-array-band"]),"raster-particle-count":new ja(Ga["paint_raster-particle"]["raster-particle-count"]),"raster-particle-color":new qa(Ga["paint_raster-particle"]["raster-particle-color"]),"raster-particle-max-speed":new ja(Ga["paint_raster-particle"]["raster-particle-max-speed"]),"raster-particle-speed-factor":new ja(Ga["paint_raster-particle"]["raster-particle-speed-factor"]),"raster-particle-fade-opacity-factor":new ja(Ga["paint_raster-particle"]["raster-particle-fade-opacity-factor"]),"raster-particle-reset-rate-factor":new ja(Ga["paint_raster-particle"]["raster-particle-reset-rate-factor"]),"raster-particle-elevation":new ja(Ga["paint_raster-particle"]["raster-particle-elevation"])}))},e,r,n),this._updateColorRamp(),this.lastInvalidatedAt=Rt.now();}onRemove(t){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(t){return !1}_handleSpecialPaintPropertyUpdate(t){"raster-particle-color"!==t&&"raster-particle-max-speed"!==t||(this._updateColorRamp(),this._invalidateAnimationState()),"raster-particle-count"===t&&this._invalidateAnimationState();}_updateColorRamp(){if(!this.hasColorMap())return;const t=this._transitionablePaint._values["raster-particle-color"].value.expression,e=this._transitionablePaint._values["raster-particle-max-speed"].value.expression.evaluate({zoom:0});this.colorRamp=oc({expression:t,evaluationKey:"rasterParticleSpeed",image:this.colorRamp,clips:[{start:0,end:e}],resolution:256}),this.colorRampTexture=null;}_invalidateAnimationState(){this.lastInvalidatedAt=Rt.now();}tileCoverLift(){return this.paint.get("raster-particle-elevation")}}class Am extends hs{constructor(t,e){super(t,{},e,null),this.implementation=t,t.slot&&(this.slot=t.slot);}is3D(){return "3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}isDraped(t){return void 0!==this.implementation.renderToTile}shouldRedrape(){return !!this.implementation.shouldRerenderTiles&&this.implementation.shouldRerenderTiles()}recalculate(){}updateTransitions(){}hasTransition(){return !1}serialize(){}onAdd(t){this.implementation.onAdd&&this.implementation.onAdd(t,t.painter.context.gl);}onRemove(t){this.implementation.onRemove&&this.implementation.onRemove(t,t.painter.context.gl);}}function Sm(t,e,r){const n=[0,0,1],i=O.quat.identity([]);return O.quat.rotateY(i,i,r?-Y(t)+Math.PI:Y(t)),O.quat.rotateX(i,i,-Y(e)),O.vec3.transformQuat(n,n,i),O.vec3.normalize(n,n)}function Im(t,e){const r=Pm(t.projection,t.zoom,t.width,t.height),n=function(t,e,r,n,i){const a=new nl(r.lng-180*km,r.lat),s=new nl(r.lng+180*km,r.lat),o=t.project(a.lng,a.lat),l=t.project(s.lng,s.lat),u=-Math.atan2(l.y-o.y,l.x-o.x),c=vl.fromLngLat(r);c.y=Q(c.y,-1+km,1-km);const h=c.toLngLat(),p=t.project(h.lng,h.lat),f=vl.fromLngLat(h);f.x+=km;const d=f.toLngLat(),m=t.project(d.lng,d.lat),y=Em(m.x-p.x,m.y-p.y,u),g=vl.fromLngLat(h);g.y+=km;const x=g.toLngLat(),v=t.project(x.lng,x.lat),b=Em(v.x-p.x,v.y-p.y,u),w=Math.abs(y.x)/Math.abs(b.y),_=O.mat4.identity([]);O.mat4.rotateZ(_,_,-u*(1-(i?0:n)));const M=O.mat4.identity([]);return O.mat4.scale(M,M,[1,1-(1-w)*n,1]),M[4]=-b.x/b.y*n,O.mat4.rotateZ(M,M,u),O.mat4.multiply(M,_,M),M}(t.projection,0,t.center,r,e),i=zm(t);return O.mat4.scale(n,n,[i,i,1]),n}function zm(t){const e=t.projection,r=Pm(t.projection,t.zoom,t.width,t.height),n=Tm(e,t.center),i=Tm(e,nl.convert(e.center));return Math.pow(2,n*r+(1-r)*i)}function Pm(t,e,r,n,i=1/0){const a=t.range;if(!a)return 0;const s=Math.min(i,Math.max(r,n)),o=Math.log(s/1024)/Math.LN2;return tt(a[0]+o,a[1]+o,e)}const km=1/4e4;function Tm(t,e){const r=Q(e.lat,-dl,dl),n=new nl(e.lng-180*km,r),i=new nl(e.lng+180*km,r),a=t.project(n.lng,r),s=t.project(i.lng,r),o=vl.fromLngLat(n),l=vl.fromLngLat(i),u=s.x-a.x,c=s.y-a.y,h=l.x-o.x,p=l.y-o.y,f=Math.sqrt((h*h+p*p)/(u*u+c*c));return Math.log(f)/Math.LN2}function Em(t,e,r){const n=Math.cos(r),i=Math.sin(r);return {x:t*n-e*i,y:t*i+e*n}}function Bm(t,e,r){O.mat4.identity(t),O.mat4.rotateZ(t,t,Y(e[2])),O.mat4.rotateX(t,t,Y(e[0])),O.mat4.rotateY(t,t,Y(e[1])),O.mat4.scale(t,t,r),O.mat4.multiply(t,t,[1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1]);}function Vm(t,e,r,n,i,a,s,o){const l=[r[0]-e[0],r[1]-e[1],0],u=[n[0]-e[0],n[1]-e[1],0];if(O.vec3.length(l)<1e-12||O.vec3.length(u)<1e-12)return O.quat.identity(t);const c=O.vec3.cross([],l,u);O.vec3.normalize(c,c),O.vec3.subtract(u,n,e),l[2]=(a-i)*o,u[2]=(s-i)*o;const h=l;return O.vec3.cross(h,l,u),O.vec3.normalize(h,h),O.quat.rotationTo(t,c,h)}function Cm(t,e,r=!1){const n=Lu(e.zoom),i=function(t,e,r){const n=e.worldSize,i=[t[12],t[13],t[14]],a=pl(i[1]/n),s=hl(i[0]/n),o=O.mat4.identity([]),l=cl(1,a)*n,u=cl(1,0)*n*yl(a,e.zoom),c=1/Cu(n);let h=u*c;if(r){const t=Pm(e.projection,e.zoom,e.width,e.height,1024);h=c*e.projection.pixelSpaceConversion(e.center.lat,n,t);}const p=tl(a,s);O.vec3.add(p,p,O.vec3.scale([],O.vec3.normalize([],p),l*h*i[2]));const f=function(t){const e=[t[0],t[1],t[2]];let r=[0,1,0];const n=O.vec3.cross([],r,e);return O.vec3.cross(r,e,n),0===O.vec3.squaredLength(r)&&(r=[0,1,0],O.vec3.cross(n,e,r)),O.vec3.normalize(n,n),O.vec3.normalize(r,r),O.vec3.normalize(e,e),[n[0],n[1],n[2],0,r[0],r[1],r[2],0,e[0],e[1],e[2],0,t[0],t[1],t[2],1]}(p);O.mat4.scale(o,o,[h,h,h*l]),O.mat4.translate(o,o,[-i[0],-i[1],-i[2]]);const d=O.mat4.multiply([],e.globeMatrix,f);return O.mat4.multiply(d,d,o),O.mat4.multiply(d,d,t),d}(t,e,r);if(n>0){const r=function(t,e){const r=e.worldSize,n=cl(1,0)*r*yl(e.center.lat,e.zoom)/Cu(r),i=cl(1,e.center.lat)*r,a=O.mat4.identity([]);return O.mat4.rotateY(a,a,Y(e.center.lng)),O.mat4.rotateX(a,a,Y(e.center.lat)),O.mat4.translate(a,a,[0,0,Go]),O.mat4.scale(a,a,[n,n,n*i]),O.mat4.translate(a,a,[e.point.x-.5*r,e.point.y-.5*r,0]),O.mat4.multiply(a,a,t),O.mat4.multiply(a,e.globeMatrix,a)}(t,e);return function(t,e,r){const n=(t,e,r)=>{const n=O.vec3.length(t),i=O.vec3.length(e),a=Au(t,e,r);return O.vec3.scale(a,a,1/O.vec3.length(a)*Pe(n,i,r))},i=n([t[0],t[1],t[2]],[e[0],e[1],e[2]],r),a=n([t[4],t[5],t[6]],[e[4],e[5],e[6]],r),s=n([t[8],t[9],t[10]],[e[8],e[9],e[10]],r),o=Au([t[12],t[13],t[14]],[e[12],e[13],e[14]],r);return [i[0],i[1],i[2],0,a[0],a[1],a[2],0,s[0],s[1],s[2],0,o[0],o[1],o[2],1]}(i,r,n)}return i}function Rm(t,e,r,n){const i=gu.projectAabbCorners(n,r);let a=Number.MAX_VALUE,s=-1;for(let t=0;t<i.length;++t){const r=i[t];r[0]=(.5*r[0]+.5)*e.width,r[1]=(.5-.5*r[1])*e.height,r[2]<a&&(s=t,a=r[2]);}const o=t=>new q(i[t][0],i[t][1]);let l;switch(s){case 0:case 6:l=[o(1),o(5),o(4),o(7),o(3),o(2),o(1)];break;case 1:case 7:l=[o(0),o(4),o(5),o(6),o(2),o(3),o(0)];break;case 3:case 5:l=[o(1),o(0),o(4),o(7),o(6),o(2),o(1)];break;default:l=[o(1),o(5),o(6),o(7),o(3),o(0),o(1)];}if(Bl(t,l))return a}const Dm=ms([{name:"a_pos_3f",components:3,type:"Float32"}]),Lm=ms([{name:"a_color_3f",components:3,type:"Float32"}]),Fm=ms([{name:"a_color_4f",components:4,type:"Float32"}]),Om=ms([{name:"a_uv_2f",components:2,type:"Float32"}]),Um=ms([{name:"a_normal_3f",components:3,type:"Float32"}]),jm=ms([{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=ms([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]),qm={None:0,Model:1,Symbol:2,FillExtrusion:4,All:7};class $m{constructor(t,e,r,n){this.message=(t?`${t}: `:"")+r,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__);}}function Gm(t,e){const r=-1===t.indexOf("://");try{return new URL(t,r&&e?"http://example.com":void 0),!0}catch(t){return !1}}class Xm{constructor(t,e){this.feature=t,this.instancedDataOffset=e,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0];}}class Ym{constructor(){this.instancedDataArray=new Xs,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={};}}class Zm{constructor(t){this.zoom=t.zoom,this.canonical=t.canonical,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.projection=t.projection,this.index=t.index,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0},this.modelUris=[],this.modelsRequested=!1,this.activeReplacements=[],this.replacementUpdateTime=0;}updateFootprints(t,e){}populate(t,e,r,n){this.tileToMeter=xl(r);const i=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:a,id:s,index:o,sourceLayerIndex:l}of t){const t=null!=s?s:a.properties&&a.properties.hasOwnProperty("id")?a.properties.id:void 0,u=Pl(a,i);if(!this.layers[0]._featureFilter.filter(new Ba(this.zoom),u,r))continue;const c={id:t,sourceLayerIndex:l,index:o,geometry:i?u.geometry:zl(a,r,n),properties:a.properties,type:a.type,patterns:{}},h=this.addFeature(c,c.geometry,u);h&&e.featureIndex.insert(a,c.geometry,o,l,this.index,this.instancesPerModel[h].instancedDataArray.length,Wr/32);}this.lookup=null;}update(t,e,r,n){for(const e in this.instancesPerModel){const r=this.instancesPerModel[e];for(const e in t)r.idToFeaturesIndex.hasOwnProperty(e)&&(this.evaluate(r.features[r.idToFeaturesIndex[e]],t[e],r,!0),this.uploaded=!1);}this.maxHeight=0;}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return !1;let t=!1;for(const e in this.instancesPerModel){const r=this.instancesPerModel[e];for(const e of r.features){const n=this.layers[0],i=e.feature,a=this.canonical,s=n.paint.get("model-rotation").evaluate(i,{},a),o=n.paint.get("model-scale").evaluate(i,{},a),l=n.paint.get("model-translation").evaluate(i,{},a);O.vec3.exactEquals(e.rotation,s)&&O.vec3.exactEquals(e.scale,o)&&O.vec3.exactEquals(e.translation,l)||(this.evaluate(e,e.featureStates,r,!0),t=!0);}}return t}updateReplacement(t,e,r,n){if(e.updateTime===this.replacementUpdateTime)return !1;this.replacementUpdateTime=e.updateTime;const i=e.getReplacementRegionsForTile(t.toUnwrapped(),!0);if(_h(this.activeReplacements,i))return !1;this.activeReplacements=i;let a=!1;for(const e in this.instancesPerModel){const i=this.instancesPerModel[e],s=i.instancedDataArray;for(const e of i.features){const i=e.instancedDataOffset,o=e.instancedDataCount;for(let e=0;e<o;e++){const o=16*(e+i);let l=s.float32[o+0];const u=l>Wr;l=u?l-Wr:l;const c=Math.floor(l),h=s.float32[o+1];let p=!1;for(const e of this.activeReplacements)if(!xh(e,r,qm.Model,n)&&!(e.min.x>c||c>e.max.x||e.min.y>h||h>e.max.y)&&(p=Ph(zh(c,h,t.canonical,e.footprintTileId.canonical),e.footprint),p))break;s.float32[o]=p?l+Wr:l,a=a||p!==u;}}}return a}isEmpty(){for(const t in this.instancesPerModel)if(0!==this.instancesPerModel[t].instancedDataArray.length)return !1;return !0}uploadPending(){return !this.uploaded}upload(t){if(!this.uploaded)for(const e in this.instancesPerModel){const r=this.instancesPerModel[e];r.instancedDataArray.length<0||0===r.instancedDataArray.length||(r.instancedDataBuffer?r.instancedDataBuffer.updateData(r.instancedDataArray):r.instancedDataBuffer=t.createVertexBuffer(r.instancedDataArray,jm.members,!0,void 0,this.instanceCount));}this.uploaded=!0;}destroy(){for(const t in this.instancesPerModel){const e=this.instancesPerModel[t];0!==e.instancedDataArray.length&&e.instancedDataBuffer&&e.instancedDataBuffer.destroy();}const t=this.layers[0].modelManager;if(t&&this.modelUris)for(const e of this.modelUris)t.removeModel(e,"");}addFeature(t,e,r){const n=this.layers[0],i=n.layout.get("model-id").evaluate(r,{},this.canonical);if(!i)return ft(`modelId is not evaluated for layer ${n.id} and it is not going to get rendered.`),i;Gm(i,!1)&&(this.modelUris.includes(i)||this.modelUris.push(i)),this.instancesPerModel[i]||(this.instancesPerModel[i]=new Ym);const a=this.instancesPerModel[i],s=a.instancedDataArray,o=new Xm(r,s.length);for(const t of e)for(const e of t){if(e.x<0||e.x>=Wr||e.y<0||e.y>=Wr)continue;const t=(this.lookupDim-1)/Wr,r=this.lookupDim*(e.y*t|0)+e.x*t|0;if(this.lookup){if(0!==this.lookup[r])continue;this.lookup[r]=1;}this.instanceCount++;const n=s.length;s.resize(n+1),a.instancesEvaluatedElevation.push(0),s.float32[16*n]=e.x,s.float32[16*n+1]=e.y;}return o.instancedDataCount=a.instancedDataArray.length-o.instancedDataOffset,o.instancedDataCount>0&&(t.id&&(a.idToFeaturesIndex[t.id]=a.features.length),a.features.push(o),this.evaluate(o,{},a,!1)),i}getModelUris(){return this.modelUris}evaluate(t,e,r,n){const i=this.layers[0],a=t.feature,s=this.canonical,o=t.rotation=i.paint.get("model-rotation").evaluate(a,e,s),l=t.scale=i.paint.get("model-scale").evaluate(a,e,s),u=t.translation=i.paint.get("model-translation").evaluate(a,e,s),c=i.paint.get("model-color").evaluate(a,e,s);c.a=i.paint.get("model-color-mix-intensity").evaluate(a,e,s);const h=[];this.maxVerticalOffset<u[2]&&(this.maxVerticalOffset=u[2]),this.maxScale=Math.max(Math.max(this.maxScale,l[0]),Math.max(l[1],l[2])),Bm(h,o,l);const p=Math.round(100*c.a)+c.b/1.05;for(let e=0;e<t.instancedDataCount;++e){const i=t.instancedDataOffset+e,a=16*i,o=r.instancedDataArray.float32;let l=0;n&&(l=o[a+6]-r.instancesEvaluatedElevation[i]);const f=0|o[a+1];o[a]=(0|o[a])+c.r/1.05,o[a+1]=f+c.g/1.05,o[a+2]=p,o[a+3]=1/(s.z>10?this.tileToMeter:xl(s,f)),o[a+4]=u[0],o[a+5]=u[1],o[a+6]=u[2]+l,o[a+7]=h[0],o[a+8]=h[1],o[a+9]=h[2],o[a+10]=h[4],o[a+11]=h[5],o[a+12]=h[6],o[a+13]=h[8],o[a+14]=h[9],o[a+15]=h[10],r.instancesEvaluatedElevation[i]=u[2];}}}let Wm,Hm;sa(Zm,"ModelBucket",{omit:["layers"]}),sa(Ym,"PerModelAttributes"),sa(Xm,"ModelFeature");const Km=64,Jm={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function Qm(t,e,r,n,i,a,s,o,l,u=!1){const c=r.zoom,h=r.project(n),p=yl(n.lat,c),f=1/p;O.mat4.identity(t),O.mat4.translate(t,t,[h.x+s[0]*f,h.y+s[1]*f,s[2]]);let d=1,m=1;const y=r.worldSize;if(u){if("mercator"===r.projection.name){let t=0;r.elevation&&(t=r.elevation.getAtPointOrZero(new vl(h.x/y,h.y/y),0));const e=O.vec4.transformMat4([],[h.x,h.y,t,1],r.projMatrix)[3]/r.cameraToCenterDistance;d=e,m=e*yl(r.center.lat,c);}else if("globe"===r.projection.name){const e=Cm(t,r),i=O.mat4.multiply([],r.projMatrix,e),a=[0,0,0,1];O.vec4.transformMat4(a,a,i);const s=a[3]/r.cameraToCenterDistance,o=Lu(c),l=r.projection.pixelsPerMeter(n.lat,y)*yl(n.lat,c),u=r.projection.pixelsPerMeter(r.center.lat,y)*yl(r.center.lat,c);d=s/Pe(l,ml(r.center.lat),o),m=s*p/l,d*=u,m*=u;}}else d=f;O.mat4.scale(t,t,[d,d,m]);const g=[...t],x=e.orientation,v=[];if(Bm(v,[x[0]+i[0],x[1]+i[1],x[2]+i[2]],a),O.mat4.multiply(t,g,v),o&&r.elevation){let i=0;const a=[];if(l&&r.elevation){i=function(t,e,r,n,i){const a=e.elevation;if(!a)return 0;const s=gu.projectAabbCorners(r,n),o=cl(1,i.lat)*e.worldSize,l=function(t,e){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=t[i.corners[0]],a=t[i.corners[1]],s=t[i.corners[2]],o=[a[0]-n[0],a[1]-n[1],e*(a[2]-n[2])],l=O.vec3.cross(o,o,[s[0]-n[0],s[1]-n[1],e*(s[2]-n[2])]);O.vec3.normalize(l,l),i.dotProductWithUp=O.vec3.dot(l,r);}return n.sort(((t,e)=>t.dotProductWithUp-e.dotProductWithUp)),n[0].corners}(s,o),u=s[l[0]],c=s[l[1]],h=s[l[2]],p=s[l[3]],f=a.getAtPointOrZero(new vl(u[0]/e.worldSize,u[1]/e.worldSize),0),d=a.getAtPointOrZero(new vl(c[0]/e.worldSize,c[1]/e.worldSize),0),m=a.getAtPointOrZero(new vl(h[0]/e.worldSize,h[1]/e.worldSize),0),y=a.getAtPointOrZero(new vl(p[0]/e.worldSize,p[1]/e.worldSize),0),g=(f+y)/2,x=(d+m)/2;return g>x?d<m?Vm(t,c,p,u,d,y,f,o):Vm(t,h,u,p,m,f,y,o):f<y?Vm(t,u,c,h,f,d,m,o):Vm(t,p,h,c,y,m,d,o),Math.max(g,x)}(a,r,e.aabb,t,n);const s=O.mat4.fromQuat([],a),o=O.mat4.multiply([],s,v);O.mat4.multiply(t,g,o);}else i=r.elevation.getAtPointOrZero(new vl(h.x/y,h.y/y),0);0!==i&&(t[14]+=i);}}function ty(t,e,r=!1){t.uploaded||(t.gfxTexture=new cm(e,t.image,r?e.gl.R8:e.gl.RGBA8,{useMipmap:t.sampler.minFilter>=e.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null);}function ey(t,e,r){t.indexBuffer=e.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=e.createVertexBuffer(t.vertexArray,Dm.members,!1,!0),t.normalArray&&(t.normalBuffer=e.createVertexBuffer(t.normalArray,Um.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=e.createVertexBuffer(t.texcoordArray,Om.members,!1,!0)),t.colorArray&&(t.colorBuffer=e.createVertexBuffer(t.colorArray,(12===t.colorArray.bytesPerElement?Lm:Fm).members,!1,!0)),t.featureArray&&(t.pbrBuffer=e.createVertexBuffer(t.featureArray,Nm.members,!0)),t.segments=ho.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);const n=t.material;n.pbrMetallicRoughness.baseColorTexture&&ty(n.pbrMetallicRoughness.baseColorTexture,e),n.pbrMetallicRoughness.metallicRoughnessTexture&&ty(n.pbrMetallicRoughness.metallicRoughnessTexture,e),n.normalTexture&&ty(n.normalTexture,e),n.occlusionTexture&&ty(n.occlusionTexture,e,r),n.emissionTexture&&ty(n.emissionTexture,e);}function ry(t,e,r){if(t.meshes)for(const n of t.meshes)ey(n,e,r);if(t.children)for(const n of t.children)ry(n,e,r);}function ny(t){if(t.meshes)for(const e of t.meshes)e.indexArray.destroy(),e.vertexArray.destroy(),e.colorArray&&e.colorArray.destroy(),e.normalArray&&e.normalArray.destroy(),e.texcoordArray&&e.texcoordArray.destroy(),e.featureArray&&e.featureArray.destroy();if(t.children)for(const e of t.children)ny(e);}function iy(t){if(t.meshes)for(const r of t.meshes)r.vertexBuffer&&(r.vertexBuffer.destroy(),r.indexBuffer.destroy(),r.normalBuffer&&r.normalBuffer.destroy(),r.texcoordBuffer&&r.texcoordBuffer.destroy(),r.colorBuffer&&r.colorBuffer.destroy(),r.pbrBuffer&&r.pbrBuffer.destroy(),r.segments.destroy(),r.material&&((e=r.material).pbrMetallicRoughness.baseColorTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),e.pbrMetallicRoughness.metallicRoughnessTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),e.normalTexture&&e.normalTexture.gfxTexture&&e.normalTexture.gfxTexture.destroy(),e.emissionTexture&&e.emissionTexture.gfxTexture&&e.emissionTexture.gfxTexture.destroy(),e.occlusionTexture&&e.occlusionTexture.gfxTexture&&e.occlusionTexture.gfxTexture.destroy()));var e;if(t.children)for(const e of t.children)iy(e);}class ay{constructor(t,e,r){this._demTile=t,this._dem=this._demTile.dem,this._scale=e,this._offset=r;}static create(t,e,r){const n=r||t.findDEMTileFor(e);if(!n||!n.dem)return;const i=n.dem,a=n.tileID,s=1<<e.canonical.z-a.canonical.z;return new ay(n,i.dim/Wr/s,[(e.canonical.x/s-a.canonical.x)*i.dim,(e.canonical.y/s-a.canonical.y)*i.dim])}tileCoordToPixel(t,e){const r=e*this._scale+this._offset[1],n=Math.floor(t*this._scale+this._offset[0]),i=Math.floor(r);return new q(n,i)}getElevationAt(t,e,r,n){const i=t*this._scale+this._offset[0],a=e*this._scale+this._offset[1],s=Math.floor(i),o=Math.floor(a),l=this._dem;return n=!!n,r?Pe(Pe(l.get(s,o,n),l.get(s,o+1,n),a-o),Pe(l.get(s+1,o,n),l.get(s+1,o+1,n),a-o),i-s):l.get(s,o,n)}getElevationAtPixel(t,e,r){return this._dem.get(t,e,!!r)}getMeterToDEM(t){return (1<<this._demTile.tileID.canonical.z)*cl(1,t)*this._dem.stride}}const sy=new Float32Array(262144),oy=new Uint8Array(262144);function ly(t){let e=0;if(t.meshes)for(const r of t.meshes)e=Math.max(e,r.aabb.max[2]);if(t.children)for(const r of t.children)e=Math.max(e,ly(r));return e}function uy(t,e,r){if(t.meshes)for(const n of t.meshes){if(n.aabb.min[0]===1/0)continue;const i=gu.applyTransform(n.aabb,t.matrix);r.insert(e,i.min[0],i.min[1],i.max[0],i.max[1]);}if(t.children)for(const n of t.children)uy(n,e,r);}const cy=["","wall","door","roof","window","lamp","logo"];class hy{constructor(t){this.node=t,this.evaluatedRMEA=[[1,0,0,1],[1,0,0,1],[1,0,0,1],[1,0,0,1],[.4,1,0,1],[1,0,0,1],[1,0,0,1]],this.hiddenByReplacement=!1,this.evaluatedScale=[1,1,1],this.evaluatedColor=[],this.emissionHeightBasedParams=[],this.cameraCollisionOpacity=1,this.feature={type:"Point",id:t.id,geometry:[],properties:{height:ly(t)}},this.aabb=this._getLocalBounds();}_getLocalBounds(){if(!this.node.meshes)return new gu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);if(!this.aabb){let t=0;const e=new gu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(const r of this.node.meshes)this.node.lightMeshIndex!==t&&(r.transformedAabb=gu.applyTransformFast(r.aabb,this.node.matrix),e.encapsulate(r.transformedAabb)),t++;this.aabb=e;}return this.aabb}}class py{constructor(t,e,r,n,i,a,s){this.id=r,this.layers=t,this.layerIds=this.layers.map((t=>t.fqid)),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.modelTraits|=Jm.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,n&&(this.modelTraits|=Jm.HasMapboxMeshFeatures),i&&(this.modelTraits|=Jm.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=a,this.dirty=!0,this.needsUpload=!1,this.nodesInfo=[];for(const t of e)this.nodesInfo.push(new hy(t)),uy(t,s.featureIndexArray.length,s.grid),s.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,s.bucketLayerIDs.length-1,0);}updateFootprints(t,e){for(const r of this.getNodesInfo()){const n=r.node;n.footprint&&e.push({footprint:n.footprint,id:t});}}update(t){const e=0!==Object.keys(t).length;if(e&&!this.stateDependentLayers.length)return;const r=e?this.stateDependentLayers:this.layers;for(const e of r)this.evaluate(e,t);}populate(){console.log("populate 3D model bucket");}uploadPending(){return !this.uploaded||this.needsUpload}upload(t){if(!this.needsUpload)return;const e=this.getNodesInfo();for(const r of e){const e=r.node;this.uploaded?this.updatePbrBuffer(e):ry(e,t,!0);}for(const t of e)ny(t.node);this.uploaded=!0,this.needsUpload=!1;}updatePbrBuffer(t){let e=!1;if(!t.meshes)return e;for(const r of t.meshes)r.pbrBuffer&&(r.pbrBuffer.updateData(r.featureArray),e=!0);return e}needsReEvaluation(t,e,r){const n=t.transform.projectionOptions,i=t.style.getBrightness(),a=this.brightness!==i;return !!(!this.uploaded||this.dirty||n.name!==this.projection.name||fy(r.paint.get("model-color").value,a)||fy(r.paint.get("model-color-mix-intensity").value,a)||fy(r.paint.get("model-roughness").value,a)||fy(r.paint.get("model-emissive-strength").value,a)||fy(r.paint.get("model-height-based-emissive-strength-multiplier").value,a))&&(this.projection=n,this.brightness=i,!0)}evaluateScale(t,e){if(t.transform.zoom===this.zoom)return;this.zoom=t.transform.zoom;const r=this.getNodesInfo(),n=this.id.canonical;for(const t of r){const r=t.feature;t.evaluatedScale=e.paint.get("model-scale").evaluate(r,{},n);}}evaluate(t,e){const r=this.getNodesInfo();for(const n of r){if(!n.node.meshes)continue;const r=n.feature,i=e&&e[r.id],a=n.node.meshes&&n.node.meshes[0].featureData,s=n.evaluatedColor[2],o=n.evaluatedRMEA[2],l=this.id.canonical;if(n.hasTranslucentParts=!1,a){for(let e=0;e<cy.length;e++){const a=cy[e];a.length&&(r.properties.part=a);const s=t.paint.get("model-color").evaluate(r,i,l).toRenderColor(null),o=t.paint.get("model-color-mix-intensity").evaluate(r,i,l);n.evaluatedColor[e]=[s.r,s.g,s.b,o],n.evaluatedRMEA[e][0]=t.paint.get("model-roughness").evaluate(r,i,l),n.evaluatedRMEA[e][2]=t.paint.get("model-emissive-strength").evaluate(r,i,l),n.evaluatedRMEA[e][3]=s.a,n.emissionHeightBasedParams[e]=t.paint.get("model-height-based-emissive-strength-multiplier").evaluate(r,i,l),!n.hasTranslucentParts&&s.a<1&&(n.hasTranslucentParts=!0);}delete r.properties.part,my(n,s!==n.evaluatedColor[2]||o!==n.evaluatedRMEA[2],this.modelTraits);}else n.evaluatedRMEA[0][2]=t.paint.get("model-emissive-strength").evaluate(r,i,l);n.evaluatedScale=t.paint.get("model-scale").evaluate(r,i,l),this.updatePbrBuffer(n.node)||(this.needsUpload=!0);}this.dirty=!1;}elevationUpdate(t,e,r,n){const i=t.findDEMTileFor(r);if(i&&(i.tileID.canonical!==this.terrainTile||e!==this.terrainExaggeration)){if(i.dem&&i.tileID.overscaledZ!==this.elevationReadFromZ){this.elevationReadFromZ=i.tileID.overscaledZ;const e=ay.create(t,r,i);if(!e)return;this.modelTraits&Jm.HasMapboxMeshFeatures&&this.updateDEM(t,e,r,n);for(const t of this.getNodesInfo()){const r=t.node;if(!r.footprint||!r.footprint.vertices||!r.footprint.vertices.length)continue;const n=r.footprint.vertices;let i=e.getElevationAt(n[0].x,n[0].y,!0,!0);for(let t=1;t<n.length;t++)i=Math.min(i,e.getElevationAt(n[t].x,n[t].y,!0,!0));r.elevation=i;}}this.terrainTile=i.tileID.canonical,this.terrainExaggeration=e;}}updateDEM(t,e,r,n){let i=e._dem._modifiedForSources[n];if(void 0===i&&(e._dem._modifiedForSources[n]=[],i=e._dem._modifiedForSources[n]),i.includes(r.canonical))return;const a=e._dem.dim;i.push(r.canonical);let s=!1;for(const t of this.getNodesInfo()){const r=t.node;if(!r.footprint||!r.footprint.grid)continue;const n=r.footprint.grid,i=e.tileCoordToPixel(n.min.x,n.min.y),o=e.tileCoordToPixel(n.max.x,n.max.y),l=Math.min(Math.min(a-o.y,i.x),Math.min(i.y,a-o.x));if(l<0)continue;const u=Q(l,2,5);let c=Math.max(0,i.x-u),h=Math.max(0,i.y-u),p=Math.min(o.x+u,a-1),f=Math.min(o.y+u,a-1);for(let t=h;t<=f;++t)for(let e=c;e<=p;++e)oy[t*a+e]=255;let d=0,m=0;for(let t=0;t<n.cellsY;++t)for(let r=0;r<n.cellsX;++r){if(!n.cells[t*n.cellsX+r])continue;const i=e.tileCoordToPixel(n.min.x+r/n.xScale,n.min.y+t/n.yScale),s=e.tileCoordToPixel(n.min.x+(r+1)/n.xScale,n.min.y+(t+1)/n.yScale);for(let t=i.y;t<=Math.min(s.y+1,a-1);++t)for(let r=i.x;r<=Math.min(s.x+1,a-1);++r)255===oy[t*a+r]&&(oy[t*a+r]=0,d+=e.getElevationAtPixel(r,t),m++);}const y=d/m;c=Math.max(1,i.x-u),h=Math.max(1,i.y-u),p=Math.min(o.x+u,a-2),f=Math.min(o.y+u,a-2),s=!0;for(let t=h;t<=f;++t)for(let r=c;r<=p;++r)0===oy[t*a+r]&&(sy[t*a+r]=e._dem.set(r,t,y));for(let t=1;t<u;++t){c=Math.max(1,i.x-t),h=Math.max(1,i.y-t),p=Math.min(o.x+t,a-2),f=Math.min(o.y+t,a-2);for(let r=h;r<=f;++r)for(let n=c;n<=p;++n){const i=r*a+n;if(255===oy[i]){let s=0,o=0,l=-1,c=-1;for(let e=-1;e<=1;++e)for(let i=-1;i<=1;++i){const u=(r+e)*a+n+i;if(oy[u]>=t)continue;const h=sy[u],p=Math.abs(h);p>o&&(s=h,o=p,l=i,c=e);}if(o>.1){const a=1-(t+.5*Math.abs(l*c))/u;let o=e._dem.get(n,r)+s*a;const h=e._dem.get(n+l,r+c),p=e._dem.get(n-l,r-c,!0);(o-h)*(o-p)>0&&(o=(h+p)/2),sy[i]=e._dem.set(n,r,o),oy[i]=t;}}}}}s&&(e._demTile.needsDEMTextureUpload=!0,e._dem._timestamp=Rt.now());}getNodesInfo(){return this.nodesInfo}destroy(){const t=this.getNodesInfo();for(const e of t)ny(e.node),iy(e.node);}isEmpty(){return !this.nodesInfo.length}updateReplacement(t,e){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const r=e.getReplacementRegionsForTile(t.toUnwrapped()),n=this.getNodesInfo();for(let t=0;t<this.nodesInfo.length;t++){const e=n[t].node;n[t].hiddenByReplacement=!!e.footprint&&!r.find((t=>t.footprint===e.footprint));}}getHeightAtTileCoord(t,e){const r=this.getNodesInfo(),n=[],i=[0,0,0],a=O.mat4.identity([]);for(let s=0;s<this.nodesInfo.length;s++){const o=r[s],l=o.node.meshes[0],u=l.transformedAabb;if(t<u.min[0]||e<u.min[1]||t>u.max[0]||e>u.max[1])continue;if(!0===o.node.hidden)return {height:1/0,maxHeight:o.feature.properties.height,hidden:!1,verticalScale:o.evaluatedScale[2]};O.mat4.invert(a,o.node.matrix),i[0]=t,i[1]=e,O.vec3.transformMat4(i,i,a);const c=(i[0]-l.aabb.min[0])/(l.aabb.max[0]-l.aabb.min[0])*Km|0,h=Math.min(63,(i[1]-l.aabb.min[1])/(l.aabb.max[1]-l.aabb.min[1])*Km|0)*Km+Math.min(63,c),p=l.heightmap[h];if(!(p<0&&o.node.footprint)){if(o.hiddenByReplacement)return;return {height:p,maxHeight:o.feature.properties.height,hidden:!1,verticalScale:o.evaluatedScale[2]}}if(o.node.footprint.grid.query(new q(t,e),new q(t,e),n),n.length>0)return {height:void 0,maxHeight:o.feature.properties.height,hidden:o.hiddenByReplacement,verticalScale:o.evaluatedScale[2]}}}}function fy(t,e){return !t.isLightConstant&&e}function dy(t,e,r,n,i,a,s,o){let l=(61440&e|(61440&e)>>4)>>8,u=(3840&e|(3840&e)>>4)>>4,c=240&e|(240&e)>>4;r[3]>0&&(l=Pe(l,255*r[0],r[3]),u=Pe(u,255*r[1],r[3]),c=Pe(c,255*r[2],r[3]));const h=l<<8|u,p=c<<8|Math.floor(255*n[3]),f=function(t){const e=Q(t,0,2);return Math.min(Math.round(.5*e*255),255)}(n[2])<<8|15*n[0]<<4|15*n[1],d=Q(i[0],0,1),m=Q(i[1],0,1),y=Q(i[2],0,1),g=Q(i[3],0,1);let x,v,b,w;if(d!==m&&s!==a&&m!==d){const t=s-a;v=1/(t*(m-d)),b=-(a+t*d)/(t*(m-d));const e=Q(i[4],-1,1);w=Math.pow(10,e),x=255*y<<8|255*g;}else x=65535,v=0,b=1,w=1;if(t.emplaceBack(h,p,f,x,v,b,w),o){const t=o.length;o.clear();for(let e=0;e<t;e++)o.emplaceBack(h,p,f,x,v,b,w);}}function my(t,e,r){const n=t.node;let i=0;const a=r&Jm.HasMeshoptCompression;for(const r of n.meshes){if(n.lights&&n.lightMeshIndex===i)continue;if(!r.featureData)continue;r.featureArray=new Ys,r.featureArray.reserve(r.featureData.length);let s=e;for(const e of r.featureData){const i=a?65535&e:e>>16&65535,o=a?e>>16&65535:65535&e,l=(15&o)<8?15&o:0,u=t.evaluatedRMEA[l],c=t.evaluatedColor[l],h=t.emissionHeightBasedParams[l];let p;if(s&&2===l&&n.lights&&(p=new Ys,p.resize(10*n.lights.length)),dy(r.featureArray,i,c,u,h,r.aabb.min[2],r.aabb.max[2],p),p&&s){s=!1;const t=n.meshes[n.lightMeshIndex];t.featureArray=p,t.featureArray._trim();}}r.featureArray._trim(),i++;}}sa(py,"Tiled3dModelBucket",{omit:["layers"]}),sa(hy,"Tiled3dModelFeature");const yy=["id","tile","layer","source","sourceLayer","state"];class gy{constructor(t,e,r,n,i){this.type="Feature",this._vectorTileFeature=t,this._z=e,this._x=r,this._y=n,this.properties=t.properties,this.id=i;}clone(){const t=new gy(this._vectorTileFeature,this._z,this._x,this._y,this.id);return this.state&&(t.state={...this.state}),this.layer&&(t.layer={...this.layer}),this.namespace&&(t.namespace=this.namespace),t}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(t){this._geometry=t;}toJSON(){const t={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};for(const e of yy)void 0!==this[e]&&(t[e]=this[e]);return t}}function xy(t,e,r,n){const i=1<<t.z;e.lat=pl((n/Wr+t.y)/i),e.lng=hl((r/Wr+t.x)/i);}const vy={circle:class extends hs{constructor(t,e,r,n){super(t,{layout:Hl||(Hl=new $a({"circle-sort-key":new Na(Ga.layout_circle["circle-sort-key"]),visibility:new ja(Ga.layout_circle.visibility)})),paint:Kl||(Kl=new $a({"circle-radius":new Na(Ga.paint_circle["circle-radius"]),"circle-color":new Na(Ga.paint_circle["circle-color"]),"circle-blur":new Na(Ga.paint_circle["circle-blur"]),"circle-opacity":new Na(Ga.paint_circle["circle-opacity"]),"circle-translate":new ja(Ga.paint_circle["circle-translate"]),"circle-translate-anchor":new ja(Ga.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new ja(Ga.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new ja(Ga.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new Na(Ga.paint_circle["circle-stroke-width"]),"circle-stroke-color":new Na(Ga.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new Na(Ga.paint_circle["circle-stroke-opacity"]),"circle-emissive-strength":new ja(Ga.paint_circle["circle-emissive-strength"])}))},e,r,n);}createBucket(t){return new El(t)}queryRadius(t){const e=t;return Xl("circle-radius",this,e)+Xl("circle-stroke-width",this,e)+Yl(this.paint.get("circle-translate"))}queryIntersectsFeature(t,e,r,n,i,a,s,o){const l=Wl(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),a.angle,t.pixelToTileUnitsFactor),u=this.paint.get("circle-radius").evaluate(e,r)+this.paint.get("circle-stroke-width").evaluate(e,r);return Gu(t,n,a,s,o,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),l,u)}getProgramIds(){return ["circle"]}getDefaultProgramParams(t,e,r){const n=$u(this);return {config:new Fo(this,{zoom:e,lut:r}),defines:n,overrideFog:!1}}},heatmap:class extends hs{createBucket(t){return new Hu(t)}constructor(t,e,r,n){super(t,{layout:Ku||(Ku=new $a({visibility:new ja(Ga.layout_heatmap.visibility)})),paint:Ju||(Ju=new $a({"heatmap-radius":new Na(Ga.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Na(Ga.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new ja(Ga.paint_heatmap["heatmap-intensity"]),"heatmap-color":new qa(Ga.paint_heatmap["heatmap-color"]),"heatmap-opacity":new ja(Ga.paint_heatmap["heatmap-opacity"])}))},e,r,n),this._updateColorRamp();}_handleSpecialPaintPropertyUpdate(t){"heatmap-color"===t&&this._updateColorRamp();}_updateColorRamp(){this.colorRamp=oc({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null;}resize(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null);}queryRadius(t){return Xl("heatmap-radius",this,t)}queryIntersectsFeature(t,e,r,n,i,a,s,o){const l=this.paint.get("heatmap-radius").evaluate(e,r);return Gu(t,n,a,s,o,!0,!0,new q(0,0),l)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return ["heatmap","heatmapTexture"]}getDefaultProgramParams(t,e,r){return "heatmap"===t?{config:new Fo(this,{zoom:e,lut:r}),overrideFog:!1}:{}}},hillshade:class extends hs{constructor(t,e,r,n){super(t,{layout:Qu||(Qu=new $a({visibility:new ja(Ga.layout_hillshade.visibility)})),paint:tc||(tc=new $a({"hillshade-illumination-direction":new ja(Ga.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new ja(Ga.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new ja(Ga.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new ja(Ga.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new ja(Ga.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new ja(Ga.paint_hillshade["hillshade-accent-color"]),"hillshade-emissive-strength":new ja(Ga.paint_hillshade["hillshade-emissive-strength"])}))},e,r,n);}shouldRedrape(){return this.hasOffscreenPass()&&"viewport"===this.paint.get("hillshade-illumination-anchor")}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return ["hillshade","hillshadePrepare"]}getDefaultProgramParams(t,e,r){return {overrideFog:!1}}},fill:class extends hs{constructor(t,e,r,n){super(t,{layout:Uc||(Uc=new $a({"fill-sort-key":new Na(Ga.layout_fill["fill-sort-key"]),visibility:new ja(Ga.layout_fill.visibility),"fill-elevation-reference":new ja(Ga.layout_fill["fill-elevation-reference"])})),paint:jc||(jc=new $a({"fill-antialias":new ja(Ga.paint_fill["fill-antialias"]),"fill-opacity":new Na(Ga.paint_fill["fill-opacity"]),"fill-color":new Na(Ga.paint_fill["fill-color"]),"fill-outline-color":new Na(Ga.paint_fill["fill-outline-color"]),"fill-translate":new ja(Ga.paint_fill["fill-translate"]),"fill-translate-anchor":new ja(Ga.paint_fill["fill-translate-anchor"]),"fill-pattern":new Na(Ga.paint_fill["fill-pattern"]),"fill-emissive-strength":new ja(Ga.paint_fill["fill-emissive-strength"]),"fill-z-offset":new Na(Ga.paint_fill["fill-z-offset"])}))},e,r,n);}getProgramIds(){const t=this.paint.get("fill-pattern"),e=t&&t.constantOr(1),r=[e?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&r.push(e&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),r}getDefaultProgramParams(t,e,r){return {config:new Fo(this,{zoom:e,lut:r}),overrideFog:!1}}recalculate(t,e){super.recalculate(t,e);const r=this.paint._values["fill-outline-color"];"constant"===r.value.kind&&void 0===r.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"]);}createBucket(t){return new Oc(t)}queryRadius(){return Yl(this.paint.get("fill-translate"))}queryIntersectsFeature(t,e,r,n,i,a){return !t.queryGeometry.isAboveHorizon&&Cl(Zl(t.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),a.angle,t.pixelToTileUnitsFactor),n)}isTileClipped(){return !0}is3D(){return 0!==this.paint.get("fill-z-offset").constantOr(1)}},"fill-extrusion":class extends hs{constructor(t,e,r,n){super(t,{layout:sp||(sp=new $a({visibility:new ja(Ga["layout_fill-extrusion"].visibility),"fill-extrusion-edge-radius":new ja(Ga["layout_fill-extrusion"]["fill-extrusion-edge-radius"])})),paint:op||(op=new $a({"fill-extrusion-opacity":new ja(Ga["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Na(Ga["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new ja(Ga["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new ja(Ga["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Na(Ga["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Na(Ga["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Na(Ga["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-height-alignment":new ja(Ga["paint_fill-extrusion"]["fill-extrusion-height-alignment"]),"fill-extrusion-base-alignment":new ja(Ga["paint_fill-extrusion"]["fill-extrusion-base-alignment"]),"fill-extrusion-vertical-gradient":new ja(Ga["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"]),"fill-extrusion-ambient-occlusion-intensity":new ja(Ga["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-intensity"]),"fill-extrusion-ambient-occlusion-radius":new ja(Ga["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-radius"]),"fill-extrusion-ambient-occlusion-wall-radius":new ja(Ga["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-wall-radius"]),"fill-extrusion-ambient-occlusion-ground-radius":new ja(Ga["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-ground-radius"]),"fill-extrusion-ambient-occlusion-ground-attenuation":new ja(Ga["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-ground-attenuation"]),"fill-extrusion-flood-light-color":new ja(Ga["paint_fill-extrusion"]["fill-extrusion-flood-light-color"]),"fill-extrusion-flood-light-intensity":new ja(Ga["paint_fill-extrusion"]["fill-extrusion-flood-light-intensity"]),"fill-extrusion-flood-light-wall-radius":new Na(Ga["paint_fill-extrusion"]["fill-extrusion-flood-light-wall-radius"]),"fill-extrusion-flood-light-ground-radius":new Na(Ga["paint_fill-extrusion"]["fill-extrusion-flood-light-ground-radius"]),"fill-extrusion-flood-light-ground-attenuation":new ja(Ga["paint_fill-extrusion"]["fill-extrusion-flood-light-ground-attenuation"]),"fill-extrusion-vertical-scale":new ja(Ga["paint_fill-extrusion"]["fill-extrusion-vertical-scale"]),"fill-extrusion-rounded-roof":new ja(Ga["paint_fill-extrusion"]["fill-extrusion-rounded-roof"]),"fill-extrusion-cutoff-fade-range":new ja(Ga["paint_fill-extrusion"]["fill-extrusion-cutoff-fade-range"]),"fill-extrusion-emissive-strength":new Na(Ga["paint_fill-extrusion"]["fill-extrusion-emissive-strength"]),"fill-extrusion-line-width":new Na(Ga["paint_fill-extrusion"]["fill-extrusion-line-width"]),"fill-extrusion-cast-shadows":new ja(Ga["paint_fill-extrusion"]["fill-extrusion-cast-shadows"])}))},e,r,n),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0};}createBucket(t){return new Wh(t)}queryRadius(){return Yl(this.paint.get("fill-extrusion-translate"))}is3D(){return !0}hasShadowPass(){return this.paint.get("fill-extrusion-cast-shadows")}cutoffRange(){return this.paint.get("fill-extrusion-cutoff-fade-range")}canCastShadows(){return !0}getProgramIds(){return [this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}queryIntersectsFeature(t,e,r,n,i,a,s,o,l){const u=Wl(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),a.angle,t.pixelToTileUnitsFactor),c=this.paint.get("fill-extrusion-height").evaluate(e,r),h=this.paint.get("fill-extrusion-base").evaluate(e,r),p=[0,0],f=o&&a.elevation,d=a.elevation?a.elevation.exaggeration():1,m=t.tile.getBucket(this);if(f&&m instanceof Wh){const t=m.centroidVertexArray,e=l+1;e<t.length&&(p[0]=t.geta_centroid_pos0(e),p[1]=t.geta_centroid_pos1(e));}if(0===p[0]&&1===p[1])return !1;"globe"===a.projection.name&&(n=ip([n],[new q(0,0),new q(Wr,Wr)],t.tileID.canonical).map((t=>t.polygon)).flat());const y=f?o:null,[g,x]=function(t,e,r,n,i,a,s,o,l,u,c){return "globe"===t.projection.name?function(t,e,r,n,i,a,s,o,l,u,c){const h=[],p=[],f=t.projection.upVectorScale(c,t.center.lat,t.worldSize).metersToTile,d=[0,0,0,1],m=[0,0,0,1],y=(t,e,r,n)=>{t[0]=e,t[1]=r,t[2]=n,t[3]=1;},g=np();r>0&&(r+=g),n+=g;for(const g of e){const e=[],x=[];for(const h of g){const p=h.x+i.x,g=h.y+i.y,v=t.projection.projectTilePoint(p,g,c),b=t.projection.upVector(c,h.x,h.y);let w=r,_=n;if(s){const t=cp(p,g,r,n,s,o,l,u);w+=t.base,_+=t.top;}0!==r?y(d,v.x+b[0]*f*w,v.y+b[1]*f*w,v.z+b[2]*f*w):y(d,v.x,v.y,v.z),y(m,v.x+b[0]*f*_,v.y+b[1]*f*_,v.z+b[2]*f*_),O.vec3.transformMat4(d,d,a),O.vec3.transformMat4(m,m,a),e.push(new ph(d[0],d[1],d[2])),x.push(new ph(m[0],m[1],m[2]));}h.push(e),p.push(x);}return [h,p]}(t,e,r,n,i,a,s,o,l,u,c):s?function(t,e,r,n,i,a,s,o,l){const u=[],c=[],h=[0,0,0,1];for(const p of t){const t=[],f=[];for(const u of p){const c=u.x+n.x,p=u.y+n.y,d=cp(c,p,e,r,a,s,o,l);h[0]=c,h[1]=p,h[2]=d.base,h[3]=1,O.vec4.transformMat4(h,h,i),h[3]=Math.max(h[3],1e-5);const m=new ph(h[0]/h[3],h[1]/h[3],h[2]/h[3]);h[0]=c,h[1]=p,h[2]=d.top,h[3]=1,O.vec4.transformMat4(h,h,i),h[3]=Math.max(h[3],1e-5);const y=new ph(h[0]/h[3],h[1]/h[3],h[2]/h[3]);t.push(m),f.push(y);}u.push(t),c.push(f);}return [u,c]}(e,r,n,i,a,s,o,l,u):function(t,e,r,n,i){const a=[],s=[],o=i[8]*e,l=i[9]*e,u=i[10]*e,c=i[11]*e,h=i[8]*r,p=i[9]*r,f=i[10]*r,d=i[11]*r;for(const e of t){const t=[],r=[];for(const a of e){const e=a.x+n.x,s=a.y+n.y,m=i[0]*e+i[4]*s+i[12],y=i[1]*e+i[5]*s+i[13],g=i[2]*e+i[6]*s+i[14],x=i[3]*e+i[7]*s+i[15],v=m+o,b=y+l,w=g+u,_=Math.max(x+c,1e-5),M=m+h,A=y+p,S=g+f,I=Math.max(x+d,1e-5);t.push(new ph(v/_,b/_,w/_)),r.push(new ph(M/I,A/I,S/I));}a.push(t),s.push(r);}return [a,s]}(e,r,n,i,a)}(a,n,h,c,u,s,y,p,d,a.center.lat,t.tileID.canonical),v=t.queryGeometry;return function(t,e,r){let n=1/0;Cl(r,e)&&(n=up(r,e[0]));for(let i=0;i<e.length;i++){const a=e[i],s=t[i];for(let t=0;t<a.length-1;t++){const e=a[t],i=[e,a[t+1],s[t+1],s[t],e];Bl(r,i)&&(n=Math.min(n,up(r,i)));}}return n!==1/0&&n}(g,x,v.isPointQuery()?v.screenBounds:v.screenGeometry)}},line:class extends hs{constructor(t,e,r,n){const i=Vp();super(t,i,e,r,n),i.layout&&(this.layout=new Ua(i.layout)),this.gradientVersion=0;}_handleSpecialPaintPropertyUpdate(t){if("line-gradient"===t){const t=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=t._styleExpression&&t._styleExpression.expression instanceof On,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}recalculate(t,e){super.recalculate(t,e),this.paint._values["line-floorwidth"]=(()=>{if(Rp)return Rp;const t=Vp();return Rp=new Cp(t.paint.properties["line-width"].specification),Rp.useIntegerZoom=!0,Rp})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t);}createBucket(t){return new _p(t)}getProgramIds(){return [this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getDefaultProgramParams(t,e,r){const n=Tp(this);return {config:new Fo(this,{zoom:e,lut:r}),defines:n,overrideFog:!1}}queryRadius(t){const e=t,r=Dp(Xl("line-width",this,e),Xl("line-gap-width",this,e)),n=Xl("line-offset",this,e);return r/2+Math.abs(n)+Yl(this.paint.get("line-translate"))}queryIntersectsFeature(t,e,r,n,i,a){if(t.queryGeometry.isAboveHorizon)return !1;const s=Zl(t.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),a.angle,t.pixelToTileUnitsFactor),o=t.pixelToTileUnitsFactor/2*Dp(this.paint.get("line-width").evaluate(e,r),this.paint.get("line-gap-width").evaluate(e,r)),l=this.paint.get("line-offset").evaluate(e,r);return l&&(n=function(t,e){const r=[],n=new q(0,0);for(let i=0;i<t.length;i++){const a=t[i],s=[];for(let t=0;t<a.length;t++){const r=a[t],i=a[t+1],o=0===t?n:r.sub(a[t-1])._unit()._perp(),l=t===a.length-1?n:i.sub(r)._unit()._perp(),u=o._add(l)._unit();u._mult(1/(u.x*l.x+u.y*l.y)),s.push(u._mult(e)._add(r));}r.push(s);}return r}(n,l*t.pixelToTileUnitsFactor)),function(t,e,r){for(let n=0;n<e.length;n++){const i=e[n];if(t.length>=3)for(let e=0;e<i.length;e++)if(jl(t,i[e]))return !0;if(Rl(t,i,r))return !0}return !1}(s,n,o)}isTileClipped(){return !0}isDraped(t){const e=this.layout.get("line-z-offset"),r=e.isConstant()&&!e.constantOr(0),n=this.layout.get("line-elevation-reference");return !("sea"===n||"ground"===n)&&(r||"none"!==n)}},symbol:rm,background:class extends hs{constructor(t,e,r,n){super(t,{layout:nm||(nm=new $a({visibility:new ja(Ga.layout_background.visibility)})),paint:im||(im=new $a({"background-pitch-alignment":new ja(Ga.paint_background["background-pitch-alignment"]),"background-color":new ja(Ga.paint_background["background-color"]),"background-pattern":new ja(Ga.paint_background["background-pattern"]),"background-opacity":new ja(Ga.paint_background["background-opacity"]),"background-emissive-strength":new ja(Ga.paint_background["background-emissive-strength"])}))},e,r,n);}getProgramIds(){return [this.paint.get("background-pattern")?"backgroundPattern":"background"]}getDefaultProgramParams(t,e,r){return {overrideFog:!1}}is3D(){return "viewport"===this.paint.get("background-pitch-alignment")}},raster:gm,"raster-particle":Mm,sky:class extends hs{constructor(t,e,r,n){super(t,{layout:bm||(bm=new $a({visibility:new ja(Ga.layout_sky.visibility)})),paint:wm||(wm=new $a({"sky-type":new ja(Ga.paint_sky["sky-type"]),"sky-atmosphere-sun":new ja(Ga.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new ja(Ga.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new ja(Ga.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new ja(Ga.paint_sky["sky-gradient-radius"]),"sky-gradient":new qa(Ga.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new ja(Ga.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new ja(Ga.paint_sky["sky-atmosphere-color"]),"sky-opacity":new ja(Ga.paint_sky["sky-opacity"])}))},e,r,n),this._updateColorRamp();}_handleSpecialPaintPropertyUpdate(t){"sky-gradient"===t?this._updateColorRamp():"sky-atmosphere-sun"!==t&&"sky-atmosphere-halo-color"!==t&&"sky-atmosphere-color"!==t&&"sky-atmosphere-sun-intensity"!==t||(this._skyboxInvalidated=!0);}_updateColorRamp(){this.colorRamp=oc({expression:this._transitionablePaint._values["sky-gradient"].value.expression,evaluationKey:"skyRadialProgress"}),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null);}needsSkyboxCapture(t){if(this._skyboxInvalidated||!this.skyboxTexture||!this.skyboxGeometry)return !0;if(!this.paint.get("sky-atmosphere-sun")){const e=t.style.light.properties.get("position");return this._lightPosition.azimuthal!==e.azimuthal||this._lightPosition.polar!==e.polar}return !1}getCenter(t,e){if("atmosphere"===this.paint.get("sky-type")){const r=this.paint.get("sky-atmosphere-sun"),n=!r,i=t.style.light,a=i.properties.get("position");return n&&"viewport"===i.properties.get("anchor")&&ft("The sun direction is attached to a light with viewport anchor, lighting may behave unexpectedly."),n?Sm(a.azimuthal,90-a.polar,e):Sm(r[0],90-r[1],e)}const r=this.paint.get("sky-gradient-center");return Sm(r[0],90-r[1],e)}isSky(){return !0}markSkyboxValid(t){this._skyboxInvalidated=!1,this._lightPosition=t.style.light.properties.get("position");}hasOffscreenPass(){return !0}getProgramIds(){const t=this.paint.get("sky-type");return "atmosphere"===t?["skyboxCapture","skybox"]:"gradient"===t?["skyboxGradient"]:null}},slot:class extends hs{constructor(t,e,r,n){super(t,{paint:_m||(_m=new $a({}))},e,null);}},model:class extends hs{constructor(t,e,r,n){super(t,{layout:Wm||(Wm=new $a({visibility:new ja(Ga.layout_model.visibility),"model-id":new Na(Ga.layout_model["model-id"])})),paint:Hm||(Hm=new $a({"model-opacity":new ja(Ga.paint_model["model-opacity"]),"model-rotation":new Na(Ga.paint_model["model-rotation"]),"model-scale":new Na(Ga.paint_model["model-scale"]),"model-translation":new Na(Ga.paint_model["model-translation"]),"model-color":new Na(Ga.paint_model["model-color"]),"model-color-mix-intensity":new Na(Ga.paint_model["model-color-mix-intensity"]),"model-type":new ja(Ga.paint_model["model-type"]),"model-cast-shadows":new ja(Ga.paint_model["model-cast-shadows"]),"model-receive-shadows":new ja(Ga.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new ja(Ga.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new Na(Ga.paint_model["model-emissive-strength"]),"model-roughness":new Na(Ga.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new Na(Ga.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new ja(Ga.paint_model["model-cutoff-fade-range"]),"model-front-cutoff":new ja(Ga.paint_model["model-front-cutoff"])}))},e,r,n),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0};}createBucket(t){return new Zm(t)}getProgramIds(){return ["model"]}is3D(){return !0}hasShadowPass(){return !0}canCastShadows(){return !0}hasLightBeamPass(){return !0}cutoffRange(){return this.paint.get("model-cutoff-fade-range")}queryRadius(t){return t instanceof py?Wr-1:0}queryIntersectsFeature(t,e,r,n,i,a){if(!this.modelManager)return !1;const s=this.modelManager,o=t.tile.getBucket(this);if(!(o&&o instanceof Zm))return !1;const l=o;for(const r in l.instancesPerModel){const n=l.instancesPerModel[r],i=void 0!==e.id?e.id:e.properties&&e.properties.hasOwnProperty("id")?e.properties.id:void 0;if(n.idToFeaturesIndex.hasOwnProperty(i)){const e=n.features[n.idToFeaturesIndex[i]],o=s.getModel(r,this.scope);if(!o)return !1;let u=O.mat4.create();const c=new nl(0,0),h=l.canonical;let p=Number.MAX_VALUE;for(let r=0;r<e.instancedDataCount;++r){const i=16*(e.instancedDataOffset+r),s=n.instancedDataArray.float32,l=[s[i+4],s[i+5],s[i+6]];xy(h,c,s[i],0|s[i+1]),Qm(u,o,a,c,e.rotation,e.scale,l,!1,!1,!1),"globe"===a.projection.name&&(u=Cm(u,a));const f=O.mat4.multiply([],a.projMatrix,u),d=t.queryGeometry,m=Rm(d.isPointQuery()?d.screenBounds:d.screenGeometry,a,f,o.aabb);null!=m&&(p=Math.min(m,p));}return p!==Number.MAX_VALUE&&p}}return !1}_handleOverridablePaintPropertyUpdate(t,e,r){return !(!this.layout||e.isDataDriven()||r.isDataDriven()||"model-color"!==t&&"model-color-mix-intensity"!==t&&"model-rotation"!==t&&"model-scale"!==t&&"model-translation"!==t&&"model-emissive-strength"!==t)}_isPropertyZoomDependent(t){const e=this._transitionablePaint._values[t];return null!=e&&null!=e.value&&null!=e.value.expression&&e.value.expression instanceof Ki}isZoomDependent(){return this._isPropertyZoomDependent("model-scale")||this._isPropertyZoomDependent("model-rotation")||this._isPropertyZoomDependent("model-translation")}queryIntersectsMatchingFeature(t,e,r,n){const i=t.tile,a=i.getBucket(this);let s=null,o=Number.MAX_VALUE;if(!(a&&a instanceof py))return {queryFeature:s,intersectionZ:o};const l=a.getNodesInfo()[e];if(l.hiddenByReplacement||!l.node.meshes||!r.filter(new Ba(i.tileID.overscaledZ),l.feature,i.tileID.canonical))return {queryFeature:s,intersectionZ:o};const u=l.node,c=n.calculatePosMatrix(i.tileID.toUnwrapped(),n.worldSize),h=l.evaluatedScale;let p=0;n.elevation&&u.elevation&&(p=u.elevation*n.elevation.exaggeration()),O.mat4.translate(c,c,[(u.anchor?u.anchor[0]:0)*(h[0]-1),(u.anchor?u.anchor[1]:0)*(h[1]-1),p]),O.mat4.scale(c,c,h);const f=t.queryGeometry,d=f.isPointQuery()?f.screenBounds:f.screenGeometry,m=function(t){const e=O.mat4.multiply([],c,t.matrix);O.mat4.multiply(e,n.expandedFarZProjMatrix,e);for(let r=0;r<t.meshes.length;++r){const i=t.meshes[r];if(r===t.lightMeshIndex)continue;const a=Rm(d,n,e,i.aabb);null!=a&&(o=Math.min(a,o));}if(t.children)for(const e of t.children)m(e);};if(m(u),o===Number.MAX_VALUE)return {queryFeature:s,intersectionZ:o};const y=new nl(0,0);xy(i.tileID.canonical,y,l.node.anchor[0],l.node.anchor[1]);const{z:g,x,y:v}=i.tileID.canonical;return s=new gy({},g,x,v,l.feature.id),s.properties=l.feature.properties,s.geometry={type:"Point",coordinates:[y.lng,y.lat]},s.layer={...this.serialize(),id:this.fqid},s.state={},s.tile=i.tileID.canonical,{queryFeature:s,intersectionZ:o}}},clip:class extends hs{constructor(t,e,r,n){super(t,{layout:Nc||(Nc=new $a({"clip-layer-types":new ja(Ga.layout_clip["clip-layer-types"]),"clip-layer-scope":new ja(Ga.layout_clip["clip-layer-scope"])})),paint:qc||(qc=new $a({}))},e,r,n);}recalculate(t,e){super.recalculate(t,e);}createBucket(t){return new Xc(t)}isTileClipped(){return !0}is3D(){return !0}}};class by{constructor(t){this._callback=t,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 wy{constructor(){this.tasks={},this.taskQueue=[],ot(["process"],this),this.invoker=new by(this.process),this.nextId=0;}add(t,e){const r=this.nextId++,n=function({type:t,isSymbolTile:e,zoom:r}){return r=r||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-r:"maybePrepare"===t&&e?400-r:500:200-r:100-r}(e);if(0===n){try{t();}finally{}return null}return this.tasks[r]={fn:t,metadata:e,priority:n,id:r},this.taskQueue.push(r),this.invoker.trigger(),{cancel:()=>{delete this.tasks[r];}}}process(){try{if(this.taskQueue=this.taskQueue.filter((t=>!!this.tasks[t])),!this.taskQueue.length)return;const t=this.pick();if(null===t)return;const e=this.tasks[t];if(delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),!e)return;e.fn();}finally{}}pick(){let t=null,e=1/0;for(let r=0;r<this.taskQueue.length;r++){const n=this.tasks[this.taskQueue[r]];n.priority<e&&(e=n.priority,t=r);}if(null===t)return null;const r=this.taskQueue[t];return this.taskQueue.splice(t,1),r}remove(){this.invoker.remove();}}class _y{constructor(t,e,r){this.target=t,this.parent=e,this.mapId=r,this.callbacks={},this.cancelCallbacks={},ot(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.scheduler=new wy;}send(t,e,r,n,i=!1,a){const s=Math.round(1e18*Math.random()).toString(36).substring(0,10);r&&(r.metadata=a,this.callbacks[s]=r);const o=new Set;return this.target.postMessage({id:s,type:t,hasCallback:!!r,targetMapId:n,mustQueue:i,sourceMapId:this.mapId,data:ua(e,o)},o),{cancel:()=>{r&&delete this.callbacks[s],this.target.postMessage({id:s,type:"<cancel>",targetMapId:n,sourceMapId:this.mapId});}}}receive(t){const e=t.data,r=e.id;if(r&&(!e.targetMapId||this.mapId===e.targetMapId))if("<cancel>"===e.type){const t=this.cancelCallbacks[r];delete this.cancelCallbacks[r],t&&t.cancel();}else if(e.mustQueue||gt()){const t=this.callbacks[r],n=this.scheduler.add((()=>this.processTask(r,e)),t&&t.metadata||{type:"message"});n&&(this.cancelCallbacks[r]=n);}else this.processTask(r,e);}processTask(t,e){if(delete this.cancelCallbacks[t],"<response>"===e.type){const r=this.callbacks[t];delete this.callbacks[t],r&&(e.error?r(ca(e.error)):r(null,ca(e.data)));}else {const r=new Set,n=e.hasCallback?(e,n)=>{this.target.postMessage({id:t,type:"<response>",sourceMapId:this.mapId,error:e?ua(e):null,data:ua(n,r)},r);}:()=>{},i=ca(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,i,n);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],i.source,i.scope)[t[1]](i,n);}else n(new Error(`Could not find function ${e.type}`));}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1);}}class My{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=at();const r=this.workerPool.acquire(this.id);for(let t=0;t<r.length;t++){const n=new My.Actor(r[t],e,this.id);n.name=`Worker ${t}`,this.actors.push(n);}this.ready=!1,this.broadcast("checkIfReady",null,(()=>{this.ready=!0;}));}broadcast(t,e,r){rt(this.actors,((r,n)=>{r.send(t,e,n);}),r=r||function(){});}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((t=>{t.remove();})),this.actors=[],this.workerPool.release(this.id);}}My.Actor=_y;class Ay{constructor(t){this.size=t,this.minimums=[],this.maximums=[],this.leaves=[];}getElevation(t,e){const r=this.toIdx(t,e);return {min:this.minimums[r],max:this.maximums[r]}}isLeaf(t,e){return this.leaves[this.toIdx(t,e)]}toIdx(t,e){return e*this.size+t}}function Sy(t,e,r,n){let i=0,a=Number.MAX_VALUE;for(let s=0;s<3;s++)if(Math.abs(n[s])<1e-15){if(r[s]<t[s]||r[s]>e[s])return null}else {const o=1/n[s];let l=(t[s]-r[s])*o,u=(e[s]-r[s])*o;if(l>u){const t=l;l=u,u=t;}if(l>i&&(i=l),u<a&&(a=u),i>a)return null}return i}function Iy(t,e,r,n,i,a,s,o,l,u,c){const h=n-t,p=i-e,f=a-r,d=s-t,m=o-e,y=l-r,g=c[1]*y-c[2]*m,x=c[2]*d-c[0]*y,v=c[0]*m-c[1]*d,b=h*g+p*x+f*v;if(Math.abs(b)<1e-15)return null;const w=1/b,_=u[0]-t,M=u[1]-e,A=u[2]-r,S=(_*g+M*x+A*v)*w;if(S<0||S>1)return null;const I=M*f-A*p,z=A*h-_*f,P=_*p-M*h,k=(c[0]*I+c[1]*z+c[2]*P)*w;return k<0||S+k>1?null:(d*I+m*z+y*P)*w}function zy(t,e,r){return (t-e)/(r-e)}function Py(t,e,r,n,i,a,s,o,l){const u=1<<r,c=a-n,h=s-i,p=(t+1)/u*c+n,f=(e+0)/u*h+i,d=(e+1)/u*h+i;o[0]=(t+0)/u*c+n,o[1]=f,l[0]=p,l[1]=d;}class ky{constructor(t){if(this.maximums=[],this.minimums=[],this.leaves=[],this.childOffsets=[],this.nodeCount=0,this.dem=t,this._siblingOffset=[[0,0],[1,0],[0,1],[1,1]],!this.dem)return;const e=function(t){const e=Math.ceil(Math.log2(t.dim/8)),r=[];let n=Math.ceil(Math.pow(2,e));const i=1/n,a=(t,e,r,n,i)=>{const a=n?1:0,s=(t+1)*r-a,o=e*r,l=(e+1)*r-a;i[0]=t*r,i[1]=o,i[2]=s,i[3]=l;};let s=new Ay(n);const o=[];for(let e=0;e<n*n;e++){a(e%n,Math.floor(e/n),i,!1,o);const r=Ey(o[0],o[1],t),l=Ey(o[2],o[1],t),u=Ey(o[2],o[3],t),c=Ey(o[0],o[3],t);s.minimums.push(Math.min(r,l,u,c)),s.maximums.push(Math.max(r,l,u,c)),s.leaves.push(1);}for(r.push(s),n/=2;n>=1;n/=2){const t=r[r.length-1];s=new Ay(n);for(let e=0;e<n*n;e++){a(e%n,Math.floor(e/n),2,!0,o);const r=t.getElevation(o[0],o[1]),i=t.getElevation(o[2],o[1]),l=t.getElevation(o[2],o[3]),u=t.getElevation(o[0],o[3]),c=t.isLeaf(o[0],o[1]),h=t.isLeaf(o[2],o[1]),p=t.isLeaf(o[2],o[3]),f=t.isLeaf(o[0],o[3]),d=Math.min(r.min,i.min,l.min,u.min),m=Math.max(r.max,i.max,l.max,u.max),y=c&&h&&p&&f;s.maximums.push(m),s.minimums.push(d),s.leaves.push(m-d<=5&&y?1:0);}r.push(s);}return r}(this.dem),r=e.length-1,n=e[r];this._addNode(n.minimums[0],n.maximums[0],n.leaves[0]),this._construct(e,0,0,r,0);}raycastRoot(t,e,r,n,i,a,s=1){return Sy([t,e,-100],[r,n,this.maximums[0]*s],i,a)}raycast(t,e,r,n,i,a,s=1){if(!this.nodeCount)return null;const o=this.raycastRoot(t,e,r,n,i,a,s);if(null==o)return null;const l=[],u=[],c=[],h=[],p=[{idx:0,t:o,nodex:0,nodey:0,depth:0}];for(;p.length>0;){const{idx:o,t:f,nodex:d,nodey:m,depth:y}=p.pop();if(this.leaves[o]){Py(d,m,y,t,e,r,n,c,h);const o=1<<y,l=(d+0)/o,u=(d+1)/o,p=(m+0)/o,g=(m+1)/o,x=Ey(l,p,this.dem)*s,v=Ey(u,p,this.dem)*s,b=Ey(u,g,this.dem)*s,w=Ey(l,g,this.dem)*s,_=Iy(c[0],c[1],x,h[0],c[1],v,h[0],h[1],b,i,a),M=Iy(h[0],h[1],b,c[0],h[1],w,c[0],c[1],x,i,a),A=Math.min(null!==_?_:Number.MAX_VALUE,null!==M?M:Number.MAX_VALUE);if(A!==Number.MAX_VALUE)return A;{const t=O.vec3.scaleAndAdd([],i,a,f);if(Ty(x,v,w,b,zy(t[0],c[0],h[0]),zy(t[1],c[1],h[1]))>=t[2])return f}continue}let g=0;for(let p=0;p<this._siblingOffset.length;p++){Py((d<<1)+this._siblingOffset[p][0],(m<<1)+this._siblingOffset[p][1],y+1,t,e,r,n,c,h),c[2]=-100,h[2]=this.maximums[this.childOffsets[o]+p]*s;const f=Sy(c,h,i,a);if(null!=f){const t=f;l[p]=t;let e=!1;for(let r=0;r<g&&!e;r++)t>=l[u[r]]&&(u.splice(r,0,p),e=!0);e||(u[g]=p),g++;}}for(let t=0;t<g;t++){const e=u[t];p.push({idx:this.childOffsets[o]+e,t:l[e],nodex:(d<<1)+this._siblingOffset[e][0],nodey:(m<<1)+this._siblingOffset[e][1],depth:y+1});}}return null}_addNode(t,e,r){return this.minimums.push(t),this.maximums.push(e),this.leaves.push(r),this.childOffsets.push(0),this.nodeCount++}_construct(t,e,r,n,i){if(1===t[n].isLeaf(e,r))return;this.childOffsets[i]||(this.childOffsets[i]=this.nodeCount);const a=n-1,s=t[a];let o=0,l=0;for(let t=0;t<this._siblingOffset.length;t++){const n=2*e+this._siblingOffset[t][0],i=2*r+this._siblingOffset[t][1],a=s.getElevation(n,i),u=s.isLeaf(n,i),c=this._addNode(a.min,a.max,u);u&&(o|=1<<t),l||(l=c);}for(let n=0;n<this._siblingOffset.length;n++)o&1<<n||this._construct(t,2*e+this._siblingOffset[n][0],2*r+this._siblingOffset[n][1],a,l+n);}}function Ty(t,e,r,n,i,a){return Pe(Pe(t,r,a),Pe(e,n,a),i)}function Ey(t,e,r){const n=r.dim,i=Q(t*n-.5,0,n-1),a=Q(e*n-.5,0,n-1),s=Math.floor(i),o=Math.floor(a),l=Math.min(s+1,n-1),u=Math.min(o+1,n-1);return Ty(r.get(s,o),r.get(l,o),r.get(s,u),r.get(l,u),i-s,a-o)}const By={mapbox:[6553.6,25.6,.1,1e4],terrarium:[256,1,1/256,32768]};function Vy(t,e,r){return (256*t*256+256*e+r)/10-1e4}function Cy(t,e,r){return 256*t+e+r/256-32768}class Ry{get tree(){return this._tree||this._buildQuadTree(),this._tree}constructor(t,e,r,n=!1){if(this.uid=t,e.height!==e.width)throw new RangeError("DEM tiles must be square");if(r&&"mapbox"!==r&&"terrarium"!==r)return void ft(`"${r}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);this.stride=e.height;const i=this.dim=e.height-2,a=new Uint32Array(e.data.buffer);if(this.pixels=new Uint8Array(e.data.buffer),this.floatView=new Float32Array(e.data.buffer),this.borderReady=n,this._modifiedForSources={},!n){for(let t=0;t<i;t++)a[this._idx(-1,t)]=a[this._idx(0,t)],a[this._idx(i,t)]=a[this._idx(i-1,t)],a[this._idx(t,-1)]=a[this._idx(t,0)],a[this._idx(t,i)]=a[this._idx(t,i-1)];a[this._idx(-1,-1)]=a[this._idx(0,0)],a[this._idx(i,-1)]=a[this._idx(i-1,0)],a[this._idx(-1,i)]=a[this._idx(0,i-1)],a[this._idx(i,i)]=a[this._idx(i-1,i-1)];}const s="terrarium"===r?Cy:Vy;for(let t=0;t<a.length;++t){const e=4*t;this.floatView[t]=s(this.pixels[e],this.pixels[e+1],this.pixels[e+2]);}this._timestamp=Rt.now();}_buildQuadTree(){this._tree=new ky(this);}get(t,e,r=!1){r&&(t=Q(t,-1,this.dim),e=Q(e,-1,this.dim));const n=this._idx(t,e);return this.floatView[n]}set(t,e,r){const n=this._idx(t,e),i=this.floatView[n];return this.floatView[n]=r,r-i}static getUnpackVector(t){return By[t]}_idx(t,e){if(t<-1||t>=this.dim+1||e<-1||e>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return (e+1)*this.stride+(t+1)}static pack(t,e){const r=[0,0,0,0],n=Ry.getUnpackVector(e);let i=Math.floor((t+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 sc({width:this.stride,height:this.stride},this.pixels)}backfillBorder(t,e,r){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let n=e*this.dim,i=e*this.dim+this.dim,a=r*this.dim,s=r*this.dim+this.dim;switch(e){case-1:n=i-1;break;case 1:i=n+1;}switch(r){case-1:a=s-1;break;case 1:s=a+1;}const o=-e*this.dim,l=-r*this.dim;for(let e=a;e<s;e++)for(let r=n;r<i;r++){const n=4*this._idx(r,e),i=4*this._idx(r+o,e+l);this.pixels[n+0]=t.pixels[i+0],this.pixels[n+1]=t.pixels[i+1],this.pixels[n+2]=t.pixels[i+2],this.pixels[n+3]=t.pixels[i+3];}}onDeserialize(){this._tree&&(this._tree.dem=this);}}function Dy(t,e,r){1===t?e.headerLength=r.readFixed32():2===t?e.x=r.readVarint():3===t?e.y=r.readVarint():4===t?e.z=r.readVarint():5===t&&e.layers.push(function(t,e){return t.readFields(jy,{version:0,name:"",units:"",tileSize:0,buffer:0,pixelFormat:0,dataIndex:[]},e)}(r,r.readVarint()+r.pos));}function Ly(t,e,r){1===t?(e.delta_filter=function(t,e){return t.readFields(Fy,{blockSize:0},e)}(r,r.readVarint()+r.pos),e.filter="delta_filter"):2===t?(r.readVarint(),e.filter="zigzag_filter"):3===t?(r.readVarint(),e.filter="bitshuffle_filter"):4===t&&(r.readVarint(),e.filter="byteshuffle_filter");}function Fy(t,e,r){1===t&&(e.blockSize=r.readVarint());}function Oy(t,e,r){1===t?(r.readVarint(),e.codec="gzip_data"):2===t?(r.readVarint(),e.codec="jpeg_image"):3===t?(r.readVarint(),e.codec="webp_image"):4===t&&(r.readVarint(),e.codec="png_image");}function Uy(t,e,r){let n=0,i=0;1===t?e.firstByte=r.readFixed64():2===t?e.lastByte=r.readFixed64():3===t?e.filters.push(function(t,e){return t.readFields(Ly,{},e)}(r,r.readVarint()+r.pos)):4===t?e.codec=function(t,e){return t.readFields(Oy,{},e)}(r,r.readVarint()+r.pos):5===t?i=r.readFloat():6===t?n=r.readFloat():7===t?e.bands.push(r.readString()):8===t?e.offset=r.readDouble():9===t&&(e.scale=r.readDouble()),0===e.offset&&(e.offset=i),0===e.scale&&(e.scale=n);}function jy(t,e,r){1===t?e.version=r.readVarint():2===t?e.name=r.readString():3===t?e.units=r.readString():4===t?e.tileSize=r.readVarint():5===t?e.buffer=r.readVarint():6===t?e.pixelFormat=r.readVarint():7===t&&e.dataIndex.push(function(t,e){return t.readFields(Uy,{firstByte:0,lastByte:0,filters:[],codec:null,offset:0,scale:0,bands:[]},e)}(r,r.readVarint()+r.pos));}function Ny(t,e,r){if(2===t)!function(t,e,r){t.readFields(qy,r,e);}(r,r.readVarint()+r.pos,e);else if(3===t)throw new Error("Not implemented")}function qy(t,e,r){if(1===t){let t=0;const n=r.readVarint()+r.pos;for(;r.pos<n;)e[t++]=r.readVarint();}}sa(Ry,"DEMData"),sa(ky,"DemMinMaxQuadTree",{omit:["dem"]});class $y{constructor(t){this.capacity=t,this.cache=new Map;}get(t){if(!this.cache.has(t))return;const e=this.cache.get(t);return this.cache.delete(t),this.cache.set(t,e),e}put(t,e){this.cache.has(t)?this.cache.delete(t):this.cache.size===this.capacity&&this.cache.delete(this.cache.keys().next().value),this.cache.set(t,e);}}function Gy(t,e){if(4!==e.length)throw new Error(`Expected data of dimension 4 but got ${e.length}.`);let r=e[3];for(let n=2;n>=1;n--){const i=1===n?1:0,a=2===n?1:0;for(let n=0;n<e[0];n++){const s=e[1]*n;for(let n=i;n<e[1];n++){const i=e[2]*(n+s);for(let n=a;n<e[2];n++){const a=e[3]*(n+i);for(let n=0;n<e[3];n++){const e=a+n;t[e]+=t[e-r];}}}}r*=e[n];}return t}function Xy(t){for(let e=0,r=t.length;e<r;e++)t[e]=t[e]>>>1^-(1&t[e]);return t}function Yy(t,e){switch(e){case"uint32":return t;case"uint16":for(let e=0;e<t.length;e+=2){const r=t[e],n=t[e+1];t[e]=(240&r)>>4|(61440&r)>>8|(240&n)<<4|61440&n,t[e+1]=15&r|(3840&r)>>4|(15&n)<<8|(3840&n)<<4;}return t;case"uint8":for(let e=0;e<t.length;e+=4){const r=t[e],n=t[e+1],i=t[e+2],a=t[e+3];t[e+0]=(192&r)>>6|(192&n)>>4|(192&i)>>2|192&a,t[e+1]=(48&r)>>4|(48&n)>>2|48&i|(48&a)<<2,t[e+2]=(12&r)>>2|12&n|(12&i)<<2|(12&a)<<4,t[e+3]=3&r|(3&n)<<2|(3&i)<<4|(3&a)<<6;}return t;default:throw new Error(`Invalid pixel format, "${e}"`)}}var Zy=Uint8Array,Wy=Uint16Array,Hy=Int32Array,Ky=new Zy([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]),Jy=new Zy([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]),Qy=new Zy([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),tg=function(t,e){for(var r=new Wy(31),n=0;n<31;++n)r[n]=e+=1<<t[n-1];var i=new Hy(r[30]);for(n=1;n<30;++n)for(var a=r[n];a<r[n+1];++a)i[a]=a-r[n]<<5|n;return {b:r,r:i}},eg=tg(Ky,2),rg=eg.b,ng=eg.r;rg[28]=258,ng[258]=28;for(var ig=tg(Jy,0).b,ag=new Wy(32768),sg=0;sg<32768;++sg){var og=(43690&sg)>>1|(21845&sg)<<1;ag[sg]=((65280&(og=(61680&(og=(52428&og)>>2|(13107&og)<<2))>>4|(3855&og)<<4))>>8|(255&og)<<8)>>1;}var lg=function(t,e,r){for(var n=t.length,i=0,a=new Wy(e);i<n;++i)t[i]&&++a[t[i]-1];var s,o=new Wy(e);for(i=1;i<e;++i)o[i]=o[i-1]+a[i-1]<<1;s=new Wy(1<<e);var l=15-e;for(i=0;i<n;++i)if(t[i])for(var u=i<<4|t[i],c=e-t[i],h=o[t[i]-1]++<<c,p=h|(1<<c)-1;h<=p;++h)s[ag[h]>>l]=u;return s},ug=new Zy(288);for(sg=0;sg<144;++sg)ug[sg]=8;for(sg=144;sg<256;++sg)ug[sg]=9;for(sg=256;sg<280;++sg)ug[sg]=7;for(sg=280;sg<288;++sg)ug[sg]=8;var cg=new Zy(32);for(sg=0;sg<32;++sg)cg[sg]=5;var hg=lg(ug,9),pg=lg(cg,5),fg=function(t){for(var e=t[0],r=1;r<t.length;++r)t[r]>e&&(e=t[r]);return e},dg=function(t,e,r){var n=e/8|0;return (t[n]|t[n+1]<<8)>>(7&e)&r},mg=function(t,e){var r=e/8|0;return (t[r]|t[r+1]<<8|t[r+2]<<16)>>(7&e)},yg=["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"],gg=function(t,e,r){var n=new Error(e||yg[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,gg),!r)throw n;return n},xg=new Zy(0),vg="undefined"!=typeof TextDecoder&&new TextDecoder;try{vg.decode(xg,{stream:!0});}catch(t){}const bg={gzip_data:"gzip"};class wg extends Error{constructor(t){super(t),this.name="MRTError";}}const _g={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},Mg={uint32:1,uint16:2,uint8:4},Ag={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let Sg;class Ig{constructor(t=5){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=t;}getLayer(t){const e=this.layers[t];if(!e)throw new wg(`Layer '${t}' not found`);return e}getHeaderLength(t){const e=new Uint8Array(t),r=new DataView(t);if(13!==e[0])throw new wg("File is not a valid MRT.");return r.getUint32(1,!0)}parseHeader(t){const e=new Uint8Array(t),r=this.getHeaderLength(t);if(e.length<r)throw new wg(`Expected header with length >= ${r} but got buffer of length ${e.length}`);const n=function(t,e){return t.readFields(Dy,{headerLength:0,x:0,y:0,z:0,layers:[]},void 0)}(new Sg(e.subarray(0,r)));if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new wg(`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 t of n.layers)this.layers[t.name]=new zg(t,{cacheSize:this._cacheSize});return this}createDecodingTask(t){const e=[],r=this.getLayer(t.layerName);for(let n of t.blockIndices){const i=r.dataIndex[n],a=i.firstByte-t.firstByte,s=i.lastByte-t.firstByte;if(r._blocksInProgress.has(n))continue;const o={layerName:r.name,firstByte:a,lastByte:s,pixelFormat:r.pixelFormat,blockIndex:n,blockShape:[i.bands.length].concat(r.bandShape),buffer:r.buffer,codec:i.codec.codec,filters:i.filters.map((t=>t.filter))};r._blocksInProgress.add(n),e.push(o);}return new Pg(e,(()=>{e.forEach((t=>r._blocksInProgress.delete(t.blockIndex)));}),((t,n)=>{if(e.forEach((t=>r._blocksInProgress.delete(t.blockIndex))),t)throw t;n.forEach((t=>{this.getLayer(t.layerName).processDecodedData(t);}));}))}}class zg{constructor({version:t,name:e,units:r,tileSize:n,pixelFormat:i,buffer:a,dataIndex:s},o){if(this.version=t,1!==this.version)throw new wg(`Cannot parse raster layer encoded with MRT version ${t}`);this.name=e,this.units=r,this.tileSize=n,this.buffer=a,this.pixelFormat=_g[i],this.dataIndex=s,this.bandShape=[n+2*a,n+2*a,Mg[this.pixelFormat]],this._decodedBlocks=new $y(o?o.cacheSize:5),this._blocksInProgress=new Set;}get dimension(){return Mg[this.pixelFormat]}get cacheSize(){return this._decodedBlocks.capacity}getBandList(){return this.dataIndex.map((({bands:t})=>t)).flat()}processDecodedData(t){const e=t.blockIndex.toString();this._decodedBlocks.get(e)||this._decodedBlocks.put(e,t.data);}getBlockForBand(t){let e=0;switch(typeof t){case"string":for(const[r,n]of this.dataIndex.entries()){for(const[i,a]of n.bands.entries())if(a===t)return {bandIndex:e+i,blockIndex:r,blockBandIndex:i};e+=n.bands.length;}break;case"number":for(const[r,n]of this.dataIndex.entries()){if(t>=e&&t<e+n.bands.length)return {bandIndex:t,blockIndex:r,blockBandIndex:t-e};e+=n.bands.length;}break;default:throw new wg(`Invalid band \`${JSON.stringify(t)}\`. Expected string or integer.`)}throw new wg(`Band not found: ${JSON.stringify(t)}`)}getDataRange(t){let e=1/0,r=-1/0;const n=[],i=new Set;for(const a of t){const{blockIndex:t}=this.getBlockForBand(a);if(t<0)throw new wg(`Invalid band: ${JSON.stringify(a)}`);const s=this.dataIndex[t];n.includes(t)||n.push(t),i.add(t),e=Math.min(e,s.firstByte),r=Math.max(r,s.lastByte);}if(i.size>this.cacheSize)throw new wg(`Number of blocks to decode (${i.size}) exceeds cache size (${this.cacheSize}).`);return {layerName:this.name,firstByte:e,lastByte:r,blockIndices:n}}hasBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0}hasDataForBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0&&!!this._decodedBlocks.get(e.toString())}getBandView(t){const{blockIndex:e,blockBandIndex:r}=this.getBlockForBand(t),n=this._decodedBlocks.get(e.toString());if(!n)throw new wg(`Data for band ${JSON.stringify(t)} of layer "${this.name}" not decoded.`);const i=this.dataIndex[e],a=this.bandShape.reduce(((t,e)=>t*e),1),s=r*a,o=n.subarray(s,s+a);return {data:o,bytes:new Uint8Array(o.buffer).subarray(o.byteOffset,o.byteOffset+o.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:i.offset,scale:i.scale}}}Ig.setPbf=function(t){Sg=t;};class Pg{constructor(t,e,r){this.tasks=t,this._onCancel=e,this._onComplete=r,this._finalized=!1;}cancel(){this._finalized||(this._onCancel(),this._finalized=!0);}complete(t,e){this._finalized||(this._onComplete(t,e),this._finalized=!0);}}Ig.performDecoding=function(t,e){const r=new Uint8Array(t);return Promise.all(e.tasks.map((t=>{const{layerName:e,firstByte:n,lastByte:i,pixelFormat:a,blockShape:s,blockIndex:o,filters:l,codec:u}=t,c=r.subarray(n,i+1),h=new Uint32Array(s[0]*s[1]*s[2]);let p;if("gzip_data"!==u)throw new wg(`Unhandled codec: ${u}`);return p=function(t,e){if(!globalThis.DecompressionStream&&"gzip_data"===e)return Promise.resolve(((a=function(t){31==t[0]&&139==t[1]&&8==t[2]||gg(6,"invalid gzip data");var e=t[3],r=10;4&e&&(r+=2+(t[10]|t[11]<<8));for(var n=(e>>3&1)+(e>>4&1);n>0;n-=!t[r++]);return r+(2&e)}(i=t))+8>i.length&&gg(6,"invalid gzip data"),function(t,e,r,n){var i=t.length;if(!i||e.f&&!e.l)return r||new Zy(0);var a=!r,s=a||2!=e.i,o=e.i;a&&(r=new Zy(3*i));var l,u,c=function(t){var e=r.length;if(t>e){var n=new Zy(Math.max(2*e,t));n.set(r),r=n;}},h=e.f||0,p=e.p||0,f=e.b||0,d=e.l,m=e.d,y=e.m,g=e.n,x=8*i;do{if(!d){h=dg(t,p,1);var v=dg(t,p+1,3);if(p+=3,!v){var b=t[(E=4+((p+7)/8|0))-4]|t[E-3]<<8,w=E+b;if(w>i){o&&gg(0);break}s&&c(f+b),r.set(t.subarray(E,w),f),e.b=f+=b,e.p=p=8*w,e.f=h;continue}if(1==v)d=hg,m=pg,y=9,g=5;else if(2==v){var _=dg(t,p,31)+257,M=dg(t,p+10,15)+4,A=_+dg(t,p+5,31)+1;p+=14;for(var S=new Zy(A),I=new Zy(19),z=0;z<M;++z)I[Qy[z]]=dg(t,p+3*z,7);p+=3*M;var P=fg(I),k=(1<<P)-1,T=lg(I,P);for(z=0;z<A;){var E,B=T[dg(t,p,k)];if(p+=15&B,(E=B>>4)<16)S[z++]=E;else {var V=0,C=0;for(16==E?(C=3+dg(t,p,3),p+=2,V=S[z-1]):17==E?(C=3+dg(t,p,7),p+=3):18==E&&(C=11+dg(t,p,127),p+=7);C--;)S[z++]=V;}}var R=S.subarray(0,_),D=S.subarray(_);y=fg(R),g=fg(D),d=lg(R,y),m=lg(D,g);}else gg(1);if(p>x){o&&gg(0);break}}s&&c(f+131072);for(var L=(1<<y)-1,F=(1<<g)-1,O=p;;O=p){var U=(V=d[mg(t,p)&L])>>4;if((p+=15&V)>x){o&&gg(0);break}if(V||gg(2),U<256)r[f++]=U;else {if(256==U){O=p,d=null;break}var j=U-254;U>264&&(j=dg(t,p,(1<<($=Ky[z=U-257]))-1)+rg[z],p+=$);var N=m[mg(t,p)&F],q=N>>4;if(N||gg(3),p+=15&N,D=ig[q],q>3){var $=Jy[q];D+=mg(t,p)&(1<<$)-1,p+=$;}if(p>x){o&&gg(0);break}s&&c(f+131072);var G=f+j;if(f<D){var X=0-D,Y=Math.min(D,G);for(X+f<0&&gg(3);f<Y;++f)r[f]=(void 0)[X+f];}for(;f<G;++f)r[f]=r[f-D];}}e.l=d,e.p=O,e.b=f,e.f=h,d&&(h=1,e.m=y,e.d=m,e.n=g);}while(!h);return f!=r.length&&a?(l=r,(null==(u=f)||u>l.length)&&(u=l.length),new Zy(l.subarray(0,u))):r.subarray(0,f)}(i.subarray(a,-8),{i:2},new Zy(((r=i)[(n=r.length)-4]|r[n-3]<<8|r[n-2]<<16|r[n-1]<<24)>>>0))));var r,n,i,a;const s=bg[e];if(!s)throw new Error(`Unhandled codec: ${e}`);const o=new globalThis.DecompressionStream(s);return new Response(new Blob([t]).stream().pipeThrough(o)).arrayBuffer().then((t=>new Uint8Array(t)))}(c,u).then((t=>(function(t,e){t.readFields(Ny,e);}(new Sg(t),h),new(0,Ag[a])(h.buffer)))),p.then((t=>{for(let e=l.length-1;e>=0;e--)switch(l[e]){case"delta_filter":Gy(t,s);break;case"zigzag_filter":Xy(t);break;case"bitshuffle_filter":Yy(t,a);break;default:throw new wg(`Unhandled filter "${l[e]}"`)}return {layerName:e,blockIndex:o,data:t}})).catch((t=>{throw t}))})))},sa(Pg,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]});var kg={workerUrl:"",workerClass:null,workerParams:void 0};const Tg="mapboxgl_preloaded_worker_pool";class Eg{constructor(){this.active={};}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length<Eg.workerCount;)this.workers.push(null!=kg.workerClass?new kg.workerClass:new self.Worker(kg.workerUrl,kg.workerParams));return this.active[t]=!0,this.workers.slice()}release(t){delete this.active[t],this.workers&&0===this.numActive()&&(this.workers.forEach((t=>{t.terminate();})),this.workers=null);}isPreloaded(){return !!this.active[Tg]}numActive(){return Object.keys(this.active).length}}let Bg;function Vg(){return Bg||(Bg=new Eg),Bg}Eg.workerCount=2;let Cg,Rg,Dg,Lg,Fg,Og=null;function Ug(){return gt()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:Rg||St.DRACO_URL}function jg(){if(gt()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(Lg)return Lg;const t=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]);if("object"!=typeof WebAssembly)throw new Error("WebAssembly not supported, cannot instantiate meshoptimizer");return Lg=WebAssembly.validate(t)?St.MESHOPT_SIMD_URL:St.MESHOPT_URL,Lg}const Ng={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},qg={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},$g={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function Gg(t,e,r){const n=r.json.bufferViews.length,i=r.buffers.length;e.bufferView=n,r.json.bufferViews[n]={buffer:i,byteLength:t.byteLength},r.buffers[i]=t;}const Xg="KHR_draco_mesh_compression";function Yg(t,e){const r=t.extensions&&t.extensions[Xg];if(!r)return;const n=new Dg.Decoder,i=tx(e,r.bufferView),a=new Dg.Mesh;if(!n.DecodeArrayToMesh(i,i.byteLength,a))throw new Error("Failed to decode Draco mesh");const s=e.json.accessors[t.indices],o=Ng[s.componentType],l=s.count*o.BYTES_PER_ELEMENT,u=Dg._malloc(l);o===Uint16Array?n.GetTrianglesUInt16Array(a,l,u):n.GetTrianglesUInt32Array(a,l,u),Gg(Dg.memory.buffer.slice(u,u+l),s,e),Dg._free(u);for(const i of Object.keys(r.attributes)){const s=n.GetAttributeByUniqueId(a,r.attributes[i]),o=e.json.accessors[t.attributes[i]],l=qg[o.componentType],u=o.count*$g[o.type]*Ng[o.componentType].BYTES_PER_ELEMENT,c=Dg._malloc(u);n.GetAttributeDataArrayForAllPoints(a,s,Dg[l],u,c),Gg(Dg.memory.buffer.slice(c,c+u),o,e),Dg._free(c);}n.destroy(),a.destroy(),delete t.extensions[Xg];}const Zg="EXT_meshopt_compression";function Wg(t,e){if(!t.extensions||!t.extensions[Zg])return;const r=t.extensions[Zg],n=new Uint8Array(e.buffers[r.buffer],r.byteOffset||0,r.byteLength||0),i=new Uint8Array(r.count*r.byteStride);Fg.decodeGltfBuffer(i,r.count,r.byteStride,n,r.mode,r.filter),t.buffer=e.buffers.length,t.byteOffset=0,e.buffers[t.buffer]=i.buffer,delete t.extensions[Zg];}const Hg=1179937895,Kg=new TextDecoder("utf8");function Jg(t,e){return new URL(t,e).href}function Qg(t,e,r,n){return fetch(Jg(t.uri,n)).then((t=>t.arrayBuffer())).then((t=>{e.buffers[r]=t;}))}function tx(t,e){const r=t.json.bufferViews[e];return new Uint8Array(t.buffers[r.buffer],r.byteOffset||0,r.byteLength)}function ex(t,e,r,n){if(t.uri){const i=Jg(t.uri,n);return fetch(i).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{e.images[r]=t;}))}if(void 0!==t.bufferView){const n=tx(e,t.bufferView),i=new Blob([n],{type:t.mimeType});return createImageBitmap(i).then((t=>{e.images[r]=t;}))}}function rx(t,e=0,r){const n={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===Hg){const r=new Uint32Array(t,e);let i=2;const a=(r[i++]>>2)-3,s=r[i++]>>2;if(i++,n.json=JSON.parse(Kg.decode(r.subarray(i,i+s))),i+=s,i<a){const a=r[i++];i++;const s=e+(i<<2);n.buffers[0]=t.slice(s,s+a);}}else n.json=JSON.parse(Kg.decode(new Uint8Array(t,e)));const{buffers:i,images:a,meshes:s,extensionsUsed:o,bufferViews:l}=n.json;let u=Promise.resolve();if(i){const t=[];for(let e=0;e<i.length;e++){const a=i[e];a.uri?t.push(Qg(a,n,e,r)):n.buffers[e]||(n.buffers[e]=null);}u=Promise.all(t);}return u.then((()=>{const t=[],e=o&&o.includes(Xg),i=o&&o.includes(Zg);if(e&&t.push(function(){if(!Dg)return null!=Cg?Cg:(Cg=function(t){let e,r=null;function n(){e=new Uint8Array(r.buffer);}function i(){throw new Error("Unexpected Draco error.")}const a={a:{a:i,d:function(t,r,n){return e.copyWithin(t,r,r+n)},c:function(t){const i=e.length,a=Math.max(t>>>0,Math.ceil(1.2*i)),s=Math.ceil((a-i)/65536);try{return r.grow(s),n(),!0}catch(t){return !1}},b:i}};return (WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,a):t.then((t=>t.arrayBuffer())).then((t=>WebAssembly.instantiate(t,a)))).then((t=>{const{Rb:i,Qb:a,P:s,T:o,X:l,Ja:u,La:c,Qa:h,Va:p,Wa:f,eb:d,jb:m,f:y,e:g,yb:x,zb:v,Ab:b,Bb:w,Db:_,Gb:M}=t.instance.exports;r=g;const A=(()=>{let t=0,r=0,n=0,s=0;return o=>{n&&(i(s),i(t),r+=n,n=t=0),t||(r+=128,t=a(r));const l=o.length+7&-8;let u=t;l>=r&&(n=l,u=s=a(l));for(let t=0;t<o.length;t++)e[u+t]=o[t];return u}})();return n(),y(),{memory:g,_free:i,_malloc:a,Mesh:class{constructor(){this.ptr=s();}destroy(){o(this.ptr);}},Decoder:class{constructor(){this.ptr=u();}destroy(){m(this.ptr);}DecodeArrayToMesh(t,e,r){const n=A(t),i=c(this.ptr,n,e,r.ptr);return !!l(i)}GetAttributeByUniqueId(t,e){return {ptr:h(this.ptr,t.ptr,e)}}GetTrianglesUInt16Array(t,e,r){p(this.ptr,t.ptr,e,r);}GetTrianglesUInt32Array(t,e,r){f(this.ptr,t.ptr,e,r);}GetAttributeDataArrayForAllPoints(t,e,r,n,i){d(this.ptr,t.ptr,e.ptr,r,n,i);}},DT_INT8:x(),DT_UINT8:v(),DT_INT16:b(),DT_UINT16:w(),DT_UINT32:_(),DT_FLOAT32:M()}}))}(fetch(Ug())),Cg.then((t=>{Dg=t,Cg=void 0;})))}()),i&&t.push(function(){if(Fg)return;const t=function(t){let e;const r=WebAssembly.instantiateStreaming(t,{}).then((t=>{e=t.instance,e.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(t,r,a,s,o,l){!function(t,e,r,n,i,a,s){const o=t.exports.sbrk,l=n+3&-4,u=o(l*i),c=o(a.length),h=new Uint8Array(t.exports.memory.buffer);h.set(a,c);const p=e(u,n,i,c,a.length);if(0===p&&s&&s(u,l,i),r.set(h.subarray(u,u+n*i)),o(u-o(0)),0!==p)throw new Error(`Malformed buffer data: ${p}`)}(e,e.exports[i[o]],t,r,a,s,e.exports[n[l]]);}}}(fetch(jg()));return t.ready.then((()=>{Fg=t;}))}()),a)for(let e=0;e<a.length;e++)t.push(ex(a[e],n,e,r));return (t.length?Promise.all(t):Promise.resolve()).then((()=>{if(e&&s)for(const{primitives:t}of s)for(const e of t)Yg(e,n);if(i&&s&&l)for(const t of l)Wg(t,n);return n}))}))}function nx(t,e){const r=t.json.bufferViews[e.bufferView],n=Ng[e.componentType];return new n(t.buffers[r.buffer],(e.byteOffset||0)+(r.byteOffset||0),e.count*(r.byteStride&&r.byteStride!==$g[e.type]*n.BYTES_PER_ELEMENT?r.byteStride/n.BYTES_PER_ELEMENT:$g[e.type]))}function ix(t,e,r,n){const i=Ng[e.componentType],a=function(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(i),s=t.json.bufferViews[e.bufferView],o=s.byteStride?s.byteStride/i.BYTES_PER_ELEMENT:$g[e.type],l=r.float32,u=l.length/r.capacity;for(let t=0,r=0;t<e.count*o;t+=o,r+=u)for(let e=0;e<u;e++)l[r+e]=n[t+e]*a;r._trim();}function ax(t,e,r){const n=t.indices,i=t.attributes,a={};a.indexArray=new Rs;const s=e.json.accessors[n],o=s.count/3;a.indexArray.reserve(o);const l=nx(e,s);for(let t=0;t<o;t++)a.indexArray.emplaceBack(l[3*t],l[3*t+1],l[3*t+2]);a.indexArray._trim(),a.vertexArray=new Ms;const u=e.json.accessors[i.POSITION];a.vertexArray.reserve(u.count);const c=nx(e,u);for(let t=0;t<u.count;t++)a.vertexArray.emplaceBack(c[3*t],c[3*t+1],c[3*t+2]);if(a.vertexArray._trim(),a.aabb=new gu(u.min,u.max),a.centroid=function(t,e){const r=[0,0,0],n=t.length;if(n>0){for(let i=0;i<n;i++){const n=3*t[i];r[0]+=e[n],r[1]+=e[n+1],r[2]+=e[n+2];}r[0]/=n,r[1]/=n,r[2]/=n;}return r}(l,c),void 0!==i.COLOR_0){const t=e.json.accessors[i.COLOR_0],r=$g[t.type],n=nx(e,t);a.colorArray=3===r?new Ms:new _s,a.colorArray.resize(t.count),ix(e,t,a.colorArray,n);}if(void 0!==i.NORMAL){a.normalArray=new Ms;const t=e.json.accessors[i.NORMAL];a.normalArray.resize(t.count);const r=nx(e,t);ix(e,t,a.normalArray,r);}if(void 0!==i.TEXCOORD_0&&r.length>0){a.texcoordArray=new Gs;const t=e.json.accessors[i.TEXCOORD_0];a.texcoordArray.resize(t.count);const r=nx(e,t);ix(e,t,a.texcoordArray,r);}if(void 0!==i._FEATURE_ID_RGBA4444){const t=e.json.accessors[i._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes("EXT_meshopt_compression")&&(a.featureData=nx(e,t));}void 0!==i._FEATURE_RGBA4444&&(a.featureData=new Uint32Array(nx(e,e.json.accessors[i._FEATURE_RGBA4444]).buffer));const h=t.material;return a.material=function(t,e){const{emissiveFactor:r=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:i=.5,normalTexture:a,occlusionTexture:s,emissiveTexture:o,doubleSided:l}=t,{baseColorFactor:u=[1,1,1,1],metallicFactor:c=1,roughnessFactor:h=1,baseColorTexture:p,metallicRoughnessTexture:f}=t.pbrMetallicRoughness||{},d=s?e[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&d){const t=s.extensions.KHR_texture_transform;d.offsetScale=[t.offset[0],t.offset[1],t.scale[0],t.scale[1]];}return {pbrMetallicRoughness:{baseColorFactor:new Ie(...u),metallicFactor:c,roughnessFactor:h,baseColorTexture:p?e[p.index]:void 0,metallicRoughnessTexture:f?e[f.index]:void 0},doubleSided:l,emissiveFactor:r,alphaMode:n,alphaCutoff:i,normalTexture:a?e[a.index]:void 0,occlusionTexture:d,emissionTexture:o?e[o.index]:void 0,defined:void 0===t.defined}}(void 0!==h?e.json.materials[h]:{defined:!1},r),a}function sx(t,e,r){const{matrix:n,rotation:i,translation:a,scale:s,mesh:o,extras:l,children:u}=t,c={};if(c.matrix=n||O.mat4.fromRotationTranslationScale([],i||[0,0,0,1],a||[0,0,0],s||[1,1,1]),void 0!==o){c.meshes=r[o];const t=c.anchor=[0,0];for(const e of c.meshes){const{min:r,max:n}=e.aabb;t[0]+=r[0]+n[0],t[1]+=r[1]+n[1];}t[0]=Math.floor(t[0]/c.meshes.length/2),t[1]=Math.floor(t[1]/c.meshes.length/2);}if(l&&(l.id&&(c.id=l.id),l.lights&&(c.lights=function(t){if(!t.length)return [];const e=function(t){const e=atob(t),r=new Uint8Array(e.length);for(let t=0;t<e.length;t++)r[t]=e.codePointAt(t);return r}(t),r=[],n=e.length/24,i=new Uint16Array(e.buffer),a=new Float32Array(e.buffer);for(let t=0;t<n;t++){const e=i[2*t*6]/30,n=i[2*t*6+1]/30,s=i[2*t*6+10]/100,o=a[6*t+1],l=a[6*t+2],u=a[6*t+3],c=a[6*t+4],h=u-o,p=c-l,f=Math.hypot(h,p);r.push({pos:[o+.5*h,l+.5*p,n],normal:[p/f,-h/f,0],width:f,height:e,depth:s,points:[o,l,u,c]});}return r}(l.lights))),u){const t=[];for(const n of u)t.push(sx(e.json.nodes[n],e,r));c.children=t;}return c}function ox(t){if(0===t.vertices.length||0===t.indices.length)return null;const e=new $c(t.vertices,t.indices,8,256),[r,n]=[e.min.clone(),e.max.clone()];return {vertices:t.vertices,indices:t.indices,grid:e,min:r,max:n}}function lx(t){if(!t.extras||!t.extras.ground)return null;const e=t.extras.ground;if(!e||!Array.isArray(e)||0===e.length)return null;const r=e[0];if(!r||!Array.isArray(r)||0===r.length)return null;const n=[];for(const t of r){if(!Array.isArray(t)||2!==t.length)continue;const e=t[0],r=t[1];"number"==typeof e&&"number"==typeof r&&n.push(new q(e,r));}if(n.length<3)return null;n.length>1&&n[n.length-1].equals(n[0])&&n.pop();let i=0;for(let t=0;t<n.length;t++){const e=n[t],r=n[(t+1)%n.length],a=n[(t+2)%n.length];i+=(e.x-r.x)*(a.y-r.y)-(a.x-r.x)*(e.y-r.y);}i>0&&n.reverse();const a=cc(n.flatMap((t=>[t.x,t.y])),[]);return 0===a.length?null:{vertices:n,indices:a}}function ux(t,e){const r=[],n=[];let i=0;const a=[];for(const s of t){i=r.length;const t=s.vertexArray.float32,o=s.indexArray.uint16;for(let n=0;n<s.vertexArray.length;n++)a[0]=t[3*n+0],a[1]=t[3*n+1],a[2]=t[3*n+2],O.vec3.transformMat4(a,a,e),r.push(new q(a[0],a[1]));for(let t=0;t<3*s.indexArray.length;t++)n.push(o[t]+i);}if(n.length%3!=0)return null;for(let t=0;t<n.length;t+=3){const e=r[n[t+0]],i=r[n[t+1]],a=r[n[t+2]];(e.x-i.x)*(a.y-i.y)-(a.x-i.x)*(e.y-i.y)>0&&([n[t+1],n[t+2]]=[n[t+2],n[t+1]]);}return {vertices:r,indices:n}}function cx(t){const e=function(t,e){const r=[],n=WebGL2RenderingContext;if(t.json.textures)for(const i of t.json.textures){const a={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==i.sampler&&Object.assign(a,t.json.samplers[i.sampler]),r.push({image:e[i.source],sampler:a,uploaded:!1});}return r}(t,t.images),r=function(t,e){const r=[];for(const n of t.json.meshes){const i=[];for(const r of n.primitives)i.push(ax(r,t,e));r.push(i);}return r}(t,e),{scenes:n,scene:i,nodes:a}=t.json,s=n?n[i||0].nodes:a,o=[];for(const e of s)o.push(sx(a[e],t,r));return function(t,e,r){const n={},i=new Set;for(let a=0;a<t.length;a++){const t=r[e[a]];if(!t.extras)continue;const s=t.extras["mapbox:footprint:version"],o=t.extras["mapbox:footprint:id"];(s||o)&&i.add(a),"1.0.0"===s&&o&&(n[o]=a);}for(let a=0;a<t.length;a++){if(i.has(a))continue;const s=t[a],o=r[e[a]];if(!o.extras)continue;let l=null;s.id in n&&(l=ux(t[n[s.id]].meshes,s.matrix)),l||(l=lx(o)),l&&(s.footprint=ox(l));}if(i.size>0){const e=Array.from(i.values()).sort(((t,e)=>t-e));for(let r=e.length-1;r>=0;r--)t.splice(e[r],1);}}(o,s,t.json.nodes),o}function hx(t){t.heightmap=new Float32Array(4096),t.heightmap.fill(-1);const e=t.vertexArray.float32,r=t.aabb.min[0]-1,n=t.aabb.min[1]-1,i=Km/(t.aabb.max[0]-r+2),a=Km/(t.aabb.max[1]-n+2);for(let s=0;s<e.length;s+=3){const o=e[s+2],l=(e[s+0]-r)*i|0,u=(e[s+1]-n)*a|0;o>t.heightmap[u*Km+l]&&(t.heightmap[u*Km+l]=o);}}function px(t,e){const r={};r.indexArray=new Rs,r.indexArray.reserve(4*t.length),r.vertexArray=new Ms,r.vertexArray.reserve(10*t.length),r.colorArray=new _s,r.vertexArray.reserve(10*t.length);let n=0;for(const i of t){const t=Math.min(10,Math.max(4,1.3*i.height))*e,a=[-i.normal[1],i.normal[0],0],s=Math.min(.29,.1*i.width/i.depth),o=i.width-2*i.depth*e*(s+.01),l=O.vec3.scaleAndAdd([],i.pos,a,o/2),u=O.vec3.scaleAndAdd([],i.pos,a,-o/2),c=[l[0],l[1],l[2]+i.height],h=[u[0],u[1],u[2]+i.height],p=O.vec3.scaleAndAdd([],i.normal,a,s);O.vec3.scale(p,p,t);const f=O.vec3.scaleAndAdd([],i.normal,a,-s);O.vec3.scale(f,f,t),O.vec3.add(p,l,p),O.vec3.add(f,u,f),l[2]+=.1,u[2]+=.1,r.vertexArray.emplaceBack(p[0],p[1],p[2]),r.vertexArray.emplaceBack(f[0],f[1],f[2]),r.vertexArray.emplaceBack(l[0],l[1],l[2]),r.vertexArray.emplaceBack(u[0],u[1],u[2]),r.vertexArray.emplaceBack(c[0],c[1],c[2]),r.vertexArray.emplaceBack(h[0],h[1],h[2]),r.vertexArray.emplaceBack(l[0],l[1],l[2]),r.vertexArray.emplaceBack(u[0],u[1],u[2]),r.vertexArray.emplaceBack(p[0],p[1],p[2]),r.vertexArray.emplaceBack(f[0],f[1],f[2]);const d=o/t/2;r.colorArray.emplaceBack(-d-s,-1,d,.8),r.colorArray.emplaceBack(d+s,-1,d,.8),r.colorArray.emplaceBack(-d,0,d,1.3),r.colorArray.emplaceBack(d,0,d,1.3),r.colorArray.emplaceBack(d+s,-.8,d,.7),r.colorArray.emplaceBack(d+s,-.8,d,.7),r.colorArray.emplaceBack(0,0,d,1.3),r.colorArray.emplaceBack(0,0,d,1.3),r.colorArray.emplaceBack(d+s,-1.2,d,.8),r.colorArray.emplaceBack(d+s,-1.2,d,.8),r.indexArray.emplaceBack(6+n,4+n,8+n),r.indexArray.emplaceBack(7+n,9+n,5+n),r.indexArray.emplaceBack(0+n,1+n,2+n),r.indexArray.emplaceBack(1+n,3+n,2+n),n+=10;}const i={defined:!0,emissiveFactor:[0,0,0]},a={};return a.baseColorFactor=Ie.white,i.pbrMetallicRoughness=a,r.material=i,r.aabb=new gu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),r}class fx{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e<t.length;e++){const r=t[e];this._stringToNumber[r]=e,this._numberToString[e]=r;}}encode(t){return this._stringToNumber[t]}decode(t){return this._numberToString[t]}}class dx{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new ia(Wr,16,0),this.featureIndexArray=new ao,this.promoteId=e,this.is3DTile=!1,this.serializedLayersCache=new Map;}insert(t,e,r,n,i,a=0,s=0){const o=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(r,n,i,a);const l=this.grid;for(let t=0;t<e.length;t++){const r=e[t],n=[1/0,1/0,-1/0,-1/0];for(let t=0;t<r.length;t++){const e=r[t];n[0]=Math.min(n[0],e.x),n[1]=Math.min(n[1],e.y),n[2]=Math.max(n[2],e.x),n[3]=Math.max(n[3],e.y);}0!==s&&(n[0]-=s,n[1]-=s,n[2]+=s,n[3]+=s),n[0]<Wr&&n[1]<Wr&&n[2]>=0&&n[3]>=0&&l.insert(o,n[0],n[1],n[2],n[3]);}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new hh.VectorTile(new uf(this.rawTileData)).layers,this.sourceLayerCoder=new fx(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const t in this.vtLayers)this.vtFeatures[t]=[];}return this.vtLayers}query(t,e,r){this.loadVTLayers(),this.serializedLayersCache.clear();const n=Wa(t.filter),i=t.tileResult,a=t.transform,s=i.bufferedTilespaceBounds,o=this.grid.query(s.min.x,s.min.y,s.max.x,s.max.y,((t,e,r,n)=>Nl(i.bufferedTilespaceGeometry,t,e,r,n)));o.sort(yx);let l=null;a.elevation&&o.length>0&&(l=ay.create(a.elevation,this.tileID));const u={};let c;for(let s=0;s<o.length;s++){const h=o[s];if(h===c)continue;c=h;const p=this.featureIndexArray.get(h);let f=null;if(this.is3DTile){const t=this.bucketLayerIDs[0][0],r=e[t];if("model"!==r.type)continue;const{queryFeature:s,intersectionZ:o}=r.queryIntersectsMatchingFeature(i,p.featureIndex,n,a);s&&this.appendToResult(u,t,p.featureIndex,s,o);}else this.loadMatchingFeature(u,p,n,t.layers,t.availableImages,e,r,((e,r,n,a=0)=>(f||(f=zl(e,this.tileID.canonical,t.tileTransform)),r.queryIntersectsFeature(i,e,n,f,this.z,t.transform,t.pixelPosMatrix,l,a))));}return u}loadMatchingFeature(t,e,r,n,i,a,s,o){const{featureIndex:l,bucketIndex:u,sourceLayerIndex:c,layoutVertexArrayOffset:h}=e,p=this.bucketLayerIDs[u];if(n.length&&!function(t,e){for(let r=0;r<t.length;r++)if(e.indexOf(t[r])>=0)return !0;return !1}(n,p))return;const f=this.sourceLayerCoder.decode(c),d=this.vtLayers[f].feature(l);if(r.needGeometry){const t=Pl(d,!0);if(!r.filter(new Ba(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!r.filter(new Ba(this.tileID.overscaledZ),d))return;const m=this.getId(d,f);for(let e=0;e<p.length;e++){const r=p[e];if(n.length&&n.indexOf(r)<0)continue;const u=a[r];if(!u)continue;let c={};void 0!==m&&s&&(c=s.getState(u.sourceLayer||"_geojsonTileLayer",m));const f=!o||o(d,u,c,h);if(!f)continue;const y=new gy(d,this.z,this.x,this.y,m);let g=this.serializedLayersCache.get(r);g||(g=u.serialize(),g.id=r,this.serializedLayersCache.set(r,g)),y.layer=nt({},g),y.tile=this.tileID.canonical,y.layer.paint=mx(g.paint,u.paint,d,c,i),y.layer.layout=mx(g.layout,u.layout,d,c,i),this.appendToResult(t,r,l,y,f);}}appendToResult(t,e,r,n,i){let a=t[e];void 0===a&&(a=t[e]=[]),a.push({featureIndex:r,feature:n,intersectionZ:i});}lookupSymbolFeatures(t,e,r,n,i,a,s){const o={};this.loadVTLayers();const l=Wa(n);for(const n of t)this.loadMatchingFeature(o,{bucketIndex:e,sourceLayerIndex:r,featureIndex:n,layoutVertexArrayOffset:0},l,i,a,s);return o}loadFeature(t){const{featureIndex:e,sourceLayerIndex:r}=t;this.loadVTLayers();const n=this.sourceLayerCoder.decode(r),i=this.vtFeatures[n];if(i[e])return i[e];const a=this.vtLayers[n].feature(e);return i[e]=a,a}hasLayer(t){for(const e of this.bucketLayerIDs)for(const r of e)if(t===r)return !0;return !1}getId(t,e){let r=t.id;if(this.promoteId){const n="string"==typeof this.promoteId?this.promoteId:this.promoteId[e];null!=n&&(r=t.properties[n]),"boolean"==typeof r&&(r=Number(r));}return r}}function mx(t,e,r,n,i){return ut(t,((t,a)=>{const s=e instanceof Ua?e.get(a):null;return s&&s.evaluate?s.evaluate(r,n,i):s}))}function yx(t,e){return e-t}sa(dx,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const gx=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class xx{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[e,r]=new Uint8Array(t,0,2);if(219!==e)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=gx[15&r];if(!i)throw new Error("Unrecognized array type.");const[a]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new xx(s,a,i,t)}constructor(t,e=64,r=Float64Array,n){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+e,2),65535),this.ArrayType=r,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const i=gx.indexOf(this.ArrayType),a=2*t*this.ArrayType.BYTES_PER_ELEMENT,s=t*this.IndexArrayType.BYTES_PER_ELEMENT,o=(8-s%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,t),this.coords=new this.ArrayType(this.data,8+s+o,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+a+s+o),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+s+o,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+i]),new Uint16Array(this.data,2,1)[0]=e,new Uint32Array(this.data,4,1)[0]=t);}add(t,e){const r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=t,this.coords[this._pos++]=e,r}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return vx(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,r,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:i,coords:a,nodeSize:s}=this,o=[0,i.length-1,0],l=[];for(;o.length;){const u=o.pop()||0,c=o.pop()||0,h=o.pop()||0;if(c-h<=s){for(let s=h;s<=c;s++){const o=a[2*s],u=a[2*s+1];o>=t&&o<=r&&u>=e&&u<=n&&l.push(i[s]);}continue}const p=h+c>>1,f=a[2*p],d=a[2*p+1];f>=t&&f<=r&&d>=e&&d<=n&&l.push(i[p]),(0===u?t<=f:e<=d)&&(o.push(h),o.push(p-1),o.push(1-u)),(0===u?r>=f:n>=d)&&(o.push(p+1),o.push(c),o.push(1-u));}return l}within(t,e,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:i,nodeSize:a}=this,s=[0,n.length-1,0],o=[],l=r*r;for(;s.length;){const u=s.pop()||0,c=s.pop()||0,h=s.pop()||0;if(c-h<=a){for(let r=h;r<=c;r++)Mx(i[2*r],i[2*r+1],t,e)<=l&&o.push(n[r]);continue}const p=h+c>>1,f=i[2*p],d=i[2*p+1];Mx(f,d,t,e)<=l&&o.push(n[p]),(0===u?t-r<=f:e-r<=d)&&(s.push(h),s.push(p-1),s.push(1-u)),(0===u?t+r>=f:e+r>=d)&&(s.push(p+1),s.push(c),s.push(1-u));}return o}}function vx(t,e,r,n,i,a){if(i-n<=r)return;const s=n+i>>1;bx(t,e,s,n,i,a),vx(t,e,r,n,s-1,1-a),vx(t,e,r,s+1,i,1-a);}function bx(t,e,r,n,i,a){for(;i>n;){if(i-n>600){const s=i-n+1,o=r-n+1,l=Math.log(s),u=.5*Math.exp(2*l/3),c=.5*Math.sqrt(l*u*(s-u)/s)*(o-s/2<0?-1:1);bx(t,e,r,Math.max(n,Math.floor(r-o*u/s+c)),Math.min(i,Math.floor(r+(s-o)*u/s+c)),a);}const s=e[2*r+a];let o=n,l=i;for(wx(t,e,n,r),e[2*i+a]>s&&wx(t,e,n,i);o<l;){for(wx(t,e,o,l),o++,l--;e[2*o+a]<s;)o++;for(;e[2*l+a]>s;)l--;}e[2*n+a]===s?wx(t,e,n,l):(l++,wx(t,e,l,i)),l<=r&&(n=l+1),r<=l&&(i=l-1);}}function wx(t,e,r,n){_x(t,r,n),_x(e,2*r,2*n),_x(e,2*r+1,2*n+1);}function _x(t,e,r){const n=t[e];t[e]=t[r],t[r]=n;}function Mx(t,e,r,n){const i=t-r,a=e-n;return i*i+a*a}t.$=Ra,t.A=class extends $m{},t.B=cr,t.C=Ee,t.D=Xa,t.E=_e,t.F=Fi,t.G=Ri,t.H=Li,t.I=jf,t.J=Zi,t.K=Ya,t.L=Ji,t.M=Wi,t.N=En,t.O=Vn,t.P=q,t.Q=Tn,t.R=te,t.S=mr,t.T=cm,t.U=Se,t.V=$m,t.W=Za,t.X=Oi,t.Y=Di,t.Z=function(t){const e=t.value;let r=[];if(!e)return r;const n=cr(e);return "string"!==n?(r=r.concat([new $m(t.key,e,`string expected, "${n}" found`)]),r):(Gm(e,!0)||(r=r.concat([new $m(t.key,e,`invalid url "${e}"`)])),r)},t._=Ga,t.a=function(t){return St.API_CDN_URL_REGEX.test(t)},t.a$=gs,t.a0=$a,t.a1=ja,t.a2=class{constructor(t){this.specification=t;}possiblyEvaluate(t,e){return yt(t.expression.evaluate(e))}interpolate(t,e,r){return {x:Pe(t.x,e.x,r),y:Pe(t.y,e.y,r),z:Pe(t.z,e.z,r),azimuthal:Pe(t.azimuthal,e.azimuthal,r),polar:Pe(t.polar,e.polar,r)}}},t.a3=Ba,t.a4=Ki,t.a5=vl,t.a6=O,t.a7=tt,t.a8=Ua,t.a9=Lu,t.aA=nu,t.aB=gm,t.aC=Mm,t.aD=mm,t.aE=function(t,e){const r=document.createElement("video");r.muted=!0,r.onloadstart=function(){e(null,r);};for(let e=0;e<t.length;e++){const n=document.createElement("source");ae(t[e])||(r.crossOrigin="Anonymous"),n.src=t[e],r.appendChild(n);}return {cancel:()=>{}}},t.aF=hm,t.aG=function(t){return fetch(t).then((t=>t.arrayBuffer())).then((e=>rx(e,0,t)))},t.aH=cx,t.aI=class{constructor(t,e,r,n){this.id=t,this.position=null!=e?new nl(e[0],e[1]):new nl(0,0),this.orientation=null!=r?r:[0,0,0],this.nodes=n,this.uploaded=!1,this.aabb=new gu([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[];}_applyTransformations(t,e){if(O.mat4.multiply(t.matrix,e,t.matrix),t.meshes)for(const e of t.meshes){const r=gu.applyTransformFast(e.aabb,t.matrix);this.aabb.encapsulate(r);}if(t.children)for(const e of t.children)this._applyTransformations(e,t.matrix);}computeBoundsAndApplyParent(){const t=O.mat4.identity([]);for(const e of this.nodes)this._applyTransformations(e,t);}computeModelMatrix(t,e,r,n,i,a,s=!1){Qm(this.matrix,this,t.transform,this.position,e,r,n,i,a,s);}upload(t){if(!this.uploaded){for(const e of this.nodes)ry(e,t);for(const t of this.nodes)ny(t);this.uploaded=!0;}}destroy(){for(const t of this.nodes)iy(t);}},t.aJ=ot,t.aK=function(t){return t.indexOf(os)>=0},t.aL=xd,t.aM=hl,t.aN=pl,t.aO=vs,t.aP=Rs,t.aQ=at,t.aR=Ks,t.aS=Hd,t.aT=function(){Ea.isLoading()||Ea.isLoaded()||"deferred"!==ka()||Ta();},t.aU=Wa,t.aV=Pl,t.aW=gy,t.aX=xt,t.aY=_p,t.aZ=Oc,t.a_=zl,t.aa=Pe,t.ab=Wr,t.ac=ke,t.ad=class{constructor(t){this.specification=t;}possiblyEvaluate(t,e){return function([t,e]){const r=yt([1,t,e]);return {x:r.x,y:r.y,z:r.z}}(t.expression.evaluate(e))}interpolate(t,e,r){return {x:Pe(t.x,e.x,r),y:Pe(t.y,e.y,r),z:Pe(t.z,e.z,r)}}},t.ae=function(t,e,r=0,n=!0){const i=new q(r,r),a=t.sub(i),s=e.add(i),o=[a,new q(s.x,a.y),s,new q(a.x,s.y)];return n&&o.push(a.clone()),o},t.af=function(t,e){const r=[];for(let n=0;n<t.length;n++){const i=et(n-1,-1,t.length-1),a=et(n+1,-1,t.length-1),s=t[n],o=t[a],l=t[i].sub(s).unit(),u=o.sub(s).unit(),c=u.angleWithSep(l.x,l.y),h=l.add(u).unit().mult(-1*e/Math.sin(c/2));r.push(s.add(h));}return r},t.ag=vd,t.ah=Nl,t.ai=function(t,e,r=0){return O.vec3.fromValues(((e.x-r)*t.scale-t.x)*Wr,(e.y*t.scale-t.y)*Wr,fl(e.z,e.y))},t.aj=cu,t.ak=Ip,t.al=function(t){let e=1/0,r=1/0,n=-1/0,i=-1/0;for(const a of t)e=Math.min(e,a.x),r=Math.min(r,a.y),n=Math.max(n,a.x),i=Math.max(i,a.y);return {min:new q(e,r),max:new q(n,i)}},t.am=ll,t.an=jl,t.ao=wl,t.ap=Q,t.aq=Go,t.ar=function(t,e){const r={};for(let n=0;n<e.length;n++){const i=e[n];i in t&&(r[i]=t[i]);}return r},t.as=il,t.at=ul,t.au=class{constructor(t){this.entries={},this.scheduler=t;}request(t,e,r,n){const i=this.entries[t]=this.entries[t]||{callbacks:[]};if(i.result){const[t,r]=i.result;return this.scheduler?this.scheduler.add((()=>{n(t,r);}),e):n(t,r),()=>{}}return i.callbacks.push(n),i.cancel||(i.cancel=r(((r,n)=>{i.result=[r,n];for(const t of i.callbacks)this.scheduler?this.scheduler.add((()=>{t(r,n);}),e):t(r,n);setTimeout((()=>delete this.entries[t]),3e3);}))),()=>{i.result||(i.callbacks=i.callbacks.filter((t=>t!==n)),i.callbacks.length||(i.cancel(),delete this.entries[t]));}}},t.av=ls,t.aw=function(t,e,r){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const n=ie(t.request,((t,n,i,a)=>{t?e(t):n&&e(null,{vectorTile:r?void 0:new hh.VectorTile(new uf(n)),rawData:n,cacheControl:i,expires:a});}));return ()=>{n.cancel(),e();}}),e)},t.ax=function(t){Xt++,Xt>Ut&&(t.getActor().send("enforceCacheSizeLimit",Ot),Xt=0);},t.ay=Ct,t.az=function(t){return t<=1?1:Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},t.b=function(t){return St.API_FONTS_REGEX.test(t)},t.b$=hu,t.b0=$s,t.b1=uu,t.b2=ho,t.b3=cc,t.b4=om,t.b5=function(t,e){const r=Lu(e.zoom);if(0===r)return Mu(t);const n=zu(t),i=Pu(n),a=ll(n.getWest())*e.worldSize,s=ll(n.getEast())*e.worldSize,o=ul(n.getNorth())*e.worldSize,l=ul(n.getSouth())*e.worldSize,u=[a,o,0],c=[s,o,0],h=[a,l,0],p=[s,l,0],f=O.mat4.invert([],e.globeMatrix);return O.vec3.transformMat4(u,u,f),O.vec3.transformMat4(c,c,f),O.vec3.transformMat4(h,h,f),O.vec3.transformMat4(p,p,f),i[0]=Au(i[0],h,r),i[1]=Au(i[1],p,r),i[2]=Au(i[2],c,r),i[3]=Au(i[3],u,r),gu.fromPoints(i)},t.b6=Bu,t.b7=ku,t.b8=Au,t.b9=xs,t.bA=Ie,t.bB=et,t.bC=Y,t.bD=bt,t.bE=cl,t.bF=function(t,e,r){t[4*e+0]=r[0],t[4*e+1]=r[1],t[4*e+2]=r[2],t[4*e+3]=r[3];},t.bG=Po,t.bH=Mo,t.bI=Ao,t.bJ=_o,t.bK=wo,t.bL=nl,t.bM=Ud,t.bN=ru,t.bO=yu,t.bP=zm,t.bQ=eu,t.bR=Iu,t.bS=function(t,e,r,n,i,a,s,o,l){if("globe"===l.name)return Iu(t,e,new eu(r,n,i),!1);const u=xd({z:r,x:n,y:i},l);return new gu([(a+u.x/u.scale)*e,e*(u.y/u.scale),s],[(a+u.x2/u.scale)*e,e*(u.y2/u.scale),o])},t.bT=function(t,e,r){let n=0;for(let r=0;r<2;++r){const i=0;t[r]>i&&(n+=(t[r]-i)*(t[r]-i)),e[r]<i&&(n+=(i-e[r])*(i-e[r]));}return n},t.bU=dl,t.bV=Yo,t.bW=function(t){const e=O.mat4.identity(new Float64Array(16));O.mat4.multiply(e,t.pixelMatrix,t.globeMatrix);const r=[0,Ko,0],n=[0,Jo,0];return O.vec3.transformMat4(r,r,e),O.vec3.transformMat4(n,n,e),[r[0]>0&&r[0]<=t.width&&r[1]>0&&r[1]<=t.height&&!Ou(t,new nl(t.center.lat,90)),n[0]>0&&n[0]<=t.width&&n[1]>0&&n[1]<=t.height&&!Ou(t,new nl(t.center.lat,-90))]},t.bX=function(t,e){const{scale:r}=t.tileTransform,n=r*Wr/(t.tileSize*Math.pow(2,e.zoom-t.tileID.overscaledZ+t.tileID.canonical.z));return O.mat2.scale(new Float32Array(4),e.inverseAdjustmentMatrix,[n,n])},t.bY=Pm,t.bZ=Im,t.b_=function(t){const e=Im(t,!0);return O.mat2.invert([],[e[0],e[1],e[4],e[5]])},t.ba=lu,t.bb=Ig,t.bc=uf,t.bd=ie,t.be=function(t){const e=[];for(const r in t)e.push(t[r]);return e},t.bf=function(t,e){const r=[];for(const n in t)n in e||r.push(n);return r},t.bg=rt,t.bh=["type","source","source-layer","minzoom","maxzoom","filter","layout"],t.bi=$,t.bj=function(t,e){const{x:r,y:n}=t.point,i=Du(r,n,t.worldSize/t._pixelsPerMercatorPixel,0,0);return O.mat4.multiply(i,i,Vu(Mu(e)))},t.bk=Hp,t.bl=mf,t.bm=Wp,t.bn=function(t,e,r,n,i){const a=5*e+2;t.float32[a+0]=r,t.float32[a+1]=n,t.float32[a+2]=i;},t.bo=Xd,t.bp=Ff,t.bq=Bl,t.br=Xp,t.bs=xh,t.bt=qm,t.bu=zh,t.bv=Ph,t.bw=ld,t.bx=od,t.by=If,t.bz=xx,t.c=zt,t.c$=au,t.c0=function(t){const{x:e,y:r}=t.point,{lng:n,lat:i}=t._center;return Du(e,r,t.worldSize,n,i)},t.c1=Z,t.c2=iu,t.c3=Xo,t.c4=function(t){const e=Math.round((t+45+360)%360/90)%4;return W[e]},t.c5=45,t.c6=ol,t.c7=So,t.c8=function(t,e,r){const n=Math.sqrt(t*t+e*e+r*r),i=n>0?Math.acos(r/n)*X:0;let a=0!==t||0!==e?Math.atan2(-e,-t)*X+90:0;return a<0&&(a+=360),[n,a,i]},t.c9=xl,t.cA=function(t){const e=dl-5;t=Q(t,-e,e)/e*90;const r=Math.pow(Math.abs(Math.sin(Y(t))),3);return Math.round(r*(Ho.length-1))},t.cB=function(t,e,r,n){const i=e.getNorth(),a=e.getSouth(),s=e.getWest(),o=e.getEast(),l=1<<t.z,u=o-s,c=i-a,h=u/Wo,p=-c/Ho[r],f=[0,h,0,p,0,0,i,s,0];if(t.z>0){const t=180/n;O.mat3.multiply(f,f,[t/u+1,0,0,0,t/c+1,0,-.5*t/h,.5*t/p,1]);}return f[2]=l,f[5]=t.x,f[8]=t.y,f},t.cC=Mu,t.cD=function(t,e,r){const n=O.mat4.identity(new Float64Array(16)),i=(e/(1<<t)-.5)*Math.PI*2;return O.mat4.rotateY(n,r.globeMatrix,i),Float32Array.from(n)},t.cE=class{isDataAvailableAtPoint(t){const e=this._source();if(this.isUsingMockSource()||!e||t.y<0||t.y>1)return !1;const r=e.getSource().maxzoom,n=1<<r,i=Math.floor(t.x),a=Math.floor((t.x-i)*n),s=Math.floor(t.y*n),o=this.findDEMTileFor(new nu(r,i,r,a,s));return !(!o||!o.dem)}getAtPointOrZero(t,e=0){return this.getAtPoint(t,e)||0}getAtPoint(t,e,r=!0){if(this.isUsingMockSource())return null;null==e&&(e=null);const n=this._source();if(!n)return e;if(t.y<0||t.y>1)return e;const i=n.getSource().maxzoom,a=1<<i,s=Math.floor(t.x),o=t.x-s,l=new nu(i,s,i,Math.floor(o*a),Math.floor(t.y*a)),u=this.findDEMTileFor(l);if(!u||!u.dem)return e;const c=u.dem,h=1<<u.tileID.canonical.z,p=(o*h-u.tileID.canonical.x)*c.dim,f=(t.y*h-u.tileID.canonical.y)*c.dim,d=Math.floor(p),m=Math.floor(f);return (r?this.exaggeration():1)*Pe(Pe(c.get(d,m),c.get(d,m+1),f-m),Pe(c.get(d+1,m),c.get(d+1,m+1),f-m),p-d)}getAtTileOffset(t,e,r){const n=1<<t.canonical.z;return this.getAtPointOrZero(new vl(t.wrap+(t.canonical.x+e/Wr)/n,(t.canonical.y+r/Wr)/n))}getAtTileOffsetFunc(t,e,r,n){return i=>{const a=this.getAtTileOffset(t,i.x,i.y),s=n.upVector(t.canonical,i.x,i.y),o=n.upVectorScale(t.canonical,e,r).metersToTile;return O.vec3.scale(s,s,a*o),s}}getForTilePoints(t,e,r,n){if(this.isUsingMockSource())return !1;const i=ay.create(this,t,n);return !!i&&(e.forEach((t=>{t[2]=this.exaggeration()*i.getElevationAt(t[0],t[1],r);})),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const r=e.dem.tree,n=e.tileID,i=1<<t.canonical.z-n.canonical.z;let a=t.canonical.x/i-n.canonical.x,s=t.canonical.y/i-n.canonical.y,o=0;for(let e=0;e<t.canonical.z-n.canonical.z&&!r.leaves[o];e++){a*=2,s*=2;const t=2*Math.floor(s)+Math.floor(a);o=r.childOffsets[o]+t,a%=1,s%=1;}return {min:this.exaggeration()*r.minimums[o],max:this.exaggeration()*r.maximums[o]}}getMinElevationBelowMSL(){throw new Error("Pure virtual method called.")}raycast(t,e,r){throw new Error("Pure virtual method called.")}pointCoordinate(t){throw new Error("Pure virtual method called.")}_source(){throw new Error("Pure virtual method called.")}isUsingMockSource(){throw new Error("Pure virtual method called.")}exaggeration(){throw new Error("Pure virtual method called.")}findDEMTileFor(t){throw new Error("Pure virtual method called.")}get visibleDemTiles(){throw new Error("Getter must be implemented in subclass.")}getMinMaxForVisibleTiles(){const t=this.visibleDemTiles;if(0===t.length)return null;let e=!1,r=Number.MAX_VALUE,n=Number.MIN_VALUE;for(const i of t){const t=this.getMinMaxForTile(i.tileID);t&&(r=Math.min(r,t.min),n=Math.max(n,t.max),e=!0);}return e?{min:r,max:n}:null}},t.cF=sc,t.cG=xu,t.cH=function(t,e){return [Math.pow(t[0],2.2)*e,Math.pow(t[1],2.2)*e,Math.pow(t[2],2.2)*e]},t.cI=Ru,t.cJ=At,t.cK=Mt,t.cL=256,t.cM=function(t,e){const r=[0,0,0],n=Bu(Mu(e.canonical));return O.vec3.transformMat4(r,r,n),O.vec3.transformMat4(r,r,t),r},t.cN=t=>({u_camera_to_center_distance:new _o(t),u_extrude_scale:new Eo(t),u_device_pixel_ratio:new _o(t),u_matrix:new Po(t),u_inv_rot_matrix:new Po(t),u_merc_center:new Mo(t),u_tile_id:new Ao(t),u_zoom_transition:new _o(t),u_up_dir:new Ao(t),u_emissive_strength:new _o(t)}),t.cO=t=>({u_matrix:new Po(t),u_pixels_to_tile_units:new Eo(t),u_device_pixel_ratio:new _o(t),u_units_to_pixels:new Mo(t),u_dash_image:new wo(t),u_gradient_image:new wo(t),u_image_height:new _o(t),u_texsize:new Mo(t),u_tile_units_to_pixels:new _o(t),u_alpha_discard_threshold:new _o(t),u_trim_offset:new Mo(t),u_trim_fade_range:new Mo(t),u_trim_color:new So(t),u_emissive_strength:new _o(t),u_zbias_factor:new _o(t),u_tile_to_meter:new _o(t)}),t.cP=t=>({u_matrix:new Po(t),u_texsize:new Mo(t),u_pixels_to_tile_units:new Eo(t),u_device_pixel_ratio:new _o(t),u_image:new wo(t),u_units_to_pixels:new Mo(t),u_tile_units_to_pixels:new _o(t),u_alpha_discard_threshold:new _o(t),u_trim_offset:new Mo(t),u_emissive_strength:new _o(t),u_zbias_factor:new _o(t),u_tile_to_meter:new _o(t)}),t.cQ=Vs,t.cR=Gp,t.cS=Kp,t.cT=$u,t.cU=(t,e,r,n,i,a)=>{const s=t.transform,o="globe"===s.projection.name;let l;if("map"===a.paint.get("circle-pitch-alignment"))if(o){const t=Ru(s.zoom,e.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([t,0,0,t]);}else l=s.calculatePixelsToTileUnitsMatrix(r);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const u={u_camera_to_center_distance:t.transform.getCameraToCenterDistance(s.projection),u_matrix:t.translatePosMatrix(e.projMatrix,r,a.paint.get("circle-translate"),a.paint.get("circle-translate-anchor")),u_device_pixel_ratio:Rt.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:qu,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:a.paint.get("circle-emissive-strength")};if(o){u.u_inv_rot_matrix=n,u.u_merc_center=i,u.u_tile_id=[e.canonical.x,e.canonical.y,1<<e.canonical.z],u.u_zoom_transition=Lu(s.zoom);const t=i[0]*Wr,r=i[1]*Wr;u.u_up_dir=s.projection.upVector(new eu(0,0,0),t,r);}return u},t.cV=Tp,t.cW=(t,e,r,n,i,a)=>{const s=t.transform,o=s.pitch<15?zp(.07,.7,Q((14-s.zoom)/5,0,1)):.07;return {u_matrix:kp(t,e,r,n),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:i,u_image:0,u_tile_units_to_pixels:Pp(e,s),u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:a,u_emissive_strength:r.paint.get("line-emissive-strength"),u_zbias_factor:o,u_tile_to_meter:xl(e.tileID.canonical,0)}},t.cX=(t,e,r,n,i,a,s)=>{const o=t.transform,l=o.calculatePixelsToTileUnitsMatrix(e),u=o.pitch<15?zp(.07,.7,Q((14-o.zoom)/5,0,1)):.07;return {u_matrix:kp(t,e,r,n),u_pixels_to_tile_units:l,u_device_pixel_ratio:a,u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:i,u_texsize:Ep(r)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:Pp(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:s,u_trim_fade_range:r.paint.get("line-trim-fade-range"),u_trim_color:r.paint.get("line-trim-color").toRenderColor(r.lut).toArray01(),u_emissive_strength:r.paint.get("line-emissive-strength"),u_zbias_factor:u,u_tile_to_meter:xl(e.tileID.canonical,0)}},t.cY=st,t.cZ=oc,t.c_=np,t.ca=gu,t.cb=yt,t.cc=function(t){return [Math.pow(t[0],1/2.2),Math.pow(t[1],1/2.2),Math.pow(t[2],1/2.2)]},t.cd=function(t){return t({pluginStatus:Aa,pluginURL:Sa}),Pa.on("pluginStateChange",t),t},t.ce=My,t.cf=Vg,t.cg=Zf,t.ch=Yf,t.ci=re,t.cj=Ia,t.ck=Lt,t.cl=ge,t.cm=ht,t.cn=function(t){const e=t.indexOf(os);return e>=0?t.slice(0,e):t},t.co=function(t){const e=t.indexOf(os);return e>=0?t.slice(e+1):""},t.cp=function(t){const e=[],r=t.id;return void 0===r&&e.push({message:`layers.${r}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${r}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${r}: property "renderingMode" must be either "2d" or "3d"`}),e},t.cq=function(t,e,r,n){return "custom"===t.type?new Am(t,e):new vy[t.type](t,e,r,n)},t.cr=ct,t.cs=Pa,t.ct=ne,t.cu=Io,t.cv=class extends bo{constructor(t){super(t),this.current=ko;}set(t,e,r){if(this.fetchUniformLocation(t,e))for(let t=0;t<9;t++)if(r[t]!==this.current[t]){this.current=r,this.gl.uniformMatrix3fv(this.location,!1,r);break}}},t.cw=H,t.cx=function(t,e,r){const n=Lu(r.zoom),i=t.style.map._antialias,a=e.options.extStandardDerivativesForceOff||t.terrain&&t.terrain.exaggeration()>0;return 0===n&&!i&&!a},t.cy=function(t){const e=t.pixelsPerMeter,r=e/cl(1,t.center.lat),n=O.mat4.identity(new Float64Array(16));return O.mat4.translate(n,n,[t.point.x,t.point.y,0]),O.mat4.scale(n,n,[r,r,e]),Float32Array.from(n)},t.cz=zu,t.d=function(t){return St.API_TILEJSON_REGEX.test(t)},t.d$=e,t.d0=Wh,t.d1=Lh,t.d2=450,t.d3=7,t.d4=ym,t.d5=ms,t.d6=Zs,t.d7=256,t.d8=Vu,t.d9=Ms,t.dA=Fu,t.dB=function(t){const e=[0,0,0],r=O.mat4.identity(new Float64Array(16));return O.mat4.multiply(r,t.pixelMatrix,t.globeMatrix),O.vec3.transformMat4(e,e,r),new q(e[0],e[1])},t.dC=function(t,e,r=!1){if(Aa===ba||Aa===wa||Aa===_a)throw new Error("setRTLTextPlugin cannot be called multiple times.");Sa=Rt.resolveURL(t),Aa=ba,Ma=e,za(),r||Ta();},t.dD=ka,t.dE=function(){Vg().acquire(Tg);},t.dF=function(){const t=Bg;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(Tg),Bg=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()"));},t.dG=Eg,t.dH=function(t){const e=$t();if(!e)return;const r=e.delete(Ft);t&&r.catch(t).then((()=>t()));},t.dI=kg,t.dJ=Ug,t.dK=function(t){Rg=Rt.resolveURL(t),Og||(Og=new My(Vg(),new _e)),Og.broadcast("setDracoUrl",Rg);},t.dL=jg,t.dM=function(t){Lg=Rt.resolveURL(t),Og||(Og=new My(Vg(),new _e)),Og.broadcast("setMeshoptUrl",Lg);},t.dN=sa,t.dO=ic,t.dP=Xf,t.dQ=fx,t.dR=dx,t.dS=xp,t.dT=ut,t.dU=Nf,t.dV=function(t,e,r,n,i,a,s,o,l,u,c=1,h){t.createArrays(),t.tilePixelRatio=Wr/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const p=t.layers[0].layout,f=t.layers[0]._unevaluatedLayout._values,d={};if(d.scaleFactor=c,d.textSizeScaleRange=p.get("text-size-scale-range"),d.iconSizeScaleRange=p.get("icon-size-scale-range"),d.textScaleFactor=Q(d.scaleFactor,d.textSizeScaleRange[0],d.textSizeScaleRange[1]),d.iconScaleFactor=Q(d.scaleFactor,d.iconSizeScaleRange[0],d.iconSizeScaleRange[1]),"composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:r}=t.textSizeData;d.compositeTextSizes=[f["text-size"].possiblyEvaluate(new Ba(e),o),f["text-size"].possiblyEvaluate(new Ba(r),o)];}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:r}=t.iconSizeData;d.compositeIconSizes=[f["icon-size"].possiblyEvaluate(new Ba(e),o),f["icon-size"].possiblyEvaluate(new Ba(r),o)];}d.layoutTextSize=f["text-size"].possiblyEvaluate(new Ba(l+1),o),d.layoutIconSize=f["icon-size"].possiblyEvaluate(new Ba(l+1),o),d.textMaxSize=f["text-size"].possiblyEvaluate(new Ba(18),o);const m="map"===p.get("text-rotation-alignment")&&"point"!==p.get("symbol-placement"),y=p.get("text-size");let g=!1;for(const e of t.features)if(e.icon&&e.icon.nameSecondary){g=!0;break}for(const a of t.features){const l=p.get("text-font").evaluate(a,{},o).join(","),c=y.evaluate(a,{},o)*d.textScaleFactor,f=d.layoutTextSize.evaluate(a,{},o)*d.textScaleFactor,x=(d.layoutIconSize.evaluate(a,{},o),{horizontal:{},vertical:void 0}),v=a.text;let b,w=[0,0];if(v){const n=v.toString(),s=p.get("text-letter-spacing").evaluate(a,{},o)*Xp,u=p.get("text-line-height").evaluate(a,{},o)*Xp,h=fa(n)?s:0,d=p.get("text-anchor").evaluate(a,{},o),y=p.get("text-variable-anchor");if(!y){const t=p.get("text-radial-offset").evaluate(a,{},o);w=t?od(d,[t*Xp,ad]):p.get("text-offset").evaluate(a,{},o).map((t=>t*Xp));}let g=m?"center":p.get("text-justify").evaluate(a,{},o);const b="point"===p.get("symbol-placement"),_=b?p.get("text-max-width").evaluate(a,{},o)*Xp:1/0,M=a=>{t.allowVerticalPlacement&&pa(n)&&(x.vertical=xf(v,e,r,i,l,_,u,d,a,h,w,mf.vertical,!0,f,c));};if(!m&&y){const t="auto"===g?y.map((t=>ld(t))):[g];let n=!1;for(let a=0;a<t.length;a++){const s=t[a];if(!x.horizontal[s])if(n)x.horizontal[s]=x.horizontal[0];else {const t=xf(v,e,r,i,l,_,u,"center",s,h,w,mf.horizontal,!1,f,c);t&&(x.horizontal[s]=t,n=1===t.positionedLines.length);}}M("left");}else {if("auto"===g&&(g=ld(d)),b||p.get("text-writing-mode").indexOf("horizontal")>=0||!pa(n)){const t=xf(v,e,r,i,l,_,u,d,g,h,w,mf.horizontal,!1,f,c);t&&(x.horizontal[g]=t);}M(b?"left":g);}}let _=!1;if(a.icon&&a.icon.namePrimary){const e=n[a.icon.namePrimary];e&&(b=Pf(i[a.icon.namePrimary],a.icon.nameSecondary?i[a.icon.nameSecondary]:void 0,p.get("icon-offset").evaluate(a,{},o),p.get("icon-anchor").evaluate(a,{},o)),_=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&ft("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==p.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0));}const M=fd(x.horizontal)||x.vertical;t.iconsInText||(t.iconsInText=!!M&&M.iconsInText),(M||b)&&ud(t,a,x,b,n,d,f,0,w,_,s,o,u,h,g);}a&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray,d.textScaleFactor);},t.dW=hh,t.dX=Ry,t.dY=N,t.dZ=ch,t.d_=lf,t.da=Os,t.db=Us,t.dc=function(t,e,r,n,i){return Q((t-e)/(r-e)*(i-n)+n,n,i)},t.dd=Si,t.de=yl,t.df=class{constructor(t,e,r,n){this.context=t,this.format=n,this.size=r,this.texture=t.gl.createTexture();const[i,a,s]=this.size,{gl:o}=t;o.bindTexture(o.TEXTURE_3D,this.texture),t.pixelStoreUnpackFlipY.set(!1),t.pixelStoreUnpack.set(1),t.pixelStoreUnpackPremultiplyAlpha.set(!1),o.texImage3D(o.TEXTURE_3D,0,this.format,i,a,s,0,lm(this.format),um(this.format),e.data);}bind(t,e){const{context:r}=this,{gl:n}=r;n.bindTexture(n.TEXTURE_3D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,e),this.wrapS=e);}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null;}},t.dg=Cm,t.dh=[1,1,1],t.di=ay,t.dj=Jm,t.dk=Ts,t.dl=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new q(1/0,1/0),max:new q(-1/0,-1/0)};}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[];}get updateTime(){return this._updateTime}getReplacementRegionsForTile(t,e=!1){const r=Mh(new q(0,0),new q(Wr,Wr),t),n=[];if(e&&!wh(r,this._globalClipBounds))return n;for(const e of this._activeRegions){if(e.hiddenByOverlap)continue;if(!wh(r,e))continue;const i=Ah(e.min,e.max,t);n.push({min:i.min,max:i.max,sourceId:this._sourceIds[e.priority],footprint:e.footprint,footprintTileId:e.tileId,order:e.order,clipMask:e.clipMask,clipScope:e.clipScope});}return n}setSources(t){this._setSources(t.map((t=>({getSourceId:()=>t.cache.id,getFootprints:()=>{const e=[];for(const r of t.cache.getVisibleCoordinates()){const n=t.cache.getTile(r).buckets[t.layer];n&&n.updateFootprints(r.toUnwrapped(),e);}return e},getOrder:()=>t.order,getClipMask:()=>t.clipMask,getClipScope:()=>t.clipScope}))));}_addSource(t){const e=t.getFootprints();if(0===e.length)return;const r=t.getOrder(),n=t.getClipMask(),i=t.getClipScope();for(const t of e){if(!t.footprint)continue;const e=Mh(t.footprint.min,t.footprint.max,t.id);this._activeRegions.push({min:e.min,max:e.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:t.id,footprint:t.footprint,order:r,clipMask:n,clipScope:i});}this._sourceIds.push(t.getSourceId());}_computeReplacement(){this._activeRegions.sort(((t,e)=>t.priority-e.priority||vh(t.min,e.min)||vh(t.max,e.max)||t.order-e.order||t.clipMask-e.clipMask||function(t,e){const r=(t,e)=>t+e;return t.length-e.length||t.reduce(r,"").localeCompare(e.reduce(r,""))}(t.clipScope,e.clipScope)));let t=this._activeRegions.length!==this._prevRegions.length;if(!t){let e=0;for(;!t&&e!==this._activeRegions.length;){const r=this._activeRegions[e],n=this._prevRegions[e];t=r.priority!==n.priority||!bh(r,n)||r.order!==n.order||r.clipMask!==n.clipMask||!$(r.clipScope,n.clipScope),++e;}}if(t){++this._updateTime;for(const t of this._activeRegions)t.order!==gh&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,t.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,t.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,t.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,t.max.y));const t=t=>{const e=this._activeRegions;if(t>=e.length)return t;const r=e[t].priority;for(;t<e.length&&e[t].priority===r;)++t;return t};if(this._sourceIds.length>1){let e=0,r=t(e);for(;e!==r;){let n=e;const i=e;for(;n!==r;){const t=this._activeRegions[n];t.hiddenByOverlap=!1;for(let e=0;e<i;e++){const r=this._activeRegions[e];if(!r.hiddenByOverlap&&t.order===gh&&wh(t,r)&&(t.hiddenByOverlap=Ih(t.footprint,t.tileId,r.footprint,r.tileId),t.hiddenByOverlap))break}++n;}e=r,r=t(e);}}}}_setSources(t){[this._prevRegions,this._activeRegions]=[this._activeRegions,[]],this._sourceIds=[];for(let e=t.length-1;e>=0;e--)this._addSource(t[e]);this._computeReplacement();}},t.dm=class{constructor(t){this._createGrid(t),this._createPoles(t);}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy();}_fillGridMeshWithLods(t,e){const r=new gs,n=new Rs,i=[],a=t+1+2,s=e[0]+1,o=e[0]+1+(1+e.length),l=(t,e,r)=>{let n=t===a-1?t-2:0===t?t:t-1;return n+=r?24575:0,[n,e]};for(let t=0;t<a;++t)r.emplaceBack(...l(t,0,!0));for(let t=0;t<s;++t)for(let e=0;e<a;++e)r.emplaceBack(...l(e,t,(0===e||e===a-1)&&!0));for(let t=0;t<e.length;++t){const n=e[t];for(let t=0;t<a;++t)r.emplaceBack(...l(t,n,!0));}for(let t=0;t<e.length;++t){const s=n.length,l=e[t]+1+2,u=new Rs;for(let r=0;r<l-1;r++){const i=r===l-2,s=i?a*(o-e.length+t-r):a;for(let t=0;t<a-1;t++){const e=r*a+t;0===r||i||0===t||t===a-2?(u.emplaceBack(e+1,e,e+s),u.emplaceBack(e+s,e+s+1,e+1)):(n.emplaceBack(e+1,e,e+s),n.emplaceBack(e+s,e+s+1,e+1));}}const c=ho.simpleSegment(0,s,r.length,n.length-s);for(let t=0;t<u.uint16.length;t+=3)n.emplaceBack(u.uint16[t],u.uint16[t+1],u.uint16[t+2]);const h=ho.simpleSegment(0,s,r.length,n.length-s);i.push({withoutSkirts:c,withSkirts:h});}return {vertices:r,indices:n,segments:i}}_createGrid(t){const e=this._fillGridMeshWithLods(Wo,Ho);this._gridSegments=e.segments,this._gridBuffer=t.createVertexBuffer(e.vertices,uu.members),this._gridIndexBuffer=t.createIndexBuffer(e.indices,!0);}_createPoles(t){const e=new Rs;for(let t=0;t<=Wo;t++)e.emplaceBack(0,t+1,t+2);this._poleIndexBuffer=t.createIndexBuffer(e,!0);const r=new Os,n=new Os,i=new Os,a=new Os;this._poleSegments=[];for(let t=0,e=0;t<Xo;t++){const s=360/(1<<t);r.emplaceBack(0,-Go,0,.5,0),n.emplaceBack(0,-Go,0,.5,1),i.emplaceBack(0,-Go,0,.5,.5),a.emplaceBack(0,-Go,0,.5,.5);for(let t=0;t<=Wo;t++){let e=t/Wo,o=0;const l=Pe(0,s,e),[u,c,h]=Qo(ju,Nu,l,Go);r.emplaceBack(u,c,h,e,o),n.emplaceBack(u,c,h,e,1-o);const p=Y(l);e=.5+.5*Math.sin(p),o=.5+.5*Math.cos(p),i.emplaceBack(u,c,h,e,o),a.emplaceBack(u,c,h,e,1-o);}this._poleSegments.push(ho.simpleSegment(e,0,66,64)),e+=66;}this._poleNorthVertexBuffer=t.createVertexBuffer(r,ou,!1),this._poleSouthVertexBuffer=t.createVertexBuffer(n,ou,!1),this._texturedPoleNorthVertexBuffer=t.createVertexBuffer(i,ou,!1),this._texturedPoleSouthVertexBuffer=t.createVertexBuffer(a,ou,!1);}getGridBuffers(t,e){return [this._gridBuffer,this._gridIndexBuffer,e?this._gridSegments[t].withSkirts:this._gridSegments[t].withoutSkirts]}getPoleBuffers(t,e){return [e?this._texturedPoleNorthVertexBuffer:this._poleNorthVertexBuffer,e?this._texturedPoleSouthVertexBuffer:this._poleSouthVertexBuffer,this._poleIndexBuffer,this._poleSegments[t]]}},t.dn=gh,t.dp=K,t.dq=function(){return !!document.fullscreenElement||!!document.webkitFullscreenElement},t.dr=J,t.ds=gl,t.dt=tl,t.du=function([t,e,r]){const n=Math.hypot(t,e,r),i=Math.atan2(t,r),a=.5*Math.PI-Math.acos(-e/n);return new nl(Z(i),Z(a))},t.dv=Tm,t.dw=el,t.dx=function(t){const e=t.navigator?t.navigator.userAgent:null;return !!function(t){if(null==vt){const e=t.navigator?t.navigator.userAgent:null;vt=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")));}return vt}(t)&&e&&(e.match("Version/15.4")||e.match("Version/15.5")||e.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},t.dy=function(t,e){Ot=t,Ut=e;},t.dz=Ou,t.e=St,t.e0=function(t){let e=0;if(new Uint32Array(t,0,1)[0]!==Hg){const r=new Uint32Array(t,0,7),[,,n,i,a,s]=r;e=r.byteLength+i+a+s+a,(n!==t.byteLength||e>=t.byteLength)&&ft("Invalid b3dm header information.");}return rx(t,e)},t.e1=function(t,e){const r=cx(t);for(const t of r){for(const e of t.meshes)hx(e);t.lights&&(t.lightMeshIndex=t.meshes.length,t.meshes.push(px(t.lights,e)));}return r},t.e2=py,t.e3=_y,t.e4=Ea,t.e5=function(t){Gt(),null!=Nt&&Nt.then((e=>{e.keys().then((r=>{for(let n=0;n<r.length-t;n++)e.delete(r[n]);}));}));},t.f=function(t){return 0===t.indexOf("mapbox:")},t.g=function(t,e){return ne(nt(t,{method:"GET"}),e)},t.h=It,t.i=function(t){return St.API_STYLE_REGEX.test(t)&&!zt(t)},t.j=function(t){return decodeURIComponent(atob(t).split("").map((t=>"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2))).join(""))},t.k=function(t){return btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,((t,e)=>String.fromCharCode(Number("0x"+e)))))},t.l=nt,t.m=Yt,t.n=function(t,e){return ne(nt(t,{type:"json"}),e)},t.o=ue,t.p=function(t,e){return ne(nt(t,{method:"POST"}),e)},t.q=Rt,t.r=ac,t.s=function(t){try{const e=self[t];return e.setItem("_mapbox_test_",1),e.removeItem("_mapbox_test_"),!0}catch(t){return !1}},t.t=ve,t.u=function(){return function t(e){return e?(e^Math.random()*(16>>e/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()},t.v=function(t){return !!t&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t)},t.w=ft,t.x=xe,t.y=2,t.z=Of;})); |
| 33 |
|
| 34 |
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 o of e)t+=`${s(o)},`;return `${t}]`}let t="{";for(const o of Object.keys(e).sort())t+=`${o}:${s(e[o])},`;return `${t}}`}function o(t){let o="";for(const i of e.bh)o+=`/${s(t[i])}`;return o}class i{constructor(e){this.keyCache={},this._layers={},this._layerConfigs={},e&&this.replace(e);}replace(e,t){this._layerConfigs={},this._layers={},this.update(e,[],t);}update(t,s,i){this._options=i;for(const s of t)this._layerConfigs[s.id]=s,(this._layers[s.id]=e.cq(s,this.scope,null,this._options)).compileFilter(i),this.keyCache[s.id]&&delete this.keyCache[s.id];for(const e of s)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const n=function(e,t){const s={};for(let i=0;i<e.length;i++){const n=t&&t[e[i].id]||o(e[i]);t&&(t[e[i].id]=n);let r=s[n];r||(r=s[n]=[]),r.push(e[i]);}const i=[];for(const e in s)i.push(s[e]);return i}(e.be(this._layerConfigs),this.keyCache);for(const e of n){const t=e.map((e=>this._layers[e.id])),s=t[0];if("none"===s.visibility)continue;const o=s.source||"";let i=this.familiesBySource[o];i||(i=this.familiesBySource[o]={});const n=s.sourceLayer||"_geojsonTileLayer";let r=i[n];r||(r=i[n]=[]),r.push(t);}}}const n=1*e.dP;class r{constructor(t){const s={},o=[];for(const e in t){const i=t[e],r=s[e]={};for(const e in i.glyphs){const t=i.glyphs[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const s=t.metrics.localGlyph?n:1,a={x:0,y:0,w:t.bitmap.width+2*s,h:t.bitmap.height+2*s};o.push(a),r[e]=a;}}const{w:i,h:r}=e.z(o),a=new e.dO({width:i||1,height:r||1});for(const o in t){const i=t[o];for(const t in i.glyphs){const r=i.glyphs[+t];if(!r||0===r.bitmap.width||0===r.bitmap.height)continue;const l=s[o][t],c=r.metrics.localGlyph?n:1;e.dO.copy(r.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},r.bitmap);}}this.image=a,this.positions=s;}}e.dN(r,"GlyphAtlas");class a{constructor(t){this.tileID=new e.aA(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.aL(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;}parse(t,s,o,i,n){this.status="parsing",this.data=t,this.collisionBoxArray=new e.aR;const a=new e.dQ(Object.keys(t.layers).sort()),c=new e.dR(this.tileID,this.promoteId);c.bucketLayerIDs=[];const h={},u=new e.dS(256,256),d={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:u,availableImages:o,brightness:this.brightness},f=s.familiesBySource[this.source];for(const s in f){const i=t.layers[s];if(!i)continue;let n=!1,r=!1,u=!1;for(const e of f[s])"symbol"===e[0].type?n=!0:r=!0,e[0].is3D()&&"model"!==e[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(!0===this.isSymbolTile&&!n)continue;if(!1===this.isSymbolTile&&!r)continue;1===i.version&&e.w(`Vector tile source "${this.source}" layer "${s}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const p=a.encode(s),g=[];for(let e=0,t=0;e<i.length;e++){const o=i.feature(e),n=c.getId(o,s);if(this.localizableLayerIds&&this.localizableLayerIds.has(s)){const e=o.properties?o.properties.worldview:null;if(this.worldview&&"string"==typeof e)if("all"===e)o.properties.$localized=!0;else {if(!e.split(",").includes(this.worldview))continue;o.properties.$localized=!0,o.properties.worldview=this.worldview;}}g.push({feature:o,id:n,index:t,sourceLayerIndex:p}),t++;}for(const t of f[s]){const s=t[0];(!this.extraShadowCaster||s.is3D()&&"model"!==s.type)&&(void 0!==this.isSymbolTile&&"symbol"===s.type!==this.isSymbolTile||s.minzoom&&this.zoom<Math.floor(s.minzoom)||s.maxzoom&&this.zoom>=s.maxzoom||"none"!==s.visibility&&(l(t,this.zoom,d.brightness,o),(h[s.id]=s.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:p,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep})).populate(g,d,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(t.map((t=>e.av(t.id,t.scope))))));}}let p,g,m,y;u.trim();const x={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},w=()=>{if(p)return this.status="done",n(p);if(this.extraShadowCaster)this.status="done",n(null,{buckets:e.be(h).filter((e=>!e.isEmpty())),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:d.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(g&&m&&y){const t=new r(g),s=new e.dU(m,y,this.lut);for(const i in h){const n=h[i];n instanceof e.aS?(l(n.layers,this.zoom,d.brightness,o),e.dV(n,g,t.positions,m,s.iconPositions,this.showCollisionBoxes,o,this.tileID.canonical,this.tileZoom,this.projection,this.scaleFactor,this.brightness)):n.hasPattern&&(n instanceof e.aY||n instanceof e.aZ||n instanceof e.d0)&&(l(n.layers,this.zoom,d.brightness,o),n.addFeatures(d,this.tileID.canonical,s.patternPositions,o,this.tileTransform,this.brightness));}this.status="done",n(null,{buckets:e.be(h).filter((e=>!e.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:t.image,lineAtlas:u,imageAtlas:s,brightness:d.brightness});}};if(!this.extraShadowCaster){const t=e.dT(d.glyphDependencies,(e=>Object.keys(e).map(Number)));Object.keys(t).length?i.send("getGlyphs",{uid:this.uid,stacks:t,scope:this.scope},((e,t)=>{p||(p=e,g=t,w());}),void 0,!1,x):g={};const s=Object.keys(d.iconDependencies);s.length?i.send("getImages",{icons:s,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((e,t)=>{p||(p=e,m=t,w());}),void 0,!1,x):m={};const o=Object.keys(d.patternDependencies);o.length?i.send("getImages",{icons:o,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((e,t)=>{p||(p=e,y=t,w());}),void 0,!1,x):y={};}w();}}function l(t,s,o,i){const n=new e.a3(s,{brightness:o});for(const e of t)e.recalculate(n,i);}class c extends e.E{constructor(t,s,o,i,n,r){super(),this.actor=t,this.layerIndex=s,this.availableImages=o,this.loadVectorData=n||e.aw,this.loading={},this.loaded={},this.deduped=new e.au(t.scheduler),this.isSpriteLoaded=i,this.scheduler=t.scheduler,this.brightness=r;}loadTile(s,o){const i=s.uid,n=s&&s.request,r=n&&n.collectResourceTiming,l=this.loading[i]=new a(s);l.abort=this.loadVectorData(s,((a,c)=>{const h=!this.loading[i];if(delete this.loading[i],h||a||!c)return l.status="done",h||(this.loaded[i]=l),o(a);const u=c.rawData,d={};c.expires&&(d.expires=c.expires),c.cacheControl&&(d.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new e.dW.VectorTile(new e.bc(u));const f=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((s,i)=>{if(s||!i)return o(s);const a={};if(r){const e=t(n);e.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(e)));}o(null,e.l({rawTileData:u.slice(0)},i,d,a));}));};this.isSpriteLoaded?f():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(f,{type:"parseTile",isSymbolTile:s.isSymbolTile,zoom:s.tileZoom}):f();})),this.loaded=this.loaded||{},this.loaded[i]=l;}));}reloadTile(t,s){const o=this.loaded,i=t.uid;if(o&&o[i]){const n=o[i];n.scaleFactor=t.scaleFactor,n.showCollisionBoxes=t.showCollisionBoxes,n.projection=t.projection,n.brightness=t.brightness,n.tileTransform=e.aL(t.tileID.canonical,t.projection),n.extraShadowCaster=t.extraShadowCaster,n.lut=t.lut;const r=(e,t)=>{const o=n.reloadCallback;o&&(delete n.reloadCallback,n.parse(n.vectorTile,this.layerIndex,this.availableImages,this.actor,o)),s(e,t);};"parsing"===n.status?n.reloadCallback=r:"done"===n.status&&(n.vectorTile?n.parse(n.vectorTile,this.layerIndex,this.availableImages,this.actor,r):r());}else s(null,void 0);}abortTile(e,t){const s=e.uid,o=this.loading[s];o&&(o.abort&&o.abort(),delete this.loading[s]),t();}removeTile(e,t){const s=this.loaded,o=e.uid;s&&s[o]&&delete s[o],t();}}class h{loadTile(t,s){const{uid:o,encoding:i,rawImageData:n,padding:r}=t,a=ImageBitmap&&n instanceof ImageBitmap?this.getImageData(n,r):n;s(null,new e.dX(o,a,i,r<1));}getImageData(e,t){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(e.width,e.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=e.width,this.offscreenCanvas.height=e.height,this.offscreenCanvasContext.drawImage(e,0,0,e.width,e.height);const 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.bb.setPbf(e.bc);class u{decodeRasterArray({task:t,buffer:s},o){e.bb.performDecoding(s,t).then((e=>{o(null,e);}),(e=>{o(e);}));}}const d=e.dW.VectorTileFeature.prototype.toGeoJSON;class f{constructor(t){this._feature=t,this.extent=e.ab,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 o=[];for(const t of s)o.push(new e.P(t[0],t[1]));t.push(o);}return t}}toGeoJSON(e,t,s){return d.call(this,e,t,s)}}class p{constructor(t){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=e.ab,this.length=t.length,this._features=t;}feature(e){return new f(this._features[e])}}const g=64/4096,m=128;class y{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 o=this.features.get(e);o&&this.updateCache(o,t),s.geometry?(o=w(s),this.updateCache(o,t),this.features.set(e,o)):this.features.delete(e),this.updateCache(o,t);}}updateCache(e,t){for(const{canonical:s,uid:o}of Object.values(t)){const{z:i,x:n,y:r}=s;x(e,Math.pow(2,i),n,r)&&delete t[o];}}getTile(e,t,s){const o=Math.pow(2,e),i=[];for(const e of this.features.values())x(e,o,t,s)&&i.push(I(e,o,t,s));return {features:i}}getFeatures(){return [...this.features.values()]}}function x({minX:e,minY:t,maxX:s,maxY:o},i,n,r){return e<(n+1+g)/i&&t<(r+1+g)/i&&s>(n-g)/i&&o>(r-g)/i}function w(e){const{id:t,geometry:s,properties:o}=e;if(!s)return;if("GeometryCollection"===s.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:i,coordinates:n}=s,r={id:t,type:1,geometry:[],tags:o,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=r.geometry;if("Point"===i)b(n,a,r);else if("MultiPoint"===i)for(const e of n)b(e,a,r);else if("LineString"===i)r.type=2,S(n,a,r);else if("MultiLineString"===i)r.type=2,v(n,a,r);else if("Polygon"===i)r.type=3,v(n,a,r,!0);else {if("MultiPolygon"!==i)throw new Error("Input data is not a valid GeoJSON object.");r.type=3;for(const e of n)v(e,a,r,!0);}return r}function b([t,s],o,i){const n=e.am(t);let r=e.at(s);r=r<0?0:r>1?1:r,o.push(n,r),i.minX=Math.min(i.minX,n),i.minY=Math.min(i.minY,r),i.maxX=Math.max(i.maxX,n),i.maxY=Math.max(i.maxY,r);}function S(e,t,s,o=!1,i=!1){const n=[];for(const t of e)b(t,n,s);t.push(n),o&&function(e,t){let s=0;for(let t=0,o=e.length,i=o-2;t<o;i=t,t+=2)s+=(e[t]-e[i])*(e[t+1]+e[i+1]);if(s>0===t)for(let t=0,s=e.length;t<s/2;t+=2){const o=e[t],i=e[t+1];e[t]=e[s-2-t],e[t+1]=e[s-1-t],e[s-2-t]=o,e[s-1-t]=i;}}(n,i);}function v(e,t,s,o=!1){for(let i=0;i<e.length;i++)S(e[i],t,s,o,0===i);}function I(t,s,o,i){const{id:n,type:r,geometry:a,tags:l}=t,c=[];if(1===r)!function(t,s,o,i,n){for(let r=0;r<t.length;r+=2){const a=Math.round(e.ab*(t[r+0]*s-o)),l=Math.round(e.ab*(t[r+1]*s-i));n.push([a,l]);}}(a,s,o,i,c);else for(const e of a)M(e,s,o,i,c);return {id:n,type:r,geometry:c,tags:l}}function M(t,s,o,i,n){const r=-m,a=e.ab+m;let l;for(let c=0;c<t.length-2;c+=2){let h=Math.round(e.ab*(t[c+0]*s-o)),u=Math.round(e.ab*(t[c+1]*s-i)),d=Math.round(e.ab*(t[c+2]*s-o)),f=Math.round(e.ab*(t[c+3]*s-i));const p=d-h,g=f-u;h<r&&d<r||(h<r?(u+=Math.round(g*((r-h)/p)),h=r):d<r&&(f=u+Math.round(g*((r-h)/p)),d=r),u<r&&f<r||(u<r?(h+=Math.round(p*((r-u)/g)),u=r):f<r&&(d=h+Math.round(p*((r-u)/g)),f=r),h>=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])))));}}var k,T,P,C={exports:{}},L=function(){if(P)return C.exports;P=1;var t=e.d_(),s=function(){if(T)return k;T=1;var t=e.dY(),s=e.dZ().VectorTileFeature;function o(e,t){this.options=t||{},this.features=e,this.length=e.length;}function i(e,t){this.id="number"==typeof e.id?e.id:void 0,this.type=e.type,this.rawGeometry=1===e.type?[e.geometry]:e.geometry,this.properties=e.tags,this.extent=t||4096;}return k=o,o.prototype.feature=function(e){return new i(this.features[e],this.options.extent)},i.prototype.loadGeometry=function(){var e=this.rawGeometry;this.geometry=[];for(var s=0;s<e.length;s++){for(var o=e[s],i=[],n=0;n<o.length;n++)i.push(new t(o[n][0],o[n][1]));this.geometry.push(i);}return this.geometry},i.prototype.bbox=function(){this.geometry||this.loadGeometry();for(var e=this.geometry,t=1/0,s=-1/0,o=1/0,i=-1/0,n=0;n<e.length;n++)for(var r=e[n],a=0;a<r.length;a++){var l=r[a];t=Math.min(t,l.x),s=Math.max(s,l.x),o=Math.min(o,l.y),i=Math.max(i,l.y);}return [t,o,s,i]},i.prototype.toGeoJSON=s.prototype.toGeoJSON,k}();function o(e){var s=new t;return function(e,t){for(var s in e.layers)t.writeMessage(3,i,e.layers[s]);}(e,s),s.finish()}function i(e,t){var s;t.writeVarintField(15,e.version||1),t.writeStringField(1,e.name||""),t.writeVarintField(5,e.extent||4096);var o={keys:[],values:[],keycache:{},valuecache:{}};for(s=0;s<e.length;s++)o.feature=e.feature(s),t.writeMessage(2,n,o);var i=o.keys;for(s=0;s<i.length;s++)t.writeStringField(3,i[s]);var r=o.values;for(s=0;s<r.length;s++)t.writeMessage(4,h,r[s]);}function n(e,t){var s=e.feature;void 0!==s.id&&t.writeVarintField(1,s.id),t.writeMessage(2,r,e),t.writeVarintField(3,s.type),t.writeMessage(4,c,s);}function r(e,t){var s=e.feature,o=e.keys,i=e.values,n=e.keycache,r=e.valuecache;for(var a in s.properties){var l=s.properties[a],c=n[a];if(null!==l){void 0===c&&(o.push(a),n[a]=c=o.length-1),t.writeVarint(c);var h=typeof l;"string"!==h&&"boolean"!==h&&"number"!==h&&(l=JSON.stringify(l));var u=h+":"+l,d=r[u];void 0===d&&(i.push(l),r[u]=d=i.length-1),t.writeVarint(d);}}}function a(e,t){return (t<<3)+(7&e)}function l(e){return e<<1^e>>31}function c(e,t){for(var s=e.loadGeometry(),o=e.type,i=0,n=0,r=s.length,c=0;c<r;c++){var h=s[c],u=1;1===o&&(u=h.length),t.writeVarint(a(1,u));for(var d=3===o?h.length-1:h.length,f=0;f<d;f++){1===f&&1!==o&&t.writeVarint(a(2,d-1));var p=h[f].x-i,g=h[f].y-n;t.writeVarint(l(p)),t.writeVarint(l(g)),i+=p,n+=g;}3===o&&t.writeVarint(a(7,1));}}function h(e,t){var s=typeof e;"string"===s?t.writeStringField(1,e):"boolean"===s?t.writeBooleanField(7,e):"number"===s&&(e%1!=0?t.writeDoubleField(3,e):e<0?t.writeSVarintField(6,e):t.writeVarintField(5,e));}return C.exports=o,C.exports.fromVectorTileJs=o,C.exports.fromGeojsonVt=function(e,t){t=t||{};var i={};for(var n in e)i[n]=new s(e[n].features,t),i[n].name=n,i[n].version=t.version,i[n].extent=t.extent;return o({layers:i})},C.exports.GeoJSONWrapper=s,C.exports}(),_=e.d$(L);const D={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:e=>e},z=Math.fround||(j=new Float32Array(1),e=>(j[0]=+e,j[0]));var j;const O=3,A=5,F=6;class Z{constructor(e){this.options=Object.assign(Object.create(D),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:o}=this.options;t&&console.time("total time");const i=`prepare ${e.length} points`;t&&console.time(i),this.points=e;const n=[];for(let t=0;t<e.length;t++){const s=e[t];if(!s.geometry)continue;const[o,i]=s.geometry.coordinates,r=z(N(o)),a=z(X(i));n.push(r,a,1/0,t,-1,1),this.options.reduce&&n.push(0);}let r=this.trees[o+1]=this._createTree(n);t&&console.timeEnd(i);for(let e=o;e>=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 o=Math.max(-90,Math.min(90,e[1]));let i=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,i=180;else if(s>i){const e=this.getClusters([s,o,180,n],t),r=this.getClusters([-180,o,i,n],t);return e.concat(r)}const r=this.trees[this._limitZoom(t)],a=r.range(N(s),X(n),N(i),X(o)),l=r.data,c=[];for(const e of a){const t=this.stride*e;c.push(l[t+A]>1?E(l,t,this.clusterProps):this.points[l[t+O]]);}return c}getChildren(e){const t=this._getOriginId(e),s=this._getOriginZoom(e),o="No cluster with the specified id.",i=this.trees[s];if(!i)throw new Error(o);const n=i.data;if(t*this.stride>=n.length)throw new Error(o);const r=this.options.radius/(this.options.extent*Math.pow(2,s-1)),a=i.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+A]>1?E(n,s,this.clusterProps):this.points[n[s+O]]);}if(0===l.length)throw new Error(o);return l}getLeaves(e,t,s){const o=[];return this._appendLeaves(o,e,t=t||10,s=s||0,0),o}getTile(e,t,s){const o=this.trees[this._limitZoom(e)],i=Math.pow(2,e),{extent:n,radius:r}=this.options,a=r/n,l=(s-a)/i,c=(s+1+a)/i,h={features:[]};return this._addTileFeatures(o.range((t-a)/i,l,(t+1+a)/i,c),o.data,t,s,i,h),0===t&&this._addTileFeatures(o.range(1-a/i,l,1,c),o.data,i,s,i,h),t===i-1&&this._addTileFeatures(o.range(0,l,a/i,c),o.data,-1,s,i,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,o,i){const n=this.getChildren(t);for(const t of n){const n=t.properties;if(n&&n.cluster?i+n.point_count<=o?i+=n.point_count:i=this._appendLeaves(e,n.cluster_id,s,o,i):i<o?i++:e.push(t),e.length===s)break}return i}_createTree(t){const s=new e.bz(t.length/this.stride|0,this.options.nodeSize,Float32Array);for(let e=0;e<t.length;e+=this.stride)s.add(t[e],t[e+1]);return s.finish(),s.data=t,s}_addTileFeatures(e,t,s,o,i,n){for(const r of e){const e=r*this.stride,a=t[e+A]>1;let l,c,h;if(a)l=Y(t,e,this.clusterProps),c=t[e],h=t[e+1];else {const s=this.points[t[e+O]];l=s.properties;const[o,i]=s.geometry.coordinates;c=N(o),h=X(i);}const u={type:1,geometry:[[Math.round(this.options.extent*(c*i-s)),Math.round(this.options.extent*(h*i-o))]],tags:l};let d;d=a||this.options.generateId?t[e+O]:this.points[t[e+O]].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:o,reduce:i,minPoints:n}=this.options,r=s/(o*Math.pow(2,t)),a=e.data,l=[],c=this.stride;for(let s=0;s<a.length;s+=c){if(a[s+2]<=t)continue;a[s+2]=t;const o=a[s],h=a[s+1],u=e.within(a[s],a[s+1],r),d=a[s+A];let f=d;for(const e of u){const s=e*c;a[s+2]>t&&(f+=a[s+A]);}if(f>d&&f>=n){let e,n=o*d,r=h*d,p=-1;const g=(s/c<<5)+(t+1)+this.points.length;for(const o of u){const l=o*c;if(a[l+2]<=t)continue;a[l+2]=t;const h=a[l+A];n+=a[l]*h,r+=a[l+1]*h,a[l+4]=g,i&&(e||(e=this._map(a,s,!0),p=this.clusterProps.length,this.clusterProps.push(e)),i(e,this._map(a,l)));}a[s+4]=g,l.push(n/f,r/f,1/0,g,-1,f),i&&l.push(p);}else {for(let e=0;e<c;e++)l.push(a[s+e]);if(f>1)for(const e of u){const s=e*c;if(!(a[s+2]<=t)){a[s+2]=t;for(let e=0;e<c;e++)l.push(a[s+e]);}}}}return l}_getOriginId(e){return e-this.points.length>>5}_getOriginZoom(e){return (e-this.points.length)%32}_map(e,t,s){if(e[t+A]>1){const o=this.clusterProps[e[t+F]];return s?Object.assign({},o):o}const o=this.points[e[t+O]].properties,i=this.options.map(o);return s&&i===o?Object.assign({},i):i}}function E(e,t,s){return {type:"Feature",id:e[t+O],properties:Y(e,t,s),geometry:{type:"Point",coordinates:[(o=e[t],360*(o-.5)),W(e[t+1])]}};var o;}function Y(e,t,s){const o=e[t+A],i=o>=1e4?`${Math.round(o/1e3)}k`:o>=1e3?Math.round(o/100)/10+"k":o,n=e[t+F],r=-1===n?{}:Object.assign({},s[n]);return Object.assign(r,{cluster:!0,cluster_id:e[t+O],point_count:o,point_count_abbreviated:i})}function N(e){return e/360+.5}function X(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 W(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function B(e,t,s,o){let i=o;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 o=t+3;o<s;o+=3){const t=G(e[o],e[o+1],l,c,h,u);if(t>i)r=o,i=t;else if(t===i){const e=Math.abs(o-n);e<a&&(r=o,a=e);}}i>o&&(r-t>3&&B(e,t,r,o),e[r+2]=i,s-r>3&&B(e,r,s,o));}function G(e,t,s,o,i,n){let r=i-s,a=n-o;if(0!==r||0!==a){const l=((e-s)*r+(t-o)*a)/(r*r+a*a);l>1?(s=i,o=n):l>0&&(s+=r*l,o+=a*l);}return r=e-s,a=t-o,r*r+a*a}function J(e,t,s,o){const i={id:e??null,type:t,geometry:s,tags:o,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===t||"MultiPoint"===t||"LineString"===t)R(i,s);else if("Polygon"===t)R(i,s[0]);else if("MultiLineString"===t)for(const e of s)R(i,e);else if("MultiPolygon"===t)for(const e of s)R(i,e[0]);return i}function R(e,t){for(let s=0;s<t.length;s+=3)e.minX=Math.min(e.minX,t[s]),e.minY=Math.min(e.minY,t[s+1]),e.maxX=Math.max(e.maxX,t[s]),e.maxY=Math.max(e.maxY,t[s+1]);}function V(e,t,s,o){if(!t.geometry)return;const i=t.geometry.coordinates;if(i&&0===i.length)return;const n=t.geometry.type,r=Math.pow(s.tolerance/((1<<s.maxZoom)*s.extent),2);let a=[],l=t.id;if(s.promoteId?l=t.properties[s.promoteId]:s.generateId&&(l=o||0),"Point"===n)$(i,a);else if("MultiPoint"===n)for(const e of i)$(e,a);else if("LineString"===n)q(i,a,r,!1);else if("MultiLineString"===n){if(s.lineMetrics){for(const s of i)a=[],q(s,a,r,!1),e.push(J(l,"LineString",a,t.properties));return}U(i,a,r,!1);}else if("Polygon"===n)U(i,a,r,!0);else {if("MultiPolygon"!==n){if("GeometryCollection"===n){for(const i of t.geometry.geometries)V(e,{id:l,geometry:i,properties:t.properties},s,o);return}throw new Error("Input data is not a valid GeoJSON object.")}for(const e of i){const t=[];U(e,t,r,!0),a.push(t);}}e.push(J(l,n,a,t.properties));}function $(e,t){t.push(Q(e[0]),H(e[1]),0);}function q(e,t,s,o){let i,n,r=0;for(let s=0;s<e.length;s++){const a=Q(e[s][0]),l=H(e[s][1]);t.push(a,l,0),s>0&&(r+=o?(i*l-a*n)/2:Math.sqrt(Math.pow(a-i,2)+Math.pow(l-n,2))),i=a,n=l;}const a=t.length-3;t[2]=1,B(t,0,a,s),t[a+2]=1,t.size=Math.abs(r),t.start=0,t.end=t.size;}function U(e,t,s,o){for(let i=0;i<e.length;i++){const n=[];q(e[i],n,s,o),t.push(n);}}function Q(e){return e/360+.5}function H(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 K(e,t,s,o,i,n,r,a){if(o/=t,n>=(s/=t)&&r<o)return e;if(r<s||n>=o)return null;const l=[];for(const t of e){const e=t.geometry;let n=t.type;const r=0===i?t.minX:t.minY,c=0===i?t.maxX:t.maxY;if(r>=s&&c<o){l.push(t);continue}if(c<s||r>=o)continue;let h=[];if("Point"===n||"MultiPoint"===n)ee(e,h,s,o,i);else if("LineString"===n)te(e,h,s,o,i,!1,a.lineMetrics);else if("MultiLineString"===n)oe(e,h,s,o,i,!1);else if("Polygon"===n)oe(e,h,s,o,i,!0);else if("MultiPolygon"===n)for(const t of e){const e=[];oe(t,e,s,o,i,!0),e.length&&h.push(e);}if(h.length){if(a.lineMetrics&&"LineString"===n){for(const e of h)l.push(J(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(J(t.id,n,h,t.tags));}}return l.length?l:null}function ee(e,t,s,o,i){for(let n=0;n<e.length;n+=3){const r=e[n+i];r>=s&&r<=o&&ie(t,e[n],e[n+1],e[n+2]);}}function te(e,t,s,o,i,n,r){let a=se(e);const l=0===i?ne:re;let c,h,u=e.start;for(let d=0;d<e.length-3;d+=3){const f=e[d],p=e[d+1],g=e[d+2],m=e[d+3],y=e[d+4],x=0===i?f:p,w=0===i?m:y;let b=!1;r&&(c=Math.sqrt(Math.pow(f-m,2)+Math.pow(p-y,2))),x<s?w>s&&(h=l(a,f,p,m,y,s),r&&(a.start=u+c*h)):x>o?w<o&&(h=l(a,f,p,m,y,o),r&&(a.start=u+c*h)):ie(a,f,p,g),w<s&&x>=s&&(h=l(a,f,p,m,y,s),b=!0),w>o&&x<=o&&(h=l(a,f,p,m,y,o),b=!0),!n&&b&&(r&&(a.end=u+c*h),t.push(a),a=se(e)),r&&(u+=c);}let d=e.length-3;const f=e[d],p=e[d+1],g=0===i?f:p;g>=s&&g<=o&&ie(a,f,p,e[d+2]),d=a.length-3,n&&d>=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&ie(a,a[0],a[1],a[2]),a.length&&t.push(a);}function se(e){const t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function oe(e,t,s,o,i,n){for(const r of e)te(r,t,s,o,i,n,!1);}function ie(e,t,s,o){e.push(t,s,o);}function ne(e,t,s,o,i,n){const r=(n-t)/(o-t);return ie(e,n,s+(i-s)*r,1),r}function re(e,t,s,o,i,n){const r=(n-s)/(i-s);return ie(e,t+(o-t)*r,n,1),r}function ae(e,t){const s=[];for(let o=0;o<e.length;o++){const i=e[o],n=i.type;let r;if("Point"===n||"MultiPoint"===n||"LineString"===n)r=le(i.geometry,t);else if("MultiLineString"===n||"Polygon"===n){r=[];for(const e of i.geometry)r.push(le(e,t));}else if("MultiPolygon"===n){r=[];for(const e of i.geometry){const s=[];for(const o of e)s.push(le(o,t));r.push(s);}}s.push(J(i.id,n,r,i.tags));}return s}function le(e,t){const s=[];s.size=e.size,void 0!==e.start&&(s.start=e.start,s.end=e.end);for(let o=0;o<e.length;o+=3)s.push(e[o]+t,e[o+1],e[o+2]);return s}function ce(e,t){if(e.transformed)return e;const s=1<<e.z,o=e.x,i=e.y;for(const n of e.features){const e=n.geometry,r=n.type;if(n.geometry=[],1===r)for(let r=0;r<e.length;r+=2)n.geometry.push(he(e[r],e[r+1],t,s,o,i));else for(let r=0;r<e.length;r++){const a=[];for(let n=0;n<e[r].length;n+=2)a.push(he(e[r][n],e[r][n+1],t,s,o,i));n.geometry.push(a);}}return e.transformed=!0,e}function he(e,t,s,o,i,n){return [Math.round(s*(e*o-i)),Math.round(s*(t*o-n))]}function ue(e,t,s,o,i){const n=t===i.maxZoom?0:i.tolerance/((1<<t)*i.extent),r={features:[],numPoints:0,numSimplified:0,numFeatures:e.length,source:null,x:s,y:o,z:t,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0};for(const t of e)de(r,t,n,i);return r}function de(e,t,s,o){const i=t.geometry,n=t.type,r=[];if(e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),"Point"===n||"MultiPoint"===n)for(let t=0;t<i.length;t+=3)r.push(i[t],i[t+1]),e.numPoints++,e.numSimplified++;else if("LineString"===n)fe(r,i,e,s,!1,!1);else if("MultiLineString"===n||"Polygon"===n)for(let t=0;t<i.length;t++)fe(r,i[t],e,s,"Polygon"===n,0===t);else if("MultiPolygon"===n)for(let t=0;t<i.length;t++){const o=i[t];for(let t=0;t<o.length;t++)fe(r,o[t],e,s,!0,0===t);}if(r.length){let s=t.tags||null;if("LineString"===n&&o.lineMetrics){s={};for(const e in t.tags)s[e]=t.tags[e];s.mapbox_clip_start=i.start/i.size,s.mapbox_clip_end=i.end/i.size;}const a={geometry:r,type:"Polygon"===n||"MultiPolygon"===n?3:"LineString"===n||"MultiLineString"===n?2:1,tags:s};null!==t.id&&(a.id=t.id),e.features.push(a);}}function fe(e,t,s,o,i,n){const r=o*o;if(o>0&&t.size<(i?r:o))return void(s.numPoints+=t.length/3);const a=[];for(let e=0;e<t.length;e+=3)(0===o||t[e+2]>r)&&(s.numSimplified++,a.push(t[e],t[e+1])),s.numPoints++;i&&function(e,t){let s=0;for(let t=0,o=e.length,i=o-2;t<o;i=t,t+=2)s+=(e[t]-e[i])*(e[t+1]+e[i+1]);if(s>0===t)for(let t=0,s=e.length;t<s/2;t+=2){const o=e[t],i=e[t+1];e[t]=e[s-2-t],e[t+1]=e[s-1-t],e[s-2-t]=o,e[s-1-t]=i;}}(a,n),e.push(a);}const pe={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0};class ge{constructor(e,t){const s=(t=this.options=function(e,t){for(const s in t)e[s]=t[s];return e}(Object.create(pe),t)).debug;if(s&&console.time("preprocess data"),t.maxZoom<0||t.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(t.promoteId&&t.generateId)throw new Error("promoteId and generateId cannot be used together.");let o=function(e,t){const s=[];if("FeatureCollection"===e.type)for(let o=0;o<e.features.length;o++)V(s,e.features[o],t,o);else V(s,"Feature"===e.type?e:{geometry:e},t);return s}(e,t);this.tiles={},this.tileCoords=[],s&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",t.indexMaxZoom,t.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),o=function(e,t){const s=t.buffer/t.extent;let o=e;const i=K(e,1,-1-s,s,0,-1,2,t),n=K(e,1,1-s,2+s,0,-1,2,t);return (i||n)&&(o=K(e,1,-s,1+s,0,-1,2,t)||[],i&&(o=ae(i,1).concat(o)),n&&(o=o.concat(ae(n,-1)))),o}(o,t),o.length&&this.splitTile(o,0,0,0),s&&(o.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)));}splitTile(e,t,s,o,i,n,r){const a=[e,t,s,o],l=this.options,c=l.debug;for(;a.length;){o=a.pop(),s=a.pop(),t=a.pop(),e=a.pop();const h=1<<t,u=me(t,s,o);let d=this.tiles[u];if(!d&&(c>1&&console.time("creation"),d=this.tiles[u]=ue(e,t,s,o,l),this.tileCoords.push({z:t,x:s,y:o}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,s,o,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==i){if(t===l.indexMaxZoom||d.numPoints<=l.indexMaxPoints)continue}else {if(t===l.maxZoom||t===i)continue;if(null!=i){const e=i-t;if(s!==n>>e||o!==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,x=null,w=null,b=null,S=K(e,h,s-f,s+g,0,d.minX,d.maxX,l),v=K(e,h,s+p,s+m,0,d.minX,d.maxX,l);e=null,S&&(y=K(S,h,o-f,o+g,1,d.minY,d.maxY,l),x=K(S,h,o+p,o+m,1,d.minY,d.maxY,l),S=null),v&&(w=K(v,h,o-f,o+g,1,d.minY,d.maxY,l),b=K(v,h,o+p,o+m,1,d.minY,d.maxY,l),v=null),c>1&&console.timeEnd("clipping"),a.push(y||[],t+1,2*s,2*o),a.push(x||[],t+1,2*s,2*o+1),a.push(w||[],t+1,2*s+1,2*o),a.push(b||[],t+1,2*s+1,2*o+1);}}getTile(e,t,s){e=+e,t=+t,s=+s;const o=this.options,{extent:i,debug:n}=o;if(e<0||e>24)return null;const r=1<<e,a=me(e,t=t+r&r-1,s);if(this.tiles[a])return ce(this.tiles[a],i);n>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]?ce(this.tiles[a],i):null):null}}function me(e,t,s){return 32*((1<<e)*s+t)+e}function ye(e,t){const s=e.tileID.canonical;if(!this._geoJSONIndex)return void t(null,null);const o=this._geoJSONIndex.getTile(s.z,s.x,s.y);if(!o)return void t(null,null);const i=new p(o.features);let n=_(i);0===n.byteOffset&&n.byteLength===n.buffer.byteLength||(n=new Uint8Array(n)),t(null,{vectorTile:i,rawData:n.buffer});}class xe extends c{constructor(e,t,s,o,i,n){super(e,t,s,o,ye,n),i&&(this.loadGeoJSON=i),this._dynamicIndex=new y;}loadData(s,o){const i=s&&s.request,n=i&&i.collectResourceTiming;this.loadGeoJSON(s,((r,a)=>{if(r||!a)return o(r);if("object"!=typeof a)return o(new Error(`Input data given to '${s.source}' is not a valid GeoJSON object.`));{try{if(s.filter){const t=e.M(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 Z(function({superclusterOptions:t,clusterProperties:s}){if(!s||!t)return t;const o={},i={},n={accumulated:null,zoom:0},r={properties:null},a=Object.keys(s);for(const t of a){const[n,r]=s[t],a=e.M(r),l=e.M("string"==typeof n?[n,["accumulated"],["get",t]]:n);o[t]=a.value,i[t]=l.value;}return t.map=e=>{r.properties=e;const t={};for(const e of a)t[e]=o[e].evaluate(n,r);return t},t.reduce=(e,t)=>{r.properties=t;for(const t of a)n.accumulated=e[t],e[t]=i[t].evaluate(n,r);},t}(s)).load(a.features):s.dynamic?this._dynamicIndex:function(e,t){return new ge(e,t)}(a,s.geojsonVtOptions);}catch(e){return o(e)}const r={};if(n){const e=t(i);e&&(r.resourceTiming={},r.resourceTiming[s.source]=JSON.parse(JSON.stringify(e)));}o(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.n(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.`));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.`))}}}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 we{constructor(t,s){this.tileID=new e.aA(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;}parse(t,s,o,i){this.status="parsing";const n=new e.aA(o.tileID.overscaledZ,o.tileID.wrap,o.tileID.canonical.z,o.tileID.canonical.x,o.tileID.canonical.y),r=[],a=s.familiesBySource[o.source],l=new e.dR(n,o.promoteId);return l.bucketLayerIDs=[],l.is3DTile=!0,e.e0(t).then((t=>{if(!t)return i(new Error("Could not parse tile"));const s=e.e1(t,1/e.c9(o.tileID.canonical)),c=t.json.extensionsUsed&&t.json.extensionsUsed.includes("MAPBOX_mesh_features")||t.json.asset.extras&&t.json.asset.extras.MAPBOX_mesh_features,h=t.json.extensionsUsed&&t.json.extensionsUsed.includes("EXT_meshopt_compression"),u=new e.a3(this.zoom,{brightness:this.brightness});for(const t in a)for(const o of a[t]){const t=o[0];l.bucketLayerIDs.push(o.map((t=>e.av(t.id,t.scope)))),t.recalculate(u,[]);const i=new e.e2(o,s,n,c,h,this.brightness,l);c||(i.needsUpload=!0),r.push(i),i.evaluate(t);}this.status="done",i(null,{buckets:r,featureIndex:l,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:null});})).catch((e=>i(new Error(e.message))))}}class be{constructor(e,t,s,o,i,n){this.actor=e,this.layerIndex=t,this.availableImages=s,this.brightness=n,this.loading={},this.loaded={};}loadTile(t,s){const o=t.uid,i=this.loading[o]=new we(t,this.brightness);e.bd(t.request,((e,n)=>{const r=!this.loading[o];return delete this.loading[o],r||e?(i.status="done",r||(this.loaded[o]=i),s(e)):n&&0!==n.byteLength?void i.parse(n,this.layerIndex,t,((e,t)=>{i.status="done",this.loaded=this.loaded||{},this.loaded[o]=i,e||!t?s(e):s(null,t);})):(i.status="done",this.loaded[o]=i,s())}));}reloadTile(e,t){const s=this.loaded,o=e.uid;if(s&&s[o]){const i=s[o];i.projection=e.projection,i.brightness=e.brightness;const n=(s,o)=>{i.reloadCallback&&(delete i.reloadCallback,this.loadTile(e,t)),t(s,o);};"parsing"===i.status?i.reloadCallback=n:"done"===i.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,o=e.uid;s&&s[o]&&delete s[o],t();}}class Se{constructor(t){this.self=t,this.actor=new e.e3(t,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=e.bM({name:"mercator"}),this.workerSourceTypes={vector:c,geojson:xe,"batched-model":be},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(e,t)=>{if(this.workerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.workerSourceTypes[e]=t;},this.self.registerRTLTextPlugin=t=>{if(e.e4.isParsed())throw new Error("RTL text plugin already registered.");e.e4.applyArabicShaping=t.applyArabicShaping,e.e4.processBidirectionalText=t.processBidirectionalText,e.e4.processStyledBidirectionalText=t.processStyledBidirectionalText;};}clearCaches(e,t,s){delete this.layerIndexes[e],delete this.availableImages[e],delete this.workerSources[e],delete this.demWorkerSources[e],delete this.rasterArrayWorkerSource,s();}checkIfReady(e,t,s){s();}setReferrer(e,t){this.referrer=t;}spriteLoaded(t,{scope:s,isLoaded:o}){if(this.isSpriteLoaded[t]||(this.isSpriteLoaded[t]={}),this.isSpriteLoaded[t][s]=o,this.workerSources[t]&&this.workerSources[t][s])for(const i in this.workerSources[t][s]){const n=this.workerSources[t][s][i];for(const t in n){const s=n[t];s instanceof c&&(s.isSpriteLoaded=o,s.fire(new e.x("isSpriteLoaded")));}}}setImages(e,{scope:t,images:s},o){if(this.availableImages[e]||(this.availableImages[e]={}),this.availableImages[e][t]=s,this.workerSources[e]&&this.workerSources[e][t]){for(const o in this.workerSources[e][t]){const i=this.workerSources[e][t][o];for(const e in i)i[e].availableImages=s;}o();}else o();}setProjection(t,s){this.projections[t]=e.bM(s);}setBrightness(e,t,s){this.brightness=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);}loadDEMTile(e,t,s){this.getDEMWorkerSource(e,t.source,t.scope).loadTile(t,s);}decodeRasterArray(e,t,s){this.getRasterArrayWorkerSource().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 o=this.workerSources[e][t.scope][t.type][t.source];delete this.workerSources[e][t.scope][t.type][t.source],void 0!==o.removeSource?o.removeSource(t,s):s();}loadWorkerSource(e,t,s){try{this.self.importScripts(t.url),s();}catch(e){s(e.toString());}}syncRTLPluginState(t,s,o){try{e.e4.setState(s);const t=e.e4.getPluginURL();if(e.e4.isLoaded()&&!e.e4.isParsed()&&null!=t){this.self.importScripts(t);const s=e.e4.isParsed();o(s?void 0:new Error(`RTL Text Plugin failed to import scripts from ${t}`),s);}}catch(e){o(e.toString());}}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}getLayerIndex(e,t){this.layerIndexes[e]||(this.layerIndexes[e]={});let s=this.layerIndexes[e][t];return s||(s=this.layerIndexes[e][t]=new i,s.scope=t),s}getWorkerSource(e,t,s,o){return this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][o]||(this.workerSources[e][o]={}),this.workerSources[e][o][t]||(this.workerSources[e][o][t]={}),this.isSpriteLoaded[e]||(this.isSpriteLoaded[e]={}),this.workerSources[e][o][t][s]||(this.workerSources[e][o][t][s]=new this.workerSourceTypes[t]({send:(t,s,o,i,n,r)=>{this.actor.send(t,s,o,e,n,r);},scheduler:this.actor.scheduler},this.getLayerIndex(e,o),this.getAvailableImages(e,o),this.isSpriteLoaded[e][o],void 0,this.brightness)),this.workerSources[e][o][t][s]}getDEMWorkerSource(e,t,s){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][s]||(this.demWorkerSources[e][s]={}),this.demWorkerSources[e][s][t]||(this.demWorkerSources[e][s][t]=new h),this.demWorkerSources[e][s][t]}getRasterArrayWorkerSource(){return this.rasterArrayWorkerSource||(this.rasterArrayWorkerSource=new u),this.rasterArrayWorkerSource}enforceCacheSizeLimit(t,s){e.e5(s);}getWorkerPerformanceMetrics(e,t,s){s(void 0,void 0);}}return "undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new Se(self)),Se})); |
| 35 |
|
| 36 |
define(["./shared"],(function(e){var t="3.8.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,a={},n=function(){if(r)return a;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,a.supported=e,a.notSupportedReason=t;var i={};return e.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0},a}();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,u=h&&void 0!==h.userSelect?"userSelect":"WebkitUserSelect";let d;function _(){h&&u&&(d=h[u],h[u]="none");}function p(){h&&u&&(h[u]=d);}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 y(e,i,t)}function v(e,t){const i=e.getBoundingClientRect(),o=[];for(let s=0;s<t.length;s++)o.push(y(e,i,t[s]));return o}function x(e){return void 0!==window.InstallTrigger&&2===e.button&&e.ctrlKey&&window.navigator.platform.toUpperCase().indexOf("MAC")>=0?0:e.button}function y(t,i,o){const s=t.offsetWidth===i.width?1:t.offsetWidth/i.width;return new e.P((o.clientX-i.left)*s,(o.clientY-i.top)*s)}const b="01",w="NO_ACCESS_TOKEN";class T{constructor(e,t,i){this._transformRequestFn=e,this._customAccessToken=t,this._silenceAuthErrors=!!i,this._createSkuToken();}_createSkuToken(){const e=function(){let e="";for(let t=0;t<10;t++)e+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return {token:["1",b,e].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=e.token,this._skuTokenExpiresAt=e.tokenExpiresAt;}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}normalizeStyleURL(i,o){if(!e.f(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.f(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.f(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.f(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)}normalizeSpriteURL(t,i,o,s){const r=S(t);return e.f(t)?(r.path=`/styles/v1${r.path}/sprite${i}${o}`,this._makeAPIURL(r,this._customAccessToken||s)):(r.path+=`${i}${o}`,C(r))}normalizeTileURL(t,i,o){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!e.f(t))return t;const s=S(t);s.path=s.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${i||o&&"raster"!==s.authority&&512===o?"@2x":""}${e.m.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.f(i),s=[];for(const i of t.tiles||[])e.h(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 C(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||""}`),C(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 C(e){const t=e.params.length?`?${e.params.join("&")}`:"";return `${e.protocol}://${e.authority}${e.path}${t}`}const I="mapbox.eventData";function D(t){if(!t)return null;const i=t.split(".");if(!i||3!==i.length)return null;try{return JSON.parse(e.j(i[1]))}catch(e){return null}}class R{constructor(e){this.type=e,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null;}getStorageKey(t){const i=D(e.e.ACCESS_TOKEN);let o="";return o=i&&i.u?e.k(i.u):e.e.ACCESS_TOKEN||"",t?`${I}.${t}:${o}`:`${I}:${o}`}fetchEventData(){const t=e.s("localStorage"),i=this.getStorageKey(),o=this.getStorageKey("uuid");if(t)try{const e=localStorage.getItem(i);e&&(this.eventData=JSON.parse(e));const t=localStorage.getItem(o);t&&(this.anonId=t);}catch(t){e.w("Unable to read from LocalStorage");}}saveEventData(){const t=e.s("localStorage"),i=this.getStorageKey(),o=this.getStorageKey("uuid"),s=this.anonId;if(t&&s)try{localStorage.setItem(o,s),Object.keys(this.eventData).length>=1&&localStorage.setItem(i,JSON.stringify(this.eventData));}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 a={event:this.type,created:new Date(t).toISOString()},n=i?e.l(a,i):a,l={url:C(r),headers:{"Content-Type":"text/plain"},body:JSON.stringify([n])};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);}}const A=new class extends R{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.f(t)||e.h(t)))&&this.queueRequest(Date.now(),i);}processRequests(i){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const o=D(e.e.ACCESS_TOKEN),s=o?o.u:e.e.ACCESS_TOKEN;let r=s!==this.eventData.tokenU;e.v(this.anonId)||(this.anonId=e.u(),r=!0);const a=this.queue.shift();if(this.eventData.lastSuccess){const e=new Date(this.eventData.lastSuccess),t=new Date(a),i=(a-this.eventData.lastSuccess)/864e5;r=r||i>=1||i<-1||e.getDate()!==t.getDate();}else r=!0;r?this.postEvent(a,{sdkIdentifier:"mapbox-gl-js",sdkVersion:t,skuId:b,"enabled.telemetry":!1,userId:this.anonId},(e=>{e||(this.eventData.lastSuccess=a,this.eventData.tokenU=s);}),i):this.processRequests();}},L=A.postTurnstileEvent.bind(A),P=new class extends R{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.fetchEventData(),e.v(this.anonId)||(this.anonId=e.u()),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;}},M=P.postMapLoadEvent.bind(P),z=new class extends R{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 a=this.getMapInstanceId(o),n={mapInstanceId:a,eventId:this.getEventId(a),style:s};r.length&&(n.importedStyles=r),this.queueRequest({timestamp:Date.now(),payload:n},t);}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:t,payload:i}=this.queue.shift();this.postEvent(t,i,(()=>{}),e);}},O=z.postStyleLoadEvent.bind(z),F=new class extends R{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:a}=this.queue.shift(),n=function(o){const r=performance.getEntriesByType("resource"),a=performance.getEntriesByType("mark"),n=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`,a=`${i}RequestCachedCount`;t[e]=Math.min(t[e]||1/0,o.startTime),t[s]=Math.max(t[s]||-1/0,o.responseEnd);const n=e=>{void 0===t[e]&&(t[e]=0),++t[e];};void 0!==o.transferSize&&0===o.transferSize&&n(a),n(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,u={counters:[],metadata:[],attributes:[]},d=(e,t,i)=>{null!=i&&e.push({name:t,value:i.toString()});};for(const e in n)d(u.counters,e,n[e]);if(o.interactionRange[0]!==1/0&&o.interactionRange[1]!==-1/0&&(d(u.counters,"interactionRangeMin",o.interactionRange[0]),d(u.counters,"interactionRangeMax",o.interactionRange[1])),a)for(const e of Object.keys(i)){const t=i[e],o=a.find((e=>e.name===t));o&&d(u.counters,t,o.startTime);}return d(u.counters,"visibilityHidden",o.visibilityHidden),d(u.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)),d(u.attributes,"terrainEnabled",o.terrainEnabled?"true":"false"),d(u.attributes,"fogEnabled",o.fogEnabled?"true":"false"),d(u.attributes,"projection",o.projection),d(u.attributes,"zoom",o.zoom),d(u.metadata,"devicePixelRatio",l),d(u.metadata,"connectionEffectiveType",h),d(u.metadata,"navigatorUserAgent",navigator.userAgent),d(u.metadata,"screenWidth",window.screen.width),d(u.metadata,"screenHeight",window.screen.height),d(u.metadata,"windowWidth",window.innerWidth),d(u.metadata,"windowHeight",window.innerHeight),d(u.metadata,"mapWidth",o.width/l),d(u.metadata,"mapHeight",o.height/l),d(u.metadata,"webglRenderer",o.renderer),d(u.metadata,"webglVendor",o.vendor),d(u.metadata,"sdkVersion",t),d(u.metadata,"sdkIdentifier","mapbox-gl-js"),u}(a);for(const e of n.metadata);for(const e of n.counters);for(const e of n.attributes);this.postEvent(r,n,(()=>{}),o);}},B=F.postPerformanceEvent.bind(F),k=new class extends R{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 a={url:C(r),headers:{"Content-Type":"text/plain"}};this.pendingRequest=e.g(a,(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;}},N=k.getSessionAPI.bind(k),U=new Set;function G(e,t){t?U.add(e):U.delete(e);}class V{constructor(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps=new Set,this._updatedImages=new Set;}isDirty(){return this._changed}setDirty(){this._changed=!0;}getUpdatedSourceCaches(){return this._updatedSourceCaches}updateSourceCache(e,t){this._updatedSourceCaches[e]=t,this.setDirty();}discardSourceCacheUpdate(e){delete this._updatedSourceCaches[e];}updateLayer(e){const t=e.scope;this._updatedLayers[t]=this._updatedLayers[t]||new Set,this._updatedLayers[t].add(e.id),this.setDirty();}removeLayer(e){const t=e.scope;this._removedLayers[t]=this._removedLayers[t]||{},this._updatedLayers[t]=this._updatedLayers[t]||new Set,this._removedLayers[t][e.id]=e,this._updatedLayers[t].delete(e.id),this._updatedPaintProps.delete(e.fqid),this.setDirty();}getRemovedLayer(e){return this._removedLayers[e.scope]?this._removedLayers[e.scope][e.id]:null}discardLayerRemoval(e){this._removedLayers[e.scope]&&delete this._removedLayers[e.scope][e.id];}getLayerUpdatesByScope(){const e={};for(const t in this._updatedLayers)e[t]=e[t]||{},e[t].updatedIds=Array.from(this._updatedLayers[t].values());for(const t in this._removedLayers)e[t]=e[t]||{},e[t].removedIds=Object.keys(this._removedLayers[t]);return e}getUpdatedPaintProperties(){return this._updatedPaintProps}updatePaintProperties(e){this._updatedPaintProps.add(e.fqid),this.setDirty();}getUpdatedImages(){return Array.from(this._updatedImages.values())}updateImage(e){this._updatedImages.add(e),this.setDirty();}resetUpdatedImages(){this._updatedImages.clear();}reset(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps.clear(),this._updatedImages.clear();}}function j(e){const{userImage:t}=e;return !!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}class H extends e.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded={},this.requestors=[],this.patterns={},this.atlasImage={},this.atlasTexture={},this.dirty=!0;}createScope(t){this.images[t]={},this.loaded[t]=!1,this.updatedImages[t]={},this.patterns[t]={},this.callbackDispatchedThisFrame[t]={},this.atlasImage[t]=new e.r({width:1,height:1});}isLoaded(){for(const e in this.loaded)if(!this.loaded[e])return !1;return !0}setLoaded(e,t){if(this.loaded[t]!==e&&(this.loaded[t]=e,e)){for(const{ids:e,callback: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[t][e]}addImage(e,t,i){this._validate(e,i)&&(this.images[t][e]=i);}_validate(t,i){let o=!0;return this._validateStretch(i.stretchX,i.data&&i.data.width)||(this.fire(new e.t(new Error(`Image "${t}" has invalid "stretchX" value`))),o=!1),this._validateStretch(i.stretchY,i.data&&i.data.height)||(this.fire(new e.t(new Error(`Image "${t}" has invalid "stretchY" value`))),o=!1),this._validateContent(i.content,i)||(this.fire(new e.t(new Error(`Image "${t}" 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]<i||o[1]<o[0]||t<o[1])return !1;i=o[1];}return !0}_validateContent(e,t){return !(e&&(4!==e.length||e[0]<0||t.data.width<e[0]||e[1]<0||t.data.height<e[1]||e[2]<0||t.data.width<e[2]||e[3]<0||t.data.height<e[3]||e[2]<e[0]||e[3]<e[1]))}updateImage(e,t,i){i.version=this.images[t][e].version+1,this.images[t][e]=i,this.updatedImages[t][e]=!0;}removeImage(e,t){const i=this.images[t][e];delete this.images[t][e],delete this.patterns[t][e],i.userImage&&i.userImage.onRemove&&i.userImage.onRemove();}listImages(e){return Object.keys(this.images[e])}getImages(e,t,i){let o=!0;const s=!!this.loaded[t];if(!s)for(const i of e)this.images[t][i]||(o=!1);s||o?this._notify(e,t,i):this.requestors.push({ids:e,scope:t,callback:i});}getUpdatedImages(e){return this.updatedImages[e]}_notify(t,i,o){const s={};for(const o of t){this.images[i][o]||this.fire(new e.x("styleimagemissing",{id:o}));const t=this.images[i][o];t?s[o]={data:t.data.clone(),pixelRatio:t.pixelRatio,sdf:t.sdf,version:t.version,stretchX:t.stretchX,stretchY:t.stretchY,content:t.content,hasRenderCallback:Boolean(t.userImage&&t.userImage.render)}:e.w(`Image "${o}" 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.`);}o(null,s);}getPixelSize(e){const{width:t,height:i}=this.atlasImage[e];return {width:t,height:i}}getPattern(t,i,o){const s=this.patterns[i][t],r=this.getImage(t,i);if(!r)return null;if(s&&s.position.version===r.version)return s.position;if(s)s.position.version=r.version;else {const o={w:r.data.width+2*e.y,h:r.data.height+2*e.y,x:0,y:0},s=new e.I(o,r,e.y);this.patterns[i][t]={bin:o,position:s};}return this._updatePatternAtlas(i,o),this.patterns[i][t].position}bind(t,i){const o=t.gl;let s=this.atlasTexture[i];s?this.dirty&&(s.update(this.atlasImage[i]),this.dirty=!1):(s=new e.T(t,this.atlasImage[i],o.RGBA8),this.atlasTexture[i]=s),s.bind(o.LINEAR,o.CLAMP_TO_EDGE);}_updatePatternAtlas(t,i){const o=[];for(const e in this.patterns[t])o.push(this.patterns[t][e].bin);const{w:s,h:r}=e.z(o),a=this.atlasImage[t];a.resize({width:s||1,height:r||1});for(const o in this.patterns[t]){const{bin:s,position:r}=this.patterns[t][o];let n=r.padding;const l=s.x+n,c=s.y+n,h=this.images[t][o].data,u=h.width,d=h.height;n=n>1?n-1:n,e.r.copy(h,a,{x:0,y:0},{x:l,y:c},{width:u,height:d},i),e.r.copy(h,a,{x:0,y:d-n},{x:l,y:c-n},{width:u,height:n},i),e.r.copy(h,a,{x:0,y:0},{x:l,y:c+d},{width:u,height:n},i),e.r.copy(h,a,{x:u-n,y:0},{x:l-n,y:c},{width:n,height:d},i),e.r.copy(h,a,{x:0,y:0},{x:l+u,y:c},{width:n,height:d},i),e.r.copy(h,a,{x:u-n,y:d-n},{x:l-n,y:c-n},{width:n,height:n},i),e.r.copy(h,a,{x:0,y:d-n},{x:l+u,y:c-n},{width:n,height:n},i),e.r.copy(h,a,{x:0,y:0},{x:l+u,y:c+d},{width:n,height:n},i),e.r.copy(h,a,{x:u-n,y:0},{x:l-n,y:c+d},{width:n,height:n},i);}this.dirty=!0;}beginFrame(){for(const e in this.images)this.callbackDispatchedThisFrame[e]={};}dispatchRenderCallbacks(e,t){for(const i of e){if(this.callbackDispatchedThisFrame[t][i])continue;this.callbackDispatchedThisFrame[t][i]=!0;const e=this.images[t][i];j(e)&&this.updateImage(i,t,e);}}}function Z(t){const i=t.key,o=t.value,s=t.valueSpec||{},r=t.objectElementValidators||{},a=t.style,n=t.styleSpec;let l=[];const c=e.B(o);if("object"!==c)return [new e.V(i,o,`object expected, ${c} found`)];for(const t in o){const c=t.split(".")[0];let h;r[c]?h=r[c]:s[c]?h=_e:r["*"]?h=r["*"]:s["*"]&&(h=_e),h?l=l.concat(h({key:(i?`${i}.`:i)+t,value:o[t],valueSpec:s[c]||s["*"],style:a,styleSpec:n,object:o,objectKey:t},o)):l.push(new e.A(i,o[t],`unknown property "${t}"`));}for(const t in s)r[t]||s[t].required&&void 0===s[t].default&&void 0===o[t]&&l.push(new e.V(i,o,`missing required property "${t}"`));return l}function q(t){const i=t.value,o=t.valueSpec,s=t.style,r=t.styleSpec,a=t.key,n=t.arrayElementValidator||_e;if("array"!==e.B(i))return [new e.V(a,i,`array expected, ${e.B(i)} found`)];if(o.length&&i.length!==o.length)return [new e.V(a,i,`array length ${o.length} expected, length ${i.length} found`)];if(o["min-length"]&&i.length<o["min-length"])return [new e.V(a,i,`array length at least ${o["min-length"]} expected, length ${i.length} found`)];let l={type:o.value,values:o.values,minimum:o.minimum,maximum:o.maximum,function:void 0};r.$version<7&&(l.function=o.function),"object"===e.B(o.value)&&(l=o.value);let c=[];for(let e=0;e<i.length;e++)c=c.concat(n({array:i,arrayIndex:e,value:i[e],valueSpec:l,style:s,styleSpec:r,key:`${a}[${e}]`},!0));return c}function W(t){const i=t.key,o=t.value,s=t.valueSpec;let r=e.B(o);if("number"===r&&o!=o&&(r="NaN"),"number"!==r)return [new e.V(i,o,`number expected, ${r} found`)];if("minimum"in s){let r=s.minimum;if("array"===e.B(s.minimum)&&(r=s.minimum[t.arrayIndex]),o<r)return [new e.V(i,o,`${o} is less than the minimum value ${r}`)]}if("maximum"in s){let r=s.maximum;if("array"===e.B(s.maximum)&&(r=s.maximum[t.arrayIndex]),o>r)return [new e.V(i,o,`${o} is greater than the maximum value ${r}`)]}return []}function $(t){const i=t.valueSpec,o=e.D(t.value.type);let s,r,a,n={};const l="categorical"!==o&&void 0===t.value.property,c=!l,h="array"===e.B(t.value.stops)&&"array"===e.B(t.value.stops[0])&&"object"===e.B(t.value.stops[0][0]),u=Z({key:t.key,value:t.value,valueSpec:t.styleSpec.function,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===o)return [new e.V(t.key,t.value,'identity function may not have a "stops" property')];let i=[];const s=t.value;return i=i.concat(q({key:t.key,value:s,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:d})),"array"===e.B(s)&&0===s.length&&i.push(new e.V(t.key,s,"array must have at least one stop")),i},default:function(e){return _e({key:e.key,value:e.value,valueSpec:i,style:e.style,styleSpec:e.styleSpec})}}});return "identity"===o&&l&&u.push(new e.V(t.key,t.value,'missing required property "property"')),"identity"===o||t.value.stops||u.push(new e.V(t.key,t.value,'missing required property "stops"')),"exponential"===o&&t.valueSpec.expression&&!e.F(t.valueSpec)&&u.push(new e.V(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(c&&!e.G(t.valueSpec)?u.push(new e.V(t.key,t.value,"property functions not supported")):l&&!e.H(t.valueSpec)&&u.push(new e.V(t.key,t.value,"zoom functions not supported"))),"categorical"!==o&&!h||void 0!==t.value.property||u.push(new e.V(t.key,t.value,'"property" property is required')),u;function d(t){let o=[];const s=t.value,l=t.key;if("array"!==e.B(s))return [new e.V(l,s,`array expected, ${e.B(s)} found`)];if(2!==s.length)return [new e.V(l,s,`array length 2 expected, length ${s.length} found`)];if(h){if("object"!==e.B(s[0]))return [new e.V(l,s,`object expected, ${e.B(s[0])} found`)];if(void 0===s[0].zoom)return [new e.V(l,s,"object stop key must have zoom")];if(void 0===s[0].value)return [new e.V(l,s,"object stop key must have value")];const i=e.D(s[0].zoom);if("number"!=typeof i)return [new e.V(l,s[0].zoom,"stop zoom values must be numbers")];if(a&&a>i)return [new e.V(l,s[0].zoom,"stop zoom values must appear in ascending order")];i!==a&&(a=i,r=void 0,n={}),o=o.concat(Z({key:`${l}[0]`,value:s[0],valueSpec:{zoom:{}},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:W,value:_}}));}else o=o.concat(_({key:`${l}[0]`,value:s[0],valueSpec:{},style:t.style,styleSpec:t.styleSpec},s));return e.J(e.K(s[1]))?o.concat([new e.V(`${l}[1]`,s[1],"expressions are not allowed in function stops.")]):o.concat(_e({key:`${l}[1]`,value:s[1],valueSpec:i,style:t.style,styleSpec:t.styleSpec}))}function _(t,a){const l=e.B(t.value),c=e.D(t.value),h=null!==t.value?t.value:a;if(s){if(l!==s)return [new e.V(t.key,h,`${l} stop domain type must match previous stop domain type ${s}`)]}else s=l;if("number"!==l&&"string"!==l&&"boolean"!==l&&"number"!=typeof c&&"string"!=typeof c&&"boolean"!=typeof c)return [new e.V(t.key,h,"stop domain value must be a number, string, or boolean")];if("number"!==l&&"categorical"!==o){let s=`number expected, ${l} found`;return e.G(i)&&void 0===o&&(s+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new e.V(t.key,h,s)]}return "categorical"!==o||"number"!==l||"number"==typeof c&&isFinite(c)&&Math.floor(c)===c?"categorical"!==o&&"number"===l&&"number"==typeof c&&"number"==typeof r&&void 0!==r&&c<r?[new e.V(t.key,h,"stop domain values must appear in ascending order")]:(r=c,"categorical"===o&&c in n?[new e.V(t.key,h,"stop domain values must be unique")]:(n[c]=!0,[])):[new e.V(t.key,h,`integer expected, found ${String(c)}`)]}}function X(t){const i=("property"===t.expressionContext?e.L:e.M)(e.K(t.value),t.valueSpec);if("error"===i.result)return i.value.map((i=>new 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.N(o))return [new e.V(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext)return J(o,t);if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!e.O(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.Q(o))return [new e.V(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return []}function J(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.S&&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(...J(e,i));})),s)}function K(t){const i=t.key,o=t.value,s=t.valueSpec,r=[];return Array.isArray(s.values)?-1===s.values.indexOf(e.D(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.D(o))&&r.push(new e.V(i,o,`expected one of [${Object.keys(s.values).join(", ")}], ${JSON.stringify(o)} found`)),r}function Y(t){return e.W(e.K(t.value))?X(e.C({},t,{expressionContext:"filter",valueSpec:t.styleSpec[`filter_${t.layerType||"fill"}`]})):Q(t)}function Q(t){const i=t.value,o=t.key;if("array"!==e.B(i))return [new e.V(o,i,`array expected, ${e.B(i)} found`)];const s=t.styleSpec;let r,a=[];if(i.length<1)return [new e.V(o,i,"filter array must have at least 1 element")];switch(a=a.concat(K({key:`${o}[0]`,value:i[0],valueSpec:s.filter_operator,style:t.style,styleSpec:t.styleSpec})),e.D(i[0])){case"<":case"<=":case">":case">=":i.length>=2&&"$type"===e.D(i[1])&&a.push(new e.V(o,i,`"$type" cannot be use with operator "${i[0]}"`));case"==":case"!=":3!==i.length&&a.push(new e.V(o,i,`filter array for operator "${i[0]}" must have 3 elements`));case"in":case"!in":i.length>=2&&(r=e.B(i[1]),"string"!==r&&a.push(new e.V(`${o}[1]`,i[1],`string expected, ${r} found`)));for(let n=2;n<i.length;n++)r=e.B(i[n]),"$type"===e.D(i[1])?a=a.concat(K({key:`${o}[${n}]`,value:i[n],valueSpec:s.geometry_type,style:t.style,styleSpec:t.styleSpec})):"string"!==r&&"number"!==r&&"boolean"!==r&&a.push(new e.V(`${o}[${n}]`,i[n],`string, number, or boolean expected, ${r} found`));break;case"any":case"all":case"none":for(let e=1;e<i.length;e++)a=a.concat(Q({key:`${o}[${e}]`,value:i[e],style:t.style,styleSpec:t.styleSpec}));break;case"has":case"!has":r=e.B(i[1]),2!==i.length?a.push(new e.V(o,i,`filter array for "${i[0]}" operator must have 2 elements`)):"string"!==r&&a.push(new e.V(`${o}[1]`,i[1],`string expected, ${r} found`));}return a}function ee(t,i){const o=t.key,s=t.style,r=t.layer,a=t.styleSpec,n=t.value,l=t.objectKey,c=a[`${i}_${t.layerType}`];if(!c)return [];const h=l.match(/^(.*)-transition$/);if("paint"===i&&h&&c[h[1]]&&c[h[1]].transition)return _e({key:o,value:n,valueSpec:a.transition,style:s,styleSpec:a});const u=t.valueSpec||c[l];if(!u)return [new e.A(o,n,`unknown property "${l}"`)];let d;if("string"===e.B(n)&&e.G(u)&&!u.tokens&&(d=/^{([^}]+)}$/.exec(n))){const t=`\`{ "type": "identity", "property": ${d?JSON.stringify(d[1]):'"_"'} }\``;return [new e.V(o,n,`"${l}" does not support interpolation syntax\nUse an identity property function instead: ${t}.`)]}const _=[];if("symbol"===t.layerType)"text-field"!==l||!s||s.glyphs||s.imports||_.push(new e.V(o,n,'use of "text-field" requires a style "glyphs" property')),"text-font"===l&&e.X(e.K(n))&&"identity"===e.D(n.type)&&_.push(new e.V(o,n,'"text-font" does not support identity functions'));else if("model"===t.layerType&&"paint"===i&&r&&r.layout&&r.layout.hasOwnProperty("model-id")&&e.G(u)&&(e.Y(u)||e.H(u))){const t=e.L(e.K(n),u),i=t.value.expression||t.value._styleExpression.expression;i&&!e.O(i,["measure-light"])&&("model-emissive-strength"===l&&e.Q(i)&&e.N(i)||_.push(new e.V(o,n,`${l} does not support measure-light expressions when the model layer source is vector tile or GeoJSON.`)));}return _.concat(_e({key:t.key,value:n,valueSpec:u,style:s,styleSpec:a,expressionContext:"property",propertyType:i,propertyKey:l}))}function te(e){return ee(e,"paint")}function ie(e){return ee(e,"layout")}function oe(t){let i=[];const o=t.value,s=t.key,r=t.style,a=t.styleSpec;o.type||o.ref||i.push(new e.V(s,o,'either "type" or "ref" is required'));let n=e.D(o.type);const l=e.D(o.ref);if(o.id){const a=e.D(o.id);for(let n=0;n<t.arrayIndex;n++){const t=r.layers[n];e.D(t.id)===a&&i.push(new e.V(s,o.id,`duplicate layer id "${o.id}", previously used at line ${t.id.__line__}`));}}if("ref"in o){let t;["type","source","source-layer","filter","layout"].forEach((t=>{t in o&&i.push(new e.V(s,o[t],`"${t}" is prohibited for ref layers`));})),r.layers.forEach((i=>{e.D(i.id)===l&&(t=i);})),t?t.ref?i.push(new e.V(s,o.ref,"ref cannot reference another ref layer")):n=e.D(t.type):"string"==typeof l&&i.push(new e.V(s,o.ref,`ref layer "${l}" not found`));}else if("background"!==n&&"sky"!==n&&"slot"!==n)if(o.source){const t=r.sources&&r.sources[o.source],a=t&&e.D(t.type);t?"vector"===a&&"raster"===n?i.push(new e.V(s,o.source,`layer "${o.id}" requires a raster source`)):"raster"===a&&"raster"!==n?i.push(new e.V(s,o.source,`layer "${o.id}" requires a vector source`)):"vector"!==a||o["source-layer"]?"raster-dem"===a&&"hillshade"!==n?i.push(new e.V(s,o.source,"raster-dem source can only be used with layer type 'hillshade'.")):"raster-array"!==a||["raster","raster-particle"].includes(n)?"line"!==n||!o.paint||!o.paint["line-gradient"]&&!o.paint["line-trim-offset"]||"geojson"===a&&t.lineMetrics?"raster-particle"===n&&"raster-array"!==a&&i.push(new e.V(s,o.source,`layer "${o.id}" requires a 'raster-array' source.`)):i.push(new e.V(s,o,`layer "${o.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):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,o,'missing required property "source"'));return i=i.concat(Z({key:s,value:o,valueSpec:a.layer,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":()=>[],type:()=>_e({key:`${s}.type`,value:o.type,valueSpec:a.layer.type,style:t.style,styleSpec:t.styleSpec,object:o,objectKey:"type"}),filter:t=>Y(e.C({layerType:n},t)),layout:t=>Z({layer:o,key:t.key,value:t.value,valueSpec:{},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":t=>ie(e.C({layerType:n},t))}}),paint:t=>Z({layer:o,key:t.key,value:t.value,valueSpec:{},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":t=>te(e.C({layerType:n,layer:o},t))}})}})),i}function se(t){const i=t.value,o=t.key,s=e.B(i);return "string"!==s?[new e.V(o,i,`string expected, ${s} found`)]:[]}const re={promoteId:function({key:t,value:i}){if("string"===e.B(i))return se({key:t,value:i});{const e=[];for(const o in i)e.push(...se({key:`${t}.${o}`,value:i[o]}));return e}}};function ae(t){const i=t.value,o=t.key,s=t.styleSpec,r=t.style;if(!i.type)return [new e.V(o,i,'"type" is required')];const a=e.D(i.type);let n=[];switch(["vector","raster","raster-dem","raster-array"].includes(a)&&(i.url||i.tiles||n.push(new e.A(o,i,'Either "url" or "tiles" is required.'))),a){case"vector":case"raster":case"raster-dem":case"raster-array":return n=n.concat(Z({key:o,value:i,valueSpec:s[`source_${a.replace("-","_")}`],style:t.style,styleSpec:s,objectElementValidators:re})),n;case"geojson":if(n=Z({key:o,value:i,valueSpec:s.source_geojson,style:r,styleSpec:s,objectElementValidators:re}),i.cluster)for(const e in i.clusterProperties){const[t,s]=i.clusterProperties[e],r="string"==typeof t?[t,["accumulated"],["get",e]]:t;n.push(...X({key:`${o}.${e}.map`,value:s,expressionContext:"cluster-map"})),n.push(...X({key:`${o}.${e}.reduce`,value:r,expressionContext:"cluster-reduce"}));}return n;case"video":return Z({key:o,value:i,valueSpec:s.source_video,style:r,styleSpec:s});case"image":return Z({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 K({key:`${o}.type`,value:i.type,valueSpec:{values:ne(s)},style:r,styleSpec:s})}}function ne(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 le(t){const i=t.value,o=t.styleSpec,s=o.light,r=t.style;let a=[];const n=e.B(i);if(void 0===i)return a;if("object"!==n)return a=a.concat([new e.V("light",i,`object expected, ${n} found`)]),a;for(const t in i){const n=t.match(/^(.*)-transition$/);a=a.concat(n&&s[n[1]]&&s[n[1]].transition?_e({key:t,value:i[t],valueSpec:o.transition,style:r,styleSpec:o}):s[t]?_e({key:t,value:i[t],valueSpec:s[t],style:r,styleSpec:o}):[new e.V(t,i[t],`unknown property "${t}"`)]);}return a}function ce(t){const i=t.value;let o=[];if(!i)return o;const s=e.B(i);if("object"!==s)return o=o.concat([new e.V("light-3d",i,`object expected, ${s} found`)]),o;const r=t.styleSpec,a=r["light-3d"],n=t.key,l=t.style,c=t.style.lights;for(const t of ["type","id"])if(!(t in i))return o=o.concat([new e.V("light-3d",i,`missing property ${t} on light`)]),o;if(i.type&&c)for(let s=0;s<t.arrayIndex;s++){const t=e.D(i.type),r=c[s];e.D(r.type)===t&&o.push(new e.V(n,i.id,`duplicate light type "${i.type}", previously defined at line ${r.id.__line__}`));}const h=`properties_light_${i.type}`;if(!(h in r))return o=o.concat([new e.V("light-3d",i,`Invalid light type ${i.type}`)]),o;const u=r[h];for(const s in i)if("properties"===s){const a=i[s],n=e.B(a);if("object"!==n)return o=o.concat([new e.V("properties",a,`object expected, ${n} found`)]),o;for(const i in a)o=o.concat(u[i]?_e({key:i,value:a[i],valueSpec:u[i],style:l,styleSpec:r}):[new e.A(t.key,a[i],`unknown property "${i}"`)]);}else {const t=s.match(/^(.*)-transition$/);o=o.concat(t&&a[t[1]]&&a[t[1]].transition?_e({key:s,value:i[s],valueSpec:r.transition,style:l,styleSpec:r}):a[s]?_e({key:s,value:i[s],valueSpec:a[s],style:l,styleSpec:r}):[new e.A(s,i[s],`unknown property "${s}"`)]);}return o}function he(t){const i=t.value,o=t.key,s=t.style,r=t.styleSpec,a=r.terrain;let n=[];const l=e.B(i);if(void 0===i)return n;if("null"===l)return n;if("object"!==l)return n=n.concat([new e.V("terrain",i,`object expected, ${l} found`)]),n;for(const t in i){const o=t.match(/^(.*)-transition$/);n=n.concat(o&&a[o[1]]&&a[o[1]].transition?_e({key:t,value:i[t],valueSpec:r.transition,style:s,styleSpec:r}):a[t]?_e({key:t,value:i[t],valueSpec:a[t],style:s,styleSpec:r}):[new e.A(t,i[t],`unknown property "${t}"`)]);}if(i.source){const t=s.sources&&s.sources[i.source],r=t&&e.D(t.type);t?"raster-dem"!==r&&n.push(new e.V(o,i.source,`terrain cannot be used with a source of type ${String(r)}, it only be used with a "raster-dem" source type`)):n.push(new e.V(o,i.source,`source "${i.source}" not found`));}else n.push(new e.V(o,i,'terrain is missing required property "source"'));return n}function ue(t){const i=t.value,o=t.style,s=t.styleSpec,r=s.fog;let a=[];const n=e.B(i);if(void 0===i)return a;if("object"!==n)return a=a.concat([new e.V("fog",i,`object expected, ${n} found`)]),a;for(const t in i){const n=t.match(/^(.*)-transition$/);a=a.concat(n&&r[n[1]]&&r[n[1]].transition?_e({key:t,value:i[t],valueSpec:s.transition,style:o,styleSpec:s}):r[t]?_e({key:t,value:i[t],valueSpec:r[t],style:o,styleSpec:s}):[new e.A(t,i[t],`unknown property "${t}"`)]);}return a}const de={"*":()=>[],array:q,boolean:function(t){const i=t.value,o=t.key,s=e.B(i);return "boolean"!==s?[new e.V(o,i,`boolean expected, ${s} found`)]:[]},number:W,color:function(t){const i=t.key,o=t.value,s=e.B(o);return "string"!==s?[new e.V(i,o,`color expected, ${s} found`)]:null===e.U.parseCSSColor(o)?[new e.V(i,o,`color expected, "${o}" found`)]:[]},enum:K,filter:Y,function:$,layer:oe,object:Z,source:ae,model:e.Z,light:le,"light-3d":ce,terrain:he,fog:ue,string:se,formatted:function(e){return 0===se(e).length?[]:X(e)},resolvedImage:function(e){return 0===se(e).length?[]:X(e)},projection:function(t){const i=t.value,o=t.styleSpec,s=o.projection,r=t.style;let a=[];const n=e.B(i);if("object"===n)for(const e in i)a=a.concat(_e({key:e,value:i[e],valueSpec:s[e],style:r,styleSpec:o}));else "string"!==n&&(a=a.concat([new e.V("projection",i,`object or string expected, ${n} found`)]));return a},import:function(t){const{value:i,styleSpec:o}=t,{data:s,...r}=i;Object.defineProperty(r,"__line__",{value:i.__line__,enumerable:!1});let a=Z(e.C({},t,{value:r,valueSpec:o.import}));return ""===e.D(r.id)&&a.push(new e.V(`${t.key}.id`,r,"import id can't be an empty string")),s&&(a=a.concat(fe(s,o,{key:`${t.key}.data`}))),a}};function _e(t,i=!1){const o=t.value,s=t.valueSpec,r=t.styleSpec;if(s.expression&&e.X(e.D(o)))return $(t);if(s.expression&&e.J(e.K(o)))return X(t);if(s.type&&de[s.type]){const o=de[s.type](t);return !0===i&&o.length>0&&"array"===e.B(t.value)?X(t):o}return Z(e.C({},t,{valueSpec:s.type?r[s.type]:s}))}function pe(t){const i=t.value,o=t.key,s=se(t);return s.length||(-1===i.indexOf("{fontstack}")&&s.push(new e.V(o,i,'"glyphs" url must include a "{fontstack}" token')),-1===i.indexOf("{range}")&&s.push(new e.V(o,i,'"glyphs" url must include a "{range}" token'))),s}function fe(t,i=e._,o={}){return _e({key:o.key||"",value:t,valueSpec:i.$root,styleSpec:i,style:t,objectElementValidators:{glyphs:pe,"*":()=>[]}})}function me(t,i=e._){return Ie(fe(t,i))}const ge=e=>Ie(ae(e)),ve=e=>Ie(le(e)),xe=e=>Ie(ce(e)),ye=e=>Ie(he(e)),be=e=>Ie(ue(e)),we=e=>Ie(oe(e)),Te=e=>Ie(Y(e)),Ee=e=>Ie(te(e)),Se=e=>Ie(ie(e)),Ce=t=>Ie(e.Z(t));function Ie(e){return e.slice().sort(((e,t)=>e.line&&t.line?e.line-t.line:0))}function De(t,i){let o=!1;if(i&&i.length)for(const s of i)s instanceof e.A?e.w(s.message):(t.fire(new e.t(new Error(s.message))),o=!0);return o}let Re;class Ae extends e.E{constructor(t,i="flat"){super(),this._transitionable=new e.$(Re||(Re=new e.a0({anchor:new e.a1(e._.light.anchor),position:new e.a2(e._.light.position),color:new e.a1(e._.light.color),intensity:new e.a1(e._.light.intensity)}))),this.setLight(t,i),this._transitioning=this._transitionable.untransitioned();}getLight(){return this._transitionable.serialize()}setLight(e,t,i={}){this._validate(ve,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)&&De(this,t.call(me,e.l({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e._})))}}let Le=class extends e.E{constructor(t,i,o,s){super(),this.scope=o,this._transitionable=new e.$(new e.a0({source:new e.a1(e._.terrain.source),exaggeration:new e.a1(e._.terrain.exaggeration)}),o,s),this._transitionable.setTransitionOrValue(t,s),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=i;}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.a3(t)).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.a3(t)),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.a4}};const Pe=45,Me=65,ze=.05;function Oe(t,i,o,s){const r=e.a7(Pe,Me,o),[a,n]=Fe(t,s);let l=1-Math.min(1,Math.exp((i-a)/(n-a)*-6));return l*=l*l,l=Math.min(1,1.00747*l),l*r*t.alpha}function Fe(e,t){const i=.5/Math.tan(.5*t);return [e.range[0]+i,e.range[1]+i]}function Be(t,i,o,s,r){const a=e.a6.vec3.transformMat4([],[i,o,s],r.mercatorFogMatrix);return Oe(t,e.a6.vec3.length(a),r.pitch,r._fov)}function ke(t,i,o,s,r,a,n){const l=[[o,s,0],[r,s,0],[r,a,0],[o,a,0]];let c=Number.MAX_VALUE,h=-Number.MAX_VALUE;for(const t of l){const o=e.a6.vec3.transformMat4([],t,i),s=e.a6.vec3.length(o);c=Math.min(c,s),h=Math.max(h,s);}return [Oe(t,c,n.pitch,n._fov),Oe(t,h,n.pitch,n._fov)]}class Ne extends e.E{constructor(t,i,o,s){super();const r=new e.a0({range:new e.a1(e._.fog.range),color:new e.a1(e._.fog.color),"high-color":new e.a1(e._.fog["high-color"]),"space-color":new e.a1(e._.fog["space-color"]),"horizon-blend":new e.a1(e._.fog["horizon-blend"]),"star-intensity":new e.a1(e._.fog["star-intensity"]),"vertical-range":new e.a1(e._.fog["vertical-range"])});this._transitionable=new e.$(r,o,new Map(s)),this.set(t,s),this._transitioning=this._transitionable.untransitioned(),this._transform=i,this.properties=new e.a8(r),this.scope=o;}get state(){const t=this._transform,i="globe"===t.projection.name,o=e.a9(t.zoom),s=this.properties.get("range"),r=[.5,3];return {range:i?[e.aa(r[0],s[0],o),e.aa(r[1],s[1],o)]:s,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(t,i,o={}){if(this._validate(be,t,o))return;const s=e.l({},t);for(const t of Object.keys(e._.fog))void 0===s[t]&&(s[t]=e._.fog[t].default);this._options=s,this._transitionable.setTransitionOrValue(this._options,i);}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.a7(Pe,Me,t))*i.a}getOpacityAtLatLng(t,i){return this._transform.projection.supportsFog?function(t,i,o){const s=e.a5.fromLngLat(i),r=o.elevation?o.elevation.getAtPointOrZero(s):0;return Be(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 ke(this.state,i,0,0,e.ab,e.ab,this._transform)}getOpacityForBounds(e,t,i,o,s){return this._transform.projection.supportsFog?ke(this.state,e,t,i,o,s,this._transform):[1,1]}getFovAdjustedRange(e){return this._transform.projection.supportsFog?Fe(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.ac(r,i,r[2]/(r[2]-i[2]));}if(Be(this.state,s[0],s[1],0,this._transform)>=ze)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)&&De(this,t.call(me,e.l({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e._})))}}class Ue extends e.E{constructor(t,i,o,s){super(),this.scope=o,this._options=t,this.properties=new e.a8(i),this._transitionable=new e.$(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")}}let Ge,Ve;class je{constructor(e,t,i,o){this.screenBounds=e,this.cameraPoint=t,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=i,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,o);}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]),a=e.P.convert(t[1]);o=[r,a],s=e.ae(r,a).every((e=>i.isPointAboveHorizon(e)));}return new je(o,i.getCameraPoint(),s,i)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(t){return e.ae(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.ae(i,o,0,!1);return this.cameraPoint.y>o.y&&(this.cameraPoint.x>i.x&&this.cameraPoint.x<o.x?s.splice(3,0,this.cameraPoint):this.cameraPoint.x>=o.x?s[2]=this.cameraPoint:this.cameraPoint.x<=i.x&&(s[3]=this.cameraPoint)),e.af(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.ae(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=t.queryPadding/i._pixelsPerMercatorPixel+1,a=o?this._bufferedCameraMercator(r,i):this._bufferedScreenMercator(r,i);let n=t.tileID.wrap+(a.unwrapped?s:0);const l=a.polygon.map((i=>e.ag(t.tileTransform,i,n)));if(!e.ah(l,0,0,e.ab,e.ab))return;n=t.tileID.wrap+(this.screenGeometryMercator.unwrapped?s:0);const c=this.screenGeometryMercator.polygon.map((i=>e.ai(t.tileTransform,i,n))),h=c.map((t=>new e.P(t[0],t[1]))),u=i.getFreeCameraOptions().position||new e.a5(0,0,0),d=e.ai(t.tileTransform,u,n),_=c.map((t=>{const i=e.a6.vec3.sub(t,t,d);return e.a6.vec3.normalize(i,i),new e.aj(d,i)})),p=e.ak(t,1,i.zoom)*i._pixelsPerMercatorPixel;return {queryGeometry:this,tilespaceGeometry:h,tilespaceRays:_,bufferedTilespaceGeometry:l,bufferedTilespaceBounds:(f=e.al(l),f.min.x=e.ap(f.min.x,0,e.ab),f.min.y=e.ap(f.min.y,0,e.ab),f.max.x=e.ap(f.max.x,0,e.ab),f.max.y=e.ap(f.max.y,0,e.ab),f),tile:t,tileID:t.tileID,pixelToTileUnitsFactor:p};var f;}_bufferedScreenMercator(e,t){const i=qe(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=qe(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.a6.mat4.multiply([],i.pixelMatrix,i.globeMatrix),s=[0,-e.aq,0,1],r=[0,e.aq,0,1],a=[0,0,0,1];e.a6.vec4.transformMat4(s,s,o),e.a6.vec4.transformMat4(r,r,o),e.a6.vec4.transformMat4(a,a,o);const n=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.an(t,n)&&s[3]<a[3],h=e.an(t,l)&&r[3]<a[3];if(!c&&!h)return null;const u=function(e,t,i){for(let o=1;o<e.length;o++){const s=Ze(t.pointCoordinate3D(e[o-1]).x),r=Ze(t.pointCoordinate3D(e[o]).x);if(i<0){if(s<r)return {idx:o,t:-s/(r-1-s)}}else if(r<s)return {idx:o,t:(1-s)/(r+1-s)}}return null}(t,i,c?-1:1);if(!u)return null;const{idx:d,t:_}=u;let p=d>1?He(t.slice(0,d),i):[],f=d<t.length?He(t.slice(d),i):[];p=p.map((t=>new e.P(Ze(t.x),t.y))),f=f.map((t=>new e.P(Ze(t.x),t.y)));const m=[...p];0===m.length&&m.push(f[f.length-1]);const g=e.aa(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.a5(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;e<t.length-1;e++)t[e].x>s&&(s=t[e].x,r=e);for(let e=0;e<t.length-1;e++){const i=(r+e)%(t.length-1),s=t[i],a=t[i+1];Math.abs(s.x-a.x)>.5&&(s.x<a.x?(s.x+=1,0===i&&(t[t.length-1].x+=1)):(a.x+=1,i+1===t.length-1&&(t[0].x+=1)),o=!0);}const a=e.am(i.center.lng);return o&&a<Math.abs(a-1)&&t.forEach((e=>{e.x-=1;})),{polygon:t,unwrapped:o}}(He(t,i).map((t=>new e.P(Ze(t.x),t.y))),i);return {polygon:s.polygon.map((t=>new e.a5(t.x,t.y))),unwrapped:s.unwrapped}}}function He(t,i){return e.ao(t,(e=>{const t=i.pointCoordinate3D(e);e.x=t.x,e.y=t.y;}),1/256)}function Ze(e){return e<0?1+e%1:e%1}function qe(e){return 100*e|0}function We(t,i,o,s,r){const a=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 t of s.variants){if(null==t||"object"!=typeof t||t.constructor!==Object)return r(new Error("variant must be an object"));if(!Array.isArray(t.capabilities))return r(new Error("capabilities must be an array"));if(1===t.capabilities.length&&"meshopt"===t.capabilities[0]){s=e.l(s,t);break}}}const o=e.ar(e.l({},s,t),["tilejson","tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding","vector_layers","raster_layers","worldview_options","worldview_default","worldview"]);o.tiles=i.canonicalizeTileset(o,t.url),r(null,o);}},n=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)),a=s.every((e=>e===i));return r&&a?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 n?e.q.frame((()=>a(null,n))):t.url?e.n(i.transformRequest(i.normalizeSourceURL(t.url,null,o,s),e.R.Source),a):e.q.frame((()=>{const{data:e,...i}=t;a(null,i);}))}class $e{constructor(t,i,o){this.bounds=e.as.convert(this.validateBounds(t)),this.minzoom=i||0,this.maxzoom=o||24;}validateBounds(e){return Array.isArray(e)&&4===e.length?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(t){const i=Math.pow(2,t.z),o=Math.floor(e.am(this.bounds.getWest())*i),s=Math.floor(e.at(this.bounds.getNorth())*i),r=Math.ceil(e.am(this.bounds.getEast())*i),a=Math.ceil(e.at(this.bounds.getSouth())*i);return t.x>=o&&t.x<r&&t.y>=s&&t.y<a}}class Xe extends e.E{constructor(t,i,o,s){if(super(),this.id=t,this.dispatcher=o,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,e.l(this,e.ar(i,["url","scheme","tileSize","promoteId"])),this._options=e.l({type:"vector"},i),this._collectResourceTiming=!!i.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(s),this._tileWorkers={},this._deduped=new e.au;}load(t){this._loaded=!1,this.fire(new e.x("dataloading",{dataType:"source"}));const i=Array.isArray(this.map._language)?this.map._language.join():this.map._language,o=this.map.getWorldview();this._tileJSONRequest=We(this._options,this.map._requestManager,i,o,((s,r)=>{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.t(s));else if(r){if(e.l(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);}r.bounds&&(this.tileBounds=new $e(r.bounds,this.minzoom,this.maxzoom)),L(r.tiles,this.map._requestManager._customAccessToken),this.fire(new e.x("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.x("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.av(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 e.l({},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),a=this.map.style?this.map.style.getLut(this.scope):null,n=a?{image:a.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:n,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,pixelRatio:e.q.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:t.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:t.isExtraShadowCaster,tessellationStep:this.map._tessellationStep,scaleFactor:this.map.getScaleFactor()};if(this.hasWorldviews&&e.f(o)&&(l.worldview=this.map.getWorldview()||this.worldviewDefault,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.aw.call({deduped:this._deduped},l,((e,i)=>{e||!i?c.call(this,e):(l.data={cacheControl:i.cacheControl,expires:i.expires,rawData:i.rawData.slice(0)},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&&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.ax(this.dispatcher),i(null),void(t.reloadCallback&&(this.loadTile(t,t.reloadCallback),t.reloadCallback=null)))}}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.actor&&e.actor.send("abortTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope});}unloadTile(e,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 Je 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=e.l({type:"raster"},i),e.l(this,e.ar(i,["url","scheme","tileSize"]));}load(t){this._loaded=!1,this.fire(new e.x("dataloading",{dataType:"source"})),this._tileJSONRequest=We(this._options,this.map._requestManager,null,null,((i,o)=>{this._tileJSONRequest=null,this._loaded=!0,i?this.fire(new e.t(i)):o&&(e.l(this,o),o.raster_layers&&(this.rasterLayers=o.raster_layers,this.rasterLayerIds=this.rasterLayers.map((e=>e.id))),o.bounds&&(this.tileBounds=new $e(o.bounds,this.minzoom,this.maxzoom)),L(o.tiles),this.fire(new e.x("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.x("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.av(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 e.l({},this._options)}hasTile(e){return !this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(t,i){const o=e.q.devicePixelRatio>=2,s=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),o,this.tileSize);t.request=e.o(this.map._requestManager.transformRequest(s,e.R.Tile),((o,s,r,a)=>(delete t.request,t.aborted?(t.state="unloaded",i(null)):o?(t.state="errored",i(o)):s?(this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:r,expires:a}),t.setTexture(s,this.map.painter),t.state="loaded",e.ax(this.dispatcher),void i(null)):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(!0),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);}}class Ke extends Je{constructor(t,i,o,s){super(t,i,o,s),this.type="raster-array",this.maxzoom=22,this._options=e.l({type:"raster-array"},i);}triggerRepaint(e){const t=this.map.painter._terrain,i=this.map.style.getSourceCache(this.id);t&&t.enabled&&i&&t._clearRenderCacheForTile(i.id,e.tileID),this.map.triggerRepaint();}loadTile(t,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.requestParams=s,t.actor||(t.actor=this.dispatcher.getActor()),t.request=t.fetchHeader(void 0,((e,o,s,r)=>{if(delete t.request,t.aborted)return t.state="unloaded",i(null);if(e){if(20===e.code)return;return t.state="errored",i(e)}this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:s,expires:r}),t.state="empty",i(null);}));}unloadTile(t,i){const o=t.texture;o&&o instanceof e.T?(t.destroy(!0),this.map.painter.saveTileTexture(o)):(t.destroy(),t.flushQueues(),t._isHeaderLoaded=!1,delete t._mrt,delete t.textureDescriptor),t.fbo&&(t.fbo.destroy(),delete t.fbo),delete t.request,delete t.requestParams,delete t.neighboringTiles,t.state="unloaded";}prepareTile(t,i,o){t._isHeaderLoaded&&("empty"!==t.state&&(t.state="reloading"),t.fetchBand(i,o,((i,o)=>{if(i)return t.state="errored",this.fire(new e.t(i)),void this.triggerRepaint(t);o&&(t.setTexture(o,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.aB?r=i.paint.get("raster-array-band"):i instanceof e.aC&&(r=i.paint.get("raster-particle-array-band"));const a=r||this.getInitialBand(s);if(null!=a)if(t.textureDescriptor){if(!t.updateNeeded(s,a)||o)return Object.assign({},t.textureDescriptor,{texture:t.texture})}else this.prepareTile(t,s,a);}}const Ye={vector:Xe,raster:Je,"raster-dem":class extends Je{constructor(t,i,o,s){super(t,i,o,s),this.type="raster-dem",this.maxzoom=22,this._options=e.l({type:"raster-dem"},i),this.encoding=i.encoding||"mapbox";}loadTile(t,i){const o=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function s(e,o){e&&(t.state="errored",i(e)),o&&(t.dem=o,t.dem.onDeserialize(),t.needsHillshadePrepare=!0,t.needsDEMTextureUpload=!0,t.state="loaded",i(null));}t.request=e.o(this.map._requestManager.transformRequest(o,e.R.Tile),function(o,r,a,n){if(delete t.request,t.aborted)t.state="unloaded",i(null);else if(o)t.state="errored",i(o);else if(r){this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:a,expires:n});const i=ImageBitmap&&r instanceof ImageBitmap&&e.ay(),o=1-(r.width-e.az(r.width))/2;o<1||t.neighboringTiles||(t.neighboringTiles=this._getNeighboringTiles(t.tileID));const l=i?r:e.q.getImageData(r,o),c={uid:t.uid,coord:t.tileID,source:this.id,scope:this.scope,rawImageData:l,encoding:this.encoding,padding:o};t.actor&&"expired"!==t.state||(t.actor=this.dispatcher.getActor(),t.actor.send("loadDEMTile",c,s.bind(this),void 0,!0));}}.bind(this));}_getNeighboringTiles(t){const i=t.canonical,o=Math.pow(2,i.z),s=(i.x-1+o)%o,r=0===i.x?t.wrap-1:t.wrap,a=(i.x+1+o)%o,n=i.x+1===o?t.wrap+1:t.wrap,l={};return l[new e.aA(t.overscaledZ,r,i.z,s,i.y).key]={backfilled:!1},l[new e.aA(t.overscaledZ,n,i.z,a,i.y).key]={backfilled:!1},i.y>0&&(l[new e.aA(t.overscaledZ,r,i.z,s,i.y-1).key]={backfilled:!1},l[new e.aA(t.overscaledZ,t.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new e.aA(t.overscaledZ,n,i.z,a,i.y-1).key]={backfilled:!1}),i.y+1<o&&(l[new e.aA(t.overscaledZ,r,i.z,s,i.y+1).key]={backfilled:!1},l[new e.aA(t.overscaledZ,t.wrap,i.z,i.x,i.y+1).key]={backfilled:!1},l[new e.aA(t.overscaledZ,n,i.z,a,i.y+1).key]={backfilled:!1}),l}},"raster-array":Ke,geojson:class extends e.E{constructor(t,i,o,s){super(),this.id=t,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._loaded=!1,this.actor=o.getActor(),this.setEventedParent(s),this._data=i.data,this._options=e.l({},i),this._collectResourceTiming=i.collectResourceTiming,void 0!==i.maxzoom&&(this.maxzoom=i.maxzoom),void 0!==i.minzoom&&(this.minzoom=i.minzoom),i.type&&(this.type=i.type),i.attribution&&(this.attribution=i.attribution),this.promoteId=i.promoteId;const r=e.ab/this.tileSize;this.workerOptions=e.l({source:this.id,scope:this.scope,cluster:i.cluster||!1,geojsonVtOptions:{buffer:(void 0!==i.buffer?i.buffer:128)*r,tolerance:(void 0!==i.tolerance?i.tolerance:.375)*r,extent:e.ab,maxZoom:this.maxzoom,lineMetrics:i.lineMetrics||!1,generateId:i.generateId||!1},superclusterOptions:{maxZoom:void 0!==i.clusterMaxZoom?i.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,i.clusterMinPoints||2),extent:e.ab,radius:(void 0!==i.clusterRadius?i.clusterRadius:50)*r,log:!1,generateId:i.generateId||!1},clusterProperties:i.clusterProperties,filter:i.filter,dynamic:i.dynamic},i.workerOptions);}onAdd(e){this.map=e,this.setData(this._data);}setData(e){return this._data=e,this._updateWorkerData(),this}updateData(t){if(!this._options.dynamic)return this.fire(new e.t(new Error("Can't call updateData on a GeoJSON source with dynamic set to false.")));if("string"!=typeof t&&("Feature"===t.type&&(t={type:"FeatureCollection",features:[t]}),"FeatureCollection"!==t.type))return this.fire(new e.t(new Error("Data to update should be a feature or a feature collection.")));if(this._coalesce&&"string"!=typeof t&&"string"!=typeof this._data&&"FeatureCollection"===this._data.type){const e=new Map;for(const t of this._data.features)e.set(t.id,t);for(const i of t.features)e.set(i.id,i);this._data.features=[...e.values()];}else this._data=t;return this._updateWorkerData(!0),this}getClusterExpansionZoom(e,t){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:e,source:this.id,scope:this.scope},t),this}getClusterChildren(e,t){return this.actor.send("geojson.getClusterChildren",{clusterId:e,source:this.id,scope:this.scope},t),this}getClusterLeaves(e,t,i,o){return this.actor.send("geojson.getClusterLeaves",{source:this.id,scope:this.scope,clusterId:e,limit:t,offset:i},o),this}_updateWorkerData(t=!1){if(this._pendingLoad)return void(this._coalesce=!0);this.fire(new e.x("dataloading",{dataType:"source"})),this._loaded=!1;const i=e.l({append:t},this.workerOptions);i.scope=this.scope;const o=this._data;"string"==typeof o?(i.request=this.map._requestManager.transformRequest(e.q.resolveURL(o),e.R.Source),i.request.collectResourceTiming=this._collectResourceTiming):i.data=JSON.stringify(o),this._pendingLoad=this.actor.send(`${this.type}.loadData`,i,((i,o)=>{if(this._loaded=!0,this._pendingLoad=null,i)this.fire(new e.t(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.x("data",i)),this._partialReload=!1,this._metadataFired=!0;}this._coalesce&&(this._updateWorkerData(t),this._coalesce=!1);}));}loaded(){return this._loaded}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,a=this._partialReload,n={type:this.type,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,lut:r,scope:this.scope,pixelRatio:e.q.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,brightness:this.map.style&&this.map.style.getBrightness()||0,scaleFactor:this.map.getScaleFactor(),partial:a};t.request=this.actor.send(o,n,((e,s)=>a&&!s?(t.state="loaded",i(null)):(delete t.request,t.destroy(),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 e.l({},this._options,{type:this.type,data:this._data})}hasTransition(){return !1}},video:class extends e.aD{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.aE(this.urls,((t,i)=>{this._loaded=!0,t?this.fire(new e.t(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;t<i.start(0)||t>i.end(0)?this.fire(new e.t(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.aD,model:class extends e.E{constructor(e,t,i,o){super(),this.id=e,this.type="model",this.models=[],this._loaded=!1,this._options=t;}load(){const t=[];for(const i in this._options.models){const o=this._options.models[i],s=e.aG(this.map._requestManager.transformRequest(o.uri,e.R.Model).url).then((t=>{if(!t)return;const s=e.aH(t),r=new e.aI(i,o.position,o.orientation,s);r.computeBoundsAndApplyParent(),this.models.push(r);})).catch((t=>{this.fire(new e.t(new Error(`Could not load model ${i} from ${o.uri}: ${t.message}`)));}));t.push(s);}return Promise.allSettled(t).then((()=>{this._loaded=!0,this.fire(new e.x("data",{dataType:"source",sourceDataType:"metadata"}));})).catch((t=>{this.fire(new e.t(new Error(`Could not load models: ${t.message}`)));}))}onAdd(e){this.map=e,this.load();}hasTransition(){return !1}loaded(){return this._loaded}getModels(){return this.models}loadTile(e,t){}serialize(){return {type:"model"}}},"batched-model":class extends e.E{constructor(e,t,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();}load(t){this._loaded=!1,this.fire(new e.x("dataloading",{dataType:"source"}));const i=Array.isArray(this.map._language)?this.map._language.join():this.map._language,o=this.map.getWorldview();this._tileJSONRequest=We(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.t(s))):r&&(e.l(this,r),r.bounds&&(this.tileBounds=new $e(r.bounds,this.minzoom,this.maxzoom)),L(r.tiles,this.map._requestManager._customAccessToken),this.fire(new e.x("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.x("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,lut:null,maxZoom:null,promoteId:null,pixelRatio:null,scaleFactor:null};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 e.l({},this._options)}},canvas:class extends e.aD{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.t(new e.V(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new e.t(new e.V(`sources.${t}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new e.t(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.t(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.t(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.t(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint();},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1);},this._finishLoading());}getCanvas(){return this.canvas}onAdd(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.aF||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.t(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new e.t(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new $e(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),e.l(this,e.ar(i,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]));}serialize(){return e.ar(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new e.x("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.x("data",{dataType:"source",sourceDataType:"content"}));}loaded(){return this._loaded}onAdd(t){this.map=t,this._loaded=!1,this.fire(new e.x("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=>{20!==i.code&&(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(!0),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.av(this.id,this.scope);this.map.style.clearSource(t);}_update(){this.fire(new e.x("data",{dataType:"source",sourceDataType:"content"}));}}},Qe=function(t,i,o,s){const r=new Ye[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.aJ(["load","abort","unload","serialize","prepare"],r),r};function et(t,i){const o=e.a6.mat4.identity([]);return e.a6.mat4.scale(o,o,[.5*t.width,.5*-t.height,1]),e.a6.mat4.translate(o,o,[1,-1,0]),e.a6.mat4.multiply(o,o,t.calculateProjMatrix(i.toUnwrapped())),Float32Array.from(o)}function tt(t,i,o,s,r,a,n,l,c=!1){const h=t.tilesIn(o,l,c);h.sort(ot);const u=[];for(const e of h)u.push({wrappedTileID:e.tile.tileID.wrapped().key,queryResults:e.tile.queryRenderedFeatures(i,t._state,e,s,r,a,n,et(t.transform,e.tile.tileID),c)});const d=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]||{},a=t[i]=t[i]||[];for(const e of o)s[e.featureIndex]||(s[e.featureIndex]=!0,a.push(e));}}return t}(u);for(const i in d)d[i].forEach((o=>{const s=o.feature,r=s.layer;r&&"background"!==r.type&&"sky"!==r.type&&"slot"!==r.type&&(e.aK(i)||(s.source=r.source,r["source-layer"]&&(s.sourceLayer=r["source-layer"])),s.state=void 0!==s.id?t.getFeatureState(r["source-layer"],s.id):{});}));return d}function it(e,t){const i=e.getRenderableIds().map((t=>e.getTileByID(t))),o=[],s={};for(let e=0;e<i.length;e++){const r=i[e],a=r.tileID.canonical.key;s[a]||(s[a]=!0,r.querySourceFeatures(o,t));}return o}function ot(e,t){const i=e.tileID,o=t.tileID;return i.overscaledZ-o.overscaledZ||i.canonical.y-o.canonical.y||i.wrap-o.wrap||i.canonical.x-o.canonical.x}function st(e,t){const i={};if(!t)return i;for(const o of e){const e=o.layerIds.map((e=>t.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 rt=32,at=33,nt=new Uint16Array(8184);for(let e=0;e<2046;e++){let t=e+2,i=0,o=0,s=0,r=0,a=0,n=0;for(1&t?s=r=a=rt:i=o=n=rt;(t>>=1)>1;){const e=i+s>>1,l=o+r>>1;1&t?(s=i,r=o,i=a,o=n):(i=s,o=r,s=a,r=n),a=e,n=l;}const l=4*e;nt[l+0]=i,nt[l+1]=o,nt[l+2]=s,nt[l+3]=r;}const lt=new Uint16Array(2178),ct=new Uint8Array(1089),ht=new Uint16Array(1089);function ut(e){return 0===e?-.03125:32===e?.03125:0}const dt=(()=>({type:2,extent:e.ab,loadGeometry:()=>[[new e.P(0,0),new e.P(e.ab+1,0),new e.P(e.ab+1,e.ab+1),new e.P(0,e.ab+1),new e.P(0,0)]]}))();class _t{constructor(t,i,o,s,r){this.tileID=t,this.uid=e.aQ(),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);}registerFadeDuration(t){const i=t+this.timeAdded;i<e.q.now()||this.fadeEndTime&&i<this.fadeEndTime||(this.fadeEndTime=i);}wasRequested(){return "errored"===this.state||"loaded"===this.state||"reloading"===this.state}get tileTransform(){return this._tileTransform||(this._tileTransform=e.aL(this.tileID.canonical,this.projection)),this._tileTransform}loadVectorData(t,i,o){if(this.unloadVectorData(),this.state="loaded",t){t.featureIndex&&(this.latestFeatureIndex=t.featureIndex,t.rawTileData?(this.latestRawTileData=t.rawTileData,this.latestFeatureIndex.rawTileData=t.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=t.collisionBoxArray,this.buckets=st(t.buckets,i.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const i=this.buckets[t];if(i instanceof e.aS){if(this.hasSymbolBuckets=!0,!o)break;i.justReloaded=!0;}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const i=this.buckets[t];if(i instanceof e.aS&&i.hasRTLText){this.hasRTLText=!0,e.aT();break}}this.queryPadding=0;for(const e in this.buckets){const t=this.buckets[e],o=i.style.getOwnLayer(e);if(!o)continue;const s=o.queryRadius(t);this.queryPadding=Math.max(this.queryPadding,s);}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),t.lineAtlas&&(this.lineAtlas=t.lineAtlas),this._lastUpdatedBrightness=t.brightness;}else this.collisionBoxArray=new e.aR;}unloadVectorData(){if(this.hasData()){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded";}}loadModelData(e,t,i){e&&(e.resourceTiming&&(this.resourceTiming=e.resourceTiming),this.buckets={...this.buckets,...st(e.buckets,t.style)},e.featureIndex&&(this.latestFeatureIndex=e.featureIndex));}getBucket(e){return this.buckets[e.fqid]}upload(t){for(const e in this.buckets){const i=this.buckets[e];i.uploadPending()&&i.upload(t);}const i=t.gl,o=this.imageAtlas;if(o&&!o.uploaded){const s=!!Object.keys(o.patternPositions).length;this.imageAtlasTexture=new e.T(t,o.image,i.RGBA8,{useMipmap:s}),this.imageAtlas.uploaded=!0;}this.glyphAtlasImage&&(this.glyphAtlasTexture=new e.T(t,this.glyphAtlasImage,i.R8),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new e.T(t,this.lineAtlas.image,i.R8),this.lineAtlas.uploaded=!0);}prepare(e,t,i){if(this.imageAtlas&&this.imageAtlasTexture&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture,i),!t||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;const o=t.style.getBrightness();(this._lastUpdatedBrightness||o)&&(this._lastUpdatedBrightness&&o&&Math.abs(this._lastUpdatedBrightness-o)<.001||(this._lastUpdatedBrightness=o,this.updateBuckets(t)));}queryRenderedFeatures(e,t,i,o,s,r,a,n,l){return this.latestFeatureIndex&&(this.latestFeatureIndex.rawTileData||this.latestFeatureIndex.is3DTile)?this.latestFeatureIndex.query({tileResult:i,pixelPosMatrix:n,transform:a,filter:o,layers:s,availableImages:r,tileTransform:this.tileTransform},e,t):{}}querySourceFeatures(t,i){const o=this.latestFeatureIndex;if(!o||!o.rawTileData)return;const s=o.loadVTLayers(),r=i?i.sourceLayer:"",a=s._geojsonTileLayer||s[r];if(!a)return;const n=e.aU(i&&i.filter),{z:l,x:c,y:h}=this.tileID.canonical,u={z:l,x:c,y:h};for(let i=0;i<a.length;i++){const s=a.feature(i);if(n.needGeometry){const t=e.aV(s,!0);if(!n.filter(new e.a3(this.tileID.overscaledZ),t,this.tileID.canonical))continue}else if(!n.filter(new e.a3(this.tileID.overscaledZ),s))continue;const d=o.getId(s,r),_=new e.aW(s,l,c,h,d);_.tile=u,t.push(_);}}hasData(){return "loaded"===this.state||"reloading"===this.state||"expired"===this.state}patternsLoaded(){return !!this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(t){const i=this.expirationTime;if(t.cacheControl){const i=e.aX(t.cacheControl);i["max-age"]&&(this.expirationTime=Date.now()+1e3*i["max-age"]);}else t.expires&&(this.expirationTime=new Date(t.expires).getTime());if(this.expirationTime){const e=Date.now();let t=!1;if(this.expirationTime>e)t=!1;else if(i)if(this.expirationTime<i)t=!0;else {const o=this.expirationTime-i;o?this.expirationTime=e+Math.max(o,3e4):t=!0;}else t=!0;t?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0;}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-(new Date).getTime(),Math.pow(2,31)-1)}refreshFeatureState(e){this.latestFeatureIndex&&(this.latestFeatureIndex.rawTileData||this.latestFeatureIndex.is3DTile)&&e&&this.updateBuckets(e);}updateBuckets(t){if(!this.latestFeatureIndex)return;const i=this.latestFeatureIndex.loadVTLayers(),o=t.style.listImages(),s=t.style.getBrightness();for(const r in this.buckets){if(!t.style.hasLayer(r))continue;const a=this.buckets[r],n=a.layers[0],l=n.sourceLayer||"_geojsonTileLayer",c=i[l],h=t.style.getSourceCache(n.source,n.scope);let u={};h&&(u=h._state.getState(l,void 0)),a.update(u,c,o,this.imageAtlas&&this.imageAtlas.patternPositions||{},s),(a instanceof e.aY||a instanceof e.aZ)&&t._terrain&&t._terrain.enabled&&h&&a.programConfigurations.needsUpload&&t._terrain._clearRenderCacheForTile(h.id,this.tileID);const d=t&&t.style&&t.style.getOwnLayer(r);d&&(this.queryPadding=Math.max(this.queryPadding,d.queryRadius(a)));}}holdingForFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return !this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<e.q.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0;}setHoldDuration(t){this.symbolFadeHoldUntil=e.q.now()+t;}setTexture(t,i){const o=i.context,s=o.gl;this.texture=this.texture||i.getTileTexture(t.width),this.texture&&this.texture instanceof e.T?this.texture.update(t):(this.texture=new e.T(o,t,s.RGBA8,{useMipmap:!0}),this.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE));}setDependencies(e,t){const i={};for(const e of t)i[e]=!0;this.dependencies[e]=i;}hasDependency(e,t){for(const i of e){const e=this.dependencies[i];if(e)for(const i of t)if(e[i])return !0}return !1}clearQueryDebugViz(){}_makeDebugTileBoundsBuffers(t,i){if(!i||"mercator"===i.name||this._tileDebugBuffer)return;const o=e.a_(dt,this.tileID.canonical,this.tileTransform)[0],s=new e.a$,r=new e.b0;for(let e=0;e<o.length;e++){const{x:t,y:i}=o[e];s.emplaceBack(t,i),r.emplaceBack(e);}r.emplaceBack(0),this._tileDebugIndexBuffer=t.createIndexBuffer(r),this._tileDebugBuffer=t.createVertexBuffer(s,e.b1.members),this._tileDebugSegments=e.b2.simpleSegment(0,0,s.length,r.length);}_makeTileBoundsBuffers(t,i){if(this._tileBoundsBuffer||!i||"mercator"===i.name)return;const o=e.a_(dt,this.tileID.canonical,this.tileTransform)[0];let s,r;if(this.isRaster){const t=function(t,i){const o=e.aL(t,i),s=Math.pow(2,t.z);for(let r=0;r<at;r++)for(let a=0;a<at;a++){const n=e.aM((t.x+(a+ut(a))/rt)/s),l=e.aN((t.y+(r+ut(r))/rt)/s),c=i.project(n,l),h=r*at+a;lt[2*h+0]=Math.round((c.x*o.scale-o.x)*e.ab),lt[2*h+1]=Math.round((c.y*o.scale-o.y)*e.ab);}ct.fill(0),ht.fill(0);for(let e=2045;e>=0;e--){const t=4*e,i=nt[t+0],o=nt[t+1],s=nt[t+2],r=nt[t+3],a=i+s>>1,n=o+r>>1,l=a+n-o,c=n+i-a,h=o*at+i,u=r*at+s,d=n*at+a,_=Math.hypot((lt[2*h+0]+lt[2*u+0])/2-lt[2*d+0],(lt[2*h+1]+lt[2*u+1])/2-lt[2*d+1])>=16;ct[d]=ct[d]||(_?1:0),e<1022&&(ct[d]=ct[d]||ct[(o+c>>1)*at+(i+l>>1)]||ct[(r+c>>1)*at+(s+l>>1)]);}const r=new e.aO,a=new e.aP;let n=0;function l(t,i){const o=i*at+t;return 0===ht[o]&&(r.emplaceBack(lt[2*o+0],lt[2*o+1],t*e.ab/rt,i*e.ab/rt),ht[o]=++n),ht[o]-1}function c(e,t,i,o,s,r){const n=e+i>>1,h=t+o>>1;if(Math.abs(e-s)+Math.abs(t-r)>1&&ct[h*at+n])c(s,r,e,t,n,h),c(i,o,s,r,n,h);else {const n=l(e,t),c=l(i,o),h=l(s,r);a.emplaceBack(n,c,h);}}return c(0,0,rt,rt,rt,0),c(rt,rt,0,0,0,rt),{vertices:r,indices:a}}(this.tileID.canonical,i);s=t.vertices,r=t.indices;}else {s=new e.aO,r=new e.aP;for(const{x:e,y:t}of o)s.emplaceBack(e,t,0,0);const t=e.b3(s.int16,void 0,4);for(let e=0;e<t.length;e+=3)r.emplaceBack(t[e],t[e+1],t[e+2]);}this._tileBoundsBuffer=t.createVertexBuffer(s,e.b4.members),this._tileBoundsIndexBuffer=t.createIndexBuffer(r),this._tileBoundsSegments=e.b2.simpleSegment(0,0,s.length,r.length);}_makeGlobeTileDebugBuffers(t,i){const o=i.projection;if(!o||"globe"!==o.name||i.freezeTileCoverage)return;const s=this.tileID.canonical,r=e.b5(s,i),a=e.b6(r),n=e.a9(i.zoom);let l;n>0&&(l=e.a6.mat4.invert(new Float64Array(16),i.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(t,s,i,a,l,n),this._makeGlobeTileDebugTextBuffer(t,s,i,a,l,n);}_globePoint(t,i,o,s,r,a,n){let l=e.b7(t,i,o);if(a){const r=1<<o.z,c=e.am(s.center.lng),h=e.at(s.center.lat),u=(o.x+.5)/r-c;let d=0;u>.5?d=-1:u<-.5&&(d=1);let _=(t/e.ab+o.x)/r+d,p=(i/e.ab+o.y)/r;_=(_-c)*s._pixelsPerMercatorPixel+c,p=(p-h)*s._pixelsPerMercatorPixel+h;const f=[_*s.worldSize,p*s.worldSize,0];e.a6.vec3.transformMat4(f,f,a),l=e.b8(l,f,n);}return e.a6.vec3.transformMat4(l,l,r)}_makeGlobeTileDebugBorderBuffer(t,i,o,s,r,a){const n=new e.a$,l=new e.b0,c=new e.b9,h=(e,t,h,u,d)=>{const _=(h-e)/(d-1),p=(u-t)/(d-1),f=n.length;for(let h=0;h<d;h++){const u=e+h*_,d=t+h*p;n.emplaceBack(u,d);const m=this._globePoint(u,d,i,o,s,r,a);c.emplaceBack(m[0],m[1],m[2]),l.emplaceBack(f+h);}},u=e.ab;h(0,0,u,0,16),h(u,0,u,u,16),h(u,u,0,u,16),h(0,u,0,0,16),this._tileDebugIndexBuffer=t.createIndexBuffer(l),this._tileDebugBuffer=t.createVertexBuffer(n,e.b1.members),this._globeTileDebugBorderBuffer=t.createVertexBuffer(c,e.ba.members),this._tileDebugSegments=e.b2.simpleSegment(0,0,n.length,l.length);}_makeGlobeTileDebugTextBuffer(t,i,o,s,r,a){const n=e.ab/4,l=new e.a$,c=new e.aP,h=new e.b9,u=25;c.reserve(32),l.reserve(u),h.reserve(u);const d=(e,t)=>u*e+t;for(let e=0;e<u;e++){const t=e*n;for(let e=0;e<u;e++){const c=e*n;l.emplaceBack(c,t);const u=this._globePoint(c,t,i,o,s,r,a);h.emplaceBack(u[0],u[1],u[2]);}}for(let e=0;e<4;e++)for(let t=0;t<4;t++){const i=d(e,t),o=d(e,t+1),s=d(e+1,t),r=d(e+1,t+1);c.emplaceBack(i,o,s),c.emplaceBack(s,o,r);}this._tileDebugTextIndexBuffer=t.createIndexBuffer(c),this._tileDebugTextBuffer=t.createVertexBuffer(l,e.b1.members),this._globeTileDebugTextBuffer=t.createVertexBuffer(h,e.ba.members),this._tileDebugTextSegments=e.b2.simpleSegment(0,0,u,32);}destroy(t=!1){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&(this.imageAtlasTexture.destroy(),delete this.imageAtlasTexture),this.glyphAtlasTexture&&(this.glyphAtlasTexture.destroy(),delete this.glyphAtlasTexture),this.lineAtlasTexture&&(this.lineAtlasTexture.destroy(),delete this.lineAtlasTexture),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),!t&&this.texture&&this.texture instanceof e.T&&(this.texture.destroy(),delete this.texture),this.hillshadeFBO&&(this.hillshadeFBO.destroy(),delete this.hillshadeFBO),this.dem&&delete this.dem,this.neighboringTiles&&delete this.neighboringTiles,this.demTexture&&(this.demTexture.destroy(),delete this.demTexture),this.rasterParticleState&&(this.rasterParticleState.destroy(),delete this.rasterParticleState),this.latestFeatureIndex=null,this.state="unloaded";}}e.bb.setPbf(e.bc);class pt extends _t{constructor(e,t,i,o,s){super(e,t,i,o,s),this._workQueue=[],this._fetchQueue=[],this._isHeaderLoaded=!1;}setTexture(t,i){const o=i.context,s=o.gl;this.texture=this.texture||i.getTileTexture(t.width),this.texture&&this.texture instanceof e.T?this.texture.update(t,{premultiply:!1}):this.texture=new e.T(o,t,s.RGBA8,{premultiply:!1});}flushQueues(){for(;this._workQueue.length;)this._workQueue.pop()();for(;this._fetchQueue.length;)this._fetchQueue.pop()();}fetchHeader(t=16384,i){const o=this._mrt=new e.bb(30),s=Object.assign({},this.requestParams,{headers:{Range:"bytes=0-"+(t-1)}});return this.entireBuffer=null,this.request=e.bd(s,((e,s,r,a)=>{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].last_byte);s.byteLength>=n&&(this.entireBuffer=s),i(null,this.entireBuffer||s,r,a);}catch(e){i(e);}})),this.request}fetchBand(t,i,o){const s=this._mrt;if(!this._isHeaderLoaded||!s)return void o(new Error("Tile header is not ready"));const r=this.actor;if(!r)return void o(new Error("Can't fetch tile band without an actor"));let a;const n=(e,s)=>{a.complete(e,s),e?o(e):(this.updateTextureDescriptor(t,i),o(null,this.textureDescriptor&&this.textureDescriptor.img));},l=(e,t)=>{if(e)return o(e);const i=r.send("decodeRasterArray",{buffer:t,task:a},n,void 0,!0);this._workQueue.push((()=>{i&&i.cancel(),a.cancel();}));},c=s.getLayer(t);if(!c)return void o(new Error(`Unknown sourceLayer "${t}"`));if(c.hasDataForBand(i))return this.updateTextureDescriptor(t,i),void o(null,this.textureDescriptor?this.textureDescriptor.img:null);const h=c.getDataRange([i]);if(a=s.createDecodingTask(h),!a||a.tasks.length)if(this.flushQueues(),this.entireBuffer)l(null,this.entireBuffer.slice(h.firstByte,h.lastByte+1));else {const t=Object.assign({},this.requestParams,{headers:{Range:`bytes=${h.firstByte}-${h.lastByte}`}}),i=e.bd(t,l);this._fetchQueue.push((()=>{i.cancel(),a.cancel();}));}else o(null);}updateNeeded(e,t){return (!this.textureDescriptor||this.textureDescriptor.band!==t||this.textureDescriptor.layer!==e)&&"errored"!==this.state}updateTextureDescriptor(t,i){if(!this._mrt)return;const o=this._mrt.getLayer(t);if(!o||!o.hasBand(i)||!o.hasDataForBand(i))return;const{bytes:s,tileSize:r,buffer:a,offset:n,scale:l}=o.getBandView(i),c=r+2*a,h={data:s,width:c,height:c},u=this.texture;u&&u instanceof e.T&&u.update(h,{premultiply:!1}),this.textureDescriptor={layer:t,band:i,img:h,buffer:a,offset:n,tileSize:r,format:o.pixelFormat,mix:[l,256*l,65536*l,16777216*l]};}}class ft{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(t,i,o){const s=String(i);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][s]=this.stateChanges[t][s]||{},e.l(this.stateChanges[t][s],o),null===this.deletedStates[t]){this.deletedStates[t]={};for(const e in this.state[t])e!==s&&(this.deletedStates[t][e]=null);}else if(this.deletedStates[t]&&null===this.deletedStates[t][s]){this.deletedStates[t][s]={};for(const e in this.state[t][s])o[e]||(this.deletedStates[t][s][e]=null);}else for(const e in o)this.deletedStates[t]&&this.deletedStates[t][s]&&null===this.deletedStates[t][s][e]&&delete this.deletedStates[t][s][e];}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(t,i){const o=this.state[t]||{},s=this.stateChanges[t]||{},r=this.deletedStates[t];if(null===r)return {};if(void 0!==i){const t=String(i),a=e.l({},o[t],s[t]);if(r){const e=r[i];if(null===e)return {};for(const t in e)delete a[t];}return a}const a=e.l({},o,s);if(r)for(const e in r)delete a[e];return a}initializeTileState(e,t){e.refreshFeatureState(t);}coalesceChanges(t,i){const o={};for(const t in this.stateChanges){this.state[t]=this.state[t]||{};const i={};for(const o in this.stateChanges[t])this.state[t][o]||(this.state[t][o]={}),e.l(this.state[t][o],this.stateChanges[t][o]),i[o]=this.state[t][o];o[t]=i;}for(const t in this.deletedStates){this.state[t]=this.state[t]||{};const i={};if(null===this.deletedStates[t])for(const e in this.state[t])i[e]={},this.state[t][e]={};else for(const e in this.deletedStates[t]){if(null===this.deletedStates[t][e])this.state[t][e]={};else if(this.state[t][e])for(const i of Object.keys(this.deletedStates[t][e]))delete this.state[t][e][i];i[e]=this.state[t][e];}o[t]=o[t]||{},e.l(o[t],i);}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(o).length)for(const e in t)t[e].refreshFeatureState(i);}}class gt 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 ft(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&&"raster"===this._source._dataType;}onAdd(e){this.map=e,this._minTileCacheSize=void 0===this._minTileCacheSize&&e?e._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&e?e._maxTileCacheSize:this._maxTileCacheSize;}loaded(){if(this._sourceErrored)return !0;if(!this._sourceLoaded)return !1;if(!this._source.loaded())return !1;for(const e in this._tiles){const t=this._tiles[e];if("loaded"!==t.state&&"errored"!==t.state)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),i.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope);}}getIds(){return e.be(this._tiles).map((e=>e.tileID)).sort(vt).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),a=new e.P(s.canonical.x,s.canonical.y)._rotate(this.transform.angle);return o.overscaledZ-s.overscaledZ||a.y-r.y||a.x-r.x})).map((e=>e.tileID.key)):o.map((e=>e.tileID)).sort(vt).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){if(s)if(t.state="errored",404!==s.status)this._source.fire(new e.t(s,{tile:t}));else {if(this._source.fire(new e.x("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id,tile:t})),!(t.tileID.key in this._loadedParentTiles))return;if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const e=this.map.painter.terrain;this.update(this.transform,e.getScaledDemTileSize(),!0),e.resetTileLookupCache(this.id);}else this.update(this.transform);}else t.timeAdded=e.q.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),this._source.fire(new e.x("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id}));}_backfillDEM(e){const t=this.getRenderableIds();for(let o=0;o<t.length;o++){const s=t[o];if(e.neighboringTiles&&e.neighboringTiles[s]){const t=this.getTileByID(s);i(e,t),i(t,e);}}function i(e,t){if(!e.dem||e.dem.borderReady)return;e.needsHillshadePrepare=!0,e.needsDEMTextureUpload=!0;let i=t.tileID.canonical.x-e.tileID.canonical.x;const o=t.tileID.canonical.y-e.tileID.canonical.y,s=Math.pow(2,e.tileID.canonical.z),r=t.tileID.key;0===i&&0===o||Math.abs(o)>1||(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 a=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()&&(a=e);}let n=a;for(;n.overscaledZ>t;)if(n=n.scaledTo(n.overscaledZ-1),e[n.key]){o[a.key]=a;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,a="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,r):r;this._cache.setMaxSize(a);}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){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 r="batched-model"===this._source.type;let a,n=this._source.maxzoom;const l=this.map&&this.map.painter?this.map.painter._terrain:null;if(l&&l.sourceCache===this&&l.attenuationRange()){const e=l.attenuationRange()[0],t=Math.floor(e)-Math.log2(l.getDemUpscale());n>t&&(n=t);}if(this.used||this.usedForTerrain){if(this._source.tileID)a=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new e.aA(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:n,roundZoom:this._source.roundZoom&&!o,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:r}),this._source.minzoom<=1&&"globe"===t.projection.name&&(a.push(new e.aA(1,0,1,0,0)),a.push(new e.aA(1,0,1,1,0)),a.push(new e.aA(1,0,1,0,1)),a.push(new e.aA(1,0,1,1,1)));}else if(a=t.coveringTiles({tileSize:i||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:n,roundZoom:this._source.roundZoom&&!o,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:r}),this._source.hasTile){const e=this._source.hasTile.bind(this._source);a=a.filter((t=>e(t)));}}else a=[];if(a.length>0&&this.castsShadows&&s&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!xt(this._source.type)){const e=t.coveringZoomLevel({tileSize:i||this._source.tileSize,roundZoom:this._source.roundZoom&&!o}),n=Math.min(e,this._source.maxzoom);if(r){const e=t.extendTileCover(a,n);for(const t of e)a.push(t);}else {const e=t.extendTileCover(a,n,s);for(const t of e)this._shadowCasterTiles[t.key]=!0,a.push(t);}}const c=this._updateRetainedTiles(a);if(xt(this._source.type)&&0!==a.length){const t={},i={},o=Object.keys(c);for(const s of o){const o=c[s],r=this._tiles[s];if(!r||r.fadeEndTime&&r.fadeEndTime<=e.q.now())continue;const a=this.findLoadedParent(o,Math.max(o.overscaledZ-gt.maxOverzooming,this._source.minzoom));a&&(this._addTile(a.tileID),t[a.tileID.key]=a.tileID),i[s]=o;}const s=a[a.length-1].overscaledZ;for(const e in this._tiles){const t=this._tiles[e];if(c[e]||!t.hasData())continue;let o=t.tileID;for(;o.overscaledZ>s;){o=o.scaledTo(o.overscaledZ-1);const s=this._tiles[o.key];if(s&&s.hasData()&&i[o.key]){c[e]=t.tileID;break}}}for(const e in t)c[e]||(this._coveredTiles[e]=!0,c[e]=t[e]);}for(const e in c)this._tiles[e].clearFadeHold();const h=e.bf(this._tiles,c);for(const e of h){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-gt.maxOverzooming,this._source.minzoom),a=Math.max(s+gt.maxUnderzooming,this._source.minzoom),n={};for(const i of e){const e=this._addTile(i);t[i.key]=i,e.hasData()||o<this._source.maxzoom&&(n[i.key]=i);}this._retainLoadedChildren(n,o,a,t);for(const o of e){let e=this._tiles[o.key];if(e.hasData())continue;if(o.canonical.z>=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 a=o.overscaledZ-1;a>=r;--a){const r=o.scaledTo(a);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 pt(t,o,this.transform.tileZoom,e,this._isRaster):new _t(t,o,this.transform.tileZoom,e,this._isRaster),this._loadTile(i,this._tileLoaded.bind(this,i,t.key,i.state));}return i?(i.uses++,this._tiles[t.key]=i,o||this._source.fire(new e.x("dataloading",{tile:i,coord:i.tileID,dataType:"source"})),i):null}_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 a="globe"===r.projection.name,n=e.am(r.center.lng);for(const l in this._tiles){const c=this._tiles[l];if(o&&c.clearQueryDebugViz(),c.holdingForFade())continue;let h;if(a){const t=c.tileID.canonical;if(0===t.z){const i=[Math.abs(e.ap(n,...yt(t,-1))-n),Math.abs(e.ap(n,...yt(t,1))-n)];h=[0,2*i.indexOf(Math.min(...i))-1];}else {const i=[Math.abs(e.ap(n,...yt(t,-1))-n),Math.abs(e.ap(n,...yt(t,0))-n),Math.abs(e.ap(n,...yt(t,1))-n)];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<<e.canonical.z);s[e.key]=((e.canonical.x+.5)*t+e.wrap-i[0])*o[0]+((e.canonical.y+.5)*t-i[1])*o[1]-i[2]*o[2];}return t.sort(((e,t)=>s[e.key]-s[t.key])),t}hasTransition(){if(this._source.hasTransition())return !0;if(xt(this._source.type))for(const t in this._tiles){const i=this._tiles[t];if(void 0!==i.fadeEndTime&&i.fadeEndTime>=e.q.now())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,a=this.usedForTerrain&&r?r.getScaledDemTileSize():this._source.tileSize;for(const e of s){const t=e.coveringTiles({tileSize:a,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 n=Array.from(o.values());e.bg(n,((e,t)=>{const i=new _t(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(i,(e=>{"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),t(e,i);}));}),i);}}function vt(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 xt(e){return "raster"===e||"image"===e||"video"===e||"custom"===e}function yt(e,t){const i=1<<e.z;return [e.x/i+t,(e.x+1)/i+t]}gt.maxOverzooming=10,gt.maxUnderzooming=3;class bt{constructor(e){this.style=e,this.layersGotHidden=!1,this.layers=[];}processLayersChanged(){this.layers=[];const e=!1,t=!1;for(const i in this.style._mergedLayers){const o=this.style._mergedLayers[i];if("fill-extrusion"===o.type)this.layers.push({layer:o,visible:e,visibilityChanged:t});else if("model"===o.type){const i=this.style.getLayerSource(o);i&&"batched-model"===i.type&&this.layers.push({layer:o,visible:e,visibilityChanged:t});}}}onNewFrame(e){this.layersGotHidden=!1;for(const t of this.layers){const i=t.layer;let o=!1;"fill-extrusion"===i.type?o=!i.isHidden(e)&&i.paint.get("fill-extrusion-opacity")>0:"model"===i.type&&(o=!i.isHidden(e)&&i.paint.get("model-opacity")>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);let r=o?o.getTile(t):null;if(!r&&o&&t.canonical.z>o.getSource().minzoom){let e=t.scaledTo(Math.min(o.getSource().maxzoom,t.overscaledZ-1));for(;e.overscaledZ>=o.getSource().minzoom&&(r=o.getTile(e),!r&&0!==e.overscaledZ);)e=e.scaledTo(e.overscaledZ-1);}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.symbolInstances.length;o++){const s=e.symbolInstances.get(o),r=s.zOffset,a=this._getHeightAtTileOffset(t,s.tileAnchorX,s.tileAnchorY);s.zOffset=a!==Number.NEGATIVE_INFINITY?a:r,i||r===s.zOffset||(i=!0),e.hasAnyZOffset||0===s.zOffset||(e.hasAnyZOffset=!0);}i&&(e.zOffsetBuffersNeedUpload=!0,e.zOffsetSortDirty=!0);}_mapCoordToOverlappingTile(t,i,o,s){let r=i,a=o;if(t.canonical.z!==s.canonical.z){const n=s.canonical,l=1/(1<<t.canonical.z-n.z);r=(i+t.canonical.x*e.ab)*l-n.x*e.ab|0,a=(o+t.canonical.y*e.ab)*l-n.y*e.ab|0;}return {tileX:r,tileY:a}}_getHeightAtTileOffset(e,t,i){let o,s;for(let r=0;r<this.layers.length;++r){if("fill-extrusion"!==this.layers[r].layer.type)continue;const{bucket:a,tileID:n,verticalScale:l}=this.currentBuildingBuckets[r];if(!a)continue;const{tileX:c,tileY:h}=this._mapCoordToOverlappingTile(e,t,i,n),u=a.getHeightAtTileCoord(c,h);u&&void 0!==u.height&&(u.hidden?o=u.height:s=Math.max(u.height*l,s||0));}if(void 0!==s)return s;for(let s=0;s<this.layers.length;++s){const r=this.layers[s];if("model"!==r.layer.type||!r.visible)continue;const{bucket:a,tileID:n}=this.currentBuildingBuckets[s];if(!a)continue;const{tileX:l,tileY:c}=this._mapCoordToOverlappingTile(e,t,i,n),h=a.getHeightAtTileCoord(l,c);if(h&&!h.hidden)return void 0===h.height&&void 0!==o?Math.min(h.maxHeight,o)*h.verticalScale:h.height?h.height*h.verticalScale:Number.NEGATIVE_INFINITY}return this.layersGotHidden?0:Number.NEGATIVE_INFINITY}}function wt(t,i){const o={};for(const e in t)"ref"!==e&&(o[e]=t[e]);return e.bh.forEach((e=>{e in i&&(o[e]=i[e]);})),o}function Tt(e){e=e.slice();const t=Object.create(null);for(let i=0;i<e.length;i++)t[e[i].id]=e[i];for(let i=0;i<e.length;i++)"ref"in e[i]&&(e[i]=wt(e[i],t[e[i].ref]));return e}const Et={setStyle:"setStyle",addLayer:"addLayer",removeLayer:"removeLayer",setPaintProperty:"setPaintProperty",setLayoutProperty:"setLayoutProperty",setSlot:"setSlot",setFilter:"setFilter",addSource:"addSource",removeSource:"removeSource",setGeoJSONSourceData:"setGeoJSONSourceData",setLayerZoomRange:"setLayerZoomRange",setLayerProperty:"setLayerProperty",setCenter:"setCenter",setZoom:"setZoom",setBearing:"setBearing",setPitch:"setPitch",setSprite:"setSprite",setGlyphs:"setGlyphs",setTransition:"setTransition",setLight:"setLight",setTerrain:"setTerrain",setFog:"setFog",setCamera:"setCamera",setLights:"setLights",setProjection:"setProjection",addImport:"addImport",removeImport:"removeImport",updateImport:"updateImport"};function St(e,t,i){i.push({command:Et.addSource,args:[e,t[e]]});}function Ct(e,t,i){t.push({command:Et.removeSource,args:[e]}),i[e]=!0;}function It(e,t,i,o){Ct(e,i,o),St(e,t,i);}function Dt(t,i,o){let s;for(s in t[o])if(t[o].hasOwnProperty(s)&&"data"!==s&&!e.bi(t[o][s],i[o][s]))return !1;for(s in i[o])if(i[o].hasOwnProperty(s)&&"data"!==s&&!e.bi(t[o][s],i[o][s]))return !1;return !0}function Rt(t,i,o,s,r,a){let n;for(n in i=i||{},t=t||{})t.hasOwnProperty(n)&&(e.bi(t[n],i[n])||o.push({command:a,args:[s,n,i[n],r]}));for(n in i)i.hasOwnProperty(n)&&!t.hasOwnProperty(n)&&(e.bi(t[n],i[n])||o.push({command:a,args:[s,n,i[n],r]}));}function At(e){return e.id}function Lt(e,t){return e[t.id]=t,e}class Pt{constructor(e,t){this.reset(e,t);}reset(e,t){this.points=e||[],this._distances=[0];for(let e=1;e<this.points.length;e++)this._distances[e]=this._distances[e-1]+this.points[e].dist(this.points[e-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(t||0,.5*this.length),this.paddedLength=this.length-2*this.padding;}lerp(t){if(1===this.points.length)return this.points[0];t=e.ap(t,0,1);let i=1,o=this._distances[i];const s=t*this.paddedLength+this.padding;for(;o<s&&i<this._distances.length;)o=this._distances[++i];const r=i-1,a=this._distances[r],n=o-a,l=n>0?(s-a)/n:0;return this.points[r].mult(1-l).add(this.points[i].mult(l))}}class Mt{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;e<this.xCellCount*this.yCellCount;e++)o.push([]),s.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=e,this.height=t,this.xScale=this.xCellCount/e,this.yScale=this.yCellCount/t,this.boxUid=0,this.circleUid=0;}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(e,t,i,o,s){this._forEachCell(t,i,o,s,this._insertBoxCell,this.boxUid++),this.boxKeys.push(e),this.bboxes.push(t),this.bboxes.push(i),this.bboxes.push(o),this.bboxes.push(s);}insertCircle(e,t,i,o){this._forEachCell(t-o,i-o,t+o,i+o,this._insertCircleCell,this.circleUid++),this.circleKeys.push(e),this.circles.push(t),this.circles.push(i),this.circles.push(o);}_insertBoxCell(e,t,i,o,s,r){this.boxCells[s].push(r);}_insertCircleCell(e,t,i,o,s,r){this.circleCells[s].push(r);}_query(e,t,i,o,s,r){if(i<0||e>this.width||o<0||t>this.height)return !s&&[];const a=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=o){if(s)return !0;for(let e=0;e<this.boxKeys.length;e++)a.push({key:this.boxKeys[e],x1:this.bboxes[4*e],y1:this.bboxes[4*e+1],x2:this.bboxes[4*e+2],y2:this.bboxes[4*e+3]});for(let e=0;e<this.circleKeys.length;e++){const t=this.circles[3*e],i=this.circles[3*e+1],o=this.circles[3*e+2];a.push({key:this.circleKeys[e],x1:t-o,y1:i-o,x2:t+o,y2:i+o});}return r?a.filter(r):a}return this._forEachCell(e,t,i,o,this._queryCell,a,{hitTest:s,seenUids:{box:{},circle:{}}},r),s?a.length>0:a}_queryCircle(e,t,i,o,s){const r=e-i,a=e+i,n=t-i,l=t+i;if(a<0||r>this.width||l<0||n>this.height)return !o&&[];const c=[];return this._forEachCell(r,n,a,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,a,n){const l=a.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]&&(!n||n(this.boxKeys[h]))){if(a.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)&&(!n||n(this.circleKeys[c]))){if(a.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,a,n){const l=a.circle,c=a.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])&&(!n||n(this.boxKeys[t])))return r.push(!0),!0}}const u=this.circleCells[s];if(null!==u){const e=this.circles;for(const t of u)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)&&(!n||n(this.circleKeys[t])))return r.push(!0),!0}}}_forEachCell(e,t,i,o,s,r,a,n){const l=this._convertToXCellCoord(e),c=this._convertToYCellCoord(t),h=this._convertToXCellCoord(i),u=this._convertToYCellCoord(o);for(let d=l;d<=h;d++)for(let l=c;l<=u;l++)if(s.call(this,e,t,i,o,this.xCellCount*l+d,r,a,n))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 a=o-e,n=s-t,l=i+r;return l*l>a*a+n*n}_circleAndRectCollide(e,t,i,o,s,r,a){const n=(r-o)/2,l=Math.abs(e-(o+n));if(l>n+i)return !1;const c=(a-s)/2,h=Math.abs(t-(s+c));if(h>c+i)return !1;if(l<=n||h<=c)return !0;const u=l-n,d=h-c;return u*u+d*d<=i*i}}const zt={unknown:0,flipRequired:1,flipNotRequired:2},Ot=Math.tan(85*Math.PI/180);function Ft(t,i,o,s,r,a,n){const l=e.a6.mat4.create();if(o)if("globe"===a.name){const t=e.bj(r,i);e.a6.mat4.multiply(l,l,t);}else {const t=e.a6.mat2.invert([],n);l[0]=t[0],l[1]=t[1],l[4]=t[2],l[5]=t[3],s||e.a6.mat4.rotateZ(l,l,r.angle);}else e.a6.mat4.multiply(l,r.labelPlaneMatrix,t);return l}function Bt(e,t,i,o,s,r,a){const n=Ft(e,t,i,o,s,r,a);return "globe"===r.name&&i||(n[2]=n[6]=n[10]=n[14]=0),n}function kt(t,i,o,s,r,a,n){if(o){if("globe"===a.name){const l=Ft(t,i,o,s,r,a,n);return e.a6.mat4.invert(l,l),e.a6.mat4.multiply(l,t,l),l}{const i=e.a6.mat4.clone(t),o=e.a6.mat4.identity([]);return o[0]=n[0],o[1]=n[1],o[4]=n[2],o[5]=n[3],e.a6.mat4.multiply(i,i,o),s||e.a6.mat4.rotateZ(i,i,-r.angle),i}}return r.glCoordMatrix}function Nt(t,i,o,s){const r=[t,i,o,1];o?e.a6.vec4.transformMat4(r,r,s):Jt(r,r,s);const a=r[3];return r[0]/=a,r[1]/=a,r[2]/=a,r}function Ut(e,t){return Math.min(.5+e/t*.5,1.5)}function Gt(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 Vt(t,i,o,s,r,a,n,l,c,h){const u=o.transform,d=s?t.textSizeData:t.iconSizeData,_=e.bk(d,o.transform.zoom),p="globe"===u.projection.name,f=[256/o.width*2+1,256/o.height*2+1],m=s?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;m.clear();let g=null;p&&(g=s?t.text.globeExtVertexArray:t.icon.globeExtVertexArray);const v=t.lineVertexArray,x=s?t.text.placedSymbolArray:t.icon.placedSymbolArray,y=o.transform.width/o.transform.height;let b,w=!1;for(let s=0;s<x.length;s++){const p=x.get(s),{numGlyphs:T,writingMode:E}=p;if(E!==e.bl.vertical||w||b===e.bl.horizontal||(w=!0),b=E,(p.hidden||E===e.bl.vertical)&&!w){Xt(T,m);continue}w=!1;const S=new e.P(p.tileAnchorX,p.tileAnchorY);let{x:C,y:I,z:D}=u.projection.projectTilePoint(S.x,S.y,h.canonical);if(c){const[e,t,i]=c(S);C+=e,I+=t,D+=i;}const R=[C,I,D,1];if(e.a6.vec4.transformMat4(R,R,i),!Gt(R,f)){Xt(T,m);continue}const A=R[3],L=Ut(o.transform.getCameraToCenterDistance(u.projection),A),P=e.bm(d,_,p),M=n?P/L:P*L,z=Nt(C,I,D,r);if(z[3]<=0){Xt(T,m);continue}let O={};const F=n?null:c,B=Zt(p,M,!1,l,i,r,a,t.glyphOffsetArray,v,m,g,z,S,O,y,F,u.projection,h,n);w=B.useVertical,F&&B.needsFlipping&&(O={}),(B.notEnoughRoom||w||B.needsFlipping&&Zt(p,M,!0,l,i,r,a,t.glyphOffsetArray,v,m,g,z,S,O,y,F,u.projection,h,n).notEnoughRoom)&&Xt(T,m);}s?(t.text.dynamicLayoutVertexBuffer.updateData(m),g&&t.text.globeExtVertexBuffer&&t.text.globeExtVertexBuffer.updateData(g)):(t.icon.dynamicLayoutVertexBuffer.updateData(m),g&&t.icon.globeExtVertexBuffer&&t.icon.globeExtVertexBuffer.updateData(g));}function jt(e,t,i,o,s,r,a,n,l,c,h,u,d,_,p,f){const{lineStartIndex:m,glyphStartIndex:g,segment:v}=n,x=g+n.numGlyphs,y=m+n.lineLength,b=t.getoffsetX(g),w=t.getoffsetX(x-1),T=$t(e*b,i,o,s,r,a,v,m,y,l,c,h,u,d,!0,_,p,f);if(!T)return null;const E=$t(e*w,i,o,s,r,a,v,m,y,l,c,h,u,d,!0,_,p,f);return E?{first:T,last:E}:null}function Ht(t,i,o,s){return t===e.bl.horizontal&&Math.abs(s)>Math.abs(o)?{useVertical:!0}:t===e.bl.vertical?s>0?{needsFlipping:!0}:null:i!==zt.unknown&&function(e,t){return 0===e||Math.abs(t/e)>Ot}(o,s)?i===zt.flipRequired?{needsFlipping:!0}:null:o<0?{needsFlipping:!0}:null}function Zt(t,i,o,s,r,a,n,l,c,h,u,d,_,p,f,m,g,v,x){const y=i/24,b=t.lineOffsetX*y,w=t.lineOffsetY*y,{lineStartIndex:T,glyphStartIndex:E,numGlyphs:S,segment:C,writingMode:I,flipState:D}=t,R=T+t.lineLength,A=t=>{if(u){const[i,o,s]=t.up,r=h.length;e.bn(u,r+0,i,o,s),e.bn(u,r+1,i,o,s),e.bn(u,r+2,i,o,s),e.bn(u,r+3,i,o,s);}const[i,o,s]=t.point;e.bo(h,i,o,s,t.angle);};if(S>1){const e=jt(y,l,b,w,o,d,_,t,c,a,p,m,!1,g,v,x);if(!e)return {notEnoughRoom:!0};if(s&&!o){let[i,o,s]=e.first.point,[r,a,l]=e.last.point;[i,o]=Nt(i,o,s,n),[r,a]=Nt(r,a,l,n);const c=Ht(I,D,(r-i)*f,a-o);if(t.flipState=c&&c.needsFlipping?zt.flipRequired:zt.flipNotRequired,c)return c}A(e.first);for(let e=E+1;e<E+S-1;e++){const t=$t(y*l.getoffsetX(e),b,w,o,d,_,C,T,R,c,a,p,m,!1,!1,g,v,x);if(!t)return h.length-=4*(e-E),{notEnoughRoom:!0};A(t);}A(e.last);}else {if(s&&!o){const i=Nt(_.x,_.y,0,r),o=T+C+1,s=new e.P(c.getx(o),c.gety(o)),a=Nt(s.x,s.y,0,r),n=a[3]>0?a:Wt(_,s,i,1,r,void 0,g,v.canonical),l=Ht(I,D,(n[0]-i[0])*f,n[1]-i[1]);if(t.flipState=l&&l.needsFlipping?zt.flipRequired:zt.flipNotRequired,l)return l}const i=$t(y*l.getoffsetX(E),b,w,o,d,_,C,T,R,c,a,p,m,!1,!1,g,v,x);if(!i)return {notEnoughRoom:!0};A(i);}return {}}function qt(e,t,i,o,s){const{x:r,y:a,z:n}=o.projectTilePoint(e.x,e.y,t);if(!s)return Nt(r,a,n,i);const[l,c,h]=s(e);return Nt(r+l,a+c,n+h,i)}function Wt(t,i,o,s,r,a,n,l){const c=qt(t.sub(i)._unit()._add(t),l,r,n,a);return e.a6.vec3.sub(c,o,c),e.a6.vec3.normalize(c,c),e.a6.vec3.scaleAndAdd(c,o,c,s)}function $t(t,i,o,s,r,a,n,l,c,h,u,d,_,p,f,m,g,v){const x=s?t-i:t+i;let y=x>0?1:-1,b=0;s&&(y*=-1,b=Math.PI),y<0&&(b+=Math.PI);let w=l+n+(y>0?0:1)|0,T=r,E=r,S=0,C=0;const I=Math.abs(x),D=[],R=[];let A=a,L=A;const P=()=>Wt(L,A,E,I-S+1,u,_,m,g.canonical);for(;S+C<=I;){if(w+=y,w<l||w>=c)return null;if(E=T,L=A,D.push(E),p&&R.push(L),A=new e.P(h.getx(w),h.gety(w)),T=d[w],!T){const e=qt(A,g.canonical,u,m,_);T=e[3]>0?d[w]=e:P();}S+=C,C=e.a6.vec3.distance(E,T);}f&&_&&(d[w]&&(T=P(),C=e.a6.vec3.distance(E,T)),d[w]=T);const M=(I-S)/C,z=A.sub(L)._mult(M)._add(L),O=e.a6.vec3.sub([],T,E),F=e.a6.vec3.scaleAndAdd([],E,O,M);let B=[0,0,1],k=O[0],N=O[1];if(v&&(B=m.upVector(g.canonical,z.x,z.y),0!==B[0]||0!==B[1]||1!==B[2])){const t=[B[2],0,-B[0]],i=e.a6.vec3.cross([],B,t);e.a6.vec3.normalize(t,t),e.a6.vec3.normalize(i,i),k=e.a6.vec3.dot(O,t),N=e.a6.vec3.dot(O,i);}if(o){const t=e.a6.vec3.cross([],B,O);e.a6.vec3.normalize(t,t),e.a6.vec3.scaleAndAdd(F,F,t,o*y);}const U=b+Math.atan2(N,k);return D.push(F),p&&R.push(z),{point:F,angle:U,path:D,tilePath:R,up:B}}function Xt(e,t){const i=t.length,o=i+4*e;t.resize(o),t.float32.fill(-1/0,4*i,4*o);}function Jt(e,t,i){const o=t[0],s=t[1];return e[0]=i[0]*o+i[4]*s+i[12],e[1]=i[1]*o+i[5]*s+i[13],e[3]=i[3]*o+i[7]*s+i[15],e}const Kt=100;class Yt{constructor(e,t,i=new Mt(e.width+200,e.height+200,25),o=new Mt(e.width+200,e.height+200,25)){this.transform=e,this.grid=i,this.ignoredGrid=o,this.pitchfactor=Math.cos(e._pitch)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+Kt,this.screenBottomBoundary=e.height+Kt,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.fogState=t;}placeCollisionBox(e,t,i,o,s,r,a,n){let l=i.projectedAnchorX,c=i.projectedAnchorY,h=i.projectedAnchorZ;const u=i.elevation,d=i.tileID,_=e.getProjection();if(u&&d){const[e,t,o]=_.upVector(d.canonical,i.tileAnchorX,i.tileAnchorY),s=_.upVectorScale(d.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;l+=e*u*s,c+=t*u*s,h+=o*u*s;}const p=this.projectAndGetPerspectiveRatio(a,l,c,h,i.tileID,"globe"===_.name||!!u||this.transform.pitch>0,_),f=r*p.perspectiveRatio,m=(i.x1*t+o.x-i.padding)*f+p.point.x,g=(i.y1*t+o.y-i.padding)*f+p.point.y,v=(i.x2*t+o.x+i.padding)*f+p.point.x,x=(i.y2*t+o.y+i.padding)*f+p.point.y,y=p.perspectiveRatio<=.55||p.occluded;return !this.isInsideGrid(m,g,v,x)||!s&&this.grid.hitTest(m,g,v,x,n)||y?{box:[],offscreen:!1,occluded:p.occluded}:{box:[m,g,v,x],offscreen:this.isOffscreen(m,g,v,x),occluded:!1}}placeCollisionCircles(t,i,o,s,r,a,n,l,c,h,u,d,_,p,f){const m=[],g=this.transform.elevation,v=t.getProjection(),x=g?g.getAtTileOffsetFunc(f,this.transform.center.lat,this.transform.worldSize,v):null,y=new e.P(o.tileAnchorX,o.tileAnchorY);let{x:b,y:w,z:T}=v.projectTilePoint(y.x,y.y,f.canonical);if(x){const[e,t,i]=x(y);b+=e,w+=t,T+=i;}const E="globe"===v.name,S=this.projectAndGetPerspectiveRatio(n,b,w,T,f,E||!!g||this.transform.pitch>0,v),{perspectiveRatio:C}=S,I=(u?a/C:a*C)/e.br,D=Nt(b,w,T,l),R=S.signedDistanceFromCamera>0?jt(I,r,o.lineOffsetX*I,o.lineOffsetY*I,!1,D,y,o,s,l,{},g&&!u?x:null,u&&!!g,v,f,u):null;let A=!1,L=!1,P=!0;if(R&&!S.occluded){const t=.5*_*C+p,o=new e.P(-100,-100),s=new e.P(this.screenRightBoundary,this.screenBottomBoundary),r=new Pt,{first:a,last:n}=R,l=a.path.length;let u=[];for(let e=l-1;e>=1;e--)u.push(a.path[e]);for(let e=1;e<n.path.length;e++)u.push(n.path[e]);const f=2.5*t;c&&(u=u.map((([e,t,i],o)=>(x&&!E&&(i=x(o<l-1?a.tilePath[l-1-o]:n.tilePath[o-l+2])[2]),Nt(e,t,i,c)))),u.some((e=>e[3]<=0))&&(u=[]));let g=[];if(u.length>0){let t=1/0,i=-1/0,r=1/0,a=-1/0;for(const e of u)t=Math.min(t,e[0]),r=Math.min(r,e[1]),i=Math.max(i,e[0]),a=Math.max(a,e[1]);i>=o.x&&t<=s.x&&a>=o.y&&r<=s.y&&(g=[u.map((t=>new e.P(t[0],t[1])))],(t<o.x||i>s.x||r<o.y||a>s.y)&&(g=e.bp(g,o.x,o.y,s.x,s.y)));}for(const e of g){r.reset(e,.25*t);let o=0;o=r.length<=.5*t?1:Math.ceil(r.paddedLength/f)+1;for(let e=0;e<o;e++){const s=e/Math.max(o-1,1),a=r.lerp(s),n=a.x+Kt,l=a.y+Kt;m.push(n,l,t,0);const c=n-t,u=l-t,_=n+t,p=l+t;if(P=P&&this.isOffscreen(c,u,_,p),L=L||this.isInsideGrid(c,u,_,p),!i&&this.grid.hitTestCircle(n,l,t,d)&&(A=!0,!h))return {circles:[],offscreen:!1,collisionDetected:A,occluded:!1}}}}return {circles:!h&&A||!L?[]:m,offscreen:P,collisionDetected:A,occluded:S.occluded}}queryRenderedSymbols(t){if(0===t.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return {};const i=[];let o=1/0,s=1/0,r=-1/0,a=-1/0;for(const n of t){const t=new e.P(n.x+Kt,n.y+Kt);o=Math.min(o,t.x),s=Math.min(s,t.y),r=Math.max(r,t.x),a=Math.max(a,t.y),i.push(t);}const n=this.grid.query(o,s,r,a).concat(this.ignoredGrid.query(o,s,r,a)),l={},c={};for(const t of n){const o=t.key;if(void 0===l[o.bucketInstanceId]&&(l[o.bucketInstanceId]={}),l[o.bucketInstanceId][o.featureIndex])continue;const s=[new e.P(t.x1,t.y1),new e.P(t.x2,t.y1),new e.P(t.x2,t.y2),new e.P(t.x1,t.y2)];e.bq(i,s)&&(l[o.bucketInstanceId][o.featureIndex]=!0,void 0===c[o.bucketInstanceId]&&(c[o.bucketInstanceId]=[]),c[o.bucketInstanceId].push(o.featureIndex));}return c}insertCollisionBox(e,t,i,o,s){(t?this.ignoredGrid:this.grid).insert({bucketInstanceId:i,featureIndex:o,collisionGroupID:s},e[0],e[1],e[2],e[3]);}insertCollisionCircles(e,t,i,o,s){const r=t?this.ignoredGrid:this.grid,a={bucketInstanceId:i,featureIndex:o,collisionGroupID:s};for(let t=0;t<e.length;t+=4)r.insertCircle(a,e[t],e[t+1],e[t+2]);}projectAndGetPerspectiveRatio(t,i,o,s,r,a,n){const l=[i,o,s,1];let c=!1;if(s||this.transform.pitch>0){if(e.a6.vec4.transformMat4(l,l,t),this.fogState&&r&&"globe"!==n.name){const t=function(t,i,o,s,r,a){const n=a.calculateFogTileMatrix(r),l=[i,o,s];return e.a6.vec3.transformMat4(l,l,n),Oe(t,e.a6.vec3.length(l),a.pitch,a._fov)}(this.fogState,i,o,s,r.toUnwrapped(),this.transform);c=t>.9;}}else Jt(l,l,t);const h=l[3];return {point:new e.P((l[0]/h+1)/2*this.transform.width+Kt,(-l[1]/h+1)/2*this.transform.height+Kt),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(n)/h*.5,1.5),signedDistanceFromCamera:h,occluded:a&&l[2]>h||c}}isOffscreen(e,t,i,o){return i<Kt||e>=this.screenRightBoundary||o<Kt||t>this.screenBottomBoundary}isInsideGrid(e,t,i,o){return i>=0&&e<this.gridRightBoundary&&o>=0&&t<this.gridBottomBoundary}getViewportMatrix(){const t=e.a6.mat4.identity([]);return e.a6.mat4.translate(t,t,[-100,-100,0]),t}}function Qt(t,i,o){const s=i.createTileMatrix(t,t.worldSize,o.toUnwrapped());return e.a6.mat4.multiply(new Float32Array(16),t.projMatrix,s)}function ei(e,t,i){if(t.projection.name===i.projection.name)return e.projMatrix;const o=i.clone();return o.setProjection(t.projection),Qt(o,t.getProjection(),e)}function ti(e,t,i){return t.name===i.projection.name?e.projMatrix:Qt(i,t,e)}class ii{constructor(e,t,i,o){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?t:-t))):o&&i?1:0,this.placed=i;}isHidden(){return 0===this.opacity&&!this.placed}}class oi{constructor(e,t,i,o,s,r=!1){this.text=new ii(e?e.text:null,t,i,s),this.icon=new ii(e?e.icon:null,t,o,s),this.clipped=r;}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class si{constructor(e,t,i,o=!1){this.text=e,this.icon=t,this.skipFade=i,this.clipped=o;}}class ri{constructor(){this.invProjMatrix=e.a6.mat4.create(),this.viewportMatrix=e.a6.mat4.create(),this.circles=[];}}class ai{constructor(e,t,i,o,s){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=i,this.bucketIndex=o,this.tileID=s;}}class ni{constructor(e){this.crossSourceCollisions=e,this.maxGroupID=0,this.collisionGroups={};}get(e){if(this.crossSourceCollisions)return {ID:0,predicate:null};if(!this.collisionGroups[e]){const t=++this.maxGroupID;this.collisionGroups[e]={ID:t,predicate:e=>e.collisionGroupID===t};}return this.collisionGroups[e]}}function li(t,i,o,s,r){const{horizontalAlign:a,verticalAlign:n}=e.by(t),l=-(a-.5)*i,c=-(n-.5)*o,h=e.bx(t,s);return new e.P(l+h[0]*r,c+h[1]*r)}function ci(t,i,o,s,r){const a=new e.P(t,i);return o&&a._rotate(s?r:-r),a}class hi{constructor(e,t,i,o,s,r){this.transform=e.clone(),this.projection=e.projection.name,this.collisionIndex=new Yt(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 ni(i),this.collisionCircleArrays={},this.prevPlacement=o,o&&(o.prevPlacement=void 0),this.placedOrientations={};}getBucketParts(t,i,o,s,r=1){const a=o.getBucket(i),n=o.latestFeatureIndex;if(!a||!n||i.fqid!==a.layerIds[0])return;const l=a.layers[0].layout,c=a.layers[0].paint,h=o.collisionBoxArray,u=Math.pow(2,this.transform.zoom-o.tileID.overscaledZ),d=o.tileSize/e.ab,_=o.tileID.toUnwrapped();this.transform.setProjection(a.projection);const p=(f=o.tileID,m=a.getProjection(),g=this.transform,m.name===this.projection?g.calculateProjMatrix(f.toUnwrapped()):Qt(g,m,f));var f,m,g;const v="map"===l.get("text-pitch-alignment"),x="map"===l.get("text-rotation-alignment");i.compileFilter(i.options);const y=i.dynamicFilter(),b=i.dynamicFilterNeedsFeature(),w=this.transform.calculatePixelsToTileUnitsMatrix(o),T=Bt(p,o.tileID.canonical,v,x,this.transform,a.getProjection(),w);let E=null;if(v){const t=kt(p,o.tileID.canonical,v,x,this.transform,a.getProjection(),w);E=e.a6.mat4.multiply([],this.transform.labelPlaneMatrix,t);}let S=null;y&&o.latestFeatureIndex&&(S={unwrappedTileID:_,dynamicFilter:y,dynamicFilterNeedsFeature:b}),this.retainedQueryData[a.bucketInstanceId]=new ai(a.bucketInstanceId,n,a.sourceLayerIndex,a.index,o.tileID);const C=a.layers[0].layout.get("text-size-scale-range"),I=e.ap(r,C[0],C[1]),D=a.layers[0].layout.get("icon-size-scale-range"),R=e.ap(r,D[0],D[1]),A={bucket:a,layout:l,paint:c,posMatrix:p,textLabelPlaneMatrix:T,labelToScreenMatrix:E,clippingData:S,scale:u,textPixelRatio:d,holdingForFade:o.holdingForFade(),collisionBoxArray:h,partiallyEvaluatedTextSize:e.bk(a.textSizeData,this.transform.zoom,I),partiallyEvaluatedIconSize:e.bk(a.iconSizeData,this.transform.zoom,R),collisionGroup:this.collisionGroups.get(a.sourceID),latestFeatureIndex:o.latestFeatureIndex};if(s)for(const e of a.sortKeyRanges){const{sortKey:i,symbolInstanceStart:o,symbolInstanceEnd:s}=e;t.push({sortKey:i,symbolInstanceStart:o,symbolInstanceEnd:s,parameters:A});}else t.push({symbolInstanceStart:0,symbolInstanceEnd:a.symbolInstances.length,parameters:A});}attemptAnchorPlacement(e,t,i,o,s,r,a,n,l,c,h,u,d,_,p,f,m,g){const{textOffset0:v,textOffset1:x,crossTileID:y}=u,b=[v,x],w=li(e,i,o,b,s),T=this.collisionIndex.placeCollisionBox(_,s,t,ci(w.x,w.y,r,a,this.transform.angle),h,n,l,c.predicate);if(f){const e=_.getSymbolInstanceIconSize(g,this.transform.zoom,u.placedIconSymbolIndex);if(0===this.collisionIndex.placeCollisionBox(_,e,f,ci(w.x,w.y,r,a,this.transform.angle),h,n,l,c.predicate).box.length)return}if(T.box.length>0){let t;return this.prevPlacement&&this.prevPlacement.variableOffsets[y]&&this.prevPlacement.placements[y]&&this.prevPlacement.placements[y].text&&(t=this.prevPlacement.variableOffsets[y].anchor),this.variableOffsets[y]={textOffset:b,width:i,height:o,anchor:e,textScale:s,prevAnchor:t},this.markUsedJustification(_,e,u,p),_.allowVerticalPlacement&&(this.markUsedOrientation(_,p,u),this.placedOrientations[y]=p),{shift:w,placedGlyphBoxes:T}}}placeLayerBucketPart(t,i,o,s,r=1){const{bucket:a,layout:n,paint:l,posMatrix:c,textLabelPlaneMatrix:h,labelToScreenMatrix:u,clippingData:d,textPixelRatio:_,holdingForFade:p,collisionBoxArray:f,partiallyEvaluatedTextSize:m,partiallyEvaluatedIconSize:g,collisionGroup:v,latestFeatureIndex:x}=t.parameters,y=n.get("text-optional"),b=n.get("icon-optional"),w=n.get("text-allow-overlap"),T=n.get("icon-allow-overlap"),E="map"===n.get("text-rotation-alignment"),S="map"===n.get("text-pitch-alignment"),C=n.get("symbol-z-elevate"),I=l.get("symbol-z-offset"),D="sea"===n.get("symbol-elevation-reference"),R=n.get("text-size-scale-range"),A=n.get("icon-size-scale-range"),L=e.ap(r,R[0],R[1]),P=e.ap(r,A[0],A[1]);this.transform.setProjection(a.projection);let M=w&&(T||!a.hasIconData()||b),z=T&&(w||!a.hasTextData()||y);const O=!I.isConstant();!a.collisionArrays&&f&&a.deserializeCollisionBoxes(f),o&&s&&a.updateCollisionDebugBuffers(this.transform.zoom,f,L,P);const F=(t,s,l)=>{const{crossTileID:f,numVerticalGlyphVertices:C}=t;let R=null;if(d&&d.dynamicFilterNeedsFeature||O){const e=this.retainedQueryData[a.bucketInstanceId];R=x.loadFeature({featureIndex:t.featureIndex,bucketIndex:e.bucketIndex,sourceLayerIndex:e.sourceLayerIndex,layoutVertexArrayOffset:0});}if(d&&!(0,d.dynamicFilter)({zoom:this.transform.zoom,pitch:this.transform.pitch},R,this.retainedQueryData[a.bucketInstanceId].tileID.canonical,new e.P(t.tileAnchorX,t.tileAnchorY),this.transform.calculateDistanceTileData(d.unwrappedTileID)))return this.placements[f]=new si(!1,!1,!1,!0),void i.add(f);const A=I.evaluate(R,{});if(i.has(f))return;if(p)return void(this.placements[f]=new si(!1,!1,!1));let L=!1,P=!1,F=!0,B=!1,k=!1,N=null,U={box:null,offscreen:null,occluded:null},G={box:null,offscreen:null,occluded:null},V=null,j=null,H=null,Z=0,q=0,W=0;l.textFeatureIndex?Z=l.textFeatureIndex:t.useRuntimeCollisionCircles&&(Z=t.featureIndex),l.verticalTextFeatureIndex&&(q=l.verticalTextFeatureIndex);const $=e=>{e.tileID=this.retainedQueryData[a.bucketInstanceId].tileID;const i=this.transform.elevation;e.elevation=D?A:A+(i?i.getAtTileOffset(e.tileID,e.tileAnchorX,e.tileAnchorY):0),e.elevation+=t.zOffset;},X=l.textBox;if(X){$(X);const i=i=>{let o=e.bl.horizontal;if(a.allowVerticalPlacement&&!i&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[f];e&&(this.placedOrientations[f]=e,o=e,this.markUsedOrientation(a,o,t));}return o},o=(t,i)=>{if(a.allowVerticalPlacement&&C>0&&l.verticalTextBox){for(const o of a.writingModes)if(o===e.bl.vertical?(U=i(),G=U):U=t(),U&&U.box&&U.box.length)break}else U=t();};if(n.get("text-variable-anchor")){let r=n.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[f]){const e=this.prevPlacement.variableOffsets[f];r.indexOf(e.anchor)>0&&(r=r.filter((t=>t!==e.anchor)),r.unshift(e.anchor));}const h=(e,i,o)=>{const n=a.getSymbolInstanceTextSize(m,t,this.transform.zoom,s),l=(e.x2-e.x1)*n+2*e.padding,h=(e.y2-e.y1)*n+2*e.padding,u=t.hasIconTextFit&&!T?i:null;u&&$(u);let d={box:[],offscreen:!1,occluded:!1};const p=w?2*r.length:r.length;for(let i=0;i<p;++i){const p=this.attemptAnchorPlacement(r[i%r.length],e,l,h,n,E,S,_,c,v,i>=r.length,t,s,a,o,u,m,g);if(p&&(d=p.placedGlyphBoxes,d&&d.box&&d.box.length)){L=!0,N=p.shift;break}}return d};o((()=>h(X,l.iconBox,e.bl.horizontal)),(()=>{const t=l.verticalTextBox;return t&&$(t),a.allowVerticalPlacement&&!(U&&U.box&&U.box.length)&&C>0&&t?h(t,l.verticalIconBox,e.bl.vertical):{box:null,offscreen:null,occluded:null}})),U&&(L=U.box,F=U.offscreen,B=U.occluded);const u=i(!(!U||!U.box));if(!L&&this.prevPlacement){const e=this.prevPlacement.variableOffsets[f];e&&(this.variableOffsets[f]=e,this.markUsedJustification(a,e.anchor,t,u));}}else {const n=(i,o)=>{const n=a.getSymbolInstanceTextSize(m,t,this.transform.zoom,s,r),l=this.collisionIndex.placeCollisionBox(a,n,i,new e.P(0,0),w,_,c,v.predicate);return l&&l.box&&l.box.length&&(this.markUsedOrientation(a,o,t),this.placedOrientations[f]=o),l};o((()=>n(X,e.bl.horizontal)),(()=>{const t=l.verticalTextBox;return a.allowVerticalPlacement&&C>0&&t?($(t),n(t,e.bl.vertical)):{box:null,offscreen:null,occluded:null}})),i(!!(U&&U.box&&U.box.length));}}if(V=U,L=V&&V.box&&V.box.length>0,F=V&&V.offscreen,B=V&&V.occluded,t.useRuntimeCollisionCircles){const i=a.text.placedSymbolArray.get(t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex),s=e.bm(a.textSizeData,m,i),r=n.get("text-padding");j=this.collisionIndex.placeCollisionCircles(a,w,i,a.lineVertexArray,a.glyphOffsetArray,s,c,h,u,o,S,v.predicate,t.collisionCircleDiameter*s/e.br,r,this.retainedQueryData[a.bucketInstanceId].tileID),L=w||j.circles.length>0&&!j.collisionDetected,F=F&&j.offscreen,B=j.occluded;}if(l.iconFeatureIndex&&(W=l.iconFeatureIndex),l.iconBox){const i=i=>{$(i);const o=t.hasIconTextFit&&N?ci(N.x,N.y,E,S,this.transform.angle):new e.P(0,0),s=a.getSymbolInstanceIconSize(g,this.transform.zoom,t.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(a,s,i,o,T,_,c,v.predicate)};G&&G.box&&G.box.length&&l.verticalIconBox?(H=i(l.verticalIconBox),P=H.box.length>0):(H=i(l.iconBox),P=H.box.length>0),F=F&&H.offscreen,k=H.occluded;}const J=y||0===t.numHorizontalGlyphVertices&&0===C,K=b||0===t.numIconVertices;if(J||K?K?J||(P=P&&L):L=P&&L:P=L=P&&L,L&&V&&V.box&&this.collisionIndex.insertCollisionBox(V.box,n.get("text-ignore-placement"),a.bucketInstanceId,G&&G.box&&q?q:Z,v.ID),P&&H&&this.collisionIndex.insertCollisionBox(H.box,n.get("icon-ignore-placement"),a.bucketInstanceId,W,v.ID),j&&(L&&this.collisionIndex.insertCollisionCircles(j.circles,n.get("text-ignore-placement"),a.bucketInstanceId,Z,v.ID),o)){const e=a.bucketInstanceId;let t=this.collisionCircleArrays[e];void 0===t&&(t=this.collisionCircleArrays[e]=new ri);for(let e=0;e<j.circles.length;e+=4)t.circles.push(j.circles[e+0]),t.circles.push(j.circles[e+1]),t.circles.push(j.circles[e+2]),t.circles.push(j.collisionDetected?1:0);}const Y="globe"!==a.projection.name;M=M&&(Y||!B),z=z&&(Y||!k),this.placements[f]=new si(L||M,P||z,F||a.justReloaded),i.add(f);};if(C&&this.buildingIndex&&(this.buildingIndex.updateZOffset(a,this.retainedQueryData[a.bucketInstanceId].tileID),a.updateZOffset()),a.sortFeaturesByY){const t=a.getSortedSymbolIndexes(this.transform.angle);for(let e=t.length-1;e>=0;--e){const i=t[e];F(a.symbolInstances.get(i),i,a.collisionArrays[i]);}a.hasAnyZOffset&&e.w(`${a.layerIds[0]} layer symbol-z-elevate: symbols are not sorted by elevation if symbol-z-order is evaluated to viewport-y`);}else if(a.hasAnyZOffset){const e=a.getSortedIndexesByZOffset();for(let t=0;t<e.length;++t){const i=e[t];F(a.symbolInstances.get(i),i,a.collisionArrays[i]);}}else for(let e=t.symbolInstanceStart;e<t.symbolInstanceEnd;e++)F(a.symbolInstances.get(e),e,a.collisionArrays[e]);if(o&&a.bucketInstanceId in this.collisionCircleArrays){const t=this.collisionCircleArrays[a.bucketInstanceId];e.a6.mat4.invert(t.invProjMatrix,c),t.viewportMatrix=this.collisionIndex.getViewportMatrix();}a.justReloaded=!1;}markUsedJustification(t,i,o,s){const{leftJustifiedTextSymbolIndex:r,centerJustifiedTextSymbolIndex:a,rightJustifiedTextSymbolIndex:n,verticalPlacedTextSymbolIndex:l,crossTileID:c}=o,h=e.bw(i),u=s===e.bl.vertical?l:"left"===h?r:"center"===h?a:"right"===h?n:-1;r>=0&&(t.text.placedSymbolArray.get(r).crossTileID=u>=0&&r!==u?0:c),a>=0&&(t.text.placedSymbolArray.get(a).crossTileID=u>=0&&a!==u?0:c),n>=0&&(t.text.placedSymbolArray.get(n).crossTileID=u>=0&&n!==u?0:c),l>=0&&(t.text.placedSymbolArray.get(l).crossTileID=u>=0&&l!==u?0:c);}markUsedOrientation(t,i,o){const s=i===e.bl.horizontal||i===e.bl.horizontalOnly?i:0,r=i===e.bl.vertical?i:0,{leftJustifiedTextSymbolIndex:a,centerJustifiedTextSymbolIndex:n,rightJustifiedTextSymbolIndex:l,verticalPlacedTextSymbolIndex:c}=o,h=t.text.placedSymbolArray;a>=0&&(h.get(a).placedOrientation=s),n>=0&&(h.get(n).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:{},a=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],r=s[e];r?(this.opacities[e]=new oi(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 oi(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 oi(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 a)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=a[e]);i?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e);}updateLayerOpacities(e,t,i,o){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),t.layers[0].layout.get("symbol-z-elevate")&&this.buildingIndex&&(this.buildingIndex.updateZOffset(t,r.tileID),t.updateZOffset()));}}updateBucketOpacities(t,i,o,s,r,a,n,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,u=!!t.layers[0].dynamicFilter(),d=new oi(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"),x="sea"===c.get("symbol-elevation-reference"),y=!v.isConstant(),b=new oi(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;o<t/4;o++)e.opacityVertexArray.emplaceBack(i);};let T=0;a&&t.updateReplacement(n,a);for(let s=0;s<t.symbolInstances.length;s++){const c=t.symbolInstances.get(s),{numHorizontalGlyphVertices:h,numVerticalGlyphVertices:_,crossTileID:p,numIconVertices:E,tileAnchorX:S,tileAnchorY:C}=c;let I=null;const D=this.retainedQueryData[t.bucketInstanceId];y&&c&&D&&(I=o.latestFeatureIndex.loadFeature({featureIndex:c.featureIndex,bucketIndex:D.bucketIndex,sourceLayerIndex:D.sourceLayerIndex,layoutVertexArrayOffset:0}));const R=v.evaluate(I,{}),A=i.has(p);let L=this.opacities[p];A?L=d:L||(L=b,this.opacities[p]=L),i.add(p);const P=h>0||_>0,M=E>0,z=this.placedOrientations[p],O=z===e.bl.vertical,F=z===e.bl.horizontal||z===e.bl.horizontalOnly;!P&&!M||L.isHidden()||T++;let B=!1;if((P||M)&&a)for(const i of t.activeReplacements){if(e.bs(i,r,e.bt.Symbol,l))continue;if(i.min.x>S||S>i.max.x||i.min.y>C||C>i.max.y)continue;const t=e.bu(S,C,n.canonical,i.footprintTileId.canonical);if(B=e.bv(t,i.footprint),B)break}if(P){const e=B?yi:xi(L.text);w(t.text,h,O?yi:e),w(t.text,_,F?yi:e);const i=L.text.isHidden(),{leftJustifiedTextSymbolIndex:o,centerJustifiedTextSymbolIndex:s,rightJustifiedTextSymbolIndex:r,verticalPlacedTextSymbolIndex:a}=c,n=t.text.placedSymbolArray,l=i||O?1:0;o>=0&&(n.get(o).hidden=l),s>=0&&(n.get(s).hidden=l),r>=0&&(n.get(r).hidden=l),a>=0&&(n.get(a).hidden=i||F?1:0);const u=this.variableOffsets[p];u&&this.markUsedJustification(t,u.anchor,c,z);const d=this.placedOrientations[p];d&&(this.markUsedJustification(t,"left",c,d),this.markUsedOrientation(t,d,c));}if(M){const e=B?yi:xi(L.icon),{placedIconSymbolIndex:i,verticalPlacedIconSymbolIndex:o}=c,s=t.icon.placedSymbolArray,r=L.icon.isHidden()?1:0;i>=0&&(w(t.icon,E,O?yi:e),s.get(i).hidden=r),o>=0&&(w(t.icon,c.numVerticalIconVertices,F?yi: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=li(e.anchor,e.width,e.height,e.textOffset,e.textScale),m&&o._rotate(g?this.transform.angle:-this.transform.angle)):s=!1;}u&&(s=!L.clipped),i.textBox&&ui(t.textCollisionBox.collisionVertexArray,L.text.placed,!s||O,R,x,o.x,o.y),i.verticalTextBox&&ui(t.textCollisionBox.collisionVertexArray,L.text.placed,!s||F,R,x,o.x,o.y);}const r=s&&Boolean(!F&&i.verticalIconBox);i.iconBox&&ui(t.iconCollisionBox.collisionVertexArray,L.icon.placed,r,R,x,c.hasIconTextFit?o.x:0,c.hasIconTextFit?o.y:0),i.verticalIconBox&&ui(t.iconCollisionBox.collisionVertexArray,L.icon.placed,!r,R,x,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 this.stale||e-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(e,t){const i=this.zoomAtLastRecencyCheck===t?1-this.zoomAdjustment(t):1;return this.zoomAtLastRecencyCheck=t,this.commitTime+this.fadeDuration*i>e}setStale(){this.stale=!0;}}function ui(e,t,i,o,s,r,a){e.emplaceBack(t?1:0,i?1:0,r||0,a||0,o,s?1:0),e.emplaceBack(t?1:0,i?1:0,r||0,a||0,o,s?1:0),e.emplaceBack(t?1:0,i?1:0,r||0,a||0,o,s?1:0),e.emplaceBack(t?1:0,i?1:0,r||0,a||0,o,s?1:0);}const di=Math.pow(2,25),_i=Math.pow(2,24),pi=Math.pow(2,17),fi=Math.pow(2,16),mi=Math.pow(2,9),gi=Math.pow(2,8),vi=Math.pow(2,1);function xi(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*di+t*_i+i*pi+t*fi+i*mi+t*gi+i*vi+t}const yi=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 a=this._bucketParts;for(;this._currentTileIndex<e.length;)if(t.getBucketParts(a,o,e[this._currentTileIndex],this._sortAcrossTiles,r),this._currentTileIndex++,s())return !0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,a.sort(((e,t)=>e.sortKey-t.sortKey)));this._currentPartIndex<a.length;){const e=a[this._currentPartIndex];if(t.placeLayerBucketPart(e,this._seenCrossTileIDs,i,0===e.symbolInstanceStart,r),this._currentPartIndex++,s())return !0}return !1}}class wi{constructor(e,t,i,o,s,r,a,n,l){this.placement=new hi(e,s,r,a,n,l),this._currentPlacementIndex=t.length-1,this._forceFullPlacement=i,this._showCollisionBoxes=o,this._done=!1;}isDone(){return this._done}continuePlacement(t,i,o,s,r){const a=e.q.now(),n=()=>{const t=e.q.now()-a;return !this._forceFullPlacement&&t>2};for(;this._currentPlacementIndex>=0;){const a=i[t[this._currentPlacementIndex]],l=this.placement.collisionIndex.transform.zoom;if("symbol"===a.type&&(!a.minzoom||a.minzoom<=l)&&(!a.maxzoom||a.maxzoom>l)){const t=a,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),u=t.layout.get("text-allow-overlap")||t.layout.get("icon-allow-overlap")||t.layout.get("text-ignore-placement")||t.layout.get("icon-ignore-placement"),d=h&&u,_=this._inProgressLayer=this._inProgressLayer||new bi(t),p=e.av(a.source,a.scope);if(_.continuePlacement(i||d?s[p]:o[p],this.placement,this._showCollisionBoxes,a,n,r))return;delete this._inProgressLayer;}this._currentPlacementIndex--;}this._done=!0;}commit(e){return this.placement.commit(e),this.placement}}const Ti=512/e.ab/2;class Ei{constructor(t,i,o){this.tileID=t,this.bucketInstanceId=o,this.index=new e.bz(i.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const s=t.canonical.x*e.ab,r=t.canonical.y*e.ab;for(let e=0;e<i.length;e++){const{key:t,crossTileID:o,tileAnchorX:a,tileAnchorY:n}=i.get(e),l=Math.floor((s+a)*Ti),c=Math.floor((r+n)*Ti);this.index.add(l,c),this.keys.push(t),this.crossTileIDs.push(o);}this.index.finish();}findMatches(t,i,o){const s=this.tileID.canonical.z<i.canonical.z?1:Math.pow(2,this.tileID.canonical.z-i.canonical.z),r=Ti/Math.pow(2,i.canonical.z-this.tileID.canonical.z),a=i.canonical.x*e.ab,n=i.canonical.y*e.ab;for(let e=0;e<t.length;e++){const i=t.get(e);if(i.crossTileID)continue;const{key:l,tileAnchorX:c,tileAnchorY:h}=i,u=Math.floor((a+c)*r),d=Math.floor((n+h)*r),_=this.index.range(u-s,d-s,u+s,d+s);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 Si{constructor(){this.maxCrossTileID=0;}generate(){return ++this.maxCrossTileID}}class Ci{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;e<t.symbolInstances.length;e++)t.symbolInstances.get(e).crossTileID=0;this.usedCrossTileIDs[e.overscaledZ]||(this.usedCrossTileIDs[e.overscaledZ]=new Set);const o=this.usedCrossTileIDs[e.overscaledZ];for(const i in this.indexes){const s=this.indexes[i];if(Number(i)>e.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.symbolInstances.length;e++){const s=t.symbolInstances.get(e);s.crossTileID||(s.crossTileID=i.generate(),o.add(s.crossTileID));}return void 0===this.indexes[e.overscaledZ]&&(this.indexes[e.overscaledZ]={}),this.indexes[e.overscaledZ][e.key]=new Ei(e,t.symbolInstances,t.bucketInstanceId),!0}removeBucketCrossTileIDs(e,t){for(const i of t.crossTileIDs)this.usedCrossTileIDs[e].delete(i);}removeStaleBuckets(e){let t=!1;for(const i in this.indexes){const o=this.indexes[i];for(const s in o)e[o[s].bucketInstanceId]||(this.removeBucketCrossTileIDs(i,o[s]),delete o[s],t=!0);}return t}}class Ii{constructor(){this.layerIndexes={},this.crossTileIDs=new Si,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={};}addLayer(e,t,i,o){let s=this.layerIndexes[e.fqid];void 0===s&&(s=this.layerIndexes[e.fqid]=new Ci);let r=!1;const a={};"globe"!==o.name&&s.handleWrapJump(i);for(const i of t){const t=i.getBucket(e);t&&e.fqid===t.layerIds[0]&&(t.bucketInstanceId||(t.bucketInstanceId=++this.maxBucketInstanceId),s.addBucket(i.tileID,t,this.crossTileIDs)&&(r=!0),a[t.bucketInstanceId]=!0);}return s.removeStaleBuckets(a)&&(r=!0),r}pruneUnusedLayers(e){const t={};e.forEach((e=>{t[e]=!0;}));for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e];}}const Di=771;class Ri{constructor(e,t,i,o){this.blendFunction=e,this.blendColor=t,this.mask=i,this.blendEquation=o;}}Ri.Replace=[1,0,1,0],Ri.disabled=new Ri(Ri.Replace,e.bA.transparent,[!1,!1,!1,!1]),Ri.unblended=new Ri(Ri.Replace,e.bA.transparent,[!0,!0,!0,!0]),Ri.alphaBlended=new Ri([1,Di,1,Di],e.bA.transparent,[!0,!0,!0,!0]),Ri.alphaBlendedNonPremultiplied=new Ri([770,Di,770,Di],e.bA.transparent,[!0,!0,!0,!0]),Ri.multiply=new Ri([774,0,774,0],e.bA.transparent,[!0,!0,!0,!0]);class Ai{constructor(e,t,i){this.func=e,this.mask=t,this.range=i;}}Ai.ReadOnly=!1,Ai.ReadWrite=!0,Ai.disabled=new Ai(519,Ai.ReadOnly,[0,1]);const Li=7680;class Pi{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;}}Pi.disabled=new Pi({func:519,mask:0},0,0,Li,Li,Li);const Mi=1029,zi=2305;class Oi{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i;}}function Fi(t,i){const o=e.bD(t,3);e.a6.mat4.fromQuat(t,i),e.bF(t,3,o);}function Bi(t,i){const o=e.a6.quat.identity([]);return e.a6.quat.rotateZ(o,o,-i),e.a6.quat.rotateX(o,o,-t),o}function ki(t,i){const o=[t[0],t[1],0],s=[i[0],i[1],0];if(e.a6.vec3.length(o)>=1e-15){const t=e.a6.vec3.normalize([],o);e.a6.vec3.scale(s,t,e.a6.vec3.dot(s,t)),i[0]=s[0],i[1]=s[1];}const r=e.a6.vec3.cross([],i,t);if(e.a6.vec3.len(r)<1e-15)return null;const a=Math.atan2(-r[1],r[0]);return Bi(Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2]),a)}Oi.disabled=new Oi(!1,Mi,zi),Oi.backCCW=new Oi(!0,Mi,zi),Oi.backCW=new Oi(!0,Mi,2304),Oi.frontCW=new Oi(!0,1028,2304),Oi.frontCCW=new Oi(!0,1028,zi);class Ni{constructor(e,t){this.position=e,this.orientation=t;}get position(){return this._position}set position(t){if(t){const i=t instanceof e.a5?t:new e.a5(t[0],t[1],t[2]);this._renderWorldCopies&&(i.x=e.bB(i.x,0,1)),this._position=i;}else this._position=null;}lookAtPoint(t,i){if(this.orientation=null,!this.position)return;const o=this.position,s=this._elevation?this._elevation.getAtPointOrZero(e.a5.fromLngLat(t)):0,r=e.a5.fromLngLat(t,s),a=[r.x-o.x,r.y-o.y,r.z-o.z];i||(i=[0,0,1]),i[2]=Math.abs(i[2]),this.orientation=ki(a,i);}setPitchBearing(t,i){this.orientation=Bi(e.bC(t),e.bC(-i));}}class Ui{constructor(t,i){this._transform=e.a6.mat4.identity([]),this.orientation=i,this.position=t;}get mercatorPosition(){const t=this.position;return new e.a5(t[0],t[1],t[2])}get position(){const t=e.bD(this._transform,3);return [t[0],t[1],t[2]]}set position(t){var i;t&&e.bF(this._transform,3,[(i=t)[0],i[1],i[2],1]);}get orientation(){return this._orientation}set orientation(t){this._orientation=t||e.a6.quat.identity([]),t&&Fi(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=Bi(e,t),Fi(this._transform,this._orientation);}forward(){const t=e.bD(this._transform,2);return [-t[0],-t[1],-t[2]]}up(){const t=e.bD(this._transform,1);return [-t[0],-t[1],-t[2]]}right(){const t=e.bD(this._transform,0);return [t[0],t[1],t[2]]}getCameraToWorld(t,i){const o=new Float64Array(16);return e.a6.mat4.invert(o,this.getWorldToCamera(t,i)),o}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(t,i,o){const s=this.position;e.a6.vec3.scale(s,s,-t);const r=new Float64Array(16);return e.a6.mat4.fromScaling(r,[o,o,o]),e.a6.mat4.translate(r,r,s),r[10]*=i,r}getWorldToCamera(t,i){const o=new Float64Array(16),s=new Float64Array(4),r=this.position;return e.a6.quat.conjugate(s,this._orientation),e.a6.vec3.scale(r,r,-t),e.a6.mat4.fromQuat(o,s),e.a6.mat4.translate(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.a6.mat4.perspective(r,t,i,o,s),r}getCameraToClipOrthographic(t,i,o,s,r,a){const n=new Float64Array(16);return e.a6.mat4.ortho(n,t,i,o,s,r,a),n}getDistanceToElevation(t,i=!1){const o=0===t?0:e.bE(t,i?e.aN(this.position[1]):this.position[1]),s=this.forward();return (o-this.position[2])/s[2]}clone(){return new Ui([...this.position],[...this.orientation])}}const Gi={BaseColor:5,MetallicRoughness:6,Normal:7,Occlusion:8,Emission:9,LUT:10,ShadowMap0:11};class Vi{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.aa(t.top,i.top,o)),null!=i.bottom&&null!=t.bottom&&(this.bottom=e.aa(t.bottom,i.bottom,o)),null!=i.left&&null!=t.left&&(this.left=e.aa(t.left,i.left,o)),null!=i.right&&null!=t.right&&(this.right=e.aa(t.right,i.right,o)),this}getCenter(t,i){const o=e.ap((this.left+t-this.right)/2,0,t),s=e.ap((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 Vi(this.top,this.bottom,this.left,this.right)}toJSON(){return {top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const ji=(e,t,i)=>(1-i)*e+i*t,Hi=e=>e*e*e*e*e;class Zi{constructor(t,i,o,s,r,a,n){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(a),this.setMaxBounds(n),this.width=0,this.height=0,this._center=new e.bL(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._unmodified=!0,this._edgeInsets=new Vi,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new Ui,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._pixelsPerMercatorPixel=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._tileCoverLift=0,this.freezeTileCoverage=!1,this._horizonShift=.1,this._orthographicProjectionAtLowPitch=!1;}clone(){const e=new Zi(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection());return e._elevation=this._elevation,e._centerAltitude=this._centerAltitude,e._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,e.tileSize=this.tileSize,e.mercatorFromTransition=this.mercatorFromTransition,e.width=this.width,e.height=this.height,e.cameraElevationReference=this.cameraElevationReference,e._center=this._center,e._setZoom(this.zoom),e._seaLevelZoom=this._seaLevelZoom,e.angle=this.angle,e._fov=this._fov,e._pitch=this._pitch,e._nearZ=this._nearZ,e._farZ=this._farZ,e._averageElevation=this._averageElevation,e._orthographicProjectionAtLowPitch=this._orthographicProjectionAtLowPitch,e._unmodified=this._unmodified,e._edgeInsets=this._edgeInsets.clone(),e._camera=this._camera.clone(),e._calcMatrices(),e.freezeTileCoverage=this.freezeTileCoverage,e.frustumCorners=this.frustumCorners,e}get isOrthographic(){return "globe"!==this.projection.name&&this._orthographicProjectionAtLowPitch&&this.pitch<15}get elevation(){return this._elevation}set elevation(e){this._elevation!==e&&(this._elevation=e,this._updateCameraOnTerrain(),this._calcMatrices());}get depthOcclusionForSymbolsAndCircles(){return "globe"!==this.projection.name&&!this.isOrthographic}updateElevation(e,t=!1){const i=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(null==this._seaLevelZoom||i)&&this._updateCameraOnTerrain(),(e||i)&&this._constrainCamera(t),this._calcMatrices();}getProjection(){return e.ar(this.projection,["name","center","parallels"])}setProjection(t){this.projectionOptions=t||{name:"mercator"};const i=this.projection?this.getProjection():void 0;this.projection=e.bM(this.projectionOptions);const o=this.getProjection(),s=!e.bi(i,o);return s&&this._calcMatrices(),this.mercatorFromTransition=!1,s}setOrthographicProjectionAtLowPitch(e){return this._orthographicProjectionAtLowPitch!==e&&(this._orthographicProjectionAtLowPitch=e,this._calcMatrices(),!0)}setMercatorFromTransition(){const t=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=e.bM({name:"mercator"});const i=t!==this.projection.name;return i&&this._calcMatrices(),i}get minZoom(){return this._minZoom}set minZoom(e){this._minZoom!==e&&(this._minZoom=e,this.zoom=Math.max(this.zoom,e));}get maxZoom(){return this._maxZoom}set maxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.zoom=Math.min(this.zoom,e));}get minPitch(){return this._minPitch}set minPitch(e){this._minPitch!==e&&(this._minPitch=e,this.pitch=Math.max(this.pitch,e));}get maxPitch(){return this._maxPitch}set maxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.pitch=Math.min(this.pitch,e));}get renderWorldCopies(){return this._renderWorldCopies&&!0===this.projection.supportsWorldCopies}set renderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e;}get worldSize(){return this.tileSize*this.scale}get cameraWorldSizeForFog(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get cameraWorldSize(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation,!0),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return e.bE(1,this.center.lat)*this.cameraWorldSizeForFog}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new e.P(this.width,this.height)}get bearing(){return e.bB(this.rotation,-180,180)}set bearing(e){this.rotation=e;}get rotation(){return -this.angle/Math.PI*180}set rotation(t){const i=-t*Math.PI/180;this.angle!==i&&(this._unmodified=!1,this.angle=i,this._calcMatrices(),this.rotationMatrix=e.a6.mat2.create(),e.a6.mat2.rotate(this.rotationMatrix,this.rotationMatrix,this.angle));}get pitch(){return this._pitch/Math.PI*180}set pitch(t){const i=e.ap(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==i&&(this._unmodified=!1,this._pitch=i,this._calcMatrices());}get aspect(){return this.width/this.height}get fov(){return this._fov/Math.PI*180}get fovX(){return this._fov}get fovY(){const e=1/Math.tan(.5*this.fovX);return 2*Math.atan(1/this.aspect/e)}set fov(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=e.bC(t),this._calcMatrices());}get averageElevation(){return this._averageElevation}set averageElevation(e){this._averageElevation=e,this._calcFogMatrices(),this._distanceTileDataCache={};}get zoom(){return this._zoom}set zoom(e){const t=Math.min(Math.max(e,this.minZoom),this.maxZoom);this._zoom!==t&&(this._unmodified=!1,this._setZoom(t),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices());}_setZoom(e){this._zoom=e,this.scale=this.zoomScale(e),this.tileZoom=Math.floor(e),this.zoomFraction=e-this.tileZoom;}get tileCoverLift(){return this._tileCoverLift}set tileCoverLift(e){this._tileCoverLift!==e&&(this._tileCoverLift=e);}_updateCameraOnTerrain(){const e=this.elevation?this.elevation.getAtPoint(this.locationCoordinate(this.center),Number.NEGATIVE_INFINITY):Number.NEGATIVE_INFINITY,t=this.elevation&&e===Number.NEGATIVE_INFINITY&&this.elevation.visibleDemTiles.length>0&&this.elevation.exaggeration()>0&&this._centerAltitudeValidForExaggeration;if(!this._elevation||e===Number.NEGATIVE_INFINITY&&(!t||!this._centerAltitude))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const 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(){void 0!==this._centerAltitudeValidForExaggeration&&(this._seaLevelZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize));}sampleAverageElevation(){if(!this._elevation)return 0;const t=this._elevation,i=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],o=this.horizonLineFromTop();let s=0,r=0;for(let a=0;a<i.length;a++){const n=new e.P(i[a][0]*this.width,o+i[a][1]*(this.height-o)),l=t.pointCoordinate(n);if(!l)continue;const c=1/Math.hypot(l[0]-this._camera.position[0],l[1]-this._camera.position[1]);s+=l[3]*c,r+=c;}return 0===r?NaN:s/r}get center(){return this._center}set center(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this._terrainEnabled()&&("ground"===this.cameraElevationReference?this._updateCameraOnTerrain():this._updateZoomFromElevation()),this._constrain(),this._calcMatrices());}_updateZoomFromElevation(){if(null==this._seaLevelZoom||!this._elevation)return;const e=this._seaLevelZoom,t=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center)),i=this.pixelsPerMeter/this.worldSize*t,o=this._mercatorZfromZoom(e),s=this._mercatorZfromZoom(this._maxZoom),r=Math.max(o-i,s);this._setZoom(this._zoomFromMercatorZ(r));}get padding(){return this._edgeInsets.toJSON()}set padding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices());}computeZoomRelativeTo(t){const i=this.rayIntersectionCoordinate(this.pointRayIntersection(this.centerPoint,t.toAltitude()));let o;o=t.z<this._camera.position[2]?[i.x,i.y,i.z]:[t.x,t.y,t.z];const s=e.a6.vec3.length(e.a6.vec3.sub([],this._camera.position,o));return e.ap(this._zoomFromMercatorZ(s),this._minZoom,this._maxZoom)}setFreeCameraOptions(t){if(!this.height)return;if(!t.position&&!t.orientation)return;this._updateCameraState();let i=!1;if(t.orientation&&!e.a6.quat.exactEquals(t.orientation,this._camera.orientation)&&(i=this._setCameraOrientation(t.orientation)),t.position){const o=[t.position.x,t.position.y,t.position.z];e.a6.vec3.exactEquals(o,this._camera.position)||(this._setCameraPosition(o),i=!0);}i&&(this._updateStateFromCamera(),this.recenterOnTerrain());}getFreeCameraOptions(){this._updateCameraState();const t=this._camera.position,i=new Ni;return i.position=new e.a5(t[0],t[1],t[2]),i.orientation=this._camera.orientation,i._elevation=this.elevation,i._renderWorldCopies=this.renderWorldCopies,i}_setCameraOrientation(t){if(!e.a6.quat.length(t))return !1;e.a6.quat.normalize(t,t);const i=e.a6.vec3.transformQuat([],[0,0,-1],t),o=e.a6.vec3.transformQuat([],[0,-1,0],t);if(o[2]<0)return !1;const s=ki(i,o);return !!s&&(this._camera.orientation=s,!0)}_setCameraPosition(t){const i=this.zoomScale(this.minZoom)*this.tileSize,o=this.zoomScale(this.maxZoom)*this.tileSize,s=this.cameraToCenterDistance;t[2]=e.ap(t[2],s/o,s/i),this._camera.position=t;}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}get fovAboveCenter(){return this._fov*(.5+this.centerOffset.y/this.height)}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,t,i){this._unmodified=!1,this._edgeInsets.interpolate(e,t,i),this._constrain(),this._calcMatrices();}coveringZoomLevel(e){const t=(e.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/e.tileSize));return Math.max(0,t)}getVisibleUnwrappedCoordinates(t){const i=[new e.bN(0,t)];if(this.renderWorldCopies){const o=this.pointCoordinate(new e.P(0,0)),s=this.pointCoordinate(new e.P(this.width,0)),r=this.pointCoordinate(new e.P(this.width,this.height)),a=this.pointCoordinate(new e.P(0,this.height)),n=Math.floor(Math.min(o.x,s.x,r.x,a.x)),l=Math.floor(Math.max(o.x,s.x,r.x,a.x)),c=1;for(let o=n-c;o<=l+c;o++)0!==o&&i.push(new e.bN(o,t));}return i}isLODDisabled(e){return (!e||this.pitch<=60)&&this._edgeInsets.top<=this._edgeInsets.bottom&&!this._elevation&&!this.projection.isReprojectedInTileSpace}extendTileCover(t,i,o){let s=[];const r=void 0!==o,a=!r;if(a&&this.zoom<i)return s;if(r&&0===o[0]&&0===o[1])return s;const n=new Set,l=(t,i,o,r,a)=>{const l=e.c2(i,t,o,r,a);n.has(l)||(s.push(new e.aA(t,i,o,r,a)),n.add(l));};for(let e=0;e<t.length;e++){const s=t[e];if(a&&s.canonical.z!==i)continue;const n=s.canonical,c=s.overscaledZ,h=s.wrap,u=1<<n.z,d=n.x+1<u,_=n.x>0,p=n.y+1<u,f=n.y>0,m=s.wrap-(_?0:1),g=s.wrap+(d?0:1),v=_?n.x-1:u-1,x=d?n.x+1:0;if(r)o[0]<0?(l(c,g,n.z,x,n.y),o[1]<0&&p&&(l(c,h,n.z,n.x,n.y+1),l(c,g,n.z,x,n.y+1)),o[1]>0&&f&&(l(c,h,n.z,n.x,n.y-1),l(c,g,n.z,x,n.y-1))):o[0]>0?(l(c,m,n.z,v,n.y),o[1]<0&&p&&(l(c,h,n.z,n.x,n.y+1),l(c,m,n.z,v,n.y+1)),o[1]>0&&f&&(l(c,h,n.z,n.x,n.y-1),l(c,m,n.z,v,n.y-1))):o[1]<0&&p?l(c,h,n.z,n.x,n.y+1):f&&l(c,h,n.z,n.x,n.y-1);else {const e=s.visibleQuadrants;1&e&&(l(c,m,n.z,v,n.y),f&&(l(c,h,n.z,n.x,n.y-1),l(c,m,n.z,v,n.y-1))),2&e&&(l(c,g,n.z,x,n.y),f&&(l(c,h,n.z,n.x,n.y-1),l(c,g,n.z,x,n.y-1))),4&e&&(l(c,m,n.z,v,n.y),p&&(l(c,h,n.z,n.x,n.y+1),l(c,m,n.z,v,n.y+1))),8&e&&(l(c,g,n.z,x,n.y),p&&(l(c,h,n.z,n.x,n.y+1),l(c,g,n.z,x,n.y+1)));}}const c=[];for(const e of s)s.some((t=>e.isChildOf(t)))||c.push(e);if(s=c.filter((e=>!t.some((t=>!!(e.overscaledZ<i&&t.isChildOf(e))||e.equals(t)||e.isChildOf(t))))),a){const e=1<<i,t="globe"===this.projection.name?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),o=[e*t.x,e*t.y],r=4,a=r*r;s=s.filter((e=>{const t=e.canonical.x+.5-o[0],i=e.canonical.y+.5-o[1];return t*t+i*i<a}));}return s}coveringTiles(t){let i=this.coveringZoomLevel(t);const o=i,s=this.elevation&&this.elevation.exaggeration(),r=s&&!t.isTerrainDEM,a="mercator"===this.projection.name;if(void 0!==t.minzoom&&i<t.minzoom)return [];void 0!==t.maxzoom&&i>t.maxzoom&&(i=t.maxzoom);const n=this.locationCoordinate(this.center),l=this.center.lat,c=1<<i,h=[c*n.x,c*n.y,0],u="globe"===this.projection.name,d=!u,_=e.bO.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,i,d),p=u?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),f=c*e.bE(1,this.center.lat),m=this._camera.position[2]/e.bE(1,this.center.lat),g=[c*p.x,c*p.y,m*(d?1:f)],v=u||s,x=this.cameraToCenterDistance/t.tileSize*(t.roundZoom?1:.502),y=this.isLODDisabled(!0)?i:0;let b;if(this._elevation&&t.isTerrainDEM)b=1e4*this._elevation.exaggeration();else if(this._elevation){const e=this._elevation.getMinMaxForVisibleTiles();b=e?e.max:this._centerAltitude;}else b=this._centerAltitude;const w=t.isTerrainDEM?-b:this._elevation?this._elevation.getMinElevationBelowMSL():0,T=this.projection.isReprojectedInTileSpace?e.bP(this):1,E=t=>{const i=1/4e4,o=new e.a5(t.x+i,t.y,t.z),s=new e.a5(t.x,t.y+i,t.z),r=t.toLngLat(),a=o.toLngLat(),n=s.toLngLat(),l=this.locationCoordinate(r),c=this.locationCoordinate(a),h=this.locationCoordinate(n),u=Math.hypot(c.x-l.x,c.y-l.y),d=Math.hypot(h.x-l.x,h.y-l.y);return Math.sqrt(u*d)*T/i},S=t=>{const i=b,o=w;return {aabb:e.bS(this,c,0,0,0,t,o,i,this.projection),zoom:0,x:0,y:0,minZ:o,maxZ:i,wrap:t,fullyVisible:!1}},C=[];let I=[];const D=i,R=t.reparseOverscaled?o:i,A=(m-this._centerAltitude)*f,L=e=>{if(!this._elevation||!e.tileID||!a)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=M(e),e.shouldSplit||(i.min[2]=i.max[2]=i.center[2]=this._centerAltitude));},P=(e,t)=>{if(.707*t<e)return 1;const i=t/e;return i/(1.4144271570014144+(Math.pow(1.1,i-1.4144271570014144+1)-1)/(1.1-1)-1)},M=t=>{if(t.zoom<y)return !0;if(t.zoom===D)return !1;if(null!=t.shouldSplit)return t.shouldSplit;const i=t.aabb.distanceX(g),s=t.aabb.distanceY(g);let n=A,c=1;if(u){n=t.aabb.distanceZ(g);const i=Math.pow(2,t.zoom),o=e.aN((t.y+1)/i),s=e.aN(t.y/i),r=Math.min(Math.max(l,o),s),a=e.c6(r)/e.c6(l);if(c=r===l?1/Math.max(1,this._mercatorScaleRatio-.3):Math.min(1,a/this._mercatorScaleRatio),this.zoom<=e.c3&&t.zoom===D-1&&a>=.9)return !0}else if(r&&(n=t.aabb.distanceZ(g)*f),this.projection.isReprojectedInTileSpace&&o<=5){const i=Math.pow(2,t.zoom),o=E(new e.a5((t.x+.5)/i,(t.y+.5)/i));c=o>.85?1:o;}if(!a){const e=Math.sqrt(i*i+s*s+n*n);let o=(1<<D-t.zoom)*x*c;return o*=P(Math.max(n,A),e),e<o}let d=Number.MAX_VALUE,_=0;const p=t.aabb.getCorners(),m=[];for(const t of p){e.a6.vec3.sub(m,t,g),u||(r?m[2]*=f:m[2]=A);const i=e.a6.vec3.dot(m,this._camera.forward());i<d&&(d=i,_=Math.abs(m[2]));}let v=(1<<D-t.zoom)*x*c;if(v*=P(Math.max(_,A),d),d<v)return !0;const b=t.aabb.closestPoint(h);return b[0]===h[0]&&b[1]===h[1]};if(this.renderWorldCopies)for(let e=1;e<=3;e++)C.push(S(-e)),C.push(S(e));for(C.push(S(0));C.length>0;){const o=C.pop(),s=o.x,n=o.y;let l=o.fullyVisible;const d=()=>"globe"===this.projection.name&&(0===o.y||o.y===(1<<o.zoom)-1);if(!l){let t=v?o.aabb.intersects(_):o.aabb.intersectsFlat(_);if(0===t&&d()){const i=new e.bQ(o.zoom,s,n);t=e.bR(this,c,i,!0).intersects(_);}if(0===t)continue;l=2===t;}if(o.zoom!==D&&M(o))for(let t=0;t<4;t++){const i=(s<<1)+t%2,h=(n<<1)+(t>>1),d={aabb:a?o.aabb.quadrant(t):e.bS(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&&!u&&(d.tileID=new e.aA(o.zoom+1===D?R:o.zoom+1,o.wrap,o.zoom+1,i,h),L(d)),C.push(d);}else {const r=o.zoom===D?R:o.zoom;if(t.minzoom&&t.minzoom>r)continue;let a=0;if(!l){let i=v?o.aabb.intersectsPrecise(_):o.aabb.intersectsPreciseFlat(_);if(0===i&&d()){const t=new e.bQ(o.zoom,s,n);i=e.bR(this,c,t,!0).intersectsPrecise(_);}if(0===i)continue;if(t.calculateQuadrantVisibility)if(_.containsPoint(o.aabb.center))a=15;else for(let e=0;e<4;e++)0!==o.aabb.quadrant(e).intersects(_)&&(a|=1<<e);}const u=h[0]-(.5+s+(o.wrap<<o.zoom))*(1<<i-o.zoom),p=h[1]-.5-n,f=o.tileID?o.tileID:new e.aA(r,o.wrap,o.zoom,s,n);t.calculateQuadrantVisibility&&(f.visibleQuadrants=a),I.push({tileID:f,distanceSq:u*u+p*p});}}if(this.fogCullDistSq){const i=this.fogCullDistSq,o=this.horizonLineFromTop();I=I.filter((s=>{const r=[0,0,0,1],a=[e.ab,e.ab,0,1],n=this.calculateFogTileMatrix(s.tileID.toUnwrapped());e.a6.vec4.transformMat4(r,r,n),e.a6.vec4.transformMat4(a,a,n);const l=e.a6.vec4.min([],r,a),c=e.a6.vec4.max([],r,a),h=e.bT(l,c);if(0===h)return !0;let u=!1;const d=this._elevation;if(d&&h>i&&0!==o){const i=this.calculateProjMatrix(s.tileID.toUnwrapped());let r;t.isTerrainDEM||(r=d.getMinMaxForTile(s.tileID)),r||(r={min:w,max:b});const a=e.c4(this.rotation),n=[a[0]*e.ab,a[1]*e.ab,r.max];e.a6.vec3.transformMat4(n,n,i),u=(1-n[1])*this.height*.5<o;}return h<i||u}));}return I.sort(((e,t)=>e.distanceSq-t.distanceSq)).map((e=>e.tileID))}resize(e,t){this.width=e,this.height=t,this.pixelsToGLUnits=[2/e,-2/t],this._constrain(),this._calcMatrices();}get unmodified(){return this._unmodified}zoomScale(e){return Math.pow(2,e)}scaleZoom(e){return Math.log(e)/Math.LN2}project(t){const i=e.ap(t.lat,-e.bU,e.bU),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.bE(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 a=this.locationCoordinate(t);this.setLocation(new e.a5(a.x-o,a.y-s));}setLocation(e){this.center=this.coordinateLocation(e),this.projection.wrap&&(this.center=this.center.wrap());}locationPoint(e){return this.projection.locationPoint(this,e)}locationPoint3D(e){return this.projection.locationPoint(this,e,!0)}pointLocation(e){return this.coordinateLocation(this.pointCoordinate(e))}pointLocation3D(e){return this.coordinateLocation(this.pointCoordinate3D(e))}locationCoordinate(t,i){const o=i?e.bE(i,t.lat):void 0,s=this.projection.project(t.lng,t.lat);return new e.a5(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.a6.vec4.transformMat4(s,s,this.pixelMatrixInverse),e.a6.vec4.transformMat4(r,r,this.pixelMatrixInverse);const a=r[3];e.a6.vec4.scale(s,s,1/s[3]),e.a6.vec4.scale(r,r,1/a);const n=s[2],l=r[2];return {p0:s,p1:r,t:n===l?0:(o-n)/(l-n)}}screenPointToMercatorRay(t){const i=[t.x,t.y,0,1],o=[t.x,t.y,1,1];return e.a6.vec4.transformMat4(i,i,this.pixelMatrixInverse),e.a6.vec4.transformMat4(o,o,this.pixelMatrixInverse),e.a6.vec4.scale(i,i,1/i[3]),e.a6.vec4.scale(o,o,1/o[3]),i[2]=e.bE(i[2],this._center.lat)*this.worldSize,o[2]=e.bE(o[2],this._center.lat)*this.worldSize,e.a6.vec4.scale(i,i,1/this.worldSize),e.a6.vec4.scale(o,o,1/this.worldSize),new e.aj([i[0],i[1],i[2]],e.a6.vec3.normalize([],e.a6.vec3.sub([],o,i)))}rayIntersectionCoordinate(t){const{p0:i,p1:o,t:s}=t,r=e.bE(i[2],this._center.lat),a=e.bE(o[2],this._center.lat);return new e.a5(e.aa(i[0],o[0],s)/this.worldSize,e.aa(i[1],o[1],s)/this.worldSize,e.aa(r,a,s))}pointCoordinate(e,t=this._centerAltitude){return this.projection.pointCoordinate(this,e.x,e.y,t)}pointCoordinate3D(t){if(!this.elevation)return this.pointCoordinate(t);let i=this.projection.pointCoordinate3D(this,t.x,t.y);if(i)return new e.a5(i[0],i[1],i[2]);let o=0,s=this.horizonLineFromTop();if(t.y>s)return this.pointCoordinate(t);const r=.02*s,a=t.clone();for(let t=0;t<10&&s-o>r;t++){a.y=e.aa(o,s,.66);const t=this.projection.pointCoordinate3D(this,a.x,a.y);t?(s=a.y,i=t):o=a.y;}return i?new e.a5(i[0],i[1],i[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.bV)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.a6.vec4.transformMat4(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)),a=this.pointLocation3D(new e.P(s,t)),n=this.pointLocation3D(new e.P(s,o)),l=this.pointLocation3D(new e.P(i,o));let c=Math.min(r.lng,a.lng,n.lng,l.lng),h=Math.max(r.lng,a.lng,n.lng,l.lng),u=Math.min(r.lat,a.lat,n.lat,l.lat),d=Math.max(r.lat,a.lat,n.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 a=(t+o)/2,n=(i+s)/2,l=new e.P(a,n),{lng:m,lat:g}=this.pointLocation3D(l),v=Math.max(0,c-m,u-g,m-h,g-d);c=Math.min(c,m),h=Math.max(h,m),u=Math.min(u,g),d=Math.max(d,g),(r<p||v>_)&&(f(t,i,a,n,r+1),f(a,n,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.bW(this);t?(d=90,h=180,c=-180):i&&(u=-90,h=180,c=-180);}return new e.as(new e.bL(c,u),new e.bL(h,d))}_getBoundsRectangular(t,i){const{top:o,left:s}=this._edgeInsets,r=this.height-this._edgeInsets.bottom,a=this.width-this._edgeInsets.right,n=new e.P(s,o),l=new e.P(a,o),c=new e.P(a,r),h=new e.P(s,r);let u=this.pointCoordinate(n,t),d=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 u.y>1&&d.y>=0?u=new e.a5((1-p.y)/f(p,u)+p.x,1):u.y<0&&d.y<=1&&(u=new e.a5(-p.y/f(p,u)+p.x,0)),d.y>1&&u.y>=0?d=new e.a5((1-_.y)/f(_,d)+_.x,1):d.y<0&&u.y<=1&&(d=new e.a5(-_.y/f(_,d)+_.x,0)),(new e.as).extend(this.coordinateLocation(u)).extend(this.coordinateLocation(d)).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.bU,this.maxLat=e.bU,this.minLng=-180,this.maxLng=180,t&&(this.minLat=t.getSouth(),this.maxLat=t.getNorth(),this.minLng=t.getWest(),this.maxLng=t.getEast(),this.maxLng<this.minLng&&(this.maxLng+=360)),this.worldMinX=e.am(this.minLng)*this.tileSize,this.worldMaxX=e.am(this.maxLng)*this.tileSize,this.worldMinY=e.at(this.maxLat)*this.tileSize,this.worldMaxY=e.at(this.minLat)*this.tileSize,this._constrain();}calculatePosMatrix(e,t){return this.projection.createTileMatrix(this,t,e)}calculateDistanceTileData(t){const i=t.key,o=this._distanceTileDataCache;if(o[i])return o[i];const s=t.canonical,r=1/this.height,a=this.cameraWorldSize,n=a/this.zoomScale(s.z),l=(s.x+Math.pow(2,s.z)*t.wrap)*n,c=s.y*n,h=this.point;h.x*=a/this.worldSize,h.y*=a/this.worldSize;const u=this.angle,d=Math.sin(-u),_=-Math.cos(-u);return o[i]={bearing:[d,_],center:[(h.x-l)*r,(h.y-c)*r],scale:n/e.ab*r},o[i]}calculateFogTileMatrix(t){const i=t.key,o=this._fogTileMatrixCache;if(o[i])return o[i];const s=this.projection.createTileMatrix(this,this.cameraWorldSizeForFog,t);return e.a6.mat4.multiply(s,this.worldToFogMatrix,s),o[i]=new Float32Array(s),o[i]}calculateProjMatrix(t,i=!1,o=!1){const s=t.key;let r;if(r=o?this._expandedProjMatrixCache:i?this._alignedProjMatrixCache:this._projMatrixCache,r[s])return r[s];const a=this.calculatePosMatrix(t,this.worldSize);let n;return n=this.projection.isReprojectedInTileSpace?this.mercatorMatrix:o?this.expandedFarZProjMatrix:i?this.alignedProjMatrix:this.projMatrix,e.a6.mat4.multiply(a,n,a),r[s]=new Float32Array(a),r[s]}calculatePixelsToTileUnitsMatrix(t){const i=t.tileID.key,o=this._pixelsToTileUnitsCache;if(o[i])return o[i];const s=e.bX(t,this);return o[i]=s,o[i]}customLayerMatrix(){return this.mercatorMatrix.slice()}globeToMercatorMatrix(){if("globe"===this.projection.name){const t=1/this.worldSize,i=e.a6.mat4.fromScaling([],[t,t,t]);return e.a6.mat4.multiply(i,i,this.globeMatrix),i}}recenterOnTerrain(){if(!this._elevation||"globe"===this.projection.name)return;const t=this._elevation;this._updateCameraState();const i=e.bE(1,this._center.lat)*this.worldSize,o=this._computeCameraPosition(i),s=this._camera.forward(),r=e.bE(1,this._center.lat);o[2]/=r,s[2]/=r,e.a6.vec3.normalize(s,s);const a=t.raycast(o,s,t.exaggeration());if(a){const t=e.a6.vec3.scaleAndAdd([],o,s,a),i=new e.a5(t[0],t[1],e.bE(t[2],e.aN(t[1]))),n=(i.z+e.a6.vec3.length([i.x-o[0],i.y-o[1],i.z-o[2]*r]))*this._pixelsPerMercatorPixel;this._seaLevelZoom=this._zoomFromMercatorZ(n),this._centerAltitude=i.toAltitude(),this._center=this.coordinateLocation(i),this._updateZoomFromElevation(),this._constrain(),this._calcMatrices();}}_constrainCamera(t=!1){if(!this._elevation)return;const i=this._elevation,o=e.bE(1,this._center.lat)*this.worldSize,s=this._computeCameraPosition(o),r=i.getAtPointOrZero(new e.a5(...s)),a=this.pixelsPerMeter/this.worldSize*r,n=this._minimumHeightOverTerrain(),l=s[2]-a;if(l<=n)if(l<0||t){const t=this.locationCoordinate(this._center,this._centerAltitude),i=[s[0],s[1],t.z-s[2]],o=e.a6.vec3.length(i);i[2]-=(n-l)/this._pixelsPerMercatorPixel;const r=e.a6.vec3.length(i);if(0===r)return;e.a6.vec3.scale(i,i,o/r*this._pixelsPerMercatorPixel),this._camera.position=[s[0],s[1],t.z*this._pixelsPerMercatorPixel-i[2]],this._updateStateFromCamera();}else this._isCameraConstrained=!0;}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const t="globe"===this.projection.name||this.mercatorFromTransition;if(this.projection.isReprojectedInTileSpace||t){const i=this.center;return i.lat=e.ap(i.lat,this.minLat,this.maxLat),(this.maxBounds||!this.renderWorldCopies&&!t)&&(i.lng=e.ap(i.lng,this.minLng,this.maxLng)),this.center=i,void(this._constraining=!1)}const i=this._unmodified,{x:o,y:s}=this.point;let r=0,a=o,n=s;const l=this.width/2,c=this.height/2,h=this.worldMinY*this.scale,u=this.worldMaxY*this.scale;if(s-c<h&&(n=h+c),s+c>u&&(n=u-c),u-h<this.height&&(r=Math.max(r,this.height/(u-h)),n=(u+h)/2),this.maxBounds||!this._renderWorldCopies||!this.projection.wrap){const e=this.worldMinX*this.scale,t=this.worldMaxX*this.scale,i=this.worldSize/2-(e+t)/2;a=(o+i+this.worldSize)%this.worldSize-i,a-l<e&&(a=e+l),a+l>t&&(a=t-l),t-e<this.width&&(r=Math.max(r,this.width/(t-e)),a=(t+e)/2);}a===o&&n===s||(this.center=this.unproject(new e.P(a,n))),r&&(this.zoom+=this.scaleZoom(r)),this._constrainCamera(),this._unmodified=i,this._constraining=!1;}_minZoomForBounds(){let e=Math.max(0,this.scaleZoom(this.height/(this.worldMaxY-this.worldMinY)));return this.maxBounds&&(e=Math.max(e,this.scaleZoom(this.width/(this.worldMaxX-this.worldMinX)))),e}_maxCameraBoundsDistance(){return this._mercatorZfromZoom(this._minZoomForBounds())}_calcMatrices(){if(!this.height)return;const t=this.centerOffset,i="globe"===this.projection.name,o=this.pixelsPerMeter;"globe"===this.projection.name&&(this._mercatorScaleRatio=e.bE(1,this.center.lat)/e.bE(1,e.c5));const s=e.bY(this.projection,this.zoom,this.width,this.height,1024);this._pixelsPerMercatorPixel=this.projection.pixelSpaceConversion(this.center.lat,this.worldSize,s),this.cameraToCenterDistance=.5/Math.tan(.5*this._fov)*this.height*this._pixelsPerMercatorPixel,this._updateCameraState(),this._farZ=this.projection.farthestPixelDistance(this),this._nearZ=this.height/50;const r="meters"===this.projection.zAxisUnit?o:1,a=this._camera.getWorldToCamera(this.worldSize,r);let n;const l=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,this._farZ);if(l[8]=2*-t.x/this.width,l[9]=2*t.y/this.height,this.isOrthographic){let e=.5*this.height/Math.tan(this._fov/2)*1*Math.tan(.5*this._fov),i=e*this.aspect,o=-i,s=-e;i-=t.x,o-=t.x,e+=t.y,s+=t.y,n=this._camera.getCameraToClipOrthographic(o,i,s,e,this._nearZ,this._farZ),((e,t,i,o)=>{for(let s=0;s<16;s++)e[s]=ji(t[s],i[s],o);})(n,n,l,Hi(this.pitch>=15?1:this.pitch/15));}else n=l;const c=e.a6.mat4.mul([],l,a);let h=e.a6.mat4.mul([],n,a);if(this.projection.isReprojectedInTileSpace){const t=this.locationCoordinate(this.center),i=e.a6.mat4.identity([]);e.a6.mat4.translate(i,i,[t.x*this.worldSize,t.y*this.worldSize,0]),e.a6.mat4.multiply(i,i,e.bZ(this)),e.a6.mat4.translate(i,i,[-t.x*this.worldSize,-t.y*this.worldSize,0]),e.a6.mat4.multiply(h,h,i),e.a6.mat4.multiply(c,c,i),this.inverseAdjustmentMatrix=e.b_(this);}else this.inverseAdjustmentMatrix=[1,0,0,1];if(this.mercatorMatrix=e.a6.mat4.scale([],h,[this.worldSize,this.worldSize,this.worldSize/r,1]),this.projMatrix=h,this.invProjMatrix=e.a6.mat4.invert(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.a6.mat4.mul([],i,a);}else this.expandedFarZProjMatrix=this.projMatrix;const u=e.a6.mat4.invert([],n);this.frustumCorners=e.b$.fromInvProjectionMatrix(u,this.horizonLineFromTop(),this.height),this.cameraFrustum=e.bO.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!i);const d=new Float32Array(16);e.a6.mat4.identity(d),e.a6.mat4.scale(d,d,[1,-1,1]),e.a6.mat4.rotateX(d,d,this._pitch),e.a6.mat4.rotateZ(d,d,this.angle);const _=e.a6.mat4.perspective(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ);this.starsProjMatrix=e.a6.mat4.clone(_);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.a6.mat4.multiply(d,_,d);const f=this.point,m=f.x,g=f.y,v=this.width%2/2,x=this.height%2/2,y=Math.cos(this.angle),b=Math.sin(this.angle),w=m-Math.round(m)+y*v+b*x,T=g-Math.round(g)+y*x+b*v,E=new Float64Array(h);if(e.a6.mat4.translate(E,E,[w>.5?w-1:w,T>.5?T-1:T,0]),this.alignedProjMatrix=E,h=e.a6.mat4.create(),e.a6.mat4.scale(h,h,[this.width/2,-this.height/2,1]),e.a6.mat4.translate(h,h,[1,-1,0]),this.labelPlaneMatrix=h,h=e.a6.mat4.create(),e.a6.mat4.scale(h,h,[1,-1,1]),e.a6.mat4.translate(h,h,[-1,-1,0]),e.a6.mat4.scale(h,h,[2/this.width,2/this.height,1]),this.glCoordMatrix=h,this.pixelMatrix=e.a6.mat4.multiply(new Float64Array(16),this.labelPlaneMatrix,c),this._calcFogMatrices(),this._distanceTileDataCache={},h=e.a6.mat4.invert(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.c0(this);const t=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=e.a6.vec3.transformMat4(t,t,a),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.a6.vec3.scale(r,r,s),e.a6.vec3.scale(o,o,-1),e.a6.vec3.multiply(o,o,r);const a=e.a6.mat4.create();e.a6.mat4.translate(a,a,o),e.a6.mat4.scale(a,a,r),this.mercatorFogMatrix=a,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.a6.vec3.scaleAndAdd([],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.bE(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,a=this._mercatorZfromZoom(this._maxZoom)*Math.cos(e.bC(this._maxPitch)),n=Math.max((t[2]-r)/Math.cos(o),a),l=this._zoomFromMercatorZ(n);e.a6.vec3.scaleAndAdd(t,t,i,n),this._pitch=e.ap(o,e.bC(this.minPitch),e.bC(this.maxPitch)),this.angle=e.bB(s,-Math.PI,Math.PI),this._setZoom(e.ap(l,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new e.a5(t[0],t[1],t[2])),this._unmodified=!1,this._constrain(),this._calcMatrices();}_worldSizeFromZoom(e){return Math.pow(2,e)*this.tileSize}_mercatorZfromZoom(e){return this.cameraToCenterDistance/this._worldSizeFromZoom(e)}_minimumHeightOverTerrain(){const e=Math.min(null!=this._seaLevelZoom?this._seaLevelZoom:this._zoom,this._maxZoom)+4;return this._mercatorZfromZoom(e)}_zoomFromMercatorZ(e){return this.scaleZoom(this.cameraToCenterDistance/(e*this.tileSize))}zoomFromMercatorZAdjusted(t){let i=0,o=e.bV,s=0,r=1/0;for(;o-i>1e-6&&o>i;){const e=i+.5*(o-i),a=this.tileSize*Math.pow(2,e),n=this.getCameraToCenterDistance(this.projection,e,a),l=this.scaleZoom(n/(t*this.tileSize)),c=Math.abs(e-l);c<r&&(r=c,s=e),e<l?i=e:o=e;}return s}_terrainEnabled(){return !(!this._elevation||!this.projection.supportsTerrain&&(e.w("Terrain is not yet supported with alternate projections. Use mercator or globe to enable terrain."),1))}anyCornerOffEdge(t,i){const o=Math.min(t.x,i.x),s=Math.max(t.x,i.x),r=Math.min(t.y,i.y),a=Math.max(t.y,i.y);if(r<this.horizonLineFromTop(!1))return !0;if("mercator"!==this.projection.name)return !1;const n=[new e.P(o,r),new e.P(s,a),new e.P(o,a),new e.P(s,r)],l=this.renderWorldCopies?-3:0,c=this.renderWorldCopies?4:1;for(const e of n){const t=this.pointRayIntersection(e);if(t.t<0)return !0;const i=this.rayIntersectionCoordinate(t);if(i.x<l||i.y<0||i.x>c||i.y>1)return !0}return !1}isHorizonVisible(){return this.pitch+e.c1(this.fovAboveCenter)>88||this.anyCornerOffEdge(new e.P(0,0),new e.P(this.width,this.height))}zoomDeltaToMovement(t,i){const o=e.a6.vec3.length(e.a6.vec3.sub([],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.a6.vec4.transformMat4(r,r,s);const a=r[3]=Math.max(r[3],1e-6);return r[0]/=a,r[1]/=a,r[2]/=a,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.bY(t,i,this.width,this.height,1024),r=t.pixelSpaceConversion(this.center.lat,o,s);let a=.5/Math.tan(.5*this._fov)*this.height*r;return this.isOrthographic&&(a=ji(1,a,Hi(this.pitch>=15?1:this.pitch/15))),a}getWorldToCameraMatrix(){const t=this._camera.getWorldToCamera(this.worldSize,"meters"===this.projection.zAxisUnit?this.pixelsPerMeter:1);return "globe"===this.projection.name&&e.a6.mat4.multiply(t,t,this.globeMatrix),t}getFrustum(t){return e.bO.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,t,"meters"===this.projection.zAxisUnit)}}const qi=(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.a7(60,45,o.pitch):e.a7(30,15,o.pitch),a=o._farZ-o._nearZ,n=i*o.height,l=((1-(c=r))*o.cameraToCenterDistance+c*(o._farZ+n))*s;var c;return {shouldRenderCutoff:r<1,uniformValues:{u_cutoff_params:[o._nearZ,o._farZ,(l-o._nearZ)/a,(l-n-o._nearZ)/a]}}},Wi={cascadeCount:2,normalOffset:3,shadowMapResolution:2048};class $i{constructor(e,t){this.aabb=e,this.lastCascade=t;}}class Xi{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 $i(t,null);}clear(){this.receivers={};}get(e){return this.receivers[e.key]}computeRequiredCascades(t,i,o){const s=e.ca.fromPoints(t.points);let r=0;for(const t in this.receivers){const a=this.receivers[t];if(!a)continue;if(!s.intersectsAabb(a.aabb))continue;a.aabb.min=s.closestPoint(a.aabb.min),a.aabb.max=s.closestPoint(a.aabb.max);const n=a.aabb.getCorners();for(let t=0;t<o.length;t++){let s=!0;for(const r of n){const a=[r[0]*i,r[1]*i,r[2]];if(e.a6.vec3.transformMat4(a,a,o[t].matrix),a[0]<-1||a[0]>1||a[1]<-1||a[1]>1){s=!1;break}}if(a.lastCascade=t,r=Math.max(r,t),s)break}}return r+1}}class Ji{constructor(e){this.painter=e,this._enabled=!1,this._shadowLayerCount=0,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new Xi,this._depthMode=new Ai(e.context.gl.LEQUAL,Ai.ReadWrite,[0,1]),this._uniformValues={u_light_matrix_0:new Float32Array(16),u_light_matrix_1:new Float32Array(16),u_shadow_intensity:0,u_fade_range:[0,0],u_shadow_normal_offset:[1,1,1],u_shadow_texel_size:1,u_shadow_map_resolution:1,u_shadow_direction:[0,0,1],u_shadow_bias:[36e-5,.0012,.012],u_shadowmap_0:0,u_shadowmap_1:0},this._forceDisable=!1,this.useNormalOffset=!1,e.tp.registerParameter(this,["Shadows"],"_forceDisable",{label:"forceDisable"},(()=>{this.painter.style.map.triggerRepaint();})),e.tp.registerParameter(Wi,["Shadows"],"cascadeCount",{min:1,max:2,step:1}),e.tp.registerParameter(Wi,["Shadows"],"normalOffset",{min:0,max:10,step:.05}),e.tp.registerParameter(Wi,["Shadows"],"shadowMapResolution",{min:32,max:2048,step:32}),e.tp.registerBinding(this,["Shadows"],"_numCascadesToRender",{readonly:!0,label:"numCascadesToRender"});}destroy(){for(const e of this._cascades)e.texture.destroy(),e.framebuffer.destroy();this._cascades=[];}updateShadowParameters(t,i){const o=this.painter;if(this._enabled=!1,this._shadowLayerCount=0,this._receivers.clear(),!i||!i.properties)return;const s=i.properties.get("shadow-intensity");if(!i.shadowsEnabled()||s<=0)return;if(this._shadowLayerCount=o.style.order.reduce(((e,i)=>{const s=o.style._mergedLayers[i];return e+(s.hasShadowPass()&&!s.isHidden(t.zoom)?1:0)}),0),this._enabled=this._shadowLayerCount>0,!this.enabled)return;const r=o.context,a=Wi.shadowMapResolution,n=Wi.shadowMapResolution;if(0===this._cascades.length||Wi.shadowMapResolution!==this._cascades[0].texture.size[0]){this._cascades=[];for(let t=0;t<Wi.cascadeCount;++t){const t=o._shadowMapDebug,i=r.gl,s=r.createFramebuffer(a,n,t,"texture"),l=new e.T(r,{width:a,height:n,data:null},i.DEPTH_COMPONENT16);if(s.depthAttachment.set(l.texture),t){const t=new e.T(r,{width:a,height:n,data:null},i.RGBA8);s.colorAttachment.set(t.texture);}this._cascades.push({framebuffer:s,texture:l,matrix:[],far:0,boundingSphereRadius:0,frustum:new e.bO,scale:0});}}this.shadowDirection=Yi(i);let l=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]&&(l=(i[1]-i[0])*e.exaggeration());}const c=1.5*t.cameraToCenterDistance,h=3*c,u=new Float64Array(16);for(let i=0;i<this._cascades.length;++i){const o=this._cascades[i];let s=t.height/50,r=1;1===Wi.cascadeCount?r=h:0===i?r=c:(s=c,r=h);const[a,n]=eo(t,this.shadowDirection,s,r,Wi.shadowMapResolution,l);o.scale=t.scale,o.matrix=a,o.boundingSphereRadius=n,e.a6.mat4.invert(u,o.matrix),o.frustum=e.bO.fromInvProjectionMatrix(u,1,0,!0),o.far=r;}const d=this._cascades.length-1;this._uniformValues.u_fade_range=[.75*this._cascades[d].far,this._cascades[d].far],this._uniformValues.u_shadow_intensity=s,this._uniformValues.u_shadow_direction=[this.shadowDirection[0],this.shadowDirection[1],this.shadowDirection[2]],this._uniformValues.u_shadow_texel_size=1/Wi.shadowMapResolution,this._uniformValues.u_shadow_map_resolution=Wi.shadowMapResolution,this._uniformValues.u_shadowmap_0=Gi.ShadowMap0,this._uniformValues.u_shadowmap_1=Gi.ShadowMap0+1,this._groundShadowTiles=o.transform.coveringTiles({tileSize:512,renderWorldCopies:!0});const _=o.transform.elevation;for(const e of this._groundShadowTiles){let t={min:0,max:0};if(_){const i=_.getMinMaxForTile(e);i&&(t=i);}this.addShadowReceiver(e.toUnwrapped(),t.min,t.max);}}get enabled(){return this._enabled&&!this._forceDisable}set enabled(e){this._enabled=e;}drawShadowPass(t,i){if(!this.enabled)return;const o=this.painter,s=o.context;this._numCascadesToRender=this._receivers.computeRequiredCascades(o.transform.getFrustum(0),o.transform.worldSize,this._cascades),s.viewport.set([0,0,Wi.shadowMapResolution,Wi.shadowMapResolution]);for(let r=0;r<this._numCascadesToRender;++r){o.currentShadowCascade=r,s.bindFramebuffer.set(this._cascades[r].framebuffer.framebuffer),s.clear({color:e.bA.white,depth:1});for(const e of t.order){const s=t._mergedLayers[e];if(!s.hasShadowPass()||s.isHidden(o.transform.zoom))continue;const r=t.getLayerSourceCache(s),a=r?i[r.id]:void 0;("model"===s.type||a&&a.length)&&o.renderLayer(o,r,s,a);}}o.currentShadowCascade=0;}drawGroundShadows(){if(!this.enabled)return;const e=this.painter,t=e.style,i=e.context,o=t.directionalLight,s=t.ambientLight;if(!o||!s)return;const r=[],a=qi(e,e.longestCutoffRange);a.shouldRenderCutoff&&r.push("RENDER_CUTOFF"),r.push("RENDER_SHADOWS","DEPTH_TEXTURE"),this.useNormalOffset&&r.push("NORMAL_OFFSET");const n=Qi(t,o,s),l=new Ai(i.gl.LEQUAL,Ai.ReadOnly,e.depthRangeFor3D);for(const t of this._groundShadowTiles){const o=t.toUnwrapped(),s=e.isTileAffectedByFog(t),c=e.getOrCreateProgram("groundShadow",{defines:r,overrideFog:s});this.setupShadows(o,c),e.uploadCommonUniforms(i,c,o,null,a);const h={u_matrix:e.transform.calculateProjMatrix(o),u_ground_shadow_factor:n};c.draw(e,i.gl.TRIANGLES,l,Pi.disabled,Ri.multiply,Oi.disabled,h,"ground_shadow",e.tileExtentBuffer,e.quadTriangleIndexBuffer,e.tileExtentSegments,{},e.transform.zoom,null,null);}}getShadowPassColorMode(){return this.painter._shadowMapDebug?Ri.unblended:Ri.disabled}getShadowPassDepthMode(){return this._depthMode}getShadowCastingLayerCount(){return this._shadowLayerCount}calculateShadowPassMatrixFromTile(t){const i=this.painter.transform,o=i.calculatePosMatrix(t,i.worldSize);return e.a6.mat4.multiply(o,this._cascades[this.painter.currentShadowCascade].matrix,o),Float32Array.from(o)}calculateShadowPassMatrixFromMatrix(t){return e.a6.mat4.multiply(t,this._cascades[this.painter.currentShadowCascade].matrix,t),Float32Array.from(t)}setupShadows(t,i,o,s=0){if(!this.enabled)return;const r=this.painter.transform,a=this.painter.context,n=a.gl,l=this._uniformValues,c=new Float64Array(16),h=r.calculatePosMatrix(t,r.worldSize);for(let t=0;t<this._cascades.length;t++)e.a6.mat4.multiply(c,this._cascades[t].matrix,h),l[0===t?"u_light_matrix_0":"u_light_matrix_1"]=Float32Array.from(c),a.activeTexture.set(n.TEXTURE0+Gi.ShadowMap0+t),this._cascades[t].texture.bind(n.NEAREST,n.CLAMP_TO_EDGE);if(this.useNormalOffset=!!o,this.useNormalOffset){const i=e.c9(t.canonical),a=2/r.tileSize*e.ab/Wi.shadowMapResolution,n=a*this._cascades[0].boundingSphereRadius,c=a*this._cascades[this._cascades.length-1].boundingSphereRadius,h=("vector-tile"===o?1:3)/Math.pow(2,s-t.canonical.z-(1-r.zoom+Math.floor(r.zoom)));l.u_shadow_normal_offset=[i,n*h,c*h],l.u_shadow_bias=[6e-5,.0012,.012];}else l.u_shadow_bias=[36e-5,.0012,.012];i.setShadowUniformValues(a,l);}setupShadowsFromMatrix(t,i,o=!1){if(!this.enabled)return;const s=this.painter.context,r=s.gl,a=this._uniformValues,n=new Float64Array(16);for(let i=0;i<Wi.cascadeCount;i++)e.a6.mat4.multiply(n,this._cascades[i].matrix,t),a[0===i?"u_light_matrix_0":"u_light_matrix_1"]=Float32Array.from(n),s.activeTexture.set(r.TEXTURE0+Gi.ShadowMap0+i),this._cascades[i].texture.bind(r.NEAREST,r.CLAMP_TO_EDGE);if(this.useNormalOffset=o,o){const e=Wi.normalOffset;a.u_shadow_normal_offset=[1,e,e],a.u_shadow_bias=[6e-5,.0012,.012];}else a.u_shadow_bias=[36e-5,.0012,.012];i.setShadowUniformValues(s,a);}getShadowUniformValues(){return this._uniformValues}getCurrentCascadeFrustum(){return this._cascades[this.painter.currentShadowCascade].frustum}computeSimplifiedTileShadowVolume(t,i,o,s){if(s[2]>=0)return {};const r=function(t,i,o){const s=o/(1<<t.canonical.z);return new e.ca([t.canonical.x*s+t.wrap*o,t.canonical.y*s+t.wrap*o,0],[(t.canonical.x+1)*s+t.wrap*o,(t.canonical.y+1)*s+t.wrap*o,i])}(t,i,o).getCorners(),a=i/-s[2];s[0]<0?(e.a6.vec3.add(r[0],r[0],[s[0]*a,0,0]),e.a6.vec3.add(r[3],r[3],[s[0]*a,0,0])):s[0]>0&&(e.a6.vec3.add(r[1],r[1],[s[0]*a,0,0]),e.a6.vec3.add(r[2],r[2],[s[0]*a,0,0])),s[1]<0?(e.a6.vec3.add(r[0],r[0],[0,s[1]*a,0]),e.a6.vec3.add(r[1],r[1],[0,s[1]*a,0])):s[1]>0&&(e.a6.vec3.add(r[2],r[2],[0,s[1]*a,0]),e.a6.vec3.add(r[3],r[3],[0,s[1]*a,0]));const n={};return n.vertices=r,n.planes=[Ki(r[1],r[0],r[4]),Ki(r[2],r[1],r[5]),Ki(r[3],r[2],r[6]),Ki(r[0],r[3],r[7])],n}addShadowReceiver(t,i,o){this._receivers.add(t,e.ca.fromTileIdAndHeight(t,i,o));}getMaxCascadeForTile(e){const t=this._receivers.get(e);return t&&t.lastCascade?t.lastCascade:0}}function Ki(t,i,o){const s=e.a6.vec3.sub([],o,i),r=e.a6.vec3.sub([],t,i),a=e.a6.vec3.cross([],s,r),n=e.a6.vec3.length(a);return 0===n?[0,0,1,0]:(e.a6.vec3.scale(a,a,1/n),[a[0],a[1],a[2],-e.a6.vec3.dot(a,i)])}function Yi(t){const i=t.properties.get("direction"),o=e.c8(i.x,i.y,i.z);o[2]=e.ap(o[2],0,75);const s=e.cb([o[0],o[1],o[2]]);return e.a6.vec3.fromValues(s.x,s.y,s.z)}function Qi(t,i,o){const s=i.properties.get("color"),r=i.properties.get("intensity"),a=i.properties.get("direction"),n=[a.x,a.y,a.z],l=o.properties.get("color"),c=o.properties.get("intensity"),h=Math.max(e.a6.vec3.dot([0,0,1],n),0),u=[0,0,0];e.a6.vec3.scale(u,l.toRenderColor(t.getLut(i.scope)).toArray01Linear().slice(0,3),c);const d=[0,0,0];return e.a6.vec3.scale(d,s.toRenderColor(t.getLut(o.scope)).toArray01Linear().slice(0,3),h*r),e.cc([u[0]>0?u[0]/(u[0]+d[0]):0,u[1]>0?u[1]/(u[1]+d[1]):0,u[2]>0?u[2]/(u[2]+d[2]):0])}function eo(t,i,o,s,r,a){const n=t.zoom,l=t.scale,c=t.worldSize,h=1/c,u=t.aspect,d=Math.sqrt(1+u*u)*Math.tan(.5*t.fovX),_=d*d,p=s-o,f=s+o;let m,g;_>p/f?(m=s,g=s*d):(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),x=t._camera.getCameraToWorldMercator(),y=[0,0,-m*h];e.a6.vec3.transformMat4(y,y,x);let b=g*h;const w=t._edgeInsets;if(!(0===w.left&&0===w.top&&0===w.right&&0===w.bottom||w.left===w.right&&w.top===w.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 a=new Float64Array(16);e.a6.mat4.mul(a,r,i);const h=new Float64Array(16);e.a6.mat4.invert(h,a);const u=e.bO.fromInvProjectionMatrix(h,c,n,!0);for(const i of u.points){const o=((T=i)[0]/=l,T[1]/=l,T[2]=e.bE(T[2],t._center.lat),T);b=Math.max(b,e.a6.vec3.len(e.a6.vec3.subtract([],y,o)));}}var T;b*=r/(r-1);const E=Math.acos(i[2]),S=Math.atan2(-i[0],-i[1]),C=new Ui;C.position=y,C.setPitchBearing(E,S);const I=C.getWorldToCamera(c,v),D=b*c,R=Math.min(t._mercatorZfromZoom(17)*c*-2,-2*D),A=C.getCameraToClipOrthographic(-D,D,-D,D,R,(D+a*v)/i[2]),L=new Float64Array(16);e.a6.mat4.multiply(L,A,I);const P=e.a6.vec3.fromValues(Math.floor(1e6*y[0])/1e6*c,Math.floor(1e6*y[1])/1e6*c,0),M=.5*r,z=[0,0,0];e.a6.vec3.transformMat4(z,P,L),e.a6.vec3.scale(z,z,M);const O=[Math.floor(z[0]),Math.floor(z[1]),Math.floor(z[2])],F=[0,0,0];e.a6.vec3.sub(F,z,O),e.a6.vec3.scale(F,F,-1/M);const B=new Float64Array(16);return e.a6.mat4.identity(B),e.a6.mat4.translate(B,B,F),e.a6.mat4.multiply(L,B,L),[L,D]}class to extends e.E{constructor(e){super(),this.requestManager=e,this.models={"":{}},this.numModelsLoading={};}loadModel(t,i){return e.aG(this.requestManager.transformRequest(i,e.R.Model).url).then((i=>{if(!i)return;const o=e.aH(i),s=new e.aI(t,void 0,void 0,o);return s.computeBoundsAndApplyParent(),s})).catch((o=>{if(o&&404===o.status)return null;this.fire(new e.t(new Error(`Could not load model ${t} from ${i}: ${o.message}`)));}))}load(t,i){this.models[i]||(this.models[i]={});const o=Object.keys(t);this.numModelsLoading[i]=(this.numModelsLoading[i]||0)+o.length;const s=[];for(const e of o)s.push(this.loadModel(e,t[e]));Promise.allSettled(s).then((t=>{for(let e=0;e<t.length;e++){const{status:s,value:r}=t[e];"fulfilled"===s&&r&&(this.models[i][o[e]]={model:r,numReferences:1});}this.numModelsLoading[i]-=o.length,this.fire(new e.x("data",{dataType:"style"}));})).catch((t=>{this.fire(new e.t(new Error(`Could not load models: ${t.message}`)));}));}isLoaded(){for(const e in this.numModelsLoading)if(this.numModelsLoading[e]>0)return !1;return !0}hasModel(e,t){return !!this.getModel(e,t)}getModel(e,t){return this.models[t]||(this.models[t]={}),this.models[t][e]?this.models[t][e].model:void 0}addModel(e,t,i){this.models[i]||(this.models[i]={}),this.hasModel(e,i)&&this.models[i][e].numReferences++,this.load({[e]:this.requestManager.normalizeModelURL(t)},i);}addModels(e,t){this.models[t]||(this.models[t]={});const i={};for(const o in e)this.models[t][o]={},i[o]=this.requestManager.normalizeModelURL(e[o]);this.load(i,t);}addModelsFromBucket(e,t){this.models[t]||(this.models[t]={});const i={};for(const o of e)this.hasModel(o,t)?this.models[t][o].numReferences++:i[o]=this.requestManager.normalizeModelURL(o);this.load(i,t);}removeModel(e,t){if(this.models[t]&&this.models[t][e]&&(this.models[t][e].numReferences--,0===this.models[t][e].numReferences)){const i=this.models[t][e].model;delete this.models[t][e],i.destroy();}}listModels(e){return this.models[e]||(this.models[e]={}),Object.keys(this.models[e])}upload(e,t){this.models[t]||(this.models[t]={});for(const i in this.models[t])this.models[t][i].model&&this.models[t][i].model.upload(e.context);}}const io=new e.a0({data:new e.a1(e._.colorTheme.data)}),oo=(e,t)=>De(e,t&&t.filter((e=>"source.canvas"!==e.identifier))),so=e.ar(Et,["addLayer","removeLayer","setLights","setPaintProperty","setLayoutProperty","setSlot","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection","setCamera","addImport","removeImport","updateImport"]),ro=e.ar(Et,["setCenter","setZoom","setBearing","setPitch"]),ao={version:8,layers:[],sources:{}},no={duration:300,delay:0};class lo 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=e.l({},no),this._buildingIndex=new bt(this),this.crossTileSymbolIndex=new Ii,this._mergedOrder=[],this._drapedFirstOrder=[],this._mergedLayers={},this._mergedSourceCaches={},this._mergedOtherSourceCaches={},this._mergedSymbolSourceCaches={},this._mergedLayerSelectors=new Map,this._clipLayerPresent=!1,this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this._changes=i.styleChanges||new V,this.dispatcher=i.dispatcher?i.dispatcher:new e.ce(e.cf(),this),i.imageManager?this.imageManager=i.imageManager:(this.imageManager=new H,this.imageManager.setEventedParent(this)),this.imageManager.createScope(this.scope),this.glyphManager=i.glyphManager?i.glyphManager:new e.cg(t._requestManager,i.localFontFamily?e.ch.all:i.localIdeographFontFamily?e.ch.ideographs:e.ch.none,i.localFontFamily||i.localIdeographFontFamily),i.modelManager?this.modelManager=i.modelManager:(this.modelManager=new to(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._order=[],this._markersNeedUpdate=!1,this._styleColorTheme={lut:null,lutLoading:!1,lutLoadingCorrelationID:0,colorTheme:null},this._styleColorThemeForScope={},this.options=i.configOptions?i.configOptions:new Map,this._configDependentLayers=i.configDependentLayers?i.configDependentLayers:new Set,this._config=i.config,this._initialConfig=i.initialConfig,this.dispatcher.broadcast("setReferrer",e.ci());const o=this;this._rtlTextPluginCallback=lo.registerForPluginStateChange((t=>{o.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:t.pluginStatus,pluginURL:t.pluginURL},((t,i)=>{if(e.cj(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.f(t))return t;const i=e.ck(t);if(!i.startsWith("http"))try{return new URL(i,location.href).toString()}catch(e){return i}return i}return `json://${e.cl(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.n(r,((t,o)=>{t?this.fire(new e.t(t)):o&&s(o,i);}));}else "object"==typeof t&&s(t,i);}loadURL(t,i={}){this.fire(new e.x("dataloading",{dataType:"style"}));const o="boolean"==typeof i.validate?i.validate:!e.f(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.n(r,((i,s)=>{if(this._request=null,i)this.fire(new e.t(i));else if(s)return this.importsCache.set(t,s),this._load(s,o)}));}loadJSON(t,i={}){this.fire(new e.x("dataloading",{dataType:"style"})),this.globalId=this._getGlobalId(t),this._request=e.q.frame((()=>{this._request=null,this._load(t,!1!==i.validate);}));}loadEmpty(){this.fire(new e.x("dataloading",{dataType:"style"})),this._load(ao,!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 a=e.data||this.importsCache.get(e.url);a?(t.loadJSON(a,{validate:i}),this._isInternalStyle(a)&&(t.globalId=null)):e.url?t.loadURL(e.url,{validate:i}):t.loadEmpty();const n={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(n).concat(this.fragments.slice(e));}else this.fragments.push(n);}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.av(t.id,this.scope):t.id;let o;const s=this._initialConfig&&this._initialConfig[i];(t.config||s)&&(o=e.l({},t.config,s));const r=new lo(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,configDependentLayers:this._configDependentLayers});return r.setEventedParent(this.map,{style:r}),r}_reloadImports(){this.mergeAll(),this._updateMapProjection(),this.updateConfigDependencies(),this.map._triggerCameraUpdate(this.camera),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),this._shouldPrecompile=this.map._precompilePrograms&&this.isRootStyle();}_isInternalStyle(e){return this.isRootStyle()&&(e.fragment||!!e.schema&&!1!==e.fragment)}_load(t,i){const o=t.schema;if(this._isInternalStyle(t)){const o=e.l({},ao,{imports:[{id:"basemap",data:t,url:""}]});return void this._load(o,i)}if(this.updateConfig(this._config,o),i&&oo(this,me(t)))return;this._loaded=!0,this.stylesheet=e.cm(t);const s=()=>{for(const e in t.sources)this.addSource(e,t.sources[e],{validate:!1,isInitialLoad:!0});t.sprite?this._loadSprite(t.sprite):(this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0})),this.glyphManager.setURL(t.glyphs,this.scope);const o=Tt(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 Ae(e.properties,e.id);}else this.setLights(this.stylesheet.lights);this.light||(this.light=new Ae(this.stylesheet.light)),this._layers={};for(const t of o){const i=e.cq(t,this.scope,this._styleColorTheme.lut,this.options);0!==i.configDependencies.size&&this._configDependentLayers.add(i.fqid),i.setEventedParent(this,{layer:{id:i.id}}),this._layers[i.id]=i;const o=this.getOwnLayerSourceCache(i),s=!!this.directionalLight&&this.directionalLight.shadowsEnabled();o&&i.canCastShadows()&&s&&(o.castsShadows=!0);}this.stylesheet.models&&this.modelManager.addModels(this.stylesheet.models,this.scope);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.transition&&this.setTransition(this.stylesheet.transition),this.fire(new e.x("data",{dataType:"style"}));const r=this.isRootStyle();t.imports?this._loadImports(t.imports,i).then((()=>{this._reloadImports(),this.fire(new e.x(r?"style.load":"style.import.load"));})):(this._reloadImports(),this.fire(new e.x(r?"style.load":"style.import.load")));},r=this.stylesheet["color-theme"];if(this._styleColorTheme.colorTheme=r,r){const t=this._evaluateColorThemeData(r);this._loadColorTheme(t).then((()=>{s();})).catch((t=>{e.w(`Couldn't load color theme from the stylesheet: ${t}`),s();}));}else this._styleColorTheme.lut=null,s();}isRootStyle(){return 0===this.importDepth}mergeAll(){let t,i,o,s,r,a,n,l;const c={};this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle((e=>{if(e.stylesheet){if(null!=e.light&&(t=e.light),e.stylesheet.lights)for(const t of e.stylesheet.lights)"ambient"===t.type&&null!=e.ambientLight&&(i=e.ambientLight),"directional"===t.type&&null!=e.directionalLight&&(o=e.directionalLight);s=this._prioritizeTerrain(s,e.terrain,e.stylesheet.terrain),e.stylesheet.fog&&null!=e.fog&&(r=e.fog),null!=e.stylesheet.camera&&(l=e.stylesheet.camera),null!=e.stylesheet.projection&&(a=e.stylesheet.projection),null!=e.stylesheet.transition&&(n=e.stylesheet.transition),c[e.scope]=e._styleColorTheme;}})),this.light=t,this.ambientLight=i,this.directionalLight=o,this.fog=r,this._styleColorThemeForScope=c,null===s?delete this.terrain:this.terrain=s,this.camera=l||{"camera-projection":"perspective"},this.projection=a||{name:"mercator"},this.transition=e.l({},no,n),this.mergeSources(),this.mergeLayers();}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.av(i,s.scope);t[o]=s._sourceCaches[i];}for(const t in s._otherSourceCaches){const o=e.av(t,s.scope);i[o]=s._otherSourceCaches[t];}for(const t in s._symbolSourceCaches){const i=e.av(t,s.scope);o[i]=s._symbolSourceCaches[t];}})),this._mergedSourceCaches=t,this._mergedOtherSourceCaches=i,this._mergedSymbolSourceCaches=o;}mergeLayers(){const t={},i=[],o={};this._mergedSlots=[],this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this._mergedLayerSelectors.clear(),this.forEachFragmentStyle((o=>{for(const s of o._order){const r=o._layers[s];if("slot"===r.type){const i=e.cn(s);if(t[i])continue;t[i]=[];}r.slot&&t[r.slot]?t[r.slot].push(r):i.push(r);}const{featuresets:s}=o.stylesheet||{};if(s)for(const t in s){const{selectors:i}=s[t];for(const s of i){const i=o._layers[s.layer],r=this._mergedLayerSelectors.get(i.fqid)||[];let a;if(s.properties)for(const t in s.properties){const i=e.M(s.properties[t]);"success"===i.result&&(a=a||{},a[t]=i.value);}r.push({featuresetId:t,featureNamespace:s.featureNamespace,properties:a}),this._mergedLayerSelectors.set(i.fqid,r);}}})),this._mergedOrder=[];const s=(i=[])=>{for(const r of i)if("slot"===r.type){const i=e.cn(r.id);t[i]&&s(t[i]),this._mergedSlots.push(i);}else {const t=e.av(r.id,r.scope);this._mergedOrder.push(t),o[t]=r,r.is3D()&&(this._has3DLayers=!0),"circle"===r.type&&(this._hasCircleLayers=!0),"symbol"===r.type&&(this._hasSymbolLayers=!0),"clip"===r.type&&(this._clipLayerPresent=!0);}};s(i),this._mergedOrder.sort(((e,t)=>{const i=o[e],s=o[t];return i.hasInitialOcclusionOpacityProperties?s.is3D()?1:0:i.is3D()&&s.hasInitialOcclusionOpacityProperties?-1:0})),this._mergedLayers=o,this.updateDrapeFirstLayers(),this._buildingIndex.processLayersChanged();}terrainSetForDrapingOnly(){return !!this.terrain&&0===this.terrain.drapeRenderMode}getCamera(){return this.stylesheet.camera}setCamera(t){return this.stylesheet.camera=e.l({},this.stylesheet.camera,t),this.camera=this.stylesheet.camera,this}_evaluateColorThemeData(t){return t.data?function(t,i,o){const s=e.l({},i);for(const t of Object.keys(e._.colorTheme))void 0===s[t]&&(s[t]=e._.colorTheme[t].default);const r=new e.$(io,t,new Map(o));return r.setTransitionOrValue(s,o),r.untransitioned().possiblyEvaluate(new e.a3(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 a=t;a.startsWith(r)||(a=r+a);const n="mapbox-reserved-lut",l=new Image;l.src=a,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:a,data:c}=e.q.getImageData(l);if(a>32)return void s(new Error("The height of the image must be less than or equal to 32 pixels."));if(r!==a*a)return void s(new Error("The width of the image must be equal to the height squared."));this.getImage(n)&&this.removeImage(n),this.addImage(n,{data:new e.r({width:r,height:a},c),pixelRatio:1,sdf:!1,version:0});const h=this.imageManager.getImage(n,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,a;const n=e.q.devicePixelRatio>1?"@2x":"";let l=e.n(i.transformRequest(i.normalizeSpriteURL(t,n,".json"),e.R.SpriteJSON),((e,t)=>{l=null,a||(a=e,s=t,h());})),c=e.o(i.transformRequest(i.normalizeSpriteURL(t,n,".png"),e.R.SpriteImage),((e,t)=>{c=null,a||(a=e,r=t,h());}));function h(){if(a)o(a);else if(s&&r){const t=e.q.getImageData(r),i={};for(const o in s){const{width:r,height:a,x:n,y:l,sdf:c,pixelRatio:h,stretchX:u,stretchY:d,content:_}=s[o],p=new e.r({width:r,height:a});e.r.copy(t,p,{x:n,y:l},{x:0,y:0},{width:r,height:a},null),i[o]={data:p,pixelRatio:h,sdf:c,stretchX:u,stretchY:d,content:_};}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.t(t));else if(i)for(const e in i)this.imageManager.addImage(e,this.scope,i[e]);this.imageManager.setLoaded(!0,this.scope),this._availableImages=this.imageManager.listImages(this.scope),this.dispatcher.broadcast("setImages",{scope:this.scope,images:this._availableImages}),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new e.x("data",{dataType:"style"}));}));}_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.t(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.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()}hasTransitions(){if(this.hasLightTransitions())return !0;if(this.hasFogTransition())return !0;for(const e in this._sourceCaches)if(this._sourceCaches[e].hasTransition())return !0;for(const e in this._layers)if(this._layers[e].hasTransition())return !0;return !1}get order(){return this.terrain?this._drapedFirstOrder:this._mergedOrder}_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.t(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.t(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));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._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(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();for(const t in r){const i=this._mergedSourceCaches[t];r[t]!==i.used&&i.getSource().fire(new e.x("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.z=t.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),o&&this.fire(new e.x("data",{dataType:"style"}));}_updateTilesForChangedImages(){const e=this._changes.getUpdatedImages();if(e.length){for(const t in this._sourceCaches)this._sourceCaches[t].reloadTilesForDependencies(["icons","patterns"],e);this._changes.resetUpdatedImages();}}_updateWorkerLayers(e,t,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(),oo(this,me(t)))return !1;(t=e.cm(t)).layers=Tt(t.layers);const o=function(t,i){if(!t)return [{command:Et.setStyle,args:[i]}];let o=[];try{if(!e.bi(t.version,i.version))return [{command:Et.setStyle,args:[i]}];if(e.bi(t.center,i.center)||o.push({command:Et.setCenter,args:[i.center]}),e.bi(t.zoom,i.zoom)||o.push({command:Et.setZoom,args:[i.zoom]}),e.bi(t.bearing,i.bearing)||o.push({command:Et.setBearing,args:[i.bearing]}),e.bi(t.pitch,i.pitch)||o.push({command:Et.setPitch,args:[i.pitch]}),e.bi(t.sprite,i.sprite)||o.push({command:Et.setSprite,args:[i.sprite]}),e.bi(t.glyphs,i.glyphs)||o.push({command:Et.setGlyphs,args:[i.glyphs]}),e.bi(t.imports,i.imports)||function(t=[],i=[],o){i=i||[];const s=(t=t||[]).map(At),r=i.map(At),a=t.reduce(Lt,{}),n=i.reduce(Lt,{}),l=s.slice();let c,h,u,d;for(c=0,h=0;c<s.length;c++)u=s[c],n.hasOwnProperty(u)?h++:(o.push({command:Et.removeImport,args:[u]}),l.splice(l.indexOf(u,h),1));for(c=0,h=0;c<r.length;c++)u=r[r.length-1-c],l[l.length-1-c]!==u&&(a.hasOwnProperty(u)?(o.push({command:Et.removeImport,args:[u]}),l.splice(l.lastIndexOf(u,l.length-h),1)):h++,d=l[l.length-c],o.push({command:Et.addImport,args:[n[u],d]}),l.splice(l.length-c,0,u));for(const t of i){const i=a[t.id];i&&!e.bi(i,t)&&o.push({command:Et.updateImport,args:[t.id,t]});}}(t.imports,i.imports,o),e.bi(t.transition,i.transition)||o.push({command:Et.setTransition,args:[i.transition]}),e.bi(t.light,i.light)||o.push({command:Et.setLight,args:[i.light]}),e.bi(t.fog,i.fog)||o.push({command:Et.setFog,args:[i.fog]}),e.bi(t.projection,i.projection)||o.push({command:Et.setProjection,args:[i.projection]}),e.bi(t.lights,i.lights)||o.push({command:Et.setLights,args:[i.lights]}),e.bi(t.camera,i.camera)||o.push({command:Et.setCamera,args:[i.camera]}),!e.bi(t["color-theme"],i["color-theme"]))return [{command:Et.setStyle,args:[i]}];const s={},r=[];!function(t,i,o,s){let r;for(r in i=i||{},t=t||{})t.hasOwnProperty(r)&&(i.hasOwnProperty(r)||Ct(r,o,s));for(r in i){if(!i.hasOwnProperty(r))continue;const a=i[r];t.hasOwnProperty(r)?e.bi(t[r],a)||("geojson"===t[r].type&&"geojson"===a.type&&Dt(t,i,r)?o.push({command:Et.setGeoJSONSourceData,args:[r,a.data]}):It(r,i,o,s)):St(r,i,o);}}(t.sources,i.sources,r,s);const a=[];t.layers&&t.layers.forEach((e=>{e.source&&s[e.source]?o.push({command:Et.removeLayer,args:[e.id]}):a.push(e);}));let n=t.terrain;n&&s[n.source]&&(o.push({command:Et.setTerrain,args:[void 0]}),n=void 0),o=o.concat(r),e.bi(n,i.terrain)||o.push({command:Et.setTerrain,args:[i.terrain]}),function(t,i,o){i=i||[];const s=(t=t||[]).map(At),r=i.map(At),a=t.reduce(Lt,{}),n=i.reduce(Lt,{}),l=s.slice(),c=Object.create(null);let h,u,d,_,p,f,m;for(h=0,u=0;h<s.length;h++)d=s[h],n.hasOwnProperty(d)?u++:(o.push({command:Et.removeLayer,args:[d]}),l.splice(l.indexOf(d,u),1));for(h=0,u=0;h<r.length;h++)d=r[r.length-1-h],l[l.length-1-h]!==d&&(a.hasOwnProperty(d)?(o.push({command:Et.removeLayer,args:[d]}),l.splice(l.lastIndexOf(d,l.length-u),1)):u++,f=l[l.length-h],o.push({command:Et.addLayer,args:[n[d],f]}),l.splice(l.length-h,0,d),c[d]=!0);for(h=0;h<r.length;h++)if(d=r[h],_=a[d],p=n[d],!c[d]&&!e.bi(_,p))if(e.bi(_.source,p.source)&&e.bi(_["source-layer"],p["source-layer"])&&e.bi(_.type,p.type)){for(m in Rt(_.layout,p.layout,o,d,null,Et.setLayoutProperty),Rt(_.paint,p.paint,o,d,null,Et.setPaintProperty),e.bi(_.slot,p.slot)||o.push({command:Et.setSlot,args:[d,p.slot]}),e.bi(_.filter,p.filter)||o.push({command:Et.setFilter,args:[d,p.filter]}),e.bi(_.minzoom,p.minzoom)&&e.bi(_.maxzoom,p.maxzoom)||o.push({command:Et.setLayerZoomRange,args:[d,p.minzoom,p.maxzoom]}),_)_.hasOwnProperty(m)&&"layout"!==m&&"paint"!==m&&"filter"!==m&&"metadata"!==m&&"minzoom"!==m&&"maxzoom"!==m&&"slot"!==m&&(0===m.indexOf("paint.")?Rt(_[m],p[m],o,d,m.slice(6),Et.setPaintProperty):e.bi(_[m],p[m])||o.push({command:Et.setLayerProperty,args:[d,m,p[m]]}));for(m in p)p.hasOwnProperty(m)&&!_.hasOwnProperty(m)&&"layout"!==m&&"paint"!==m&&"filter"!==m&&"metadata"!==m&&"minzoom"!==m&&"maxzoom"!==m&&"slot"!==m&&(0===m.indexOf("paint.")?Rt(_[m],p[m],o,d,m.slice(6),Et.setPaintProperty):e.bi(_[m],p[m])||o.push({command:Et.setLayerProperty,args:[d,m,p[m]]}));}else o.push({command:Et.removeLayer,args:[d]}),f=l[l.lastIndexOf(d)+1],o.push({command:Et.addLayer,args:[p,f]});}(a,i.layers,o);}catch(e){console.warn("Unable to compute style diff:",e),o=[{command:Et.setStyle,args:[i]}];}return o}(this.serialize(),t).filter((e=>!(e.command in ro)));if(0===o.length)return !1;const s=o.filter((e=>!(e.command in so)));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].apply(this,e.args));})),i&&Promise.all(r).then(i),this.stylesheet=t,this.mergeAll(),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),!0}addImage(t,i){return this.getImage(t)?this.fire(new e.t(new Error("An image with this name already exists."))):(this.imageManager.addImage(t,this.scope,i),this._afterImageUpdated(t),this)}updateImage(e,t){this.imageManager.updateImage(e,this.scope,t);}getImage(e){return this.imageManager.getImage(e,this.scope)}removeImage(t){return this.getImage(t)?(this.imageManager.removeImage(t,this.scope),this._afterImageUpdated(t),this):this.fire(new e.t(new Error("No image with this name exists.")))}_afterImageUpdated(t){this._availableImages=this.imageManager.listImages(this.scope),this._changes.updateImage(t),this.dispatcher.broadcast("setImages",{scope:this.scope,images:this._availableImages}),this.fire(new e.x("data",{dataType:"style"}));}listImages(){return this._checkLoaded(),this._availableImages.slice()}addModel(e,t,i={}){return this._checkLoaded(),this._validate(Ce,`models.${e}`,t,null,i)||(this.modelManager.addModel(e,t,this.scope),this._changes.setDirty()),this}hasModel(e){return this.modelManager.hasModel(e,this.scope)}removeModel(t){return this.hasModel(t)?(this.modelManager.removeModel(t,this.scope),this):this.fire(new e.t(new Error("No model with this ID exists.")))}listModels(){return this._checkLoaded(),this.modelManager.listModels(this.scope)}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(ge,`sources.${t}`,i,null,o))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const s=Qe(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.av(i,this.scope),r=this._sourceCaches[i]=new gt(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.t(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.t(new Error(`Source "${t}" cannot be removed while terrain is using it.`)));const o=this.getOwnSourceCaches(t);for(const t of o){const i=e.cn(t.id);delete this._sourceCaches[i],this._changes.discardSourceCacheUpdate(t.id),t.fire(new e.x("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 o of t){if(this._validate(xe,"lights",o))return;switch(o.type){case"ambient":if(this.ambientLight){const e=this.ambientLight;e.set(o),e.updateTransitions(i);}else this.ambientLight=new Ue(o,Ge||(Ge=new e.a0({color:new e.a1(e._.properties_light_ambient.color),intensity:new e.a1(e._.properties_light_ambient.intensity)})),this.scope,this.options);break;case"directional":if(this.directionalLight){const e=this.directionalLight;e.set(o),e.updateTransitions(i);}else this.directionalLight=new Ue(o,Ve||(Ve=new e.a0({direction:new e.ad(e._.properties_light_directional.direction),color:new e.a1(e._.properties_light_directional.color),intensity:new e.a1(e._.properties_light_directional.intensity),"cast-shadows":new e.a1(e._.properties_light_directional["cast-shadows"]),"shadow-intensity":new e.a1(e._.properties_light_directional["shadow-intensity"])})),this.scope,this.options);}}const o=new e.a3(this.z||0,i);this.ambientLight&&this.ambientLight.recalculate(o),this.directionalLight&&this.directionalLight.recalculate(o),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").toRenderColor(null).toArray01(),r=t.properties.get("intensity"),a=t.properties.get("direction"),n=1-e.c8(a.x,a.y,a.z)[2]/90,l=o(s)*r*n,c=i.properties.get("color").toRenderColor(null).toArray01(),h=i.properties.get("intensity"),u=o(c)*h;return Number(((l+u)/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(!t)return this;if(e.aK(t)){const i=e.co(t),o=this.fragments.find((({id:e})=>e===i));if(!o)throw new Error(`Style import '${t}' not found`);const s=e.cn(t);return o.style.getFragmentStyle(s)}{const e=this.fragments.find((({id:e})=>e===t));if(!e)throw new Error(`Style import '${t}' not found`);return e.style}}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.t(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.av(i,o.scope),r=o.options.get(s),a=r?r.value||r.default:null;return a?a.serialize():null}setConfigProperty(t,i,o){const s=this.getFragmentStyle(t);if(!s)return;const r=s.stylesheet.schema;if(!r||!r[i])return;const a=e.M(o);if("success"!==a.result)return void oo(this,a.value);const n=a.value.expression,l=e.av(i,s.scope),c=s.options.get(l);if(!c)return;let h;const{minValue:u,maxValue:d,stepValue:_,type:p,values:f}=r[i],m=e.M(r[i].default);"success"===m.result&&(h=m.value.expression),h?(this.options.set(l,{...c,value:n,default:h,minValue:u,maxValue:d,stepValue:_,type:p,values:f}),this.updateConfigDependencies(i)):this.fire(new e.t(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.av(t,i.scope),r=i.options.get(o),a=r?r.value||r.default:null;s[t]=a?a.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 a=e.M(i[o].default);if("success"===a.result&&(s=a.value.expression),t&&void 0!==t[o]){const i=e.M(t[o]);"success"===i.result&&(r=i.value.expression);}const{minValue:n,maxValue:l,stepValue:c,type:h,values:u}=i[o];if(s){const t=e.av(o,this.scope);this.options.set(t,{default:s,value:r,minValue:n,maxValue:l,stepValue:c,type:h,values:u});}else this.fire(new e.t(new Error(`No schema defined for config option "${o}".`)));}else this.fire(new e.t(new Error("Attempting to set config for a style without schema.")));}updateConfigDependencies(e){for(const t of this._configDependentLayers){const i=this.getLayer(t);if(i){if(e&&!i.configDependencies.has(e))continue;i.possiblyEvaluateVisibility(),this._updateLayer(i);}}this.ambientLight&&this.ambientLight.updateConfig(this.options),this.directionalLight&&this.directionalLight.updateConfig(this.options),this.fog&&this.fog.updateConfig(this.options),this.forEachFragmentStyle((e=>{if(e._styleColorTheme.colorTheme){const t=e._evaluateColorThemeData(e._styleColorTheme.colorTheme);(!e._styleColorTheme.lut&&""!==t||e._styleColorTheme.lut&&t!==e._styleColorTheme.lut.data)&&e.setColorTheme(e._styleColorTheme.colorTheme);}})),this._changes.setDirty();}addLayer(t,i,o={}){this._checkLoaded();const s=t.id;if(this._layers[s])return void this.fire(new e.t(new Error(`Layer with id "${s}" already exists on this map`)));let r;if("custom"===t.type){if(oo(this,e.cp(t)))return;r=e.cq(t,this.scope,this._styleColorTheme.lut,this.options);}else {if("object"==typeof t.source&&(this.addSource(s,t.source),t=e.cm(t),t=e.l(t,{source:s})),this._validate(we,`layers.${s}`,t,{arrayIndex:-1},o))return;r=e.cq(t,this.scope,this._styleColorTheme.lut,this.options),this._validateLayer(r),r.setEventedParent(this,{layer:{id:s}});}0!==r.configDependencies.size&&this._configDependentLayers.add(r.fqid);let a=this._order.length;if(i){const t=this._order.indexOf(i);if(-1===t)return void this.fire(new e.t(new Error(`Layer with id "${i}" does not exist on this map.`)));r.slot===this._layers[i].slot?a=t:e.w(`Layer with id "${i}" has a different slot. Layers can only be rearranged within the same slot.`);}this._order.splice(a,0,s),this._layerOrderChanged=!0,this._layers[s]=r;const n=this.getOwnLayerSourceCache(r),l=!!this.directionalLight&&this.directionalLight.shadowsEnabled();n&&r.canCastShadows()&&l&&(n.castsShadows=!0);const c=this._changes.getRemovedLayer(r);if(c&&r.source&&n&&"custom"!==r.type){this._changes.discardLayerRemoval(r);const t=e.av(r.source,r.scope);c.type!==r.type?this._changes.updateSourceCache(t,"clear"):(this._changes.updateSourceCache(t,"reload"),n.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.t(new Error(`Layer with id "${i}" does not exist on this map.`)));o.slot===this._layers[i].slot?r=t:e.w(`Layer with id "${i}" has a different slot. Layers can only be rearranged within the same slot.`);}this._order.splice(r,0,t),this._changes.setDirty(),this._layerOrderChanged=!0,this.mergeLayers();}removeLayer(e){this._checkLoaded();const t=this._checkLayer(e);if(!t)return;t.setEventedParent(null);const i=this._order.indexOf(e);this._order.splice(i,1),delete this._layers[e],this._changes.setDirty(),this._layerOrderChanged=!0,this._configDependentLayers.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.bi(s.filter,i))return null==i?(s.filter=void 0,void this._updateLayer(s)):void(this._validate(Te,`layers.${s.id}.filter`,i,{layerType:s.type},o)||(s.filter=e.cm(i),this._updateLayer(s)))}getFilter(t){const i=this._checkLayer(t);if(i)return e.cm(i.filter)}setLayoutProperty(t,i,o,s={}){this._checkLoaded();const r=this._checkLayer(t);if(r&&!e.bi(r.getLayoutProperty(i),o)){if(null!=o&&(!s||!1!==s.validate)&&oo(r,Se.call(me,{key:`layers.${t}.layout.${i}`,layerType:r.type,objectKey:i,value:o,styleSpec:e._,style:{glyphs:!0,sprite:!0}})))return;r.setLayoutProperty(i,o),0!==r.configDependencies.size&&this._configDependentLayers.add(r.fqid),this._updateLayer(r);}}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.bi(r.getPaintProperty(i),o))return;if(null!=o&&(!s||!1!==s.validate)&&oo(r,Ee.call(me,{key:`layers.${t}.paint.${i}`,layerType:r.type,objectKey:i,value:o,styleSpec:e._})))return;const a=r.setPaintProperty(i,o);0!==r.configDependencies.size&&this._configDependentLayers.add(r.fqid),a&&this._updateLayer(r),this._changes.updatePaintProperties(r);}getPaintProperty(e,t){const i=this._checkLayer(e);if(i)return i.getPaintProperty(t)}setFeatureState(t,i){this._checkLoaded();const o=t.featureset;if(o){if("featuresetId"in o){const e=this.getFragmentStyle(o.importId),s=e.getFeaturesetLayers(o.featuresetId);for(const{source:o,sourceLayer:r}of s)e.setFeatureState({id:t.id,source:o,sourceLayer:r},i);}else if("layerId"in o){const e=this.getLayer(o.layerId);this.setFeatureState({id:t.id,source:e.source,sourceLayer:e.sourceLayer},i);}return}const s=t.source,r=t.sourceLayer,a=this._checkSource(s);if(!a)return;const n=a.type;if("geojson"===n&&r)return void this.fire(new e.t(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===n&&!r)return void this.fire(new e.t(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===t.id&&this.fire(new e.t(new Error("The feature id parameter must be provided.")));const l=this.getOwnSourceCaches(s);for(const e of l)e.setFeatureState(r,t.id,i);}removeFeatureState(t,i){this._checkLoaded();const o=t.featureset;if(o){if("featuresetId"in o){const e=this.getFragmentStyle(o.importId),s=e.getFeaturesetLayers(o.featuresetId);for(const{source:o,sourceLayer:r}of s)e.removeFeatureState({id:t.id,source:o,sourceLayer:r},i);}else if("layerId"in o){const e=this.getLayer(o.layerId);this.removeFeatureState({id:t.id,source:e.source,sourceLayer:e.sourceLayer},i);}return}const s=t.source,r=this._checkSource(s);if(!r)return;const a=r.type,n="vector"===a?t.sourceLayer:void 0;if("vector"===a&&!n)return void this.fire(new e.t(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.t(new Error("A feature id is required to remove its specific state property.")));const l=this.getOwnSourceCaches(s);for(const e of l)e.removeFeatureState(n,t.id,i);}getFeatureState(t){this._checkLoaded();const i=t.featureset;if(i){let o;if("featuresetId"in i){const s=this.getFragmentStyle(i.importId),r=s.getFeaturesetLayers(i.featuresetId);for(const{source:i,sourceLayer:a}of r){const r=s.getFeatureState({id:t.id,source:i,sourceLayer:a});if(r&&!o)o=r;else if(!e.bi(o,r))return void this.fire(new e.t(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){const e=this.getLayer(i.layerId);o=this.getFeatureState({id:t.id,source:e.source,sourceLayer:e.sourceLayer});}return o}const o=t.source,s=t.sourceLayer,r=this._checkSource(o);if(r){if("vector"!==r.type||s)return void 0===t.id&&this.fire(new e.t(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(o)[0].getFeatureState(s,t.id);this.fire(new e.t(new Error("The sourceLayer parameter must be provided for vector source types.")));}}setTransition(t){return this.stylesheet.transition=e.l({},this.stylesheet.transition,t),this.transition=this.stylesheet.transition,this}getTransition(){return e.l({},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.cr({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,fragment:this.stylesheet.fragment,imports:this._serializeImports(),schema:this.stylesheet.schema,camera:this.stylesheet.camera,light:this.stylesheet.light,lights:this.stylesheet.lights,terrain:i,fog:this.stylesheet.fog,center:this.stylesheet.center,"color-theme":this.stylesheet["color-theme"],zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,projection:this.stylesheet.projection,sources:this._serializeSources(),layers:this._serializeLayers(this._order)},(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.av(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(),i=this.order,o={},s=[];for(let r=i.length-1;r>=0;r--){const a=i[r];if(t(a)){o[a]=r;for(const t of e){const e=t[a];if(e)for(const t of e)s.push(t);}}}s.sort(((e,t)=>t.intersectionZ-e.intersectionZ));const r=[];for(let a=i.length-1;a>=0;a--){const n=i[a];if(t(n))for(let e=s.length-1;e>=0;e--){const t=s[e].feature;if(t.layer&&o[t.layer.id]<a)break;r.push(t),s.pop();}else for(const t of e){const e=t[n];if(e)for(const t of e)r.push(t.feature);}}return r}queryRenderedFeatures(t,i,o){i&&!Array.isArray(i)&&i.filter&&this._validate(Te,"queryRenderedFeatures.filter",i.filter,null,i);let s,r=!1;const a=new Set;if(i&&i.layers){if(!Array.isArray(i.layers))return this.fire(new e.t(new Error("parameters.layers must be an Array."))),[];s=[];for(const t of i.layers){const i=this._mergedLayers[t];if(!i)return this.fire(new e.t(new Error(`The layer '${t}' does not exist in the map's style and cannot be queried for features.`))),[];i.is3D()&&(r=!0),a.add(i.source),s.push(t);}}else r=this.has3DLayers();const n=this._queryRenderedFeatures(t,o,{layerIds:s,filter:i.filter,has3DLayers:r,includedSources:a}),l=this._flattenAndSortRenderedFeatures(n),c=[];for(const t of l)e.co(t.layer.id)===this.scope&&c.push(t);return c}queryRenderedFeaturesForInteractions(t,i,o){let s=[];for(const{featureset:r,filter:a,radius:n}of i){let i=!1;const l=[],c=new Set;if("featuresetId"in r){const e=this.getFeaturesetLayers(r.featuresetId,r.importId);if(0===e.length)continue;for(const t of e)t.is3D()&&(i=!0),c.add(t.source),l.push(t.fqid);}else if("layerId"in r){const t=this._mergedLayers[r.layerId];if(!t)return this.fire(new e.t(new Error(`The layer '${r.layerId}' does not exist in the map's style and cannot be queried for features.`))),[];t.is3D()&&(i=!0),c.add(t.source),l.push(r.layerId);}let h=t;if(n)if(t instanceof e.P||"number"==typeof t[0]){const i=e.P.convert(t);h=[[i.x-n,i.y-n],[i.x+n,i.y+n]];}else {const i=e.P.convert(t[0]),o=e.P.convert(t[1]);h=[[i.x-n,i.y-n],[o.x+n,o.y+n]];}s=s.concat(this._queryRenderedFeatures(h,o,{layerIds:l,filter:a,has3DLayers:i,includedSources:c}));}const r=this._flattenAndSortRenderedFeatures(s),a=(e,t,i)=>{const o=e.clone();if(delete o.layer,o.featureset=t,i&&i.featureNamespace&&(o.namespace=i.featureNamespace),i&&i.properties){const t={},s=this.map.transform.zoom;for(const o of Object.keys(i.properties)){const r=i.properties[o].evaluate({zoom:s},e._vectorTileFeature,e.state,e.tile,this._availableImages);null!=r&&(t[o]=r);}o.properties=t;}return o},n=[];for(const t of r){const o=t.layer.id,s=e.cn(o),r=e.co(o);for(const{featureset:e}of i){if("layerId"in e&&e.layerId!==o)continue;if("layerId"in e&&e.layerId===o){const i=a(t,e);n.push(i);continue}if("featuresetId"in e){if(e.importId!==r)continue;if(!this.getFeaturesetLayers(e.featuresetId,e.importId).map((e=>e.id)).includes(s))continue}const i=this._mergedLayerSelectors.get(o)||[];for(const o of i){const i=a(t,e,o);n.push(i);}}}return n}_queryRenderedFeatures(t,i,o){const{layerIds:s,filter:r,has3DLayers:a,includedSources:n}=o,l=[],c=je.createFromScreenPoints(t,i);for(const e in this._mergedSourceCaches){if(!this._mergedSourceCaches[e].getSource())continue;const t=this._mergedSourceCaches[e].getSource().id;s&&!n.has(t)||l.push(tt(this._mergedSourceCaches[e],this._mergedLayers,c,r,s||[],this._availableImages,i,a,!!this.map._showQueryGeometry));}return this.placement&&l.push(function(t,i,o,s,r,a,n,l){const c={},h=n.queryRenderedSymbols(o),u=[];for(const e of Object.keys(h).map(Number))u.push(l[e]);u.sort(ot);for(const e of u){const i=e.featureIndex.lookupSymbolFeatures(h[e.bucketInstanceId],e.bucketIndex,e.sourceLayerIndex,s,r,a,t);for(const t in i){const o=c[t]=c[t]||[],s=i[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)o.push(e);}}for(const o in c)c[o].forEach((s=>{const r=s.feature,a=t[o],n=i(a);if(!n)return;const l=n.getFeatureState(r.layer["source-layer"],r.id);r.state=l,e.aK(a.id)||(r.source=r.layer.source,r.layer["source-layer"]&&(r.sourceLayer=r.layer["source-layer"]));}));return c}(this._mergedLayers,this.getLayerSourceCache.bind(this),c.screenGeometry,r,s||[],this._availableImages,this.placement.collisionIndex,this.placement.retainedQueryData)),l}querySourceFeatures(e,t){const i=t&&t.filter;i&&this._validate(Te,"querySourceFeatures.filter",i,null,t);let o=[];const s=this.getOwnSourceCaches(e);for(const e of s)o=o.concat(it(e,t));return o}addSourceType(e,t,i){return lo.getSourceType(e)?i(new Error(`A source type called "${e}" already exists.`)):(lo.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.bi(t[i],s[i])){r=!0;break}if(!r)return;const a=this._getTransitionParameters();this.light.setLight(t,i,o),this.light.updateTransitions(a);}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.q.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=null==t.source;if(1===i){if(this.disableElevatedTerrain)return;if("object"==typeof o.source){const t="terrain-dem-src";this.addSource(t,o.source),o=e.cm(o),o=e.l(o,{source:t});}const t=e.l({},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(ye,"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.x("data",{dataType:"style"}));}else {const i=this.terrain,s=i.get();for(const t of Object.keys(e._.terrain))!o.hasOwnProperty(t)&&e._.terrain[t].default&&(o[t]=e._.terrain[t].default);for(const o in t)if(!e.bi(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.x("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0;}_createFog(e){const t=this.fog=new Ne(e,this.map.transform,this.scope,this.options);this.stylesheet.fog=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.bi(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;}setColorTheme(t){this._checkLoaded();const i=()=>{for(const e in this._layers)this._layers[e].lut=this._styleColorTheme.lut;for(const e in this._sourceCaches)this._sourceCaches[e].clearTiles();};if(this._styleColorTheme.colorTheme=t,!t)return this._styleColorTheme.lut=null,void i();const o=this._evaluateColorThemeData(t);this._loadColorTheme(o).then((()=>{this.fire(new e.x("colorthemeset")),i();})).catch((t=>{e.w(`Couldn't set color theme: ${t}`);}));}_getTransitionParameters(t){return {now:e.q.now(),transition:e.l(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 Le(e,t,this.scope,this.options);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 a=e.l({},this.serialize());return oo(this,t.call(me,e.l({key:i,style:a,value:o,styleSpec:e._},s)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),e.cs.off("pluginStateChange",this._rtlTextPluginCallback);for(const e in this._mergedLayers)this._mergedLayers[e].setEventedParent(null);for(const e in this._mergedSourceCaches)this._mergedSourceCaches[e].clearTiles(),this._mergedSourceCaches[e].setEventedParent(null);this.setEventedParent(null),delete this.fog,delete this.terrain,delete this.ambientLight,delete this.directionalLight,this.isRootStyle()&&(this.imageManager.setEventedParent(null),this.modelManager.setEventedParent(null),this.dispatcher.remove());}clearSource(e){const t=this.getSourceCaches(e);for(const e of t)e.clearTiles();}clearSources(){for(const e in this._mergedSourceCaches)this._mergedSourceCaches[e].clearTiles();}reloadSource(e){const t=this.getSourceCaches(e);for(const e of t)e.resume(),e.reload();}reloadSources(){for(const e of this.getSources())e.reload&&e.reload();}updateSources(e){let t;this.directionalLight&&(t=Yi(this.directionalLight));for(const i in this._mergedSourceCaches)this._mergedSourceCaches[i].update(e,void 0,void 0,t);}_generateCollisionBoxes(){for(const e in this._sourceCaches){const t=this._sourceCaches[e];t.resume(),t.reload();}}_updatePlacement(t,i,o,s,r,a,n=!1){let l=!1,c=!1;const h={},u={};for(const t of this._mergedOrder){const o=this._mergedLayers[t];if("symbol"!==o.type)continue;const s=e.av(o.source,o.scope);let r=h[s];if(!r){const e=this.getLayerSourceCache(o);if(!e)continue;const t=e.getRenderableIds(!0).map((t=>e.getTileByID(t)));u[s]=t.slice(),r=h[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,i.center.lng,i.projection);l=l||a;}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder),n=n||this._layerOrderChanged||0===s,this._layerOrderChanged&&this.fire(new e.x("neworder")),(n||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(e.q.now(),i.zoom))&&(this.pauseablePlacement=new wi(i,this._mergedOrder,n,o,s,r,this.placement,this.fog&&i.projection.supportsFog?this.fog.state:null,this._buildingIndex),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._mergedOrder,this._mergedLayers,h,u,this.map.painter.scaleFactor),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(e.q.now()),c=!0),l&&this.pauseablePlacement.placement.setStale()),c||l){this._buildingIndex.onNewFrame(i.zoom);for(let t=0;t<this._mergedOrder.length;t++){const i=this._mergedLayers[this._mergedOrder[t]];if("symbol"!==i.type)continue;const o=this.isLayerClipped(i);this.placement.updateLayerOpacities(i,h[e.av(i.source,i.scope)],t,o?a:null);}}return {needsRerender:!this.pauseablePlacement.isDone()||this.placement.hasTransitions(e.q.now())}}_releaseSymbolFadeTiles(){for(const e in this._sourceCaches)this._sourceCaches[e].releaseSymbolFadeTiles();}addImport(t,i){this._checkLoaded();const o=this.stylesheet.imports=this.stylesheet.imports||[];if(-1!==o.findIndex((({id:e})=>e===t.id)))return void this.fire(new e.t(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.t(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.bi(i.config,o[s].config)||this.setImportConfig(t,i.config),e.bi(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],a=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(a).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){this._checkLoaded();const i=this.getImportIndex(e),o=this.stylesheet.imports||[];if(-1===i)return this;t?o[i].config=t:delete o[i].config;const s=this.fragments[i],r=s.style.stylesheet&&s.style.stylesheet.schema;return s.config=t,s.style.updateConfig(t,r),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.t(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.av(t,i);return this._mergedOtherSourceCaches[o]}getLayerSourceCache(t){const i=e.av(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);}}getImages(e,t,i){this.imageManager.getImages(t.icons,t.scope,i),this._updateTilesForChangedImages();const o=e=>{e&&e.setDependencies(t.tileID.key,t.type,t.icons);};o(this._otherSourceCaches[t.source]),o(this._symbolSourceCaches[t.source]);}getGlyphs(e,t,i){this.glyphManager.getGlyphs(t.stacks,t.scope,i);}getResource(t,i,o){return e.ct(i,o)}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.t(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)return !1;const i="fill-extrusion"===e.type&&"building"===e.sourceLayer;if(e.is3D()){if(i||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");}destroy(){this._clearWorkerCaches(),this.fragments.forEach((e=>{e.style._remove();})),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain);}}lo.getSourceType=function(e){return Ye[e]},lo.setSourceType=function(e,t){Ye[e]=t;},lo.registerForPluginStateChange=e.cd;var co="\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",ho="\nout vec4 glFragColor;highp float unpack_depth(highp vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}highp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}\n#ifdef INDICATOR_CUTOUT\nuniform vec2 u_indicator_cutout_centers;uniform vec4 u_indicator_cutout_params;\n#endif\nvec4 applyCutout(vec4 color) {\n#ifdef INDICATOR_CUTOUT\nfloat holeMinOpacity=u_indicator_cutout_params.x;float holeRadius=max(u_indicator_cutout_params.y,0.0);float holeAspectRatio=u_indicator_cutout_params.z;float fadeStart=u_indicator_cutout_params.w;float distA=distance(vec2(gl_FragCoord.x,gl_FragCoord.y*holeAspectRatio),vec2(u_indicator_cutout_centers[0],u_indicator_cutout_centers[1]*holeAspectRatio));return color*min(smoothstep(fadeStart,holeRadius,distA)+holeMinOpacity,1.0);\n#else\nreturn color;\n#endif\n}\n#ifdef DEBUG_WIREFRAME\n#define HANDLE_WIREFRAME_DEBUG \\\nglFragColor=vec4(0.7,0.0,0.0,0.7); \\\ngl_FragDepth=gl_FragCoord.z-0.0001;\n#else\n#define HANDLE_WIREFRAME_DEBUG\n#endif\n#ifdef RENDER_CUTOFF\nuniform highp vec4 u_cutoff_params;in float v_cutoff_opacity;\n#endif\nvec4 textureLodCustom(sampler2D image,highp vec2 pos,highp vec2 lod_coord) {highp vec2 size=vec2(textureSize(image,0));highp vec2 dx=dFdx(lod_coord.xy*size);highp vec2 dy=dFdy(lod_coord.xy*size);highp float delta_max_sqr=max(dot(dx,dx),dot(dy,dy));highp float lod=0.5*log2(delta_max_sqr);return textureLod(image,pos,lod);}vec4 applyLUT(highp sampler3D lut,vec4 col) {vec3 size=vec3(textureSize(lut,0));vec3 uvw=(col.rbg*float(size-1.0)+0.5)/size;return vec4(texture(lut,uvw).rgb,col.a);}vec3 applyLUT(highp sampler3D lut,vec3 col) {return applyLUT(lut,vec4(col,1.0)).rgb;}",uo="\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);}",_o="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;}",po="\n#define ELEVATION_SCALE 7.0\n#define ELEVATION_OFFSET 450.0\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix(\nmix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;}\n#else\nvec3 elevationVector(vec2 pos) { return vec3(0,0,1); }\n#endif\n#ifdef TERRAIN\nuniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;uniform vec2 u_dem_tl;uniform vec2 u_dem_tl_prev;uniform float u_dem_scale;uniform float u_dem_scale_prev;uniform float u_dem_size;uniform float u_dem_lerp;uniform float u_exaggeration;uniform float u_meter_to_dem;uniform mat4 u_label_plane_matrix_inv;vec4 tileUvToDemSample(vec2 uv,float dem_size,float dem_scale,vec2 dem_tl) {vec2 pos=dem_size*(uv*dem_scale+dem_tl)+1.0;vec2 f=fract(pos);return vec4((pos-f+0.5)/(dem_size+2.0),f);}float currentElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale+u_dem_tl)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture(u_dem,pos).r;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale,u_dem_tl);vec2 pos=r.xy;vec2 f=r.zw;float tl=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(dd,0)).r;float bl=texture(u_dem,pos+vec2(0,dd)).r;float br=texture(u_dem,pos+vec2(dd,dd)).r;return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}float prevElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale_prev+u_dem_tl_prev)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture(u_dem_prev,pos).r;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale_prev,u_dem_tl_prev);vec2 pos=r.xy;vec2 f=r.zw;float tl=texture(u_dem_prev,pos).r;float tr=texture(u_dem_prev,pos+vec2(dd,0)).r;float bl=texture(u_dem_prev,pos+vec2(0,dd)).r;float br=texture(u_dem_prev,pos+vec2(dd,dd)).r;return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}\n#ifdef TERRAIN_VERTEX_MORPHING\nfloat elevation(vec2 apos) {\n#ifdef ZERO_EXAGGERATION\nreturn 0.0;\n#endif\nfloat nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}\n#else\nfloat elevation(vec2 apos) {\n#ifdef ZERO_EXAGGERATION\nreturn 0.0;\n#endif\nreturn currentElevation(apos);}\n#endif\nvec4 fourSample(vec2 pos,vec2 off) {float tl=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(off.x,0.0)).r;float bl=texture(u_dem,pos+vec2(0.0,off.y)).r;float br=texture(u_dem,pos+off).r;return vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);}\n#else\nfloat elevation(vec2 pos) { return 0.0; }\n#endif\n#ifdef DEPTH_OCCLUSION\nuniform highp sampler2D u_depth;uniform highp vec2 u_depth_size_inv;uniform highp vec2 u_depth_range_unpack;uniform highp float u_occluder_half_size;uniform highp float u_occlusion_depth_offset;\n#ifdef DEPTH_D24\nfloat unpack_depth(float depth) {return depth*u_depth_range_unpack.x+u_depth_range_unpack.y;}vec4 unpack_depth4(vec4 depth) {return depth*u_depth_range_unpack.x+vec4(u_depth_range_unpack.y);}\n#else\nhighp float unpack_depth_rgba(vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}\n#endif\nbool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;\n#ifdef DEPTH_D24\nfloat depth=unpack_depth(texture(u_depth,(coord.xy+1.0)*0.5).r);\n#else\nfloat depth=unpack_depth_rgba(texture(u_depth,(coord.xy+1.0)*0.5));\n#endif\nreturn coord.z+u_occlusion_depth_offset > depth;}highp vec4 getCornerDepths(vec2 coord) {highp vec3 df=vec3(u_occluder_half_size*u_depth_size_inv,0.0);highp vec2 uv=0.5*coord.xy+0.5;\n#ifdef DEPTH_D24\nhighp vec4 depth=vec4(\ntexture(u_depth,uv-df.xz).r,texture(u_depth,uv+df.xz).r,texture(u_depth,uv-df.zy).r,texture(u_depth,uv+df.zy).r\n);depth=unpack_depth4(depth);\n#else\nhighp vec4 depth=vec4(\nunpack_depth_rgba(texture(u_depth,uv-df.xz)),unpack_depth_rgba(texture(u_depth,uv+df.xz)),unpack_depth_rgba(texture(u_depth,uv-df.zy)),unpack_depth_rgba(texture(u_depth,uv+df.zy))\n);\n#endif\nreturn depth;}highp float occlusionFadeMultiSample(vec4 frag) {highp vec3 coord=frag.xyz/frag.w;highp vec2 uv=0.5*coord.xy+0.5;int NX=3;int NY=4;highp vec2 df=u_occluder_half_size*u_depth_size_inv;highp vec2 oneStep=2.0*u_occluder_half_size*u_depth_size_inv/vec2(NX-1,NY-1);highp float res=0.0;for (int y=0; y < NY;++y) {for (int x=0; x < NX;++x) {\n#ifdef DEPTH_D24\nhighp float depth=unpack_depth(texture(u_depth,uv-df+vec2(float(x)*oneStep.x,float(y)*oneStep.y)).r);\n#else\nhighp float depth=unpack_depth_rgba(texture(u_depth,uv-df+vec2(float(x)*oneStep.x,float(y)*oneStep.y)));\n#endif\nres+=1.0-clamp(300.0*(coord.z+u_occlusion_depth_offset-depth),0.0,1.0);}}res=clamp(2.0*res/float(NX*NY)-0.5,0.0,1.0);return res;}highp float occlusionFade(vec4 frag) {highp vec3 coord=frag.xyz/frag.w;highp vec4 depth=getCornerDepths(coord.xy);return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z+u_occlusion_depth_offset)-depth),0.0,1.0));}\n#else\nbool isOccluded(vec4 frag) { return false; }highp float occlusionFade(vec4 frag) { return 1.0; }highp float occlusionFadeMultiSample(vec4 frag) { return 1.0; }\n#endif//DEPTH_OCCLUSION",fo="#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",mo="highp vec3 hash(highp vec2 p) {highp vec3 p3=fract(p.xyx*vec3(443.8975,397.2973,491.1871));p3+=dot(p3,p3.yxz+19.19);return fract((p3.xxy+p3.yzz)*p3.zyx);}vec3 dither(vec3 color,highp vec2 seed) {vec3 rnd=hash(seed)+hash(seed+0.59374)-0.5;return color+rnd/255.0;}\n#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump vec2 u_fog_vertical_limit;uniform mediump float u_fog_temporal_offset;in vec3 v_fog_pos;uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform highp vec2 u_viewport;uniform float u_globe_transition;uniform int u_is_globe;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}float globe_glow_progress() {highp vec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float sdf=length(closest_point-u_globe_pos)/u_globe_radius;return sdf+PI*0.5;}float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos,float opacity_limit) {float depth=length(pos);float opacity;if (u_is_globe==1) {float glow_progress=globe_glow_progress();float t=mix(glow_progress,depth,u_globe_transition);opacity=fog_opacity(fog_range(t));} else {opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);}return mix(color,u_fog_color.rgb,min(opacity,opacity_limit));}vec3 fog_apply(vec3 color,vec3 pos) {return fog_apply(color,pos,1.0);}vec4 fog_apply_from_vert(vec4 color,float fog_opac) {float alpha=EPSILON+color.a;color.rgb=mix(color.rgb/alpha,u_fog_color.rgb,fog_opac)*alpha;return color;}vec3 fog_apply_sky_gradient(vec3 camera_ray,vec3 sky_color) {float horizon_blend=fog_horizon_blending(normalize(camera_ray));return mix(sky_color,u_fog_color.rgb,horizon_blend);}vec4 fog_apply_premultiplied(vec4 color,vec3 pos) {float alpha=EPSILON+color.a;color.rgb=fog_apply(color.rgb/alpha,pos)*alpha;return color;}vec4 fog_apply_premultiplied(vec4 color,vec3 pos,float heightMeters) {float verticalProgress=(u_fog_vertical_limit.x > 0.0 || u_fog_vertical_limit.y > 0.0) ? smoothstep(u_fog_vertical_limit.x,u_fog_vertical_limit.y,heightMeters) : 0.0;float opacityLimit=1.0-smoothstep(0.9,1.0,fog_opacity(pos));return mix(fog_apply_premultiplied(color,pos),color,min(verticalProgress,opacityLimit));}vec3 fog_dither(vec3 color) {\n#ifdef FOG_DITHERING\nvec2 dither_seed=gl_FragCoord.xy+u_fog_temporal_offset;return dither(color,dither_seed);\n#else\nreturn color;\n#endif\n}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}\n#endif",go="#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",vo="#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;}",xo="#ifdef RENDER_SHADOWS\nuniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_normal_offset;vec3 shadow_normal_offset(vec3 normal) {float tileInMeters=u_shadow_normal_offset[0];vec3 n=vec3(-normal.xy,tileInMeters*normal.z);float dotScale=min(1.0-dot(normal,u_shadow_direction),1.0)*0.5+0.5;return n*dotScale;}vec3 shadow_normal_offset_model(vec3 normal) {vec3 transformed_normal=vec3(-normal.xy,normal.z);float NDotL=dot(normalize(transformed_normal),u_shadow_direction);float dotScale=min(1.0-NDotL,1.0)*0.5+0.5;return normal*dotScale;}float shadow_normal_offset_multiplier0() {return u_shadow_normal_offset[1];}float shadow_normal_offset_multiplier1() {return u_shadow_normal_offset[2];}\n#endif//RENDER_SHADOWS",yo="#ifdef RENDER_SHADOWS\n#ifdef DEPTH_TEXTURE\nuniform highp sampler2D u_shadowmap_0;uniform highp sampler2D u_shadowmap_1;\n#else\nuniform sampler2D u_shadowmap_0;uniform sampler2D u_shadowmap_1;\n#endif\nuniform float u_shadow_intensity;uniform float u_shadow_map_resolution;uniform float u_shadow_texel_size;uniform highp vec3 u_shadow_normal_offset;uniform vec2 u_fade_range;uniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_bias;highp float shadow_sample_1(highp vec2 uv,highp float compare) {highp float shadow_depth;\n#ifdef DEPTH_TEXTURE\nshadow_depth=texture(u_shadowmap_1,uv).r;\n#else\nshadow_depth=unpack_depth(texture(u_shadowmap_1,uv))*0.5+0.5;\n#endif\nreturn step(shadow_depth,compare);}highp float shadow_sample_0(highp vec2 uv,highp float compare) {highp float shadow_depth;\n#ifdef DEPTH_TEXTURE\nshadow_depth=texture(u_shadowmap_0,uv).r;\n#else\nshadow_depth=unpack_depth(texture(u_shadowmap_0,uv))*0.5+0.5;\n#endif\nreturn step(shadow_depth,compare);}float shadow_occlusion_1(highp vec4 pos,highp float bias) {highp vec2 uv=pos.xy;return shadow_sample_1(uv,pos.z-bias);}float shadow_occlusion_0(highp vec4 pos,highp float bias) {highp float compare0=pos.z-bias;\n#ifdef TEXTURE_GATHER\nhighp vec2 uv=pos.xy;highp vec4 samples=textureGather(u_shadowmap_0,uv,0);lowp vec4 stepSamples=step(samples,vec4(compare0));\n#else\nhighp vec2 uv00=pos.xy-vec2(0.5*u_shadow_texel_size);highp vec2 uv10=uv00+vec2(u_shadow_texel_size,0.0);highp vec2 uv01=uv00+vec2(0.0,u_shadow_texel_size);highp vec2 uv11=uv01+vec2(u_shadow_texel_size,0.0);lowp vec4 stepSamples=vec4(\nshadow_sample_0(uv01,compare0),shadow_sample_0(uv11,compare0),shadow_sample_0(uv10,compare0),shadow_sample_0(uv00,compare0)\n);\n#endif\nvec2 f=fract(pos.xy*u_shadow_map_resolution-vec2(0.5));lowp vec2 lerpx=mix(stepSamples.wx,stepSamples.zy,f.xx);return mix(lerpx.x,lerpx.y,f.y);}float shadow_occlusion(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,highp float bias) {\n#ifdef SHADOWS_SINGLE_CASCADE\nlight_view_pos0.xyz=light_view_pos0.xyz/light_view_pos0.w*0.5+0.5;return shadow_occlusion_0(light_view_pos0,bias);\n#else\nlight_view_pos0.xyz/=light_view_pos0.w;light_view_pos1.xyz/=light_view_pos1.w;vec4 uv=vec4(light_view_pos0.xy,light_view_pos1.xy);vec4 abs_bounds=abs(uv);if (abs_bounds.x < 1.0 && abs_bounds.y < 1.0) {light_view_pos0.xyz=light_view_pos0.xyz*0.5+0.5;return shadow_occlusion_0(light_view_pos0,bias);}if (abs_bounds.z >=1.0 || abs_bounds.w >=1.0) {return 0.0;}light_view_pos1.xyz=light_view_pos1.xyz*0.5+0.5;float occlusion1=shadow_occlusion_1(light_view_pos1,bias);return mix(occlusion1,0.0,smoothstep(u_fade_range.x,u_fade_range.y,view_depth));\n#endif\n}highp float calculate_shadow_bias(float NDotL) {\n#ifdef NORMAL_OFFSET\nreturn 0.5*u_shadow_bias.x;\n#else\nreturn 0.5*(u_shadow_bias.x+clamp(u_shadow_bias.y*tan(acos(NDotL)),0.0,u_shadow_bias.z));\n#endif\n}float shadowed_light_factor_normal(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=calculate_shadow_bias(NDotL);float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor_normal_opacity(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,float shadow_opacity) {float NDotL=dot(N,u_shadow_direction);float bias=calculate_shadow_bias(NDotL);float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias)*shadow_opacity;return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor_normal_unbiased(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return 1.0-(u_shadow_intensity*occlusion);}float shadow_occlusion(float ndotl,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=calculate_shadow_bias(ndotl);return shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);}\n#endif";const bo=[];Io(co,bo),Io(uo,bo),Io(ho,bo);const wo={"_prelude_fog.vertex.glsl":fo,"_prelude_terrain.vertex.glsl":po,"_prelude_shadow.vertex.glsl":xo,"_prelude_fog.fragment.glsl":mo,"_prelude_shadow.fragment.glsl":yo,"_prelude_lighting.glsl":"\n#ifdef LIGHTING_3D_MODE\nuniform mediump vec3 u_lighting_ambient_color;uniform mediump vec3 u_lighting_directional_dir;uniform mediump vec3 u_lighting_directional_color;uniform mediump vec3 u_ground_radiance;float calculate_ambient_directional_factor(vec3 normal) {float NdotL=dot(normal,u_lighting_directional_dir);const float factor_reduction_max=0.3;float dir_luminance=dot(u_lighting_directional_color,vec3(0.2126,0.7152,0.0722));float directional_factor_min=1.0-factor_reduction_max*min(dir_luminance,1.0);float ambient_directional_factor=mix(directional_factor_min,1.0,min((NdotL+1.0),1.0));const float vertical_factor_min=0.92;float vertical_factor=mix(vertical_factor_min,1.0,normal.z*0.5+0.5);return vertical_factor*ambient_directional_factor;}vec3 linearProduct(vec3 srgbIn,vec3 k) {return srgbIn*pow(k,vec3(1./2.2));}vec3 apply_lighting(vec3 color,vec3 normal,float dir_factor) {float ambient_directional_factor=calculate_ambient_directional_factor(normal);vec3 ambient_contrib=ambient_directional_factor*u_lighting_ambient_color;vec3 directional_contrib=u_lighting_directional_color*dir_factor;return linearProduct(color,ambient_contrib+directional_contrib);}vec4 apply_lighting(vec4 color,vec3 normal,float dir_factor) {return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting(vec3 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return apply_lighting(color.rgb,normal,dir_factor);}vec4 apply_lighting(vec4 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting_ground(vec3 color) {return color*u_ground_radiance;}vec4 apply_lighting_ground(vec4 color) {return vec4(apply_lighting_ground(color.rgb),color.a);}float calculate_NdotL(vec3 normal) {const float ext=0.70710678118;return (clamp(dot(normal,u_lighting_directional_dir),-ext,1.0)+ext)/(1.0+ext);}vec4 apply_lighting_with_emission_ground(vec4 color,float emissive_strength) {return mix(apply_lighting_ground(color),color,emissive_strength);}vec3 compute_flood_lighting(vec3 flood_light_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=flood_light_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);float occlusion_ramp=smoothstep(0.0,0.2,1.0-occlusion);return mix(fully_occluded_color,flood_light_color,occlusion_ramp);}vec3 compute_emissive_draped(vec3 unlit_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=unlit_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);return mix(fully_occluded_color,unlit_color,1.0-occlusion);}\n#endif//LIGHTING_3D_MODE","_prelude_raster_array.glsl":go,"_prelude_raster_particle.glsl":vo},To={};Do("",po),Do(mo,fo),Do(yo,xo),Do(go,""),Do(vo,"");const Eo=Do(ho,uo),So=co;var Co={background:Do('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec4 u_color;uniform float u_opacity;\n#ifdef LIGHTING_3D_MODE\nin vec4 v_color;\n#endif\nvoid main() {vec4 out_color;\n#ifdef LIGHTING_3D_MODE\nout_color=v_color;\n#else\nout_color=u_color;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_lighting.glsl"\nin vec2 a_pos;uniform mat4 u_matrix;\n#ifdef LIGHTING_3D_MODE\nuniform mediump vec4 u_color;out vec4 v_color;uniform float u_emissive_strength;\n#endif\nvoid main() {gl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef LIGHTING_3D_MODE\nv_color=apply_lighting_with_emission_ground(u_color,u_emissive_strength);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),backgroundPattern:Do('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_pattern_tl;uniform vec2 u_pattern_br;uniform vec2 u_texsize;uniform float u_opacity;uniform float u_emissive_strength;uniform sampler2D u_image;in highp vec2 v_pos;void main() {highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(u_pattern_tl/u_texsize,u_pattern_br/u_texsize,imagecoord);vec4 out_color=textureLodCustom(u_image,pos,v_pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_pattern_size;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec2 u_pattern_units_to_pixels;in vec2 a_pos;out highp vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_pattern_size,u_pattern_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),circle:Do('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nin vec3 v_data;in float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nuniform float u_emissive_strength;void main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float blur_positive=blur < 0.0 ? 0.0 : 1.0;lowp float antialiasblur=v_data.z;float extrude_length=length(extrude)+antialiasblur*(1.0-blur_positive);float antialiased_blur=-max(abs(blur),antialiasblur);float opacity_t=smoothstep((1.0-blur_positive)*antialiased_blur,blur_positive*antialiased_blur,extrude_length-1.0)-smoothstep(0.0,antialiasblur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(\nantialiased_blur,0.0,extrude_length-radius/(radius+stroke_width)\n);vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_apply_premultiplied(out_color,v_fog_pos);\n#endif\nglFragColor=out_color*(v_visibility*opacity_t);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#define NUM_VISIBILITY_RINGS 2\n#define INV_SQRT2 0.70710678\n#define ELEVATION_BIAS 0.0001\n#define NUM_SAMPLES_PER_RING 16\nuniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;in vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\nout vec3 v_data;out float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvec2 calc_offset(vec2 extrusion,float radius,float stroke_width, float view_scale) {return extrusion*(radius+stroke_width)*u_extrude_scale*view_scale;}float cantilevered_elevation(vec2 pos,float radius,float stroke_width,float view_scale) {vec2 c1=pos+calc_offset(vec2(-1,-1),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1,-1),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1,1),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1,1),radius,stroke_width,view_scale);float h1=elevation(c1)+ELEVATION_BIAS;float h2=elevation(c2)+ELEVATION_BIAS;float h3=elevation(c3)+ELEVATION_BIAS;float h4=elevation(c4)+ELEVATION_BIAS;return max(h4,max(h3,max(h1,h2)));}float circle_elevation(vec2 pos) {\n#if defined(TERRAIN)\nreturn elevation(pos)+ELEVATION_BIAS;\n#else\nreturn 0.0;\n#endif\n}vec4 project_vertex(vec2 extrusion,vec4 world_center,vec4 projected_center,float radius,float stroke_width, float view_scale,mat3 surface_vectors) {vec2 sample_offset=calc_offset(extrusion,radius,stroke_width,view_scale);\n#ifdef PITCH_WITH_MAP\n#ifdef PROJECTION_GLOBE_VIEW\nreturn u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) );\n#else\nreturn u_matrix*( world_center+vec4(sample_offset,0,0) );\n#endif\n#else\nreturn projected_center+vec4(sample_offset,0,0);\n#endif\n}float get_sample_step() {\n#ifdef PITCH_WITH_MAP\nreturn 2.0*PI/float(NUM_SAMPLES_PER_RING);\n#else\nreturn PI/float(NUM_SAMPLES_PER_RING);\n#endif\n}void main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);vec4 world_center;mat3 surface_vectors;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=a_pos_normal_3/16384.0;surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(circle_center)*circle_elevation(circle_center);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*circle_elevation(circle_center);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,circle_center,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);world_center=vec4(pos,1);\n#else \nsurface_vectors=mat3(1.0);float height=circle_elevation(circle_center);world_center=vec4(circle_center,height,1);\n#endif\nvec4 projected_center=u_matrix*world_center;float view_scale=0.0;\n#ifdef PITCH_WITH_MAP\n#ifdef SCALE_WITH_MAP\nview_scale=1.0;\n#else\nview_scale=projected_center.w/u_camera_to_center_distance;\n#endif\n#else\n#ifdef SCALE_WITH_MAP\nview_scale=u_camera_to_center_distance;\n#else\nview_scale=projected_center.w;\n#endif\n#endif\ngl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0;\n#ifdef TERRAIN\nfloat step=get_sample_step();vec4 occlusion_world_center;vec4 occlusion_projected_center;\n#ifdef PITCH_WITH_MAP\nfloat cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);occlusion_world_center=vec4(circle_center,cantilevered_height,1);occlusion_projected_center=u_matrix*occlusion_world_center;\n#else\nocclusion_world_center=world_center;occlusion_projected_center=projected_center;\n#endif\nfor(int ring=0; ring < NUM_VISIBILITY_RINGS; ring++) {float scale=(float(ring)+1.0)/float(NUM_VISIBILITY_RINGS);for(int i=0; i < NUM_SAMPLES_PER_RING; i++) {vec2 extrusion=vec2(cos(step*float(i)),-sin(step*float(i)))*scale;vec4 frag_pos=project_vertex(extrusion,occlusion_world_center,occlusion_projected_center,radius,stroke_width,view_scale,surface_vectors);visibility+=float(!isOccluded(frag_pos));}}visibility/=float(NUM_VISIBILITY_RINGS)*float(NUM_SAMPLES_PER_RING);\n#else\nvisibility=1.0;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nvisibility=1.0;\n#endif\nv_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);\n#ifdef FOG\nv_fog_pos=fog_position(world_center.xyz);\n#endif\n}'),clippingMask:Do("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:Do('#include "_prelude_fog.fragment.glsl"\nuniform highp float u_intensity;in vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);glFragColor=vec4(val,1.0,1.0,1.0);\n#ifdef FOG\nif (u_is_globe==0) {glFragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;in vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\nout vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 tilePos=floor(a_pos*0.5);vec3 pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(tilePos)*elevation(tilePos);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#else\npos=vec3(tilePos+extrude,elevation(tilePos));\n#endif\ngl_Position=u_matrix*vec4(pos,1);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),heatmapTexture:Do("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:Do("in float v_placed;in float v_notUsed;void main() {vec4 red =vec4(1.0,0.0,0.0,1.0);vec4 blue=vec4(0.0,0.0,1.0,0.5);glFragColor =mix(red,blue,step(0.5,v_placed))*0.5;glFragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}",'#include "_prelude_terrain.vertex.glsl"\nin vec3 a_pos;in vec2 a_anchor_pos;in vec2 a_extrude;in vec2 a_placed;in vec2 a_shift;in vec2 a_elevation_from_sea;in float a_size_scale;in vec2 a_padding;in float a_auto_z_offset;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;out float v_placed;out float v_notUsed;void main() {float feature_elevation=a_elevation_from_sea.x+a_auto_z_offset;float terrain_elevation=(a_elevation_from_sea.y==1.0 ? 0.0 : elevation(a_anchor_pos));vec4 projectedPoint=u_matrix*vec4(a_pos+elevationVector(a_anchor_pos)*(feature_elevation+terrain_elevation),1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,1.5);gl_Position=projectedPoint;gl_Position.xy+=(a_extrude*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}'),collisionCircle:Do("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:Do("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);glFragColor=mix(u_color,overlay_color,overlay_color.a);}",'#include "_prelude_terrain.vertex.glsl"\nin vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;\n#endif\nout vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {float h=elevation(a_pos);v_uv=a_pos/8192.0;\n#ifdef PROJECTION_GLOBE_VIEW\ngl_Position=u_matrix*vec4(a_pos_3+elevationVector(a_pos)*h,1);\n#else\ngl_Position=u_matrix*vec4(a_pos*u_overlay_scale,h,1);\n#endif\n}'),fill:Do('#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\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\nglFragColor=out_color*opacity;\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;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp float z_offset\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;\n#endif\nfloat hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);\n#ifdef 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}'),fillOutline:Do('#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\nglFragColor=out_color*(alpha*opacity);\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);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\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:Do('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;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\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\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);float dist=length(v_pos_world-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#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\nglFragColor=out_color*(alpha*opacity);\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#pragma mapbox: define lowp float pixel_ratio\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\n#pragma mapbox: initialize highp float z_offset\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;\n#endif\nfloat hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);v_pos_world=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef 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:Do('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;in 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 lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#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\nglFragColor=out_color*opacity;\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;\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#pragma mapbox: define lowp float pixel_ratio\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\n#pragma mapbox: initialize highp float z_offset\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;\n#endif\nfloat hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);\n#ifdef 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:Do('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nin vec4 v_color;in vec4 v_flat;\n#ifdef RENDER_SHADOWS\nin highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;\n#endif\nuniform lowp float u_opacity;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;in vec2 v_ao;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nin vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nin highp vec3 v_normal;\n#endif\nuniform vec3 u_flood_light_color;uniform highp float u_vertical_scale;uniform float u_flood_light_intensity;uniform vec3 u_ground_shadow_factor;\n#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)\nin float v_flood_radius;in float v_has_floodlight;\n#endif\nin float v_height;\n#pragma mapbox: define highp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize highp float emissive_strength\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nvec3 normal=normalize(v_normal);\n#endif\nfloat z;vec4 color=v_color;\n#ifdef ZERO_ROOF_RADIUS\nz=float(normal.z > 0.00001);\n#ifdef LIGHTING_3D_MODE\nnormal=mix(normal,vec3(0.0,0.0,1.0),z);\n#else\ncolor=mix(v_color,v_roof_color,z);\n#endif\n#endif\nfloat h=max(0.0,v_height);float ao_shade=1.0;\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h_floors=h/(u_ao[1]*u_vertical_scale);float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);ao_shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;\n#ifdef ZERO_ROOF_RADIUS\nconcave*=(1.0-z);\n#endif\nfloat x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);ao_shade*=mix(1.0,x_shade*x_shade*x_shade,concave);\n#ifdef LIGHTING_3D_MODE\n#ifdef FLOOD_LIGHT\ncolor.rgb*=mix(ao_shade,1.0,v_has_floodlight);\n#else\ncolor.rgb*=ao_shade;\n#endif\n#else\ncolor.rgb*=ao_shade;\n#endif\n#endif\n#ifdef LIGHTING_3D_MODE\nfloat flood_radiance=0.0;\n#ifdef FLOOD_LIGHT\nflood_radiance=(1.0-min(h/v_flood_radius,1.0))*u_flood_light_intensity*v_has_floodlight;\n#endif\n#ifdef RENDER_SHADOWS\n#ifdef FLOOD_LIGHT\nfloat ndotl_unclamped=dot(normal,u_shadow_direction);float ndotl=max(0.0,ndotl_unclamped);float occlusion=ndotl_unclamped < 0.0 ? 1.0 : shadow_occlusion(ndotl,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);vec3 litColor=apply_lighting(color.rgb,normal,(1.0-u_shadow_intensity*occlusion)*ndotl);vec3 floodLitColor=compute_flood_lighting(u_flood_light_color*u_opacity,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=mix(litColor,floodLitColor,flood_radiance);\n#else\nfloat shadowed_lighting_factor;\n#ifdef RENDER_CUTOFF\nshadowed_lighting_factor=shadowed_light_factor_normal_opacity(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,v_cutoff_opacity);if (v_cutoff_opacity==0.0) {discard;}\n#else\nshadowed_lighting_factor=shadowed_light_factor_normal(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);\n#endif\ncolor.rgb=apply_lighting(color.rgb,normal,shadowed_lighting_factor);\n#endif\n#else\ncolor.rgb=apply_lighting(color.rgb,normal);\n#ifdef FLOOD_LIGHT\ncolor.rgb=mix(color.rgb,u_flood_light_color*u_opacity,flood_radiance);\n#endif\n#endif\ncolor.rgb=mix(color.rgb,v_flat.rgb,emissive_strength);color*=u_opacity;\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos,h));\n#endif\n#ifdef INDICATOR_CUTOUT\ncolor=applyCutout(color);\n#endif\nglFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\n#include "_prelude_lighting.glsl"\nuniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_edge_radius;uniform float u_width_scale;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#ifdef RENDER_WALL_MODE\nin vec3 a_join_normal_inside;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\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;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define highp float flood_light_wall_radius\n#pragma mapbox: define highp float line_width\n#pragma mapbox: define highp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize highp float flood_light_wall_radius\n#pragma mapbox: initialize highp float line_width\n#pragma mapbox: initialize highp float emissive_strength\nbase*=u_vertical_scale;height*=u_vertical_scale;vec4 pos_nx=floor(a_pos_normal_ed*0.5);vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nv_normal=normal;\n#endif\nbase=max(0.0,base);float attr_height=height;height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\nfloat ele=0.0;float h=0.0;float c_ele=0.0;vec3 pos;\n#ifdef TERRAIN\nbool 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);cutoff=cutoff_opacity(u_cutoff_params,ground.z);if (centroid_pos.y !=0.0 && centroid_pos.x !=0.0) {vec3 g=floor(ground_pos);vec3 mod_=centroid_random-g*8.0;float seed=min(1.0,0.1*(min(3.5,max(mod_.x+mod_.y,0.2*attr_height))*0.35+mod_.z));if (cutoff < 0.8-seed) {cutoff=0.0;}}float cutoff_scale=cutoff;v_cutoff_opacity=cutoff;scaled_pos.z=mix(c_ele,h,cutoff_scale);\n#endif\nfloat hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (cutoff==0.0 && centroid_pos.x !=0.0) || (color.a==0.0));\n#ifdef RENDER_WALL_MODE\nvec2 wall_offset=u_width_scale*line_width*(a_join_normal_inside.xy/EXTENT);scaled_pos.xy+=(1.0-a_join_normal_inside.z)*wall_offset*0.5;scaled_pos.xy-=a_join_normal_inside.z*wall_offset*0.5;\n#endif\ngl_Position=mix(u_matrix*vec4(scaled_pos,1),AWAY,hidden);h=h-ele;v_height=h;\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=pos;vec3 shd_pos1=pos;\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(normal);shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);\n#endif\nfloat NdotL=0.0;float colorvalue=0.0;\n#ifndef LIGHTING_3D_MODE\ncolorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),NdotL);if (normal.y !=0.0) {float r=0.84;r=mix(0.7,0.98,1.0-u_lightintensity);NdotL*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}\n#endif\n#ifdef FAUX_AO\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\n#ifdef TERRAIN\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\n#endif\nv_ao=vec2(mix(concave,-concave,start),y_ground);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\n#ifdef LIGHTING_3D_MODE\n#ifdef FLOOD_LIGHT\nfloat is_wall=1.0-float(t > 0.0 && top_up_ny.y > 0.0);v_has_floodlight=float(flood_light_wall_radius > 0.0 && is_wall > 0.0);v_flood_radius=flood_light_wall_radius*u_vertical_scale;\n#endif\nv_color=vec4(color.rgb,1.0);v_flat=vec4(linearProduct(color.rgb,vec3(calculate_NdotL(normal))),1.0);\n#else\nv_color=vec4(0.0,0.0,0.0,1.0);v_color.rgb+=clamp(color.rgb*NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nfloat roofNdotL=clamp(u_lightpos.z,0.0,1.0);roofNdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),roofNdotL);v_roof_color=vec4(0.0,0.0,0.0,1.0);v_roof_color.rgb+=clamp(color.rgb*roofNdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_roof_color*=u_opacity;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),fillExtrusionDepth:Do("in highp float v_depth;void main() {\n#ifndef DEPTH_TEXTURE\nglFragColor=pack_depth(v_depth);\n#endif\n}",'#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_edge_radius;uniform float u_width_scale;uniform float u_vertical_scale;\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() {\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:Do('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;in vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nin vec3 v_normal;\n#endif\nin highp vec2 v_pos;in vec4 v_lighting;uniform lowp float u_opacity;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define mediump vec4 pattern\n#pragma mapbox: define highp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize highp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color,normalize(v_normal))*u_opacity;\n#else\nout_color=out_color*v_lighting;\n#endif\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);out_color.rgb=out_color.rgb*shade;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_lighting.glsl"\nuniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform float u_tile_units_to_pixels;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_width_scale;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#ifdef RENDER_WALL_MODE\nin vec3 a_join_normal_inside;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\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#pragma mapbox: define highp float pixel_ratio\n#pragma mapbox: define highp float line_width\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize highp float pixel_ratio\n#pragma mapbox: initialize highp float line_width\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec4 pos_nx=floor(a_pos_normal_ed*0.5);mediump vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;mediump vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=a_pos_normal_ed.w;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\nfloat ele=0.0;float h=z;vec3 p;float c_ele;\n#ifdef TERRAIN\nbool 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:Do('#include "_prelude_shadow.fragment.glsl"\nprecision highp float;uniform vec3 u_ground_shadow_factor;in vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;\n#ifdef FOG\nin float v_fog_opacity;\n#endif\nvoid main() {float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);vec3 shadow=mix(u_ground_shadow_factor,vec3(1.0),light);\n#ifdef RENDER_CUTOFF\nshadow=mix(vec3(1.0),shadow,cutoff_opacity(u_cutoff_params,1.0/gl_FragCoord.w));\n#endif\n#ifdef FOG\nshadow=mix(shadow,vec3(1.0),v_fog_opacity);\n#endif\n#ifdef INDICATOR_CUTOUT\nshadow=mix(shadow,vec3(1.0),1.0-applyCutout(vec4(1.0)).r);\n#endif\nglFragColor=vec4(shadow,1.0);}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;in vec2 a_pos;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1;\n#ifdef FOG\nout float v_fog_opacity;\n#endif\nvoid main() {gl_Position=u_matrix*vec4(a_pos,0.0,1.0);v_pos_light_view_0=u_light_matrix_0*vec4(a_pos,0.0,1.0);v_pos_light_view_1=u_light_matrix_1*vec4(a_pos,0.0,1.0);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);v_fog_opacity=fog(v_fog_pos);\n#endif\n}'),fillExtrusionGroundEffect:Do("uniform highp float u_ao_pass;uniform highp float u_opacity;uniform highp float u_flood_light_intensity;uniform highp vec3 u_flood_light_color;uniform highp float u_attenuation;uniform sampler2D u_fb;uniform float u_fb_size;\n#ifdef SDF_SUBPASS\nin highp vec2 v_pos;in highp vec4 v_line_segment;in highp float v_flood_light_radius_tile;in highp vec2 v_ao;float line_df(highp vec2 a,highp vec2 b,highp vec2 p) {highp vec2 ba=b-a;highp vec2 pa=p-a;highp float r=clamp(dot(pa,ba)/dot(ba,ba),0.0,1.0);return length(pa-r*ba);}\n#ifdef FOG\nin highp float v_fog;\n#endif\n#endif\nvoid main() {\n#ifdef CLEAR_SUBPASS\nvec4 color=vec4(1.0);\n#ifdef CLEAR_FROM_TEXTURE\ncolor=texture(u_fb,gl_FragCoord.xy/vec2(u_fb_size));\n#endif\nglFragColor=color;\n#else\n#ifdef SDF_SUBPASS\nhighp float d=line_df(v_line_segment.xy,v_line_segment.zw,v_pos);highp float effect_radius=mix(v_flood_light_radius_tile,v_ao.y,u_ao_pass);d/=effect_radius;d=min(d,1.0);d=1.0-pow(1.0-d,u_attenuation);highp float effect_intensity=mix(u_flood_light_intensity,v_ao.x,u_ao_pass);highp float fog=1.0;\n#ifdef FOG\nfog=v_fog;\n#endif\n#ifdef RENDER_CUTOFF\nfog*=v_cutoff_opacity;\n#endif\nglFragColor=vec4(vec3(0.0),mix(1.0,d,effect_intensity*u_opacity*fog));\n#else\nvec4 color=mix(vec4(u_flood_light_color,1.0),vec4(vec3(0.0),1.0),u_ao_pass);\n#ifdef OVERDRAW_INSPECTOR\ncolor=vec4(1.0);\n#endif\nglFragColor=color;\n#endif\nHANDLE_WIREFRAME_DEBUG;\n#endif\n}",'#include "_prelude_fog.vertex.glsl"\nin highp vec4 a_pos_end;in highp float a_angular_offset_factor;in highp float a_hidden_by_landmark;\n#ifdef SDF_SUBPASS\nout highp vec2 v_pos;out highp vec4 v_line_segment;out highp float v_flood_light_radius_tile;out highp vec2 v_ao;\n#ifdef FOG\nout highp float v_fog;\n#endif\n#endif\nuniform highp float u_flood_light_intensity;uniform highp mat4 u_matrix;uniform highp float u_ao_pass;uniform highp float u_meter_to_tile;uniform highp float u_edge_radius;uniform highp float u_dynamic_offset;uniform highp vec2 u_ao;\n#pragma mapbox: define highp float flood_light_ground_radius\nconst float TANGENT_CUTOFF=4.0;const float NORM=32767.0;void main() {\n#pragma mapbox: initialize highp float flood_light_ground_radius\nvec2 p=a_pos_end.xy;vec2 q=floor(a_pos_end.zw*0.5);vec2 start_bottom=a_pos_end.zw-q*2.0;float fl_ground_radius=flood_light_ground_radius;fl_ground_radius=abs(flood_light_ground_radius);float direction=flood_light_ground_radius < 0.0 ?-1.0 : 1.0;float flood_radius_tile=fl_ground_radius*u_meter_to_tile;vec2 v=normalize(q-p);float ao_radius=u_ao.y/3.5;float effect_radius=mix(flood_radius_tile,ao_radius,u_ao_pass)+u_edge_radius;float angular_offset_factor=a_angular_offset_factor/NORM*TANGENT_CUTOFF;float angular_offset=direction*angular_offset_factor*effect_radius;float top=1.0-start_bottom.y;float side=(0.5-start_bottom.x)*2.0;vec2 extrusion_parallel=v*side*mix(u_dynamic_offset,angular_offset,top);vec2 perp=vec2(v.y,-v.x);vec2 extrusion_perp=direction*perp*effect_radius*top;vec3 pos=vec3(mix(q,p,start_bottom.x),0.0);pos.xy+=extrusion_parallel+extrusion_perp;\n#ifdef SDF_SUBPASS\nv_pos=pos.xy;v_line_segment=vec4(p,q)+perp.xyxy*u_edge_radius;v_flood_light_radius_tile=flood_radius_tile;v_ao=vec2(u_ao.x,ao_radius);\n#ifdef FOG\nv_fog_pos=fog_position(pos);v_fog=1.0-fog(v_fog_pos);\n#endif\n#endif\nfloat hidden_by_landmark=0.0;\n#ifdef HAS_CENTROID\nhidden_by_landmark=a_hidden_by_landmark;\n#endif\nfloat isFloodlit=float(fl_ground_radius > 0.0 && u_flood_light_intensity > 0.0);float hidden=mix(1.0-isFloodlit,isFloodlit,u_ao_pass);hidden+=hidden_by_landmark;gl_Position=mix(u_matrix*vec4(pos,1.0),AWAY,float(hidden > 0.0));\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n}'),hillshadePrepare:Do("precision highp float;uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;float getElevation(vec2 coord) {return texture(u_image,coord).r/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y));float b=getElevation(v_pos+vec2(0,-epsilon.y));float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y));float d=getElevation(v_pos+vec2(-epsilon.x,0));float e=getElevation(v_pos+vec2(epsilon.x,0));float f=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float g=getElevation(v_pos+vec2(0,epsilon.y));float h=getElevation(v_pos+vec2(epsilon.x,epsilon.y));float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2(\n(c+e+e+h)-(a+d+d+f),(f+g+g+h)-(a+b+b+c)\n)/pow(2.0,exaggeration+(19.2562-u_zoom));glFragColor=clamp(vec4(\nderiv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);}","uniform mat4 u_matrix;uniform vec2 u_dimension;in vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:Do('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;uniform float u_emissive_strength;void main() {vec4 pixel=texture(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);glFragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef LIGHTING_3D_MODE\nglFragColor=apply_lighting_with_emission_ground(glFragColor,u_emissive_strength);\n#endif\n#ifdef FOG\nglFragColor=fog_dither(fog_apply_premultiplied(glFragColor,v_fog_pos));\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;in vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),line:Do('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nuniform lowp float u_device_pixel_ratio;uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;uniform highp vec2 u_trim_fade_range;uniform lowp vec4 u_trim_color;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec4 v_uv;\n#ifdef RENDER_LINE_DASH\nuniform sampler2D u_dash_image;in vec2 v_tex;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform sampler2D u_gradient_image;\n#endif\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;}uniform float u_emissive_strength;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float border_width\n#pragma mapbox: define lowp vec4 border_color\nfloat linearstep(float edge0,float edge1,float x) {return clamp((x-edge0)/(edge1-edge0),0.0,1.0);}void main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float border_width\n#pragma mapbox: initialize lowp vec4 border_color\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);\n#ifdef RENDER_LINE_DASH\nfloat sdfdist=texture(u_dash_image,v_tex).r;float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/dash.z;alpha*=linearstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);\n#endif\nhighp vec4 out_color;\n#ifdef RENDER_LINE_GRADIENT\nout_color=texture(u_gradient_image,v_uv.xy);\n#else\nout_color=color;\n#endif\nfloat trim_alpha=1.0;\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float start=v_uv[2];highp float end=v_uv[3];highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=(start+(v_uv.x)*(end-start));if (trim_end > trim_start) {highp float start_transition=max(0.0,min(1.0,(line_progress-trim_start)/max(u_trim_fade_range[0],1.0e-9)));highp float end_transition=max(0.0,min(1.0,(trim_end-line_progress)/max(u_trim_fade_range[1],1.0e-9)));highp float transition_factor=min(start_transition,end_transition);out_color=mix(out_color,u_trim_color,transition_factor);trim_alpha=out_color.a;}\n#endif\nif (u_alpha_discard_threshold !=0.0) {if (alpha < u_alpha_discard_threshold) {discard;}}\n#ifdef RENDER_LINE_BORDER\nfloat edgeBlur=(border_width+1.0/u_device_pixel_ratio);float alpha2=clamp(min(dist-(v_width2.t-edgeBlur),v_width2.s-dist)/edgeBlur,0.0,1.0);if (alpha2 < 1.) {float smoothAlpha=smoothstep(0.6,1.0,alpha2);if (border_color.a==0.0) {float Y=(out_color.a > 0.01) ? luminance(out_color.rgb/out_color.a) : 1.;float adjustment=(Y > 0.) ? 0.5/Y : 0.45;if (out_color.a > 0.25 && Y < 0.25) {vec3 borderColor=(Y > 0.) ? out_color.rgb : vec3(1,1,1)*out_color.a;out_color.rgb=out_color.rgb+borderColor*(adjustment*(1.0-smoothAlpha));} else {out_color.rgb*=(0.6 +0.4*smoothAlpha);}} else {out_color.rgb=mix(border_color.rgb*border_color.a*trim_alpha,out_color.rgb,smoothAlpha);}}\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#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*=(alpha*opacity);\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_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)\nin float a_z_offset;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nin highp vec4 a_packed;\n#endif\n#ifdef RENDER_LINE_DASH\nin float a_linesofar;\n#endif\nuniform mat4 u_matrix;uniform mat2 u_pixels_to_tile_units;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;\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 float v_gamma_scale;out highp vec4 v_uv;\n#ifdef RENDER_LINE_DASH\nuniform vec2 u_texsize;uniform float u_tile_units_to_pixels;out vec2 v_tex;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform float u_image_height;\n#endif\n#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 lowp float border_width\n#pragma mapbox: define lowp vec4 border_color\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float border_width\n#pragma mapbox: initialize lowp vec4 border_color\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*EXTRUDE_SCALE;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*EXTRUDE_SCALE*normal.y*mat2(t,-u,u,t);float hidden=float(opacity==0.0);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\ngl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,a_z_offset+0.01*step(0.01,a_z_offset),1.0)+projected_extrude;\n#else\n#ifdef ELEVATED\nvec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 offset_pos=pos+offsetTile;float ele=0.0;\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]+a_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+a_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+a_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#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nfloat a_uv_x=a_packed[0];float a_split_index=a_packed[1];highp float a_clip_start=a_packed[2];highp float a_clip_end=a_packed[3];\n#ifdef RENDER_LINE_GRADIENT\nhighp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec4(a_uv_x,a_split_index*texel_height-half_texel_height,a_clip_start,a_clip_end);\n#else\nv_uv=vec4(a_uv_x,0.0,a_clip_start,a_clip_end);\n#endif\n#endif\n#ifdef RENDER_LINE_DASH\nfloat scale=dash.z==0.0 ? 0.0 : u_tile_units_to_pixels/dash.z;float height=dash.y;v_tex=vec2(a_linesofar*scale/floorwidth,(-normal.y*height+dash.x+0.5)/u_texsize.y);\n#endif\nv_width2=vec2(outset,inset);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),linePattern:Do('#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_alpha_discard_threshold;uniform highp vec2 u_texsize;uniform highp float u_tile_units_to_pixels;uniform highp vec2 u_trim_offset;uniform sampler2D u_image;in vec2 v_normal;in vec2 v_width2;in highp float v_linesofar;in float v_gamma_scale;in float v_width;\n#ifdef RENDER_LINE_TRIM_OFFSET\nin highp vec4 v_uv;\n#endif\n#ifdef LINE_JOIN_NONE\nin vec2 v_pattern_data;\n#endif\n#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\nuniform float u_emissive_strength;\n#pragma mapbox: define mediump vec4 pattern\n#pragma mapbox: define mediump float pixel_ratio\n#pragma mapbox: define mediump float blur\n#pragma mapbox: define mediump float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize mediump float pixel_ratio\n#pragma mapbox: initialize mediump float blur\n#pragma mapbox: initialize mediump float opacity\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;float pattern_size=display_size.x/u_tile_units_to_pixels;float aspect=display_size.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);highp float pattern_x=v_linesofar/pattern_size*aspect;highp float x=mod(pattern_x,1.0);highp float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;highp vec2 pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(x,y));highp vec2 lod_pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(pattern_x,y));vec4 color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float start=v_uv[2];highp float end=v_uv[3];highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=(start+(v_uv.x)*(end-start));if (trim_end > trim_start) {if (line_progress <=trim_end && line_progress >=trim_start) {color=vec4(0,0,0,0);}}\n#endif\n#ifdef LINE_JOIN_NONE\nfloat pattern_len=pattern_size/aspect;float segment_phase=pattern_len-mod(v_linesofar-v_pattern_data.x+pattern_len,pattern_len);float visible_start=segment_phase-step(pattern_len*0.5,segment_phase)*pattern_len;float visible_end=floor((v_pattern_data.y-segment_phase)/pattern_len)*pattern_len+segment_phase;visible_end+=step(pattern_len*0.5,v_pattern_data.y-visible_end)*pattern_len;if (v_pattern_data.x < visible_start || v_pattern_data.x >=visible_end) {color=vec4(0.0);}\n#endif\n#ifdef LIGHTING_3D_MODE\ncolor=apply_lighting_with_emission_ground(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);color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\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);\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_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 float a_z_offset;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nin highp vec4 a_packed;\n#endif\nin highp float a_linesofar;\n#ifdef LINE_JOIN_NONE\nin highp vec3 a_pattern_data;out vec2 v_pattern_data;\n#endif\nuniform mat4 u_matrix;uniform float u_tile_units_to_pixels;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform float u_device_pixel_ratio;\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 vec4 v_uv;\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#pragma mapbox: define mediump float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize mediump float blur\n#pragma mapbox: initialize mediump float opacity\n#pragma mapbox: initialize mediump float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize mediump float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize mediump float pixel_ratio\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);vec2 dist=outset*a_extrude*scale;float u=0.5*a_direction;float t=1.0-abs(u);vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float hidden=float(opacity==0.0);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\ngl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,a_z_offset+0.01*step(0.01,a_z_offset),1.0)+projected_extrude;\n#else\n#ifdef ELEVATED\nvec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 offset_pos=pos+offsetTile;float ele=0.0;\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]+a_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+a_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+a_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\nfloat a_uv_x=a_packed[0];highp float a_clip_start=a_packed[2];highp float a_clip_end=a_packed[3];v_uv=vec4(a_uv_x,0.0,a_clip_start,a_clip_end);\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;\n#ifdef LINE_JOIN_NONE\nv_width=floorwidth+ANTIALIASING;mediump float pixels_to_tile_units=1.0/u_tile_units_to_pixels;mediump float pixel_ratio_inverse=1.0/pixel_ratio;mediump float aspect=v_width/((pattern.w-pattern.y)*pixel_ratio_inverse);highp float subt_multiple=(pattern.z-pattern.x)*pixel_ratio_inverse*pixels_to_tile_units*aspect*32.0;highp float subt=floor(a_pattern_data.z/subt_multiple)*subt_multiple;float offset_sign=(fract(a_pattern_data.x)-0.5)*4.0;float line_progress_offset=offset_sign*v_width*0.5*pixels_to_tile_units;v_linesofar=(a_pattern_data.z-subt)+a_linesofar+line_progress_offset;v_pattern_data=vec2(a_pattern_data.x+line_progress_offset,a_pattern_data.y);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),raster:Do('#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\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform mat3 u_grid_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;uniform vec2 u_texture_offset;uniform float u_raster_elevation;uniform float u_zoom_transition;uniform vec2 u_merc_center;\n#define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8\n#ifdef GLOBE_POLES\nin vec3 a_globe_pos;in vec2 a_uv;\n#else\nin vec2 a_pos;in vec2 a_texture_pos;\n#endif\nout vec2 v_pos0;out vec2 v_pos1;out float v_depth;\n#ifdef PROJECTION_GLOBE_VIEW\nout float v_split_fade;\n#endif\nvoid main() {vec2 uv;\n#ifdef GLOBE_POLES\nvec3 globe_pos=a_globe_pos;globe_pos+=normalize(globe_pos)*u_raster_elevation*GLOBE_UPSCALE;gl_Position=u_matrix*u_globe_matrix*vec4(globe_pos ,1.0);uv=a_uv;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(a_globe_pos,1.0)).xyz);\n#endif\n#else\nfloat w=1.0+dot(a_texture_pos,u_perspective_transform);uv=a_texture_pos/8192.0;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);vec3 globe_pos=latLngToECEF(latLng.xy);globe_pos+=normalize(globe_pos)*u_raster_elevation*GLOBE_UPSCALE;vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);float mercatorY=mercatorYfromLat(latLng[0]);float mercatorX=mercatorXfromLng(latLng[1]); \nv_split_fade=0.0;if (u_zoom_transition > 0.0) {vec2 merc_pos=vec2(mercatorX,mercatorY);merc_world_pos=vec4(merc_pos,u_raster_elevation,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;float opposite_merc_center=mod(u_merc_center.x+0.5,1.0);float dist_from_poles=(abs(mercatorY-0.5)*2.0);float range=0.1;v_split_fade=abs(opposite_merc_center-mercatorX);v_split_fade=clamp(1.0-v_split_fade,0.0,1.0);v_split_fade=max(smoothstep(1.0-range,1.0,dist_from_poles),max(smoothstep(1.0-range,1.0,v_split_fade),smoothstep(1.0-range,1.0,1.0-v_split_fade)));}float tiles=u_grid_matrix[0][2];if (tiles > 0.0) {float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];float uvY=mercatorY*tiles-idy;float uvX=mercatorX*tiles-idx;uv=vec2(uvX,uvY);}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition)*w,w);gl_Position=u_matrix*interpolated_pos;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n#else\ngl_Position=u_matrix*vec4(a_pos*w,u_raster_elevation*w,w);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n#endif\n#endif\nv_pos0=uv;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;v_pos0=u_texture_offset.x+u_texture_offset.y*v_pos0;v_pos1=u_texture_offset.x+u_texture_offset.y*v_pos1;\n#ifdef RENDER_CUTOFF\nv_depth=gl_Position.z;\n#endif\n}'),rasterParticle:Do('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform float u_fade_t;uniform float u_opacity;uniform highp float u_raster_elevation;in vec2 v_pos0;in vec2 v_pos1;uniform sampler2D u_image0;uniform sampler2D u_image1;void main() {vec4 color0,color1,color;color0=texture(u_image0,v_pos0);color1=texture(u_image1,v_pos1);if (color0.a > 0.0) color0.rgb/=color0.a;if (color1.a > 0.0) color1.rgb/=color1.a;color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 out_color=color.rgb;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),0.0).rgb;\n#endif\n#ifdef FOG\nhighp float fog_limit_high_meters=1000000.0;highp float fog_limit_low_meters=600000.0;float fog_limit=1.0-smoothstep(fog_limit_low_meters,fog_limit_high_meters,u_raster_elevation);out_color=fog_dither(fog_apply(out_color,v_fog_pos,fog_limit));\n#endif\nglFragColor=vec4(out_color*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform mat3 u_grid_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_raster_elevation;uniform float u_zoom_transition;uniform vec2 u_merc_center;\n#define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8\nin vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {float w=1.0;vec2 uv;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float mercatorX=mercatorXfromLng(latLng[1]);float tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];float uvX=mercatorX*tiles-idx;float uvY=mercatorY*tiles-idy;uv=vec2(uvX,uvY);vec3 globe_pos=latLngToECEF(latLng.xy);globe_pos+=normalize(globe_pos)*u_raster_elevation*GLOBE_UPSCALE;vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {vec2 merc_pos=vec2(mercatorX,mercatorY);merc_world_pos=vec4(merc_pos,u_raster_elevation,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition)*w,w);gl_Position=u_matrix*interpolated_pos;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n#else\nuv=a_texture_pos/8192.0;gl_Position=u_matrix*vec4(a_pos*w,u_raster_elevation*w,w);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n#endif\nv_pos0=uv;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}'),rasterParticleDraw:Do("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:Do("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:Do('#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:Do('#include "_prelude_lighting.glsl"\n#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;uniform bool u_is_halo;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\nin vec2 v_tex_a;\n#ifdef ICON_TRANSITION\nin vec2 v_tex_b;\n#endif\nin float v_draw_halo;in vec3 v_gamma_scale_size_fade_opacity;\n#ifdef RENDER_TEXT_AND_SYMBOL\nin float is_sdf;in vec2 v_tex_a_icon;\n#endif\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\n#pragma mapbox: initialize lowp float emissive_strength\nvec4 out_color;float fade_opacity=v_gamma_scale_size_fade_opacity[2];\n#ifdef RENDER_TEXT_AND_SYMBOL\nif (is_sdf==ICON) {vec2 tex_icon=v_tex_a_icon;lowp float alpha=opacity*fade_opacity;glFragColor=texture(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nreturn;}\n#endif\n#ifdef RENDER_SDF\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_gamma_scale_size_fade_opacity.x;float size=v_gamma_scale_size_fade_opacity.y;float fontScale=u_is_text ? size/24.0 : size;out_color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;bool draw_halo=v_draw_halo > 0.0;if (draw_halo) {out_color=halo_color;gamma=(halo_blur*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 COLOR_ADJUSTMENT\nout_color=u_color_adj_mat*out_color;\n#endif\n#endif\nout_color*=opacity*fade_opacity;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\nin vec4 a_pos_offset;in vec4 a_tex_size;in vec4 a_pixeloffset;in vec4 a_projected_pos;in float a_fade_opacity;\n#ifdef Z_OFFSET\nin float a_auto_z_offset;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_globe_anchor;in vec3 a_globe_normal;\n#endif\n#ifdef ICON_TRANSITION\nin vec2 a_texb;\n#endif\n#ifdef OCCLUSION_QUERIES\nin float a_occlusion_query_opacity;\n#endif\nuniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_elevation_from_sea;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;uniform vec2 u_texsize_icon;uniform bool u_is_halo;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nout vec2 v_tex_a;\n#ifdef ICON_TRANSITION\nout vec2 v_tex_b;\n#endif\nout float v_draw_halo;out vec3 v_gamma_scale_size_fade_opacity;\n#ifdef RENDER_TEXT_AND_SYMBOL\nout float is_sdf;out vec2 v_tex_a_icon;\n#endif\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n#pragma mapbox: define lowp float emissive_strength\n#pragma mapbox: define lowp float occlusion_opacity\n#pragma mapbox: define lowp float z_offset\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\n#pragma mapbox: initialize lowp float emissive_strength\n#pragma mapbox: initialize lowp float occlusion_opacity\n#pragma mapbox: initialize lowp float z_offset\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_min_font_scale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;float e=u_elevation_from_sea ? z_offset : z_offset+elevation(tile_anchor);\n#ifdef Z_OFFSET\ne+=a_auto_z_offset;\n#endif\nvec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;vec3 world_pos_globe;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos_globe=a_globe_anchor+h;world_pos=mix_globe_mercator(world_pos_globe,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nworld_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetprojected_point;vec2 a;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetprojected_point=u_matrix*vec4(a_globe_anchor+displacement,1);vec4 projected_point_globe=u_matrix*vec4(world_pos_globe,1);a=projected_point_globe.xy/projected_point_globe.w;\n#else\noffsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);a=projected_point.xy/projected_point.w;\n#endif\nvec2 b=offsetprojected_point.xy/offsetprojected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*max(a_min_font_scale,font_scale)+a_pxoffset/16.0);\n#ifdef TERRAIN\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\n#endif\n#ifdef Z_OFFSET\nz+=u_pitch_with_map ? a_auto_z_offset+(u_elevation_from_sea ? z_offset : z_offset) : 0.0;\n#else\nz+=u_pitch_with_map ? (u_elevation_from_sea ? z_offset : z_offset) : 0.0;\n#endif\nfloat occlusion_fade=globe_occlusion_fade;float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nvec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));float out_fade_opacity=interpolated_fade_opacity*projection_transition_fade;\n#ifdef DEPTH_OCCLUSION\nfloat depth_occlusion=occlusionFadeMultiSample(projected_point);float depth_occlusion_multplier=mix(occlusion_opacity,1.0,depth_occlusion);out_fade_opacity*=depth_occlusion_multplier;\n#endif\n#ifdef OCCLUSION_QUERIES\nfloat occludedFadeMultiplier=mix(occlusion_opacity,1.0,a_occlusion_query_opacity);out_fade_opacity*=occludedFadeMultiplier;\n#endif\nfloat alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,hidden);\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,hidden);\n#endif\nfloat gamma_scale=gl_Position.w;v_draw_halo=(u_is_halo && float(gl_InstanceID)==0.0) ? 1.0 : 0.0;v_gamma_scale_size_fade_opacity=vec3(gamma_scale,size,out_fade_opacity);v_tex_a=a_tex/u_texsize;\n#ifdef RENDER_TEXT_AND_SYMBOL\nis_sdf=a_size[0]-2.0*a_size_min;v_tex_a_icon=a_tex/u_texsize_icon;\n#endif\n#ifdef ICON_TRANSITION\nv_tex_b=a_texb/u_texsize;\n#endif\n}'),terrainRaster:Do('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image0;in vec2 v_pos0;\n#ifdef FOG\nin float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nin vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;\n#endif\nuniform vec3 u_ground_shadow_factor;void main() {vec4 image_color=texture(u_image0,v_pos0);vec4 color;\n#ifdef LIGHTING_3D_MODE\nconst vec3 normal=vec3(0.0,0.0,1.0);\n#ifdef RENDER_SHADOWS\nfloat cutoffOpacity=1.0;\n#ifdef RENDER_CUTOFF\ncutoffOpacity=cutoff_opacity(u_cutoff_params,1.0/gl_FragCoord.w);\n#endif\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nvec3 unlit_base=image_color.rgb*(1.0-image_color.a);vec3 emissive_base=image_color.rgb*image_color.a;float ndotl=u_shadow_direction.z;float occlusion=ndotl < 0.0 ? 1.0 : shadow_occlusion(v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,0.0);ndotl=max(0.0,ndotl);vec3 lit=apply_lighting(unlit_base,normal,mix(1.0,(1.0-(u_shadow_intensity*occlusion))*ndotl,cutoffOpacity));vec3 emissive=compute_emissive_draped(emissive_base,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=lit+emissive;color.a=1.0;\n#else\nfloat lighting_factor=shadowed_light_factor_normal_unbiased(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);color=apply_lighting(image_color,normal,mix(1.0,lighting_factor,cutoffOpacity));\n#endif\n#else\nfloat lighting_factor=u_lighting_directional_dir.z;color=apply_lighting(image_color,normal,lighting_factor);\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\ncolor.rgb=mix(color.rgb,image_color.rgb,image_color.a);color.a=1.0;\n#endif\n#endif\n#else\ncolor=image_color;\n#endif\n#ifdef FOG\n#ifdef ZERO_EXAGGERATION\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#else\ncolor=fog_dither(fog_apply_from_vert(color,v_fog_opacity));\n#endif\n#endif\nglFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_skirt_height;in vec2 a_pos;out vec2 v_pos0;\n#ifdef FOG\nout float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1;out float v_depth;\n#endif\nvoid main() {vec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;vec2 decodedPos=decomposedPosAndSkirt.xy;float elevation=elevation(decodedPos)-skirt*u_skirt_height;v_pos0=decodedPos/8192.0;gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);\n#ifdef FOG\n#ifdef ZERO_EXAGGERATION\nv_fog_pos=fog_position(decodedPos);\n#else\nv_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));\n#endif\n#endif\n#ifdef RENDER_SHADOWS\nvec3 pos=vec3(decodedPos,elevation);v_pos_light_view_0=u_light_matrix_0*vec4(pos,1.);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1.);\n#endif\n}'),terrainDepth:Do("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:Do('#include "_prelude_fog.fragment.glsl"\nin lowp vec3 v_uv;uniform lowp samplerCube u_cubemap;uniform lowp float u_opacity;uniform highp float u_temporal_offset;uniform highp vec3 u_sun_direction;float sun_disk(highp vec3 ray_direction,highp vec3 sun_direction) {highp float cos_angle=dot(normalize(ray_direction),sun_direction);const highp float cos_sun_angular_diameter=0.99996192306;const highp float smoothstep_delta=1e-5;return smoothstep(\ncos_sun_angular_diameter-smoothstep_delta,cos_sun_angular_diameter+smoothstep_delta,cos_angle);}float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec3 uv=v_uv;const float y_bias=0.015;uv.y+=y_bias;uv.y=pow(abs(uv.y),1.0/5.0);uv.y=map(uv.y,0.0,1.0,-1.0,1.0);vec3 sky_color=texture(u_cubemap,uv).rgb;\n#ifdef FOG\nsky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color);\n#endif\nsky_color.rgb=dither(sky_color.rgb,gl_FragCoord.xy+u_temporal_offset);sky_color+=0.1*sun_disk(v_uv,u_sun_direction);glFragColor=vec4(sky_color*u_opacity,u_opacity);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}',_o),skyboxGradient:Do('#include "_prelude_fog.fragment.glsl"\nin highp vec3 v_uv;uniform lowp sampler2D u_color_ramp;uniform highp vec3 u_center_direction;uniform lowp float u_radius;uniform lowp float u_opacity;uniform highp float u_temporal_offset;void main() {float progress=acos(dot(normalize(v_uv),u_center_direction))/u_radius;vec4 color=texture(u_color_ramp,vec2(progress,0.5));\n#ifdef FOG\ncolor.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a;\n#endif\ncolor*=u_opacity;color.rgb=dither(color.rgb,gl_FragCoord.xy+u_temporal_offset);glFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}',_o),skyboxCapture:Do("\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:Do('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image0;uniform float u_far_z_cutoff;in vec2 v_pos0;\n#ifndef FOG\nuniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform vec2 u_viewport;\n#endif\nvoid main() {vec4 color;\n#ifdef CUSTOM_ANTIALIASING\nvec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);vec3 dir=normalize(ray_dir);vec3 closest_point=dot(u_globe_pos,dir)*dir;float norm_dist_from_center=1.0-length(closest_point-u_globe_pos)/u_globe_radius;const float antialias_pixel=2.0;float antialias_factor=antialias_pixel*fwidth(norm_dist_from_center);float antialias=smoothstep(0.0,antialias_factor,norm_dist_from_center);vec4 raster=texture(u_image0,v_pos0);\n#ifdef LIGHTING_3D_MODE\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nraster=apply_lighting_with_emission_ground(raster,raster.a);color=vec4(raster.rgb*antialias,antialias);\n#else\nraster=apply_lighting_ground(raster);color=vec4(raster.rgb*antialias,raster.a*antialias);\n#endif\n#else\ncolor=vec4(raster.rgb*antialias,raster.a*antialias);\n#endif\n#else\ncolor=texture(u_image0,v_pos0);\n#ifdef LIGHTING_3D_MODE\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\ncolor=apply_lighting_with_emission_ground(color,color.a);color.a=1.0;\n#else\ncolor=apply_lighting_ground(color);\n#endif\n#endif\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ncolor*=1.0-step(u_far_z_cutoff,1.0/gl_FragCoord.w);glFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_proj_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;uniform mat3 u_grid_matrix;uniform float u_skirt_height;\n#ifdef GLOBE_POLES\nin vec3 a_globe_pos;in vec2 a_uv;\n#else\nin vec2 a_pos;\n#endif\nout vec2 v_pos0;void main() {\n#ifdef GLOBE_POLES\nvec3 globe_pos=a_globe_pos;vec2 uv=a_uv;\n#else\nfloat tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=mercatorY*tiles-idy;float mercatorX=mercatorXfromLng(latLng[1]);float uvX=mercatorX*tiles-idx;vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);vec2 uv=vec2(uvX,uvY);\n#endif\nv_pos0=uv;vec2 tile_pos=uv*EXTENT;vec3 globe_derived_up_vector=normalize(globe_pos)*u_tile_up_scale;\n#ifdef GLOBE_POLES\nvec3 up_vector=globe_derived_up_vector;\n#else\nvec3 up_vector=elevationVector(tile_pos);\n#endif\nfloat height=elevation(tile_pos);globe_pos+=up_vector*height;\n#ifndef GLOBE_POLES\nglobe_pos-=globe_derived_up_vector*u_skirt_height*decomposed_pos_and_skirt.z;\n#endif\n#ifdef GLOBE_POLES\nvec4 interpolated_pos=u_globe_matrix*vec4(globe_pos,1.0);\n#else\nvec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {merc_world_pos=vec4(merc_pos,height-u_skirt_height*decomposed_pos_and_skirt.z,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0);\n#endif\ngl_Position=u_proj_matrix*interpolated_pos;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n}'),globeAtmosphere:Do('#include "_prelude_fog.fragment.glsl"\nuniform float u_transition;uniform highp float u_fadeout_range;uniform highp float u_temporal_offset;uniform vec4 u_color;uniform vec4 u_high_color;uniform vec4 u_space_color;uniform float u_horizon_angle;in highp vec3 v_ray_dir;in highp vec3 v_horizon_dir;void main() {highp vec3 dir=normalize(v_ray_dir);float globe_pos_dot_dir;\n#ifdef PROJECTION_GLOBE_VIEW\nglobe_pos_dot_dir=dot(u_globe_pos,dir);highp vec3 closest_point_forward=abs(globe_pos_dot_dir)*dir;float norm_dist_from_center=length(closest_point_forward-u_globe_pos)/u_globe_radius;if (norm_dist_from_center < 0.98) {\n#ifdef ALPHA_PASS\nglFragColor=vec4(0,0,0,0);return;\n#else\n#ifdef NATIVE\nglFragColor=vec4(1,1,1,1);\n#else\nglFragColor=vec4(0,0,0,1);\n#endif\nreturn;\n#endif\n}\n#endif\nhighp vec3 horizon_dir=normalize(v_horizon_dir);float horizon_angle_mercator=dir.y < horizon_dir.y ?\n0.0 : max(acos(clamp(dot(dir,horizon_dir),-1.0,1.0)),0.0);float horizon_angle;\n#ifdef PROJECTION_GLOBE_VIEW\nhighp vec3 closest_point=globe_pos_dot_dir*dir;highp float closest_point_to_center=length(closest_point-u_globe_pos);highp float theta=asin(clamp(closest_point_to_center/length(u_globe_pos),-1.0,1.0));horizon_angle=globe_pos_dot_dir < 0.0 ?\nPI-theta-u_horizon_angle : theta-u_horizon_angle;float angle_t=pow(u_transition,10.0);horizon_angle=mix(horizon_angle,horizon_angle_mercator,angle_t);\n#else\nhorizon_angle=horizon_angle_mercator;\n#endif\nhorizon_angle/=PI;float t=exp(-horizon_angle/u_fadeout_range);float alpha_0=u_color.a;float alpha_1=u_high_color.a;float alpha_2=u_space_color.a;vec3 color_stop_0=u_color.rgb;vec3 color_stop_1=u_high_color.rgb;vec3 color_stop_2=u_space_color.rgb;\n#ifdef ALPHA_PASS\nfloat a0=mix(alpha_2,1.0,alpha_1);float a1=mix(a0,1.0,alpha_0);float a2=mix(a0,a1,t);float a =mix(alpha_2,a2,t);glFragColor=vec4(1.0,1.0,1.0,a);\n#else\nvec3 c0=mix(color_stop_2,color_stop_1,alpha_1);vec3 c1=mix(c0,color_stop_0,alpha_0);vec3 c2=mix(c0,c1,t);vec3 c=c2;\n#ifndef NATIVE\nc=dither(c,gl_FragCoord.xy+u_temporal_offset);\n#endif\nglFragColor=vec4(c*t,t);\n#endif\n}',"in vec3 a_pos;in vec2 a_uv;uniform vec3 u_frustum_tl;uniform vec3 u_frustum_tr;uniform vec3 u_frustum_br;uniform vec3 u_frustum_bl;uniform float u_horizon;out highp vec3 v_ray_dir;out highp vec3 v_horizon_dir;void main() {v_ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,a_uv.x),mix(u_frustum_bl,u_frustum_br,a_uv.x),a_uv.y);v_horizon_dir=mix(\nmix(u_frustum_tl,u_frustum_bl,u_horizon),mix(u_frustum_tr,u_frustum_br,u_horizon),a_uv.x);gl_Position=vec4(a_pos,1.0);}"),model:Do('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform float u_opacity;uniform vec3 u_lightcolor;uniform vec3 u_lightpos;uniform float u_lightintensity;uniform vec4 u_baseColorFactor;uniform vec4 u_emissiveFactor;uniform float u_metallicFactor;uniform float u_roughnessFactor;uniform float u_emissive_strength;in highp vec4 v_position_height;in lowp vec4 v_color_mix;\n#ifdef RENDER_SHADOWS\nin highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in float v_depth_shadows;\n#endif\n#ifdef OCCLUSION_TEXTURE_TRANSFORM\nuniform vec4 u_occlusionTextureTransform;\n#endif\n#pragma mapbox: define-attribute highp vec3 normal_3f\n#pragma mapbox: define-attribute highp vec3 color_3f\n#pragma mapbox: define-attribute highp vec4 color_4f\n#pragma mapbox: define-attribute highp vec2 uv_2f\n#pragma mapbox: initialize-attribute highp vec3 normal_3f\n#pragma mapbox: initialize-attribute highp vec3 color_3f\n#pragma mapbox: initialize-attribute highp vec4 color_4f\n#pragma mapbox: initialize-attribute highp vec2 uv_2f\n#ifdef HAS_ATTRIBUTE_a_pbr\nin lowp vec4 v_roughness_metallic_emissive_alpha;in mediump vec4 v_height_based_emission_params;\n#endif\n#ifdef HAS_TEXTURE_u_baseColorTexture\nuniform sampler2D u_baseColorTexture;uniform bool u_baseTextureIsAlpha;uniform bool u_alphaMask;uniform float u_alphaCutoff;\n#endif\n#ifdef HAS_TEXTURE_u_metallicRoughnessTexture\nuniform sampler2D u_metallicRoughnessTexture;\n#endif\n#ifdef HAS_TEXTURE_u_occlusionTexture\nuniform sampler2D u_occlusionTexture;uniform float u_aoIntensity;\n#endif\n#ifdef HAS_TEXTURE_u_normalTexture\nuniform sampler2D u_normalTexture;\n#endif\n#ifdef HAS_TEXTURE_u_emissionTexture\nuniform sampler2D u_emissionTexture;\n#endif\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nin highp float v_depth;uniform highp sampler2D u_depthTexture;uniform highp vec2 u_inv_depth_size;uniform highp vec2 u_depth_range_unpack;\n#ifdef DEPTH_D24\nhighp float unpack_depth(highp float depth) {return depth*u_depth_range_unpack.x+u_depth_range_unpack.y;}\n#else\nhighp float unpack_depth_rgba(highp vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}\n#endif\nbool isOccluded() {highp vec2 coord=gl_FragCoord.xy*u_inv_depth_size;\n#ifdef DEPTH_D24\nhighp float depth=unpack_depth(texture(u_depthTexture,coord).r);\n#else\nhighp float depth=unpack_depth_rgba(texture(u_depthTexture,coord));\n#endif\nreturn v_depth > depth+0.0005;}\n#endif\n#define saturate(_x) clamp(_x,0.,1.)\nvec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}float calculate_NdotL(vec3 normal,vec3 lightDir) {const float ext=0.70710678118;return (clamp(dot(normal,lightDir),-ext,1.0)+ext)/(1.0+ext);}vec3 getDiffuseShadedColor(vec3 albedo,vec3 normal,vec3 lightDir,vec3 lightColor)\n{\n#ifdef LIGHTING_3D_MODE\nvec3 transformed_normal=vec3(-normal.xy,normal.z);float lighting_factor;\n#ifdef RENDER_SHADOWS\nlighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);\n#else\nlighting_factor=saturate(dot(transformed_normal,u_lighting_directional_dir));\n#endif\nreturn apply_lighting(albedo,transformed_normal,lighting_factor);\n#else\nvec3 n=normal;float colorvalue=((albedo.x*0.2126)+(albedo.y*0.7152))+(albedo.z*0.0722);vec3 c=vec3(0.03,0.03,0.03);float directional=clamp(dot(n,vec3(lightDir)),0.0,1.0);directional=mix(1.0-u_lightintensity,max((1.0-colorvalue)+u_lightintensity,1.0),directional);vec3 c3=c+clamp((albedo*directional)*lightColor,mix(vec3(0.0),vec3(0.3),vec3(1.0)-lightColor),vec3(1.0));return c3;\n#endif\n}vec4 getBaseColor() {vec4 albedo=u_baseColorFactor;\n#ifdef HAS_ATTRIBUTE_a_color_3f\nalbedo*=vec4(color_3f,1.0);\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\n#else\n#ifdef HAS_ATTRIBUTE_a_color_4f\nalbedo*=color_4f;\n#endif\n#endif\n#if defined (HAS_TEXTURE_u_baseColorTexture) && defined (HAS_ATTRIBUTE_a_uv_2f)\nvec4 texColor=texture(u_baseColorTexture,uv_2f);if(u_alphaMask) {if (texColor.w < u_alphaCutoff) {discard;}}\n#ifdef UNPREMULT_TEXTURE_IN_SHADER\nif(texColor.w > 0.0) {texColor.rgb/=texColor.w;}texColor.w=1.0;\n#endif\nif(u_baseTextureIsAlpha) {if (texColor.r < 0.5) {discard;}} else {texColor.rgb=sRGBToLinear(texColor.rgb);albedo*=texColor;}\n#endif\nvec4 color=vec4(mix(albedo.rgb,v_color_mix.rgb,v_color_mix.a),albedo.a);\n#ifdef APPLY_LUT_ON_GPU\ncolor=applyLUT(u_lutTexture,color);\n#endif\nreturn color;}highp mat3 cotangentFrame(highp vec3 N,highp vec3 p,highp vec2 uv ) {\n#ifdef HAS_TEXTURE_u_normalTexture\nhighp vec3 dp1=vec3(dFdx(p.x),dFdx(p.y),dFdx(p.z));highp vec3 dp2=vec3(dFdy(p.x),dFdy(p.y),dFdy(p.z));highp vec2 duv1=vec2(dFdx(uv.x),dFdx(uv.y));highp vec2 duv2=vec2(dFdy(uv.x),dFdy(uv.y));highp vec3 dp2perp=cross( dp2,N );highp vec3 dp1perp=cross( N,dp1 );highp vec3 T=dp2perp*duv1.x+dp1perp*duv2.x;highp vec3 B=dp2perp*duv1.y+dp1perp*duv2.y;highp float lengthT=dot(T,T);highp float lengthB=dot(B,B);highp float maxLength=max(lengthT,lengthB);highp float invmax=inversesqrt( maxLength );highp mat3 res=mat3( T*invmax,B*invmax,N );return res;\n#else\nreturn mat3(1.0);\n#endif\n}highp vec3 getNormal(){highp vec3 n;\n#ifdef HAS_ATTRIBUTE_a_normal_3f\nn=normalize(normal_3f);\n#else\nhighp vec3 fdx=vec3(dFdx(v_position_height.x),dFdx(v_position_height.y),dFdx(v_position_height.z));highp vec3 fdy=vec3(dFdy(v_position_height.x),dFdy(v_position_height.y),dFdy(v_position_height.z));n=normalize(cross(fdx,fdy))*-1.0;\n#endif\n#if defined(HAS_TEXTURE_u_normalTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\nvec3 nMap=texture( u_normalTexture,uv_2f).xyz;nMap=normalize(2.0*nMap-vec3(1.0));highp vec3 v=normalize(-v_position_height.xyz);highp mat3 TBN=cotangentFrame(n,v,uv_2f);n=normalize(TBN*nMap);\n#endif\nreturn n;}struct Material {float perceptualRoughness;float alphaRoughness;float metallic;vec3 f90;vec4 baseColor;vec3 diffuseColor;vec3 specularColor;highp vec3 normal;};Material getPBRMaterial() {Material mat;mat.baseColor=getBaseColor();mat.perceptualRoughness=u_roughnessFactor;mat.metallic=u_metallicFactor;\n#ifdef HAS_ATTRIBUTE_a_pbr\nmat.perceptualRoughness=v_roughness_metallic_emissive_alpha.x;mat.metallic=v_roughness_metallic_emissive_alpha.y;mat.baseColor.w*=v_roughness_metallic_emissive_alpha.w;\n#endif\n#if defined(HAS_TEXTURE_u_metallicRoughnessTexture) && defined(HAS_ATTRIBUTE_a_uv_2f) \nvec4 mrSample=texture(u_metallicRoughnessTexture,uv_2f);mat.perceptualRoughness*=mrSample.g;mat.metallic*=mrSample.b;\n#endif\nconst float c_minRoughness=0.04;mat.perceptualRoughness=clamp(mat.perceptualRoughness,c_minRoughness,1.0);mat.metallic=saturate(mat.metallic);mat.alphaRoughness=mat.perceptualRoughness*mat.perceptualRoughness;const vec3 f0=vec3(0.04);mat.diffuseColor=mat.baseColor.rgb*(vec3(1.0)-f0);mat.diffuseColor*=1.0-mat.metallic;mat.specularColor=mix(f0,mat.baseColor.rgb,mat.metallic);highp float reflectance=max(max(mat.specularColor.r,mat.specularColor.g),mat.specularColor.b);highp float reflectance90=saturate(reflectance*25.0);mat.f90=vec3(reflectance90);mat.normal=getNormal();return mat;}float V_GGX(float NdotL,float NdotV,float roughness)\n{float a2=roughness*roughness;float GGXV=NdotL*sqrt(NdotV*NdotV*(1.0-a2)+a2);float GGXL=NdotV*sqrt(NdotL*NdotL*(1.0-a2)+a2);return 0.5/(GGXV+GGXL);}float V_GGXFast(float NdotL,float NdotV,float roughness) {float a=roughness;float GGXV=NdotL*(NdotV*(1.0-a)+a);float GGXL=NdotV*(NdotL*(1.0-a)+a);return 0.5/(GGXV+GGXL);}vec3 F_Schlick(vec3 specularColor,vec3 f90,float VdotH)\n{return specularColor+(f90-specularColor)*pow(clamp(1.0-VdotH,0.0,1.0),5.0);}vec3 F_SchlickFast(vec3 specularColor,float VdotH)\n{float x=1.0-VdotH;float x4=x*x*x*x;return specularColor+(1.0-specularColor)*x4*x;}float D_GGX(highp float NdotH,float alphaRoughness)\n{highp float a4=alphaRoughness*alphaRoughness;highp float f=(NdotH*a4-NdotH)*NdotH+1.0;return a4/(PI*f*f);}vec3 diffuseBurley(Material mat,float LdotH,float NdotL,float NdotV)\n{float f90=2.0*LdotH*LdotH*mat.alphaRoughness-0.5;return (mat.diffuseColor/PI)*(1.0+f90*pow((1.0-NdotL),5.0))*(1.0+f90*pow((1.0-NdotV),5.0));}vec3 diffuseLambertian(Material mat)\n{\n#ifdef LIGHTING_3D_MODE\nreturn mat.diffuseColor;\n#else\nreturn mat.diffuseColor/PI;\n#endif\n}vec3 EnvBRDFApprox(vec3 specularColor,float roughness,highp float NdotV)\n{vec4 c0=vec4(-1,-0.0275,-0.572,0.022);vec4 c1=vec4(1,0.0425,1.04,-0.04);highp vec4 r=roughness*c0+c1;highp float a004=min(r.x*r.x,exp2(-9.28*NdotV))*r.x+r.y;vec2 AB=vec2(-1.04,1.04)*a004+r.zw;return specularColor*AB.x+AB.y;}vec3 computeIndirectLightContribution(Material mat,float NdotV,vec3 normal)\n{vec3 env_light=vec3(0.65,0.65,0.65);\n#ifdef LIGHTING_3D_MODE\nfloat ambient_factor=calculate_ambient_directional_factor(normal);env_light=u_lighting_ambient_color*ambient_factor;\n#endif\nvec3 envBRDF=EnvBRDFApprox(mat.specularColor,mat.perceptualRoughness,NdotV);vec3 indirectSpecular= envBRDF*env_light;vec3 indirectDiffuse=mat.diffuseColor*env_light;return indirectSpecular+indirectDiffuse;}vec3 computeLightContribution(Material mat,vec3 lightPosition,vec3 lightColor)\n{highp vec3 n=mat.normal;highp vec3 v=normalize(-v_position_height.xyz);highp vec3 l=normalize(lightPosition);highp vec3 h=normalize(v+l);float NdotV=clamp(abs(dot(n,v)),0.001,1.0);float NdotL=saturate(dot(n,l));highp float NdotH=saturate(dot(n,h));float VdotH=saturate(dot(v,h));vec3 f=F_SchlickFast(mat.specularColor,VdotH);float g=V_GGXFast(NdotL,NdotV,mat.alphaRoughness);float d=D_GGX(NdotH,mat.alphaRoughness);vec3 diffuseTerm=(1.0-f)*diffuseLambertian(mat);vec3 specularTerm=f*g*d;vec3 transformed_normal=vec3(-n.xy,n.z);float lighting_factor;\n#ifdef RENDER_SHADOWS\nlighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);\n#else\nlighting_factor=NdotL;\n#endif\nvec3 directLightColor=(specularTerm+diffuseTerm)*lighting_factor*lightColor;vec3 indirectLightColor=computeIndirectLightContribution(mat,NdotV,transformed_normal);vec3 color=(saturate(directLightColor)+indirectLightColor);float intensityFactor=1.0;\n#if !defined(LIGHTING_3D_MODE)\nconst vec3 luminosityFactor=vec3(0.2126,0.7152,0.0722);float luminance=dot(diffuseTerm,luminosityFactor);intensityFactor=mix((1.0-u_lightintensity),max((1.0-luminance+u_lightintensity),1.0),NdotL);\n#endif\ncolor*=intensityFactor;return color;}void main() {\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nif (isOccluded()) {discard;}\n#endif\nvec3 lightDir=u_lightpos;vec3 lightColor=u_lightcolor;\n#ifdef LIGHTING_3D_MODE\nlightDir=u_lighting_directional_dir;lightDir.xy=-lightDir.xy;lightColor=u_lighting_directional_color;\n#endif\nvec4 finalColor;\n#ifdef DIFFUSE_SHADED\nvec3 N=getNormal();vec3 baseColor=getBaseColor().rgb;vec3 diffuse=getDiffuseShadedColor(baseColor,N,lightDir,lightColor);\n#ifdef HAS_TEXTURE_u_occlusionTexture\nfloat ao=(texture(u_occlusionTexture,uv_2f).r-1.0)*u_aoIntensity+1.0;diffuse*=ao;\n#endif\nfinalColor=vec4(mix(diffuse,baseColor,u_emissive_strength),1.0)*u_opacity;\n#else\nMaterial mat=getPBRMaterial();vec3 color=computeLightContribution(mat,lightDir,lightColor);float ao=1.0;\n#if defined (HAS_TEXTURE_u_occlusionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\n#ifdef OCCLUSION_TEXTURE_TRANSFORM\nvec2 uv=uv_2f.xy*u_occlusionTextureTransform.zw+u_occlusionTextureTransform.xy;\n#else\nvec2 uv=uv_2f;\n#endif\nao=(texture(u_occlusionTexture,uv).x-1.0)*u_aoIntensity+1.0;color*=ao;\n#endif\nvec4 emissive=u_emissiveFactor;\n#if defined(HAS_TEXTURE_u_emissionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\nemissive.rgb*=sRGBToLinear(texture(u_emissionTexture,uv_2f).rgb);\n#endif\n#ifdef APPLY_LUT_ON_GPU\nfloat emissiveFactorLength=max(length(u_emissiveFactor.rgb),0.001);emissive.rgb=sRGBToLinear(applyLUT(u_lutTexture,linearTosRGB(emissive.rgb/emissiveFactorLength).rbg))*emissiveFactorLength;\n#endif\ncolor+=emissive.rgb;float opacity=mat.baseColor.w*u_opacity;\n#ifdef HAS_ATTRIBUTE_a_pbr\nfloat resEmission=v_roughness_metallic_emissive_alpha.z;resEmission*=v_height_based_emission_params.z+v_height_based_emission_params.w*pow(clamp(v_height_based_emission_params.x,0.0,1.0),v_height_based_emission_params.y);vec3 color_mix=v_color_mix.rgb;\n#ifdef APPLY_LUT_ON_GPU\ncolor_mix=applyLUT(u_lutTexture,color_mix);\n#endif\ncolor=mix(color,color_mix,min(1.0,resEmission));\n#ifdef HAS_ATTRIBUTE_a_color_4f\nfloat distance=length(vec2(1.3*max(0.0,abs(color_4f.x)-color_4f.z),color_4f.y));distance+= mix(0.5,0.0,clamp(resEmission-1.0,0.0,1.0));opacity*=v_roughness_metallic_emissive_alpha.w*saturate(1.0-distance*distance);\n#endif\n#endif\nvec3 unlitColor=mat.baseColor.rgb*ao+emissive.rgb;color=mix(color,unlitColor,u_emissive_strength);color=linearTosRGB(color);color*=opacity;finalColor=vec4(color,opacity);\n#endif\n#ifdef FOG\nfinalColor=fog_dither(fog_apply_premultiplied(finalColor,v_fog_pos,v_position_height.w));\n#endif\n#ifdef RENDER_CUTOFF\nfinalColor*=v_cutoff_opacity;\n#endif\n#ifdef INDICATOR_CUTOUT\nfinalColor=applyCutout(finalColor);\n#endif\nglFragColor=finalColor;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin vec3 a_pos_3f;\n#pragma mapbox: define-attribute highp vec3 normal_3f\n#pragma mapbox: define-attribute highp vec2 uv_2f\n#pragma mapbox: define-attribute highp vec3 color_3f\n#pragma mapbox: define-attribute highp vec4 color_4f\n#pragma mapbox: define-attribute-vertex-shader-only highp vec4 pbr\n#pragma mapbox: define-attribute-vertex-shader-only highp vec3 heightBasedEmissiveStrength\nuniform mat4 u_matrix;uniform mat4 u_node_matrix;uniform mat4 u_lighting_matrix;uniform vec3 u_camera_pos;uniform vec4 u_color_mix;\n#ifdef INSTANCED_ARRAYS\nin vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3;\n#else\nuniform highp mat4 u_normal_matrix;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out float v_depth_shadows;\n#endif\nout vec4 v_position_height;out lowp vec4 v_color_mix;\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nout highp float v_depth;\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\nout lowp vec4 v_roughness_metallic_emissive_alpha;out mediump vec4 v_height_based_emission_params;\n#endif\nvec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() {\n#pragma mapbox: initialize-attribute highp vec3 normal_3f\n#pragma mapbox: initialize-attribute highp vec2 uv_2f\n#pragma mapbox: initialize-attribute highp vec3 color_3f\n#pragma mapbox: initialize-attribute highp vec4 color_4f\n#pragma mapbox: initialize-attribute-custom highp vec4 pbr\n#pragma mapbox: initialize-attribute-custom highp vec3 heightBasedEmissiveStrength\nhighp mat4 normal_matrix;\n#ifdef INSTANCED_ARRAYS\nnormal_matrix=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3);\n#else\nnormal_matrix=u_normal_matrix;\n#endif\nvec3 local_pos;mat3 rs;\n#ifdef MODEL_POSITION_ON_GPU\nvec3 pos_color=normal_matrix[0].xyz;vec4 translate=normal_matrix[1];vec3 pos_a=floor(pos_color);vec3 rgb=1.05*(pos_color-pos_a);float hidden=float(pos_a.x > EXTENT);float color_mix=pos_a.z/100.0;v_color_mix=vec4(sRGBToLinear(rgb),color_mix);float meter_to_tile=normal_matrix[0].w;vec4 pos=vec4(pos_a.xy,translate.z,1.0);rs[0].x=normal_matrix[1].w;rs[0].yz=normal_matrix[2].xy;rs[1].xy=normal_matrix[2].zw;rs[1].z=normal_matrix[3].x;rs[2].xyz=normal_matrix[3].yzw;vec4 pos_node=u_lighting_matrix*vec4(a_pos_3f,1.0);vec3 rotated_pos_node=rs*pos_node.xyz;vec3 pos_model_tile=(rotated_pos_node+vec3(translate.xy,0.0))*vec3(meter_to_tile,meter_to_tile,1.0);pos.xyz+=pos_model_tile;local_pos=pos.xyz;gl_Position=mix(u_matrix*pos,AWAY,hidden);pos.z*=meter_to_tile;v_position_height.xyz=pos.xyz-u_camera_pos;\n#else\nlocal_pos=a_pos_3f;gl_Position=u_matrix*vec4(a_pos_3f,1);v_position_height.xyz=vec3(u_lighting_matrix*vec4(a_pos_3f,1));v_color_mix=vec4(sRGBToLinear(u_color_mix.rgb),u_color_mix.a);\n#endif\nv_position_height.w=a_pos_3f.z;\n#ifdef HAS_ATTRIBUTE_a_pbr\nvec4 albedo_c=decode_color(pbr.xy);vec2 e_r_m=unpack_float(pbr.z);vec2 r_m= unpack_float(e_r_m.y*16.0);r_m.r=r_m.r*16.0;v_color_mix=vec4(albedo_c.rgb,1.0);v_roughness_metallic_emissive_alpha=vec4(vec3(r_m,e_r_m.x)/255.0,albedo_c.a);v_roughness_metallic_emissive_alpha.z*=2.0;float heightBasedRelativeIntepolation=a_pos_3f.z*heightBasedEmissiveStrength.x+heightBasedEmissiveStrength.y;v_height_based_emission_params.x=heightBasedRelativeIntepolation;v_height_based_emission_params.y=heightBasedEmissiveStrength.z;vec2 emissionMultiplierValues=unpack_float(pbr.w)/256.0;v_height_based_emission_params.z=emissionMultiplierValues.x;v_height_based_emission_params.w=emissionMultiplierValues.y-emissionMultiplierValues.x;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(local_pos);\n#endif\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef HAS_ATTRIBUTE_a_normal_3f\n#ifdef MODEL_POSITION_ON_GPU\nfloat x_squared_scale=dot(rs[0],rs[0]);float y_squared_scale=dot(rs[1],rs[1]);float z_squared_scale=dot(rs[2],rs[2]);vec3 squared_scale=vec3(x_squared_scale,y_squared_scale,z_squared_scale);normal_3f=rs*((u_lighting_matrix*vec4(normal_3f,0.0)).xyz/squared_scale);normal_3f=normalize(normal_3f);\n#else\nnormal_3f=vec3(normal_matrix*vec4(normal_3f,0));\n#endif\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\n#ifdef HAS_ATTRIBUTE_a_color_4f\nv_roughness_metallic_emissive_alpha.w=clamp(color_4f.a*v_roughness_metallic_emissive_alpha.w*(v_roughness_metallic_emissive_alpha.z-1.0),0.0,1.0);\n#endif\n#endif\n#ifdef RENDER_SHADOWS\nvec4 shadow_pos=u_node_matrix*vec4(local_pos,1.0);\n#ifdef NORMAL_OFFSET\n#ifdef HAS_ATTRIBUTE_a_normal_3f\n#ifdef MODEL_POSITION_ON_GPU\nvec3 offset=shadow_normal_offset(vec3(-normal_3f.xy,normal_3f.z));shadow_pos.xyz+=offset*shadow_normal_offset_multiplier0();\n#else\nvec3 offset=shadow_normal_offset_model(normal_3f);shadow_pos.xyz+=offset*shadow_normal_offset_multiplier0();\n#endif\n#endif\n#endif\nv_pos_light_view_0=u_light_matrix_0*shadow_pos;v_pos_light_view_1=u_light_matrix_1*shadow_pos;v_depth_shadows=gl_Position.w;\n#endif\n}'),modelDepth:Do("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:Do("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:Do("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:Do("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;}"),occlusion:Do("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 Io(e,t){const i=e.replace(/\s*\/\/[^\n]*\n/g,"\n").split("\n");for(let e of i)if(e=e.trim(),"#"===e[0]&&e.includes("if")&&!e.includes("endif")){e=e.replace("#","").replace(/ifdef|ifndef|elif|if/g,"").replace(/!|defined|\(|\)|\|\||&&/g,"").replace(/\s+/g," ").trim();const i=e.split(" ");for(const e of i)t.includes(e)||t.push(e);}}function Do(e,t){const i=/#include\s+"([^"]+)"/g,o=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g;let s=t.match(/(attribute(\S*)|(^\s*|;)in) (highp |mediump |lowp )?([\w]+) ([\w]+)/gm);s&&(s=s.map((e=>{const t=e.split(" ");return t[t.length-1]})),s=[...new Set(s)]);const r={},a=[],n=[];if(e=e.replace(i,((e,t)=>(n.push(t),""))),(t=t.replace(i,((e,t)=>(a.push(t),"")))).includes("flat out"))return void console.error('The usage of "flat" qualifier is disallowed, see: https://bugs.webkit.org/show_bug.cgi?id=268071');let l=[...bo];Io(e,l),Io(t,l);for(const e of [...a,...n])wo[e]||console.error(`Undefined include: ${e}`),To[e]||(To[e]=[],Io(wo[e],To[e])),l=[...l,...To[e]];return {fragmentSource:e=e.replace(o,((e,t,i,o,s)=>(r[s]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${s}\nin ${i} ${o} ${s};\n#else\nuniform ${i} ${o} u_${s};\n#endif\n`:"initialize"===t?`\n#ifdef HAS_UNIFORM_u_${s}\n ${i} ${o} ${s} = u_${s};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${s}\n in ${i} ${o} ${s};\n#endif\n`:"initialize-attribute"===t?"":void 0))),vertexSource:t=t.replace(o,((e,t,i,o,s)=>{const a="float"===o?"vec2":o,n=s.match(/color/)?"color":a;return "define-attribute-vertex-shader-only"===t?`\n#ifdef HAS_ATTRIBUTE_a_${s}\nin ${i} ${o} a_${s};\n#endif\n`:r[s]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${s}\nuniform lowp float u_${s}_t;\nin ${i} ${a} a_${s};\nout ${i} ${o} ${s};\n#else\nuniform ${i} ${o} u_${s};\n#endif\n`:"initialize"===t?"vec4"===n?`\n#ifndef HAS_UNIFORM_u_${s}\n ${s} = a_${s};\n#else\n ${i} ${o} ${s} = u_${s};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${s}\n ${s} = unpack_mix_${n}(a_${s}, u_${s}_t);\n#else\n ${i} ${o} ${s} = u_${s};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${s}\n in ${i} ${o} a_${s};\n out ${i} ${o} ${s};\n#endif\n`:"initialize-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${s}\n ${s} = a_${s};\n#endif\n`:void 0:"define"===t?`\n#ifndef HAS_UNIFORM_u_${s}\nuniform lowp float u_${s}_t;\nin ${i} ${a} a_${s};\n#else\nuniform ${i} ${o} u_${s};\n#endif\n`:"define-instanced"===t?"mat4"===n?`\n#ifdef INSTANCED_ARRAYS\nin vec4 a_${s}0;\nin vec4 a_${s}1;\nin vec4 a_${s}2;\nin vec4 a_${s}3;\n#else\nuniform ${i} ${o} u_${s};\n#endif\n`:`\n#ifdef INSTANCED_ARRAYS\nin ${i} ${a} a_${s};\n#else\nuniform ${i} ${o} u_${s};\n#endif\n`:"initialize-attribute-custom"===t?`\n#ifdef HAS_ATTRIBUTE_a_${s}\n ${i} ${o} ${s} = a_${s};\n#endif\n`:"vec4"===n?`\n#ifndef HAS_UNIFORM_u_${s}\n ${i} ${o} ${s} = a_${s};\n#else\n ${i} ${o} ${s} = u_${s};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${s}\n ${i} ${o} ${s} = unpack_mix_${n}(a_${s}, u_${s}_t);\n#else\n ${i} ${o} ${s} = u_${s};\n#endif\n`})),staticAttributes:s,usedDefines:l,vertexIncludes:a,fragmentIncludes:n}}class Ro{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,a,n){this.context=e;let l=this.boundPaintVertexBuffers.length!==o.length;for(let e=0;!l&&e<o.length;e++)this.boundPaintVertexBuffers[e]!==o[e]&&(l=!0);let c=this.boundDynamicVertexBuffers.length!==a.length;for(let e=0;!c&&e<a.length;e++)this.boundDynamicVertexBuffers[e]!==a[e]&&(c=!0);if(!this.vao||this.boundProgram!==t||this.boundLayoutVertexBuffer!==i||l||c||this.boundIndexBuffer!==s||this.boundVertexOffset!==r)this.freshBind(t,i,o,s,r,a,n);else {e.bindVertexArrayOES.set(this.vao);for(const i of a)i&&(i.bind(),n&&i.instanceCount&&i.setVertexAttribDivisor(e.gl,t,n));s&&s.dynamicDraw&&s.bind();}}freshBind(e,t,i,o,s,r,a){const n=e.numAttributes,l=this.context,c=l.gl;this.vao&&this.destroy(),this.vao=l.gl.createVertexArray(),l.bindVertexArrayOES.set(this.vao),this.boundProgram=e,this.boundLayoutVertexBuffer=t,this.boundPaintVertexBuffers=i,this.boundIndexBuffer=o,this.boundVertexOffset=s,this.boundDynamicVertexBuffers=r,t.enableAttributes(c,e),t.bind(),t.setVertexAttribPointers(c,e,s);for(const t of i)t.enableAttributes(c,e),t.bind(),t.setVertexAttribPointers(c,e,s);for(const t of r)t&&(t.enableAttributes(c,e),t.bind(),t.setVertexAttribPointers(c,e,s),a&&t.instanceCount&&t.setVertexAttribDivisor(c,e,a));o&&o.bind(),l.currentNumAttributes=n;}destroy(){this.vao&&(this.context.gl.deleteVertexArray(this.vao),this.vao=null);}}function Ao(t,i){const o=Math.pow(2,i.canonical.z),s=i.canonical.y;return [new e.a5(0,s/o).toLngLat().lat,new e.a5(0,(s+1)/o).toLngLat().lat]}function Lo(t,i,o,s,r,a,n){const l=t.context,c=l.gl,h=o.hillshadeFBO;if(!h)return;t.prepareDrawTile();const u=t.isTileAffectedByFog(i),d=t.getOrCreateProgram("hillshade",{overrideFog:u});l.activeTexture.set(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,h.colorAttachment.get());const _=((t,i,o,s)=>{const r=o.paint.get("hillshade-shadow-color"),a=o.paint.get("hillshade-highlight-color"),n=o.paint.get("hillshade-accent-color"),l=o.paint.get("hillshade-emissive-strength");let c=e.bC(o.paint.get("hillshade-illumination-direction"));if("viewport"===o.paint.get("hillshade-illumination-anchor"))c-=t.transform.angle;else if(t.style&&t.style.enable3dLights()&&t.style.directionalLight){const i=t.style.directionalLight.properties.get("direction"),o=e.c8(i.x,i.y,i.z);c=e.bC(o[1]);}const h=!t.options.moving;return {u_matrix:s||t.transform.calculateProjMatrix(i.tileID.toUnwrapped(),h),u_image:0,u_latrange:Ao(0,i.tileID),u_light:[o.paint.get("hillshade-exaggeration"),c],u_shadow:r.toRenderColor(o.lut),u_highlight:a.toRenderColor(o.lut),u_emissive_strength:l,u_accent:n.toRenderColor(o.lut)}})(t,o,s,t.terrain?i.projMatrix:null);t.uploadCommonUniforms(l,d,i.toUnwrapped());const{tileBoundsBuffer:p,tileBoundsIndexBuffer:f,tileBoundsSegments:m}=t.getTileBoundsBuffers(o);d.draw(t,c.TRIANGLES,r,a,n,Oi.disabled,_,s.id,p,f,m);}function Po(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 a=o.getPixels();i.demTexture?i.demTexture.update(a,{premultiply:!1}):i.demTexture=new e.T(s,a,r.R32F,{premultiply:!1}),i.needsDEMTextureUpload=!1;}function Mo(t,i,o){const s=t.context,r=s.gl;if(!i.dem)return;const a=i.dem;if(s.activeTexture.set(r.TEXTURE1),Po(t,i,a),!i.demTexture)return;i.demTexture.bind(r.NEAREST,r.CLAMP_TO_EDGE);const n=a.dim;s.activeTexture.set(r.TEXTURE0);let l=i.hillshadeFBO;if(!l){const t=new e.T(s,{width:n,height:n,data:null},r.RGBA8);t.bind(r.LINEAR,r.CLAMP_TO_EDGE),l=i.hillshadeFBO=s.createFramebuffer(n,n,!0,"renderbuffer"),l.colorAttachment.set(t.texture);}s.bindFramebuffer.set(l.framebuffer),s.viewport.set([0,0,n,n]);const{tileBoundsBuffer:c,tileBoundsIndexBuffer:h,tileBoundsSegments:u}=t.getMercatorTileBoundsBuffers(),d=[];t.linearFloatFilteringSupported()&&d.push("TERRAIN_DEM_FLOAT_FORMAT"),t.getOrCreateProgram("hillshadePrepare",{defines:d}).draw(t,r.TRIANGLES,Ai.disabled,Pi.disabled,Ri.unblended,Oi.disabled,((t,i)=>{const o=i.stride,s=e.a6.mat4.create();return e.a6.mat4.ortho(s,0,e.ab,-e.ab,0,0,1),e.a6.mat4.translate(s,s,[0,-e.ab,0]),{u_matrix:s,u_image:1,u_dimension:[o,o],u_zoom:t.overscaledZ}})(i.tileID,a),o.id,c,h,u),i.needsHillshadePrepare=!1;}class zo{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 Oo extends zo{getDefault(){return e.bA.transparent}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.clearColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1);}}class Fo extends zo{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1);}}class Bo extends zo{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1);}}class ko extends zo{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 No extends zo{getDefault(){return !0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1);}}class Uo extends zo{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1);}}class Go extends zo{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 Vo extends zo{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 jo extends zo{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 Ho extends zo{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 Zo extends zo{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 qo extends zo{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1);}}class Wo extends zo{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 $o extends zo{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 Xo extends zo{getDefault(){return e.bA.transparent}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.blendColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1);}}class Jo extends zo{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 Ko extends zo{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 Yo extends zo{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1);}}class Qo extends zo{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1);}}let es=class extends zo{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1);}};class ts extends zo{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1);}}class is extends zo{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 os extends zo{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 ss extends zo{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 rs extends zo{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 as extends zo{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 ns extends zo{getDefault(){return null}set(e){const t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1;}}class ls extends zo{getDefault(){return null}set(e){this.gl&&(e!==this.current||this.dirty)&&(this.gl.bindVertexArray(e),this.current=e,this.dirty=!1);}}class cs extends zo{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 hs extends zo{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 zo{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 ds extends zo{constructor(e,t){super(e),this.context=e,this.parent=t;}getDefault(){return null}}class _s extends ds{setDirty(){this.dirty=!0;}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1;}}class ps extends ds{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 fs extends ds{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 ms extends ps{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}const gs=(e,t,i)=>({u_matrix:e,u_image0:0,u_skirt_height:t,u_ground_shadow_factor:i}),vs=(e,t,i,o,s,r,a,n,l,c,h,u,d,_,p,f)=>({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_frustum_tl:a,u_frustum_tr:n,u_frustum_br:l,u_frustum_bl:c,u_globe_pos:h,u_globe_radius:u,u_viewport:d,u_grid_matrix:f?Float32Array.from(f):new Float32Array(9),u_skirt_height:_,u_far_z_cutoff:p});function xs(e,t){return null!=e&&null!=t&&!(!e.hasData()||!t.hasData())&&null!=e.demTexture&&null!=t.demTexture&&e.tileID.key!==t.tileID.key}const ys=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()}},bs={0:null,1:"TERRAIN_VERTEX_MORPHING"};function ws(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 Ts(e,t){const i=1<<e.z;return !t&&(0===e.x||e.x===i-1)||0===e.y||e.y===i-1}const Es=e=>({u_matrix:e});function Ss(t,i,o,s,r){if(r>0){const a=e.q.now(),n=(a-t.timeAdded)/r,l=i?(a-i.timeAdded)/r:-1,c=o.getSource(),h=s.coveringZoomLevel({tileSize:c.tileSize,roundZoom:c.roundZoom}),u=!i||Math.abs(i.tileID.overscaledZ-h)>Math.abs(t.tileID.overscaledZ-h),d=u&&t.refreshedUponExpiration?1:e.ap(u?n:1-l,0,1);return t.refreshedUponExpiration&&n>=1&&(t.refreshedUponExpiration=!1),i?{opacity:1,mix:1-d}:{opacity:d,mix:0}}return {opacity:1,mix:0}}class Cs extends gt{constructor(t){const i={type:"raster-dem",maxzoom:t.transform.maxZoom},o=new e.ce(e.cf(),null),s=Qe("mock-dem",i,o,t.style);super("mock-dem",s,!1),s.setEventedParent(this),this._sourceLoaded=!0;}_loadTile(e,t){e.state="loaded",t(null);}}class Is extends gt{constructor(t){const i=Qe("proxy",{type:"geojson",maxzoom:t.transform.maxZoom},new e.ce(e.cf(),null),t.style);super("proxy",i,!1),i.setEventedParent(this),this.map=this.getSource().map=t,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 _t(i,this._source.tileSize*i.overscaleFactor(),e.tileZoom);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 Ds extends e.aA{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 Rs extends e.cE{constructor(t,i){super(),this._debugParams={sortTilesHiZFirst:!0,disableRenderCache:!1},t.tp.registerParameter(this._debugParams,["Terrain"],"sortTilesHiZFirst",{},(()=>{this._style.map.triggerRepaint();})),t.tp.registerParameter(this._debugParams,["Terrain"],"disableRenderCache",{},(()=>{this._style.map.triggerRepaint();})),t.tp.registerButton(["Terrain"],"Invalidate Render Cache",(()=>{this.invalidateRenderCache=!0,this._style.map.triggerRepaint();})),this.painter=t,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[o,s,r]=function(t){const i=new e.a$,o=new e.aP,s=131;i.reserve(17161),o.reserve(33800);const r=e.ab/128,a=e.ab+r/2,n=a+r;for(let t=-r;t<n;t+=r)for(let o=-r;o<n;o+=r){const s=o<0||o>a||t<0||t>a?24575:0,r=e.ap(Math.round(o),0,e.ab),n=e.ap(Math.round(t),0,e.ab);i.emplaceBack(r+s,n);}const l=(e,t)=>{const i=t*s+e;o.emplaceBack(i+1,i,i+s),o.emplaceBack(i+s,i+s+1,i+1);};for(let e=1;e<129;e++)for(let t=1;t<129;t++)l(t,e);return [0,129].forEach((e=>{for(let t=0;t<130;t++)l(t,e),l(e,t);})),[i,o,32768]}(),a=t.context;this.gridBuffer=a.createVertexBuffer(o,e.b1.members),this.gridIndexBuffer=a.createIndexBuffer(s),this.gridSegments=e.b2.simpleSegment(0,0,o.length,s.length),this.gridNoSkirtSegments=e.b2.simpleSegment(0,0,o.length,r),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new Is(i.map),this.orthoMatrix=e.a6.mat4.create(),e.a6.mat4.ortho(this.orthoMatrix,"globe"===this.painter.transform.projection.name?.015:0,e.ab,0,e.ab,0,1);const n=a.gl;this._overlapStencilMode=new Pi({func:n.GEQUAL,mask:255},0,255,n.KEEP,n.KEEP,n.REPLACE),this._previousZoom=t.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=i,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new Cs(i.map),this._pendingGroundEffectLayers=[];}set style(e){e.on("data",this._onStyleDataEvent.bind(this)),this._style=e,this._style.map.on("moveend",(()=>{this._clearLineLayersFromRenderCache();}));}update(t,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,a=t.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=e.q.now();const n=t.terrain&&t.terrain.scope,l=s.get("source"),c=r?this._mockSourceCache:t.getSourceCache(l,n);if(!c)return void e.w(`Couldn't find terrain source "${l}".`);if(this.sourceCache=c,this._attenuationRange=t.terrain.getAttenuationRange(),this._exaggeration=a?this.calculateExaggeration(i):s.get("exaggeration"),!i.projection.requiresDraping&&a&&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,a=this._style.terrain;if(!this._previousUpdateTimestamp)return a.getExaggeration(r);let n=r-this._previousZoom;const l=this._previousUpdateTimestamp;let c=r;null!=this._evaluationZoom&&(c=this._evaluationZoom,Math.abs(r-c)>.5&&(n=.5*(r-c+n)),n*s<0&&(c+=n)),this._evaluationZoom=c;const h=a.getExaggeration(c),u=h===a.getExaggeration(Math.max(0,c-.1));if(u&&Math.abs(h-this._exaggeration)<.01)return h;let d=Math.min(.1,.00375*(this._updateTimestamp-l));return (u||h<.1||Math.abs(n)<1e-4)&&(d=Math.min(.2,4*d)),e.aa(this._exaggeration,h,d)}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){e.coord&&"source"===e.dataType?this._clearRenderCacheForTile(e.sourceCacheId,e.coord):"style"===e.dataType&&(this.invalidateRenderCache=!0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this._previousCameraAltitude=void 0);}_disable(){if(this.enabled&&(this.enabled=!1,this._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.a5.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<<t.canonical.z)*t.wrap,t.canonical.y),r=new e.P(i.canonical.x+(1<<i.canonical.z)*i.wrap,i.canonical.y),a=s.mult(1<<t.canonical.z);return a.x-=.5,a.y-=.5,a.distSqr(o)-a.distSqr(r)}));}(s,this.painter);const r=this.proxyToSource||{};this.proxyToSource={},s.forEach((e=>{this.proxyToSource[e.key]={};})),this.terrainTileForTile={};const a=this._style._mergedSourceCaches;for(const e in a){const i=a[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&&this._assignTerrainTiles(o);}this.proxiedCoords[i.id]=s.map((e=>new Ds(e,e.key,this.orthoMatrix))),this._assignTerrainTiles(s),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(r),this.renderingToTexture=!1;const n={};this._visibleDemTiles=[];for(const e of this.proxyCoords){const t=this.terrainTileForTile[e.key];if(!t)continue;const i=t.tileID.key;i in n||(this._visibleDemTiles.push(t),n[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),Po(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),a=o||"";return i[`u_dem_tl${a}`]=[s.x*r%1,s.y*r%1],i[`u_dem_scale${a}`]=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.cF({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,a={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};a.u_exaggeration=this.exaggeration();let n=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,a,"_prev")&&(l=e),this._prepareDemTileUniforms(t,i,a)&&(n=i));}const h=e=>e&&e.demTexture&&this.painter.linearFloatFilteringSupported()?r.LINEAR:r.NEAREST;let u=null;var d;if(this.enabled?l&&n?(u=n.demTexture,s.activeTexture.set(r.TEXTURE4),l.demTexture.bind(h(l),r.CLAMP_TO_EDGE),a.u_dem_lerp=c):(n=this.terrainTileForTile[t.tileID.key],u=this._prepareDemTileUniforms(t,n,a)?n.demTexture:this.emptyDEMTexture):u=this.emptyDEMTexture,s.activeTexture.set(r.TEXTURE2),u&&(a.u_dem_size=1===(d=u).size[0]?1:d.size[0]-2,u.bind(h(n),r.CLAMP_TO_EDGE)),this.painter.setupDepthForOcclusion(o&&o.useDepthForOcclusion,i,a),o&&o.useMeterToDem&&n){const t=(1<<n.tileID.canonical.z)*e.bE(1,this.painter.transform.center.lat)*this.sourceCache.getSource().tileSize;a.u_meter_to_dem=t;}if(o&&o.labelPlaneMatrixInv&&(a.u_label_plane_matrix_inv=o.labelPlaneMatrixInv),i.setTerrainUniformValues(s,a),"globe"===this.painter.transform.projection.name){const e=this.globeUniformValues(this.painter.transform,t.tileID.canonical,o&&o.useDenormalizedUpVectorScale);i.setGlobeUniformValues(s,e);}}globeUniformValues(t,i,o){const s=t.projection;return {u_tile_tl_up:s.upVector(i,0,0),u_tile_tr_up:s.upVector(i,e.ab,0),u_tile_br_up:s.upVector(i,e.ab,e.ab),u_tile_bl_up:s.upVector(i,0,e.ab),u_tile_up_scale:o?e.cG(1):s.upVectorScale(i,t.center.lat,t.worldSize).metersToTile}}renderToBackBuffer(t){const i=this.painter,o=this.painter.context;0!==t.length&&(o.bindFramebuffer.set(null),o.viewport.set([0,0,i.width,i.height]),i.gpuTimingDeferredRenderStart(),this.renderingToTexture=!1,function(t,i,o,s,r){if("globe"===t.transform.projection.name)!function(t,i,o,s,r){const a=t.context,n=a.gl;let l,c;const h=t.transform,u=e.cx(t,a,h),d=(e,i)=>{if(c===i)return;const o=[bs[i],"PROJECTION_GLOBE_VIEW"];u&&o.push("CUSTOM_ANTIALIASING");const s=t.isTileAffectedByFog(e);l=t.getOrCreateProgram("globeRaster",{defines:o,overrideFog:s}),c=i;},_=t.colorModeForRenderPass(),p=new Ai(n.LEQUAL,Ai.ReadWrite,t.depthRangeFor3D);ys.update(r);const f=e.cy(h),m=[e.am(h.center.lng),e.at(h.center.lat)],g=t.globeSharedBuffers,v=[h.width*e.q.devicePixelRatio,h.height*e.q.devicePixelRatio],x=Float32Array.from(h.globeMatrix),y={useDenormalizedUpVectorScale:!0};{const h=t.transform,u=ws(h.zoom,i.exaggeration(),i.sourceCache._source.tileSize);c=-1;const b=n.TRIANGLES;for(const c of s){const s=o.getTile(c),w=Pi.disabled,T=i.prevTerrainTileForTile[c.key],E=i.terrainTileForTile[c.key];xs(T,E)&&ys.newMorphing(c.key,T,E,r,250),a.activeTexture.set(n.TEXTURE0),s.texture&&s.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE);const S=ys.getMorphValuesForProxy(c.key),C=S?1:0;S&&e.C(y,{morphing:{srcDemTile:S.from,dstDemTile:S.to,phase:e.cw(S.phase)}});const I=e.cz(c.canonical),D=e.cA(I.getCenter().lat),R=e.cB(c.canonical,I,D,h.worldSize/h._pixelsPerMercatorPixel),A=e.b6(e.cC(c.canonical)),L=vs(h.expandedFarZProjMatrix,x,f,A,e.a9(h.zoom),m,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,v,u,h._farZ,R);if(d(c,C),l&&(i.setupElevationDraw(s,l,y),t.uploadCommonUniforms(a,l,c.toUnwrapped()),g)){const[e,i,o]=g.getGridBuffers(D,0!==u);l.draw(t,b,p,w,_,Oi.backCCW,L,"globe_raster",e,i,o);}}}if(g&&(t.renderDefaultNorthPole||t.renderDefaultSouthPole)){const r=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];u&&r.push("CUSTOM_ANTIALIASING"),l=t.getOrCreateProgram("globeRaster",{defines:r});for(const r of s){const{x:s,y:c,z:u}=r.canonical,d=0===c,f=c===(1<<u)-1,[x,b,w,T]=g.getPoleBuffers(u,!1);if(T&&(d||f)){const c=o.getTile(r);a.activeTexture.set(n.TEXTURE0),c.texture&&c.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE);let g=e.cD(u,s,h);const E=e.b6(e.cC(r.canonical)),S=(e,i)=>e.draw(t,n.TRIANGLES,p,Pi.disabled,_,Oi.disabled,vs(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),"globe_pole_raster",i,w,T);i.setupElevationDraw(c,l,y),t.uploadCommonUniforms(a,l,r.toUnwrapped()),d&&t.renderDefaultNorthPole&&S(l,x),f&&t.renderDefaultSouthPole&&(g=e.a6.mat4.scale(e.a6.mat4.create(),g,[1,-1,1]),S(l,b));}}}}(t,i,o,s,r);else {const a=t.context,n=a.gl;let l,c;const h=t.shadowRenderer,u=qi(t,t.longestCutoffRange),d=e=>{if(c===e)return;const i=[];i.push(bs[e]),u.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 Ai(n.LEQUAL,Ai.ReadWrite,t.depthRangeFor3D);ys.update(r);const f=t.transform,m=ws(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=Qi(t.style,e,i));}{c=-1;const v=n.TRIANGLES,[x,y]=[i.gridIndexBuffer,i.gridSegments];for(const c of s){const s=o.getTile(c),b=Pi.disabled,w=i.prevTerrainTileForTile[c.key],T=i.terrainTileForTile[c.key];xs(w,T)&&ys.newMorphing(c.key,w,T,r,250),a.activeTexture.set(n.TEXTURE0),s.texture&&s.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE);const E=ys.getMorphValuesForProxy(c.key),S=E?1:0;let C;E&&(C={morphing:{srcDemTile:E.from,dstDemTile:E.to,phase:e.cw(E.phase)}});const I=gs(c.projMatrix,Ts(c.canonical,f.renderWorldCopies)?m/10:m,g);if(d(S),!l)continue;i.setupElevationDraw(s,l,C);const D=c.toUnwrapped();h&&h.setupShadows(D,l),t.uploadCommonUniforms(a,l,D,null,u),l.draw(t,v,p,b,_,Oi.backCCW,I,"terrain_raster",i.gridBuffer,x,y);}}}}(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],a=this._drapedRenderBatches.shift(),n=i.style.order,l=[];let c=0;for(const h of r){const r=s.getTileByID(h.proxyTileKey),u=s.proxyCachedFBO[h.key]?s.proxyCachedFBO[h.key][t]:void 0,d=void 0!==u?s.renderCache[u]:this.pool[c++],_=void 0!==u;if(r.texture=d.tex,_&&!d.dirty){l.push(r.tileID);continue}let p;o.bindFramebuffer.set(d.fb.framebuffer),this.renderedToTile=!1,d.dirty&&(o.clear({color:e.bA.transparent,stencil:0}),d.dirty=!1);for(let e=a.start;e<=a.end;++e){const t=i.style._mergedLayers[n[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 a=r;o.viewport.set([0,0,d.fb.width,d.fb.height]),p!==(s?s.id:null)&&(this._setupStencil(d,r,t,s),p=s?s.id:null),i.renderLayer(i,s,t,a);}if(0===this._drapedRenderBatches.length)for(const e of this._pendingGroundEffectLayers){const t=i.style._mergedLayers[n[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 a=r;o.viewport.set([0,0,d.fb.width,d.fb.height]),p!==(s?s.id:null)&&(this._setupStencil(d,r,t,s),p=s?s.id:null),i.renderLayer(i,s,t,a);}this.renderedToTile?(d.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]),a.end+1}postRender(){}isLayerOrderingCorrect(e){const t=e.order.length;let i=-1,o=t;for(let s=0;s<t;++s)this._style.isLayerDraped(e._mergedLayers[e.order[s]])?i=Math.max(i,s):o=Math.min(o,s);return o>i}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<<s.overscaledZ,{x:a,y:n}=s.canonical,l=a/r,c=(a+1)/r,h=n/r,u=(n+1)/r;return {minx:l,miny:h,maxx:c,maxy:u,t:o.dem.tree.raycastRoot(l,h,c,u,e,t,i),tile:o}}));o.sort(((e,t)=>(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],!0,null);return r.colorAttachment.set(s.texture),r.depthAttachment=new ms(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,dirty:!1}}_initFBOPool(){for(;this.pool.length<Math.min(5,this.proxyCoords.length);)this.pool.push(this._createFBO());}_shouldDisableRenderCache(){if(this._debugParams.disableRenderCache)return !0;if(this._style.hasLightTransitions())return !0;for(const e in this._style._mergedSourceCaches)if(this._style._mergedSourceCaches[e].hasTransition())return !0;return this._style.order.some((e=>{const t=this._style._mergedLayers[e],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 Xe){t=!0;break}if(!t)return;const i={};for(let t=0;t<this._style.order.length;++t){const o=this._style._mergedLayers[this._style.order[t]],s=this._style.getLayerSourceCache(o);if(s&&!i[s.id]&&!o.isHidden(this.painter.transform.zoom)&&"line"===o.type&&o.widthExpression()instanceof e.a4){i[s.id]=!0;for(const e of this.proxyCoords){const t=this.proxyToSource[e.key][s.id];if(t)for(const e of t)this._clearRenderCacheForTile(s.id,e);}}}}_clearRasterLayersFromRenderCache(){let e=!1;for(const t in this._style._mergedSourceCaches)if(this._style._mergedSourceCaches[t]._source instanceof Je){e=!0;break}if(!e)return;const t={};for(let e=0;e<this._style.order.length;++e){const i=this._style._mergedLayers[this._style.order[e]],o=this._style.getLayerSourceCache(i);if(!o||t[o.id])continue;if(i.isHidden(this.painter.transform.zoom)||"raster"!==i.type)continue;const s=i.paint.get("raster-fade-duration");for(const e of this.proxyCoords){const t=this.proxyToSource[e.key][o.id];if(t)for(const e of t){const t=Ss(o.getTile(e),o.findLoadedParent(e,0),o,this.painter.transform,s);(1!==t.opacity||0!==t.mix)&&this._clearRenderCacheForTile(o.id,e);}}}}_setupDrapedRenderBatches(){const t=this._style.order,i=t.length;if(0===i)return;const o=[];this._pendingGroundEffectLayers=[];let s,r=0,a=this._style._mergedLayers[t[r]];for(;!this._style.isLayerDraped(a)&&a.isHidden(this.painter.transform.zoom)&&++r<i;)a=this._style._mergedLayers[t[r]];for(;r<i;++r){const e=this._style._mergedLayers[t[r]];e.isHidden(this.painter.transform.zoom)||(this._style.isLayerDraped(e)?void 0===s&&(s=r):("fill-extrusion"===e.type&&this._pendingGroundEffectLayers.push(r),void 0!==s&&(o.push({start:s,end:r-1}),s=void 0)));}if(void 0!==s&&o.push({start:s,end:r-1}),0!==o.length){const t=o[o.length-1];this._pendingGroundEffectLayers.every((e=>e>t.end))||e.w("fill-extrusion with flood lighting and/or ground ambient occlusion should be moved to be on top of all draped layers.");}this._drapedRenderBatches=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<e.length;++i){const o=Object.values(e[i]);t.renderCachePool.push(...o);}}return}this._clearRasterLayersFromRenderCache();const i=this.proxyCoords,o=this._tilesDirty;for(let s=i.length-1;s>=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 a=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)))){a=-1;break}++a;}for(const e in t.proxyCachedFBO[r.key])t.renderCache[t.proxyCachedFBO[r.key][e]].dirty=a<0||a!==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 a;if(i.isTileClipped())a=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);a=1,this._overlapStencilMode.test={func:r.GREATER,mask:255},this._overlapStencilType="Mask";}this._stencilRef+a>255&&(s.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=a,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):Pi.disabled}_renderTileClippingMasks(e,t){const i=this.painter,o=this.painter.context,s=o.gl;i._tileClippingMaskIDs={},o.setColorMode(Ri.disabled),o.setDepthMode(Ai.disabled);const r=i.getOrCreateProgram("clippingMask");for(const o of e){const e=i._tileClippingMaskIDs[o.key]=--t;r.draw(i,s.TRIANGLES,Ai.disabled,new Pi({func:s.ALWAYS,mask:0},e,255,s.KEEP,s.KEEP,s.REPLACE),Ri.disabled,Oi.disabled,Es(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.a6.vec4.transformMat4(o,o,i.pixelMatrixInverse),e.a6.vec4.scale(o,o,1/o[3]),o[0]/=i.worldSize,o[1]/=i.worldSize;const s=i._camera.position,r=e.bE(1,i.center.lat),a=[s[0],s[1],s[2]/r,0],n=e.a6.vec3.subtract([],o.slice(0,3),a);e.a6.vec3.normalize(n,n);const l=this.raycast(a,n,this._exaggeration);return null!==l&&l?(e.a6.vec3.scaleAndAdd(a,a,n,l),a[3]=a[2],a[2]*=r,a):null}_setupProxiedCoordsForOrtho(t,i,o){if(t.getSource()instanceof e.aD)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;e<r.length;e++){const i=r[e],a=this._findTileCoveringTileID(i,t);if(a){const e=this._createProxiedId(i,a,o[i.key]&&o[i.key][t.id]);s.push(e),this.proxyToSource[i.key][t.id]=[e];}}let a=!1;const n=new Set;for(let e=0;e<i.length;e++){const r=t.getTile(i[e]);if(!r||!r.hasData())continue;const l=this._findTileCoveringTileID(r.tileID,this.proxySourceCache);if(l&&l.tileID.canonical.z!==r.tileID.canonical.z){const e=this.proxyToSource[l.tileID.key][t.id],i=this._createProxiedId(l.tileID,r,o[l.tileID.key]&&o[l.tileID.key][t.id]);e?e.splice(e.length-1,0,i):this.proxyToSource[l.tileID.key][t.id]=[i];const c=this.proxyToSource[l.tileID.key][t.id];n.has(c)||n.add(c),s.push(i),a=!0;}}if(this._sourceTilesOverlap[t.id]=a,a&&this._debugParams.sortTilesHiZFirst)for(const e of n)e.sort(((e,t)=>t.overscaledZ-e.overscaledZ));}_setupProxiedCoordsForImageSource(t,i,o){if(!t.getSource().loaded())return;const s=this.proxiedCoords[t.id]=[],r=this.proxyCoords,a=t.getSource(),n=a.tileID;if(!n)return;const l=new e.P(n.x,n.y)._div(1<<n.z),c=a.coordinates.map(e.a5.fromLngLat).reduce(((e,t)=>(e.min.x=Math.min(e.min.x,t.x-l.x),e.min.y=Math.min(e.min.y,t.y-l.y),e.max.x=Math.max(e.max.x,t.x-l.x),e.max.y=Math.max(e.max.y,t.y-l.y),e)),{min:new e.P(Number.MAX_VALUE,Number.MAX_VALUE),max:new e.P(-Number.MAX_VALUE,-Number.MAX_VALUE)}),h=(t,i)=>{const o=t.wrap+t.canonical.x/(1<<t.canonical.z),s=t.canonical.y/(1<<t.canonical.z),r=e.ab/(1<<t.canonical.z),a=i.wrap+i.canonical.x/(1<<i.canonical.z),n=i.canonical.y/(1<<i.canonical.z);return o+r<a+c.min.x||o>a+c.max.x||s+r<n+c.min.y||s>n+c.max.y};for(let e=0;e<r.length;e++){const a=r[e];for(let e=0;e<i.length;e++){const r=t.getTile(i[e]);if(!r||!r.hasData())continue;if(h(a,r.tileID))continue;const n=this._createProxiedId(a,r,o[a.key]&&o[a.key][t.id]),l=this.proxyToSource[a.key][t.id];l?l.push(n):this.proxyToSource[a.key][t.id]=[n],s.push(n);}}}_createProxiedId(t,i,o){let s=this.orthoMatrix;if(o){const e=o.find((e=>e.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,a,n;s=e.a6.mat4.create();const l=i.tileID.wrap-t.wrap<<t.overscaledZ;o>0?(r=e.ab>>o,a=r*((i.tileID.canonical.x<<o)-t.canonical.x+l),n=r*((i.tileID.canonical.y<<o)-t.canonical.y)):(r=e.ab<<-o,a=e.ab*(i.tileID.canonical.x-(t.canonical.x+l<<-o)),n=e.ab*(i.tileID.canonical.y-(t.canonical.y<<-o))),e.a6.mat4.ortho(s,0,r,0,r,0,1),e.a6.mat4.translate(s,s,[a,n,0]);}return new Ds(i.tileID,t.key,s)}_findTileCoveringTileID(t,i){let o=i.getTile(t);if(o&&o.hasData())return o;const s=this._findCoveringTileCache[i.id],r=s[t.key];if(o=r?i.getTileByID(r):null,o&&o.hasData()||null===r)return o;let a=o?o.tileID:t,n=a.overscaledZ;const l=i.getSource().minzoom,c=[];if(!r){const s=i.getSource().maxzoom;if(t.canonical.z>=s){const o=t.canonical.z-s;i.getSource().reparseOverscaled?(n=Math.max(t.canonical.z+2,i.transform.tileZoom),a=new e.aA(n,t.wrap,s,t.canonical.x>>o,t.canonical.y>>o)):0!==o&&(n=s,a=new e.aA(n,t.wrap,s,t.canonical.x>>o,t.canonical.y>>o));}a.key!==t.key&&(c.push(a.key),o=i.getTile(a));}const h=e=>{c.forEach((t=>{s[t]=e;})),c.length=0;};for(n-=1;n>=l&&(!o||!o.hasData());n--){o&&h(o.tileID.key);const e=a.calculateScaledKey(n);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 As(t,i,o){const s=function(t,i,o){const s=e.a6.vec3.dot(i,t),r=e.a6.vec3.dot(o,[.2126,.7152,.0722]),a=(e,t,i)=>(1-i)*e+i*t,n=a(1-.3*Math.min(r,1),1,Math.min(s+1,1));return a(.92,1,Math.asin(e.ap(i[2],-1,1))/Math.PI+.5)*n}(t,[0,0,1],i),r=[0,0,0];e.a6.vec3.scale(r,o.slice(0,3),s);const a=[0,0,0];e.a6.vec3.scale(a,i.slice(0,3),t[2]);const n=[0,0,0];return e.a6.vec3.add(n,r,a),e.cc(n)}const Ls=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],Ps=["stars","rain_particle","snow_particle","fillExtrusion","fillExtrusionGroundEffect","model","symbol"];class Ms{static cacheKey(e,t,i,o){let s=`${t}${o?o.cacheKey:""}`;for(const t of i)e.usedDefines.includes(t)&&(s+=`/${t}`);return s}constructor(t,i,o,s,r,a){const n=t.gl;this.program=n.createProgram(),this.configuration=s,this.name=i,this.fixedDefines=[...a];const l=s?s.getBinderAttributes():[],c=(o.staticAttributes||[]).concat(l);let h=s?s.defines():[];h=h.concat(a.map((e=>`#define ${e}`)));const u="#version 300 es\n";let d=u+h.concat("precision mediump float;",So,Eo.fragmentSource).join("\n");for(const e of o.fragmentIncludes)d+=`\n${wo[e]}`;d+=`\n${o.fragmentSource}`;let _=u+h.concat("precision highp float;",So,Eo.vertexSource).join("\n");for(const e of o.vertexIncludes)_+=`\n${wo[e]}`;_+=`\n${o.vertexSource}`;const p=n.createShader(n.FRAGMENT_SHADER);if(n.isContextLost())return void(this.failedToCreate=!0);n.shaderSource(p,d),n.compileShader(p),n.attachShader(this.program,p);const f=n.createShader(n.VERTEX_SHADER);if(n.isContextLost())this.failedToCreate=!0;else {n.shaderSource(f,_),n.compileShader(f),n.attachShader(this.program,f),this.attributes={},this.numAttributes=c.length;for(let e=0;e<this.numAttributes;e++)if(c[e]){const t=c[e].startsWith("a_")?c[e]:`a_${c[e]}`;n.bindAttribLocation(this.program,e,t),this.attributes[t]=e;}n.linkProgram(this.program),n.deleteShader(f),n.deleteShader(p),this.fixedUniforms=r(t),this.binderUniforms=s?s.getUniforms(t):[],(a.includes("TERRAIN")||-1!==i.indexOf("symbol")||-1!==i.indexOf("circle"))&&(this.terrainUniforms=(t=>({u_dem:new e.bK(t),u_dem_prev:new e.bK(t),u_dem_tl:new e.bH(t),u_dem_scale:new e.bJ(t),u_dem_tl_prev:new e.bH(t),u_dem_scale_prev:new e.bJ(t),u_dem_size:new e.bJ(t),u_dem_lerp:new e.bJ(t),u_exaggeration:new e.bJ(t),u_depth:new e.bK(t),u_depth_size_inv:new e.bH(t),u_depth_range_unpack:new e.bH(t),u_occluder_half_size:new e.bJ(t),u_occlusion_depth_offset:new e.bJ(t),u_meter_to_dem:new e.bJ(t),u_label_plane_matrix_inv:new e.bG(t)}))(t)),a.includes("GLOBE")&&(this.globeUniforms=(t=>({u_tile_tl_up:new e.bI(t),u_tile_tr_up:new e.bI(t),u_tile_br_up:new e.bI(t),u_tile_bl_up:new e.bI(t),u_tile_up_scale:new e.bJ(t)}))(t)),a.includes("FOG")&&(this.fogUniforms=(t=>({u_fog_matrix:new e.bG(t),u_fog_range:new e.bH(t),u_fog_color:new e.c7(t),u_fog_horizon_blend:new e.bJ(t),u_fog_vertical_limit:new e.bH(t),u_fog_temporal_offset:new e.bJ(t),u_frustum_tl:new e.bI(t),u_frustum_tr:new e.bI(t),u_frustum_br:new e.bI(t),u_frustum_bl:new e.bI(t),u_globe_pos:new e.bI(t),u_globe_radius:new e.bJ(t),u_globe_transition:new e.bJ(t),u_is_globe:new e.bK(t),u_viewport:new e.bH(t)}))(t)),a.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(t=>({u_cutoff_params:new e.c7(t)}))(t)),a.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(t=>({u_lighting_ambient_color:new e.bI(t),u_lighting_directional_dir:new e.bI(t),u_lighting_directional_color:new e.bI(t),u_ground_radiance:new e.bI(t)}))(t)),a.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(t=>({u_light_matrix_0:new e.bG(t),u_light_matrix_1:new e.bG(t),u_fade_range:new e.bH(t),u_shadow_normal_offset:new e.bI(t),u_shadow_intensity:new e.bJ(t),u_shadow_texel_size:new e.bJ(t),u_shadow_map_resolution:new e.bJ(t),u_shadow_direction:new e.bI(t),u_shadow_bias:new e.bI(t),u_shadowmap_0:new e.bK(t),u_shadowmap_1:new e.bK(t)}))(t));}}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,a,n,l,c,h){const u=t.options.wireframe;if(!1===u.terrain&&!1===u.layers2D&&!1===u.layers3D)return;const d=t.context;if(!(()=>!(!u.terrain||"terrainRaster"!==this.name&&"globeRaster"!==this.name)||!(!u.layers2D||t._terrain&&t._terrain.renderingToTexture||!Ls.includes(this.name))||!(!u.layers3D||!Ps.includes(this.name)))())return;const _=d.gl,p=t.wireframeDebugCache.getLinesFromTrianglesBuffer(t.frameCounter,r,d);if(!p)return;const f=[...this.fixedDefines];f.push("DEBUG_WIREFRAME");const m=t.getOrCreateProgram(this.name,{config:this.configuration,defines:f});d.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,d,m.binderUniforms,n,{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(),d.setColorMode(new Ri([_.ONE,_.ONE_MINUS_SRC_ALPHA,_.ZERO,_.ONE],e.bA.transparent,[!0,!0,!0,!1])),d.setDepthMode(new Ai(i.func===_.LESS?_.LEQUAL:i.func,Ai.ReadOnly,i.range)),d.setStencilMode(Pi.disabled);const v=3*a.primitiveLength*2,x=3*a.primitiveOffset*2*2;h&&h>1?_.drawElementsInstanced(_.LINES,v,_.UNSIGNED_SHORT,x,h):_.drawElements(_.LINES,v,_.UNSIGNED_SHORT,x),r.bind(),d.program.set(this.program),d.setDepthMode(i),d.setStencilMode(o),d.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,a,n,l,c,h,u,d,_,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 of Object.keys(this.fixedUniforms))this.fixedUniforms[e].set(this.program,e,a[e]);_&&_.setUniforms(this.program,m,this.binderUniforms,u,{zoom:d});const v={[g.POINTS]:1,[g.LINES]:2,[g.TRIANGLES]:3,[g.LINE_STRIP]:1}[t];this.checkUniforms(n,"RENDER_SHADOWS",this.shadowUniforms);const x=f&&f>0?1:void 0;for(const r of h.get()){const a=r.vaos||(r.vaos={});(a[n]||(a[n]=new Ro)).bind(m,this,l,_?_.getPaintVertexBuffers():[],c,r.vertexOffset,p||[],x),f&&f>1?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),t===g.TRIANGLES&&c&&this._drawDebugWireframe(e,i,o,s,c,r,u,d,_,f);}}}function zs(t,i){const o=Math.pow(2,i.tileID.overscaledZ),s=i.tileSize*Math.pow(2,t.transform.tileZoom)/o,r=s*(i.tileID.canonical.x+i.tileID.wrap*o),a=s*i.tileID.canonical.y;return {u_image:0,u_texsize:i.imageAtlasTexture?i.imageAtlasTexture.size:[0,0],u_tile_units_to_pixels:1/e.ak(i,1,t.transform.tileZoom),u_pixel_coord_upper:[r>>16,a>>16],u_pixel_coord_lower:[65535&r,65535&a]}}const Os={terrain:0,flat:1},Fs=e.a6.mat4.create(),Bs=(t,i,o,s,r,a,n,l,c,h,u,d,_,p,f,m,g,v)=>{const x=i.style.light,y=x.properties.get("position"),b=[y.x,y.y,y.z],w=e.a6.mat3.create();"viewport"===x.properties.get("anchor")&&(e.a6.mat3.fromRotation(w,-i.transform.angle),e.a6.vec3.transformMat3(b,b,w));const T=x.properties.get("color"),E=i.transform,S={u_matrix:t,u_lightpos:b,u_lightintensity:x.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:Fs,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_height_type:Os[h],u_base_type:Os[u],u_ao:r,u_edge_radius:a,u_width_scale:n,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<<l.canonical.z],S.u_zoom_transition=d,S.u_inv_rot_matrix=p,S.u_merc_center=_,S.u_up_dir=E.projection.upVector(new e.bQ(0,0,0),_[0]*e.ab,_[1]*e.ab),S.u_height_lift=c),S},ks=(e,t,i,o,s,r)=>({u_matrix:e,u_edge_radius:t,u_width_scale:i,u_vertical_scale:o,u_height_type:Os[s],u_base_type:Os[r]}),Ns=(t,i,o,s,r,a,n,l,c,h,u,d,_,p,f,m,g)=>{const v=Bs(t,i,o,s,r,a,n,l,h,u,d,_,p,f,m,g,1,[0,0,0]),x={u_height_factor:-Math.pow(2,l.overscaledZ)/c.tileSize/8};return e.l(v,zs(i,c),x)},Us=(e,t)=>({u_matrix:e,u_emissive_strength:t}),Gs=(t,i,o,s)=>e.l(Us(t,i),zs(o,s)),Vs=(e,t,i)=>({u_matrix:e,u_world:i,u_emissive_strength:t}),js=(t,i,o,s,r)=>e.l(Gs(t,i,o,s),{u_world:r}),Hs=(t,i,o,s)=>{const r=e.ab/o.tileSize;return {u_matrix:t,u_camera_to_center_distance:i.getCameraToCenterDistance(s),u_extrude_scale:[i.pixelsToGLUnits[0]/r,i.pixelsToGLUnits[1]/r]}},Zs=(e,t,i=1)=>({u_matrix:e,u_color:t.toRenderColor(null),u_overlay:0,u_overlay_scale:i}),qs=e.a6.mat4.create(),Ws=(t,i,o,s,r,a,n)=>{const l=t.transform,c="globe"===l.projection.name,h=c?e.cI(l.zoom,i.canonical)*l._pixelsPerMercatorPixel:e.ak(o,1,a),u={u_matrix:i.projMatrix,u_extrude_scale:h,u_intensity:n,u_inv_rot_matrix:qs,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(c){u.u_inv_rot_matrix=s,u.u_merc_center=r,u.u_tile_id=[i.canonical.x,i.canonical.y,1<<i.canonical.z],u.u_zoom_transition=e.a9(l.zoom);const t=r[0]*e.ab,o=r[1]*e.ab;u.u_up_dir=l.projection.upVector(new e.bQ(0,0,0),t,o);}return u};function $s(e,[t,i,o,s],[r,a]){if(r===a)return [0,0,0,0];const n=255*(e-1)/(e*(a-r));return [t*n,i*n,o*n,s*n]}function Xs(e,t,[i,o]){return i===o?0:.5/e+(t-i)*(e-1)/(e*(o-i))}const Js=(t,i,o,s,r,a,n,l,c,h,u,d,_,p,f,m,g,v,x,y,b)=>({u_matrix:t,u_normalize_matrix:i,u_globe_matrix:o,u_merc_matrix:s,u_grid_matrix:r,u_tl_parent:a,u_scale_parent:h,u_fade_t:u.mix,u_opacity:u.opacity*d.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:d.paint.get("raster-brightness-min"),u_brightness_high:d.paint.get("raster-brightness-max"),u_saturation_factor:e.cJ(d.paint.get("raster-saturation")),u_contrast_factor:e.cK(d.paint.get("raster-contrast")),u_spin_weights:Ks(d.paint.get("raster-hue-rotate")),u_perspective_transform:_,u_raster_elevation:p,u_zoom_transition:n,u_merc_center:l,u_cutoff_params:c,u_colorization_mix:$s(e.cL,m,v),u_colorization_offset:Xs(e.cL,g,v),u_color_ramp:f,u_texture_offset:[y/(x+2*y),x/(x+2*y)],u_texture_res:[x+2*y,x+2*y],u_emissive_strength:b});function Ks(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 Ys=.05,Qs=(e,t,i,o,s,r,a,n,l,c,h,u)=>({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:u,u_zoom_transition:a,u_merc_center:n,u_cutoff_params:l}),er=(e,t,i,o,s,r,a,n,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:a,u_uv_offset:n,u_data_scale:[255*l[0],255*l[1]],u_data_offset:c,u_particle_pos_scale:1.1,u_particle_pos_offset:[Ys,Ys]}),tr=(e,t,i,o,s,r,a,n,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:a,u_rand_seed:Math.random(),u_uv_offset:n,u_data_scale:[255*l[0],255*l[1]],u_data_offset:c,u_particle_pos_scale:1.1,u_particle_pos_offset:[Ys,Ys]}),ir=e.a6.mat4.create(),or=(t,i,o,s,r,a,n,l,c,h,u,d,_,p,f,m,g,v,x,y,b,w)=>{const T=r.transform,E={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:T.getCameraToCenterDistance(x),u_rotate_symbol:+o,u_aspect_ratio:T.width/T.height,u_fade_change:r.options.fadeDuration?r.symbolFadeChange:1,u_matrix:a,u_label_plane_matrix:n,u_coord_matrix:l,u_is_text:+h,u_elevation_from_sea:c?1:0,u_pitch_with_map:+s,u_texsize:u,u_texsize_icon:d,u_texture:0,u_texture_icon:1,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:ir,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:ir,u_up_vector:[0,-1,0],u_color_adj_mat:y,u_icon_transition:b||0,u_gamma_scale:s?r.transform.getCameraToCenterDistance(x)*Math.cos(r.terrain?0:r.transform._pitch):1,u_device_pixel_ratio:e.q.devicePixelRatio,u_is_halo:+_,u_scale_factor:w||1};return "globe"===x.name&&(E.u_tile_id=[p.canonical.x,p.canonical.y,1<<p.canonical.z],E.u_zoom_transition=f,E.u_inv_rot_matrix=g,E.u_merc_center=m,E.u_camera_forward=T._camera.forward(),E.u_ecef_origin=e.cM(T.globeMatrix,p.toUnwrapped()),E.u_tile_matrix=Float32Array.from(T.globeMatrix),E.u_up_vector=v),E},sr=(e,t,i,o)=>({u_matrix:e,u_emissive_strength:t,u_opacity:i,u_color:o}),rr=(t,i,o,s,r,a,n,l,c)=>e.l(function(t,i,o,s,r,a){const{width:n,height:l}=s.imageManager.getPixelSize(i),c=Math.pow(2,a.tileID.overscaledZ),h=a.tileSize*Math.pow(2,s.transform.tileZoom)/c,u=h*(a.tileID.canonical.x+a.tileID.wrap*c),d=h*a.tileID.canonical.y;return {u_image:0,u_pattern_tl:o.tl,u_pattern_br:o.br,u_texsize:[n,l],u_pattern_size:o.displaySize,u_pattern_units_to_pixels:r?[s.transform.width,-1*s.transform.height]:[1/e.ak(a,1,s.transform.tileZoom),1/e.ak(a,1,s.transform.tileZoom)],u_pixel_coord_upper:[u>>16,d>>16],u_pixel_coord_lower:[65535&u,65535&d]}}(0,a,n,s,l,c),{u_matrix:t,u_emissive_strength:i,u_opacity:o}),ar=new Float32Array(e.a6.mat4.identity([])),nr=(t,i,o,s,r,a,n,l,c,h,u,d,_,p=[0,0,0],f)=>{const m=r.style.light,g=m.properties.get("position"),v=[-g.x,-g.y,g.z],x=e.a6.mat3.create();"viewport"===m.properties.get("anchor")&&(e.a6.mat3.fromRotation(x,-r.transform.angle),e.a6.vec3.transformMat3(v,v,x));const y="MASK"===u.alphaMode,b=m.properties.get("color").toRenderColor(null),w=_.paint.get("model-ambient-occlusion-intensity"),T=_.paint.get("model-color").constantOr(e.bA.white).toRenderColor(null),E=_.paint.get("model-color-mix-intensity").constantOr(0);return {u_matrix:t,u_lighting_matrix:i,u_normal_matrix:o,u_node_matrix:s||ar,u_lightpos:v,u_lightintensity:m.properties.get("intensity"),u_lightcolor:[b.r,b.g,b.b],u_camera_pos:p,u_opacity:a,u_baseTextureIsAlpha:0,u_alphaMask:+y,u_alphaCutoff:u.alphaCutoff,u_baseColorFactor:[n.r,n.g,n.b,n.a],u_emissiveFactor:[l[0],l[1],l[2],1],u_metallicFactor:c,u_roughnessFactor:h,u_baseColorTexture:Gi.BaseColor,u_metallicRoughnessTexture:Gi.MetallicRoughness,u_normalTexture:Gi.Normal,u_occlusionTexture:Gi.Occlusion,u_emissionTexture:Gi.Emission,u_lutTexture:Gi.LUT,u_color_mix:[T.r,T.g,T.b,E],u_aoIntensity:w,u_emissive_strength:d,u_occlusionTextureTransform:f||[0,0,0,0]}},lr=(e,t=ar,i=ar)=>({u_matrix:e,u_instance:t,u_node_matrix:i}),cr={fillExtrusion:t=>({u_matrix:new e.bG(t),u_lightpos:new e.bI(t),u_lightintensity:new e.bJ(t),u_lightcolor:new e.bI(t),u_vertical_gradient:new e.bJ(t),u_opacity:new e.bJ(t),u_edge_radius:new e.bJ(t),u_width_scale:new e.bJ(t),u_ao:new e.bH(t),u_height_type:new e.bK(t),u_base_type:new e.bK(t),u_tile_id:new e.bI(t),u_zoom_transition:new e.bJ(t),u_inv_rot_matrix:new e.bG(t),u_merc_center:new e.bH(t),u_up_dir:new e.bI(t),u_height_lift:new e.bJ(t),u_flood_light_color:new e.bI(t),u_vertical_scale:new e.bJ(t),u_flood_light_intensity:new e.bJ(t),u_ground_shadow_factor:new e.bI(t)}),fillExtrusionDepth:t=>({u_matrix:new e.bG(t),u_edge_radius:new e.bJ(t),u_width_scale:new e.bJ(t),u_vertical_scale:new e.bJ(t),u_height_type:new e.bK(t),u_base_type:new e.bK(t)}),fillExtrusionPattern:t=>({u_matrix:new e.bG(t),u_lightpos:new e.bI(t),u_lightintensity:new e.bJ(t),u_lightcolor:new e.bI(t),u_vertical_gradient:new e.bJ(t),u_height_factor:new e.bJ(t),u_edge_radius:new e.bJ(t),u_width_scale:new e.bJ(t),u_ao:new e.bH(t),u_height_type:new e.bK(t),u_base_type:new e.bK(t),u_tile_id:new e.bI(t),u_zoom_transition:new e.bJ(t),u_inv_rot_matrix:new e.bG(t),u_merc_center:new e.bH(t),u_up_dir:new e.bI(t),u_height_lift:new e.bJ(t),u_image:new e.bK(t),u_texsize:new e.bH(t),u_pixel_coord_upper:new e.bH(t),u_pixel_coord_lower:new e.bH(t),u_tile_units_to_pixels:new e.bJ(t),u_opacity:new e.bJ(t)}),fillExtrusionGroundEffect:t=>({u_matrix:new e.bG(t),u_opacity:new e.bJ(t),u_ao_pass:new e.bJ(t),u_meter_to_tile:new e.bJ(t),u_ao:new e.bH(t),u_flood_light_intensity:new e.bJ(t),u_flood_light_color:new e.bI(t),u_attenuation:new e.bJ(t),u_edge_radius:new e.bJ(t),u_fb:new e.bK(t),u_fb_size:new e.bJ(t),u_dynamic_offset:new e.bJ(t)}),fill:t=>({u_matrix:new e.bG(t),u_emissive_strength:new e.bJ(t)}),fillPattern:t=>({u_matrix:new e.bG(t),u_emissive_strength:new e.bJ(t),u_image:new e.bK(t),u_texsize:new e.bH(t),u_pixel_coord_upper:new e.bH(t),u_pixel_coord_lower:new e.bH(t),u_tile_units_to_pixels:new e.bJ(t)}),fillOutline:t=>({u_matrix:new e.bG(t),u_emissive_strength:new e.bJ(t),u_world:new e.bH(t)}),fillOutlinePattern:t=>({u_matrix:new e.bG(t),u_emissive_strength:new e.bJ(t),u_world:new e.bH(t),u_image:new e.bK(t),u_texsize:new e.bH(t),u_pixel_coord_upper:new e.bH(t),u_pixel_coord_lower:new e.bH(t),u_tile_units_to_pixels:new e.bJ(t)}),circle:e.cN,collisionBox:t=>({u_matrix:new e.bG(t),u_camera_to_center_distance:new e.bJ(t),u_extrude_scale:new e.bH(t)}),collisionCircle:t=>({u_matrix:new e.bG(t),u_inv_matrix:new e.bG(t),u_camera_to_center_distance:new e.bJ(t),u_viewport_size:new e.bH(t)}),debug:t=>({u_color:new e.cu(t),u_matrix:new e.bG(t),u_overlay:new e.bK(t),u_overlay_scale:new e.bJ(t)}),clippingMask:t=>({u_matrix:new e.bG(t)}),heatmap:t=>({u_extrude_scale:new e.bJ(t),u_intensity:new e.bJ(t),u_matrix:new e.bG(t),u_inv_rot_matrix:new e.bG(t),u_merc_center:new e.bH(t),u_tile_id:new e.bI(t),u_zoom_transition:new e.bJ(t),u_up_dir:new e.bI(t)}),heatmapTexture:t=>({u_image:new e.bK(t),u_color_ramp:new e.bK(t),u_opacity:new e.bJ(t)}),hillshade:t=>({u_matrix:new e.bG(t),u_image:new e.bK(t),u_latrange:new e.bH(t),u_light:new e.bH(t),u_shadow:new e.cu(t),u_highlight:new e.cu(t),u_emissive_strength:new e.bJ(t),u_accent:new e.cu(t)}),hillshadePrepare:t=>({u_matrix:new e.bG(t),u_image:new e.bK(t),u_dimension:new e.bH(t),u_zoom:new e.bJ(t)}),line:e.cO,linePattern:e.cP,raster:t=>({u_matrix:new e.bG(t),u_normalize_matrix:new e.bG(t),u_globe_matrix:new e.bG(t),u_merc_matrix:new e.bG(t),u_grid_matrix:new e.cv(t),u_tl_parent:new e.bH(t),u_scale_parent:new e.bJ(t),u_fade_t:new e.bJ(t),u_opacity:new e.bJ(t),u_image0:new e.bK(t),u_image1:new e.bK(t),u_brightness_low:new e.bJ(t),u_brightness_high:new e.bJ(t),u_saturation_factor:new e.bJ(t),u_contrast_factor:new e.bJ(t),u_spin_weights:new e.bI(t),u_perspective_transform:new e.bH(t),u_raster_elevation:new e.bJ(t),u_zoom_transition:new e.bJ(t),u_merc_center:new e.bH(t),u_cutoff_params:new e.c7(t),u_colorization_mix:new e.c7(t),u_colorization_offset:new e.bJ(t),u_color_ramp:new e.bK(t),u_texture_offset:new e.bH(t),u_texture_res:new e.bH(t),u_emissive_strength:new e.bJ(t)}),rasterParticle:t=>({u_matrix:new e.bG(t),u_normalize_matrix:new e.bG(t),u_globe_matrix:new e.bG(t),u_merc_matrix:new e.bG(t),u_grid_matrix:new e.cv(t),u_tl_parent:new e.bH(t),u_scale_parent:new e.bJ(t),u_fade_t:new e.bJ(t),u_opacity:new e.bJ(t),u_image0:new e.bK(t),u_image1:new e.bK(t),u_raster_elevation:new e.bJ(t),u_zoom_transition:new e.bJ(t),u_merc_center:new e.bH(t),u_cutoff_params:new e.c7(t)}),rasterParticleTexture:t=>({u_texture:new e.bK(t),u_opacity:new e.bJ(t)}),rasterParticleDraw:t=>({u_particle_texture:new e.bK(t),u_particle_texture_side_len:new e.bJ(t),u_tile_offset:new e.bH(t),u_velocity:new e.bK(t),u_color_ramp:new e.bK(t),u_velocity_res:new e.bH(t),u_max_speed:new e.bJ(t),u_uv_offset:new e.bH(t),u_data_scale:new e.bH(t),u_data_offset:new e.bJ(t),u_particle_pos_scale:new e.bJ(t),u_particle_pos_offset:new e.bH(t)}),rasterParticleUpdate:t=>({u_particle_texture:new e.bK(t),u_particle_texture_side_len:new e.bJ(t),u_velocity:new e.bK(t),u_velocity_res:new e.bH(t),u_max_speed:new e.bJ(t),u_speed_factor:new e.bJ(t),u_reset_rate:new e.bJ(t),u_rand_seed:new e.bJ(t),u_uv_offset:new e.bH(t),u_data_scale:new e.bH(t),u_data_offset:new e.bJ(t),u_particle_pos_scale:new e.bJ(t),u_particle_pos_offset:new e.bH(t)}),symbol:t=>({u_is_size_zoom_constant:new e.bK(t),u_is_size_feature_constant:new e.bK(t),u_size_t:new e.bJ(t),u_size:new e.bJ(t),u_camera_to_center_distance:new e.bJ(t),u_rotate_symbol:new e.bK(t),u_aspect_ratio:new e.bJ(t),u_fade_change:new e.bJ(t),u_matrix:new e.bG(t),u_label_plane_matrix:new e.bG(t),u_coord_matrix:new e.bG(t),u_is_text:new e.bK(t),u_elevation_from_sea:new e.bK(t),u_pitch_with_map:new e.bK(t),u_texsize:new e.bH(t),u_texsize_icon:new e.bH(t),u_texture:new e.bK(t),u_texture_icon:new e.bK(t),u_gamma_scale:new e.bJ(t),u_device_pixel_ratio:new e.bJ(t),u_tile_id:new e.bI(t),u_zoom_transition:new e.bJ(t),u_inv_rot_matrix:new e.bG(t),u_merc_center:new e.bH(t),u_camera_forward:new e.bI(t),u_tile_matrix:new e.bG(t),u_up_vector:new e.bI(t),u_ecef_origin:new e.bI(t),u_is_halo:new e.bK(t),u_icon_transition:new e.bJ(t),u_color_adj_mat:new e.bG(t),u_scale_factor:new e.bJ(t)}),background:t=>({u_matrix:new e.bG(t),u_emissive_strength:new e.bJ(t),u_opacity:new e.bJ(t),u_color:new e.cu(t)}),backgroundPattern:t=>({u_matrix:new e.bG(t),u_emissive_strength:new e.bJ(t),u_opacity:new e.bJ(t),u_image:new e.bK(t),u_pattern_tl:new e.bH(t),u_pattern_br:new e.bH(t),u_texsize:new e.bH(t),u_pattern_size:new e.bH(t),u_pixel_coord_upper:new e.bH(t),u_pixel_coord_lower:new e.bH(t),u_pattern_units_to_pixels:new e.bH(t)}),terrainRaster:t=>({u_matrix:new e.bG(t),u_image0:new e.bK(t),u_skirt_height:new e.bJ(t),u_ground_shadow_factor:new e.bI(t)}),skybox:t=>({u_matrix:new e.bG(t),u_sun_direction:new e.bI(t),u_cubemap:new e.bK(t),u_opacity:new e.bJ(t),u_temporal_offset:new e.bJ(t)}),skyboxGradient:t=>({u_matrix:new e.bG(t),u_color_ramp:new e.bK(t),u_center_direction:new e.bI(t),u_radius:new e.bJ(t),u_opacity:new e.bJ(t),u_temporal_offset:new e.bJ(t)}),skyboxCapture:t=>({u_matrix_3f:new e.cv(t),u_sun_direction:new e.bI(t),u_sun_intensity:new e.bJ(t),u_color_tint_r:new e.c7(t),u_color_tint_m:new e.c7(t),u_luminance:new e.bJ(t)}),globeRaster:t=>({u_proj_matrix:new e.bG(t),u_globe_matrix:new e.bG(t),u_normalize_matrix:new e.bG(t),u_merc_matrix:new e.bG(t),u_zoom_transition:new e.bJ(t),u_merc_center:new e.bH(t),u_image0:new e.bK(t),u_grid_matrix:new e.cv(t),u_skirt_height:new e.bJ(t),u_far_z_cutoff:new e.bJ(t),u_frustum_tl:new e.bI(t),u_frustum_tr:new e.bI(t),u_frustum_br:new e.bI(t),u_frustum_bl:new e.bI(t),u_globe_pos:new e.bI(t),u_globe_radius:new e.bJ(t),u_viewport:new e.bH(t)}),globeAtmosphere:t=>({u_frustum_tl:new e.bI(t),u_frustum_tr:new e.bI(t),u_frustum_br:new e.bI(t),u_frustum_bl:new e.bI(t),u_horizon:new e.bJ(t),u_transition:new e.bJ(t),u_fadeout_range:new e.bJ(t),u_color:new e.c7(t),u_high_color:new e.c7(t),u_space_color:new e.c7(t),u_temporal_offset:new e.bJ(t),u_horizon_angle:new e.bJ(t)}),model:t=>({u_matrix:new e.bG(t),u_lighting_matrix:new e.bG(t),u_normal_matrix:new e.bG(t),u_node_matrix:new e.bG(t),u_lightpos:new e.bI(t),u_lightintensity:new e.bJ(t),u_lightcolor:new e.bI(t),u_camera_pos:new e.bI(t),u_opacity:new e.bJ(t),u_baseColorFactor:new e.c7(t),u_emissiveFactor:new e.c7(t),u_metallicFactor:new e.bJ(t),u_roughnessFactor:new e.bJ(t),u_baseTextureIsAlpha:new e.bK(t),u_alphaMask:new e.bK(t),u_alphaCutoff:new e.bJ(t),u_baseColorTexture:new e.bK(t),u_metallicRoughnessTexture:new e.bK(t),u_normalTexture:new e.bK(t),u_occlusionTexture:new e.bK(t),u_emissionTexture:new e.bK(t),u_lutTexture:new e.bK(t),u_color_mix:new e.c7(t),u_aoIntensity:new e.bJ(t),u_emissive_strength:new e.bJ(t),u_occlusionTextureTransform:new e.c7(t)}),modelDepth:t=>({u_matrix:new e.bG(t),u_instance:new e.bG(t),u_node_matrix:new e.bG(t)}),groundShadow:t=>({u_matrix:new e.bG(t),u_ground_shadow_factor:new e.bI(t)}),stars:t=>({u_matrix:new e.bG(t),u_up:new e.bI(t),u_right:new e.bI(t),u_intensity_multiplier:new e.bJ(t)}),snowParticle:t=>({u_modelview:new e.bG(t),u_projection:new e.bG(t),u_time:new e.bJ(t),u_cam_pos:new e.bI(t),u_velocityConeAperture:new e.bJ(t),u_velocity:new e.bJ(t),u_horizontalOscillationRadius:new e.bJ(t),u_horizontalOscillationRate:new e.bJ(t),u_boxSize:new e.bJ(t),u_billboardSize:new e.bJ(t),u_simpleShapeParameters:new e.bH(t),u_screenSize:new e.bH(t),u_thinningCenterPos:new e.bH(t),u_thinningShape:new e.bI(t),u_thinningAffectedRatio:new e.bJ(t),u_thinningParticleOffset:new e.bJ(t),u_particleColor:new e.c7(t),u_direction:new e.bI(t)}),rainParticle:t=>({u_modelview:new e.bG(t),u_projection:new e.bG(t),u_time:new e.bJ(t),u_cam_pos:new e.bI(t),u_texScreen:new e.bK(t),u_velocityConeAperture:new e.bJ(t),u_velocity:new e.bJ(t),u_boxSize:new e.bJ(t),u_rainDropletSize:new e.bH(t),u_distortionStrength:new e.bJ(t),u_rainDirection:new e.bI(t),u_color:new e.c7(t),u_screenSize:new e.bH(t),u_thinningCenterPos:new e.bH(t),u_thinningShape:new e.bI(t),u_thinningAffectedRatio:new e.bJ(t),u_thinningParticleOffset:new e.bJ(t),u_shapeDirectionalPower:new e.bJ(t),u_mode:new e.bJ(t)}),occlusion:t=>({u_matrix:new e.bG(t),u_anchorPos:new e.bI(t),u_screenSizePx:new e.bH(t),u_occluderSizePx:new e.bH(t),u_color:new e.c7(t)})};class hr{constructor(e,t,i,o){this.id=hr.uniqueIdxCounter,hr.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=hr.uniqueIdxCounter,hr.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);}}hr.uniqueIdxCounter=0;const ur={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class dr{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 a=e.gl;this.buffer=a.createBuffer(),e.bindVertexBuffer.set(this.buffer),a.bufferData(a.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?a.DYNAMIC_DRAW:a.STATIC_DRAW),this.dynamicDraw||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;i<this.attributes.length;i++){const o=t.attributes[this.attributes[i].name];void 0!==o&&e.enableVertexAttribArray(o);}}setVertexAttribPointers(e,t,i){for(let o=0;o<this.attributes.length;o++){const s=this.attributes[o],r=t.attributes[s.name];void 0!==r&&e.vertexAttribPointer(r,s.components,e[ur[s.type]],!1,this.itemSize,s.offset+this.itemSize*(i||0));}}setVertexAttribDivisor(e,t,i){for(let o=0;o<this.attributes.length;o++){const s=t.attributes[this.attributes[o].name];void 0!==s&&this.instanceCount&&this.instanceCount>0&&e.vertexAttribDivisor(s,i);}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer);}}class _r{constructor(e,t,i,o,s){this.context=e,this.width=t,this.height=i;const r=this.framebuffer=e.gl.createFramebuffer();o&&(this.colorAttachment=new _s(e,r)),s&&(this.depthAttachmentType=s,this.depthAttachment="renderbuffer"===s?new ps(e,r):new fs(e,r));}destroy(){const e=this.context.gl;if(this.colorAttachment){const t=this.colorAttachment.get();t&&e.deleteTexture(t);}if(this.depthAttachment&&this.depthAttachmentType)if("renderbuffer"===this.depthAttachmentType){const t=this.depthAttachment.get();t&&e.deleteRenderbuffer(t);}else {const t=this.depthAttachment.get();t&&e.deleteTexture(t);}e.deleteFramebuffer(this.framebuffer);}}class pr{constructor(e,t){this.gl=e,this.clearColor=new Oo(this),this.clearDepth=new Fo(this),this.clearStencil=new Bo(this),this.colorMask=new ko(this),this.depthMask=new No(this),this.stencilMask=new Uo(this),this.stencilFunc=new Go(this),this.stencilOp=new Vo(this),this.stencilTest=new jo(this),this.depthRange=new Ho(this),this.depthTest=new Zo(this),this.depthFunc=new qo(this),this.blend=new Wo(this),this.blendFunc=new $o(this),this.blendColor=new Xo(this),this.blendEquation=new Jo(this),this.cullFace=new Ko(this),this.cullFaceSide=new Yo(this),this.frontFace=new Qo(this),this.program=new es(this),this.activeTexture=new ts(this),this.viewport=new is(this),this.bindFramebuffer=new os(this),this.bindRenderbuffer=new ss(this),this.bindTexture=new rs(this),this.bindVertexBuffer=new as(this),this.bindElementBuffer=new ns(this),this.bindVertexArrayOES=new ls(this),this.pixelStoreUnpack=new cs(this),this.pixelStoreUnpackPremultiplyAlpha=new hs(this),this.pixelStoreUnpackFlipY=new us(this),this.options=t?{...t}:{},this.options.extTextureFilterAnisotropicForceOff||(this.extTextureFilterAnisotropic=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=e.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT))),this.extDebugRendererInfo=e.getExtension("WEBGL_debug_renderer_info"),this.extDebugRendererInfo&&(this.renderer=e.getParameter(this.extDebugRendererInfo.UNMASKED_RENDERER_WEBGL),this.vendor=e.getParameter(this.extDebugRendererInfo.UNMASKED_VENDOR_WEBGL)),this.options.extTextureFloatLinearForceOff||(this.extTextureFloatLinear=e.getExtension("OES_texture_float_linear")),this.extRenderToTextureHalfFloat=e.getExtension("EXT_color_buffer_half_float"),this.extTimerQuery=e.getExtension("EXT_disjoint_timer_query_webgl2"),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),this.maxPointSize=e.getParameter(e.ALIASED_POINT_SIZE_RANGE)[1];}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault();}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.bindVertexArrayOES.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0;}createIndexBuffer(e,t,i){return new hr(this,e,t,i)}createVertexBuffer(e,t,i,o,s){return new dr(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 _r(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),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.bi(t.blendFunction,Ri.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 fr;function mr(t,i,o,s,r,a,n){const l=t.context,c=l.gl,h=t.transform,u=t.getOrCreateProgram("collisionBox"),d=[];let _=0,p=0;for(let l=0;l<s.length;l++){const f=s[l],m=i.getTile(f),g=m.getBucket(o);if(!g)continue;const v=ei(f,g,h);let x=v;0===r[0]&&0===r[1]||(x=t.translatePosMatrix(v,m,r,a));const y=n?g.textCollisionBox:g.iconCollisionBox,b=g.collisionCircleArray;if(b.length>0){const t=e.a6.mat4.create(),i=x;e.a6.mat4.mul(t,g.placementInvProjMatrix,h.glCoordMatrix),e.a6.mat4.mul(t,t,g.placementViewportMatrix),d.push({circleArray:b,circleOffset:p,transform:i,invTransform:t,projection:g.getProjection()}),_+=b.length/4,p=_;}y&&(t.terrain&&t.terrain.setupElevationDraw(m,u),u.draw(t,c.LINES,Ai.disabled,Pi.disabled,t.colorModeForRenderPass(),Oi.disabled,Hs(x,h,m,g.getProjection()),o.id,y.layoutVertexBuffer,y.indexBuffer,y.segments,null,h.zoom,null,[y.collisionVertexBuffer,y.collisionVertexBufferExt]));}if(!n||!d.length)return;const f=t.getOrCreateProgram("collisionCircle"),m=new e.cQ;m.resize(4*_),m._trim();let g=0;for(const e of d)for(let t=0;t<e.circleArray.length/4;t++){const i=4*t,o=e.circleArray[i+0],s=e.circleArray[i+1],r=e.circleArray[i+2],a=e.circleArray[i+3];m.emplace(g++,o,s,r,a,0),m.emplace(g++,o,s,r,a,1),m.emplace(g++,o,s,r,a,2),m.emplace(g++,o,s,r,a,3);}(!fr||fr.length<2*_)&&(fr=function(t){const i=2*t,o=new e.aP;o.resize(i),o._trim();for(let e=0;e<i;e++){const t=6*e;o.uint16[t+0]=4*e+0,o.uint16[t+1]=4*e+1,o.uint16[t+2]=4*e+2,o.uint16[t+3]=4*e+2,o.uint16[t+4]=4*e+3,o.uint16[t+5]=4*e+0;}return o}(_));const v=l.createIndexBuffer(fr,!0),x=l.createVertexBuffer(m,e.cR.members,!0);for(const i of d){const s={u_matrix:i.transform,u_inv_matrix:i.invTransform,u_camera_to_center_distance:(y=h).getCameraToCenterDistance(i.projection),u_viewport_size:[y.width,y.height]};f.draw(t,c.TRIANGLES,Ai.disabled,Pi.disabled,t.colorModeForRenderPass(),Oi.disabled,s,o.id,x,v,e.b2.simpleSegment(0,2*i.circleOffset,i.circleArray.length,i.circleArray.length/2),null,h.zoom);}var y;x.destroy(),v.destroy();}const gr=e.a6.mat4.create();function vr(t){const i=t._camera.getWorldToCamera(t.worldSize,1),o=e.a6.mat4.multiply([],i,t.globeMatrix);e.a6.mat4.invert(o,o);const s=[0,0,0],r=[0,1,0,0];return e.a6.vec4.transformMat4(r,r,o),s[0]=r[0],s[1]=r[1],s[2]=r[2],e.a6.vec3.normalize(s,s),s}function xr({width:t,height:i,anchor:o,textOffset:s,textScale:r},a){const{horizontalAlign:n,verticalAlign:l}=e.by(o),c=-(n-.5)*t,h=-(l-.5)*i,u=e.bx(o,s);return new e.P((c/r+u[0])*a,(h/r+u[1])*a)}function yr(t,i,o,s,r,a,n,l,c,h,u){const d=t.text.placedSymbolArray,_=t.text.dynamicLayoutVertexArray,p=t.icon.dynamicLayoutVertexArray,f={},m=t.getProjection(),g=ti(l,m,a),v=a.elevation,x=m.upVectorScale(l.canonical,a.center.lat,a.worldSize).metersToTile;_.clear();for(let p=0;p<d.length;p++){const y=d.get(p),{tileAnchorX:b,tileAnchorY:w,numGlyphs:T}=y,E=y.hidden||!y.crossTileID||t.allowVerticalPlacement&&!y.placedOrientation?null:s[y.crossTileID];if(E){let s=0,d=0,p=0;if(v){const e=v?v.getAtTileOffset(l,b,w):0,[t,i,o]=m.upVector(l.canonical,b,w);s=e*t*x,d=e*i*x,p=e*o*x;}let[S,C,I,D]=Nt(y.projectedAnchorX+s,y.projectedAnchorY+d,y.projectedAnchorZ+p,o?g:n);const R=Ut(a.getCameraToCenterDistance(m),D);let A=r.evaluateSizeForFeature(t.textSizeData,h,y)*R/e.br;o&&(A*=t.tilePixelRatio/c);const L=xr(E,A);o?(({x:S,y:C,z:I}=m.projectTilePoint(b+L.x,w+L.y,l.canonical)),[S,C,I]=Nt(S+s,C+d,I+p,n)):(i&&L._rotate(-a.angle),S+=L.x,C+=L.y,I=0);const P=t.allowVerticalPlacement&&y.placedOrientation===e.bl.vertical?Math.PI/2:0;for(let t=0;t<T;t++)e.bo(_,S,C,I,P);u&&y.associatedIconIndex>=0&&(f[y.associatedIconIndex]={x:S,y:C,z:I,angle:P});}else Xt(T,_);}if(u){p.clear();const i=t.icon.placedSymbolArray;for(let t=0;t<i.length;t++){const o=i.get(t),{numGlyphs:s}=o,r=f[t];if(o.hidden||!r)Xt(s,p);else {const{x:t,y:i,z:o,angle:a}=r;for(let r=0;r<s;r++)e.bo(p,t,i,o,a);}}t.icon.dynamicLayoutVertexBuffer.updateData(p);}t.text.dynamicLayoutVertexBuffer.updateData(_);}function br(t,i,o,s,r,a,n={}){const l=o.paint.get("icon-translate"),c=o.paint.get("text-translate"),h=o.paint.get("icon-translate-anchor"),u=o.paint.get("text-translate-anchor"),d=o.layout.get("icon-rotation-alignment"),_=o.layout.get("text-rotation-alignment"),p=o.layout.get("icon-pitch-alignment"),f=o.layout.get("text-pitch-alignment"),m=o.layout.get("icon-keep-upright"),g=o.layout.get("text-keep-upright"),v=o.paint.get("icon-color-saturation"),x=o.paint.get("icon-color-contrast"),y=o.paint.get("icon-color-brightness-min"),b=o.paint.get("icon-color-brightness-max"),w="sea"===o.layout.get("symbol-elevation-reference"),T=t.context,E=T.gl,S=t.transform,C="map"===d,I="map"===_,D="map"===p,R="map"===f,A=void 0!==o.layout.get("symbol-sort-key").constantOr(1);let L=!1;const P=t.depthModeForSublayer(0,Ai.ReadOnly),M=[e.am(S.center.lng),e.at(S.center.lat)],z=o.layout.get("text-variable-anchor"),O="globe"===S.projection.name,F=[],B=[0,-1,0];for(const r of s){const s=i.getTile(r),a=s.getBucket(o);if(!a)continue;if("mercator"===a.projection.name&&O)continue;if(a.fullyClipped)continue;const d="globe"===a.projection.name,_=d?e.a9(S.zoom):0,p=ti(r,a.getProjection(),S),f=S.calculatePixelsToTileUnitsMatrix(s),T=z&&a.hasTextData(),P=a.hasIconTextFit()&&T&&a.hasIconData(),k=a.getProjection().createInversionMatrix(S,r.canonical),N=e=>{S.depthOcclusionForSymbolsAndCircles&&(o.hasInitialOcclusionOpacityProperties||t.terrain)&&(e.push("DEPTH_D24"),e.push("DEPTH_OCCLUSION"));},U=()=>{const i=C&&"point"!==o.layout.get("symbol-placement"),n=[];N(n);const c=i||P,u=o.paint.get("icon-image-cross-fade").constantOr(0);t.terrainRenderModeElevated()&&D&&n.push("PITCH_WITH_MAP_TERRAIN"),d&&(n.push("PROJECTION_GLOBE_VIEW"),c&&n.push("PROJECTED_POS_ON_VIEWPORT")),u>0&&n.push("ICON_TRANSITION"),a.icon.zOffsetVertexBuffer&&n.push("Z_OFFSET"),0===v&&0===x&&0===y&&1===b||n.push("COLOR_ADJUSTMENT"),a.sdfIcons&&n.push("RENDER_SDF");const g=a.icon.programConfigurations.get(o.id),T=t.getOrCreateProgram("symbol",{config:g,defines:n}),I=s.imageAtlasTexture?s.imageAtlasTexture.size:[0,0],R=a.iconSizeData,A=e.bk(R,S.zoom),L=D||0!==S.pitch,z=Ft(p,s.tileID.canonical,D,C,S,a.getProjection(),f),F=kt(p,s.tileID.canonical,D,C,S,a.getProjection(),f),U=t.translatePosMatrix(F,s,l,h,!0),G=t.translatePosMatrix(p,s,l,h),V=c?gr:z,j=C&&!D&&!i;let H=B;!O&&!S.mercatorFromTransition||C||(H=vr(S));const Z=d?H:B,q=o.getColorAdjustmentMatrix(v,x,y,b),W=or(R.kind,A,j,D,t,G,V,U,w,!1,I,[0,0],!0,r,_,M,k,Z,a.getProjection(),q,u),$=s.imageAtlasTexture?s.imageAtlasTexture:null,X=1!==o.layout.get("icon-size").constantOr(0)||a.iconsNeedLinear,J=a.sdfIcons||t.options.rotating||t.options.zooming||X||L?E.LINEAR:E.NEAREST,K=a.sdfIcons&&0!==o.paint.get("icon-halo-width").constantOr(1),Y=t.terrain&&D&&i?e.a6.mat4.invert(e.a6.mat4.create(),z):gr;if(i&&a.icon){const e=S.elevation,i=e?e.getAtTileOffsetFunc(r,S.center.lat,S.worldSize,a.getProjection()):null,o=Bt(p,s.tileID.canonical,D,C,S,a.getProjection(),f);Vt(a,p,t,!1,o,F,D,m,i,r);}return {program:T,buffers:a.icon,uniformValues:W,atlasTexture:$,atlasTextureIcon:null,atlasInterpolation:J,atlasInterpolationIcon:null,isSDF:a.sdfIcons,hasHalo:K,tile:s,labelPlaneMatrixInv:Y}},G=()=>{const i=I&&"point"!==o.layout.get("symbol-placement"),n=[],l=i||z||P;t.terrainRenderModeElevated()&&R&&n.push("PITCH_WITH_MAP_TERRAIN"),d&&(n.push("PROJECTION_GLOBE_VIEW"),l&&n.push("PROJECTED_POS_ON_VIEWPORT")),a.text.zOffsetVertexBuffer&&n.push("Z_OFFSET"),a.iconsInText&&n.push("RENDER_TEXT_AND_SYMBOL"),n.push("RENDER_SDF"),N(n);const h=a.text.programConfigurations.get(o.id),m=t.getOrCreateProgram("symbol",{config:h,defines:n});let v,x=[0,0],y=null;const b=a.textSizeData;a.iconsInText&&(x=s.imageAtlasTexture?s.imageAtlasTexture.size:[0,0],y=s.imageAtlasTexture?s.imageAtlasTexture:null,v=R||0!==S.pitch||t.options.rotating||t.options.zooming||"composite"===b.kind||"camera"===b.kind?E.LINEAR:E.NEAREST);const T=s.glyphAtlasTexture?s.glyphAtlasTexture.size:[0,0],C=o.layout.get("text-size-scale-range"),D=e.ap(t.scaleFactor,C[0],C[1]),A=e.bk(b,S.zoom,D),L=Ft(p,s.tileID.canonical,R,I,S,a.getProjection(),f),F=kt(p,s.tileID.canonical,R,I,S,a.getProjection(),f),U=t.translatePosMatrix(F,s,c,u,!0),G=t.translatePosMatrix(p,s,c,u),V=l?gr:L,j=I&&!R&&!i;let H=B;!O&&!S.mercatorFromTransition||I||(H=vr(S));const Z=or(b.kind,A,j,R,t,G,V,U,w,!0,T,x,!0,r,_,M,k,d?H:B,a.getProjection(),null,null,D),q=s.glyphAtlasTexture?s.glyphAtlasTexture:null,W=E.LINEAR,$=0!==o.paint.get("text-halo-width").constantOr(1),X=t.terrain&&R&&i?e.a6.mat4.invert(e.a6.mat4.create(),L):gr;if(i&&a.text){const e=S.elevation,i=e?e.getAtTileOffsetFunc(r,S.center.lat,S.worldSize,a.getProjection()):null,o=Bt(p,s.tileID.canonical,R,I,S,a.getProjection(),f);Vt(a,p,t,!0,o,F,R,g,i,r);}return {program:m,buffers:a.text,uniformValues:Z,atlasTexture:q,atlasTextureIcon:y,atlasInterpolation:W,atlasInterpolationIcon:v,isSDF:!0,hasHalo:$,tile:s,labelPlaneMatrixInv:X}},V=a.icon.segments.get().length,j=a.text.segments.get().length,H=V&&!n.onlyText?U():null,Z=j&&!n.onlyIcons?G():null,q=o.paint.get("icon-opacity").constantOr(1),W=o.paint.get("text-opacity").constantOr(1);if(A&&a.canOverlap){L=!0;const t=q&&!n.onlyText?a.icon.segments.get():[],i=W&&!n.onlyIcons?a.text.segments.get():[];for(const i of t)F.push({segments:new e.b2([i]),sortKey:i.sortKey,state:H});for(const t of i)F.push({segments:new e.b2([t]),sortKey:t.sortKey,state:Z});}else n.onlyText||F.push({segments:q?a.icon.segments:new e.b2([]),sortKey:0,state:H}),n.onlyIcons||F.push({segments:W?a.text.segments:new e.b2([]),sortKey:0,state:Z});}L&&F.sort(((e,t)=>e.sortKey-t.sortKey));for(const e of F){const i=e.state;if(i)if(t.terrain?t.terrain.setupElevationDraw(i.tile,i.program,{useDepthForOcclusion:S.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:i.labelPlaneMatrixInv}):t.setupDepthForOcclusion(S.depthOcclusionForSymbolsAndCircles,i.program),T.activeTexture.set(E.TEXTURE0),i.atlasTexture&&i.atlasTexture.bind(i.atlasInterpolation,E.CLAMP_TO_EDGE,!0),i.atlasTextureIcon&&(T.activeTexture.set(E.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,E.CLAMP_TO_EDGE,!0)),t.uploadCommonLightUniforms(t.context,i.program),i.hasHalo){const s=i.uniformValues;s.u_is_halo=1,wr(i.buffers,e.segments,o,t,i.program,P,r,a,s,2),s.u_is_halo=0;}else {if(i.isSDF){const s=i.uniformValues;i.hasHalo&&(s.u_is_halo=1,wr(i.buffers,e.segments,o,t,i.program,P,r,a,s,1)),s.u_is_halo=0;}wr(i.buffers,e.segments,o,t,i.program,P,r,a,i.uniformValues,1);}}}function wr(e,t,i,o,s,r,a,n,l,c){const h=[e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer,e.iconTransitioningVertexBuffer,e.globeExtVertexBuffer,e.zOffsetVertexBuffer];s.draw(o,o.context.gl.TRIANGLES,r,a,n,Oi.disabled,l,i.id,e.layoutVertexBuffer,e.indexBuffer,t,i.paint,o.transform.zoom,e.programConfigurations.get(i.id),h,c);}function Tr(e,t,i,o,s,r,a){const n=e.context.gl,l=i.paint.get("fill-pattern"),c=i.is3D(),h=c?e.stencilModeFor3D():Pi.disabled,u=l&&l.constantOr(1);let d,_,p,f,m;a?(_=u&&!i.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",d=n.LINES):(_=u?"fillPattern":"fill",d=n.TRIANGLES);for(const g of o){const o=t.getTile(g);if(u&&!o.patternsLoaded())continue;const v=o.getBucket(i);if(!v)continue;e.prepareDrawTile();const x=v.programConfigurations.get(i.id),y=e.isTileAffectedByFog(g),b=e.getOrCreateProgram(_,{config:x,overrideFog:y});u&&(e.context.activeTexture.set(n.TEXTURE0),o.imageAtlasTexture&&o.imageAtlasTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE),x.updatePaintBuffers());const w=l.constantOr(null);if(w&&o.imageAtlas){const e=o.imageAtlas.patternPositions[w.toString()];e&&x.setConstantPatternPositions(e);}const T=e.translatePosMatrix(g.projMatrix,o,i.paint.get("fill-translate"),i.paint.get("fill-translate-anchor")),E=i.paint.get("fill-emissive-strength");if(a){f=v.indexBuffer2,m=v.segments2;const t=e.terrain&&e.terrain.renderingToTexture?e.terrain.drapeBufferSize:[n.drawingBufferWidth,n.drawingBufferHeight];p="fillOutlinePattern"===_&&u?js(T,E,e,o,t):Vs(T,E,t);}else f=v.indexBuffer,m=v.segments,p=u?Gs(T,E,e,o):Us(T,E);e.uploadCommonUniforms(e.context,b,g.toUnwrapped()),b.draw(e,d,s,c?h:e.stencilModeForClipping(g),r,Oi.disabled,p,i.id,v.layoutVertexBuffer,f,m,i.paint,e.transform.zoom,x,void 0);}}function Er(t,i,o,s,r,a,n,l){o.resetLayerRenderingStats(t);const c=t.context,h=c.gl,u=t.transform,d=o.paint.get("fill-extrusion-pattern"),_=d.constantOr(1),p=o.paint.get("fill-extrusion-opacity"),f=t.style.enable3dLights(),m=o.paint.get(f&&!_?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),g=[o.paint.get("fill-extrusion-ambient-occlusion-intensity"),m],v=o.layout.get("fill-extrusion-edge-radius"),x=v>0&&!o.paint.get("fill-extrusion-rounded-roof"),y=x?0:v,b="globe"===u.projection.name?e.c_():0,w="globe"===u.projection.name,T=w?e.a9(u.zoom):0,E=[e.am(u.center.lng),e.at(u.center.lat)],S=o.paint.get("fill-extrusion-flood-light-color").toRenderColor(o.lut).toArray01().slice(0,3),C=o.paint.get("fill-extrusion-flood-light-intensity"),I=o.paint.get("fill-extrusion-vertical-scale"),D=0!==o.paint.get("fill-extrusion-line-width").constantOr(1),R=o.paint.get("fill-extrusion-height-alignment"),A=o.paint.get("fill-extrusion-base-alignment"),L=qi(t,o.paint.get("fill-extrusion-cutoff-fade-range")),P=[];let M;w&&P.push("PROJECTION_GLOBE_VIEW"),g[0]>0&&P.push("FAUX_AO"),x&&P.push("ZERO_ROOF_RADIUS"),l&&P.push("HAS_CENTROID"),C>0&&P.push("FLOOD_LIGHT"),L.shouldRenderCutoff&&P.push("RENDER_CUTOFF"),D&&P.push("RENDER_WALL_MODE");const z="shadow"===t.renderPass,O=t.shadowRenderer,F=z&&!!O;t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!0);let B=[0,0,0];if(O){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(B=Qi(t.style,e,i)),z||(P.push("RENDER_SHADOWS","DEPTH_TEXTURE"),O.useNormalOffset&&P.push("NORMAL_OFFSET")),M=P.concat(["SHADOWS_SINGLE_CASCADE"]);}const k=F?"fillExtrusionDepth":_?"fillExtrusionPattern":"fillExtrusion",N=o.getLayerRenderingStats();for(const e of s){const s=i.getTile(e),f=s.getBucket(o);if(!f||f.projection.name!==u.projection.name)continue;let m=!1;O&&(m=0===O.getMaxCascadeForTile(e.toUnwrapped()));const v=t.isTileAffectedByFog(e),x=f.programConfigurations.get(o.id),F=t.getOrCreateProgram(k,{config:x,defines:m?M:P,overrideFog:v});if(t.terrain&&t.terrain.setupElevationDraw(s,F,{useMeterToDem:!0}),!f.centroidVertexBuffer){const e=F.attributes.a_centroid_pos;void 0!==e&&h.vertexAttrib2f(e,0,0);}!z&&O&&O.setupShadows(s.tileID.toUnwrapped(),F,"vector-tile",s.tileID.overscaledZ),_&&(t.context.activeTexture.set(h.TEXTURE0),s.imageAtlasTexture&&s.imageAtlasTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),x.updatePaintBuffers());const U=d.constantOr(null);if(U&&s.imageAtlas){const e=s.imageAtlas.patternPositions[U.toString()];e&&x.setConstantPatternPositions(e);}const G=o.paint.get("fill-extrusion-vertical-gradient"),V=1/f.tileToMeter;let j;if(z&&O){if(Ar(s.tileID,f,t))continue;const e=O.calculateShadowPassMatrixFromTile(s.tileID.toUnwrapped());j=ks(e,y,V,I,R,A);}else {const i=t.translatePosMatrix(e.expandedProjMatrix,s,o.paint.get("fill-extrusion-translate"),o.paint.get("fill-extrusion-translate-anchor")),r=u.projection.createInversionMatrix(u,e.canonical);j=_?Ns(i,t,G,p,g,y,V,e,s,b,R,A,T,E,r,S,I):Bs(i,t,G,p,g,y,V,e,b,R,A,T,E,r,S,I,C,B);}t.uploadCommonUniforms(c,F,e.toUnwrapped(),null,L);let H=f.segments;if("mercator"===u.projection.name&&!z&&(H=f.getVisibleSegments(s.tileID,t.terrain,t.transform.getFrustum(0)),!H.get().length))continue;if(N)if(z)for(const e of H.get())N.numRenderedVerticesInShadowPass+=e.primitiveLength;else for(const e of H.get())N.numRenderedVerticesInTransparentPass+=e.primitiveLength;const Z=[];(t.terrain||l)&&Z.push(f.centroidVertexBuffer),w&&Z.push(f.layoutVertexExtBuffer),D&&Z.push(f.wallVertexBuffer),F.draw(t,c.gl.TRIANGLES,r,a,n,Oi.backCCW,j,o.id,f.layoutVertexBuffer,f.indexBuffer,H,o.paint,t.transform.zoom,x,Z);}t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!1);}function Sr(t,i,o,s,r,a,n,l,c,h,u,d,_,p,f,m,g,v,x){const y=t.context,b=y.gl,w=t.transform,T=t.transform.zoom,E=[],S=qi(t,o.paint.get("fill-extrusion-cutoff-fade-range"));"clear"===h?(E.push("CLEAR_SUBPASS"),x&&(E.push("CLEAR_FROM_TEXTURE"),y.activeTexture.set(b.TEXTURE0),x.bind(b.LINEAR,b.CLAMP_TO_EDGE))):"sdf"===h&&E.push("SDF_SUBPASS"),g&&E.push("HAS_CENTROID"),S.shouldRenderCutoff&&E.push("RENDER_CUTOFF");const C=o.layout.get("fill-extrusion-edge-radius"),I=(e,i,s,h,v)=>{const b=i.programConfigurations.get(o.id),w=t.isTileAffectedByFog(e),I=t.getOrCreateProgram("fillExtrusionGroundEffect",{config:b,defines:E,overrideFog:w}),D=((e,t,i,o,s,r,a,n,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:a,u_flood_light_color:n,u_attenuation:l,u_edge_radius:c,u_fb:0,u_fb_size:h,u_dynamic_offset:1}))(0,h,u,c,v,[d,_*v],p,f,m,T>=17?0:C*v,x?x.size[0]:0),R=[];g&&R.push(i.hiddenByLandmarkVertexBuffer),t.uploadCommonUniforms(y,I,e.toUnwrapped(),null,S),I.draw(t,y.gl.TRIANGLES,r,a,n,l,D,o.id,i.vertexBuffer,i.indexBuffer,s,o.paint,T,b,R);};for(const r of s){const s=i.getTile(r),a=s.getBucket(o);if(!a||a.projection.name!==w.projection.name||!a.groundEffect||a.groundEffect&&!a.groundEffect.hasData())continue;const n=a.groundEffect,l=1/a.tileToMeter;{const e=t.translatePosMatrix(r.projMatrix,s,o.paint.get("fill-extrusion-translate"),o.paint.get("fill-extrusion-translate-anchor")),i=n.getDefaultSegment();I(r,n,i,e,l);}if(v)for(let a=0;a<4;a++){const n=e.c$[a](r),c=i.getTile(n);if(!c)continue;const h=c.getBucket(o);if(!h||h.projection.name!==w.projection.name||!h.groundEffect||h.groundEffect&&!h.groundEffect.hasData())continue;const u=h.groundEffect;let d,_;0===a?(d=[-e.ab,0,0],_=1):1===a?(d=[e.ab,0,0],_=0):2===a?(d=[0,-e.ab,0],_=3):(d=[0,e.ab,0],_=2);const p=u.regionSegments[_];if(!p)continue;const f=new Float32Array(16);e.a6.mat4.translate(f,r.projMatrix,d),I(r,u,p,t.translatePosMatrix(f,s,o.paint.get("fill-extrusion-translate"),o.paint.get("fill-extrusion-translate-anchor")),l);}}}function Cr(t,i,o,s,r,a,n){0===s.centroidVertexArray.length&&s.createCentroidsBuffer();const l=a?a.findDEMTileFor(o):null;if(!(l&&l.dem||n))return;const c=t=>new e.P(Math.ceil((t+e.d2)*e.d3),0),h=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<t)continue;const s=o(e.calculateScaledKey(e.overscaledZ+i));if(s)return s}},u=[0,0,0],d=(t,i)=>(u[0]=Math.min(t.min.y,i.min.y),u[1]=Math.max(t.max.y,i.max.y),u[2]=e.ab-i.min.x>t.max.x?i.min.x-e.ab:t.max.x,u),_=(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.ab-i.min.y>t.max.y?i.min.y-e.ab:t.max.y,u),p=[(e,t)=>d(e,t),(e,t)=>d(t,e),(e,t)=>_(e,t),(e,t)=>_(t,e)],f=(t,i,s,r,n,c,h)=>{if(!a)return 0;const u=[[c?s:t,c?t:s,0],[c?s:i,c?i:s,0]],d=h<0?e.ab+h:h,_=[c?d:(t+i)/2,c?(t+i)/2:d,0];return 0===s&&h<0||0!==s&&h>0?a.getForTilePoints(n,[_],!0,r):u.push(_),a.getForTilePoints(o,u,!0,l),Math.max(u[0][2],u[1][2],_[2])/a.exaggeration()};for(let t=0;t<4;t++){const i=s.borderFeatureIndices[t];if(0===i.length)continue;const r=e.c$[t](o),l=h(r);if(!(l&&l instanceof e.d0))continue;if(s.borderDoneWithNeighborZ[t]===l.canonical.z)continue;0===l.centroidVertexArray.length&&l.createCentroidsBuffer();const u=a?a.findDEMTileFor(r):null;if(!(u&&u.dem||n))continue;const d=(t<2?1:5)-t,_=l.borderDoneWithNeighborZ[d]!==s.canonical.z,v=l.borderFeatureIndices[d];let x=0;if(s.canonical.z!==l.canonical.z){for(const e of i)s.showCentroid(s.featuresOnBorder[e]);if(_)for(const e of v)l.showCentroid(l.featuresOnBorder[e]);s.borderDoneWithNeighborZ[t]=l.canonical.z,l.borderDoneWithNeighborZ[d]=s.canonical.z;}for(const o of i){const i=s.featuresOnBorder[o],a=s.centroidData[i.centroidDataIndex],h=i.borders[t];let _;for(;x<v.length;){_=l.featuresOnBorder[v[x]];const e=_.borders[d];if(e[1]>h[0]+3||e[0]>h[0]-3)break;l.showCentroid(_),x++;}if(_&&x<v.length){const o=x;let y=0;for(;!(_.borders[d][0]>h[1]-3)&&(y++,++x!==v.length);)_=l.featuresOnBorder[v[x]];_=l.featuresOnBorder[v[o]];let b=!1;if(y>=1){const e=_.borders[d];Math.abs(h[0]-e[0])<3&&Math.abs(h[1]-e[1])<3&&(y=1,b=!0,x=o+1);}else if(0===y){s.showCentroid(i);continue}const w=l.centroidData[_.centroidDataIndex];n&&b&&(((m=a).flags|(g=w).flags)&e.d1?(m.flags|=e.d1,g.flags|=e.d1):(m.flags&=~e.d1,g.flags&=~e.d1));const T=i.intersectsCount()>1||_.intersectsCount()>1;if(y>1)x=o,a.centroidXY=w.centroidXY=new e.P(0,0);else if(u&&u.dem&&!T){const i=p[t](a,w),o=t%2?e.ab-1:0,s=f(i[0],Math.min(e.ab-1,i[1]),o,u,r,t<2,i[2]);a.centroidXY=w.centroidXY=c(s);}else T?a.centroidXY=w.centroidXY=new e.P(0,0):(a.centroidXY=s.encodeBorderCentroid(i),w.centroidXY=l.encodeBorderCentroid(_));s.writeCentroidToBuffer(a),l.writeCentroidToBuffer(w);}else s.showCentroid(i);}s.borderDoneWithNeighborZ[t]=l.canonical.z,l.borderDoneWithNeighborZ[d]=s.canonical.z;}var m,g;(s.needsCentroidUpdate||!s.centroidVertexBuffer&&0!==s.centroidVertexArray.length)&&s.uploadCentroid(t);}const Ir=[1,0,0],Dr=[0,1,0],Rr=[0,0,1];function Ar(t,i,o){const s=o.transform,r=o.shadowRenderer;if(!r)return !0;const a=t.toUnwrapped(),n=s.tileSize*r._cascades[o.currentShadowCascade].scale;let l=i.maxHeight;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(a,l,n,c);if(!h)return !1;const u=[Ir,Dr,Rr,c,[c[0],0,c[2]],[0,c[1],c[2]]],d="globe"===s.projection.name,_=s.scaleZoom(n),p=e.bO.fromInvProjectionMatrix(s.invProjMatrix,s.worldSize,_,!d),f=r.getCurrentCascadeFrustum();return 0===p.intersectsPrecise(h.vertices,h.planes,u)||0===f.intersectsPrecise(h.vertices,h.planes,u)}function Lr(t){return [t[0]*e.d4,t[1]*e.d4,t[2]*e.d4,0]}function Pr(t,i,o,s,r,a,n,l,c){const h=s.getSource(),u=o.globeSharedBuffers;if(!u)return;let d,_,p;if(i&&(d=s.getTile(i)),h instanceof e.aD?(_=h.texture,p=e.cD(0,0,o.transform)):d&&i&&(_=d.texture,p=e.cD(i.canonical.z,i.canonical.x,o.transform)),!_||!p)return;t||(p=e.a6.mat4.scale(e.a6.mat4.create(),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(a),x=n.defines;x.push("GLOBE_POLES");const y=new Ai(m.LEQUAL,Ai.ReadWrite,o.depthRangeFor3D),b=Float32Array.from(o.transform.expandedFarZProjMatrix),w=Float32Array.from(e.b6(e.cC(new e.bQ(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&&f.extTextureFilterAnisotropic&&o.transform.pitch>20&&m.texParameterf(m.TEXTURE_2D,f.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,f.extTextureFilterAnisotropicMax);const[T,E,S,C]=i?u.getPoleBuffers(i.canonical.z,!1):u.getPoleBuffers(0,!0),I=r.paint.get("raster-elevation");let D;t?(D=T,o.renderDefaultNorthPole=0!==I):(D=E,o.renderDefaultSouthPole=0!==I);const R=Lr(n.mix),A=((e,t,i,o,s,r,a,n,l,c,h,u,d)=>Js(e,t,i,new Float32Array(16),new Float32Array(9),[0,0],o,[0,0],[0,0,0,0],1,{opacity:1,mix:0},r,[0,0]||[0,0],n,2,c,h,u,1,0,d))(b,w,p,e.a9(o.transform.zoom),0,r,0,I,0,R,n.offset,n.range,a),L=o.getOrCreateProgram("raster",{defines:x});o.uploadCommonUniforms(f,L,null),L.draw(o,m.TRIANGLES,y,c,v,l,A,r.id,D,S,C);}function Mr(e){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 zr(e,t,i,o){if(e)return t instanceof Ke&&e instanceof pt?t.getTextureDescriptor(e,i,!0):{texture:e.texture,mix:Lr(o.mix),offset:o.offset,buffer:0,tileSize:1}}var Or=e.d5([{name:"a_index",type:"Int16",components:1}]);class Fr{constructor(t,i,o,s){const r={width:o[0],height:o[1],data:null},a=t.gl;this.targetColorTexture=new e.T(t,r,a.RGBA8,{useMipmap:!1}),this.backgroundColorTexture=new e.T(t,r,a.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.d6;r.reserve(s);for(let e=0;e<s;e++)r.emplaceBack(e);this.particleIndexBuffer=this.context.createVertexBuffer(r,Or.members,!0),this.particleSegment=e.b2.simpleSegment(0,0,this.particleIndexBuffer.length,0),this.particleTextureDimension=i.width;}update(t){return !(this.lastInvalidatedAt<t&&(this.lastInvalidatedAt=e.q.now(),1))}destroy(){this.targetColorTexture.destroy(),this.backgroundColorTexture.destroy(),this.particleIndexBuffer.destroy(),this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleSegment.destroy();}}function Br(t,i,o){if(!t)return null;const s=i.getTextureDescriptor(t,o,!0);if(!s)return null;let{texture:r,mix:a,offset:n,tileSize:l,buffer:c,format:h}=s;if(!r||!h)return null;let u=!1;return "uint32"===h&&(u=!0,a[3]=0,a=$s(e.d7,a,[0,o.paint.get("raster-particle-max-speed")]),n=Xs(e.d7,n,[0,o.paint.get("raster-particle-max-speed")])),{texture:r,textureOffset:[c/(l+2*c),l/(l+2*c)],tileSize:l,scalarData:u,scale:a,offset:n,defines:["RASTER_ARRAY",{uint8:"DATA_FORMAT_UINT8",uint16:"DATA_FORMAT_UINT16",uint32:"DATA_FORMAT_UINT32"}[h]]}}function kr(e){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]}const Nr=new e.bA(1,0,0,1),Ur=new e.bA(0,1,0,1),Gr=new e.bA(0,0,1,1),Vr=new e.bA(1,0,1,1),jr=new e.bA(0,1,1,1);function Hr(t,i,o,s,r,a,n){const l=t.context,c=t.transform,h=l.gl,u="globe"===c.projection.name,d=u?["PROJECTION_GLOBE_VIEW"]:[];let _=e.a6.mat4.clone(o.projMatrix);if(u&&e.a9(c.zoom)>0){const t=e.b5(o.canonical,c),i=e.d8(t);_=e.a6.mat4.multiply(new Float32Array(16),c.globeMatrix,i),e.a6.mat4.multiply(_,c.projMatrix,_);}const p=e.a6.mat4.create();p[12]+=2*r/(e.q.devicePixelRatio*c.width),p[13]+=2*a/(e.q.devicePixelRatio*c.height),e.a6.mat4.multiply(_,p,_);const f=t.getOrCreateProgram("debug",{defines:d}),m=i.getTileByID(o.key);t.terrain&&t.terrain.setupElevationDraw(m,f);const g=Ai.disabled,v=Pi.disabled,x=t.colorModeForRenderPass(),y="$debug";l.activeTexture.set(h.TEXTURE0),t.emptyTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),u?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,x,Oi.disabled,Zs(_,s),y,b,w,T,null,null,null,[m._globeTileDebugBorderBuffer]),n){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,C=m._tileDebugTextBuffer||t.debugBuffer,I=m._tileDebugTextIndexBuffer||t.quadTriangleIndexBuffer,D=m._tileDebugTextSegments||t.debugSegments;f.draw(t,h.TRIANGLES,g,v,Ri.alphaBlended,Oi.disabled,Zs(_,e.bA.transparent,S),y,C,I,D,null,null,null,[m._globeTileDebugTextBuffer]);}function Zr(e,t,i,o){Wr(e,0,t+i/2,e.transform.width,i,o);}function qr(e,t,i,o){Wr(e,t-i/2,0,i,e.transform.height,o);}function Wr(t,i,o,s,r,a){const n=t.context,l=n.gl;l.enable(l.SCISSOR_TEST),l.scissor(i*e.q.devicePixelRatio,o*e.q.devicePixelRatio,s*e.q.devicePixelRatio,r*e.q.devicePixelRatio),n.clear({color:a}),l.disable(l.SCISSOR_TEST);}const $r=e.d5([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:Xr}=$r;function Jr(e,t,i,o){e.emplaceBack(t,i,o);}class Kr{constructor(t){this.vertexArray=new e.d9,this.indices=new e.aP,Jr(this.vertexArray,-1,-1,1),Jr(this.vertexArray,1,-1,1),Jr(this.vertexArray,-1,1,1),Jr(this.vertexArray,1,1,1),Jr(this.vertexArray,-1,-1,-1),Jr(this.vertexArray,1,-1,-1),Jr(this.vertexArray,-1,1,-1),Jr(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,Xr),this.indexBuffer=t.createIndexBuffer(this.indices),this.segment=e.b2.simpleSegment(0,0,36,12);}}function Yr(t,i,o,s,r,a){const n=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"),u=((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.a6.mat3.fromMat4(e.a6.mat3.create(),s),r,h,l,c);n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+a,i.skyboxTexture,0),o.draw(t,n.TRIANGLES,Ai.disabled,Pi.disabled,Ri.unblended,Oi.frontCW,u,"skyboxCapture",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment);}const Qr=e.d5([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class ea{constructor(t){const i=new e.da;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.aP;o.emplaceBack(0,1,2),o.emplaceBack(2,3,0),this.vertexBuffer=t.createVertexBuffer(i,Qr.members),this.indexBuffer=t.createIndexBuffer(o),this.segments=e.b2.simpleSegment(0,0,4,2);}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy();}}const ta=e.d5([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_size_scale",components:1},{type:"Float32",name:"a_fade_opacity",components:1}]);class ia{constructor(){this.starsCount=16e3,this.sizeMultiplier=.15,this.sizeRange=100,this.intensityRange=200;}}class oa{constructor(t){this.colorModeAlphaBlendedWriteRGB=new Ri([1,Di,1,Di],e.bA.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new Ri([1,0,1,0],e.bA.transparent,[!1,!1,!1,!0]),this.params=new ia,this.updateNeeded=!0,t.tp.registerParameter(this.params,["Stars"],"starsCount",{min:100,max:16e3,step:1},(()=>{this.updateNeeded=!0;})),t.tp.registerParameter(this.params,["Stars"],"sizeMultiplier",{min:.01,max:2,step:.01}),t.tp.registerParameter(this.params,["Stars"],"sizeRange",{min:0,max:200,step:1},(()=>{this.updateNeeded=!0;})),t.tp.registerParameter(this.params,["Stars"],"intensityRange",{min:0,max:200,step:1},(()=>{this.updateNeeded=!0;}));}update(t){const i=t.context;if(!this.atmosphereBuffer||this.updateNeeded){this.updateNeeded=!1,this.atmosphereBuffer=new ea(i);const t=this.params.sizeRange,o=this.params.intensityRange,s=function(t){const i=e.dd(30),o=[];for(let s=0;s<t;++s){const t=2*Math.PI*i(),s=Math.acos(1-2*i())-.5*Math.PI;o.push(e.a6.vec3.fromValues(Math.cos(s)*Math.cos(t),Math.cos(s)*Math.sin(t),Math.sin(s)));}return o}(this.params.starsCount),r=e.dd(300),a=new e.db,n=new e.aP;let l=0;for(let i=0;i<s.length;++i){const c=e.a6.vec3.scale([],s[i],200),h=Math.max(0,1+.01*t*(1*r()-.5)),u=Math.max(0,1+.01*o*(1*r()-.5));a.emplaceBack(c[0],c[1],c[2],-1,-1,h,u),a.emplaceBack(c[0],c[1],c[2],1,-1,h,u),a.emplaceBack(c[0],c[1],c[2],1,1,h,u),a.emplaceBack(c[0],c[1],c[2],-1,1,h,u),n.emplaceBack(l+0,l+1,l+2),n.emplaceBack(l+0,l+2,l+3),l+=4;}this.starsVx=i.createVertexBuffer(a,ta.members),this.starsIdx=i.createIndexBuffer(n),this.starsSegments=e.b2.simpleSegment(0,0,a.length,n.length);}}destroy(){this.atmosphereBuffer&&this.atmosphereBuffer.destroy(),this.starsVx&&this.starsVx.destroy(),this.starsIdx&&this.starsIdx.destroy();}drawAtmosphereGlow(t,i){const o=t.context,s=o.gl,r=t.transform,a=new Ai(s.LEQUAL,Ai.ReadOnly,[0,1]),n=e.a9(r.zoom),l=t.style.getLut(i.scope),c=i.properties.get("color").toRenderColor(l).toArray01(),h=i.properties.get("high-color").toRenderColor(l).toArray01(),u=i.properties.get("space-color").toRenderColor(l).toArray01PremultipliedAlpha(),d=5e-4,_=e.dc(i.properties.get("horizon-blend"),0,1,d,.25),p=e.cx(t,o,r)&&_===d?r.worldSize/(2*Math.PI*1.025)-1:r.globeRadius,f=t.frameCounter/1e3%1,m=e.a6.vec3.length(r.globeCenterInViewSpace),g=Math.sqrt(Math.pow(m,2)-Math.pow(p,2)),v=Math.acos(g/m),x=e=>{const i="globe"===r.projection.name?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];e&&i.push("ALPHA_PASS");const l=t.getOrCreateProgram("globeAtmosphere",{defines:i}),d=((e,t,i,o,s,r,a,n,l,c,h,u)=>({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:a,u_color:n,u_high_color:l,u_space_color:c,u_temporal_offset:h,u_horizon_angle:u}))(r.frustumCorners.TL,r.frustumCorners.TR,r.frustumCorners.BR,r.frustumCorners.BL,r.frustumCorners.horizon,n,_,c,h,u,f,v);t.uploadCommonUniforms(o,l);const p=this.atmosphereBuffer;p&&l.draw(t,s.TRIANGLES,a,Pi.disabled,e?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,Oi.backCW,d,e?"atmosphere_glow_alpha":"atmosphere_glow",p.vertexBuffer,p.indexBuffer,p.segments);};x(!1),x(!0);}drawStars(t,i){const o=e.ap(i.properties.get("star-intensity"),0,1);if(0===o)return;const s=t.context,r=s.gl,a=t.transform,n=t.getOrCreateProgram("stars"),l=e.a6.quat.identity([]);e.a6.quat.rotateX(l,l,-a._pitch),e.a6.quat.rotateZ(l,l,-a.angle),e.a6.quat.rotateX(l,l,e.bC(a._center.lat)),e.a6.quat.rotateY(l,l,-e.bC(a._center.lng));const c=e.a6.mat4.fromQuat(new Float32Array(16),l),h=e.a6.mat4.multiply([],a.starsProjMatrix,c),u=e.a6.mat3.fromMat4([],c),d=e.a6.mat3.invert([],u),_=[0,1,0];e.a6.vec3.transformMat3(_,_,d),e.a6.vec3.scale(_,_,this.params.sizeMultiplier);const p=[1,0,0];e.a6.vec3.transformMat3(p,p,d),e.a6.vec3.scale(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,n),this.starsVx&&this.starsIdx&&n.draw(t,r.TRIANGLES,Ai.disabled,Pi.disabled,this.colorModeAlphaBlendedWriteRGB,Oi.disabled,f,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments);}}function sa(t,i){const o=[...t],s=i.cameraWorldSizeForFog/i.worldSize,r=e.a6.mat4.identity([]);return e.a6.mat4.scale(r,r,[s,s,1]),e.a6.mat4.multiply(o,r,o),e.a6.mat4.multiply(o,i.worldToFogMatrix,o),o}function ra(t,i,o,s,r){const a=o.material,n=s.context,{baseColorTexture:l,metallicRoughnessTexture:c}=a.pbrMetallicRoughness,{normalTexture:h,occlusionTexture:u,emissionTexture:d}=a;function _(e,i,o){if(e&&(t.push(i),n.activeTexture.set(n.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",Gi.BaseColor),_(c,"HAS_TEXTURE_u_metallicRoughnessTexture",Gi.MetallicRoughness),_(h,"HAS_TEXTURE_u_normalTexture",Gi.Normal),_(u,"HAS_TEXTURE_u_occlusionTexture",Gi.Occlusion),_(d,"HAS_TEXTURE_u_emissionTexture",Gi.Emission),r&&(r.texture||(r.texture=new e.df(s.context,r.image,[r.image.height,r.image.height,r.image.height],n.gl.RGBA8)),n.activeTexture.set(n.gl.TEXTURE0+Gi.LUT),r.texture&&r.texture.bind(n.gl.LINEAR,n.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"!==a.alphaMode&&"MASK"!==a.alphaMode||t.push("UNPREMULT_TEXTURE_IN_SHADER"),a.defined||t.push("DIFFUSE_SHADED"),t.push("USE_STANDARD_DERIVATIVES");const p=s.shadowRenderer;p&&(t.push("RENDER_SHADOWS","DEPTH_TEXTURE"),p.useNormalOffset&&t.push("NORMAL_OFFSET"));}function aa(t,i,o,s,r,a){const n=o.paint.get("model-opacity"),l=i.context,c=new Ai(i.context.gl.LEQUAL,Ai.ReadWrite,i.depthRangeFor3D),h=i.transform,u=t.mesh,d=u.material,_=d.pbrMetallicRoughness,p=i.style.fog;let f;f="pixels"===i.transform.projection.zAxisUnit?[...t.nodeModelMatrix]:e.a6.mat4.multiply([],s.zScaleMatrix,t.nodeModelMatrix),e.a6.mat4.multiply(f,s.negCameraPosMatrix,f);const m=e.a6.mat4.invert([],f);e.a6.mat4.transpose(m,m);const g=o.paint.get("model-emissive-strength").constantOr(0),v=nr(new Float32Array(t.worldViewProjection),new Float32Array(f),new Float32Array(m),null,i,n,_.baseColorFactor.toRenderColor(null),d.emissiveFactor,_.metallicFactor,_.roughnessFactor,d,g,o),x={defines:[]},y=[],b=i.shadowRenderer;b&&(b.useNormalOffset=!1),ra(x.defines,y,u,i,o.lut);let w=null;if(p){const e=sa(t.nodeModelMatrix,i.transform);if(w=new Float32Array(e),"globe"!==h.projection.name){const t=u.aabb.min,i=u.aabb.max,[o,s]=p.getOpacityForBounds(e,t[0],t[1],i[0],i[1]);x.overrideFog=o>=ze||s>=ze;}}const T=qi(i,o.paint.get("model-cutoff-fade-range"));T.shouldRenderCutoff&&x.defines.push("RENDER_CUTOFF");const E=i.getOrCreateProgram("model",x);i.uploadCommonUniforms(l,E,null,w,T),"shadow"!==i.renderPass&&b&&b.setupShadowsFromMatrix(t.nodeModelMatrix,E),E.draw(i,l.gl.TRIANGLES,c,r,a,u.material.doubleSided?Oi.disabled:Oi.backCCW,v,o.id,u.vertexBuffer,u.indexBuffer,u.segments,o.paint,i.transform.zoom,void 0,y);}function na(t,i,o,s,r,a,n){let l;l="globe"===t.projection.name?e.dg(o,t):[...o],e.a6.mat4.multiply(l,l,i.matrix);const c=e.a6.mat4.multiply([],s,l);if(i.meshes)for(const t of i.meshes){if("BLEND"!==t.material.alphaMode){n.push({mesh:t,depth:0,modelIndex:r,worldViewProjection:c,nodeModelMatrix:l});continue}const i=e.a6.vec3.transformMat4([],t.centroid,c);i[2]>0&&a.push({mesh:t,depth:i[2],modelIndex:r,worldViewProjection:c,nodeModelMatrix:l});}if(i.children)for(const e of i.children)na(t,e,o,s,r,a,n);}function la(e,t,i,o){const s=i.shadowRenderer;if(!s)return;const r=s.getShadowPassDepthMode(),a=s.getShadowPassColorMode(),n=s.calculateShadowPassMatrixFromMatrix(t),l=lr(n);i.getOrCreateProgram("modelDepth",{defines:i._shadowMapDebug?[]:["DEPTH_TEXTURE"]}).draw(i,i.context.gl.TRIANGLES,r,Pi.disabled,a,Oi.backCCW,l,o.id,e.vertexBuffer,e.indexBuffer,e.segments,o.paint,i.transform.zoom,void 0,void 0);}function ca(t,i,o){const s=i.updateZoomBasedPaintProperties(),r=function(t,i,o){let s,r,a,n=t.terrain?t.terrain.exaggeration():0;if(t.terrain&&n>0){const i=t.terrain,r=i.findDEMTileFor(o);r&&r.dem?s=e.di.create(i,o,r):n=0;}if(0===n&&(i.terrainElevationMin=0,i.terrainElevationMax=0),n===i.validForExaggeration&&(0===n||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;e<t.instancedDataArray.length;++e){const o=(s?n*s.getElevationAt(0|t.instancedDataArray.float32[16*e],0|t.instancedDataArray.float32[16*e+1],!0,!0):0)+t.instancesEvaluatedElevation[e];t.instancedDataArray.float32[16*e+6]=o,r=r?Math.min(i.terrainElevationMin,o):o,a=a?Math.max(i.terrainElevationMax,o):o;}}return i.terrainElevationMin=r||0,i.terrainElevationMax=a||0,i.validForExaggeration=n,i.validForDEMTile=s&&s._demTile?{id:s._demTile.tileID,timestamp:s._dem._timestamp}:{id:void 0,timestamp:0},!0}(t,i,o);(s||r)&&(i.uploaded=!1,i.upload(t.context));}const ha={shadowUniformsInitialized:!1,useSingleShadowCascade:!1,tileMatrix:new Float64Array(16),shadowTileMatrix:new Float32Array(16),aabb:new e.ca([0,0,0],[e.ab,e.ab,0])};function ua(t,i){const o=1<<t.canonical.z,s=i.getFreeCameraOptions().position,r=i.elevation,a=t.canonical.x/o,n=(t.canonical.x+1)/o,l=t.canonical.y/o,c=(t.canonical.y+1)/o;let h=i._centerAltitude;if(r){const e=r.getMinMaxForTile(t);e&&e.max>h&&(h=e.max);}const u=e.ap(s.x,a,n)-s.x,d=e.ap(s.y,l,c)-s.y,_=e.bE(h,i.center.lat)-s.z;return i._zoomFromMercatorZ(Math.sqrt(u*u+d*d+_*_))}function da(e,t,i,o,s,r,a){const n=e.context,l="shadow"===e.renderPass,c=e.shadowRenderer,h=l&&c?c.getShadowPassDepthMode():new Ai(n.gl.LEQUAL,Ai.ReadWrite,e.depthRangeFor3D),u=e.isTileAffectedByFog(r);if(i.meshes)for(const d of i.meshes){const _=["MODEL_POSITION_ON_GPU"],p=[];let f,m,g;o.instancedDataArray.length>20&&_.push("INSTANCED_ARRAYS");const v=qi(e,t.paint.get("model-cutoff-fade-range"));if(v.shouldRenderCutoff&&_.push("RENDER_CUTOFF"),l&&c)f=e.getOrCreateProgram("modelDepth",{defines:_}),m=lr(a.shadowTileMatrix,a.shadowTileMatrix,Float32Array.from(i.matrix)),g=c.getShadowPassColorMode();else {ra(_,p,d,e,t.lut),f=e.getOrCreateProgram("model",{defines:_,overrideFog:u});const o=d.material,l=o.pbrMetallicRoughness,h=t.paint.get("model-opacity"),x=t.paint.get("model-emissive-strength").constantOr(0);m=nr(r.expandedProjMatrix,Float32Array.from(i.matrix),new Float32Array(16),null,e,h,l.baseColorFactor.toRenderColor(null),o.emissiveFactor,l.metallicFactor,l.roughnessFactor,o,x,t,s),c&&(a.shadowUniformsInitialized?f.setShadowUniformValues(n,c.getShadowUniformValues()):(c.setupShadows(r.toUnwrapped(),f,"model-tile",r.overscaledZ),a.shadowUniformsInitialized=!0)),g=v.shouldRenderCutoff||h<1||"OPAQUE"!==o.alphaMode?Ri.alphaBlended:Ri.unblended;}e.uploadCommonUniforms(n,f,r.toUnwrapped(),null,v);const x=d.material.doubleSided?Oi.disabled:Oi.backCCW;if(o.instancedDataArray.length>20)p.push(o.instancedDataBuffer),f.draw(e,n.gl.TRIANGLES,h,Pi.disabled,g,x,m,t.id,d.vertexBuffer,d.indexBuffer,d.segments,t.paint,e.transform.zoom,void 0,p,o.instancedDataArray.length);else {const i=l?"u_instance":"u_normal_matrix";for(let s=0;s<o.instancedDataArray.length;++s)m[i]=new Float32Array(o.instancedDataArray.arrayBuffer,64*s,16),f.draw(e,n.gl.TRIANGLES,h,Pi.disabled,g,x,m,t.id,d.vertexBuffer,d.indexBuffer,d.segments,t.paint,e.transform.zoom,void 0,p);}}if(i.children)for(const n of i.children)da(e,t,n,o,s,r,a);}const _a=[1,-1,1];function pa(t,i,o,s){if(!o.modelManager)return !0;const r=o.modelManager;if(!o.shadowRenderer)return !0;const a=o.shadowRenderer,n=i.aabb;let l=!0,c=t.maxHeight;if(0===c){let e=0;for(const i in t.instancesPerModel){const t=r.getModel(i,s);t?e=Math.max(e,Math.max(Math.max(t.aabb.max[0],t.aabb.max[1]),t.aabb.max[2])):l=!1;}c=t.maxScale*e*1.41+t.maxVerticalOffset,l&&(t.maxHeight=c);}n.max[2]=c,n.min[2]+=t.terrainElevationMin,n.max[2]+=t.terrainElevationMax,e.a6.vec3.transformMat4(n.min,n.min,i.tileMatrix),e.a6.vec3.transformMat4(n.max,n.max,i.tileMatrix);const h=n.intersects(a.getCurrentCascadeFrustum());return 0===o.currentShadowCascade&&(t.isInsideFirstShadowMapFrustum=2===h),0===h}function fa(t,i){const o=t.uniformValues.u_cutoff_params[0],s=t.uniformValues.u_cutoff_params[1],r=t.uniformValues.u_cutoff_params[2],a=t.uniformValues.u_cutoff_params[3];return s===o||a===r?1:e.ap(((i-o)/(s-o)-r)/(a-r),0,1)}function ma(t,i,o,s){if(i.pitch<20)return 1;const r=i.getWorldToCameraMatrix();e.a6.mat4.multiply(r,r,t);const a=e.a6.vec4.fromValues(o.min[0],o.min[1],o.min[2],1);let n=e.a6.vec4.transformMat4(e.a6.vec4.create(),a,r),l=n,c=n;a[1]=o.max[1],n=e.a6.vec4.transformMat4(e.a6.vec4.create(),a,r),l=n[1]<l[1]?n:l,c=n[1]>c[1]?n:c,a[0]=o.max[0],n=e.a6.vec4.transformMat4(e.a6.vec4.create(),a,r),l=n[1]<l[1]?n:l,c=n[1]>c[1]?n:c,a[1]=o.min[1],n=e.a6.vec4.transformMat4(e.a6.vec4.create(),a,r),l=n[1]<l[1]?n:l,c=n[1]>c[1]?n:c;const h=e.ap(s[0],0,1),u=100*i.pixelsPerMeter*e.ap(s[1],0,1),d=e.ap(s[2],0,1),_=e.a6.vec4.lerp(e.a6.vec4.create(),l,c,h),p=Math.tan(.5*i.fovX),f=-_[2]*p;if(0===u)return _[1]<-Math.abs(f)?d:1;const m=(-Math.abs(f)-_[1])/u,g=(e,t,i)=>(1-i)*e+i*t,v=e.ap(g(1,d,m),d,1);return g(1,v,e.ap((i.pitch-20)/20,0,1))}class ga{}class va{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),a=new ArrayBuffer(r),n=new Int16Array(a);s.getBufferSubData(s.ELEMENT_ARRAY_BUFFER,0,new Int16Array(a));const l=new e.dk;for(let e=0;e<r/2;e+=3){const t=n[e],i=n[e+1],o=n[e+2];l.emplaceBack(t,i),l.emplaceBack(i,o),l.emplaceBack(o,t);}const c=o.bindVertexArrayOES.current,h=new ga;return h.buf=new hr(o,l),h.lastUsedFrameIdx=t,this._storage.set(i.id,h),o.bindVertexArrayOES.set(c),h.buf}update(e){for(const[t,i]of this._storage)e-i.lastUsedFrameIdx>30&&(i.buf.destroy(),this._storage.delete(t));}destroy(){for(const[e,t]of this._storage)t.buf.destroy(),this._storage.delete(e);}}class xa{constructor(e){this.occluderSize=30,this.depthOffset=-1e-4,e.registerParameter(this,["Occlusion"],"occluderSize",{min:1,max:100,step:1}),e.registerParameter(this,["Occlusion"],"depthOffset",{min:-.05,max:0,step:1e-5});}}class ya{registerParameter(){}registerButton(){}registerBinding(){}refreshUI(){}}const ba={symbol:function(t,i,o,s,r){if("translucent"!==t.renderPass)return;const a=Pi.disabled,n=t.colorModeForRenderPass(),l=o.layout.get("text-variable-anchor"),c=o.layout.get("text-size-scale-range"),h=e.ap(t.scaleFactor,c[0],c[1]);l&&function(t,i,o,s,r,a,n,l){const c=i.transform,h="map"===r,u="map"===a;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 a=e.bk(r.textSizeData,c.zoom,l),d=ti(i,r.getProjection(),c),_=c.calculatePixelsToTileUnitsMatrix(t),p=Ft(d,t.tileID.canonical,u,h,c,r.getProjection(),_),f=r.hasIconTextFit()&&r.hasIconData();if(a){const o=Math.pow(2,c.zoom-t.tileID.overscaledZ);yr(r,h,u,n,e.cS,c,p,i,o,a,f);}}}(s,t,o,i,o.layout.get("text-rotation-alignment"),o.layout.get("text-pitch-alignment"),r,h);const u=0!==o.paint.get("icon-opacity").constantOr(1),d=0!==o.paint.get("text-opacity").constantOr(1);void 0!==o.layout.get("symbol-sort-key").constantOr(1)&&(u||d)?br(t,i,o,s,a,n):(u&&br(t,i,o,s,a,n,{onlyIcons:!0}),d&&br(t,i,o,s,a,n,{onlyText:!0})),i.map.showCollisionBoxes&&(mr(t,i,o,s,o.paint.get("text-translate"),o.paint.get("text-translate-anchor"),!0),mr(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"),a=o.paint.get("circle-stroke-width"),n=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===a.constantOr(1)||0===n.constantOr(1)))return;const h=t.context,u=h.gl,d=t.transform,_=t.depthModeForSublayer(0,Ai.ReadOnly),p=Pi.disabled,f=t.colorModeForDrapableLayerRenderPass(c),m="globe"===d.projection.name,g=[e.am(d.center.lng),e.at(d.center.lat)],v=[];for(let r=0;r<s.length;r++){const a=s[r],n=i.getTile(a),c=n.getBucket(o);if(!c||c.projection.name!==d.projection.name)continue;const h=c.programConfigurations.get(o.id),u=e.cT(o),_=t.isTileAffectedByFog(a);m&&u.push("PROJECTION_GLOBE_VIEW"),u.push("DEPTH_D24"),t.terrain&&d.depthOcclusionForSymbolsAndCircles&&u.push("DEPTH_OCCLUSION");const p=t.getOrCreateProgram("circle",{config:h,defines:u,overrideFog:_}),f=c.layoutVertexBuffer,x=c.globeExtVertexBuffer,y=c.indexBuffer,b=d.projection.createInversionMatrix(d,a.canonical),w={programConfiguration:h,program:p,layoutVertexBuffer:f,globeExtVertexBuffer:x,indexBuffer:y,uniformValues:e.cU(t,a,n,b,g,o),tile:n};if(l){const t=c.segments.get();for(const i of t)v.push({segments:new e.b2([i]),sortKey:i.sortKey,state:w});}else v.push({segments:c.segments,sortKey:0,state:w});}l&&v.sort(((e,t)=>e.sortKey-t.sortKey));const x={useDepthForOcclusion:d.depthOcclusionForSymbolsAndCircles};for(const e of v){const{programConfiguration:i,program:s,layoutVertexBuffer:r,globeExtVertexBuffer:a,indexBuffer:n,uniformValues:l,tile:c}=e.state,m=e.segments;t.terrain&&t.terrain.setupElevationDraw(c,s,x),t.uploadCommonUniforms(h,s,c.tileID.toUnwrapped()),s.draw(t,u.TRIANGLES,_,p,f,Oi.disabled,l,o.id,r,n,m,o.paint,d.zoom,i,[a]);}},heatmap:function(t,i,o,s){if(0!==o.paint.get("heatmap-opacity"))if("offscreen"===t.renderPass){const r=t.context,a=r.gl,n=Pi.disabled,l=new Ri([a.ONE,a.ONE,a.ONE,a.ONE],e.bA.transparent,[!0,!0,!0,!0]);!function(e,t,i,o){const s=e.gl,r=t.width*o,a=t.height*o;e.activeTexture.set(s.TEXTURE1),e.viewport.set([0,0,r,a]);let n=i.heatmapFbo;if(!n||n&&(n.width!==r||n.height!==a)){n&&n.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),n=i.heatmapFbo=e.createFramebuffer(r,a,!0,null),function(e,t,i,o,s,r){const a=e.gl;a.texImage2D(a.TEXTURE_2D,0,e.extRenderToTextureHalfFloat?a.RGBA16F:a.RGBA,s,r,0,a.RGBA,e.extRenderToTextureHalfFloat?a.HALF_FLOAT:a.UNSIGNED_BYTE,null),o.colorAttachment.set(i);}(e,0,t,n,r,a);}else s.bindTexture(s.TEXTURE_2D,n.colorAttachment.get()),e.bindFramebuffer.set(n.framebuffer);}(r,t,o,"globe"===t.transform.projection.name?.5:.25),r.clear({color:e.bA.transparent});const c=t.transform,h="globe"===c.projection.name,u=h?["PROJECTION_GLOBE_VIEW"]:[],d=h?Oi.frontCCW:Oi.disabled,_=[e.am(c.center.lng),e.at(c.center.lat)];for(let e=0;e<s.length;e++){const p=s[e];if(i.hasRenderableParent(p))continue;const f=i.getTile(p),m=f.getBucket(o);if(!m||m.projection.name!==c.projection.name)continue;const g=t.isTileAffectedByFog(p),v=m.programConfigurations.get(o.id),x=t.getOrCreateProgram("heatmap",{config:v,defines:u,overrideFog:g}),{zoom:y}=t.transform;t.terrain&&t.terrain.setupElevationDraw(f,x),t.uploadCommonUniforms(r,x,p.toUnwrapped());const b=c.projection.createInversionMatrix(c,p.canonical);x.draw(t,a.TRIANGLES,Ai.disabled,n,l,d,Ws(t,p,f,b,_,y,o.paint.get("heatmap-intensity")),o.id,m.layoutVertexBuffer,m.indexBuffer,m.segments,o.paint,t.transform.zoom,v,h?[m.globeExtVertexBuffer]:null);}r.viewport.set([0,0,t.width,t.height]);}else "translucent"===t.renderPass&&(t.context.setColorMode(t.colorModeForRenderPass()),function(t,i){const o=t.context,s=o.gl,r=i.heatmapFbo;if(!r)return;o.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,r.colorAttachment.get()),o.activeTexture.set(s.TEXTURE1);let a=i.colorRampTexture;a||(a=i.colorRampTexture=new e.T(o,i.colorRamp,s.RGBA8)),a.bind(s.LINEAR,s.CLAMP_TO_EDGE),t.getOrCreateProgram("heatmapTexture").draw(t,s.TRIANGLES,Ai.disabled,Pi.disabled,t.colorModeForRenderPass(),Oi.disabled,((e,t,i,o)=>({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"),a=o.paint.get("line-width");if(0===r.constantOr(1)||0===a.constantOr(1))return;const n=o.paint.get("line-emissive-strength"),l=o.paint.get("line-occlusion-opacity"),c="sea"===o.layout.get("line-elevation-reference"),h=t.context,u=h.gl,d=!o.isDraped();if(d&&"globe"===t.transform.projection.name)return;const _=o.layout.get("line-cross-slope"),p=void 0!==_,f=_<1,m=d?new Ai(t.depthOcclusion?u.GREATER:u.LEQUAL,Ai.ReadOnly,t.depthRangeFor3D):t.depthModeForSublayer(0,Ai.ReadOnly),g=t.colorModeForDrapableLayerRenderPass(n),v=t.terrain&&t.terrain.renderingToTexture,x=v?1:e.q.devicePixelRatio,y=o.paint.get("line-dasharray"),b=y.constantOr(1),w=o.layout.get("line-cap"),T=y.constantOr(null),E=w.constantOr(null),S=o.paint.get("line-pattern"),C=S.constantOr(1),I=S.constantOr(null),D=o.paint.get("line-opacity").constantOr(1);let R=!C&&1!==D||t.depthOcclusion&&l>0&&l<1;const A=o.paint.get("line-gradient"),L=C?"linePattern":"line",P=e.cV(o);let M;if(v&&t.terrain&&t.terrain.clipOrMaskOverlapStencilType()&&(R=!1),0!==l&&t.depthOcclusion){const t=o.paint._values["line-opacity"];t&&t.value&&"constant"===t.value.kind?M=t.value:e.w(`Occlusion opacity for layer ${o.id} is supported only when line-opacity isn't data-driven.`);}if(d&&(t.forceTerrainMode=!0),!d&&0!==l&&t.terrain&&!v)return void e.w(`Occlusion opacity for layer ${o.id} is supported on terrain only if the layer has line-z-offset enabled.`);const z=R&&d?t.stencilModeFor3D():Pi.disabled;d&&(P.push("ELEVATED"),p&&P.push(f?"CROSS_SLOPE_HORIZONTAL":"CROSS_SLOPE_VERTICAL"),c&&P.push("ELEVATION_REFERENCE_SEA"));for(const r of s){const s=i.getTile(r);if(C&&!s.patternsLoaded())continue;const a=s.getBucket(o);if(!a)continue;t.prepareDrawTile();const n=a.programConfigurations.get(o.id),_=t.isTileAffectedByFog(r),p=t.getOrCreateProgram(L,{config:n,defines:P,overrideFog:_,overrideRtt:!d&&void 0});if(I&&s.imageAtlas){const e=s.imageAtlas.patternPositions[I.toString()];e&&n.setConstantPatternPositions(e);}if(!C&&T&&E&&s.lineAtlas){const e=s.lineAtlas.getDash(T,E);e&&n.setConstantPatternPositions(e);}let[f,y]=o.paint.get("line-trim-offset");if("round"===E||"square"===E){const e=1;f!==y&&(0===f&&(f-=e),1===y&&(y+=e));}const w=v?r.projMatrix:null,S=C?e.cW(t,s,o,w,x,[f,y]):e.cX(t,s,o,w,a.lineClipsArray.length,x,[f,y]);if(A){const s=a.gradients[o.id];let n=s.texture;if(o.gradientVersion!==s.version){let l=256;if(o.stepInterpolant){const o=i.getSource().maxzoom,s=r.canonical.z===o?Math.ceil(1<<t.transform.maxZoom-r.canonical.z):1;l=e.ap(e.cY(a.maxLineLength/e.ab*1024*s),256,h.maxTextureSize);}s.gradient=e.cZ({expression:o.gradientExpression(),evaluationKey:"lineProgress",resolution:l,image:s.gradient||void 0,clips:a.lineClipsArray}),s.texture?s.texture.update(s.gradient):s.texture=new e.T(h,s.gradient,u.RGBA8),s.version=o.gradientVersion,n=s.texture;}h.activeTexture.set(u.TEXTURE1),n.bind(o.stepInterpolant?u.NEAREST:u.LINEAR,u.CLAMP_TO_EDGE);}b&&(h.activeTexture.set(u.TEXTURE0),s.lineAtlasTexture&&s.lineAtlasTexture.bind(u.LINEAR,u.REPEAT),n.updatePaintBuffers()),C&&(h.activeTexture.set(u.TEXTURE0),s.imageAtlasTexture&&s.imageAtlasTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),n.updatePaintBuffers()),d&&!c&&t.terrain.setupElevationDraw(s,p),t.uploadCommonUniforms(h,p,r.toUnwrapped());const O=e=>{null!=M&&(M.value=D*l),p.draw(t,u.TRIANGLES,m,e,g,Oi.disabled,S,o.id,a.layoutVertexBuffer,a.indexBuffer,a.segments,o.paint,t.transform.zoom,n,[a.layoutVertexBuffer2,a.patternVertexBuffer,a.zOffsetVertexBuffer]),null!=M&&(M.value=D);};if(R&&!d){const e=t.stencilModeForClipping(r).ref;0===e&&v&&h.clear({stencil:0});const i={func:u.EQUAL,mask:255};S.u_alpha_discard_threshold=.8,O(new Pi(i,e,255,u.KEEP,u.KEEP,u.INVERT)),S.u_alpha_discard_threshold=0,O(new Pi(i,e,255,u.KEEP,u.KEEP,u.KEEP));}else R&&d&&(S.u_alpha_discard_threshold=.001),O(d?z:t.stencilModeForClipping(r));}d&&(t.forceTerrainMode=!1),R&&(t.resetStencilClippingMasks(),v&&h.clear({stencil:0})),0===l||t.depthOcclusion||v||t.layersWithOcclusionOpacity.push(t.currentLayer);},fill:function(t,i,o,s){const r=o.paint.get("fill-color"),a=o.paint.get("fill-opacity"),n=o.is3D(),l=new Ai(t.context.gl.LEQUAL,Ai.ReadWrite,t.depthRangeFor3D);if(0===a.constantOr(1))return;const c=o.paint.get("fill-emissive-strength"),h=t.colorModeForDrapableLayerRenderPass(c),u=o.paint.get("fill-pattern"),d=t.opaquePassEnabledForLayer()&&!u.constantOr(1)&&1===r.constantOr(e.bA.transparent).a&&1===a.constantOr(0)?"opaque":"translucent";if(t.renderPass===d){const e=n?l:t.depthModeForSublayer(1,"opaque"===t.renderPass?Ai.ReadWrite:Ai.ReadOnly);Tr(t,i,o,s,e,h,!1);}if(!n&&"translucent"===t.renderPass&&o.paint.get("fill-antialias")){const e=n?l:t.depthModeForSublayer(o.getPaintProperty("fill-outline-color")?2:0,Ai.ReadOnly);Tr(t,i,o,s,e,h,!0);}},"fill-extrusion":function(t,i,o,s){const r=o.paint.get("fill-extrusion-opacity"),a=t.context,n=a.gl,l=t.terrain,c=l&&l.renderingToTexture;if(0===r)return;const h=t.conflationActive&&t.style.isLayerClipped(o,i.getSource()),u=t.style.order.indexOf(o.fqid);if(h&&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||h)for(const e of s){const s=i.getTile(e).getBucket(o);s&&Cr(t.context,i,e,s,o,l,h);}if("shadow"===t.renderPass&&t.shadowRenderer){const a=t.shadowRenderer;if(l&&r<.65&&o._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof e.a4)return;const n=a.getShadowPassDepthMode(),c=a.getShadowPassColorMode();Er(t,i,o,s,n,Pi.disabled,c,h);}else if("translucent"===t.renderPass){const u=!o.paint.get("fill-extrusion-pattern").constantOr(1),d=o.paint.get("fill-extrusion-color").constantOr(e.bA.white);if(!c&&0!==d.a){const e=new Ai(t.context.gl.LEQUAL,Ai.ReadWrite,t.depthRangeFor3D);1===r&&u?Er(t,i,o,s,e,Pi.disabled,Ri.unblended,h):(Er(t,i,o,s,e,Pi.disabled,Ri.disabled,h),Er(t,i,o,s,e,t.stencilModeFor3D(),t.colorModeForRenderPass(),h),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"),d=o.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),_=o.paint.get("fill-extrusion-flood-light-intensity"),p=o.paint.get("fill-extrusion-flood-light-color").toRenderColor(o.lut).toArray01().slice(0,3),f=u>0&&d>0,m=_>0,g=(e,t,i)=>(1-i)*e+i*t,v=a=>{const l=t.depthModeForSublayer(1,Ai.ReadOnly,n.LEQUAL,!0),c=o.paint.get(a?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),f=g(.1,3,c),m=t._showOverdrawInspector;if(!m){const c=new Pi({func:n.ALWAYS,mask:255},255,255,n.KEEP,n.KEEP,n.REPLACE),m=new Ri([n.ONE,n.ONE,n.ONE,n.ONE],e.bA.transparent,[!1,!1,!1,!0],n.MIN);Sr(t,i,o,s,l,c,m,Oi.disabled,a,"sdf",r,u,d,_,p,f,h,!1);}{const c=m?Pi.disabled:new Pi({func:n.EQUAL,mask:255},255,255,n.KEEP,n.DECR,n.DECR),g=m?t.colorModeForRenderPass():new Ri([n.ONE_MINUS_DST_ALPHA,n.DST_ALPHA,n.ONE,n.ONE],e.bA.transparent,[!0,!0,!0,!0]);Sr(t,i,o,s,l,c,g,Oi.disabled,a,"color",r,u,d,_,p,f,h,!1);}};if(c){const c=(a,l,c)=>{const f=t.depthModeForSublayer(1,Ai.ReadOnly,n.LEQUAL,!1),m=o.paint.get(a?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),v=g(.1,3,m);{const c=new Ri([n.ONE,n.ONE,n.ONE,n.ONE],e.bA.transparent,[!1,!1,!1,!0]);Sr(t,i,o,s,f,Pi.disabled,c,Oi.disabled,a,"clear",r,u,d,_,p,v,h,l);}{const c=new Pi({func:n.ALWAYS,mask:255},255,255,n.KEEP,n.KEEP,n.REPLACE),m=new Ri([n.ONE,n.ONE,n.ONE,n.ONE],e.bA.transparent,[!1,!1,!1,!0],n.MIN);Sr(t,i,o,s,f,c,m,Oi.disabled,a,"sdf",r,u,d,_,p,v,h,l);}{const c=a?n.ZERO:n.ONE_MINUS_DST_ALPHA,m=new Pi({func:n.EQUAL,mask:255},255,255,n.KEEP,n.DECR,n.DECR),g=new Ri([c,n.DST_ALPHA,n.ONE_MINUS_DST_ALPHA,n.ZERO],e.bA.transparent,[!0,!0,!0,!0]);Sr(t,i,o,s,f,m,g,Oi.disabled,a,"color",r,u,d,_,p,v,h,l);}{const m=new Ri([n.ONE,n.ONE,n.ONE,a?n.ZERO:n.ONE],e.bA.transparent,[!1,!1,!1,!0],a?n.FUNC_ADD:n.MAX);Sr(t,i,o,s,f,Pi.disabled,m,Oi.disabled,a,"clear",r,u,d,_,p,v,h,l,c);}};if(f||m){let i;if(t.prepareDrawTile(),l){const t=l.drapeBufferSize[0],o=l.drapeBufferSize[1];i=l.framebufferCopyTexture,i&&(!i||i.size[0]===t&&i.size[1]===o)||(i&&i.destroy(),i=l.framebufferCopyTexture=new e.T(a,new e.r({width:t,height:o}),n.RGBA8)),i.bind(n.LINEAR,n.CLAMP_TO_EDGE),n.copyTexSubImage2D(n.TEXTURE_2D,0,0,0,0,0,t,o);}f&&c(!0,!1,i),m&&c(!1,!0,i);}}else f&&v(!0),m&&v(!1),(f||m)&&t.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,[a,n]="translucent"!==e.renderPass||r?[{},o]:e.stencilConfigForOverlap(o);for(const o of n){const s=t.getTile(o);if(s.needsHillshadePrepare&&"offscreen"===e.renderPass)Mo(e,s,i);else if("translucent"===e.renderPass){const t=e.depthModeForSublayer(0,Ai.ReadOnly),n=i.paint.get("hillshade-emissive-strength"),l=e.colorModeForDrapableLayerRenderPass(n),c=r&&e.terrain?e.terrain.stencilModeForRTTOverlap(o):a[o.overscaledZ];Lo(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,a){if("translucent"!==t.renderPass)return;if(0===o.paint.get("raster-opacity"))return;const n="globe"===t.transform.projection.name,l=0!==o.paint.get("raster-elevation"),c=l&&n;if(t.renderElevatedRasterBackface&&!c)return;const h=t.context,u=h.gl,d=i.getSource(),_=function(t,i,o,s){const r=i.paint.get("raster-color"),a="raster-array"===t.type,n=[],l=i.paint.get("raster-resampling"),c=i.paint.get("raster-color-mix");let h=i.paint.get("raster-color-range");const u=[c[0],c[1],c[2],0],d=c[3];let _="nearest"===l?s.NEAREST:s.LINEAR;if(a&&(n.push("RASTER_ARRAY"),r||n.push("RASTER_COLOR"),"linear"===l&&n.push("RASTER_ARRAY_LINEAR"),_=s.NEAREST,!h&&t.rasterLayers)){const e=t.rasterLayers.find((({id:e})=>e===i.sourceLayer));e&&e.fields&&e.fields.range&&(h=e.fields.range);}if(h=h||[0,1],r){n.push("RASTER_COLOR"),o.activeTexture.set(s.TEXTURE2),i.updateColorRamp(h);let t=i.colorRampTexture;t||(t=i.colorRampTexture=new e.T(o,i.colorRamp,s.RGBA8)),t.bind(s.LINEAR,s.CLAMP_TO_EDGE);}return {mix:u,range:h,offset:d,defines:n,resampling:_}}(d,o,h,u);if(d instanceof e.aD&&!s.length&&!n)return;const p=o.paint.get("raster-emissive-strength"),f=t.colorModeForDrapableLayerRenderPass(p),m=t.terrain&&t.terrain.renderingToTexture,g=!t.options.moving,v="nearest"===o.paint.get("raster-resampling")?u.NEAREST:u.LINEAR;if(d instanceof e.aD&&!s.length&&(d.onNorthPole||d.onSouthPole)){const e=l?t.stencilModeFor3D():Pi.disabled;return void Pr(!!d.onNorthPole,null,t,i,o,p,_,Oi.disabled,e)}if(!s.length)return;const[x,y]=d instanceof e.aD||m?[{},s]:t.stencilConfigForOverlap(s),b=y[y.length-1].overscaledZ;c&&_.defines.push("PROJECTION_GLOBE_VIEW"),l&&_.defines.push("RENDER_CUTOFF");const w=(s,r,y)=>{for(const w of s){const s=w.toUnwrapped(),T=i.getTile(w);if(m&&(!T||!T.hasData()))continue;h.activeTexture.set(u.TEXTURE0);const E=zr(T,d,o,_);if(!E||!E.texture)continue;const{texture:S,mix:C,offset:I,tileSize:D,buffer:R}=E;let A,L;m?(A=Ai.disabled,L=w.projMatrix):l?(A=new Ai(u.LEQUAL,Ai.ReadWrite,t.depthRangeFor3D),L=n?Float32Array.from(t.transform.expandedFarZProjMatrix):t.transform.calculateProjMatrix(s,g)):(A=t.depthModeForSublayer(w.overscaledZ-b,1===o.paint.get("raster-opacity")?Ai.ReadWrite:Ai.ReadOnly,u.LESS),L=t.transform.calculateProjMatrix(s,g));const P=t.terrain&&m?t.terrain.stencilModeForRTTOverlap(w):x[w.overscaledZ],M=a?0:o.paint.get("raster-fade-duration");T.registerFadeDuration(M);const z=i.findLoadedParent(w,0),O=Ss(T,z,i,t.transform,M);let F,B;t.terrain&&t.terrain.prepareDrawTile(),h.activeTexture.set(u.TEXTURE0),S.bind(v,u.CLAMP_TO_EDGE),h.activeTexture.set(u.TEXTURE1),z?(z.texture&&z.texture.bind(v,u.CLAMP_TO_EDGE),F=Math.pow(2,z.tileID.overscaledZ-T.tileID.overscaledZ),B=[T.tileID.canonical.x*F%1,T.tileID.canonical.y*F%1]):S.bind(v,u.CLAMP_TO_EDGE),S.useMipmap&&h.extTextureFilterAnisotropic&&t.transform.pitch>20&&u.texParameterf(u.TEXTURE_2D,h.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,h.extTextureFilterAnisotropicMax);const k=t.transform;let N;const U=l?Mr(k):[0,0,0,0];let G,V,j,H,Z,q=0;if(c&&d instanceof e.aD&&d.coordinates.length>3)G=Float32Array.from(e.b6(e.cC(new e.bQ(0,0,0)))),V=Float32Array.from(k.globeMatrix),j=Float32Array.from(e.cy(k)),H=[e.am(k.center.lng),e.at(k.center.lat)],N=d.elevatedGlobePerspectiveTransform,Z=d.elevatedGlobeGridMatrix||new Float32Array(9);else if(c){const t=e.cz(w.canonical);q=e.cA(t.getCenter().lat),G=Float32Array.from(e.b6(e.cC(w.canonical))),V=Float32Array.from(k.globeMatrix),j=Float32Array.from(e.cy(k)),H=[e.am(k.center.lng),e.at(k.center.lat)],N=[0,0],Z=Float32Array.from(e.cB(w.canonical,t,q,k.worldSize/k._pixelsPerMercatorPixel));}else N=d instanceof e.aD?d.perspectiveTransform:[0,0],G=new Float32Array(16),V=new Float32Array(9),j=new Float32Array(16),H=[0,0],Z=new Float32Array(9);const W=Js(L,G,V,j,Z,B||[0,0],e.a9(t.transform.zoom),H,U,F||1,O,o,N,l?o.paint.get("raster-elevation"):0,2,C,I,_.range,D,R,p),$=t.isTileAffectedByFog(w),X=t.getOrCreateProgram("raster",{defines:_.defines,overrideFog:$});if(t.uploadCommonUniforms(h,X,s),d instanceof e.aD){const i=d.elevatedGlobeVertexBuffer,s=d.elevatedGlobeIndexBuffer;if(m||!n)d.boundsBuffer&&d.boundsSegments&&X.draw(t,u.TRIANGLES,A,Pi.disabled,f,Oi.disabled,W,o.id,d.boundsBuffer,t.quadTriangleIndexBuffer,d.boundsSegments);else if(i&&s){const a=k.zoom<=e.c3?d.elevatedGlobeSegments:d.getSegmentsForLongitude(k.center.lng);a&&X.draw(t,u.TRIANGLES,A,Pi.disabled,f,r,W,o.id,i,s,a);}}else if(c){A=new Ai(u.LEQUAL,Ai.ReadOnly,t.depthRangeFor3D);const e=t.globeSharedBuffers;if(e){const[i,s,a]=e.getGridBuffers(q,!1);X.draw(t,u.TRIANGLES,A,y||P,t.colorModeForRenderPass(),r,W,o.id,i,s,a);}}else {const{tileBoundsBuffer:e,tileBoundsIndexBuffer:i,tileBoundsSegments:s}=t.getTileBoundsBuffers(T);X.draw(t,u.TRIANGLES,A,P,f,Oi.disabled,W,o.id,e,i,s);}}if(!(d instanceof e.aD)&&c)for(const e of s){const s=e.canonical.y===(1<<e.canonical.z)-1;0===e.canonical.y&&Pr(!0,e,t,i,o,p,_,r,y||Pi.disabled),s&&Pr(!1,e,t,i,o,p,_,r===Oi.frontCW?Oi.backCW:Oi.frontCW,y||Pi.disabled);}};c?w(y,t.renderElevatedRasterBackface?Oi.backCW:Oi.frontCW,t.stencilModeFor3D()):w(y,Oi.disabled,void 0),t.resetStencilClippingMasks();},"raster-particle":function(t,i,o,s,r,a){"offscreen"===t.renderPass&&function(t,i,o,s){if(!s.length)return;const r=t.context,a=r.gl,n=i.getSource();if(!(n instanceof Ke))return;const l=Math.ceil(Math.sqrt(o.paint.get("raster-particle-count")));let c=o.particlePositionRGBAImage;if(!c||c.width!==l){const t=function(e){const t=e*e,i=new Uint8Array(4*t),o=function(e){return e|=0,e=Math.imul(2747636419^e,2654435769),e=Math.imul(e^e>>>16,2654435769),((e=Math.imul(e^e>>>16,2654435769))>>>0)/4294967296},s=1/1.1;for(let e=0;e<t;e++){const t=s*(o(2*e+0)+Ys),r=s*(o(2*e+1)+Ys),a=255*t%1,n=255*r%1,l=a,c=r-n/255,h=n;i[4*e+0]=255*(t-a/255),i[4*e+1]=255*l,i[4*e+2]=255*c,i[4*e+3]=255*h;}return i}(l);c=o.particlePositionRGBAImage=new e.r({width:l,height:l},t);}let h=o.particleFramebuffer;h?h.width!==l&&(h.destroy(),h=o.particleFramebuffer=r.createFramebuffer(l,l,!0,null)):h=o.particleFramebuffer=r.createFramebuffer(l,l,!0,null);const u=[];for(const e of s){const t=i.getTile(e);if(!(t instanceof pt))continue;const s=Br(t,n,o);if(!s)continue;const a=[t.tileSize,t.tileSize];let h=o.tileFramebuffer;h||(h=o.tileFramebuffer=r.createFramebuffer(a[0],a[1],!0,null));let d=t.rasterParticleState;d||(d=t.rasterParticleState=new Fr(r,e,a,c));const _=d.update(o.lastInvalidatedAt);d.particleTextureDimension!==l&&d.updateParticleTexture(e,c);const p=d.targetColorTexture;d.targetColorTexture=d.backgroundColorTexture,d.backgroundColorTexture=p;const f=d.particleTexture0;d.particleTexture0=d.particleTexture1,d.particleTexture1=f,u.push([e,s,d,_]);}if(0===u.length)return;const d=e.q.now(),_=o.previousDrawTimestamp?.001*(d-o.previousDrawTimestamp):.0167;if(o.previousDrawTimestamp=d,o.hasColorMap()){r.activeTexture.set(a.TEXTURE0+2);let t=o.colorRampTexture;t||(t=o.colorRampTexture=new e.T(r,o.colorRamp,a.RGBA8)),t.bind(a.LINEAR,a.CLAMP_TO_EDGE);}r.bindFramebuffer.set(o.tileFramebuffer.framebuffer),function(t,i,o){const s=t.context,r=s.gl,a=i.tileFramebuffer;s.activeTexture.set(r.TEXTURE0);const n={u_texture:0,u_opacity:1.05*(c=i.paint.get("raster-particle-fade-opacity-factor"))/(c+.05)},l=t.getOrCreateProgram("rasterParticleTexture",{defines:[],overrideFog:!1});var c;for(const c of o){const[,,o,h]=c;a.colorAttachment.set(o.targetColorTexture.texture),s.viewport.set([0,0,a.width,a.height]),s.clear({color:e.bA.transparent}),h&&(o.backgroundColorTexture.bind(r.NEAREST,r.CLAMP_TO_EDGE),l.draw(t,r.TRIANGLES,Ai.disabled,Pi.disabled,Ri.alphaBlended,Oi.disabled,n,i.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments));}}(t,o,u),function(t,i,o,s){const r=t.context,a=r.gl,n=o.tileFramebuffer,l="globe"===t.transform.projection.name,c=o.paint.get("raster-particle-max-speed");for(const h of s){const[s,u,d]=h;r.activeTexture.set(a.TEXTURE0+0),u.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE),n.colorAttachment.set(d.targetColorTexture.texture);const _=t.getOrCreateProgram("rasterParticleDraw",{defines:u.defines,overrideFog:!1});r.activeTexture.set(a.TEXTURE0+1);const p=u.scalarData?[]:[0,1,2,3].map((t=>e.c$[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 n=r.rasterParticleState;if(!n)continue;const h=e.canonical.x+(1<<e.canonical.z)*(e.wrap-s.wrap),d=e.canonical.y;n.particleTexture0.bind(a.NEAREST,a.CLAMP_TO_EDGE);const p=er(1,n.particleTexture0.size[0],[h-f,d-m],0,u.texture.size,2,c,u.textureOffset,u.scale,u.offset);_.draw(t,a.POINTS,Ai.disabled,Pi.disabled,Ri.alphaBlended,Oi.disabled,p,o.id,n.particleIndexBuffer,void 0,n.particleSegment);}}}(t,i,o,u),r.bindFramebuffer.set(o.particleFramebuffer.framebuffer),function(t,i,o,s){const r=t.context,a=r.gl,n=i.paint.get("raster-particle-max-speed"),l=s*i.paint.get("raster-particle-speed-factor")*.15,c=function(e){return Math.pow(e,6)}(.01+1*i.paint.get("raster-particle-reset-rate-factor")),h=i.particleFramebuffer;r.viewport.set([0,0,h.width,h.height]);for(const s of o){const[,o,u]=s;r.activeTexture.set(a.TEXTURE0+0),o.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE),r.activeTexture.set(a.TEXTURE0+1);const d=u.particleTexture0;d.bind(a.NEAREST,a.CLAMP_TO_EDGE);const _=tr(1,d.size[0],0,o.texture.size,n,l,c,o.textureOffset,o.scale,o.offset);h.colorAttachment.set(u.particleTexture1.texture),r.clear({color:e.bA.transparent}),t.getOrCreateProgram("rasterParticleUpdate",{defines:o.defines}).draw(t,a.TRIANGLES,Ai.disabled,Pi.disabled,Ri.unblended,Oi.disabled,_,i.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments);}}(t,o,u,_);}(t,i,o,s),"translucent"===t.renderPass&&(function(t,i,o,s,r){const a=t.context,n=a.gl,l=i.getSource().tileSize,c=5*(1-e.a7(e.bV,e.bV+1,t.transform.zoom))*l+o.paint.get("raster-particle-elevation"),h=!t.options.moving,u="globe"===t.transform.projection.name;if(!s.length)return;const[d,_]=t.stencilConfigForOverlap(s),p=[];u&&p.push("PROJECTION_GLOBE_VIEW");const f=t.stencilModeFor3D();for(const s of _){const r=s.toUnwrapped(),l=i.getTile(s);if(!l.rasterParticleState)continue;const _=l.rasterParticleState,m=100;l.registerFadeDuration(m);const g=i.findLoadedParent(s,0),v=Ss(l,g,i,t.transform,m);let x,y;t.terrain&&t.terrain.prepareDrawTile(),a.activeTexture.set(n.TEXTURE0),_.targetColorTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE),a.activeTexture.set(n.TEXTURE1),g&&g.rasterParticleState?(g.rasterParticleState.targetColorTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE),x=Math.pow(2,g.tileID.overscaledZ-l.tileID.overscaledZ),y=[l.tileID.canonical.x*x%1,l.tileID.canonical.y*x%1]):_.targetColorTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE);const b=u?Float32Array.from(t.transform.expandedFarZProjMatrix):t.transform.calculateProjMatrix(r,h),w=t.transform,T=kr(w),E=e.cz(s.canonical),S=e.cA(E.getCenter().lat);let C,I,D,R,A;u?(C=Float32Array.from(e.b6(e.cC(s.canonical))),I=Float32Array.from(w.globeMatrix),D=Float32Array.from(e.cy(w)),R=[e.am(w.center.lng),e.at(w.center.lat)],A=Float32Array.from(e.cB(s.canonical,E,S,w.worldSize/w._pixelsPerMercatorPixel))):(C=new Float32Array(16),I=new Float32Array(9),D=new Float32Array(16),R=[0,0],A=new Float32Array(9));const L=Qs(b,C,I,D,A,y||[0,0],e.a9(t.transform.zoom),R,T,x||1,v,c),P=t.isTileAffectedByFog(s),M=t.getOrCreateProgram("rasterParticle",{defines:p,overrideFog:P});if(t.uploadCommonUniforms(a,M,r),u){const e=new Ai(n.LEQUAL,Ai.ReadOnly,t.depthRangeFor3D),i=0,s=t.globeSharedBuffers;if(s){const[r,a,l]=s.getGridBuffers(S,0!==i);M.draw(t,n.TRIANGLES,e,f,Ri.alphaBlended,t.renderElevatedRasterBackface?Oi.frontCCW:Oi.backCCW,L,o.id,r,a,l);}}else {const e=t.depthModeForSublayer(0,Ai.ReadOnly),i=d[s.overscaledZ],{tileBoundsBuffer:r,tileBoundsIndexBuffer:a,tileBoundsSegments:c}=t.getTileBoundsBuffers(l);M.draw(t,n.TRIANGLES,e,i,Ri.alphaBlended,Oi.disabled,L,o.id,r,a,c);}}t.resetStencilClippingMasks();}(t,i,o,s),t.style.map.triggerRepaint());},background:function(t,i,o,s){const r=o.paint.get("background-color"),a=o.paint.get("background-opacity"),n=o.paint.get("background-emissive-strength"),l="viewport"===o.paint.get("background-pitch-alignment");if(0===a)return;const c=t.context,h=c.gl,u=t.transform,d=u.tileSize,_=o.paint.get("background-pattern");let p;if(void 0!==_){if(null===_)return;if(p=t.imageManager.getPattern(_.toString(),o.scope,t.style.getLut(o.scope)),!p)return}const f=!_&&1===r.a&&1===a&&t.opaquePassEnabledForLayer()?"opaque":"translucent";if(t.renderPass!==f)return;const m=Pi.disabled,g=t.depthModeForSublayer(0,"opaque"===f?Ai.ReadWrite:Ai.ReadOnly),v=t.colorModeForDrapableLayerRenderPass(n),x=_?"backgroundPattern":"background";let y,b=s;if(b||(y=t.getBackgroundTiles(),b=Object.values(y).map((e=>e.tileID))),_&&(c.activeTexture.set(h.TEXTURE0),t.imageManager.bind(t.context,o.scope)),l){const i=t.getOrCreateProgram(x,{overrideFog:!1,overrideRtt:!0}),s=new Float32Array(e.a6.mat4.identity([])),c=new e.aA(0,0,0,0,0),u=_?rr(s,n,a,t,0,o.scope,p,l,{tileID:c,tileSize:d}):sr(s,n,a,r.toRenderColor(o.lut));i.draw(t,h.TRIANGLES,g,m,v,Oi.disabled,u,o.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments);}else for(const e of b){const f=t.isTileAffectedByFog(e),b=t.getOrCreateProgram(x,{overrideFog:f}),w=e.toUnwrapped(),T=s?e.projMatrix:t.transform.calculateProjMatrix(w);t.prepareDrawTile();const E=i?i.getTile(e):y?y[e.key]:new _t(e,d,u.zoom,t),S=_?rr(T,n,a,t,0,o.scope,p,l,{tileID:e,tileSize:d}):sr(T,n,a,r.toRenderColor(o.lut));t.uploadCommonUniforms(c,b,w);const{tileBoundsBuffer:C,tileBoundsIndexBuffer:I,tileBoundsSegments:D}=t.getTileBoundsBuffers(E);b.draw(t,h.TRIANGLES,g,m,v,Oi.disabled,S,o.id,C,I,D);}},sky:function(t,i,o){const s=t._atmosphere?e.a9(t.transform.zoom):1,r=o.paint.get("sky-opacity")*s;if(0===r)return;const a=t.context,n=o.paint.get("sky-type"),l=new Ai(a.gl.LEQUAL,Ai.ReadOnly,[0,1]),c=t.frameCounter/1e3%1;"atmosphere"===n?"offscreen"===t.renderPass?o.needsSkyboxCapture(t)&&(function(t,i,o,s){const r=t.context,a=r.gl;let n=i.skyboxFbo;if(!n){n=i.skyboxFbo=r.createFramebuffer(32,32,!0,null),i.skyboxGeometry=new Kr(r),i.skyboxTexture=r.gl.createTexture(),a.bindTexture(a.TEXTURE_CUBE_MAP,i.skyboxTexture),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_MAG_FILTER,a.LINEAR);for(let e=0;e<6;++e)a.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,a.RGBA,32,32,0,a.RGBA,a.UNSIGNED_BYTE,null);}r.bindFramebuffer.set(n.framebuffer),r.viewport.set([0,0,32,32]);const l=i.getCenter(t,!0),c=t.getOrCreateProgram("skyboxCapture"),h=new Float64Array(16);e.a6.mat4.identity(h),e.a6.mat4.rotateY(h,h,.5*-Math.PI),Yr(t,i,c,h,l,0),e.a6.mat4.identity(h),e.a6.mat4.rotateY(h,h,.5*Math.PI),Yr(t,i,c,h,l,1),e.a6.mat4.identity(h),e.a6.mat4.rotateX(h,h,.5*-Math.PI),Yr(t,i,c,h,l,2),e.a6.mat4.identity(h),e.a6.mat4.rotateX(h,h,.5*Math.PI),Yr(t,i,c,h,l,3),e.a6.mat4.identity(h),Yr(t,i,c,h,l,4),e.a6.mat4.identity(h),e.a6.mat4.rotateY(h,h,Math.PI),Yr(t,i,c,h,l,5),r.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,a=r.gl,n=e.transform,l=e.getOrCreateProgram("skybox");r.activeTexture.set(a.TEXTURE0),a.bindTexture(a.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}))(n.skyboxMatrix,t.getCenter(e,!1),0,o,s);e.uploadCommonUniforms(r,l),l.draw(e,a.TRIANGLES,i,Pi.disabled,e.colorModeForRenderPass(),Oi.backCW,c,"skybox",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment);}(t,o,l,r,c):"gradient"===n&&"sky"===t.renderPass&&function(t,i,o,s,r){const a=t.context,n=a.gl,l=t.transform,c=t.getOrCreateProgram("skyboxGradient");i.skyboxGeometry||(i.skyboxGeometry=new Kr(a)),a.activeTexture.set(n.TEXTURE0);let h=i.colorRampTexture;h||(h=i.colorRampTexture=new e.T(a,i.colorRamp,n.RGBA8)),h.bind(n.LINEAR,n.CLAMP_TO_EDGE);const u=((t,i,o,s,r)=>({u_matrix:t,u_color_ramp:0,u_center_direction:i,u_radius:e.bC(o),u_opacity:s,u_temporal_offset:r}))(l.skyboxMatrix,i.getCenter(t,!1),i.paint.get("sky-gradient-radius"),s,r);t.uploadCommonUniforms(a,c),c.draw(t,n.TRIANGLES,o,Pi.disabled,t.colorModeForRenderPass(),Oi.backCW,u,"skyboxGradient",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment);}(t,o,l,r,c);},debug:function(t,i,o,s,r,a){for(let n=0;n<o.length;n++)if(r){const r=1,l=.8,c=new e.bA(s.r*l,s.g*l,s.b*l,1);Hr(t,i,o[n],s,-r,-r,a),Hr(t,i,o[n],s,-r,r,a),Hr(t,i,o[n],s,r,r,a),Hr(t,i,o[n],s,r,-r,a),Hr(t,i,o[n],c,0,0,a);}else Hr(t,i,o[n],s,0,0,a);},custom:function(t,i,o,s){const r=t.context,a=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=a.prerender;if(i){if(t.setCustomLayerDefaults(),r.setColorMode(t.colorModeForRenderPass()),"globe"===t.transform.projection.name){const o=t.transform.pointMerc;i.call(a,r.gl,t.transform.customLayerMatrix(),t.transform.getProjection(),t.transform.globeToMercatorMatrix(),e.a9(t.transform.zoom),[o.x,o.y],t.transform.pixelsPerMeterRatio);}else i.call(a,r.gl,t.transform.customLayerMatrix());r.setDirty(),t.setBaseState();}}else if("translucent"===t.renderPass){if(t.terrain&&t.terrain.renderingToTexture){const i=a.renderToTile;if(i){const o=s[0].canonical,n=new e.a5(o.x+s[0].wrap*(1<<o.z),o.y,o.z);r.setDepthMode(Ai.disabled),r.setStencilMode(Pi.disabled),r.setColorMode(t.colorModeForRenderPass()),t.setCustomLayerDefaults(),i.call(a,r.gl,n),r.setDirty(),t.setBaseState();}return}t.setCustomLayerDefaults(),r.setColorMode(t.colorModeForRenderPass()),r.setStencilMode(Pi.disabled);const i="3d"===a.renderingMode?new Ai(t.context.gl.LEQUAL,Ai.ReadWrite,t.depthRangeFor3D):t.depthModeForSublayer(0,Ai.ReadOnly);if(r.setDepthMode(i),"globe"===t.transform.projection.name){const i=t.transform.pointMerc;a.render(r.gl,t.transform.customLayerMatrix(),t.transform.getProjection(),t.transform.globeToMercatorMatrix(),e.a9(t.transform.zoom),[i.x,i.y],t.transform.pixelsPerMeterRatio);}else a.render(r.gl,t.transform.customLayerMatrix());r.setDirty(),t.setBaseState(),r.bindFramebuffer.set(null);}}else e.w("Custom layers are not yet supported with this projection. Use mercator or globe to enable usage of custom layers.");},model:function(t,i,o,s){if("opaque"===t.renderPass)return;const r=o.paint.get("model-opacity");if(0===r)return;const a=o.paint.get("model-cast-shadows");if("shadow"===t.renderPass){if(!a)return;if(t.terrain&&r<.65&&o._transitionablePaint._values["model-opacity"].value.expression instanceof e.a4)return}const n=t.shadowRenderer,l=o.paint.get("model-receive-shadows");n&&(n.useNormalOffset=!0,l||(n.enabled=!1));const c=()=>{n&&(n.useNormalOffset=!0,l||(n.enabled=!0));},h=i.getSource();if("light-beam"===t.renderPass&&"batched-model"!==h.type)return;if("vector"===h.type||"geojson"===h.type)return function(t,i,o,s,r){const a=t.transform;if("mercator"!==a.projection.name)return void e.w(`Drawing 3D models for ${a.projection.name} projection is not yet implemented`);const n=a.getFreeCameraOptions().position;if(!t.modelManager)return;const l=t.modelManager;o.modelManager=l;const c=t.shadowRenderer;if(!o._unevaluatedLayout._values.hasOwnProperty("model-id"))return;const h=o._unevaluatedLayout._values["model-id"],u={...o.layout.get("model-id").parameters},d=t.style.order.indexOf(o.fqid);for(const _ of s){const s=i.getTile(_).getBucket(o);if(!s||s.projection.name!==a.projection.name)continue;const p=s.getModelUris();p&&!s.modelsRequested&&(l.addModelsFromBucket(p,r),s.modelsRequested=!0);const f=ua(_,a);u.zoom=f;const m=h.possiblyEvaluate(u);if(ca(t,s,_),ha.shadowUniformsInitialized=!1,ha.useSingleShadowCascade=!!c&&0===c.getMaxCascadeForTile(_.toUnwrapped()),"shadow"===t.renderPass&&c){if(1===t.currentShadowCascade&&s.isInsideFirstShadowMapFrustum)continue;const i=a.calculatePosMatrix(_.toUnwrapped(),a.worldSize);if(ha.tileMatrix.set(i),ha.shadowTileMatrix=Float32Array.from(c.calculateShadowPassMatrixFromMatrix(i)),ha.aabb.min.fill(0),ha.aabb.max[0]=ha.aabb.max[1]=e.ab,ha.aabb.max[2]=0,pa(s,ha,t,o.scope))continue}const g=1<<_.canonical.z,v=[((n.x-_.wrap)*g-_.canonical.x)*e.ab,(n.y*g-_.canonical.y)*e.ab,n.z*g*e.ab];t.conflationActive&&Object.keys(s.instancesPerModel).length>0&&t.style.isLayerClipped(o,i.getSource())&&s.updateReplacement(_,t.replacementSource,d,r)&&(s.uploaded=!1,s.upload(t.context));for(let e in s.instancesPerModel){const i=s.instancesPerModel[e];i.features.length>0&&(e=m.evaluate(i.features[0].feature,{}));const a=l.getModel(e,r);if(a&&a.uploaded)for(const e of a.nodes)da(t,o,e,i,v,_,ha);}}}(t,i,o,s,"vector"===h.type?o.scope:""),void c();if(!h.loaded())return;if("batched-model"===h.type)return function(t,i,o,s){o.resetLayerRenderingStats(t);const r=t.context,a=t.transform,n=t.style.fog,l=t.shadowRenderer;if("mercator"!==a.projection.name)return void e.w(`Drawing 3D landmark models for ${a.projection.name} projection is not yet implemented`);const c=t.transform.getFreeCameraOptions().position,h=e.a6.vec3.scale([],[c.x,c.y,c.z],t.transform.worldSize),u=e.a6.vec3.negate([],h),d=e.a6.mat4.identity([]),_=e.de(a.center.lat,a.zoom),p=e.a6.mat4.fromScaling([],[1,1,1/_]);e.a6.mat4.translate(d,d,u);const f=o.paint.get("model-opacity"),m=new Ai(r.gl.LEQUAL,Ai.ReadWrite,t.depthRangeFor3D),g=new Ai(r.gl.LEQUAL,Ai.ReadOnly,t.depthRangeFor3D),v=new e.ca([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),x="shadow"===t.renderPass,y=x&&l?l.getCurrentCascadeFrustum():a.getFrustum(a.scaleZoom(a.worldSize)),b=o.paint.get("model-front-cutoff"),w=b[2]<1,T=qi(t,o.paint.get("model-cutoff-fade-range")),E=o.getLayerRenderingStats();((function(e,t,i,o){const s=e.terrain?e.terrain.exaggeration():0,r=e.transform.zoom;for(const a of o){const o=t.getTile(a).getBucket(i);o&&(e.conflationActive&&o.updateReplacement(a,e.replacementSource),o.evaluateScale(e,i),e.terrain&&s>0&&o.elevationUpdate(e.terrain,s,a,i.source),o.needsReEvaluation(e,r,i)&&o.evaluate(i));}}))(t,i,o,s),function(){let c,u,S;w?(c=s.length-1,u=-1,S=-1):(c=0,u=s.length,S=1);const C=new Float64Array(16),I=e.a6.vec3.create(),D=new e.P(0,0);for(let R=c;R!==u;R+=S){const c=s[R],u=i.getTile(c).getBucket(o);if(!u||!u.uploaded)continue;let S=!1;l&&(S=0===l.getMaxCascadeForTile(c.toUnwrapped()));const A=a.calculatePosMatrix(c.toUnwrapped(),a.worldSize),L=u.modelTraits;!x&&w&&(e.a6.mat4.invert(C,A),e.a6.vec3.transformMat4(I,h,C),D.x=I[0],D.y=I[1]);const P=[];for(const i of u.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.a6.vec3.transformMat4(v.min,v.min,A),e.a6.vec3.transformMat4(v.max,v.max,A),v})(),n=i.evaluatedScale;if(n[0]<=1&&n[1]<=1&&n[2]<=1&&0===r.intersects(y))continue;if(!x&&w){const t=1/6;i.cameraCollisionOpacity=h[0]>r.min[0]&&h[0]<r.max[0]&&h[1]>r.min[1]&&h[1]<r.max[1]&&h[2]*_<r.max[2]&&o.footprint&&e.bv(D,o.footprint)?Math.max(i.cameraCollisionOpacity-t,0):Math.min(1,i.cameraCollisionOpacity+t);}const l=[...A],c=o.anchor?o.anchor[0]:0,u=o.anchor?o.anchor[1]:0;e.a6.mat4.translate(l,l,[c*(n[0]-1),u*(n[1]-1),s]),e.a6.vec3.exactEquals(n,e.dh)||e.a6.mat4.scale(l,l,n);const d=e.a6.mat4.multiply([],l,o.matrix),p=e.a6.mat4.multiply([],a.expandedFarZProjMatrix,d),m=e.a6.mat4.multiply([],a.expandedFarZProjMatrix,l),g=e.a6.vec4.transformMat4([],[c,u,s,1],p)[2];o.hidden=!1;let E=f;x||(w&&(E*=i.cameraCollisionOpacity,E*=ma(l,a,i.aabb,b)),E*=fa(T,g)),0!==E?P.push({nodeInfo:i,depth:g,opacity:E,wvpForNode:p,wvpForTile:m,nodeModelMatrix:d,tileModelMatrix:l}):o.hidden=!0;}x||P.sort(((e,t)=>!w||1===e.opacity&&1===t.opacity?e.depth<t.depth?-1:1:1===e.opacity?-1:1===t.opacity?1:e.depth>t.depth?-1:1));for(const i of P){const s=i.nodeInfo,c=s.node;let h=e.a6.mat4.multiply([],p,i.tileModelMatrix);e.a6.mat4.multiply(h,d,h);const u=e.a6.mat4.invert([],h);e.a6.mat4.transpose(u,u),e.a6.mat4.scale(u,u,_a),h=e.a6.mat4.multiply(h,h,c.matrix);const _="light-beam"===t.renderPass,f=L&e.dj.HasMapboxMeshFeatures,v=f?0:s.evaluatedRMEA[0][2];for(let e=0;e<c.meshes.length;++e){const d=c.meshes[e],p=e===c.lightMeshIndex;let y=i.wvpForNode;if(p){if(!_&&!t.terrain&&t.shadowRenderer){t.currentLayer<t.firstLightBeamLayer&&(t.firstLightBeamLayer=t.currentLayer);continue}y=i.wvpForTile;}else if(_)continue;const b={defines:[]},w=[];if(!x&&l&&(l.useNormalOffset=!!d.normalBuffer),ra(b.defines,w,d,t,o.lut),f||b.defines.push("DIFFUSE_SHADED"),S&&b.defines.push("SHADOWS_SINGLE_CASCADE"),E&&(x?E.numRenderedVerticesInShadowPass+=d.vertexArray.length:E.numRenderedVerticesInTransparentPass+=d.vertexArray.length),x){la(d,i.nodeModelMatrix,t,o);continue}let T=null;if(n){const e=sa(i.nodeModelMatrix,t.transform);if(T=new Float32Array(e),"globe"!==a.projection.name){const t=d.aabb.min,i=d.aabb.max,[o,s]=n.getOpacityForBounds(e,t[0],t[1],i[0],i[1]);b.overrideFog=o>=ze||s>=ze;}}const C=d.material;let I;C.occlusionTexture&&C.occlusionTexture.offsetScale&&(I=C.occlusionTexture.offsetScale,b.defines.push("OCCLUSION_TEXTURE_TRANSFORM"));const D=t.getOrCreateProgram("model",b);!x&&l&&l.setupShadowsFromMatrix(i.tileModelMatrix,D,l.useNormalOffset),t.uploadCommonUniforms(r,D,null,T);const R=C.pbrMetallicRoughness;R.metallicFactor=.9,R.roughnessFactor=.5;const A=nr(new Float32Array(y),new Float32Array(h),new Float32Array(u),new Float32Array(c.matrix),t,i.opacity,R.baseColorFactor.toRenderColor(null),C.emissiveFactor,R.metallicFactor,R.roughnessFactor,C,v,o,[0,0,0],I);!p&&(s.hasTranslucentParts||i.opacity<1)&&D.draw(t,r.gl.TRIANGLES,m,Pi.disabled,Ri.disabled,Oi.backCCW,A,o.id,d.vertexBuffer,d.indexBuffer,d.segments,o.paint,t.transform.zoom,void 0,w),D.draw(t,r.gl.TRIANGLES,p?g:m,Pi.disabled,p||i.opacity<1||s.hasTranslucentParts?Ri.alphaBlended:Ri.unblended,Oi.backCCW,A,o.id,d.vertexBuffer,d.indexBuffer,d.segments,o.paint,t.transform.zoom,void 0,w);}}}}();}(t,i,o,s),void c();if("model"!==h.type)return;const u=h.getModels(),d=[],_=t.transform.getFreeCameraOptions().position,p=e.a6.vec3.scale([],[_.x,_.y,_.z],t.transform.worldSize);e.a6.vec3.negate(p,p);const f=[],m=[];let g=0;for(const i of u){const s=o.paint.get("model-rotation").constantOr(null),r=o.paint.get("model-scale").constantOr(null),a=o.paint.get("model-translation").constantOr(null);i.computeModelMatrix(t,s,r,a,!0,!0,!1);const n=e.a6.mat4.identity([]),l=e.de(i.position.lat,t.transform.zoom),c=e.a6.mat4.fromScaling([],[1,1,1/l]);e.a6.mat4.translate(n,n,p),d.push({zScaleMatrix:c,negCameraPosMatrix:n});for(const e of i.nodes)na(t.transform,e,i.matrix,t.transform.expandedFarZProjMatrix,g,f,m);g++;}if(f.sort(((e,t)=>t.depth-e.depth)),"shadow"!==t.renderPass){if(1===r)for(const e of m)aa(e,t,o,d[e.modelIndex],Pi.disabled,t.colorModeForRenderPass());else {for(const e of m)aa(e,t,o,d[e.modelIndex],Pi.disabled,Ri.disabled);for(const e of m)aa(e,t,o,d[e.modelIndex],t.stencilModeFor3D(),t.colorModeForRenderPass());t.resetStencilClippingMasks();}for(const e of f)aa(e,t,o,d[e.modelIndex],Pi.disabled,t.colorModeForRenderPass());c();}else {for(const e of m)la(e.mesh,e.nodeModelMatrix,t,o);for(const e of f)la(e.mesh,e.nodeModelMatrix,t,o);c();}}},wa={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,"vector"===o.type?e.scope:""));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 Ke&&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 a=t.getIds().map((e=>t.getTileByID(e)));for(const e of a)e.updateNeeded(s,r)&&o.prepareTile(e,s,r);},"raster-particle":function(e,t,i){const o=t.getSource();if(!(o instanceof Ke&&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 a=t.getIds().map((e=>t.getTileByID(e)));for(const e of a)e.updateNeeded(s,r)&&o.prepareTile(e,s,r);}};class Ta{constructor(t,i,o,s,r){this.context=new pr(t,i),this.transform=o,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.tp=r,this._timeStamp=e.q.now(),this._averageFPS=0,this._fpsHistory=[],this._dt=0,this._debugParams={forceEnablePrecipitation:!1,showTerrainProxyTiles:!1,fpsWindow:30,continousRedraw:!1,enabledLayers:{}};const a=["fill","line","symbol","circle","heatmap","fill-extrusion","raster","raster-particle","hillshade","model","background","sky"];for(const e of a)this._debugParams.enabledLayers[e]=!0;r.registerParameter(this._debugParams,["Terrain"],"showTerrainProxyTiles",{},(()=>{this.style.map.triggerRepaint();})),r.registerParameter(this._debugParams,["Precipitation"],"forceEnablePrecipitation"),r.registerParameter(this._debugParams,["FPS"],"fpsWindow",{min:1,max:100,step:1}),r.registerBinding(this._debugParams,["FPS"],"continousRedraw",{readonly:!0,label:"continuous redraw"}),r.registerBinding(this,["FPS"],"_averageFPS",{readonly:!0,label:"value"}),r.registerBinding(this,["FPS"],"_averageFPS",{readonly:!0,label:"graph",view:"graph",min:0,max:200});for(const e of a)r.registerParameter(this._debugParams.enabledLayers,["Debug","Layers"],e);this.occlusionParams=new xa(r),this.setup(),this.numSublayers=gt.maxUnderzooming+gt.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.dl,this.longestCutoffRange=0,this.minCutoffZoom=0,this._fogVisible=!1,this._cachedTileFogOpacities={},this._shadowRenderer=new Ji(this),this._wireframeDebugCache=new va,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0,this.layersWithOcclusionOpacity=[];const n=new e.r({width:1,height:1},Uint8Array.of(0,0,0,0));this.emptyDepthTexture=new e.T(this.context,n,t.RGBA8),this._clippingActiveLastFrame=!1,this.scaleFactor=s;}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 Rs(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 Rs(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.q.devicePixelRatio,this.height=i*e.q.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.a$;i.emplaceBack(0,0),i.emplaceBack(e.ab,0),i.emplaceBack(0,e.ab),i.emplaceBack(e.ab,e.ab),this.tileExtentBuffer=t.createVertexBuffer(i,e.b1.members),this.tileExtentSegments=e.b2.simpleSegment(0,0,4,2);const o=new e.a$;o.emplaceBack(0,0),o.emplaceBack(e.ab,0),o.emplaceBack(0,e.ab),o.emplaceBack(e.ab,e.ab),this.debugBuffer=t.createVertexBuffer(o,e.b1.members),this.debugSegments=e.b2.simpleSegment(0,0,4,5);const s=new e.a$;s.emplaceBack(-1,-1),s.emplaceBack(1,-1),s.emplaceBack(-1,1),s.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(s,e.b1.members),this.viewportSegments=e.b2.simpleSegment(0,0,4,2);const r=new e.aO;r.emplaceBack(0,0,0,0),r.emplaceBack(e.ab,0,e.ab,0),r.emplaceBack(0,e.ab,0,e.ab),r.emplaceBack(e.ab,e.ab,e.ab,e.ab),this.mercatorBoundsBuffer=t.createVertexBuffer(r,e.b4.members),this.mercatorBoundsSegments=e.b2.simpleSegment(0,0,4,2);const a=new e.aP;a.emplaceBack(0,1,2),a.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(a);const n=new e.b0;for(const e of [0,1,3,2,0])n.emplaceBack(e);this.debugIndexBuffer=t.createIndexBuffer(n),this.emptyTexture=new e.T(t,new e.r({width:1,height:1},Uint8Array.of(0,0,0,0)),t.gl.RGBA8),this.identityMat=e.a6.mat4.create();const l=this.context.gl;this.stencilClearMode=new Pi({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,Ai.disabled,this.stencilClearMode,Ri.disabled,Oi.disabled,Es(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(Ri.disabled),o.setDepthMode(Ai.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:a,tileBoundsIndexBuffer:n,tileBoundsSegments:l}=this.getTileBoundsBuffers(i);r.draw(this,s.TRIANGLES,Ai.disabled,new Pi({func:s.ALWAYS,mask:0},o,255,s.KEEP,s.KEEP,s.REPLACE),Ri.disabled,Oi.disabled,Es(e.projMatrix),"$clipping",a,n,l);}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,t=this.context.gl;return new Pi({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 Pi({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;i<s;i++)e[i+o]=new Pi({func:t.GEQUAL,mask:255},i+this.nextStencilID,255,t.KEEP,t.KEEP,t.REPLACE);return this.nextStencilID+=s,[e,i]}return [{[o]:Pi.disabled},i]}colorModeForRenderPass(){const t=this.context.gl;if(this._showOverdrawInspector){const i=1/8;return new Ri([t.CONSTANT_COLOR,t.ONE,t.CONSTANT_COLOR,t.ONE],new e.bA(i,i,i,0),[!0,!0,!0,!0])}return "opaque"===this.renderPass?Ri.unblended:Ri.alphaBlended}colorModeForDrapableLayerRenderPass(t){const i=this.context.gl;return (()=>this.style&&this.style.enable3dLights()&&this.terrain&&this.terrain.renderingToTexture)()&&"translucent"===this.renderPass?new Ri([i.ONE,i.ONE_MINUS_SRC_ALPHA,i.CONSTANT_ALPHA,i.ONE_MINUS_SRC_ALPHA],new e.bA(0,0,0,void 0===t?0:t),[!0,!0,!0,!0]):this.colorModeForRenderPass()}depthModeForSublayer(e,t,i,o=!1){if(this.depthOcclusion)return new Ai(this.context.gl.GREATER,Ai.ReadOnly,this.depthRangeFor3D);if(!this.opaquePassEnabledForLayer()&&!o)return Ai.disabled;const s=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new Ai(i||this.context.gl.LEQUAL,t,[s,s])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}blitDepth(){const t=this.context.gl,i=Math.ceil(this.width),o=Math.ceil(this.height),s=this.context.bindFramebuffer.get(),r=t.getParameter(t.TEXTURE_BINDING_2D);this.depthFBO&&this.depthFBO.width===i&&this.depthFBO.height===o||(this.depthFBO&&(this.depthFBO.destroy(),this.depthFBO=void 0,this.depthTexture=void 0),0!==i&&0!==o&&(this.depthFBO=new _r(this.context,i,o,!1,"texture"),this.depthTexture=new e.T(this.context,{width:i,height:o,data:null},t.DEPTH24_STENCIL8),this.depthFBO.depthAttachment.set(this.depthTexture.texture))),this.context.bindFramebuffer.set(s),t.bindTexture(t.TEXTURE_2D,r),this.depthFBO&&(t.bindFramebuffer(t.READ_FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,this.depthFBO.framebuffer),t.blitFramebuffer(0,0,i,o,0,0,i,o,t.DEPTH_BUFFER_BIT,t.NEAREST),t.bindFramebuffer(t.FRAMEBUFFER,this.context.bindFramebuffer.current));}updateAverageFPS(){this._fpsHistory.push(0===this._dt?0:1e3/this._dt),this._fpsHistory.length>this._debugParams.fpsWindow&&this._fpsHistory.splice(0,this._fpsHistory.length-this._debugParams.fpsWindow),this._averageFPS=Math.round(this._fpsHistory.reduce(((e,t)=>e+t/this._fpsHistory.length),0));}render(t,i){const o=e.q.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.style._getOrder(!(!this.terrain||!this.terrain.enabled)).filter((e=>{const t=s[e];return !(t.type in this._debugParams.enabledLayers)||this._debugParams.enabledLayers[t.type]}));let a=!1,n=!1;for(const e of r){const t=s[e];"circle"===t.type&&(a=!0),"symbol"===t.type&&(t.hasInitialOcclusionOpacityProperties?n=!0:a=!0);}const l=r.map((e=>s[e])),c=this.style._mergedSourceCaches;this.imageManager=t.imageManager,this.modelManager=t.modelManager,this.symbolFadeChange=t.placement.symbolFadeChange(e.q.now()),this.imageManager.beginFrame();let h=0,u=!1;for(const e in c){const t=c[e];t.used&&(t.prepare(this.context),t.getSource().usedInConflation&&++h);}let d=!1;for(const e of l)e.isHidden(this.transform.zoom)||("clip"===e.type&&(d=!0),this.prepareLayer(e));const _={},p={},f={},m={},g={};for(const e in c){const t=c[e];_[e]=t.getVisibleCoordinates(),p[e]=_[e].slice().reverse(),f[e]=t.getVisibleCoordinates(!0).reverse(),m[e]=t.getShadowCasterCoordinates(),g[e]=t.sortCoordinatesByDistance(_[e]);}const v=e=>{const t=this.style.getLayerSourceCache(e);return t&&t.used?t.getSource():null};if(h||d||this._clippingActiveLastFrame){const t=[],i=[];let o=0;for(const e of l)this.isSourceForClippingOrConflation(e,v(e))&&(t.push(e),i.push(o)),o++;if(t&&(d||t.length>1)||this._clippingActiveLastFrame){d=!1;const o=[];for(let s=0;s<t.length;s++){const r=t[s],a=i[s],n=this.style.getLayerSourceCache(r);if(!n||!n.used||!n.getSource().usedInConflation&&"clip"!==r.type)continue;let l=e.dn,c=e.bt.None;const h=[];let u=!0;if("clip"===r.type){l=a;for(const t of r.layout.get("clip-layer-types"))c|="model"===t?e.bt.Model:"symbol"===t?e.bt.Symbol:e.bt.FillExtrusion;for(const e of r.layout.get("clip-layer-scope"))h.push(e);r.isHidden(this.transform.zoom)?u=!1:d=!0;}u&&o.push({layer:r.fqid,cache:n,order:l,clipMask:c,clipScope:h});}this.replacementSource.setSources(o),u=!0;}}this._clippingActiveLastFrame=d,u||this.replacementSource.clear(),this.conflationActive=u,this.minCutoffZoom=0,this.longestCutoffRange=0,this.opaquePassCutoff=1/0,this._lastOcclusionLayer=-1,this.layersWithOcclusionOpacity=[];for(let e=0;e<l.length;e++){const t=l[e],i=t.cutoffRange();if(this.longestCutoffRange=Math.max(i,this.longestCutoffRange),i>0){const e=v(t);e&&(this.minCutoffZoom=Math.max(e.minzoom,this.minCutoffZoom)),t.minzoom&&(this.minCutoffZoom=Math.max(t.minzoom,this.minCutoffZoom));}t.is3D()&&(this.opaquePassCutoff===1/0&&(this.opaquePassCutoff=e),this._lastOcclusionLayer=e);}const x=this.style&&this.style.fog;x?(this._fogVisible=0!==x.getOpacity(this.transform.pitch),this._fogVisible&&"globe"!==this.transform.projection.name&&(this._fogVisible=x.isVisibleOnFrustum(this.transform.cameraFrustum))):this._fogVisible=!1,this._cachedTileFogOpacities={},this.terrain&&(this.terrain.updateTileBinding(f),this.opaquePassCutoff=0);const y=this._shadowRenderer;if(y){y.updateShadowParameters(this.transform,this.style.directionalLight);for(const e in c)for(const t of _[e]){let e={min:0,max:0};this.terrain&&(e=this.terrain.getMinMaxForTile(t)||e),y.addShadowReceiver(t.toUnwrapped(),e.min,e.max);}}if("globe"!==this.transform.projection.name||this.globeSharedBuffers||(this.globeSharedBuffers=new e.dm(this.context)),this.style.fog&&this.transform.projection.supportsFog?(this._atmosphere||(this._atmosphere=new oa(this)),this._atmosphere.update(this)):this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0),!U.has(this.context.gl))return;this.renderPass="offscreen";for(const e of l){const i=t.getLayerSourceCache(e);if(!e.hasOffscreenPass()||e.isHidden(this.transform.zoom))continue;const o=i?p[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-(l.length+2)*this.numSublayers*this.depthEpsilon],this._shadowRenderer&&(this.renderPass="shadow",this._shadowRenderer.drawShadowPass(this.style,m)),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]);const b="globe"===this.transform.projection.name||this.transform.isHorizonVisible(),w=(()=>{if(i.showOverdrawInspector)return e.bA.black;const t=this.style.fog;if(t&&this.transform.projection.supportsFog){const i=this.style.getLut(t.scope);if(!b){const o=t.properties.get("color").toRenderColor(i).toArray01();return new e.bA(...o)}if(b){const o=t.properties.get("space-color").toRenderColor(i).toArray01();return new e.bA(...o)}}return e.bA.transparent})();if(this.context.clear({color:w,depth:1}),this.clearStencil(),this._showOverdrawInspector=i.showOverdrawInspector,this.renderPass="opaque",this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&b&&this._atmosphere.drawStars(this,this.style.fog),!this.terrain)for(this.currentLayer=r.length-1;this.currentLayer>=0;this.currentLayer--){const e=l[this.currentLayer],i=t.getLayerSourceCache(e);if(e.isSky())continue;const o=i?(e.is3D()?g:p)[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&&b&&this._atmosphere.drawAtmosphereGlow(this,this.style.fog),this.renderPass="sky",(!this._atmosphere||e.a9(this.transform.zoom)>0)&&("globe"===this.transform.projection.name||this.transform.isHorizonVisible()))for(this.currentLayer=0;this.currentLayer<r.length;this.currentLayer++){const e=l[this.currentLayer],i=t.getLayerSourceCache(e);e.isSky()&&this.renderLayer(this,i,e,i?p[i.id]:void 0);}function T(e,t){let i;return t&&(i=("symbol"===e.type?f:e.is3D()?g:p)[t.id]),i}if(this.renderPass="translucent","globe"===this.transform.projection.name){for(this.renderElevatedRasterBackface=!0,this.currentLayer=0;this.currentLayer<r.length;){const e=l[this.currentLayer];if("raster"===e.type||"raster-particle"===e.type){const i=t.getLayerSourceCache(e);this.renderLayer(this,i,e,T(e,i));}++this.currentLayer;}this.renderElevatedRasterBackface=!1;}this.currentLayer=0,this.firstLightBeamLayer=Number.MAX_SAFE_INTEGER;let E=0;y&&(E=y.getShadowCastingLayerCount());let S=!1,C=-1;for(let e=0;e<r.length;++e){const t=l[e];t.isHidden(this.transform.zoom)||t.is3D()&&(C=e);}for(n&&-1===C&&(a=!0);this.currentLayer<r.length;){const e=l[this.currentLayer],i=t.getLayerSourceCache(e);if(e.isSky())++this.currentLayer;else if(this.terrain&&this.style.isLayerDraped(e)){if(e.isHidden(this.transform.zoom)){++this.currentLayer;continue}this.currentLayer=this.terrain.renderBatch(this.currentLayer),this._lastOcclusionLayer=Math.max(this.currentLayer,this._lastOcclusionLayer);}else {if(a&&!S&&this.terrain&&!this.transform.isOrthographic&&(S=!0,this.blitDepth()),n&&-1!==C&&this.currentLayer===C+1&&!this.transform.isOrthographic&&this.blitDepth(),e.is3D()||this.terrain||this._renderTileClippingMasks(e,i,i?_[i.id]:void 0),this.renderLayer(this,i,e,T(e,i)),!this.terrain&&y&&E>0&&e.hasShadowPass()&&0==--E&&(y.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=l[this.currentLayer];if(!e.hasLightBeamPass())continue;const i=t.getLayerSourceCache(e);this.renderLayer(this,i,e,i?p[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=l[this.currentLayer],o=t.getLayerSourceCache(i),s=o?p[o.id]:void 0;i.is3D()||this.terrain||this._renderTileClippingMasks(i,o,o?_[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.options.showTileBoundaries||this.options.showQueryGeometry||this.options.showTileAABBs){let i=null;l.forEach((e=>{const o=t.getLayerSourceCache(e);o&&!e.isHidden(this.transform.zoom)&&o.getVisibleCoordinates().length&&(!i||i.getSource().maxzoom<o.getSource().maxzoom)&&(i=o);})),i&&this.options.showTileBoundaries&&ba.debug(this,i,i.getVisibleCoordinates(),e.bA.red,!1,this.options.showParseStatus);}this.terrain&&this._debugParams.showTerrainProxyTiles&&ba.debug(this,this.terrain.proxySourceCache,this.terrain.proxyCoords,new e.bA(1,.8,.1,1),!0,this.options.showParseStatus),this.options.showPadding&&function(e){const t=e.transform.padding;Zr(e,e.transform.height-(t.top||0),3,Nr),Zr(e,t.bottom||0,3,Ur),qr(e,t.left||0,3,Gr),qr(e,e.transform.width-(t.right||0),3,Vr);const i=e.transform.centerPoint;!function(e,t,i,o){Wr(e,t-1,i-10,2,20,o),Wr(e,t-10,i-1,20,2,o);}(e,i.x,e.transform.height-i.y,jr);}(this),this.context.setDefault(),this.frameCounter=(this.frameCounter+1)%Number.MAX_SAFE_INTEGER,this.tileLoaded&&this.options.speedIndexTiming&&(this.loadTimeStamps.push(performance.now()),this.saveCanvasCopy()),u||(this.conflationActive=!1);}prepareLayer(e){this.gpuTimingStart(e);const{unsupportedLayers:t}=this.transform.projection,i=!t||!t.includes(e.type);if(wa[e.type]&&(i||this.terrain&&"custom"===e.type)){const t=this.style.getLayerSourceCache(e);wa[e.type](e,t,this);}this.gpuTimingEnd();}renderLayer(e,t,i,o){i.isHidden(this.transform.zoom)||("background"===i.type||"sky"===i.type||"custom"===i.type||"model"===i.type||"raster"===i.type||"raster-particle"===i.type||o&&o.length)&&(this.id=i.id,this.gpuTimingStart(i),e.transform.projection.unsupportedLayers&&e.transform.projection.unsupportedLayers.includes(i.type)&&(!e.terrain||"custom"!==i.type)||"clip"===i.type||ba[i.type](e,t,i,o,this.style.placement.variableOffsets,this.options.isInitialLoad),this.gpuTimingEnd());}gpuTimingStart(e){if(!this.options.gpuTiming)return;const t=this.context.extTimerQuery,i=this.context.gl;let o=this.gpuTimers[e.id];o||(o=this.gpuTimers[e.id]={calls:0,cpuTime:0,query:i.createQuery()}),o.calls++,i.beginQuery(t.TIME_ELAPSED_EXT,o.query);}gpuTimingDeferredRenderStart(){if(this.options.gpuTimingDeferredRender){const e=this.context.extTimerQuery,t=this.context.gl,i=t.createQuery();this.deferredRenderGpuTimeQueries.push(i),t.beginQuery(e.TIME_ELAPSED_EXT,i);}}gpuTimingDeferredRenderEnd(){this.options.gpuTimingDeferredRender&&this.context.gl.endQuery(this.context.extTimerQuery.TIME_ELAPSED_EXT);}gpuTimingEnd(){this.options.gpuTiming&&this.context.gl.endQuery(this.context.extTimerQuery.TIME_ELAPSED_EXT);}collectGpuTimers(){const e=this.gpuTimers;return this.gpuTimers={},e}collectDeferredRenderGpuQueries(){const e=this.deferredRenderGpuTimeQueries;return this.deferredRenderGpuTimeQueries=[],e}queryGpuTimers(e){const t={};for(const i in e){const o=e[i],s=this.context.extTimerQuery,r=s.getQueryParameter(o.query,this.context.gl.QUERY_RESULT)/1e6;s.deleteQueryEXT(o.query),t[i]=r;}return t}queryGpuTimeDeferredRender(e){if(!this.options.gpuTimingDeferredRender)return 0;const t=this.context.gl;let i=0;for(const o of e)i+=t.getQueryParameter(o,t.QUERY_RESULT)/1e6,t.deleteQuery(o);return i}translatePosMatrix(t,i,o,s,r){if(!o[0]&&!o[1])return t;const a=r?"map"===s?this.transform.angle:0:"viewport"===s?-this.transform.angle:0;if(a){const e=Math.sin(a),t=Math.cos(a);o=[o[0]*t-o[1]*e,o[0]*e+o[1]*t];}const n=[r?o[0]:e.ak(i,o[0],this.transform.zoom),r?o[1]:e.ak(i,o[1],this.transform.zoom),0],l=new Float32Array(16);return e.a6.mat4.translate(l,t,n),l}saveTileTexture(e){const t=e.size[0],i=this._tileTextures[t];i?i.push(e):this._tileTextures[t]=[e];}getTileTexture(e){const t=this._tileTextures[e];return t&&t.length>0?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","FOG_DITHERING"),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=Ms.cacheKey(Co[e],e,s,o);return this.cache[r]||(this.cache[r]=new Ms(this.context,e,Co[e],o,cr[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=t.properties.get("color").toRenderColor(o.getLut(t.scope)).toArray01(),a=t.properties.get("intensity"),n=i.properties.get("color").toRenderColor(o.getLut(i.scope)).toArray01(),l=i.properties.get("intensity"),c=[s.x,s.y,s.z],h=e.cH(n,l),u=e.cH(r,a);return {u_lighting_ambient_color:h,u_lighting_directional_dir:c,u_lighting_directional_color:u,u_ground_radiance:As(c,u,h)}})(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 a=this.style.fog;if(a){const r=a.getOpacity(this.transform.pitch),n=((t,i,o,s,r,a,n,l,c,h,u,d)=>{const _=t.transform,p=i.properties.get("color").toRenderColor(t.style.getLut(i.scope)).toArray01();p[3]=s;const f=t.frameCounter/1e3%1,[m,g]=i.properties.get("vertical-range");return {u_fog_matrix:o?_.calculateFogTileMatrix(o):d||t.identityMat,u_fog_range:i.getFovAdjustedRange(_._fov),u_fog_color:p,u_fog_horizon_blend:i.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(m,g),g],u_fog_temporal_offset:f,u_frustum_tl:r,u_frustum_tr:a,u_frustum_br:n,u_frustum_bl:l,u_globe_pos:c,u_globe_radius:h,u_viewport:u,u_globe_transition:e.a9(_.zoom),u_is_globe:+("globe"===_.projection.name)}})(this,a,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.q.devicePixelRatio,this.transform.height*e.q.devicePixelRatio],s);i.setFogUniformValues(t,n);}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 _t(o,512,this.transform.tileZoom,this);return t}clearBackgroundTiles(){this._backgroundTiles={};}isSourceForClippingOrConflation(e,t){return !(!e.is3D()||"clip"!==e.type&&(e.minzoom&&e.minzoom>this.transform.zoom||(this.style._clipLayerPresent||"building"!==e.sourceLayer)&&(!t||"batched-model"!==t.type)))}isTileAffectedByFog(e){if(!this.style||!this.style.fog)return !1;if("globe"===this.transform.projection.name)return !0;let t=this._cachedTileFogOpacities[e.key];return t||(this._cachedTileFogOpacities[e.key]=t=this.style.fog.getOpacityForTile(e)),t[0]>=ze||t[1]>=ze}setupDepthForOcclusion(e,t,i){const o=this.context,s=o.gl,r=!!i;var a;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/((a=this.depthRangeFor3D)[1]-a[0]),-1-2*a[0]/(a[1]-a[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);}}function Ea(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 Sa{constructor(t){this._hashName=t&&encodeURIComponent(t),e.aJ(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=Ea(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=Ca(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(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 Ca(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),a=Math.round(i.lng*r)/r,n=Math.round(i.lat*r)/r,l=e.getBearing(),c=e.getPitch();let h=t?`/${a}/${n}/${o}`:`${o}/${n}/${a}`;return (l||c)&&(h+="/"+Math.round(10*l)/10),c&&(h+=`/${Math.round(c)}`),h}const Ia={linearity:.3,easing:e.dp(0,0,.3,1)},Da=e.l({deceleration:2500,maxSpeed:1400},Ia),Ra=e.l({deceleration:20,maxSpeed:1400},Ia),Aa=e.l({deceleration:1e3,maxSpeed:360},Ia),La=e.l({deceleration:1e3,maxSpeed:90},Ia);class Pa{constructor(e){this._map=e,this.clear();}clear(){this._inertiaBuffer=[];}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:e.q.now(),settings:t});}_drainInertiaBuffer(){const t=this._inertiaBuffer,i=e.q.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 r=za(i.pan.mag(),o,e.l({},Da,t||{}));s.offset=i.pan.mult(r.amount/i.pan.mag()),s.center=this._map.transform.center,Ma(s,r);}if(i.zoom){const e=za(i.zoom,o,Ra);s.zoom=this._map.transform.zoom+e.amount,Ma(s,e);}if(i.bearing){const t=za(i.bearing,o,Aa);s.bearing=this._map.transform.bearing+e.ap(t.amount,-179,179),Ma(s,t);}if(i.pitch){const e=za(i.pitch,o,La);s.pitch=this._map.transform.pitch+e.amount,Ma(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 Ma(e,t){(!e.duration||e.duration<t.duration)&&(e.duration=t.duration,e.easing=t.easing);}function za(t,i,o){const{maxSpeed:s,linearity:r,deceleration:a}=o,n=e.ap(t*r/(i/1e3),-s,s),l=Math.abs(n)/(a*r);return {easing:o.easing,duration:1e3*l,amount:n*(l/2)}}class Oa extends e.x{preventDefault(){this._defaultPrevented=!0;}get defaultPrevented(){return this._defaultPrevented}constructor(t,i,o,s={}){const r=g(i.getCanvasContainer(),o),a=i.unproject(r);super(t,e.l({point:r,lngLat:a,originalEvent:o},s)),this._defaultPrevented=!1,this.target=i;}}class Fa extends e.x{preventDefault(){this._defaultPrevented=!0;}get defaultPrevented(){return this._defaultPrevented}constructor(t,i,o){const s="touchend"===t?o.changedTouches:o.touches,r=v(i.getCanvasContainer(),s),a=r.map((e=>i.unproject(e))),n=r.reduce(((e,t,i,o)=>e.add(t.div(o.length))),new e.P(0,0));super(t,{points:r,point:n,lngLats:a,lngLat:i.unproject(n),originalEvent:o}),this._defaultPrevented=!1;}}class Ba extends e.x{preventDefault(){this._defaultPrevented=!0;}get defaultPrevented(){return this._defaultPrevented}constructor(e,t){super("wheel",{originalEvent:t}),this._defaultPrevented=!1;}}class ka{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance;}reset(){this._mousedownPos=void 0;}wheel(e){return this._firePreventable(new Ba(this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new Oa(e.type,this._map,e))}mouseup(e){this._map.fire(new Oa(e.type,this._map,e));}preclick(t){const i=e.l({},t);i.type="preclick",this._map.fire(new Oa(i.type,this._map,i));}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||(this.preclick(e),this._map.fire(new Oa(e.type,this._map,e)));}dblclick(e){return this._firePreventable(new Oa(e.type,this._map,e))}mouseover(e){this._map.fire(new Oa(e.type,this._map,e));}mouseout(e){this._map.fire(new Oa(e.type,this._map,e));}touchstart(e){return this._firePreventable(new Fa(e.type,this._map,e))}touchmove(e){this._map.fire(new Fa(e.type,this._map,e));}touchend(e){this._map.fire(new Fa(e.type,this._map,e));}touchcancel(e){this._map.fire(new Fa(e.type,this._map,e));}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return {}}isEnabled(){return !0}isActive(){return !1}enable(){}disable(){}}class Na{constructor(e){this._map=e;}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0;}mousemove(e){this._map.fire(new Oa(e.type,this._map,e));}mousedown(){this._delayContextMenu=!0;}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Oa("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent);}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._map.fire(new Oa(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault();}isEnabled(){return !0}isActive(){return !1}enable(){}disable(){}}class Ua{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._clickTolerance)return;this._lastPos=i,this._box||(this._box=l("div","mapboxgl-boxzoom",this._container),this._container.classList.add("mapboxgl-crosshair"),this._fireEvent("boxzoomstart",e));const r=Math.min(o.x,i.x),a=Math.max(o.x,i.x),n=Math.min(o.y,i.y),c=Math.max(o.y,i.y);this._map._requestDomTask((()=>{this._box&&(this._box.style.transform=`translate(${r}px,${n}px)`,this._box.style.width=a-r+"px",this._box.style.height=c-n+"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.x("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.x(t,{originalEvent:i}))}}function Ga(e,t){const i={};for(let o=0;o<e.length;o++)i[e[o].identifier]=t[o];return i}class Va{constructor(e){this.reset(),this.numTouches=e.numTouches;}reset(){this.centroid=void 0,this.startTime=0,this.touches={},this.aborted=!1;}touchstart(t,i,o){(this.centroid||o.length>this.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=Ga(o,i)));}touchmove(e,t,i){if(this.aborted||!this.centroid)return;const o=Ga(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 ja{constructor(e){this.singleTap=new Va(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 Ha{constructor(){this._zoomIn=new ja({numTouches:1,numTaps:2}),this._zoomOut=new ja({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 Za={0:1,2:2};class qa{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=x(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=Za[t];return void 0===e.buttons||(e.buttons&i)!==i}(e,this._eventButton))this.reset();else if(this._moved||!(t.dist(i)<this._clickTolerance))return this._moved=!0,this._lastPoint=t,this._move(i,t)}mouseupWindow(e){this._lastPoint&&x(e)===this._eventButton&&(this._moved&&m(),this.reset());}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class Wa extends qa{mousedown(e,t){super.mousedown(e,t),this._lastPoint&&(this._active=!0);}_correctButton(e,t){return 0===t&&!e.ctrlKey}_move(e,t){return {around:t,panDelta:t.sub(e)}}}class $a extends qa{_correctButton(e,t){return 0===t&&e.ctrlKey||2===t}_move(e,t){const i=.8*(t.x-e.x);if(i)return this._active=!0,{bearingDelta:i}}contextmenu(e){e.preventDefault();}}class Xa extends qa{_correctButton(e,t){return 0===t&&e.ctrlKey||2===t}_move(e,t){const i=-.5*(t.y-e.y);if(i)return this._active=!0,{pitchDelta:i}}contextmenu(e){e.preventDefault();}}class Ja{constructor(t,i){this._map=t,this._el=t.getCanvasContainer(),this._minTouches=1,this._clickTolerance=i.clickTolerance||1,this.reset(),e.aJ(["_addTouchPanBlocker","_showTouchPanBlockerAlert"],this);}reset(){this._active=!1,this._touches={},this._sum=new e.P(0,0);}touchstart(e,t,i){return this._calculateTransform(e,t,i)}touchmove(t,i,o){if(this._active&&!(o.length<this._minTouches)){if(this._map._cooperativeGestures&&!this._map.isMoving()){if(1===o.length&&!e.dq())return void this._showTouchPanBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer));}return t.cancelable&&t.preventDefault(),this._calculateTransform(t,i,o)}}touchend(e,t,i){this._calculateTransform(e,t,i),this._active&&i.length<this._minTouches&&this.reset();}touchcancel(){this.reset();}_calculateTransform(t,i,o){o.length>0&&(this._active=!0);const s=Ga(o,i),r=new e.P(0,0),a=new e.P(0,0);let n=0;for(const e in s){const t=s[e],i=this._touches[e];i&&(r._add(t),a._add(t.sub(i)),n++,s[e]=t);}if(this._touches=s,n<this._minTouches||!a.mag())return;const l=a.div(n);return this._sum._add(l),this._sum.mag()<this._clickTolerance?void 0:{around:r.div(n),panDelta:l}}enable(){this._enabled=!0,this._map._cooperativeGestures&&(this._addTouchPanBlocker(),this._el.classList.add("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page"));}disable(){this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove(),this._el.classList.remove("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page")),this.reset();}isEnabled(){return !!this._enabled}isActive(){return !!this._active}_addTouchPanBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=l("div","mapboxgl-touch-pan-blocker",this._map._container),this._alertContainer.textContent=this._map._getUIString("TouchPanBlocker.Message"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`);}_showTouchPanBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-touch-pan-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=window.setTimeout((()=>{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.removeAttribute("role");}),500);}}class Ka{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,a=Ya(i,t,s),n=Ya(i,t,r);if(!a||!n)return;const l=this._aroundCenter?null:a.add(n).div(2);return this._move([a,n],l,e)}touchend(e,t,i){if(!this._firstTwoTouches)return;const[o,s]=this._firstTwoTouches,r=Ya(i,t,o),a=Ya(i,t,s);r&&a||(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 Ya(e,t,i){for(let o=0;o<e.length;o++)if(e[o].identifier===i)return t[o]}function Qa(e,t){return Math.log(e/t)/Math.LN2}class en extends Ka{reset(){super.reset(),this._distance=0,this._startDistance=0;}_start(e){this._startDistance=this._distance=e[0].dist(e[1]);}_move(e,t){const i=this._distance;if(this._distance=e[0].dist(e[1]),this._active||!(Math.abs(Qa(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:Qa(this._distance,i),pinchAround:t}}}function tn(e,t){return 180*e.angleWith(t)/Math.PI}class on extends Ka{reset(){super.reset(),this._minDiameter=0,this._startVector=void 0,this._vector=void 0;}_start(e){this._startVector=this._vector=e[0].sub(e[1]),this._minDiameter=e[0].dist(e[1]);}_move(e,t){const i=this._vector;if(this._vector=e[0].sub(e[1]),i&&(this._active||!this._isBelowThreshold(this._vector)))return this._active=!0,{bearingDelta:tn(this._vector,i),pinchAround:t}}_isBelowThreshold(e){this._minDiameter=Math.min(this._minDiameter,e.mag());const t=25/(Math.PI*this._minDiameter)*360,i=this._startVector;if(!i)return !1;const o=tn(e,i);return Math.abs(o)<t}}function sn(e){return Math.abs(e.y)>Math.abs(e.x)}class rn extends Ka{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,sn(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]),a=t[1].sub(s[1]);return this._map._cooperativeGestures&&!e.dq()&&o.touches.length<3||(this._valid=this.gestureBeginsVertically(r,a,o.timeStamp),!this._valid)?void 0:(this._lastPoints=t,this._active=!0,{pitchDelta:(r.y+a.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 sn(e)&&sn(t)&&r}}const an={panStep:100,bearingStep:15,pitchStep:10};class nn{constructor(){const e=an;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:a=>{const n=a.getZoom();a.easeTo({duration:300,easeId:"keyboardHandler",easing:ln,zoom:t?Math.round(n)+t*(e.shiftKey?2:1):n,bearing:a.getBearing()+i*this._bearingStep,pitch:a.getPitch()+o*this._pitchStep,offset:[-s*this._panStep,-r*this._panStep],center:a.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 ln(e){return e*(2-e)}const cn=4.000244140625,hn=1/450;class un{constructor(t,i){this._map=t,this._el=t.getCanvasContainer(),this._handler=i,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=hn,e.aJ(["_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.dq()))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.q.now(),s=o-(this._lastWheelEventTime||0);this._lastWheelEventTime=o,0!==i&&i%cn==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)>cn?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),a="number"==typeof this._targetZoom?t.zoomScale(this._targetZoom):r;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(a*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 a,n=!1;if("wheel"===this._type&&s&&r){const t=Math.min((e.q.now()-this._lastWheelEventTime)/200,1),i=r(t);a=e.aa(s,o,i),t<1?this._frameId||(this._frameId=!0):n=!0;}else a=o,n=!0;this._active=!0,n&&(this._active=!1,this._finishTimeout=window.setTimeout((()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout;}),200));let l=a-i();return l*this._lastDelta<0&&(l=0),{noInertia:!0,needsRenderFrame:!n,zoomDelta:l,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let i=e.dr;if(this._prevEase){const t=this._prevEase,o=(e.q.now()-t.start)/t.duration,s=t.easing(o+.01)-t.easing(o),r=.27/Math.sqrt(s*s+1e-4)*.01,a=Math.sqrt(.0729-r*r);i=e.dp(r,a,.25,1);}return this._prevEase={start:e.q.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 dn{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 _n{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 pn{constructor(){this._tap=new ja({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 fn{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 mn{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 gn{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 vn=e=>e.zoom||e.drag||e.pitch||e.rotate;class xn extends e.x{}class yn{constructor(){this.constants=[1,1,.01],this.radius=0;}setup(t,i){const o=e.a6.vec3.sub([],i,t);this.radius=e.a6.vec3.length(o[2]<0?e.a6.vec3.div([],o,this.constants):[o[0],o[1],0]);}projectRay(t){e.a6.vec3.div(t,t,this.constants),e.a6.vec3.normalize(t,t),e.a6.vec3.mul(t,t,this.constants);const i=e.a6.vec3.scale([],t,this.radius);if(i[2]>0){const t=e.a6.vec3.scale([],[0,0,1],e.a6.vec3.dot(i,[0,0,1])),o=e.a6.vec3.scale([],e.a6.vec3.normalize([],[i[0],i[1],0]),this.radius),s=e.a6.vec3.add([],i,e.a6.vec3.scale([],e.a6.vec3.sub([],e.a6.vec3.add([],o,t),i),2));i[0]=s[0],i[1]=s[1];}return i}}function bn(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta}class wn{constructor(t,i){this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Pa(t),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new yn,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(i),e.aJ(["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 ka(t,e));const o=t.boxZoom=new Ua(t,e);this._add("boxZoom",o);const s=new Ha,r=new _n;t.doubleClickZoom=new dn(r,s),this._add("tapZoom",s),this._add("clickZoom",r);const a=new pn;this._add("tapDragZoom",a);const n=t.touchPitch=new rn(t);this._add("touchPitch",n);const l=new $a(e),c=new Xa(e);t.dragRotate=new mn(e,l,c),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",c,["mouseRotate"]);const h=new Wa(e),u=new Ja(t,e);t.dragPan=new fn(i,h,u),this._add("mousePan",h),this._add("touchPan",u,["touchZoom","touchRotate"]);const d=new on,_=new en;t.touchZoomRotate=new gn(i,_,d,a),this._add("touchRotate",d,["touchPan","touchZoom"]),this._add("touchZoom",_,["touchPan","touchRotate"]),this._add("blockableMapEvent",new Na(t));const p=t.scrollZoom=new un(t,this);this._add("scrollZoom",p,["mousePan"]);const f=t.keyboard=new nn;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 !!vn(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={},a={},n=e.touches?this._getMapTouches(e.touches):void 0,l=n?v(this._el,n):i?void 0:g(this._el,e);for(const{handlerName:i,handler:c,allowed:h}of this._handlers){if(!c.isEnabled())continue;let u;this._blockedByActive(a,h,i)?c.reset():c[t||e.type]&&(u=c[t||e.type](e,l,n),this.mergeHandlerResult(s,r,u,i,o),u&&u.needsRenderFrame&&this._triggerRenderFrame()),(u||c.isActive())&&(a[i]=c);}const c={};for(const e in this._previousActiveHandlers)a[e]||(c[e]=o);this._previousActiveHandlers=a,(Object.keys(c).length||bn(s))&&(this._changes.push([s,r,c]),this._triggerRenderFrame()),(Object.keys(a).length||bn(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(t,i,o,s,r){if(!o)return;e.l(t,o);const a={handlerName:s,originalEvent:o.originalEvent||r};void 0!==o.zoomDelta&&(i.zoom=a),void 0!==o.panDelta&&(i.drag=a),void 0!==o.pitchDelta&&(i.pitch=a),void 0!==o.bearingDelta&&(i.rotate=a);}_applyChanges(){const t={},i={},o={};for(const[s,r,a]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),e.l(i,r),e.l(o,a);this._updateMapTransform(t,i,o),this._changes=[];}_updateMapTransform(t,i,o){const s=this._map,r=s.transform,a=e=>[e.x,e.y,e.z];if((e=>{const t=this._eventsInProgress.drag;return t&&!this._handlersById[t.handlerName].isActive()})()&&!bn(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),!bn(t))return void this._fireEvents(i,o,!0);let{panDelta:n,zoomDelta:l,bearingDelta:c,pitchDelta:h,around:u,aroundCoord:d,pinchAround:_}=t;r._isCameraConstrained&&(l>0&&(l=0),r._isCameraConstrained=!1),void 0!==_&&(u=_),(l||(e=>i[e]&&!this._eventsInProgress[e])("drag"))&&u&&(this._dragOrigin=a(r.pointCoordinate3D(u)),this._originalZoom=r.zoom,this._trackingEllipsoid.setup(r._camera.position,this._dragOrigin)),r.cameraElevationReference="sea",s._stop(!0),u=u||s.transform.centerPoint,c&&(r.bearing+=c),h&&(r.pitch+=h),r._updateCameraState();const p=[0,0,0];if(n)if("mercator"===r.projection.name){const e=this._trackingEllipsoid.projectRay(r.screenPointToMercatorRay(u).dir),t=this._trackingEllipsoid.projectRay(r.screenPointToMercatorRay(u.sub(n)).dir);p[0]=t[0]-e[0],p[1]=t[1]-e[1];}else {const t=r.pointCoordinate(u);if("globe"===r.projection.name){n=n.rotate(-r.angle);const i=r._pixelsPerMercatorPixel/r.worldSize;p[0]=-n.x*e.ds(e.aN(t.y))*i,p[1]=-n.y*e.ds(r.center.lat)*i;}else {const e=r.pointCoordinate(u.sub(n));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=a(d||r.pointCoordinate3D(u)),i={dir:e.a6.vec3.normalize([],e.a6.vec3.sub([],t,r._camera.position))};if(i.dir[2]<0){const o=r.zoomDeltaToMovement(t,l);e.a6.vec3.scale(m,i.dir,o);}}const g=e.a6.vec3.add(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=vn(this._eventsInProgress),r=vn(t),a={};for(const e in t){const{originalEvent:i}=t[e];this._eventsInProgress[e]||(a[`${e}start`]=i),this._eventsInProgress[e]=t[e];}!s&&r&&this._fireEvent("movestart",r.originalEvent);for(const e in a)this._fireEvent(e,a[e]);r&&this._fireEvent("move",r.originalEvent);for(const e in t){const{originalEvent:i}=t[e];this._fireEvent(e,i);}const n={};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,n[`${e}end`]=l);}for(const e in n)this._fireEvent(e,n[e]);const c=vn(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<e&&e<this._bearingSnap;t?(i(t.bearing||this._map.getBearing())&&(t.bearing=0),this._map.easeTo(t,{originalEvent:l})):(this._map.fire(new e.x("moveend",{originalEvent:l})),i(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1;}}_fireEvent(t,i){this._map.fire(new e.x(t,i?{originalEvent:i}:{}));}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add((e=>{this._frameId=void 0,this.handleEvent(new xn("renderFrame",{timeStamp:e})),this._applyChanges();}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame());}}const Tn="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class En 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.aJ(["_renderFrameCallback"],this);}getCenter(){return new e.bL(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,e.l({offset:t},i),o)}panTo(t,i,o){return this.easeTo(e.l({center:t},i),o)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(t,i,o){return this.easeTo(e.l({zoom:t},i),o)}zoomIn(e,t){return this.zoomTo(this.getZoom()+1,e,t),this}zoomOut(e,t){return this.zoomTo(this.getZoom()-1,e,t),this}getBearing(){return this.transform.bearing}setBearing(e,t){return this.jumpTo({bearing:e},t),this}getPadding(){return this.transform.padding}setPadding(e,t){return this.jumpTo({padding:e},t),this}rotateTo(t,i,o){return this.easeTo(e.l({bearing:t},i),o)}resetNorth(t,i){return this.rotateTo(0,e.l({duration:1e3},t),i),this}resetNorthPitch(t,i){return this.easeTo(e.l({bearing:0,pitch:0,duration:1e3},t),i),this}snapToNorth(e,t){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(e,t):this}getPitch(){return this.transform.pitch}setPitch(e,t){return this.jumpTo({pitch:e},t),this}cameraForBounds(t,i){t=e.as.convert(t);const o=i&&i.bearing||0,s=i&&i.pitch||0,r=t.getNorthWest(),a=t.getSouthEast();return this._cameraForBounds(this.transform,r,a,o,s,i)}_extendPadding(t){const i={top:0,right:0,bottom:0,left:0};return null==t?e.l({},i,this.transform.padding):"number"==typeof t?{top:t,bottom:t,right:t,left:t}:e.l({},i,t)}_extendCameraOptions(t){return (t=e.l({offset:[0,0],maxZoom:this.transform.maxZoom},t)).padding=this._extendPadding(t.padding),t}_minimumAABBFrustumDistance(e,t){const i=t.max[0]-t.min[0],o=t.max[1]-t.min[1];return i/o>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,a){const n=t.clone(),l=this._extendCameraOptions(a);n.bearing=s,n.pitch=r;const c=e.bL.convert(i),h=e.bL.convert(o),u=.5*(c.lat+h.lat),d=.5*(c.lng+h.lng),_=e.dt(u,d),p=e.a6.vec3.normalize([],_),f=e.a6.vec3.normalize([],e.a6.vec3.cross([],p,[0,1,0])),m=e.a6.vec3.cross([],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.dt(c.lat,c.lng),e.dt(h.lat,c.lng),e.dt(h.lat,h.lng),e.dt(c.lat,h.lng),e.dt(u,c.lng),e.dt(u,h.lng),e.dt(c.lat,d),e.dt(h.lat,d)];let x=e.ca.fromPoints(v.map((t=>[e.a6.vec3.dot(f,t),e.a6.vec3.dot(m,t),e.a6.vec3.dot(p,t)])));const y=e.a6.vec3.transformMat4([],x.center,g);0===e.a6.vec3.squaredLength(y)&&e.a6.vec3.set(y,0,0,1),e.a6.vec3.normalize(y,y),e.a6.vec3.scale(y,y,e.aq),n.center=e.du(y);const b=n.getWorldToCameraMatrix(),w=e.a6.mat4.invert(new Float64Array(16),b);x=e.ca.applyTransform(x,e.a6.mat4.multiply([],b,g));const T=this._extendAABB(x,n,l,s);if(!T)return void e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");x=T,e.a6.vec3.transformMat4(y,y,b);const E=.5*(x.max[2]-x.min[2]),S=this._minimumAABBFrustumDistance(n,x),C=e.a6.vec3.scale([],[0,0,1],E),I=e.a6.vec3.add(C,y,C),D=S+(0===n.pitch?0:e.a6.vec3.distance(y,I)),R=n.globeCenterInViewSpace,A=e.a6.vec3.sub([],y,[R[0],R[1],R[2]]);e.a6.vec3.normalize(A,A),e.a6.vec3.scale(A,A,D);const L=e.a6.vec3.add([],y,A);e.a6.vec3.transformMat4(L,L,w);const P=e.dw/e.aq,M=e.a6.vec3.length(L),z=e.bE(Math.max(M*P-e.dw,Number.EPSILON),0),O=Math.min(n.zoomFromMercatorZAdjusted(z),l.maxZoom);return O>.5*(e.c3+e.bV)?(n.setProjection({name:"mercator"}),n.zoom=O,this._cameraForBounds(n,i,o,s,r,a)):{center:n.center,zoom:O,bearing:s,pitch:r}}_extendAABB(t,i,o,s){const r=.5*((o.padding.left||0)+(o.padding.right||0)),a=.5*((o.padding.top||0)+(o.padding.bottom||0)),n=a,l=r,c=r,h=a,u=i.width-(l+c),d=i.height-(n+h),_=e.a6.vec3.sub([],t.max,t.min),p=Math.min(u/_[0],d/_[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.ca([t.min[0]-l*m,t.min[1]-h*m,t.min[2]],[t.max[0]+c*m,t.max[1]+n*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.bC(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=e.l({},{exaggerated:!0},i),o.getAtPoint(e.a5.fromLngLat(t),null,i.exaggerated)):null}_cameraForBounds(t,i,o,s,r,a){if("globe"===t.projection.name)return this._cameraForBoundsOnGlobe(t,i,o,s,r,a);const n=t.clone(),l=this._extendCameraOptions(a);n.bearing=s,n.pitch=r;const c=e.bL.convert(i),h=e.bL.convert(o),u=new e.bL(c.lng,h.lat),d=new e.bL(h.lng,c.lat),_=n.project(c),p=n.project(h),f=this.queryTerrainElevation(c),m=this.queryTerrainElevation(h),g=this.queryTerrainElevation(u),v=this.queryTerrainElevation(d),x=[[_.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 y=e.ca.fromPoints(x);const b=n.getWorldToCameraMatrix(),w=e.a6.mat4.invert(new Float64Array(16),b);y=e.ca.applyTransform(y,b);const T=this._extendAABB(y,n,l,s);if(!T)return void e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");y=T;const E=.5*e.a6.vec3.sub([],y.max,y.min)[2],S=this._minimumAABBFrustumDistance(n,y),C=[0,0,1,0];e.a6.vec4.transformMat4(C,C,b),e.a6.vec4.normalize(C,C);const I=e.a6.vec3.scale([],C,S+E),D=e.a6.vec3.add([],y.center,I);e.a6.vec3.transformMat4(y.center,y.center,w),e.a6.vec3.transformMat4(D,D,w);const R=n.unproject(new e.P(y.center[0],y.center[1])),A=e.dv(n.projection,R),L=Math.pow(2,A),P=Math.min(n._zoomFromMercatorZ(D[2]*n.pixelsPerMeter*L/n.worldSize),l.maxZoom);return n.mercatorFromTransition&&P<.5*(e.c3+e.bV)?(n.setProjection({name:"globe"}),n.zoom=P,this._cameraForBounds(n,i,o,s,r,a)):{center:R,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 a=e.P.convert(t),n=e.P.convert(i),l=new e.P(Math.min(a.x,n.x),Math.min(a.y,n.y)),c=new e.P(Math.max(a.x,n.x),Math.max(a.y,n.y));if("mercator"===this.transform.projection.name&&this.transform.anyCornerOffEdge(a,n))return this;const h=this.transform.pointLocation3D(l),u=this.transform.pointLocation3D(c),d=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,u.lng,d.lng,_.lng),Math.min(h.lat,u.lat,d.lat,_.lat)],f=[Math.max(h.lng,u.lng,d.lng,_.lng),Math.max(h.lat,u.lat,d.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(t,i,o){return t?(i=e.l(t,i)).linear?this.easeTo(i,o):this.flyTo(i,o):this}jumpTo(t,i){this.stop();const o=t.preloadOnly?this.transform.clone():this.transform;let s=!1,r=!1,a=!1;"zoom"in t&&o.zoom!==+t.zoom&&(s=!0,o.zoom=+t.zoom),void 0!==t.center&&(o.center=e.bL.convert(t.center)),"bearing"in t&&o.bearing!==+t.bearing&&(r=!0,o.bearing=+t.bearing),"pitch"in t&&o.pitch!==+t.pitch&&(a=!0,o.pitch=+t.pitch);const n="number"==typeof t.padding?this._extendPadding(t.padding):t.padding;if(null!=t.padding&&!o.isPaddingEqual(n))if(!1===t.retainPadding){const e=o.clone();e.padding=n,o.setLocationAtPoint(o.center,e.centerPoint);}else o.padding=n;return t.preloadOnly?(this._preloadTiles(o),this):(this.fire(new e.x("movestart",i)).fire(new e.x("move",i)),s&&this.fire(new e.x("zoomstart",i)).fire(new e.x("zoom",i)).fire(new e.x("zoomend",i)),r&&this.fire(new e.x("rotatestart",i)).fire(new e.x("rotate",i)).fire(new e.x("rotateend",i)),a&&this.fire(new e.x("pitchstart",i)).fire(new e.x("pitch",i)).fire(new e.x("pitchend",i)),this.fire(new e.x("moveend",i)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||e.w(Tn),this.transform.getFreeCameraOptions()}setFreeCameraOptions(t,i){const o=this.transform;if(!o.projection.supportsFreeCamera)return e.w(Tn),this;this.stop();const s=o.zoom,r=o.pitch,a=o.bearing;o.setFreeCameraOptions(t);const n=s!==o.zoom,l=r!==o.pitch,c=a!==o.bearing;return this.fire(new e.x("movestart",i)).fire(new e.x("move",i)),n&&this.fire(new e.x("zoomstart",i)).fire(new e.x("zoom",i)).fire(new e.x("zoomend",i)),c&&this.fire(new e.x("rotatestart",i)).fire(new e.x("rotate",i)).fire(new e.x("rotateend",i)),l&&this.fire(new e.x("pitchstart",i)).fire(new e.x("pitch",i)).fire(new e.x("pitchend",i)),this.fire(new e.x("moveend",i)),this}easeTo(t,i){this._stop(!1,t.easeId),(!1===(t=e.l({offset:[0,0],duration:500,easing:e.dr},t)).animate||this._prefersReducedMotion(t))&&(t.duration=0);const o=this.transform,s=this.getZoom(),r=this.getBearing(),a=this.getPitch(),n=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:a,u=this._extendPadding(t.padding),d=e.P.convert(t.offset);let _,p,f;if("globe"===o.projection.name){const i=e.a5.fromLngLat(o.center),s=d.rotate(-o.angle);i.x+=s.x/o.worldSize,i.y+=s.y/o.worldSize;const r=i.toLngLat(),a=e.bL.convert(t.center||r);this._normalizeCenter(a),_=o.centerPoint.add(s),p=new e.P(i.x,i.y).mult(o.worldSize),f=new e.P(e.am(a.lng),e.at(a.lat)).mult(o.worldSize).sub(p);}else {_=o.centerPoint.add(d);const i=o.pointLocation(_),s=e.bL.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.bL.convert(t.around),v=o.locationPoint(g));const x=this._zooming||l!==s,y=this._rotating||r!==c,b=this._pitching||h!==a,w=!o.isPaddingEqual(u),T=!1===t.retainPadding?o.clone():o,E=o=>E=>{if(x&&(o.zoom=e.aa(s,l,E)),y&&(o.bearing=e.aa(r,c,E)),b&&(o.pitch=e.aa(a,h,E)),w&&(T.interpolatePadding(n,u,E),_=T.centerPoint.add(d)),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=x,this._rotating=y,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.x("movestart",t)),this._zooming&&!o.zooming&&this.fire(new e.x("zoomstart",t)),this._rotating&&!o.rotating&&this.fire(new e.x("rotatestart",t)),this._pitching&&!o.pitching&&this.fire(new e.x("pitchstart",t));}_fireMoveEvents(t){this.fire(new e.x("move",t)),this._zooming&&this.fire(new e.x("zoom",t)),this._rotating&&this.fire(new e.x("rotate",t)),this._pitching&&this.fire(new e.x("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.x("zoomend",t)),s&&this.fire(new e.x("rotateend",t)),r&&this.fire(new e.x("pitchend",t)),this.fire(new e.x("moveend",t));}flyTo(t,i){if(this._prefersReducedMotion(t)){const o=e.ar(t,["center","zoom","bearing","pitch","around","padding","retainPadding"]);return this.jumpTo(o,i)}this.stop(),t=e.l({offset:[0,0],speed:1.2,curve:1.42,easing:e.dr},t);const o=this.transform,s=this.getZoom(),r=this.getBearing(),a=this.getPitch(),n=this.getPadding(),l="zoom"in t?e.ap(+t.zoom,o.minZoom,o.maxZoom):s,c="bearing"in t?this._normalizeBearing(t.bearing,r):r,h="pitch"in t?+t.pitch:a,u=this._extendPadding(t.padding),d=o.zoomScale(l-s),_=e.P.convert(t.offset);let p=o.centerPoint.add(_);const f=o.pointLocation(p),m=e.bL.convert(t.center||f);this._normalizeCenter(m);const g=o.project(f),v=o.project(m).sub(g);let x=t.curve;const y=Math.max(o.width,o.height),b=y/d,w=v.mag();if("minZoom"in t){const i=e.ap(Math.min(t.minZoom,s,l),o.minZoom,o.maxZoom),r=y/o.zoomScale(i-s);x=Math.sqrt(r/w*2);}const T=x*x;function E(e){const t=(b*b-y*y+(e?-1:1)*T*T*w*w)/(2*(e?b:y)*T*w);return Math.log(Math.sqrt(t*t+1)-t)}function S(e){return (Math.exp(e)-Math.exp(-e))/2}function C(e){return (Math.exp(e)+Math.exp(-e))/2}const I=E(0);let D=function(e){return C(I)/C(I+x*e)},R=function(e){return y*((C(I)*(S(t=I+x*e)/C(t))-S(I))/T)/w;var t;},A=(E(1)-I)/x;if(Math.abs(w)<1e-6||!isFinite(A)){if(Math.abs(y-b)<1e-6)return this.easeTo(t,i);const e=b<y?-1:1;A=Math.abs(Math.log(b/y))/x,R=function(){return 0},D=function(t){return Math.exp(e*x*t)};}t.duration="duration"in t?+t.duration:1e3*A/("screenSpeed"in t?+t.screenSpeed/x:+t.speed),t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0);const L=r!==c,P=h!==a,M=!o.isPaddingEqual(u),z=!1===t.retainPadding?o.clone():o,O=o=>d=>{const f=d*A,x=1/D(f);o.zoom=1===d?l:s+o.scaleZoom(x),L&&(o.bearing=e.aa(r,c,d)),P&&(o.pitch=e.aa(a,h,d)),M&&(z.interpolatePadding(n,u,d),p=z.centerPoint.add(_));const y=1===d?m:o.unproject(g.add(v.mult(R(f))).mult(x));return o.setLocationAtPoint(o.renderWorldCopies?y.wrap():y,p),o._updateCameraOnTerrain(),t.preloadOnly||this._fireMoveEvents(i),o};if(t.preloadOnly){const e=this._emulate(O,t.duration,o);return this._preloadTiles(e),this}return this._zooming=!0,this._rotating=L,this._pitching=P,this._padding=M,this._prepareEase(i,!1),this._ease(O(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.q.now(),this._easeOptions=o,this._onEaseFrame=t,this._onEaseEnd=i,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback));}_renderFrameCallback(){const t=Math.min((e.q.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.bB(t,-180,180);const o=Math.abs(t-i);return Math.abs(t-360-i)<o&&(t-=360),Math.abs(t+360-i)<o&&(t+=360),t}_normalizeCenter(e){const t=this.transform;if(t.maxBounds)return;if("globe"!==t.projection.name&&!t.renderWorldCopies)return;const i=e.lng-t.center.lng;e.lng+=i>180?-360:i<-180?360:0;}_prefersReducedMotion(t){return this._respectPrefersReducedMotion&&e.q.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 Sn{constructor(t={}){this.options=t,e.aJ(["_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}${o<i.length-1?"&":""}`),e)),"?");t.href=`${e.e.FEEDBACK_URL}/${o}#${Ca(this._map,!0)}`,t.rel="noopener nofollow";}}_updateData(e){!e||"metadata"!==e.sourceDataType&&"visibility"!==e.sourceDataType&&"style"!==e.dataType||(this._updateAttributions(),this._updateEditLink());}_updateAttributions(){if(!this._map.style)return;let e=[];if(this._map.style.stylesheet){const e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id;}const t=this._map.style._mergedSourceCaches;for(const i in t){const o=t[i];if(o.used){const t=o.getSource();t.attribution&&e.indexOf(t.attribution)<0&&e.push(t.attribution);}}e.sort(((e,t)=>e.length-t.length)),e=e.filter(((t,i)=>{for(let o=i+1;o<e.length;o++)if(e[o].indexOf(t)>=0)return !1;return !0})),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=[...this.options.customAttribution,...e]:e.unshift(this.options.customAttribution));const i=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 Cn{constructor(){e.aJ(["_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 In{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 Dn{constructor(e){this.jumpTo(e);}getValue(t){if(t<=this._startTime)return this._start;if(t>=this._endTime)return this._end;const i=e.cw((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 Rn={"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"},An=["mouseenter","mouseover","mouseleave","mouseout"];class Ln extends e.x{constructor(e,t,i,o){const{point:s,lngLat:r,originalEvent:a,target:n}=e;super(e.type,{point:s,lngLat:r,originalEvent:a,target:n}),this.preventDefault=()=>{e.preventDefault();},this.id=t,this.interaction=i,this.feature=o;}}class Pn{constructor(e){this.map=e,this.interactionsByType=new Map,this.typeById=new Map,this.filters=new Map,this.handleType=this.handleType.bind(this);}add(t,i){if(this.typeById.has(t))throw new Error(`Interaction id "${t}" already exists.`);const{type:o,filter:s}=i;if(s){const i=e.M(s,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===i.result)throw new Error(i.value.map((e=>`${e.key}: ${e.message}`)).join(", "));this.filters.set(t,i.value);}const r=this.interactionsByType.get(o)||new Map;0===r.size&&(An.includes(o)?this.map.on(o,i.featureset,this.handleType):this.map.on(o,this.handleType),this.interactionsByType.set(o,r)),r.set(t,i),this.typeById.set(t,o);}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),0===i.size&&this.map.off(t,this.handleType));}handleType(t){const i=this.interactionsByType.get(t.type),o=Array.from(i).reverse(),s=[];for(const[,e]of o)e.featureset&&s.push({featureset:e.featureset,filter:e.filter,radius:e.radius});let r=this.map.style.queryRenderedFeaturesForInteractions(t.point,s,this.map.transform);!r.length&&An.includes(t.type)&&(r=[null]);let a=!1;for(const i of r){for(const[s,r]of o){const{handler:o,featureset:n}=r;if(n&&(null==i||e.bi(i.featureset,n))&&!1!==o(new Ln(t,s,r,i))){a=!0;break}}if(a)break}if(!a)for(const[e,i]of o){const{handler:o,featureset:s}=i;if(!s&&!1!==o(new Ln(t,e,i,null)))break}}}function Mn(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.bi(t,i)}const zn={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},On={showCompass:!0,showZoom:!0,visualizePitch:!1};class Fn{constructor(t,i,o=!1){this._clickTolerance=10,this.element=i,this.mouseRotate=new $a({clickTolerance:t.dragRotate._mouseRotate._clickTolerance}),this.map=t,o&&(this.mousePitch=new Xa({clickTolerance:t.dragRotate._mousePitch._clickTolerance})),e.aJ(["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,{passive:!1}),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(t){this.down(e.l({},t,{ctrlKey:!0,preventDefault:()=>t.preventDefault()}),g(this.element,t)),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({preventDefault:()=>e.preventDefault()},this._lastPos));}touchend(e){0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),this.reset();}reset(){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp();}}function Bn(t,i,o){if(t=new e.bL(t.lng,t.lat),i){const s=new e.bL(t.lng-360,t.lat),r=new e.bL(t.lng+360,t.lat),a=360*Math.ceil(Math.abs(t.lng-o.center.lng)/360),n=o.locationPoint(t).distSqr(i),l=i.x<0||i.y<0||i.x>o.width||i.y>o.height;o.locationPoint(s).distSqr(i)<n&&(l||Math.abs(s.lng-o.center.lng)<a)?t=s:o.locationPoint(r).distSqr(i)<n&&(l||Math.abs(r.lng-o.center.lng)<a)&&(t=r);}for(;Math.abs(t.lng-o.center.lng)>180;){const e=o.locationPoint(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 kn={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};class Nn extends e.E{constructor(t,i){if(super(),(t instanceof HTMLElement||i)&&(t=e.l({element:t},i)),e.aJ(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this),this._anchor=t&&t.anchor||"center",this._color=t&&t.color||"#3FB1CE",this._scale=t&&t.scale||1,this._draggable=t&&t.draggable||!1,this._clickTolerance=t&&t.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=t&&t.rotation||0,this._rotationAlignment=t&&t.rotationAlignment||"auto",this._pitchAlignment=t&&t.pitchAlignment&&t.pitchAlignment||"auto",this._updateMoving=()=>this._update(!0),this._occludedOpacity=t&&t.occludedOpacity||.2,t&&t.element)this._element=t.element,this._offset=e.P.convert(t&&t.offset||[0,0]);else {this._defaultMarker=!0,this._element=l("div");const i=41,o=27,s=c("svg",{display:"block",height:i*this._scale+"px",width:o*this._scale+"px",viewBox:`0 0 ${o} ${i}`},this._element),r=c("radialGradient",{id:"shadowGradient"},c("defs",{},s));c("stop",{offset:"10%","stop-opacity":.4},r),c("stop",{offset:"100%","stop-opacity":.05},r),c("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},s),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"},s),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"},s),c("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},s),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 o=this._element.classList;for(const e in kn)o.remove(`mapboxgl-marker-anchor-${e}`);o.add(`mapboxgl-marker-anchor-${this._anchor}`);const s=t&&t.className?t.className.trim().split(/\s+/):[];o.add(...s),this._popup=null;}addTo(e){return e===this._map||(this.remove(),this._map=e,e.getCanvasContainer().appendChild(this._element),e.on("move",this._updateMoving),e.on("moveend",this._update),e.on("remove",this._clearFadeTimer),e._addMarker(this),this.setDraggable(this._draggable),this._update(),e.on("click",this._onMapClick)),this}remove(){const e=this._map;return e&&(e.off("click",this._onMapClick),e.off("move",this._updateMoving),e.off("moveend",this._update),e.off("mousedown",this._addDragHandler),e.off("touchstart",this._addDragHandler),e.off("mouseup",this._onUp),e.off("touchend",this._onUp),e.off("mousemove",this._onMove),e.off("touchmove",this._onMove),e.off("remove",this._clearFadeTimer),e._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=e.bL.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeAttribute("role"),this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),e){if(!("offset"in e.options)){const t=38.1,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,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),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);let s;t._showingGlobe()&&e.dz(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 ${kn[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.c1(e.dA(i.transform,this._lngLat)),r=t.sub(e.dB(i.transform)),a=Math.abs(r.x)+Math.abs(r.y);if(0===a)return "";const n=s/a;return `rotateX(${-r.y*n}deg) rotateY(${r.x*n}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.bL(this._lngLat.lng,this._lngLat.lat+.001)),s=i.project(new e.bL(this._lngLat.lng,this._lngLat.lat-.001)).sub(t);o=e.c1(Math.atan2(s.y,s.x))-90;}else o=-i.getBearing();else if("horizon"===s){const s=e.a7(4,6,i.getZoom()),r=e.dB(i.transform);r.y+=s*i.transform.height;const a=t.sub(r),n=e.c1(Math.atan2(a.y,a.x));o=(n>90?n-270:n+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=Bn(this._lngLat,this._pos,t.transform)),this._pos=t.project(this._lngLat),!0===e?this._updateFrameId=requestAnimationFrame((()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM());})):this._pos=this._pos.round(),t._requestDomTask((()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(t._showingGlobe()||t.getTerrain()||t.getFog())&&!this._fadeTimer&&(this._fadeTimer=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)<e)return;this._isDragging=!0;}this._pos=t.point.sub(s),this._lngLat=i.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new e.x("dragstart"))),this.fire(new e.x("drag"));}}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1;const t=this._map;t&&(t.off("mousemove",this._onMove),t.off("touchmove",this._onMove)),"active"===this._state&&this.fire(new e.x("dragend")),this._state="inactive";}_addDragHandler(e){const t=this._map,i=this._pos;t&&i&&this._element.contains(e.originalEvent.target)&&(e.preventDefault(),this._positionDelta=e.point.sub(i),this._pointerdownPos=e.point,this._state="pending",t.on("mousemove",this._onMove),t.on("touchmove",this._onMove),t.once("mouseup",this._onUp),t.once("touchend",this._onUp));}setDraggable(e){this._draggable=!!e;const t=this._map;return t&&(e?(t.on("mousedown",this._addDragHandler),t.on("touchstart",this._addDragHandler)):(t.off("mousedown",this._addDragHandler),t.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||"auto",this._update(),this}getRotationAlignment(){return "auto"===this._rotationAlignment||"horizon"===this._rotationAlignment&&this._map&&!this._map._showingGlobe()?"viewport":this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e||"auto",this._update(),this}getPitchAlignment(){return "auto"===this._pitchAlignment?this.getRotationAlignment():this._pitchAlignment}setOccludedOpacity(e){return this._occludedOpacity=e||.2,this._update(),this}getOccludedOpacity(){return this._occludedOpacity}}const Un={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0,showUserHeading:!1},Gn={maxWidth:100,unit:"metric"},Vn={kilometer:"km",meter:"m",mile:"mi",foot:"ft","nautical-mile":"nm"},jn={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},Hn=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function Zn(t=new e.P(0,0),i="bottom"){if("number"==typeof t){const o=Math.round(Math.sqrt(.5*Math.pow(t,2)));switch(i){case"top":return new e.P(0,t);case"top-left":return new e.P(o,o);case"top-right":return new e.P(-o,o);case"bottom":return new e.P(0,-t);case"bottom-left":return new e.P(o,-o);case"bottom-right":return new e.P(-o,-o);case"left":return new e.P(t,0);case"right":return new e.P(-t,0)}return new e.P(0,0)}return t instanceof e.P||Array.isArray(t)?e.P.convert(t):e.P.convert(t[i]||[0,0])}const qn={version:t,supported:n.supported,setRTLTextPlugin:e.dC,getRTLTextPluginStatus:e.dD,Map:class extends En{constructor(t){o.mark(i.create);const s=t;if(null!=(t=e.l({},zn,t)).minZoom&&null!=t.maxZoom&&t.minZoom>t.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=t.minPitch&&null!=t.maxPitch&&t.minPitch>t.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=t.minPitch&&t.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=t.maxPitch&&t.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(t.antialias&&e.dx(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 Zi(t.minZoom,t.maxZoom,t.minPitch,t.maxPitch,t.renderWorldCopies),t),this._repaint=!!t.repaint,this._interactive=t.interactive,this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._failIfMajorPerformanceCaveat=t.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=t.preserveDrawingBuffer,this._antialias=t.antialias,this._trackResize=t.trackResize,this._bearingSnap=t.bearingSnap,this._refreshExpiredTiles=t.refreshExpiredTiles,this._fadeDuration=t.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=t.crossSourceCollisions,this._collectResourceTiming=t.collectResourceTiming,this._language=this._parseLanguage(t.language),this._worldview=t.worldview,this._renderTaskQueue=new In,this._domRenderTaskQueue=new In,this._controls=[],this._markers=[],this._popups=[],this._mapId=e.aQ(),this._locale=e.l({},Rn,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._scaleFactorChanged=!1,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new Dn(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?{...t.contextCreateOptions}:{},"string"==typeof t.container){const e=document.getElementById(t.container);if(!e)throw new Error(`Container '${t.container.toString()}' not found.`);this._container=e;}else {if(!(t.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=t.container;}if(this._container.childNodes.length>0&&e.w("The map container element should be empty, otherwise the map's interactivity will be negatively impacted. If you want to display a message when WebGL is not supported, use the Mapbox GL Supported plugin instead."),t.maxBounds&&this.setMaxBounds(t.maxBounds),e.aJ(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._tp||(this._tp=new ya),this._tp.registerParameter(this,["Debug"],"showOverdrawInspector"),this._tp.registerParameter(this,["Debug"],"showTileBoundaries"),this._tp.registerParameter(this,["Debug"],"showParseStatus"),this._tp.registerParameter(this,["Debug"],"repaint"),this._tp.registerParameter(this,["Debug"],"showTileAABBs"),this._tp.registerParameter(this,["Debug"],"showPadding"),this._tp.registerParameter(this,["Debug"],"showCollisionBoxes",{noSave:!0}),this._tp.registerParameter(this.transform,["Debug"],"freezeTileCoverage",{noSave:!0},(()=>{this._update();})),this._tp.registerParameter(this,["Debug","Wireframe"],"showTerrainWireframe"),this._tp.registerParameter(this,["Debug","Wireframe"],"showLayers2DWireframe"),this._tp.registerParameter(this,["Debug","Wireframe"],"showLayers3DWireframe"),this._tp.registerParameter(this,["Scaling"],"_scaleFactor",{min:.1,max:10,step:.1},(()=>{this.setScaleFactor(this._scaleFactor);})),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 wn(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 Sa("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 i=t.bounds;i&&(this.resize(),this.fitBounds(i,e.l({},t.fitBoundsOptions,{duration:0})));}this.resize(),t.attributionControl&&this.addControl(new Sn({customAttribution:t.customAttribution})),this._logoControl=new Cn,this.addControl(this._logoControl,t.logoPosition),this.on("style.load",(()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet),this._postStyleLoadEvent();})),this.on("data",(t=>{this._update("style"===t.dataType),this.fire(new e.x(`${t.dataType}data`,t));})),this.on("dataloading",(t=>{this.fire(new e.x(`${t.dataType}dataloading`,t));})),this._interactions=new Pn(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.t(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.t(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.x("movestart",t)).fire(new e.x("move",t)),this.fire(new e.x("resize",t)),i&&this.fire(new e.x("moveend",t)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(t){return this.transform.setMaxBounds(e.as.convert(t)),this._update()}setMinZoom(t){if((t=t??-2)>=-2&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()<t?this.setZoom(t):this.fire(new e.x("zoomstart")).fire(new e.x("zoom")).fire(new e.x("zoomend")),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(t){if((t=t??22)>=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t?this.setZoom(t):this.fire(new e.x("zoomstart")).fire(new e.x("zoom")).fire(new e.x("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()<t?this.setPitch(t):this.fire(new e.x("pitchstart")).fire(new e.x("pitch")).fire(new e.x("pitchend")),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(t){if((t=t??85)>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.x("pitchstart")).fire(new e.x("pitch")).fire(new e.x("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._tp.refreshUI(),this._scaleFactorChanged=!0,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.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.bV?(t.setMercatorFromTransition(),o=!0):"mercator"===i&&t.zoom<e.bV&&(t.setProjection({name:"globe"}),o=!0),o&&(this.style.applyProjectionUpdate(),this.style._forceSymbolLayerUpdate());}_prioritizeAndUpdateProjection(e,t){return this._updateProjection(e||t||{name:"mercator"})}_updateProjection(t){let i;return i="globe"===t.name&&this.transform.zoom>=e.bV?this.transform.setMercatorFromTransition():this.transform.setProjection(t),this.style.applyProjectionUpdate(),i&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}project(t){return this.transform.locationPoint3D(e.bL.convert(t))}unproject(t){return this.transform.pointLocation3D(e.P.convert(t))}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()||!1}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()||!1}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()||!1}_isDragging(){return this.handlers&&this.handlers._isDragging()||!1}_createDelegatedListener(e,t,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,{featureset: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 Oa(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 Oa(e,this,t.originalEvent)));},a=t=>{s&&(s=!1,i.call(this,new Oa(e,this,t.originalEvent)));};return {listener:i,targets:t,delegates:{mousemove:r,mouseout:a}}}{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<e.length;o++){const s=e[o];if(s.listener===i&&Mn(s.targets,t)){for(const e in s.delegates)this.off(e,s.delegates[e]);return e.splice(o,1),this}}})(o),this}queryRenderedFeatures(t,i){if(!this.style)return [];if(void 0!==i||void 0===t||t instanceof e.P||Array.isArray(t)||(i=t,t=void 0),t=t||[[0,0],[this.transform.width,this.transform.height]],"featureset"in(i=i||{}))return this._isFeaturesetDescriptorValid(i.featureset)?this.style.queryRenderedFeaturesForInteractions(t,[i],this.transform):[];if(i.layers&&Array.isArray(i.layers))for(const e of i.layers)if(!this._isValidId(e))return [];return this.style.queryRenderedFeatures(t,i,this.transform)}querySourceFeatures(e,t){return !e||"string"==typeof e&&!this._isValidId(e)?[]:this.style.querySourceFeatures(e,t)}isPointOnSurface(t){const{name:i}=this.transform.projection;return "globe"!==i&&"mercator"!==i&&e.w(`${i} projection does not support isPointOnSurface, this API may behave unexpectedly.`),this.transform.isPointOnSurface(e.P.convert(t))}addInteraction(e,t){return this._interactions.add(e,t),this}removeInteraction(e){return this._interactions.remove(e),this}setStyle(t,i){return i=e.l({},{localIdeographFontFamily:this._localIdeographFontFamily,localFontFamily:this._localFontFamily},i),this.style&&t&&!1!==i.diff&&i.localFontFamily===this._localFontFamily&&i.localIdeographFontFamily===this._localIdeographFontFamily&&!i.config?(this.style._diffStyle(t,((o,s)=>{o?(e.w(`Unable to perform style diff: ${String(o.message||o.error||o)}. Rebuilding the style from scratch.`),this._updateStyle(t,i)):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(t,i){if(this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),t){const o=e.l({},i);i&&i.config&&(o.initialConfig=i.config,delete o.config),this.style=new lo(this,o).load(t),this.style.setEventedParent(this,{style:this.style});}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new lo(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.t(new Error("IDs can't be empty."))),!1):!e.aK(t)||(this.fire(new e.t(new Error(`IDs can't contain special symbols: "${t}".`))),!1)}_isFeaturesetDescriptorValid(e){return "featuresetId"in e?this._isValidId(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._isFeaturesetDescriptorValid(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:a,content:n}={}){if(this._lazyInitEmptyStyle(),i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap){const{width:l,height:c,data:h}=e.q.getImageData(i);this.style.addImage(t,{data:new e.r({width:l,height:c},h),pixelRatio:o,stretchX:r,stretchY:a,content:n,sdf:s,version:0});}else if(void 0===i.width||void 0===i.height)this.fire(new e.t(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));else {const{width:l,height:c}=i,h=i;this.style.addImage(t,{data:new e.r({width:l,height:c},new Uint8Array(h.data)),pixelRatio:o,stretchX:r,stretchY:a,content:n,sdf:s,version:0,userImage:h}),h.onAdd&&h.onAdd(this,t);}}updateImage(t,i){this._lazyInitEmptyStyle();const o=this.style.getImage(t);if(!o)return void this.fire(new e.t(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const s=i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap?e.q.getImageData(i):i,{width:r,height:a,data:n}=s;if(void 0===r||void 0===a)return void this.fire(new e.t(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(r!==o.data.width||a!==o.data.height)return void this.fire(new e.t(new Error(`The width and height of the updated image (${r}, ${a})\n must be that same as the previous version of the image\n (${o.data.width}, ${o.data.height})`)));const l=!(i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap);o.data.replace(n,l),this.style.updateImage(t,o);}hasImage(t){return t?!!this.style&&!!this.style.getImage(t):(this.fire(new e.t(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e);}loadImage(t,i){e.o(this._requestManager.transformRequest(t,e.R.Image),((t,o)=>{i(t,o instanceof HTMLImageElement?e.q.getImageData(o):o);}));}listImages(){return this.style.listImages()}addModel(e,t){this._lazyInitEmptyStyle(),this.style.addModel(e,t);}hasModel(t){return t?this.style.hasModel(t):(this.fire(new e.t(new Error("Missing required model id"))),!1)}removeModel(e){this.style.removeModel(e);}listModels(){return this.style.listModels()}addLayer(e,t){return this._isValidId(e.id)?(this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)):this}getSlot(e){const t=this.getLayer(e);return t&&t.slot||null}setSlot(e,t){return this.style.setSlot(e,t),this.style.mergeLayers(),this._update(!0)}addImport(e,t){return this.style.addImport(e,t),this}updateImport(e,t){return "string"!=typeof t&&t.id!==e?(this.removeImport(e),this.addImport(t)):(this.style.updateImport(e,t),this._update(!0))}removeImport(e){return this.style.removeImport(e),this}moveImport(e,t){return this.style.moveImport(e,t),this._update(!0)}moveLayer(e,t){return this._isValidId(e)?(this.style.moveLayer(e,t),this._update(!0)):this}removeLayer(e){return this._isValidId(e)?(this.style.removeLayer(e),this._update(!0)):this}getLayer(e){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}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}setColorTheme(e){return this._lazyInitEmptyStyle(),this.style.setColorTheme(e),this._update(!0)}setCamera(e){return this.style.setCamera(e),this._triggerCameraUpdate(e)}_triggerCameraUpdate(e){return this._update(this.transform.setOrthographicProjectionAtLowPitch("orthographic"===e["camera-projection"]))}getCamera(){return this.style.camera}_queryFogOpacity(t){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(e.bL.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)}_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.q.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=e.l({},n.supported.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),i=this._canvas.getContext("webgl2",t);i?(G(i,!0),this.painter=new Ta(i,this._contextCreateOptions,this.transform,this._scaleFactor,this._tp),this.on("data",(e=>{"source"===e.dataType&&this.painter.setTileLoadedFlag(!0);})),e.m.testSupport(i)):this.fire(new e.t(new Error("Failed to initialize WebGL")));}_contextLost(t){t.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new e.x("webglcontextlost",{originalEvent:t}));}_contextRestored(t){this._setupPainter(),this.resize(),this._update(),this.fire(new e.x("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.x("renderstart")),++this._frameId;const r=this.painter.context.extTimerQuery,a=e.q.now(),n=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(s=n.createQuery(),n.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.q.now(),s=new e.a3(t,{now:o,fadeDuration:l,pitch:i,transition:this.style.transition});this.style.update(s);}this.style&&this.style.hasFogTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let c=!1;this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),c=this._updateAverageElevation(a),this.style.updateSources(this.transform),this._forceMarkerAndPopupUpdate()):c=this._updateAverageElevation(a);const h=this.style&&this.style._updatePlacement(this.painter,this.painter.transform,this.showCollisionBoxes,l,this._crossSourceCollisions,this.painter.replacementSource,this._scaleFactorChanged);if(this._scaleFactorChanged&&(this._scaleFactorChanged=!1),h&&(this._placementDirty=h.needsRerender),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showParseStatus:this.showParseStatus,wireframe:{terrain:this.showTerrainWireframe,layers2D:this.showLayers2DWireframe,layers3D:this.showLayers3DWireframe},showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,showTileAABBs:this.showTileAABBs,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration: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.x("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,o.mark(i.load),this.fire(new e.x("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),s){const t=e.q.now()-a;n.endQuery(r.TIME_ELAPSED_EXT),setTimeout((()=>{const i=n.getQueryParameter(s,n.QUERY_RESULT)/1e6;n.deleteQuery(s),this.fire(new e.x("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.x("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.x("gpu-timing-deferred-render",{gpuTime:i}));}),50);}const u=this._sourcesDirty||this._styleDirty||this._placementDirty||c;if(u||this._repaint)this.triggerRepaint();else {const t=this.idle();if(t&&(c=this._updateAverageElevation(a,!0)),c)this.triggerRepaint();else if(this._triggerFrame(!1),t&&(this.fire(new e.x("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const t=this._calculateSpeedIndex();this.fire(new e.x("speedindexcompleted",{speedIndex:t})),this.speedIndexTiming=!1;}}!this._loaded||this._fullyLoaded||u||(this._fullyLoaded=!0,o.mark(i.fullLoad),this._performanceMetricsCollection&&B(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(){N(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(t=>{if(t&&(t.message===w||401===t.status)){const t=this.painter.context.gl;G(t,!1),this._logoControl instanceof Cn&&this._logoControl._updateLogo(),t&&t.clear(t.DEPTH_BUFFER_BIT|t.COLOR_BUFFER_BIT|t.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new e.t(new Error("A valid Mapbox access token is required to use Mapbox GL JS. To create an account or a new access token, visit https://account.mapbox.com/")));}})),M(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(()=>{}));}_postStyleLoadEvent(){this.style.globalId&&O(this._requestManager._customAccessToken,{map:this,skuToken:this._requestManager._skuToken,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()});}_updateTerrain(){const e=this._isDragging();this.painter.updateTerrain(this.style,e);}_calculateSpeedIndex(){const e=this.painter.canvasCopy(),t=this.painter.getCanvasCopiesAndTimestamps();t.timeStamps.push(performance.now());const 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<t.length;r++){const a=t[r];let n=0;for(let t=0;t<a.length;t+=4)a[t]===e[t]&&a[t+1]===e[t+1]&&a[t+2]===e[t+2]&&a[t+3]===e[t+3]&&(n+=1);o+=(i[r+2]-i[r+1])*(1-n/s);}return o}remove(){this._hash&&this._hash.remove();for(const e of this._controls)e.onRemove(this);this._controls=[],this._frame&&(this._frame.cancel(),this._frame=null),this._renderTaskQueue.clear(),this._domRenderTaskQueue.clear(),this.style&&this.style.destroy(),this.painter.destroy(),this.handlers&&this.handlers.destroy(),this.handlers=void 0,this.setStyle(null),window.removeEventListener("resize",this._onWindowResize,!1),window.removeEventListener("orientationchange",this._onWindowResize,!1),window.removeEventListener(this._fullscreenchangeEvent,this._onWindowResize,!1),window.removeEventListener("online",this._onWindowOnline,!1),window.removeEventListener("visibilitychange",this._onVisibilityChange,!1);const t=this.painter.context.gl.getExtension("WEBGL_lose_context");t&&t.loseContext(),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvasContainer.remove(),this._controlContainer.remove(),this._missingCSSCanary.remove(),this._canvas=void 0,this._canvasContainer=void 0,this._controlContainer=void 0,this._missingCSSCanary=void 0,this._container.classList.remove("mapboxgl-map"),this._container.removeEventListener("scroll",this._onMapScroll,!1),U.delete(this.painter.context.gl),k.remove(),P.remove(),this._removed=!0,this.fire(new e.x("remove"));}triggerRepaint(){this._triggerFrame(!0);}_triggerFrame(t){this._renderNextFrame=this._renderNextFrame||t,this.style&&!this._frame&&(this._frame=e.q.frame((e=>{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.bg(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._tp.refreshUI(),this._update());}get showParseStatus(){return !!this._showParseStatus}set showParseStatus(e){this._showParseStatus!==e&&(this._showParseStatus=e,this._tp.refreshUI(),this._update());}get showTerrainWireframe(){return !!this._showTerrainWireframe}set showTerrainWireframe(e){this._showTerrainWireframe!==e&&(this._showTerrainWireframe=e,this._tp.refreshUI(),this._update());}get showLayers2DWireframe(){return !!this._showLayers2DWireframe}set showLayers2DWireframe(e){this._showLayers2DWireframe!==e&&(this._showLayers2DWireframe=e,this._tp.refreshUI(),this._update());}get showLayers3DWireframe(){return !!this._showLayers3DWireframe}set showLayers3DWireframe(e){this._showLayers3DWireframe!==e&&(this._showLayers3DWireframe=e,this._tp.refreshUI(),this._update());}get speedIndexTiming(){return !!this._speedIndexTiming}set speedIndexTiming(e){this._speedIndexTiming!==e&&(this._speedIndexTiming=e,this._update());}get showPadding(){return !!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._tp.refreshUI(),this._update());}get showCollisionBoxes(){return !!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,this._tp.refreshUI(),e?this.style._generateCollisionBoxes():this._update());}get showOverdrawInspector(){return !!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._tp.refreshUI(),this._update());}get repaint(){return !!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this._tp.refreshUI(),this.triggerRepaint());}get vertices(){return !!this._vertices}set vertices(e){this._vertices=e,this._update();}get showTileAABBs(){return !!this._showTileAABBs}set showTileAABBs(e){this._showTileAABBs!==e&&(this._showTileAABBs=e,this._tp.refreshUI(),e&&this._update());}_setCacheLimits(t,i){e.dy(t,i);}get version(){return t}},NavigationControl:class{constructor(t={}){this.options=e.l({},On,t),this._container=l("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this.options.showZoom&&(e.aJ(["_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.aJ(["_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 Fn(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=e.l({geolocation:i},Un,t),e.aJ(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=Ea(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(){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.longitude<t.getWest()||i.longitude>t.getEast()||i.latitude<t.getSouth()||i.latitude>t.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");}}_onSuccess(t){if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new e.x("outofmaxbounds",t)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=t,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(t),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(t),this.options.showUserLocation&&this._userLocationDotMarker.removeClassName("mapboxgl-user-location-dot-stale"),this.fire(new e.x("geolocate",t)),this._finish();}}_updateCamera(t){const i=new e.bL(t.coords.longitude,t.coords.latitude),o=t.coords.accuracy,s=this._map.getBearing(),r=e.l({bearing:s},this.options.fitBoundsOptions);this._map.fitBounds(i.toBounds(o),r,{geolocateSource:!0});}_updateMarker(t){if(t){const i=new e.bL(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.bE(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.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.x("error",t)),this._finish();}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0;}_setupUI(t){if(void 0!==this._map){if(this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this._geolocateButton=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 Nn({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=l("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Nn({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",(t=>{t.geolocateSource||"ACTIVE_LOCK"!==this._watchState||t.originalEvent&&"resize"===t.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new e.x("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.x("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":this._numberOfWatches--,this._noTimeout=!1,this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this.fire(new e.x("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new e.x("trackuserlocationstart"));}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"BACKGROUND":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");break;case"BACKGROUND_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error");}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let e;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(e={maximumAge:6e5,timeout:0},this._noTimeout=!0):(e=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,e),this.options.showUserHeading&&this._addDeviceOrientationListener();}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=window.setTimeout(this._finish,1e4);return !0}_addDeviceOrientationListener(){const e=()=>{"ondeviceorientationabsolute"in window?window.addEventListener("deviceorientationabsolute",this._onDeviceOrientation):window.addEventListener("deviceorientation",this._onDeviceOrientation);};"undefined"!=typeof DeviceMotionEvent&&"function"==typeof DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((t=>{"granted"===t&&e();})).catch(console.error):e();}_clearWatch(){this.options.geolocation.clearWatch(this._geolocationWatchID),window.removeEventListener("deviceorientation",this._onDeviceOrientation),window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientation),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null);}},AttributionControl:Sn,ScaleControl:class{constructor(t={}){this.options=e.l({},Gn,t),this._isNumberFormatSupported=function(){try{return new Intl.NumberFormat("en",{style:"unit",unitDisplay:"short",unit:"meter"}),!0}catch(e){return !1}}(),e.aJ(["_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]),a=s.distanceTo(r);if("imperial"===this.options.unit){const t=3.2808*a;t>5280?this._setScale(e,t/5280,"mile"):this._setScale(e,t,"foot");}else "nautical"===this.options.unit?this._setScale(e,a/1852,"nautical-mile"):a>=1e3?this._setScale(e,a/1e3,"kilometer"):this._setScale(e,a,"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=this._isNumberFormatSupported&&"nautical-mile"!==i?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:i}).format(o):`${o} ${Vn[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.aJ(["_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();}},Popup:class extends e.E{constructor(t){super(),this.options=e.l(Object.create(jn),t),e.aJ(["_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.x("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.x("close")),this}getLngLat(){return this._lngLat}setLngLat(t){this._lngLat=e.bL.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}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.setAttribute("aria-hidden","true"),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,a=o.x<s/2,n=o.x>t.transform.width-s/2;if(o.y+e<r)return a?"top-left":n?"top-right":"top";if(o.y>t.transform.height-r){if(a)return "bottom-left";if(n)return "bottom-right"}return a?"left":n?"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=Bn(this._lngLat,this._pos,i.transform)),!this._trackPointer||t){const o=this._pos=this._trackPointer&&t instanceof e.P?t:i.project(this._lngLat),s=Zn(this.options.offset),r=this._anchor=this._getAnchor(s.y),a=Zn(this.options.offset,r),n=o.add(a).round();i._requestDomTask((()=>{this._container&&r&&(this._container.style.transform=`${kn[r]} translate(${n.x}px,${n.y}px)`);}));}if(!this._marker&&i._showingGlobe()){const t=e.dz(i.transform,this._lngLat)?0:1;this._setOpacity(t);}this._updateClassList();}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(Hn);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:Nn,Style:lo,LngLat:e.bL,LngLatBounds:e.as,Point:e.P,MercatorCoordinate:e.a5,FreeCameraOptions:Ni,Evented:e.E,config:e.e,prewarm:e.dE,clearPrewarmedResources:e.dF,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.dG.workerCount},set workerCount(t){e.dG.workerCount=t;},get maxParallelImageRequests(){return e.e.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(t){e.e.MAX_PARALLEL_IMAGE_REQUESTS=t;},clearStorage(t){e.dH(t);},get workerUrl(){return e.dI.workerUrl},set workerUrl(t){e.dI.workerUrl=t;},get workerClass(){return e.dI.workerClass},set workerClass(t){e.dI.workerClass=t;},get workerParams(){return e.dI.workerParams},set workerParams(t){e.dI.workerParams=t;},get dracoUrl(){return e.dJ()},set dracoUrl(t){e.dK(t);},get meshoptUrl(){return e.dL()},set meshoptUrl(t){e.dM(t);},setNow:e.q.setNow,restoreNow:e.q.restoreNow};return qn})); |
| 37 |
|
| 38 |
// |
| 39 |
// Our custom intro provides a specialized "define()" function, called by the |
| 40 |
// AMD modules below, that sets up the worker blob URL and then executes the |
| 41 |
// main module, storing its exported value as 'mapboxgl' |
| 42 |
|
| 43 |
|
| 44 |
var mapboxgl$1 = mapboxgl; |
| 45 |
|
| 46 |
return mapboxgl$1; |
| 47 |
|
| 48 |
})); |
| 49 |
//# sourceMappingURL=mapbox-gl.js.map |
| 50 |
|