From 19c743f6e2284e09f6f2f5fc39d1f2090c9ebbd3 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 27 Nov 2024 05:02:35 +0000 Subject: [PATCH] Update docs from maps rnmapbox/maps@fa80ae5 --- ...d8a4be.js => AppEntry-86e434537b54e1c33df4cc9889a07af8.js} | 4 ++-- static/example-app/index.html | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename static/example-app/_expo/static/js/web/{AppEntry-031c79dce78ed48370eb25af07d8a4be.js => AppEntry-86e434537b54e1c33df4cc9889a07af8.js} (77%) diff --git a/static/example-app/_expo/static/js/web/AppEntry-031c79dce78ed48370eb25af07d8a4be.js b/static/example-app/_expo/static/js/web/AppEntry-86e434537b54e1c33df4cc9889a07af8.js similarity index 77% rename from static/example-app/_expo/static/js/web/AppEntry-031c79dce78ed48370eb25af07d8a4be.js rename to static/example-app/_expo/static/js/web/AppEntry-86e434537b54e1c33df4cc9889a07af8.js index b5f4ed9..e50f565 100644 --- a/static/example-app/_expo/static/js/web/AppEntry-031c79dce78ed48370eb25af07d8a4be.js +++ b/static/example-app/_expo/static/js/web/AppEntry-86e434537b54e1c33df4cc9889a07af8.js @@ -301,7 +301,7 @@ __d((function(g,_r,_i,_a,m,_e,d){Object.defineProperty(_e,"__esModule",{value:!0 __d((function(g,r,i,a,m,e,d){var t=r(d[0]);Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"Camera",{enumerable:!0,get:function(){return n.default}}),Object.defineProperty(e,"Logger",{enumerable:!0,get:function(){return o.default}}),Object.defineProperty(e,"MapView",{enumerable:!0,get:function(){return f.default}}),Object.defineProperty(e,"MarkerView",{enumerable:!0,get:function(){return l.default}}),e.default=void 0,r(d[1]);var u=t(r(d[2])),n=t(r(d[3])),f=t(r(d[4])),l=t(r(d[5])),o=t(r(d[6])),c={Camera:n.default,MapView:f.default,Logger:o.default,MarkerView:l.default},b=Object.assign({},u.default,c);e.default=b}),295,[1,296,297,305,307,308,309]); __d((function(g,r,i,a,m,e,d){}),296,[]); __d((function(g,r,i,a,m,e,d){var t=r(d[0]);Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var s=t(r(d[1])),l={LineJoin:{},StyleURL:{Street:'mapbox://styles/mapbox/streets-v11',Satellite:'mapbox://styles/mapbox/satellite-v9'},setAccessToken:function(t){s.default.accessToken=t}};e.default=l}),297,[1,298]); -__d((function(e,t,r,i,n,a,o){var s=t(o[0]),l=t(o[1]),u=t(o[2]),c=t(o[3]),h=t(o[4]),f=t(o[5]),d=t(o[6]),p=t(o[7]),m=t(o[8]),v=t(o[9]),_=t(o[10]),y=t(o[11]),g=t(o[12]),x=t(o[13]),b=["data"],w=["data"];function k(e,t,r,i){var n=h(_(1&i?e.prototype:e),t,r);return 2&i&&"function"==typeof n?function(e){return n.apply(r,e)}:n}function T(e,t,r){return t=_(t),v(e,M()?Reflect.construct(t,r||[],_(e).constructor):t.apply(e,r))}function M(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(M=function(){return!!e})()}!(function(e,t){'object'==typeof a&&void 0!==n?n.exports=t():'function'==typeof define&&define.amd?define(t):(e='undefined'!=typeof globalThis?globalThis:e||self).mapboxgl=t()})(this,(function(){'use strict';var e,t,r;function i(i,n){if(e)if(t){var a="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 = {}; ("+e+")(sharedChunk); ("+t+")(sharedChunk); self.onerror = null;",o={};e(o),r=n(o),'undefined'!=typeof window&&window&&window.URL&&window.URL.createObjectURL&&(r.workerUrl=window.URL.createObjectURL(new Blob([a],{type:'text/javascript'})))}else t=n;else e=n}return i(0,(function(e){function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var r,i={},n={};function a(){if(r)return n;r=1,Object.defineProperty(n,"__esModule",{value:!0}),n.setMatrixArrayType=function(e){n.ARRAY_TYPE=t=e},n.toRadian=function(e){return e*a},n.equals=function(t,r){return Math.abs(t-r)<=e*Math.max(1,Math.abs(t),Math.abs(r))},n.RANDOM=n.ARRAY_TYPE=n.EPSILON=void 0;var e=1e-6;n.EPSILON=e;var t="undefined"!=typeof Float32Array?Float32Array:Array;n.ARRAY_TYPE=t;var i=Math.random;n.RANDOM=i;var a=Math.PI/180;return Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)}),n}var o,s={};function l(){if(o)return s;function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}o=1,Object.defineProperty(s,"__esModule",{value:!0}),s.create=function(){var e=new t.ARRAY_TYPE(4);return t.ARRAY_TYPE!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e},s.clone=function(e){var r=new t.ARRAY_TYPE(4);return r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=e[3],r},s.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},s.identity=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e},s.fromValues=function(e,r,i,n){var a=new t.ARRAY_TYPE(4);return a[0]=e,a[1]=r,a[2]=i,a[3]=n,a},s.set=function(e,t,r,i,n){return e[0]=t,e[1]=r,e[2]=i,e[3]=n,e},s.transpose=function(e,t){if(e===t){var r=t[1];e[1]=t[2],e[2]=r}else e[0]=t[0],e[1]=t[2],e[2]=t[1],e[3]=t[3];return e},s.invert=function(e,t){var r=t[0],i=t[1],n=t[2],a=t[3],o=r*a-n*i;return o?(e[0]=a*(o=1/o),e[1]=-i*o,e[2]=-n*o,e[3]=r*o,e):null},s.adjoint=function(e,t){var r=t[0];return e[0]=t[3],e[1]=-t[1],e[2]=-t[2],e[3]=r,e},s.determinant=function(e){return e[0]*e[3]-e[2]*e[1]},s.multiply=i,s.rotate=function(e,t,r){var i=t[0],n=t[1],a=t[2],o=t[3],s=Math.sin(r),l=Math.cos(r);return e[0]=i*l+a*s,e[1]=n*l+o*s,e[2]=i*-s+a*l,e[3]=n*-s+o*l,e},s.scale=function(e,t,r){var i=t[1],n=t[2],a=t[3],o=r[0],s=r[1];return e[0]=t[0]*o,e[1]=i*o,e[2]=n*s,e[3]=a*s,e},s.fromRotation=function(e,t){var r=Math.sin(t),i=Math.cos(t);return e[0]=i,e[1]=r,e[2]=-r,e[3]=i,e},s.fromScaling=function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=t[1],e},s.str=function(e){return"mat2("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},s.frob=function(e){return Math.hypot(e[0],e[1],e[2],e[3])},s.LDU=function(e,t,r,i){return e[2]=i[2]/i[0],r[0]=i[0],r[1]=i[1],r[3]=i[3]-e[2]*r[1],[e,t,r]},s.add=function(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e},s.subtract=n,s.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]},s.equals=function(e,r){var i=e[0],n=e[1],a=e[2],o=e[3],s=r[0],l=r[1],u=r[2],c=r[3];return Math.abs(i-s)<=t.EPSILON*Math.max(1,Math.abs(i),Math.abs(s))&&Math.abs(n-l)<=t.EPSILON*Math.max(1,Math.abs(n),Math.abs(l))&&Math.abs(a-u)<=t.EPSILON*Math.max(1,Math.abs(a),Math.abs(u))&&Math.abs(o-c)<=t.EPSILON*Math.max(1,Math.abs(o),Math.abs(c))},s.multiplyScalar=function(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e},s.multiplyScalarAndAdd=function(e,t,r,i){return e[0]=t[0]+r[0]*i,e[1]=t[1]+r[1]*i,e[2]=t[2]+r[2]*i,e[3]=t[3]+r[3]*i,e},s.sub=s.mul=void 0;var t=(function(t){if(t&&t.__esModule)return t;if(null===t||"object"!==e(t)&&"function"!=typeof t)return{default:t};var i=r(void 0);if(i&&i.has(t))return i.get(t);var n={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in t)if("default"!==o&&Object.prototype.hasOwnProperty.call(t,o)){var s=a?Object.getOwnPropertyDescriptor(t,o):null;s&&(s.get||s.set)?Object.defineProperty(n,o,s):n[o]=t[o]}return n.default=t,i&&i.set(t,n),n})(a());function r(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return(r=function(e){return e?i:t})(e)}function i(e,t,r){var i=t[0],n=t[1],a=t[2],o=t[3],s=r[0],l=r[1],u=r[2],c=r[3];return e[0]=i*s+a*l,e[1]=n*s+o*l,e[2]=i*u+a*c,e[3]=n*u+o*c,e}function n(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e}return s.mul=i,s.sub=n,s}var u,h={};function v(){if(u)return h;function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}u=1,Object.defineProperty(h,"__esModule",{value:!0}),h.create=function(){var e=new t.ARRAY_TYPE(6);return t.ARRAY_TYPE!=Float32Array&&(e[1]=0,e[2]=0,e[4]=0,e[5]=0),e[0]=1,e[3]=1,e},h.clone=function(e){var r=new t.ARRAY_TYPE(6);return r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=e[3],r[4]=e[4],r[5]=e[5],r},h.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e},h.identity=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e},h.fromValues=function(e,r,i,n,a,o){var s=new t.ARRAY_TYPE(6);return s[0]=e,s[1]=r,s[2]=i,s[3]=n,s[4]=a,s[5]=o,s},h.set=function(e,t,r,i,n,a,o){return e[0]=t,e[1]=r,e[2]=i,e[3]=n,e[4]=a,e[5]=o,e},h.invert=function(e,t){var r=t[0],i=t[1],n=t[2],a=t[3],o=t[4],s=t[5],l=r*a-i*n;return l?(e[0]=a*(l=1/l),e[1]=-i*l,e[2]=-n*l,e[3]=r*l,e[4]=(n*s-a*o)*l,e[5]=(i*o-r*s)*l,e):null},h.determinant=function(e){return e[0]*e[3]-e[1]*e[2]},h.multiply=i,h.rotate=function(e,t,r){var i=t[0],n=t[1],a=t[2],o=t[3],s=t[4],l=t[5],u=Math.sin(r),c=Math.cos(r);return e[0]=i*c+a*u,e[1]=n*c+o*u,e[2]=i*-u+a*c,e[3]=n*-u+o*c,e[4]=s,e[5]=l,e},h.scale=function(e,t,r){var i=t[1],n=t[2],a=t[3],o=t[4],s=t[5],l=r[0],u=r[1];return e[0]=t[0]*l,e[1]=i*l,e[2]=n*u,e[3]=a*u,e[4]=o,e[5]=s,e},h.translate=function(e,t,r){var i=t[0],n=t[1],a=t[2],o=t[3],s=t[4],l=t[5],u=r[0],c=r[1];return e[0]=i,e[1]=n,e[2]=a,e[3]=o,e[4]=i*u+a*c+s,e[5]=n*u+o*c+l,e},h.fromRotation=function(e,t){var r=Math.sin(t),i=Math.cos(t);return e[0]=i,e[1]=r,e[2]=-r,e[3]=i,e[4]=0,e[5]=0,e},h.fromScaling=function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=t[1],e[4]=0,e[5]=0,e},h.fromTranslation=function(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=t[0],e[5]=t[1],e},h.str=function(e){return"mat2d("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+")"},h.frob=function(e){return Math.hypot(e[0],e[1],e[2],e[3],e[4],e[5],1)},h.add=function(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e[4]=t[4]+r[4],e[5]=t[5]+r[5],e},h.subtract=n,h.multiplyScalar=function(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*r,e[5]=t[5]*r,e},h.multiplyScalarAndAdd=function(e,t,r,i){return e[0]=t[0]+r[0]*i,e[1]=t[1]+r[1]*i,e[2]=t[2]+r[2]*i,e[3]=t[3]+r[3]*i,e[4]=t[4]+r[4]*i,e[5]=t[5]+r[5]*i,e},h.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]},h.equals=function(e,r){var i=e[0],n=e[1],a=e[2],o=e[3],s=e[4],l=e[5],u=r[0],c=r[1],h=r[2],f=r[3],d=r[4],p=r[5];return Math.abs(i-u)<=t.EPSILON*Math.max(1,Math.abs(i),Math.abs(u))&&Math.abs(n-c)<=t.EPSILON*Math.max(1,Math.abs(n),Math.abs(c))&&Math.abs(a-h)<=t.EPSILON*Math.max(1,Math.abs(a),Math.abs(h))&&Math.abs(o-f)<=t.EPSILON*Math.max(1,Math.abs(o),Math.abs(f))&&Math.abs(s-d)<=t.EPSILON*Math.max(1,Math.abs(s),Math.abs(d))&&Math.abs(l-p)<=t.EPSILON*Math.max(1,Math.abs(l),Math.abs(p))},h.sub=h.mul=void 0;var t=(function(t){if(t&&t.__esModule)return t;if(null===t||"object"!==e(t)&&"function"!=typeof t)return{default:t};var i=r(void 0);if(i&&i.has(t))return i.get(t);var n={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in t)if("default"!==o&&Object.prototype.hasOwnProperty.call(t,o)){var s=a?Object.getOwnPropertyDescriptor(t,o):null;s&&(s.get||s.set)?Object.defineProperty(n,o,s):n[o]=t[o]}return n.default=t,i&&i.set(t,n),n})(a());function r(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return(r=function(e){return e?i:t})(e)}function i(e,t,r){var i=t[0],n=t[1],a=t[2],o=t[3],s=t[4],l=t[5],u=r[0],c=r[1],h=r[2],f=r[3],d=r[4],p=r[5];return e[0]=i*u+a*c,e[1]=n*u+o*c,e[2]=i*h+a*f,e[3]=n*h+o*f,e[4]=i*d+a*p+s,e[5]=n*d+o*p+l,e}function n(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e[4]=t[4]-r[4],e[5]=t[5]-r[5],e}return h.mul=i,h.sub=n,h}var _,b={};function w(){if(_)return b;function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}_=1,Object.defineProperty(b,"__esModule",{value:!0}),b.create=function(){var e=new t.ARRAY_TYPE(9);return t.ARRAY_TYPE!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e},b.fromMat4=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[4],e[4]=t[5],e[5]=t[6],e[6]=t[8],e[7]=t[9],e[8]=t[10],e},b.clone=function(e){var r=new t.ARRAY_TYPE(9);return r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=e[3],r[4]=e[4],r[5]=e[5],r[6]=e[6],r[7]=e[7],r[8]=e[8],r},b.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e},b.fromValues=function(e,r,i,n,a,o,s,l,u){var c=new t.ARRAY_TYPE(9);return c[0]=e,c[1]=r,c[2]=i,c[3]=n,c[4]=a,c[5]=o,c[6]=s,c[7]=l,c[8]=u,c},b.set=function(e,t,r,i,n,a,o,s,l,u){return e[0]=t,e[1]=r,e[2]=i,e[3]=n,e[4]=a,e[5]=o,e[6]=s,e[7]=l,e[8]=u,e},b.identity=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},b.transpose=function(e,t){if(e===t){var r=t[1],i=t[2],n=t[5];e[1]=t[3],e[2]=t[6],e[3]=r,e[5]=t[7],e[6]=i,e[7]=n}else e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8];return e},b.invert=function(e,t){var r=t[0],i=t[1],n=t[2],a=t[3],o=t[4],s=t[5],l=t[6],u=t[7],c=t[8],h=c*o-s*u,f=-c*a+s*l,d=u*a-o*l,p=r*h+i*f+n*d;return p?(e[0]=h*(p=1/p),e[1]=(-c*i+n*u)*p,e[2]=(s*i-n*o)*p,e[3]=f*p,e[4]=(c*r-n*l)*p,e[5]=(-s*r+n*a)*p,e[6]=d*p,e[7]=(-u*r+i*l)*p,e[8]=(o*r-i*a)*p,e):null},b.adjoint=function(e,t){var r=t[0],i=t[1],n=t[2],a=t[3],o=t[4],s=t[5],l=t[6],u=t[7],c=t[8];return e[0]=o*c-s*u,e[1]=n*u-i*c,e[2]=i*s-n*o,e[3]=s*l-a*c,e[4]=r*c-n*l,e[5]=n*a-r*s,e[6]=a*u-o*l,e[7]=i*l-r*u,e[8]=r*o-i*a,e},b.determinant=function(e){var t=e[3],r=e[4],i=e[5],n=e[6],a=e[7],o=e[8];return e[0]*(o*r-i*a)+e[1]*(-o*t+i*n)+e[2]*(a*t-r*n)},b.multiply=i,b.translate=function(e,t,r){var i=t[0],n=t[1],a=t[2],o=t[3],s=t[4],l=t[5],u=t[6],c=t[7],h=t[8],f=r[0],d=r[1];return e[0]=i,e[1]=n,e[2]=a,e[3]=o,e[4]=s,e[5]=l,e[6]=f*i+d*o+u,e[7]=f*n+d*s+c,e[8]=f*a+d*l+h,e},b.rotate=function(e,t,r){var i=t[0],n=t[1],a=t[2],o=t[3],s=t[4],l=t[5],u=t[6],c=t[7],h=t[8],f=Math.sin(r),d=Math.cos(r);return e[0]=d*i+f*o,e[1]=d*n+f*s,e[2]=d*a+f*l,e[3]=d*o-f*i,e[4]=d*s-f*n,e[5]=d*l-f*a,e[6]=u,e[7]=c,e[8]=h,e},b.scale=function(e,t,r){var i=r[0],n=r[1];return e[0]=i*t[0],e[1]=i*t[1],e[2]=i*t[2],e[3]=n*t[3],e[4]=n*t[4],e[5]=n*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e},b.fromTranslation=function(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=t[0],e[7]=t[1],e[8]=1,e},b.fromRotation=function(e,t){var r=Math.sin(t),i=Math.cos(t);return e[0]=i,e[1]=r,e[2]=0,e[3]=-r,e[4]=i,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},b.fromScaling=function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=t[1],e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},b.fromMat2d=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=0,e[3]=t[2],e[4]=t[3],e[5]=0,e[6]=t[4],e[7]=t[5],e[8]=1,e},b.fromQuat=function(e,t){var r=t[0],i=t[1],n=t[2],a=t[3],o=r+r,s=i+i,l=n+n,u=r*o,c=i*o,h=i*s,f=n*o,d=n*s,p=n*l,m=a*o,v=a*s,_=a*l;return e[0]=1-h-p,e[3]=c-_,e[6]=f+v,e[1]=c+_,e[4]=1-u-p,e[7]=d-m,e[2]=f-v,e[5]=d+m,e[8]=1-u-h,e},b.normalFromMat4=function(e,t){var r=t[0],i=t[1],n=t[2],a=t[3],o=t[4],s=t[5],l=t[6],u=t[7],c=t[8],h=t[9],f=t[10],d=t[11],p=t[12],m=t[13],v=t[14],_=t[15],y=r*s-i*o,g=r*l-n*o,x=r*u-a*o,b=i*l-n*s,w=i*u-a*s,k=n*u-a*l,T=c*m-h*p,M=c*v-f*p,S=c*_-d*p,E=h*v-f*m,I=h*_-d*m,A=f*_-d*v,C=y*A-g*I+x*E+b*S-w*M+k*T;return C?(e[0]=(s*A-l*I+u*E)*(C=1/C),e[1]=(l*S-o*A-u*M)*C,e[2]=(o*I-s*S+u*T)*C,e[3]=(n*I-i*A-a*E)*C,e[4]=(r*A-n*S+a*M)*C,e[5]=(i*S-r*I-a*T)*C,e[6]=(m*k-v*w+_*b)*C,e[7]=(v*x-p*k-_*g)*C,e[8]=(p*w-m*x+_*y)*C,e):null},b.projection=function(e,t,r){return e[0]=2/t,e[1]=0,e[2]=0,e[3]=0,e[4]=-2/r,e[5]=0,e[6]=-1,e[7]=1,e[8]=1,e},b.str=function(e){return"mat3("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+", "+e[8]+")"},b.frob=function(e){return Math.hypot(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8])},b.add=function(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e[4]=t[4]+r[4],e[5]=t[5]+r[5],e[6]=t[6]+r[6],e[7]=t[7]+r[7],e[8]=t[8]+r[8],e},b.subtract=n,b.multiplyScalar=function(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,e[8]=t[8]*r,e},b.multiplyScalarAndAdd=function(e,t,r,i){return e[0]=t[0]+r[0]*i,e[1]=t[1]+r[1]*i,e[2]=t[2]+r[2]*i,e[3]=t[3]+r[3]*i,e[4]=t[4]+r[4]*i,e[5]=t[5]+r[5]*i,e[6]=t[6]+r[6]*i,e[7]=t[7]+r[7]*i,e[8]=t[8]+r[8]*i,e},b.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]},b.equals=function(e,r){var i=e[0],n=e[1],a=e[2],o=e[3],s=e[4],l=e[5],u=e[6],c=e[7],h=e[8],f=r[0],d=r[1],p=r[2],m=r[3],v=r[4],_=r[5],y=r[6],g=r[7],x=r[8];return Math.abs(i-f)<=t.EPSILON*Math.max(1,Math.abs(i),Math.abs(f))&&Math.abs(n-d)<=t.EPSILON*Math.max(1,Math.abs(n),Math.abs(d))&&Math.abs(a-p)<=t.EPSILON*Math.max(1,Math.abs(a),Math.abs(p))&&Math.abs(o-m)<=t.EPSILON*Math.max(1,Math.abs(o),Math.abs(m))&&Math.abs(s-v)<=t.EPSILON*Math.max(1,Math.abs(s),Math.abs(v))&&Math.abs(l-_)<=t.EPSILON*Math.max(1,Math.abs(l),Math.abs(_))&&Math.abs(u-y)<=t.EPSILON*Math.max(1,Math.abs(u),Math.abs(y))&&Math.abs(c-g)<=t.EPSILON*Math.max(1,Math.abs(c),Math.abs(g))&&Math.abs(h-x)<=t.EPSILON*Math.max(1,Math.abs(h),Math.abs(x))},b.sub=b.mul=void 0;var t=(function(t){if(t&&t.__esModule)return t;if(null===t||"object"!==e(t)&&"function"!=typeof t)return{default:t};var i=r(void 0);if(i&&i.has(t))return i.get(t);var n={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in t)if("default"!==o&&Object.prototype.hasOwnProperty.call(t,o)){var s=a?Object.getOwnPropertyDescriptor(t,o):null;s&&(s.get||s.set)?Object.defineProperty(n,o,s):n[o]=t[o]}return n.default=t,i&&i.set(t,n),n})(a());function r(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return(r=function(e){return e?i:t})(e)}function i(e,t,r){var i=t[0],n=t[1],a=t[2],o=t[3],s=t[4],l=t[5],u=t[6],c=t[7],h=t[8],f=r[0],d=r[1],p=r[2],m=r[3],v=r[4],_=r[5],y=r[6],g=r[7],x=r[8];return e[0]=f*i+d*o+p*u,e[1]=f*n+d*s+p*c,e[2]=f*a+d*l+p*h,e[3]=m*i+v*o+_*u,e[4]=m*n+v*s+_*c,e[5]=m*a+v*l+_*h,e[6]=y*i+g*o+x*u,e[7]=y*n+g*s+x*c,e[8]=y*a+g*l+x*h,e}function n(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e[4]=t[4]-r[4],e[5]=t[5]-r[5],e[6]=t[6]-r[6],e[7]=t[7]-r[7],e[8]=t[8]-r[8],e}return b.mul=i,b.sub=n,b}var M,S={};function E(){if(M)return S;function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}M=1,Object.defineProperty(S,"__esModule",{value:!0}),S.create=function(){var e=new t.ARRAY_TYPE(16);return t.ARRAY_TYPE!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e},S.clone=function(e){var r=new t.ARRAY_TYPE(16);return r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=e[3],r[4]=e[4],r[5]=e[5],r[6]=e[6],r[7]=e[7],r[8]=e[8],r[9]=e[9],r[10]=e[10],r[11]=e[11],r[12]=e[12],r[13]=e[13],r[14]=e[14],r[15]=e[15],r},S.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},S.fromValues=function(e,r,i,n,a,o,s,l,u,c,h,f,d,p,m,v){var _=new t.ARRAY_TYPE(16);return _[0]=e,_[1]=r,_[2]=i,_[3]=n,_[4]=a,_[5]=o,_[6]=s,_[7]=l,_[8]=u,_[9]=c,_[10]=h,_[11]=f,_[12]=d,_[13]=p,_[14]=m,_[15]=v,_},S.set=function(e,t,r,i,n,a,o,s,l,u,c,h,f,d,p,m,v){return e[0]=t,e[1]=r,e[2]=i,e[3]=n,e[4]=a,e[5]=o,e[6]=s,e[7]=l,e[8]=u,e[9]=c,e[10]=h,e[11]=f,e[12]=d,e[13]=p,e[14]=m,e[15]=v,e},S.identity=i,S.transpose=function(e,t){if(e===t){var r=t[1],i=t[2],n=t[3],a=t[6],o=t[7],s=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=r,e[6]=t[9],e[7]=t[13],e[8]=i,e[9]=a,e[11]=t[14],e[12]=n,e[13]=o,e[14]=s}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e},S.invert=function(e,t){var r=t[0],i=t[1],n=t[2],a=t[3],o=t[4],s=t[5],l=t[6],u=t[7],c=t[8],h=t[9],f=t[10],d=t[11],p=t[12],m=t[13],v=t[14],_=t[15],y=r*s-i*o,g=r*l-n*o,x=r*u-a*o,b=i*l-n*s,w=i*u-a*s,k=n*u-a*l,T=c*m-h*p,M=c*v-f*p,S=c*_-d*p,E=h*v-f*m,I=h*_-d*m,A=f*_-d*v,C=y*A-g*I+x*E+b*S-w*M+k*T;return C?(e[0]=(s*A-l*I+u*E)*(C=1/C),e[1]=(n*I-i*A-a*E)*C,e[2]=(m*k-v*w+_*b)*C,e[3]=(f*w-h*k-d*b)*C,e[4]=(l*S-o*A-u*M)*C,e[5]=(r*A-n*S+a*M)*C,e[6]=(v*x-p*k-_*g)*C,e[7]=(c*k-f*x+d*g)*C,e[8]=(o*I-s*S+u*T)*C,e[9]=(i*S-r*I-a*T)*C,e[10]=(p*w-m*x+_*y)*C,e[11]=(h*x-c*w-d*y)*C,e[12]=(s*M-o*E-l*T)*C,e[13]=(r*E-i*M+n*T)*C,e[14]=(m*g-p*b-v*y)*C,e[15]=(c*b-h*g+f*y)*C,e):null},S.adjoint=function(e,t){var r=t[0],i=t[1],n=t[2],a=t[3],o=t[4],s=t[5],l=t[6],u=t[7],c=t[8],h=t[9],f=t[10],d=t[11],p=t[12],m=t[13],v=t[14],_=t[15];return e[0]=s*(f*_-d*v)-h*(l*_-u*v)+m*(l*d-u*f),e[1]=-(i*(f*_-d*v)-h*(n*_-a*v)+m*(n*d-a*f)),e[2]=i*(l*_-u*v)-s*(n*_-a*v)+m*(n*u-a*l),e[3]=-(i*(l*d-u*f)-s*(n*d-a*f)+h*(n*u-a*l)),e[4]=-(o*(f*_-d*v)-c*(l*_-u*v)+p*(l*d-u*f)),e[5]=r*(f*_-d*v)-c*(n*_-a*v)+p*(n*d-a*f),e[6]=-(r*(l*_-u*v)-o*(n*_-a*v)+p*(n*u-a*l)),e[7]=r*(l*d-u*f)-o*(n*d-a*f)+c*(n*u-a*l),e[8]=o*(h*_-d*m)-c*(s*_-u*m)+p*(s*d-u*h),e[9]=-(r*(h*_-d*m)-c*(i*_-a*m)+p*(i*d-a*h)),e[10]=r*(s*_-u*m)-o*(i*_-a*m)+p*(i*u-a*s),e[11]=-(r*(s*d-u*h)-o*(i*d-a*h)+c*(i*u-a*s)),e[12]=-(o*(h*v-f*m)-c*(s*v-l*m)+p*(s*f-l*h)),e[13]=r*(h*v-f*m)-c*(i*v-n*m)+p*(i*f-n*h),e[14]=-(r*(s*v-l*m)-o*(i*v-n*m)+p*(i*l-n*s)),e[15]=r*(s*f-l*h)-o*(i*f-n*h)+c*(i*l-n*s),e},S.determinant=function(e){var t=e[0],r=e[1],i=e[2],n=e[3],a=e[4],o=e[5],s=e[6],l=e[7],u=e[8],c=e[9],h=e[10],f=e[11],d=e[12],p=e[13],m=e[14],v=e[15];return(t*o-r*a)*(h*v-f*m)-(t*s-i*a)*(c*v-f*p)+(t*l-n*a)*(c*m-h*p)+(r*s-i*o)*(u*v-f*d)-(r*l-n*o)*(u*m-h*d)+(i*l-n*s)*(u*p-c*d)},S.multiply=n,S.translate=function(e,t,r){var i,n,a,o,s,l,u,c,h,f,d,p,m=r[0],v=r[1],_=r[2];return t===e?(e[12]=t[0]*m+t[4]*v+t[8]*_+t[12],e[13]=t[1]*m+t[5]*v+t[9]*_+t[13],e[14]=t[2]*m+t[6]*v+t[10]*_+t[14],e[15]=t[3]*m+t[7]*v+t[11]*_+t[15]):(n=t[1],a=t[2],o=t[3],s=t[4],l=t[5],u=t[6],c=t[7],h=t[8],f=t[9],d=t[10],p=t[11],e[0]=i=t[0],e[1]=n,e[2]=a,e[3]=o,e[4]=s,e[5]=l,e[6]=u,e[7]=c,e[8]=h,e[9]=f,e[10]=d,e[11]=p,e[12]=i*m+s*v+h*_+t[12],e[13]=n*m+l*v+f*_+t[13],e[14]=a*m+u*v+d*_+t[14],e[15]=o*m+c*v+p*_+t[15]),e},S.scale=function(e,t,r){var i=r[0],n=r[1],a=r[2];return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e[4]=t[4]*n,e[5]=t[5]*n,e[6]=t[6]*n,e[7]=t[7]*n,e[8]=t[8]*a,e[9]=t[9]*a,e[10]=t[10]*a,e[11]=t[11]*a,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},S.rotate=function(e,r,i,n){var a,o,s,l,u,c,h,f,d,p,m,v,_,y,g,x,b,w,k,T,M,S,E,I,A=n[0],C=n[1],P=n[2],z=Math.hypot(A,C,P);return z0?(i[0]=2*(u*l+f*n+c*s-h*a)/d,i[1]=2*(c*l+f*a+h*n-u*s)/d,i[2]=2*(h*l+f*s+u*a-c*n)/d):(i[0]=2*(u*l+f*n+c*s-h*a),i[1]=2*(c*l+f*a+h*n-u*s),i[2]=2*(h*l+f*s+u*a-c*n)),o(e,r,i),e},S.getTranslation=function(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e},S.getScaling=s,S.getRotation=function(e,r){var i=new t.ARRAY_TYPE(3);s(i,r);var n=1/i[0],a=1/i[1],o=1/i[2],l=r[0]*n,u=r[1]*a,c=r[2]*o,h=r[4]*n,f=r[5]*a,d=r[6]*o,p=r[8]*n,m=r[9]*a,v=r[10]*o,_=l+f+v,y=0;return _>0?(y=2*Math.sqrt(_+1),e[3]=.25*y,e[0]=(d-m)/y,e[1]=(p-c)/y,e[2]=(u-h)/y):l>f&&l>v?(y=2*Math.sqrt(1+l-f-v),e[3]=(d-m)/y,e[0]=.25*y,e[1]=(u+h)/y,e[2]=(p+c)/y):f>v?(y=2*Math.sqrt(1+f-l-v),e[3]=(p-c)/y,e[0]=(u+h)/y,e[1]=.25*y,e[2]=(d+m)/y):(y=2*Math.sqrt(1+v-l-f),e[3]=(u-h)/y,e[0]=(p+c)/y,e[1]=(d+m)/y,e[2]=.25*y),e},S.fromRotationTranslationScale=function(e,t,r,i){var n=t[0],a=t[1],o=t[2],s=t[3],l=n+n,u=a+a,c=o+o,h=n*l,f=n*u,d=n*c,p=a*u,m=a*c,v=o*c,_=s*l,y=s*u,g=s*c,x=i[0],b=i[1],w=i[2];return e[0]=(1-(p+v))*x,e[1]=(f+g)*x,e[2]=(d-y)*x,e[3]=0,e[4]=(f-g)*b,e[5]=(1-(h+v))*b,e[6]=(m+_)*b,e[7]=0,e[8]=(d+y)*w,e[9]=(m-_)*w,e[10]=(1-(h+p))*w,e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e},S.fromRotationTranslationScaleOrigin=function(e,t,r,i,n){var a=t[0],o=t[1],s=t[2],l=t[3],u=a+a,c=o+o,h=s+s,f=a*u,d=a*c,p=a*h,m=o*c,v=o*h,_=s*h,y=l*u,g=l*c,x=l*h,b=i[0],w=i[1],k=i[2],T=n[0],M=n[1],S=n[2],E=(1-(m+_))*b,I=(d+x)*b,A=(p-g)*b,C=(d-x)*w,P=(1-(f+_))*w,z=(v+y)*w,D=(p+g)*k,R=(v-y)*k,L=(1-(f+m))*k;return e[0]=E,e[1]=I,e[2]=A,e[3]=0,e[4]=C,e[5]=P,e[6]=z,e[7]=0,e[8]=D,e[9]=R,e[10]=L,e[11]=0,e[12]=r[0]+T-(E*T+C*M+D*S),e[13]=r[1]+M-(I*T+P*M+R*S),e[14]=r[2]+S-(A*T+z*M+L*S),e[15]=1,e},S.fromQuat=function(e,t){var r=t[0],i=t[1],n=t[2],a=t[3],o=r+r,s=i+i,l=n+n,u=r*o,c=i*o,h=i*s,f=n*o,d=n*s,p=n*l,m=a*o,v=a*s,_=a*l;return e[0]=1-h-p,e[1]=c+_,e[2]=f-v,e[3]=0,e[4]=c-_,e[5]=1-u-p,e[6]=d+m,e[7]=0,e[8]=f+v,e[9]=d-m,e[10]=1-u-h,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},S.frustum=function(e,t,r,i,n,a,o){var s=1/(r-t),l=1/(n-i),u=1/(a-o);return e[0]=2*a*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=2*a*l,e[6]=0,e[7]=0,e[8]=(r+t)*s,e[9]=(n+i)*l,e[10]=(o+a)*u,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*a*2*u,e[15]=0,e},S.perspectiveNO=l,S.perspectiveZO=function(e,t,r,i,n){var a,o=1/Math.tan(t/2);return e[0]=o/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=n&&n!==1/0?(e[10]=n*(a=1/(i-n)),e[14]=n*i*a):(e[10]=-1,e[14]=-i),e},S.perspectiveFromFieldOfView=function(e,t,r,i){var n=Math.tan(t.upDegrees*Math.PI/180),a=Math.tan(t.downDegrees*Math.PI/180),o=Math.tan(t.leftDegrees*Math.PI/180),s=Math.tan(t.rightDegrees*Math.PI/180),l=2/(o+s),u=2/(n+a);return e[0]=l,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=u,e[6]=0,e[7]=0,e[8]=-(o-s)*l*.5,e[9]=(n-a)*u*.5,e[10]=i/(r-i),e[11]=-1,e[12]=0,e[13]=0,e[14]=i*r/(r-i),e[15]=0,e},S.orthoNO=u,S.orthoZO=function(e,t,r,i,n,a,o){var s=1/(t-r),l=1/(i-n),u=1/(a-o);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=u,e[11]=0,e[12]=(t+r)*s,e[13]=(n+i)*l,e[14]=a*u,e[15]=1,e},S.lookAt=function(e,r,n,a){var o,s,l,u,c,h,f,d,p,m,v=r[0],_=r[1],y=r[2],g=a[0],x=a[1],b=a[2],w=n[0],k=n[1],T=n[2];return Math.abs(v-w)0&&(c*=d=1/Math.sqrt(d),h*=d,f*=d);var p=l*f-u*h,m=u*c-s*f,v=s*h-l*c;return(d=p*p+m*m+v*v)>0&&(p*=d=1/Math.sqrt(d),m*=d,v*=d),e[0]=p,e[1]=m,e[2]=v,e[3]=0,e[4]=h*v-f*m,e[5]=f*p-c*v,e[6]=c*m-h*p,e[7]=0,e[8]=c,e[9]=h,e[10]=f,e[11]=0,e[12]=n,e[13]=a,e[14]=o,e[15]=1,e},S.str=function(e){return"mat4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+", "+e[8]+", "+e[9]+", "+e[10]+", "+e[11]+", "+e[12]+", "+e[13]+", "+e[14]+", "+e[15]+")"},S.frob=function(e){return Math.hypot(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15])},S.add=function(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e[4]=t[4]+r[4],e[5]=t[5]+r[5],e[6]=t[6]+r[6],e[7]=t[7]+r[7],e[8]=t[8]+r[8],e[9]=t[9]+r[9],e[10]=t[10]+r[10],e[11]=t[11]+r[11],e[12]=t[12]+r[12],e[13]=t[13]+r[13],e[14]=t[14]+r[14],e[15]=t[15]+r[15],e},S.subtract=c,S.multiplyScalar=function(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,e[8]=t[8]*r,e[9]=t[9]*r,e[10]=t[10]*r,e[11]=t[11]*r,e[12]=t[12]*r,e[13]=t[13]*r,e[14]=t[14]*r,e[15]=t[15]*r,e},S.multiplyScalarAndAdd=function(e,t,r,i){return e[0]=t[0]+r[0]*i,e[1]=t[1]+r[1]*i,e[2]=t[2]+r[2]*i,e[3]=t[3]+r[3]*i,e[4]=t[4]+r[4]*i,e[5]=t[5]+r[5]*i,e[6]=t[6]+r[6]*i,e[7]=t[7]+r[7]*i,e[8]=t[8]+r[8]*i,e[9]=t[9]+r[9]*i,e[10]=t[10]+r[10]*i,e[11]=t[11]+r[11]*i,e[12]=t[12]+r[12]*i,e[13]=t[13]+r[13]*i,e[14]=t[14]+r[14]*i,e[15]=t[15]+r[15]*i,e},S.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]},S.equals=function(e,r){var i=e[0],n=e[1],a=e[2],o=e[3],s=e[4],l=e[5],u=e[6],c=e[7],h=e[8],f=e[9],d=e[10],p=e[11],m=e[12],v=e[13],_=e[14],y=e[15],g=r[0],x=r[1],b=r[2],w=r[3],k=r[4],T=r[5],M=r[6],S=r[7],E=r[8],I=r[9],A=r[10],C=r[11],P=r[12],z=r[13],D=r[14],R=r[15];return Math.abs(i-g)<=t.EPSILON*Math.max(1,Math.abs(i),Math.abs(g))&&Math.abs(n-x)<=t.EPSILON*Math.max(1,Math.abs(n),Math.abs(x))&&Math.abs(a-b)<=t.EPSILON*Math.max(1,Math.abs(a),Math.abs(b))&&Math.abs(o-w)<=t.EPSILON*Math.max(1,Math.abs(o),Math.abs(w))&&Math.abs(s-k)<=t.EPSILON*Math.max(1,Math.abs(s),Math.abs(k))&&Math.abs(l-T)<=t.EPSILON*Math.max(1,Math.abs(l),Math.abs(T))&&Math.abs(u-M)<=t.EPSILON*Math.max(1,Math.abs(u),Math.abs(M))&&Math.abs(c-S)<=t.EPSILON*Math.max(1,Math.abs(c),Math.abs(S))&&Math.abs(h-E)<=t.EPSILON*Math.max(1,Math.abs(h),Math.abs(E))&&Math.abs(f-I)<=t.EPSILON*Math.max(1,Math.abs(f),Math.abs(I))&&Math.abs(d-A)<=t.EPSILON*Math.max(1,Math.abs(d),Math.abs(A))&&Math.abs(p-C)<=t.EPSILON*Math.max(1,Math.abs(p),Math.abs(C))&&Math.abs(m-P)<=t.EPSILON*Math.max(1,Math.abs(m),Math.abs(P))&&Math.abs(v-z)<=t.EPSILON*Math.max(1,Math.abs(v),Math.abs(z))&&Math.abs(_-D)<=t.EPSILON*Math.max(1,Math.abs(_),Math.abs(D))&&Math.abs(y-R)<=t.EPSILON*Math.max(1,Math.abs(y),Math.abs(R))},S.sub=S.mul=S.ortho=S.perspective=void 0;var t=(function(t){if(t&&t.__esModule)return t;if(null===t||"object"!==e(t)&&"function"!=typeof t)return{default:t};var i=r(void 0);if(i&&i.has(t))return i.get(t);var n={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in t)if("default"!==o&&Object.prototype.hasOwnProperty.call(t,o)){var s=a?Object.getOwnPropertyDescriptor(t,o):null;s&&(s.get||s.set)?Object.defineProperty(n,o,s):n[o]=t[o]}return n.default=t,i&&i.set(t,n),n})(a());function r(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return(r=function(e){return e?i:t})(e)}function i(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function n(e,t,r){var i=t[0],n=t[1],a=t[2],o=t[3],s=t[4],l=t[5],u=t[6],c=t[7],h=t[8],f=t[9],d=t[10],p=t[11],m=t[12],v=t[13],_=t[14],y=t[15],g=r[0],x=r[1],b=r[2],w=r[3];return e[0]=g*i+x*s+b*h+w*m,e[1]=g*n+x*l+b*f+w*v,e[2]=g*a+x*u+b*d+w*_,e[3]=g*o+x*c+b*p+w*y,e[4]=(g=r[4])*i+(x=r[5])*s+(b=r[6])*h+(w=r[7])*m,e[5]=g*n+x*l+b*f+w*v,e[6]=g*a+x*u+b*d+w*_,e[7]=g*o+x*c+b*p+w*y,e[8]=(g=r[8])*i+(x=r[9])*s+(b=r[10])*h+(w=r[11])*m,e[9]=g*n+x*l+b*f+w*v,e[10]=g*a+x*u+b*d+w*_,e[11]=g*o+x*c+b*p+w*y,e[12]=(g=r[12])*i+(x=r[13])*s+(b=r[14])*h+(w=r[15])*m,e[13]=g*n+x*l+b*f+w*v,e[14]=g*a+x*u+b*d+w*_,e[15]=g*o+x*c+b*p+w*y,e}function o(e,t,r){var i=t[0],n=t[1],a=t[2],o=t[3],s=i+i,l=n+n,u=a+a,c=i*s,h=i*l,f=i*u,d=n*l,p=n*u,m=a*u,v=o*s,_=o*l,y=o*u;return e[0]=1-(d+m),e[1]=h+y,e[2]=f-_,e[3]=0,e[4]=h-y,e[5]=1-(c+m),e[6]=p+v,e[7]=0,e[8]=f+_,e[9]=p-v,e[10]=1-(c+d),e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e}function s(e,t){var r=t[4],i=t[5],n=t[6],a=t[8],o=t[9],s=t[10];return e[0]=Math.hypot(t[0],t[1],t[2]),e[1]=Math.hypot(r,i,n),e[2]=Math.hypot(a,o,s),e}function l(e,t,r,i,n){var a,o=1/Math.tan(t/2);return e[0]=o/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=n&&n!==1/0?(e[10]=(n+i)*(a=1/(i-n)),e[14]=2*n*i*a):(e[10]=-1,e[14]=-2*i),e}function u(e,t,r,i,n,a,o){var s=1/(t-r),l=1/(i-n),u=1/(a-o);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*u,e[11]=0,e[12]=(t+r)*s,e[13]=(n+i)*l,e[14]=(o+a)*u,e[15]=1,e}function c(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e[4]=t[4]-r[4],e[5]=t[5]-r[5],e[6]=t[6]-r[6],e[7]=t[7]-r[7],e[8]=t[8]-r[8],e[9]=t[9]-r[9],e[10]=t[10]-r[10],e[11]=t[11]-r[11],e[12]=t[12]-r[12],e[13]=t[13]-r[13],e[14]=t[14]-r[14],e[15]=t[15]-r[15],e}return S.perspective=l,S.ortho=u,S.mul=n,S.sub=c,S}var I,A={},C={};function P(){if(I)return C;function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}I=1,Object.defineProperty(C,"__esModule",{value:!0}),C.create=i,C.clone=function(e){var r=new t.ARRAY_TYPE(3);return r[0]=e[0],r[1]=e[1],r[2]=e[2],r},C.length=n,C.fromValues=function(e,r,i){var n=new t.ARRAY_TYPE(3);return n[0]=e,n[1]=r,n[2]=i,n},C.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},C.set=function(e,t,r,i){return e[0]=t,e[1]=r,e[2]=i,e},C.add=function(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e},C.subtract=o,C.multiply=s,C.divide=l,C.ceil=function(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e},C.floor=function(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e},C.min=function(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e[2]=Math.min(t[2],r[2]),e},C.max=function(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e[2]=Math.max(t[2],r[2]),e},C.round=function(e,t){return e[0]=Math.round(t[0]),e[1]=Math.round(t[1]),e[2]=Math.round(t[2]),e},C.scale=function(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e},C.scaleAndAdd=function(e,t,r,i){return e[0]=t[0]+r[0]*i,e[1]=t[1]+r[1]*i,e[2]=t[2]+r[2]*i,e},C.distance=u,C.squaredDistance=c,C.squaredLength=h,C.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e},C.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e},C.normalize=function(e,t){var r=t[0],i=t[1],n=t[2],a=r*r+i*i+n*n;return a>0&&(a=1/Math.sqrt(a)),e[0]=t[0]*a,e[1]=t[1]*a,e[2]=t[2]*a,e},C.dot=f,C.cross=function(e,t,r){var i=t[0],n=t[1],a=t[2],o=r[0],s=r[1],l=r[2];return e[0]=n*l-a*s,e[1]=a*o-i*l,e[2]=i*s-n*o,e},C.lerp=function(e,t,r,i){var n=t[0],a=t[1],o=t[2];return e[0]=n+i*(r[0]-n),e[1]=a+i*(r[1]-a),e[2]=o+i*(r[2]-o),e},C.hermite=function(e,t,r,i,n,a){var o=a*a,s=o*(2*a-3)+1,l=o*(a-2)+a,u=o*(a-1),c=o*(3-2*a);return e[0]=t[0]*s+r[0]*l+i[0]*u+n[0]*c,e[1]=t[1]*s+r[1]*l+i[1]*u+n[1]*c,e[2]=t[2]*s+r[2]*l+i[2]*u+n[2]*c,e},C.bezier=function(e,t,r,i,n,a){var o=1-a,s=o*o,l=a*a,u=s*o,c=3*a*s,h=3*l*o,f=l*a;return e[0]=t[0]*u+r[0]*c+i[0]*h+n[0]*f,e[1]=t[1]*u+r[1]*c+i[1]*h+n[1]*f,e[2]=t[2]*u+r[2]*c+i[2]*h+n[2]*f,e},C.random=function(e,r){r=r||1;var i=2*t.RANDOM()*Math.PI,n=2*t.RANDOM()-1,a=Math.sqrt(1-n*n)*r;return e[0]=Math.cos(i)*a,e[1]=Math.sin(i)*a,e[2]=n*r,e},C.transformMat4=function(e,t,r){var i=t[0],n=t[1],a=t[2],o=r[3]*i+r[7]*n+r[11]*a+r[15];return e[0]=(r[0]*i+r[4]*n+r[8]*a+r[12])/(o=o||1),e[1]=(r[1]*i+r[5]*n+r[9]*a+r[13])/o,e[2]=(r[2]*i+r[6]*n+r[10]*a+r[14])/o,e},C.transformMat3=function(e,t,r){var i=t[0],n=t[1],a=t[2];return e[0]=i*r[0]+n*r[3]+a*r[6],e[1]=i*r[1]+n*r[4]+a*r[7],e[2]=i*r[2]+n*r[5]+a*r[8],e},C.transformQuat=function(e,t,r){var i=r[0],n=r[1],a=r[2],o=t[0],s=t[1],l=t[2],u=n*l-a*s,c=a*o-i*l,h=i*s-n*o,f=n*h-a*c,d=a*u-i*h,p=i*c-n*u,m=2*r[3];return c*=m,h*=m,d*=2,p*=2,e[0]=o+(u*=m)+(f*=2),e[1]=s+c+d,e[2]=l+h+p,e},C.rotateX=function(e,t,r,i){var n=[],a=[];return n[0]=t[0]-r[0],n[1]=t[1]-r[1],n[2]=t[2]-r[2],a[0]=n[0],a[1]=n[1]*Math.cos(i)-n[2]*Math.sin(i),a[2]=n[1]*Math.sin(i)+n[2]*Math.cos(i),e[0]=a[0]+r[0],e[1]=a[1]+r[1],e[2]=a[2]+r[2],e},C.rotateY=function(e,t,r,i){var n=[],a=[];return n[0]=t[0]-r[0],n[1]=t[1]-r[1],n[2]=t[2]-r[2],a[0]=n[2]*Math.sin(i)+n[0]*Math.cos(i),a[1]=n[1],a[2]=n[2]*Math.cos(i)-n[0]*Math.sin(i),e[0]=a[0]+r[0],e[1]=a[1]+r[1],e[2]=a[2]+r[2],e},C.rotateZ=function(e,t,r,i){var n=[],a=[];return n[0]=t[0]-r[0],n[1]=t[1]-r[1],n[2]=t[2]-r[2],a[0]=n[0]*Math.cos(i)-n[1]*Math.sin(i),a[1]=n[0]*Math.sin(i)+n[1]*Math.cos(i),a[2]=n[2],e[0]=a[0]+r[0],e[1]=a[1]+r[1],e[2]=a[2]+r[2],e},C.angle=function(e,t){var r=e[0],i=e[1],n=e[2],a=t[0],o=t[1],s=t[2],l=Math.sqrt(r*r+i*i+n*n)*Math.sqrt(a*a+o*o+s*s),u=l&&f(e,t)/l;return Math.acos(Math.min(Math.max(u,-1),1))},C.zero=function(e){return e[0]=0,e[1]=0,e[2]=0,e},C.str=function(e){return"vec3("+e[0]+", "+e[1]+", "+e[2]+")"},C.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]},C.equals=function(e,r){var i=e[0],n=e[1],a=e[2],o=r[0],s=r[1],l=r[2];return Math.abs(i-o)<=t.EPSILON*Math.max(1,Math.abs(i),Math.abs(o))&&Math.abs(n-s)<=t.EPSILON*Math.max(1,Math.abs(n),Math.abs(s))&&Math.abs(a-l)<=t.EPSILON*Math.max(1,Math.abs(a),Math.abs(l))},C.forEach=C.sqrLen=C.len=C.sqrDist=C.dist=C.div=C.mul=C.sub=void 0;var t=(function(t){if(t&&t.__esModule)return t;if(null===t||"object"!==e(t)&&"function"!=typeof t)return{default:t};var i=r(void 0);if(i&&i.has(t))return i.get(t);var n={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in t)if("default"!==o&&Object.prototype.hasOwnProperty.call(t,o)){var s=a?Object.getOwnPropertyDescriptor(t,o):null;s&&(s.get||s.set)?Object.defineProperty(n,o,s):n[o]=t[o]}return n.default=t,i&&i.set(t,n),n})(a());function r(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return(r=function(e){return e?i:t})(e)}function i(){var e=new t.ARRAY_TYPE(3);return t.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function n(e){return Math.hypot(e[0],e[1],e[2])}function o(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e}function s(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e}function l(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e[2]=t[2]/r[2],e}function u(e,t){return Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2])}function c(e,t){var r=t[0]-e[0],i=t[1]-e[1],n=t[2]-e[2];return r*r+i*i+n*n}function h(e){var t=e[0],r=e[1],i=e[2];return t*t+r*r+i*i}function f(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}C.sub=o,C.mul=s,C.div=l,C.dist=u,C.sqrDist=c,C.len=n,C.sqrLen=h;var d,p=(d=i(),function(e,t,r,i,n,a){var o,s;for(t||(t=3),r||(r=0),s=i?Math.min(i*t+r,e.length):e.length,o=r;o0&&(o=1/Math.sqrt(o)),e[0]=r*o,e[1]=i*o,e[2]=n*o,e[3]=a*o,e},R.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},R.cross=function(e,t,r,i){var n=r[0]*i[1]-r[1]*i[0],a=r[0]*i[2]-r[2]*i[0],o=r[0]*i[3]-r[3]*i[0],s=r[1]*i[2]-r[2]*i[1],l=r[1]*i[3]-r[3]*i[1],u=r[2]*i[3]-r[3]*i[2],c=t[0],h=t[1],f=t[2],d=t[3];return e[0]=h*u-f*l+d*s,e[1]=-c*u+f*o-d*a,e[2]=c*l-h*o+d*n,e[3]=-c*s+h*a-f*n,e},R.lerp=function(e,t,r,i){var n=t[0],a=t[1],o=t[2],s=t[3];return e[0]=n+i*(r[0]-n),e[1]=a+i*(r[1]-a),e[2]=o+i*(r[2]-o),e[3]=s+i*(r[3]-s),e},R.random=function(e,r){var i,n,a,o,s,l;r=r||1;do{s=(i=2*t.RANDOM()-1)*i+(n=2*t.RANDOM()-1)*n}while(s>=1);do{l=(a=2*t.RANDOM()-1)*a+(o=2*t.RANDOM()-1)*o}while(l>=1);var u=Math.sqrt((1-s)/l);return e[0]=r*i,e[1]=r*n,e[2]=r*a*u,e[3]=r*o*u,e},R.transformMat4=function(e,t,r){var i=t[0],n=t[1],a=t[2],o=t[3];return e[0]=r[0]*i+r[4]*n+r[8]*a+r[12]*o,e[1]=r[1]*i+r[5]*n+r[9]*a+r[13]*o,e[2]=r[2]*i+r[6]*n+r[10]*a+r[14]*o,e[3]=r[3]*i+r[7]*n+r[11]*a+r[15]*o,e},R.transformQuat=function(e,t,r){var i=t[0],n=t[1],a=t[2],o=r[0],s=r[1],l=r[2],u=r[3],c=u*i+s*a-l*n,h=u*n+l*i-o*a,f=u*a+o*n-s*i,d=-o*i-s*n-l*a;return e[0]=c*u+d*-o+h*-l-f*-s,e[1]=h*u+d*-s+f*-o-c*-l,e[2]=f*u+d*-l+c*-s-h*-o,e[3]=t[3],e},R.zero=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e},R.str=function(e){return"vec4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},R.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]},R.equals=function(e,r){var i=e[0],n=e[1],a=e[2],o=e[3],s=r[0],l=r[1],u=r[2],c=r[3];return Math.abs(i-s)<=t.EPSILON*Math.max(1,Math.abs(i),Math.abs(s))&&Math.abs(n-l)<=t.EPSILON*Math.max(1,Math.abs(n),Math.abs(l))&&Math.abs(a-u)<=t.EPSILON*Math.max(1,Math.abs(a),Math.abs(u))&&Math.abs(o-c)<=t.EPSILON*Math.max(1,Math.abs(o),Math.abs(c))},R.forEach=R.sqrLen=R.len=R.sqrDist=R.dist=R.div=R.mul=R.sub=void 0;var t=(function(t){if(t&&t.__esModule)return t;if(null===t||"object"!==e(t)&&"function"!=typeof t)return{default:t};var i=r(void 0);if(i&&i.has(t))return i.get(t);var n={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in t)if("default"!==o&&Object.prototype.hasOwnProperty.call(t,o)){var s=a?Object.getOwnPropertyDescriptor(t,o):null;s&&(s.get||s.set)?Object.defineProperty(n,o,s):n[o]=t[o]}return n.default=t,i&&i.set(t,n),n})(a());function r(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return(r=function(e){return e?i:t})(e)}function i(){var e=new t.ARRAY_TYPE(4);return t.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function n(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e}function o(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e[3]=t[3]*r[3],e}function s(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e[2]=t[2]/r[2],e[3]=t[3]/r[3],e}function l(e,t){return Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2],t[3]-e[3])}function u(e,t){var r=t[0]-e[0],i=t[1]-e[1],n=t[2]-e[2],a=t[3]-e[3];return r*r+i*i+n*n+a*a}function c(e){return Math.hypot(e[0],e[1],e[2],e[3])}function h(e){var t=e[0],r=e[1],i=e[2],n=e[3];return t*t+r*r+i*i+n*n}R.sub=n,R.mul=o,R.div=s,R.dist=l,R.sqrDist=u,R.len=c,R.sqrLen=h;var f,d=(f=i(),function(e,t,r,i,n,a){var o,s;for(t||(t=4),r||(r=0),s=i?Math.min(i*t+r,e.length):e.length,o=r;ot.EPSILON?(e[0]=r[0]/n,e[1]=r[1]/n,e[2]=r[2]/n):(e[0]=1,e[1]=0,e[2]=0),i},A.getAngle=function(e,t){var r=v(e,t);return Math.acos(2*r*r-1)},A.multiply=c,A.rotateX=function(e,t,r){r*=.5;var i=t[0],n=t[1],a=t[2],o=t[3],s=Math.sin(r),l=Math.cos(r);return e[0]=i*l+o*s,e[1]=n*l+a*s,e[2]=a*l-n*s,e[3]=o*l-i*s,e},A.rotateY=function(e,t,r){r*=.5;var i=t[0],n=t[1],a=t[2],o=t[3],s=Math.sin(r),l=Math.cos(r);return e[0]=i*l-a*s,e[1]=n*l+o*s,e[2]=a*l+i*s,e[3]=o*l-n*s,e},A.rotateZ=function(e,t,r){r*=.5;var i=t[0],n=t[1],a=t[2],o=t[3],s=Math.sin(r),l=Math.cos(r);return e[0]=i*l+n*s,e[1]=n*l-i*s,e[2]=a*l+o*s,e[3]=o*l-a*s,e},A.calculateW=function(e,t){var r=t[0],i=t[1],n=t[2];return e[0]=r,e[1]=i,e[2]=n,e[3]=Math.sqrt(Math.abs(1-r*r-i*i-n*n)),e},A.exp=h,A.ln=f,A.pow=function(e,t,r){return f(e,t),m(e,e,r),h(e,e),e},A.slerp=d,A.random=function(e){var r=t.RANDOM(),i=t.RANDOM(),n=t.RANDOM(),a=Math.sqrt(1-r),o=Math.sqrt(r);return e[0]=a*Math.sin(2*Math.PI*i),e[1]=a*Math.cos(2*Math.PI*i),e[2]=o*Math.sin(2*Math.PI*n),e[3]=o*Math.cos(2*Math.PI*n),e},A.invert=function(e,t){var r=t[0],i=t[1],n=t[2],a=t[3],o=r*r+i*i+n*n+a*a,s=o?1/o:0;return e[0]=-r*s,e[1]=-i*s,e[2]=-n*s,e[3]=a*s,e},A.conjugate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},A.fromMat3=p,A.fromEuler=function(e,t,r,i){var n=.5*Math.PI/180;t*=n,r*=n,i*=n;var a=Math.sin(t),o=Math.cos(t),s=Math.sin(r),l=Math.cos(r),u=Math.sin(i),c=Math.cos(i);return e[0]=a*l*c-o*s*u,e[1]=o*s*c+a*l*u,e[2]=o*l*u-a*s*c,e[3]=o*l*c+a*s*u,e},A.str=function(e){return"quat("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},A.setAxes=A.sqlerp=A.rotationTo=A.equals=A.exactEquals=A.normalize=A.sqrLen=A.squaredLength=A.len=A.length=A.lerp=A.dot=A.scale=A.mul=A.add=A.set=A.copy=A.fromValues=A.clone=void 0;var t=s(a()),r=s(w()),i=s(P()),n=s(L());function o(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(o=function(e){return e?r:t})(e)}function s(t,r){if(t&&t.__esModule)return t;if(null===t||"object"!==e(t)&&"function"!=typeof t)return{default:t};var i=o(r);if(i&&i.has(t))return i.get(t);var n={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if("default"!==s&&Object.prototype.hasOwnProperty.call(t,s)){var l=a?Object.getOwnPropertyDescriptor(t,s):null;l&&(l.get||l.set)?Object.defineProperty(n,s,l):n[s]=t[s]}return n.default=t,i&&i.set(t,n),n}function l(){var e=new t.ARRAY_TYPE(4);return t.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function u(e,t,r){r*=.5;var i=Math.sin(r);return e[0]=i*t[0],e[1]=i*t[1],e[2]=i*t[2],e[3]=Math.cos(r),e}function c(e,t,r){var i=t[0],n=t[1],a=t[2],o=t[3],s=r[0],l=r[1],u=r[2],c=r[3];return e[0]=i*c+o*s+n*u-a*l,e[1]=n*c+o*l+a*s-i*u,e[2]=a*c+o*u+i*l-n*s,e[3]=o*c-i*s-n*l-a*u,e}function h(e,t){var r=t[0],i=t[1],n=t[2],a=t[3],o=Math.sqrt(r*r+i*i+n*n),s=Math.exp(a),l=o>0?s*Math.sin(o)/o:0;return e[0]=r*l,e[1]=i*l,e[2]=n*l,e[3]=s*Math.cos(o),e}function f(e,t){var r=t[0],i=t[1],n=t[2],a=t[3],o=Math.sqrt(r*r+i*i+n*n),s=o>0?Math.atan2(o,a)/o:0;return e[0]=r*s,e[1]=i*s,e[2]=n*s,e[3]=.5*Math.log(r*r+i*i+n*n+a*a),e}function d(e,r,i,n){var a,o,s,l,u,c=r[0],h=r[1],f=r[2],d=r[3],p=i[0],m=i[1],v=i[2],_=i[3];return(o=c*p+h*m+f*v+d*_)<0&&(o=-o,p=-p,m=-m,v=-v,_=-_),1-o>t.EPSILON?(a=Math.acos(o),s=Math.sin(a),l=Math.sin((1-n)*a)/s,u=Math.sin(n*a)/s):(l=1-n,u=n),e[0]=l*c+u*p,e[1]=l*h+u*m,e[2]=l*f+u*v,e[3]=l*d+u*_,e}function p(e,t){var r,i=t[0]+t[4]+t[8];if(i>0)r=Math.sqrt(i+1),e[3]=.5*r,e[0]=(t[5]-t[7])*(r=.5/r),e[1]=(t[6]-t[2])*r,e[2]=(t[1]-t[3])*r;else{var n=0;t[4]>t[0]&&(n=1),t[8]>t[3*n+n]&&(n=2);var a=(n+1)%3,o=(n+2)%3;r=Math.sqrt(t[3*n+n]-t[3*a+a]-t[3*o+o]+1),e[n]=.5*r,e[3]=(t[3*a+o]-t[3*o+a])*(r=.5/r),e[a]=(t[3*a+n]+t[3*n+a])*r,e[o]=(t[3*o+n]+t[3*n+o])*r}return e}A.clone=n.clone,A.fromValues=n.fromValues,A.copy=n.copy,A.set=n.set,A.add=n.add,A.mul=c;var m=n.scale;A.scale=m;var v=n.dot;A.dot=v,A.lerp=n.lerp;var _=n.length;A.length=_,A.len=_;var y=n.squaredLength;A.squaredLength=y,A.sqrLen=y;var g=n.normalize;A.normalize=g,A.exactEquals=n.exactEquals,A.equals=n.equals;var x,b,k,T=(x=i.create(),b=i.fromValues(1,0,0),k=i.fromValues(0,1,0),function(e,t,r){var n=i.dot(t,r);return n<-.999999?(i.cross(x,b,t),i.len(x)<1e-6&&i.cross(x,k,t),i.normalize(x,x),u(e,x,Math.PI),e):n>.999999?(e[0]=0,e[1]=0,e[2]=0,e[3]=1,e):(i.cross(x,t,r),e[0]=x[0],e[1]=x[1],e[2]=x[2],e[3]=1+n,g(e,e))});A.rotationTo=T;var M,S,E=(M=l(),S=l(),function(e,t,r,i,n,a){return d(M,t,n,a),d(S,r,i,a),d(e,M,S,2*a*(1-a)),e});A.sqlerp=E;var I,C=(I=r.create(),function(e,t,r,i){return I[0]=r[0],I[3]=r[1],I[6]=r[2],I[1]=i[0],I[4]=i[1],I[7]=i[2],I[2]=-t[0],I[5]=-t[1],I[8]=-t[2],g(e,p(e,I))});return A.setAxes=C,A}var B,F={};function N(){if(B)return F;function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}B=1,Object.defineProperty(F,"__esModule",{value:!0}),F.create=function(){var e=new t.ARRAY_TYPE(8);return t.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[4]=0,e[5]=0,e[6]=0,e[7]=0),e[3]=1,e},F.clone=function(e){var r=new t.ARRAY_TYPE(8);return r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=e[3],r[4]=e[4],r[5]=e[5],r[6]=e[6],r[7]=e[7],r},F.fromValues=function(e,r,i,n,a,o,s,l){var u=new t.ARRAY_TYPE(8);return u[0]=e,u[1]=r,u[2]=i,u[3]=n,u[4]=a,u[5]=o,u[6]=s,u[7]=l,u},F.fromRotationTranslationValues=function(e,r,i,n,a,o,s){var l=new t.ARRAY_TYPE(8);l[0]=e,l[1]=r,l[2]=i,l[3]=n;var u=.5*a,c=.5*o,h=.5*s;return l[4]=u*n+c*i-h*r,l[5]=c*n+h*e-u*i,l[6]=h*n+u*r-c*e,l[7]=-u*e-c*r-h*i,l},F.fromRotationTranslation=s,F.fromTranslation=function(e,t){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e[4]=.5*t[0],e[5]=.5*t[1],e[6]=.5*t[2],e[7]=0,e},F.fromRotation=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=0,e[5]=0,e[6]=0,e[7]=0,e},F.fromMat4=function(e,n){var a=r.create();i.getRotation(a,n);var o=new t.ARRAY_TYPE(3);return i.getTranslation(o,n),s(e,a,o),e},F.copy=l,F.identity=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e[6]=0,e[7]=0,e},F.set=function(e,t,r,i,n,a,o,s,l){return e[0]=t,e[1]=r,e[2]=i,e[3]=n,e[4]=a,e[5]=o,e[6]=s,e[7]=l,e},F.getDual=function(e,t){return e[0]=t[4],e[1]=t[5],e[2]=t[6],e[3]=t[7],e},F.setDual=function(e,t){return e[4]=t[0],e[5]=t[1],e[6]=t[2],e[7]=t[3],e},F.getTranslation=function(e,t){var r=t[4],i=t[5],n=t[6],a=t[7],o=-t[0],s=-t[1],l=-t[2],u=t[3];return e[0]=2*(r*u+a*o+i*l-n*s),e[1]=2*(i*u+a*s+n*o-r*l),e[2]=2*(n*u+a*l+r*s-i*o),e},F.translate=function(e,t,r){var i=t[0],n=t[1],a=t[2],o=t[3],s=.5*r[0],l=.5*r[1],u=.5*r[2],c=t[4],h=t[5],f=t[6],d=t[7];return e[0]=i,e[1]=n,e[2]=a,e[3]=o,e[4]=o*s+n*u-a*l+c,e[5]=o*l+a*s-i*u+h,e[6]=o*u+i*l-n*s+f,e[7]=-i*s-n*l-a*u+d,e},F.rotateX=function(e,t,i){var n=-t[0],a=-t[1],o=-t[2],s=t[3],l=t[4],u=t[5],c=t[6],h=t[7],f=l*s+h*n+u*o-c*a,d=u*s+h*a+c*n-l*o,p=c*s+h*o+l*a-u*n,m=h*s-l*n-u*a-c*o;return r.rotateX(e,t,i),e[4]=f*(s=e[3])+m*(n=e[0])+d*(o=e[2])-p*(a=e[1]),e[5]=d*s+m*a+p*n-f*o,e[6]=p*s+m*o+f*a-d*n,e[7]=m*s-f*n-d*a-p*o,e},F.rotateY=function(e,t,i){var n=-t[0],a=-t[1],o=-t[2],s=t[3],l=t[4],u=t[5],c=t[6],h=t[7],f=l*s+h*n+u*o-c*a,d=u*s+h*a+c*n-l*o,p=c*s+h*o+l*a-u*n,m=h*s-l*n-u*a-c*o;return r.rotateY(e,t,i),e[4]=f*(s=e[3])+m*(n=e[0])+d*(o=e[2])-p*(a=e[1]),e[5]=d*s+m*a+p*n-f*o,e[6]=p*s+m*o+f*a-d*n,e[7]=m*s-f*n-d*a-p*o,e},F.rotateZ=function(e,t,i){var n=-t[0],a=-t[1],o=-t[2],s=t[3],l=t[4],u=t[5],c=t[6],h=t[7],f=l*s+h*n+u*o-c*a,d=u*s+h*a+c*n-l*o,p=c*s+h*o+l*a-u*n,m=h*s-l*n-u*a-c*o;return r.rotateZ(e,t,i),e[4]=f*(s=e[3])+m*(n=e[0])+d*(o=e[2])-p*(a=e[1]),e[5]=d*s+m*a+p*n-f*o,e[6]=p*s+m*o+f*a-d*n,e[7]=m*s-f*n-d*a-p*o,e},F.rotateByQuatAppend=function(e,t,r){var i=r[0],n=r[1],a=r[2],o=r[3],s=t[0],l=t[1],u=t[2],c=t[3];return e[0]=s*o+c*i+l*a-u*n,e[1]=l*o+c*n+u*i-s*a,e[2]=u*o+c*a+s*n-l*i,e[3]=c*o-s*i-l*n-u*a,e[4]=(s=t[4])*o+(c=t[7])*i+(l=t[5])*a-(u=t[6])*n,e[5]=l*o+c*n+u*i-s*a,e[6]=u*o+c*a+s*n-l*i,e[7]=c*o-s*i-l*n-u*a,e},F.rotateByQuatPrepend=function(e,t,r){var i=t[0],n=t[1],a=t[2],o=t[3],s=r[0],l=r[1],u=r[2],c=r[3];return e[0]=i*c+o*s+n*u-a*l,e[1]=n*c+o*l+a*s-i*u,e[2]=a*c+o*u+i*l-n*s,e[3]=o*c-i*s-n*l-a*u,e[4]=i*(c=r[7])+o*(s=r[4])+n*(u=r[6])-a*(l=r[5]),e[5]=n*c+o*l+a*s-i*u,e[6]=a*c+o*u+i*l-n*s,e[7]=o*c-i*s-n*l-a*u,e},F.rotateAroundAxis=function(e,r,i,n){if(Math.abs(n)0){r=Math.sqrt(r);var i=t[0]/r,n=t[1]/r,a=t[2]/r,o=t[3]/r,s=t[4],l=t[5],u=t[6],c=t[7],h=i*s+n*l+a*u+o*c;e[0]=i,e[1]=n,e[2]=a,e[3]=o,e[4]=(s-i*h)/r,e[5]=(l-n*h)/r,e[6]=(u-a*h)/r,e[7]=(c-o*h)/r}return e},F.str=function(e){return"quat2("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+")"},F.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]},F.equals=function(e,r){var i=e[0],n=e[1],a=e[2],o=e[3],s=e[4],l=e[5],u=e[6],c=e[7],h=r[0],f=r[1],d=r[2],p=r[3],m=r[4],v=r[5],_=r[6],y=r[7];return Math.abs(i-h)<=t.EPSILON*Math.max(1,Math.abs(i),Math.abs(h))&&Math.abs(n-f)<=t.EPSILON*Math.max(1,Math.abs(n),Math.abs(f))&&Math.abs(a-d)<=t.EPSILON*Math.max(1,Math.abs(a),Math.abs(d))&&Math.abs(o-p)<=t.EPSILON*Math.max(1,Math.abs(o),Math.abs(p))&&Math.abs(s-m)<=t.EPSILON*Math.max(1,Math.abs(s),Math.abs(m))&&Math.abs(l-v)<=t.EPSILON*Math.max(1,Math.abs(l),Math.abs(v))&&Math.abs(u-_)<=t.EPSILON*Math.max(1,Math.abs(u),Math.abs(_))&&Math.abs(c-y)<=t.EPSILON*Math.max(1,Math.abs(c),Math.abs(y))},F.sqrLen=F.squaredLength=F.len=F.length=F.dot=F.mul=F.setReal=F.getReal=void 0;var t=o(a()),r=o(O()),i=o(E());function n(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(n=function(e){return e?r:t})(e)}function o(t,r){if(t&&t.__esModule)return t;if(null===t||"object"!==e(t)&&"function"!=typeof t)return{default:t};var i=n(r);if(i&&i.has(t))return i.get(t);var a={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if("default"!==s&&Object.prototype.hasOwnProperty.call(t,s)){var l=o?Object.getOwnPropertyDescriptor(t,s):null;l&&(l.get||l.set)?Object.defineProperty(a,s,l):a[s]=t[s]}return a.default=t,i&&i.set(t,a),a}function s(e,t,r){var i=.5*r[0],n=.5*r[1],a=.5*r[2],o=t[0],s=t[1],l=t[2],u=t[3];return e[0]=o,e[1]=s,e[2]=l,e[3]=u,e[4]=i*u+n*l-a*s,e[5]=n*u+a*o-i*l,e[6]=a*u+i*s-n*o,e[7]=-i*o-n*s-a*l,e}function l(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e}function u(e,t,r){var i=t[0],n=t[1],a=t[2],o=t[3],s=r[4],l=r[5],u=r[6],c=r[7],h=t[4],f=t[5],d=t[6],p=t[7],m=r[0],v=r[1],_=r[2],y=r[3];return e[0]=i*y+o*m+n*_-a*v,e[1]=n*y+o*v+a*m-i*_,e[2]=a*y+o*_+i*v-n*m,e[3]=o*y-i*m-n*v-a*_,e[4]=i*c+o*s+n*u-a*l+h*y+p*m+f*_-d*v,e[5]=n*c+o*l+a*s-i*u+f*y+p*v+d*m-h*_,e[6]=a*c+o*u+i*l-n*s+d*y+p*_+h*v-f*m,e[7]=o*c-i*s-n*l-a*u+p*y-h*m-f*v-d*_,e}F.getReal=r.copy,F.setReal=r.copy,F.mul=u;var c=r.dot;F.dot=c;var h=r.length;F.length=h,F.len=h;var f=r.squaredLength;return F.squaredLength=f,F.sqrLen=f,F}var V,U,j={};function G(){if(V)return j;function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}V=1,Object.defineProperty(j,"__esModule",{value:!0}),j.create=i,j.clone=function(e){var r=new t.ARRAY_TYPE(2);return r[0]=e[0],r[1]=e[1],r},j.fromValues=function(e,r){var i=new t.ARRAY_TYPE(2);return i[0]=e,i[1]=r,i},j.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e},j.set=function(e,t,r){return e[0]=t,e[1]=r,e},j.add=function(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e},j.subtract=n,j.multiply=o,j.divide=s,j.ceil=function(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e},j.floor=function(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e},j.min=function(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e},j.max=function(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e},j.round=function(e,t){return e[0]=Math.round(t[0]),e[1]=Math.round(t[1]),e},j.scale=function(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e},j.scaleAndAdd=function(e,t,r,i){return e[0]=t[0]+r[0]*i,e[1]=t[1]+r[1]*i,e},j.distance=l,j.squaredDistance=u,j.length=c,j.squaredLength=h,j.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e},j.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e},j.normalize=function(e,t){var r=t[0],i=t[1],n=r*r+i*i;return n>0&&(n=1/Math.sqrt(n)),e[0]=t[0]*n,e[1]=t[1]*n,e},j.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]},j.cross=function(e,t,r){var i=t[0]*r[1]-t[1]*r[0];return e[0]=e[1]=0,e[2]=i,e},j.lerp=function(e,t,r,i){var n=t[0],a=t[1];return e[0]=n+i*(r[0]-n),e[1]=a+i*(r[1]-a),e},j.random=function(e,r){r=r||1;var i=2*t.RANDOM()*Math.PI;return e[0]=Math.cos(i)*r,e[1]=Math.sin(i)*r,e},j.transformMat2=function(e,t,r){var i=t[0],n=t[1];return e[0]=r[0]*i+r[2]*n,e[1]=r[1]*i+r[3]*n,e},j.transformMat2d=function(e,t,r){var i=t[0],n=t[1];return e[0]=r[0]*i+r[2]*n+r[4],e[1]=r[1]*i+r[3]*n+r[5],e},j.transformMat3=function(e,t,r){var i=t[0],n=t[1];return e[0]=r[0]*i+r[3]*n+r[6],e[1]=r[1]*i+r[4]*n+r[7],e},j.transformMat4=function(e,t,r){var i=t[0],n=t[1];return e[0]=r[0]*i+r[4]*n+r[12],e[1]=r[1]*i+r[5]*n+r[13],e},j.rotate=function(e,t,r,i){var n=t[0]-r[0],a=t[1]-r[1],o=Math.sin(i),s=Math.cos(i);return e[0]=n*s-a*o+r[0],e[1]=n*o+a*s+r[1],e},j.angle=function(e,t){var r=e[0],i=e[1],n=t[0],a=t[1],o=Math.sqrt(r*r+i*i)*Math.sqrt(n*n+a*a);return Math.acos(Math.min(Math.max(o&&(r*n+i*a)/o,-1),1))},j.zero=function(e){return e[0]=0,e[1]=0,e},j.str=function(e){return"vec2("+e[0]+", "+e[1]+")"},j.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]},j.equals=function(e,r){var i=e[0],n=e[1],a=r[0],o=r[1];return Math.abs(i-a)<=t.EPSILON*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(n-o)<=t.EPSILON*Math.max(1,Math.abs(n),Math.abs(o))},j.forEach=j.sqrLen=j.sqrDist=j.dist=j.div=j.mul=j.sub=j.len=void 0;var t=(function(t){if(t&&t.__esModule)return t;if(null===t||"object"!==e(t)&&"function"!=typeof t)return{default:t};var i=r(void 0);if(i&&i.has(t))return i.get(t);var n={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in t)if("default"!==o&&Object.prototype.hasOwnProperty.call(t,o)){var s=a?Object.getOwnPropertyDescriptor(t,o):null;s&&(s.get||s.set)?Object.defineProperty(n,o,s):n[o]=t[o]}return n.default=t,i&&i.set(t,n),n})(a());function r(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return(r=function(e){return e?i:t})(e)}function i(){var e=new t.ARRAY_TYPE(2);return t.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0),e}function n(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e}function o(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e}function s(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e}function l(e,t){return Math.hypot(t[0]-e[0],t[1]-e[1])}function u(e,t){var r=t[0]-e[0],i=t[1]-e[1];return r*r+i*i}function c(e){return Math.hypot(e[0],e[1])}function h(e){var t=e[0],r=e[1];return t*t+r*r}j.len=c,j.sub=n,j.mul=o,j.div=s,j.dist=l,j.sqrDist=u,j.sqrLen=h;var f,d=(f=i(),function(e,t,r,i,n,a){var o,s;for(t||(t=2),r||(r=0),s=i?Math.min(i*t+r,e.length):e.length,o=r;o1)return 1;for(var r=e,i=0;i<8;i++){var n=this.sampleCurveX(r)-e;if(Math.abs(n)n?o=r:s=r,r=.5*(s-o)+o;return r},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}},q})(),Y=t(X);function J(){if(H)return $;function e(e,t){this.x=e,this.y=t}return H=1,$=e,e.prototype={clone:function(){return new e(this.x,this.y)},add:function(e){return this.clone()._add(e)},sub:function(e){return this.clone()._sub(e)},multByPoint:function(e){return this.clone()._multByPoint(e)},divByPoint:function(e){return this.clone()._divByPoint(e)},mult:function(e){return this.clone()._mult(e)},div:function(e){return this.clone()._div(e)},rotate:function(e){return this.clone()._rotate(e)},rotateAround:function(e,t){return this.clone()._rotateAround(e,t)},matMult:function(e){return this.clone()._matMult(e)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(e){return this.x===e.x&&this.y===e.y},dist:function(e){return Math.sqrt(this.distSqr(e))},distSqr:function(e){var t=e.x-this.x,r=e.y-this.y;return t*t+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith:function(e){return this.angleWithSep(e.x,e.y)},angleWithSep:function(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult:function(e){var t=e[2]*this.x+e[3]*this.y;return this.x=e[0]*this.x+e[1]*this.y,this.y=t,this},_add:function(e){return this.x+=e.x,this.y+=e.y,this},_sub:function(e){return this.x-=e.x,this.y-=e.y,this},_mult:function(e){return this.x*=e,this.y*=e,this},_div:function(e){return this.x/=e,this.y/=e,this},_multByPoint:function(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint:function(e){return this.x/=e.x,this.y/=e.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var e=this.y;return this.y=this.x,this.x=-e,this},_rotate:function(e){var t=Math.cos(e),r=Math.sin(e),i=r*this.x+t*this.y;return this.x=t*this.x-r*this.y,this.y=i,this},_rotateAround:function(e,t){var r=Math.cos(e),i=Math.sin(e),n=t.y+i*(this.x-t.x)+r*(this.y-t.y);return this.x=t.x+r*(this.x-t.x)-i*(this.y-t.y),this.y=n,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},e.convert=function(t){return t instanceof e?t:Array.isArray(t)?new e(t[0],t[1]):t},$}var K=t(J());function Q(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(var r=0;r=1)return 1;var t=e*e,r=t*e;return 4*(e<.5?r:3*(e-t)+r-.75)}function oe(e,t,r,i){var n=new Y(e,t,r,i);return function(e){return n.solve(e)}}var se=oe(.25,.1,.25,1);function le(e,t,r){return Math.min(r,Math.max(t,e))}function ue(e,t,r){return(r=le((r-e)/(t-e),0,1))*r*(3-2*r)}function ce(e,t,r){var i=r-t,n=((e-t)%i+i)%i+t;return n===t?r:n}function he(e,t,r){if(!e.length)return r(null,[]);var i=e.length,n=new Array(e.length),a=null;e.forEach((function(e,o){t(e,(function(e,t){e&&(a=e),n[o]=t,0==--i&&r(a,n)}))}))}function fe(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i(t.y-e.y)*(r.x-e.x)}function Te(e){for(var t,r,i=0,n=0,a=e.length,o=a-1;n@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(function(e,r,i,n){var a=i||n;return t[r]=!a||a.toLowerCase(),""})),t["max-age"]){var r=parseInt(t["max-age"],10);isNaN(r)?delete t["max-age"]:t["max-age"]=r}return t}var Ie,Ae=null;function Ce(e,t){return[e[4*t],e[4*t+1],e[4*t+2],e[4*t+3]]}function Pe(e,t,r,i){for(;t>1;e[n]>1;e[n]<=i?t=n+1:r=n}return t}function De(e){return e>0?1/(1.001-e):1+e}function Re(e){return e>0?1-1/(1.001-e):-e}var Le,Oe,Be,Fe,Ne,Ve,Ue={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(null==Ie){var e=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{Ie=null!=process.env.API_URL_REGEX?new RegExp(process.env.API_URL_REGEX):e}catch(t){Ie=e}}return Ie},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(!Ue.API_URL)return null;try{var e=new URL(Ue.API_URL);return"api.mapbox.cn"===e.hostname?"https://events.mapbox.cn/events/v2":"api.mapbox.com"===e.hostname?"https://events.mapbox.com/events/v2":null}catch(e){return null}},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",RASTERARRAYS_URL_PREFIX:"rasterarrays/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,DEFAULT_STYLE:"mapbox://styles/mapbox/standard",MAX_PARALLEL_IMAGE_REQUESTS:16,DRACO_URL:"https://api.mapbox.com/mapbox-gl-js/draco_decoder_gltf_v1.5.6.wasm",MESHOPT_URL:"https://api.mapbox.com/mapbox-gl-js/meshopt_base_v0.20.wasm",MESHOPT_SIMD_URL:"https://api.mapbox.com/mapbox-gl-js/meshopt_simd_v0.20.wasm",GLYPHS_URL:"mapbox://fonts/mapbox/{fontstack}/{range}.pbf",TILES3D_URL_PREFIX:"3dtiles/v1"};function je(e){return Ue.API_URL_REGEX.test(e)}function Ge(e){return Ue.API_SPRITE_REGEX.test(e)}function qe(){return null==Le&&(Le=self.OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof self.createImageBitmap),Le}var Ze={now:function(){return void 0!==Fe?Fe:performance.now()},setNow:function(e){Fe=e},restoreNow:function(){Fe=void 0},frame:function(e){var t=requestAnimationFrame(e);return{cancel:function(){return cancelAnimationFrame(t)}}},getImageData:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=e.width,i=e.height;Ne||(Ne=document.createElement("canvas"));var n=Ne.getContext("2d",{willReadFrequently:!0});if(!n)throw new Error("failed to create canvas 2d context");return(r>Ne.width||i>Ne.height)&&(Ne.width=r,Ne.height=i),n.clearRect(-t,-t,r+2*t,i+2*t),n.drawImage(e,0,0,r,i),n.getImageData(-t,-t,r+2*t,i+2*t)},resolveURL:function(e){return Oe||(Oe=document.createElement("a")),Oe.href=e,Oe.href},get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return!!window.matchMedia&&(null==Be&&(Be=window.matchMedia("(prefers-reduced-motion: reduce)")),Be.matches)},hasCanvasFingerprintNoise:function(){if(void 0!==Ve)return Ve;if(!qe())return Ve=!1,!1;for(var e=new OffscreenCanvas(85,1),t=e.getContext("2d",{willReadFrequently:!0}),r=0,i=0;i1&&void 0!==arguments[1]?arguments[1]:{persistentParams:[]},r=e.indexOf("?");if(r<0)return e;var i=new URLSearchParams,n=new URLSearchParams(e.slice(r));for(var a of t.persistentParams){var o=n.get(a);o&&i.set(a,o)}var s=i.toString();return`${e.slice(0,r)}${s.length>0?`?${s}`:""}`}var We,Xe,Ye="mapbox-tiles",Je=500,Ke=50,Qe=["language","worldview","jobid"];function et(){try{return caches}catch(e){}}function tt(){var e=et();e&&null==We&&(We=e.open(Ye))}var rt,it,nt=1/0,at={supported:!1,testSupport:function(e){!ot&&it&&(st?ut(e):rt=e)}},ot=!1,st=!1,lt="undefined"!=typeof self?self:{};function ut(e){var t=e.createTexture();e.bindTexture(e.TEXTURE_2D,t);try{if(e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,it),e.isContextLost())return;at.supported=!0}catch(e){}e.deleteTexture(t),ot=!0}lt.document&&((it=lt.document.createElement("img")).onload=function(){rt&&ut(rt),rt=null,st=!0},it.onerror=function(){ot=!0,rt=null},it.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");var ct={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image",Model:"Model"};"function"==typeof Object.freeze&&Object.freeze(ct);var ht=(function(e){function t(e,r,i){var n;return p(this,t),401===r&&je(i)&&(e+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),(n=T(this,t,[e])).status=r,n.url=i,n}return y(t,e),m(t,[{key:"toString",value:function(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}])})(g(Error)),ft=Se()?function(){return self.worker&&self.worker.referrer}:function(){return("blob:"===location.protocol?parent:self).location.href},dt=function(e,t){if(!(/^file:/.test(r=e.url)||/^file:/.test(ft())&&!/^\w+:/.test(r))){if(self.fetch&&self.Request&&self.AbortController&&Request.prototype.hasOwnProperty("signal"))return(function(e,t){var r,i=new AbortController,n=new Request(e.url,{method:e.method||"GET",body:e.body,credentials:e.credentials,headers:e.headers,referrer:ft(),referrerPolicy:e.referrerPolicy,signal:i.signal}),a=!1,o=!1,s=(r=n.url).indexOf("sku=")>0&&je(r);"json"===e.type&&n.headers.set("Accept","application/json");var l=function(r,i,a){if(!o){if(r&&"SecurityError"!==r.message&&we(r.toString()),i&&a)return u(i);var l=Date.now();fetch(n).then((function(r){if(r.ok){var i=s?r.clone():null;return u(r,i,l)}return t(new ht(r.statusText,r.status,e.url))})).catch((function(r){"AbortError"!==r.name&&t(new Error(`${r.message} ${e.url}`))}))}},u=function(r,i,s){("arrayBuffer"===e.type?r.arrayBuffer():"json"===e.type?r.json():r.text()).then((function(e){o||(i&&s&&(function(e,t,r){if(tt(),null!=We){var i=Ee(t.headers.get("Cache-Control")||"");if(!i["no-store"]){var n={status:t.status,statusText:t.statusText,headers:new Headers};t.headers.forEach((function(e,t){return n.headers.set(t,e)})),i["max-age"]&&n.headers.set("Expires",new Date(r+1e3*i["max-age"]).toUTCString());var a=n.headers.get("Expires");if(a&&!(new Date(a).getTime()-r<42e4)){var o=He(e.url,{persistentParams:Qe});if(206===t.status){var s=e.headers.get("Range");if(!s)return;n.status=200,o=$e(o,{range:s})}!(function(e,t){if(void 0===Xe)try{new Response(new ReadableStream),Xe=!0}catch(e){Xe=!1}Xe?t(e.body):e.blob().then(t)})(t,(function(e){var r,i=new Response(200!==(r=t.status)&&404!==r&&[101,103,204,205,304].includes(r)?null:e,n);tt(),null!=We&&We.then((function(e){return e.put(o,i)})).catch((function(e){return we(e.message)}))}))}}}})(n,i,s),a=!0,t(null,e,r.headers.get("Cache-Control"),r.headers.get("Expires")))})).catch((function(e){o||t(new Error(e.message))}))};return s?(function(e,t){if(tt(),null==We)return t(null);We.then((function(r){var i=He(e.url,{persistentParams:Qe}),n=e.headers.get("Range");n&&(i=$e(i,{range:n})),r.match(i).then((function(e){var n=(function(e){if(!e)return!1;var t=new Date(e.headers.get("Expires")||0),r=Ee(e.headers.get("Cache-Control")||"");return t>Date.now()&&!r["no-cache"]})(e);r.delete(i),n&&r.put(i,e.clone()),t(null,e,n)})).catch(t)})).catch(t)})(n,l):l(null,null),{cancel:function(){o=!0,a||i.abort()}}})(e,t);if(Se()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",e,t,void 0,!0)}var r;return(function(e,t){var r=new XMLHttpRequest;for(var i in r.open(e.method||"GET",e.url,!0),"arrayBuffer"===e.type&&(r.responseType="arraybuffer"),e.headers)r.setRequestHeader(i,e.headers[i]);return"json"===e.type&&(r.responseType="text",r.setRequestHeader("Accept","application/json")),r.withCredentials="include"===e.credentials,r.onerror=function(){t(new Error(r.statusText))},r.onload=function(){if((r.status>=200&&r.status<300||0===r.status)&&null!==r.response){var i=r.response;if("json"===e.type)try{i=JSON.parse(r.response)}catch(e){return t(e)}t(null,i,r.getResponseHeader("Cache-Control"),r.getResponseHeader("Expires"))}else t(new ht(r.statusText,r.status,e.url))},r.send(e.body),{cancel:function(){return r.abort()}}})(e,t)},pt=function(e,t){return dt(fe(e,{type:"arrayBuffer"}),t)};function mt(e){var t=document.createElement("a");return t.href=e,t.protocol===location.protocol&&t.host===location.host}var vt,_t,yt="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";vt=[],_t=0;var gt,xt,bt,wt=function(e,t){if(at.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),_t>=Ue.MAX_PARALLEL_IMAGE_REQUESTS){var r={requestParameters:e,callback:t,cancelled:!1,cancel:function(){this.cancelled=!0}};return vt.push(r),r}_t++;var i=!1,n=function(){if(!i)for(i=!0,_t--;vt.length&&_t>>16)*o&65535)<<16)&4294967295)<<15|l>>>17))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<13|n>>>19))+((5*(n>>>16)&65535)<<16)&4294967295))+((58964+(a>>>16)&65535)<<16);switch(l=0,r){case 3:l^=(255&e.charCodeAt(u+2))<<16;case 2:l^=(255&e.charCodeAt(u+1))<<8;case 1:n^=l=(65535&(l=(l=(65535&(l^=255&e.charCodeAt(u)))*o+(((l>>>16)*o&65535)<<16)&4294967295)<<15|l>>>17))*s+(((l>>>16)*s&65535)<<16)&4294967295}return n^=e.length,n=2246822507*(65535&(n^=n>>>16))+((2246822507*(n>>>16)&65535)<<16)&4294967295,n=3266489909*(65535&(n^=n>>>13))+((3266489909*(n>>>16)&65535)<<16)&4294967295,(n^=n>>>16)>>>0}),Tt.exports),t=(xt||(xt=1,Mt.exports=function(e,t){for(var r,i=e.length,n=t^i,a=0;i>=4;)r=1540483477*(65535&(r=255&e.charCodeAt(a)|(255&e.charCodeAt(++a))<<8|(255&e.charCodeAt(++a))<<16|(255&e.charCodeAt(++a))<<24))+((1540483477*(r>>>16)&65535)<<16),n=1540483477*(65535&n)+((1540483477*(n>>>16)&65535)<<16)^(r=1540483477*(65535&(r^=r>>>24))+((1540483477*(r>>>16)&65535)<<16)),i-=4,++a;switch(i){case 3:n^=(255&e.charCodeAt(a+2))<<16;case 2:n^=(255&e.charCodeAt(a+1))<<8;case 1:n=1540483477*(65535&(n^=255&e.charCodeAt(a)))+((1540483477*(n>>>16)&65535)<<16)}return n=1540483477*(65535&(n^=n>>>13))+((1540483477*(n>>>16)&65535)<<16),(n^=n>>>15)>>>0}),Mt.exports);return kt.exports=e,kt.exports.murmur3=e,kt.exports.murmur2=t,kt.exports})(),Et=t(St),It=m((function e(t){p(this,e),fe(this,(arguments.length<=1?void 0:arguments[1])||{}),this.type=t})),At=(function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return p(this,t),T(this,t,["error",fe({error:e},r)])}return y(t,e),m(t)})(It);function Ct(e,t,r){r[e]&&-1!==r[e].indexOf(t)||(r[e]=r[e]||[],r[e].push(t))}function Pt(e,t,r){if(r&&r[e]){var i=r[e].indexOf(t);-1!==i&&r[e].splice(i,1)}}var zt,Dt=(function(){return m((function e(){p(this,e)}),[{key:"on",value:function(e,t){return this._listeners=this._listeners||{},Ct(e,t,this._listeners),this}},{key:"off",value:function(e,t){return Pt(e,t,this._listeners),Pt(e,t,this._oneTimeListeners),this}},{key:"once",value:function(e,t){var r=this;return t?(this._oneTimeListeners=this._oneTimeListeners||{},Ct(e,t,this._oneTimeListeners),this):new Promise((function(t){return r.once(e,t)}))}},{key:"fire",value:function(e,t){var r="string"==typeof e?new It(e,t):e,i=r.type;if(this.listens(i)){r.target=this;var n=this._listeners&&this._listeners[i]?this._listeners[i].slice():[];for(var a of n)a.call(this,r);var o=this._oneTimeListeners&&this._oneTimeListeners[i]?this._oneTimeListeners[i].slice():[];for(var s of o)Pt(i,s,this._oneTimeListeners),s.call(this,r);var l=this._eventedParent;l&&(fe(r,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),l.fire(r))}else r instanceof At&&console.error(r.error);return this}},{key:"listens",value:function(e){return!!(this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e))}},{key:"setEventedParent",value:function(e,t){return this._eventedParent=e,this._eventedParentData=t,this}}])})(),Rt={},Lt=(function(){if(zt)return Rt;zt=1;var e={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function t(e){return(e=Math.round(e))<0?0:e>255?255:e}function r(e){return t("%"===e[e.length-1]?parseFloat(e)/100*255:parseInt(e))}function i(e){return(t="%"===e[e.length-1]?parseFloat(e)/100:parseFloat(e))<0?0:t>1?1:t;var t}function n(e,t,r){return r<0?r+=1:r>1&&(r-=1),6*r<1?e+(t-e)*r*6:2*r<1?t:3*r<2?e+(t-e)*(.6666666666666666-r)*6:e}try{Rt.parseCSSColor=function(a){var o,s=a.replace(/ /g,"").toLowerCase();if(s in e)return e[s].slice();if("#"===s[0])return 4===s.length?(o=parseInt(s.substr(1),16))>=0&&o<=4095?[(3840&o)>>4|(3840&o)>>8,240&o|(240&o)>>4,15&o|(15&o)<<4,1]:null:7===s.length&&(o=parseInt(s.substr(1),16))>=0&&o<=16777215?[(16711680&o)>>16,(65280&o)>>8,255&o,1]:null;var l=s.indexOf("("),u=s.indexOf(")");if(-1!==l&&u+1===s.length){var c=s.substr(0,l),h=s.substr(l+1,u-(l+1)).split(","),f=1;switch(c){case"rgba":if(4!==h.length)return null;f=i(h.pop());case"rgb":return 3!==h.length?null:[r(h[0]),r(h[1]),r(h[2]),f];case"hsla":if(4!==h.length)return null;f=i(h.pop());case"hsl":if(3!==h.length)return null;var d=(parseFloat(h[0])%360+360)%360/360,p=i(h[1]),m=i(h[2]),v=m<=.5?m*(p+1):m+p-m*p,_=2*m-v;return[t(255*n(_,v,d+.3333333333333333)),t(255*n(_,v,d)),t(255*n(_,v,d-.3333333333333333)),f];default:return null}}return null}}catch(e){}return Rt})(),Ot=(function(){function e(t,r,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;p(this,e),this.r=t,this.g=r,this.b=i,this.a=n}return m(e,[{key:"toString",value:function(){var e=0===this.a?[0,0,0,0]:[255*this.r/this.a,255*this.g/this.a,255*this.b/this.a,this.a],t=x(e,4),r=t[0],i=t[1],n=t[2],a=t[3];return`rgba(${Math.round(r)},${Math.round(i)},${Math.round(n)},${a})`}},{key:"toRenderColor",value:function(e){var t=this.r,r=this.g,i=this.b,n=this.a;return new Bt(e,t,r,i,n)}}],[{key:"parse",value:function(t){if(t){if(t instanceof e)return t;if("string"==typeof t){var r=Lt.parseCSSColor(t);return r?new e(r[0]/255*r[3],r[1]/255*r[3],r[2]/255*r[3],r[3]):void 0}}}}])})(),Bt=(function(){return m((function e(t,r,i,n,a){if(p(this,e),t){var o=t.image.height,s=o*o;r=0===a?0:r/a*(o-1),i=0===a?0:i/a*(o-1),n=0===a?0:n/a*(o-1);var l=Math.floor(r),u=Math.floor(i),c=Math.floor(n),h=Math.ceil(r),f=Math.ceil(i),d=Math.ceil(n),m=r-l,v=i-u,_=n-c,y=t.image.data,g=4*(l+u*s+c*o),x=4*(l+u*s+d*o),b=4*(l+f*s+c*o),w=4*(l+f*s+d*o),k=4*(h+u*s+c*o),T=4*(h+u*s+d*o),M=4*(h+f*s+c*o),S=4*(h+f*s+d*o);if(g<0||S>=y.length)throw new Error("out of range");this.r=Ft(Ft(Ft(y[g],y[x],_),Ft(y[b],y[w],_),v),Ft(Ft(y[k],y[T],_),Ft(y[M],y[S],_),v),m)/255*a,this.g=Ft(Ft(Ft(y[g+1],y[x+1],_),Ft(y[b+1],y[w+1],_),v),Ft(Ft(y[k+1],y[T+1],_),Ft(y[M+1],y[S+1],_),v),m)/255*a,this.b=Ft(Ft(Ft(y[g+2],y[x+2],_),Ft(y[b+2],y[w+2],_),v),Ft(Ft(y[k+2],y[T+2],_),Ft(y[M+2],y[S+2],_),v),m)/255*a,this.a=a}else this.r=r,this.g=i,this.b=n,this.a=a}),[{key:"toArray",value:function(){var e=this.r,t=this.g,r=this.b,i=this.a;return 0===i?[0,0,0,0]:[255*e/i,255*t/i,255*r/i,i]}},{key:"toArray01",value:function(){var e=this.r,t=this.g,r=this.b,i=this.a;return 0===i?[0,0,0,0]:[e/i,t/i,r/i,i]}},{key:"toArray01Scaled",value:function(e){var t=this.r,r=this.g,i=this.b,n=this.a;return 0===n?[0,0,0]:[t/n*e,r/n*e,i/n*e]}},{key:"toArray01PremultipliedAlpha",value:function(){return[this.r,this.g,this.b,this.a]}},{key:"toArray01Linear",value:function(){var e=this.r,t=this.g,r=this.b,i=this.a;return 0===i?[0,0,0,0]:[Math.pow(e/i,2.2),Math.pow(t/i,2.2),Math.pow(r/i,2.2),i]}}])})();function Ft(e,t,r){return e*(1-r)+t*r}function Nt(e,t,r){return e.map((function(e,i){return Ft(e,t[i],r)}))}Ot.black=new Ot(0,0,0,1),Ot.white=new Ot(1,1,1,1),Ot.transparent=new Ot(0,0,0,0),Ot.red=new Ot(1,0,0,1),Ot.blue=new Ot(0,0,1,1);var Vt=Object.freeze({__proto__:null,array:Nt,color:function(e,t,r){return new Ot(Ft(e.r,t.r,r),Ft(e.g,t.g,r),Ft(e.b,t.b,r),Ft(e.a,t.a,r))},number:Ft});function Ut(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i1&&void 0!==arguments[1]?arguments[1]:[];for(var i of(p(this,e),this.parent=t,this.bindings={},r)){var n=x(i,2),a=n[0],o=n[1];this.bindings[a]=o}}return m(e,[{key:"concat",value:function(t){return new e(this,t)}},{key:"get",value:function(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw new Error(`${e} not found in scope.`)}},{key:"has",value:function(e){return!!this.bindings[e]||!!this.parent&&this.parent.has(e)}}])})(),qt={kind:"null"},Zt={kind:"number"},$t={kind:"string"},Ht={kind:"boolean"},Wt={kind:"color"},Xt={kind:"object"},Yt={kind:"value"},Jt={kind:"collator"},Kt={kind:"formatted"},Qt={kind:"resolvedImage"};function er(e,t){return{kind:"array",itemType:e,N:t}}function tr(e){if("array"===e.kind){var t=tr(e.itemType);return"number"==typeof e.N?`array<${t}, ${e.N}>`:"value"===e.itemType.kind?"array":`array<${t}>`}return e.kind}var rr=[qt,Zt,$t,Ht,Wt,Kt,Xt,er(Yt),Qt];function ir(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!ir(e.itemType,t.itemType))&&("number"!=typeof e.N||e.N===t.N))return null}else{if(e.kind===t.kind)return null;if("value"===e.kind)for(var r of rr)if(!ir(r,t))return null}return`Expected ${tr(e)} but found ${tr(t)} instead.`}function nr(e,t){return t.some((function(t){return t.kind===e.kind}))}function ar(e,t){return t.some((function(t){return"null"===t?null===e:"array"===t?Array.isArray(e):"object"===t?e&&!Array.isArray(e)&&"object"==typeof e:t===typeof e}))}var or=(function(){return m((function e(t,r,i){p(this,e),this.sensitivity=t?r?"variant":"case":r?"accent":"base",this.locale=i,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}),[{key:"compare",value:function(e,t){return this.collator.compare(e,t)}},{key:"resolvedLocale",value:function(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}])})(),sr=m((function e(t,r,i,n,a){p(this,e),this.text=t.normalize?t.normalize():t,this.image=r,this.scale=i,this.fontStack=n,this.textColor=a})),lr=(function(){function e(t){p(this,e),this.sections=t}return m(e,[{key:"isEmpty",value:function(){return 0===this.sections.length||!this.sections.some((function(e){return 0!==e.text.length||e.image&&0!==e.image.namePrimary.length}))}},{key:"toString",value:function(){return 0===this.sections.length?"":this.sections.map((function(e){return e.text})).join("")}},{key:"serialize",value:function(){var e=["format"];for(var t of this.sections)if(t.image)e.push(["image",t.image.namePrimary]);else{e.push(t.text);var r={};t.fontStack&&(r["text-font"]=["literal",t.fontStack.split(",")]),t.scale&&(r["font-scale"]=t.scale),t.textColor&&(r["text-color"]=["rgba"].concat(t.textColor.toRenderColor(null).toArray())),e.push(r)}return e}}],[{key:"fromString",value:function(t){return new e([new sr(t,null,null,null,null)])}},{key:"factory",value:function(t){return t instanceof e?t:e.fromString(t)}}])})(),ur=(function(){function e(t){p(this,e),this.namePrimary=t.namePrimary,t.nameSecondary&&(this.nameSecondary=t.nameSecondary),this.available=t.available}return m(e,[{key:"toString",value:function(){return this.nameSecondary?`[${this.namePrimary},${this.nameSecondary}]`:this.namePrimary}},{key:"serialize",value:function(){return this.nameSecondary?["image",this.namePrimary,this.nameSecondary]:["image",this.namePrimary]}}],[{key:"fromString",value:function(t,r){return t?new e({namePrimary:t,nameSecondary:r,available:!1}):null}}])})();function cr(e,t,r,i){return"number"==typeof e&&e>=0&&e<=255&&"number"==typeof t&&t>=0&&t<=255&&"number"==typeof r&&r>=0&&r<=255?void 0===i||"number"==typeof i&&i>=0&&i<=1?null:`Invalid rgba value [${[e,t,r,i].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof i?[e,t,r,i]:[e,t,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function hr(e){if(null===e)return!0;if("string"==typeof e)return!0;if("boolean"==typeof e)return!0;if("number"==typeof e)return!0;if(e instanceof Ot)return!0;if(e instanceof or)return!0;if(e instanceof lr)return!0;if(e instanceof ur)return!0;if(Array.isArray(e)){for(var t of e)if(!hr(t))return!1;return!0}if("object"==typeof e){for(var r in e)if(!hr(e[r]))return!1;return!0}return!1}function fr(e){if(null===e)return qt;if("string"==typeof e)return $t;if("boolean"==typeof e)return Ht;if("number"==typeof e)return Zt;if(e instanceof Ot)return Wt;if(e instanceof or)return Jt;if(e instanceof lr)return Kt;if(e instanceof ur)return Qt;if(Array.isArray(e)){var t,r=e.length;for(var i of e){var n=fr(i);if(t){if(t===n)continue;t=Yt;break}t=n}return er(t||Yt,r)}return Xt}function dr(e){var t=typeof e;return null===e?"":"string"===t||"number"===t||"boolean"===t?String(e):e instanceof Ot||e instanceof lr||e instanceof ur?e.toString():JSON.stringify(e)}var pr=(function(){function e(t,r){p(this,e),this.type=t,this.value=r}return m(e,[{key:"evaluate",value:function(){return this.value}},{key:"eachChild",value:function(){}},{key:"outputDefined",value:function(){return!0}},{key:"serialize",value:function(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof Ot?["rgba"].concat(this.value.toRenderColor(null).toArray()):this.value instanceof lr?this.value.serialize():this.value}}],[{key:"parse",value:function(t,r){if(2!==t.length)return r.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!hr(t[1]))return r.error("invalid value");var i=t[1],n=fr(i),a=r.expectedType;return"array"!==n.kind||0!==n.N||!a||"array"!==a.kind||"number"==typeof a.N&&0!==a.N||(n=a),new e(n,i)}}])})(),mr=(function(){return m((function e(t){p(this,e),this.name="ExpressionEvaluationError",this.message=t}),[{key:"toJSON",value:function(){return this.message}}])})(),vr={string:$t,number:Zt,boolean:Ht,object:Xt},_r=(function(){function e(t,r){p(this,e),this.type=t,this.args=r}return m(e,[{key:"evaluate",value:function(e){for(var t=0;t1)&&t.push(i)}}return t.concat(this.args.map((function(e){return e.serialize()})))}}],[{key:"parse",value:function(t,r){if(t.length<2)return r.error("Expected at least one argument.");var i,n=1,a=t[0];if("array"===a){var o,s;if(t.length>2){var l=t[1];if("string"!=typeof l||!(l in vr)||"object"===l)return r.error('The item type argument of "array" must be one of string, number, boolean',1);o=vr[l],n++}else o=Yt;if(t.length>3){if(null!==t[2]&&("number"!=typeof t[2]||t[2]<0||t[2]!==Math.floor(t[2])))return r.error('The length argument to "array" must be a positive integer literal',2);s=t[2],n++}i=er(o,s)}else i=vr[a];for(var u=[];n-1,t.nameSecondary&&t.available&&e.availableImages&&(t.available=e.availableImages.indexOf(t.nameSecondary)>-1)),t}},{key:"eachChild",value:function(e){e(this.inputPrimary),this.inputSecondary&&e(this.inputSecondary)}},{key:"outputDefined",value:function(){return!1}},{key:"serialize",value:function(){return this.inputSecondary?["image",this.inputPrimary.serialize(),this.inputSecondary.serialize()]:["image",this.inputPrimary.serialize()]}}],[{key:"parse",value:function(t,r){if(t.length<2)return r.error("Expected two or more arguments.");var i=r.parse(t[1],1,$t);if(!i)return r.error("No image name provided.");if(2===t.length)return new e(i);var n=r.parse(t[2],1,$t);return n?new e(i,n):r.error("Secondary image variant is not a string.")}}])})();function xr(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":null===e?"null":typeof e}var br={"to-boolean":Ht,"to-color":Wt,"to-number":Zt,"to-string":$t},wr=(function(){function e(t,r){p(this,e),this.type=t,this.args=r}return m(e,[{key:"evaluate",value:function(e){if("boolean"===this.type.kind)return Boolean(this.args[0].evaluate(e));if("color"===this.type.kind){var t,r;for(var i of this.args){if(r=null,(t=i.evaluate(e))instanceof Ot)return t;if("string"==typeof t){var n=e.parseColor(t);if(n)return n}else if(Array.isArray(t)&&!(r=t.length<3||t.length>4?`Invalid rbga value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:cr(t[0],t[1],t[2],t[3])))return new Ot(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new mr(r||`Could not parse color from value '${"string"==typeof t?t:String(JSON.stringify(t))}'`)}if("number"===this.type.kind){var a=null;for(var o of this.args){if(null===(a=o.evaluate(e)))return 0;var s=Number(a);if(!isNaN(s))return s}throw new mr(`Could not convert ${JSON.stringify(a)} to number.`)}return"formatted"===this.type.kind?lr.fromString(dr(this.args[0].evaluate(e))):"resolvedImage"===this.type.kind?ur.fromString(dr(this.args[0].evaluate(e))):"array"===this.type.kind?this.args.map((function(t){return t.evaluate(e)})):dr(this.args[0].evaluate(e))}},{key:"eachChild",value:function(e){this.args.forEach(e)}},{key:"outputDefined",value:function(){return this.args.every((function(e){return e.outputDefined()}))}},{key:"serialize",value:function(){if("formatted"===this.type.kind)return new yr([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new gr(this.args[0]).serialize();var e="array"===this.type.kind?[]:[`to-${this.type.kind}`];return this.eachChild((function(t){e.push(t.serialize())})),e}}],[{key:"parse",value:function(t,r){if(t.length<2)return r.error("Expected at least one argument.");var i=t[0],n=[],a=qt;if("to-array"===i){if(!Array.isArray(t[1]))return null;var o=t[1].length;if(r.expectedType){if("array"!==r.expectedType.kind)return r.error(`Expected ${r.expectedType.kind} but found array.`);a=er(r.expectedType.itemType,o)}else{if(!(o>0&&hr(t[1][0])))return null;a=er(fr(t[1][0]),o)}for(var s=0;s2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.length-1,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:Cr;i>r;){if(i-r>600){var a=i-r+1,o=t-r+1,s=Math.log(a),l=.5*Math.exp(2*s/3),u=.5*Math.sqrt(s*l*(a-l)/a)*(o-a/2<0?-1:1);Ir(e,t,Math.max(r,Math.floor(t-o*l/a+u)),Math.min(i,Math.floor(t+(a-o)*l/a+u)),n)}var c=e[t],h=r,f=i;for(Ar(e,r,t),n(e[i],c)>0&&Ar(e,r,i);h0;)f--}0===n(e[r],c)?Ar(e,r,f):Ar(e,++f,i),f<=t&&(r=f+1),t<=f&&(i=f-1)}}function Ar(e,t,r){var i=e[t];e[t]=e[r],e[r]=i}function Cr(e,t){return et?1:0}function Pr(e){for(var t,r,i=0,n=0,a=e.length,o=a-1;n=t[2]||e[1]<=t[1]||e[3]>=t[3])}function Rr(e,t,r){var i=e[0]-t[0],n=e[1]-t[1],a=e[0]-r[0],o=e[1]-r[1];return i*o-a*n==0&&i*a<=0&&n*o<=0}function Lr(e,t){for(var r,i,n,a=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=!1,s=0,l=t.length;s(r=e)[1]!=(n=p)[1]>r[1]&&r[0]<(n[0]-i[0])*(r[1]-i[1])/(n[1]-i[1])+i[0]&&(o=!o)}return o}function Or(e,t,r,i){var n=i[0]-r[0],a=i[1]-r[1],o=(e[0]-r[0])*a-n*(e[1]-r[1]),s=(t[0]-r[0])*a-n*(t[1]-r[1]);return o>0&&s<0||o<0&&s>0}function Br(e,t,r,i){return 0!=(n=[i[0]-r[0],i[1]-r[1]])[0]*(a=[t[0]-e[0],t[1]-e[1]])[1]-n[1]*a[0]&&!(!Or(e,t,r,i)||!Or(r,i,e,t));var n,a}var Fr=8192;function Nr(e,t){var r=(180+e[0])/360,i=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e[1]*Math.PI/360)))/360,n=Math.pow(2,t.z);return[Math.round(r*n*Fr),Math.round(i*n*Fr)]}function Vr(e,t){for(var r=0;rr[2]){var n=.5*i,a=e[0]-r[0]>n?-i:r[0]-e[0]>n?i:0;0===a&&(a=e[0]-r[2]>n?-i:r[2]-e[0]>n?i:0),e[0]+=a}zr(t,e)}function Hr(e,t,r,i){var n=Math.pow(2,i.z)*Fr,a=[i.x*Fr,i.y*Fr],o=[];if(!e)return o;for(var s of e)for(var l of s){var u=[l.x+a[0],l.y+a[1]];$r(u,t,r,n),o.push(u)}return o}function Wr(e,t,r,i){var n,a=Math.pow(2,i.z)*Fr,o=[i.x*Fr,i.y*Fr],s=[];if(!e)return s;for(var l of e){var u=[];for(var c of l){var h=[c.x+o[0],c.y+o[1]];zr(t,h),u.push(h)}s.push(u)}if(t[2]-t[0]<=a/2)for(var f of((n=t)[0]=n[1]=1/0,n[2]=n[3]=-1/0,s))for(var d of f)$r(d,t,r,a);return s}var Xr=(function(){function e(t,r){p(this,e),this.type=Ht,this.geojson=t,this.geometries=r}return m(e,[{key:"evaluate",value:function(e){if(null!=e.geometry()&&null!=e.canonicalID()){if("Point"===e.geometryType())return(function(e,t){var r=[1/0,1/0,-1/0,-1/0],i=[1/0,1/0,-1/0,-1/0],n=e.canonicalID();if(!n)return!1;if("Polygon"===t.type){var a=qr(t.coordinates,i,n),o=Hr(e.geometry(),r,i,n);if(!Dr(r,i))return!1;for(var s of o)if(!Lr(s,a))return!1}if("MultiPolygon"===t.type){var l=Zr(t.coordinates,i,n),u=Hr(e.geometry(),r,i,n);if(!Dr(r,i))return!1;for(var c of u)if(!Vr(c,l))return!1}return!0})(e,this.geometries);if("LineString"===e.geometryType())return(function(e,t){var r=[1/0,1/0,-1/0,-1/0],i=[1/0,1/0,-1/0,-1/0],n=e.canonicalID();if(!n)return!1;if("Polygon"===t.type){var a=qr(t.coordinates,i,n),o=Wr(e.geometry(),r,i,n);if(!Dr(r,i))return!1;for(var s of o)if(!jr(s,a))return!1}if("MultiPolygon"===t.type){var l=Zr(t.coordinates,i,n),u=Wr(e.geometry(),r,i,n);if(!Dr(r,i))return!1;for(var c of u)if(!Gr(c,l))return!1}return!0})(e,this.geometries)}return!1}},{key:"eachChild",value:function(){}},{key:"outputDefined",value:function(){return!0}},{key:"serialize",value:function(){return["within",this.geojson]}}],[{key:"parse",value:function(t,r){if(2!==t.length)return r.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(hr(t[1])){var i=t[1];if("FeatureCollection"===i.type)for(var n=0;nt)return ei(n,a,(t-(r-o))/o)}return e[e.length-1]}},{key:"pointToSegmentDistance",value:function(e,t,r){var i=x(t,2),n=i[0],a=i[1],o=ti(r[0]-n)*this.kx,s=(r[1]-a)*this.ky;if(0!==o||0!==s){var l=(ti(e[0]-n)*this.kx*o+(e[1]-a)*this.ky*s)/(o*o+s*s);l>1?(n=r[0],a=r[1]):l>0&&(n+=o/this.kx*l,a+=s/this.ky*l)}return o=ti(e[0]-n)*this.kx,s=(e[1]-a)*this.ky,Math.sqrt(o*o+s*s)}},{key:"pointOnLine",value:function(e,t){for(var r=1/0,i=e[0][0],n=e[0][1],a=0,o=0,s=0;s1?(l=e[s+1][0],u=e[s+1][1]):f>0&&(l+=c/this.kx*f,u+=h/this.ky*f));var d=(c=ti(t[0]-l)*this.kx)*c+(h=(t[1]-u)*this.ky)*h;dn.index||i.index===n.index&&i.t>n.t){var a=i;i=n,n=a}var o=[i.point],s=i.index+1,l=n.index;!Qr(r[s],o[0])&&s<=l&&o.push(r[s]);for(var u=s+1;u<=l;u++)o.push(r[u]);return Qr(r[l],n.point)||o.push(n.point),o}},{key:"lineSliceAlong",value:function(e,t,r){for(var i=0,n=[],a=0;ae&&0===n.length&&n.push(ei(o,s,(e-(i-l))/l)),i>=t)return n.push(ei(o,s,(t-(i-l))/l)),n;i>e&&n.push(s)}return n}},{key:"bufferPoint",value:function(e,t){var r=t/this.ky,i=t/this.kx;return[e[0]-i,e[1]-r,e[0]+i,e[1]+r]}},{key:"bufferBBox",value:function(e,t){var r=t/this.ky,i=t/this.kx;return[e[0]-i,e[1]-r,e[2]+i,e[3]+r]}},{key:"insideBBox",value:function(e,t){return ti(e[0]-t[0])>=0&&ti(e[0]-t[2])<=0&&e[1]>=t[1]&&e[1]<=t[3]}}],[{key:"fromTile",value:function(t,r,i){var n=Math.PI*(1-2*(t+.5)/Math.pow(2,r));return new e(Math.atan(.5*(Math.exp(n)-Math.exp(-n)))/Jr,i)}},{key:"units",get:function(){return Yr}}])})();function Qr(e,t){return e[0]===t[0]&&e[1]===t[1]}function ei(e,t,r){var i=ti(t[0]-e[0]);return[e[0]+i*r,e[1]+(t[1]-e[1])*r]}function ti(e){for(;e<-180;)e+=360;for(;e>180;)e-=360;return e}var ri=(function(){return m((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(e,t){return et?1:0};if(p(this,e),this.data=t,this.length=this.data.length,this.compare=r,this.length>0)for(var i=(this.length>>1)-1;i>=0;i--)this._down(i)}),[{key:"push",value:function(e){this.data.push(e),this._up(this.length++)}},{key:"pop",value:function(){if(0!==this.length){var e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}}},{key:"peek",value:function(){return this.data[0]}},{key:"_up",value:function(e){for(var t=this.data,r=this.compare,i=t[e];e>0;){var n=e-1>>1,a=t[n];if(r(i,a)>=0)break;t[e]=a,e=n}t[e]=i}},{key:"_down",value:function(e){for(var t=this.data,r=this.compare,i=this.length>>1,n=t[e];e=0)break;t[e]=t[a],e=a}t[e]=n}}])})(),ii=8192;function ni(e,t){return t.dist-e.dist}function ai(e){var t=[1/0,1/0,-1/0,-1/0];if(t.length!==e.length)return!1;for(var r=0;r=e[0]&&e[1]e[1])return[null,null];var r=oi(e);if(t){if(2===r)return[e,null];var i=Math.floor(r/2);return[[e[0],e[0]+i],[e[0]+i,e[1]]]}if(1===r)return[e,null];var n=Math.floor(r/2)-1;return[[e[0],e[0]+n],[e[0]+n+1,e[1]]]}function ui(e,t){var r=[1/0,1/0,-1/0,-1/0];if(!si(t,e.length))return r;for(var i=t[0];i<=t[1];++i)zr(r,e[i]);return r}function ci(e){for(var t=[1/0,1/0,-1/0,-1/0],r=0;rt[2]&&(i=e[0]-t[2]),e[1]>t[3]&&(n=e[1]-t[3]),e[3]3&&void 0!==arguments[3]?arguments[3]:1/0,n=ci(e),a=ci(t);if(i!==1/0&&hi(n,a,r)>=i)return i;if(Dr(n,a)){if(ki(e,t))return 0}else if(ki(t,e))return 0;var o=i;for(var s of e)for(var l=0,u=s.length,c=u-1;l4&&void 0!==arguments[4]?arguments[4]:1/0,a=Math.min(i.distance(e[0],r[0][0]),n);if(0===a)return a;for(var o=new ri([{dist:0,range1:[0,e.length-1],range2:[0,0]}],ni),s=t?50:100,l=ci(r);o.length;){var u=o.pop();if(!(u.dist>=a)){var c=u.range1;if(oi(c)<=s){if(!si(c,e.length))return NaN;if(t){var h=wi(e,c,r,i);if(0===(a=Math.min(a,h)))return a}else for(var f=c[0];f<=c[1];++f){var d=bi(e[f],r,i);if(0===(a=Math.min(a,d)))return a}}else{var p=li(c,t);if(null!==p[0]){var m=hi(ui(e,p[0]),l,i);m5&&void 0!==arguments[5]?arguments[5]:1/0,o=Math.min(a,n.distance(e[0],r[0]));if(0===o)return o;for(var s=new ri([{dist:0,range1:[0,e.length-1],range2:[0,r.length-1]}],ni),l=t?50:100,u=i?50:100;s.length;){var c=s.pop();if(!(c.dist>=o)){var h=c.range1,f=c.range2;if(oi(h)<=l&&oi(f)<=u){if(!si(h,e.length)||!si(f,r.length))return NaN;if(t&&i?o=Math.min(o,gi(e,h,r,f,n)):t||i?t&&!i?o=Math.min(o,_i(r,f,e,h,n)):!t&&i&&(o=Math.min(o,_i(e,h,r,f,n))):o=Math.min(o,xi(e,h,r,f,n)),0===o)return o}else{var d=li(h,t),p=li(f,i);Mi(s,o,n,e,r,d[0],p[0]),Mi(s,o,n,e,r,d[0],p[1]),Mi(s,o,n,e,r,d[1],p[0]),Mi(s,o,n,e,r,d[1],p[1])}}}return o}function Ii(e,t,r,i){var n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1/0,a=ui(e,[0,e.length-1]);for(var o of r)if(!(n!==1/0&&hi(a,ui(o,[0,o.length-1]),i)>=n)&&0===(n=Math.min(n,Ei(e,t,o,!0,i,n))))return n;return n}function Ai(e,t,r,i){var n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1/0,a=ui(e,[0,e.length-1]);for(var o of r)if(!(n!==1/0&&hi(a,ci(o),i)>=n)){var s=Si(e,t,o,i,n);if(isNaN(s))return s;if(0===(n=Math.min(n,s)))return n}return n}function Ci(e){return"Point"===e||"MultiPoint"===e||"LineString"===e||"MultiLineString"===e||"Polygon"===e||"MultiPolygon"===e}var Pi=(function(){function e(t,r){p(this,e),this.type=Zt,this.geojson=t,this.geometries=r}return m(e,[{key:"evaluate",value:function(e){var t=e.geometry(),r=e.canonicalID();if(null!=t&&null!=r){if("Point"===e.geometryType())return(function(e,t,r){var i=[];for(var n of e)for(var a of n)i.push(pi(a,t));var o=new Kr(i[0][1],"meters");return"Point"===r.type||"MultiPoint"===r.type||"LineString"===r.type?Ei(i,!1,"Point"===r.type?[r.coordinates]:r.coordinates,"LineString"===r.type,o):"MultiLineString"===r.type?Ii(i,!1,r.coordinates,o):"Polygon"===r.type||"MultiPolygon"===r.type?Ai(i,!1,"Polygon"===r.type?[r.coordinates]:r.coordinates,o):null})(t,r,this.geometries);if("LineString"===e.geometryType())return(function(e,t,r){var i=[];for(var n of e){var a=[];for(var o of n)a.push(pi(o,t));i.push(a)}var s=new Kr(i[0][0][1],"meters");if("Point"===r.type||"MultiPoint"===r.type||"LineString"===r.type)return Ii("Point"===r.type?[r.coordinates]:r.coordinates,"LineString"===r.type,i,s);if("MultiLineString"===r.type){for(var l=1/0,u=0;ur&&(e=r),e}var Ri=(function(){function e(t,r,i){p(this,e),this.type=t,this.key=r,this.scope=i}return m(e,[{key:"evaluate",value:function(e){var t=[this.key,this.scope,e.scope].filter(Boolean).join("\x1f"),r=e.getConfig(t);if(!r)return null;var i=r.type,n=r.value,a=r.values,o=r.minValue,s=r.maxValue,l=r.stepValue,u=r.default.evaluate(e),c=u;if(n){var h=e.scope;e.scope=(h||"").split("\x1f").slice(1).join("\x1f"),c=n.evaluate(e),e.scope=h}return i&&(c=zi(i,c)),void 0===c||void 0===o&&void 0===s&&void 0===l||("number"==typeof c?c=Di(c,o,s,l):Array.isArray(c)&&(c=c.map((function(e){return"number"==typeof e?Di(e,o,s,l):e})))),void 0!==n&&void 0!==c&&a&&!a.includes(c)&&(c=u,i&&(c=zi(i,c))),(i&&i!==this.type||void 0!==c&&fr(c)!==this.type)&&(c=zi(this.type.kind,c)),c}},{key:"eachChild",value:function(){}},{key:"outputDefined",value:function(){return!1}},{key:"serialize",value:function(){var e=["config",this.key];return this.scope&&e.concat(this.key),e}}],[{key:"parse",value:function(t,r){var i=r.expectedType;if(null==i&&(i=Yt),t.length<2||t.length>3)return r.error("Invalid number of arguments for 'config' expression.");var n=r.parse(t[1],1);if(!(n instanceof pr))return r.error("Key name of 'config' expression must be a string literal.");if(t.length>=3){var a=r.parse(t[2],2);return a instanceof pr?new e(i,dr(n.value),dr(a.value)):r.error("Scope of 'config' expression must be a string literal.")}return new e(i,dr(n.value))}}])})();function Li(e){if(e instanceof Mr){if("get"===e.name&&1===e.args.length)return!1;if("feature-state"===e.name)return!1;if("has"===e.name&&1===e.args.length)return!1;if("properties"===e.name||"geometry-type"===e.name||"id"===e.name)return!1;if(/^filter-/.test(e.name))return!1}if(e instanceof Xr)return!1;if(e instanceof Pi)return!1;var t=!0;return e.eachChild((function(e){t&&!Li(e)&&(t=!1)})),t}function Oi(e){if(e instanceof Mr&&"feature-state"===e.name)return!1;var t=!0;return e.eachChild((function(e){t&&!Oi(e)&&(t=!1)})),t}function Bi(e){if(e instanceof Ri)return new Set([e.key]);var t=new Set;return e.eachChild((function(e){t=new Set([].concat(d(t),d(Bi(e))))})),t}function Fi(e,t){if(e instanceof Mr&&t.indexOf(e.name)>=0)return!1;var r=!0;return e.eachChild((function(e){r&&!Fi(e,t)&&(r=!1)})),r}var Ni=(function(){function e(t,r){p(this,e),this.type=r.type,this.name=t,this.boundExpression=r}return m(e,[{key:"evaluate",value:function(e){return this.boundExpression.evaluate(e)}},{key:"eachChild",value:function(){}},{key:"outputDefined",value:function(){return!1}},{key:"serialize",value:function(){return["var",this.name]}}],[{key:"parse",value:function(t,r){if(2!==t.length||"string"!=typeof t[1])return r.error("'var' expression requires exactly one string literal argument.");var i=t[1];return r.scope.has(i)?new e(i,r.scope.get(i)):r.error(`Unknown variable "${i}". Make sure "${i}" has been bound in an enclosing "let" expression before using it.`,1)}}])})(),Vi=(function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=arguments.length>2?arguments[2]:void 0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:new Gt,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[],o=arguments.length>5?arguments[5]:void 0,s=arguments.length>6?arguments[6]:void 0;p(this,e),this.registry=t,this.path=r,this.key=r.map((function(e){return"string"==typeof e?`['${e}']`:`[${e}]`})).join(""),this.scope=n,this.errors=a,this.expectedType=i,this._scope=o,this.options=s}return m(e,[{key:"parse",value:function(e,t,r,i){var n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};return t||r?this.concat(t,null,r,i)._parse(e,n):this._parse(e,n)}},{key:"parseObjectValue",value:function(e,t,r,i,n){var a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};return this.concat(t,r,i,n)._parse(e,a)}},{key:"_parse",value:function(e,t){function r(e,t,r){return"assert"===r?new _r(t,[e]):"coerce"===r?new wr(t,[e]):e}if(null!==e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e||(e=["literal",e]),Array.isArray(e)){if(0===e.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');var i="string"==typeof e[0]?this.registry[e[0]]:void 0;if(i){var n=i.parse(e,this);if(!n)return null;if(this.expectedType){var a=this.expectedType,o=n.type;if("string"!==a.kind&&"number"!==a.kind&&"boolean"!==a.kind&&"object"!==a.kind&&"array"!==a.kind||"value"!==o.kind)if("color"!==a.kind&&"formatted"!==a.kind&&"resolvedImage"!==a.kind||"value"!==o.kind&&"string"!==o.kind){if(this.checkSubtype(a,o))return null}else n=r(n,a,t.typeAnnotation||"coerce");else n=r(n,a,t.typeAnnotation||"assert")}if(!(n instanceof pr)&&"resolvedImage"!==n.type.kind&&ji(n)){var s=new Tr(this._scope,this.options);try{n=new pr(n.type,n.evaluate(s))}catch(e){return this.error(e.message),null}}return n}return wr.parse(["to-array",e],this)}return this.error(void 0===e?"'undefined' value invalid. Use null instead.":"object"==typeof e?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}},{key:"concat",value:function(t,r,i,n){var a="number"==typeof t?this.path.concat(t):this.path;a="string"==typeof r?a.concat(r):a;var o=n?this.scope.concat(n):this.scope;return new e(this.registry,a,i||null,o,this.errors,this._scope,this.options)}},{key:"error",value:function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;it))throw new mr("Input is not a number.");o=s-1}return 0}var qi=(function(){function e(t,r,i){for(var n of(p(this,e),this.type=t,this.input=r,this.labels=[],this.outputs=[],i)){var a=x(n,2),o=a[0],s=a[1];this.labels.push(o),this.outputs.push(s)}}return m(e,[{key:"evaluate",value:function(e){var t=this.labels,r=this.outputs;if(1===t.length)return r[0].evaluate(e);var i=this.input.evaluate(e);if(i<=t[0])return r[0].evaluate(e);var n=t.length;return i>=t[n-1]?r[n-1].evaluate(e):r[Gi(t,i)].evaluate(e)}},{key:"eachChild",value:function(e){for(var t of(e(this.input),this.outputs))e(t)}},{key:"outputDefined",value:function(){return this.outputs.every((function(e){return e.outputDefined()}))}},{key:"serialize",value:function(){for(var e=["step",this.input.serialize()],t=0;t0&&e.push(this.labels[t]),e.push(this.outputs[t].serialize());return e}}],[{key:"parse",value:function(t,r){if(t.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return r.error("Expected an even number of arguments.");var i=r.parse(t[1],1,Zt);if(!i)return null;var n=[],a=null;r.expectedType&&"value"!==r.expectedType.kind&&(a=r.expectedType);for(var o=1;o=s)return r.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',u);var h=r.parse(l,c,a);if(!h)return null;a=a||h.type,n.push([s,h])}return new e(a,i,n)}}])})(),Zi=.95047,$i=1.08883,Hi=.13793103448275862,Wi=.12841854934601665,Xi=Math.PI/180,Yi=180/Math.PI;function Ji(e){return e>.008856451679035631?Math.pow(e,.3333333333333333):e/Wi+Hi}function Ki(e){return e>.20689655172413793?e*e*e:Wi*(e-Hi)}function Qi(e){return 255*(e<=.0031308?12.92*e:1.055*Math.pow(e,.4166666666666667)-.055)}function en(e){return(e/=255)<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function tn(e){var t=en(e.r),r=en(e.g),i=en(e.b),n=Ji((.4124564*t+.3575761*r+.1804375*i)/Zi),a=Ji((.2126729*t+.7151522*r+.072175*i)/1);return{l:116*a-16,a:500*(n-a),b:200*(a-Ji((.0193339*t+.119192*r+.9503041*i)/$i)),alpha:e.a}}function rn(e){var t=(e.l+16)/116,r=isNaN(e.a)?t:t+e.a/500,i=isNaN(e.b)?t:t-e.b/200;return t=1*Ki(t),r=Zi*Ki(r),i=$i*Ki(i),new Ot(Qi(3.2404542*r-1.5371385*t-.4985314*i),Qi(-.969266*r+1.8760108*t+.041556*i),Qi(.0556434*r-.2040259*t+1.0572252*i),e.alpha)}function nn(e,t,r){var i=t-e;return e+r*(i>180||i<-180?i-360*Math.round(i/360):i)}var an={forward:tn,reverse:rn,interpolate:function(e,t,r){return{l:Ft(e.l,t.l,r),a:Ft(e.a,t.a,r),b:Ft(e.b,t.b,r),alpha:Ft(e.alpha,t.alpha,r)}}},on={forward:function(e){var t=tn(e),r=t.l,i=t.a,n=t.b,a=Math.atan2(n,i)*Yi;return{h:a<0?a+360:a,c:Math.sqrt(i*i+n*n),l:r,alpha:e.a}},reverse:function(e){var t=e.h*Xi,r=e.c;return rn({l:e.l,a:Math.cos(t)*r,b:Math.sin(t)*r,alpha:e.alpha})},interpolate:function(e,t,r){return{h:nn(e.h,t.h,r),c:Ft(e.c,t.c,r),l:Ft(e.l,t.l,r),alpha:Ft(e.alpha,t.alpha,r)}}},sn=Object.freeze({__proto__:null,hcl:on,lab:an}),ln=(function(){function e(t,r,i,n,a){for(var o of(p(this,e),this.type=t,this.operator=r,this.interpolation=i,this.input=n,this.labels=[],this.outputs=[],a)){var s=x(o,2),l=s[0],u=s[1];this.labels.push(l),this.outputs.push(u)}}return m(e,[{key:"evaluate",value:function(t){var r=this.labels,i=this.outputs;if(1===r.length)return i[0].evaluate(t);var n=this.input.evaluate(t);if(n<=r[0])return i[0].evaluate(t);var a=r.length;if(n>=r[a-1])return i[a-1].evaluate(t);var o=Gi(r,n),s=e.interpolationFactor(this.interpolation,n,r[o],r[o+1]),l=i[o].evaluate(t),u=i[o+1].evaluate(t);return"interpolate"===this.operator?Vt[this.type.kind.toLowerCase()](l,u,s):"interpolate-hcl"===this.operator?on.reverse(on.interpolate(on.forward(l),on.forward(u),s)):an.reverse(an.interpolate(an.forward(l),an.forward(u),s))}},{key:"eachChild",value:function(e){for(var t of(e(this.input),this.outputs))e(t)}},{key:"outputDefined",value:function(){return this.outputs.every((function(e){return e.outputDefined()}))}},{key:"serialize",value:function(){var e;e="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);for(var t=[this.operator,e,this.input.serialize()],r=0;r1})))return r.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);a={name:"cubic-bezier",controlPoints:u}}if(t.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return r.error("Expected an even number of arguments.");if(!(o=r.parse(o,2,Zt)))return null;var c=[],h=null;"interpolate-hcl"===n||"interpolate-lab"===n?h=Wt:r.expectedType&&"value"!==r.expectedType.kind&&(h=r.expectedType);for(var d=0;d=p)return r.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',v);var y=r.parse(m,_,h);if(!y)return null;h=h||y.type,c.push([p,y])}return"number"===h.kind||"color"===h.kind||"array"===h.kind&&"number"===h.itemType.kind&&"number"==typeof h.N?new e(h,n,a,o,c):r.error(`Type ${tr(h)} is not interpolatable.`)}}])})();function un(e,t,r,i){var n=i-r,a=e-r;return 0===n?0:1===t?a/n:(Math.pow(t,a)-1)/(Math.pow(t,n)-1)}var cn=(function(){function e(t,r){p(this,e),this.type=t,this.args=r}return m(e,[{key:"evaluate",value:function(e){var t,r=null,i=0;for(var n of this.args){if(i++,(r=n.evaluate(e))&&r instanceof ur&&!r.available&&(t||(t=r),r=null,i===this.args.length))return t;if(null!==r)break}return r}},{key:"eachChild",value:function(e){this.args.forEach(e)}},{key:"outputDefined",value:function(){return this.args.every((function(e){return e.outputDefined()}))}},{key:"serialize",value:function(){var e=["coalesce"];return this.eachChild((function(t){e.push(t.serialize())})),e}}],[{key:"parse",value:function(t,r){if(t.length<2)return r.error("Expectected at least one argument.");var i=null,n=r.expectedType;n&&"value"!==n.kind&&(i=n);var a=[];for(var o of t.slice(1)){var s=r.parse(o,1+a.length,i,void 0,{typeAnnotation:"omit"});if(!s)return null;i=i||s.type,a.push(s)}var l=n&&a.some((function(e){return ir(n,e.type)}));return new e(l?Yt:i,a)}}])})(),hn=(function(){function e(t,r){p(this,e),this.type=r.type,this.bindings=[].concat(t),this.result=r}return m(e,[{key:"evaluate",value:function(e){return this.result.evaluate(e)}},{key:"eachChild",value:function(e){for(var t of this.bindings)e(t[1]);e(this.result)}},{key:"outputDefined",value:function(){return this.result.outputDefined()}},{key:"serialize",value:function(){var e=["let"];for(var t of this.bindings){var r=x(t,2),i=r[0],n=r[1];e.push(i,n.serialize())}return e.push(this.result.serialize()),e}}],[{key:"parse",value:function(t,r){if(t.length<4)return r.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);for(var i=[],n=1;n=r.length)throw new mr(`Array index out of bounds: ${t} > ${r.length-1}.`);if(t!==Math.floor(t))throw new mr(`Array index must be an integer, but found ${t} instead.`);return r[t]}},{key:"eachChild",value:function(e){e(this.index),e(this.input)}},{key:"outputDefined",value:function(){return!1}},{key:"serialize",value:function(){return["at",this.index.serialize(),this.input.serialize()]}}],[{key:"parse",value:function(t,r){if(3!==t.length)return r.error(`Expected 2 arguments, but found ${t.length-1} instead.`);var i=r.parse(t[1],1,Zt),n=r.parse(t[2],2,er(r.expectedType||Yt));return i&&n?new e(n.type.itemType,i,n):null}}])})(),dn=(function(){function e(t,r){p(this,e),this.type=Ht,this.needle=t,this.haystack=r}return m(e,[{key:"evaluate",value:function(e){var t=this.needle.evaluate(e),r=this.haystack.evaluate(e);if(null==r)return!1;if(!ar(t,["boolean","string","number","null"]))throw new mr(`Expected first argument to be of type boolean, string, number or null, but found ${tr(fr(t))} instead.`);if(!ar(r,["string","array"]))throw new mr(`Expected second argument to be of type array or string, but found ${tr(fr(r))} instead.`);return r.indexOf(t)>=0}},{key:"eachChild",value:function(e){e(this.needle),e(this.haystack)}},{key:"outputDefined",value:function(){return!0}},{key:"serialize",value:function(){return["in",this.needle.serialize(),this.haystack.serialize()]}}],[{key:"parse",value:function(t,r){if(3!==t.length)return r.error(`Expected 2 arguments, but found ${t.length-1} instead.`);var i=r.parse(t[1],1,Yt),n=r.parse(t[2],2,Yt);return i&&n?nr(i.type,[Ht,$t,Zt,qt,Yt])?new e(i,n):r.error(`Expected first argument to be of type boolean, string, number or null, but found ${tr(i.type)} instead`):null}}])})(),pn=(function(){function e(t,r,i){p(this,e),this.type=Zt,this.needle=t,this.haystack=r,this.fromIndex=i}return m(e,[{key:"evaluate",value:function(e){var t=this.needle.evaluate(e),r=this.haystack.evaluate(e);if(!ar(t,["boolean","string","number","null"]))throw new mr(`Expected first argument to be of type boolean, string, number or null, but found ${tr(fr(t))} instead.`);if(!ar(r,["string","array"]))throw new mr(`Expected second argument to be of type array or string, but found ${tr(fr(r))} instead.`);if(this.fromIndex){var i=this.fromIndex.evaluate(e);return r.indexOf(t,i)}return r.indexOf(t)}},{key:"eachChild",value:function(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}},{key:"outputDefined",value:function(){return!1}},{key:"serialize",value:function(){if(null!=this.fromIndex&&void 0!==this.fromIndex){var e=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),e]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}],[{key:"parse",value:function(t,r){if(t.length<=2||t.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);var i=r.parse(t[1],1,Yt),n=r.parse(t[2],2,Yt);if(!i||!n)return null;if(!nr(i.type,[Ht,$t,Zt,qt,Yt]))return r.error(`Expected first argument to be of type boolean, string, number or null, but found ${tr(i.type)} instead`);if(4===t.length){var a=r.parse(t[3],3,Zt);return a?new e(i,n,a):null}return new e(i,n)}}])})(),mn=(function(){function e(t,r,i,n,a,o){p(this,e),this.inputType=t,this.type=r,this.input=i,this.cases=n,this.outputs=a,this.otherwise=o}return m(e,[{key:"evaluate",value:function(e){var t=this.input.evaluate(e);return(fr(t)===this.inputType&&this.outputs[this.cases[t]]||this.otherwise).evaluate(e)}},{key:"eachChild",value:function(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}},{key:"outputDefined",value:function(){return this.outputs.every((function(e){return e.outputDefined()}))&&this.otherwise.outputDefined()}},{key:"serialize",value:function(){var e=this,t=["match",this.input.serialize()],r=Object.keys(this.cases).sort(),i=[],n={};for(var a of r){var o=n[this.cases[a]];void 0===o?(n[this.cases[a]]=i.length,i.push([this.cases[a],[a]])):i[o][1].push(a)}var s=function(t){return"number"===e.inputType.kind?Number(t):t};for(var l of i){var u=x(l,2),c=u[0],h=u[1];t.push(1===h.length?s(h[0]):h.map(s)),t.push(this.outputs[c].serialize())}return t.push(this.otherwise.serialize()),t}}],[{key:"parse",value:function(t,r){if(t.length<5)return r.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return r.error("Expected an even number of arguments.");var i,n;r.expectedType&&"value"!==r.expectedType.kind&&(n=r.expectedType);for(var a={},o=[],s=2;sNumber.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof h&&Math.floor(h)!==h)return c.error("Numeric branch labels must be integer values.");if(i){if(c.checkSubtype(i,fr(h)))return null}else i=fr(h);if(void 0!==a[String(h)])return c.error("Branch labels must be unique.");a[String(h)]=o.length}var f=r.parse(u,s,n);if(!f)return null;n=n||f.type,o.push(f)}var d=r.parse(t[1],1,Yt);if(!d)return null;var p=r.parse(t[t.length-1],t.length-1,n);return p?"value"!==d.type.kind&&r.concat(1).checkSubtype(i,d.type)?null:new e(i,n,d,a,o,p):null}}])})(),vn=(function(){function e(t,r,i){p(this,e),this.type=t,this.branches=r,this.otherwise=i}return m(e,[{key:"evaluate",value:function(e){for(var t of this.branches){var r=x(t,2),i=r[0],n=r[1];if(i.evaluate(e))return n.evaluate(e)}return this.otherwise.evaluate(e)}},{key:"eachChild",value:function(e){for(var t of this.branches){var r=x(t,2),i=r[0],n=r[1];e(i),e(n)}e(this.otherwise)}},{key:"outputDefined",value:function(){return this.branches.every((function(e){var t=x(e,2);t[0];return t[1].outputDefined()}))&&this.otherwise.outputDefined()}},{key:"serialize",value:function(){var e=["case"];return this.eachChild((function(t){e.push(t.serialize())})),e}}],[{key:"parse",value:function(t,r){if(t.length<4)return r.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return r.error("Expected an odd number of arguments.");var i;r.expectedType&&"value"!==r.expectedType.kind&&(i=r.expectedType);for(var n=[],a=1;a=5)return r.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);var i=r.parse(t[1],1,Yt),n=r.parse(t[2],2,Zt);if(!i||!n)return null;if(!nr(i.type,[er(Yt),$t,Yt]))return r.error(`Expected first argument to be of type array or string, but found ${tr(i.type)} instead`);if(4===t.length){var a=r.parse(t[3],3,Zt);return a?new e(i.type,i,n,a):null}return new e(i.type,i,n)}}])})();function yn(e,t){return"=="===e||"!="===e?"boolean"===t.kind||"string"===t.kind||"number"===t.kind||"null"===t.kind||"value"===t.kind:"string"===t.kind||"number"===t.kind||"value"===t.kind}function gn(e,t,r,i){return 0===i.compare(t,r)}function xn(e,t,r){var i="=="!==e&&"!="!==e;return(function(){function n(e,t,r){p(this,n),this.type=Ht,this.lhs=e,this.rhs=t,this.collator=r,this.hasUntypedArgument="value"===e.type.kind||"value"===t.type.kind}return m(n,[{key:"evaluate",value:function(n){var a=this.lhs.evaluate(n),o=this.rhs.evaluate(n);if(i&&this.hasUntypedArgument){var s=fr(a),l=fr(o);if(s.kind!==l.kind||"string"!==s.kind&&"number"!==s.kind)throw new mr(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${s.kind}, ${l.kind}) instead.`)}if(this.collator&&!i&&this.hasUntypedArgument){var u=fr(a),c=fr(o);if("string"!==u.kind||"string"!==c.kind)return t(n,a,o)}return this.collator?r(n,a,o,this.collator.evaluate(n)):t(n,a,o)}},{key:"eachChild",value:function(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}},{key:"outputDefined",value:function(){return!0}},{key:"serialize",value:function(){var t=[e];return this.eachChild((function(e){t.push(e.serialize())})),t}}],[{key:"parse",value:function(e,t){if(3!==e.length&&4!==e.length)return t.error("Expected two or three arguments.");var r=e[0],a=t.parse(e[1],1,Yt);if(!a)return null;if(!yn(r,a.type))return t.concat(1).error(`"${r}" comparisons are not supported for type '${tr(a.type)}'.`);var o=t.parse(e[2],2,Yt);if(!o)return null;if(!yn(r,o.type))return t.concat(2).error(`"${r}" comparisons are not supported for type '${tr(o.type)}'.`);if(a.type.kind!==o.type.kind&&"value"!==a.type.kind&&"value"!==o.type.kind)return t.error(`Cannot compare types '${tr(a.type)}' and '${tr(o.type)}'.`);i&&("value"===a.type.kind&&"value"!==o.type.kind?a=new _r(o.type,[a]):"value"!==a.type.kind&&"value"===o.type.kind&&(o=new _r(a.type,[o])));var s=null;if(4===e.length){if("string"!==a.type.kind&&"string"!==o.type.kind&&"value"!==a.type.kind&&"value"!==o.type.kind)return t.error("Cannot use collator to compare non-string types.");if(!(s=t.parse(e[3],3,Jt)))return null}return new n(a,o,s)}}])})()}var bn=xn("==",(function(e,t,r){return t===r}),gn),wn=xn("!=",(function(e,t,r){return t!==r}),(function(e,t,r,i){return!gn(0,t,r,i)})),kn=xn("<",(function(e,t,r){return t",(function(e,t,r){return t>r}),(function(e,t,r,i){return i.compare(t,r)>0})),Mn=xn("<=",(function(e,t,r){return t<=r}),(function(e,t,r,i){return i.compare(t,r)<=0})),Sn=xn(">=",(function(e,t,r){return t>=r}),(function(e,t,r,i){return i.compare(t,r)>=0})),En=(function(){function e(t,r,i,n,a,o){p(this,e),this.type=$t,this.number=t,this.locale=r,this.currency=i,this.unit=n,this.minFractionDigits=a,this.maxFractionDigits=o}return m(e,[{key:"evaluate",value:function(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(e):void 0,unit:this.unit?this.unit.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}},{key:"eachChild",value:function(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.unit&&e(this.unit),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}},{key:"outputDefined",value:function(){return!1}},{key:"serialize",value:function(){var e={};return this.locale&&(e.locale=this.locale.serialize()),this.currency&&(e.currency=this.currency.serialize()),this.unit&&(e.unit=this.unit.serialize()),this.minFractionDigits&&(e["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(e["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),e]}}],[{key:"parse",value:function(t,r){if(3!==t.length)return r.error("Expected two arguments.");var i=r.parse(t[1],1,Zt);if(!i)return null;var n=t[2];if("object"!=typeof n||Array.isArray(n))return r.error("NumberFormat options argument must be an object.");var a=null;if(n.locale&&!(a=r.parseObjectValue(n.locale,2,"locale",$t)))return null;var o=null;if(n.currency&&!(o=r.parseObjectValue(n.currency,2,"currency",$t)))return null;var s=null;if(n.unit&&!(s=r.parseObjectValue(n.unit,2,"unit",$t)))return null;var l=null;if(n["min-fraction-digits"]&&!(l=r.parseObjectValue(n["min-fraction-digits"],2,"min-fraction-digits",Zt)))return null;var u=null;return n["max-fraction-digits"]&&!(u=r.parseObjectValue(n["max-fraction-digits"],2,"max-fraction-digits",Zt))?null:new e(i,a,o,s,l,u)}}])})(),In=(function(){function e(t){p(this,e),this.type=Zt,this.input=t}return m(e,[{key:"evaluate",value:function(e){var t=this.input.evaluate(e);if("string"==typeof t)return t.length;if(Array.isArray(t))return t.length;throw new mr(`Expected value to be of type string or array, but found ${tr(fr(t))} instead.`)}},{key:"eachChild",value:function(e){e(this.input)}},{key:"outputDefined",value:function(){return!1}},{key:"serialize",value:function(){var e=["length"];return this.eachChild((function(t){e.push(t.serialize())})),e}}],[{key:"parse",value:function(t,r){if(2!==t.length)return r.error(`Expected 1 argument, but found ${t.length-1} instead.`);var i=r.parse(t[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?r.error(`Expected argument of type string or array, but found ${tr(i.type)} instead.`):new e(i):null}}])})();function An(e){return function(){e=1831565813+(e|=0)|0;var t=Math.imul(e^e>>>15,1|e);return(((t=t+Math.imul(t^t>>>7,61|t)^t)^t>>>14)>>>0)/4294967296}}var Cn={"==":bn,"!=":wn,">":Tn,"<":kn,">=":Sn,"<=":Mn,array:_r,at:fn,boolean:_r,case:vn,coalesce:cn,collator:Er,format:yr,image:gr,in:dn,"index-of":pn,interpolate:ln,"interpolate-hcl":ln,"interpolate-lab":ln,length:In,let:hn,literal:pr,match:mn,number:_r,"number-format":En,object:_r,slice:_n,step:qi,string:_r,"to-boolean":wr,"to-color":wr,"to-number":wr,"to-string":wr,var:Ni,within:Xr,distance:Pi,config:Ri};function Pn(e,t){var r=x(t,4),i=r[0],n=r[1],a=r[2],o=r[3];i=i.evaluate(e),n=n.evaluate(e),a=a.evaluate(e);var s=o?o.evaluate(e):1,l=cr(i,n,a,s);if(l)throw new mr(l);return new Ot(i/255*s,n/255*s,a/255*s,s)}function zn(e,t){var r=x(t,4),i=r[0],n=r[1],a=r[2],o=r[3];i=i.evaluate(e),n=n.evaluate(e),a=a.evaluate(e);var s=o?o.evaluate(e):1,l=(function(e,t,r,i){return"number"==typeof e&&e>=0&&e<=360?"number"==typeof t&&t>=0&&t<=100&&"number"==typeof r&&r>=0&&r<=100?void 0===i||"number"==typeof i&&i>=0&&i<=1?null:`Invalid hsla value [${[e,t,r,i].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${("number"==typeof i?[e,t,r,i]:[e,t,r]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${("number"==typeof i?[e,t,r,i]:[e,t,r]).join(", ")}]: 'h' must be between 0 and 360.`})(i,n,a,s);if(l)throw new mr(l);var u=`hsla(${i}, ${n}%, ${a}%, ${s})`,c=Ot.parse(u);if(!c)throw new mr(`Failed to parse HSLA color: ${u}`);return c}function Dn(e,t){return e in t}function Rn(e,t){var r=t[e];return void 0===r?null:r}function Ln(e){return{type:e}}function On(e){return{result:"success",value:e}}function Bn(e){return{result:"error",value:e}}function Fn(e,t){return!!e&&!!e.parameters&&e.parameters.indexOf(t)>-1}function Nn(e){return"data-driven"===e["property-type"]}function Vn(e){return Fn(e.expression,"measure-light")}function Un(e){return Fn(e.expression,"zoom")}function jn(e){return!!e.expression&&e.expression.interpolated}function Gn(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function qn(e){return e}function Zn(e,t){var r,i,n,a="color"===t.type,o=e.stops&&"object"==typeof e.stops[0][0],s=o||!(o||void 0!==e.property),l=e.type||(jn(t)?"exponential":"interval");if(a&&((e=Ut({},e)).stops&&(e.stops=e.stops.map((function(e){return[e[0],Ot.parse(e[1])]}))),e.default=Ot.parse(e.default?e.default:t.default)),e.colorSpace&&"rgb"!==e.colorSpace&&!sn[e.colorSpace])throw new Error(`Unknown color space: ${e.colorSpace}`);if("exponential"===l)r=Xn;else if("interval"===l)r=Wn;else if("categorical"===l){for(var u of(r=Hn,i=Object.create(null),e.stops))i[u[0]]=u[1];n=typeof e.stops[0][0]}else{if("identity"!==l)throw new Error(`Unknown function type "${l}"`);r=Yn}if(o){for(var c={},h=[],f=0;f=e.stops[i-1][0])return e.stops[i-1][1];var n=Gi(e.stops.map((function(e){return e[0]})),r);return e.stops[n][1]}function Xn(e,t,r){var i=void 0!==e.base?e.base:1;if("number"!==xr(r))return $n(e.default,t.default);var n=e.stops.length;if(1===n)return e.stops[0][1];if(r<=e.stops[0][0])return e.stops[0][1];if(r>=e.stops[n-1][0])return e.stops[n-1][1];var a=Gi(e.stops.map((function(e){return e[0]})),r),o=(function(e,t,r,i){var n=i-r,a=e-r;return 0===n?0:1===t?a/n:(Math.pow(t,a)-1)/(Math.pow(t,n)-1)})(r,i,e.stops[a][0],e.stops[a+1][0]),s=e.stops[a][1],l=e.stops[a+1][1],u=Vt[t.type]||qn;if(e.colorSpace&&"rgb"!==e.colorSpace){var c=sn[e.colorSpace];u=function(e,t){return c.reverse(c.interpolate(c.forward(e),c.forward(t),o))}}return"function"==typeof s.evaluate?{evaluate:function(){for(var e=arguments.length,t=new Array(e),r=0;r":[Ht,[$t,Yt],function(e,t){var r=x(t,2),i=r[0],n=r[1],a=e.properties()[i.value],o=n.value;return typeof a==typeof o&&a>o}],"filter-id->":[Ht,[Yt],function(e,t){var r=x(t,1)[0],i=e.id(),n=r.value;return typeof i==typeof n&&i>n}],"filter-<=":[Ht,[$t,Yt],function(e,t){var r=x(t,2),i=r[0],n=r[1],a=e.properties()[i.value],o=n.value;return typeof a==typeof o&&a<=o}],"filter-id-<=":[Ht,[Yt],function(e,t){var r=x(t,1)[0],i=e.id(),n=r.value;return typeof i==typeof n&&i<=n}],"filter->=":[Ht,[$t,Yt],function(e,t){var r=x(t,2),i=r[0],n=r[1],a=e.properties()[i.value],o=n.value;return typeof a==typeof o&&a>=o}],"filter-id->=":[Ht,[Yt],function(e,t){var r=x(t,1)[0],i=e.id(),n=r.value;return typeof i==typeof n&&i>=n}],"filter-has":[Ht,[Yt],function(e,t){return x(t,1)[0].value in e.properties()}],"filter-has-id":[Ht,[],function(e){return null!==e.id()&&void 0!==e.id()}],"filter-type-in":[Ht,[er($t)],function(e,t){return x(t,1)[0].value.indexOf(e.geometryType())>=0}],"filter-id-in":[Ht,[er(Yt)],function(e,t){return x(t,1)[0].value.indexOf(e.id())>=0}],"filter-in-small":[Ht,[$t,er(Yt)],function(e,t){var r=x(t,2),i=r[0];return r[1].value.indexOf(e.properties()[i.value])>=0}],"filter-in-large":[Ht,[$t,er(Yt)],function(e,t){var r=x(t,2),i=r[0],n=r[1];return(function(e,t,r,i){for(;r<=i;){var n=r+i>>1;if(t[n]===e)return!0;t[n]>e?i=n-1:r=n+1}return!1})(e.properties()[i.value],n.value,0,n.value.length-1)}],all:{type:Ht,overloads:[[[Ht,Ht],function(e,t){var r=x(t,2),i=r[0],n=r[1];return i.evaluate(e)&&n.evaluate(e)}],[Ln(Ht),function(e,t){for(var r of t)if(!r.evaluate(e))return!1;return!0}]]},any:{type:Ht,overloads:[[[Ht,Ht],function(e,t){var r=x(t,2),i=r[0],n=r[1];return i.evaluate(e)||n.evaluate(e)}],[Ln(Ht),function(e,t){for(var r of t)if(r.evaluate(e))return!0;return!1}]]},"!":[Ht,[Ht],function(e,t){return!x(t,1)[0].evaluate(e)}],"is-supported-script":[Ht,[$t],function(e,t){var r=x(t,1)[0],i=e.globals&&e.globals.isSupportedScript;return!i||i(r.evaluate(e))}],upcase:[$t,[$t],function(e,t){return x(t,1)[0].evaluate(e).toUpperCase()}],downcase:[$t,[$t],function(e,t){return x(t,1)[0].evaluate(e).toLowerCase()}],concat:[$t,Ln(Yt),function(e,t){return t.map((function(t){return dr(t.evaluate(e))})).join("")}],"resolved-locale":[$t,[Jt],function(e,t){return x(t,1)[0].evaluate(e).resolvedLocale()}],random:[Zt,[Zt,Zt,Yt],function(e,t){var r,i=t.map((function(t){return t.evaluate(e)})),n=x(i,3),a=n[0],o=n[1],s=n[2];if(a>o)return a;if(a===o)return a;if("string"==typeof s)r=(function(e){var t=0;if(0===e.length)return t;for(var r=0;r0&&"string"==typeof e[0]&&e[0]in Cn}function Qn(e,t,r,i){var n=new Ui(Cn,[],t?(function(e){var t={color:Wt,string:$t,number:Zt,enum:$t,boolean:Ht,formatted:Kt,resolvedImage:Qt};return"array"===e.type?er(t[e.value]||Yt,e.length):t[e.type]})(t):void 0,void 0,void 0,r,i),a=n.parse(e,void 0,void 0,void 0,t&&"string"===t.type?{typeAnnotation:"coerce"}:void 0);return a?On(new Jn(a,t,r,i)):Bn(n.errors)}var ea=(function(){return m((function e(t,r,i){p(this,e),this.kind=t,this._styleExpression=r,this.isLightConstant=i,this.isStateDependent="constant"!==t&&!Oi(r.expression),this.configDependencies=Bi(r.expression)}),[{key:"evaluateWithoutErrorHandling",value:function(e,t,r,i,n,a){return this._styleExpression.evaluateWithoutErrorHandling(e,t,r,i,n,a)}},{key:"evaluate",value:function(e,t,r,i,n,a){return this._styleExpression.evaluate(e,t,r,i,n,a)}}])})(),ta=(function(){return m((function e(t,r,i,n,a){p(this,e),this.kind=t,this.zoomStops=i,this._styleExpression=r,this.isStateDependent="camera"!==t&&!Oi(r.expression),this.isLightConstant=a,this.configDependencies=Bi(r.expression),this.interpolationType=n}),[{key:"evaluateWithoutErrorHandling",value:function(e,t,r,i,n,a){return this._styleExpression.evaluateWithoutErrorHandling(e,t,r,i,n,a)}},{key:"evaluate",value:function(e,t,r,i,n,a){return this._styleExpression.evaluate(e,t,r,i,n,a)}},{key:"interpolationFactor",value:function(e,t,r){return this.interpolationType?ln.interpolationFactor(this.interpolationType,e,t,r):0}}])})();function ra(e,t,r,i){if("error"===(e=Qn(e,t,r,i)).result)return e;var n=e.value.expression,a=Li(n);if(!a&&!Nn(t))return Bn([new jt("","data expressions not supported")]);var o=Fi(n,["zoom","pitch","distance-from-center"]);if(!o&&!Un(t))return Bn([new jt("","zoom expressions not supported")]);var s=Fi(n,["measure-light"]);if(!s&&!Vn(t))return Bn([new jt("","measure-light expression not supported")]);var l=t.expression&&t.expression.relaxZoomRestriction,u=na(n);return u||o||l?u instanceof jt?Bn([u]):u instanceof ln&&!jn(t)?Bn([new jt("",'"interpolate" expressions cannot be used with this property')]):On(u?new ta(a?"camera":"composite",e.value,u.labels,u instanceof ln?u.interpolation:void 0,s):new ea(a?"constant":"source",e.value,s)):Bn([new jt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}var ia=(function(){function e(t,r){p(this,e),this._parameters=t,this._specification=r,Ut(this,Zn(this._parameters,this._specification))}return m(e,null,[{key:"deserialize",value:function(t){return new e(t._parameters,t._specification)}},{key:"serialize",value:function(e){return{_parameters:e._parameters,_specification:e._specification}}}])})();function na(e){var t=null;if(e instanceof hn)t=na(e.result);else if(e instanceof cn){for(var r of e.args)if(t=na(r))break}else(e instanceof qi||e instanceof ln)&&e.input instanceof Mr&&"zoom"===e.input.name&&(t=e);return t instanceof jt||e.eachChild((function(e){var r=na(e);r instanceof jt?t=r:t&&r&&t!==r&&(t=new jt("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),t}var aa,oa,sa=(function(){if(oa)return aa;oa=1,aa=t;var e=3;function t(t,r,i){var n=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;var a=new Int32Array(this.arrayBuffer);t=a[0],this.d=(r=a[1])+2*(i=a[2]);for(var o=0;o=c[d+0]&&i>=c[d+1])?(o[f]=!0,a.push(u[f])):o[f]=!1}}},t.prototype._forEachCell=function(e,t,r,i,n,a,o,s){for(var l=this._convertToCellCoord(e),u=this._convertToCellCoord(t),c=this._convertToCellCoord(r),h=this._convertToCellCoord(i),f=l;f<=c;f++)for(var d=u;d<=h;d++){var p=this.d*d+f;if((!s||s(this._convertFromCellCoord(f),this._convertFromCellCoord(d),this._convertFromCellCoord(f+1),this._convertFromCellCoord(d+1)))&&n.call(this,e,t,r,i,p,a,o,s))return}},t.prototype._convertFromCellCoord=function(e){return(e-this.padding)/this.scale},t.prototype._convertToCellCoord=function(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))},t.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var t=this.cells,r=e+this.cells.length+1+1,i=0,n=0;n2&&void 0!==arguments[2]?arguments[2]:{};Object.defineProperty(e,"_classRegistryKey",{value:t,writable:!1}),ua[t]={klass:e,omit:r.omit||[]}}for(var ha in ca(Object,"Object"),la.serialize=function(e,t){var r=e.toArrayBuffer();return t&&t.add(r),{buffer:r}},la.deserialize=function(e){return new la(e.buffer)},Object.defineProperty(la,"name",{value:"Grid"}),ca(la,"Grid"),ca(Ot,"Color"),ca(Error,"Error"),ca(lr,"Formatted"),ca(sr,"FormattedSection"),ca(ht,"AJAXError"),ca(ur,"ResolvedImage"),ca(ia,"StylePropertyFunction"),ca(Jn,"StyleExpression",{omit:["_evaluator"]}),ca(ta,"ZoomDependentExpression"),ca(ea,"ZoomConstantExpression"),ca(Mr,"CompoundExpression",{omit:["_evaluate"]}),Cn)ua[Cn[ha]._classRegistryKey]||ca(Cn[ha],`Expression${ha}`);function fa(e){return e&&"undefined"!=typeof ArrayBuffer&&(e instanceof ArrayBuffer||e.constructor&&"ArrayBuffer"===e.constructor.name)}function da(e){return self.ImageBitmap&&e instanceof ImageBitmap}function pa(e,t){if(null==e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||e instanceof Boolean||e instanceof Number||e instanceof String||e instanceof Date||e instanceof RegExp)return e;if(fa(e)||da(e))return t&&t.add(e),e;if(ArrayBuffer.isView(e)){var r=e;return t&&t.add(r.buffer),r}if(e instanceof ImageData)return t&&t.add(e.data.buffer),e;if(Array.isArray(e)){var i=[];for(var n of e)i.push(pa(n,t));return i}if(e instanceof Map){var a={$name:"Map"};for(var o of e.entries()){var s=x(o,2),l=s[0],u=s[1];a[l]=pa(u)}return a}if(e instanceof Set){var c={$name:"Set"},h=0;for(var f of e.values())c[++h]=pa(f);return c}if("object"==typeof e){var d=e.constructor,p=d._classRegistryKey;if(!p)throw new Error(`can't serialize object of unregistered class ${p}`);var m=d.serialize?d.serialize(e,t):{};if(!d.serialize){for(var v in e)e.hasOwnProperty(v)&&(ua[p].omit.indexOf(v)>=0||(m[v]=pa(e[v],t)));e instanceof Error&&(m.message=e.message)}if(m.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==p&&(m.$name=p),m}throw new Error("can't serialize object of type "+typeof e)}function ma(e){if(null==e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||e instanceof Boolean||e instanceof Number||e instanceof String||e instanceof Date||e instanceof RegExp||fa(e)||da(e)||ArrayBuffer.isView(e)||e instanceof ImageData)return e;if(Array.isArray(e))return e.map(ma);if("object"==typeof e){var t=e.$name||"Object";if("Map"===t){var r=new Map;for(var i of Object.keys(e))"$name"!==i&&r.set(i,ma(e[i]));return r}if("Set"===t){var n=new Set;for(var a of Object.keys(e))"$name"!==a&&n.add(ma(e[a]));return n}var o=ua[t].klass;if(!o)throw new Error(`can't deserialize unregistered class ${t}`);if(o.deserialize)return o.deserialize(e);var s=Object.create(o.prototype);for(var l of Object.keys(e))"$name"!==l&&(s[l]=ma(e[l]));return s}throw new Error("can't deserialize object of type "+typeof e)}var va=function(e){return e>=128&&e<=255},_a=function(e){return e>=1536&&e<=1791},ya=function(e){return e>=1872&&e<=1919},ga=function(e){return e>=2208&&e<=2303},xa=function(e){return e>=4352&&e<=4607},ba=function(e){return e>=5120&&e<=5759},wa=function(e){return e>=6016&&e<=6143},ka=function(e){return e>=6320&&e<=6399},Ta=function(e){return e>=8192&&e<=8303},Ma=function(e){return e>=8448&&e<=8527},Sa=function(e){return e>=8528&&e<=8591},Ea=function(e){return e>=8960&&e<=9215},Ia=function(e){return e>=9216&&e<=9279},Aa=function(e){return e>=9280&&e<=9311},Ca=function(e){return e>=9312&&e<=9471},Pa=function(e){return e>=9632&&e<=9727},za=function(e){return e>=9728&&e<=9983},Da=function(e){return e>=11008&&e<=11263},Ra=function(e){return e>=11904&&e<=12031},La=function(e){return e>=12032&&e<=12255},Oa=function(e){return e>=12272&&e<=12287},Ba=function(e){return e>=12288&&e<=12351},Fa=function(e){return e>=12352&&e<=12447},Na=function(e){return e>=12448&&e<=12543},Va=function(e){return e>=12544&&e<=12591},Ua=function(e){return e>=12592&&e<=12687},ja=function(e){return e>=12688&&e<=12703},Ga=function(e){return e>=12704&&e<=12735},qa=function(e){return e>=12736&&e<=12783},Za=function(e){return e>=12784&&e<=12799},$a=function(e){return e>=12800&&e<=13055},Ha=function(e){return e>=13056&&e<=13311},Wa=function(e){return e>=13312&&e<=19903},Xa=function(e){return e>=19904&&e<=19967},Ya=function(e){return e>=19968&&e<=40959},Ja=function(e){return e>=40960&&e<=42127},Ka=function(e){return e>=42128&&e<=42191},Qa=function(e){return e>=43360&&e<=43391},eo=function(e){return e>=44032&&e<=55215},to=function(e){return e>=55216&&e<=55295},ro=function(e){return e>=57344&&e<=63743},io=function(e){return e>=63744&&e<=64255},no=function(e){return e>=64336&&e<=65023},ao=function(e){return e>=65040&&e<=65055},oo=function(e){return e>=65072&&e<=65103},so=function(e){return e>=65104&&e<=65135},lo=function(e){return e>=65136&&e<=65279},uo=function(e){return e>=65280&&e<=65519},co=function(e){return e>=131072&&e<=173791};function ho(e){for(var t of e)if(mo(t.charCodeAt(0)))return!0;return!1}function fo(e){for(var t of e)if(!po(t.charCodeAt(0)))return!1;return!0}function po(e){return!(_a(e)||ya(e)||ga(e)||no(e)||lo(e))}function mo(e){return!(746!==e&&747!==e&&(e<4352||!(Ga(e)||Va(e)||oo(e)&&!(e>=65097&&e<=65103)||io(e)||Ha(e)||Ra(e)||qa(e)||!(!Ba(e)||e>=12296&&e<=12305||e>=12308&&e<=12319||12336===e)||Wa(e)||Ya(e)||$a(e)||Ua(e)||Qa(e)||to(e)||xa(e)||eo(e)||Fa(e)||Oa(e)||ja(e)||La(e)||Za(e)||Na(e)&&12540!==e||!(!uo(e)||65288===e||65289===e||65293===e||e>=65306&&e<=65310||65339===e||65341===e||65343===e||e>=65371&&e<=65503||65507===e||e>=65512&&e<=65519)||!(!so(e)||e>=65112&&e<=65118||e>=65123&&e<=65126)||ba(e)||ka(e)||ao(e)||Xa(e)||Ja(e)||Ka(e))))}function vo(e){return!(mo(e)||(function(e){return!!(va(e)&&(167===e||169===e||174===e||177===e||188===e||189===e||190===e||215===e||247===e)||Ta(e)&&(8214===e||8224===e||8225===e||8240===e||8241===e||8251===e||8252===e||8258===e||8263===e||8264===e||8265===e||8273===e)||Ma(e)||Sa(e)||Ea(e)&&(e>=8960&&e<=8967||e>=8972&&e<=8991||e>=8996&&e<=9e3||9003===e||e>=9085&&e<=9114||e>=9150&&e<=9165||9167===e||e>=9169&&e<=9179||e>=9186&&e<=9215)||Ia(e)&&9251!==e||Aa(e)||Ca(e)||Pa(e)||za(e)&&!(e>=9754&&e<=9759)||Da(e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||Ba(e)||Na(e)||ro(e)||oo(e)||so(e)||uo(e)||8734===e||8756===e||8757===e||e>=9984&&e<=10087||e>=10102&&e<=10131||65532===e||65533===e)})(e))}function _o(e){return e>=1424&&e<=2303||no(e)||lo(e)}function yo(e,t){return!(!t&&_o(e)||e>=2304&&e<=3583||e>=3840&&e<=4255||wa(e))}function go(e){for(var t of e)if(_o(t.charCodeAt(0)))return!0;return!1}var xo="deferred",bo="loading",wo="loaded",ko=null,To="unavailable",Mo=null,So=function(e){e&&"string"==typeof e&&e.indexOf("NetworkError")>-1&&(To="error"),ko&&ko(e)};function Eo(){Io.fire(new It("pluginStateChange",{pluginStatus:To,pluginURL:Mo}))}var Io=new Dt,Ao=function(){return To},Co=function(){if(To!==xo||!Mo)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");To=bo,Eo(),Mo&&pt({url:Mo},(function(e){e?So(e):(To=wo,Eo())}))},Po={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:function(){return To===wo||null!=Po.applyArabicShaping},isLoading:function(){return To===bo},setState:function(e){To=e.pluginStatus,Mo=e.pluginURL},isParsed:function(){return null!=Po.applyArabicShaping&&null!=Po.processBidirectionalText&&null!=Po.processStyledBidirectionalText},getPluginURL:function(){return Mo}},zo=(function(){return m((function e(t,r){p(this,e),this.zoom=t,r?(this.now=r.now,this.fadeDuration=r.fadeDuration,this.transition=r.transition,this.pitch=r.pitch,this.brightness=r.brightness):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0)}),[{key:"isSupportedScript",value:function(e){return(function(e,t){for(var r of e)if(!yo(r.charCodeAt(0),t))return!1;return!0})(e,Po.isLoaded())}}])})(),Do=(function(){return m((function e(t,r,i,n){p(this,e),this.property=t,this.value=r,this.expression=(function(e,t,r,i){if(Gn(e))return new ia(e,t);if(Kn(e)||Array.isArray(e)&&e.length>0){var n=ra(e,t,r,i);if("error"===n.result)throw new Error(n.value.map((function(e){return`${e.key}: ${e.message}`})).join(", "));return n.value}var a=e;return"string"==typeof e&&"color"===t.type&&(a=Ot.parse(e)),{kind:"constant",configDependencies:new Set,evaluate:function(){return a}}})(void 0===r?t.specification.default:r,t.specification,i,n)}),[{key:"isDataDriven",value:function(){return"source"===this.expression.kind||"composite"===this.expression.kind}},{key:"possiblyEvaluate",value:function(e,t,r){return this.property.possiblyEvaluate(this,e,t,r)}}])})(),Ro=(function(){return m((function e(t,r,i){p(this,e),this.property=t,this.value=new Do(t,void 0,r,i)}),[{key:"transitioned",value:function(e,t){return new Oo(this.property,this.value,t,fe({},e.transition,this.transition),e.now)}},{key:"untransitioned",value:function(){return new Oo(this.property,this.value,null,{},0)}}])})(),Lo=(function(){return m((function e(t,r,i){p(this,e),this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues),this._scope=r,this._options=i,this.configDependencies=new Set}),[{key:"getValue",value:function(e){return xe(this._values[e].value.value)}},{key:"setValue",value:function(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new Ro(this._values[e].property,this._scope,this._options)),this._values[e].value=new Do(this._values[e].property,null===t?void 0:xe(t),this._scope,this._options),this._values[e].value.expression.configDependencies&&(this.configDependencies=new Set([].concat(d(this.configDependencies),d(this._values[e].value.expression.configDependencies))))}},{key:"setTransitionOrValue",value:function(e,t){t&&(this._options=t);var r=this._properties.properties;if(e)for(var i in e){var n=e[i];if(_e(i,"-transition")){var a=i.slice(0,-11);r[a]&&this.setTransition(a,n)}else r.hasOwnProperty(i)&&this.setValue(i,n)}}},{key:"getTransition",value:function(e){return xe(this._values[e].transition)}},{key:"setTransition",value:function(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new Ro(this._values[e].property)),this._values[e].transition=xe(t)||void 0}},{key:"serialize",value:function(){var e={};for(var t of Object.keys(this._values)){var r=this.getValue(t);void 0!==r&&(e[t]=r);var i=this.getTransition(t);void 0!==i&&(e[`${t}-transition`]=i)}return e}},{key:"transitioned",value:function(e,t){var r=new Bo(this._properties);for(var i of Object.keys(this._values))r._values[i]=this._values[i].transitioned(e,t._values[i]);return r}},{key:"untransitioned",value:function(){var e=new Bo(this._properties);for(var t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}}])})(),Oo=(function(){return m((function e(t,r,i,n,a){p(this,e);var o=n.delay||0,s=n.duration||0;a=a||0,this.property=t,this.value=r,this.begin=a+o,this.end=this.begin+s,t.specification.transition&&(n.delay||n.duration)&&(this.prior=i)}),[{key:"possiblyEvaluate",value:function(e,t,r){var i=e.now||0,n=this.value.possiblyEvaluate(e,t,r),a=this.prior;if(a){if(i>this.end)return this.prior=null,n;if(this.value.isDataDriven())return this.prior=null,n;if(i":1,">=":1,"<":1,"<=":1,"in":1,"!in":1,"all":1,"any":1,"none":1,"has":1,"!has":1}},"geometry_type":{"type":"enum","values":{"Point":1,"LineString":1,"Polygon":1}},"function":{"expression":{"type":"expression"},"stops":{"type":"array","value":"function_stop"},"base":{"type":"number","default":1,"minimum":0},"property":{"type":"string","default":"$zoom"},"type":{"type":"enum","values":{"identity":1,"exponential":1,"interval":1,"categorical":1},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":1,"lab":1,"hcl":1},"default":"rgb"},"default":{"type":"*","required":false}},"function_stop":{"type":"array","minimum":0,"maximum":24,"value":["number","color"],"length":2},"expression":{"type":"array","value":"*","minimum":1},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"high-color":{"type":"color","property-type":"data-constant","default":"#245cdf","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"space-color":{"type":"color","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"horizon-blend":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,0.2,7,0.1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"star-intensity":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],5,0.35,6,0],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vertical-range":{"type":"array","default":[0,0],"minimum":0,"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}}},"camera":{"camera-projection":{"type":"enum","values":{"perspective":1,"orthographic":1},"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"default":"perspective","property-type":"data-constant"}},"colorTheme":{"data":{"type":"string","property-type":"data-constant","expression":{}}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"property-type":"data-constant","expression":{"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":1,"equalEarth":1,"equirectangular":1,"lambertConformalConic":1,"mercator":1,"naturalEarth":1,"winkelTripel":1,"globe":1},"default":"mercator","required":true},"center":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-180,-90],"maximum":[180,90]},"parallels":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-90,-90],"maximum":[90,90]}},"terrain":{"source":{"type":"string","required":true},"exaggeration":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_raster-particle","paint_hillshade","paint_background","paint_sky","paint_model"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"fill-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"fill-z-offset":{"type":"number","default":0,"minimum":0,"transition":true,"experimental":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-ambient-occlusion-intensity":{"property-type":"data-constant","type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-radius":{"property-type":"data-constant","type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-wall-radius":{"property-type":"data-constant","type":"number","experimental":true,"default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-radius":{"property-type":"data-constant","type":"number","experimental":true,"default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-attenuation":{"property-type":"data-constant","type":"number","experimental":true,"default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-flood-light-color":{"property-type":"data-constant","type":"color","experimental":true,"default":"#ffffff","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-intensity":{"property-type":"data-constant","type":"number","experimental":true,"default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-wall-radius":{"property-type":"data-driven","type":"number","experimental":true,"default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-radius":{"property-type":"data-driven","type":"number","experimental":true,"default":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-attenuation":{"property-type":"data-constant","type":"number","experimental":true,"default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-vertical-scale":{"property-type":"data-constant","type":"number","experimental":true,"default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-rounded-roof":{"property-type":"data-constant","type":"boolean","default":true,"experimental":true,"expression":{"parameters":["zoom"]}},"fill-extrusion-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{},"property-type":"data-constant"},"fill-extrusion-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"property-type":"data-driven"},"fill-extrusion-line-width":{"type":"number","default":0,"minimum":0,"transition":true,"experimental":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-extrusion-cast-shadows":{"type":"boolean","default":true,"property-type":"data-constant"}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-gradient":{"type":"color","expression":{"interpolated":true,"parameters":["line-progress"]},"property-type":"color-ramp"},"line-trim-offset":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1],"property-type":"constant"},"line-trim-fade-range":{"type":"array","value":"number","experimental":true,"length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1],"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"line-trim-color":{"type":"color","experimental":true,"default":"transparent","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"line-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"line-border-width":{"type":"number","private":true,"default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-border-color":{"type":"color","private":true,"default":"rgba(0, 0, 0, 0)","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-occlusion-opacity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true,"property-type":"data-constant"}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"heatmap-color":{"type":"color","default":["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"],"expression":{"interpolated":true,"parameters":["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-occlusion-opacity":{"type":"number","minimum":0,"maximum":1,"default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"property-type":"data-driven"},"text-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-image-cross-fade":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"transition":true},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-occlusion-opacity":{"type":"number","minimum":0,"maximum":1,"default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","transition":true,"overridable":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-color-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{},"property-type":"data-constant"},"icon-color-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{},"property-type":"data-constant"},"icon-color-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{},"property-type":"data-constant"},"icon-color-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{},"property-type":"data-constant"},"symbol-z-offset":{"type":"number","default":0,"minimum":0,"transition":true,"experimental":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"symbol-elevation-reference":{"type":"enum","values":{"sea":1,"ground":1},"default":"ground","experimental":true,"expression":{"parameters":["zoom"]},"property-type":"data-constant"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-color":{"type":"color","expression":{"interpolated":true,"parameters":["raster-value"]},"property-type":"color-ramp"},"raster-color-mix":{"type":"array","default":[0.2126,0.7152,0.0722,0],"length":4,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-color-range":{"type":"array","length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-resampling":{"type":"enum","values":{"linear":1,"nearest":1},"default":"linear","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"raster-array-band":{"type":"string","required":false,"experimental":true,"property-type":"data-constant"},"raster-elevation":{"type":"number","default":0,"minimum":0,"transition":true,"experimental":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_raster-particle":{"raster-particle-array-band":{"type":"string","required":false,"property-type":"data-constant"},"raster-particle-count":{"type":"number","default":512,"minimum":1,"property-type":"data-constant"},"raster-particle-color":{"type":"color","expression":{"interpolated":true,"parameters":["raster-particle-speed"]},"property-type":"color-ramp"},"raster-particle-max-speed":{"type":"number","default":1,"minimum":1,"property-type":"data-constant"},"raster-particle-speed-factor":{"type":"number","default":0.2,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-particle-fade-opacity-factor":{"type":"number","default":0.98,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-particle-reset-rate-factor":{"type":"number","default":0.8,"minimum":0,"maximum":1,"property-type":"data-constant"},"raster-particle-elevation":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"hillshade-accent-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"hillshade-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"}},"paint_background":{"background-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":[]},"property-type":"data-constant"},"background-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":1,"atmosphere":1},"default":"atmosphere","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun-intensity":{"type":"number","default":10,"minimum":0,"maximum":100,"property-type":"data-constant"},"sky-gradient-center":{"type":"array","value":"number","default":[0,0],"length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient-radius":{"type":"number","default":90,"minimum":0,"maximum":180,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"expression":{"interpolated":true,"parameters":["sky-radial-progress"]},"property-type":"color-ramp"},"sky-atmosphere-halo-color":{"type":"color","default":"white","property-type":"data-constant"},"sky-atmosphere-color":{"type":"color","default":"white","property-type":"data-constant"},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_model":{"model-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"model-rotation":{"type":"array","value":"number","length":3,"default":[0,0,0],"period":360,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-scale":{"type":"array","value":"number","length":3,"default":[1,1,1],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-translation":{"type":"array","value":"number","length":3,"default":[0,0,0],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-color":{"type":"color","default":"#ffffff","property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":true},"model-color-mix-intensity":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-type":{"type":"enum","values":{"common-3d":1,"location-indicator":1},"default":"common-3d","property-type":"data-constant"},"model-cast-shadows":{"type":"boolean","default":true,"property-type":"data-constant"},"model-receive-shadows":{"type":"boolean","default":true,"property-type":"data-constant"},"model-ambient-occlusion-intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant","transition":true},"model-emissive-strength":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-roughness":{"type":"number","default":1,"minimum":0,"maximum":1,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state"]},"transition":true},"model-height-based-emissive-strength-multiplier":{"type":"array","default":[1,1,1,1,0],"length":5,"value":"number","property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{},"property-type":"data-constant"},"model-front-cutoff":{"type":"array","private":true,"value":"number","property-type":"data-constant","expression":{"interpolated":true,"parameters":["zoom"]},"length":3,"default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1]}},"transition":{"duration":{"type":"number","default":300,"minimum":0},"delay":{"type":"number","default":0,"minimum":0}},"property-type":{"data-driven":{"type":"property-type"},"color-ramp":{"type":"property-type"},"data-constant":{"type":"property-type"},"constant":{"type":"property-type"}},"promoteId":{"*":{"type":"string"}}}');function $o(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function Ho(e){if(Array.isArray(e))return e.map(Ho);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){var t={};for(var r in e)t[r]=Ho(e[r]);return t}return $o(e)}function Wo(e){if(!0===e||!1===e)return!0;if(!Array.isArray(e)||0===e.length)return!1;switch(e[0]){case"has":return e.length>=2&&"$id"!==e[1]&&"$type"!==e[1];case"in":return e.length>=3&&("string"!=typeof e[1]||Array.isArray(e[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==e.length||Array.isArray(e[1])||Array.isArray(e[2]);case"any":case"all":for(var t of e.slice(1))if(!Wo(t)&&"boolean"!=typeof t)return!1;return!0;default:return!0}}function Xo(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"fill";if(null==e)return{filter:function(){return!0},needGeometry:!1,needFeature:!1};Wo(e)||(e=rs(e));var n=e,a=!0;try{a=(function(e){if(!Ko(e))return e;var t=Ho(e);return Jo(t),t=Yo(t)})(n)}catch(e){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.\nThis is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md\nand paste the contents of this message in the report.\nThank you!\nFilter Expression:\n${JSON.stringify(n,null,2)}\n `)}var o,s=Zo[`filter_${i}`],l=Qn(a,s,t,r);if("error"===l.result)throw new Error(l.value.map((function(e){return`${e.key}: ${e.message}`})).join(", "));o=function(e,t,r){return l.value.evaluate(e,t,{},r)};var u=null,c=null;if(a!==n){var h=Qn(n,s,t,r);if("error"===h.result)throw new Error(h.value.map((function(e){return`${e.key}: ${e.message}`})).join(", "));u=function(e,t,r,i,n){return h.value.evaluate(e,t,{},r,void 0,void 0,i,n)},c=!Li(h.value.expression)}return{filter:o,dynamicFilter:u||void 0,needGeometry:ts(a),needFeature:!!c}}function Yo(e){if(!Array.isArray(e))return e;var t=(function(e){if(Qo.has(e[0]))for(var t=1;t",">=","<","<=","to-boolean"]);function es(e,t){return et?1:0}function ts(e){if(!Array.isArray(e))return!1;if("within"===e[0]||"distance"===e[0])return!0;for(var t=1;t"===r||"<="===r||">="===r?is(e[1],e[2],r):"any"===r?(t=e.slice(1),["any"].concat(t.map(rs))):"all"===r?["all"].concat(e.slice(1).map(rs)):"none"===r?["all"].concat(e.slice(1).map(rs).map(os)):"in"===r?ns(e[1],e.slice(2)):"!in"===r?os(ns(e[1],e.slice(2))):"has"===r?as(e[1]):"!has"!==r||os(as(e[1]))}function is(e,t,r){switch(e){case"$type":return[`filter-type-${r}`,t];case"$id":return[`filter-id-${r}`,t];default:return[`filter-${r}`,e,t]}}function ns(e,t){if(0===t.length)return!1;switch(e){case"$type":return["filter-type-in",["literal",t]];case"$id":return["filter-id-in",["literal",t]];default:return t.length>200&&!t.some((function(e){return typeof e!=typeof t[0]}))?["filter-in-large",e,["literal",t.sort(es)]]:["filter-in-small",e,["literal",t]]}}function as(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function os(e){return["!",e]}var ss="\x1f";function ls(e,t){return t?`${e}${ss}${t}`:e}var us="-transition",cs=new Set(["fill","line","background","hillshade","raster"]),hs=(function(e){function t(e,r,i,n,a){var o;if(p(this,t),(o=T(this,t)).id=e.id,o.fqid=ls(o.id,i),o.type=e.type,o.scope=i,o.lut=n,o.options=a,o._featureFilter={filter:function(){return!0},needGeometry:!1,needFeature:!1},o._filterCompiled=!1,o.configDependencies=new Set,"custom"!==e.type&&(o.metadata=e.metadata,o.minzoom=e.minzoom,o.maxzoom=e.maxzoom,"background"!==e.type&&"sky"!==e.type&&"slot"!==e.type&&(o.source=e.source,o.sourceLayer=e["source-layer"],o.filter=e.filter),e.slot&&(o.slot=e.slot),r.layout&&(o._unevaluatedLayout=new Fo(r.layout,o.scope,a),o.configDependencies=new Set([].concat(d(o.configDependencies),d(o._unevaluatedLayout.configDependencies)))),r.paint)){for(var s in o._transitionablePaint=new Lo(r.paint,o.scope,a),e.paint)o.setPaintProperty(s,e.paint[s]);for(var l in e.layout)o.setLayoutProperty(l,e.layout[l]);o.configDependencies=new Set([].concat(d(o.configDependencies),d(o._transitionablePaint.configDependencies))),o._transitioningPaint=o._transitionablePaint.untransitioned(),o.paint=new Vo(r.paint)}return o}return y(t,e),m(t,[{key:"onAdd",value:function(e){}},{key:"onRemove",value:function(e){}},{key:"isDraped",value:function(e){return!this.is3D()&&cs.has(this.type)}},{key:"getLayoutProperty",value:function(e){return"visibility"===e?this.visibility:this._unevaluatedLayout.getValue(e)}},{key:"setLayoutProperty",value:function(e,t){if("custom"!==this.type||"visibility"!==e){var r=this._unevaluatedLayout;r._properties.properties[e]&&(r.setValue(e,t),this.configDependencies=new Set([].concat(d(this.configDependencies),d(r.configDependencies))),"visibility"===e&&this.possiblyEvaluateVisibility())}else this.visibility=t}},{key:"possiblyEvaluateVisibility",value:function(){this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0})}},{key:"getPaintProperty",value:function(e){return _e(e,us)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}},{key:"setPaintProperty",value:function(e,t){var r=this._transitionablePaint,i=r._properties.properties;if(_e(e,us)){var n=e.slice(0,-11);return i[n]&&r.setTransition(n,t||void 0),!1}if(!i[e])return!1;var a=r._values[e],o=a.value.isDataDriven(),s=a.value;r.setValue(e,t),this.configDependencies=new Set([].concat(d(this.configDependencies),d(r.configDependencies))),this._handleSpecialPaintPropertyUpdate(e);var l=r._values[e].value,u=l.isDataDriven(),c=_e(e,"pattern")||"line-dasharray"===e;return u||o||c||this._handleOverridablePaintPropertyUpdate(e,s,l)}},{key:"_handleSpecialPaintPropertyUpdate",value:function(e){}},{key:"getProgramIds",value:function(){return null}},{key:"getDefaultProgramParams",value:function(e,t,r){return null}},{key:"_handleOverridablePaintPropertyUpdate",value:function(e,t,r){return!1}},{key:"isHidden",value:function(e){return!!(this.minzoom&&e=this.maxzoom)||"none"===this.visibility}},{key:"updateTransitions",value:function(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}},{key:"hasTransition",value:function(){return this._transitioningPaint.hasTransition()}},{key:"recalculate",value:function(e,t){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,t)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,t)}},{key:"serialize",value:function(){return ge({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()},(function(e,t){return!(void 0===e||"layout"===t&&!Object.keys(e).length||"paint"===t&&!Object.keys(e).length)}))}},{key:"is3D",value:function(){return!1}},{key:"isSky",value:function(){return!1}},{key:"isTileClipped",value:function(){return!1}},{key:"hasOffscreenPass",value:function(){return!1}},{key:"hasShadowPass",value:function(){return!1}},{key:"canCastShadows",value:function(){return!1}},{key:"hasLightBeamPass",value:function(){return!1}},{key:"cutoffRange",value:function(){return 0}},{key:"tileCoverLift",value:function(){return 0}},{key:"resize",value:function(){}},{key:"isStateDependent",value:function(){for(var e in this.paint._values){var t=this.paint.get(e);if(t instanceof No&&Nn(t.property.specification)&&("source"===t.value.kind||"composite"===t.value.kind)&&t.value.isStateDependent)return!0}return!1}},{key:"compileFilter",value:function(e){this._filterCompiled||(this._featureFilter=Xo(this.filter,this.scope,e),this._filterCompiled=!0)}},{key:"invalidateCompiledFilter",value:function(){this._filterCompiled=!1}},{key:"dynamicFilter",value:function(){return this._featureFilter.dynamicFilter}},{key:"dynamicFilterNeedsFeature",value:function(){return this._featureFilter.needFeature}},{key:"getLayerRenderingStats",value:function(){return this._stats}},{key:"resetLayerRenderingStats",value:function(e){this._stats&&("shadow"===e.renderPass?this._stats.numRenderedVerticesInShadowPass=0:this._stats.numRenderedVerticesInTransparentPass=0)}},{key:"queryRadius",value:function(e){}},{key:"queryIntersectsFeature",value:function(e,t,r,i,n,a,o,s,l){}},{key:"queryIntersectsMatchingFeature",value:function(e,t,r,i){}}])})(Dt),fs={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array},ds=m((function e(t,r){p(this,e),this._structArray=t,this._pos1=r*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8})),ps=(function(){return m((function e(){p(this,e),this.isTransferred=!1,this.capacity=-1,this.resize(0)}),[{key:"_trim",value:function(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}},{key:"clear",value:function(){this.length=0}},{key:"resize",value:function(e){this.reserve(e),this.length=e}},{key:"reserve",value:function(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);var t=this.uint8;this._refreshViews(),t&&this.uint8.set(t)}}},{key:"_refreshViews",value:function(){throw new Error("StructArray#_refreshViews() must be implemented by each concrete StructArray layout")}},{key:"emplace",value:function(){throw new Error("StructArray#emplace() must be implemented by each concrete StructArray layout")}},{key:"emplaceBack",value:function(){throw new Error("StructArray#emplaceBack() must be implemented by each concrete StructArray layout")}},{key:"destroy",value:function(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null}}],[{key:"serialize",value:function(e,t){return e._trim(),t&&(e.isTransferred=!0,t.add(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}},{key:"deserialize",value:function(e){var t=Object.create(this.prototype);return t.arrayBuffer=e.arrayBuffer,t.length=e.length,t.capacity=e.arrayBuffer.byteLength/t.bytesPerElement,t._refreshViews(),t}}])})();function ms(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=0,i=0;return{members:e.map((function(e){var n=fs[e.type].BYTES_PER_ELEMENT,a=r=vs(r,Math.max(t,n)),o=e.components||1;return i=Math.max(i,n),r+=n*o,{name:e.name,type:e.type,components:o,offset:a}})),size:vs(r,Math.max(i,t)),alignment:t}}function vs(e,t){return Math.ceil(e/t)*t}var _s=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t){var r=this.length;return this.resize(r+1),this.emplace(r,e,t)}},{key:"emplace",value:function(e,t,r){var i=2*e;return this.int16[i+0]=t,this.int16[i+1]=r,e}}])})(ps);_s.prototype.bytesPerElement=4,ca(_s,"StructArrayLayout2i4");var ys=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t,r){var i=this.length;return this.resize(i+1),this.emplace(i,e,t,r)}},{key:"emplace",value:function(e,t,r,i){var n=3*e;return this.int16[n+0]=t,this.int16[n+1]=r,this.int16[n+2]=i,e}}])})(ps);ys.prototype.bytesPerElement=6,ca(ys,"StructArrayLayout3i6");var gs=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t,r,i){var n=this.length;return this.resize(n+1),this.emplace(n,e,t,r,i)}},{key:"emplace",value:function(e,t,r,i,n){var a=4*e;return this.int16[a+0]=t,this.int16[a+1]=r,this.int16[a+2]=i,this.int16[a+3]=n,e}}])})(ps);gs.prototype.bytesPerElement=8,ca(gs,"StructArrayLayout4i8");var xs=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t,r,i,n){var a=this.length;return this.resize(a+1),this.emplace(a,e,t,r,i,n)}},{key:"emplace",value:function(e,t,r,i,n,a){var o=5*e;return this.int16[o+0]=t,this.int16[o+1]=r,this.int16[o+2]=i,this.int16[o+3]=n,this.int16[o+4]=a,e}}])})(ps);xs.prototype.bytesPerElement=10,ca(xs,"StructArrayLayout5i10");var bs=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t,r,i,n,a,o){var s=this.length;return this.resize(s+1),this.emplace(s,e,t,r,i,n,a,o)}},{key:"emplace",value:function(e,t,r,i,n,a,o,s){var l=6*e,u=12*e,c=3*e;return this.int16[l+0]=t,this.int16[l+1]=r,this.uint8[u+4]=i,this.uint8[u+5]=n,this.uint8[u+6]=a,this.uint8[u+7]=o,this.float32[c+2]=s,e}}])})(ps);bs.prototype.bytesPerElement=12,ca(bs,"StructArrayLayout2i4ub1f12");var ws=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t,r,i){var n=this.length;return this.resize(n+1),this.emplace(n,e,t,r,i)}},{key:"emplace",value:function(e,t,r,i,n){var a=4*e;return this.float32[a+0]=t,this.float32[a+1]=r,this.float32[a+2]=i,this.float32[a+3]=n,e}}])})(ps);ws.prototype.bytesPerElement=16,ca(ws,"StructArrayLayout4f16");var ks=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t,r){var i=this.length;return this.resize(i+1),this.emplace(i,e,t,r)}},{key:"emplace",value:function(e,t,r,i){var n=3*e;return this.float32[n+0]=t,this.float32[n+1]=r,this.float32[n+2]=i,e}}])})(ps);ks.prototype.bytesPerElement=12,ca(ks,"StructArrayLayout3f12");var Ts=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t,r,i,n){var a=this.length;return this.resize(a+1),this.emplace(a,e,t,r,i,n)}},{key:"emplace",value:function(e,t,r,i,n,a){var o=6*e,s=3*e;return this.uint16[o+0]=t,this.uint16[o+1]=r,this.uint16[o+2]=i,this.uint16[o+3]=n,this.float32[s+2]=a,e}}])})(ps);Ts.prototype.bytesPerElement=12,ca(Ts,"StructArrayLayout4ui1f12");var Ms=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t,r,i){var n=this.length;return this.resize(n+1),this.emplace(n,e,t,r,i)}},{key:"emplace",value:function(e,t,r,i,n){var a=4*e;return this.uint16[a+0]=t,this.uint16[a+1]=r,this.uint16[a+2]=i,this.uint16[a+3]=n,e}}])})(ps);Ms.prototype.bytesPerElement=8,ca(Ms,"StructArrayLayout4ui8");var Ss=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t,r,i,n,a){var o=this.length;return this.resize(o+1),this.emplace(o,e,t,r,i,n,a)}},{key:"emplace",value:function(e,t,r,i,n,a,o){var s=6*e;return this.int16[s+0]=t,this.int16[s+1]=r,this.int16[s+2]=i,this.int16[s+3]=n,this.int16[s+4]=a,this.int16[s+5]=o,e}}])})(ps);Ss.prototype.bytesPerElement=12,ca(Ss,"StructArrayLayout6i12");var Es=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t,r,i,n,a,o,s,l,u,c,h){var f=this.length;return this.resize(f+1),this.emplace(f,e,t,r,i,n,a,o,s,l,u,c,h)}},{key:"emplace",value:function(e,t,r,i,n,a,o,s,l,u,c,h,f){var d=12*e;return this.int16[d+0]=t,this.int16[d+1]=r,this.int16[d+2]=i,this.int16[d+3]=n,this.uint16[d+4]=a,this.uint16[d+5]=o,this.uint16[d+6]=s,this.uint16[d+7]=l,this.int16[d+8]=u,this.int16[d+9]=c,this.int16[d+10]=h,this.int16[d+11]=f,e}}])})(ps);Es.prototype.bytesPerElement=24,ca(Es,"StructArrayLayout4i4ui4i24");var Is=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t,r,i,n,a){var o=this.length;return this.resize(o+1),this.emplace(o,e,t,r,i,n,a)}},{key:"emplace",value:function(e,t,r,i,n,a,o){var s=10*e,l=5*e;return this.int16[s+0]=t,this.int16[s+1]=r,this.int16[s+2]=i,this.float32[l+2]=n,this.float32[l+3]=a,this.float32[l+4]=o,e}}])})(ps);Is.prototype.bytesPerElement=20,ca(Is,"StructArrayLayout3i3f20");var As=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e){var t=this.length;return this.resize(t+1),this.emplace(t,e)}},{key:"emplace",value:function(e,t){return this.uint32[1*e+0]=t,e}}])})(ps);As.prototype.bytesPerElement=4,ca(As,"StructArrayLayout1ul4");var Cs=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t){var r=this.length;return this.resize(r+1),this.emplace(r,e,t)}},{key:"emplace",value:function(e,t,r){var i=2*e;return this.uint16[i+0]=t,this.uint16[i+1]=r,e}}])})(ps);Cs.prototype.bytesPerElement=4,ca(Cs,"StructArrayLayout2ui4");var Ps=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"_refreshViews",value:function(){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)}},{key:"emplaceBack",value:function(e,t,r,i,n,a,o,s,l,u,c,h,f){var d=this.length;return this.resize(d+1),this.emplace(d,e,t,r,i,n,a,o,s,l,u,c,h,f)}},{key:"emplace",value:function(e,t,r,i,n,a,o,s,l,u,c,h,f,d){var p=20*e,m=10*e;return this.int16[p+0]=t,this.int16[p+1]=r,this.int16[p+2]=i,this.int16[p+3]=n,this.int16[p+4]=a,this.float32[m+3]=o,this.float32[m+4]=s,this.float32[m+5]=l,this.float32[m+6]=u,this.int16[p+14]=c,this.uint32[m+8]=h,this.uint16[p+18]=f,this.uint16[p+19]=d,e}}])})(ps);Ps.prototype.bytesPerElement=40,ca(Ps,"StructArrayLayout5i4f1i1ul2ui40");var zs=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t,r,i,n,a,o){var s=this.length;return this.resize(s+1),this.emplace(s,e,t,r,i,n,a,o)}},{key:"emplace",value:function(e,t,r,i,n,a,o,s){var l=8*e;return this.int16[l+0]=t,this.int16[l+1]=r,this.int16[l+2]=i,this.int16[l+4]=n,this.int16[l+5]=a,this.int16[l+6]=o,this.int16[l+7]=s,e}}])})(ps);zs.prototype.bytesPerElement=16,ca(zs,"StructArrayLayout3i2i2i16");var Ds=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t,r,i,n){var a=this.length;return this.resize(a+1),this.emplace(a,e,t,r,i,n)}},{key:"emplace",value:function(e,t,r,i,n,a){var o=4*e,s=8*e;return this.float32[o+0]=t,this.float32[o+1]=r,this.float32[o+2]=i,this.int16[s+6]=n,this.int16[s+7]=a,e}}])})(ps);Ds.prototype.bytesPerElement=16,ca(Ds,"StructArrayLayout2f1f2i16");var Rs=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t,r,i,n,a){var o=this.length;return this.resize(o+1),this.emplace(o,e,t,r,i,n,a)}},{key:"emplace",value:function(e,t,r,i,n,a,o){var s=20*e,l=5*e;return this.uint8[s+0]=t,this.uint8[s+1]=r,this.float32[l+1]=i,this.float32[l+2]=n,this.float32[l+3]=a,this.float32[l+4]=o,e}}])})(ps);Rs.prototype.bytesPerElement=20,ca(Rs,"StructArrayLayout2ub4f20");var Ls=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t,r){var i=this.length;return this.resize(i+1),this.emplace(i,e,t,r)}},{key:"emplace",value:function(e,t,r,i){var n=3*e;return this.uint16[n+0]=t,this.uint16[n+1]=r,this.uint16[n+2]=i,e}}])})(ps);Ls.prototype.bytesPerElement=6,ca(Ls,"StructArrayLayout3ui6");var Os=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"_refreshViews",value:function(){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)}},{key:"emplaceBack",value:function(e,t,r,i,n,a,o,s,l,u,c,h,f,d,p,m,v,_,y,g,x){var b=this.length;return this.resize(b+1),this.emplace(b,e,t,r,i,n,a,o,s,l,u,c,h,f,d,p,m,v,_,y,g,x)}},{key:"emplace",value:function(e,t,r,i,n,a,o,s,l,u,c,h,f,d,p,m,v,_,y,g,x,b){var w=30*e,k=15*e,T=60*e;return this.int16[w+0]=t,this.int16[w+1]=r,this.int16[w+2]=i,this.float32[k+2]=n,this.float32[k+3]=a,this.uint16[w+8]=o,this.uint16[w+9]=s,this.uint32[k+5]=l,this.uint32[k+6]=u,this.uint32[k+7]=c,this.uint16[w+16]=h,this.uint16[w+17]=f,this.uint16[w+18]=d,this.float32[k+10]=p,this.float32[k+11]=m,this.uint8[T+48]=v,this.uint8[T+49]=_,this.uint8[T+50]=y,this.uint32[k+13]=g,this.int16[w+28]=x,this.uint8[T+58]=b,e}}])})(ps);Os.prototype.bytesPerElement=60,ca(Os,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");var Bs=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"_refreshViews",value:function(){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)}},{key:"emplaceBack",value:function(e,t,r,i,n,a,o,s,l,u,c,h,f,d,p,m,v,_,y,g,x,b,w,k,T,M,S,E,I,A,C,P){var z=this.length;return this.resize(z+1),this.emplace(z,e,t,r,i,n,a,o,s,l,u,c,h,f,d,p,m,v,_,y,g,x,b,w,k,T,M,S,E,I,A,C,P)}},{key:"emplace",value:function(e,t,r,i,n,a,o,s,l,u,c,h,f,d,p,m,v,_,y,g,x,b,w,k,T,M,S,E,I,A,C,P,z){var D=20*e,R=40*e,L=80*e;return this.float32[D+0]=t,this.float32[D+1]=r,this.int16[R+4]=i,this.int16[R+5]=n,this.int16[R+6]=a,this.int16[R+7]=o,this.int16[R+8]=s,this.int16[R+9]=l,this.int16[R+10]=u,this.int16[R+11]=c,this.int16[R+12]=h,this.uint16[R+13]=f,this.uint16[R+14]=d,this.uint16[R+15]=p,this.uint16[R+16]=m,this.uint16[R+17]=v,this.uint16[R+18]=_,this.uint16[R+19]=y,this.uint16[R+20]=g,this.uint16[R+21]=x,this.uint16[R+22]=b,this.uint16[R+23]=w,this.uint16[R+24]=k,this.uint16[R+25]=T,this.uint16[R+26]=M,this.uint16[R+27]=S,this.uint32[D+14]=E,this.float32[D+15]=I,this.float32[D+16]=A,this.float32[D+17]=C,this.float32[D+18]=P,this.uint8[L+76]=z,e}}])})(ps);Bs.prototype.bytesPerElement=80,ca(Bs,"StructArrayLayout2f9i15ui1ul4f1ub80");var Fs=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e){var t=this.length;return this.resize(t+1),this.emplace(t,e)}},{key:"emplace",value:function(e,t){return this.float32[1*e+0]=t,e}}])})(ps);Fs.prototype.bytesPerElement=4,ca(Fs,"StructArrayLayout1f4");var Ns=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t,r,i,n){var a=this.length;return this.resize(a+1),this.emplace(a,e,t,r,i,n)}},{key:"emplace",value:function(e,t,r,i,n,a){var o=5*e;return this.float32[o+0]=t,this.float32[o+1]=r,this.float32[o+2]=i,this.float32[o+3]=n,this.float32[o+4]=a,e}}])})(ps);Ns.prototype.bytesPerElement=20,ca(Ns,"StructArrayLayout5f20");var Vs=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t,r,i,n,a,o){var s=this.length;return this.resize(s+1),this.emplace(s,e,t,r,i,n,a,o)}},{key:"emplace",value:function(e,t,r,i,n,a,o,s){var l=7*e;return this.float32[l+0]=t,this.float32[l+1]=r,this.float32[l+2]=i,this.float32[l+3]=n,this.float32[l+4]=a,this.float32[l+5]=o,this.float32[l+6]=s,e}}])})(ps);Vs.prototype.bytesPerElement=28,ca(Vs,"StructArrayLayout7f28");var Us=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t,r,i){var n=this.length;return this.resize(n+1),this.emplace(n,e,t,r,i)}},{key:"emplace",value:function(e,t,r,i,n){var a=6*e;return this.uint32[3*e+0]=t,this.uint16[a+2]=r,this.uint16[a+3]=i,this.uint16[a+4]=n,e}}])})(ps);Us.prototype.bytesPerElement=12,ca(Us,"StructArrayLayout1ul3ui12");var js=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e){var t=this.length;return this.resize(t+1),this.emplace(t,e)}},{key:"emplace",value:function(e,t){return this.uint16[1*e+0]=t,e}}])})(ps);js.prototype.bytesPerElement=2,ca(js,"StructArrayLayout1ui2");var Gs=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t){var r=this.length;return this.resize(r+1),this.emplace(r,e,t)}},{key:"emplace",value:function(e,t,r){var i=2*e;return this.float32[i+0]=t,this.float32[i+1]=r,e}}])})(ps);Gs.prototype.bytesPerElement=8,ca(Gs,"StructArrayLayout2f8");var qs=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t,r,i,n,a,o,s,l,u,c,h,f,d,p,m){var v=this.length;return this.resize(v+1),this.emplace(v,e,t,r,i,n,a,o,s,l,u,c,h,f,d,p,m)}},{key:"emplace",value:function(e,t,r,i,n,a,o,s,l,u,c,h,f,d,p,m,v){var _=16*e;return this.float32[_+0]=t,this.float32[_+1]=r,this.float32[_+2]=i,this.float32[_+3]=n,this.float32[_+4]=a,this.float32[_+5]=o,this.float32[_+6]=s,this.float32[_+7]=l,this.float32[_+8]=u,this.float32[_+9]=c,this.float32[_+10]=h,this.float32[_+11]=f,this.float32[_+12]=d,this.float32[_+13]=p,this.float32[_+14]=m,this.float32[_+15]=v,e}}])})(ps);qs.prototype.bytesPerElement=64,ca(qs,"StructArrayLayout16f64");var Zs=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t,r,i,n,a,o){var s=this.length;return this.resize(s+1),this.emplace(s,e,t,r,i,n,a,o)}},{key:"emplace",value:function(e,t,r,i,n,a,o,s){var l=10*e,u=5*e;return this.uint16[l+0]=t,this.uint16[l+1]=r,this.uint16[l+2]=i,this.uint16[l+3]=n,this.float32[u+2]=a,this.float32[u+3]=o,this.float32[u+4]=s,e}}])})(ps);Zs.prototype.bytesPerElement=20,ca(Zs,"StructArrayLayout4ui3f20");var $s=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e){var t=this.length;return this.resize(t+1),this.emplace(t,e)}},{key:"emplace",value:function(e,t){return this.int16[1*e+0]=t,e}}])})(ps);$s.prototype.bytesPerElement=2,ca($s,"StructArrayLayout1i2");var Hs=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e){var t=this.length;return this.resize(t+1),this.emplace(t,e)}},{key:"emplace",value:function(e,t){return this.uint8[1*e+0]=t,e}}])})(ps);Hs.prototype.bytesPerElement=1,ca(Hs,"StructArrayLayout1ub1");var Ws=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"projectedAnchorX",get:function(){return this._structArray.int16[this._pos2+0]}},{key:"projectedAnchorY",get:function(){return this._structArray.int16[this._pos2+1]}},{key:"projectedAnchorZ",get:function(){return this._structArray.int16[this._pos2+2]}},{key:"tileAnchorX",get:function(){return this._structArray.int16[this._pos2+3]}},{key:"tileAnchorY",get:function(){return this._structArray.int16[this._pos2+4]}},{key:"x1",get:function(){return this._structArray.float32[this._pos4+3]}},{key:"y1",get:function(){return this._structArray.float32[this._pos4+4]}},{key:"x2",get:function(){return this._structArray.float32[this._pos4+5]}},{key:"y2",get:function(){return this._structArray.float32[this._pos4+6]}},{key:"padding",get:function(){return this._structArray.int16[this._pos2+14]}},{key:"featureIndex",get:function(){return this._structArray.uint32[this._pos4+8]}},{key:"sourceLayerIndex",get:function(){return this._structArray.uint16[this._pos2+18]}},{key:"bucketIndex",get:function(){return this._structArray.uint16[this._pos2+19]}}])})(ds);Ws.prototype.size=40;var Xs=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"get",value:function(e){return new Ws(this,e)}}])})(Ps);ca(Xs,"CollisionBoxArray");var Ys=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"projectedAnchorX",get:function(){return this._structArray.int16[this._pos2+0]}},{key:"projectedAnchorY",get:function(){return this._structArray.int16[this._pos2+1]}},{key:"projectedAnchorZ",get:function(){return this._structArray.int16[this._pos2+2]}},{key:"tileAnchorX",get:function(){return this._structArray.float32[this._pos4+2]}},{key:"tileAnchorY",get:function(){return this._structArray.float32[this._pos4+3]}},{key:"glyphStartIndex",get:function(){return this._structArray.uint16[this._pos2+8]}},{key:"numGlyphs",get:function(){return this._structArray.uint16[this._pos2+9]}},{key:"vertexStartIndex",get:function(){return this._structArray.uint32[this._pos4+5]}},{key:"lineStartIndex",get:function(){return this._structArray.uint32[this._pos4+6]}},{key:"lineLength",get:function(){return this._structArray.uint32[this._pos4+7]}},{key:"segment",get:function(){return this._structArray.uint16[this._pos2+16]}},{key:"lowerSize",get:function(){return this._structArray.uint16[this._pos2+17]}},{key:"upperSize",get:function(){return this._structArray.uint16[this._pos2+18]}},{key:"lineOffsetX",get:function(){return this._structArray.float32[this._pos4+10]}},{key:"lineOffsetY",get:function(){return this._structArray.float32[this._pos4+11]}},{key:"writingMode",get:function(){return this._structArray.uint8[this._pos1+48]}},{key:"placedOrientation",get:function(){return this._structArray.uint8[this._pos1+49]},set:function(e){this._structArray.uint8[this._pos1+49]=e}},{key:"hidden",get:function(){return this._structArray.uint8[this._pos1+50]},set:function(e){this._structArray.uint8[this._pos1+50]=e}},{key:"crossTileID",get:function(){return this._structArray.uint32[this._pos4+13]},set:function(e){this._structArray.uint32[this._pos4+13]=e}},{key:"associatedIconIndex",get:function(){return this._structArray.int16[this._pos2+28]}},{key:"flipState",get:function(){return this._structArray.uint8[this._pos1+58]},set:function(e){this._structArray.uint8[this._pos1+58]=e}}])})(ds);Ys.prototype.size=60;var Js=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"get",value:function(e){return new Ys(this,e)}}])})(Os);ca(Js,"PlacedSymbolArray");var Ks=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"tileAnchorX",get:function(){return this._structArray.float32[this._pos4+0]}},{key:"tileAnchorY",get:function(){return this._structArray.float32[this._pos4+1]}},{key:"projectedAnchorX",get:function(){return this._structArray.int16[this._pos2+4]}},{key:"projectedAnchorY",get:function(){return this._structArray.int16[this._pos2+5]}},{key:"projectedAnchorZ",get:function(){return this._structArray.int16[this._pos2+6]}},{key:"rightJustifiedTextSymbolIndex",get:function(){return this._structArray.int16[this._pos2+7]}},{key:"centerJustifiedTextSymbolIndex",get:function(){return this._structArray.int16[this._pos2+8]}},{key:"leftJustifiedTextSymbolIndex",get:function(){return this._structArray.int16[this._pos2+9]}},{key:"verticalPlacedTextSymbolIndex",get:function(){return this._structArray.int16[this._pos2+10]}},{key:"placedIconSymbolIndex",get:function(){return this._structArray.int16[this._pos2+11]}},{key:"verticalPlacedIconSymbolIndex",get:function(){return this._structArray.int16[this._pos2+12]}},{key:"key",get:function(){return this._structArray.uint16[this._pos2+13]}},{key:"textBoxStartIndex",get:function(){return this._structArray.uint16[this._pos2+14]}},{key:"textBoxEndIndex",get:function(){return this._structArray.uint16[this._pos2+15]}},{key:"verticalTextBoxStartIndex",get:function(){return this._structArray.uint16[this._pos2+16]}},{key:"verticalTextBoxEndIndex",get:function(){return this._structArray.uint16[this._pos2+17]}},{key:"iconBoxStartIndex",get:function(){return this._structArray.uint16[this._pos2+18]}},{key:"iconBoxEndIndex",get:function(){return this._structArray.uint16[this._pos2+19]}},{key:"verticalIconBoxStartIndex",get:function(){return this._structArray.uint16[this._pos2+20]}},{key:"verticalIconBoxEndIndex",get:function(){return this._structArray.uint16[this._pos2+21]}},{key:"featureIndex",get:function(){return this._structArray.uint16[this._pos2+22]}},{key:"numHorizontalGlyphVertices",get:function(){return this._structArray.uint16[this._pos2+23]}},{key:"numVerticalGlyphVertices",get:function(){return this._structArray.uint16[this._pos2+24]}},{key:"numIconVertices",get:function(){return this._structArray.uint16[this._pos2+25]}},{key:"numVerticalIconVertices",get:function(){return this._structArray.uint16[this._pos2+26]}},{key:"useRuntimeCollisionCircles",get:function(){return this._structArray.uint16[this._pos2+27]}},{key:"crossTileID",get:function(){return this._structArray.uint32[this._pos4+14]},set:function(e){this._structArray.uint32[this._pos4+14]=e}},{key:"textOffset0",get:function(){return this._structArray.float32[this._pos4+15]}},{key:"textOffset1",get:function(){return this._structArray.float32[this._pos4+16]}},{key:"collisionCircleDiameter",get:function(){return this._structArray.float32[this._pos4+17]}},{key:"zOffset",get:function(){return this._structArray.float32[this._pos4+18]},set:function(e){this._structArray.float32[this._pos4+18]=e}},{key:"hasIconTextFit",get:function(){return this._structArray.uint8[this._pos1+76]}}])})(ds);Ks.prototype.size=80;var Qs=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"get",value:function(e){return new Ks(this,e)}}])})(Bs);ca(Qs,"SymbolInstanceArray");var el=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"getoffsetX",value:function(e){return this.float32[1*e+0]}}])})(Fs);ca(el,"GlyphOffsetArray");var tl=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"getx",value:function(e){return this.int16[2*e+0]}},{key:"gety",value:function(e){return this.int16[2*e+1]}}])})(_s);ca(tl,"SymbolLineVertexArray");var rl=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"featureIndex",get:function(){return this._structArray.uint32[this._pos4+0]}},{key:"sourceLayerIndex",get:function(){return this._structArray.uint16[this._pos2+2]}},{key:"bucketIndex",get:function(){return this._structArray.uint16[this._pos2+3]}},{key:"layoutVertexArrayOffset",get:function(){return this._structArray.uint16[this._pos2+4]}}])})(ds);rl.prototype.size=12;var il=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"get",value:function(e){return new rl(this,e)}}])})(Us);ca(il,"FeatureIndexArray");var nl=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"geta_centroid_pos0",value:function(e){return this.uint16[2*e+0]}},{key:"geta_centroid_pos1",value:function(e){return this.uint16[2*e+1]}}])})(Cs);ca(nl,"FillExtrusionCentroidArray");var al=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"a_join_normal_inside0",get:function(){return this._structArray.int16[this._pos2+0]}},{key:"a_join_normal_inside1",get:function(){return this._structArray.int16[this._pos2+1]}},{key:"a_join_normal_inside2",get:function(){return this._structArray.int16[this._pos2+2]}}])})(ds);al.prototype.size=6;var ol=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"get",value:function(e){return new al(this,e)}}])})(ys);ca(ol,"FillExtrusionWallArray");var sl=ms([{name:"a_pos",components:2,type:"Int16"}],4),ll=ms([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]),ul=(function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];p(this,e),this.segments=t}return m(e,[{key:"_prepareSegment",value:function(t,r,i,n){var a=this.segments[this.segments.length-1];return t>e.MAX_VERTEX_ARRAY_LENGTH&&we(`Max vertices per segment is ${e.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}`),(!a||a.vertexLength+t>e.MAX_VERTEX_ARRAY_LENGTH||a.sortKey!==n)&&(a={vertexOffset:r,primitiveOffset:i,vertexLength:0,primitiveLength:0},void 0!==n&&(a.sortKey=n),this.segments.push(a)),a}},{key:"prepareSegment",value:function(e,t,r,i){return this._prepareSegment(e,t.length,r.length,i)}},{key:"get",value:function(){return this.segments}},{key:"destroy",value:function(){for(var e of this.segments)for(var t in e.vaos)e.vaos[t].destroy()}}],[{key:"simpleSegment",value:function(t,r,i,n){return new e([{vertexOffset:t,primitiveOffset:r,vertexLength:i,primitiveLength:n,vaos:{},sortKey:0}])}}])})();function cl(e,t){return 256*(e=le(Math.floor(e),0,255))+le(Math.floor(t),0,255)}ul.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,ca(ul,"SegmentVector");var hl=ms([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),fl=ms([{name:"a_dash",components:4,type:"Uint16"}]),dl=(function(){function e(){p(this,e),this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}return m(e,[{key:"add",value:function(e,t,r,i){this.ids.push(pl(e)),this.positions.push(t,r,i)}},{key:"eachPosition",value:function(e,t){for(var r=pl(e),i=0,n=this.ids.length-1;i>1;this.ids[a]>=r?n=a:i=a+1}for(;this.ids[i]===r;)t(this.positions[3*i],this.positions[3*i+1],this.positions[3*i+2]),i++}}],[{key:"serialize",value:function(e,t){var r=new Float64Array(e.ids),i=new Uint32Array(e.positions);return ml(r,i,0,r.length-1),t&&(t.add(r.buffer),t.add(i.buffer)),{ids:r,positions:i}}},{key:"deserialize",value:function(t){var r,i=new e;for(var n of(i.ids=t.ids,i.positions=t.positions,i.ids))n!==r&&i.uniqueIds.push(n),r=n;return i.indexed=!0,i}}])})();function pl(e){var t=+e;return!isNaN(t)&&Number.MIN_SAFE_INTEGER<=t&&t<=Number.MAX_SAFE_INTEGER?t:Et(String(e))}function ml(e,t,r,i){for(;r>1],a=r-1,o=i+1;;){do{a++}while(e[a]n);if(a>=o)break;vl(e,a,o),vl(t,3*a,3*o),vl(t,3*a+1,3*o+1),vl(t,3*a+2,3*o+2)}o-r2&&void 0!==arguments[2]?arguments[2]:function(){return!0};p(this,e),this.binders={},this._buffers=[],this.context=r;var n=[];for(var a in t.paint._values){var o=t.paint.get(a);if(i(a)&&(o instanceof No&&Nn(o.property.specification))){var s=Fl(a,t.type),l=o.value,u=o.property.specification.type,c=!!o.property.useIntegerZoom,h="line-dasharray"===a||a.endsWith("pattern"),f="line-dasharray"===a&&"constant"!==t.layout.get("line-cap").value.kind;if("constant"!==l.kind||f)if("source"===l.kind||f||h){var d=Ul(a,u,"source");this.binders[a]=h?new Rl(l,s,u,d,t.id):new zl(l,s,u,d),n.push(`/a_${a}`)}else{var m=Ul(a,u,"composite");this.binders[a]=new Dl(l,s,u,c,r,m),n.push(`/z_${a}`)}else this.binders[a]=h?new Pl(l.value,s):new Cl(l.value,s,u,r),n.push(`/u_${a}`)}}this.cacheKey=n.sort().join("")}),[{key:"getMaxValue",value:function(e){var t=this.binders[e];return t instanceof zl||t instanceof Dl?t.maxValue:0}},{key:"populatePaintArrays",value:function(e,t,r,i,n,a,o){for(var s in this.binders){var l=this.binders[s];l.context=this.context,(l instanceof zl||l instanceof Dl||l instanceof Rl)&&l.populatePaintArray(e,t,r,i,n,a,o)}}},{key:"setConstantPatternPositions",value:function(e){for(var t in this.binders){var r=this.binders[t];r instanceof Pl&&r.setConstantPatternPositions(e)}}},{key:"updatePaintArrays",value:function(e,t,r,i,n,a,o,s){var l=this,u=!1,c=Object.keys(e),h=0!==c.length,f=h?c:t.uniqueIds;this.context.lut=n.lut;var d=function(){var c=l.binders[p];if(c.context=l.context,(c instanceof zl||c instanceof Dl||c instanceof Rl)&&(!0===c.expression.isStateDependent||!1===c.expression.isLightConstant)){var d=n.paint.get(p);c.expression=d.value;var m=function(){var r=e[v.toString()];t.eachPosition(v,(function(e,t,n){var l=i.feature(e);c.updatePaintArray(t,n,l,r,a,o,s)}))};for(var v of f)m();if(!h){var _=function(){var t=e[y.toString()];r.eachPosition(y,(function(e,r,n){var l=i.feature(e);c.updatePaintArray(r,n,l,t,a,o,s)}))};for(var y of r.uniqueIds)_()}u=!0}};for(var p in this.binders)d();return u}},{key:"defines",value:function(){var e=[];for(var t in this.binders){var r=this.binders[t];(r instanceof Cl||r instanceof Pl)&&e.push.apply(e,d(r.uniformNames.map((function(e){return`#define HAS_UNIFORM_${e}`}))))}return e}},{key:"getBinderAttributes",value:function(){var e=[];for(var t in this.binders){var r=this.binders[t];if(r instanceof zl||r instanceof Dl||r instanceof Rl)for(var i=0;i2&&void 0!==arguments[2]?arguments[2]:function(){return!0};for(var n of(p(this,e),this.programConfigurations={},t))this.programConfigurations[n.id]=new Ll(n,r,i);this.needsUpload=!1,this._featureMap=new dl,this._featureMapWithoutIds=new dl,this._bufferOffset=0,this._idlessCounter=0}),[{key:"populatePaintArrays",value:function(e,t,r,i,n,a,o,s){for(var l in this.programConfigurations)this.programConfigurations[l].populatePaintArrays(e,t,i,n,a,o,s);void 0!==t.id?this._featureMap.add(t.id,r,this._bufferOffset,e):(this._featureMapWithoutIds.add(this._idlessCounter,r,this._bufferOffset,e),this._idlessCounter+=1),this._bufferOffset=e,this.needsUpload=!0}},{key:"updatePaintArrays",value:function(e,t,r,i,n,a){for(var o of r)this.needsUpload=this.programConfigurations[o.id].updatePaintArrays(e,this._featureMap,this._featureMapWithoutIds,t,o,i,n,a||0)||this.needsUpload}},{key:"get",value:function(e){return this.programConfigurations[e]}},{key:"upload",value:function(e){if(this.needsUpload){for(var t in this.programConfigurations)this.programConfigurations[t].upload(e);this.needsUpload=!1}}},{key:"destroy",value:function(){for(var e in this.programConfigurations)this.programConfigurations[e].destroy()}}])})(),Bl={"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 Fl(e,t){return Bl[e]||[e.replace(`${t}-`,"").replace(/-/g,"_")]}var Nl={"line-pattern":{source:Ts,composite:Ts},"fill-pattern":{source:Ts,composite:Ts},"fill-extrusion-pattern":{source:Ts,composite:Ts},"line-dasharray":{source:Ms,composite:Ms}},Vl={color:{source:Gs,composite:ws},number:{source:Fs,composite:Gs}};function Ul(e,t,r){var i=Nl[e];return i&&i[r]||Vl[t][r]}ca(Cl,"ConstantBinder"),ca(Pl,"PatternConstantBinder"),ca(zl,"SourceExpressionBinder"),ca(Rl,"PatternCompositeBinder"),ca(Dl,"CompositeExpressionBinder"),ca(Ll,"ProgramConfiguration",{omit:["_buffers"]}),ca(Ol,"ProgramConfigurationSet");var jl=ii/Math.PI/2,Gl=64,ql=[Gl,32,16],Zl=-jl,$l=jl;function Hl(e,t,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:jl;return r=re(r),[e*Math.sin(r)*i,-t*i,e*Math.cos(r)*i]}function Wl(e,t,r){return Hl(Math.cos(re(e)),Math.sin(re(e)),t,r)}var Xl=6371008.8,Yl=2*Math.PI*Xl,Jl=(function(){function e(t,r){if(p(this,e),isNaN(t)||isNaN(r))throw new Error(`Invalid LngLat object: (${t}, ${r})`);if(this.lng=+t,this.lat=+r,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}return m(e,[{key:"wrap",value:function(){return new e(ce(this.lng,-180,180),this.lat)}},{key:"toArray",value:function(){return[this.lng,this.lat]}},{key:"toString",value:function(){return`LngLat(${this.lng}, ${this.lat})`}},{key:"distanceTo",value:function(e){var t=Math.PI/180,r=this.lat*t,i=e.lat*t,n=Math.sin(r)*Math.sin(i)+Math.cos(r)*Math.cos(i)*Math.cos((e.lng-this.lng)*t);return Xl*Math.acos(Math.min(n,1))}},{key:"toBounds",value:function(){var e=360*(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)/40075017,t=e/Math.cos(Math.PI/180*this.lat);return new Kl({lng:this.lng-t,lat:this.lat-e},{lng:this.lng+t,lat:this.lat+e})}},{key:"toEcef",value:function(e){return Wl(this.lat,this.lng,jl+e*jl/Xl)}}],[{key:"convert",value:function(t){if(t instanceof e)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new e(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new e(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: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}])})(),Kl=(function(){function e(t,r){if(p(this,e),t)if(r)this.setSouthWest(t).setNorthEast(r);else if(4===t.length){var i=t;this.setSouthWest([i[0],i[1]]).setNorthEast([i[2],i[3]])}else{var n=t;this.setSouthWest(n[0]).setNorthEast(n[1])}}return m(e,[{key:"setNorthEast",value:function(e){return this._ne=e instanceof Jl?new Jl(e.lng,e.lat):Jl.convert(e),this}},{key:"setSouthWest",value:function(e){return this._sw=e instanceof Jl?new Jl(e.lng,e.lat):Jl.convert(e),this}},{key:"extend",value:function(t){var r,i,n=this._sw,a=this._ne;if(t instanceof Jl)r=t,i=t;else{if(!(t instanceof e))return Array.isArray(t)?4===t.length||t.every(Array.isArray)?this.extend(e.convert(t)):this.extend(Jl.convert(t)):"object"==typeof t&&null!==t&&t.hasOwnProperty("lat")&&(t.hasOwnProperty("lon")||t.hasOwnProperty("lng"))?this.extend(Jl.convert(t)):this;if(r=t._sw,i=t._ne,!r||!i)return this}return n||a?(n.lng=Math.min(r.lng,n.lng),n.lat=Math.min(r.lat,n.lat),a.lng=Math.max(i.lng,a.lng),a.lat=Math.max(i.lat,a.lat)):(this._sw=new Jl(r.lng,r.lat),this._ne=new Jl(i.lng,i.lat)),this}},{key:"getCenter",value:function(){return new Jl((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}},{key:"getSouthWest",value:function(){return this._sw}},{key:"getNorthEast",value:function(){return this._ne}},{key:"getNorthWest",value:function(){return new Jl(this.getWest(),this.getNorth())}},{key:"getSouthEast",value:function(){return new Jl(this.getEast(),this.getSouth())}},{key:"getWest",value:function(){return this._sw.lng}},{key:"getSouth",value:function(){return this._sw.lat}},{key:"getEast",value:function(){return this._ne.lng}},{key:"getNorth",value:function(){return this._ne.lat}},{key:"toArray",value:function(){return[this._sw.toArray(),this._ne.toArray()]}},{key:"toString",value:function(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}},{key:"isEmpty",value:function(){return!(this._sw&&this._ne)}},{key:"contains",value:function(e){var t=Jl.convert(e),r=t.lng,i=t.lat,n=this._sw.lng<=r&&r<=this._ne.lng;return this._sw.lng>this._ne.lng&&(n=this._sw.lng>=r&&r>=this._ne.lng),this._sw.lat<=i&&i<=this._ne.lat&&n}}],[{key:"convert",value:function(t){if(t)return t instanceof e?t:new e(t)}}])})();function Ql(e){return Yl*Math.cos(e*Math.PI/180)}function eu(e){return(180+e)/360}function tu(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function ru(e,t){return e/Ql(t)}function iu(e){return 360*e-180}function nu(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function au(e,t){return e*Ql(nu(t))}var ou=85.051129;function su(e){return Math.cos(re(le(e,-85.051129,ou)))}function lu(e,t){var r=le(t,0,25.5),i=Math.pow(2,r);return su(e)*Yl/(512*i)}function uu(e){return 1/Math.cos(e*Math.PI/180)}function cu(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=Math.exp(Math.PI*(1-(e.y+t/ii)/(1<2&&void 0!==arguments[2]?arguments[2]:0;p(this,e),this.x=+t,this.y=+r,this.z=+i}return m(e,[{key:"toLngLat",value:function(){return new Jl(iu(this.x),nu(this.y))}},{key:"toAltitude",value:function(){return au(this.z,this.y)}},{key:"meterInMercatorCoordinateUnits",value:function(){return 1/Yl*uu(nu(this.y))}}],[{key:"fromLngLat",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=Jl.convert(t);return new e(eu(i.lng),tu(i.lat),ru(r,i.lat))}}])})();function fu(e,t,r,i,n,a,o,s,l){var u=(t+i)/2,c=(r+n)/2,h=new K(u,c);s(h),(function(e,t,r,i,n,a){var o=r-n,s=i-a;return Math.abs((i-t)*o-(r-e)*s)/Math.hypot(o,s)})(h.x,h.y,a.x,a.y,o.x,o.y)>=l?(fu(e,t,r,u,c,a,h,s,l),fu(e,u,c,i,n,h,o,s,l)):e.push(o)}function du(e,t,r){var i=e[0],n=i.x,a=i.y;t(i);for(var o=[i],s=1;se.x+1||ie.y+1)&&we("Geometry exceeds allowed extent, reduce your vector tile buffer size"),e}function gu(e,t,r){var i=e.loadGeometry(),n=e.extent,a=ii/n;if(t&&r&&r.projection.isReprojectedInTileSpace)for(var o=1<=n||p.y<0||p.y>=n||(h(p),d.push(p));i[f]=d}for(var m of i)for(var v of m)yu(v,a);return i}function xu(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?gu(e):[]}}function bu(e,t,r,i,n){e.emplaceBack(2*t+(i+1)/2,2*r+(n+1)/2)}function wu(e,t,r){var i=16384;e.emplaceBack(t.x,t.y,t.z,r[0]*i,r[1]*i,r[2]*i)}var ku,Tu,Mu=(function(){return m((function e(t){p(this,e),this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((function(e){return e.fqid})),this.index=t.index,this.hasPattern=!1,this.projection=t.projection,this.layoutVertexArray=new _s,this.indexArray=new Ls,this.segments=new ul,this.programConfigurations=new Ol(t.layers,{zoom:t.zoom,lut:t.lut}),this.stateDependentLayerIds=this.layers.filter((function(e){return e.isStateDependent()})).map((function(e){return e.id}))}),[{key:"updateFootprints",value:function(e,t){}},{key:"populate",value:function(e,t,r,i){var n=this.layers[0],a=[],o=null;for(var s of("circle"===n.type&&(o=n.layout.get("circle-sort-key")),e)){var l=s.feature,u=s.id,c=s.index,h=s.sourceLayerIndex,f=this.layers[0]._featureFilter.needGeometry,d=xu(l,f);if(this.layers[0]._featureFilter.filter(new zo(this.zoom),d,r)){var p=o?o.evaluate(d,{},r):void 0,m={id:u,properties:l.properties,type:l.type,sourceLayerIndex:h,index:c,geometry:f?d.geometry:gu(l,r,i),patterns:{},sortKey:p};a.push(m)}}o&&a.sort((function(e,t){return e.sortKey-t.sortKey}));var v=null;for(var _ of("globe"===i.projection.name&&(this.globeExtVertexArray=new Ss,v=i.projection),a)){var y=_.geometry,g=_.index,x=_.sourceLayerIndex,b=e[g].feature;this.addFeature(_,y,g,t.availableImages,r,v,t.brightness),t.featureIndex.insert(b,y,g,x,this.index)}}},{key:"update",value:function(e,t,r,i,n){var a=0!==Object.keys(e).length;a&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(e,t,a?this.stateDependentLayers:this.layers,r,i,n)}},{key:"isEmpty",value:function(){return 0===this.layoutVertexArray.length}},{key:"uploadPending",value:function(){return!this.uploaded||this.programConfigurations.needsUpload}},{key:"upload",value:function(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,sl.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,ll.members))),this.programConfigurations.upload(e),this.uploaded=!0}},{key:"destroy",value:function(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}},{key:"addFeature",value:function(e,t,r,i,n,a,o){for(var s of t)for(var l of s){var u=l.x,c=l.y;if(!(u<0||u>=ii||c<0||c>=ii)){if(a){var h=a.projectTilePoint(u,c,n),f=a.upVector(n,u,c),d=this.globeExtVertexArray;wu(d,h,f),wu(d,h,f),wu(d,h,f),wu(d,h,f)}var p=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),m=p.vertexLength;bu(this.layoutVertexArray,u,c,-1,-1),bu(this.layoutVertexArray,u,c,1,-1),bu(this.layoutVertexArray,u,c,1,1),bu(this.layoutVertexArray,u,c,-1,1),this.indexArray.emplaceBack(m,m+1,m+2),this.indexArray.emplaceBack(m,m+2,m+3),p.vertexLength+=4,p.primitiveLength+=2}}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,r,{},i,n,o)}}])})();function Su(e,t){for(var r=0;r1){if(Cu(e,t))return!0;for(var i=0;i1?r:r.sub(t)._mult(n)._add(t))}function Ru(e,t){for(var r,i,n,a=!1,o=0;ot.y!=n.y>t.y&&t.x<(n.x-i.x)*(t.y-i.y)/(n.y-i.y)+i.x&&(a=!a);return a}function Lu(e,t){for(var r=!1,i=0,n=e.length-1;it.y!=o.y>t.y&&t.x<(o.x-a.x)*(t.y-a.y)/(o.y-a.y)+a.x&&(r=!r)}return r}function Ou(e,t,r,i,n){for(var a of e)if(t<=a.x&&r<=a.y&&i>=a.x&&n>=a.y)return!0;var o=[new K(t,r),new K(t,n),new K(i,n),new K(i,r)];if(e.length>2)for(var s of o)if(Lu(e,s))return!0;for(var l=0;ln.x&&t.x>n.x||e.yn.y&&t.y>n.y)return!1;var a=ke(e,t,r[0]);return a!==ke(e,t,r[1])||a!==ke(e,t,r[2])||a!==ke(e,t,r[3])}function Fu(e,t,r,i,n,a){var o=t.y-e.y,s=e.x-t.x;if(a=a||0){var l=o*o+s*s;if(0===l)return!0;var u=Math.sqrt(l);o/=u,s/=u}return!((r.x-e.x)*o+(r.y-e.y)*s-a<0||(i.x-e.x)*o+(i.y-e.y)*s-a<0||(n.x-e.x)*o+(n.y-e.y)*s-a<0)}function Nu(e,t,r,i,n,a,o){return!(Fu(e,t,i,n,a,o)||Fu(t,r,i,n,a,o)||Fu(r,e,i,n,a,o)||Fu(i,n,e,t,r,o)||Fu(n,a,e,t,r,o)||Fu(a,i,e,t,r,o))}function Vu(e,t,r){var i=t.paint.get(e).value;return"constant"===i.kind?i.value:r.programConfigurations.get(t.id).getMaxValue(e)}function Uu(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function ju(e,t,r,i,n){if(!t[0]&&!t[1])return e;var a=K.convert(t)._mult(n);"viewport"===r&&a._rotate(-i);for(var o=[],s=0;s0;a--)n+=(t&(i=1<this.canonical.z?new e(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new e(t,this.wrap,t,this.canonical.x>>r,this.canonical.y>>r)}},{key:"calculateScaledKey",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(this.overscaledZ===e&&t)return this.key;if(e>this.canonical.z)return Yu(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y);var r=this.canonical.z-e;return Yu(this.wrap*+t,e,e,this.canonical.x>>r,this.canonical.y>>r)}},{key:"isChildOf",value:function(e){if(e.wrap!==this.wrap)return!1;var t=this.canonical.z-e.canonical.z;return 0===e.overscaledZ||e.overscaledZ>t&&e.canonical.y===this.canonical.y>>t}},{key:"children",value:function(t){if(this.overscaledZ>=t)return[new e(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];var r=this.canonical.z+1,i=2*this.canonical.x,n=2*this.canonical.y;return[new e(r,this.wrap,r,i,n),new e(r,this.wrap,r,i+1,n),new e(r,this.wrap,r,i,n+1),new e(r,this.wrap,r,i+1,n+1)]}},{key:"isLessThan",value:function(e){return this.wrape.wrap)&&(this.overscaledZe.overscaledZ)&&(this.canonical.xe.canonical.x)&&this.canonical.y=0;if(0===a)return 0;a!==t.length&&(r=!1)}return r?2:1}function ac(e,t){for(var r of e.projections){var i=ic(t,e.points[0],r.axis);if(r.projection[1]i[1])return 0}return 1}function oc(e,t){for(var r=0,i=[0,0,0,0],n=0;n=0&&r++;return r}var sc=(function(){function e(t,r){for(var i of(p(this,e),this.points=t||new Array(8).fill([0,0,0]),this.planes=r||new Array(6).fill([0,0,0,0]),this.bounds=lc.fromPoints(this.points),this.projections=[],this.frustumEdges=[W.vec3.sub([],this.points[2],this.points[3]),W.vec3.sub([],this.points[0],this.points[3]),W.vec3.sub([],this.points[4],this.points[0]),W.vec3.sub([],this.points[5],this.points[1]),W.vec3.sub([],this.points[6],this.points[2]),W.vec3.sub([],this.points[7],this.points[3])],this.frustumEdges)){var n=[0,-i[2],i[1]],a=[i[2],0,-i[0]];this.projections.push({axis:n,projection:ic(this.points,this.points[0],n)}),this.projections.push({axis:a,projection:ic(this.points,this.points[0],a)})}}return m(e,[{key:"intersectsPrecise",value:function(e,t,r){for(var i=0;ic[1]||c[0]>u[1])return 0}}return 1}},{key:"containsPoint",value:function(e){for(var t of this.planes){var r=t[3];if(W.vec3.dot([t[0],t[1],t[2]],e)+r<0)return!1}return!0}}],[{key:"fromInvProjectionMatrix",value:function(t,r,i,n){for(var a=Math.pow(2,i),o=[[-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((function(e){var i=W.vec4.transformMat4([],e,t),o=1/i[3]/r*a;return W.vec4.mul(i,i,[o,o,n?1/i[3]:o,o])})),s=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((function(e){var t=W.vec3.sub([],o[e[0]],o[e[1]]),r=W.vec3.sub([],o[e[2]],o[e[1]]),i=W.vec3.normalize([],W.vec3.cross([],t,r)),n=-W.vec3.dot(i,o[e[1]]);return i.concat(n)})),l=[],u=0;ue.max[t]||e.min[t]>this.max[t])return!1;return!0}},{key:"intersectsAabbXY",value:function(e){return!(this.min[0]>e.max[0]||e.min[0]>this.max[0]||this.min[1]>e.max[1]||e.min[1]>this.max[1])}},{key:"encapsulate",value:function(e){for(var t=0;t<3;t++)this.min[t]=Math.min(this.min[t],e.min[t]),this.max[t]=Math.max(this.max[t],e.max[t])}},{key:"encapsulatePoint",value:function(e){for(var t=0;t<3;t++)this.min[t]=Math.min(this.min[t],e[t]),this.max[t]=Math.max(this.max[t],e[t])}},{key:"closestPoint",value:function(e){return[Math.max(Math.min(this.max[0],e[0]),this.min[0]),Math.max(Math.min(this.max[1],e[1]),this.min[1]),Math.max(Math.min(this.max[2],e[2]),this.min[2])]}}],[{key:"fromPoints",value:function(t){var r=[1/0,1/0,1/0],i=[-1/0,-1/0,-1/0];for(var n of t)W.vec3.min(r,r,n),W.vec3.max(i,i,n);return new e(r,i)}},{key:"fromTileIdAndHeight",value:function(t,r,i){var n=1<3&&void 0!==arguments[3])||arguments[3],n=W.vec3.scale([],e._camera.position,e.worldSize),a=[t,r,1,1];W.vec4.transformMat4(a,a,e.pixelMatrixInverse),W.vec4.scale(a,a,1/a[3]);var o=W.vec3.sub([],a,n),s=W.vec3.normalize([],o),l=e.globeMatrix,u=[l[12],l[13],l[14]],c=W.vec3.sub([],u,n),h=W.vec3.length(c),f=W.vec3.normalize([],c),d=e.worldSize/(2*Math.PI),p=W.vec3.dot(f,s),m=Math.asin(d/h);if(m1?null:(function(e,t,r,i){var n=Math.sin(r);return e*(Math.sin((1-i)*r)/n)+t*(Math.sin(i*r)/n)})(e.a[t],e.b[t],e.angle,le(r,0,1))+e.center[t];var r}function pc(e){if(e.z<=1)return cc[e.z+2*e.y+e.x];var t=gc(yc(e));return lc.fromPoints(t)}function mc(e,t,r){return W.vec3.scale(e,e,1-r),W.vec3.scaleAndAdd(e,e,t,r)}function vc(e,t,r){for(var i of e)W.vec3.transformMat4(i,i,t),W.vec3.scale(i,i,r)}function _c(e,t,r,i){var n=t/e.worldSize,a=e.globeMatrix;if(r.z<=1){var o=pc(r).getCorners();return vc(o,a,n),lc.fromPoints(o)}var s=yc(r,i),l=gc(s,jl+uc(e._tileCoverLift));vc(l,a,n);var u=Number.MAX_VALUE,c=[-u,-u,-u],h=[u,u,u];if(s.contains(e.center)){for(var f of l)W.vec3.min(h,h,f),W.vec3.max(c,c,f);c[2]=0;var d=e.point,p=[d.x*n,d.y*n,0];return W.vec3.min(h,h,p),W.vec3.max(c,c,p),new lc(h,c)}if(e._tileCoverLift>0){for(var m of l)W.vec3.min(h,h,m),W.vec3.max(c,c,m);return new lc(h,c)}var v=[a[12]*n,a[13]*n,a[14]*n],_=s.getCenter(),y=le(e.center.lat,-85.051129,ou),g=le(_.lat,-85.051129,ou),x=eu(e.center.lng),b=tu(y),w=x-eu(_.lng),k=b-tu(g);w>.5?w-=1:w<-.5&&(w+=1);var T=0;if(Math.abs(w)>Math.abs(k))T=w>=0?1:3;else{T=k>=0?0:2;var M=[a[4]*n,a[5]*n,a[6]*n],S=-Math.sin(re(k>=0?s.getSouth():s.getNorth()))*jl;W.vec3.scaleAndAdd(v,v,M,S)}var E=l[T],I=l[(T+1)%4],A=new fc(E,I,v),C=[dc(A,0)||E[0],dc(A,1)||E[1],dc(A,2)||E[2]],P=Ic(e.zoom);if(P>0){for(var z=(function(e,t,r,i,n){var a=e.x,o=e.y,s=1/(1<.5?f=-1:d<-.5&&(f=1),c=(c*t-(n*=t))*r+n,[[l=((l+f)*t-(i*=t))*r+i,h=(h*t-n)*r+n,0],[u=((u+f)*t-i)*r+i,h,0],[u,c,0],[l,c,0]]})(r,t,e._pixelsPerMercatorPixel,x,b),D=0;D1&&void 0!==arguments[1]&&arguments[1],a=1/(1<1&&void 0!==arguments[1]?arguments[1]:jl,r=re(e.getNorth()),i=re(e.getSouth()),n=Math.cos(r),a=Math.cos(i),o=Math.sin(r),s=Math.sin(i),l=e.getWest(),u=e.getEast();return[Hl(a,s,l,t),Hl(a,s,u,t),Hl(n,o,u,t),Hl(n,o,l,t)]}function xc(e,t,r,i){var n=1<Math.PI/2*1.01}var Pc=re(85),zc=Math.cos(Pc),Dc=Math.sin(Pc),Rc=W.mat4.create(),Lc=function(e){var t=[];return"map"===e.paint.get("circle-pitch-alignment")&&t.push("PITCH_WITH_MAP"),"map"===e.paint.get("circle-pitch-scale")&&t.push("SCALE_WITH_MAP"),t};function Oc(e,t,r,i,n,a,o,s,l){if(a&&e.queryGeometry.isAboveHorizon)return!1;a&&(l*=e.pixelToTileUnitsFactor);var u=e.tileID.canonical,c=r.projection.upVectorScale(u,r.center.lat,r.worldSize).metersToTile;for(var h of t){var f,d=function(){var t=p.add(s),h=n&&r.elevation?r.elevation.exaggeration()*n.getElevationAt(t.x,t.y,!0):0,f=r.projection.projectTilePoint(t.x,t.y,u);if(h>0){var d=r.projection.upVector(u,t.x,t.y);f.x+=d[0]*c*h,f.y+=d[1]*c*h,f.z+=d[2]*c*h}var m=a?t:Bc(f.x,f.y,f.z,i),v=a?e.tilespaceRays.map((function(e){return Vc(e,h)})):e.queryGeometry.screenGeometry,_=W.vec4.transformMat4([],[f.x,f.y,f.z,1],i);if(!o&&a?l*=_[3]/r.cameraToCenterDistance:o&&!a&&(l*=r.cameraToCenterDistance/_[3]),a){var y=nu((p.y/ii+u.y)/(1<e.width||n.height>e.height||r.x>e.width-n.width||r.y>e.height-n.height)throw new RangeError("out of range source coordinates for image copy");if(n.width>t.width||n.height>t.height||i.x>t.width-n.width||i.y>t.height-n.height)throw new RangeError("out of range destination coordinates for image copy");for(var l=e.data,u=t.data,c=4===a&&s,h=0;h2&&void 0!==arguments[2]?arguments[2]:2,o=t&&t.length,s=o?t[0]*a:e.length,l=th(e,0,s,a,!0),u=[];if(!l||l.next===l.prev)return u;if(o&&(l=(function(e,t,r,i){for(var n=[],a=0,o=t.length;a80*a){r=1/0,i=1/0;for(var c=-1/0,h=-1/0,f=a;fc&&(c=d),p>h&&(h=p)}n=0!==(n=Math.max(c-r,h-i))?32767/n:0}return ih(l,u,a,r,i,n,0),u}function th(e,t,r,i,n){var a;if(n===(function(e,t,r,i){for(var n=0,a=t,o=r-i;a0)for(var o=t;o=t;s-=i)a=wh(s/i|0,e[s],e[s+1],a);return a&&vh(a,a.next)&&(kh(a),a=a.next),a}function rh(e,t){if(!e)return e;t||(t=e);var r,i=e;do{if(r=!1,i.steiner||!vh(i,i.next)&&0!==mh(i.prev,i,i.next))i=i.next;else{if(kh(i),(i=t=i.prev)===i.next)break;r=!0}}while(r||i!==t);return t}function ih(e,t,r,i,n,a,o){if(e){!o&&a&&(function(e,t,r,i){var n=e;do{0===n.z&&(n.z=hh(n.x,n.y,t,r,i)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==e);n.prevZ.nextZ=null,n.prevZ=null,(function(e){var t,r=1;do{var i=void 0,n=e;e=null;var a=null;for(t=0;n;){t++;for(var o=n,s=0,l=0;l0||u>0&&o;)0!==s&&(0===u||!o||n.z<=o.z)?(i=n,n=n.nextZ,s--):(i=o,o=o.nextZ,u--),a?a.nextZ=i:e=i,i.prevZ=a,a=i;n=o}a.nextZ=null,r*=2}while(t>1)})(n)})(e,i,n,a);for(var s=e;e.prev!==e.next;){var l=e.prev,u=e.next;if(a?ah(e,i,n,a):nh(e))t.push(l.i,e.i,u.i),kh(e),e=u.next,s=u.next;else if((e=u)===s){o?1===o?ih(e=oh(rh(e),t),t,r,i,n,a,2):2===o&&sh(e,t,r,i,n,a):ih(rh(e),t,r,i,n,a,1);break}}}}function nh(e){var t=e.prev,r=e,i=e.next;if(mh(t,r,i)>=0)return!1;for(var n=t.x,a=r.x,o=i.x,s=t.y,l=r.y,u=i.y,c=na?n>o?n:o:a>o?a:o,d=s>l?s>u?s:u:l>u?l:u,p=i.next;p!==t;){if(p.x>=c&&p.x<=f&&p.y>=h&&p.y<=d&&dh(n,s,a,l,o,u,p.x,p.y)&&mh(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function ah(e,t,r,i){var n=e.prev,a=e,o=e.next;if(mh(n,a,o)>=0)return!1;for(var s=n.x,l=a.x,u=o.x,c=n.y,h=a.y,f=o.y,d=sl?s>u?s:u:l>u?l:u,v=c>h?c>f?c:f:h>f?h:f,_=hh(d,p,t,r,i),y=hh(m,v,t,r,i),g=e.prevZ,x=e.nextZ;g&&g.z>=_&&x&&x.z<=y;){if(g.x>=d&&g.x<=m&&g.y>=p&&g.y<=v&&g!==n&&g!==o&&dh(s,c,l,h,u,f,g.x,g.y)&&mh(g.prev,g,g.next)>=0)return!1;if(g=g.prevZ,x.x>=d&&x.x<=m&&x.y>=p&&x.y<=v&&x!==n&&x!==o&&dh(s,c,l,h,u,f,x.x,x.y)&&mh(x.prev,x,x.next)>=0)return!1;x=x.nextZ}for(;g&&g.z>=_;){if(g.x>=d&&g.x<=m&&g.y>=p&&g.y<=v&&g!==n&&g!==o&&dh(s,c,l,h,u,f,g.x,g.y)&&mh(g.prev,g,g.next)>=0)return!1;g=g.prevZ}for(;x&&x.z<=y;){if(x.x>=d&&x.x<=m&&x.y>=p&&x.y<=v&&x!==n&&x!==o&&dh(s,c,l,h,u,f,x.x,x.y)&&mh(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function oh(e,t){var r=e;do{var i=r.prev,n=r.next.next;!vh(i,n)&&_h(i,r,r.next,n)&&xh(i,n)&&xh(n,i)&&(t.push(i.i,r.i,n.i),kh(r),kh(r.next),r=e=n),r=r.next}while(r!==e);return rh(r)}function sh(e,t,r,i,n,a){var o=e;do{for(var s=o.next.next;s!==o.prev;){if(o.i!==s.i&&ph(o,s)){var l=bh(o,s);return o=rh(o,o.next),l=rh(l,l.next),ih(o,t,r,i,n,a,0),void ih(l,t,r,i,n,a,0)}s=s.next}o=o.next}while(o!==e)}function lh(e,t){return e.x-t.x}function uh(e,t){var r=(function(e,t){var r,i=t,n=e.x,a=e.y,o=-1/0;do{if(a<=i.y&&a>=i.next.y&&i.next.y!==i.y){var s=i.x+(a-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(s<=n&&s>o&&(o=s,r=i.x=i.x&&i.x>=u&&n!==i.x&&dh(ar.x||i.x===r.x&&ch(r,i)))&&(r=i,h=f)}i=i.next}while(i!==l);return r})(e,t);if(!r)return t;var i=bh(r,e);return rh(i,i.next),rh(r,r.next)}function ch(e,t){return mh(e.prev,e,t.prev)<0&&mh(t.next,e,e.next)<0}function hh(e,t,r,i,n){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*n|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*n|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function fh(e){var t=e,r=e;do{(t.x=(e-o)*(a-s)&&(e-o)*(i-s)>=(r-o)*(t-s)&&(r-o)*(a-s)>=(n-o)*(i-s)}function ph(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!(function(e,t){var r=e;do{if(r.i!==e.i&&r.next.i!==e.i&&r.i!==t.i&&r.next.i!==t.i&&_h(r,r.next,e,t))return!0;r=r.next}while(r!==e);return!1})(e,t)&&(xh(e,t)&&xh(t,e)&&(function(e,t){var r=e,i=!1,n=(e.x+t.x)/2,a=(e.y+t.y)/2;do{r.y>a!=r.next.y>a&&r.next.y!==r.y&&n<(r.next.x-r.x)*(a-r.y)/(r.next.y-r.y)+r.x&&(i=!i),r=r.next}while(r!==e);return i})(e,t)&&(mh(e.prev,e,t.prev)||mh(e,t.prev,t))||vh(e,t)&&mh(e.prev,e,e.next)>0&&mh(t.prev,t,t.next)>0)}function mh(e,t,r){return(t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function vh(e,t){return e.x===t.x&&e.y===t.y}function _h(e,t,r,i){var n=gh(mh(e,t,r)),a=gh(mh(e,t,i)),o=gh(mh(r,i,e)),s=gh(mh(r,i,t));return n!==a&&o!==s||!(0!==n||!yh(e,r,t))||!(0!==a||!yh(e,i,t))||!(0!==o||!yh(r,e,i))||!(0!==s||!yh(r,t,i))}function yh(e,t,r){return t.x<=Math.max(e.x,r.x)&&t.x>=Math.min(e.x,r.x)&&t.y<=Math.max(e.y,r.y)&&t.y>=Math.min(e.y,r.y)}function gh(e){return e>0?1:e<0?-1:0}function xh(e,t){return mh(e.prev,e,e.next)<0?mh(e,t,e.next)>=0&&mh(e,e.prev,t)>=0:mh(e,t,e.prev)<0||mh(e,e.next,t)<0}function bh(e,t){var r=Th(e.i,e.x,e.y),i=Th(t.i,t.x,t.y),n=e.next,a=t.prev;return e.next=t,t.prev=e,r.next=n,n.prev=r,i.next=r,r.prev=i,a.next=i,i.prev=a,i}function wh(e,t,r,i){var n=Th(e,t,r);return i?(n.next=i.next,n.prev=i,i.next.prev=n,i.next=n):(n.prev=n,n.next=n),n}function kh(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Th(e,t,r){return{i:e,x:t,y:r,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Mh(e,t){var r=e.length;if(r<=1)return[e];for(var i,n,a=[],o=0;o1)for(var l=0;l5&&void 0!==arguments[5]?arguments[5]:[],o=arguments.length>6?arguments[6]:void 0;for(var s of Mh(t,500)){var l=0;for(var u of s)l+=u.length;var c=this.segments.prepareSegment(l,this.layoutVertexArray,this.indexArray),h=c.vertexLength,f=[],d=[];for(var p of s)if(0!==p.length){p!==s[0]&&d.push(f.length/2);var m=this.segments2.prepareSegment(p.length,this.layoutVertexArray,this.indexArray2),v=m.vertexLength;this.layoutVertexArray.emplaceBack(p[0].x,p[0].y),this.indexArray2.emplaceBack(v+p.length-1,v),f.push(p[0].x),f.push(p[0].y);for(var _=1;_this.max.x||this.min.x>e.x||e.y>this.max.y||this.min.y>e.y)){var r=Lh(e.x-this.min.x,this.xScale,this.cellsX),i=Lh(e.y-this.min.y,this.yScale,this.cellsY),n=this.cells[i*this.cellsX+r];if(n){this._lazyInitLookup();for(var a=0;athis.max.x||this.min.x>t.x||e.y>this.max.y||this.min.y>t.y)){this._lazyInitLookup();for(var i=Lh(e.x-this.min.x,this.xScale,this.cellsX),n=Lh(t.x-this.min.x,this.xScale,this.cellsX),a=Lh(e.y-this.min.y,this.yScale,this.cellsY),o=Lh(t.y-this.min.y,this.yScale,this.cellsY),s=a;s<=o;s++)for(var l=i;l<=n;l++){var u=this.cells[s*this.cellsX+l];if(u)for(var c=0;c>3}if(a--,1===n||2===n)o+=t.readSVarint(),s+=t.readSVarint(),1===n&&(r&&l.push(r),r=[]),r.push(new e(o,s));else{if(7!==n)throw new Error("unknown command "+n);r&&r.push(r[0].clone())}}return r&&l.push(r),l},t.prototype.bbox=function(){var e=this._pbf;e.pos=this._geometry;for(var t=e.readVarint()+e.pos,r=1,i=0,n=0,a=0,o=1/0,s=-1/0,l=1/0,u=-1/0;e.pos>3}if(i--,1===r||2===r)(n+=e.readSVarint())s&&(s=n),(a+=e.readSVarint())u&&(u=a);else if(7!==r)throw new Error("unknown command "+r)}return[o,l,s,u]},t.prototype.toGeoJSON=function(e,r,n){var a,o,s=this.extent*Math.pow(2,n),l=this.extent*e,u=this.extent*r,c=this.loadGeometry(),h=t.types[this.type];function f(e){for(var t=0;t>3;t=1===i?e.readString():2===i?e.readFloat():3===i?e.readDouble():4===i?e.readVarint64():5===i?e.readVarint():6===i?e.readSVarint():7===i?e.readBoolean():null}return t})(r))}return Nh=t,t.prototype.feature=function(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];var r=this._pbf.readVarint()+this._pbf.pos;return new e(this._pbf,r,this.extent,this._keys,this._values)},Nh}function ef(){return Gh||(Gh=1,Jh.VectorTile=(function(){if(jh)return Uh;jh=1;var e=Qh();function t(t,r,i){if(3===t){var n=new e(i,i.readVarint()+i.pos);n.length&&(r[n.name]=n)}}return Uh=function(e,r){this.layers=e.readFields(t,{},r)},Uh})(),Jh.VectorTileFeature=Kh(),Jh.VectorTileLayer=Qh()),Jh}var tf=ef(),rf=(function(e){function t(e,r,i){var n;return p(this,t),(n=T(this,t,[e,r])).z=i,n}return y(t,e),m(t)})(K),nf=(function(e){function t(e,r,i,n){var a;return p(this,t),(a=T(this,t,[e,r,i])).w=n,a}return y(t,e),m(t)})(rf);function af(e,t,r,i){var n=[],a=0===i?function(e,t,r,i,n,a){e.push(new K(a,r+(a-t)/(i-t)*(n-r)))}:function(e,t,r,i,n,a){e.push(new K(t+(a-r)/(n-r)*(i-t),a))};for(var o of e){var s=[];for(var l of o)if(!(l.length<=2)){for(var u=[],c=0;ct&&a(u,h,f,d,p,t):m>r?v=t&&a(u,h,f,d,p,t),v>r&&m<=r&&a(u,h,f,d,p,r)}var _=l[l.length-1],y=0===i?_.x:_.y;y>=t&&y<=r&&u.push(_),u.length&&(_=u[u.length-1],u[0].x===_.x&&u[0].y===_.y||u.push(u[0]),s.push(u))}s.length&&n.push(s)}return n}function of(e,t,r,i){var n="x"===r?"y":"x",a=(i-e[r])/(t[r]-e[r]);e[n]=e[n]+(t[n]-e[n])*a,e[r]=i,e.hasOwnProperty("z")&&(e.z=Ft(e.z,t.z,a)),e.hasOwnProperty("w")&&(e.w=Ft(e.w,t.w,a))}function sf(e,t,r,i){var n=r,a=i;for(var o of["x","y"]){var s=e,l=t;s[o]>=l[o]&&(s=t,l=e),s[o]n&&of(s,l,o,n),s[o]a&&of(l,s,o,a)}}var lf=Number.MAX_SAFE_INTEGER;function uf(e,t,r,i){return e.ordert.max.x||e.max.xt.max.y||e.max.y0&&(i.length>1&&r.push(i),i=[])}return i.length>1&&r.push(i),r}var wf=tf.VectorTileFeature.types,kf=["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"],Tf=["fill-extrusion-flood-light-ground-radius"],Mf=Math.pow(2,13),Sf=Math.pow(2,15)-1,Ef=new K(0,1),If=2147483648;function Af(e,t,r,i,n,a,o,s){e.emplaceBack((t<<1)+o,(r<<1)+a,(Math.floor(i*Mf)<<1)+n,Math.round(s))}function Cf(e,t,r){e.emplaceBack(t.x*ii,t.y*ii,r?1:0)}function Pf(e,t,r,i,n,a){e.emplaceBack(t.x,t.y,(r.x<<1)+i,(r.y<<1)+n,a)}function zf(e,t,r){var i=16384;e.emplaceBack(t.x,t.y,t.z,r[0]*i,r[1]*i,r[2]*i)}var Df=m((function e(){p(this,e),this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0})),Rf=(function(){return m((function e(){p(this,e),this.centroidXY=new K(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 K(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new K(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0}),[{key:"span",value:function(){return new K(this.max.x-this.min.x,this.max.y-this.min.y)}}])})(),Lf=(function(){return m((function e(){p(this,e),this.acc=new K(0,0),this.accCount=0,this.centroidDataIndex=0}),[{key:"startRing",value:function(e,t){e.min.x===Number.MAX_VALUE&&(e.min.x=e.max.x=t.x,e.min.y=e.max.y=t.y)}},{key:"appendEdge",value:function(e,t,r){this.accCount++,this.acc._add(t);var i=!!this.borders;t.xe.max.x&&(e.max.x=t.x,i=!0),t.ye.max.y&&(e.max.y=t.y,i=!0),((0===t.x||t.x===ii)&&t.x===r.x)!=((0===t.y||t.y===ii)&&t.y===r.y)&&this.processBorderOverlap(t,r),i&&this.checkBorderIntersection(t,r)}},{key:"checkBorderIntersection",value:function(e,t){t.x<0!=e.x<0&&this.addBorderIntersection(0,Ft(t.y,e.y,(0-t.x)/(e.x-t.x))),t.x>ii!=e.x>ii&&this.addBorderIntersection(1,Ft(t.y,e.y,(ii-t.x)/(e.x-t.x))),t.y<0!=e.y<0&&this.addBorderIntersection(2,Ft(t.x,e.x,(0-t.y)/(e.y-t.y))),t.y>ii!=e.y>ii&&this.addBorderIntersection(3,Ft(t.x,e.x,(ii-t.y)/(e.y-t.y)))}},{key:"addBorderIntersection",value:function(e,t){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);var r=this.borders[e];tr[1]&&(r[1]=t)}},{key:"processBorderOverlap",value:function(e,t){if(e.x===t.x){if(e.y===t.y)return;var r=0===e.x?0:1;this.addBorderIntersection(r,t.y),this.addBorderIntersection(r,e.y)}else{var i=0===e.y?2:3;this.addBorderIntersection(i,t.x),this.addBorderIntersection(i,e.x)}}},{key:"centroid",value:function(){return 0===this.accCount?new K(0,0):new K(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}},{key:"intersectsCount",value:function(){return this.borders?this.borders.reduce((function(e,t){return e+ +(t[0]!==Number.MAX_VALUE)}),0):0}}])})();function Of(e,t){var r,i,n,a=e.add(t)._unit(),o=le(e.x*a.x+e.y*a.y,-1,1);return n=Math.acos(o),Math.min(4,Math.max(-4,Math.tan(n)))/4*Sf*((r=e).x*(i=t).y-r.y*i.x<0?-1:1)}var Bf=[function(e){return e.x<0},function(e){return e.x>ii},function(e){return e.y<0},function(e){return e.y>ii}];function Ff(e,t,r,i){var n=[4];if(0===i)return n;r._mult(i);for(var a=e.sub(r),o=t.sub(r),s=[e,t,a,o],l=0;l<4;l++)for(var u of s)if(Bf[l](u)){n.push(l);break}return n}var Nf,Vf,Uf=(function(){return m((function e(t){p(this,e),this.vertexArray=new xs,this.indexArray=new Ls,this.programConfigurations=new Ol(t.layers,{zoom:t.zoom,lut:t.lut},(function(e){return Tf.includes(e)})),this._segments=new ul,this.hiddenByLandmarkVertexArray=new Hs,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new ul}),[{key:"getDefaultSegment",value:function(){return this.regionSegments[4]}},{key:"hasData",value:function(){return 0!==this.vertexArray.length}},{key:"addData",value:function(e,t,r){var i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],n=e.length;if(n>2){var a,o=Math.max(0,this._segments.get().length-1),s=this._segments._prepareSegment(4*n,this.vertexArray.length,2*this._segmentToGroundQuads[o].length);o!==this._segments.get().length-1&&(o++,this._segmentToGroundQuads[o]=[],this._segmentToRegionTriCounts[o]=[0,0,0,0,0]);var l=e[0],u=e[1];a=Of(l.sub(e[n-1])._perp()._unit(),u.sub(l)._perp()._unit());for(var c=0;c0?this.hiddenByLandmarkVertexBuffer=e.createVertexBuffer(this.hiddenByLandmarkVertexArray,Wh.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1)}},{key:"destroy",value:function(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(var e=0;e<=4;e++){var t=this.regionSegments[e];t&&t.destroy()}}}}])})(),jf=(function(){return m((function e(t){p(this,e),this.zoom=t.zoom,this.canonical=t.canonical,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((function(e){return e.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 Ls,this.footprintVertices=new _s,this.footprintSegments=[],this.layoutVertexArray=new gs,this.centroidVertexArray=new nl,this.wallVertexArray=new ol,this.indexArray=new Ls,this.programConfigurations=new Ol(t.layers,{zoom:t.zoom,lut:t.lut},(function(e){return kf.includes(e)})),this.segments=new ul,this.stateDependentLayerIds=this.layers.filter((function(e){return e.isStateDependent()})).map((function(e){return e.id})),this.groundEffect=new Uf(t),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[]}),[{key:"updateFootprints",value:function(e,t){}},{key:"populate",value:function(e,t,r,i){for(var n of(this.features=[],this.hasPattern=Eh("fill-extrusion",this.layers,t),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=cu(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),e)){var a=n.feature,o=n.id,s=n.index,l=n.sourceLayerIndex,u=this.layers[0]._featureFilter.needGeometry,c=xu(a,u);if(this.layers[0]._featureFilter.filter(new zo(this.zoom),c,r)){var h={id:o,sourceLayerIndex:l,index:s,geometry:u?c.geometry:gu(a,r,i),properties:a.properties,type:a.type,patterns:{}},f=this.layoutVertexArray.length,d="Polygon"===wf[h.type];if(this.hasPattern)this.features.push(Ih("fill-extrusion",this.layers,h,this.zoom,t));else if(this.wallMode)for(var p of h.geometry)for(var m of bf(p,d))this.addFeature(h,[m],s,r,{},t.availableImages,i,t.brightness);else this.addFeature(h,h.geometry,s,r,{},t.availableImages,i,t.brightness);t.featureIndex.insert(a,h.geometry,s,l,this.index,f)}}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}},{key:"addFeatures",value:function(e,t,r,i,n,a){for(var o of this.features){var s="Polygon"===wf[o.type],l=o.geometry;if(this.wallMode)for(var u of l)for(var c of bf(u,s))this.addFeature(o,[c],o.index,t,r,i,n,a);else this.addFeature(o,l,o.index,t,r,i,n,a)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles()}},{key:"update",value:function(e,t,r,i,n){var a=0!==Object.keys(e).length;if(!a||this.stateDependentLayers.length){var o=a?this.stateDependentLayers:this.layers;this.programConfigurations.updatePaintArrays(e,t,o,r,i,n),this.groundEffect.update(e,t,o,r,i,n)}}},{key:"isEmpty",value:function(){return 0===this.layoutVertexArray.length}},{key:"uploadPending",value:function(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}},{key:"upload",value:function(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Yh),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.wallVertexBuffer=e.createVertexBuffer(this.wallVertexArray,Hh.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=e.createVertexBuffer(this.layoutVertexExtArray,Xh.members,!0)),this.groundEffect.upload(e)),this.groundEffect.uploadPaintProperties(e),this.programConfigurations.upload(e),this.uploaded=!0}},{key:"uploadCentroid",value:function(e){this.groundEffect.uploadHiddenByLandmark(e),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,$h.members,!0):this.centroidVertexBuffer&&this.centroidVertexBuffer.updateData(this.centroidVertexArray),this.needsCentroidUpdate=!1)}},{key:"destroy",value:function(){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())}},{key:"addFeature",value:function(e,t,r,i,n,a,o,s){var l=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(e,{})/this.tileToMeter,u=[new K(0,0),new K(ii,ii)],c=o.projection,h="globe"===c.name,f=this.wallMode||"Polygon"===wf[e.type],p=new Lf;p.centroidDataIndex=this.centroidData.length;var m,v=new Rf,_=this.layers[0].paint.get("fill-extrusion-base").evaluate(e,{},i)<=0,y=this.layers[0].paint.get("fill-extrusion-height").evaluate(e,{},i);if(v.height=y,v.vertexArrayOffset=this.layoutVertexArray.length,v.groundVertexArrayOffset=this.groundEffect.vertexArray.length,h&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new Ss),this.wallMode){if(h)return void we("Non zero fill-extrusion-line-width is not yet supported on globe.");if(1!==t.length)return;m=(function(e){var t=e[0].x===e[e.length-1].x&&e[0].y===e[e.length-1].y,r=(function(e){for(var t=0,r=e.length,i=0;i=0})(e);r||(e=e.reverse());var i={geometry:[],joinNormals:[],indices:[]},n=[],a=[],o=[],s=e.length;if(s<(t?3:2))return i;for(;s>=2&&e[s-1].equals(e[s-2]);)s--;for(var l,u,c,h,f,p=0;p0,x="miter";"miter"===x&&y>2&&(x="bevel"),"bevel"===x&&(y>100&&(x="flipbevel"),y<2&&(x="miter"));var b=function(e,t,r,i){var s=new K(e.x,e.y),l=new K(e.x,e.y);s.x+=t.x*i,s.y+=t.y*i,l.x-=t.x*Math.max(r,1),l.y-=t.y*Math.max(r,1),o.push(t),n.push(s),a.push(l)};if("miter"===x)v._mult(y),b(l,v,0,0);else if("flipbevel"===x)b(l,v=f.mult(-1),0,0),b(l,v.mult(-1),0,0);else{var w=-Math.sqrt(y*y-1),k=g?w:0,T=g?0:w;u&&b(l,h,k,T),c&&b(l,f,k,T)}}i.geometry=[].concat(n,d(a.reverse()),[n[0]]),i.joinNormals=[].concat(o,d(o.reverse()),[o[o.length-1]]);for(var M=i.geometry.length-1,S=0;S=0;k--){var T=w[k];(0===T.length||(g=T[0]).every((function(e){return e.x<=0}))||g.every((function(e){return e.x>=ii}))||g.every((function(e){return e.y<=0}))||g.every((function(e){return e.y>=ii})))&&w.splice(k,1)}if(h)x=Jf(w,u,i);else for(var M of(x=[],w))x.push({polygon:M,bounds:u});var S=f?this.edgeRadius:0,E=S>0&&this.zoom<17,I=function(e,t){if(0===e.length)return!1;var r=e[e.length-1];return t.x===r.x&&t.y===r.y};for(var A of x){var C=A.polygon,P=A.bounds,z=0,D=0;for(var R of C)f&&!R[0].equals(R[R.length-1])&&R.push(R[0]),D+=f?R.length-1:R.length;var L=this.segments.prepareSegment((f?5:4)*D,this.layoutVertexArray,this.indexArray);v.footprintSegIdx<0&&(v.footprintSegIdx=this.footprintSegments.length),v.polygonSegIdx<0&&(v.polygonSegIdx=this.polygonSegments.length);var O={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},B=new Df;if(B.vertexOffset=this.footprintVertices.length,B.indexOffset=3*this.footprintIndices.length,B.ringIndices=[],f){var F=[],N=[];z=L.vertexLength;for(var V=0;V4&&Wf(re[re.length-2],re[0],re[1]),ne=S?qf(re[re.length-2],re[0],re[1],S):0,ae=[],oe=void 0,se=void 0,le=void 0;se=re[1].sub(re[0])._perp()._unit();for(var ue=!0,ce=1,he=0;ce0?1:0,ye=fe.dist(de);if(he+ye>32768&&(he=0),S){le=pe.sub(de)._perp()._unit();var ge=Zf(fe,de,pe,Gf(se,le),S);isNaN(ge)&&(ge=0);var xe=de.sub(fe)._unit();fe=fe.add(xe.mult(ne))._round(),de=de.add(xe.mult(-ge))._round(),ne=ge,se=le,_&&this.zoom>=17&&(I(ae,fe)||ae.push(fe),I(ae,de)||ae.push(de))}var be=L.vertexLength,ke=re.length>4&&Wf(fe,de,pe),Te=Xf(he,ie,ue);if(Af(this.layoutVertexArray,fe.x,fe.y,ve,_e,0,0,Te),Af(this.layoutVertexArray,fe.x,fe.y,ve,_e,0,1,Te),this.wallMode){var Me=b(ce-1,re),Se=m.joinNormals[ce-1];Cf(this.wallVertexArray,Se,Me),Cf(this.wallVertexArray,Se,Me)}if(Te=Xf(he+=ye,ke,!ue),ie=ke,Af(this.layoutVertexArray,de.x,de.y,ve,_e,0,0,Te),Af(this.layoutVertexArray,de.x,de.y,ve,_e,0,1,Te),this.wallMode){var Ee=b(ce,re),Ie=m.joinNormals[ce];Cf(this.wallVertexArray,Ie,Ee),Cf(this.wallVertexArray,Ie,Ee)}if(L.vertexLength+=4,this.indexArray.emplaceBack(be+0,be+1,be+2),this.indexArray.emplaceBack(be+1,be+3,be+2),L.primitiveLength+=2,S){var Ae=z+(1===ce?re.length-2:ce-2),Ce=1===ce?z:Ae+1;if(this.indexArray.emplaceBack(be+1,Ae,be+3),this.indexArray.emplaceBack(Ae,Ce,be+3),L.primitiveLength+=2,void 0===oe&&(oe=be),!$f(pe,re[ce],P)){var Pe=ce===re.length-1?oe:L.vertexLength;this.indexArray.emplaceBack(be+2,be+3,Pe),this.indexArray.emplaceBack(be+3,Pe+1,Pe),this.indexArray.emplaceBack(be+3,Ce,Pe+1),L.primitiveLength+=3}ue=!ue}if(h){var ze=this.layoutVertexExtArray,De=c.projectTilePoint(fe.x,fe.y,i),Re=c.projectTilePoint(de.x,de.y,i),Le=c.upVector(i,fe.x,fe.y),Oe=c.upVector(i,de.x,de.y);zf(ze,De,Le),zf(ze,De,Le),zf(ze,Re,Oe),zf(ze,Re,Oe)}}}f&&(z+=re.length-1),_&&S&&this.zoom>=17&&(0!==ae.length&&I(ae,ae[0])&&ae.pop(),this.groundEffect.addData(ae,P,l,S>0))}this.footprintSegments.push(B),O.triangleCount=this.indexArray.length-O.triangleArrayOffset,this.polygonSegments.push(O),++v.footprintSegLen,++v.polygonSegLen}if(v.vertexCount=this.layoutVertexArray.length-v.vertexArrayOffset,v.groundVertexCount=this.groundEffect.vertexArray.length-v.groundVertexArrayOffset,0!==v.vertexCount){if(v.centroidXY=p.borders?Ef:this.encodeCentroid(p,v),this.centroidData.push(v),p.borders){this.featuresOnBorder.push(p);for(var Be=this.featuresOnBorder.length-1,Fe=0;Feii),n=2*i+(+(r.min.x+r.max.x>ii)^i),a=0;a0&&this.triangleSubSegments.push({segment:x,min:y,max:g});for(var I=p=m;Il.max.x||l.min.x>o.max.x||o.min.y>l.max.y||l.min.y>o.max.y))for(var u=0;ut!=f>t&&e<(this.footprintVertices.int16[2*(u+a.vertexOffset)+0]-c)*(t-h)/(f-h)+c&&(i=!i)}o=s}}return i}},{key:"getHeightAtTileCoord",value:function(e,t){var r=Number.NEGATIVE_INFINITY,i=!0,n=4*(e+ii)*ii+(t+ii);if(this.partLookup.hasOwnProperty(n)){var a=this.partLookup[n];return a?{height:a.height,hidden:!!(a.flags&If)}:void 0}for(var o of this.centroidData)e>o.max.x||o.min.x>e||t>o.max.y||o.min.y>t||this.footprintContainsPoint(e,t,o)&&o&&o.height>r&&(r=o.height,this.partLookup[n]=o,i=!!(o.flags&If));if(r!==Number.NEGATIVE_INFINITY)return{height:r,hidden:i};this.partLookup[n]=void 0}}])})();function Gf(e,t){var r=e.add(t)._unit();return e.x*r.x+e.y*r.y}function qf(e,t,r,i){var n=t.sub(e)._perp()._unit(),a=r.sub(t)._perp()._unit();return Zf(e,t,r,Gf(n,a),i)}function Zf(e,t,r,i,n){var a=Math.sqrt(1-i*i);return Math.min(e.dist(t)/3,t.dist(r)/3,n*a/i)}function $f(e,t,r){return e.xr[1].x&&t.x>r[1].x||e.yr[1].y&&t.y>r[1].y}function Hf(e,t){return e.xt[1].x||e.yt[1].y}function Wf(e,t,r){if(e.x<0||e.x>=ii||t.x<0||t.x>=ii||r.x<0||r.x>=ii)return!1;var i=r.sub(t),n=i.perp(),a=e.sub(t);return(i.x*a.x+i.y*a.y)/Math.sqrt((i.x*i.x+i.y*i.y)*(a.x*a.x+a.y*a.y))>-.866&&n.x*a.x+n.y*a.y<0}function Xf(e,t,r){var i=t?2|e:-3&e;return r?1|i:-2&i}function Yf(){var e=Math.PI/32,t=Math.tan(e),r=Xl;return r*Math.sqrt(1+2*t*t)-r}function Jf(e,t,r){var i=1<4&&void 0!==arguments[4]?arguments[4]:0,a=arguments.length>5?arguments[5]:void 0,o=[];if(!e.length||!r||!i)return o;for(var s=function(e,t){for(var r of e)o.push({polygon:r,bounds:t})},l=Math.ceil(Math.log2(r)),u=Math.ceil(Math.log2(i)),c=l-u,h=[],f=0;f0?0:1);for(var d=0;d_+1?m.push({polygons:T,bounds:S,depth:_+1}):s(T,S)}if(M.length){var E=[new K(0===y?k:g.x,1===y?k:g.y),x];h.length>_+1?m.push({polygons:M,bounds:E,depth:_+1}):s(M,E)}}return o})(e,t,Math.ceil((a-n)/11.25),Math.ceil((o-s)/11.25),1,(function(e,t,n){if(0===e)return.5*(t+n);var a=nu((r.y+t/ii)/i);return(tu(.5*(nu((r.y+n/ii)/i)+a))*i-r.y)*ii}))}function Kf(e,t,r,i,n,a){for(var o=Math.pow(2,i.z-n.z),s=0;s1&&(s=e[++o]);var u=Math.abs(l-s.left),c=Math.abs(l-s.right),h=Math.min(u,c),f=void 0,d=n/r*(i+1);if(s.isDash){var p=i-Math.abs(d);f=Math.sqrt(h*h+p*p)}else f=i-Math.sqrt(h*h+d*d);this.image.data[a+l]=Math.max(0,Math.min(255,f+128))}}},{key:"addRegularDash",value:function(e,t){for(var r=e.length-1;r>=0;--r){var i=e[r],n=e[r+1];i.zeroLength?e.splice(r,1):n&&n.isDash===i.isDash&&(n.left=i.left,e.splice(r,1))}var a=e[0],o=e[e.length-1];a.isDash===o.isDash&&(a.left=o.left-this.width,o.right=a.right+this.width);for(var s=this.width*this.nextRow,l=0,u=e[l],c=0;c1&&(u=e[++l]);var h=Math.abs(c-u.left),f=Math.abs(c-u.right),d=Math.min(h,f);this.image.data[s+c]=Math.max(0,Math.min(255,(u.isDash?d:-d)+t+128))}}},{key:"addDash",value:function(e,t){var r=this.getKey(e,t);if(this.positions[r])return this.positions[r];var i="round"===t,n=i?7:0,a=2*n+1;if(this.nextRow+a>this.height)return we("LineAtlas out of space"),null;0===e.length&&e.push(1);for(var o=0,s=0;s0&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,id.members,!0)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,nd),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}},{key:"destroy",value:function(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}},{key:"lineFeatureClips",value:function(e){if(e.properties&&e.properties.hasOwnProperty("mapbox_clip_start")&&e.properties.hasOwnProperty("mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}},{key:"addFeature",value:function(e,t,r,i,n,a,o){var s=this.layers[0].layout,l=s.get("line-join").evaluate(e,{}),u=s.get("line-cap").evaluate(e,{}),c=s.get("line-miter-limit"),h=s.get("line-round-limit");for(var f of(this.lineClips=this.lineFeatureClips(e),t))this.addLine(f,e,i,l,u,c,h);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,r,n,a,i,o)}},{key:"addLine",value:function(e,t,r,i,n,a,o){this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.currentVertex=void 0;var s={zoom:this.zoom,lineProgress:void 0},l=this.layers[0].layout,u="none"===i;if(this.patternJoinNone=this.hasPattern&&u,this.segmentStart=0,this.segmentStartf32=0,this.segmentPoints=[],this.lineClips){this.lineClipsArray.push(this.lineClips);for(var c=0;c=2&&e[f-1].equals(e[f-2]);)f--;for(var d=0;d0;if(D&&w>d){var L=p.dist(m);if(L>2*x){var O=p.sub(p.sub(m)._mult(x/L)._round());this.updateDistance(m,O),this.addCurrentVertex(O,_,0,0,b,g),m=O}}if(M&&"round"===S&&(Pa&&(S="bevel"),"bevel"===S&&(P>2&&(S="flipbevel"),P100)A=y.mult(-1);else{var B=P*_.add(y).mag()/_.sub(y).mag();A._perp()._mult(B*(R?-1:1))}this.addCurrentVertex(p,A,0,0,b,g),this.addCurrentVertex(p,A.mult(-1),0,0,b,g)}else if("bevel"===S||"fakeround"===S){var F=-Math.sqrt(P*P-1),N=R?F:0,V=R?0:F;if(m&&this.addCurrentVertex(p,_,N,V,b,g),"fakeround"===S)for(var U=Math.round(180*z/Math.PI/20),j=1;j2*x){var H=p.add(v.sub(p)._mult(x/$)._round());this.updateDistance(p,H),this.addCurrentVertex(H,y,0,0,b,g),p=H}}}}}},{key:"addVerticesTo",value:function(e,t,r,i,n,a,o,s,l,u){var c=(t.w-e.w)/this.tessellationStep|0;if(c>1){this.lineSoFar=e.w;for(var h=(t.x-e.x)/c,f=(t.y-e.y)/c,d=(t.z-e.z)/c,p=(t.w-e.w)/c,m=1;m6&&void 0!==arguments[6]&&arguments[6],s=t.x+t.y*r,l=t.y-t.x*r,u=t.y*i-t.x,c=-t.y-t.x*i;if(null!=a){var h=-10,f=8202,d=a,p=new nf(e.x,e.y,d,this.lineSoFar),m=pd(e,h,f),v=this.lineSoFar;if(this.currentVertex)if(m){var _=this.currentVertexIsOutside,y=this.currentVertex,g=new nf(e.x,e.y,d,this.lineSoFar);sf(y,g,h,f),pd(g,h,f)||(_&&(this.e1=this.e2=-1,this.lineSoFar=y.w,this.addHalfVertex(y,s,l,o,!1,r,n,y.z),this.addHalfVertex(y,u,c,o,!0,-i,n,y.z)),this.addVerticesTo(y,g,s,l,u,c,r,i,n,o))}else{var x=this.currentVertex;this.currentVertexIsOutside&&(sf(x,p,h,f),this.e1=this.e2=-1,this.lineSoFar=x.w,this.addHalfVertex(x,s,l,o,!1,r,n,x.z),this.addHalfVertex(x,u,c,o,!0,-i,n,x.z)),this.addVerticesTo(x,p,s,l,u,c,r,i,n,o)}else m||(this.addHalfVertex(e,s,l,o,!1,r,n,a),this.addHalfVertex(e,u,c,o,!0,-i,n,a));this.currentVertex=p,this.currentVertexIsOutside=m,this.lineSoFar=v}else this.addHalfVertex(e,s,l,o,!1,r,n,a),this.addHalfVertex(e,u,c,o,!0,-i,n,a)}},{key:"addHalfVertex",value:function(e,t,r,i,n,a,o,s){var l=e.x,u=e.y;this.patternJoinNone&&(0===this.segmentPoints.length&&(this.segmentStart=this.lineSoFar,this.segmentStartf32=Math.fround(this.lineSoFar)),n||this.segmentPoints.push(this.lineSoFar-this.segmentStart,a)),this.layoutVertexArray.emplaceBack((l<<1)+(i?1:0),(u<<1)+(n?1:0),Math.round(63*t)+128,Math.round(63*r)+128,1+(0===a?0:a<0?-1:1),0,this.lineSoFar-this.segmentStartf32),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineClips.start,this.lineClips.end);var c=o.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,c),o.primitiveLength++),n?this.e2=c:this.e1=c,null!=s&&this.zOffsetVertexArray.emplaceBack(s)}},{key:"updateScaledDistance",value:function(){if(this.lineClips){var e=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=e*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}},{key:"updateDistance",value:function(e,t){this.distance+=e.dist(t),this.updateScaledDistance()}}])})();function pd(e,t,r){return e.xr||e.yr}function md(e,t,r){return t*(ii/(e.tileSize*Math.pow(2,r-e.tileID.overscaledZ)))}function vd(e,t){return 1/md(e,1,t.tileZoom)}function _d(e,t,r,i){return e.translatePosMatrix(i||t.tileID.projMatrix,t,r.paint.get("line-translate"),r.paint.get("line-translate-anchor"))}ca(dd,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});var yd,gd=function(e){var t=[];xd(e)&&t.push("RENDER_LINE_DASH"),e.paint.get("line-gradient")&&t.push("RENDER_LINE_GRADIENT");var r=e.paint.get("line-trim-offset");0===r[0]&&0===r[1]||t.push("RENDER_LINE_TRIM_OFFSET"),0!==e.paint.get("line-border-width").constantOr(1)&&t.push("RENDER_LINE_BORDER");var i="none"===e.layout.get("line-join").constantOr("miter"),n=!!e.paint.get("line-pattern").constantOr(1);return i&&n&&t.push("LINE_JOIN_NONE"),t};function xd(e){var t=e.paint.get("line-dasharray").value;return t.value||"constant"!==t.kind}var bd,wd=function(){return yd||(yd={layout:ld||(ld=new qo({"line-cap":new jo(Zo.layout_line["line-cap"]),"line-join":new jo(Zo.layout_line["line-join"]),"line-miter-limit":new Uo(Zo.layout_line["line-miter-limit"]),"line-round-limit":new Uo(Zo.layout_line["line-round-limit"]),"line-sort-key":new jo(Zo.layout_line["line-sort-key"]),"line-z-offset":new jo(Zo.layout_line["line-z-offset"]),visibility:new Uo(Zo.layout_line.visibility)})),paint:ud||(ud=new qo({"line-opacity":new jo(Zo.paint_line["line-opacity"]),"line-color":new jo(Zo.paint_line["line-color"]),"line-translate":new Uo(Zo.paint_line["line-translate"]),"line-translate-anchor":new Uo(Zo.paint_line["line-translate-anchor"]),"line-width":new jo(Zo.paint_line["line-width"]),"line-gap-width":new jo(Zo.paint_line["line-gap-width"]),"line-offset":new jo(Zo.paint_line["line-offset"]),"line-blur":new jo(Zo.paint_line["line-blur"]),"line-dasharray":new jo(Zo.paint_line["line-dasharray"]),"line-pattern":new jo(Zo.paint_line["line-pattern"]),"line-gradient":new Go(Zo.paint_line["line-gradient"]),"line-trim-offset":new Uo(Zo.paint_line["line-trim-offset"]),"line-trim-fade-range":new Uo(Zo.paint_line["line-trim-fade-range"]),"line-trim-color":new Uo(Zo.paint_line["line-trim-color"]),"line-emissive-strength":new Uo(Zo.paint_line["line-emissive-strength"]),"line-border-width":new jo(Zo.paint_line["line-border-width"]),"line-border-color":new jo(Zo.paint_line["line-border-color"]),"line-occlusion-opacity":new Uo(Zo.paint_line["line-occlusion-opacity"])}))})},kd=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"possiblyEvaluate",value:function(e,r){return r=new zo(Math.floor(r.zoom),{now:r.now,fadeDuration:r.fadeDuration,transition:r.transition}),k(t,"possiblyEvaluate",this,3)([e,r])}},{key:"evaluate",value:function(e,r,i,n){return r=fe({},r,{zoom:Math.floor(r.zoom)}),k(t,"evaluate",this,3)([e,r,i,n])}}])})(jo);function Td(e,t){return t>0?t+2*e:e}var Md=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),Sd=ms([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),Ed=ms([{name:"a_projected_pos",components:4,type:"Float32"}],4);ms([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);var Id=ms([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),Ad=ms([{name:"a_texb",components:2,type:"Uint16"}]),Cd=ms([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),Pd=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"}]);var zd=ms([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Dd=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 Rd=24,Ld=128;function Od(e,t){var r=t.expression;if("constant"===r.kind)return{kind:"constant",layoutSize:r.evaluate(new zo(e+1))};if("source"===r.kind)return{kind:"source"};for(var i=r.zoomStops,n=r.interpolationType,a=0;a":"\ufe40","?":"\ufe16","@":"\uff20","[":"\ufe47","\\":"\uff3c","]":"\ufe48","^":"\uff3e",_:"\ufe33","`":"\uff40","{":"\ufe37","|":"\u2015","}":"\ufe38","~":"\uff5e","\xa2":"\uffe0","\xa3":"\uffe1","\xa5":"\uffe5","\xa6":"\uffe4","\xac":"\uffe2","\xaf":"\uffe3","\u2013":"\ufe32","\u2014":"\ufe31","\u2018":"\ufe43","\u2019":"\ufe44","\u201c":"\ufe41","\u201d":"\ufe42","\u2026":"\ufe19","\u2027":"\u30fb","\u20a9":"\uffe6","\u3001":"\ufe11","\u3002":"\ufe12","\u3008":"\ufe3f","\u3009":"\ufe40","\u300a":"\ufe3d","\u300b":"\ufe3e","\u300c":"\ufe41","\u300d":"\ufe42","\u300e":"\ufe43","\u300f":"\ufe44","\u3010":"\ufe3b","\u3011":"\ufe3c","\u3014":"\ufe39","\u3015":"\ufe3a","\u3016":"\ufe17","\u3017":"\ufe18","\uff01":"\ufe15","\uff08":"\ufe35","\uff09":"\ufe36","\uff0c":"\ufe10","\uff0d":"\ufe32","\uff0e":"\u30fb","\uff1a":"\ufe13","\uff1b":"\ufe14","\uff1c":"\ufe3f","\uff1e":"\ufe40","\uff1f":"\ufe16","\uff3b":"\ufe47","\uff3d":"\ufe48","\uff3f":"\ufe33","\uff5b":"\ufe37","\uff5c":"\u2015","\uff5d":"\ufe38","\uff5f":"\ufe35","\uff60":"\ufe36","\uff61":"\ufe12","\uff62":"\ufe41","\uff63":"\ufe42","\u2190":"\u2191","\u2192":"\u2193"};function jd(e){return"\ufe36"===e||"\ufe48"===e||"\ufe38"===e||"\ufe44"===e||"\ufe42"===e||"\ufe3e"===e||"\ufe3c"===e||"\ufe3a"===e||"\ufe18"===e||"\ufe40"===e||"\ufe10"===e||"\ufe13"===e||"\ufe14"===e||"\uff40"===e||"\uffe3"===e||"\ufe11"===e||"\ufe12"===e}function Gd(e){return"\ufe35"===e||"\ufe47"===e||"\ufe37"===e||"\ufe43"===e||"\ufe41"===e||"\ufe3d"===e||"\ufe3b"===e||"\ufe39"===e||"\ufe17"===e||"\ufe3f"===e}var qd,Zd,$d,Hd={};function Wd(){if($d)return Zd;$d=1,Zd=t;var e=(qd||(qd=1,Hd.read=function(e,t,r,i,n){var a,o,s=8*n-i-1,l=(1<>1,c=-7,h=r?n-1:0,f=r?-1:1,d=e[t+h];for(h+=f,a=d&(1<<-c)-1,d>>=-c,c+=s;c>0;a=256*a+e[t+h],h+=f,c-=8);for(o=a&(1<<-c)-1,a>>=-c,c+=i;c>0;o=256*o+e[t+h],h+=f,c-=8);if(0===a)a=1-u;else{if(a===l)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,i),a-=u}return(d?-1:1)*o*Math.pow(2,a-i)},Hd.write=function(e,t,r,i,n,a){var o,s,l,u=8*a-n-1,c=(1<>1,f=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,d=i?0:a-1,p=i?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,o=c):(o=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-o))<1&&(o--,l*=2),(t+=o+h>=1?f/l:f*Math.pow(2,1-h))*l>=2&&(o++,l/=2),o+h>=c?(s=0,o=c):o+h>=1?(s=(t*l-1)*Math.pow(2,n),o+=h):(s=t*Math.pow(2,h-1)*Math.pow(2,n),o=0));n>=8;e[r+d]=255&s,d+=p,s/=256,n-=8);for(o=o<0;e[r+d]=255&o,d+=p,o/=256,u-=8);e[r+d-p]|=128*m}),Hd);function t(e){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(e)?e:new Uint8Array(e||0),this.pos=0,this.type=0,this.length=this.buf.length}t.Varint=0,t.Fixed64=1,t.Bytes=2,t.Fixed32=5;var r=4294967296,i=2.3283064365386963e-10,n="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function a(e){return e.type===t.Bytes?e.readVarint()+e.pos:e.pos+1}function o(e,t,r){return r?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function s(e,t,r){var i=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));r.realloc(i);for(var n=r.pos-1;n>=e;n--)r.buf[n+i]=r.buf[n]}function l(e,t){for(var r=0;r>>8,e[r+2]=t>>>16,e[r+3]=t>>>24}function g(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}return t.prototype={destroy:function(){this.buf=null},readFields:function(e,t,r){for(r=r||this.length;this.pos>3,a=this.pos;this.type=7&i,e(n,t,this),this.pos===a&&this.skip(i)}return t},readMessage:function(e,t){return this.readFields(e,t,this.readVarint()+this.pos)},readFixed32:function(){var e=_(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=g(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=_(this.buf,this.pos)+_(this.buf,this.pos+4)*r;return this.pos+=8,e},readSFixed64:function(){var e=_(this.buf,this.pos)+g(this.buf,this.pos+4)*r;return this.pos+=8,e},readFloat:function(){var t=e.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=e.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(e){var t,r,i=this.buf;return t=127&(r=i[this.pos++]),r<128?t:(t|=(127&(r=i[this.pos++]))<<7,r<128?t:(t|=(127&(r=i[this.pos++]))<<14,r<128?t:(t|=(127&(r=i[this.pos++]))<<21,r<128?t:(function(e,t,r){var i,n,a=r.buf;if(i=(112&(n=a[r.pos++]))>>4,n<128)return o(e,i,t);if(i|=(127&(n=a[r.pos++]))<<3,n<128)return o(e,i,t);if(i|=(127&(n=a[r.pos++]))<<10,n<128)return o(e,i,t);if(i|=(127&(n=a[r.pos++]))<<17,n<128)return o(e,i,t);if(i|=(127&(n=a[r.pos++]))<<24,n<128)return o(e,i,t);if(i|=(1&(n=a[r.pos++]))<<31,n<128)return o(e,i,t);throw new Error("Expected varint not more than 10 bytes")})(t|=(15&(r=i[this.pos]))<<28,e,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var e=this.readVarint();return e%2==1?(e+1)/-2:e/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&n?(function(e,t,r){return n.decode(e.subarray(t,r))})(this.buf,t,e):(function(e,t,r){for(var i="",n=t;n239?4:l>223?3:l>191?2:1;if(n+c>r)break;1===c?l<128&&(u=l):2===c?128==(192&(a=e[n+1]))&&(u=(31&l)<<6|63&a)<=127&&(u=null):3===c?(o=e[n+2],128==(192&(a=e[n+1]))&&128==(192&o)&&((u=(15&l)<<12|(63&a)<<6|63&o)<=2047||u>=55296&&u<=57343)&&(u=null)):4===c&&(o=e[n+2],s=e[n+3],128==(192&(a=e[n+1]))&&128==(192&o)&&128==(192&s)&&((u=(15&l)<<18|(63&a)<<12|(63&o)<<6|63&s)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,c=1):u>65535&&(u-=65536,i+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),i+=String.fromCharCode(u),n+=c}return i})(this.buf,t,e)},readBytes:function(){var e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t},readPackedVarint:function(e,r){if(this.type!==t.Bytes)return e.push(this.readVarint(r));var i=a(this);for(e=e||[];this.pos127;);else if(r===t.Bytes)this.pos=this.readVarint()+this.pos;else if(r===t.Fixed32)this.pos+=4;else{if(r!==t.Fixed64)throw new Error("Unimplemented type: "+r);this.pos+=8}},writeTag:function(e,t){this.writeVarint(e<<3|t)},realloc:function(e){for(var t=this.length||16;t268435455||e<0?(function(e,t){var r,i;if(e>=0?(r=e%4294967296|0,i=e/4294967296|0):(i=~(-e/4294967296),4294967295^(r=~(-e%4294967296))?r=r+1|0:(r=0,i=i+1|0)),e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),(function(e,t,r){r.buf[r.pos++]=127&e|128,e>>>=7,r.buf[r.pos++]=127&e|128,e>>>=7,r.buf[r.pos++]=127&e|128,e>>>=7,r.buf[r.pos++]=127&e|128,r.buf[r.pos]=127&(e>>>=7)})(r,0,t),(function(e,t){var r=(7&e)<<4;t.buf[t.pos++]|=r|((e>>>=3)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e)))))})(i,t)})(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))))},writeSVarint:function(e){this.writeVarint(e<0?2*-e-1:2*e)},writeBoolean:function(e){this.writeVarint(Boolean(e))},writeString:function(e){e=String(e),this.realloc(4*e.length),this.pos++;var t=this.pos;this.pos=(function(e,t,r){for(var i,n,a=0;a55295&&i<57344){if(!n){i>56319||a+1===t.length?(e[r++]=239,e[r++]=191,e[r++]=189):n=i;continue}if(i<56320){e[r++]=239,e[r++]=191,e[r++]=189,n=i;continue}i=n-55296<<10|i-56320|65536,n=null}else n&&(e[r++]=239,e[r++]=191,e[r++]=189,n=null);i<128?e[r++]=i:(i<2048?e[r++]=i>>6|192:(i<65536?e[r++]=i>>12|224:(e[r++]=i>>18|240,e[r++]=i>>12&63|128),e[r++]=i>>6&63|128),e[r++]=63&i|128)}return r})(this.buf,e,this.pos);var r=this.pos-t;r>=128&&s(t,r,this),this.pos=t-1,this.writeVarint(r),this.pos+=r},writeFloat:function(t){this.realloc(4),e.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),e.write(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(e){var t=e.length;this.writeVarint(t),this.realloc(t);for(var r=0;r=128&&s(r,i,this),this.pos=r-1,this.writeVarint(i),this.pos+=i},writeMessage:function(e,r,i){this.writeTag(e,t.Bytes),this.writeRawMessage(r,i)},writePackedVarint:function(e,t){t.length&&this.writeMessage(e,l,t)},writePackedSVarint:function(e,t){t.length&&this.writeMessage(e,u,t)},writePackedBoolean:function(e,t){t.length&&this.writeMessage(e,f,t)},writePackedFloat:function(e,t){t.length&&this.writeMessage(e,c,t)},writePackedDouble:function(e,t){t.length&&this.writeMessage(e,h,t)},writePackedFixed32:function(e,t){t.length&&this.writeMessage(e,d,t)},writePackedSFixed32:function(e,t){t.length&&this.writeMessage(e,p,t)},writePackedFixed64:function(e,t){t.length&&this.writeMessage(e,m,t)},writePackedSFixed64:function(e,t){t.length&&this.writeMessage(e,v,t)},writeBytesField:function(e,r){this.writeTag(e,t.Bytes),this.writeBytes(r)},writeFixed32Field:function(e,r){this.writeTag(e,t.Fixed32),this.writeFixed32(r)},writeSFixed32Field:function(e,r){this.writeTag(e,t.Fixed32),this.writeSFixed32(r)},writeFixed64Field:function(e,r){this.writeTag(e,t.Fixed64),this.writeFixed64(r)},writeSFixed64Field:function(e,r){this.writeTag(e,t.Fixed64),this.writeSFixed64(r)},writeVarintField:function(e,r){this.writeTag(e,t.Varint),this.writeVarint(r)},writeSVarintField:function(e,r){this.writeTag(e,t.Varint),this.writeSVarint(r)},writeStringField:function(e,r){this.writeTag(e,t.Bytes),this.writeString(r)},writeFloatField:function(e,r){this.writeTag(e,t.Fixed32),this.writeFloat(r)},writeDoubleField:function(e,r){this.writeTag(e,t.Fixed64),this.writeDouble(r)},writeBooleanField:function(e,t){this.writeVarintField(e,Boolean(t))}},Zd}var Xd=t(Wd());function Yd(e,t,r){t.glyphs=[],1===e&&r.readMessage(Jd,t)}function Jd(e,t,r){if(3===e){var i=r.readMessage(Kd,{}),n=i.id,a=i.bitmap,o=i.width,s=i.height,l=i.left,u=i.top,c=i.advance;t.glyphs.push({id:n,bitmap:new Xc({width:o+6,height:s+6},a),metrics:{width:o,height:s,left:l,top:u,advance:c}})}else 4===e?t.ascender=r.readSVarint():5===e&&(t.descender=r.readSVarint())}function Kd(e,t,r){1===e?t.id=r.readVarint():2===e?t.bitmap=r.readBytes():3===e?t.width=r.readVarint():4===e?t.height=r.readVarint():5===e?t.left=r.readSVarint():6===e?t.top=r.readSVarint():7===e&&(t.advance=r.readVarint())}var Qd={horizontal:1,vertical:2,horizontalOnly:3},ep=(function(){function e(){p(this,e),this.scale=1,this.fontStack="",this.imageName=null}return m(e,null,[{key:"forText",value:function(t,r){var i=new e;return i.scale=t||1,i.fontStack=r,i}},{key:"forImage",value:function(t){var r=new e;return r.imageName=t,r}}])})(),tp=(function(){function e(){p(this,e),this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}return m(e,[{key:"length",value:function(){return this.text.length}},{key:"getSection",value:function(e){return this.sections[this.sectionIndex[e]]}},{key:"getSections",value:function(){return this.sections}},{key:"getSectionIndex",value:function(e){return this.sectionIndex[e]}},{key:"getCodePoint",value:function(e){return this.text.codePointAt(e)}},{key:"verticalizePunctuation",value:function(e){this.text=(function(e,t){for(var r="",i=0;i=0&&i>=e&&ip[this.text.charCodeAt(i)];i--)r--;this.text=this.text.substring(e,r),this.sectionIndex=this.sectionIndex.slice(e,r)}},{key:"substring",value:function(t,r){var i=new e;return i.text=this.text.substring(t,r),i.sectionIndex=this.sectionIndex.slice(t,r),i.sections=this.sections,i}},{key:"toString",value:function(){return this.text}},{key:"getMaxScale",value:function(){var e=this;return this.sectionIndex.reduce((function(t,r){return Math.max(t,e.sections[r].scale)}),0)}},{key:"addTextSection",value:function(e,t){this.text+=e.text,this.sections.push(ep.forText(e.scale,e.fontStack||t));for(var r=this.sections.length-1,i=0;i=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}],[{key:"fromFeature",value:function(t,r){for(var i=new e,n=0;n=0,c=0,h=0;h0&&q>I&&(I=q)}else{var Z=r[z.fontStack];if(!Z)continue;Z[R]&&(B=Z[R]);var $=t[z.fontStack];if(!$)continue;var H=$.glyphs[R];if(!H)continue;if(O=H.metrics,N=8203!==R?Rd:0,v){var W=void 0!==$.ascender?Math.abs($.ascender):0,X=void 0!==$.descender?Math.abs($.descender):0,Y=(W+X)*L;A-r/2;){if(--o<0)return!1;s-=e[o].dist(a),a=e[o]}s+=e[o].dist(e[o+1]),o++;for(var l=[],u=0;si;)u-=l.shift().angleDelta;if(u>n)return!1;o++,s+=c.dist(h)}return!0}function vp(e){for(var t=0,r=0;ru){var p=(u-l)/d,m=Ft(h.x,f.x,p),v=Ft(h.y,f.y,p),_=new pp(m,v,0,f.angleTo(h),c);return!o||mp(e,_,s,o,t)?_:void 0}l+=d}}function xp(e,t,r,i,n,a,o,s,l){var u=_p(i,a,o),c=yp(i,n),h=c*o,f=0===e[0].x||e[0].x===l||0===e[0].y||e[0].y===l;return t-h=0&&x=0&&b=0&&f+u<=c){var w=new pp(x,b,0,y,p);i&&!mp(e,w,a,i,n)||d.push(w)}}h+=_}return s||d.length||o||(d=bp(e,h/2,r,i,n,a,o,!0,l)),d}function wp(e,t,r,i,n){for(var a=[],o=0;o=i&&h.x>=i||(c.x>=i?c=new K(i,c.y+(i-c.x)/(h.x-c.x)*(h.y-c.y))._round():h.x>=i&&(h=new K(i,c.y+(i-c.x)/(h.x-c.x)*(h.y-c.y))._round()),c.y>=n&&h.y>=n||(c.y>=n?c=new K(c.x+(n-c.y)/(h.y-c.y)*(h.x-c.x),n)._round():h.y>=n&&(h=new K(c.x+(n-c.y)/(h.y-c.y)*(h.x-c.x),n)._round()),l&&c.equals(l[l.length-1])||(l=[c],a.push(l)),l.push(h)))))}return a}function kp(e){var t=0,r=0;for(var i of e)t+=i.w*i.h,r=Math.max(r,i.w);e.sort((function(e,t){return t.h-e.h}));var n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),r),h:1/0}],a=0,o=0;for(var s of e)for(var l=n.length-1;l>=0;l--){var u=n[l];if(!(s.w>u.w||s.h>u.h)){if(s.x=u.x,s.y=u.y,o=Math.max(o,s.y+s.h),a=Math.max(a,s.x+s.w),s.w===u.w&&s.h===u.h){var c=n.pop();l1?y-1:y,Yc.copy(v.data,c,{x:0,y:0},{x:g,y:x},v.data,i),Yc.copy(v.data,c,{x:0,y:w-y},{x:g,y:x-y},{width:b,height:y},i),Yc.copy(v.data,c,{x:0,y:0},{x:g,y:x+w},{width:b,height:y},i),Yc.copy(v.data,c,{x:b-y,y:0},{x:g-y,y:x},{width:y,height:w},i),Yc.copy(v.data,c,{x:0,y:0},{x:g+b,y:x},{width:y,height:w},i),Yc.copy(v.data,c,{x:b-y,y:w-y},{x:g-y,y:x-y},{width:y,height:y},i),Yc.copy(v.data,c,{x:0,y:w-y},{x:g+b,y:x-y},{width:y,height:y},i),Yc.copy(v.data,c,{x:0,y:0},{x:g+b,y:x+w},{width:y,height:y},i),Yc.copy(v.data,c,{x:b-y,y:0},{x:g-y,y:x+w},{width:y,height:y},i)}this.image=c,this.iconPositions=n,this.patternPositions=a}),[{key:"addImages",value:function(e,t,r,i){for(var n in e){var a=e[n],o={x:0,y:0,w:a.data.width+2*r,h:a.data.height+2*r};i.push(o),t[n]=new Tp(o,a,r),a.hasRenderCallback&&this.haveRenderCallbacks.push(n)}}},{key:"patchUpdatedImages",value:function(e,t,r){for(var i in this.haveRenderCallbacks=this.haveRenderCallbacks.filter((function(t){return e.hasImage(t,r)})),e.dispatchRenderCallbacks(this.haveRenderCallbacks,r),e.getUpdatedImages(r))this.patchUpdatedImage(this.iconPositions[i],e.getImage(i,r),t),this.patchUpdatedImage(this.patternPositions[i],e.getImage(i,r),t)}},{key:"patchUpdatedImage",value:function(e,t,r){if(e&&t&&e.version!==t.version){e.version=t.version;var i=x(e.tl,2),n=i[0],a=i[1];r.update(t.data,{position:{x:n,y:a}})}}}])})();ca(Tp,"ImagePosition"),ca(Mp,"ImageAtlas");var Sp=1e20;function Ep(e,t,r,i,n,a,o,s,l){for(var u=t;u-1);a[++l]=s,o[l]=u,o[l+1]=Sp}for(var f=0,d=0;f65535)r(new Error("glyphs > 65535 not supported"));else if(s.ranges[u])r(null,{stack:i,id:a,glyph:l});else{var c=s.requests[u];c||(c=s.requests[u]=[],e.loadGlyphRange(i,u,o,n.requestManager,(function(e,t){if(t){for(var r in s.ascender=t.ascender,s.descender=t.descender,t.glyphs)n._doesCharSupportLocalGlyph(+r)||(s.glyphs[+r]=t.glyphs[+r]);s.ranges[u]=!0}for(var i of c)i(e,t);delete s.requests[u]}))),c.push((function(e,t){e?r(e):t&&r(null,{stack:i,id:a,glyph:t.glyphs[a]||null})}))}}else r(null,{stack:i,id:a,glyph:l})}),(function(e,t){if(e)i(e);else if(t){var r={};for(var a of t){var o=a.stack,s=a.id,l=a.glyph;void 0===r[o]&&(r[o]={}),void 0===r[o].glyphs&&(r[o].glyphs={}),r[o].glyphs[s]=l&&{id:l.id,bitmap:l.bitmap.clone(),metrics:l.metrics},r[o].ascender=n.entries[o].ascender,r[o].descender=n.entries[o].descender}i(null,r)}}))}},{key:"_doesCharSupportLocalGlyph",value:function(e){return this.localGlyphMode!==Ap.none&&(this.localGlyphMode===Ap.all?!!this.localFontFamily:!!this.localFontFamily&&(Ya(e)||eo(e)||Fa(e)||Na(e)||Ba(e)||Wa(e)||co(e)))}},{key:"_tinySDF",value:function(t,r,i){var n=this.localFontFamily;if(n&&this._doesCharSupportLocalGlyph(i)){var a=t.tinySDF;if(!a){var o="400";/bold/i.test(r)?o="900":/medium/i.test(r)?o="500":/light/i.test(r)&&(o="200"),(a=t.tinySDF=new e.TinySDF({fontFamily:n,fontWeight:o,fontSize:48,buffer:6,radius:16})).fontWeight=o}if(this.localGlyphs[a.fontWeight][i])return this.localGlyphs[a.fontWeight][i];var s=String.fromCodePoint(i),l=a.draw(s),u=l.data,c=l.width,h=l.height,f=l.glyphWidth,d=l.glyphHeight,p=l.glyphLeft,m=l.glyphTop,v=l.glyphAdvance;return this.localGlyphs[a.fontWeight][i]={id:i,bitmap:new Xc({width:c,height:h},u),metrics:{width:f/2,height:d/2,left:p/2,top:m/2-27,advance:v/2,localGlyph:!0}}}}}])})();Cp.loadGlyphRange=function(e,t,r,i,n){var a=256*t,o=a+255,s=i.transformRequest(i.normalizeGlyphsURL(r).replace("{fontstack}",e).replace("{range}",`${a}-${o}`),ct.Glyphs);pt(s,(function(e,t){if(e)n(e);else if(t){var r={},i=(function(e){return new Xd(e).readFields(Yd,{})})(t);for(var a of i.glyphs)r[a.id]=a;n(null,{glyphs:r,ascender:i.ascender,descender:i.descender})}}))},Cp.TinySDF=(function(){return m((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=t.fontSize,i=void 0===r?24:r,n=t.buffer,a=void 0===n?3:n,o=t.radius,s=void 0===o?8:o,l=t.cutoff,u=void 0===l?.25:l,c=t.fontFamily,h=void 0===c?"sans-serif":c,f=t.fontWeight,d=void 0===f?"normal":f,m=t.fontStyle,v=void 0===m?"normal":m;p(this,e),this.buffer=a,this.cutoff=u,this.radius=s;var _=this.size=i+4*a,y=this._createCanvas(_),g=this.ctx=y.getContext("2d",{willReadFrequently:!0});g.font=`${v} ${d} ${i}px ${h}`,g.textBaseline="alphabetic",g.textAlign="left",g.fillStyle="black",this.gridOuter=new Float64Array(_*_),this.gridInner=new Float64Array(_*_),this.f=new Float64Array(_),this.z=new Float64Array(_+1),this.v=new Uint16Array(_)}),[{key:"_createCanvas",value:function(e){var t=document.createElement("canvas");return t.width=t.height=e,t}},{key:"draw",value:function(e){var t=this.ctx.measureText(e),r=t.width,i=t.actualBoundingBoxAscent,n=t.actualBoundingBoxDescent,a=t.actualBoundingBoxLeft,o=t.actualBoundingBoxRight,s=Math.ceil(i),l=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-a))),u=Math.min(this.size-this.buffer,s+Math.ceil(n)),c=l+2*this.buffer,h=u+2*this.buffer,f=Math.max(c*h,0),d=new Uint8ClampedArray(f),p={data:d,width:c,height:h,glyphWidth:l,glyphHeight:u,glyphTop:s,glyphLeft:0,glyphAdvance:r};if(0===l||0===u)return p;var m=this.ctx,v=this.buffer,_=this.gridInner,y=this.gridOuter;m.clearRect(v,v,l,u),m.fillText(e,v,v+s);var g=m.getImageData(v,v,l,u);y.fill(Sp,0,f),_.fill(0,0,f);for(var x=0;x0?T*T:0,_[k]=T<0?T*T:0}}}Ep(y,0,0,c,h,c,this.f,this.v,this.z),Ep(_,v,v,l,u,c,this.f,this.v,this.z);for(var M=0;M1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=1/0,n=1/0,a=-1/0,o=-1/0,s=e[0],l=0;la)&&(a=u.x),(!l||u.y>o)&&(o=u.y)}var c=Math.min(a-i,o-n),h=c/2,f=new ri([],Fp);if(0===c)return new K(i,n);for(var d=i;dm.d||!m.d)&&(m=_,r&&console.log("found best %d after %d probes",Math.round(1e4*_.d)/1e4,v)),_.max-m.d<=t||(h=_.h/2,f.push(new Np(_.p.x-h,_.p.y-h,h,e)),f.push(new Np(_.p.x+h,_.p.y-h,h,e)),f.push(new Np(_.p.x-h,_.p.y+h,h,e)),f.push(new Np(_.p.x+h,_.p.y+h,h,e)),v+=4)}return r&&(console.log(`num probes: ${v}`),console.log(`best distance: ${m.d}`)),m.p}function Fp(e,t){return t.max-e.max}var Np=m((function e(t,r,i,n){p(this,e),this.p=new K(t,r),this.h=i,this.d=(function(e,t){for(var r=!1,i=1/0,n=0;ne.y!=c.y>e.y&&e.x<(c.x-u.x)*(e.y-u.y)/(c.y-u.y)+u.x&&(r=!r),i=Math.min(i,Du(e,u,c))}return(r?1:-1)*Math.sqrt(i)})(this.p,n),this.max=this.d+this.h*Math.SQRT2})),Vp=Number.POSITIVE_INFINITY,Up=Math.sqrt(2);function jp(e,t){var r=x(t,2),i=r[0],n=r[1],a=0,o=0;if(n===Vp){i<0&&(i=0);var s=i/Up;switch(e){case"top-right":case"top-left":o=s-7;break;case"bottom-right":case"bottom-left":o=7-s;break;case"bottom":o=7-i;break;case"top":o=i-7}switch(e){case"top-right":case"bottom-right":a=-s;break;case"top-left":case"bottom-left":a=s;break;case"left":a=i;break;case"right":a=-i}}else{switch(i=Math.abs(i),n=Math.abs(n),e){case"top-right":case"top-left":case"top":o=n-7;break;case"bottom-right":case"bottom-left":case"bottom":o=7-n}switch(e){case"top-right":case"bottom-right":case"right":a=-i;break;case"top-left":case"bottom-left":case"left":a=i}}return[a,o]}function Gp(e){switch(e){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function qp(e,t,r,i,n,a,o,s,l,u,c,h,f,d,p){var m=a.textMaxSize.evaluate(t,{},h);void 0===m&&(m=o);var v,_,y=e.layers[0].layout,g=y.get("icon-offset").evaluate(t,{},h),b=Wp(r.horizontal)||r.vertical,w="globe"===f.name,k=o/24,T=e.tilePixelRatio*m/24,M=(v=e.overscaling,e.zoom>18&&v>2&&(v>>=1),Math.max(ii/(512*v),1)*y.get("symbol-spacing")),S=y.get("text-padding")*e.tilePixelRatio,E=y.get("icon-padding")*e.tilePixelRatio,I=re(y.get("text-max-angle")),A="map"===y.get("text-rotation-alignment")&&"point"!==y.get("symbol-placement"),C="map"===y.get("icon-rotation-alignment")&&"point"!==y.get("symbol-placement"),P=y.get("symbol-placement"),z=M/2,D=y.get("icon-text-fit").evaluate(t,{},h),R=y.get("icon-text-fit-padding").evaluate(t,{},h),L="none"!==D;!1===e.hasAnyIconTextFit&&L&&(e.hasAnyIconTextFit=!0),i&&L&&(e.allowVerticalPlacement&&r.vertical&&(_=dp(i,r.vertical,D,R,g,k)),b&&(i=dp(i,b,D,R,g,k)));var O=function(o,s,m){if(!(s.x<0||s.x>=ii||s.y<0||s.y>=ii)){var v=null;if(w){var y=f.projectTilePoint(s.x,s.y,m),b=y.x,k=y.y,T=y.z;v={anchor:new pp(b,k,T,0,void 0),up:f.upVector(m,s.x,s.y)}}!(function(e,t,r,i,n,a,o,s,l,u,c,h,f,d,p,m,v,_,y,g,b,w,k,T,M,S,E,I,A){var C,P,z,D,R,L,O,B=e.addToLineVertexArray(t,i),F=0,N=0,V=0,U=0,j=-1,G=-1,q={},Z=Et(""),$=r?r.anchor:t,H="none"!==l.layout.get("icon-text-fit").evaluate(b,{},M),W=0,X=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?(I=l.layout.get("text-offset").evaluate(b,{},M).map((function(e){return e*Rd})),W=(A=x(I,2))[0],X=A[1]):(W=l.layout.get("text-radial-offset").evaluate(b,{},M)*Rd,X=Vp),e.allowVerticalPlacement&&n.vertical){var Y=n.vertical;if(p)L=Yp(Y),s&&(O=Yp(s));else{var J=l.layout.get("text-rotate").evaluate(b,{},M)+90;z=Xp(u,$,t,c,h,f,Y,d,J,m),s&&(D=Xp(u,$,t,c,h,f,s,_,J))}}if(a){var K=l.layout.get("icon-rotate").evaluate(b,{},M),Q=Pp(a,K,k,H),ee=s?Pp(s,K,k,H):void 0;P=Xp(u,$,t,c,h,f,a,_,K),F=4*Q.length;var te=e.iconSizeData,re=null;"source"===te.kind?(re=[Ld*l.layout.get("icon-size").evaluate(b,{},M)])[0]>$p&&we(`${e.layerIds[0]}: Value for "icon-size" is >= ${Zp}. Reduce your "icon-size".`):"composite"===te.kind&&(((re=[Ld*w.compositeIconSizes[0].evaluate(b,{},M),Ld*w.compositeIconSizes[1].evaluate(b,{},M)])[0]>$p||re[1]>$p)&&we(`${e.layerIds[0]}: Value for "icon-size" is >= ${Zp}. Reduce your "icon-size".`)),e.addSymbols(e.icon,Q,re,g,y,b,!1,r,t,B.lineStartIndex,B.lineLength,-1,T,M,S,E),j=e.icon.placedSymbolArray.length-1,ee&&(N=4*ee.length,e.addSymbols(e.icon,ee,re,g,y,b,Qd.vertical,r,t,B.lineStartIndex,B.lineLength,-1,T,M,S,E),G=e.icon.placedSymbolArray.length-1)}for(var ie in n.horizontal){var ne=n.horizontal[ie];C||(Z=Et(ne.text),p?R=Yp(ne):C=Xp(u,$,t,c,h,f,ne,d,l.layout.get("text-rotate").evaluate(b,{},M),m));var ae=1===ne.positionedLines.length;if(V+=Hp(e,r,t,ne,o,l,p,b,m,B,n.vertical?Qd.horizontal:Qd.horizontalOnly,ae?Object.keys(n.horizontal):[ie],q,j,w,T,M,S),ae)break}n.vertical&&(U+=Hp(e,r,t,n.vertical,o,l,p,b,m,B,Qd.vertical,["vertical"],q,G,w,T,M,S));var oe=-1,se=function(e,t){return e?Math.max(e,t):t};oe=se(R,oe),oe=se(L,oe);var le=(oe=se(O,oe))>-1?1:0;e.glyphOffsetArray.length>=65535&&we("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==b.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,b.sortKey),e.symbolInstances.emplaceBack(t.x,t.y,$.x,$.y,$.z,q.right>=0?q.right:-1,q.center>=0?q.center:-1,q.left>=0?q.left:-1,q.vertical>=0?q.vertical:-1,j,G,Z,void 0!==C?C:e.collisionBoxArray.length,void 0!==C?C+1:e.collisionBoxArray.length,void 0!==z?z:e.collisionBoxArray.length,void 0!==z?z+1:e.collisionBoxArray.length,void 0!==P?P:e.collisionBoxArray.length,void 0!==P?P+1:e.collisionBoxArray.length,D||e.collisionBoxArray.length,D?D+1:e.collisionBoxArray.length,c,V,U,F,N,le,0,W,X,oe,0,H?1:0)})(e,s,v,o,r,i,n,_,e.layers[0],e.collisionBoxArray,t.index,t.sourceLayerIndex,e.index,S,A,l,0,E,C,g,t,a,u,c,h,d,p)}};if("line"===P)for(var B of wp(t.geometry,0,0,ii,ii)){var F=xp(B,M,I,r.vertical||b,i,24,T,e.overscaling,ii);for(var N of F)b&&Jp(e,b.text,z,N)||O(B,N,h)}else if("line-center"===P){for(var V of t.geometry)if(V.length>1){var U=gp(V,I,r.vertical||b,i,24,T);U&&O(V,U,h)}}else if("Polygon"===t.type)for(var j of Mh(t.geometry,0)){var G=Bp(j,16);O(j[0],new pp(G.x,G.y,0,0,void 0),h)}else if("LineString"===t.type)for(var q of t.geometry)O(q,new pp(q[0].x,q[0].y,0,0,void 0),h);else if("Point"===t.type)for(var Z of t.geometry)for(var $ of Z)O([$],new pp($.x,$.y,0,0,void 0),h)}var Zp=255,$p=32640;function Hp(e,t,r,i,n,a,o,s,l,u,h,f,p,m,v,_,y,g){var x=(function(e,t,r,i,n,a,o,s){var l=[];if(0===t.positionedLines.length)return l;var u=i.layout.get("text-rotate").evaluate(a,{})*Math.PI/180,h=(function(e){var t=e[0],r=e[1],i=t*r;return i>0?[t,-r]:i<0?[-t,r]:0===t?[r,t]:[r,-t]})(r),f=Math.abs(t.top-t.bottom);for(var p of t.positionedLines)f-=p.lineOffset;for(var m=t.positionedLines.length,v=f/m,_=t.top-r[1],y=0;y$p&&we(`${e.layerIds[0]}: Value for "text-size" is >= ${Zp}. Reduce your "text-size".`):"composite"===b.kind&&(((w=[Ld*v.compositeTextSizes[0].evaluate(s,{},y),Ld*v.compositeTextSizes[1].evaluate(s,{},y)])[0]>$p||w[1]>$p)&&we(`${e.layerIds[0]}: Value for "text-size" is >= ${Zp}. Reduce your "text-size".`)),e.addSymbols(e.text,x,w,l,o,s,h,t,r,u.lineStartIndex,u.lineLength,m,_,y,g,!1),f))p[k]=e.text.placedSymbolArray.length-1;return 4*x.length}function Wp(e){for(var t in e)return e[t];return null}function Xp(e,t,r,i,n,a,o,s,l,u){var c=o.top,h=o.bottom,f=o.left,d=o.right,p=o.collisionPadding;if(p&&(f-=p[0],c-=p[1],d+=p[2],h+=p[3]),l){var m=new K(f,c),v=new K(d,c),_=new K(f,h),y=new K(d,h),g=re(l),x=new K(0,0);u&&(x=new K(u[0],u[1])),m._rotateAround(g,x),v._rotateAround(g,x),_._rotateAround(g,x),y._rotateAround(g,x),f=Math.min(m.x,v.x,_.x,y.x),d=Math.max(m.x,v.x,_.x,y.x),c=Math.min(m.y,v.y,_.y,y.y),h=Math.max(m.y,v.y,_.y,y.y)}return e.emplaceBack(t.x,t.y,t.z,r.x,r.y,f,c,d,h,s,i,n,a),e.length-1}function Yp(e){e.collisionPadding&&(e.top-=e.collisionPadding[1],e.bottom+=e.collisionPadding[3]);var t=e.bottom-e.top;return t>0?Math.max(10,t):null}function Jp(e,t,r,i){var n=e.compareText;if(t in n){for(var a=n[t],o=a.length-1;o>=0;o--)if(i.dist(a[o])g&&(x(e,u,i,n,s,l),x(u,r,s,l,a,o))}x(h,f,i,a,n,a),x(f,d,n,a,n,o),x(d,p,n,o,i,o),x(p,h,i,o,i,a),m-=g,v-=g,_+=g,y+=g;var b=1/Math.max(_-m,y-v);return{scale:b,x:m*b,y:v*b,x2:_*b,y2:y*b,projection:t}}function em(e,t){var r=t.x,i=t.y;return new K(((r-(arguments.length>2&&void 0!==arguments[2]?arguments[2]:0))*e.scale-e.x)*ii,(i*e.scale-e.y)*ii)}var tm=W.mat4.identity(new Float32Array(16)),rm=(function(){return m((function e(t){p(this,e),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]}),[{key:"project",value:function(e,t){return{x:0,y:0,z:0}}},{key:"unproject",value:function(e,t){return new Jl(0,0)}},{key:"projectTilePoint",value:function(e,t,r){return{x:e,y:t,z:0}}},{key:"locationPoint",value:function(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return e._coordinatePoint(e.locationCoordinate(t),r)}},{key:"pixelsPerMeter",value:function(e,t){return ru(1,e)*t}},{key:"pixelSpaceConversion",value:function(e,t,r){return 1}},{key:"farthestPixelDistance",value:function(e){return Kp(e,e.pixelsPerMeter)}},{key:"pointCoordinate",value:function(e,t,r,i){var n=e.horizonLineFromTop(!1),a=new K(t,Math.max(n,r));return e.rayIntersectionCoordinate(e.pointRayIntersection(a,i))}},{key:"pointCoordinate3D",value:function(e,t,r){var i=new K(t,r);if(e.elevation)return e.elevation.pointCoordinate(i);var n=this.pointCoordinate(e,i.x,i.y,0);return[n.x,n.y,n.z]}},{key:"isPointAboveHorizon",value:function(e,t){if(e.elevation&&e.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(e,t.x,t.y);var r=e.horizonLineFromTop();return t.y0?t<-hm+r&&(t=-hm+r):t>hm-r&&(t=hm-r);var a=n/Math.pow(fm(t),i),o=a*Math.sin(i*e),s=n-a*Math.cos(i*e);return o=.5*(o/Math.PI+.5),s=.5*(s/Math.PI+.5),{x:o,y:this.southernCenter?s:1-s,z:0}}},{key:"unproject",value:function(e,t){e=(2*e-.5)*Math.PI,this.southernCenter&&(t=1-t),t=(2*(1-t)-.5)*Math.PI;var r=this.n,i=this.f,n=i-t,a=Math.sign(n),o=Math.sign(r)*Math.sqrt(e*e+n*n),s=Math.atan2(e,Math.abs(n))*a;n*r<0&&(s-=Math.PI*Math.sign(e)*a);var l=le(ie(s/r)+this.center[0],-180,180),u=le(ie(2*Math.atan(Math.pow(i/o,1/r))-hm),-85.051129,ou);return new Jl(l,this.southernCenter?-u:u)}}])})(rm),pm=(function(e){function t(e){var r;return p(this,t),(r=T(this,t,[e])).wrap=!0,r.supportsWorldCopies=!0,r.supportsTerrain=!0,r.supportsFog=!0,r.supportsFreeCamera=!0,r.isReprojectedInTileSpace=!1,r.unsupportedLayers=[],r.range=null,r}return y(t,e),m(t,[{key:"project",value:function(e,t){return{x:eu(e),y:tu(t),z:0}}},{key:"unproject",value:function(e,t){var r=iu(e),i=nu(t);return new Jl(r,i)}}])})(rm),mm=re(ou),vm=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"project",value:function(e,t){var r=(t=re(t))*t,i=r*r;return{x:.5*((e=re(e))*(.8707-.131979*r+i*(i*(.003971*r-.001529*i)-.013791))/Math.PI+.5),y:1-.5*(t*(1.007226+r*(.015085+i*(.028874*r-.044475-.005916*i)))/Math.PI+1),z:0}}},{key:"unproject",value:function(e,t){e=(2*e-.5)*Math.PI;var r=t=(2*(1-t)-1)*Math.PI,i=25,n=0,a=r*r;do{var o=(a=r*r)*a;r=le(r-(n=(r*(1.007226+a*(.015085+o*(.028874*a-.044475-.005916*o)))-t)/(1.007226+a*(.045255+o*(.259866*a-.311325-.06507600000000001*o)))),-mm,mm)}while(Math.abs(n)>1e-6&&--i>0);var s=le(ie(e/(.8707+(a=r*r)*(a*(a*a*a*(.003971-.001529*a)-.013791)-.131979))),-180,180),l=ie(r);return new Jl(s,l)}}])})(rm),_m=re(ou),ym=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t,[{key:"project",value:function(e,t){t=re(t),e=re(e);var r=Math.cos(t),i=2/Math.PI,n=Math.acos(r*Math.cos(e/2)),a=Math.sin(n)/n,o=.5*(e*i+2*r*Math.sin(e/2)/a)||0,s=.5*(t+Math.sin(t)/a)||0;return{x:.5*(o/Math.PI+.5),y:1-.5*(s/Math.PI+1),z:0}}},{key:"unproject",value:function(e,t){var r=e=(2*e-.5)*Math.PI,i=t=(2*(1-t)-1)*Math.PI,n=25,a=1e-6,o=0,s=0;do{var l=Math.cos(i),u=Math.sin(i),c=2*u*l,h=u*u,f=l*l,d=Math.cos(r/2),p=Math.sin(r/2),m=2*d*p,v=p*p,_=1-f*d*d,y=_?1/_:0,g=_?Math.acos(l*d)*Math.sqrt(1/_):0,x=.5*(2*g*l*p+2*r/Math.PI)-e,b=.5*(g*u+i)-t,w=.5*y*(f*v+g*l*d*h)+1/Math.PI,k=y*(m*c/4-g*u*p),T=.125*y*(c*p-g*u*f*m),M=.5*y*(h*d+g*v*l)+.5,S=k*T-M*w;s=(x*T-b*w)/S,r=le(r-(o=(b*k-x*M)/S),-Math.PI,Math.PI),i=le(i-s,-_m,_m)}while((Math.abs(o)>a||Math.abs(s)>a)&&--n>0);return new Jl(ie(r),ie(i))}}])})(rm),gm=(function(e){function t(e){var r;return p(this,t),(r=T(this,t,[e])).center=e.center||[0,0],r.parallels=e.parallels||[0,0],r.cosPhi=Math.max(.01,Math.cos(re(r.parallels[0]))),r.scale=1/(2*Math.max(Math.PI*r.cosPhi,1/r.cosPhi)),r.wrap=!0,r.supportsWorldCopies=!0,r}return y(t,e),m(t,[{key:"project",value:function(e,t){var r=this.scale,i=this.cosPhi;return{x:re(e)*i*r+.5,y:-Math.sin(re(t))/i*r+.5,z:0}}},{key:"unproject",value:function(e,t){var r=this.scale,i=this.cosPhi,n=-(t-.5)/r,a=le(ie((e-.5)/r)/i,-180,180),o=Math.asin(le(n*i,-1,1)),s=le(ie(o),-85.051129,ou);return new Jl(a,s)}}])})(rm),xm=(function(e){function t(e){var r;return p(this,t),(r=T(this,t,[e])).requiresDraping=!0,r.supportsWorldCopies=!1,r.supportsFog=!0,r.zAxisUnit="pixels",r.unsupportedLayers=["debug"],r.range=[3,5],r}return y(t,e),m(t,[{key:"projectTilePoint",value:function(e,t,r){var i=xc(e,t,r),n=kc(pc(r));return W.vec3.transformMat4(i,i,n),{x:i[0],y:i[1],z:i[2]}}},{key:"locationPoint",value:function(e,t){var r=Wl(t.lat,t.lng),i=W.vec3.normalize([],r),n=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(t),e._centerAltitude):e._centerAltitude,a=ru(1,0)*ii*n;W.vec3.scaleAndAdd(r,r,i,a);var o=W.mat4.identity(new Float64Array(16));return W.mat4.multiply(o,e.pixelMatrix,e.globeMatrix),W.vec3.transformMat4(r,r,o),new K(r[0],r[1])}},{key:"pixelsPerMeter",value:function(e,t){return ru(1,0)*t}},{key:"pixelSpaceConversion",value:function(e,t,r){var i=ru(1,e)*t,n=Ft(ru(1,45)*t,i,r);return this.pixelsPerMeter(e,t)/n}},{key:"createTileMatrix",value:function(e,t,r){var i=Tc(pc(r.canonical));return W.mat4.multiply(new Float64Array(16),e.globeMatrix,i)}},{key:"createInversionMatrix",value:function(e,t){var r=e.center,i=kc(pc(t));return W.mat4.rotateY(i,i,re(r.lng)),W.mat4.rotateX(i,i,re(r.lat)),W.mat4.scale(i,i,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(i)}},{key:"pointCoordinate",value:function(e,t,r,i){return hc(e,t,r,!0)||new hu(0,0)}},{key:"pointCoordinate3D",value:function(e,t,r){var i=this.pointCoordinate(e,t,r,0);return[i.x,i.y,i.z]}},{key:"isPointAboveHorizon",value:function(e,t){return!hc(e,t.x,t.y,!1)}},{key:"farthestPixelDistance",value:function(e){var t=(function(e,t){var r,i=e.cameraToCenterDistance,n=e._centerAltitude*t,a=e._camera,o=e._camera.forward(),s=W.vec3.add([],W.vec3.scale([],o,-i),[0,0,n]),l=e.worldSize/(2*Math.PI),u=[0,0,-l],c=e.width/e.height,h=Math.tan(e.fovAboveCenter),f=W.vec3.scale([],a.up(),h),d=W.vec3.scale([],a.right(),h*c),p=W.vec3.normalize([],W.vec3.add([],W.vec3.add([],o,f),d)),m=[];if(new tc(s,p).closestPointOnSphere(u,l,m)){var v=W.vec3.add([],m,u),_=W.vec3.sub([],v,s);r=Math.cos(e.fovAboveCenter)*W.vec3.length(_)}else{var y=W.vec3.sub([],s,u),g=W.vec3.sub([],u,s);W.vec3.normalize(g,g);var x=W.vec3.length(y)-l;r=Math.sqrt(x*(x+2*l));var b=Math.acos(r/(l+x))-Math.acos(W.vec3.dot(o,g));r*=Math.cos(b)}return 1.01*r})(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),r=Ic(e.zoom);if(r>0){var i=Kp(e,ru(1,e.center.lat)*e.worldSize),n=e.worldSize/(2*Math.PI),a=Math.max(e.width,e.height)/e.worldSize*Math.PI;return Ft(t,i+n*(1-Math.cos(a)),Math.pow(r,10))}return t}},{key:"upVector",value:function(e,t,r){return xc(t,r,e,1)}},{key:"upVectorScale",value:function(e){return{metersToTile:uc(bc(pc(e)))}}}])})(pm);function bm(e){var t=e.parallels,r=!!t&&Math.abs(t[0]+t[1])<.01;switch(e.name){case"mercator":return new pm(e);case"equirectangular":return new cm(e);case"naturalEarth":return new vm(e);case"equalEarth":return new um(e);case"winkelTripel":return new ym(e);case"albers":return r?new gm(e):new im(e);case"lambertConformalConic":return r?new gm(e):new dm(e);case"globe":return new xm(e)}throw new Error(`Invalid projection name: ${e.name}`)}var wm=tf.VectorTileFeature.types,km=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function Tm(e,t,r,i,n,a,o,s,l,u,c,h,f){var d=s?Math.min($p,Math.round(s[0])):0,p=s?Math.min($p,Math.round(s[1])):0;e.emplaceBack(t,r,Math.round(32*i),Math.round(32*n),a,o,(d<<1)+(l?1:0),p,16*u,16*c,256*h,256*f)}function Mm(e,t,r){e.emplaceBack(t,r)}function Sm(e,t,r,i,n,a,o){e.emplaceBack(t,r,i,n,a,o)}function Em(e,t,r,i,n){e.emplaceBack(t,r,i,n),e.emplaceBack(t,r,i,n),e.emplaceBack(t,r,i,n),e.emplaceBack(t,r,i,n)}function Im(e){for(var t of e.sections)if(go(t.text))return!0;return!1}var Am=(function(){return m((function e(t){p(this,e),this.layoutVertexArray=new Es,this.indexArray=new Ls,this.programConfigurations=t,this.segments=new ul,this.dynamicLayoutVertexArray=new ws,this.opacityVertexArray=new As,this.placedSymbolArray=new Js,this.iconTransitioningVertexArray=new Cs,this.globeExtVertexArray=new Is,this.zOffsetVertexArray=new Fs}),[{key:"isEmpty",value:function(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length&&0===this.iconTransitioningVertexArray.length}},{key:"upload",value:function(e,t,r,i,n){this.isEmpty()||(r&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Md.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,t),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,Ed.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,km,!0),this.iconTransitioningVertexArray.length>0&&(this.iconTransitioningVertexBuffer=e.createVertexBuffer(this.iconTransitioningVertexArray,Ad.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,Sd.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||n)&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,Id.members,!0)),this.opacityVertexBuffer.itemSize=1),(r||i)&&this.programConfigurations.upload(e))}},{key:"destroy",value:function(){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())}}])})();ca(Am,"SymbolBuffers");var Cm=(function(){return m((function e(t,r,i){p(this,e),this.layoutVertexArray=new t,this.layoutAttributes=r,this.indexArray=new i,this.segments=new ul,this.collisionVertexArray=new Rs,this.collisionVertexArrayExt=new ws}),[{key:"upload",value:function(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,Cd.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,Pd.members,!0)}},{key:"destroy",value:function(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}])})();ca(Cm,"CollisionBuffers");var Pm,zm,Dm,Rm=(function(){return m((function e(t){p(this,e),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((function(e){return e.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=W.mat4.identity([]),this.placementViewportMatrix=W.mat4.identity([]);var r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Od(this.zoom,r["text-size"]),this.iconSizeData=Od(this.zoom,r["icon-size"]);var i=this.layers[0].layout,n=i.get("symbol-sort-key"),a=i.get("symbol-z-order");this.canOverlap=i.get("text-allow-overlap")||i.get("icon-allow-overlap")||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==a&&void 0!==n.constantOr(1),this.sortFeaturesByY=("viewport-y"===a||"auto"===a&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=i.get("text-writing-mode").map((function(e){return Qd[e]})),this.stateDependentLayerIds=this.layers.filter((function(e){return e.isStateDependent()})).map((function(e){return e.id})),this.sourceID=t.sourceID,this.projection=t.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=i.get("symbol-z-elevate"),this.activeReplacements=[],this.replacementUpdateTime=0}),[{key:"createArrays",value:function(){this.text=new Am(new Ol(this.layers,{zoom:this.zoom,lut:this.lut},(function(e){return e.startsWith("text")||e.startsWith("symbol")}))),this.icon=new Am(new Ol(this.layers,{zoom:this.zoom,lut:this.lut},(function(e){return e.startsWith("icon")||e.startsWith("symbol")}))),this.glyphOffsetArray=new el,this.lineVertexArray=new tl,this.symbolInstances=new Qs}},{key:"calculateGlyphDependencies",value:function(e,t,r,i,n){for(var a=0;a0)&&("constant"!==l.value.kind||l.value.value.length>0),f="constant"!==c.value.kind||!!c.value.value||Object.keys(c.parameters).length>0,d=o.get("symbol-sort-key");if(this.features=[],h||f){var p=t.iconDependencies,m=t.glyphDependencies,v=t.availableImages,_=new zo(this.zoom),y=function(){var e,t,u=a._featureFilter.needGeometry,c=xu(x,u);if(!a._featureFilter.filter(_,c,r))return 0;if(u||(c.geometry=gu(x,r,i)),s&&1!==x.type&&r.z<=5)for(var y=c.geometry,g=function(e,t){var i=xc(e.x,e.y,r,1),n=xc(t.x,t.y,r,1);return W.vec3.dot(i,n)<.98078528056},T=0;T=0,e.sections))if(P.image)p[P.image.namePrimary]=!0;else{var z=ho(e.toString()),D=P.fontStack||A,R=m[D]=m[D]||{};n.calculateGlyphDependencies(P.text,R,C,n.allowVerticalPlacement,z)}}};for(var g of e){var x=g.feature,b=g.id,w=g.index,k=g.sourceLayerIndex;y()}"line"===o.get("symbol-placement")&&(this.features=(function(e){var t={},r={},i=[],n=0;function a(t){i.push(e[t]),n++}function o(e,t,n){var a=r[e];return delete r[e],r[t]=a,i[a].geometry[0].pop(),i[a].geometry[0]=i[a].geometry[0].concat(n[0]),a}function s(e,r,n){var a=t[r];return delete t[r],t[e]=a,i[a].geometry[0].shift(),i[a].geometry[0]=n[0].concat(i[a].geometry[0]),a}function l(e,t,r){var i=r?t[0][t[0].length-1]:t[0][0];return`${e}:${i.x}:${i.y}`}for(var u=0;ue.length&&e.resize(r);for(var n=-t;n<0;n++)e.emplace(n+r,i)},t=function(e,t,r){(i+=t)>e.length&&e.resize(i);for(var n=-t;n<0;n++)e.emplace(n+i,r)};if(this.zOffsetBuffersNeedUpload){this.zOffsetBuffersNeedUpload=!1;for(var r=0,i=0,n=0;n0;if((o>0||s>0)&&(e(this.text.zOffsetVertexArray,o,u),e(this.text.zOffsetVertexArray,s,u)),c){var h=a.placedIconSymbolIndex,f=a.verticalPlacedIconSymbolIndex;h>=0&&t(this.icon.zOffsetVertexArray,l,u),f>=0&&t(this.icon.zOffsetVertexArray,a.numVerticalIconVertices,u)}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray)}}},{key:"isEmpty",value:function(){return 0===this.symbolInstances.length&&!this.hasRTLText}},{key:"uploadPending",value:function(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}},{key:"upload",value:function(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.uploaded=!0}},{key:"destroyDebugData",value:function(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}},{key:"getProjection",value:function(){return this.projectionInstance||(this.projectionInstance=bm(this.projection)),this.projectionInstance}},{key:"destroy",value:function(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}},{key:"addToLineVertexArray",value:function(e,t){var r=this.lineVertexArray.length;if(void 0!==e.segment)for(var i of t){var n=i.x,a=i.y;this.lineVertexArray.emplaceBack(n,a)}return{lineStartIndex:r,lineLength:this.lineVertexArray.length-r}}},{key:"addSymbols",value:function(e,t,r,i,n,a,o,s,l,u,c,h,f,d,p,m){for(var v=e.indexArray,_=e.layoutVertexArray,y=e.globeExtVertexArray,g=e.segments.prepareSegment(4*t.length,_,v,this.canOverlap?a.sortKey:void 0),b=this.glyphOffsetArray.length,w=g.vertexLength,k=this.allowVerticalPlacement&&o===Qd.vertical?Math.PI/2:0,T=a.text&&a.text.sections,M=0;M=0?t.rightJustifiedTextSymbolIndex:t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.leftJustifiedTextSymbolIndex>=0?t.leftJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex>=0?t.verticalPlacedTextSymbolIndex:i),a=Bd(this.textSizeData,e,n)/Rd;return this.tilePixelRatio*a}},{key:"getSymbolInstanceIconSize",value:function(e,t,r){var i=this.icon.placedSymbolArray.get(r),n=Bd(this.iconSizeData,e,i);return this.tilePixelRatio*n}},{key:"_commitDebugCollisionVertexUpdate",value:function(e,t,r,i){e.emplaceBack(t,-r,-r,i),e.emplaceBack(t,r,-r,i),e.emplaceBack(t,r,r,i),e.emplaceBack(t,-r,r,i)}},{key:"_updateTextDebugCollisionBoxes",value:function(e,t,r,i,n,a){for(var o=i;o0}},{key:"hasIconData",value:function(){return this.icon.segments.get().length>0}},{key:"hasDebugData",value:function(){return this.textCollisionBox&&this.iconCollisionBox}},{key:"hasTextCollisionBoxData",value:function(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}},{key:"hasIconCollisionBoxData",value:function(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}},{key:"hasIconTextFit",value:function(){return this.hasAnyIconTextFit}},{key:"addIndicesForPlacedSymbol",value:function(e,t){for(var r=e.placedSymbolArray.get(t),i=r.vertexStartIndex+4*r.numGlyphs,n=r.vertexStartIndex;n1||this.icon.segments.get().length>1)){for(var t of(this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[],this.symbolInstanceIndexes)){var r=this.symbolInstances.get(t);this.featureSortOrder.push(r.featureIndex);var i=r.rightJustifiedTextSymbolIndex,n=r.centerJustifiedTextSymbolIndex,a=r.leftJustifiedTextSymbolIndex,o=r.verticalPlacedTextSymbolIndex,s=r.placedIconSymbolIndex,l=r.verticalPlacedIconSymbolIndex;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),n>=0&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),a>=0&&a!==n&&a!==i&&this.addIndicesForPlacedSymbol(this.text,a),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),l>=0&&this.addIndicesForPlacedSymbol(this.icon,l)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}])})();ca(Rm,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Rm.addDynamicAttributes=Em;var Lm=(function(){return m((function e(t){p(this,e),this.type=t.property.overrides?t.property.overrides.runtimeType:qt,this.defaultValue=t}),[{key:"evaluate",value:function(e){if(e.formattedSection){var t=this.defaultValue.property.overrides;if(t&&t.hasOverride(e.formattedSection))return t.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}},{key:"eachChild",value:function(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression)}},{key:"outputDefined",value:function(){return!1}},{key:"serialize",value:function(){return null}}])})();ca(Lm,"FormatSectionOverride",{omit:["defaultValue"]});var Om,Bm,Fm,Nm,Vm=function(){return Dm||(Dm={layout:Pm||(Pm=new qo({"symbol-placement":new Uo(Zo.layout_symbol["symbol-placement"]),"symbol-spacing":new Uo(Zo.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Uo(Zo.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new jo(Zo.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Uo(Zo.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new Uo(Zo.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new Uo(Zo.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Uo(Zo.layout_symbol["icon-ignore-placement"]),"icon-optional":new Uo(Zo.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Uo(Zo.layout_symbol["icon-rotation-alignment"]),"icon-size":new jo(Zo.layout_symbol["icon-size"]),"icon-text-fit":new jo(Zo.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new jo(Zo.layout_symbol["icon-text-fit-padding"]),"icon-image":new jo(Zo.layout_symbol["icon-image"]),"icon-rotate":new jo(Zo.layout_symbol["icon-rotate"]),"icon-padding":new Uo(Zo.layout_symbol["icon-padding"]),"icon-keep-upright":new Uo(Zo.layout_symbol["icon-keep-upright"]),"icon-offset":new jo(Zo.layout_symbol["icon-offset"]),"icon-anchor":new jo(Zo.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Uo(Zo.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Uo(Zo.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Uo(Zo.layout_symbol["text-rotation-alignment"]),"text-field":new jo(Zo.layout_symbol["text-field"]),"text-font":new jo(Zo.layout_symbol["text-font"]),"text-size":new jo(Zo.layout_symbol["text-size"]),"text-max-width":new jo(Zo.layout_symbol["text-max-width"]),"text-line-height":new jo(Zo.layout_symbol["text-line-height"]),"text-letter-spacing":new jo(Zo.layout_symbol["text-letter-spacing"]),"text-justify":new jo(Zo.layout_symbol["text-justify"]),"text-radial-offset":new jo(Zo.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Uo(Zo.layout_symbol["text-variable-anchor"]),"text-anchor":new jo(Zo.layout_symbol["text-anchor"]),"text-max-angle":new Uo(Zo.layout_symbol["text-max-angle"]),"text-writing-mode":new Uo(Zo.layout_symbol["text-writing-mode"]),"text-rotate":new jo(Zo.layout_symbol["text-rotate"]),"text-padding":new Uo(Zo.layout_symbol["text-padding"]),"text-keep-upright":new Uo(Zo.layout_symbol["text-keep-upright"]),"text-transform":new jo(Zo.layout_symbol["text-transform"]),"text-offset":new jo(Zo.layout_symbol["text-offset"]),"text-allow-overlap":new Uo(Zo.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Uo(Zo.layout_symbol["text-ignore-placement"]),"text-optional":new Uo(Zo.layout_symbol["text-optional"]),visibility:new Uo(Zo.layout_symbol.visibility)})),paint:zm||(zm=new qo({"icon-opacity":new jo(Zo.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new jo(Zo.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new jo(Zo.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new jo(Zo.paint_symbol["text-emissive-strength"]),"icon-color":new jo(Zo.paint_symbol["icon-color"]),"icon-halo-color":new jo(Zo.paint_symbol["icon-halo-color"]),"icon-halo-width":new jo(Zo.paint_symbol["icon-halo-width"]),"icon-halo-blur":new jo(Zo.paint_symbol["icon-halo-blur"]),"icon-translate":new Uo(Zo.paint_symbol["icon-translate"]),"icon-translate-anchor":new Uo(Zo.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new jo(Zo.paint_symbol["icon-image-cross-fade"]),"text-opacity":new jo(Zo.paint_symbol["text-opacity"]),"text-occlusion-opacity":new jo(Zo.paint_symbol["text-occlusion-opacity"]),"text-color":new jo(Zo.paint_symbol["text-color"],{runtimeType:Wt,getOverride:function(e){return e.textColor},hasOverride:function(e){return!!e.textColor}}),"text-halo-color":new jo(Zo.paint_symbol["text-halo-color"]),"text-halo-width":new jo(Zo.paint_symbol["text-halo-width"]),"text-halo-blur":new jo(Zo.paint_symbol["text-halo-blur"]),"text-translate":new Uo(Zo.paint_symbol["text-translate"]),"text-translate-anchor":new Uo(Zo.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new Uo(Zo.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new Uo(Zo.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new Uo(Zo.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new Uo(Zo.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new jo(Zo.paint_symbol["symbol-z-offset"]),"symbol-elevation-reference":new Uo(Zo.paint_symbol["symbol-elevation-reference"])}))},Dm)},Um=(function(e){function t(e,r,i,n){var a;return p(this,t),(a=T(this,t,[e,Vm(),r,i,n]))._colorAdjustmentMatrix=W.mat4.identity([]),a.hasInitialOcclusionOpacityProperties=void 0!==e.paint&&("icon-occlusion-opacity"in e.paint||"text-occlusion-opacity"in e.paint),a}return y(t,e),m(t,[{key:"recalculate",value:function(e,r){k(t,"recalculate",this,3)([e,r]),"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"));var i=this.layout.get("text-writing-mode");if(i){var n=[];for(var a of i)n.indexOf(a)<0&&n.push(a);this.layout._values["text-writing-mode"]=n}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}},{key:"getColorAdjustmentMatrix",value:function(e,t,r,i){return this._saturation===e&&this._contrast===t&&this._brightnessMin===r&&this._brightnessMax===i||(this._colorAdjustmentMatrix=(function(e,t,r,i){e=Re(e),t=De(t);var n=W.mat4.create(),a=e/3,o=1-2*a,s=[o,a,a,0,a,o,a,0,a,a,o,0,0,0,0,1],l=.5-.5*t,u=i-r;return W.mat4.multiply(n,[u,0,0,0,0,u,0,0,0,0,u,0,r,r,r,1],[t,0,0,0,0,t,0,0,0,0,t,0,l,l,l,1]),W.mat4.multiply(n,n,s),n})(e,t,r,i),this._saturation=e,this._contrast=t,this._brightnessMin=r,this._brightnessMax=i),this._colorAdjustmentMatrix}},{key:"getValueAndResolveTokens",value:function(e,t,r,i){var n=this.layout.get(e).evaluate(t,{},r,i),a=this._unevaluatedLayout._values[e];return a.isDataDriven()||Kn(a.value)||!n?n:(function(e,t){return t.replace(/{([^{}]+)}/g,(function(t,r){return r in e?String(e[r]):""}))})(t.properties,n)}},{key:"createBucket",value:function(e){return new Rm(e)}},{key:"queryRadius",value:function(){return 0}},{key:"queryIntersectsFeature",value:function(){return!1}},{key:"_setPaintOverrides",value:function(){for(var e of Vm().paint.overridableProperties)if(t.hasPaintOverride(this.layout,e)){var r,i=this.paint.get(e),n=new Lm(i),a=new Jn(n,i.property.specification,this.scope,this.options);r="constant"===i.value.kind||"source"===i.value.kind?new ea("source",a):new ta("composite",a,i.value.zoomStops,i.value._interpolationType),this.paint._values[e]=new No(i.property,r,i.parameters)}}},{key:"_handleOverridablePaintPropertyUpdate",value:function(e,r,i){return!(!this.layout||r.isDataDriven()||i.isDataDriven())&&t.hasPaintOverride(this.layout,e)}},{key:"getProgramIds",value:function(){return["symbol"]}},{key:"getDefaultProgramParams",value:function(e,t,r){return{config:new Ll(this,{zoom:t,lut:r}),overrideFog:!1}}}],[{key:"hasPaintOverride",value:function(e,t){var r=e.get("text-field"),i=Vm().paint.properties[t],n=!1,a=function(e){for(var t of e)if(i.overrides&&i.overrides.hasOverride(t))return void(n=!0)};if("constant"===r.value.kind&&r.value.value instanceof lr)a(r.value.value.sections);else if("source"===r.value.kind){var o=function(e){n||(e instanceof pr&&fr(e.value)===Kt?a(e.value.sections):e instanceof yr?a(e.sections):e.eachChild(o))},s=r.value;s._styleExpression&&o(s._styleExpression.expression)}return n}}])})(hs),jm=ms([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);function Gm(e){switch(e){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.RGBA;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.DEPTH_COMPONENT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.DEPTH_STENCIL;case WebGL2RenderingContext.R8:case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.RED}}function qm(e){switch(e){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.UNSIGNED_SHORT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.UNSIGNED_INT_24_8;case WebGL2RenderingContext.R8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.FLOAT}}var Zm=(function(){return m((function e(t,r,i,n){p(this,e),this.context=t,this.format=i,this.useMipmap=n&&n.useMipmap,this.texture=t.gl.createTexture(),this.update(r,{premultiply:n&&n.premultiply})}),[{key:"update",value:function(e,t){var r=e&&e instanceof HTMLVideoElement&&0===e.width?e.videoWidth:e.width,i=e&&e instanceof HTMLVideoElement&&0===e.height?e.videoHeight:e.height,n=this.context,a=n.gl,o=t&&t.position?t.position:{x:0,y:0},s=o.x,l=o.y,u=Math.max(s+r,this.size?this.size[0]:0),c=Math.max(l+i,this.size?this.size[1]:0);!this.size||this.size[0]===u&&this.size[1]===c||(a.bindTexture(a.TEXTURE_2D,null),a.deleteTexture(this.texture),this.texture=a.createTexture(),this.size=null),a.bindTexture(a.TEXTURE_2D,this.texture),n.pixelStoreUnpackFlipY.set(!1),n.pixelStoreUnpack.set(1),n.pixelStoreUnpackPremultiplyAlpha.set(this.format===a.RGBA8&&(!t||!1!==t.premultiply));var h=e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||ImageBitmap&&e instanceof ImageBitmap;if(!this.size&&u>0&&c>0){var f=this.useMipmap?Math.floor(Math.log2(Math.max(u,c)))+1:1;a.texStorage2D(a.TEXTURE_2D,f,this.format,u,c),this.size=[u,c]}if(this.size)if(h)a.texSubImage2D(a.TEXTURE_2D,0,s,l,Gm(this.format),qm(this.format),e);else{var d=e.data;d&&a.texSubImage2D(a.TEXTURE_2D,0,s,l,r,i,Gm(this.format),qm(this.format),d)}this.useMipmap&&a.generateMipmap(a.TEXTURE_2D)}},{key:"bind",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=this.context.gl;i.bindTexture(i.TEXTURE_2D,this.texture),e!==this.minFilter&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,e),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,this.useMipmap&&!r?e===i.NEAREST?i.NEAREST_MIPMAP_NEAREST:i.LINEAR_MIPMAP_LINEAR:e),this.minFilter=e),t!==this.wrapS&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,t),this.wrapS=t)}},{key:"bindExtraParam",value:function(e,t,r,i){var n=this.context.gl;n.bindTexture(n.TEXTURE_2D,this.texture),t!==this.magFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,t),this.magFilter=t),e!==this.minFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,this.useMipmap?e===n.NEAREST?n.NEAREST_MIPMAP_NEAREST:n.LINEAR_MIPMAP_LINEAR:e),this.minFilter=e),r!==this.wrapS&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,r),this.wrapS=r),i!==this.wrapT&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,i),this.wrapT=i)}},{key:"destroy",value:function(){this.context.gl.deleteTexture(this.texture),this.texture=null}}])})(),$m=(function(){return m((function e(t,r){p(this,e),this.context=t,this.texture=r}),[{key:"bind",value:function(e,t){var r=this.context.gl;r.bindTexture(r.TEXTURE_2D,this.texture),e!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,e),this.minFilter=e),t!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,t),this.wrapS=t)}}])})();function Hm(e,t,r,i,n,a,o,s){var l=[e,t,1,r,i,1,n,a,1],u=[o,s,1],c=W.mat3.adjoint([],l),h=W.vec3.transformMat3(u,u,c),f=x(h,3),d=f[0],p=f[1],m=f[2];return W.mat3.multiply(l,l,[d,0,0,0,p,0,0,0,m])}function Wm(e,t,r,i,n,a,o,s){var l=(function(e,t,r,i,n,a,o,s){var l=Hm(0,0,1,0,1,1,0,1),u=Hm(e,t,r,i,n,a,o,s),c=W.mat3.adjoint([],l);return W.mat3.multiply(u,u,c)})(e,t,r,i,n,a,o,s);return[l[2]/l[8]/ii,l[5]/l[8]/ii]}function Xm(e){return[e[0],Math.min(Math.max(e[1],-85.051129),ou)]}var Ym,Jm,Km,Qm,ev,tv=(function(e){function t(e,r,i,n){var a;return p(this,t),(a=T(this,t)).id=e,a.dispatcher=i,a.coordinates=r.coordinates,a.type="image",a.minzoom=0,a.maxzoom=22,a.tileSize=512,a.tiles={},a._loaded=!1,a.onNorthPole=!1,a.onSouthPole=!1,a.setEventedParent(n),a.options=r,a._dirty=!1,a}return y(t,e),m(t,[{key:"load",value:function(e,t){var r=this;if(this._loaded=t||!1,this.fire(new It("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return e&&(this.coordinates=e),this._loaded=!0,void this._finishLoading();this._imageRequest=wt(this.map._requestManager.transformRequest(this.url,ct.Image),(function(t,i){r._imageRequest=null,r._loaded=!0,t?r.fire(new At(t)):i&&(r.image=i instanceof HTMLImageElement?Ze.getImageData(i):i,r._dirty=!0,r.width=r.image.width,r.height=r.image.height,e&&(r.coordinates=e),r._finishLoading())}))}},{key:"loaded",value:function(){return this._loaded}},{key:"updateImage",value:function(e){return e.url?(this._imageRequest&&e.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=e.url,this.load(e.coordinates,this._loaded),this):this}},{key:"setTexture",value:function(e){if(!(e.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new $m(this.map.painter.context,e.handle),this.width=e.dimensions[0],this.height=e.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}},{key:"_finishLoading",value:function(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new It("data",{dataType:"source",sourceDataType:"metadata"})))}},{key:"onAdd",value:function(e){this.map=e,this.load()}},{key:"onRemove",value:function(e){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof $m||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy())}},{key:"setCoordinates",value:function(e){if(this.coordinates=e,this._boundsArray=void 0,this._unsupportedCoords=!1,!e.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;var t=e[0][1],r=e[0][1];for(var i of e)i[1]>r&&(r=i[1]),i[1]ou?this.onNorthPole=!0:n<-85.051129&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){var a=e.map(hu.fromLngLat);this.tileID=(function(e){var t=1/0,r=1/0,i=-1/0,n=-1/0;for(var a of e)t=Math.min(t,a.x),r=Math.min(r,a.y),i=Math.max(i,a.x),n=Math.max(n,a.y);var o=Math.max(i-t,n-r),s=Math.max(0,Math.floor(-Math.log(o)/Math.LN2)),l=Math.pow(2,s),u=Math.floor((t+i)/2*l);return u>1&&(u-=1),new Hu(s,u,Math.floor((r+n)/2*l))})(a),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new It("data",{dataType:"source",sourceDataType:"content"})),this}},{key:"_clear",value:function(){this._boundsArray=void 0,this._unsupportedCoords=!1}},{key:"_prepareData",value:function(e){var t=this;for(var r in this.tiles){var i=this.tiles[r];"loaded"!==i.state&&(i.state="loaded",i.texture=this.texture)}if(!(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)){var n=Qp(new Hu(0,0,0),this.map.transform.projection),a=[n.projection.project(this.coordinates[0][0],this.coordinates[0][1]),n.projection.project(this.coordinates[1][0],this.coordinates[1][1]),n.projection.project(this.coordinates[2][0],this.coordinates[2][1]),n.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!(function(e){var t=e[1].x-e[0].x,r=e[1].y-e[0].y,i=e[2].x-e[1].x,n=e[2].y-e[1].y,a=e[3].x-e[2].x,o=e[3].y-e[2].y,s=e[0].x-e[3].x,l=e[0].y-e[3].y,u=t*n-i*r,c=i*o-a*n,h=a*l-s*o,f=s*r-t*l;return u>0&&c>0&&h>0&&f>0||u<0&&c<0&&h<0&&f<0})(a))return console.warn("Image source coordinates are defining non-convex area in the Mercator projection"),void(this._unsupportedCoords=!0);var o=Qp(this.tileID,this.map.transform.projection),s=this.coordinates.map((function(e){var t=o.projection.project(e[0],e[1]);return em(o,t)._round()})),l=x(s,4),u=l[0],c=l[1],h=l[2],f=l[3];this.perspectiveTransform=Wm(u.x,u.y,c.x,c.y,h.x,h.y,f.x,f.y);var d=this._boundsArray=new gs;d.emplaceBack(u.x,u.y,0,0),d.emplaceBack(c.x,c.y,ii,0),d.emplaceBack(f.x,f.y,0,ii),d.emplaceBack(h.x,h.y,ii,ii),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=e.createVertexBuffer(d,jm.members),this.boundsSegments=ul.simpleSegment(0,0,4,2);var p,m,v,_=[],y=(function(e){for(var t=e[0][0],r=t,i=e[0][1],n=i,a=1;ar&&(r=e[a][0]),e[a][1]n&&(n=e[a][1]);return[t,i,r-t,n-i]})([Xm((p=this.coordinates)[0]),Xm(p[1]),Xm(p[2]),Xm(p[3])]),g=x(y,4),b=g[0],w=g[1],k=g[2],T=g[3],M=new gs,S=(function(e){for(var t=e[0].x,r=t,i=e[0].y,n=i,a=1;ar&&(r=e[a].x),e[a].yn&&(n=e[a].y);return[t,i,r-t,n-i]})(a),E=x(S,4),I=E[0],A=E[1],C=E[2],P=E[3],z=function(e){return[(e.x-I)/C,(e.y-A)/P]},D=a.map(z),R=x(D,4),L=R[0],O=R[1],B=R[2],F=R[3],N=(function(e,t,r,i,n,a,o,s){var l=Hm(0,0,1,0,1,1,0,1),u=Hm(e,t,r,i,n,a,o,s),c=W.mat3.adjoint([],u);return W.mat3.multiply(l,l,c)})(L[0],L[1],O[0],O[1],B[0],B[1],F[0],F[1]);this.elevatedGlobePerspectiveTransform=Wm(L[0],L[1],O[0],O[1],B[0],B[1],F[0],F[1]);for(var V=function(e,t){_.push(e.lng);var r=Math.round((e.lng-b)/k*ii),i=Math.round((e.lat-w)/T*ii),n=z(t),a=W.vec3.transformMat3([],[n[0],n[1],1],N),o=Math.round(a[0]/a[2]*ii),s=Math.round(a[1]/a[2]*ii);M.emplaceBack(r,i,o,s)},U=a[3].x-a[0].x,j=a[3].y-a[0].y,G=a[2].x-a[1].x,q=a[2].y-a[1].y,Z=0;Z<65;Z++)for(var $=Z/64,H=[a[0].x+$*U,a[0].y+$*j],X=[a[1].x+$*G,a[1].y+$*q],Y=X[0]-H[0],J=X[1]-H[1],K=0;K<65;K++){var Q=K/64,ee={x:H[0]+Y*Q,y:H[1]+J*Q,z:0};V(n.projection.unproject(ee.x,ee.y),ee)}this.elevatedGlobeVertexBuffer=e.createVertexBuffer(M,jm.members),this.maxLongitudeTriangleSize=0;for(var te=[],re=new Ls,ie=function(e,r,i){re.emplaceBack(e,r,i);var n=_[e],a=_[r],o=_[i],s=Math.min(Math.min(n,a),o),l=Math.max(Math.max(n,a),o)-s;l>t.maxLongitudeTriangleSize&&(t.maxLongitudeTriangleSize=l),te.push(s+l/2)},ne=0;ne<64;ne++)for(var ae=0;ae<64;ae++){var oe=65*ne+ae,se=oe+1,le=oe+65,ue=le+1;ie(oe,le,se),ie(se,le,ue)}m=(function(e,t){var r=Array.from({length:e.length},(function(e,t){return t}));r.sort((function(t,r){return e[t]-e[r]}));for(var i=[],n=new Ls,a=0;a4&&void 0!==arguments[4]?arguments[4]:1/0,a=e.range;if(!a)return 0;var o=Math.min(n,Math.max(r,i)),s=Math.log(o/1024)/Math.LN2;return ue(a[0]+s,a[1]+s,t)}var cv=25e-6;function hv(e,t){var r=le(t.lat,-85.051129,ou),i=new Jl(t.lng-.0045000000000000005,r),n=new Jl(t.lng+.0045000000000000005,r),a=e.project(i.lng,r),o=e.project(n.lng,r),s=hu.fromLngLat(i),l=hu.fromLngLat(n),u=o.x-a.x,c=o.y-a.y,h=l.x-s.x,f=l.y-s.y,d=Math.sqrt((h*h+f*f)/(u*u+c*c));return Math.log(d)/Math.LN2}function fv(e,t,r){var i=Math.cos(r),n=Math.sin(r);return{x:e*i-t*n,y:e*n+t*i}}function dv(e,t,r){W.mat4.identity(e),W.mat4.rotateZ(e,e,re(t[2])),W.mat4.rotateX(e,e,re(t[0])),W.mat4.rotateY(e,e,re(t[1])),W.mat4.scale(e,e,r),W.mat4.multiply(e,e,[1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1])}function pv(e,t,r,i,n,a,o,s){var l=[r[0]-t[0],r[1]-t[1],0],u=[i[0]-t[0],i[1]-t[1],0];if(W.vec3.length(l)<1e-12||W.vec3.length(u)<1e-12)return W.quat.identity(e);var c=W.vec3.cross([],l,u);W.vec3.normalize(c,c),W.vec3.subtract(u,i,t),l[2]=(a-n)*s,u[2]=(o-n)*s;var h=l;return W.vec3.cross(h,l,u),W.vec3.normalize(h,h),W.quat.rotationTo(e,c,h)}function mv(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=Ic(t.zoom),n=(function(e,t,r){var i=t.worldSize,n=[e[12],e[13],e[14]],a=nu(n[1]/i),o=iu(n[0]/i),s=W.mat4.identity([]),l=ru(1,a)*i,u=ru(1,0)*i*lu(a,t.zoom),c=1/Mc(i),h=u*c;if(r){var f=uv(t.projection,t.zoom,t.width,t.height,1024);h=c*t.projection.pixelSpaceConversion(t.center.lat,i,f)}var d=Wl(a,o);W.vec3.add(d,d,W.vec3.scale([],W.vec3.normalize([],d),l*h*n[2]));var p=(function(e){var t=[e[0],e[1],e[2]],r=[0,1,0],i=W.vec3.cross([],r,t);return W.vec3.cross(r,t,i),0===W.vec3.squaredLength(r)&&(r=[0,1,0],W.vec3.cross(i,t,r)),W.vec3.normalize(i,i),W.vec3.normalize(r,r),W.vec3.normalize(t,t),[i[0],i[1],i[2],0,r[0],r[1],r[2],0,t[0],t[1],t[2],0,e[0],e[1],e[2],1]})(d);W.mat4.scale(s,s,[h,h,h*l]),W.mat4.translate(s,s,[-n[0],-n[1],-n[2]]);var m=W.mat4.multiply([],t.globeMatrix,p);return W.mat4.multiply(m,m,s),W.mat4.multiply(m,m,e),m})(e,t,r);if(i>0){var a=(function(e,t){var r=t.worldSize,i=ru(1,0)*r*lu(t.center.lat,t.zoom)/Mc(r),n=ru(1,t.center.lat)*r,a=W.mat4.identity([]);return W.mat4.rotateY(a,a,re(t.center.lng)),W.mat4.rotateX(a,a,re(t.center.lat)),W.mat4.translate(a,a,[0,0,jl]),W.mat4.scale(a,a,[i,i,i*n]),W.mat4.translate(a,a,[t.point.x-.5*r,t.point.y-.5*r,0]),W.mat4.multiply(a,a,e),W.mat4.multiply(a,t.globeMatrix,a)})(e,t);return(function(e,t,r){var i=function(e,t,r){var i=W.vec3.length(e),n=W.vec3.length(t),a=mc(e,t,r);return W.vec3.scale(a,a,1/W.vec3.length(a)*Ft(i,n,r))},n=i([e[0],e[1],e[2]],[t[0],t[1],t[2]],r),a=i([e[4],e[5],e[6]],[t[4],t[5],t[6]],r),o=i([e[8],e[9],e[10]],[t[8],t[9],t[10]],r),s=mc([e[12],e[13],e[14]],[t[12],t[13],t[14]],r);return[n[0],n[1],n[2],0,a[0],a[1],a[2],0,o[0],o[1],o[2],0,s[0],s[1],s[2],1]})(n,a,i)}return n}function vv(e,t,r,i){for(var n=lc.projectAabbCorners(i,r),a=Number.MAX_VALUE,o=-1,s=0;sthis.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}),[{key:"updateFootprints",value:function(e,t){}},{key:"populate",value:function(e,t,r,i){this.tileToMeter=cu(r);var n=this.layers[0]._featureFilter.needGeometry;for(var a of(this.lookup=new Uint8Array(this.lookupDim*this.lookupDim),e)){var o=a.feature,s=a.id,l=a.index,u=a.sourceLayerIndex,c=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,h=xu(o,n);if(this.layers[0]._featureFilter.filter(new zo(this.zoom),h,r)){var f={id:c,sourceLayerIndex:u,index:l,geometry:n?h.geometry:gu(o,r,i),properties:o.properties,type:o.type,patterns:{}},d=this.addFeature(f,f.geometry,h);d&&t.featureIndex.insert(o,f.geometry,l,u,this.index,this.instancesPerModel[d].instancedDataArray.length,256)}}this.lookup=null}},{key:"update",value:function(e,t,r,i){for(var n in this.instancesPerModel){var a=this.instancesPerModel[n];for(var o in e)a.idToFeaturesIndex.hasOwnProperty(o)&&(this.evaluate(a.features[a.idToFeaturesIndex[o]],e[o],a,!0),this.uploaded=!1)}this.maxHeight=0}},{key:"updateZoomBasedPaintProperties",value:function(){if(!this.hasZoomDependentProperties)return!1;var e=!1;for(var t in this.instancesPerModel){var r=this.instancesPerModel[t];for(var i of r.features){var n=this.layers[0],a=i.feature,o=this.canonical,s=n.paint.get("model-rotation").evaluate(a,{},o),l=n.paint.get("model-scale").evaluate(a,{},o),u=n.paint.get("model-translation").evaluate(a,{},o);W.vec3.exactEquals(i.rotation,s)&&W.vec3.exactEquals(i.scale,l)&&W.vec3.exactEquals(i.translation,u)||(this.evaluate(i,i.featureStates,r,!0),e=!0)}}return e}},{key:"updateReplacement",value:function(e,t,r,i){if(t.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=t.updateTime;var n=t.getReplacementRegionsForTile(e.toUnwrapped(),!0);if(df(this.activeReplacements,n))return!1;this.activeReplacements=n;var a=!1;for(var o in this.instancesPerModel){var s=this.instancesPerModel[o],l=s.instancedDataArray;for(var u of s.features)for(var c=u.instancedDataOffset,h=u.instancedDataCount,f=0;fii;p=m?p-ii:p;var v=Math.floor(p),_=l.float32[d+1],y=!1;for(var g of this.activeReplacements)if(!uf(g,r,Tv.Model,i)&&!(g.min.x>v||v>g.max.x||g.min.y>_||_>g.max.y)&&(y=gf(yf(v,_,e.canonical,g.footprintTileId.canonical),g.footprint)))break;l.float32[d]=y?p+ii:p,a=a||y!==m}}return a}},{key:"isEmpty",value:function(){for(var e in this.instancesPerModel)if(0!==this.instancesPerModel[e].instancedDataArray.length)return!1;return!0}},{key:"uploadPending",value:function(){return!this.uploaded}},{key:"upload",value:function(e){if(!this.uploaded)for(var t in this.instancesPerModel){var r=this.instancesPerModel[t];r.instancedDataArray.length<0||0===r.instancedDataArray.length||(r.instancedDataBuffer?r.instancedDataBuffer.updateData(r.instancedDataArray):r.instancedDataBuffer=e.createVertexBuffer(r.instancedDataArray,wv.members,!0,void 0,this.instanceCount))}this.uploaded=!0}},{key:"destroy",value:function(){for(var e in this.instancesPerModel){var t=this.instancesPerModel[e];0!==t.instancedDataArray.length&&t.instancedDataBuffer&&t.instancedDataBuffer.destroy()}var r=this.layers[0].modelManager;if(r&&this.modelUris)for(var i of this.modelUris)r.removeModel(i,"")}},{key:"addFeature",value:function(e,t,r){var i=this.layers[0],n=i.layout.get("model-id").evaluate(r,{},this.canonical);if(!n)return we(`modelId is not evaluated for layer ${i.id} and it is not going to get rendered.`),n;Sv(n,!1)&&(this.modelUris.includes(n)||this.modelUris.push(n)),this.instancesPerModel[n]||(this.instancesPerModel[n]=new Cv);var a=this.instancesPerModel[n],o=a.instancedDataArray,s=new Av(r,o.length);for(var l of t)for(var u of l)if(!(u.x<0||u.x>=ii||u.y<0||u.y>=ii)){var c=(this.lookupDim-1)/ii,h=this.lookupDim*(u.y*c|0)+u.x*c|0;if(this.lookup){if(0!==this.lookup[h])continue;this.lookup[h]=1}this.instanceCount++;var f=o.length;o.resize(f+1),a.instancesEvaluatedElevation.push(0),o.float32[16*f]=u.x,o.float32[16*f+1]=u.y}return s.instancedDataCount=a.instancedDataArray.length-s.instancedDataOffset,s.instancedDataCount>0&&(e.id&&(a.idToFeaturesIndex[e.id]=a.features.length),a.features.push(s),this.evaluate(s,{},a,!1)),n}},{key:"getModelUris",value:function(){return this.modelUris}},{key:"evaluate",value:function(e,t,r,i){var n=this.layers[0],a=e.feature,o=this.canonical,s=e.rotation=n.paint.get("model-rotation").evaluate(a,t,o),l=e.scale=n.paint.get("model-scale").evaluate(a,t,o),u=e.translation=n.paint.get("model-translation").evaluate(a,t,o),c=n.paint.get("model-color").evaluate(a,t,o);c.a=n.paint.get("model-color-mix-intensity").evaluate(a,t,o);var h=[];this.maxVerticalOffset10?this.tileToMeter:cu(o,y)),v[m+4]=u[0],v[m+5]=u[1],v[m+6]=u[2]+_,v[m+7]=h[0],v[m+8]=h[1],v[m+9]=h[2],v[m+10]=h[4],v[m+11]=h[5],v[m+12]=h[6],v[m+13]=h[8],v[m+14]=h[9],v[m+15]=h[10],r.instancesEvaluatedElevation[p]=u[2]}}}])})();ca(Pv,"ModelBucket",{omit:["layers"]}),ca(Cv,"PerModelAttributes"),ca(Av,"ModelFeature");var zv=64,Dv={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function Rv(e,t,r,i,n,a,o,s,l){var u=arguments.length>9&&void 0!==arguments[9]&&arguments[9],c=r.zoom,h=r.project(i),f=lu(i.lat,c),p=1/f;W.mat4.identity(e),W.mat4.translate(e,e,[h.x+o[0]*p,h.y+o[1]*p,o[2]]);var m=1,v=1,_=r.worldSize;if(u){if("mercator"===r.projection.name){var y=0;r.elevation&&(y=r.elevation.getAtPointOrZero(new hu(h.x/_,h.y/_),0));var g=W.vec4.transformMat4([],[h.x,h.y,y,1],r.projMatrix)[3]/r.cameraToCenterDistance;m=g,v=g*lu(r.center.lat,c)}else if("globe"===r.projection.name){var x=mv(e,r),b=W.mat4.multiply([],r.projMatrix,x),w=[0,0,0,1];W.vec4.transformMat4(w,w,b);var k=w[3]/r.cameraToCenterDistance,T=Ic(c),M=r.projection.pixelsPerMeter(i.lat,_)*lu(i.lat,c),S=r.projection.pixelsPerMeter(r.center.lat,_)*lu(r.center.lat,c);m=k/Ft(M,su(r.center.lat),T),v=k*f/M,m*=S,v*=S}}else m=p;W.mat4.scale(e,e,[m,m,v]);var E=d(e),I=t.orientation,A=[];if(dv(A,[I[0]+n[0],I[1]+n[1],I[2]+n[2]],a),W.mat4.multiply(e,E,A),s&&r.elevation){var C=0,P=[];if(l&&r.elevation){C=(function(e,t,r,i,n){var a=t.elevation;if(!a)return 0;var o=lc.projectAabbCorners(r,i),s=ru(1,n.lat)*t.worldSize,l=(function(e,t){var r=[0,0,1],i=[{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(var n of i){var a=e[n.corners[0]],o=e[n.corners[1]],s=e[n.corners[2]],l=[o[0]-a[0],o[1]-a[1],t*(o[2]-a[2])],u=W.vec3.cross(l,l,[s[0]-a[0],s[1]-a[1],t*(s[2]-a[2])]);W.vec3.normalize(u,u),n.dotProductWithUp=W.vec3.dot(u,r)}return i.sort((function(e,t){return e.dotProductWithUp-t.dotProductWithUp})),i[0].corners})(o,s),u=o[l[0]],c=o[l[1]],h=o[l[2]],f=o[l[3]],d=a.getAtPointOrZero(new hu(u[0]/t.worldSize,u[1]/t.worldSize),0),p=a.getAtPointOrZero(new hu(c[0]/t.worldSize,c[1]/t.worldSize),0),m=a.getAtPointOrZero(new hu(h[0]/t.worldSize,h[1]/t.worldSize),0),v=a.getAtPointOrZero(new hu(f[0]/t.worldSize,f[1]/t.worldSize),0),_=(d+v)/2,y=(p+m)/2;return _>y?p2&&void 0!==arguments[2]&&arguments[2];e.uploaded||(e.gfxTexture=new Zm(t,e.image,r?t.gl.R8:t.gl.RGBA8,{useMipmap:e.sampler.minFilter>=t.gl.NEAREST_MIPMAP_NEAREST}),e.uploaded=!0,e.image=null)}function Ov(e,t,r){e.indexBuffer=t.createIndexBuffer(e.indexArray,!1,!0),e.vertexBuffer=t.createVertexBuffer(e.vertexArray,_v.members,!1,!0),e.normalArray&&(e.normalBuffer=t.createVertexBuffer(e.normalArray,bv.members,!1,!0)),e.texcoordArray&&(e.texcoordBuffer=t.createVertexBuffer(e.texcoordArray,xv.members,!1,!0)),e.colorArray&&(e.colorBuffer=t.createVertexBuffer(e.colorArray,(12===e.colorArray.bytesPerElement?yv:gv).members,!1,!0)),e.featureArray&&(e.pbrBuffer=t.createVertexBuffer(e.featureArray,kv.members,!0)),e.segments=ul.simpleSegment(0,0,e.vertexArray.length,e.indexArray.length);var i=e.material;i.pbrMetallicRoughness.baseColorTexture&&Lv(i.pbrMetallicRoughness.baseColorTexture,t),i.pbrMetallicRoughness.metallicRoughnessTexture&&Lv(i.pbrMetallicRoughness.metallicRoughnessTexture,t),i.normalTexture&&Lv(i.normalTexture,t),i.occlusionTexture&&Lv(i.occlusionTexture,t,r),i.emissionTexture&&Lv(i.emissionTexture,t)}function Bv(e,t,r){if(e.meshes)for(var i of e.meshes)Ov(i,t,r);if(e.children)for(var n of e.children)Bv(n,t,r)}function Fv(e){if(e.meshes)for(var t of e.meshes)t.indexArray.destroy(),t.vertexArray.destroy(),t.colorArray&&t.colorArray.destroy(),t.normalArray&&t.normalArray.destroy(),t.texcoordArray&&t.texcoordArray.destroy(),t.featureArray&&t.featureArray.destroy();if(e.children)for(var r of e.children)Fv(r)}function Nv(e){if(e.meshes)for(var t of e.meshes)t.vertexBuffer&&(t.vertexBuffer.destroy(),t.indexBuffer.destroy(),t.normalBuffer&&t.normalBuffer.destroy(),t.texcoordBuffer&&t.texcoordBuffer.destroy(),t.colorBuffer&&t.colorBuffer.destroy(),t.pbrBuffer&&t.pbrBuffer.destroy(),t.segments.destroy(),t.material&&((r=t.material).pbrMetallicRoughness.baseColorTexture&&r.pbrMetallicRoughness.baseColorTexture.gfxTexture&&r.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),r.pbrMetallicRoughness.metallicRoughnessTexture&&r.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&r.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),r.normalTexture&&r.normalTexture.gfxTexture&&r.normalTexture.gfxTexture.destroy(),r.emissionTexture&&r.emissionTexture.gfxTexture&&r.emissionTexture.gfxTexture.destroy(),r.occlusionTexture&&r.occlusionTexture.gfxTexture&&r.occlusionTexture.gfxTexture.destroy()));var r;if(e.children)for(var i of e.children)Nv(i)}var Vv=(function(){function e(t,r,i){p(this,e),this._demTile=t,this._dem=this._demTile.dem,this._scale=r,this._offset=i}return m(e,[{key:"tileCoordToPixel",value:function(e,t){var r=t*this._scale+this._offset[1],i=Math.floor(e*this._scale+this._offset[0]),n=Math.floor(r);return new K(i,n)}},{key:"getElevationAt",value:function(e,t,r,i){var n=e*this._scale+this._offset[0],a=t*this._scale+this._offset[1],o=Math.floor(n),s=Math.floor(a),l=this._dem;return i=!!i,r?Ft(Ft(l.get(o,s,i),l.get(o,s+1,i),a-s),Ft(l.get(o+1,s,i),l.get(o+1,s+1,i),a-s),n-o):l.get(o,s,i)}},{key:"getElevationAtPixel",value:function(e,t,r){return this._dem.get(e,t,!!r)}},{key:"getMeterToDEM",value:function(e){return(1<=P)){var j=Uv[U],G=Math.abs(j);G>O&&(L=j,O=G,B=V,F=N)}}if(O>.1){var q=1-(P+.5*Math.abs(B*F))/d,Z=t._dem.get(D,z)+L*q,$=t._dem.get(D+B,z+F),H=t._dem.get(D-B,z-F,!0);(Z-$)*(Z-H)>0&&(Z=($+H)/2),Uv[R]=t._dem.set(D,z,Z),jv[R]=P}}}}}}}o&&(t._demTile.needsDEMTextureUpload=!0,t._dem._timestamp=Ze.now())}}},{key:"getNodesInfo",value:function(){return this.nodesInfo}},{key:"destroy",value:function(){var e=this.getNodesInfo();for(var t of e)Fv(t.node),Nv(t.node)}},{key:"isEmpty",value:function(){return!this.nodesInfo.length}},{key:"updateReplacement",value:function(e,t){if(t.updateTime!==this.replacementUpdateTime){this.replacementUpdateTime=t.updateTime;for(var r=t.getReplacementRegionsForTile(e.toUnwrapped()),i=this.getNodesInfo(),n=function(){var e=i[a].node;i[a].hiddenByReplacement=!!e.footprint&&!r.find((function(t){return t.footprint===e.footprint}))},a=0;au.max[0]||t>u.max[1])){if(!0===s.node.hidden)return{height:1/0,maxHeight:s.feature.properties.height,hidden:!1,verticalScale:s.evaluatedScale[2]};W.mat4.invert(a,s.node.matrix),n[0]=e,n[1]=t,W.vec3.transformMat4(n,n,a);var c=(n[0]-l.aabb.min[0])/(l.aabb.max[0]-l.aabb.min[0])*zv|0,h=Math.min(63,(n[1]-l.aabb.min[1])/(l.aabb.max[1]-l.aabb.min[1])*zv|0)*zv+Math.min(63,c),f=l.heightmap[h];if(!(f<0&&s.node.footprint)){if(s.hiddenByReplacement)return;return{height:f,maxHeight:s.feature.properties.height,hidden:!1,verticalScale:s.evaluatedScale[2]}}if(s.node.footprint.grid.query(new K(e,t),new K(e,t),i),i.length>0)return{height:void 0,maxHeight:s.feature.properties.height,hidden:s.hiddenByReplacement,verticalScale:s.evaluatedScale[2]}}}}}])})();function Wv(e,t){return!e.isLightConstant&&t}function Xv(e,t,r,i,n,a,o,s){var l=(61440&t|(61440&t)>>4)>>8,u=(3840&t|(3840&t)>>4)>>4,c=240&t|(240&t)>>4;r[3]>0&&(l=Ft(l,255*r[0],r[3]),u=Ft(u,255*r[1],r[3]),c=Ft(c,255*r[2],r[3]));var h,f,d,p,m=l<<8|u,v=c<<8|Math.floor(255*i[3]),_=(function(e){var t=le(e,0,2);return Math.min(Math.round(.5*t*255),255)})(i[2])<<8|15*i[0]<<4|15*i[1],y=le(n[0],0,1),g=le(n[1],0,1),x=le(n[2],0,1),b=le(n[3],0,1);if(y!==g&&o!==a&&g!==y){var w=o-a;f=1/(w*(g-y)),d=-(a+w*y)/(w*(g-y));var k=le(n[4],-1,1);p=Math.pow(10,k),h=255*x<<8|255*b}else h=65535,f=0,d=1,p=1;if(e.emplaceBack(m,v,_,h,f,d,p),s){var T=s.length;s.clear();for(var M=0;M>16&65535,c=a?l>>16&65535:65535&l,h=(15&c)<8?15&c:0,f=e.evaluatedRMEA[h],d=e.evaluatedColor[h],p=e.emissionHeightBasedParams[h],m=void 0;if(s&&2===h&&i.lights&&(m=new Zs).resize(10*i.lights.length),Xv(o.featureArray,u,d,f,p,o.aabb.min[2],o.aabb.max[2],m),m&&s){s=!1;var v=i.meshes[i.lightMeshIndex];v.featureArray=m,v.featureArray._trim()}}o.featureArray._trim(),n++}}function Jv(e,t,r,i){var n=1<0&&(r+=_),i+=_,t)){var g=[],x=[];for(var b of y){var w=b.x+n.x,k=b.y+n.y,T=e.projection.projectTilePoint(w,k,c),M=e.projection.upVector(c,b.x,b.y),S=r,E=i;if(o){var I=td(w,k,r,i,o,s,l,u);S+=I.base,E+=I.top}0!==r?v(p,T.x+M[0]*d*S,T.y+M[1]*d*S,T.z+M[2]*d*S):v(p,T.x,T.y,T.z),v(m,T.x+M[0]*d*E,T.y+M[1]*d*E,T.z+M[2]*d*E),W.vec3.transformMat4(p,p,a),W.vec3.transformMat4(m,m,a),g.push(new rf(p[0],p[1],p[2])),x.push(new rf(m[0],m[1],m[2]))}h.push(g),f.push(x)}return[h,f]})(e,t,r,i,n,a,o,s,l,u,c):o?(function(e,t,r,i,n,a,o,s,l){var u=[],c=[],h=[0,0,0,1];for(var f of e){var d=[],p=[];for(var m of f){var v=m.x+i.x,_=m.y+i.y,y=td(v,_,t,r,a,o,s,l);h[0]=v,h[1]=_,h[2]=y.base,h[3]=1,W.vec4.transformMat4(h,h,n),h[3]=Math.max(h[3],1e-5);var g=new rf(h[0]/h[3],h[1]/h[3],h[2]/h[3]);h[0]=v,h[1]=_,h[2]=y.top,h[3]=1,W.vec4.transformMat4(h,h,n),h[3]=Math.max(h[3],1e-5);var x=new rf(h[0]/h[3],h[1]/h[3],h[2]/h[3]);d.push(g),p.push(x)}u.push(d),c.push(p)}return[u,c]})(t,r,i,n,a,o,s,l,u):(function(e,t,r,i,n){var a=[],o=[],s=n[8]*t,l=n[9]*t,u=n[10]*t,c=n[11]*t,h=n[8]*r,f=n[9]*r,d=n[10]*r,p=n[11]*r;for(var m of e){var v=[],_=[];for(var y of m){var g=y.x+i.x,x=y.y+i.y,b=n[0]*g+n[4]*x+n[12],w=n[1]*g+n[5]*x+n[13],k=n[2]*g+n[6]*x+n[14],T=n[3]*g+n[7]*x+n[15],M=b+s,S=w+l,E=k+u,I=Math.max(T+c,1e-5),A=b+h,C=w+f,P=k+d,z=Math.max(T+p,1e-5);v.push(new rf(M/I,S/I,E/I)),_.push(new rf(A/z,C/z,P/z))}a.push(v),o.push(_)}return[a,o]})(t,r,i,n,a)})(a,i,h,c,u,o,d?s:null,f,p,a.center.lat,e.tileID.canonical),g=x(y,2),b=g[0],w=g[1],k=e.queryGeometry;return(function(e,t,r){var i=1/0;Iu(r,t)&&(i=ed(r,t[0]));for(var n=0;n=3)for(var a=0;a4&&void 0!==arguments[4]&&arguments[4],o=arguments.length>5?arguments[5]:void 0,s=Math.round(1e18*Math.random()).toString(36).substring(0,10);r&&(r.metadata=o,this.callbacks[s]=r);var l=new Set;return this.target.postMessage({id:s,type:e,hasCallback:!!r,targetMapId:i,mustQueue:a,sourceMapId:this.mapId,data:pa(t,l)},l),{cancel:function(){r&&delete n.callbacks[s],n.target.postMessage({id:s,type:"",targetMapId:i,sourceMapId:n.mapId})}}}},{key:"receive",value:function(e){var t=this,r=e.data,i=r.id;if(i&&(!r.targetMapId||this.mapId===r.targetMapId))if(""===r.type){var n=this.cancelCallbacks[i];delete this.cancelCallbacks[i],n&&n.cancel()}else if(r.mustQueue||Se()){var a=this.callbacks[i],o=this.scheduler.add((function(){return t.processTask(i,r)}),a&&a.metadata||{type:"message"});o&&(this.cancelCallbacks[i]=o)}else this.processTask(i,r)}},{key:"processTask",value:function(e,t){var r=this;if(delete this.cancelCallbacks[e],""===t.type){var i=this.callbacks[e];delete this.callbacks[e],i&&(t.error?i(ma(t.error)):i(null,ma(t.data)))}else{var n=new Set,a=t.hasCallback?function(t,i){r.target.postMessage({id:e,type:"",sourceMapId:r.mapId,error:t?pa(t):null,data:pa(i,n)},n)}:function(e){},o=ma(t.data);if(this.parent[t.type])this.parent[t.type](t.sourceMapId,o,a);else if(this.parent.getWorkerSource){var s=t.type.split(".");this.parent.getWorkerSource(t.sourceMapId,s[0],o.source,o.scope)[s[1]](o,a)}else a(new Error(`Could not find function ${t.type}`))}}},{key:"remove",value:function(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}])})(),r_=(function(){return m((function e(t,r){var i=this;p(this,e),this.workerPool=t,this.actors=[],this.currentActor=0,this.id=pe();for(var n=this.workerPool.acquire(this.id),a=0;at[o])return null}else{var s=1/i[o],l=(e[o]-r[o])*s,u=(t[o]-r[o])*s;if(l>u){var c=l;l=u,u=c}if(l>n&&(n=l),ua)return null}return n}function a_(e,t,r,i,n,a,o,s,l,u,c){var h=i-e,f=n-t,d=a-r,p=o-e,m=s-t,v=l-r,_=c[1]*v-c[2]*m,y=c[2]*p-c[0]*v,g=c[0]*m-c[1]*p,x=h*_+f*y+d*g;if(Math.abs(x)<1e-15)return null;var b=1/x,w=u[0]-e,k=u[1]-t,T=u[2]-r,M=(w*_+k*y+T*g)*b;if(M<0||M>1)return null;var S=k*d-T*f,E=T*h-w*d,I=w*f-k*h,A=(c[0]*S+c[1]*E+c[2]*I)*b;return A<0||M+A>1?null:(p*S+m*E+v*I)*b}function o_(e,t,r){return(e-t)/(r-t)}function s_(e,t,r,i,n,a,o,s,l){var u=1<=1;i/=2){var d=r[r.length-1];o=new i_(i);for(var p=0;p6&&void 0!==arguments[6]?arguments[6]:1;return n_([e,t,-100],[r,i,this.maximums[0]*o],n,a)}},{key:"raycast",value:function(e,t,r,i,n,a){var o=arguments.length>6&&void 0!==arguments[6]?arguments[6]:1;if(!this.nodeCount)return null;var s=this.raycastRoot(e,t,r,i,n,a,o);if(null==s)return null;for(var l=[],u=[],c=[],h=[],f=[{idx:0,t:s,nodex:0,nodey:0,depth:0}];f.length>0;){var d=f.pop(),p=d.idx,m=d.t,v=d.nodex,_=d.nodey,y=d.depth;if(this.leaves[p]){s_(v,_,y,e,t,r,i,c,h);var g=1<=P[2])return m}else{for(var z=0,D=0;D=l[u[B]]&&(u.splice(B,0,D),O=!0);O||(u[z]=D),z++}}for(var F=0;F3&&void 0!==arguments[3]&&arguments[3];if(p(this,e),this.uid=t,r.height!==r.width)throw new RangeError("DEM tiles must be square");if(i&&"mapbox"!==i&&"terrarium"!==i)we(`"${i}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);else{this.stride=r.height;var a=this.dim=r.height-2,o=new Uint32Array(r.data.buffer);if(this.pixels=new Uint8Array(r.data.buffer),this.floatView=new Float32Array(r.data.buffer),this.borderReady=n,this._modifiedForSources={},!n){for(var s=0;s2&&void 0!==arguments[2]&&arguments[2]&&(e=le(e,-1,this.dim),t=le(t,-1,this.dim));var r=this._idx(e,t);return this.floatView[r]}},{key:"set",value:function(e,t,r){var i=this._idx(e,t),n=this.floatView[i];return this.floatView[i]=r,r-n}},{key:"_idx",value:function(e,t){if(e<-1||e>=this.dim+1||t<-1||t>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(t+1)*this.stride+(e+1)}},{key:"getPixels",value:function(){return new Jc({width:this.stride,height:this.stride},this.pixels)}},{key:"backfillBorder",value:function(e,t,r){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");var i=t*this.dim,n=t*this.dim+this.dim,a=r*this.dim,o=r*this.dim+this.dim;switch(t){case-1:i=n-1;break;case 1:n=i+1}switch(r){case-1:a=o-1;break;case 1:o=a+1}for(var s=-t*this.dim,l=-r*this.dim,u=a;u=1;i--){for(var n=1===i?1:0,a=2===i?1:0,o=0;o>>1^-(1&e[t]);return e}function S_(e,t){switch(t){case"uint32":return e;case"uint16":for(var r=0;r>4|(61440&i)>>8|(240&n)<<4|61440&n,e[r+1]=15&i|(3840&i)>>4|(15&n)<<8|(3840&n)<<4}return e;case"uint8":for(var a=0;a>6|(192&s)>>4|(192&l)>>2|192&u,e[a+1]=(48&o)>>4|(48&s)>>2|48&l|(48&u)<<2,e[a+2]=(12&o)>>2|12&s|(12&l)<<2|(12&u)<<4,e[a+3]=3&o|(3&s)<<2|(3&l)<<4|(3&u)<<6}return e;default:throw new Error(`Invalid pixel format, "${t}"`)}}var E_=Uint8Array,I_=Uint16Array,A_=Int32Array,C_=new E_([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]),P_=new E_([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]),z_=new E_([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),D_=function(e,t){for(var r=new I_(31),i=0;i<31;++i)r[i]=t+=1<>1|(21845&N_)<<1;F_[N_]=((65280&(V_=(61680&(V_=(52428&V_)>>2|(13107&V_)<<2))>>4|(3855&V_)<<4))>>8|(255&V_)<<8)>>1}var U_=function(e,t,r){for(var i=e.length,n=0,a=new I_(t);n>l]=u;return o},j_=new E_(288);for(N_=0;N_<144;++N_)j_[N_]=8;for(N_=144;N_<256;++N_)j_[N_]=9;for(N_=256;N_<280;++N_)j_[N_]=7;for(N_=280;N_<288;++N_)j_[N_]=8;var G_=new E_(32);for(N_=0;N_<32;++N_)G_[N_]=5;var q_=U_(j_,9),Z_=U_(G_,5),$_=function(e){for(var t=e[0],r=1;rt&&(t=e[r]);return t},H_=function(e,t,r){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(7&t)&r},W_=function(e,t){var r=t/8|0;return(e[r]|e[r+1]<<8|e[r+2]<<16)>>(7&t)},X_=["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"],Y_=function(e,t,r){var i=new Error(t||X_[e]);if(i.code=e,Error.captureStackTrace&&Error.captureStackTrace(i,Y_),!r)throw i;return i},J_=new E_(0),K_="undefined"!=typeof TextDecoder&&new TextDecoder;try{K_.decode(J_,{stream:!0})}catch(e){}var Q_,ey={gzip_data:"gzip"},ty=(function(e){function t(e){var r;return p(this,t),(r=T(this,t,[e])).name="MRTError",r}return y(t,e),m(t)})(g(Error)),ry={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},iy={uint32:1,uint16:2,uint8:4},ny={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array},ay=(function(){return m((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5;p(this,e),this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=t}),[{key:"getLayer",value:function(e){var t=this.layers[e];if(!t)throw new ty(`Layer '${e}' not found`);return t}},{key:"getHeaderLength",value:function(e){var t=new Uint8Array(e),r=new DataView(e);if(13!==t[0])throw new ty("File is not a valid MRT.");return r.getUint32(1,!0)}},{key:"parseHeader",value:function(e){var t=new Uint8Array(e),r=this.getHeaderLength(e);if(t.length= ${r} but got buffer of length ${t.length}`);var i=(function(e){return e.readFields(m_,{header_length:0,x:0,y:0,z:0,layers:[]},void 0)})(new Q_(t.subarray(0,r)));if(!isNaN(this.x)&&(this.x!==i.x||this.y!==i.y||this.z!==i.z))throw new ty(`Invalid attempt to parse header ${i.z}/${i.x}/${i.y} for tile ${this.z}/${this.x}/${this.y}`);for(var n of(this.x=i.x,this.y=i.y,this.z=i.z,i.layers))this.layers[n.name]=new oy(n,{cacheSize:this._cacheSize});return this}},{key:"createDecodingTask",value:function(e){var t=this,r=[],i=this.getLayer(e.layerName);for(var n of e.blockIndices){var a=i.dataIndex[n],o=a.first_byte-e.firstByte,s=a.last_byte-e.firstByte;if(!i._blocksInProgress.has(n)){var l={layerName:i.name,firstByte:o,lastByte:s,pixelFormat:i.pixelFormat,blockIndex:n,blockShape:[a.bands.length].concat(i.bandShape),buffer:i.buffer,codec:a.codec.codec,filters:a.filters.map((function(e){return e.filter}))};i._blocksInProgress.add(n),r.push(l)}}return new sy(r,(function(){r.forEach((function(e){return i._blocksInProgress.delete(e.blockIndex)}))}),(function(e,n){if(r.forEach((function(e){return i._blocksInProgress.delete(e.blockIndex)})),e)throw e;n.forEach((function(e){t.getLayer(e.layerName).processDecodedData(e)}))}))}}])})(),oy=(function(){return m((function e(t,r){var i=t.version,n=t.name,a=t.units,o=t.tilesize,s=t.pixel_format,l=t.buffer,u=t.data_index;if(p(this,e),this.version=i,1!==this.version)throw new ty(`Cannot parse raster layer encoded with MRT version ${i}`);this.name=n,this.units=a,this.tileSize=o,this.buffer=l,this.pixelFormat=ry[s],this.dataIndex=u,this.bandShape=[o+2*l,o+2*l,iy[this.pixelFormat]],this._decodedBlocks=new k_(r?r.cacheSize:5),this._blocksInProgress=new Set}),[{key:"dimension",get:function(){return iy[this.pixelFormat]}},{key:"cacheSize",get:function(){return this._decodedBlocks.capacity}},{key:"getBandList",value:function(){return this.dataIndex.map((function(e){return e.bands})).flat()}},{key:"processDecodedData",value:function(e){var t=e.blockIndex.toString();this._decodedBlocks.get(t)||this._decodedBlocks.put(t,e.data)}},{key:"getBlockForBand",value:function(e){var t=0;switch(typeof e){case"string":for(var r of this.dataIndex.entries()){var i=x(r,2),n=i[0],a=i[1];for(var o of a.bands.entries()){var s=x(o,2),l=s[0];if(s[1]===e)return{bandIndex:t+l,blockIndex:n,blockBandIndex:l}}t+=a.bands.length}break;case"number":for(var u of this.dataIndex.entries()){var c=x(u,2),h=c[0],f=c[1];if(e>=t&&ethis.cacheSize)throw new ty(`Number of blocks to decode (${n.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:t,lastByte:r,blockIndices:i}}},{key:"hasBand",value:function(e){return this.getBlockForBand(e).blockIndex>=0}},{key:"hasDataForBand",value:function(e){var t=this.getBlockForBand(e).blockIndex;return t>=0&&!!this._decodedBlocks.get(t.toString())}},{key:"getBandView",value:function(e){var t=this.getBlockForBand(e),r=t.blockIndex,i=t.blockBandIndex,n=this._decodedBlocks.get(r.toString());if(!n)throw new ty(`Data for band ${JSON.stringify(e)} of layer "${this.name}" not decoded.`);var a=this.dataIndex[r],o=this.bandShape.reduce((function(e,t){return e*t}),1),s=i*o,l=n.subarray(s,s+o);return{data:l,bytes:new Uint8Array(l.buffer).subarray(l.byteOffset,l.byteOffset+l.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:0!==a.offset?a.offset:a.deprecated_offset,scale:0!==a.scale?a.scale:a.deprecated_scale}}}])})();ay.setPbf=function(e){Q_=e};var sy=(function(){return m((function e(t,r,i){p(this,e),this.tasks=t,this._onCancel=r,this._onComplete=i,this._finalized=!1}),[{key:"cancel",value:function(){this._finalized||(this._onCancel(),this._finalized=!0)}},{key:"complete",value:function(e,t){this._finalized||(this._onComplete(e,t),this._finalized=!0)}}])})();ay.performDecoding=function(e,t){var r=new Uint8Array(e);return Promise.all(t.tasks.map((function(e){var t,i=e.layerName,n=e.firstByte,a=e.lastByte,o=e.pixelFormat,s=e.blockShape,l=e.blockIndex,u=e.filters,c=e.codec,h=r.subarray(n,a+1),f=new Uint32Array(s[0]*s[1]*s[2]);if("gzip_data"!==c)throw new ty(`Unhandled codec: ${c}`);return t=(function(e,t){if(!globalThis.DecompressionStream&&"gzip_data"===t)return Promise.resolve(((a=(function(e){31==e[0]&&139==e[1]&&8==e[2]||Y_(6,"invalid gzip data");var t=e[3],r=10;4&t&&(r+=2+(e[10]|e[11]<<8));for(var i=(t>>3&1)+(t>>4&1);i>0;i-=!e[r++]);return r+(2&t)})(n=e))+8>n.length&&Y_(6,"invalid gzip data"),(function(e,t,r){var i=e.length;if(!i||t.f&&!t.l)return r||new E_(0);var n=!r,a=n||2!=t.i,o=t.i;n&&(r=new E_(3*i));var s,l,u=function(e){var t=r.length;if(e>t){var i=new E_(Math.max(2*t,e));i.set(r),r=i}},c=t.f||0,h=t.p||0,f=t.b||0,d=t.l,p=t.d,m=t.m,v=t.n,_=8*i;do{if(!d){c=H_(e,h,1);var y=H_(e,h+1,3);if(h+=3,!y){var g=e[(C=4+((h+7)/8|0))-4]|e[C-3]<<8,x=C+g;if(x>i){o&&Y_(0);break}a&&u(f+g),r.set(e.subarray(C,x),f),t.b=f+=g,t.p=h=8*x,t.f=c;continue}if(1==y)d=q_,p=Z_,m=9,v=5;else if(2==y){var b=H_(e,h,31)+257,w=H_(e,h+10,15)+4,k=b+H_(e,h+5,31)+1;h+=14;for(var T=new E_(k),M=new E_(19),S=0;S>4)<16)T[S++]=C;else{var z=0,D=0;for(16==C?(D=3+H_(e,h,3),h+=2,z=T[S-1]):17==C?(D=3+H_(e,h,7),h+=3):18==C&&(D=11+H_(e,h,127),h+=7);D--;)T[S++]=z}}var R=T.subarray(0,b),L=T.subarray(b);m=$_(R),v=$_(L),d=U_(R,m),p=U_(L,v)}else Y_(1);if(h>_){o&&Y_(0);break}}a&&u(f+131072);for(var O=(1<>4;if((h+=15&z)>_){o&&Y_(0);break}if(z||Y_(2),N<256)r[f++]=N;else{if(256==N){F=h,d=null;break}var V=N-254;N>264&&(V=H_(e,h,(1<<(G=C_[S=N-257]))-1)+L_[S],h+=G);var U=p[W_(e,h)&B],j=U>>4;if(U||Y_(3),h+=15&U,L=B_[j],j>3){var G=P_[j];L+=W_(e,h)&(1<_){o&&Y_(0);break}a&&u(f+131072);var q=f+V;if(fs.length)&&(l=s.length),new E_(s.subarray(0,l))):r.subarray(0,f)})(n.subarray(a,-8),{i:2},new E_(((r=n)[(i=r.length)-4]|r[i-3]<<8|r[i-2]<<16|r[i-1]<<24)>>>0))));var r,i,n,a,o=ey[t];if(!o)throw new Error(`Unhandled codec: ${t}`);var s=new globalThis.DecompressionStream(o);return new Response(new Blob([e]).stream().pipeThrough(s)).arrayBuffer().then((function(e){return new Uint8Array(e)}))})(h,c).then((function(e){return(function(e,t){e.readFields(b_,t)})(new Q_(e),f),new(0,ny[o])(f.buffer)})),t.then((function(e){for(var t=u.length-1;t>=0;t--)switch(u[t]){case"delta_filter":T_(e,s);break;case"zigzag_filter":M_(e);break;case"bitshuffle_filter":S_(e,o);break;default:throw new ty(`Unhandled filter "${u[t]}"`)}return{layerName:i,blockIndex:l,data:e}})).catch((function(e){throw e}))})))},ca(sy,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]});var ly,uy={workerUrl:"",workerClass:null,workerParams:void 0},cy="mapboxgl_preloaded_worker_pool",hy=(function(){function e(){p(this,e),this.active={}}return m(e,[{key:"acquire",value:function(t){if(!this.workers)for(this.workers=[];this.workers.length1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2?arguments[2]:void 0,i={json:null,images:[],buffers:[]};if(new Uint32Array(e,t,1)[0]===Ay){var n=new Uint32Array(e,t),a=2,o=(n[a++]>>2)-3,s=n[a++]>>2;if(a++,i.json=JSON.parse(Cy.decode(n.subarray(a,a+s))),(a+=s)>>0,Math.ceil(1.2*n)),o=Math.ceil((a-n)/65536);try{return r.grow(o),i(),!0}catch(e){return!1}},b:n}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(e,a):e.then((function(e){return e.arrayBuffer()})).then((function(e){return WebAssembly.instantiate(e,a)}))).then((function(e){var n=e.instance.exports,a=n.Rb,o=n.Qb,s=n.P,l=n.T,u=n.X,c=n.Ja,h=n.La,f=n.Qa,d=n.Va,v=n.Wa,_=n.eb,y=n.jb,g=n.f,x=n.e,b=n.yb,w=n.zb,k=n.Ab,T=n.Bb,M=n.Db,S=n.Gb;r=x;var E=(function(){var e=0,r=0,i=0,n=0;return function(s){i&&(a(n),a(e),r+=i,i=e=0),e||(e=o(r+=128));var l=s.length+7&-8,u=e;l>=r&&(i=l,u=n=o(l));for(var c=0;c0){for(var n=0;n0){a.texcoordArray=new Gs;var x=t.json.accessors[n.TEXCOORD_0];a.texcoordArray.resize(x.count);var b=Oy(t,x);By(t,x,a.texcoordArray,b)}if(void 0!==n._FEATURE_ID_RGBA4444){var w=t.json.accessors[n._FEATURE_ID_RGBA4444];t.json.extensionsUsed&&t.json.extensionsUsed.includes("EXT_meshopt_compression")&&(a.featureData=Oy(t,w))}void 0!==n._FEATURE_RGBA4444&&(a.featureData=new Uint32Array(Oy(t,t.json.accessors[n._FEATURE_RGBA4444]).buffer));var k=e.material;return a.material=(function(e,t){var r=e.emissiveFactor,i=void 0===r?[0,0,0]:r,n=e.alphaMode,a=void 0===n?"OPAQUE":n,o=e.alphaCutoff,s=void 0===o?.5:o,l=e.normalTexture,u=e.occlusionTexture,h=e.emissiveTexture,f=e.doubleSided,p=e.pbrMetallicRoughness||{},m=p.baseColorFactor,v=void 0===m?[1,1,1,1]:m,_=p.metallicFactor,y=void 0===_?1:_,g=p.roughnessFactor,x=void 0===g?1:g,b=p.baseColorTexture,w=p.metallicRoughnessTexture,k=u?t[u.index]:void 0;if(u&&u.extensions&&u.extensions.KHR_texture_transform&&k){var T=u.extensions.KHR_texture_transform;k.offsetScale=[T.offset[0],T.offset[1],T.scale[0],T.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:c(Ot,d(v)),metallicFactor:y,roughnessFactor:x,baseColorTexture:b?t[b.index]:void 0,metallicRoughnessTexture:w?t[w.index]:void 0},doubleSided:f,emissiveFactor:i,alphaMode:a,alphaCutoff:s,normalTexture:l?t[l.index]:void 0,occlusionTexture:k,emissionTexture:h?t[h.index]:void 0,defined:void 0===e.defined}})(void 0!==k?t.json.materials[k]:{defined:!1},r),a}function Ny(e,t,r){var i=e.matrix,n=e.rotation,a=e.translation,o=e.scale,s=e.mesh,l=e.extras,u=e.children,c={};if(c.matrix=i||W.mat4.fromRotationTranslationScale([],n||[0,0,0,1],a||[0,0,0],o||[1,1,1]),void 0!==s){c.meshes=r[s];var h=c.anchor=[0,0];for(var f of c.meshes){var d=f.aabb,p=d.min,m=d.max;h[0]+=p[0]+m[0],h[1]+=p[1]+m[1]}h[0]=Math.floor(h[0]/c.meshes.length/2),h[1]=Math.floor(h[1]/c.meshes.length/2)}if(l&&(l.id&&(c.id=l.id),l.lights&&(c.lights=(function(e){if(!e.length)return[];for(var t=(function(e){for(var t=atob(e),r=new Uint8Array(t.length),i=0;i1&&i[i.length-1].equals(i[0])&&i.pop();for(var s=0,l=0;l0&&i.reverse();var f=eh(i.flatMap((function(e){return[e.x,e.y]})),[]);return 0===f.length?null:{vertices:i,indices:f}}function jy(e,t){var r=[],i=[],n=0,a=[];for(var o of e){n=r.length;for(var s=o.vertexArray.float32,l=o.indexArray.uint16,u=0;u0&&(f=[i[h+2],i[h+1]],i[h+1]=f[0],i[h+2]=f[1])}return{vertices:r,indices:i}}function Gy(e){var t=(function(e,t){var r=[],i=WebGL2RenderingContext;if(e.json.textures)for(var n of e.json.textures){var a={magFilter:i.LINEAR,minFilter:i.NEAREST,wrapS:i.REPEAT,wrapT:i.REPEAT};void 0!==n.sampler&&Object.assign(a,e.json.samplers[n.sampler]),r.push({image:t[n.source],sampler:a,uploaded:!1})}return r})(e,e.images),r=(function(e,t){var r=[];for(var i of e.json.meshes){var n=[];for(var a of i.primitives)n.push(Fy(a,e,t));r.push(n)}return r})(e,t),i=e.json,n=i.scenes,a=i.scene,o=i.nodes,s=n?n[a||0].nodes:o,l=[];for(var u of s)l.push(Ny(o[u],e,r));return(function(e,t,r){for(var i={},n=new Set,a=0;a0)for(var d=Array.from(n.values()).sort((function(e,t){return e-t})),p=d.length-1;p>=0;p--)e.splice(d[p],1)})(l,s,e.json.nodes),l}function qy(e){e.heightmap=new Float32Array(4096),e.heightmap.fill(-1);for(var t=e.vertexArray.float32,r=e.aabb.min[0]-1,i=e.aabb.min[1]-1,n=zv/(e.aabb.max[0]-r+2),a=zv/(e.aabb.max[1]-i+2),o=0;oe.heightmap[u*zv+l]&&(e.heightmap[u*zv+l]=s)}}function Zy(e,t){var r={};r.indexArray=new Ls,r.indexArray.reserve(4*e.length),r.vertexArray=new ks,r.vertexArray.reserve(10*e.length),r.colorArray=new ws,r.vertexArray.reserve(10*e.length);var i=0;for(var n of e){var a=Math.min(10,Math.max(4,1.3*n.height))*t,o=[-n.normal[1],n.normal[0],0],s=Math.min(.29,.1*n.width/n.depth),l=n.width-2*n.depth*t*(s+.01),u=W.vec3.scaleAndAdd([],n.pos,o,l/2),c=W.vec3.scaleAndAdd([],n.pos,o,-l/2),h=[u[0],u[1],u[2]+n.height],f=[c[0],c[1],c[2]+n.height],d=W.vec3.scaleAndAdd([],n.normal,o,s);W.vec3.scale(d,d,a);var p=W.vec3.scaleAndAdd([],n.normal,o,-s);W.vec3.scale(p,p,a),W.vec3.add(d,u,d),W.vec3.add(p,c,p),u[2]+=.1,c[2]+=.1,r.vertexArray.emplaceBack(d[0],d[1],d[2]),r.vertexArray.emplaceBack(p[0],p[1],p[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(f[0],f[1],f[2]),r.vertexArray.emplaceBack(u[0],u[1],u[2]),r.vertexArray.emplaceBack(c[0],c[1],c[2]),r.vertexArray.emplaceBack(d[0],d[1],d[2]),r.vertexArray.emplaceBack(p[0],p[1],p[2]);var m=l/a/2;r.colorArray.emplaceBack(-m-s,-1,m,.8),r.colorArray.emplaceBack(m+s,-1,m,.8),r.colorArray.emplaceBack(-m,0,m,1.3),r.colorArray.emplaceBack(m,0,m,1.3),r.colorArray.emplaceBack(m+s,-.8,m,.7),r.colorArray.emplaceBack(m+s,-.8,m,.7),r.colorArray.emplaceBack(0,0,m,1.3),r.colorArray.emplaceBack(0,0,m,1.3),r.colorArray.emplaceBack(m+s,-1.2,m,.8),r.colorArray.emplaceBack(m+s,-1.2,m,.8),r.indexArray.emplaceBack(6+i,4+i,8+i),r.indexArray.emplaceBack(7+i,9+i,5+i),r.indexArray.emplaceBack(0+i,1+i,2+i),r.indexArray.emplaceBack(1+i,3+i,2+i),i+=10}var v={defined:!0,emissiveFactor:[0,0,0]},_={};return _.baseColorFactor=Ot.white,v.pbrMetallicRoughness=_,r.material=v,r.aabb=new lc([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),r}var $y=(function(){return m((function e(t){p(this,e),this._stringToNumber={},this._numberToString=[];for(var r=0;r5&&void 0!==arguments[5]?arguments[5]:0,o=arguments.length>6&&void 0!==arguments[6]?arguments[6]:0,s=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(r,i,n,a);for(var l=this.grid,u=0;u=0&&h[3]>=0&&l.insert(s,h[0],h[1],h[2],h[3])}}},{key:"loadVTLayers",value:function(){if(!this.vtLayers)for(var e in this.vtLayers=new tf.VectorTile(new Xd(this.rawTileData)).layers,this.sourceLayerCoder=new $y(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={},this.vtLayers)this.vtFeatures[e]=[];return this.vtLayers}},{key:"query",value:function(e,t,r,i){var n=this;this.loadVTLayers();var a=e.params||{},o=Xo(a.filter),s=e.tileResult,l=e.transform,u=s.bufferedTilespaceBounds,c=this.grid.query(u.min.x,u.min.y,u.max.x,u.max.y,(function(e,t,r,i){return Ou(s.bufferedTilespaceGeometry,e,t,r,i)}));c.sort(Jy);var h=null;l.elevation&&c.length>0&&(h=Vv.create(l.elevation,this.tileID));for(var f,d={},p=function(){var u=c[m];if(u===f)return 0;f=u;var p=n.featureIndexArray.get(u),v=null;if(n.is3DTile){var _=n.bucketLayerIDs[0][0],y=t[_];if("model"!==y.type)return 0;var g=y.queryIntersectsMatchingFeature(s,p.featureIndex,o,l),x=g.queryFeature,b=g.intersectionZ;x&&n.appendToResult(d,_,p.featureIndex,x,b)}else n.loadMatchingFeature(d,p,o,a.layers,a.availableImages,t,r,i,(function(t,r,i){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;return v||(v=gu(t,n.tileID.canonical,e.tileTransform)),r.queryIntersectsFeature(s,t,i,v,n.z,e.transform,e.pixelPosMatrix,h,a)}))},m=0;m=0)return!0;return!1})(i,d)){var p=this.sourceLayerCoder.decode(h),m=this.vtLayers[p].feature(u);if(r.needGeometry){var v=xu(m,!0);if(!r.filter(new zo(this.tileID.overscaledZ),v,this.tileID.canonical))return}else if(!r.filter(new zo(this.tileID.overscaledZ),m))return;for(var _=this.getId(m,p),y=0;y1&&void 0!==arguments[1]?arguments[1]:64,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Float64Array,n=arguments.length>3?arguments[3]:void 0;if(p(this,e),isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+r,2),65535),this.ArrayType=i,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;var a=Ky.indexOf(this.ArrayType),o=2*t*this.ArrayType.BYTES_PER_ELEMENT,s=t*this.IndexArrayType.BYTES_PER_ELEMENT,l=(8-s%8)%8;if(a<0)throw new Error(`Unexpected typed array class: ${i}.`);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+l,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+o+s+l),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+s+l,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+a]),new Uint16Array(this.data,2,1)[0]=r,new Uint32Array(this.data,4,1)[0]=t)}return m(e,[{key:"add",value:function(e,t){var r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=e,this.coords[this._pos++]=t,r}},{key:"finish",value:function(){var e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return eg(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}},{key:"range",value:function(e,t,r,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");for(var n=this.ids,a=this.coords,o=this.nodeSize,s=[0,n.length-1,0],l=[];s.length;){var u=s.pop()||0,c=s.pop()||0,h=s.pop()||0;if(c-h<=o)for(var f=h;f<=c;f++){var d=a[2*f],p=a[2*f+1];d>=e&&d<=r&&p>=t&&p<=i&&l.push(n[f])}else{var m=h+c>>1,v=a[2*m],_=a[2*m+1];v>=e&&v<=r&&_>=t&&_<=i&&l.push(n[m]),(0===u?e<=v:t<=_)&&(s.push(h),s.push(m-1),s.push(1-u)),(0===u?r>=v:i>=_)&&(s.push(m+1),s.push(c),s.push(1-u))}}return l}},{key:"within",value:function(e,t,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");for(var i=this.ids,n=this.coords,a=this.nodeSize,o=[0,i.length-1,0],s=[],l=r*r;o.length;){var u=o.pop()||0,c=o.pop()||0,h=o.pop()||0;if(c-h<=a)for(var f=h;f<=c;f++)ng(n[2*f],n[2*f+1],e,t)<=l&&s.push(i[f]);else{var d=h+c>>1,p=n[2*d],m=n[2*d+1];ng(p,m,e,t)<=l&&s.push(i[d]),(0===u?e-r<=p:t-r<=m)&&(o.push(h),o.push(d-1),o.push(1-u)),(0===u?e+r>=p:t+r>=m)&&(o.push(d+1),o.push(c),o.push(1-u))}}return s}}],[{key:"from",value:function(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");var r=new Uint8Array(t,0,2),i=x(r,2),n=i[0],a=i[1];if(219!==n)throw new Error("Data does not appear to be in a KDBush format.");var o=a>>4;if(1!==o)throw new Error(`Got v${o} data when expected v1.`);var s=Ky[15&a];if(!s)throw new Error("Unrecognized array type.");var l=new Uint16Array(t,2,1),u=x(l,1)[0],c=new Uint32Array(t,4,1);return new e(x(c,1)[0],u,s,t)}}])})();function eg(e,t,r,i,n,a){if(!(n-i<=r)){var o=i+n>>1;tg(e,t,o,i,n,a),eg(e,t,r,i,o-1,1-a),eg(e,t,r,o+1,n,1-a)}}function tg(e,t,r,i,n,a){for(;n>i;){if(n-i>600){var o=n-i+1,s=r-i+1,l=Math.log(o),u=.5*Math.exp(2*l/3),c=.5*Math.sqrt(l*u*(o-u)/o)*(s-o/2<0?-1:1);tg(e,t,r,Math.max(i,Math.floor(r-s*u/o+c)),Math.min(n,Math.floor(r+(o-s)*u/o+c)),a)}var h=t[2*r+a],f=i,d=n;for(rg(e,t,i,r),t[2*n+a]>h&&rg(e,t,i,n);fh;)d--}t[2*i+a]===h?rg(e,t,i,d):rg(e,t,++d,n),d<=r&&(i=d+1),r<=d&&(n=d-1)}}function rg(e,t,r,i){ig(e,r,i),ig(t,2*r,2*i),ig(t,2*r+1,2*i+1)}function ig(e,t,r){var i=e[t];e[t]=e[r],e[r]=i}function ng(e,t,r,i){var n=e-r,a=t-i;return n*n+a*a}e.$=Lo,e.A=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t)})(Mv),e.B=xr,e.C=Ut,e.D=$o,e.E=Dt,e.F=jn,e.G=Nn,e.H=Un,e.I=Tp,e.J=Kn,e.K=Ho,e.L=ra,e.M=Qn,e.N=Oi,e.O=Fi,e.P=K,e.Q=Li,e.R=ct,e.S=Mr,e.T=Zm,e.U=Lt,e.V=Mv,e.W=Wo,e.X=Gn,e.Y=Vn,e.Z=function(e){var t=e.value,r=[];if(!t)return r;var i=xr(t);return"string"!==i?r=r.concat([new Mv(e.key,t,`string expected, "${i}" found`)]):(Sv(t,!0)||(r=r.concat([new Mv(e.key,t,`invalid url "${t}"`)])),r)},e._=Zo,e.a=function(e){return Ue.API_CDN_URL_REGEX.test(e)},e.a$=js,e.a0=qo,e.a1=Uo,e.a2=(function(){return m((function e(t){p(this,e),this.specification=t}),[{key:"possiblyEvaluate",value:function(e,t){return Me(e.expression.evaluate(t))}},{key:"interpolate",value:function(e,t,r){return{x:Ft(e.x,t.x,r),y:Ft(e.y,t.y,r),z:Ft(e.z,t.z,r),azimuthal:Ft(e.azimuthal,t.azimuthal,r),polar:Ft(e.polar,t.polar,r)}}}])})(),e.a3=zo,e.a4=ta,e.a5=hu,e.a6=W,e.a7=ue,e.a8=Vo,e.a9=Ic,e.aA=Xu,e.aB=iv,e.aC=nv,e.aD=tv,e.aE=function(e,t){var r=document.createElement("video");r.muted=!0,r.onloadstart=function(){t(null,r)};for(var i=0;i6&&void 0!==arguments[6]&&arguments[6];Rv(this.matrix,this,e.transform,this.position,t,r,i,n,a,o)}},{key:"upload",value:function(e){if(!this.uploaded){for(var t of this.nodes)Bv(t,e);for(var r of this.nodes)Fv(r);this.uploaded=!0}}},{key:"destroy",value:function(){for(var e of this.nodes)Nv(e)}}])})(),e.aJ=ve,e.aK=Qp,e.aL=iu,e.aM=nu,e.aN=gs,e.aO=Ls,e.aP=pe,e.aQ=Xs,e.aR=Rm,e.aS=function(){Po.isLoading()||Po.isLoaded()||"deferred"!==Ao()||Co()},e.aT=Xo,e.aU=xu,e.aV=Wy,e.aW=Ee,e.aX=dd,e.aY=Dh,e.aZ=gu,e.a_=_s,e.aa=Ft,e.ab=ii,e.ac=Nt,e.ad=(function(){return m((function e(t){p(this,e),this.specification=t}),[{key:"possiblyEvaluate",value:function(e,t){return(function(e){var t=x(e,2),r=Me([1,t[0],t[1]]);return{x:r.x,y:r.y,z:r.z}})(e.expression.evaluate(t))}},{key:"interpolate",value:function(e,t,r){return{x:Ft(e.x,t.x,r),y:Ft(e.y,t.y,r),z:Ft(e.z,t.z,r)}}}])})(),e.ae=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],n=new K(r,r),a=e.sub(n),o=t.add(n),s=[a,new K(o.x,a.y),o,new K(a.x,o.y)];return i&&s.push(a.clone()),s},e.af=function(e,t){for(var r=[],i=0;i2&&void 0!==arguments[2]?arguments[2]:0;return W.vec3.fromValues(((t.x-r)*e.scale-e.x)*ii,(t.y*e.scale-e.y)*ii,au(t.z,t.y))},e.aj=tc,e.ak=md,e.al=function(e){var t=1/0,r=1/0,i=-1/0,n=-1/0;for(var a of e)t=Math.min(t,a.x),r=Math.min(r,a.y),i=Math.max(i,a.x),n=Math.max(n,a.y);return{min:new K(t,r),max:new K(i,n)}},e.am=eu,e.an=Lu,e.ao=du,e.ap=le,e.aq=jl,e.ar=function(e,t){for(var r={},i=0;iKe&&(e.getActor().send("enforceCacheSizeLimit",Je),nt=0)},e.ay=qe,e.az=function(e){return e<=1?1:Math.pow(2,Math.floor(Math.log(e)/Math.LN2))},e.b=function(e){return Ue.API_FONTS_REGEX.test(e)},e.b$=function(e){var t=e.point,r=t.x,i=t.y,n=e._center,a=n.lng,o=n.lat;return Ec(r,i,e.worldSize,a,o)},e.b0=ec,e.b1=ul,e.b2=eh,e.b3=jm,e.b4=function(e,t){var r=Ic(t.zoom);if(0===r)return pc(e);var i=yc(e),n=gc(i),a=eu(i.getWest())*t.worldSize,o=eu(i.getEast())*t.worldSize,s=tu(i.getNorth())*t.worldSize,l=tu(i.getSouth())*t.worldSize,u=[a,s,0],c=[o,s,0],h=[a,l,0],f=[o,l,0],d=W.mat4.invert([],t.globeMatrix);return W.vec3.transformMat4(u,u,d),W.vec3.transformMat4(c,c,d),W.vec3.transformMat4(h,h,d),W.vec3.transformMat4(f,f,d),n[0]=mc(n[0],h,r),n[1]=mc(n[1],f,r),n[2]=mc(n[2],c,r),n[3]=mc(n[3],u,r),lc.fromPoints(n)},e.b5=kc,e.b6=xc,e.b7=mc,e.b8=ys,e.b9=Qu,e.bA=ce,e.bB=re,e.bC=Ce,e.bD=ru,e.bE=function(e,t,r){e[4*t+0]=r[0],e[4*t+1]=r[1],e[4*t+2]=r[2],e[4*t+3]=r[3]},e.bF=Ml,e.bG=xl,e.bH=bl,e.bI=gl,e.bJ=yl,e.bK=Jl,e.bL=bm,e.bM=Wu,e.bN=sc,e.bO=lv,e.bP=Hu,e.bQ=_c,e.bR=function(e,t,r,i,n,a,o,s,l){if("globe"===l.name)return _c(e,t,new Hu(r,i,n),!1);var u=Qp({z:r,x:i,y:n},l);return new lc([(a+u.x/u.scale)*t,t*(u.y/u.scale),o],[(a+u.x2/u.scale)*t,t*(u.y2/u.scale),s])},e.bS=function(e,t,r){for(var i=0,n=0;n<2;++n){e[n]>0&&(i+=(e[n]-0)*(e[n]-0)),t[n]<0&&(i+=(0-t[n])*(0-t[n]))}return i},e.bT=ou,e.bU=6,e.bV=function(e){var t=W.mat4.identity(new Float64Array(16));W.mat4.multiply(t,e.pixelMatrix,e.globeMatrix);var r=[0,Zl,0],i=[0,$l,0];return W.vec3.transformMat4(r,r,t),W.vec3.transformMat4(i,i,t),[r[0]>0&&r[0]<=e.width&&r[1]>0&&r[1]<=e.height&&!Cc(e,new Jl(e.center.lat,90)),i[0]>0&&i[0]<=e.width&&i[1]>0&&i[1]<=e.height&&!Cc(e,new Jl(e.center.lat,-90))]},e.bW=function(e,t){var r=e.tileTransform.scale*ii/(e.tileSize*Math.pow(2,t.zoom-e.tileID.overscaledZ+e.tileID.canonical.z));return W.mat2.scale(new Float32Array(4),t.inverseAdjustmentMatrix,[r,r])},e.bX=uv,e.bY=sv,e.bZ=function(e){var t=sv(e,!0);return W.mat2.invert([],[t[0],t[1],t[4],t[5]])},e.b_=rc,e.ba=ay,e.bb=Xd,e.bc=pt,e.bd=function(e){var t=[];for(var r in e)t.push(e[r]);return t},e.be=function(e,t){var r=[];for(var i in e)i in t||r.push(i);return r},e.bf=he,e.bg=["type","source","source-layer","minzoom","maxzoom","filter","layout"],e.bh=Q,e.bi=function(e,t){var r=e.point,i=Ec(r.x,r.y,e.worldSize/e._pixelsPerMercatorPixel,0,0);return W.mat4.multiply(i,i,Tc(pc(t)))},e.bj=Fd,e.bk=Qd,e.bl=Bd,e.bm=function(e,t,r,i,n){var a=5*t+2;e.float32[a+0]=r,e.float32[a+1]=i,e.float32[a+2]=n},e.bn=Em,e.bo=wp,e.bp=Su,e.bq=Rd,e.br=uf,e.bs=Tv,e.bt=yf,e.bu=gf,e.bv=Gp,e.bw=jp,e.bx=cp,e.by=Qy,e.bz=Ot,e.c=Ge,e.c$=Ju,e.c0=ie,e.c1=Yu,e.c2=5,e.c3=function(e){var t=Math.round((e+45+360)%360/90)%4;return ne[t]},e.c4=45,e.c5=Ql,e.c6=wl,e.c7=function(e,t,r){var i=Math.sqrt(e*e+t*t+r*r),n=i>0?Math.acos(r/i)*te:0,a=0!==e||0!==t?Math.atan2(-t,-e)*te+90:0;return a<0&&(a+=360),[i,a,n]},e.c8=cu,e.c9=lc,e.cA=function(e){var t=80.051129;e=le(e,-80.051129,t)/t*90;var r=Math.pow(Math.abs(Math.sin(re(e))),3);return Math.round(r*(ql.length-1))},e.cB=function(e,t,r,i){var n=t.getNorth(),a=t.getSouth(),o=t.getWest(),s=t.getEast(),l=1<0){var p=180/i;W.mat3.multiply(d,d,[p/u+1,0,0,0,p/c+1,0,-.5*p/h,.5*p/f,1])}return d[2]=l,d[5]=e.x,d[8]=e.y,d},e.cC=pc,e.cD=function(e,t,r){var i=W.mat4.identity(new Float64Array(16)),n=(t/(1<1)return!1;var r=t.getSource().maxzoom,i=1<1&&void 0!==arguments[1]?arguments[1]:0;return this.getAtPoint(e,t)||0}},{key:"getAtPoint",value:function(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(this.isUsingMockSource())return null;null==t&&(t=null);var i=this._source();if(!i)return t;if(e.y<0||e.y>1)return t;var n=i.getSource().maxzoom,a=1<=0?e.slice(0,t):e},e.cn=function(e){return e.indexOf(ss)>=0},e.co=function(e){var t=e.indexOf(ss);return t>=0?e.slice(t+1):""},e.cp=function(e){var t=[],r=e.id;return void 0===r&&t.push({message:`layers.${r}: missing required property "id"`}),void 0===e.render&&t.push({message:`layers.${r}: missing required method "render"`}),e.renderingMode&&"2d"!==e.renderingMode&&"3d"!==e.renderingMode&&t.push({message:`layers.${r}: property "renderingMode" must be either "2d" or "3d"`}),t},e.cq=function(e,t,r,i){return"custom"===e.type?new av(e,t):new Kv[e.type](e,t,r,i)},e.cr=ge,e.cs=Io,e.ct=dt,e.cu=kl,e.cv=(function(e){function t(e){var r;return p(this,t),(r=T(this,t,[e])).current=Sl,r}return y(t,e),m(t,[{key:"set",value:function(e,t,r){if(this.fetchUniformLocation(e,t))for(var i=0;i<9;i++)if(r[i]!==this.current[i]){this.current=r,this.gl.uniformMatrix3fv(this.location,!1,r);break}}}])})(_l),e.cw=ae,e.cx=function(e,t,r){var i=Ic(r.zoom),n=e.style.map._antialias,a=t.options.extStandardDerivativesForceOff||e.terrain&&e.terrain.exaggeration()>0;return 0===i&&!n&&!a},e.cy=function(e){var t=e.pixelsPerMeter,r=t/ru(1,e.center.lat),i=W.mat4.identity(new Float64Array(16));return W.mat4.translate(i,i,[e.point.x,e.point.y,0]),W.mat4.scale(i,i,[r,r,t]),Float32Array.from(i)},e.cz=yc,e.d=function(e){return Ue.API_TILEJSON_REGEX.test(e)},e.d$=t,e.d0=jf,e.d1=If,e.d2=450,e.d3=7,e.d4=rv,e.d5=ms,e.d6=$s,e.d7=256,e.d8=Tc,e.d9=ks,e.dA=Ac,e.dB=function(e){var t=[0,0,0],r=W.mat4.identity(new Float64Array(16));return W.mat4.multiply(r,e.pixelMatrix,e.globeMatrix),W.vec3.transformMat4(t,t,r),new K(t[0],t[1])},e.dC=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(To===xo||To===bo||To===wo)throw new Error("setRTLTextPlugin cannot be called multiple times.");Mo=Ze.resolveURL(e),To=xo,ko=t,Eo(),r||Co()},e.dD=Ao,e.dE=function(){fy().acquire(cy)},e.dF=function(){var e=ly;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(cy),ly=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},e.dG=hy,e.dH=function(e){var t=et();if(t){var r=t.delete(Ye);e&&r.catch(e).then((function(){return e()}))}},e.dI=uy,e.dJ=gy,e.dK=function(e){py=Ze.resolveURL(e),yy||(yy=new r_(fy(),new Dt)),yy.broadcast("setDracoUrl",py)},e.dL=xy,e.dM=function(e){vy=Ze.resolveURL(e),yy||(yy=new r_(fy(),new Dt)),yy.broadcast("setMeshoptUrl",vy)},e.dN=ca,e.dO=Xc,e.dP=2,e.dQ=$y,e.dR=Xy,e.dS=sd,e.dT=ye,e.dU=Mp,e.dV=function(e,t,r,i,n,a,o,s,l,u,c){e.createArrays(),e.tilePixelRatio=ii/(512*e.overscaling),e.compareText={},e.iconsNeedLinear=!1;var h=e.layers[0].layout,f=e.layers[0]._unevaluatedLayout._values,d={};if("composite"===e.textSizeData.kind){var p=e.textSizeData,m=p.minZoom,v=p.maxZoom;d.compositeTextSizes=[f["text-size"].possiblyEvaluate(new zo(m),s),f["text-size"].possiblyEvaluate(new zo(v),s)]}if("composite"===e.iconSizeData.kind){var _=e.iconSizeData,y=_.minZoom,g=_.maxZoom;d.compositeIconSizes=[f["icon-size"].possiblyEvaluate(new zo(y),s),f["icon-size"].possiblyEvaluate(new zo(g),s)]}d.layoutTextSize=f["text-size"].possiblyEvaluate(new zo(l+1),s),d.layoutIconSize=f["icon-size"].possiblyEvaluate(new zo(l+1),s),d.textMaxSize=f["text-size"].possiblyEvaluate(new zo(18),s);var x="map"===h.get("text-rotation-alignment")&&"point"!==h.get("symbol-placement"),b=h.get("text-size"),w=!1;for(var k of e.features)if(k.icon&&k.icon.nameSecondary){w=!0;break}var T=function(){var a,l=h.get("text-font").evaluate(M,{},s).join(","),f=b.evaluate(M,{},s),p=d.layoutTextSize.evaluate(M,{},s),m=(d.layoutIconSize.evaluate(M,{},s),{horizontal:{},vertical:void 0}),v=M.text,_=[0,0];if(v){var y=v.toString(),g=h.get("text-letter-spacing").evaluate(M,{},s)*Rd,k=h.get("text-line-height").evaluate(M,{},s)*Rd,T=fo(y)?g:0,S=h.get("text-anchor").evaluate(M,{},s),E=h.get("text-variable-anchor");if(!E){var I=h.get("text-radial-offset").evaluate(M,{},s);_=I?jp(S,[I*Rd,Vp]):h.get("text-offset").evaluate(M,{},s).map((function(e){return e*Rd}))}var A=x?"center":h.get("text-justify").evaluate(M,{},s),C="point"===h.get("symbol-placement"),P=C?h.get("text-max-width").evaluate(M,{},s)*Rd:1/0,z=function(i){e.allowVerticalPlacement&&ho(y)&&(m.vertical=rp(v,t,r,n,l,P,k,S,i,T,_,Qd.vertical,!0,p,f))};if(!x&&E){for(var D="auto"===A?E.map((function(e){return Gp(e)})):[A],R=!1,L=0;L=0||!ho(y)){var F=rp(v,t,r,n,l,P,k,S,A,T,_,Qd.horizontal,!1,p,f);F&&(m.horizontal[A]=F)}z(C?"left":A)}}var N=!1;if(M.icon&&M.icon.namePrimary){var V=i[M.icon.namePrimary];V&&(a=fp(n[M.icon.namePrimary],M.icon.nameSecondary?n[M.icon.nameSecondary]:void 0,h.get("icon-offset").evaluate(M,{},s),h.get("icon-anchor").evaluate(M,{},s)),N=V.sdf,void 0===e.sdfIcons?e.sdfIcons=V.sdf:e.sdfIcons!==V.sdf&&we("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(V.pixelRatio!==e.pixelRatio||0!==h.get("icon-rotate").constantOr(1))&&(e.iconsNeedLinear=!0))}var U=Wp(m.horizontal)||m.vertical;e.iconsInText||(e.iconsInText=!!U&&U.iconsInText),(U||a)&&qp(e,M,m,a,i,d,p,0,_,N,o,s,u,c,w)};for(var M of e.features)T();a&&e.generateCollisionDebugBuffers(l,e.collisionBoxArray)},e.dW=tf,e.dX=p_,e.dY=J,e.dZ=ef,e.d_=Wd,e.da=Ns,e.db=Vs,e.dc=function(e,t,r,i,n){return le((e-t)/(r-t)*(n-i)+i,i,n)},e.dd=An,e.de=lu,e.df=(function(){return m((function e(t,r,i,n){p(this,e),this.context=t,this.format=n,this.size=i,this.texture=t.gl.createTexture();var a=x(this.size,3),o=a[0],s=a[1],l=a[2],u=t.gl;u.bindTexture(u.TEXTURE_3D,this.texture),t.pixelStoreUnpackFlipY.set(!1),t.pixelStoreUnpack.set(1),t.pixelStoreUnpackPremultiplyAlpha.set(!1),u.texImage3D(u.TEXTURE_3D,0,this.format,o,s,l,0,Gm(this.format),qm(this.format),r.data)}),[{key:"bind",value:function(e,t){var r=this.context.gl;r.bindTexture(r.TEXTURE_3D,this.texture),e!==this.minFilter&&(r.texParameteri(r.TEXTURE_3D,r.TEXTURE_MAG_FILTER,e),r.texParameteri(r.TEXTURE_3D,r.TEXTURE_MIN_FILTER,e),this.minFilter=e),t!==this.wrapS&&(r.texParameteri(r.TEXTURE_3D,r.TEXTURE_WRAP_S,t),r.texParameteri(r.TEXTURE_3D,r.TEXTURE_WRAP_T,t),this.wrapS=t)}},{key:"destroy",value:function(){this.context.gl.deleteTexture(this.texture),this.texture=null}}])})(),e.dg=mv,e.dh=[1,1,1],e.di=Vv,e.dj=Dv,e.dk=Cs,e.dl=(function(){return m((function e(){p(this,e),this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new K(1/0,1/0),max:new K(-1/0,-1/0)}}),[{key:"clear",value:function(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}},{key:"updateTime",get:function(){return this._updateTime}},{key:"getReplacementRegionsForTile",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=pf(new K(0,0),new K(ii,ii),e),i=[];if(t&&!ff(r,this._globalClipBounds))return i;for(var n of this._activeRegions)if(!n.hiddenByOverlap&&ff(r,n)){var a=mf(n.min,n.max,e);i.push({min:a.min,max:a.max,sourceId:this._sourceIds[n.priority],footprint:n.footprint,footprintTileId:n.tileId,order:n.order,clipMask:n.clipMask,clipScope:n.clipScope})}return i}},{key:"setSources",value:function(e){this._setSources(e.map((function(e){return{getSourceId:function(){return e.cache.id},getFootprints:function(){var t=[];for(var r of e.cache.getVisibleCoordinates()){var i=e.cache.getTile(r).buckets[e.layer];i&&i.updateFootprints(r.toUnwrapped(),t)}return t},getOrder:function(){return e.order},getClipMask:function(){return e.clipMask},getClipScope:function(){return e.clipScope}}})))}},{key:"_addSource",value:function(e){var t=e.getFootprints();if(0!==t.length){var r=e.getOrder(),i=e.getClipMask(),n=e.getClipScope();for(var a of t)if(a.footprint){var o=pf(a.footprint.min,a.footprint.max,a.id);this._activeRegions.push({min:o.min,max:o.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:a.id,footprint:a.footprint,order:r,clipMask:i,clipScope:n})}this._sourceIds.push(e.getSourceId())}}},{key:"_computeReplacement",value:function(){var e=this;this._activeRegions.sort((function(e,t){return e.priority-t.priority||cf(e.min,t.min)||cf(e.max,t.max)||e.order-t.order||e.clipMask-t.clipMask||(function(e,t){var r=function(e,t){return e+t};return e.length-t.length||e.reduce(r,"").localeCompare(t.reduce(r,""))})(e.clipScope,t.clipScope)}));var t=this._activeRegions.length!==this._prevRegions.length;if(!t)for(var r=0;!t&&r!==this._activeRegions.length;){var i=this._activeRegions[r],n=this._prevRegions[r];t=i.priority!==n.priority||!hf(i,n)||i.order!==n.order||i.clipMask!==n.clipMask||!Q(i.clipScope,n.clipScope),++r}if(t){for(var a of(++this._updateTime,this._activeRegions))a.order!==lf&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,a.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,a.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,a.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,a.max.y));var o=function(t){var r=e._activeRegions;if(t>=r.length)return t;for(var i=r[t].priority;t1)for(var s=0,l=o(s);s!==l;){for(var u=s,c=s;u!==l;){var h=this._activeRegions[u];h.hiddenByOverlap=!1;for(var f=0;f=0;r--)this._addSource(e[r]);this._computeReplacement()}}])})(),e.dm=(function(){return m((function e(t){p(this,e),this._createGrid(t),this._createPoles(t)}),[{key:"destroy",value:function(){for(var e of(this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy(),this._poleSegments))e.destroy();for(var t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy()}},{key:"_fillGridMeshWithLods",value:function(e,t){for(var r=new _s,i=new Ls,n=[],a=e+1+2,o=t[0]+1,s=t[0]+1+(1+t.length),l=function(e,t,r){var i=e===a-1?e-2:0===e?e:e-1;return[i+=r?24575:0,t]},u=0;u=e.byteLength)&&we("Invalid b3dm header information.")}return Ly(e,t)},e.e1=function(e,t){var r=Gy(e);for(var i of r){for(var n of i.meshes)qy(n);i.lights&&(i.lightMeshIndex=i.meshes.length,i.meshes.push(Zy(i.lights,t)))}return r},e.e2=Hv,e.e3=t_,e.e4=Po,e.e5=function(e){tt(),null!=We&&We.then((function(t){t.keys().then((function(r){for(var i=0;i>t/4)).toString(16):"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e)})()},e.v=function(e){return!!e&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)},e.w=we,e.x=It,e.y=2,e.z=kp})),i(0,(function(e){function t(e){var t=e?e.url.toString():void 0;return t?performance.getEntriesByName(t):[]}function r(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e||null==e)return JSON.stringify(e);if(Array.isArray(e)){var t="[";for(var i of e)t+=`${r(i)},`;return`${t}]`}var n="{";for(var a of Object.keys(e).sort())n+=`${a}:${r(e[a])},`;return`${n}}`}function i(t){var i="";for(var n of e.bg)i+=`/${r(t[n])}`;return i}var n=(function(){return m((function e(t){p(this,e),this.keyCache={},this._layers={},this._layerConfigs={},t&&this.replace(t)}),[{key:"replace",value:function(e,t){this._layerConfigs={},this._layers={},this.update(e,[],t)}},{key:"update",value:function(t,r,n){var a=this;for(var o of(this._options=n,t))this._layerConfigs[o.id]=o,(this._layers[o.id]=e.cq(o,this.scope,null,this._options)).compileFilter(n),this.keyCache[o.id]&&delete this.keyCache[o.id];for(var s of r)delete this.keyCache[s],delete this._layerConfigs[s],delete this._layers[s];this.familiesBySource={};var l=(function(e,t){for(var r={},n=0;n=P.maxzoom||"none"!==P.visibility&&(l(C,this.zoom,_.brightness,i),(m[P.id]=P.createBucket({index:c.bucketLayerIDs.length,layers:C,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:M,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep})).populate(S,_,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(C.map((function(e){return e.id})))))}}}}v.trim();var z={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},D=function(){if(h)return s.status="done",a(h);if(s.extraShadowCaster)s.status="done",a(null,{buckets:e.bd(m).filter((function(e){return!e.isEmpty()})),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:_.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(f&&d&&p){var t=new o(f),r=new e.dU(d,p,s.lut);for(var n in m){var u=m[n];u instanceof e.aR?(l(u.layers,s.zoom,_.brightness,i),e.dV(u,f,t.positions,d,r.iconPositions,s.showCollisionBoxes,i,s.tileID.canonical,s.tileZoom,s.projection,s.brightness)):u.hasPattern&&(u instanceof e.aX||u instanceof e.aY||u instanceof e.d0)&&(l(u.layers,s.zoom,_.brightness,i),u.addFeatures(_,s.tileID.canonical,r.patternPositions,i,s.tileTransform,s.brightness))}s.status="done",a(null,{buckets:e.bd(m).filter((function(e){return!e.isEmpty()})),featureIndex:c,collisionBoxArray:s.collisionBoxArray,glyphAtlasImage:t.image,lineAtlas:v,imageAtlas:r,brightness:_.brightness})}};if(!this.extraShadowCaster){var R=e.dT(_.glyphDependencies,(function(e){return Object.keys(e).map(Number)}));Object.keys(R).length?n.send("getGlyphs",{uid:this.uid,stacks:R,scope:this.scope},(function(e,t){h||(h=e,f=t,D())}),void 0,!1,z):f={};var L=Object.keys(_.iconDependencies);L.length?n.send("getImages",{icons:L,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},(function(e,t){h||(h=e,d=t,D())}),void 0,!1,z):d={};var O=Object.keys(_.patternDependencies);O.length?n.send("getImages",{icons:O,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},(function(e,t){h||(h=e,p=t,D())}),void 0,!1,z):p={}}D()}}])})();function l(t,r,i,n){var a=new e.a3(r,{brightness:i});for(var o of t)o.recalculate(a,n)}var u=(function(r){function i(t,r,n,a,o,s){var l;return p(this,i),(l=T(this,i)).actor=t,l.layerIndex=r,l.availableImages=n,l.loadVectorData=o||e.aw,l.loading={},l.loaded={},l.deduped=new e.au(t.scheduler),l.isSpriteLoaded=a,l.scheduler=t.scheduler,l.brightness=s,l}return y(i,r),m(i,[{key:"loadTile",value:function(r,i){var n=this,a=r.uid,o=r&&r.request,l=o&&o.collectResourceTiming,u=this.loading[a]=new s(r);u.abort=this.loadVectorData(r,(function(s,c){var h=!n.loading[a];if(delete n.loading[a],h||s||!c)return u.status="done",h||(n.loaded[a]=u),i(s);var f=c.rawData,d={};c.expires&&(d.expires=c.expires),c.cacheControl&&(d.cacheControl=c.cacheControl),u.vectorTile=c.vectorTile||new e.dW.VectorTile(new e.bb(f));var p=function(){u.parse(u.vectorTile,n.layerIndex,n.availableImages,n.actor,(function(r,n){if(r||!n)return i(r);var a={};if(l){var s=t(o);s.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(s)))}i(null,e.l({rawTileData:f.slice(0)},n,d,a))}))};n.isSpriteLoaded?p():n.once("isSpriteLoaded",(function(){n.scheduler?n.scheduler.add(p,{type:"parseTile",isSymbolTile:r.isSymbolTile,zoom:r.tileZoom}):p()})),n.loaded=n.loaded||{},n.loaded[a]=u}))}},{key:"reloadTile",value:function(t,r){var i=this,n=this.loaded,a=t.uid;if(n&&n[a]){var o=n[a];o.showCollisionBoxes=t.showCollisionBoxes,o.projection=t.projection,o.brightness=t.brightness,o.tileTransform=e.aK(t.tileID.canonical,t.projection),o.extraShadowCaster=t.extraShadowCaster,o.lut=t.lut;var s=function(e,t){var n=o.reloadCallback;n&&(delete o.reloadCallback,o.parse(o.vectorTile,i.layerIndex,i.availableImages,i.actor,n)),r(e,t)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}else r(null,void 0)}},{key:"abortTile",value:function(e,t){var r=e.uid,i=this.loading[r];i&&(i.abort&&i.abort(),delete this.loading[r]),t()}},{key:"removeTile",value:function(e,t){var r=this.loaded,i=e.uid;r&&r[i]&&delete r[i],t()}}])})(e.E),c=(function(){return m((function e(){p(this,e)}),[{key:"loadTile",value:function(t,r){var i=t.uid,n=t.encoding,a=t.rawImageData,o=t.padding,s=ImageBitmap&&a instanceof ImageBitmap?this.getImageData(a,o):a;r(null,new e.dX(i,s,n,o<1))}},{key:"getImageData",value:function(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);var r=this.offscreenCanvasContext.getImageData(-t,-t,e.width+2*t,e.height+2*t);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),r}}])})();e.ba.setPbf(e.bb);var h=(function(){return m((function e(){p(this,e)}),[{key:"decodeRasterArray",value:function(t,r){var i=t.task,n=t.buffer;e.ba.performDecoding(n,i).then((function(e){r(null,e)}),(function(e){r(e)}))}}])})(),f=e.dW.VectorTileFeature.prototype.toGeoJSON,v=(function(){return m((function t(r){p(this,t),this._feature=r,this.extent=e.ab,this.type=r.type,this.properties=r.tags,"id"in r&&!isNaN(r.id)&&(this.id=parseInt(r.id,10))}),[{key:"loadGeometry",value:function(){if(1===this._feature.type){var t=[];for(var r of this._feature.geometry)t.push([new e.P(r[0],r[1])]);return t}var i=[];for(var n of this._feature.geometry){var a=[];for(var o of n)a.push(new e.P(o[0],o[1]));i.push(a)}return i}},{key:"toGeoJSON",value:function(e,t,r){return f.call(this,e,t,r)}}])})(),_=(function(){return m((function t(r){p(this,t),this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=e.ab,this.length=r.length,this._features=r}),[{key:"feature",value:function(e){return new v(this._features[e])}}])})(),g=.015625,b=(function(){return m((function e(){p(this,e),this.features=new Map}),[{key:"clear",value:function(){this.features.clear()}},{key:"load",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0;for(var r of e){var i=r.id;if(null!=i){var n=this.features.get(i);n&&this.updateCache(n,t),r.geometry?(n=M(r),this.updateCache(n,t),this.features.set(i,n)):this.features.delete(i),this.updateCache(n,t)}}}},{key:"updateCache",value:function(e,t){for(var r of Object.values(t)){var i=r.canonical,n=r.uid,a=i.z,o=i.x,s=i.y;w(e,Math.pow(2,a),o,s)&&delete t[n]}}},{key:"getTile",value:function(e,t,r){var i=Math.pow(2,e),n=[];for(var a of this.features.values())w(a,i,t,r)&&n.push(A(a,i,t,r));return{features:n}}},{key:"getFeatures",value:function(){return d(this.features.values())}}])})();function w(e,t,r,i){var n=e.minX,a=e.minY,o=e.maxX,s=e.maxY;return n<(r+1+g)/t&&a<(i+1+g)/t&&o>(r-g)/t&&s>(i-g)/t}function M(e){var t=e.id,r=e.geometry,i=e.properties;if(r){if("GeometryCollection"===r.type)throw new Error("GeometryCollection not supported in dynamic mode.");var n=r.type,a=r.coordinates,o={id:t,type:1,geometry:[],tags:i,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},s=o.geometry;if("Point"===n)S(a,s,o);else if("MultiPoint"===n)for(var l of a)S(l,s,o);else if("LineString"===n)o.type=2,E(a,s,o);else if("MultiLineString"===n)o.type=2,I(a,s,o);else if("Polygon"===n)o.type=3,I(a,s,o,!0);else{if("MultiPolygon"!==n)throw new Error("Input data is not a valid GeoJSON object.");for(var u of(o.type=3,a))I(u,s,o,!0)}return o}}function S(t,r,i){var n=x(t,2),a=n[0],o=n[1],s=e.am(a),l=e.at(o);l=l<0?0:l>1?1:l,r.push(s,l),i.minX=Math.min(i.minX,s),i.minY=Math.min(i.minY,l),i.maxX=Math.max(i.maxX,s),i.maxY=Math.max(i.maxY,l)}function E(e,t,r){var i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],n=arguments.length>4&&void 0!==arguments[4]&&arguments[4],a=[];for(var o of e)S(o,a,r);t.push(a),i&&(function(e,t){for(var r=0,i=0,n=e.length,a=n-2;i0===t)for(var o=0,s=e.length;o3&&void 0!==arguments[3]&&arguments[3],n=0;n=l&&f>=l||(c>=l?(h+=Math.round(m*((l-c)/p)),c=l):f>=l&&(d=h+Math.round(m*((l-c)/p)),f=l),h>=l&&d>=l||(h>=l?(c+=Math.round(p*((l-h)/m)),h=l):d>=l&&(f=c+Math.round(p*((l-h)/m)),d=l),o&&c===o[o.length-1][0]&&h===o[o.length-1][1]||(o=[[c,h]],a.push(o)),o.push([f,d])))))}}var P,z,D,R,L={exports:{}},O=(function(){if(D)return L.exports;D=1;var t=e.d_(),r=(function(){if(z)return P;z=1;var t=e.dY(),r=e.dZ().VectorTileFeature;function i(e,t){this.options=t||{},this.features=e,this.length=e.length}function n(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 P=i,i.prototype.feature=function(e){return new n(this.features[e],this.options.extent)},n.prototype.loadGeometry=function(){var e=this.rawGeometry;this.geometry=[];for(var r=0;r>31}function u(e,t){for(var r=e.loadGeometry(),i=e.type,n=0,a=0,o=r.length,u=0;u=i;m--){var v=+Date.now();p=this.trees[m]=this._createTree(this._cluster(p,m)),r&&console.log("z%d: %d clusters in %dms",m,p.numItems,+Date.now()-v)}return r&&console.timeEnd("total time"),this}},{key:"getClusters",value:function(e,t){var r=((e[0]+180)%360+360)%360-180,i=Math.max(-90,Math.min(90,e[1])),n=180===e[2]?180:((e[2]+180)%360+360)%360-180,a=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)r=-180,n=180;else if(r>n){var o=this.getClusters([r,i,180,a],t),s=this.getClusters([-180,i,n,a],t);return o.concat(s)}var l=this.trees[this._limitZoom(t)],u=l.range(G(r),q(a),G(n),q(i)),c=l.data,h=[];for(var f of u){var d=this.stride*f;h.push(c[d+5]>1?U(c,d,this.clusterProps):this.points[c[d+3]])}return h}},{key:"getChildren",value:function(e){var t=this._getOriginId(e),r=this._getOriginZoom(e),i="No cluster with the specified id.",n=this.trees[r];if(!n)throw new Error(i);var a=n.data;if(t*this.stride>=a.length)throw new Error(i);var o=this.options.radius/(this.options.extent*Math.pow(2,r-1)),s=n.within(a[t*this.stride],a[t*this.stride+1],o),l=[];for(var u of s){var c=u*this.stride;a[c+4]===e&&l.push(a[c+5]>1?U(a,c,this.clusterProps):this.points[a[c+3]])}if(0===l.length)throw new Error(i);return l}},{key:"getLeaves",value:function(e,t,r){var i=[];return this._appendLeaves(i,e,t=t||10,r=r||0,0),i}},{key:"getTile",value:function(e,t,r){var i=this.trees[this._limitZoom(e)],n=Math.pow(2,e),a=this.options,o=a.extent,s=a.radius/o,l=(r-s)/n,u=(r+1+s)/n,c={features:[]};return this._addTileFeatures(i.range((t-s)/n,l,(t+1+s)/n,u),i.data,t,r,n,c),0===t&&this._addTileFeatures(i.range(1-s/n,l,1,u),i.data,n,r,n,c),t===n-1&&this._addTileFeatures(i.range(0,l,s/n,u),i.data,-1,r,n,c),c.features.length?c:null}},{key:"getClusterExpansionZoom",value:function(e){for(var t=this._getOriginZoom(e)-1;t<=this.options.maxZoom;){var r=this.getChildren(e);if(t++,1!==r.length)break;e=r[0].properties.cluster_id}return t}},{key:"_appendLeaves",value:function(e,t,r,i,n){var a=this.getChildren(t);for(var o of a){var s=o.properties;if(s&&s.cluster?n+s.point_count<=i?n+=s.point_count:n=this._appendLeaves(e,s.cluster_id,r,i,n):n1,u=void 0,c=void 0,h=void 0;if(l)u=j(t,s,this.clusterProps),c=t[s],h=t[s+1];else{var f=this.points[t[s+3]];u=f.properties;var d=x(f.geometry.coordinates,2),p=d[0],m=d[1];c=G(p),h=q(m)}var v,_={type:1,geometry:[[Math.round(this.options.extent*(c*n-r)),Math.round(this.options.extent*(h*n-i))]],tags:u};void 0!==(v=l||this.options.generateId?t[s+3]:this.points[t[s+3]].id)&&(_.id=v),a.features.push(_)}}},{key:"_limitZoom",value:function(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}},{key:"_cluster",value:function(e,t){for(var r=this.options,i=r.radius,n=r.extent,a=r.reduce,o=r.minPoints,s=i/(n*Math.pow(2,t)),l=e.data,u=[],c=this.stride,h=0;ht&&(v+=l[y+5])}if(v>m&&v>=o){var g=void 0,x=f*m,b=d*m,w=-1,k=(h/c<<5)+(t+1)+this.points.length;for(var T of p){var M=T*c;if(!(l[M+2]<=t)){l[M+2]=t;var S=l[M+5];x+=l[M]*S,b+=l[M+1]*S,l[M+4]=k,a&&(g||(g=this._map(l,h,!0),w=this.clusterProps.length,this.clusterProps.push(g)),a(g,this._map(l,M)))}}l[h+4]=k,u.push(x/v,b/v,1/0,k,-1,v),a&&u.push(w)}else{for(var E=0;E1)for(var I of p){var A=I*c;if(!(l[A+2]<=t)){l[A+2]=t;for(var C=0;C>5}},{key:"_getOriginZoom",value:function(e){return(e-this.points.length)%32}},{key:"_map",value:function(e,t,r){if(e[t+5]>1){var i=this.clusterProps[e[t+6]];return r?Object.assign({},i):i}var n=this.points[e[t+3]].properties,a=this.options.map(n);return r&&a===n?Object.assign({},a):a}}])})();function U(e,t,r){return{type:"Feature",id:e[t+3],properties:j(e,t,r),geometry:{type:"Point",coordinates:[(i=e[t],360*(i-.5)),Z(e[t+1])]}};var i}function j(e,t,r){var i=e[t+5],n=i>=1e4?`${Math.round(i/1e3)}k`:i>=1e3?Math.round(i/100)/10+"k":i,a=e[t+6],o=-1===a?{}:Object.assign({},r[a]);return Object.assign(o,{cluster:!0,cluster_id:e[t+3],point_count:i,point_count_abbreviated:n})}function G(e){return e/360+.5}function q(e){var t=Math.sin(e*Math.PI/180),r=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return r<0?0:r>1?1:r}function Z(e){var t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function $(e,t,r,i){for(var n,a=i,o=t+(r-t>>1),s=r-t,l=e[t],u=e[t+1],c=e[r],h=e[r+1],f=t+3;fa)n=f,a=d;else if(d===a){var p=Math.abs(f-o);pi&&(n-t>3&&$(e,t,n,i),e[n+2]=a,r-n>3&&$(e,n,r,i))}function H(e,t,r,i,n,a){var o=n-r,s=a-i;if(0!==o||0!==s){var l=((e-r)*o+(t-i)*s)/(o*o+s*s);l>1?(r=n,i=a):l>0&&(r+=o*l,i+=s*l)}return(o=e-r)*o+(s=t-i)*s}function W(e,t,r,i){var n={id:null!=e?e:null,type:t,geometry:r,tags:i,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===t||"MultiPoint"===t||"LineString"===t)X(n,r);else if("Polygon"===t)X(n,r[0]);else if("MultiLineString"===t)for(var a of r)X(n,a);else if("MultiPolygon"===t)for(var o of r)X(n,o[0]);return n}function X(e,t){for(var r=0;r0&&(o+=i?(n*u-l*a)/2:Math.sqrt(Math.pow(l-n,2)+Math.pow(u-a,2))),n=l,a=u}var c=t.length-3;t[2]=1,$(t,0,c,r),t[c+2]=1,t.size=Math.abs(o),t.start=0,t.end=t.size}function Q(e,t,r,i){for(var n=0;n1?1:r}function re(e,t,r,i,n,a,o,s){if(i/=t,a>=(r/=t)&&o=i)return null;var l=[];for(var u of e){var c=u.geometry,h=u.type,f=0===n?u.minX:u.minY,d=0===n?u.maxX:u.maxY;if(f>=r&&d=i)){var p=[];if("Point"===h||"MultiPoint"===h)ie(c,p,r,i,n);else if("LineString"===h)ne(c,p,r,i,n,!1,s.lineMetrics);else if("MultiLineString"===h)oe(c,p,r,i,n,!1);else if("Polygon"===h)oe(c,p,r,i,n,!0);else if("MultiPolygon"===h)for(var m of c){var v=[];oe(m,v,r,i,n,!0),v.length&&p.push(v)}if(p.length){if(s.lineMetrics&&"LineString"===h){for(var _ of p)l.push(W(u.id,h,_,u.tags));continue}"LineString"!==h&&"MultiLineString"!==h||(1===p.length?(h="LineString",p=p[0]):h="MultiLineString"),"Point"!==h&&"MultiPoint"!==h||(h=3===p.length?"Point":"MultiPoint"),l.push(W(u.id,h,p,u.tags))}}}return l.length?l:null}function ie(e,t,r,i,n){for(var a=0;a=r&&o<=i&&se(t,e[a],e[a+1],e[a+2])}}function ne(e,t,r,i,n,a,o){for(var s,l,u=ae(e),c=0===n?le:ue,h=e.start,f=0;fr&&(l=c(u,d,p,v,_,r),o&&(u.start=h+s*l)):y>i?g=r&&(l=c(u,d,p,v,_,r),x=!0),g>i&&y<=i&&(l=c(u,d,p,v,_,i),x=!0),!a&&x&&(o&&(u.end=h+s*l),t.push(u),u=ae(e)),o&&(h+=s)}var b=e.length-3,w=e[b],k=e[b+1],T=0===n?w:k;T>=r&&T<=i&&se(u,w,k,e[b+2]),b=u.length-3,a&&b>=3&&(u[b]!==u[0]||u[b+1]!==u[1])&&se(u,u[0],u[1],u[2]),u.length&&t.push(u)}function ae(e){var t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function oe(e,t,r,i,n,a){for(var o of e)ne(o,t,r,i,n,a,!1)}function se(e,t,r,i){e.push(t,r,i)}function le(e,t,r,i,n,a){var o=(a-t)/(i-t);return se(e,a,r+(n-r)*o,1),o}function ue(e,t,r,i,n,a){var o=(a-r)/(n-r);return se(e,t+(i-t)*o,a,1),o}function ce(e,t){for(var r=[],i=0;i0&&t.size<(n?o:i))r.numPoints+=t.length/3;else{for(var s=[],l=0;lo)&&(r.numSimplified++,s.push(t[l],t[l+1])),r.numPoints++;n&&(function(e,t){for(var r=0,i=0,n=e.length,a=n-2;i0===t)for(var o=0,s=e.length;o24)throw new Error("maxZoom should be in the 0-24 range");if(r.promoteId&&r.generateId)throw new Error("promoteId and generateId cannot be used together.");var n=(function(e,t){var r=[];if("FeatureCollection"===e.type)for(var i=0;i1&&console.time("creation"),f=this.tiles[h]=pe(e,t,r,i,l),this.tileCoords.push({z:t,x:r,y:i}),u)){u>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,r,i,f.numFeatures,f.numPoints,f.numSimplified),console.timeEnd("creation"));var d=`z${t}`;this.stats[d]=(this.stats[d]||0)+1,this.total++}if(f.source=e,null==n){if(t===l.indexMaxZoom||f.numPoints<=l.indexMaxPoints)continue}else{if(t===l.maxZoom||t===n)continue;if(null!=n){var p=n-t;if(r!==a>>p||i!==o>>p)continue}}if(f.source=null,0!==e.length){u>1&&console.time("clipping");var m=.5*l.buffer/l.extent,v=.5-m,_=.5+m,y=1+m,g=null,x=null,b=null,w=null,k=re(e,c,r-m,r+_,0,f.minX,f.maxX,l),T=re(e,c,r+v,r+y,0,f.minX,f.maxX,l);e=null,k&&(g=re(k,c,i-m,i+_,1,f.minY,f.maxY,l),x=re(k,c,i+v,i+y,1,f.minY,f.maxY,l),k=null),T&&(b=re(T,c,i-m,i+_,1,f.minY,f.maxY,l),w=re(T,c,i+v,i+y,1,f.minY,f.maxY,l),T=null),u>1&&console.timeEnd("clipping"),s.push(g||[],t+1,2*r,2*i),s.push(x||[],t+1,2*r,2*i+1),s.push(b||[],t+1,2*r+1,2*i),s.push(w||[],t+1,2*r+1,2*i+1)}}}},{key:"getTile",value:function(e,t,r){e=+e,t=+t,r=+r;var i=this.options,n=i.extent,a=i.debug;if(e<0||e>24)return null;var o=1<1&&console.log("drilling down to z%d-%d-%d",e,t,r);for(var l,u=e,c=t,h=r;!l&&u>0;)u--,c>>=1,h>>=1,l=this.tiles[ge(u,c,h)];return l&&l.source?(a>1&&(console.log("found parent tile z%d-%d-%d",u,c,h),console.time("drilling down")),this.splitTile(l.source,u,c,h,e,t,r),a>1&&console.timeEnd("drilling down"),this.tiles[s]?fe(this.tiles[s],n):null):null}}])})();function ge(e,t,r){return 32*((1<=0?0:e.button}function D(t,r,i){var n=t.offsetWidth===r.width?1:t.offsetWidth/r.width;return new e.P((i.clientX-r.left)*n,(i.clientY-r.top)*n)}var R="01",L="NO_ACCESS_TOKEN",O=(function(){return m((function e(t,r,i){p(this,e),this._transformRequestFn=t,this._customAccessToken=r,this._silenceAuthErrors=!!i,this._createSkuToken()}),[{key:"_createSkuToken",value:function(){var e=(function(){for(var e="",t=0;t<10;t++)e+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1",R,e].join(""),tokenExpiresAt:Date.now()+432e5}})();this._skuToken=e.token,this._skuTokenExpiresAt=e.tokenExpiresAt}},{key:"_isSkuTokenExpired",value:function(){return Date.now()>this._skuTokenExpiresAt}},{key:"transformRequest",value:function(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}},{key:"normalizeStyleURL",value:function(r,i){if(!e.f(r))return r;var n=F(r);return n.params.push(`sdk=js-${t}`),n.path=`/styles/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||i)}},{key:"normalizeGlyphsURL",value:function(t,r){if(!e.f(t))return t;var i=F(t);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||r)}},{key:"normalizeModelURL",value:function(t,r){if(!e.f(t))return t;var i=F(t);return i.path=`/models/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||r)}},{key:"normalizeSourceURL",value:function(t,r,i,n){if(!e.f(t))return t;var a=F(t);return a.path=`/v4/${a.authority}.json`,a.params.push("secure"),i&&a.params.push(`language=${i}`),n&&a.params.push(`worldview=${n}`),this._makeAPIURL(a,this._customAccessToken||r)}},{key:"normalizeSpriteURL",value:function(t,r,i,n){var a=F(t);return e.f(t)?(a.path=`/styles/v1${a.path}/sprite${r}${i}`,this._makeAPIURL(a,this._customAccessToken||n)):(a.path+=`${r}${i}`,N(a))}},{key:"normalizeTileURL",value:function(t,r,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!e.f(t))return t;var n=F(t);n.path=n.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${r||i&&"raster"!==n.authority&&512===i?"@2x":""}${e.m.supported?".webp":"$1"}`),"raster"===n.authority?n.path=`/${e.e.RASTER_URL_PREFIX}${n.path}`:"rasterarrays"===n.authority?n.path=`/${e.e.RASTERARRAYS_URL_PREFIX}${n.path}`:"3dtiles"===n.authority?n.path=`/${e.e.TILES3D_URL_PREFIX}${n.path}`:(n.path=n.path.replace(/^.+\/v4\//,"/"),n.path=`/${e.e.TILE_URL_VERSION}${n.path}`);var a=this._customAccessToken||(function(e){for(var t of e){var r=t.match(/^access_token=(.*)$/);if(r)return r[1]}return null})(n.params)||e.e.ACCESS_TOKEN;return e.e.REQUIRE_ACCESS_TOKEN&&a&&this._skuToken&&n.params.push(`sku=${this._skuToken}`),this._makeAPIURL(n,a)}},{key:"canonicalizeTileURL",value:function(t,r){var i=F(t);if(!i.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!i.path.match(/\.[\w]+$/))return t;var n="mapbox://";i.path.match(/^\/raster\/v1\//)?n+=`raster/${i.path.replace(`/${e.e.RASTER_URL_PREFIX}/`,"")}`:i.path.match(/^\/rasterarrays\/v1\//)?n+=`rasterarrays/${i.path.replace(`/${e.e.RASTERARRAYS_URL_PREFIX}/`,"")}`:n+=`tiles/${i.path.replace(`/${e.e.TILE_URL_VERSION}/`,"")}`;var a=i.params;return r&&(a=a.filter((function(e){return!e.match(/^access_token=/)}))),a.length&&(n+=`?${a.join("&")}`),n}},{key:"canonicalizeTileset",value:function(t,r){var i=!!r&&e.f(r),n=[];for(var a of t.tiles||[])e.h(a)?n.push(this.canonicalizeTileURL(a,i)):n.push(a);return n}},{key:"_makeAPIURL",value:function(t,r){var i="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",n=F(e.e.API_URL);if(t.protocol=n.protocol,t.authority=n.authority,"http"===t.protocol){var a=t.params.indexOf("secure");a>=0&&t.params.splice(a,1)}if("/"!==n.path&&(t.path=`${n.path}${t.path}`),!e.e.REQUIRE_ACCESS_TOKEN)return N(t);if(r=r||e.e.ACCESS_TOKEN,!this._silenceAuthErrors){if(!r)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if("s"===r[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return t.params=t.params.filter((function(e){return-1===e.indexOf("access_token")})),t.params.push(`access_token=${r||""}`),N(t)}}])})(),B=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function F(e){var t=e.match(B);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 N(e){var t=e.params.length?`?${e.params.join("&")}`:"";return`${e.protocol}://${e.authority}${e.path}${t}`}var V="mapbox.eventData";function U(t){if(!t)return null;var r=t.split(".");if(!r||3!==r.length)return null;try{return JSON.parse(e.j(r[1]))}catch(e){return null}}var j=(function(){return m((function e(t){p(this,e),this.type=t,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}),[{key:"getStorageKey",value:function(t){var r,i=U(e.e.ACCESS_TOKEN);return r=i&&i.u?e.k(i.u):e.e.ACCESS_TOKEN||"",t?`${V}.${t}:${r}`:`${V}:${r}`}},{key:"fetchEventData",value:function(){var t=e.s("localStorage"),r=this.getStorageKey(),i=this.getStorageKey("uuid");if(t)try{var n=localStorage.getItem(r);n&&(this.eventData=JSON.parse(n));var a=localStorage.getItem(i);a&&(this.anonId=a)}catch(t){e.w("Unable to read from LocalStorage")}}},{key:"saveEventData",value:function(){var t=e.s("localStorage"),r=this.getStorageKey(),i=this.getStorageKey("uuid"),n=this.anonId;if(t&&n)try{localStorage.setItem(i,n),Object.keys(this.eventData).length>=1&&localStorage.setItem(r,JSON.stringify(this.eventData))}catch(t){e.w("Unable to write to LocalStorage")}}},{key:"processRequests",value:function(e){}},{key:"postEvent",value:function(t,r,i,n){var a=this;if(e.e.EVENTS_URL){var o=F(e.e.EVENTS_URL);o.params.push(`access_token=${n||e.e.ACCESS_TOKEN||""}`);var s={event:this.type,created:new Date(t).toISOString()},l=r?e.l(s,r):s,u={url:N(o),headers:{"Content-Type":"text/plain"},body:JSON.stringify([l])};this.pendingRequest=e.p(u,(function(e){a.pendingRequest=null,i(e),a.saveEventData(),a.processRequests(n)}))}}},{key:"queueRequest",value:function(e,t){this.queue.push(e),this.processRequests(t)}}])})(),G=new((function(r){function i(e){var t;return p(this,i),(t=T(this,i,["appUserTurnstile"]))._customAccessToken=e,t}return y(i,r),m(i,[{key:"postTurnstileEvent",value:function(t,r){e.e.EVENTS_URL&&e.e.ACCESS_TOKEN&&Array.isArray(t)&&t.some((function(t){return e.f(t)||e.h(t)}))&&this.queueRequest(Date.now(),r)}},{key:"processRequests",value:function(r){var i=this;if(!this.pendingRequest&&0!==this.queue.length){this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();var n=U(e.e.ACCESS_TOKEN),a=n?n.u:e.e.ACCESS_TOKEN,o=a!==this.eventData.tokenU;e.v(this.anonId)||(this.anonId=e.u(),o=!0);var s=this.queue.shift();if(this.eventData.lastSuccess){var l=new Date(this.eventData.lastSuccess),u=new Date(s),c=(s-this.eventData.lastSuccess)/864e5;o=o||c>=1||c<-1||l.getDate()!==u.getDate()}else o=!0;o?this.postEvent(s,{sdkIdentifier:"mapbox-gl-js",sdkVersion:t,skuId:R,"enabled.telemetry":!1,userId:this.anonId},(function(e){e||(i.eventData.lastSuccess=s,i.eventData.tokenU=a)}),r):this.processRequests()}}}])})(j)),q=G.postTurnstileEvent.bind(G),Z=new((function(r){function i(){var e;return p(this,i),(e=T(this,i,["map.load"])).success={},e.skuToken="",e}return y(i,r),m(i,[{key:"postMapLoadEvent",value:function(t,r,i,n){this.skuToken=r,this.errorCb=n,e.e.EVENTS_URL&&(i||e.e.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},i):this.errorCb(new Error(L)))}},{key:"processRequests",value:function(r){var i=this;if(!this.pendingRequest&&0!==this.queue.length){var n=this.queue.shift(),a=n.id,o=n.timestamp;a&&this.success[a]||(this.anonId||this.fetchEventData(),e.v(this.anonId)||(this.anonId=e.u()),this.postEvent(o,{sdkIdentifier:"mapbox-gl-js",sdkVersion:t,skuId:R,skuToken:this.skuToken,userId:this.anonId},(function(e){e?i.errorCb(e):a&&(i.success[a]=!0)}),r))}}},{key:"remove",value:function(){this.errorCb=null}}])})(j)),$=Z.postMapLoadEvent.bind(Z),H=new((function(t){function r(){var e;return p(this,r),(e=T(this,r,["style.load"])).eventIdPerMapInstanceMap=new Map,e.mapInstanceIdMap=new WeakMap,e}return y(r,t),m(r,[{key:"getMapInstanceId",value:function(t){var r=this.mapInstanceIdMap.get(t);return r||(r=e.u(),this.mapInstanceIdMap.set(t,r)),r}},{key:"getEventId",value:function(e){var t=this.eventIdPerMapInstanceMap.get(e)||0;return this.eventIdPerMapInstanceMap.set(e,t+1),t}},{key:"postStyleLoadEvent",value:function(t,r){var i=r.map,n=r.style,a=r.importedStyles;if(e.e.EVENTS_URL&&(t||e.e.ACCESS_TOKEN)){var o=this.getMapInstanceId(i),s={mapInstanceId:o,eventId:this.getEventId(o),style:n};a.length&&(s.importedStyles=a),this.queueRequest({timestamp:Date.now(),payload:s},t)}}},{key:"processRequests",value:function(e){if(!this.pendingRequest&&0!==this.queue.length){var t=this.queue.shift(),r=t.timestamp,i=t.payload;this.postEvent(r,i,(function(){}),e)}}}])})(j)),W=H.postStyleLoadEvent.bind(H),X=new((function(i){function a(){return p(this,a),T(this,a,["gljs.performance"])}return y(a,i),m(a,[{key:"postPerformanceEvent",value:function(t,r){e.e.EVENTS_URL&&(t||e.e.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:r},t)}},{key:"processRequests",value:function(i){if(!this.pendingRequest&&0!==this.queue.length){var a=this.queue.shift(),o=a.timestamp,s=(function(i){var a=performance.getEntriesByType("resource"),o=performance.getEntriesByType("mark"),s=(function(e){var t={};if(e)for(var r in e)if("other"!==r)for(var i of e[r]){var n=`${r}ResolveRangeMin`,a=`${r}ResolveRangeMax`,o=`${r}RequestCount`,s=`${r}RequestCachedCount`;t[n]=Math.min(t[n]||1/0,i.startTime),t[a]=Math.max(t[a]||-1/0,i.responseEnd);var l=function(e){void 0===t[e]&&(t[e]=0),++t[e]};void 0!==i.transferSize&&0===i.transferSize&&l(s),l(o)}return t})((function(e,t){var r={};if(e)for(var i of e){var n=t(i);void 0===r[n]&&(r[n]=[]),r[n].push(i)}return r})(a,n)),l=window.devicePixelRatio,u=navigator.connection||navigator.mozConnection||navigator.webkitConnection,c=u?u.effectiveType:void 0,h={counters:[],metadata:[],attributes:[]},f=function(e,t,r){null!=r&&e.push({name:t,value:r.toString()})};for(var d in s)f(h.counters,d,s[d]);if(i.interactionRange[0]!==1/0&&i.interactionRange[1]!==-1/0&&(f(h.counters,"interactionRangeMin",i.interactionRange[0]),f(h.counters,"interactionRangeMax",i.interactionRange[1])),o){var p=function(){var e=r[m],t=o.find((function(t){return t.name===e}));t&&f(h.counters,e,t.startTime)};for(var m of Object.keys(r))p()}return f(h.counters,"visibilityHidden",i.visibilityHidden),f(h.attributes,"style",(function(t){if(t)for(var r of t){var i=r.name.split("?")[0];if(e.i(i)){var n=i.split("/").slice(-2);if(2===n.length)return`mapbox://styles/${n[0]}/${n[1]}`}}})(a)),f(h.attributes,"terrainEnabled",i.terrainEnabled?"true":"false"),f(h.attributes,"fogEnabled",i.fogEnabled?"true":"false"),f(h.attributes,"projection",i.projection),f(h.attributes,"zoom",i.zoom),f(h.metadata,"devicePixelRatio",l),f(h.metadata,"connectionEffectiveType",c),f(h.metadata,"navigatorUserAgent",navigator.userAgent),f(h.metadata,"screenWidth",window.screen.width),f(h.metadata,"screenHeight",window.screen.height),f(h.metadata,"windowWidth",window.innerWidth),f(h.metadata,"windowHeight",window.innerHeight),f(h.metadata,"mapWidth",i.width/l),f(h.metadata,"mapHeight",i.height/l),f(h.metadata,"webglRenderer",i.renderer),f(h.metadata,"webglVendor",i.vendor),f(h.metadata,"sdkVersion",t),f(h.metadata,"sdkIdentifier","mapbox-gl-js"),h})(a.performanceData);for(var l of s.metadata);for(var u of s.counters);for(var c of s.attributes);this.postEvent(o,s,(function(){}),i)}}}])})(j)),Y=X.postPerformanceEvent.bind(X),J=new((function(t){function r(){var e;return p(this,r),(e=T(this,r,["map.auth"])).success={},e.skuToken="",e}return y(r,t),m(r,[{key:"getSession",value:function(t,r,i,n){var a=this;if(e.e.API_URL&&e.e.SESSION_PATH){var o=F(e.e.API_URL+e.e.SESSION_PATH);o.params.push(`sku=${r||""}`),o.params.push(`access_token=${n||e.e.ACCESS_TOKEN||""}`);var s={url:N(o),headers:{"Content-Type":"text/plain"}};this.pendingRequest=e.g(s,(function(e){a.pendingRequest=null,i(e),a.saveEventData(),a.processRequests(n)}))}}},{key:"getSessionAPI",value:function(t,r,i,n){this.skuToken=r,this.errorCb=n,e.e.SESSION_PATH&&e.e.API_URL&&(i||e.e.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},i):this.errorCb(new Error(L)))}},{key:"processRequests",value:function(e){var t=this;if(!this.pendingRequest&&0!==this.queue.length){var r=this.queue.shift(),i=r.id,n=r.timestamp;i&&this.success[i]||this.getSession(n,this.skuToken,(function(e){e?t.errorCb(e):i&&(t.success[i]=!0)}),e)}}},{key:"remove",value:function(){this.errorCb=null}}])})(j)),K=J.getSessionAPI.bind(J),Q=new Set;function ee(e,t){t?Q.add(e):Q.delete(e)}var te=(function(){return m((function e(){p(this,e),this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps=new Set,this._updatedImages=new Set}),[{key:"isDirty",value:function(){return this._changed}},{key:"setDirty",value:function(){this._changed=!0}},{key:"getUpdatedSourceCaches",value:function(){return this._updatedSourceCaches}},{key:"updateSourceCache",value:function(e,t){this._updatedSourceCaches[e]=t,this.setDirty()}},{key:"discardSourceCacheUpdate",value:function(e){delete this._updatedSourceCaches[e]}},{key:"updateLayer",value:function(e){var t=e.scope;this._updatedLayers[t]=this._updatedLayers[t]||new Set,this._updatedLayers[t].add(e.id),this.setDirty()}},{key:"removeLayer",value:function(e){var 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()}},{key:"getRemovedLayer",value:function(e){return this._removedLayers[e.scope]?this._removedLayers[e.scope][e.id]:null}},{key:"discardLayerRemoval",value:function(e){this._removedLayers[e.scope]&&delete this._removedLayers[e.scope][e.id]}},{key:"getLayerUpdatesByScope",value:function(){var e={};for(var t in this._updatedLayers)e[t]=e[t]||{},e[t].updatedIds=Array.from(this._updatedLayers[t].values());for(var r in this._removedLayers)e[r]=e[r]||{},e[r].removedIds=Object.keys(this._removedLayers[r]);return e}},{key:"getUpdatedPaintProperties",value:function(){return this._updatedPaintProps}},{key:"updatePaintProperties",value:function(e){this._updatedPaintProps.add(e.fqid),this.setDirty()}},{key:"getUpdatedImages",value:function(){return Array.from(this._updatedImages.values())}},{key:"updateImage",value:function(e){this._updatedImages.add(e),this.setDirty()}},{key:"resetUpdatedImages",value:function(){this._updatedImages.clear()}},{key:"reset",value:function(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps.clear(),this._updatedImages.clear()}}])})();function re(e){var t=e.userImage;return!!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}var ie=(function(t){function r(){var e;return p(this,r),(e=T(this,r)).images={},e.updatedImages={},e.callbackDispatchedThisFrame={},e.loaded={},e.requestors=[],e.patterns={},e.atlasImage={},e.atlasTexture={},e.dirty=!0,e}return y(r,t),m(r,[{key:"createScope",value:function(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})}},{key:"isLoaded",value:function(){for(var e in this.loaded)if(!this.loaded[e])return!1;return!0}},{key:"setLoaded",value:function(e,t){if(this.loaded[t]!==e&&(this.loaded[t]=e,e)){for(var r of this.requestors){var i=r.ids,n=r.callback;this._notify(i,t,n)}this.requestors=[]}}},{key:"hasImage",value:function(e,t){return!!this.getImage(e,t)}},{key:"getImage",value:function(e,t){return this.images[t][e]}},{key:"addImage",value:function(e,t,r){this._validate(e,r)&&(this.images[t][e]=r)}},{key:"_validate",value:function(t,r){var i=!0;return this._validateStretch(r.stretchX,r.data&&r.data.width)||(this.fire(new e.t(new Error(`Image "${t}" has invalid "stretchX" value`))),i=!1),this._validateStretch(r.stretchY,r.data&&r.data.height)||(this.fire(new e.t(new Error(`Image "${t}" has invalid "stretchY" value`))),i=!1),this._validateContent(r.content,r)||(this.fire(new e.t(new Error(`Image "${t}" has invalid "content" value`))),i=!1),i}},{key:"_validateStretch",value:function(e,t){if(!e)return!0;var r=0;for(var i of e){if(i[0]1?f-1:f,e.r.copy(m,l,{x:0,y:0},{x:d,y:p},{width:v,height:_},r),e.r.copy(m,l,{x:0,y:_-f},{x:d,y:p-f},{width:v,height:f},r),e.r.copy(m,l,{x:0,y:0},{x:d,y:p+_},{width:v,height:f},r),e.r.copy(m,l,{x:v-f,y:0},{x:d-f,y:p},{width:f,height:_},r),e.r.copy(m,l,{x:0,y:0},{x:d+v,y:p},{width:f,height:_},r),e.r.copy(m,l,{x:v-f,y:_-f},{x:d-f,y:p-f},{width:f,height:f},r),e.r.copy(m,l,{x:0,y:_-f},{x:d+v,y:p-f},{width:f,height:f},r),e.r.copy(m,l,{x:0,y:0},{x:d+v,y:p+_},{width:f,height:f},r),e.r.copy(m,l,{x:v-f,y:0},{x:d-f,y:p+_},{width:f,height:f},r)}this.dirty=!0}},{key:"beginFrame",value:function(){for(var e in this.images)this.callbackDispatchedThisFrame[e]={}}},{key:"dispatchRenderCallbacks",value:function(e,t){for(var r of e)if(!this.callbackDispatchedThisFrame[t][r]){this.callbackDispatchedThisFrame[t][r]=!0;var i=this.images[t][r];re(i)&&this.updateImage(r,t,i)}}}])})(e.E);function ne(t){var r=t.key,i=t.value,n=t.valueSpec||{},a=t.objectElementValidators||{},o=t.style,s=t.styleSpec,l=[],u=e.B(i);if("object"!==u)return[new e.V(r,i,`object expected, ${u} found`)];for(var c in i){var h=c.split(".")[0],f=void 0;a[h]?f=a[h]:n[h]?f=Se:a["*"]?f=a["*"]:n["*"]&&(f=Se),f?l=l.concat(f({key:(r?`${r}.`:r)+c,value:i[c],valueSpec:n[h]||n["*"],style:o,styleSpec:s,object:i,objectKey:c},i)):l.push(new e.A(r,i[c],`unknown property "${c}"`))}for(var d in n)a[d]||n[d].required&&void 0===n[d].default&&void 0===i[d]&&l.push(new e.V(r,i,`missing required property "${d}"`));return l}function ae(t){var r=t.value,i=t.valueSpec,n=t.style,a=t.styleSpec,o=t.key,s=t.arrayElementValidator||Se;if("array"!==e.B(r))return[new e.V(o,r,`array expected, ${e.B(r)} found`)];if(i.length&&r.length!==i.length)return[new e.V(o,r,`array length ${i.length} expected, length ${r.length} found`)];if(i["min-length"]&&r.lengths)return[new e.V(r,i,`${i} is greater than the maximum value ${s}`)]}return[]}function se(t){var r,i,n,a=t.valueSpec,o=e.D(t.value.type),s={},l="categorical"!==o&&void 0===t.value.property,u=!l,c="array"===e.B(t.value.stops)&&"array"===e.B(t.value.stops[0])&&"object"===e.B(t.value.stops[0][0]),h=ne({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')];var r=[],i=t.value;return r=r.concat(ae({key:t.key,value:i,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:f})),"array"===e.B(i)&&0===i.length&&r.push(new e.V(t.key,i,"array must have at least one stop")),r},default:function(e){return Se({key:e.key,value:e.value,valueSpec:a,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===o&&l&&h.push(new e.V(t.key,t.value,'missing required property "property"')),"identity"===o||t.value.stops||h.push(new e.V(t.key,t.value,'missing required property "stops"')),"exponential"===o&&t.valueSpec.expression&&!e.F(t.valueSpec)&&h.push(new e.V(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(u&&!e.G(t.valueSpec)?h.push(new e.V(t.key,t.value,"property functions not supported")):l&&!e.H(t.valueSpec)&&h.push(new e.V(t.key,t.value,"zoom functions not supported"))),"categorical"!==o&&!c||void 0!==t.value.property||h.push(new e.V(t.key,t.value,'"property" property is required')),h;function f(t){var r=[],o=t.value,l=t.key;if("array"!==e.B(o))return[new e.V(l,o,`array expected, ${e.B(o)} found`)];if(2!==o.length)return[new e.V(l,o,`array length 2 expected, length ${o.length} found`)];if(c){if("object"!==e.B(o[0]))return[new e.V(l,o,`object expected, ${e.B(o[0])} found`)];if(void 0===o[0].zoom)return[new e.V(l,o,"object stop key must have zoom")];if(void 0===o[0].value)return[new e.V(l,o,"object stop key must have value")];var u=e.D(o[0].zoom);if("number"!=typeof u)return[new e.V(l,o[0].zoom,"stop zoom values must be numbers")];if(n&&n>u)return[new e.V(l,o[0].zoom,"stop zoom values must appear in ascending order")];u!==n&&(n=u,i=void 0,s={}),r=r.concat(ne({key:`${l}[0]`,value:o[0],valueSpec:{zoom:{}},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:oe,value:d}}))}else r=r.concat(d({key:`${l}[0]`,value:o[0],valueSpec:{},style:t.style,styleSpec:t.styleSpec},o));return e.J(e.K(o[1]))?r.concat([new e.V(`${l}[1]`,o[1],"expressions are not allowed in function stops.")]):r.concat(Se({key:`${l}[1]`,value:o[1],valueSpec:a,style:t.style,styleSpec:t.styleSpec}))}function d(t,n){var l=e.B(t.value),u=e.D(t.value),c=null!==t.value?t.value:n;if(r){if(l!==r)return[new e.V(t.key,c,`${l} stop domain type must match previous stop domain type ${r}`)]}else r=l;if("number"!==l&&"string"!==l&&"boolean"!==l&&"number"!=typeof u&&"string"!=typeof u&&"boolean"!=typeof u)return[new e.V(t.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==l&&"categorical"!==o){var h=`number expected, ${l} found`;return e.G(a)&&void 0===o&&(h+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new e.V(t.key,c,h)]}return"categorical"!==o||"number"!==l||"number"==typeof u&&isFinite(u)&&Math.floor(u)===u?"categorical"!==o&&"number"===l&&"number"==typeof u&&"number"==typeof i&&void 0!==i&&u":case">=":r.length>=2&&"$type"===e.D(r[1])&&o.push(new e.V(i,r,`"$type" cannot be use with operator "${r[0]}"`));case"==":case"!=":3!==r.length&&o.push(new e.V(i,r,`filter array for operator "${r[0]}" must have 3 elements`));case"in":case"!in":r.length>=2&&("string"!==(n=e.B(r[1]))&&o.push(new e.V(`${i}[1]`,r[1],`string expected, ${n} found`)));for(var s=2;s1&&void 0!==arguments[1]&&arguments[1],i=t.value,n=t.valueSpec,a=t.styleSpec;if(n.expression&&e.X(e.D(i)))return se(t);if(n.expression&&e.J(e.K(i)))return le(t);if(n.type&&Me[n.type]){var o=Me[n.type](t);return!0===r&&o.length>0&&"array"===e.B(t.value)?le(t):o}return ne(e.C({},t,{valueSpec:n.type?a[n.type]:n}))}function Ee(t){var r=t.value,i=t.key,n=_e(t);return n.length||(-1===r.indexOf("{fontstack}")&&n.push(new e.V(i,r,'"glyphs" url must include a "{fontstack}" token')),-1===r.indexOf("{range}")&&n.push(new e.V(i,r,'"glyphs" url must include a "{range}" token'))),n}function Ie(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e._;return Se({key:(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).key||"",value:t,valueSpec:r.$root,styleSpec:r,style:t,objectElementValidators:{glyphs:Ee,"*":function(){return[]}}})}function Ae(t){return Ue(Ie(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:e._))}var Ce,Pe=function(e){return Ue(ge(e))},ze=function(e){return Ue(be(e))},De=function(e){return Ue(we(e))},Re=function(e){return Ue(ke(e))},Le=function(e){return Ue(Te(e))},Oe=function(e){return Ue(ve(e))},Be=function(e){return Ue(he(e))},Fe=function(e){return Ue(pe(e))},Ne=function(e){return Ue(me(e))},Ve=function(t){return Ue(e.Z(t))};function Ue(e){return e.slice().sort((function(e,t){return e.line&&t.line?e.line-t.line:0}))}function je(t,r){var i=!1;if(r&&r.length)for(var n of r)n instanceof e.A?e.w(n.message):(t.fire(new e.t(new Error(n.message))),i=!0);return i}var Ge=(function(t){function r(t){var i,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"flat";return p(this,r),(i=T(this,r))._transitionable=new e.$(Ce||(Ce=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)}))),i.setLight(t,n),i._transitioning=i._transitionable.untransitioned(),i}return y(r,t),m(r,[{key:"getLight",value:function(){return this._transitionable.serialize()}},{key:"setLight",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this._validate(ze,e,r)||(this._transitionable.setTransitionOrValue(e),this.id=t)}},{key:"updateTransitions",value:function(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}},{key:"hasTransition",value:function(){return this._transitioning.hasTransition()}},{key:"recalculate",value:function(e){this.properties=this._transitioning.possiblyEvaluate(e)}},{key:"_validate",value:function(t,r,i){return(!i||!1!==i.validate)&&je(this,t.call(Ae,e.l({value:r,style:{glyphs:!0,sprite:!0},styleSpec:e._})))}}])})(e.E),qe=new e.a0({source:new e.a1(e._.terrain.source),exaggeration:new e.a1(e._.terrain.exaggeration)}),Ze=(function(t){function r(t,i,n,a){var o;return p(this,r),(o=T(this,r)).scope=n,o._transitionable=new e.$(qe,n,a),o._transitionable.setTransitionOrValue(t,a),o._transitioning=o._transitionable.untransitioned(),o.drapeRenderMode=i,o}return y(r,t),m(r,[{key:"get",value:function(){return this._transitionable.serialize()}},{key:"set",value:function(e,t){this._transitionable.setTransitionOrValue(e,t)}},{key:"updateTransitions",value:function(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}},{key:"hasTransition",value:function(){return this._transitioning.hasTransition()}},{key:"recalculate",value:function(e){this.properties=this._transitioning.possiblyEvaluate(e)}},{key:"getExaggeration",value:function(t){return this._transitioning.possiblyEvaluate(new e.a3(t)).get("exaggeration")}},{key:"isZoomDependent",value:function(){var t=this._transitionable._values.exaggeration;return null!=t&&null!=t.value&&null!=t.value.expression&&t.value.expression instanceof e.a4}}])})(e.E),$e=.05;function He(t,r,i,n){var a=e.a7(45,65,i),o=We(t,n),s=x(o,2),l=s[0],u=s[1],c=1-Math.min(1,Math.exp((r-l)/(u-l)*-6));return c*=c*c,(c=Math.min(1,1.00747*c))*a*t.alpha}function We(e,t){var r=.5/Math.tan(.5*t);return[e.range[0]+r,e.range[1]+r]}function Xe(t,r,i,n,a){var o=e.a6.vec3.transformMat4([],[r,i,n],a.mercatorFogMatrix);return He(t,e.a6.vec3.length(o),a.pitch,a._fov)}function Ye(t,r,i,n,a,o,s){var l=[[i,n,0],[a,n,0],[a,o,0],[i,o,0]],u=Number.MAX_VALUE,c=-Number.MAX_VALUE;for(var h of l){var f=e.a6.vec3.transformMat4([],h,r),d=e.a6.vec3.length(f);u=Math.min(u,d),c=Math.max(c,d)}return[He(t,u,s.pitch,s._fov),He(t,c,s.pitch,s._fov)]}var Je,Ke,Qe=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"])}),et=(function(t){function r(t,i,n,a){var o;return p(this,r),(o=T(this,r))._transitionable=new e.$(Qe,n,new Map(a)),o.set(t,a),o._transitioning=o._transitionable.untransitioned(),o._transform=i,o.properties=new e.a8(Qe),o.scope=n,o}return y(r,t),m(r,[{key:"state",get:function(){var t=this._transform,r="globe"===t.projection.name,i=e.a9(t.zoom),n=this.properties.get("range"),a=[.5,3];return{range:r?[e.aa(a[0],n[0],i),e.aa(a[1],n[1],i)]:n,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}},{key:"get",value:function(){return this._transitionable.serialize()}},{key:"set",value:function(t,r){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!this._validate(Le,t,i)){var n=e.l({},t);for(var a of Object.keys(e._.fog))void 0===n[a]&&(n[a]=e._.fog[a].default);this._options=n,this._transitionable.setTransitionOrValue(this._options,r)}}},{key:"getOpacity",value:function(t){if(!this._transform.projection.supportsFog)return 0;var r=this.properties&&this.properties.get("color")||1;return("globe"===this._transform.projection.name?1:e.a7(45,65,t))*r.a}},{key:"getOpacityAtLatLng",value:function(t,r){return this._transform.projection.supportsFog?(function(t,r,i){var n=e.a5.fromLngLat(r),a=i.elevation?i.elevation.getAtPointOrZero(n):0;return Xe(t,n.x,n.y,a,i)})(this.state,t,r):0}},{key:"getOpacityForTile",value:function(t){if(!this._transform.projection.supportsFog)return[1,1];var r=this._transform.calculateFogTileMatrix(t.toUnwrapped());return Ye(this.state,r,0,0,e.ab,e.ab,this._transform)}},{key:"getOpacityForBounds",value:function(e,t,r,i,n){return this._transform.projection.supportsFog?Ye(this.state,e,t,r,i,n,this._transform):[1,1]}},{key:"getFovAdjustedRange",value:function(e){return this._transform.projection.supportsFog?We(this.state,e):[0,1]}},{key:"isVisibleOnFrustum",value:function(t){if(!this._transform.projection.supportsFog)return!1;for(var r of[4,5,6,7]){var i=t.points[r],n=void 0;if(i[2]>=0)n=i;else{var a=t.points[r-4];n=e.ac(a,i,a[2]/(a[2]-i[2]))}if(Xe(this.state,n[0],n[1],0,this._transform)>=$e)return!0}return!1}},{key:"updateConfig",value:function(e){this._transitionable.setTransitionOrValue(this._options,new Map(e))}},{key:"updateTransitions",value:function(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}},{key:"hasTransition",value:function(){return this._transitioning.hasTransition()}},{key:"recalculate",value:function(e){this.properties=this._transitioning.possiblyEvaluate(e)}},{key:"_validate",value:function(t,r,i){return(!i||!1!==i.validate)&&je(this,t.call(Ae,e.l({value:r,style:{glyphs:!0,sprite:!0},styleSpec:e._})))}}])})(e.E),tt=(function(t){function r(t,i,n,a){var o;return p(this,r),(o=T(this,r)).scope=n,o._options=t,o.properties=new e.a8(i),o._transitionable=new e.$(i,n,new Map(a)),o._transitionable.setTransitionOrValue(t.properties),o._transitioning=o._transitionable.untransitioned(),o}return y(r,t),m(r,[{key:"updateConfig",value:function(e){this._transitionable.setTransitionOrValue(this._options.properties,new Map(e))}},{key:"updateTransitions",value:function(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}},{key:"hasTransition",value:function(){return this._transitioning.hasTransition()}},{key:"recalculate",value:function(e){this.properties=this._transitioning.possiblyEvaluate(e)}},{key:"get",value:function(){return this._options.properties=this._transitionable.serialize(),this._options}},{key:"set",value:function(e,t){this._options=e,this._transitionable.setTransitionOrValue(e.properties,t)}},{key:"shadowsEnabled",value:function(){return!!this.properties&&!0===this.properties.get("cast-shadows")}}])})(e.E),rt=(function(){function t(e,r,i,n){p(this,t),this.screenBounds=e,this.cameraPoint=r,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=i,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,n)}return m(t,[{key:"isPointQuery",value:function(){return 1===this.screenBounds.length}},{key:"bufferedScreenGeometry",value:function(t){return e.ae(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],t)}},{key:"bufferedCameraGeometry",value:function(t){var r=this.screenBounds[0],i=1===this.screenBounds.length?this.screenBounds[0].add(new e.P(1,1)):this.screenBounds[1],n=e.ae(r,i,0,!1);return this.cameraPoint.y>i.y&&(this.cameraPoint.x>r.x&&this.cameraPoint.x=i.x?n[2]=this.cameraPoint:this.cameraPoint.x<=r.x&&(n[3]=this.cameraPoint)),e.af(n,t)}},{key:"bufferedCameraGeometryGlobe",value:function(t){var r=this.screenBounds[0],i=1===this.screenBounds.length?this.screenBounds[0].add(new e.P(1,1)):this.screenBounds[1],n=e.ae(r,i,t),a=this.cameraPoint.clone();switch(3*((a.y>r.y)+(a.y>i.y))+((a.x>r.x)+(a.x>i.x))){case 0:n[0]=a,n[4]=a.clone();break;case 1:n.splice(1,0,a);break;case 2:n[1]=a;break;case 3:n.splice(4,0,a);break;case 5:n.splice(2,0,a);break;case 6:n[3]=a;break;case 7:n.splice(3,0,a);break;case 8:n[2]=a}return n}},{key:"containsTile",value:function(t,r,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=t.queryPadding/r._pixelsPerMercatorPixel+1,o=i?this._bufferedCameraMercator(a,r):this._bufferedScreenMercator(a,r),s=t.tileID.wrap+(o.unwrapped?n:0),l=o.polygon.map((function(r){return e.ag(t.tileTransform,r,s)}));if(e.ah(l,0,0,e.ab,e.ab)){s=t.tileID.wrap+(this.screenGeometryMercator.unwrapped?n:0);var u,c=this.screenGeometryMercator.polygon.map((function(r){return e.ai(t.tileTransform,r,s)})),h=c.map((function(t){return new e.P(t[0],t[1])})),f=r.getFreeCameraOptions().position||new e.a5(0,0,0),d=e.ai(t.tileTransform,f,s),p=c.map((function(t){var r=e.a6.vec3.sub(t,t,d);return e.a6.vec3.normalize(r,r),new e.aj(d,r)})),m=e.ak(t,1,r.zoom)*r._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:h,tilespaceRays:p,bufferedTilespaceGeometry:l,bufferedTilespaceBounds:(u=e.al(l),u.min.x=e.ap(u.min.x,0,e.ab),u.min.y=e.ap(u.min.y,0,e.ab),u.max.x=e.ap(u.max.x,0,e.ab),u.max.y=e.ap(u.max.y,0,e.ab),u),tile:t,tileID:t.tileID,pixelToTileUnitsFactor:m}}}},{key:"_bufferedScreenMercator",value:function(e,t){var r,i=at(e);return this._screenRaycastCache[i]?this._screenRaycastCache[i]:(r="globe"===t.projection.name?this._projectAndResample(this.bufferedScreenGeometry(e),t):{polygon:this.bufferedScreenGeometry(e).map((function(e){return t.pointCoordinate3D(e)})),unwrapped:!0},this._screenRaycastCache[i]=r,r)}},{key:"_bufferedCameraMercator",value:function(e,t){var r,i=at(e);return this._cameraRaycastCache[i]?this._cameraRaycastCache[i]:(r="globe"===t.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(e),t):{polygon:this.bufferedCameraGeometry(e).map((function(e){return t.pointCoordinate3D(e)})),unwrapped:!0},this._cameraRaycastCache[i]=r,r)}},{key:"_projectAndResample",value:function(t,r){var i=(function(t,r){var i=e.a6.mat4.multiply([],r.pixelMatrix,r.globeMatrix),n=[0,-e.aq,0,1],a=[0,e.aq,0,1],o=[0,0,0,1];e.a6.vec4.transformMat4(n,n,i),e.a6.vec4.transformMat4(a,a,i),e.a6.vec4.transformMat4(o,o,i);var s=new e.P(n[0]/n[3],n[1]/n[3]),l=new e.P(a[0]/a[3],a[1]/a[3]),u=e.an(t,s)&&n[3]1?it(t.slice(0,f),r):[],v=fn&&(n=t[o].x,a=o);for(var s=0;s.5&&(u.x=i&&t.x=n&&t.y=2,a=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),n,this.tileSize);t.request=e.o(this.map._requestManager.transformRequest(a,e.R.Tile),(function(n,a,o,s){return delete t.request,t.aborted?(t.state="unloaded",r(null)):n?(t.state="errored",r(n)):a?(i.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:o,expires:s}),t.setTexture(a,i.map.painter),t.state="loaded",e.ax(i.dispatcher),void r(null)):r(null)}))}},{key:"abortTile",value:function(e,t){e.request&&(e.request.cancel(),delete e.request),t&&t()}},{key:"unloadTile",value:function(t,r){t.texture&&t.texture instanceof e.T?(t.destroy(!0),t.texture&&t.texture instanceof e.T&&this.map.painter.saveTileTexture(t.texture)):t.destroy(),r&&r()}},{key:"hasTransition",value:function(){return!1}},{key:"cancelTileJSONRequest",value:function(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}])})(e.E),ct=(function(t){function r(t,i,n,a){var o;return p(this,r),(o=T(this,r,[t,i,n,a])).type="raster-array",o.maxzoom=22,o._options=e.l({type:"raster-array"},i),o}return y(r,t),m(r,[{key:"triggerRepaint",value:function(e){var t=this.map.painter._terrain,r=this.map.style.getSourceCache(this.id);t&&t.enabled&&r&&t._clearRenderCacheForTile(r.id,e.tileID),this.map.triggerRepaint()}},{key:"loadTile",value:function(t,r){var i=this,n=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),a=this.map._requestManager.transformRequest(n,e.R.Tile);t.requestParams=a,t.actor||(t.actor=this.dispatcher.getActor()),t.request=t.fetchHeader(void 0,(function(e,n,a,o){if(delete t.request,t.aborted)return t.state="unloaded",r(null);if(e){if(20===e.code)return;return t.state="errored",r(e)}i.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:a,expires:o}),t.state="empty",r(null)}))}},{key:"unloadTile",value:function(t,r){var i=t.texture;i&&i instanceof e.T?(t.destroy(!0),this.map.painter.saveTileTexture(i)):(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"}},{key:"prepareTile",value:function(t,r,i){var n=this;t._isHeaderLoaded&&("empty"!==t.state&&(t.state="reloading"),t.fetchBand(r,i,(function(r,i){if(r)return t.state="errored",n.fire(new e.t(r)),void n.triggerRepaint(t);i&&(t.setTexture(i,n.map.painter),t.state="loaded",n.triggerRepaint(t))})))}},{key:"getInitialBand",value:function(e){if(!this.rasterLayers)return 0;var t=this.rasterLayers.find((function(t){return t.id===e})),r=t&&t.fields,i=r&&r.bands&&r.bands;return i?i[0]:0}},{key:"getTextureDescriptor",value:function(t,r,i){if(t){var n=r.sourceLayer||this.rasterLayerIds&&this.rasterLayerIds[0];if(n){var a=null;r instanceof e.aB?a=r.paint.get("raster-array-band"):r instanceof e.aC&&(a=r.paint.get("raster-particle-array-band"));var o=a||this.getInitialBand(n);if(null!=o)if(t.textureDescriptor){if(!t.updateNeeded(n,o)||i)return Object.assign({},t.textureDescriptor,{texture:t.texture})}else this.prepareTile(t,n,o)}}}}])})(ut),ht={vector:lt,raster:ut,"raster-dem":(function(t){function r(t,i,n,a){var o;return p(this,r),(o=T(this,r,[t,i,n,a])).type="raster-dem",o.maxzoom=22,o._options=e.l({type:"raster-dem"},i),o.encoding=i.encoding||"mapbox",o}return y(r,t),m(r,[{key:"loadTile",value:function(t,r){var i=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function n(e,i){e&&(t.state="errored",r(e)),i&&(t.dem=i,t.dem.onDeserialize(),t.needsHillshadePrepare=!0,t.needsDEMTextureUpload=!0,t.state="loaded",r(null))}t.request=e.o(this.map._requestManager.transformRequest(i,e.R.Tile),function(i,a,o,s){if(delete t.request,t.aborted)t.state="unloaded",r(null);else if(i)t.state="errored",r(i);else if(a){this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:o,expires:s});var l=ImageBitmap&&a instanceof ImageBitmap&&e.ay(),u=1-(a.width-e.az(a.width))/2;u<1||t.neighboringTiles||(t.neighboringTiles=this._getNeighboringTiles(t.tileID));var c=l?a:e.q.getImageData(a,u),h={uid:t.uid,coord:t.tileID,source:this.id,scope:this.scope,rawImageData:c,encoding:this.encoding,padding:u};t.actor&&"expired"!==t.state||(t.actor=this.dispatcher.getActor(),t.actor.send("loadDEMTile",h,n.bind(this),void 0,!0))}}.bind(this))}},{key:"_getNeighboringTiles",value:function(t){var r=t.canonical,i=Math.pow(2,r.z),n=(r.x-1+i)%i,a=0===r.x?t.wrap-1:t.wrap,o=(r.x+1+i)%i,s=r.x+1===i?t.wrap+1:t.wrap,l={};return l[new e.aA(t.overscaledZ,a,r.z,n,r.y).key]={backfilled:!1},l[new e.aA(t.overscaledZ,s,r.z,o,r.y).key]={backfilled:!1},r.y>0&&(l[new e.aA(t.overscaledZ,a,r.z,n,r.y-1).key]={backfilled:!1},l[new e.aA(t.overscaledZ,t.wrap,r.z,r.x,r.y-1).key]={backfilled:!1},l[new e.aA(t.overscaledZ,s,r.z,o,r.y-1).key]={backfilled:!1}),r.y+10&&void 0!==arguments[0]&&arguments[0];if(this._pendingLoad)this._coalesce=!0;else{this.fire(new e.x("dataloading",{dataType:"source"})),this._loaded=!1;var i=e.l({append:r},this.workerOptions);i.scope=this.scope;var n=this._data;"string"==typeof n?(i.request=this.map._requestManager.transformRequest(e.q.resolveURL(n),e.R.Source),i.request.collectResourceTiming=this._collectResourceTiming):i.data=JSON.stringify(n),this._pendingLoad=this.actor.send(`${this.type}.loadData`,i,(function(i,n){if(t._loaded=!0,t._pendingLoad=null,i)t.fire(new e.t(i));else{var a={dataType:"source",sourceDataType:t._metadataFired?"content":"metadata"};t._collectResourceTiming&&n&&n.resourceTiming&&n.resourceTiming[t.id]&&(a.resourceTiming=n.resourceTiming[t.id]),r&&(t._partialReload=!0),t.fire(new e.x("data",a)),t._partialReload=!1,t._metadataFired=!0}t._coalesce&&(t._updateWorkerData(r),t._coalesce=!1)}))}}},{key:"loaded",value:function(){return this._loaded}},{key:"loadTile",value:function(t,r){var i=this,n=t.actor?"reloadTile":"loadTile";t.actor=this.actor;var a=this.map.style?this.map.style.getLut(this.scope):null,o=this._partialReload,s={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:a?{image:a.image.clone()}:null,scope:this.scope,pixelRatio:e.q.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,brightness:this.map.style&&this.map.style.getBrightness()||0,partial:o};t.request=this.actor.send(n,s,(function(e,a){return o&&!a?(t.state="loaded",r(null)):(delete t.request,t.destroy(),t.aborted?r(null):e?r(e):(t.loadVectorData(a,i.map.painter,"reloadTile"===n),r(null)))}),void 0,"loadTile"===n)}},{key:"abortTile",value:function(e){e.request&&(e.request.cancel(),delete e.request),e.aborted=!0}},{key:"unloadTile",value:function(e,t){this.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope}),e.destroy()}},{key:"onRemove",value:function(e){this._pendingLoad&&this._pendingLoad.cancel()}},{key:"serialize",value:function(){return e.l({},this._options,{type:this.type,data:this._data})}},{key:"hasTransition",value:function(){return!1}}])})(e.E),video:(function(t){function r(e,t,i,n){var a;return p(this,r),(a=T(this,r,[e,t,i,n])).roundZoom=!0,a.type="video",a.options=t,a}return y(r,t),m(r,[{key:"load",value:function(){var t=this;this._loaded=!1;var r=this.options;for(var i of(this.urls=[],r.urls))this.urls.push(this.map._requestManager.transformRequest(i,e.R.Source).url);e.aE(this.urls,(function(r,i){t._loaded=!0,r?t.fire(new e.t(r)):i&&(t.video=i,t.video.loop=!0,t.video.setAttribute("playsinline",""),t.video.addEventListener("playing",(function(){t.map.triggerRepaint()})),t.map&&t.video.play(),t._finishLoading())}))}},{key:"pause",value:function(){this.video&&this.video.pause()}},{key:"play",value:function(){this.video&&this.video.play()}},{key:"seek",value:function(t){if(this.video){var r=this.video.seekable;tr.end(0)?this.fire(new e.t(new e.V(`sources.${this.id}`,null,`Playback for this video can be set only between the ${r.start(0)} and ${r.end(0)}-second mark.`))):this.video.currentTime=t}}},{key:"getVideo",value:function(){return this.video}},{key:"onAdd",value:function(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}},{key:"prepare",value:function(){if(!(0===Object.keys(this.tiles).length||this.video.readyState<2)){var t=this.map.painter.context,r=t.gl;this.texture?this.video.paused||(this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE),r.texSubImage2D(r.TEXTURE_2D,0,0,0,r.RGBA,r.UNSIGNED_BYTE,this.video)):(this.texture=new e.T(t,this.video,r.RGBA8),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(t)}}},{key:"serialize",value:function(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}},{key:"hasTransition",value:function(){return this.video&&!this.video.paused}}])})(e.aD),image:e.aD,model:(function(t){function r(e,t,i,n){var a;return p(this,r),(a=T(this,r)).id=e,a.type="model",a.models=[],a._loaded=!1,a._options=t,a}return y(r,t),m(r,[{key:"load",value:function(){var t=this,r=[],i=function(i){var n=t._options.models[i],a=e.aG(t.map._requestManager.transformRequest(n.uri,e.R.Model).url).then((function(r){if(r){var a=e.aH(r),o=new e.aI(i,n.position,n.orientation,a);o.computeBoundsAndApplyParent(),t.models.push(o)}})).catch((function(r){t.fire(new e.t(new Error(`Could not load model ${i} from ${n.uri}: ${r.message}`)))}));r.push(a)};for(var n in this._options.models)i(n);return Promise.allSettled(r).then((function(){t._loaded=!0,t.fire(new e.x("data",{dataType:"source",sourceDataType:"metadata"}))})).catch((function(r){t.fire(new e.t(new Error(`Could not load models: ${r.message}`)))}))}},{key:"onAdd",value:function(e){this.map=e,this.load()}},{key:"hasTransition",value:function(){return!1}},{key:"loaded",value:function(){return this._loaded}},{key:"getModels",value:function(){return this.models}},{key:"loadTile",value:function(e,t){}},{key:"serialize",value:function(){return{type:"model"}}}])})(e.E),"batched-model":(function(t){function r(e,t,i,n){var a;return p(this,r),(a=T(this,r)).type="batched-model",a.id=e,a.tileSize=512,a._options=t,a.tiles=a._options.tiles,a.maxzoom=t.maxzoom||19,a.minzoom=t.minzoom||0,a.roundZoom=!0,a.usedInConflation=!0,a.dispatcher=i,a.reparseOverscaled=!1,a.scheme="xyz",a._loaded=!1,a.setEventedParent(n),a}return y(r,t),m(r,[{key:"onAdd",value:function(e){this.map=e,this.load()}},{key:"load",value:function(t){var r=this;this._loaded=!1,this.fire(new e.x("dataloading",{dataType:"source"}));var i=Array.isArray(this.map._language)?this.map._language.join():this.map._language,n=this.map._worldview;this._tileJSONRequest=ot(this._options,this.map._requestManager,i,n,(function(a,o){r._tileJSONRequest=null,r._loaded=!0,a?(i&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${i}`),n&&2!==n.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${n}`),r.fire(new e.t(a))):o&&(e.l(r,o),o.bounds&&(r.tileBounds=new st(o.bounds,r.minzoom,r.maxzoom)),q(o.tiles,r.map._requestManager._customAccessToken),r.fire(new e.x("data",{dataType:"source",sourceDataType:"metadata"})),r.fire(new e.x("data",{dataType:"source",sourceDataType:"content"}))),t&&t(a)}))}},{key:"hasTransition",value:function(){return!1}},{key:"hasTile",value:function(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}},{key:"loaded",value:function(){return this._loaded}},{key:"loadTile",value:function(t,r){var i=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme)),n={request:this.map._requestManager.transformRequest(i,e.R.Tile),data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,showCollisionBoxes:this.map.showCollisionBoxes,isSymbolTile:t.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0};if(t.actor&&"expired"!==t.state)if("loading"===t.state)t.reloadCallback=r;else{if(t.buckets){var a=Object.values(t.buckets);for(var o of a)o.dirty=!0;return void(t.state="loaded")}t.request=t.actor.send("reloadTile",n,s.bind(this))}else t.actor=this.dispatcher.getActor(),t.request=t.actor.send("loadTile",n,s.bind(this),void 0,!0);function s(e,i){return t.aborted?r(null):e&&404!==e.status?r(e):(i&&(i.resourceTiming&&(t.resourceTiming=i.resourceTiming),this.map._refreshExpiredTiles&&t.setExpiryData(i),t.buckets=Object.assign({},t.buckets,i.buckets),i.featureIndex&&(t.latestFeatureIndex=i.featureIndex)),t.state="loaded",void r(null))}}},{key:"serialize",value:function(){return e.l({},this._options)}}])})(e.E),canvas:(function(t){function r(t,i,n,a){var o;return p(this,r),o=T(this,r,[t,i,n,a]),i.coordinates?Array.isArray(i.coordinates)&&4===i.coordinates.length&&!i.coordinates.some((function(e){return!Array.isArray(e)||2!==e.length||e.some((function(e){return"number"!=typeof e}))}))||o.fire(new e.t(new e.V(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):o.fire(new e.t(new e.V(`sources.${t}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&o.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||o.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'))):o.fire(new e.t(new e.V(`sources.${t}`,null,'missing required property "canvas"'))),o.options=i,o.animate=void 0===i.animate||i.animate,o}return y(r,t),m(r,[{key:"load",value:function(){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())}},{key:"getCanvas",value:function(){return this.canvas}},{key:"onAdd",value:function(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play()}},{key:"onRemove",value:function(e){this.pause()}},{key:"prepare",value:function(){var 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()&&0!==Object.keys(this.tiles).length){var r=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(r,this.canvas,r.gl.RGBA8,{premultiply:!0}),this._prepareData(r)}}},{key:"serialize",value:function(){return{type:"canvas",coordinates:this.coordinates}}},{key:"hasTransition",value:function(){return this._playing}},{key:"_hasInvalidDimensions",value:function(){for(var e of[this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return!0;return!1}}])})(e.aD),custom:(function(t){function r(t,i,n,a){var o;return p(this,r),(o=T(this,r)).id=t,o.type="custom",o._dataType="raster",o._dispatcher=n,o._implementation=i,o.setEventedParent(a),o.scheme="xyz",o.minzoom=0,o.maxzoom=22,o.tileSize=512,o._loaded=!1,o.roundZoom=!0,o._implementation||o.fire(new e.t(new Error(`Missing implementation for ${o.id} custom source`))),o._implementation.loadTile||o.fire(new e.t(new Error(`Missing loadTile implementation for ${o.id} custom source`))),o._implementation.bounds&&(o.tileBounds=new st(o._implementation.bounds,o.minzoom,o.maxzoom)),i.update=o._update.bind(l(o)),i.clearTiles=o._clearTiles.bind(l(o)),i.coveringTiles=o._coveringTiles.bind(l(o)),e.l(l(o),e.ar(i,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"])),o}return y(r,t),m(r,[{key:"serialize",value:function(){return e.ar(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}},{key:"load",value:function(){this._loaded=!0,this.fire(new e.x("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.x("data",{dataType:"source",sourceDataType:"content"}))}},{key:"loaded",value:function(){return this._loaded}},{key:"onAdd",value:function(t){this.map=t,this._loaded=!1,this.fire(new e.x("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(t),this.load()}},{key:"onRemove",value:function(e){this._implementation.onRemove&&this._implementation.onRemove(e)}},{key:"hasTile",value:function(e){if(this._implementation.hasTile){var t=e.canonical,r=t.x,i=t.y,n=t.z;return this._implementation.hasTile({x:r,y:i,z:n})}return!this.tileBounds||this.tileBounds.contains(e.canonical)}},{key:"loadTile",value:function(e,t){var r=e.tileID.canonical,i=r.x,n=r.y,a=r.z,o=new AbortController;e.request=Promise.resolve(this._implementation.loadTile({x:i,y:n,z:a},{signal:o.signal})).then(function(r){return delete e.request,e.aborted?(e.state="unloaded",t(null)):void 0===r?(e.state="errored",t(null)):null===r?(this.loadTileData(e,{width:this.tileSize,height:this.tileSize,data:null}),e.state="loaded",t(null)):(function(e){return e instanceof ImageData||e instanceof HTMLCanvasElement||e instanceof ImageBitmap||e instanceof HTMLImageElement})(r)?(this.loadTileData(e,r),e.state="loaded",void t(null)):(e.state="errored",t(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}.bind(this)).catch((function(r){20!==r.code&&(e.state="errored",t(r))})),e.request.cancel=function(){return o.abort()}}},{key:"loadTileData",value:function(e,t){e.setTexture(t,this.map.painter)}},{key:"unloadTile",value:function(t,r){if(t.texture&&t.texture instanceof e.T?(t.destroy(!0),t.texture&&t.texture instanceof e.T&&this.map.painter.saveTileTexture(t.texture)):t.destroy(),this._implementation.unloadTile){var i=t.tileID.canonical,n=i.x,a=i.y,o=i.z;this._implementation.unloadTile({x:n,y:a,z:o})}r&&r()}},{key:"abortTile",value:function(e,t){e.request&&e.request.cancel&&(e.request.cancel(),delete e.request),t&&t()}},{key:"hasTransition",value:function(){return!1}},{key:"_coveringTiles",value:function(){return this.map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map((function(e){return{x:e.canonical.x,y:e.canonical.y,z:e.canonical.z}}))}},{key:"_clearTiles",value:function(){var t=e.av(this.id,this.scope);this.map.style.clearSource(t)}},{key:"_update",value:function(){this.fire(new e.x("data",{dataType:"source",sourceDataType:"content"}))}}])})(e.E)},ft=function(t,r,i,n){var a=new ht[r.type](t,r,i,n);if(a.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${a.id}`);return e.aJ(["load","abort","unload","serialize","prepare"],a),a};function dt(t,r){var i=e.a6.mat4.identity([]);return e.a6.mat4.scale(i,i,[.5*t.width,.5*-t.height,1]),e.a6.mat4.translate(i,i,[1,-1,0]),e.a6.mat4.multiply(i,i,t.calculateProjMatrix(r.toUnwrapped())),Float32Array.from(i)}function pt(e,t,r,i,n,a,o){var s=arguments.length>7&&void 0!==arguments[7]&&arguments[7],l=e.tilesIn(i,o,s);l.sort(vt);var u=[];for(var c of l)u.push({wrappedTileID:c.tile.tileID.wrapped().key,queryResults:c.tile.queryRenderedFeatures(t,r,e._state,c,n,a,dt(e.transform,c.tile.tileID),s)});var h=(function(e){var t={},r={};for(var i of e){var n=i.queryResults,a=i.wrappedTileID,o=r[a]=r[a]||{};for(var s in n){var l=n[s],u=o[s]=o[s]||{},c=t[s]=t[s]||[];for(var h of l)u[h.featureIndex]||(u[h.featureIndex]=!0,c.push(h))}}return t})(u);for(var f in h)h[f].forEach((function(t){var r=t.feature,i=r.layer;i&&"background"!==i.type&&"sky"!==i.type&&"slot"!==i.type&&(r.source=i.source,i["source-layer"]&&(r.sourceLayer=i["source-layer"]),r.state=void 0!==r.id?e.getFeatureState(i["source-layer"],r.id):{})}));return h}function mt(e,t){for(var r=e.getRenderableIds().map((function(t){return e.getTileByID(t)})),i=[],n={},a=0;a>=1)>1;){var It=wt+Tt>>1,At=kt+Mt>>1;1&bt?(Tt=wt,Mt=kt,wt=St,kt=Et):(wt=Tt,kt=Mt,Tt=St,Mt=Et),St=It,Et=At}var Ct=4*xt;gt[Ct+0]=wt,gt[Ct+1]=kt,gt[Ct+2]=Tt,gt[Ct+3]=Mt}var Pt=new Uint16Array(2178),zt=new Uint8Array(1089),Dt=new Uint16Array(1089);function Rt(e){return 0===e?-.03125:32===e?.03125:0}var Lt={type:2,extent:e.ab,loadGeometry:function(){return[[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)]]}},Ot=(function(){return m((function t(r,i,n,a,o){p(this,t),this.tileID=r,this.uid=e.aP(),this.uses=0,this.tileSize=i,this.tileZoom=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=o,a&&a.style&&(this._lastUpdatedBrightness=a.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",a&&a.transform&&(this.projection=a.transform.projection)}),[{key:"registerFadeDuration",value:function(t){var r=t+this.timeAdded;rn)a=!1;else if(r)if(this.expirationTime=0;h--){var f=4*h,d=gt[f+0],p=gt[f+1],m=gt[f+2],v=gt[f+3],_=d+m>>1,y=p+v>>1,g=_+y-p,x=y+d-_,b=p*yt+d,w=v*yt+m,k=y*yt+_,T=Math.hypot((Pt[2*b+0]+Pt[2*w+0])/2-Pt[2*k+0],(Pt[2*b+1]+Pt[2*w+1])/2-Pt[2*k+1])>=16;zt[k]=zt[k]||(T?1:0),h<1022&&(zt[k]=zt[k]||zt[(p+x>>1)*yt+(d+g>>1)]||zt[(v+x>>1)*yt+(m+g>>1)])}var M=new e.aN,S=new e.aO,E=0;function I(t,r){var i=r*yt+t;return 0===Dt[i]&&(M.emplaceBack(Pt[2*i+0],Pt[2*i+1],t*e.ab/_t,r*e.ab/_t),Dt[i]=++E),Dt[i]-1}function A(e,t,r,i,n,a){var o=e+r>>1,s=t+i>>1;if(Math.abs(e-n)+Math.abs(t-a)>1&&zt[s*yt+o])A(n,a,e,t,o,s),A(r,i,n,a,o,s);else{var l=I(e,t),u=I(r,i),c=I(n,a);S.emplaceBack(l,u,c)}}return A(0,0,_t,_t,_t,0),A(_t,_t,0,0,0,_t),{vertices:M,indices:S}})(this.tileID.canonical,r);i=o.vertices,n=o.indices}else{for(var s of(i=new e.aN,n=new e.aO,a)){var l=s.x,u=s.y;i.emplaceBack(l,u,0,0)}for(var c=e.b2(i.int16,void 0,4),h=0;h0&&(n=e.a6.mat4.invert(new Float64Array(16),r.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(t,a,r,s,n,l),this._makeGlobeTileDebugTextBuffer(t,a,r,s,n,l)}}},{key:"_globePoint",value:function(t,r,i,n,a,o,s){var l=e.b6(t,r,i);if(o){var u=1<.5?d=-1:f<-.5&&(d=1);var p=(t/e.ab+i.x)/u+d,m=(r/e.ab+i.y)/u;p=(p-c)*n._pixelsPerMercatorPixel+c,m=(m-h)*n._pixelsPerMercatorPixel+h;var v=[p*n.worldSize,m*n.worldSize,0];e.a6.vec3.transformMat4(v,v,o),l=e.b7(l,v,s)}return e.a6.vec3.transformMat4(l,l,a)}},{key:"_makeGlobeTileDebugBorderBuffer",value:function(t,r,i,n,a,o){var s=this,l=new e.a_,u=new e.a$,c=new e.b8,h=function(e,t,h,f,d){for(var p=(h-e)/(d-1),m=(f-t)/(d-1),v=l.length,_=0;_0&&void 0!==arguments[0]&&arguments[0];for(var r in this.buckets)this.buckets[r].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.ba.setPbf(e.bb);var Bt=(function(t){function r(e,t,i,n,a){var o;return p(this,r),(o=T(this,r,[e,t,i,n,a]))._workQueue=[],o._fetchQueue=[],o._isHeaderLoaded=!1,o}return y(r,t),m(r,[{key:"setTexture",value:function(t,r){var i=r.context,n=i.gl;this.texture=this.texture||r.getTileTexture(t.width),this.texture&&this.texture instanceof e.T?this.texture.update(t,{premultiply:!1}):this.texture=new e.T(i,t,n.RGBA8,{premultiply:!1})}},{key:"flushQueues",value:function(){for(;this._workQueue.length;)this._workQueue.pop()();for(;this._fetchQueue.length;)this._fetchQueue.pop()()}},{key:"fetchHeader",value:function(){var t=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:16384,i=arguments.length>1?arguments[1]:void 0,n=this._mrt=new e.ba(30),a=Object.assign({},this.requestParams,{headers:{Range:"bytes=0-"+(r-1)}});return this.entireBuffer=null,this.request=e.bc(a,(function(e,a,o,s){if(e)i(e);else try{var l=n.getHeaderLength(a);if(l>r)return void(t.request=t.fetchHeader(l,i));n.parseHeader(a),t._isHeaderLoaded=!0;var u=0;for(var c of Object.values(n.layers))u=Math.max(u,c.dataIndex[c.dataIndex.length-1].last_byte);a.byteLength>=u&&(t.entireBuffer=a),i(null,t.entireBuffer||a,o,s)}catch(e){i(e)}})),this.request}},{key:"fetchBand",value:function(t,r,i){var n=this,a=this._mrt;if(this._isHeaderLoaded&&a){var o=this.actor;if(o){var s,l=function(e,a){s.complete(e,a),e?i(e):(n.updateTextureDescriptor(t,r),i(null,n.textureDescriptor&&n.textureDescriptor.img))},u=function(e,t){if(e)return i(e);var r=o.send("decodeRasterArray",{buffer:t,task:s},l,void 0,!0);n._workQueue.push((function(){r&&r.cancel(),s.cancel()}))},c=a.getLayer(t);if(c){if(c.hasDataForBand(r))return this.updateTextureDescriptor(t,r),void i(null,this.textureDescriptor?this.textureDescriptor.img:null);var h=c.getDataRange([r]);if(!(s=a.createDecodingTask(h))||s.tasks.length)if(this.flushQueues(),this.entireBuffer)u(null,this.entireBuffer.slice(h.firstByte,h.lastByte+1));else{var f=Object.assign({},this.requestParams,{headers:{Range:`bytes=${h.firstByte}-${h.lastByte}`}}),d=e.bc(f,u);this._fetchQueue.push((function(){d.cancel(),s.cancel()}))}else i(null)}else i(new Error(`Unknown sourceLayer "${t}"`))}else i(new Error("Can't fetch tile band without an actor"))}else i(new Error("Tile header is not ready"))}},{key:"updateNeeded",value:function(e,t){return(!this.textureDescriptor||this.textureDescriptor.band!==t||this.textureDescriptor.layer!==e)&&"errored"!==this.state}},{key:"updateTextureDescriptor",value:function(t,r){if(this._mrt){var i=this._mrt.getLayer(t);if(i&&i.hasBand(r)&&i.hasDataForBand(r)){var n=i.getBandView(r),a=n.bytes,o=n.tileSize,s=n.buffer,l=n.offset,u=n.scale,c=o+2*s,h={data:a,width:c,height:c},f=this.texture;f&&f instanceof e.T&&f.update(h,{premultiply:!1}),this.textureDescriptor={layer:t,band:r,img:h,buffer:s,offset:l,tileSize:o,format:i.pixelFormat,mix:[u,256*u,65536*u,16777216*u]}}}}}])})(Ot),Ft=(function(){return m((function e(t,r){p(this,e),this.max=t,this.onRemove=r,this.reset()}),[{key:"reset",value:function(){for(var e in this.data)for(var t of this.data[e])t.timeout&&clearTimeout(t.timeout),this.onRemove(t.value);return this.data={},this.order=[],this}},{key:"add",value:function(e,t,r){var i=this,n=e.wrapped().key;void 0===this.data[n]&&(this.data[n]=[]);var a={value:t,timeout:void 0};if(void 0!==r&&(a.timeout=setTimeout((function(){i.remove(e,a)}),r)),this.data[n].push(a),this.order.push(n),this.order.length>this.max){var o=this._getAndRemoveByKey(this.order[0]);o&&this.onRemove(o)}return this}},{key:"has",value:function(e){return e.wrapped().key in this.data}},{key:"getAndRemove",value:function(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}},{key:"_getAndRemoveByKey",value:function(e){var 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}},{key:"getByKey",value:function(e){var t=this.data[e];return t?t[0].value:null}},{key:"get",value:function(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}},{key:"remove",value:function(e,t){if(!this.has(e))return this;var r=e.wrapped().key,i=void 0===t?0:this.data[r].indexOf(t),n=this.data[r][i];return this.data[r].splice(i,1),n.timeout&&clearTimeout(n.timeout),0===this.data[r].length&&delete this.data[r],this.onRemove(n.value),this.order.splice(this.order.indexOf(r),1),this}},{key:"setMaxSize",value:function(e){for(this.max=e;this.order.length>this.max;){var t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}},{key:"filter",value:function(e){var t=[];for(var r in this.data)for(var i of this.data[r])e(i.value)||t.push(i);for(var n of t)this.remove(n.value.tileID,n)}}])})(),Nt=(function(){return m((function e(){p(this,e),this.state={},this.stateChanges={},this.deletedStates={}}),[{key:"updateState",value:function(t,r,i){var n=String(r);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][n]=this.stateChanges[t][n]||{},e.l(this.stateChanges[t][n],i),null===this.deletedStates[t])for(var a in this.deletedStates[t]={},this.state[t])a!==n&&(this.deletedStates[t][a]=null);else if(this.deletedStates[t]&&null===this.deletedStates[t][n])for(var o in this.deletedStates[t][n]={},this.state[t][n])i[o]||(this.deletedStates[t][n][o]=null);else for(var s in i)this.deletedStates[t]&&this.deletedStates[t][n]&&null===this.deletedStates[t][n][s]&&delete this.deletedStates[t][n][s]}},{key:"removeFeatureState",value:function(e,t,r){if(null!==this.deletedStates[e]){var i=String(t);if(this.deletedStates[e]=this.deletedStates[e]||{},r&&void 0!==t)null!==this.deletedStates[e][i]&&(this.deletedStates[e][i]=this.deletedStates[e][i]||{},this.deletedStates[e][i][r]=null);else if(void 0!==t)if(this.stateChanges[e]&&this.stateChanges[e][i])for(r in this.deletedStates[e][i]={},this.stateChanges[e][i])this.deletedStates[e][i][r]=null;else this.deletedStates[e][i]=null;else this.deletedStates[e]=null}}},{key:"getState",value:function(t,r){var i=this.state[t]||{},n=this.stateChanges[t]||{},a=this.deletedStates[t];if(null===a)return{};if(void 0!==r){var o=String(r),s=e.l({},i[o],n[o]);if(a){var l=a[r];if(null===l)return{};for(var u in l)delete s[u]}return s}var c=e.l({},i,n);if(a)for(var h in a)delete c[h];return c}},{key:"initializeTileState",value:function(e,t){e.setFeatureState(this.state,t)}},{key:"coalesceChanges",value:function(t,r){var i={};for(var n in this.stateChanges){this.state[n]=this.state[n]||{};var a={};for(var o in this.stateChanges[n])this.state[n][o]||(this.state[n][o]={}),e.l(this.state[n][o],this.stateChanges[n][o]),a[o]=this.state[n][o];i[n]=a}for(var s in this.deletedStates){this.state[s]=this.state[s]||{};var l={};if(null===this.deletedStates[s])for(var u in this.state[s])l[u]={},this.state[s][u]={};else for(var c in this.deletedStates[s]){if(null===this.deletedStates[s][c])this.state[s][c]={};else if(this.state[s][c])for(var h of Object.keys(this.deletedStates[s][c]))delete this.state[s][c][h];l[c]=this.state[s][c]}i[s]=i[s]||{},e.l(i[s],l)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(i).length)for(var f in t)t[f].setFeatureState(i,r)}}])})(),Vt=(function(t){function r(e,t,i){var n;return p(this,r),(n=T(this,r)).id=e,n._onlySymbols=i,t.on("data",(function(e){"source"===e.dataType&&"metadata"===e.sourceDataType&&(n._sourceLoaded=!0),n._sourceLoaded&&!n._paused&&"source"===e.dataType&&"content"===e.sourceDataType&&(n.reload(),n.transform&&n.update(n.transform))})),t.on("error",(function(){n._sourceErrored=!0})),n._source=t,n._tiles={},n._cache=new Ft(0,n._unloadTile.bind(l(n))),n._timers={},n._cacheTimers={},n._minTileCacheSize=t.minTileCacheSize,n._maxTileCacheSize=t.maxTileCacheSize,n._loadedParentTiles={},n.castsShadows=!1,n.tileCoverLift=0,n._coveredTiles={},n._shadowCasterTiles={},n._state=new Nt,n._isRaster="raster"===n._source.type||"raster-dem"===n._source.type||"raster-array"===n._source.type||"custom"===n._source.type&&"raster"===n._source._dataType,n}return y(r,t),m(r,[{key:"onAdd",value:function(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}},{key:"loaded",value:function(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(var e in this._tiles){var t=this._tiles[e];if("loaded"!==t.state&&"errored"!==t.state)return!1}return!0}},{key:"getSource",value:function(){return this._source}},{key:"pause",value:function(){this._paused=!0}},{key:"resume",value:function(){if(this._paused){var e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform)}}},{key:"_loadTile",value:function(e,t){return e.isSymbolTile=this._onlySymbols,e.isExtraShadowCaster=this._shadowCasterTiles[e.tileID.key],this._source.loadTile(e,t)}},{key:"_unloadTile",value:function(e){if(this._source.unloadTile)return this._source.unloadTile(e)}},{key:"_abortTile",value:function(e){if(this._source.abortTile)return this._source.abortTile(e)}},{key:"serialize",value:function(){return this._source.serialize()}},{key:"prepare",value:function(e){for(var t in this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null),this._tiles){var r=this._tiles[t];r.upload(e),r.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}},{key:"getIds",value:function(){return e.bd(this._tiles).map((function(e){return e.tileID})).sort(Ut).map((function(e){return e.key}))}},{key:"getRenderableIds",value:function(t,r){var i=this,n=[];for(var a in this._tiles)this._isIdRenderable(+a,t,r)&&n.push(this._tiles[a]);return t?n.sort((function(t,r){var n=t.tileID,a=r.tileID,o=new e.P(n.canonical.x,n.canonical.y)._rotate(i.transform.angle),s=new e.P(a.canonical.x,a.canonical.y)._rotate(i.transform.angle);return n.overscaledZ-a.overscaledZ||s.y-o.y||s.x-o.x})).map((function(e){return e.tileID.key})):n.map((function(e){return e.tileID})).sort(Ut).map((function(e){return e.key}))}},{key:"hasRenderableParent",value:function(e){var t=this.findLoadedParent(e,0);return!!t&&this._isIdRenderable(t.tileID.key)}},{key:"_isIdRenderable",value:function(e,t,r){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(t||!this._tiles[e].holdingForFade())&&(r||!this._shadowCasterTiles[e])}},{key:"reload",value:function(){if(this._paused)this._shouldReloadOnResume=!0;else for(var e in this._cache.reset(),this._tiles)"errored"!==this._tiles[e].state&&this._reloadTile(+e,"reloading")}},{key:"_reloadTile",value:function(e,t){var r=this._tiles[e];r&&("loading"!==r.state&&(r.state=t),this._loadTile(r,this._tileLoaded.bind(this,r,e,t)))}},{key:"_tileLoaded",value:function(t,r,i,n){if(n)if(t.state="errored",404!==n.status)this._source.fire(new e.t(n,{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){var a=this.map.painter.terrain;this.update(this.transform,a.getScaledDemTileSize(),!0),a.resetTileLookupCache(this.id)}else this.update(this.transform)}else t.timeAdded=e.q.now(),"expired"===i&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(r,t),"raster-dem"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),this._source.fire(new e.x("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id}))}},{key:"_backfillDEM",value:function(e){for(var t=this.getRenderableIds(),r=0;r1||(Math.abs(r)>1&&(1===Math.abs(r+n)?r+=n:1===Math.abs(r-n)&&(r-=n)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,r,i),e.neighboringTiles&&e.neighboringTiles[a]&&(e.neighboringTiles[a].backfilled=!0)))}}}},{key:"getTile",value:function(e){return this.getTileByID(e.key)}},{key:"getTileByID",value:function(e){return this._tiles[e]}},{key:"_retainLoadedChildren",value:function(e,t,r,i){for(var n in this._tiles){var a=this._tiles[n];if(!(i[n]||!a.hasData()||a.tileID.overscaledZ<=t||a.tileID.overscaledZ>r)){for(var o=a.tileID;a&&a.tileID.overscaledZ>t+1;){var s=a.tileID.scaledTo(a.tileID.overscaledZ-1);(a=this._tiles[s.key])&&a.hasData()&&(o=s)}for(var l=o;l.overscaledZ>t;)if(e[(l=l.scaledTo(l.overscaledZ-1)).key]){i[o.key]=o;break}}}}},{key:"findLoadedParent",value:function(e,t){if(e.key in this._loadedParentTiles){var r=this._loadedParentTiles[e.key];return r&&r.tileID.overscaledZ>=t?r:null}for(var i=e.overscaledZ-1;i>=t;i--){var n=e.scaledTo(i),a=this._getLoadedTile(n);if(a)return a}}},{key:"_getLoadedTile",value:function(e){var t=this._tiles[e.key];return t&&t.hasData()?t:this._cache.getByKey(this._source.reparseOverscaled?e.wrapped().key:e.canonical.key)}},{key:"updateCacheSize",value:function(e,t){t=t||this._source.tileSize;var r=Math.ceil(e.width/t)+1,i=Math.ceil(e.height/t)+1,n=Math.floor(r*i*5),a="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,n):n,o="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,a):a;this._cache.setMaxSize(o)}},{key:"handleWrapJump",value:function(e){var t=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);if(this._prevLng=e,t){var r={};for(var i in this._tiles){var n=this._tiles[i];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+t),r[n.tileID.key]=n}for(var a in this._tiles=r,this._timers)clearTimeout(this._timers[a]),delete this._timers[a];for(var o in this._tiles)this._setTileReloadTimer(+o,this._tiles[o])}}},{key:"update",value:function(t,i,n,a){if(this.transform=t,this._sourceLoaded&&!this._paused&&!this.transform.freezeTileCoverage&&(!this.usedForTerrain||n)){this.updateCacheSize(t,i),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={};var o,s="batched-model"===this._source.type;if(this.used||this.usedForTerrain){if(this._source.tileID)o=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((function(t){return new e.aA(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y)}));else if(0!==this.tileCoverLift){var l=t.clone();l.tileCoverLift=this.tileCoverLift,o=l.coveringTiles({tileSize:i||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!n,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:s}),this._source.minzoom<=1&&"globe"===t.projection.name&&(o.push(new e.aA(1,0,1,0,0)),o.push(new e.aA(1,0,1,1,0)),o.push(new e.aA(1,0,1,0,1)),o.push(new e.aA(1,0,1,1,1)))}else if(o=t.coveringTiles({tileSize:i||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!n,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:s}),this._source.hasTile){var u=this._source.hasTile.bind(this._source);o=o.filter((function(e){return u(e)}))}}else o=[];if(o.length>0&&this.castsShadows&&a&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!jt(this._source.type)){var c=t.coveringZoomLevel({tileSize:i||this._source.tileSize,roundZoom:this._source.roundZoom&&!n}),h=Math.min(c,this._source.maxzoom);if(s){var f=t.extendTileCover(o,h);for(var d of f)o.push(d)}else{var p=t.extendTileCover(o,h,a);for(var m of p)this._shadowCasterTiles[m.key]=!0,o.push(m)}}var v=this._updateRetainedTiles(o);if(jt(this._source.type)&&0!==o.length){var _={},y={},g=Object.keys(v);for(var x of g){var b=v[x],w=this._tiles[x];if(w&&!(w.fadeEndTime&&w.fadeEndTime<=e.q.now())){var k=this.findLoadedParent(b,Math.max(b.overscaledZ-r.maxOverzooming,this._source.minzoom));k&&(this._addTile(k.tileID),_[k.tileID.key]=k.tileID),y[x]=b}}var T=o[o.length-1].overscaledZ;for(var M in this._tiles){var S=this._tiles[M];if(!v[M]&&S.hasData())for(var E=S.tileID;E.overscaledZ>T;){E=E.scaledTo(E.overscaledZ-1);var I=this._tiles[E.key];if(I&&I.hasData()&&y[E.key]){v[M]=S.tileID;break}}}for(var A in _)v[A]||(this._coveredTiles[A]=!0,v[A]=_[A])}for(var C in v)this._tiles[C].clearFadeHold();var P=e.be(this._tiles,v);for(var z of P){var D=this._tiles[z];D.hasSymbolBuckets&&!D.holdingForFade()?D.setHoldDuration(this.map._fadeDuration):D.hasSymbolBuckets&&!D.symbolFadeFinished()||this._removeTile(+z)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}}},{key:"releaseSymbolFadeTiles",value:function(){for(var e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(+e)}},{key:"_updateRetainedTiles",value:function(e){var t={};if(0===e.length)return t;var i={},n=e.reduce((function(e,t){return Math.min(e,t.overscaledZ)}),1/0),a=e[0].overscaledZ,o=Math.max(a-r.maxOverzooming,this._source.minzoom),s=Math.max(a+r.maxUnderzooming,this._source.minzoom),l={};for(var u of e){var c=this._addTile(u);t[u.key]=u,c.hasData()||n=this._source.maxzoom){var d=h.children(this._source.maxzoom)[0],p=this.getTile(d);if(p&&p.hasData()){t[d.key]=d;continue}}else{var m=h.children(this._source.maxzoom);if(t[m[0].key]&&t[m[1].key]&&t[m[2].key]&&t[m[3].key])continue}for(var v=f.wasRequested(),_=h.overscaledZ-1;_>=o;--_){var y=h.scaledTo(_);if(i[y.key])break;if(i[y.key]=!0,!(f=this.getTile(y))&&v&&(f=this._addTile(y)),f&&(t[y.key]=y,v=f.wasRequested(),f.hasData()))break}}}return t}},{key:"_updateLoadedParentTileCache",value:function(){for(var e in this._loadedParentTiles={},this._tiles){for(var t=[],r=void 0,i=this._tiles[e].tileID;i.overscaledZ>0;){if(i.key in this._loadedParentTiles){r=this._loadedParentTiles[i.key];break}t.push(i.key);var n=i.scaledTo(i.overscaledZ-1);if(r=this._getLoadedTile(n))break;i=n}for(var a of t)this._loadedParentTiles[a]=r}}},{key:"_addTile",value:function(t){var r=this._tiles[t.key];if(r)return!0!==r.isExtraShadowCaster||!!this._shadowCasterTiles[t.key]||this._reloadTile(t.key,"reloading"),r;(r=this._cache.getAndRemove(t))&&(this._setTileReloadTimer(t.key,r),r.tileID=t,this._state.initializeTileState(r,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,r)));var i=Boolean(r);if(!i){var n=this.map?this.map.painter:null,a=this._source.tileSize*t.overscaleFactor();r="raster-array"===this._source.type?new Bt(t,a,this.transform.tileZoom,n,this._isRaster):new Ot(t,a,this.transform.tileZoom,n,this._isRaster),this._loadTile(r,this._tileLoaded.bind(this,r,t.key,r.state))}return r?(r.uses++,this._tiles[t.key]=r,i||this._source.fire(new e.x("dataloading",{tile:r,coord:r.tileID,dataType:"source"})),r):null}},{key:"_setTileReloadTimer",value:function(e,t){var r=this;e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);var i=t.getExpiryTimeout();i&&(this._timers[e]=setTimeout((function(){r._reloadTile(e,"expired"),delete r._timers[e]}),i))}},{key:"_removeTile",value:function(e){var 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))))}},{key:"clearTiles",value:function(){for(var e in this._shouldReloadOnResume=!1,this._paused=!1,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)}},{key:"tilesIn",value:function(t,r,i){var n=[],a=this.transform;if(!a)return n;var o="globe"===a.projection.name,s=e.am(a.center.lng);for(var l in this._tiles){var u=this._tiles[l];if(i&&u.clearQueryDebugViz(),!u.holdingForFade()){var c=void 0;if(o){var h=u.tileID.canonical;if(0===h.z){var f=[Math.abs(e.ap.apply(e,[s].concat(d(Gt(h,-1))))-s),Math.abs(e.ap.apply(e,[s].concat(d(Gt(h,1))))-s)];c=[0,2*f.indexOf(Math.min.apply(Math,f))-1]}else{var p=[Math.abs(e.ap.apply(e,[s].concat(d(Gt(h,-1))))-s),Math.abs(e.ap.apply(e,[s].concat(d(Gt(h,0))))-s),Math.abs(e.ap.apply(e,[s].concat(d(Gt(h,1))))-s)];c=[p.indexOf(Math.min.apply(Math,p))-1]}}else c=[0];for(var m of c){var v=t.containsTile(u,a,r,m);v&&n.push(v)}}}return n}},{key:"getShadowCasterCoordinates",value:function(){return this._getRenderableCoordinates(!1,!0)}},{key:"getVisibleCoordinates",value:function(e){return this._getRenderableCoordinates(e)}},{key:"_getRenderableCoordinates",value:function(e,t){var r=this,i=this.getRenderableIds(e,t).map((function(e){return r._tiles[e].tileID})),n="globe"===this.transform.projection.name;for(var a of i)a.projMatrix=this.transform.calculateProjMatrix(a.toUnwrapped()),a.expandedProjMatrix=n?this.transform.calculateProjMatrix(a.toUnwrapped(),!1,!0):a.projMatrix;return i}},{key:"sortCoordinatesByDistance",value:function(e){var t=e.slice(),r=this.transform._camera.position,i=this.transform._camera.forward(),n={};for(var a of t){var o=1/(1<=e.q.now())return!0}return!1}},{key:"setFeatureState",value:function(e,t,r){this._state.updateState(e=e||"_geojsonTileLayer",t,r)}},{key:"removeFeatureState",value:function(e,t,r){this._state.removeFeatureState(e=e||"_geojsonTileLayer",t,r)}},{key:"getFeatureState",value:function(e,t){return this._state.getState(e=e||"_geojsonTileLayer",t)}},{key:"setDependencies",value:function(e,t,r){var i=this._tiles[e];i&&i.setDependencies(t,r)}},{key:"reloadTilesForDependencies",value:function(e,t){for(var r in this._tiles)this._tiles[r].hasDependency(e,t)&&this._reloadTile(+r,"reloading");this._cache.filter((function(r){return!r.hasDependency(e,t)}))}},{key:"_preloadTiles",value:function(t,r){var i=this;if(this._sourceLoaded){var n=new Map,a=Array.isArray(t)?t:[t],o=this.map.painter.terrain,s=this.usedForTerrain&&o?o.getScaledDemTileSize():this._source.tileSize;for(var l of a){var u=l.coveringTiles({tileSize:s,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(var c of u)n.set(c.key,c);this.usedForTerrain&&l.updateElevation(!1)}var h=Array.from(n.values());e.bf(h,(function(e,t){var r=new Ot(e,i._source.tileSize*e.overscaleFactor(),i.transform.tileZoom,i.map.painter,i._isRaster);i._loadTile(r,(function(e){"raster-dem"===i._source.type&&r.dem&&i._backfillDEM(r),t(e,r)}))}),r)}else{var f=function(){i._sourceLoaded&&(i._source.off("data",f),i._preloadTiles(t,r))};this._source.on("data",f)}}}])})(e.E);function Ut(e,t){var r=Math.abs(2*e.wrap)-+(e.wrap<0),i=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||i-r||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function jt(e){return"raster"===e||"image"===e||"video"===e||"custom"===e}function Gt(e,t){var r=1<0:"model"===r.type&&(i=!r.isHidden(e)&&r.paint.get("model-opacity")>0),this.layersGotHidden=this.layersGotHidden||!i&&t.visible,t.visible=i}}},{key:"updateZOffset",value:function(e,t){for(var r of(this.currentBuildingBuckets=[],this.layers)){var i=r.layer,n=this.style.getLayerSourceCache(i),a=1;"fill-extrusion"===i.type&&(a=r.visible?i.paint.get("fill-extrusion-vertical-scale"):0);var o=n?n.getTile(t):null;if(!o&&n&&t.canonical.z>n.getSource().minzoom)for(var s=t.scaledTo(Math.min(n.getSource().maxzoom,t.overscaledZ-1));s.overscaledZ>=n.getSource().minzoom&&(!(o=n.getTile(s))&&0!==s.overscaledZ);)s=s.scaledTo(s.overscaledZ-1);this.currentBuildingBuckets.push({bucket:o?o.getBucket(i):null,tileID:o?o.tileID:t,verticalScale:a})}e.hasAnyZOffset=!1;for(var l=!1,u=0;u0?(n-o)/s:0;return this.points[a].mult(1-l).add(this.points[r].mult(l))}}])})(),rr=(function(){return m((function e(t,r,i){p(this,e);var n=this.boxCells=[],a=this.circleCells=[];this.xCellCount=Math.ceil(t/i),this.yCellCount=Math.ceil(r/i);for(var o=0;othis.width||i<0||t>this.height)return!n&&[];var o=[];if(e<=0&&t<=0&&this.width<=r&&this.height<=i){if(n)return!0;for(var s=0;s0:o}},{key:"_queryCircle",value:function(e,t,r,i,n){var a=e-r,o=e+r,s=t-r,l=t+r;if(o<0||a>this.width||l<0||s>this.height)return!i&&[];var u=[];return this._forEachCell(a,s,o,l,this._queryCellCircle,u,{hitTest:i,circle:{x:e,y:t,radius:r},seenUids:{box:{},circle:{}}},n),i?u.length>0:u}},{key:"query",value:function(e,t,r,i,n){return this._query(e,t,r,i,!1,n)}},{key:"hitTest",value:function(e,t,r,i,n){return this._query(e,t,r,i,!0,n)}},{key:"hitTestCircle",value:function(e,t,r,i){return this._queryCircle(e,t,r,!0,i)}},{key:"_queryCell",value:function(e,t,r,i,n,a,o,s){var l=o.seenUids,u=this.boxCells[n];if(null!==u){var c=this.bboxes;for(var h of u)if(!l.box[h]){l.box[h]=!0;var f=4*h;if(e<=c[f+2]&&t<=c[f+3]&&r>=c[f+0]&&i>=c[f+1]&&(!s||s(this.boxKeys[h]))){if(o.hitTest)return a.push(!0),!0;a.push({key:this.boxKeys[h],x1:c[f],y1:c[f+1],x2:c[f+2],y2:c[f+3]})}}}var d=this.circleCells[n];if(null!==d){var p=this.circles;for(var m of d)if(!l.circle[m]){l.circle[m]=!0;var v=3*m;if(this._circleAndRectCollide(p[v],p[v+1],p[v+2],e,t,r,i)&&(!s||s(this.circleKeys[m]))){if(o.hitTest)return a.push(!0),!0;var _=p[v],y=p[v+1],g=p[v+2];a.push({key:this.circleKeys[m],x1:_-g,y1:y-g,x2:_+g,y2:y+g})}}}}},{key:"_queryCellCircle",value:function(e,t,r,i,n,a,o,s){var l=o.circle,u=o.seenUids,c=this.boxCells[n];if(null!==c){var h=this.bboxes;for(var f of c)if(!u.box[f]){u.box[f]=!0;var d=4*f;if(this._circleAndRectCollide(l.x,l.y,l.radius,h[d+0],h[d+1],h[d+2],h[d+3])&&(!s||s(this.boxKeys[f])))return a.push(!0),!0}}var p=this.circleCells[n];if(null!==p){var m=this.circles;for(var v of p)if(!u.circle[v]){u.circle[v]=!0;var _=3*v;if(this._circlesCollide(m[_],m[_+1],m[_+2],l.x,l.y,l.radius)&&(!s||s(this.circleKeys[v])))return a.push(!0),!0}}}},{key:"_forEachCell",value:function(e,t,r,i,n,a,o,s){for(var l=this._convertToXCellCoord(e),u=this._convertToYCellCoord(t),c=this._convertToXCellCoord(r),h=this._convertToYCellCoord(i),f=l;f<=c;f++)for(var d=u;d<=h;d++)if(n.call(this,e,t,r,i,this.xCellCount*d+f,a,o,s))return}},{key:"_convertToXCellCoord",value:function(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}},{key:"_convertToYCellCoord",value:function(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}},{key:"_circlesCollide",value:function(e,t,r,i,n,a){var o=i-e,s=n-t,l=r+a;return l*l>o*o+s*s}},{key:"_circleAndRectCollide",value:function(e,t,r,i,n,a,o){var s=(a-i)/2,l=Math.abs(e-(i+s));if(l>s+r)return!1;var u=(o-n)/2,c=Math.abs(t-(n+u));if(c>u+r)return!1;if(l<=s||c<=u)return!0;var h=l-s,f=c-u;return h*h+f*f<=r*r}}])})(),ir=0,nr=1,ar=2,or=Math.tan(85*Math.PI/180);function sr(t,r,i,n,a,o,s){var l=e.a6.mat4.create();if(i)if("globe"===o.name){var u=e.bi(a,r);e.a6.mat4.multiply(l,l,u)}else{var c=e.a6.mat2.invert([],s);l[0]=c[0],l[1]=c[1],l[4]=c[2],l[5]=c[3],n||e.a6.mat4.rotateZ(l,l,a.angle)}else e.a6.mat4.multiply(l,a.labelPlaneMatrix,t);return l}function lr(e,t,r,i,n,a,o){var s=sr(e,t,r,i,n,a,o);return"globe"===a.name&&r||(s[2]=s[6]=s[10]=s[14]=0),s}function ur(t,r,i,n,a,o,s){if(i){if("globe"===o.name){var l=sr(t,r,i,n,a,o,s);return e.a6.mat4.invert(l,l),e.a6.mat4.multiply(l,t,l),l}var u=e.a6.mat4.clone(t),c=e.a6.mat4.identity([]);return c[0]=s[0],c[1]=s[1],c[4]=s[2],c[5]=s[3],e.a6.mat4.multiply(u,u,c),n||e.a6.mat4.rotateZ(u,u,-a.angle),u}return a.glCoordMatrix}function cr(t,r,i,n){var a=[t,r,i,1];i?e.a6.vec4.transformMat4(a,a,n):br(a,a,n);var o=a[3];return a[0]/=o,a[1]/=o,a[2]/=o,a}function hr(e,t){return Math.min(.5+e/t*.5,1.5)}function fr(e,t){var r=e[0]/e[3],i=e[1]/e[3];return r>=-t[0]&&r<=t[0]&&i>=-t[1]&&i<=t[1]}function dr(t,r,i,n,a,o,s,l,u,c){var h=i.transform,f=n?t.textSizeData:t.iconSizeData,d=e.bj(f,i.transform.zoom),p="globe"===h.projection.name,m=[256/i.width*2+1,256/i.height*2+1],v=n?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;v.clear();var _=null;p&&(_=n?t.text.globeExtVertexArray:t.icon.globeExtVertexArray);for(var y,g=t.lineVertexArray,b=n?t.text.placedSymbolArray:t.icon.placedSymbolArray,w=i.transform.width/i.transform.height,k=!1,T=0;TMath.abs(i)?{useVertical:!0}:t===e.bk.vertical?n>0?{needsFlipping:!0}:null:r!==ir&&(function(e,t){return 0===e||Math.abs(t/e)>or})(i,n)?r===nr?{needsFlipping:!0}:null:i<0?{needsFlipping:!0}:null}function vr(t,r,i,n,a,o,s,l,u,c,h,f,d,p,m,v,_,y,g){var b=r/24,w=t.lineOffsetX*b,k=t.lineOffsetY*b,T=t.lineStartIndex,M=t.glyphStartIndex,S=t.numGlyphs,E=t.segment,I=t.writingMode,A=t.flipState,C=T+t.lineLength,P=function(t){if(h){var r=x(t.up,3),i=r[0],n=r[1],a=r[2],o=c.length;e.bm(h,o+0,i,n,a),e.bm(h,o+1,i,n,a),e.bm(h,o+2,i,n,a),e.bm(h,o+3,i,n,a)}var s=x(t.point,3),l=s[0],u=s[1],f=s[2];e.bn(c,l,u,f,t.angle)};if(S>1){var z=pr(b,l,w,k,i,f,d,t,u,o,p,v,!1,_,y,g);if(!z)return{notEnoughRoom:!0};if(n&&!i){var D,R,L,O,B=x(z.first.point,3),F=B[0],N=B[1],V=B[2],U=x(z.last.point,3),j=U[0],G=U[1],q=U[2];D=cr(F,N,V,s),F=(R=x(D,2))[0],N=R[1],L=cr(j,G,q,s);var Z=mr(I,A,((j=(O=x(L,2))[0])-F)*m,(G=O[1])-N);if(t.flipState=Z&&Z.needsFlipping?nr:ar,Z)return Z}P(z.first);for(var $=M+1;$0?J:yr(d,Y,W,1,a,void 0,_,y.canonical),Q=mr(I,A,(K[0]-W[0])*m,K[1]-W[1]);if(t.flipState=Q&&Q.needsFlipping?nr:ar,Q)return Q}var ee=gr(b*l.getoffsetX(M),w,k,i,f,d,E,T,C,u,o,p,v,!1,!1,_,y,g);if(!ee)return{notEnoughRoom:!0};P(ee)}return{}}function _r(e,t,r,i,n){var a=i.projectTilePoint(e.x,e.y,t),o=a.x,s=a.y,l=a.z;if(!n)return cr(o,s,l,r);var u=n(e),c=x(u,3);return cr(o+c[0],s+c[1],l+c[2],r)}function yr(t,r,i,n,a,o,s,l){var u=_r(t.sub(r)._unit()._add(t),l,a,s,o);return e.a6.vec3.sub(u,i,u),e.a6.vec3.normalize(u,u),e.a6.vec3.scaleAndAdd(u,i,u,n)}function gr(t,r,i,n,a,o,s,l,u,c,h,f,d,p,m,v,_,y){var g=n?t-r:t+r,x=g>0?1:-1,b=0;n&&(x*=-1,b=Math.PI),x<0&&(b+=Math.PI);for(var w=l+s+(x>0?0:1)|0,k=a,T=a,M=0,S=0,E=Math.abs(g),I=[],A=[],C=o,P=C,z=function(){return yr(P,C,T,E-M+1,h,d,v,_.canonical)};M+S<=E;){if((w+=x)=u)return null;if(T=k,P=C,I.push(T),p&&A.push(P),C=new e.P(c.getx(w),c.gety(w)),!(k=f[w])){var D=_r(C,_.canonical,h,v,d);k=D[3]>0?f[w]=D:z()}M+=S,S=e.a6.vec3.distance(T,k)}m&&d&&(f[w]&&(k=z(),S=e.a6.vec3.distance(T,k)),f[w]=k);var R=(E-M)/S,L=C.sub(P)._mult(R)._add(P),O=e.a6.vec3.sub([],k,T),B=e.a6.vec3.scaleAndAdd([],T,O,R),F=[0,0,1],N=O[0],V=O[1];if(y&&(0!==(F=v.upVector(_.canonical,L.x,L.y))[0]||0!==F[1]||1!==F[2])){var U=[F[2],0,-F[0]],j=e.a6.vec3.cross([],F,U);e.a6.vec3.normalize(U,U),e.a6.vec3.normalize(j,j),N=e.a6.vec3.dot(O,U),V=e.a6.vec3.dot(O,j)}if(i){var G=e.a6.vec3.cross([],F,O);e.a6.vec3.normalize(G,G),e.a6.vec3.scaleAndAdd(B,B,G,i*x)}var q=b+Math.atan2(V,N);return I.push(B),p&&A.push(L),{point:B,angle:q,path:I,tilePath:A,up:F}}function xr(e,t){var r=t.length,i=r+4*e;t.resize(i),t.float32.fill(-1/0,4*r,4*i)}function br(e,t,r){var i=t[0],n=t[1];return e[0]=r[0]*i+r[4]*n+r[12],e[1]=r[1]*i+r[5]*n+r[13],e[3]=r[3]*i+r[7]*n+r[15],e}var wr=100,kr=(function(){return m((function e(t,r){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new rr(t.width+200,t.height+200,25),n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:new rr(t.width+200,t.height+200,25);p(this,e),this.transform=t,this.grid=i,this.ignoredGrid=n,this.pitchfactor=Math.cos(t._pitch)*t.cameraToCenterDistance,this.screenRightBoundary=t.width+wr,this.screenBottomBoundary=t.height+wr,this.gridRightBoundary=t.width+200,this.gridBottomBoundary=t.height+200,this.fogState=r}),[{key:"placeCollisionBox",value:function(e,t,r,i,n,a,o,s){var l=r.projectedAnchorX,u=r.projectedAnchorY,c=r.projectedAnchorZ,h=r.elevation,f=r.tileID,d=e.getProjection();if(h&&f){var p=d.upVector(f.canonical,r.tileAnchorX,r.tileAnchorY),m=x(p,3),v=m[0],_=m[1],y=m[2],g=d.upVectorScale(f.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;l+=v*h*g,u+=_*h*g,c+=y*h*g}var b=this.projectAndGetPerspectiveRatio(o,l,u,c,r.tileID,"globe"===d.name||!!h||this.transform.pitch>0,d),w=a*b.perspectiveRatio,k=(r.x1*t+i.x-r.padding)*w+b.point.x,T=(r.y1*t+i.y-r.padding)*w+b.point.y,M=(r.x2*t+i.x+r.padding)*w+b.point.x,S=(r.y2*t+i.y+r.padding)*w+b.point.y,E=b.perspectiveRatio<=.55||b.occluded;return!this.isInsideGrid(k,T,M,S)||!n&&this.grid.hitTest(k,T,M,S,s)||E?{box:[],offscreen:!1,occluded:b.occluded}:{box:[k,T,M,S],offscreen:this.isOffscreen(k,T,M,S),occluded:!1}}},{key:"placeCollisionCircles",value:function(t,r,i,n,a,o,s,l,u,c,h,f,d,p,m){var v=[],_=this.transform.elevation,y=t.getProjection(),g=_?_.getAtTileOffsetFunc(m,this.transform.center.lat,this.transform.worldSize,y):null,b=new e.P(i.tileAnchorX,i.tileAnchorY),w=y.projectTilePoint(b.x,b.y,m.canonical),k=w.x,T=w.y,M=w.z;if(g){var S=g(b),E=x(S,3);k+=E[0],T+=E[1],M+=E[2]}var I="globe"===y.name,A=this.projectAndGetPerspectiveRatio(s,k,T,M,m,I||!!_||this.transform.pitch>0,y),C=A.perspectiveRatio,P=(h?o/C:o*C)/e.bq,z=cr(k,T,M,l),D=A.signedDistanceFromCamera>0?pr(P,a,i.lineOffsetX*P,i.lineOffsetY*P,!1,z,b,i,n,l,{},_&&!h?g:null,h&&!!_,y,m,h):null,R=!1,L=!1,O=!0;if(D&&!A.occluded){for(var B=.5*d*C+p,F=new e.P(-100,-100),N=new e.P(this.screenRightBoundary,this.screenBottomBoundary),V=new tr,U=D.first,j=D.last,G=U.path.length,q=[],Z=G-1;Z>=1;Z--)q.push(U.path[Z]);for(var $=1;$0){var X=1/0,Y=-1/0,J=1/0,K=-1/0;for(var Q of q)X=Math.min(X,Q[0]),J=Math.min(J,Q[1]),Y=Math.max(Y,Q[0]),K=Math.max(K,Q[1]);Y>=F.x&&X<=N.x&&K>=F.y&&J<=N.y&&(W=[q.map((function(t){return new e.P(t[0],t[1])}))],(XN.x||JN.y)&&(W=e.bo(W,F.x,F.y,N.x,N.y)))}for(var ee of W){V.reset(ee,.25*B);var te;te=V.length<=.5*B?1:Math.ceil(V.paddedLength/H)+1;for(var re=0;re0){if(e.a6.vec4.transformMat4(l,l,t),this.fogState&&a&&"globe"!==s.name){var c=(function(t,r,i,n,a,o){var s=o.calculateFogTileMatrix(a),l=[r,i,n];return e.a6.vec3.transformMat4(l,l,s),He(t,e.a6.vec3.length(l),o.pitch,o._fov)})(this.fogState,r,i,n,a.toUnwrapped(),this.transform);u=c>.9}}else br(l,l,t);var h=l[3];return{point:new e.P((l[0]/h+1)/2*this.transform.width+wr,(-l[1]/h+1)/2*this.transform.height+wr),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(s)/h*.5,1.5),signedDistanceFromCamera:h,occluded:o&&l[2]>h||u}}},{key:"isOffscreen",value:function(e,t,r,i){return r=this.screenRightBoundary||ithis.screenBottomBoundary}},{key:"isInsideGrid",value:function(e,t,r,i){return r>=0&&e=0&&t5&&void 0!==arguments[5]&&arguments[5];p(this,e),this.text=new Er(t?t.text:null,r,i,a),this.icon=new Er(t?t.icon:null,r,n,a),this.clipped=o}),[{key:"isHidden",value:function(){return this.text.isHidden()&&this.icon.isHidden()}}])})(),Ar=m((function e(t,r,i){var n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];p(this,e),this.text=t,this.icon=r,this.skipFade=i,this.clipped=n})),Cr=m((function t(){p(this,t),this.invProjMatrix=e.a6.mat4.create(),this.viewportMatrix=e.a6.mat4.create(),this.circles=[]})),Pr=m((function e(t,r,i,n,a){p(this,e),this.bucketInstanceId=t,this.featureIndex=r,this.sourceLayerIndex=i,this.bucketIndex=n,this.tileID=a})),zr=(function(){return m((function e(t){p(this,e),this.crossSourceCollisions=t,this.maxGroupID=0,this.collisionGroups={}}),[{key:"get",value:function(e){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[e]){var t=++this.maxGroupID;this.collisionGroups[e]={ID:t,predicate:function(e){return e.collisionGroupID===t}}}return this.collisionGroups[e]}}])})();function Dr(t,r,i,n,a){var o=e.bx(t),s=-(o.horizontalAlign-.5)*r,l=-(o.verticalAlign-.5)*i,u=e.bw(t,n);return new e.P(s+u[0]*a,l+u[1]*a)}function Rr(t,r,i,n,a){var o=new e.P(t,r);return i&&o._rotate(n?a:-a),o}var Lr=(function(){return m((function e(t,r,i,n,a,o){p(this,e),this.transform=t.clone(),this.projection=t.projection.name,this.collisionIndex=new kr(this.transform,a),this.buildingIndex=o,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=r,this.retainedQueryData={},this.collisionGroups=new zr(i),this.collisionCircleArrays={},this.prevPlacement=n,n&&(n.prevPlacement=void 0),this.placedOrientations={}}),[{key:"getBucketParts",value:function(t,r,i,n){var a=i.getBucket(r),o=i.latestFeatureIndex;if(a&&o&&r.fqid===a.layerIds[0]){var s=a.layers[0].layout,l=a.layers[0].paint,u=i.collisionBoxArray,c=Math.pow(2,this.transform.zoom-i.tileID.overscaledZ),h=i.tileSize/e.ab,f=i.tileID.toUnwrapped();this.transform.setProjection(a.projection);var d,p,m,v=(d=i.tileID,p=a.getProjection(),m=this.transform,p.name===this.projection?m.calculateProjMatrix(d.toUnwrapped()):Tr(m,p,d)),_="map"===s.get("text-pitch-alignment"),y="map"===s.get("text-rotation-alignment");r.compileFilter();var g=r.dynamicFilter(),x=r.dynamicFilterNeedsFeature(),b=this.transform.calculatePixelsToTileUnitsMatrix(i),w=lr(v,i.tileID.canonical,_,y,this.transform,a.getProjection(),b),k=null;if(_){var T=ur(v,i.tileID.canonical,_,y,this.transform,a.getProjection(),b);k=e.a6.mat4.multiply([],this.transform.labelPlaneMatrix,T)}var M=null;g&&i.latestFeatureIndex&&(M={unwrappedTileID:f,dynamicFilter:g,dynamicFilterNeedsFeature:x}),this.retainedQueryData[a.bucketInstanceId]=new Pr(a.bucketInstanceId,o,a.sourceLayerIndex,a.index,i.tileID);var S={bucket:a,layout:s,paint:l,posMatrix:v,textLabelPlaneMatrix:w,labelToScreenMatrix:k,clippingData:M,scale:c,textPixelRatio:h,holdingForFade:i.holdingForFade(),collisionBoxArray:u,partiallyEvaluatedTextSize:e.bj(a.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:e.bj(a.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(a.sourceID),latestFeatureIndex:i.latestFeatureIndex};if(n)for(var E of a.sortKeyRanges){var I=E.sortKey,A=E.symbolInstanceStart,C=E.symbolInstanceEnd;t.push({sortKey:I,symbolInstanceStart:A,symbolInstanceEnd:C,parameters:S})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:a.symbolInstances.length,parameters:S})}}},{key:"attemptAnchorPlacement",value:function(e,t,r,i,n,a,o,s,l,u,c,h,f,d,p,m,v,_){var y,g=h.textOffset0,x=h.textOffset1,b=h.crossTileID,w=[g,x],k=Dr(e,r,i,w,n),T=this.collisionIndex.placeCollisionBox(d,n,t,Rr(k.x,k.y,a,o,this.transform.angle),c,s,l,u.predicate);if(m){var M=d.getSymbolInstanceIconSize(_,this.transform.zoom,h.placedIconSymbolIndex);if(0===this.collisionIndex.placeCollisionBox(d,M,m,Rr(k.x,k.y,a,o,this.transform.angle),c,s,l,u.predicate).box.length)return}if(T.box.length>0)return this.prevPlacement&&this.prevPlacement.variableOffsets[b]&&this.prevPlacement.placements[b]&&this.prevPlacement.placements[b].text&&(y=this.prevPlacement.variableOffsets[b].anchor),this.variableOffsets[b]={textOffset:w,width:r,height:i,anchor:e,textScale:n,prevAnchor:y},this.markUsedJustification(d,e,h,p),d.allowVerticalPlacement&&(this.markUsedOrientation(d,p,h),this.placedOrientations[b]=p),{shift:k,placedGlyphBoxes:T}}},{key:"placeLayerBucketPart",value:function(t,r,i,n){var a=this,o=t.parameters,s=o.bucket,l=o.layout,u=o.paint,c=o.posMatrix,h=o.textLabelPlaneMatrix,f=o.labelToScreenMatrix,d=o.clippingData,p=o.textPixelRatio,m=o.holdingForFade,v=o.collisionBoxArray,_=o.partiallyEvaluatedTextSize,y=o.partiallyEvaluatedIconSize,g=o.collisionGroup,x=o.latestFeatureIndex,b=l.get("text-optional"),w=l.get("icon-optional"),k=l.get("text-allow-overlap"),T=l.get("icon-allow-overlap"),M="map"===l.get("text-rotation-alignment"),S="map"===l.get("text-pitch-alignment"),E=l.get("symbol-z-elevate"),I=u.get("symbol-z-offset"),A="sea"===u.get("symbol-elevation-reference");this.transform.setProjection(s.projection);var C=k&&(T||!s.hasIconData()||w),P=T&&(k||!s.hasTextData()||b),z=!I.isConstant();!s.collisionArrays&&v&&s.deserializeCollisionBoxes(v),i&&n&&s.updateCollisionDebugBuffers(this.transform.zoom,v);var D=function(t,n,o){var u=t.crossTileID,v=t.numVerticalGlyphVertices,E=null;if(d&&d.dynamicFilterNeedsFeature||z){var D=a.retainedQueryData[s.bucketInstanceId];E=x.loadFeature({featureIndex:t.featureIndex,bucketIndex:D.bucketIndex,sourceLayerIndex:D.sourceLayerIndex,layoutVertexArrayOffset:0})}if(d&&!(0,d.dynamicFilter)({zoom:a.transform.zoom,pitch:a.transform.pitch},E,a.retainedQueryData[s.bucketInstanceId].tileID.canonical,new e.P(t.tileAnchorX,t.tileAnchorY),a.transform.calculateDistanceTileData(d.unwrappedTileID)))return a.placements[u]=new Ar(!1,!1,!1,!0),void r.add(u);var R=I.evaluate(E,{});if(!r.has(u))if(m)a.placements[u]=new Ar(!1,!1,!1);else{var L,O=!1,B=!1,F=!0,N=!1,V=!1,U=null,j={box:null,offscreen:null,occluded:null},G={box:null,offscreen:null,occluded:null},q=null,Z=null,$=0,H=0,W=0;o.textFeatureIndex?$=o.textFeatureIndex:t.useRuntimeCollisionCircles&&($=t.featureIndex),o.verticalTextFeatureIndex&&(H=o.verticalTextFeatureIndex);var X=function(e){e.tileID=a.retainedQueryData[s.bucketInstanceId].tileID;var r=a.transform.elevation;e.elevation=A?R:R+(r?r.getAtTileOffset(e.tileID,e.tileAnchorX,e.tileAnchorY):0),e.elevation+=t.zOffset},Y=o.textBox;if(Y){X(Y);var J=function(r){var i=e.bk.horizontal;if(s.allowVerticalPlacement&&!r&&a.prevPlacement){var n=a.prevPlacement.placedOrientations[u];n&&(a.placedOrientations[u]=n,i=n,a.markUsedOrientation(s,i,t))}return i},K=function(t,r){if(s.allowVerticalPlacement&&v>0&&o.verticalTextBox){for(var i of s.writingModes)if(i===e.bk.vertical?(j=r(),G=j):j=t(),j&&j.box&&j.box.length)break}else j=t()};if(l.get("text-variable-anchor")){var Q=l.get("text-variable-anchor");if(a.prevPlacement&&a.prevPlacement.variableOffsets[u]){var ee=a.prevPlacement.variableOffsets[u];Q.indexOf(ee.anchor)>0&&(Q=Q.filter((function(e){return e!==ee.anchor})),Q.unshift(ee.anchor))}var te=function(e,r,i){var o=s.getSymbolInstanceTextSize(_,t,a.transform.zoom,n),l=(e.x2-e.x1)*o+2*e.padding,u=(e.y2-e.y1)*o+2*e.padding,h=t.hasIconTextFit&&!T?r:null;h&&X(h);for(var f={box:[],offscreen:!1,occluded:!1},d=k?2*Q.length:Q.length,m=0;m=Q.length,t,n,s,i,h,_,y);if(v&&((f=v.placedGlyphBoxes)&&f.box&&f.box.length)){O=!0,U=v.shift;break}}return f};K((function(){return te(Y,o.iconBox,e.bk.horizontal)}),(function(){var t=o.verticalTextBox;return t&&X(t),s.allowVerticalPlacement&&!(j&&j.box&&j.box.length)&&v>0&&t?te(t,o.verticalIconBox,e.bk.vertical):{box:null,offscreen:null,occluded:null}})),j&&(O=j.box,F=j.offscreen,N=j.occluded);var re=J(!(!j||!j.box));if(!O&&a.prevPlacement){var ie=a.prevPlacement.variableOffsets[u];ie&&(a.variableOffsets[u]=ie,a.markUsedJustification(s,ie.anchor,t,re))}}else{var ne=function(r,i){var o=s.getSymbolInstanceTextSize(_,t,a.transform.zoom,n),l=a.collisionIndex.placeCollisionBox(s,o,r,new e.P(0,0),k,p,c,g.predicate);return l&&l.box&&l.box.length&&(a.markUsedOrientation(s,i,t),a.placedOrientations[u]=i),l};K((function(){return ne(Y,e.bk.horizontal)}),(function(){var t=o.verticalTextBox;return s.allowVerticalPlacement&&v>0&&t?(X(t),ne(t,e.bk.vertical)):{box:null,offscreen:null,occluded:null}})),J(!!(j&&j.box&&j.box.length))}}if(O=(L=j)&&L.box&&L.box.length>0,F=L&&L.offscreen,N=L&&L.occluded,t.useRuntimeCollisionCircles){var ae=s.text.placedSymbolArray.get(t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex),oe=e.bl(s.textSizeData,_,ae),se=l.get("text-padding");q=a.collisionIndex.placeCollisionCircles(s,k,ae,s.lineVertexArray,s.glyphOffsetArray,oe,c,h,f,i,S,g.predicate,t.collisionCircleDiameter*oe/e.bq,se,a.retainedQueryData[s.bucketInstanceId].tileID),O=k||q.circles.length>0&&!q.collisionDetected,F=F&&q.offscreen,N=q.occluded}if(o.iconFeatureIndex&&(W=o.iconFeatureIndex),o.iconBox){var le=function(r){X(r);var i=t.hasIconTextFit&&U?Rr(U.x,U.y,M,S,a.transform.angle):new e.P(0,0),n=s.getSymbolInstanceIconSize(y,a.transform.zoom,t.placedIconSymbolIndex);return a.collisionIndex.placeCollisionBox(s,n,r,i,T,p,c,g.predicate)};G&&G.box&&G.box.length&&o.verticalIconBox?B=(Z=le(o.verticalIconBox)).box.length>0:B=(Z=le(o.iconBox)).box.length>0,F=F&&Z.offscreen,V=Z.occluded}var ue=b||0===t.numHorizontalGlyphVertices&&0===v,ce=w||0===t.numIconVertices;if(ue||ce?ce?ue||(B=B&&O):O=B&&O:B=O=B&&O,O&&L&&L.box&&a.collisionIndex.insertCollisionBox(L.box,l.get("text-ignore-placement"),s.bucketInstanceId,G&&G.box&&H?H:$,g.ID),B&&Z&&a.collisionIndex.insertCollisionBox(Z.box,l.get("icon-ignore-placement"),s.bucketInstanceId,W,g.ID),q&&(O&&a.collisionIndex.insertCollisionCircles(q.circles,l.get("text-ignore-placement"),s.bucketInstanceId,$,g.ID),i)){var he=s.bucketInstanceId,fe=a.collisionCircleArrays[he];void 0===fe&&(fe=a.collisionCircleArrays[he]=new Cr);for(var de=0;de=0;--L){var O=R[L];D(s.symbolInstances.get(O),O,s.collisionArrays[O])}s.hasAnyZOffset&&e.w(`${s.layerIds[0]} layer symbol-z-elevate: symbols are not sorted by elevation if symbol-z-order is evaluated to viewport-y`)}else if(s.hasAnyZOffset)for(var B=s.getSortedIndexesByZOffset(),F=0;F=0&&(t.text.placedSymbolArray.get(a).crossTileID=h>=0&&a!==h?0:u),o>=0&&(t.text.placedSymbolArray.get(o).crossTileID=h>=0&&o!==h?0:u),s>=0&&(t.text.placedSymbolArray.get(s).crossTileID=h>=0&&s!==h?0:u),l>=0&&(t.text.placedSymbolArray.get(l).crossTileID=h>=0&&l!==h?0:u)}},{key:"markUsedOrientation",value:function(t,r,i){var n=r===e.bk.horizontal||r===e.bk.horizontalOnly?r:0,a=r===e.bk.vertical?r:0,o=i.leftJustifiedTextSymbolIndex,s=i.centerJustifiedTextSymbolIndex,l=i.rightJustifiedTextSymbolIndex,u=i.verticalPlacedTextSymbolIndex,c=t.text.placedSymbolArray;o>=0&&(c.get(o).placedOrientation=n),s>=0&&(c.get(s).placedOrientation=n),l>=0&&(c.get(l).placedOrientation=n),u>=0&&(c.get(u).placedOrientation=a)}},{key:"commit",value:function(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;var t=this.prevPlacement,r=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;var i=t?t.symbolFadeChange(e):1,n=t?t.opacities:{},a=t?t.variableOffsets:{},o=t?t.placedOrientations:{};for(var s in this.placements){var l=this.placements[s],u=n[s];u?(this.opacities[s]=new Ir(u,i,l.text,l.icon,null,l.clipped),r=r||l.text!==u.text.placed||l.icon!==u.icon.placed):(this.opacities[s]=new Ir(null,i,l.text,l.icon,l.skipFade,l.clipped),r=r||l.text||l.icon)}for(var c in n){var h=n[c];if(!this.opacities[c]){var f=new Ir(h,i,!1,!1);f.isHidden()||(this.opacities[c]=f,r=r||h.text.placed||h.icon.placed)}}for(var d in a)this.variableOffsets[d]||!this.opacities[d]||this.opacities[d].isHidden()||(this.variableOffsets[d]=a[d]);for(var p in o)this.placedOrientations[p]||!this.opacities[p]||this.opacities[p].isHidden()||(this.placedOrientations[p]=o[p]);r?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)}},{key:"updateLayerOpacities",value:function(e,t,r,i){var n=new Set;for(var a of t){var o=a.getBucket(e);o&&a.latestFeatureIndex&&e.fqid===o.layerIds[0]&&(this.updateBucketOpacities(o,n,a,a.collisionBoxArray,r,i,a.tileID,e.scope),o.layers[0].layout.get("symbol-z-elevate")&&this.buildingIndex&&(this.buildingIndex.updateZOffset(o,a.tileID),o.updateZOffset()))}}},{key:"updateBucketOpacities",value:function(t,r,i,n,a,o,s,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();var u=t.layers[0].layout,c=t.layers[0].paint,h=!!t.layers[0].dynamicFilter(),f=new Ir(null,0,!1,!1,!0),d=u.get("text-allow-overlap"),p=u.get("icon-allow-overlap"),m=u.get("text-variable-anchor"),v="map"===u.get("text-rotation-alignment"),_="map"===u.get("text-pitch-alignment"),y=c.get("symbol-z-offset"),g="sea"===c.get("symbol-elevation-reference"),x=!y.isConstant(),b=new Ir(null,0,d&&(p||!t.hasIconData()||u.get("icon-optional")),p&&(d||!t.hasTextData()||u.get("text-optional")),!0);!t.collisionArrays&&n&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(n);var w=function(e,t,r){for(var i=0;i0||E>0,F=A>0,N=this.placedOrientations[I],V=N===e.bk.vertical,U=N===e.bk.horizontal||N===e.bk.horizontalOnly;!B&&!F||O.isHidden()||k++;var j=!1;if((B||F)&&o)for(var G of t.activeReplacements)if(!e.br(G,a,e.bs.Symbol,l)&&!(G.min.x>C||C>G.max.x||G.min.y>P||P>G.max.y)){var q=e.bt(C,P,s.canonical,G.footprintTileId.canonical);if(j=e.bu(q,G.footprint))break}if(B){var Z=j?Zr:qr(O.text);w(t.text,S,V?Zr:Z),w(t.text,E,U?Zr:Z);var $=O.text.isHidden(),H=M.leftJustifiedTextSymbolIndex,W=M.centerJustifiedTextSymbolIndex,X=M.rightJustifiedTextSymbolIndex,Y=M.verticalPlacedTextSymbolIndex,J=t.text.placedSymbolArray,K=$||V?1:0;H>=0&&(J.get(H).hidden=K),W>=0&&(J.get(W).hidden=K),X>=0&&(J.get(X).hidden=K),Y>=0&&(J.get(Y).hidden=$||U?1:0);var Q=this.variableOffsets[I];Q&&this.markUsedJustification(t,Q.anchor,M,N);var ee=this.placedOrientations[I];ee&&(this.markUsedJustification(t,"left",M,ee),this.markUsedOrientation(t,ee,M))}if(F){var te=j?Zr:qr(O.icon),re=M.placedIconSymbolIndex,ie=M.verticalPlacedIconSymbolIndex,ne=t.icon.placedSymbolArray,ae=O.icon.isHidden()?1:0;re>=0&&(w(t.icon,A,V?Zr:te),ne.get(re).hidden=ae),ie>=0&&(w(t.icon,M.numVerticalIconVertices,U?Zr:te),ne.get(ie).hidden=ae)}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){var oe=t.collisionArrays[T];if(oe){var se=new e.P(0,0),le=!0;if(oe.textBox||oe.verticalTextBox){if(m){var ue=this.variableOffsets[I];ue?(se=Dr(ue.anchor,ue.width,ue.height,ue.textOffset,ue.textScale),v&&se._rotate(_?this.transform.angle:-this.transform.angle)):le=!1}h&&(le=!O.clipped),oe.textBox&&Or(t.textCollisionBox.collisionVertexArray,O.text.placed,!le||V,R,g,se.x,se.y),oe.verticalTextBox&&Or(t.textCollisionBox.collisionVertexArray,O.text.placed,!le||U,R,g,se.x,se.y)}var ce=le&&Boolean(!U&&oe.verticalIconBox);oe.iconBox&&Or(t.iconCollisionBox.collisionVertexArray,O.icon.placed,ce,R,g,M.hasIconTextFit?se.x:0,M.hasIconTextFit?se.y:0),oe.verticalIconBox&&Or(t.iconCollisionBox.collisionVertexArray,O.icon.placed,!ce,R,g,M.hasIconTextFit?se.x:0,M.hasIconTextFit?se.y:0)}}}if(t.fullyClipped=0===k,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){var he=this.collisionCircleArrays[t.bucketInstanceId];t.placementInvProjMatrix=he.invProjMatrix,t.placementViewportMatrix=he.viewportMatrix,t.collisionCircleArray=he.circles,delete this.collisionCircleArrays[t.bucketInstanceId]}}},{key:"symbolFadeChange",value:function(e){return 0===this.fadeDuration?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}},{key:"zoomAdjustment",value:function(e){return Math.max(0,(this.transform.zoom-e)/1.5)}},{key:"hasTransitions",value:function(e){return this.stale||e-this.lastPlacementChangeTimee}},{key:"setStale",value:function(){this.stale=!0}}])})();function Or(e,t,r,i,n,a,o){e.emplaceBack(t?1:0,r?1:0,a||0,o||0,i,n?1:0),e.emplaceBack(t?1:0,r?1:0,a||0,o||0,i,n?1:0),e.emplaceBack(t?1:0,r?1:0,a||0,o||0,i,n?1:0),e.emplaceBack(t?1:0,r?1:0,a||0,o||0,i,n?1:0)}var Br=Math.pow(2,25),Fr=Math.pow(2,24),Nr=Math.pow(2,17),Vr=Math.pow(2,16),Ur=Math.pow(2,9),jr=Math.pow(2,8),Gr=Math.pow(2,1);function qr(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;var t=e.placed?1:0,r=Math.floor(127*e.opacity);return r*Br+t*Fr+r*Nr+t*Vr+r*Ur+t*jr+r*Gr+t}var Zr=0,$r=(function(){return m((function e(t){p(this,e),this._sortAcrossTiles="viewport-y"!==t.layout.get("symbol-z-order")&&void 0!==t.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs=new Set,this._bucketParts=[]}),[{key:"continuePlacement",value:function(e,t,r,i,n){for(var a=this._bucketParts;this._currentTileIndex2};this._currentPlacementIndex>=0;){var l=r[t[this._currentPlacementIndex]],u=this.placement.collisionIndex.transform.zoom;if("symbol"===l.type&&(!l.minzoom||l.minzoom<=u)&&(!l.maxzoom||l.maxzoom>u)){var c=l,h=c.layout.get("symbol-z-elevate"),f=void 0!==c.layout.get("symbol-sort-key").constantOr(1),d=c.layout.get("symbol-z-order"),p="viewport-y"===d||"auto"===d&&!("viewport-y"!==d&&f),m=c.layout.get("text-allow-overlap")||c.layout.get("icon-allow-overlap")||c.layout.get("text-ignore-placement")||c.layout.get("icon-ignore-placement"),v=p&&m,_=this._inProgressLayer=this._inProgressLayer||new $r(c),y=e.av(l.source,l.scope);if(_.continuePlacement(h||v?n[y]:i[y],this.placement,this._showCollisionBoxes,l,s))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}},{key:"commit",value:function(e){return this.placement.commit(e),this.placement}}])})(),Wr=512/e.ab/2,Xr=(function(){return m((function t(r,i,n){p(this,t),this.tileID=r,this.bucketInstanceId=n,this.index=new e.by(i.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];for(var a=r.canonical.x*e.ab,o=r.canonical.y*e.ab,s=0;se.overscaledZ)for(var s in o){var l=o[s];l.tileID.isChildOf(e)&&l.findMatches(t.symbolInstances,e,n)}else{var u=o[e.scaledTo(Number(a)).key];u&&u.findMatches(t.symbolInstances,e,n)}}for(var c=0;c=1e-15){var a=e.a6.vec3.normalize([],i);e.a6.vec3.scale(n,a,e.a6.vec3.dot(n,a)),r[0]=n[0],r[1]=n[1]}var o=e.a6.vec3.cross([],r,t);if(e.a6.vec3.len(o)<1e-15)return null;var s=Math.atan2(-o[1],o[0]);return li(Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2]),s)}oi.disabled=new oi(!1,ni,ai),oi.backCCW=new oi(!0,ni,ai),oi.backCW=new oi(!0,ni,2304),oi.frontCW=new oi(!0,1028,2304),oi.frontCCW=new oi(!0,1028,ai);var ci=(function(){return m((function e(t,r){p(this,e),this.position=t,this.orientation=r}),[{key:"position",get:function(){return this._position},set:function(t){if(t){var r=t instanceof e.a5?t:new e.a5(t[0],t[1],t[2]);this._renderWorldCopies&&(r.x=e.bA(r.x,0,1)),this._position=r}else this._position=null}},{key:"lookAtPoint",value:function(t,r){if(this.orientation=null,this.position){var i=this.position,n=this._elevation?this._elevation.getAtPointOrZero(e.a5.fromLngLat(t)):0,a=e.a5.fromLngLat(t,n),o=[a.x-i.x,a.y-i.y,a.z-i.z];r||(r=[0,0,1]),r[2]=Math.abs(r[2]),this.orientation=ui(o,r)}}},{key:"setPitchBearing",value:function(t,r){this.orientation=li(e.bB(t),e.bB(-r))}}])})(),hi=(function(){function t(r,i){p(this,t),this._transform=e.a6.mat4.identity([]),this.orientation=i,this.position=r}return m(t,[{key:"mercatorPosition",get:function(){var t=this.position;return new e.a5(t[0],t[1],t[2])}},{key:"position",get:function(){var t=e.bC(this._transform,3);return[t[0],t[1],t[2]]},set:function(t){var r;t&&e.bE(this._transform,3,[(r=t)[0],r[1],r[2],1])}},{key:"orientation",get:function(){return this._orientation},set:function(t){this._orientation=t||e.a6.quat.identity([]),t&&si(this._transform,this._orientation)}},{key:"getPitchBearing",value:function(){var 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])}}},{key:"setPitchBearing",value:function(e,t){this._orientation=li(e,t),si(this._transform,this._orientation)}},{key:"forward",value:function(){var t=e.bC(this._transform,2);return[-t[0],-t[1],-t[2]]}},{key:"up",value:function(){var t=e.bC(this._transform,1);return[-t[0],-t[1],-t[2]]}},{key:"right",value:function(){var t=e.bC(this._transform,0);return[t[0],t[1],t[2]]}},{key:"getCameraToWorld",value:function(t,r){var i=new Float64Array(16);return e.a6.mat4.invert(i,this.getWorldToCamera(t,r)),i}},{key:"getCameraToWorldMercator",value:function(){return this._transform}},{key:"getWorldToCameraPosition",value:function(t,r,i){var n=this.position;e.a6.vec3.scale(n,n,-t);var a=new Float64Array(16);return e.a6.mat4.fromScaling(a,[i,i,i]),e.a6.mat4.translate(a,a,n),a[10]*=r,a}},{key:"getWorldToCamera",value:function(t,r){var i=new Float64Array(16),n=new Float64Array(4),a=this.position;return e.a6.quat.conjugate(n,this._orientation),e.a6.vec3.scale(a,a,-t),e.a6.mat4.fromQuat(i,n),e.a6.mat4.translate(i,i,a),i[1]*=-1,i[5]*=-1,i[9]*=-1,i[13]*=-1,i[8]*=r,i[9]*=r,i[10]*=r,i[11]*=r,i}},{key:"getCameraToClipPerspective",value:function(t,r,i,n){var a=new Float64Array(16);return e.a6.mat4.perspective(a,t,r,i,n),a}},{key:"getCameraToClipOrthographic",value:function(t,r,i,n,a,o){var s=new Float64Array(16);return e.a6.mat4.ortho(s,t,r,i,n,a,o),s}},{key:"getDistanceToElevation",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=0===t?0:e.bD(t,r?e.aM(this.position[1]):this.position[1]),n=this.forward();return(i-this.position[2])/n[2]}},{key:"clone",value:function(){return new t(d(this.position),d(this.orientation))}}])})(),fi=5,di=6,pi=7,mi=8,vi=9,_i=10,yi=11,gi=(function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(p(this,t),isNaN(e)||e<0||isNaN(r)||r<0||isNaN(i)||i<0||isNaN(n)||n<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=r,this.left=i,this.right=n}return m(t,[{key:"interpolate",value:function(t,r,i){return null!=r.top&&null!=t.top&&(this.top=e.aa(t.top,r.top,i)),null!=r.bottom&&null!=t.bottom&&(this.bottom=e.aa(t.bottom,r.bottom,i)),null!=r.left&&null!=t.left&&(this.left=e.aa(t.left,r.left,i)),null!=r.right&&null!=t.right&&(this.right=e.aa(t.right,r.right,i)),this}},{key:"getCenter",value:function(t,r){var i=e.ap((this.left+t-this.right)/2,0,t),n=e.ap((this.top+r-this.bottom)/2,0,r);return new e.P(i,n)}},{key:"equals",value:function(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}},{key:"clone",value:function(){return new t(this.top,this.bottom,this.left,this.right)}},{key:"toJSON",value:function(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}])})(),xi=function(e,t,r){return(1-r)*e+r*t},bi=function(e){return e*e*e*e*e},wi=(function(){function t(r,i,n,a,o,s,l){p(this,t),this.tileSize=512,this._renderWorldCopies=void 0===o||o,this._minZoom=r||0,this._maxZoom=i||22,this._minPitch=null!=n?n:0,this._maxPitch=null!=a?a:60,this.setProjection(s),this.setMaxBounds(l),this.width=0,this.height=0,this._center=new e.bK(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._unmodified=!0,this._edgeInsets=new gi,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new hi,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}return m(t,[{key:"clone",value:function(){var e=new t(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}},{key:"isOrthographic",get:function(){return"globe"!==this.projection.name&&this._orthographicProjectionAtLowPitch&&this.pitch<15}},{key:"elevation",get:function(){return this._elevation},set:function(e){this._elevation!==e&&(this._elevation=e,this._updateCameraOnTerrain(),this._calcMatrices())}},{key:"depthOcclusionForSymbolsAndCircles",get:function(){return"globe"!==this.projection.name&&!this.isOrthographic}},{key:"updateElevation",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(null==this._seaLevelZoom||r)&&this._updateCameraOnTerrain(),(e||r)&&this._constrainCamera(t),this._calcMatrices()}},{key:"getProjection",value:function(){return e.ar(this.projection,["name","center","parallels"])}},{key:"setProjection",value:function(t){this.projectionOptions=t||{name:"mercator"};var r=this.projection?this.getProjection():void 0;this.projection=e.bL(this.projectionOptions);var i=this.getProjection(),n=!e.bh(r,i);return n&&this._calcMatrices(),this.mercatorFromTransition=!1,n}},{key:"setOrthographicProjectionAtLowPitch",value:function(e){return this._orthographicProjectionAtLowPitch!==e&&(this._orthographicProjectionAtLowPitch=e,this._calcMatrices(),!0)}},{key:"setMercatorFromTransition",value:function(){var t=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=e.bL({name:"mercator"});var r=t!==this.projection.name;return r&&this._calcMatrices(),r}},{key:"minZoom",get:function(){return this._minZoom},set:function(e){this._minZoom!==e&&(this._minZoom=e,this.zoom=Math.max(this.zoom,e))}},{key:"maxZoom",get:function(){return this._maxZoom},set:function(e){this._maxZoom!==e&&(this._maxZoom=e,this.zoom=Math.min(this.zoom,e))}},{key:"minPitch",get:function(){return this._minPitch},set:function(e){this._minPitch!==e&&(this._minPitch=e,this.pitch=Math.max(this.pitch,e))}},{key:"maxPitch",get:function(){return this._maxPitch},set:function(e){this._maxPitch!==e&&(this._maxPitch=e,this.pitch=Math.min(this.pitch,e))}},{key:"renderWorldCopies",get:function(){return this._renderWorldCopies&&!0===this.projection.supportsWorldCopies},set:function(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e}},{key:"worldSize",get:function(){return this.tileSize*this.scale}},{key:"cameraWorldSizeForFog",get:function(){var e=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}},{key:"cameraWorldSize",get:function(){var e=Math.max(this._camera.getDistanceToElevation(this._averageElevation,!0),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}},{key:"pixelsPerMeter",get:function(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}},{key:"cameraPixelsPerMeter",get:function(){return e.bD(1,this.center.lat)*this.cameraWorldSizeForFog}},{key:"centerOffset",get:function(){return this.centerPoint._sub(this.size._div(2))}},{key:"size",get:function(){return new e.P(this.width,this.height)}},{key:"bearing",get:function(){return e.bA(this.rotation,-180,180)},set:function(e){this.rotation=e}},{key:"rotation",get:function(){return-this.angle/Math.PI*180},set:function(t){var r=-t*Math.PI/180;this.angle!==r&&(this._unmodified=!1,this.angle=r,this._calcMatrices(),this.rotationMatrix=e.a6.mat2.create(),e.a6.mat2.rotate(this.rotationMatrix,this.rotationMatrix,this.angle))}},{key:"pitch",get:function(){return this._pitch/Math.PI*180},set:function(t){var r=e.ap(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==r&&(this._unmodified=!1,this._pitch=r,this._calcMatrices())}},{key:"aspect",get:function(){return this.width/this.height}},{key:"fov",get:function(){return this._fov/Math.PI*180},set:function(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=e.bB(t),this._calcMatrices())}},{key:"fovX",get:function(){return this._fov}},{key:"fovY",get:function(){var e=1/Math.tan(.5*this.fovX);return 2*Math.atan(1/this.aspect/e)}},{key:"averageElevation",get:function(){return this._averageElevation},set:function(e){this._averageElevation=e,this._calcFogMatrices(),this._distanceTileDataCache={}}},{key:"zoom",get:function(){return this._zoom},set:function(e){var 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())}},{key:"_setZoom",value:function(e){this._zoom=e,this.scale=this.zoomScale(e),this.tileZoom=Math.floor(e),this.zoomFraction=e-this.tileZoom}},{key:"tileCoverLift",get:function(){return this._tileCoverLift},set:function(e){this._tileCoverLift!==e&&(this._tileCoverLift=e)}},{key:"_updateCameraOnTerrain",value:function(){var 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);var r=this._elevation;t||this._centerAltitude&&this._centerAltitudeValidForExaggeration&&r.exaggeration()&&this._centerAltitudeValidForExaggeration!==r.exaggeration()?(this._centerAltitude=this._centerAltitude/this._centerAltitudeValidForExaggeration*r.exaggeration(),this._centerAltitudeValidForExaggeration=r.exaggeration()):(this._centerAltitude=e||0,this._centerAltitudeValidForExaggeration=r.exaggeration()),this._updateSeaLevelZoom()}},{key:"_updateSeaLevelZoom",value:function(){void 0!==this._centerAltitudeValidForExaggeration&&(this._seaLevelZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize))}},{key:"sampleAverageElevation",value:function(){if(!this._elevation)return 0;for(var t=this._elevation,r=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],i=this.horizonLineFromTop(),n=0,a=0,o=0;o0,_=h.y+10,g=c.wrap-(v?0:1),x=c.wrap+(m?0:1),b=v?h.x-1:p-1,w=m?h.x+1:0;if(a)i[0]<0?(l(f,x,h.z,w,h.y),i[1]<0&&_&&(l(f,d,h.z,h.x,h.y+1),l(f,x,h.z,w,h.y+1)),i[1]>0&&y&&(l(f,d,h.z,h.x,h.y-1),l(f,x,h.z,w,h.y-1))):i[0]>0?(l(f,g,h.z,b,h.y),i[1]<0&&_&&(l(f,d,h.z,h.x,h.y+1),l(f,g,h.z,b,h.y+1)),i[1]>0&&y&&(l(f,d,h.z,h.x,h.y-1),l(f,g,h.z,b,h.y-1))):i[1]<0&&_?l(f,d,h.z,h.x,h.y+1):y&&l(f,d,h.z,h.x,h.y-1);else{var k=c.visibleQuadrants;1&k&&(l(f,g,h.z,b,h.y),y&&(l(f,d,h.z,h.x,h.y-1),l(f,g,h.z,b,h.y-1))),2&k&&(l(f,x,h.z,w,h.y),y&&(l(f,d,h.z,h.x,h.y-1),l(f,x,h.z,w,h.y-1))),4&k&&(l(f,g,h.z,b,h.y),_&&(l(f,d,h.z,h.x,h.y+1),l(f,g,h.z,b,h.y+1))),8&k&&(l(f,x,h.z,w,h.y),_&&(l(f,d,h.z,h.x,h.y+1),l(f,x,h.z,w,h.y+1)))}}}var T=[],M=function(e){n.some((function(t){return e.isChildOf(t)}))||T.push(e)};for(var S of n)M(S);if(n=T.filter((function(e){return!t.some((function(t){return!!(e.overscaledZt.maxzoom&&(i=t.maxzoom);var l,u=this.locationCoordinate(this.center),c=this.center.lat,h=1<=.9)return!0}else if(o&&(l=t.aabb.distanceZ(g)*_),r.projection.isReprojectedInTileSpace&&n<=5){var x=Math.pow(2,t.zoom),k=S(new e.a5((t.x+.5)/x,(t.y+.5)/x));u=k>.85?1:k}if(!s){var T=Math.sqrt(i*i+a*a+l*l),M=(1<>1),b={aabb:s?n.aabb.quadrant(_):e.bR(r,h,n.zoom+1,y,g,n.wrap,n.minZ,n.maxZ,r.projection),zoom:n.zoom+1,x:y,y:g,wrap:n.wrap,fullyVisible:u,tileID:void 0,shouldSplit:void 0,minZ:n.minZ,maxZ:n.maxZ};o&&!d&&(b.tileID=new e.aA(n.zoom+1===C?P:n.zoom+1,n.wrap,n.zoom+1,y,g),D(b)),I.push(b)}else{var w=n.zoom===C?P:n.zoom;if(t.minzoom&&t.minzoom>w)return 0;var k=0;if(!u){var T=x?n.aabb.intersectsPrecise(m):n.aabb.intersectsPreciseFlat(m);if(0===T&&c()){var M=new e.bP(n.zoom,a,l);T=e.bQ(r,h,M,!0).intersectsPrecise(m)}if(0===T)return 0;if(t.calculateQuadrantVisibility)if(m.containsPoint(n.aabb.center))k=15;else for(var S=0;S<4;S++)0!==n.aabb.quadrant(S).intersects(m)&&(k|=1<0;)B();if(this.fogCullDistSq){var F=this.fogCullDistSq,N=this.horizonLineFromTop();A=A.filter((function(i){var n=[0,0,0,1],a=[e.ab,e.ab,0,1],o=r.calculateFogTileMatrix(i.tileID.toUnwrapped());e.a6.vec4.transformMat4(n,n,o),e.a6.vec4.transformMat4(a,a,o);var s=e.a6.vec4.min([],n,a),u=e.a6.vec4.max([],n,a),c=e.bS(s,u);if(0===c)return!0;var h=!1,f=r._elevation;if(f&&c>F&&0!==N){var d,p=r.calculateProjMatrix(i.tileID.toUnwrapped());t.isTerrainDEM||(d=f.getMinMaxForTile(i.tileID)),d||(d={min:T,max:l});var m=e.c3(r.rotation),v=[m[0]*e.ab,m[1]*e.ab,d.max];e.a6.vec3.transformMat4(v,v,p),h=(1-v[1])*r.height*.51&&void 0!==arguments[1]?arguments[1]:this._centerAltitude;return this.projection.pointCoordinate(this,e.x,e.y,t)}},{key:"pointCoordinate3D",value:function(t){if(!this.elevation)return this.pointCoordinate(t);var r=this.projection.pointCoordinate3D(this,t.x,t.y);if(r)return new e.a5(r[0],r[1],r[2]);var i=0,n=this.horizonLineFromTop();if(t.y>n)return this.pointCoordinate(t);for(var a=.02*n,o=t.clone(),s=0;s<10&&n-i>a;s++){o.y=e.aa(i,n,.66);var l=this.projection.pointCoordinate3D(this,o.x,o.y);l?(n=o.y,r=l):i=o.y}return r?new e.a5(r[0],r[1],r[2]):this.pointCoordinate(t)}},{key:"isPointAboveHorizon",value:function(e){return this.projection.isPointAboveHorizon(this,e)}},{key:"isPointOnSurface",value:function(t){if(t.y<0||t.y>this.height||t.x<0||t.x>this.width)return!1;if(this.elevation||this.zoom>=e.bU)return!this.isPointAboveHorizon(t);var r=this.pointCoordinate(t);return r.y>=0&&r.y<=1}},{key:"_coordinatePoint",value:function(t,r){var i=r&&this.elevation?this.elevation.getAtPointOrZero(t,this._centerAltitude):this._centerAltitude,n=[t.x*this.worldSize,t.y*this.worldSize,i+t.toAltitude(),1];return e.a6.vec4.transformMat4(n,n,this.pixelMatrix),n[3]>0?new e.P(n[0]/n[3],n[1]/n[3]):new e.P(Number.MAX_VALUE,Number.MAX_VALUE)}},{key:"_getBoundsNonRectangular",value:function(){var t=this,r=this._edgeInsets,i=r.top,n=r.left,a=this.height-this._edgeInsets.bottom,o=this.width-this._edgeInsets.right,s=this.pointLocation3D(new e.P(n,i)),l=this.pointLocation3D(new e.P(o,i)),u=this.pointLocation3D(new e.P(o,a)),c=this.pointLocation3D(new e.P(n,a)),h=Math.min(s.lng,l.lng,u.lng,c.lng),f=Math.max(s.lng,l.lng,u.lng,c.lng),d=Math.min(s.lat,l.lat,u.lat,c.lat),p=Math.max(s.lat,l.lat,u.lat,c.lat),m=Math.pow(2,-this.zoom)/16*270,v="globe"===this.projection.name?1:4,_=function(r,i,n,a,o){var s=(r+n)/2,l=(i+a)/2,u=new e.P(s,l),c=t.pointLocation3D(u),y=c.lng,g=c.lat,x=Math.max(0,h-y,d-g,y-f,g-p);h=Math.min(h,y),f=Math.max(f,y),d=Math.min(d,g),p=Math.max(p,g),(om)&&(_(r,i,s,l,o+1),_(s,l,n,a,o+1))};if(_(n,i,o,i,1),_(o,i,o,a,1),_(o,a,n,a,1),_(n,a,n,i,1),"globe"===this.projection.name){var y=e.bV(this),g=x(y,2),b=g[0],w=g[1];b?(p=90,f=180,h=-180):w&&(d=-90,f=180,h=-180)}return new e.as(new e.bK(h,d),new e.bK(f,p))}},{key:"_getBoundsRectangular",value:function(t,r){var i=this._edgeInsets,n=i.top,a=i.left,o=this.height-this._edgeInsets.bottom,s=this.width-this._edgeInsets.right,l=new e.P(a,n),u=new e.P(s,n),c=new e.P(s,o),h=new e.P(a,o),f=this.pointCoordinate(l,t),d=this.pointCoordinate(u,t),p=this.pointCoordinate(c,r),m=this.pointCoordinate(h,r),v=function(e,t){return(t.y-e.y)/(t.x-e.x)};return f.y>1&&d.y>=0?f=new e.a5((1-m.y)/v(m,f)+m.x,1):f.y<0&&d.y<=1&&(f=new e.a5(-m.y/v(m,f)+m.x,0)),d.y>1&&f.y>=0?d=new e.a5((1-p.y)/v(p,d)+p.x,1):d.y<0&&f.y<=1&&(d=new e.a5(-p.y/v(p,d)+p.x,0)),(new e.as).extend(this.coordinateLocation(f)).extend(this.coordinateLocation(d)).extend(this.coordinateLocation(m)).extend(this.coordinateLocation(p))}},{key:"_getBoundsRectangularTerrain",value:function(){var e=this.elevation;if(!e.visibleDemTiles.length||e.isUsingMockSource())return this._getBoundsRectangular(0,0);var t=e.visibleDemTiles.reduce((function(e,t){if(t.dem){var r=t.dem.tree;e.min=Math.min(e.min,r.minimums[0]),e.max=Math.max(e.max,r.maximums[0])}return e}),{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(t.min*e.exaggeration(),t.max*e.exaggeration())}},{key:"getBounds",value:function(){return"mercator"===this.projection.name||"equirectangular"===this.projection.name?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}},{key:"horizonLineFromTop",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))-this.centerOffset.y,r=this.height/2-t*(1-this._horizonShift);return e?Math.max(0,r):r}},{key:"getMaxBounds",value:function(){return this.maxBounds}},{key:"setMaxBounds",value:function(t){this.maxBounds=t,this.minLat=-e.bT,this.maxLat=e.bT,this.minLng=-180,this.maxLng=180,t&&(this.minLat=t.getSouth(),this.maxLat=t.getNorth(),this.minLng=t.getWest(),this.maxLng=t.getEast(),this.maxLng1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=t.key;if((r=n?this._expandedProjMatrixCache:i?this._alignedProjMatrixCache:this._projMatrixCache)[a])return r[a];var o,s=this.calculatePosMatrix(t,this.worldSize);return o=this.projection.isReprojectedInTileSpace?this.mercatorMatrix:n?this.expandedFarZProjMatrix:i?this.alignedProjMatrix:this.projMatrix,e.a6.mat4.multiply(s,o,s),r[a]=new Float32Array(s),r[a]}},{key:"calculatePixelsToTileUnitsMatrix",value:function(t){var r=t.tileID.key,i=this._pixelsToTileUnitsCache;if(i[r])return i[r];var n=e.bW(t,this);return i[r]=n,i[r]}},{key:"customLayerMatrix",value:function(){return this.mercatorMatrix.slice()}},{key:"globeToMercatorMatrix",value:function(){if("globe"===this.projection.name){var t=1/this.worldSize,r=e.a6.mat4.fromScaling([],[t,t,t]);return e.a6.mat4.multiply(r,r,this.globeMatrix),r}}},{key:"recenterOnTerrain",value:function(){if(this._elevation&&"globe"!==this.projection.name){var t=this._elevation;this._updateCameraState();var r=e.bD(1,this._center.lat)*this.worldSize,i=this._computeCameraPosition(r),n=this._camera.forward(),a=e.bD(1,this._center.lat);i[2]/=a,n[2]/=a,e.a6.vec3.normalize(n,n);var o=t.raycast(i,n,t.exaggeration());if(o){var s=e.a6.vec3.scaleAndAdd([],i,n,o),l=new e.a5(s[0],s[1],e.bD(s[2],e.aM(s[1]))),u=(l.z+e.a6.vec3.length([l.x-i[0],l.y-i[1],l.z-i[2]*a]))*this._pixelsPerMercatorPixel;this._seaLevelZoom=this._zoomFromMercatorZ(u),this._centerAltitude=l.toAltitude(),this._center=this.coordinateLocation(l),this._updateZoomFromElevation(),this._constrain(),this._calcMatrices()}}}},{key:"_constrainCamera",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this._elevation){var r=this._elevation,i=e.bD(1,this._center.lat)*this.worldSize,n=this._computeCameraPosition(i),a=r.getAtPointOrZero(c(e.a5,d(n))),o=this.pixelsPerMeter/this.worldSize*a,s=this._minimumHeightOverTerrain(),l=n[2]-o;if(l<=s)if(l<0||t){var u=this.locationCoordinate(this._center,this._centerAltitude),h=[n[0],n[1],u.z-n[2]],f=e.a6.vec3.length(h);h[2]-=(s-l)/this._pixelsPerMercatorPixel;var p=e.a6.vec3.length(h);if(0===p)return;e.a6.vec3.scale(h,h,f/p*this._pixelsPerMercatorPixel),this._camera.position=[n[0],n[1],u.z*this._pixelsPerMercatorPixel-h[2]],this._updateStateFromCamera()}else this._isCameraConstrained=!0}}},{key:"_constrain",value:function(){if(this.center&&this.width&&this.height&&!this._constraining){this._constraining=!0;var t="globe"===this.projection.name||this.mercatorFromTransition;if(this.projection.isReprojectedInTileSpace||t){var r=this.center;return r.lat=e.ap(r.lat,this.minLat,this.maxLat),(this.maxBounds||!this.renderWorldCopies&&!t)&&(r.lng=e.ap(r.lng,this.minLng,this.maxLng)),this.center=r,void(this._constraining=!1)}var i=this._unmodified,n=this.point,a=n.x,o=n.y,s=0,l=a,u=o,c=this.width/2,h=this.height/2,f=this.worldMinY*this.scale,d=this.worldMaxY*this.scale;if(o-hd&&(u=d-h),d-fm&&(l=m-c),m-p=15?1:this.pitch/15))}else a=l;var d=e.a6.mat4.mul([],l,s),p=e.a6.mat4.mul([],a,s);if(this.projection.isReprojectedInTileSpace){var m=this.locationCoordinate(this.center),v=e.a6.mat4.identity([]);e.a6.mat4.translate(v,v,[m.x*this.worldSize,m.y*this.worldSize,0]),e.a6.mat4.multiply(v,v,e.bY(this)),e.a6.mat4.translate(v,v,[-m.x*this.worldSize,-m.y*this.worldSize,0]),e.a6.mat4.multiply(p,p,v),e.a6.mat4.multiply(d,d,v),this.inverseAdjustmentMatrix=e.bZ(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];if(this.mercatorMatrix=e.a6.mat4.scale([],p,[this.worldSize,this.worldSize,this.worldSize/o,1]),this.projMatrix=p,this.invProjMatrix=e.a6.mat4.invert(new Float64Array(16),this.projMatrix),r){var _=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);_[8]=2*-t.x/this.width,_[9]=2*t.y/this.height,this.expandedFarZProjMatrix=e.a6.mat4.mul([],_,s)}else this.expandedFarZProjMatrix=this.projMatrix;var y=e.a6.mat4.invert([],a);this.frustumCorners=e.b_.fromInvProjectionMatrix(y,this.horizonLineFromTop(),this.height),this.cameraFrustum=e.bN.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!r);var g=new Float32Array(16);e.a6.mat4.identity(g),e.a6.mat4.scale(g,g,[1,-1,1]),e.a6.mat4.rotateX(g,g,this._pitch),e.a6.mat4.rotateZ(g,g,this.angle);var x=e.a6.mat4.perspective(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ);this.starsProjMatrix=e.a6.mat4.clone(x);var b=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;x[8]=2*-t.x/this.width,x[9]=2*(t.y+b)/this.height,this.skyboxMatrix=e.a6.mat4.multiply(g,x,g);var w=this.point,k=w.x,T=w.y,M=this.width%2/2,S=this.height%2/2,E=Math.cos(this.angle),I=Math.sin(this.angle),A=k-Math.round(k)+E*M+I*S,C=T-Math.round(T)+E*S+I*M,P=new Float64Array(p);if(e.a6.mat4.translate(P,P,[A>.5?A-1:A,C>.5?C-1:C,0]),this.alignedProjMatrix=P,p=e.a6.mat4.create(),e.a6.mat4.scale(p,p,[this.width/2,-this.height/2,1]),e.a6.mat4.translate(p,p,[1,-1,0]),this.labelPlaneMatrix=p,p=e.a6.mat4.create(),e.a6.mat4.scale(p,p,[1,-1,1]),e.a6.mat4.translate(p,p,[-1,-1,0]),e.a6.mat4.scale(p,p,[2/this.width,2/this.height,1]),this.glCoordMatrix=p,this.pixelMatrix=e.a6.mat4.multiply(new Float64Array(16),this.labelPlaneMatrix,d),this._calcFogMatrices(),this._distanceTileDataCache={},!(p=e.a6.mat4.invert(new Float64Array(16),this.pixelMatrix)))throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=p,"globe"===this.projection.name||this.mercatorFromTransition){this.globeMatrix=e.b$(this);var z=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=e.a6.vec3.transformMat4(z,z,s),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=p;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={}}}},{key:"_calcFogMatrices",value:function(){this._fogTileMatrixCache={};var t=this.cameraWorldSizeForFog,r=this.cameraPixelsPerMeter,i=this._camera.position,n=1/this.height/this._pixelsPerMercatorPixel,a=[t,t,r];e.a6.vec3.scale(a,a,n),e.a6.vec3.scale(i,i,-1),e.a6.vec3.multiply(i,i,a);var o=e.a6.mat4.create();e.a6.mat4.translate(o,o,i),e.a6.mat4.scale(o,o,a),this.mercatorFogMatrix=o,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(t,r,n)}},{key:"_computeCameraPosition",value:function(e){var t=(e=e||this.pixelsPerMeter)/this.pixelsPerMeter,r=this._camera.forward(),i=this.point,n=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*t-e/this.worldSize*this._centerAltitude;return[i.x/this.worldSize-r[0]*n,i.y/this.worldSize-r[1]*n,e/this.worldSize*this._centerAltitude-r[2]*n]}},{key:"_updateCameraState",value:function(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}},{key:"_translateCameraConstrained",value:function(t){var r=this._maxCameraBoundsDistance()*Math.cos(this._pitch),i=this._camera.position[2],n=t[2],a=1;this.projection.wrap&&(this.center=this.center.wrap()),n>0&&(a=Math.min((r-i)/n,1)),this._camera.position=e.a6.vec3.scaleAndAdd([],this._camera.position,t,a),this._updateStateFromCamera()}},{key:"_updateStateFromCamera",value:function(){var t=this._camera.position,r=this._camera.forward(),i=this._camera.getPitchBearing(),n=i.pitch,a=i.bearing,o=e.bD(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,s=this._mercatorZfromZoom(this._maxZoom)*Math.cos(e.bB(this._maxPitch)),l=Math.max((t[2]-o)/Math.cos(n),s),u=this._zoomFromMercatorZ(l);e.a6.vec3.scaleAndAdd(t,t,r,l),this._pitch=e.ap(n,e.bB(this.minPitch),e.bB(this.maxPitch)),this.angle=e.bA(a,-Math.PI,Math.PI),this._setZoom(e.ap(u,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()}},{key:"_worldSizeFromZoom",value:function(e){return Math.pow(2,e)*this.tileSize}},{key:"_mercatorZfromZoom",value:function(e){return this.cameraToCenterDistance/this._worldSizeFromZoom(e)}},{key:"_minimumHeightOverTerrain",value:function(){var e=Math.min(null!=this._seaLevelZoom?this._seaLevelZoom:this._zoom,this._maxZoom)+4;return this._mercatorZfromZoom(e)}},{key:"_zoomFromMercatorZ",value:function(e){return this.scaleZoom(this.cameraToCenterDistance/(e*this.tileSize))}},{key:"zoomFromMercatorZAdjusted",value:function(t){for(var r=0,i=e.bU,n=0,a=1/0;i-r>1e-6&&i>r;){var o=r+.5*(i-r),s=this.tileSize*Math.pow(2,o),l=this.getCameraToCenterDistance(this.projection,o,s),u=this.scaleZoom(l/(t*this.tileSize)),c=Math.abs(o-u);cu||f.y>1)return!0}return!1}},{key:"isHorizonVisible",value:function(){return this.pitch+e.c0(this.fovAboveCenter)>88||this.anyCornerOffEdge(new e.P(0,0),new e.P(this.width,this.height))}},{key:"zoomDeltaToMovement",value:function(t,r){var i=e.a6.vec3.length(e.a6.vec3.sub([],this._camera.position,t)),n=this._zoomFromMercatorZ(i)+r;return i-this._mercatorZfromZoom(n)}},{key:"getCameraPoint",value:function(){if("globe"===this.projection.name){var t=(function(t,r){var i=x(t,3),n=[i[0],i[1],i[2],1];e.a6.vec4.transformMat4(n,n,r);var a=n[3]=Math.max(n[3],1e-6);return n[0]/=a,n[1]/=a,n[2]/=a,n})([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new e.P(t[0],t[1])}var r=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new e.P(0,r))}},{key:"getCameraToCenterDistance",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.zoom,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.worldSize,n=e.bX(t,r,this.width,this.height,1024),a=t.pixelSpaceConversion(this.center.lat,i,n),o=.5/Math.tan(.5*this._fov)*this.height*a;return this.isOrthographic&&(o=xi(1,o,bi(this.pitch>=15?1:this.pitch/15))),o}},{key:"getWorldToCameraMatrix",value:function(){var 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}},{key:"getFrustum",value:function(t){return e.bN.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,t,"meters"===this.projection.zAxisUnit)}}])})(),ki=function(t,r){if(r>0&&t.terrain&&e.w("Cutoff is currently disabled on terrain"),r<=0||t.terrain)return{shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};var i,n=t.transform,a=Math.max(Math.abs(n._zoom-(t.minCutoffZoom-1)),1),o=n.isLODDisabled(!1)?e.a7(60,45,n.pitch):e.a7(30,15,n.pitch),s=n._farZ-n._nearZ,l=r*n.height,u=((1-(i=o))*n.cameraToCenterDistance+i*(n._farZ+l))*a;return{shouldRenderCutoff:o<1,uniformValues:{u_cutoff_params:[n._nearZ,n._farZ,(u-n._nearZ)/s,(u-l-n._nearZ)/s]}}},Ti={cascadeCount:2,normalOffset:3,shadowMapResolution:2048},Mi=m((function e(t,r){p(this,e),this.aabb=t,this.lastCascade=r})),Si=(function(){return m((function e(){p(this,e)}),[{key:"add",value:function(e,t){var r=this.receivers[e.key];void 0!==r?(r.aabb.min[0]=Math.min(r.aabb.min[0],t.min[0]),r.aabb.min[1]=Math.min(r.aabb.min[1],t.min[1]),r.aabb.min[2]=Math.min(r.aabb.min[2],t.min[2]),r.aabb.max[0]=Math.max(r.aabb.max[0],t.max[0]),r.aabb.max[1]=Math.max(r.aabb.max[1],t.max[1]),r.aabb.max[2]=Math.max(r.aabb.max[2],t.max[2])):this.receivers[e.key]=new Mi(t,null)}},{key:"clear",value:function(){this.receivers={}}},{key:"get",value:function(e){return this.receivers[e.key]}},{key:"computeRequiredCascades",value:function(t,r,i){var n=e.c9.fromPoints(t.points),a=0;for(var o in this.receivers){var s=this.receivers[o];if(s&&n.intersectsAabb(s.aabb)){s.aabb.min=n.closestPoint(s.aabb.min),s.aabb.max=n.closestPoint(s.aabb.max);for(var l=s.aabb.getCorners(),u=0;u1||f[1]<-1||f[1]>1){c=!1;break}}if(s.lastCascade=u,a=Math.max(a,u),c)break}}}return a+1}}])})(),Ei=(function(){return m((function e(t){var r=this;p(this,e),this.painter=t,this._enabled=!1,this._shadowLayerCount=0,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new Si,this._depthMode=new ti(t.context.gl.LEQUAL,ti.ReadWrite,[0,1]),this._uniformValues={u_light_matrix_0:new Float32Array(16),u_light_matrix_1:new Float32Array(16),u_shadow_intensity:0,u_fade_range:[0,0],u_shadow_normal_offset:[1,1,1],u_shadow_texel_size:1,u_shadow_map_resolution:1,u_shadow_direction:[0,0,1],u_shadow_bias:[36e-5,.0012,.012],u_shadowmap_0:0,u_shadowmap_1:0},this._forceDisable=!1,this.useNormalOffset=!1,t.tp.registerParameter(this,["Shadows"],"_forceDisable",{label:"forceDisable"},(function(){r.painter.style.map.triggerRepaint()})),t.tp.registerParameter(Ti,["Shadows"],"cascadeCount",{min:1,max:2,step:1}),t.tp.registerParameter(Ti,["Shadows"],"normalOffset",{min:0,max:10,step:.05}),t.tp.registerParameter(Ti,["Shadows"],"shadowMapResolution",{min:32,max:2048,step:32}),t.tp.registerBinding(this,["Shadows"],"_numCascadesToRender",{readonly:!0,label:"numCascadesToRender"})}),[{key:"destroy",value:function(){for(var e of this._cascades)e.texture.destroy(),e.framebuffer.destroy();this._cascades=[]}},{key:"updateShadowParameters",value:function(t,r){var i=this.painter;if(this._enabled=!1,this._shadowLayerCount=0,this._receivers.clear(),r&&r.properties){var n=r.properties.get("shadow-intensity");if(r.shadowsEnabled()&&!(n<=0)&&(this._shadowLayerCount=i.style.order.reduce((function(e,r){var n=i.style._mergedLayers[r];return e+(n.hasShadowPass()&&!n.isHidden(t.zoom)?1:0)}),0),this._enabled=this._shadowLayerCount>0,this.enabled)){var a=i.context,o=Ti.shadowMapResolution,s=Ti.shadowMapResolution;if(0===this._cascades.length||Ti.shadowMapResolution!==this._cascades[0].texture.size[0]){this._cascades=[];for(var l=0;l3&&void 0!==arguments[3]?arguments[3]:0;if(this.enabled){for(var a=this.painter.transform,o=this.painter.context,s=o.gl,l=this._uniformValues,u=new Float64Array(16),c=a.calculatePosMatrix(t,a.worldSize),h=0;h2&&void 0!==arguments[2]&&arguments[2];if(this.enabled){for(var n=this.painter.context,a=n.gl,o=this._uniformValues,s=new Float64Array(16),l=0;l=0)return{};var a=(function(t,r,i){var n=i/(1<0&&(e.a6.vec3.add(a[1],a[1],[n[0]*o,0,0]),e.a6.vec3.add(a[2],a[2],[n[0]*o,0,0])),n[1]<0?(e.a6.vec3.add(a[0],a[0],[0,n[1]*o,0]),e.a6.vec3.add(a[1],a[1],[0,n[1]*o,0])):n[1]>0&&(e.a6.vec3.add(a[2],a[2],[0,n[1]*o,0]),e.a6.vec3.add(a[3],a[3],[0,n[1]*o,0]));var s={};return s.vertices=a,s.planes=[Ii(a[1],a[0],a[4]),Ii(a[2],a[1],a[5]),Ii(a[3],a[2],a[6]),Ii(a[0],a[3],a[7])],s}},{key:"addShadowReceiver",value:function(t,r,i){this._receivers.add(t,e.c9.fromTileIdAndHeight(t,r,i))}},{key:"getMaxCascadeForTile",value:function(e){var t=this._receivers.get(e);return t&&t.lastCascade?t.lastCascade:0}}])})();function Ii(t,r,i){var n=e.a6.vec3.sub([],i,r),a=e.a6.vec3.sub([],t,r),o=e.a6.vec3.cross([],n,a),s=e.a6.vec3.length(o);return 0===s?[0,0,1,0]:(e.a6.vec3.scale(o,o,1/s),[o[0],o[1],o[2],-e.a6.vec3.dot(o,r)])}function Ai(t){var r=t.properties.get("direction"),i=e.c7(r.x,r.y,r.z);i[2]=e.ap(i[2],0,75);var n=e.ca([i[0],i[1],i[2]]);return e.a6.vec3.fromValues(n.x,n.y,n.z)}function Ci(t,r,i){var n=r.properties.get("color"),a=r.properties.get("intensity"),o=r.properties.get("direction"),s=[o.x,o.y,o.z],l=i.properties.get("color"),u=i.properties.get("intensity"),c=Math.max(e.a6.vec3.dot([0,0,1],s),0),h=[0,0,0];e.a6.vec3.scale(h,l.toRenderColor(t.getLut(r.scope)).toArray01Linear().slice(0,3),u);var f=[0,0,0];return e.a6.vec3.scale(f,n.toRenderColor(t.getLut(i.scope)).toArray01Linear().slice(0,3),c*a),e.cb([h[0]>0?h[0]/(h[0]+f[0]):0,h[1]>0?h[1]/(h[1]+f[1]):0,h[2]>0?h[2]/(h[2]+f[2]):0])}function Pi(t,r,i,n,a,o){var s,l,u=t.zoom,c=t.scale,h=t.worldSize,f=1/h,d=t.aspect,p=Math.sqrt(1+d*d)*Math.tan(.5*t.fovX),m=p*p,v=n-i,_=n+i;m>v/_?(s=n,l=n*p):(s=.5*_*(1+m),l=.5*Math.sqrt(v*v+2*(n*n+i*i)*m+_*_*m*m));var y=t.projection.pixelsPerMeter(t.center.lat,h),g=t._camera.getCameraToWorldMercator(),x=[0,0,-s*f];e.a6.vec3.transformMat4(x,x,g);var b,w=l*f,k=t._edgeInsets;if(!(0===k.left&&0===k.top&&0===k.right&&0===k.bottom||k.left===k.right&&k.top===k.bottom)){var T=t._camera.getWorldToCamera(t.worldSize,"meters"===t.projection.zAxisUnit?y:1),M=t._camera.getCameraToClipPerspective(t._fov,t.width/t.height,i,n);M[8]=2*-t.centerOffset.x/t.width,M[9]=2*t.centerOffset.y/t.height;var S=new Float64Array(16);e.a6.mat4.mul(S,M,T);var E=new Float64Array(16);e.a6.mat4.invert(E,S);var I=e.bN.fromInvProjectionMatrix(E,h,u,!0);for(var A of I.points){var C=((b=A)[0]/=c,b[1]/=c,b[2]=e.bD(b[2],t._center.lat),b);w=Math.max(w,e.a6.vec3.len(e.a6.vec3.subtract([],x,C)))}}w*=a/(a-1);var P=Math.acos(r[2]),z=Math.atan2(-r[0],-r[1]),D=new hi;D.position=x,D.setPitchBearing(P,z);var R=D.getWorldToCamera(h,y),L=w*h,O=Math.min(t._mercatorZfromZoom(17)*h*-2,-2*L),B=D.getCameraToClipOrthographic(-L,L,-L,L,O,(L+o*y)/r[2]),F=new Float64Array(16);e.a6.mat4.multiply(F,B,R);var N=e.a6.vec3.fromValues(Math.floor(1e6*x[0])/1e6*h,Math.floor(1e6*x[1])/1e6*h,0),V=.5*a,U=[0,0,0];e.a6.vec3.transformMat4(U,N,F),e.a6.vec3.scale(U,U,V);var j=[Math.floor(U[0]),Math.floor(U[1]),Math.floor(U[2])],G=[0,0,0];e.a6.vec3.sub(G,U,j),e.a6.vec3.scale(G,G,-1/V);var q=new Float64Array(16);return e.a6.mat4.identity(q),e.a6.mat4.translate(q,q,G),e.a6.mat4.multiply(F,q,F),[F,L]}var zi=(function(t){function r(e){var t;return p(this,r),(t=T(this,r)).requestManager=e,t.models={"":{}},t.numModelsLoading={},t}return y(r,t),m(r,[{key:"loadModel",value:function(t,r){var i=this;return e.aG(this.requestManager.transformRequest(r,e.R.Model).url).then((function(r){if(r){var i=e.aH(r),n=new e.aI(t,void 0,void 0,i);return n.computeBoundsAndApplyParent(),n}})).catch((function(n){if(n&&404===n.status)return null;i.fire(new e.t(new Error(`Could not load model ${t} from ${r}: ${n.message}`)))}))}},{key:"load",value:function(t,r){var i=this;this.models[r]||(this.models[r]={});var n=Object.keys(t);this.numModelsLoading[r]=(this.numModelsLoading[r]||0)+n.length;var a=[];for(var o of n)a.push(this.loadModel(o,t[o]));Promise.allSettled(a).then((function(t){for(var a=0;a0)return!1;return!0}},{key:"hasModel",value:function(e,t){return!!this.getModel(e,t)}},{key:"getModel",value:function(e,t){return this.models[t]||(this.models[t]={}),this.models[t][e]?this.models[t][e].model:void 0}},{key:"addModel",value:function(e,t,r){this.models[r]||(this.models[r]={}),this.hasModel(e,r)&&this.models[r][e].numReferences++,this.load(s({},e,this.requestManager.normalizeModelURL(t)),r)}},{key:"addModels",value:function(e,t){this.models[t]||(this.models[t]={});var r={};for(var i in e)this.models[t][i]={},r[i]=this.requestManager.normalizeModelURL(e[i]);this.load(r,t)}},{key:"addModelsFromBucket",value:function(e,t){this.models[t]||(this.models[t]={});var r={};for(var i of e)this.hasModel(i,t)?this.models[t][i].numReferences++:r[i]=this.requestManager.normalizeModelURL(i);this.load(r,t)}},{key:"removeModel",value:function(e,t){if(this.models[t]&&this.models[t][e]&&(this.models[t][e].numReferences--,0===this.models[t][e].numReferences)){var r=this.models[t][e].model;delete this.models[t][e],r.destroy()}}},{key:"listModels",value:function(e){return this.models[e]||(this.models[e]={}),Object.keys(this.models[e])}},{key:"upload",value:function(e,t){for(var r in this.models[t]||(this.models[t]={}),this.models[t])this.models[t][r].model&&this.models[t][r].model.upload(e.context)}}])})(e.E),Di=new e.a0({data:new e.a1(e._.colorTheme.data)}),Ri=function(e,t){return je(e,t&&t.filter((function(e){return"source.canvas"!==e.identifier})))},Li=e.ar(Ht,["addLayer","removeLayer","setLights","setPaintProperty","setLayoutProperty","setSlot","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection","setCamera","addImport","removeImport","updateImport"]),Oi=e.ar(Ht,["setCenter","setZoom","setBearing","setPitch"]),Bi={version:8,layers:[],sources:{}},Fi={duration:300,delay:0},Ni=(function(t){function r(t){var i,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};p(this,r),(i=T(this,r)).map=t,i.scope=n.scope||"",i.globalId=null,i.fragments=[],i.importDepth=n.importDepth||0,i.importsCache=n.importsCache||new Map,i.resolvedImports=n.resolvedImports||new Set,i.transition=e.l({},Fi),i._buildingIndex=new qt(l(i)),i.crossTileSymbolIndex=new Kr,i._mergedOrder=[],i._drapedFirstOrder=[],i._mergedLayers={},i._mergedSourceCaches={},i._mergedOtherSourceCaches={},i._mergedSymbolSourceCaches={},i._clipLayerPresent=!1,i._has3DLayers=!1,i._hasCircleLayers=!1,i._hasSymbolLayers=!1,i._changes=n.styleChanges||new te,i.dispatcher=n.dispatcher?n.dispatcher:new e.cd(e.ce(),l(i)),n.imageManager?i.imageManager=n.imageManager:(i.imageManager=new ie,i.imageManager.setEventedParent(l(i))),i.imageManager.createScope(i.scope),i.glyphManager=n.glyphManager?n.glyphManager:new e.cf(t._requestManager,n.localFontFamily?e.cg.all:n.localIdeographFontFamily?e.cg.ideographs:e.cg.none,n.localFontFamily||n.localIdeographFontFamily),n.modelManager?i.modelManager=n.modelManager:(i.modelManager=new zi(t._requestManager),i.modelManager.setEventedParent(l(i))),i._layers={},i._serializedLayers={},i._sourceCaches={},i._otherSourceCaches={},i._symbolSourceCaches={},i._loaded=!1,i._precompileDone=!1,i._shouldPrecompile=!1,i._availableImages=[],i._order=[],i._markersNeedUpdate=!1,i._styleColorTheme={lut:null,lutLoading:!1,lutLoadingCorrelationID:0,colorTheme:null},i._styleColorThemeForScope={},i.options=n.configOptions?n.configOptions:new Map,i._configDependentLayers=n.configDependentLayers?n.configDependentLayers:new Set,i._config=n.config,i._initialConfig=n.initialConfig,i.dispatcher.broadcast("setReferrer",e.ch());var a=i;return i._rtlTextPluginCallback=r.registerForPluginStateChange((function(t){a.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:t.pluginStatus,pluginURL:t.pluginURL},(function(t,r){if(e.ci(t),r&&r.every((function(e){return e})))for(var i in a._sourceCaches){var n=a._sourceCaches[i],o=n.getSource().type;"vector"!==o&&"geojson"!==o||n.reload()}}))})),i.on("data",(function(e){if("source"===e.dataType&&"metadata"===e.sourceDataType){var t=i.getOwnSource(e.sourceId);if(t&&t.vectorLayerIds)for(var r in i._layers){var n=i._layers[r];n.source===t.id&&i._validateLayer(n)}}})),i}return y(r,t),m(r,[{key:"load",value:function(e){return e?("string"==typeof e?this.loadURL(e):this.loadJSON(e),this):this}},{key:"_getGlobalId",value:function(t){if(!t)return null;if("string"==typeof t){if(e.f(t))return t;var r=e.cj(t);if(!r.startsWith("http"))try{return new URL(r,location.href).toString()}catch(e){return r}return r}return`json://${e.ck(JSON.stringify(t))}`}},{key:"_diffStyle",value:function(t,r,i){var n=this;this.globalId=this._getGlobalId(t);var a=function(e,t){try{t(null,n.setState(e,i))}catch(e){t(e,!1)}};if("string"==typeof t){var o=this.map._requestManager.normalizeStyleURL(t),s=this.map._requestManager.transformRequest(o,e.R.Style);e.n(s,(function(t,i){t?n.fire(new e.t(t)):i&&a(i,r)}))}else"object"==typeof t&&a(t,r)}},{key:"loadURL",value:function(t){var r=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.fire(new e.x("dataloading",{dataType:"style"}));var n="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);var a=this.importsCache.get(t);if(a)return this._load(a,n);var o=this.map._requestManager.transformRequest(t,e.R.Style);this._request=e.n(o,(function(i,a){if(r._request=null,i)r.fire(new e.t(i));else if(a)return r.importsCache.set(t,a),r._load(a,n)}))}},{key:"loadJSON",value:function(t){var r=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.fire(new e.x("dataloading",{dataType:"style"})),this.globalId=this._getGlobalId(t),this._request=e.q.frame((function(){r._request=null,r._load(t,!1!==i.validate)}))}},{key:"loadEmpty",value:function(){this.fire(new e.x("dataloading",{dataType:"style"})),this._load(Bi,!1)}},{key:"_loadImports",value:function(t,r,i){var n=this;if(this.importDepth>=4)return e.w("Style doesn't support nesting deeper than 5"),Promise.resolve();var a=[],o=function(){var e=n._createFragmentStyle(s),t=new Promise((function(t){e.once("style.import.load",t),e.once("error",t)})).then((function(){return n.mergeAll()}));if(a.push(t),n.resolvedImports.has(s.url))return e.loadEmpty(),1;var o=s.data||n.importsCache.get(s.url);o?(e.loadJSON(o,{validate:r}),n._isInternalStyle(o)&&(e.globalId=null)):s.url?e.loadURL(s.url,{validate:r}):e.loadEmpty();var l={style:e,id:s.id,config:s.config};if(i){var u=n.fragments.findIndex((function(e){return e.id===i}));n.fragments=n.fragments.slice(0,u).concat(l).concat(n.fragments.slice(u))}else n.fragments.push(l)};for(var s of t)o();return Promise.allSettled(a)}},{key:"getImportGlobalIds",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Set;for(var r of e.fragments)r.style.globalId&&t.add(r.style.globalId),this.getImportGlobalIds(r.style,t);return d(t.values())}},{key:"_createFragmentStyle",value:function(t){var i,n=this.scope?e.av(t.id,this.scope):t.id,a=this._initialConfig&&this._initialConfig[n];(t.config||a)&&(i=e.l({},t.config,a));var o=new r(this.map,{scope:n,styleChanges:this._changes,importDepth:this.importDepth+1,importsCache:this.importsCache,resolvedImports:new Set(this.resolvedImports),dispatcher:this.dispatcher,imageManager:this.imageManager,glyphManager:this.glyphManager,modelManager:this.modelManager,config:i,configOptions:this.options,configDependentLayers:this._configDependentLayers});return o.setEventedParent(this.map,{style:o}),o}},{key:"_reloadImports",value:function(){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()}},{key:"_isInternalStyle",value:function(e){return this.isRootStyle()&&(e.fragment||!!e.schema&&!1!==e.fragment)}},{key:"_load",value:function(t,r){var i=this,n=t.schema;if(this._isInternalStyle(t)){var a=e.l({},Bi,{imports:[{id:"basemap",data:t,url:""}]});this._load(a,r)}else if(this.updateConfig(this._config,n),!r||!Ri(this,Ae(t))){this._loaded=!0,this.stylesheet=e.cl(t);var o=function(){for(var n in t.sources)i.addSource(n,t.sources[n],{validate:!1,isInitialLoad:!0});t.sprite?i._loadSprite(t.sprite):(i.imageManager.setLoaded(!0,i.scope),i.dispatcher.broadcast("spriteLoaded",{scope:i.scope,isLoaded:!0})),i.glyphManager.setURL(t.glyphs,i.scope);var a=$t(i.stylesheet.layers);if(i._order=a.map((function(e){return e.id})),i.stylesheet.light&&e.w("The `light` root property is deprecated, prefer using `lights` with `flat` light type instead."),i.stylesheet.lights)if(1===i.stylesheet.lights.length&&"flat"===i.stylesheet.lights[0].type){var o=i.stylesheet.lights[0];i.light=new Ge(o.properties,o.id)}else i.setLights(i.stylesheet.lights);for(var s of(i.light||(i.light=new Ge(i.stylesheet.light)),i._layers={},i._serializedLayers={},a)){var l=e.cq(s,i.scope,i._styleColorTheme.lut,i.options);0!==l.configDependencies.size&&i._configDependentLayers.add(l.fqid),l.setEventedParent(i,{layer:{id:l.id}}),i._layers[l.id]=l,i._serializedLayers[l.id]=l.serialize();var u=i.getOwnLayerSourceCache(l),c=!!i.directionalLight&&i.directionalLight.shadowsEnabled();u&&l.canCastShadows()&&c&&(u.castsShadows=!0)}i.stylesheet.models&&i.modelManager.addModels(i.stylesheet.models,i.scope);var h=i.stylesheet.terrain;h&&(i.checkCanvasFingerprintNoise(),i.disableElevatedTerrain||i.terrainSetForDrapingOnly()||i._createTerrain(h,1)),i.stylesheet.fog&&i._createFog(i.stylesheet.fog),i.stylesheet.transition&&i.setTransition(i.stylesheet.transition),i.fire(new e.x("data",{dataType:"style"}));var f=i.isRootStyle();t.imports?i._loadImports(t.imports,r).then((function(){i._reloadImports(),i.fire(new e.x(f?"style.load":"style.import.load"))})):(i._reloadImports(),i.fire(new e.x(f?"style.load":"style.import.load")))},s=this.stylesheet["color-theme"];if(this._styleColorTheme.colorTheme=s,s){var l=this._evaluateColorThemeData(s);this._loadColorTheme(l).then((function(){o()})).catch((function(t){e.w(`Couldn't load color theme from the stylesheet: ${t}`),o()}))}else this._styleColorTheme.lut=null,o()}}},{key:"isRootStyle",value:function(){return 0===this.importDepth}},{key:"mergeAll",value:function(){var t,r,i,n,a,o,s,l,u=this,c={};this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle((function(e){if(e.stylesheet){if(null!=e.light&&(t=e.light),e.stylesheet.lights)for(var h of e.stylesheet.lights)"ambient"===h.type&&null!=e.ambientLight&&(r=e.ambientLight),"directional"===h.type&&null!=e.directionalLight&&(i=e.directionalLight);n=u._prioritizeTerrain(n,e.terrain,e.stylesheet.terrain),e.stylesheet.fog&&null!=e.fog&&(a=e.fog),null!=e.stylesheet.camera&&(l=e.stylesheet.camera),null!=e.stylesheet.projection&&(o=e.stylesheet.projection),null!=e.stylesheet.transition&&(s=e.stylesheet.transition),c[e.scope]=e._styleColorTheme}})),this.light=t,this.ambientLight=r,this.directionalLight=i,this.fog=a,this._styleColorThemeForScope=c,null===n?delete this.terrain:this.terrain=n,this.camera=l||{"camera-projection":"perspective"},this.projection=o||{name:"mercator"},this.transition=e.l({},Fi,s),this.mergeSources(),this.mergeLayers()}},{key:"forEachFragmentStyle",value:function(e){var t=function(r){for(var i of r.fragments)t(i.style);e(r)};t(this)}},{key:"_prioritizeTerrain",value:function(e,t,r){var i=e&&0===e.drapeRenderMode;return null===r?t&&0===t.drapeRenderMode?t:i?e:null:null!=t&&(!e||i||t&&1===t.drapeRenderMode)?t:e}},{key:"mergeTerrain",value:function(){var e,t=this;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle((function(r){e=t._prioritizeTerrain(e,r.terrain,r.stylesheet.terrain)})),null===e?delete this.terrain:this.terrain=e}},{key:"mergeProjection",value:function(){var e;this.forEachFragmentStyle((function(t){null!=t.stylesheet.projection&&(e=t.stylesheet.projection)})),this.projection=e||{name:"mercator"}}},{key:"mergeSources",value:function(){var t={},r={},i={};this.forEachFragmentStyle((function(n){for(var a in n._sourceCaches){var o=e.av(a,n.scope);t[o]=n._sourceCaches[a]}for(var s in n._otherSourceCaches){var l=e.av(s,n.scope);r[l]=n._otherSourceCaches[s]}for(var u in n._symbolSourceCaches){var c=e.av(u,n.scope);i[c]=n._symbolSourceCaches[u]}})),this._mergedSourceCaches=t,this._mergedOtherSourceCaches=r,this._mergedSymbolSourceCaches=i}},{key:"mergeLayers",value:function(){var t=this,r={},i=[],n={};this._mergedSlots=[],this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle((function(t){for(var n of t._order){var a=t._layers[n];if("slot"===a.type){var o=e.cm(n);if(r[o])continue;r[o]=[]}a.slot&&r[a.slot]?r[a.slot].push(a):i.push(a)}})),this._mergedOrder=[];var a=function(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];for(var o of i)if("slot"===o.type){var s=e.cm(o.id);r[s]&&a(r[s]),t._mergedSlots.push(s)}else{var l=e.av(o.id,o.scope);t._mergedOrder.push(l),n[l]=o,o.is3D()&&(t._has3DLayers=!0),"circle"===o.type&&(t._hasCircleLayers=!0),"symbol"===o.type&&(t._hasSymbolLayers=!0),"clip"===o.type&&(t._clipLayerPresent=!0)}};a(i),this._mergedOrder.sort((function(e,t){var r=n[e],i=n[t];return r.hasInitialOcclusionOpacityProperties?i.is3D()?1:0:r.is3D()&&i.hasInitialOcclusionOpacityProperties?-1:0})),this._mergedLayers=n,this.updateDrapeFirstLayers(),this._buildingIndex.processLayersChanged()}},{key:"terrainSetForDrapingOnly",value:function(){return!!this.terrain&&0===this.terrain.drapeRenderMode}},{key:"getCamera",value:function(){return this.stylesheet.camera}},{key:"setCamera",value:function(t){return this.stylesheet.camera=e.l({},this.stylesheet.camera,t),this.camera=this.stylesheet.camera,this}},{key:"_evaluateColorThemeData",value:function(t){return t.data?(function(t,r,i){var n=e.l({},r);for(var a of Object.keys(e._.colorTheme))void 0===n[a]&&(n[a]=e._.colorTheme[a].default);var o=new e.$(Di,t,new Map(i));return o.setTransitionOrValue(n,i),o.untransitioned().possiblyEvaluate(new e.a3(0))})(this.scope,t,this.options).get("data"):null}},{key:"_loadColorTheme",value:function(t){var r=this;this._styleColorTheme.lutLoading=!0,this._styleColorTheme.lutLoadingCorrelationID+=1;var i=this._styleColorTheme.lutLoadingCorrelationID;return new Promise((function(n,a){var o="data:image/png;base64,";if(!t||0===t.length)return r._styleColorTheme.lut=null,r._styleColorTheme.lutLoading=!1,void n();var s=t;s.startsWith(o)||(s=o+s);var l="mapbox-reserved-lut",u=new Image;u.src=s,u.onerror=function(){r._styleColorTheme.lutLoading=!1,a(new Error("Failed to load image data"))},u.onload=function(){if(r._styleColorTheme.lutLoadingCorrelationID===i){r._styleColorTheme.lutLoading=!1;var o=e.q.getImageData(u),s=o.width,c=o.height,h=o.data;if(c>32)a(new Error("The height of the image must be less than or equal to 32 pixels."));else if(s===c*c){r.getImage(l)&&r.removeImage(l),r.addImage(l,{data:new e.r({width:s,height:c},h),pixelRatio:1,sdf:!1,version:0});var f=r.imageManager.getImage(l,r.scope);f?(r._styleColorTheme.lut={image:f.data,data:t},n()):a(new Error("Missing LUT image."))}else a(new Error("The width of the image must be equal to the height squared."))}else n()}}))}},{key:"getLut",value:function(e){var t=this._styleColorThemeForScope[e];return t?t.lut:null}},{key:"setProjection",value:function(e){e?this.stylesheet.projection=e:delete this.stylesheet.projection,this.mergeProjection(),this._updateMapProjection()}},{key:"applyProjectionUpdate",value:function(){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))}},{key:"_updateMapProjection",value:function(){this.isRootStyle()&&(this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.projection))}},{key:"_loadSprite",value:function(t){var r=this;this._spriteRequest=(function(t,r,i){var n,a,o,s=e.q.devicePixelRatio>1?"@2x":"",l=e.n(r.transformRequest(r.normalizeSpriteURL(t,s,".json"),e.R.SpriteJSON),(function(e,t){l=null,o||(o=e,n=t,c())})),u=e.o(r.transformRequest(r.normalizeSpriteURL(t,s,".png"),e.R.SpriteImage),(function(e,t){u=null,o||(o=e,a=t,c())}));function c(){if(o)i(o);else if(n&&a){var t=e.q.getImageData(a),r={};for(var s in n){var l=n[s],u=l.width,c=l.height,h=l.x,f=l.y,d=l.sdf,p=l.pixelRatio,m=l.stretchX,v=l.stretchY,_=l.content,y=new e.r({width:u,height:c});e.r.copy(t,y,{x:h,y:f},{x:0,y:0},{width:u,height:c},null),r[s]={data:y,pixelRatio:p,sdf:d,stretchX:m,stretchY:v,content:_}}i(null,r)}}return{cancel:function(){l&&(l.cancel(),l=null),u&&(u.cancel(),u=null)}}})(t,this.map._requestManager,(function(t,i){if(r._spriteRequest=null,t)r.fire(new e.t(t));else if(i)for(var n in i)r.imageManager.addImage(n,r.scope,i[n]);r.imageManager.setLoaded(!0,r.scope),r._availableImages=r.imageManager.listImages(r.scope),r.dispatcher.broadcast("setImages",{scope:r.scope,images:r._availableImages}),r.dispatcher.broadcast("spriteLoaded",{scope:r.scope,isLoaded:!0}),r.fire(new e.x("data",{dataType:"style"}))}))}},{key:"_validateLayer",value:function(t){var r=this.getOwnSource(t.source);if(r){var i=t.sourceLayer;i&&("geojson"===r.type||r.vectorLayerIds&&-1===r.vectorLayerIds.indexOf(i))&&this.fire(new e.t(new Error(`Source layer "${i}" does not exist on source "${r.id}" as specified by style layer "${t.id}"`)))}}},{key:"loaded",value:function(){if(!this._loaded)return!1;if(Object.keys(this._changes.getUpdatedSourceCaches()).length)return!1;for(var 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(var t of this.fragments){if(!t.style.loaded())return!1}return!0}},{key:"_serializeImports",value:function(){var e=this;if(this.stylesheet.imports)return this.stylesheet.imports.map((function(t,r){var i=e.fragments[r];return i&&i.style&&(t.data=i.style.serialize()),t}))}},{key:"_serializeSources",value:function(){var e={};for(var t in this._sourceCaches){var r=this._sourceCaches[t].getSource();e[r.id]||(e[r.id]=r.serialize())}return e}},{key:"_serializeLayers",value:function(e){var t=[];for(var r of e){var i=this._layers[r];i&&"custom"!==i.type&&t.push(i.serialize())}return t}},{key:"hasLightTransitions",value:function(){return!(!this.light||!this.light.hasTransition())||!(!this.ambientLight||!this.ambientLight.hasTransition())||!(!this.directionalLight||!this.directionalLight.hasTransition())}},{key:"hasFogTransition",value:function(){return!!this.fog&&this.fog.hasTransition()}},{key:"hasTransitions",value:function(){if(this.hasLightTransitions())return!0;if(this.hasFogTransition())return!0;for(var e in this._sourceCaches)if(this._sourceCaches[e].hasTransition())return!0;for(var t in this._layers)if(this._layers[t].hasTransition())return!0;return!1}},{key:"order",get:function(){return this.terrain?this._drapedFirstOrder:this._mergedOrder}},{key:"isLayerDraped",value:function(e){return!!this.terrain&&e.isDraped(this.getLayerSourceCache(e))}},{key:"_checkLoaded",value:function(){if(!this._loaded)throw new Error("Style is not done loading")}},{key:"_checkLayer",value:function(t){var r=this.getOwnLayer(t);if(r)return r;this.fire(new e.t(new Error(`The layer '${t}' does not exist in the map's style.`)))}},{key:"_checkSource",value:function(t){var r=this.getOwnSource(t);if(r)return r;this.fire(new e.t(new Error(`The source '${t}' does not exist in the map's style.`)))}},{key:"precompilePrograms",value:function(e,t){var r=this.map.painter;if(r)for(var i=e.minzoom||0;i<(e.maxzoom||25.5);i++){var n=e.getProgramIds();if(n)for(var a of n){var o=e.getDefaultProgramParams(a,t.zoom,this._styleColorTheme.lut);o&&(r.style=this,this.fog&&(r._fogVisible=!0,o.overrideFog=!0,r.getOrCreateProgram(a,o)),r._fogVisible=!1,o.overrideFog=!1,r.getOrCreateProgram(a,o),(this.stylesheet.terrain||this.stylesheet.projection&&"globe"===this.stylesheet.projection.name)&&(o.overrideRtt=!0,r.getOrCreateProgram(a,o)))}}}},{key:"update",value:function(t){var r=this;if(this._loaded){this.ambientLight&&this.ambientLight.recalculate(t),this.directionalLight&&this.directionalLight.recalculate(t);var i=this.calculateLightsBrightness();t.brightness=i||0,i!==this._brightness&&(this._brightness=i,this.dispatcher.broadcast("setBrightness",i));var n=this._changes.isDirty(),a=!1;if(this._changes.isDirty()){var o=this._changes.getLayerUpdatesByScope();for(var s in o){var l=o[s],u=l.updatedIds,c=l.removedIds;(u||c)&&(this._updateWorkerLayers(s,u,c),a=!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()}var h={};for(var f in this._mergedSourceCaches){var d=this._mergedSourceCaches[f];h[f]=d.used,d.used=!1,d.tileCoverLift=0}var p=function(){var e=r._mergedLayers[m];if(e.recalculate(t,r._availableImages),!e.isHidden(t.zoom)){var i=r.getLayerSourceCache(e);i&&(i.used=!0,i.tileCoverLift=Math.max(i.tileCoverLift,e.tileCoverLift()))}!r._precompileDone&&r._shouldPrecompile&&("requestIdleCallback"in window?requestIdleCallback((function(){r.precompilePrograms(e,t)})):r.precompilePrograms(e,t))};for(var m of this._mergedOrder)p();for(var v in this._shouldPrecompile&&(this._precompileDone=!0),this.terrain&&a&&this.mergeLayers(),h){var _=this._mergedSourceCaches[v];h[v]!==_.used&&_.getSource().fire(new e.x("data",{sourceDataType:"visibility",dataType:"source",sourceId:_.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),n&&this.fire(new e.x("data",{dataType:"style"}))}}},{key:"_updateTilesForChangedImages",value:function(){var e=this._changes.getUpdatedImages();if(e.length){for(var t in this._sourceCaches)this._sourceCaches[t].reloadTilesForDependencies(["icons","patterns"],e);this._changes.resetUpdatedImages()}}},{key:"_updateWorkerLayers",value:function(e,t,r){var i=this.getFragmentStyle(e);i&&this.dispatcher.broadcast("updateLayers",{layers:t?i._serializeLayers(t):[],scope:e,removedIds:r||[],options:i.options})}},{key:"setState",value:function(t,r){var i=this;if(this._checkLoaded(),Ri(this,Ae(t)))return!1;(t=e.cl(t)).layers=$t(t.layers);var n=(function(t,r){if(!t)return[{command:Ht.setStyle,args:[r]}];var i=[];try{if(!e.bh(t.version,r.version))return[{command:Ht.setStyle,args:[r]}];if(e.bh(t.center,r.center)||i.push({command:Ht.setCenter,args:[r.center]}),e.bh(t.zoom,r.zoom)||i.push({command:Ht.setZoom,args:[r.zoom]}),e.bh(t.bearing,r.bearing)||i.push({command:Ht.setBearing,args:[r.bearing]}),e.bh(t.pitch,r.pitch)||i.push({command:Ht.setPitch,args:[r.pitch]}),e.bh(t.sprite,r.sprite)||i.push({command:Ht.setSprite,args:[r.sprite]}),e.bh(t.glyphs,r.glyphs)||i.push({command:Ht.setGlyphs,args:[r.glyphs]}),e.bh(t.imports,r.imports)||(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=arguments.length>2?arguments[2]:void 0;r=r||[];var n,a,o,s,l=(t=t||[]).map(Qt),u=r.map(Qt),c=t.reduce(er,{}),h=r.reduce(er,{}),f=l.slice();for(n=0,a=0;n0)throw new Error(`Unimplemented: ${a.map((function(e){return e.command})).join(", ")}.`);var o=[];return n.forEach((function(e){o.push(i[e.command].apply(i,e.args))})),r&&Promise.all(o).then(r),this.stylesheet=t,this.mergeAll(),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),!0}},{key:"addImage",value:function(t,r){return this.getImage(t)?this.fire(new e.t(new Error("An image with this name already exists."))):(this.imageManager.addImage(t,this.scope,r),this._afterImageUpdated(t),this)}},{key:"updateImage",value:function(e,t){this.imageManager.updateImage(e,this.scope,t)}},{key:"getImage",value:function(e){return this.imageManager.getImage(e,this.scope)}},{key:"removeImage",value:function(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.")))}},{key:"_afterImageUpdated",value:function(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"}))}},{key:"listImages",value:function(){return this._checkLoaded(),this._availableImages.slice()}},{key:"addModel",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this._checkLoaded(),this._validate(Ve,`models.${e}`,t,null,r)||(this.modelManager.addModel(e,t,this.scope),this._changes.setDirty()),this}},{key:"hasModel",value:function(e){return this.modelManager.hasModel(e,this.scope)}},{key:"removeModel",value:function(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.")))}},{key:"listModels",value:function(){return this._checkLoaded(),this.modelManager.listModels(this.scope)}},{key:"addSource",value:function(t,r){var i=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(this._checkLoaded(),void 0!==this.getOwnSource(t))throw new Error(`There is already a source with ID "${t}".`);if(!r.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(r).join(", ")}.`);if(!(["vector","raster","geojson","video","image"].indexOf(r.type)>=0&&this._validate(Pe,`sources.${t}`,r,null,n))){this.map&&this.map._collectResourceTiming&&(r.collectResourceTiming=!0);var a=ft(t,r,this.dispatcher,this);a.scope=this.scope,a.setEventedParent(this,(function(){return{isSourceLoaded:i._isSourceCacheLoaded(a.id),source:a.serialize(),sourceId:a.id}}));var o=function(t){var r=(t?"symbol:":"other:")+a.id,n=e.av(r,i.scope),o=i._sourceCaches[r]=new Vt(n,a,t);(t?i._symbolSourceCaches:i._otherSourceCaches)[a.id]=o,o.onAdd(i.map)};o(!1),"vector"!==r.type&&"geojson"!==r.type||o(!0),a.onAdd&&a.onAdd(this.map),n.isInitialLoad||(this.mergeSources(),this._changes.setDirty())}}},{key:"removeSource",value:function(t){this._checkLoaded();var r=this.getOwnSource(t);if(!r)throw new Error("There is no source with this ID");for(var 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.`)));var n=this.getOwnSourceCaches(t);for(var a of n){var o=e.cm(a.id);delete this._sourceCaches[o],this._changes.discardSourceCacheUpdate(a.id),a.fire(new e.x("data",{sourceDataType:"metadata",dataType:"source",sourceId:a.getSource().id})),a.setEventedParent(null),a.clearTiles()}return delete this._otherSourceCaches[t],delete this._symbolSourceCaches[t],this.mergeSources(),r.setEventedParent(null),r.onRemove&&r.onRemove(this.map),this._changes.setDirty(),this}},{key:"setGeoJSONSourceData",value:function(e,t){this._checkLoaded(),this.getOwnSource(e).setData(t),this._changes.setDirty()}},{key:"getOwnSource",value:function(e){var t=this.getOwnSourceCache(e);return t&&t.getSource()}},{key:"getOwnSources",value:function(){var e=[];for(var t in this._otherSourceCaches){var r=this.getOwnSourceCache(t);r&&e.push(r.getSource())}return e}},{key:"areTilesLoaded",value:function(){var e=this._mergedSourceCaches;for(var t in e){var r=e[t]._tiles;for(var i in r){var n=r[i];if("loaded"!==n.state&&"errored"!==n.state)return!1}}return!0}},{key:"setLights",value:function(t){if(this._checkLoaded(),t){var r=this._getTransitionParameters();for(var i of t){if(this._validate(De,"lights",i))return;switch(i.type){case"ambient":if(this.ambientLight){var n=this.ambientLight;n.set(i),n.updateTransitions(r)}else this.ambientLight=new tt(i,Je||(Je=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){var a=this.directionalLight;a.set(i),a.updateTransitions(r)}else this.directionalLight=new tt(i,Ke||(Ke=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)}}var o=new e.a3(this.z||0,r);this.ambientLight&&this.ambientLight.recalculate(o),this.directionalLight&&this.directionalLight.recalculate(o),this._brightness=this.calculateLightsBrightness(),this.dispatcher.broadcast("setBrightness",this._brightness)}else delete this.ambientLight}},{key:"calculateLightsBrightness",value:function(){var t=this.directionalLight,r=this.ambientLight;if(t&&r){var i=function(e){return.2126*(e[0]<=.03928?e[0]/12.92:Math.pow((e[0]+.055)/1.055,2.4))+.7152*(e[1]<=.03928?e[1]/12.92:Math.pow((e[1]+.055)/1.055,2.4))+.0722*(e[2]<=.03928?e[2]/12.92:Math.pow((e[2]+.055)/1.055,2.4))},n=t.properties.get("color").toRenderColor(null).toArray01(),a=t.properties.get("intensity"),o=t.properties.get("direction"),s=1-e.c7(o.x,o.y,o.z)[2]/90,l=i(n)*a*s,u=r.properties.get("color").toRenderColor(null).toArray01(),c=r.properties.get("intensity");return(l+i(u)*c)/2}}},{key:"getBrightness",value:function(){return this._brightness}},{key:"getLights",value:function(){if(!this.enable3dLights())return null;var e=[];return this.directionalLight&&e.push(this.directionalLight.get()),this.ambientLight&&e.push(this.ambientLight.get()),e}},{key:"enable3dLights",value:function(){return!!this.ambientLight&&!!this.directionalLight}},{key:"getFragmentStyle",value:function(t){if(!t)return this;if(e.cn(t)){var r=e.co(t),i=this.fragments.find((function(e){return e.id===r}));if(!i)throw new Error(`Style import not found: ${t}`);var n=e.cm(t);return i.style.getFragmentStyle(n)}var a=this.fragments.find((function(e){return e.id===t}));if(!a)throw new Error(`Style import not found: ${t}`);return a.style}},{key:"getConfigProperty",value:function(t,r){var i=this.getFragmentStyle(t);if(!i)return null;var n=e.av(r,i.scope),a=i.options.get(n),o=a?a.value||a.default:null;return o?o.serialize():null}},{key:"setConfigProperty",value:function(t,r,i){var n=this.getFragmentStyle(t);if(n){var a=n.stylesheet.schema;if(a&&a[r]){var o=e.M(i);if("success"===o.result){var s=o.value.expression,l=e.av(r,n.scope),u=n.options.get(l);if(u){var c,h=a[r],f=h.minValue,d=h.maxValue,p=h.stepValue,m=h.type,v=h.values,_=e.M(a[r].default);"success"===_.result&&(c=_.value.expression),c?(this.options.set(l,Object.assign({},u,{value:s,default:c,minValue:f,maxValue:d,stepValue:p,type:m,values:v})),this.updateConfigDependencies(r)):this.fire(new e.t(new Error(`No schema defined for the config option "${r}" in the "${t}" fragment.`)))}}else Ri(this,o.value)}}}},{key:"getConfig",value:function(t){var r=this.getFragmentStyle(t);if(!r)return null;var i=r.stylesheet.schema;if(!i)return null;var n={};for(var a in i){var o=e.av(a,r.scope),s=r.options.get(o),l=s?s.value||s.default:null;n[a]=l?l.serialize():null}return n}},{key:"setConfig",value:function(e,t){var r=this.getFragmentStyle(e);r&&(r.updateConfig(t,r.stylesheet.schema),this.updateConfigDependencies())}},{key:"getSchema",value:function(e){var t=this.getFragmentStyle(e);return t?t.stylesheet.schema:null}},{key:"setSchema",value:function(e,t){var r=this.getFragmentStyle(e);r&&(r.stylesheet.schema=t,r.updateConfig(r._config,t),this.updateConfigDependencies())}},{key:"updateConfig",value:function(t,r){if(this._config=t,t||r)if(r)for(var i in r){var n=void 0,a=void 0,o=e.M(r[i].default);if("success"===o.result&&(n=o.value.expression),t&&void 0!==t[i]){var s=e.M(t[i]);"success"===s.result&&(a=s.value.expression)}var l=r[i],u=l.minValue,c=l.maxValue,h=l.stepValue,f=l.type,d=l.values;if(n){var p=e.av(i,this.scope);this.options.set(p,{default:n,value:a,minValue:u,maxValue:c,stepValue:h,type:f,values:d})}else this.fire(new e.t(new Error(`No schema defined for config option "${i}".`)))}else this.fire(new e.t(new Error("Attempting to set config for a style without schema.")))}},{key:"updateConfigDependencies",value:function(e){for(var t of this._configDependentLayers){var r=this.getLayer(t);if(r){if(e&&!r.configDependencies.has(e))continue;r.possiblyEvaluateVisibility(),this._updateLayer(r)}}this.ambientLight&&this.ambientLight.updateConfig(this.options),this.directionalLight&&this.directionalLight.updateConfig(this.options),this.fog&&this.fog.updateConfig(this.options),this.forEachFragmentStyle((function(e){if(e._styleColorTheme.colorTheme){var 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()}},{key:"addLayer",value:function(t,r){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this._checkLoaded();var n=t.id;if(this._layers[n])this.fire(new e.t(new Error(`Layer with id "${n}" already exists on this map`)));else{var a;if("custom"===t.type){if(Ri(this,e.cp(t)))return;a=e.cq(t,this.scope,this._styleColorTheme.lut,this.options)}else{if("object"==typeof t.source&&(this.addSource(n,t.source),t=e.cl(t),t=e.l(t,{source:n})),this._validate(Oe,`layers.${n}`,t,{arrayIndex:-1},i))return;a=e.cq(t,this.scope,this._styleColorTheme.lut,this.options),this._validateLayer(a),a.setEventedParent(this,{layer:{id:n}}),this._serializedLayers[a.id]=a.serialize()}0!==a.configDependencies.size&&this._configDependentLayers.add(a.fqid);var o=this._order.length;if(r){var s=this._order.indexOf(r);if(-1===s)return void this.fire(new e.t(new Error(`Layer with id "${r}" does not exist on this map.`)));a.slot===this._layers[r].slot?o=s:e.w(`Layer with id "${r}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(o,0,n),this._layerOrderChanged=!0,this._layers[n]=a;var l=this.getOwnLayerSourceCache(a),u=!!this.directionalLight&&this.directionalLight.shadowsEnabled();l&&a.canCastShadows()&&u&&(l.castsShadows=!0);var c=this._changes.getRemovedLayer(a);if(c&&a.source&&l&&"custom"!==a.type){this._changes.discardLayerRemoval(a);var h=e.av(a.source,a.scope);c.type!==a.type?this._changes.updateSourceCache(h,"clear"):(this._changes.updateSourceCache(h,"reload"),l.pause())}this._updateLayer(a),a.onAdd&&a.onAdd(this.map),a.scope=this.scope,this.mergeLayers()}}},{key:"moveLayer",value:function(t,r){this._checkLoaded();var i=this._checkLayer(t);if(i&&t!==r){var n=this._order.indexOf(t);this._order.splice(n,1);var a=this._order.length;if(r){var o=this._order.indexOf(r);if(-1===o)return void this.fire(new e.t(new Error(`Layer with id "${r}" does not exist on this map.`)));i.slot===this._layers[r].slot?a=o:e.w(`Layer with id "${r}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(a,0,t),this._changes.setDirty(),this._layerOrderChanged=!0,this.mergeLayers()}}},{key:"removeLayer",value:function(e){this._checkLoaded();var t=this._checkLayer(e);if(t){t.setEventedParent(null);var r=this._order.indexOf(e);this._order.splice(r,1),delete this._layers[e],delete this._serializedLayers[e],this._changes.setDirty(),this._layerOrderChanged=!0,this._configDependentLayers.delete(t.fqid),this._changes.removeLayer(t);var i=this.getOwnLayerSourceCache(t);if(i&&i.castsShadows){var n=!1;for(var a in this._layers)if(this._layers[a].source===t.source&&this._layers[a].canCastShadows()){n=!0;break}i.castsShadows=n}t.onRemove&&t.onRemove(this.map),this.mergeLayers()}}},{key:"getOwnLayer",value:function(e){return this._layers[e]}},{key:"hasLayer",value:function(e){return e in this._mergedLayers}},{key:"hasLayerType",value:function(e){for(var t in this._layers)if(this._layers[t].type===e)return!0;return!1}},{key:"setLayerZoomRange",value:function(e,t,r){this._checkLoaded();var i=this._checkLayer(e);i&&(i.minzoom===t&&i.maxzoom===r||(null!=t&&(i.minzoom=t),null!=r&&(i.maxzoom=r),this._updateLayer(i)))}},{key:"getSlots",value:function(){return this._checkLoaded(),this._mergedSlots}},{key:"setSlot",value:function(e,t){this._checkLoaded();var r=this._checkLayer(e);r&&r.slot!==t&&(r.slot=t,this._updateLayer(r))}},{key:"setFilter",value:function(t,r){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this._checkLoaded();var n=this._checkLayer(t);if(n&&!e.bh(n.filter,r))return null==r?(n.filter=void 0,void this._updateLayer(n)):void(this._validate(Be,`layers.${n.id}.filter`,r,{layerType:n.type},i)||(n.filter=e.cl(r),this._updateLayer(n)))}},{key:"getFilter",value:function(t){var r=this._checkLayer(t);if(r)return e.cl(r.filter)}},{key:"setLayoutProperty",value:function(t,r,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};this._checkLoaded();var a=this._checkLayer(t);if(a&&!e.bh(a.getLayoutProperty(r),i)){if(null!=i&&(!n||!1!==n.validate)&&Ri(a,Ne.call(Ae,{key:`layers.${t}.layout.${r}`,layerType:a.type,objectKey:r,value:i,styleSpec:e._,style:{glyphs:!0,sprite:!0}})))return;a.setLayoutProperty(r,i),0!==a.configDependencies.size&&this._configDependentLayers.add(a.fqid),this._updateLayer(a)}}},{key:"getLayoutProperty",value:function(e,t){var r=this._checkLayer(e);if(r)return r.getLayoutProperty(t)}},{key:"setPaintProperty",value:function(t,r,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};this._checkLoaded();var a=this._checkLayer(t);if(a&&!e.bh(a.getPaintProperty(r),i)&&(null==i||n&&!1===n.validate||!Ri(a,Fe.call(Ae,{key:`layers.${t}.paint.${r}`,layerType:a.type,objectKey:r,value:i,styleSpec:e._})))){var o=a.setPaintProperty(r,i);0!==a.configDependencies.size&&this._configDependentLayers.add(a.fqid),o&&this._updateLayer(a),this._changes.updatePaintProperties(a)}}},{key:"getPaintProperty",value:function(e,t){var r=this._checkLayer(e);if(r)return r.getPaintProperty(t)}},{key:"setFeatureState",value:function(t,r){this._checkLoaded();var i=t.source,n=t.sourceLayer,a=this._checkSource(i);if(a){var o=a.type;if("geojson"===o&&n)this.fire(new e.t(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));else if("vector"!==o||n){void 0===t.id&&this.fire(new e.t(new Error("The feature id parameter must be provided.")));var s=this.getOwnSourceCaches(i);for(var l of s)l.setFeatureState(n,t.id,r)}else this.fire(new e.t(new Error("The sourceLayer parameter must be provided for vector source types.")))}}},{key:"removeFeatureState",value:function(t,r){this._checkLoaded();var i=t.source,n=this._checkSource(i);if(n){var a=n.type,o="vector"===a?t.sourceLayer:void 0;if("vector"!==a||o)if(r&&"string"!=typeof t.id&&"number"!=typeof t.id)this.fire(new e.t(new Error("A feature id is required to remove its specific state property.")));else{var s=this.getOwnSourceCaches(i);for(var l of s)l.removeFeatureState(o,t.id,r)}else this.fire(new e.t(new Error("The sourceLayer parameter must be provided for vector source types.")))}}},{key:"getFeatureState",value:function(t){this._checkLoaded();var r=t.source,i=t.sourceLayer,n=this._checkSource(r);if(n){if("vector"!==n.type||i)return void 0===t.id&&this.fire(new e.t(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(r)[0].getFeatureState(i,t.id);this.fire(new e.t(new Error("The sourceLayer parameter must be provided for vector source types.")))}}},{key:"setTransition",value:function(t){return this.stylesheet.transition=e.l({},this.stylesheet.transition,t),this.transition=this.stylesheet.transition,this}},{key:"getTransition",value:function(){return e.l({},this.stylesheet.transition)}},{key:"serialize",value:function(){this._checkLoaded();var t=this.getTerrain(),r=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:r,fog:this.stylesheet.fog,center:this.stylesheet.center,"color-theme":this.stylesheet["color-theme"],zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,projection:this.stylesheet.projection,sources:this._serializeSources(),layers:this._serializeLayers(this._order)},(function(e){return void 0!==e}))}},{key:"_updateLayer",value:function(t){this._changes.updateLayer(t);var r=this.getLayerSourceCache(t),i=e.av(t.source,t.scope),n=this._changes.getUpdatedSourceCaches();t.source&&!n[i]&&r&&"raster"!==r.getSource().type&&(this._changes.updateSourceCache(i,"reload"),r.pause()),t.invalidateCompiledFilter()}},{key:"_flattenAndSortRenderedFeatures",value:function(e){for(var t=this,r=function(e){return t._mergedLayers[e].is3D()},i=this.order,n={},a=[],o=i.length-1;o>=0;o--){var s=i[o];if(r(s))for(var l of(n[s]=o,e)){var u=l[s];if(u)for(var c of u)a.push(c)}}a.sort((function(e,t){return t.intersectionZ-e.intersectionZ}));for(var h=[],f=i.length-1;f>=0;f--){var d=i[f];if(r(d))for(var p=a.length-1;p>=0;p--){var m=a[p].feature;if(m.layer&&n[m.layer.id]2&&void 0!==arguments[2]?arguments[2]:{};this._checkLoaded();var n=this.light.getLight(),a=!1;for(var o in t)if(!e.bh(t[o],n[o])){a=!0;break}if(a){var s=this._getTransitionParameters();this.light.setLight(t,r,i),this.light.updateTransitions(s)}}},{key:"getTerrain",value:function(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}},{key:"setTerrainForDraping",value:function(){this.setTerrain({source:"",exaggeration:0},0)}},{key:"checkCanvasFingerprintNoise",value:function(){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)."))}},{key:"setTerrain",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(this._checkLoaded(),!t)return this.terrainSetForDrapingOnly()||(delete this.terrain,this.map.transform.projection.requiresDraping&&this.setTerrainForDraping()),0===r&&delete this.terrain,null===t?this.stylesheet.terrain=null:delete this.stylesheet.terrain,this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);this.checkCanvasFingerprintNoise();var i=t,n=null==t.source;if(1===r){if(this.disableElevatedTerrain)return;if("object"==typeof i.source){var a="terrain-dem-src";this.addSource(a,i.source),i=e.cl(i),i=e.l(i,{source:a})}var o=e.l({},i),s={};if(this.terrain&&n){o.source=this.terrain.get().source;var l=this.terrain?this.getFragmentStyle(this.terrain.scope):null;l&&(s.style=l.serialize())}if(this._validate(Re,"terrain",o,s))return}if(!this.terrain||this.terrain.scope!==this.scope&&!n||this.terrain&&r!==this.terrain.drapeRenderMode){if(!i)return;this._createTerrain(i,r),this.fire(new e.x("data",{dataType:"style"}))}else{var u=this.terrain,c=u.get();for(var h of Object.keys(e._.terrain))!i.hasOwnProperty(h)&&e._.terrain[h].default&&(i[h]=e._.terrain[h].default);for(var f in t)if(!e.bh(t[f],c[f])){u.set(t,this.options),this.stylesheet.terrain=t;var d=this._getTransitionParameters({duration:0});u.updateTransitions(d),this.fire(new e.x("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0}},{key:"_createFog",value:function(e){var t=this.fog=new et(e,this.map.transform,this.scope,this.options);this.stylesheet.fog=t.get();var r=this._getTransitionParameters({duration:0});t.updateTransitions(r)}},{key:"_updateMarkersOpacity",value:function(){var e=this;0!==this.map._markers.length&&this.map._requestDomTask((function(){for(var t of e.map._markers)t._evaluateOpacity()}))}},{key:"getFog",value:function(){return this.fog?this.fog.get():null}},{key:"setFog",value:function(t){if(this._checkLoaded(),!t)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){var r=this.fog;if(!e.bh(r.get(),t)){r.set(t,this.options),this.stylesheet.fog=r.get();var i=this._getTransitionParameters({duration:0});r.updateTransitions(i)}}else this._createFog(t);this._markersNeedUpdate=!0}},{key:"setColorTheme",value:function(t){var r=this;this._checkLoaded();var i=function(){for(var e in r._layers)r._layers[e].lut=r._styleColorTheme.lut;for(var t in r._sourceCaches)r._sourceCaches[t].clearTiles()};if(this._styleColorTheme.colorTheme=t,!t)return this._styleColorTheme.lut=null,void i();var n=this._evaluateColorThemeData(t);this._loadColorTheme(n).then((function(){r.fire(new e.x("colorthemeset")),i()})).catch((function(t){e.w(`Couldn't set color theme: ${t}`)}))}},{key:"_getTransitionParameters",value:function(t){return{now:e.q.now(),transition:e.l(this.transition,t)}}},{key:"updateDrapeFirstLayers",value:function(){var e,t;if(this.terrain){var r=[],i=[];for(var n of this._mergedOrder)this.isLayerDraped(this._mergedLayers[n])?r.push(n):i.push(n);this._drapedFirstOrder=[],(e=this._drapedFirstOrder).push.apply(e,r),(t=this._drapedFirstOrder).push.apply(t,i)}}},{key:"_createTerrain",value:function(e,t){var r=this.terrain=new Ze(e,t,this.scope,this.options);1===t&&(this.stylesheet.terrain=e),this.mergeTerrain(),this.updateDrapeFirstLayers(),this._force3DLayerUpdate();var i=this._getTransitionParameters({duration:0});r.updateTransitions(i)}},{key:"_force3DLayerUpdate",value:function(){for(var e in this._layers){var t=this._layers[e];"fill-extrusion"===t.type&&this._updateLayer(t)}}},{key:"_forceSymbolLayerUpdate",value:function(){for(var e in this._layers){var t=this._layers[e];"symbol"===t.type&&this._updateLayer(t)}}},{key:"_validate",value:function(t,r,i,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};if(a&&!1===a.validate)return!1;var o=e.l({},this.serialize());return Ri(this,t.call(Ae,e.l({key:r,style:o,value:i,styleSpec:e._},n)))}},{key:"_remove",value:function(){for(var t in this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),e.cs.off("pluginStateChange",this._rtlTextPluginCallback),this._mergedLayers)this._mergedLayers[t].setEventedParent(null);for(var r in this._mergedSourceCaches)this._mergedSourceCaches[r].clearTiles(),this._mergedSourceCaches[r].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())}},{key:"clearSource",value:function(e){var t=this.getSourceCaches(e);for(var r of t)r.clearTiles()}},{key:"clearSources",value:function(){for(var e in this._mergedSourceCaches)this._mergedSourceCaches[e].clearTiles()}},{key:"reloadSource",value:function(e){var t=this.getSourceCaches(e);for(var r of t)r.resume(),r.reload()}},{key:"reloadSources",value:function(){for(var e of this.getSources())e.reload&&e.reload()}},{key:"updateSources",value:function(e){var t;for(var r in this.directionalLight&&(t=Ai(this.directionalLight)),this._mergedSourceCaches)this._mergedSourceCaches[r].update(e,void 0,void 0,t)}},{key:"_generateCollisionBoxes",value:function(){for(var e in this._sourceCaches){var t=this._sourceCaches[e];t.resume(),t.reload()}}},{key:"_updatePlacement",value:function(t,r,i,n,a,o){var s=this,l=arguments.length>6&&void 0!==arguments[6]&&arguments[6],u=!1,c=!1,h={},f={},d=function(){var t=s._mergedLayers[p];if("symbol"!==t.type)return 0;var i=e.av(t.source,t.scope),n=h[i];if(!n){var a=s.getLayerSourceCache(t);if(!a)return 0;var o=a.getRenderableIds(!0).map((function(e){return a.getTileByID(e)}));f[i]=o.slice(),n=h[i]=o.sort((function(e,t){return t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1)}))}var l=s.crossTileSymbolIndex.addLayer(t,n,r.center.lng,r.projection);u=u||l};for(var p of this._mergedOrder)d();if(this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder),l=l||this._layerOrderChanged||0===n,this._layerOrderChanged&&this.fire(new e.x("neworder")),(l||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(e.q.now(),r.zoom))&&(this.pauseablePlacement=new Hr(r,this._mergedOrder,l,i,n,a,this.placement,this.fog&&r.projection.supportsFog?this.fog.state:null,this._buildingIndex),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._mergedOrder,this._mergedLayers,h,f),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(e.q.now()),c=!0),u&&this.pauseablePlacement.placement.setStale()),c||u){this._buildingIndex.onNewFrame(r.zoom);for(var m=0;m=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:an("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:an('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nuniform float u_emissive_strength;void main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nvec4 out_color=color;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nin vec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;\n#endif\nuniform mat4 u_matrix;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp float z_offset\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;\n#endif\nfloat hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillOutline:an('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nin highp vec2 v_pos;uniform float u_emissive_strength;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nin vec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;\n#endif\nuniform mat4 u_matrix;uniform vec2 u_world;out highp vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp float z_offset\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;\n#endif\nfloat hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillOutlinePattern:an('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_emissive_strength;in highp vec2 v_pos;in highp vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);float dist=length(v_pos_world-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in vec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;\n#endif\nout highp vec2 v_pos;out highp vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\n#pragma mapbox: initialize highp float z_offset\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;\n#endif\nfloat hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);v_pos_world=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillPattern:an('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;in highp vec2 v_pos;uniform float u_emissive_strength;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in vec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;\n#endif\nout highp vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\n#pragma mapbox: initialize highp float z_offset\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;\n#endif\nfloat hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillExtrusion:an('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nin vec4 v_color;in vec4 v_flat;\n#ifdef RENDER_SHADOWS\nin highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;\n#endif\nuniform lowp float u_opacity;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;in vec2 v_ao;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nin vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nin highp vec3 v_normal;\n#endif\nuniform vec3 u_flood_light_color;uniform highp float u_vertical_scale;uniform float u_flood_light_intensity;uniform vec3 u_ground_shadow_factor;\n#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)\nin float v_flood_radius;in float v_has_floodlight;\n#endif\nin float v_height;\n#pragma mapbox: define highp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize highp float emissive_strength\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nvec3 normal=normalize(v_normal);\n#endif\nfloat z;vec4 color=v_color;\n#ifdef ZERO_ROOF_RADIUS\nz=float(normal.z > 0.00001);\n#ifdef LIGHTING_3D_MODE\nnormal=mix(normal,vec3(0.0,0.0,1.0),z);\n#else\ncolor=mix(v_color,v_roof_color,z);\n#endif\n#endif\nfloat h=max(0.0,v_height);float ao_shade=1.0;\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h_floors=h/(u_ao[1]*u_vertical_scale);float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);ao_shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;\n#ifdef ZERO_ROOF_RADIUS\nconcave*=(1.0-z);\n#endif\nfloat x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);ao_shade*=mix(1.0,x_shade*x_shade*x_shade,concave);\n#ifdef LIGHTING_3D_MODE\n#ifdef FLOOD_LIGHT\ncolor.rgb*=mix(ao_shade,1.0,v_has_floodlight);\n#else\ncolor.rgb*=ao_shade;\n#endif\n#else\ncolor.rgb*=ao_shade;\n#endif\n#endif\n#ifdef LIGHTING_3D_MODE\nfloat flood_radiance=0.0;\n#ifdef FLOOD_LIGHT\nflood_radiance=(1.0-min(h/v_flood_radius,1.0))*u_flood_light_intensity*v_has_floodlight;\n#endif\n#ifdef RENDER_SHADOWS\n#ifdef FLOOD_LIGHT\nfloat ndotl_unclamped=dot(normal,u_shadow_direction);float ndotl=max(0.0,ndotl_unclamped);float occlusion=ndotl_unclamped < 0.0 ? 1.0 : shadow_occlusion(ndotl,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);vec3 litColor=apply_lighting(color.rgb,normal,(1.0-u_shadow_intensity*occlusion)*ndotl);vec3 floodLitColor=compute_flood_lighting(u_flood_light_color*u_opacity,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=mix(litColor,floodLitColor,flood_radiance);\n#else\nfloat shadowed_lighting_factor;\n#ifdef RENDER_CUTOFF\nshadowed_lighting_factor=shadowed_light_factor_normal_opacity(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,v_cutoff_opacity);if (v_cutoff_opacity==0.0) {discard;}\n#else\nshadowed_lighting_factor=shadowed_light_factor_normal(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);\n#endif\ncolor.rgb=apply_lighting(color.rgb,normal,shadowed_lighting_factor);\n#endif\n#else\ncolor.rgb=apply_lighting(color.rgb,normal);\n#ifdef FLOOD_LIGHT\ncolor.rgb=mix(color.rgb,u_flood_light_color*u_opacity,flood_radiance);\n#endif\n#endif\ncolor.rgb=mix(color.rgb,v_flat.rgb,emissive_strength);color*=u_opacity;\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos,h));\n#endif\n#ifdef INDICATOR_CUTOUT\ncolor=applyCutout(color);\n#endif\nglFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\n#include "_prelude_lighting.glsl"\nuniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_edge_radius;uniform float u_width_scale;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#ifdef RENDER_WALL_MODE\nin vec3 a_join_normal_inside;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\nuniform highp float u_vertical_scale;out vec4 v_color;out vec4 v_flat;\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nout vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nout highp vec3 v_normal;\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;out vec2 v_ao;\n#endif\n#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)\nout float v_flood_radius;out float v_has_floodlight;\n#endif\nout float v_height;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define highp float flood_light_wall_radius\n#pragma mapbox: define highp float line_width\n#pragma mapbox: define highp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize highp float flood_light_wall_radius\n#pragma mapbox: initialize highp float line_width\n#pragma mapbox: initialize highp float emissive_strength\nbase*=u_vertical_scale;height*=u_vertical_scale;vec4 pos_nx=floor(a_pos_normal_ed*0.5);vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nv_normal=normal;\n#endif\nbase=max(0.0,base);float attr_height=height;height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\nfloat ele=0.0;float h=0.0;float c_ele=0.0;vec3 pos;\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);pos=vec3(pos_nx.xy,h);\n#else\nh=t > 0.0 ? height : base;pos=vec3(pos_nx.xy,h);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*h);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat cutoff=1.0;vec3 scaled_pos=pos;\n#ifdef RENDER_CUTOFF\nvec3 centroid_random=vec3(centroid_pos.xy,centroid_pos.x+centroid_pos.y+1.0);vec3 ground_pos=centroid_pos.x==0.0 ? pos.xyz : (centroid_random/8.0);vec4 ground=u_matrix*vec4(ground_pos.xy,ele,1.0);cutoff=cutoff_opacity(u_cutoff_params,ground.z);if (centroid_pos.y !=0.0 && centroid_pos.x !=0.0) {vec3 g=floor(ground_pos);vec3 mod_=centroid_random-g*8.0;float seed=min(1.0,0.1*(min(3.5,max(mod_.x+mod_.y,0.2*attr_height))*0.35+mod_.z));if (cutoff < 0.8-seed) {cutoff=0.0;}}float cutoff_scale=cutoff;v_cutoff_opacity=cutoff;scaled_pos.z=mix(c_ele,h,cutoff_scale);\n#endif\nfloat hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (cutoff==0.0 && centroid_pos.x !=0.0) || (color.a==0.0));\n#ifdef RENDER_WALL_MODE\nvec2 wall_offset=u_width_scale*line_width*(a_join_normal_inside.xy/EXTENT);scaled_pos.xy+=(1.0-a_join_normal_inside.z)*wall_offset*0.5;scaled_pos.xy-=a_join_normal_inside.z*wall_offset*0.5;\n#endif\ngl_Position=mix(u_matrix*vec4(scaled_pos,1),AWAY,hidden);h=h-ele;v_height=h;\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=pos;vec3 shd_pos1=pos;\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(normal);shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);\n#endif\nfloat NdotL=0.0;float colorvalue=0.0;\n#ifndef LIGHTING_3D_MODE\ncolorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),NdotL);if (normal.y !=0.0) {float r=0.84;r=mix(0.7,0.98,1.0-u_lightintensity);NdotL*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}\n#endif\n#ifdef FAUX_AO\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\n#ifdef TERRAIN\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\n#endif\nv_ao=vec2(mix(concave,-concave,start),y_ground);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\n#ifdef LIGHTING_3D_MODE\n#ifdef FLOOD_LIGHT\nfloat is_wall=1.0-float(t > 0.0 && top_up_ny.y > 0.0);v_has_floodlight=float(flood_light_wall_radius > 0.0 && is_wall > 0.0);v_flood_radius=flood_light_wall_radius*u_vertical_scale;\n#endif\nv_color=vec4(color.rgb,1.0);v_flat=vec4(linearProduct(color.rgb,vec3(calculate_NdotL(normal))),1.0);\n#else\nv_color=vec4(0.0,0.0,0.0,1.0);v_color.rgb+=clamp(color.rgb*NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nfloat roofNdotL=clamp(u_lightpos.z,0.0,1.0);roofNdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),roofNdotL);v_roof_color=vec4(0.0,0.0,0.0,1.0);v_roof_color.rgb+=clamp(color.rgb*roofNdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_roof_color*=u_opacity;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),fillExtrusionDepth:an("in highp float v_depth;void main() {\n#ifndef DEPTH_TEXTURE\nglFragColor=pack_depth(v_depth);\n#endif\n}",'#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_edge_radius;uniform float u_width_scale;uniform float u_vertical_scale;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#ifdef RENDER_WALL_MODE\nin vec3 a_join_normal_inside;\n#endif\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp float line_width\n#pragma mapbox: define highp vec4 color\nout highp float v_depth;void main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp float line_width\n#pragma mapbox: initialize highp vec4 color\nbase*=u_vertical_scale;height*=u_vertical_scale;vec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;base=max(0.0,base);height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\nvec3 pos;\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base);pos=vec3(pos_nx.xy,h);\n#else\npos=vec3(pos_nx.xy,t > 0.0 ? height : base);\n#endif\n#ifdef RENDER_WALL_MODE\nvec2 wall_offset=u_width_scale*line_width*(a_join_normal_inside.xy/EXTENT);pos.xy+=(1.0-a_join_normal_inside.z)*wall_offset*0.5;pos.xy-=a_join_normal_inside.z*wall_offset*0.5;\n#endif\nfloat hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (color.a==0.0));gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);v_depth=gl_Position.z/gl_Position.w;}'),fillExtrusionPattern:an('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;in vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nin vec3 v_normal;\n#endif\nin highp vec2 v_pos;in vec4 v_lighting;uniform lowp float u_opacity;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define mediump vec4 pattern\n#pragma mapbox: define highp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize highp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color,normalize(v_normal))*u_opacity;\n#else\nout_color=out_color*v_lighting;\n#endif\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);out_color.rgb=out_color.rgb*shade;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_lighting.glsl"\nuniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform float u_tile_units_to_pixels;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_width_scale;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#ifdef RENDER_WALL_MODE\nin vec3 a_join_normal_inside;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\nout highp vec2 v_pos;out vec4 v_lighting;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;out vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nout vec3 v_normal;\n#endif\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define mediump vec4 pattern\n#pragma mapbox: define highp float pixel_ratio\n#pragma mapbox: define highp float line_width\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize highp float pixel_ratio\n#pragma mapbox: initialize highp float line_width\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec4 pos_nx=floor(a_pos_normal_ed*0.5);mediump vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;mediump vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=a_pos_normal_ed.w;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\nfloat ele=0.0;float h=z;vec3 p;float c_ele;\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);p=vec3(pos_nx.xy,h);\n#else\np=vec3(pos_nx.xy,z);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\n#ifdef RENDER_WALL_MODE\nvec2 wall_offset=u_width_scale*line_width*(a_join_normal_inside.xy/EXTENT);p.xy+=(1.0-a_join_normal_inside.z)*wall_offset*0.5;p.xy-=a_join_normal_inside.z*wall_offset*0.5;\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(p,1),AWAY,hidden);vec2 pos=normal.z==1.0\n? pos_nx.xy\n: vec2(edgedistance,z*u_height_factor);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float NdotL=0.0;\n#ifdef LIGHTING_3D_MODE\nNdotL=calculate_NdotL(normal);\n#else\nNdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),NdotL);\n#endif\nif (normal.y !=0.0) {float r=0.84;\n#ifndef LIGHTING_3D_MODE\nr=mix(0.7,0.98,1.0-u_lightintensity);\n#endif\nNdotL*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}\n#ifdef FAUX_AO\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\n#ifdef TERRAIN\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\n#endif\nv_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\n#ifdef LIGHTING_3D_MODE\nv_normal=normal;\n#else\nv_lighting.rgb+=clamp(NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;\n#endif \n#ifdef FOG\nv_fog_pos=fog_position(p);\n#endif\n}'),groundShadow:an('#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:an("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:an("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:an('#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:an('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform lowp float u_device_pixel_ratio;uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;uniform highp vec2 u_trim_fade_range;uniform lowp vec4 u_trim_color;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec4 v_uv;\n#ifdef RENDER_LINE_DASH\nuniform sampler2D u_dash_image;in vec2 v_tex;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform sampler2D u_gradient_image;\n#endif\nfloat luminance(vec3 c) {return (c.r+c.r+c.b+c.g+c.g+c.g)*0.1667;}uniform float u_emissive_strength;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float border_width\n#pragma mapbox: define lowp vec4 border_color\nfloat linearstep(float edge0,float edge1,float x) {return clamp((x-edge0)/(edge1-edge0),0.0,1.0);}void main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float border_width\n#pragma mapbox: initialize lowp vec4 border_color\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);\n#ifdef RENDER_LINE_DASH\nfloat sdfdist=texture(u_dash_image,v_tex).r;float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/dash.z;alpha*=linearstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);\n#endif\nhighp vec4 out_color;\n#ifdef RENDER_LINE_GRADIENT\nout_color=texture(u_gradient_image,v_uv.xy);\n#else\nout_color=color;\n#endif\nfloat trim_alpha=1.0;\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float start=v_uv[2];highp float end=v_uv[3];highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=(start+(v_uv.x)*(end-start));if (trim_end > trim_start) {highp float start_transition=max(0.0,min(1.0,(line_progress-trim_start)/max(u_trim_fade_range[0],1.0e-9)));highp float end_transition=max(0.0,min(1.0,(trim_end-line_progress)/max(u_trim_fade_range[1],1.0e-9)));highp float transition_factor=min(start_transition,end_transition);out_color=mix(out_color,u_trim_color,transition_factor);trim_alpha=out_color.a;}\n#endif\nif (u_alpha_discard_threshold !=0.0) {if (alpha < u_alpha_discard_threshold) {discard;}}\n#ifdef RENDER_LINE_BORDER\nfloat edgeBlur=(border_width+1.0/u_device_pixel_ratio);float alpha2=clamp(min(dist-(v_width2.t-edgeBlur),v_width2.s-dist)/edgeBlur,0.0,1.0);if (alpha2 < 1.) {float smoothAlpha=smoothstep(0.6,1.0,alpha2);if (border_color.a==0.0) {float Y=(out_color.a > 0.01) ? luminance(out_color.rgb/out_color.a) : 1.;float adjustment=(Y > 0.) ? 0.5/Y : 0.45;if (out_color.a > 0.25 && Y < 0.25) {vec3 borderColor=(Y > 0.) ? out_color.rgb : vec3(1,1,1)*out_color.a;out_color.rgb=out_color.rgb+borderColor*(adjustment*(1.0-smoothAlpha));} else {out_color.rgb*=(0.6 +0.4*smoothAlpha);}} else {out_color.rgb=mix(border_color.rgb*border_color.a*trim_alpha,out_color.rgb,smoothAlpha);}}\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nout_color*=(alpha*opacity);\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#define EXTRUDE_SCALE 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS)\nin float a_z_offset;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nin highp vec4 a_packed;\n#endif\n#ifdef RENDER_LINE_DASH\nin float a_linesofar;\n#endif\nuniform mat4 u_matrix;uniform mat2 u_pixels_to_tile_units;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec4 v_uv;\n#ifdef RENDER_LINE_DASH\nuniform vec2 u_texsize;uniform float u_tile_units_to_pixels;out vec2 v_tex;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform float u_image_height;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float border_width\n#pragma mapbox: define lowp vec4 border_color\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float border_width\n#pragma mapbox: initialize lowp vec4 border_color\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*EXTRUDE_SCALE;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*EXTRUDE_SCALE*normal.y*mat2(t,-u,u,t);float hidden=float(opacity==0.0);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);\n#ifdef ELEVATED_ROADS\ngl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,a_z_offset+0.01*step(0.01,a_z_offset),1.0)+projected_extrude;\n#else\n#ifdef ELEVATED\nvec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 halfCellProgress=normal.yx*32.0;float ele0=elevation(pos);float ele_line=max(ele0,max(elevation(pos+halfCellProgress),elevation(pos-halfCellProgress)));float ele1=elevation(pos+offsetTile);float ele2=elevation(pos-offsetTile);float ele_max=max(ele_line,0.5*(ele1+ele2));float ele=ele_max-ele0+ele1+a_z_offset ;gl_Position=u_matrix*vec4(pos+offsetTile,ele,1.0)+projected_extrude;float z=clamp(gl_Position.z/gl_Position.w,0.5,1.0);float zbias=max(0.00005,(pow(z,0.8)-z)*0.1*u_exaggeration);gl_Position.z-=(gl_Position.w*zbias);gl_Position=mix(gl_Position,AWAY,hidden);\n#else\ngl_Position=mix(u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude,AWAY,hidden);\n#endif\n#endif\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nfloat a_uv_x=a_packed[0];float a_split_index=a_packed[1];highp float a_clip_start=a_packed[2];highp float a_clip_end=a_packed[3];\n#ifdef RENDER_LINE_GRADIENT\nhighp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec4(a_uv_x,a_split_index*texel_height-half_texel_height,a_clip_start,a_clip_end);\n#else\nv_uv=vec4(a_uv_x,0.0,a_clip_start,a_clip_end);\n#endif\n#endif\n#ifdef RENDER_LINE_DASH\nfloat scale=dash.z==0.0 ? 0.0 : u_tile_units_to_pixels/dash.z;float height=dash.y;v_tex=vec2(a_linesofar*scale/floorwidth,(-normal.y*height+dash.x+0.5)/u_texsize.y);\n#endif\nv_width2=vec2(outset,inset);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),linePattern:an('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform highp float u_device_pixel_ratio;uniform highp float u_alpha_discard_threshold;uniform highp vec2 u_texsize;uniform highp float u_tile_units_to_pixels;uniform highp vec2 u_trim_offset;uniform sampler2D u_image;in vec2 v_normal;in vec2 v_width2;in highp float v_linesofar;in float v_gamma_scale;in float v_width;\n#ifdef RENDER_LINE_TRIM_OFFSET\nin highp vec4 v_uv;\n#endif\n#ifdef LINE_JOIN_NONE\nin vec2 v_pattern_data;\n#endif\n#pragma mapbox: define mediump vec4 pattern\n#pragma mapbox: define mediump float pixel_ratio\n#pragma mapbox: define mediump float blur\n#pragma mapbox: define mediump float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize mediump float pixel_ratio\n#pragma mapbox: initialize mediump float blur\n#pragma mapbox: initialize mediump float opacity\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;float pattern_size=display_size.x/u_tile_units_to_pixels;float aspect=display_size.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);highp float pattern_x=v_linesofar/pattern_size*aspect;highp float x=mod(pattern_x,1.0);highp float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;highp vec2 pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(x,y));highp vec2 lod_pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(pattern_x,y));vec4 color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float start=v_uv[2];highp float end=v_uv[3];highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=(start+(v_uv.x)*(end-start));if (trim_end > trim_start) {if (line_progress <=trim_end && line_progress >=trim_start) {color=vec4(0,0,0,0);}}\n#endif\n#ifdef LINE_JOIN_NONE\nfloat pattern_len=pattern_size/aspect;float segment_phase=pattern_len-mod(v_linesofar-v_pattern_data.x+pattern_len,pattern_len);float visible_start=segment_phase-step(pattern_len*0.5,segment_phase)*pattern_len;float visible_end=floor((v_pattern_data.y-segment_phase)/pattern_len)*pattern_len+segment_phase;visible_end+=step(pattern_len*0.5,v_pattern_data.y-visible_end)*pattern_len;if (v_pattern_data.x < visible_start || v_pattern_data.x >=visible_end) {color=vec4(0.0);}\n#endif\n#ifdef LIGHTING_3D_MODE\ncolor=apply_lighting_ground(color);\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ncolor*=(alpha*opacity);if (u_alpha_discard_threshold !=0.0) {if (color.a < u_alpha_discard_threshold) {discard;}}\n#ifdef INDICATOR_CUTOUT\ncolor=applyCutout(color);\n#endif\nglFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS)\nin float a_z_offset;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nin highp vec4 a_packed;\n#endif\nin highp float a_linesofar;\n#ifdef LINE_JOIN_NONE\nin highp vec3 a_pattern_data;out vec2 v_pattern_data;\n#endif\nuniform mat4 u_matrix;uniform float u_tile_units_to_pixels;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out highp float v_linesofar;out float v_gamma_scale;out float v_width;\n#ifdef RENDER_LINE_TRIM_OFFSET\nout highp vec4 v_uv;\n#endif\n#pragma mapbox: define mediump float blur\n#pragma mapbox: define mediump float opacity\n#pragma mapbox: define mediump float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define mediump float floorwidth\n#pragma mapbox: define mediump vec4 pattern\n#pragma mapbox: define mediump float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize mediump float blur\n#pragma mapbox: initialize mediump float opacity\n#pragma mapbox: initialize mediump float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize mediump float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize mediump float pixel_ratio\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);vec2 dist=outset*a_extrude*scale;float u=0.5*a_direction;float t=1.0-abs(u);vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float hidden=float(opacity==0.0);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);\n#ifdef ELEVATED_ROADS\ngl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,a_z_offset+0.01*step(0.01,a_z_offset),1.0)+projected_extrude;\n#else\n#ifdef ELEVATED\nvec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 halfCellProgress=normal.yx*32.0;float ele0=elevation(pos);float ele_line=max(ele0,max(elevation(pos+halfCellProgress),elevation(pos-halfCellProgress)));float ele1=elevation(pos+offsetTile);float ele2=elevation(pos-offsetTile);float ele_max=max(ele_line,0.5*(ele1+ele2));float ele=ele_max-ele0+ele1+a_z_offset ;gl_Position=u_matrix*vec4(pos+offsetTile,ele,1.0)+projected_extrude;float z=clamp(gl_Position.z/gl_Position.w,0.5,1.0);float zbias=max(0.00005,(pow(z,0.8)-z)*0.1*u_exaggeration);gl_Position.z-=(gl_Position.w*zbias);gl_Position=mix(gl_Position,AWAY,hidden);\n#else\ngl_Position=mix(u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude,AWAY,hidden);\n#endif\n#endif\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nfloat a_uv_x=a_packed[0];highp float a_clip_start=a_packed[2];highp float a_clip_end=a_packed[3];v_uv=vec4(a_uv_x,0.0,a_clip_start,a_clip_end);\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;\n#ifdef LINE_JOIN_NONE\nv_width=floorwidth+ANTIALIASING;mediump float pixels_to_tile_units=1.0/u_tile_units_to_pixels;mediump float pixel_ratio_inverse=1.0/pixel_ratio;mediump float aspect=v_width/((pattern.w-pattern.y)*pixel_ratio_inverse);highp float subt_multiple=(pattern.z-pattern.x)*pixel_ratio_inverse*pixels_to_tile_units*aspect*32.0;highp float subt=floor(a_pattern_data.z/subt_multiple)*subt_multiple;float offset_sign=(fract(a_pattern_data.x)-0.5)*4.0;float line_progress_offset=offset_sign*v_width*0.5*pixels_to_tile_units;v_linesofar=(a_pattern_data.z-subt)+a_linesofar+line_progress_offset;v_pattern_data=vec2(a_pattern_data.x+line_progress_offset,a_pattern_data.y);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),raster:an('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_raster_array.glsl"\nuniform float u_fade_t;uniform float u_opacity;uniform highp float u_raster_elevation;uniform highp float u_zoom_transition;in vec2 v_pos0;in vec2 v_pos1;in float v_depth;\n#ifdef PROJECTION_GLOBE_VIEW\nin float v_split_fade;\n#endif\nuniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;uniform float u_emissive_strength;\n#ifndef RASTER_ARRAY\nuniform sampler2D u_image0;uniform sampler2D u_image1;\n#endif\n#ifdef RASTER_COLOR\nuniform sampler2D u_color_ramp;uniform highp vec4 u_colorization_mix;uniform highp float u_colorization_offset;uniform vec2 u_texture_res;\n#endif\nvoid main() {vec4 color0,color1,color;vec2 value;\n#ifdef RASTER_COLOR\n#ifdef RASTER_ARRAY\n#ifdef RASTER_ARRAY_LINEAR\nvalue=mix(\nraTexture2D_image0_linear(v_pos0,u_texture_res,u_colorization_mix,u_colorization_offset),raTexture2D_image1_linear(v_pos1,u_texture_res,u_colorization_mix,u_colorization_offset),u_fade_t\n);\n#else\nvalue=mix(\nraTexture2D_image0_nearest(v_pos0,u_texture_res,u_colorization_mix,u_colorization_offset),raTexture2D_image1_nearest(v_pos1,u_texture_res,u_colorization_mix,u_colorization_offset),u_fade_t\n);\n#endif\nif (value.y > 0.0) value.x/=value.y;\n#else\ncolor=mix(texture(u_image0,v_pos0),texture(u_image1,v_pos1),u_fade_t);value=vec2(u_colorization_offset+dot(color.rgb,u_colorization_mix.rgb),color.a);\n#endif\ncolor=texture(u_color_ramp,vec2(value.x,0.5));if (color.a > 0.0) color.rgb/=color.a;color.a*=value.y;\n#else\ncolor0=texture(u_image0,v_pos0);color1=texture(u_image1,v_pos1);if (color0.a > 0.0) color0.rgb/=color0.a;if (color1.a > 0.0) color1.rgb/=color1.a;color=mix(color0,color1,u_fade_t);\n#endif\ncolor.a*=u_opacity;\n#ifdef GLOBE_POLES\ncolor.a*=1.0-smoothstep(0.0,0.05,u_zoom_transition);\n#endif\nvec3 rgb=color.rgb;rgb=vec3(\ndot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);vec3 out_color=mix(u_high_vec,u_low_vec,rgb);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),u_emissive_strength).rgb;\n#endif\n#ifdef FOG\nhighp float fog_limit_high_meters=1000000.0;highp float fog_limit_low_meters=600000.0;float fog_limit=1.0-smoothstep(fog_limit_low_meters,fog_limit_high_meters,u_raster_elevation);out_color=fog_dither(fog_apply(out_color,v_fog_pos,fog_limit));\n#endif\nglFragColor=vec4(out_color*color.a,color.a);\n#ifdef PROJECTION_GLOBE_VIEW\nglFragColor*=mix(1.0,1.0-smoothstep(0.0,0.05,u_zoom_transition),smoothstep(0.8,0.9,v_split_fade));\n#endif\n#ifdef RENDER_CUTOFF\nglFragColor=glFragColor*cutoff_opacity(u_cutoff_params,v_depth);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform mat3 u_grid_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;uniform vec2 u_texture_offset;uniform float u_raster_elevation;uniform float u_zoom_transition;uniform vec2 u_merc_center;\n#define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8\n#ifdef GLOBE_POLES\nin vec3 a_globe_pos;in vec2 a_uv;\n#else\nin vec2 a_pos;in vec2 a_texture_pos;\n#endif\nout vec2 v_pos0;out vec2 v_pos1;out float v_depth;\n#ifdef PROJECTION_GLOBE_VIEW\nout float v_split_fade;\n#endif\nvoid main() {vec2 uv;\n#ifdef GLOBE_POLES\nvec3 globe_pos=a_globe_pos;globe_pos+=normalize(globe_pos)*u_raster_elevation*GLOBE_UPSCALE;gl_Position=u_matrix*u_globe_matrix*vec4(globe_pos ,1.0);uv=a_uv;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(a_globe_pos,1.0)).xyz);\n#endif\n#else\nfloat w=1.0+dot(a_texture_pos,u_perspective_transform);uv=a_texture_pos/8192.0;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);vec3 globe_pos=latLngToECEF(latLng.xy);globe_pos+=normalize(globe_pos)*u_raster_elevation*GLOBE_UPSCALE;vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);float mercatorY=mercatorYfromLat(latLng[0]);float mercatorX=mercatorXfromLng(latLng[1]); \nv_split_fade=0.0;if (u_zoom_transition > 0.0) {vec2 merc_pos=vec2(mercatorX,mercatorY);merc_world_pos=vec4(merc_pos,u_raster_elevation,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;float opposite_merc_center=mod(u_merc_center.x+0.5,1.0);float dist_from_poles=(abs(mercatorY-0.5)*2.0);float range=0.1;v_split_fade=abs(opposite_merc_center-mercatorX);v_split_fade=clamp(1.0-v_split_fade,0.0,1.0);v_split_fade=max(smoothstep(1.0-range,1.0,dist_from_poles),max(smoothstep(1.0-range,1.0,v_split_fade),smoothstep(1.0-range,1.0,1.0-v_split_fade)));}float tiles=u_grid_matrix[0][2];if (tiles > 0.0) {float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];float uvY=mercatorY*tiles-idy;float uvX=mercatorX*tiles-idx;uv=vec2(uvX,uvY);}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition)*w,w);gl_Position=u_matrix*interpolated_pos;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n#else\ngl_Position=u_matrix*vec4(a_pos*w,u_raster_elevation*w,w);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n#endif\n#endif\nv_pos0=uv;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;v_pos0=u_texture_offset.x+u_texture_offset.y*v_pos0;v_pos1=u_texture_offset.x+u_texture_offset.y*v_pos1;\n#ifdef RENDER_CUTOFF\nv_depth=gl_Position.z;\n#endif\n}'),rasterParticle:an('#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:an("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:an("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:an('#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:an('#include "_prelude_lighting.glsl"\n#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;uniform bool u_is_halo;\n#ifdef ICON_TRANSITION\nuniform float u_icon_transition;\n#endif\n#ifdef COLOR_ADJUSTMENT\nuniform mat4 u_color_adj_mat;\n#endif\nin vec2 v_tex_a;\n#ifdef ICON_TRANSITION\nin vec2 v_tex_b;\n#endif\nin float v_draw_halo;in vec3 v_gamma_scale_size_fade_opacity;\n#ifdef RENDER_TEXT_AND_SYMBOL\nin float is_sdf;in vec2 v_tex_a_icon;\n#endif\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\n#pragma mapbox: initialize lowp float emissive_strength\nvec4 out_color;float fade_opacity=v_gamma_scale_size_fade_opacity[2];\n#ifdef RENDER_TEXT_AND_SYMBOL\nif (is_sdf==ICON) {vec2 tex_icon=v_tex_a_icon;lowp float alpha=opacity*fade_opacity;glFragColor=texture(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nreturn;}\n#endif\n#ifdef RENDER_SDF\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_gamma_scale_size_fade_opacity.x;float size=v_gamma_scale_size_fade_opacity.y;float fontScale=u_is_text ? size/24.0 : size;out_color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;bool draw_halo=v_draw_halo > 0.0;if (draw_halo) {out_color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,v_tex_a).r;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);out_color*=alpha;\n#else\n#ifdef ICON_TRANSITION\nvec4 a=texture(u_texture,v_tex_a)*(1.0-u_icon_transition);vec4 b=texture(u_texture,v_tex_b)*u_icon_transition;out_color=(a+b);\n#else\nout_color=texture(u_texture,v_tex_a);\n#endif\n#ifdef COLOR_ADJUSTMENT\nout_color=u_color_adj_mat*out_color;\n#endif\n#endif\nout_color*=opacity*fade_opacity;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\nin vec4 a_pos_offset;in vec4 a_tex_size;in vec4 a_pixeloffset;in vec4 a_projected_pos;in float a_fade_opacity;\n#ifdef Z_OFFSET\nin float a_auto_z_offset;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_globe_anchor;in vec3 a_globe_normal;\n#endif\n#ifdef ICON_TRANSITION\nin vec2 a_texb;\n#endif\n#ifdef OCCLUSION_QUERIES\nin float a_occlusion_query_opacity;\n#endif\nuniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_elevation_from_sea;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;uniform vec2 u_texsize_icon;uniform bool u_is_halo;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nout vec2 v_tex_a;\n#ifdef ICON_TRANSITION\nout vec2 v_tex_b;\n#endif\nout float v_draw_halo;out vec3 v_gamma_scale_size_fade_opacity;\n#ifdef RENDER_TEXT_AND_SYMBOL\nout float is_sdf;out vec2 v_tex_a_icon;\n#endif\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n#pragma mapbox: define lowp float emissive_strength\n#pragma mapbox: define lowp float occlusion_opacity\n#pragma mapbox: define lowp float z_offset\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\n#pragma mapbox: initialize lowp float emissive_strength\n#pragma mapbox: initialize lowp float occlusion_opacity\n#pragma mapbox: initialize lowp float z_offset\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_min_font_scale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;float e=u_elevation_from_sea ? z_offset : z_offset+elevation(tile_anchor);\n#ifdef Z_OFFSET\ne+=a_auto_z_offset;\n#endif\nvec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;vec3 world_pos_globe;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos_globe=a_globe_anchor+h;world_pos=mix_globe_mercator(world_pos_globe,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nworld_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetprojected_point;vec2 a;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetprojected_point=u_matrix*vec4(a_globe_anchor+displacement,1);vec4 projected_point_globe=u_matrix*vec4(world_pos_globe,1);a=projected_point_globe.xy/projected_point_globe.w;\n#else\noffsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);a=projected_point.xy/projected_point.w;\n#endif\nvec2 b=offsetprojected_point.xy/offsetprojected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*max(a_min_font_scale,font_scale)+a_pxoffset/16.0);\n#ifdef TERRAIN\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\n#endif\n#ifdef Z_OFFSET\nz+=u_pitch_with_map ? a_auto_z_offset+(u_elevation_from_sea ? z_offset : z_offset) : 0.0;\n#else\nz+=u_pitch_with_map ? (u_elevation_from_sea ? z_offset : z_offset) : 0.0;\n#endif\nfloat occlusion_fade=globe_occlusion_fade;float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nvec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));float out_fade_opacity=interpolated_fade_opacity*projection_transition_fade;\n#ifdef DEPTH_OCCLUSION\nfloat depth_occlusion=occlusionFadeMultiSample(projected_point);float depth_occlusion_multplier=mix(occlusion_opacity,1.0,depth_occlusion);out_fade_opacity*=depth_occlusion_multplier;\n#endif\n#ifdef OCCLUSION_QUERIES\nfloat occludedFadeMultiplier=mix(occlusion_opacity,1.0,a_occlusion_query_opacity);out_fade_opacity*=occludedFadeMultiplier;\n#endif\nfloat alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,hidden);\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,hidden);\n#endif\nfloat gamma_scale=gl_Position.w;v_draw_halo=(u_is_halo && float(gl_InstanceID)==0.0) ? 1.0 : 0.0;v_gamma_scale_size_fade_opacity=vec3(gamma_scale,size,out_fade_opacity);v_tex_a=a_tex/u_texsize;\n#ifdef RENDER_TEXT_AND_SYMBOL\nis_sdf=a_size[0]-2.0*a_size_min;v_tex_a_icon=a_tex/u_texsize_icon;\n#endif\n#ifdef ICON_TRANSITION\nv_tex_b=a_texb/u_texsize;\n#endif\n}'),terrainRaster:an('#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:an("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:an('#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}',Gi),skyboxGradient:an('#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}',Gi),skyboxCapture:an("\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:an('#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:an('#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:an('#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:an("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:an("in highp vec2 v_uv;in mediump float v_intensity;float shapeCircle(in vec2 uv)\n{float beginFade=0.6;float lengthFromCenter=length(v_uv);return 1.0-clamp((lengthFromCenter-beginFade)/(1.0-beginFade),0.0,1.0);}void main() {float alpha=shapeCircle(v_uv);vec3 color=vec3(1.0,1.0,1.0);alpha*=v_intensity;glFragColor=vec4(color*alpha,alpha);HANDLE_WIREFRAME_DEBUG;}","\nin vec3 a_pos_3f;in vec2 a_uv;in float a_size_scale;in float a_fade_opacity;uniform mat4 u_matrix;uniform vec3 u_up;uniform vec3 u_right;uniform float u_intensity_multiplier;out highp vec2 v_uv;out mediump float v_intensity;void main() {v_uv=a_uv;v_intensity=a_fade_opacity*u_intensity_multiplier;vec3 pos=a_pos_3f;pos+=a_uv.x*u_right*a_size_scale;pos+=a_uv.y*u_up*a_size_scale;gl_Position=u_matrix*vec4(pos,1.0);}"),occlusion:an("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 nn(e,t){var r=e.replace(/\s*\/\/[^\n]*\n/g,"\n").split("\n");for(var i of r)if("#"===(i=i.trim())[0]&&i.includes("if")&&!i.includes("endif")){var n=(i=i.replace("#","").replace(/ifdef|ifndef|elif|if/g,"").replace(/!|defined|\(|\)|\|\||&&/g,"").replace(/\s+/g," ").trim()).split(" ");for(var a of n)t.includes(a)||t.push(a)}}function an(e,t){var r=/#include\s+"([^"]+)"/g,i=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g,n=t.match(/(attribute(\S*)|(^\s*|;)in) (highp |mediump |lowp )?([\w]+) ([\w]+)/gm);n&&(n=n.map((function(e){var t=e.split(" ");return t[t.length-1]})),n=d(new Set(n)));var a={},o=[],s=[];if(e=e.replace(r,(function(e,t){return s.push(t),""})),!(t=t.replace(r,(function(e,t){return o.push(t),""}))).includes("flat out")){var l=[].concat(Ji);for(var u of(nn(e,l),nn(t,l),[].concat(o,s)))Ki[u]||console.error(`Undefined include: ${u}`),Qi[u]||(Qi[u]=[],nn(Ki[u],Qi[u])),l=[].concat(d(l),d(Qi[u]));return{fragmentSource:e=e.replace(i,(function(e,t,r,i,n){return a[n]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nin ${r} ${i} ${n};\n#else\nuniform ${r} ${i} u_${n};\n#endif\n`:"initialize"===t?`\n#ifdef HAS_UNIFORM_u_${n}\n ${r} ${i} ${n} = u_${n};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n in ${r} ${i} ${n};\n#endif\n`:"initialize-attribute"===t?"":void 0})),vertexSource:t=t.replace(i,(function(e,t,r,i,n){var o="float"===i?"vec2":i,s=n.match(/color/)?"color":o;return"define-attribute-vertex-shader-only"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\nin ${r} ${i} a_${n};\n#endif\n`:a[n]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nin ${r} ${o} a_${n};\nout ${r} ${i} ${n};\n#else\nuniform ${r} ${i} u_${n};\n#endif\n`:"initialize"===t?"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = a_${n};\n#else\n ${r} ${i} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = unpack_mix_${s}(a_${n}, u_${n}_t);\n#else\n ${r} ${i} ${n} = u_${n};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n in ${r} ${i} a_${n};\n out ${r} ${i} ${n};\n#endif\n`:"initialize-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n ${n} = a_${n};\n#endif\n`:void 0:"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nin ${r} ${o} a_${n};\n#else\nuniform ${r} ${i} u_${n};\n#endif\n`:"define-instanced"===t?"mat4"===s?`\n#ifdef INSTANCED_ARRAYS\nin vec4 a_${n}0;\nin vec4 a_${n}1;\nin vec4 a_${n}2;\nin vec4 a_${n}3;\n#else\nuniform ${r} ${i} u_${n};\n#endif\n`:`\n#ifdef INSTANCED_ARRAYS\nin ${r} ${o} a_${n};\n#else\nuniform ${r} ${i} u_${n};\n#endif\n`:"initialize-attribute-custom"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n ${r} ${i} ${n} = a_${n};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${n}\n ${r} ${i} ${n} = a_${n};\n#else\n ${r} ${i} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${r} ${i} ${n} = unpack_mix_${s}(a_${n}, u_${n}_t);\n#else\n ${r} ${i} ${n} = u_${n};\n#endif\n`})),staticAttributes:n,usedDefines:l,vertexIncludes:o,fragmentIncludes:s}}console.error('The usage of "flat" qualifier is disallowed, see: https://bugs.webkit.org/show_bug.cgi?id=268071')}var on=(function(){return m((function e(){p(this,e),this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}),[{key:"bind",value:function(e,t,r,i,n,a,o,s){this.context=e;for(var l=this.boundPaintVertexBuffers.length!==i.length,u=0;!l&&u=1||!this._validOp(r);)if(!this._nextOp(r,e)){delete this.operations[t];break}}}},{key:"_nextOp",value:function(e,t){return!!e.queued&&(e.from=e.to,e.to=e.queued,e.queued=null,e.phase=0,e.startTime=t,!0)}},{key:"_validOp",value:function(e){return e.from.hasData()&&e.to.hasData()}}])})()),Kn={0:null,1:"TERRAIN_VERTEX_MORPHING"};function Qn(e,t,r){if(0===t)return 0;var i=t<1&&514===r?.25/t:1;return 6*Math.pow(1.5,22-e)*Math.max(t,1)*i}function ea(e,t){var r=1<0){var o=e.q.now(),s=(o-t.timeAdded)/a,l=r?(o-r.timeAdded)/a:-1,u=i.getSource(),c=n.coveringZoomLevel({tileSize:u.tileSize,roundZoom:u.roundZoom}),h=!r||Math.abs(r.tileID.overscaledZ-c)>Math.abs(t.tileID.overscaledZ-c),f=h&&t.refreshedUponExpiration?1:e.ap(h?s:1-l,0,1);return t.refreshedUponExpiration&&s>=1&&(t.refreshedUponExpiration=!1),r?{opacity:1,mix:1-f}:{opacity:f,mix:0}}return{opacity:1,mix:0}}var ia=(function(t){function r(t){var i;p(this,r);var n={type:"raster-dem",maxzoom:t.transform.maxZoom},a=new e.cd(e.ce(),null),o=ft("mock-dem",n,a,t.style);return i=T(this,r,["mock-dem",o,!1]),o.setEventedParent(l(i)),i._sourceLoaded=!0,i}return y(r,t),m(r,[{key:"_loadTile",value:function(e,t){e.state="loaded",t(null)}}])})(Vt),na=(function(t){function r(t){var i;p(this,r);var n=ft("proxy",{type:"geojson",maxzoom:t.transform.maxZoom},new e.cd(e.ce(),null),t.style);return i=T(this,r,["proxy",n,!1]),n.setEventedParent(l(i)),i.map=i.getSource().map=t,i.used=i._sourceLoaded=!0,i.renderCache=[],i.renderCachePool=[],i.proxyCachedFBO={},i}return y(r,t),m(r,[{key:"update",value:function(e,t,r){var i=this;if(!e.freezeTileCoverage){this.transform=e;var n=e.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((function(t,r){if(t[r.key]="",!i._tiles[r.key]){var n=new Ot(r,i._source.tileSize*r.overscaleFactor(),e.tileZoom);n.state="loaded",i._tiles[r.key]=n}return t}),{});for(var a in this._tiles)a in n||(this.freeFBO(a),this._tiles[a].unloadVectorData(),delete this._tiles[a])}}},{key:"freeFBO",value:function(e){var t=this.proxyCachedFBO[e];if(void 0!==t){var r,i=Object.values(t);(r=this.renderCachePool).push.apply(r,i),delete this.proxyCachedFBO[e]}}},{key:"deallocRenderCache",value:function(){this.renderCache.forEach((function(e){return e.fb.destroy()})),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}])})(Vt),aa=(function(e){function t(e,r,i){var n;return p(this,t),(n=T(this,t,[e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y])).proxyTileKey=r,n.projMatrix=i,n}return y(t,e),m(t)})(e.aA),oa=(function(t){function r(t,i){var n;p(this,r),(n=T(this,r))._debugParams={sortTilesHiZFirst:!0,disableRenderCache:!1},t.tp.registerParameter(n._debugParams,["Terrain"],"sortTilesHiZFirst",{},(function(){n._style.map.triggerRepaint()})),t.tp.registerParameter(n._debugParams,["Terrain"],"disableRenderCache",{},(function(){n._style.map.triggerRepaint()})),t.tp.registerButton(["Terrain"],"Invalidate Render Cache",(function(){n.invalidateRenderCache=!0,n._style.map.triggerRepaint()})),n.painter=t,n.terrainTileForTile={},n.prevTerrainTileForTile={};var a=(function(){var t=new e.a_,r=new e.aO,i=131;t.reserve(17161),r.reserve(33800);for(var n=e.ab/128,a=e.ab+n/2,o=a+n,s=-n;sa||s<0||s>a?24575:0,c=e.ap(Math.round(l),0,e.ab),h=e.ap(Math.round(s),0,e.ab);t.emplaceBack(c+u,h)}for(var f=function(e,t){var n=t*i+e;r.emplaceBack(n+1,n,n+i),r.emplaceBack(n+i,n+i+1,n+1)},d=1;d<129;d++)for(var p=1;p<129;p++)f(p,d);return[0,129].forEach((function(e){for(var t=0;t<130;t++)f(t,e),f(e,t)})),[t,r,32768]})(),o=x(a,3),s=o[0],l=o[1],u=o[2],c=t.context;n.gridBuffer=c.createVertexBuffer(s,e.b0.members),n.gridIndexBuffer=c.createIndexBuffer(l),n.gridSegments=e.b1.simpleSegment(0,0,s.length,l.length),n.gridNoSkirtSegments=e.b1.simpleSegment(0,0,s.length,u),n.proxyCoords=[],n.proxiedCoords={},n._visibleDemTiles=[],n._drapedRenderBatches=[],n._sourceTilesOverlap={},n.proxySourceCache=new na(i.map),n.orthoMatrix=e.a6.mat4.create(),e.a6.mat4.ortho(n.orthoMatrix,"globe"===n.painter.transform.projection.name?.015:0,e.ab,0,e.ab,0,1);var h=c.gl;return n._overlapStencilMode=new ii({func:h.GEQUAL,mask:255},0,255,h.KEEP,h.KEEP,h.REPLACE),n._previousZoom=t.transform.zoom,n.pool=[],n._findCoveringTileCache={},n._tilesDirty={},n.style=i,n._useVertexMorphing=!0,n._exaggeration=1,n._mockSourceCache=new ia(i.map),n._pendingGroundEffectLayers=[],n}return y(r,t),m(r,[{key:"style",set:function(e){var t=this;e.on("data",this._onStyleDataEvent.bind(this)),this._style=e,this._style.map.on("moveend",(function(){t._clearLineLayersFromRenderCache()}))}},{key:"update",value:function(t,r,i){var n=this;if(t&&t.terrain){this._style!==t&&(this.style=t,this._evaluationZoom=void 0);var a=t.terrain.properties,o=0===t.terrain.drapeRenderMode,s=t.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=e.q.now();var l=t.terrain&&t.terrain.scope,u=a.get("source"),c=o?this._mockSourceCache:t.getSourceCache(u,l);if(!c)return void e.w(`Couldn't find terrain source "${u}".`);if(this.sourceCache=c,this._exaggeration=s?this.calculateExaggeration(r):a.get("exaggeration"),!r.projection.requiresDraping&&s&&0===this._exaggeration)return void this._disable();this.enabled=!0;var h=function(){n.sourceCache.used&&e.w(`Raster DEM source '${n.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.`);var t=n.getScaledDemTileSize();n.sourceCache.update(r,t,!0),n.resetTileLookupCache(n.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,h(),this._initializing=!0),h(),r.updateElevation(!0,i),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(r),this._emptyDEMTextureDirty=!0,this._previousZoom=r.zoom}else this._disable()}},{key:"calculateExaggeration",value:function(t){var r=this._previousCameraAltitude,i=t.getFreeCameraOptions().position.z/t.pixelsPerMeter*t.worldSize;this._previousCameraAltitude=i;var n=null!=r?i-r:Number.MAX_VALUE;if(Math.abs(n)<2)return this._exaggeration;var a=t.zoom,o=this._style.terrain;if(!this._previousUpdateTimestamp)return o.getExaggeration(a);var s=a-this._previousZoom,l=this._previousUpdateTimestamp,u=a;null!=this._evaluationZoom&&(u=this._evaluationZoom,Math.abs(a-u)>.5&&(s=.5*(a-u+s)),s*n<0&&(u+=s)),this._evaluationZoom=u;var c=o.getExaggeration(u),h=c===o.getExaggeration(Math.max(0,u-.1));if(h&&Math.abs(c-this._exaggeration)<.01)return c;var f=Math.min(.1,.00375*(this._updateTimestamp-l));return(h||c<.1||Math.abs(s)<1e-4)&&(f=Math.min(.2,4*f)),e.aa(this._exaggeration,c,f)}},{key:"resetTileLookupCache",value:function(e){this._findCoveringTileCache[e]={}}},{key:"getScaledDemTileSize",value:function(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}},{key:"_onStyleDataEvent",value:function(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)}},{key:"_disable",value:function(){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(var e in this._style._mergedSourceCaches)this._style._mergedSourceCaches[e].usedForTerrain=!1}},{key:"destroy",value:function(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this.pool.forEach((function(e){return e.fb.destroy()})),this.pool=[],this.framebufferCopyTexture&&this.framebufferCopyTexture.destroy()}},{key:"_source",value:function(){return this.enabled?this.sourceCache:null}},{key:"isUsingMockSource",value:function(){return this.sourceCache===this._mockSourceCache}},{key:"exaggeration",value:function(){return this.enabled?this._exaggeration:0}},{key:"visibleDemTiles",get:function(){return this._visibleDemTiles}},{key:"drapeBufferSize",get:function(){var e=2*this.proxySourceCache.getSource().tileSize;return[e,e]}},{key:"useVertexMorphing",set:function(e){this._useVertexMorphing=e}},{key:"updateTileBinding",value:function(t){var r=this;if(this.enabled){this.prevTerrainTileForTile=this.terrainTileForTile;var i=this.proxySourceCache,n=this.painter.transform;this._initializing&&(this._initializing=0===n._centerAltitude&&-1===this.getAtPointOrZero(e.a5.fromLngLat(n.center),-1),this._emptyDEMTextureDirty=!this._initializing);var a=this.proxyCoords=i.getIds().map((function(e){var t=i.getTileByID(e).tileID;return t.projMatrix=n.calculateProjMatrix(t.toUnwrapped()),t}));!(function(t,r){var i=r.transform.pointCoordinate(r.transform.getCameraPoint()),n=new e.P(i.x,i.y);t.sort((function(t,r){if(r.overscaledZ-t.overscaledZ)return r.overscaledZ-t.overscaledZ;var i=new e.P(t.canonical.x+(1<0&&e++,t+i}),0);return e?t/e:0}},{key:"_updateEmptyDEMTexture",value:function(){var t=this.painter.context,r=t.gl;t.activeTexture.set(r.TEXTURE2);var i=this._getLoadedAreaMinimum(),n=new e.cF({width:1,height:1},new Float32Array([i]));this._emptyDEMTextureDirty=!1;var a=this._emptyDEMTexture;return a?a.update(n,{premultiply:!1}):a=this._emptyDEMTexture=new e.T(t,n,r.R32F,{premultiply:!1}),a}},{key:"setupElevationDraw",value:function(t,r,i){var n=this,a=this.painter.context,o=a.gl,s={u_dem:2,u_dem_prev:4,u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_depth_range_unpack:[0,1],u_occluder_half_size:16,u_occlusion_depth_offset:-1e-4,u_exaggeration:0};s.u_exaggeration=this.exaggeration();var l=null,u=null,c=1;if(i&&i.morphing&&this._useVertexMorphing){var h=i.morphing.srcDemTile,f=i.morphing.dstDemTile;c=i.morphing.phase,h&&f&&(this._prepareDemTileUniforms(t,h,s,"_prev")&&(u=h),this._prepareDemTileUniforms(t,f,s)&&(l=f))}var d,p=function(e){return e&&e.demTexture&&n.painter.linearFloatFilteringSupported()?o.LINEAR:o.NEAREST},m=null;if(this.enabled?u&&l?(m=l.demTexture,a.activeTexture.set(o.TEXTURE4),u.demTexture.bind(p(u),o.CLAMP_TO_EDGE),s.u_dem_lerp=c):(l=this.terrainTileForTile[t.tileID.key],m=this._prepareDemTileUniforms(t,l,s)?l.demTexture:this.emptyDEMTexture):m=this.emptyDEMTexture,a.activeTexture.set(o.TEXTURE2),m&&(s.u_dem_size=1===(d=m).size[0]?1:d.size[0]-2,m.bind(p(l),o.CLAMP_TO_EDGE)),this.painter.setupDepthForOcclusion(i&&i.useDepthForOcclusion,r,s),i&&i.useMeterToDem&&l){var v=(1<r}},{key:"getMinElevationBelowMSL",value:function(){var e=0;return this._visibleDemTiles.filter((function(e){return e.dem})).forEach((function(t){e=Math.min(e,t.dem.tree.minimums[0])})),0===e?e:(e-30)*this._exaggeration}},{key:"raycast",value:function(e,t,r){if(!this._visibleDemTiles)return null;var i=this._visibleDemTiles.filter((function(e){return e.dem})).map((function(i){var n=i.tileID,a=1<l.end}))||e.w("fill-extrusion with flood lighting and/or ground ambient occlusion should be moved to be on top of all draped layers.")}this._drapedRenderBatches=i}}},{key:"_setupRenderCache",value:function(e){var t=this.proxySourceCache;if(this._shouldDisableRenderCache()||this.invalidateRenderCache){if(this.invalidateRenderCache=!1,t.renderCache.length>t.renderCachePool.length){var r=Object.values(t.proxyCachedFBO);t.proxyCachedFBO={};for(var i=0;i=0;l--){var u=o[l];if(t.getTileByID(u.key),void 0!==t.proxyCachedFBO[u.key]){var c=e[u.key],h=this.proxyToSource[u.key],f=0,p=function(e){var t=h[e],r=c[e];if(!r||r.length!==t.length||t.some((function(t,i){return t!==r[i]||s[e]&&s[e].hasOwnProperty(t.key)})))return f=-1,1;++f};for(var m in h)if(p(m))break;for(var v in t.proxyCachedFBO[u.key])t.renderCache[t.proxyCachedFBO[u.key][v]].dirty=f<0||f!==Object.values(c).length}}var _=d(this._drapedRenderBatches);for(var y of(_.sort((function(e,t){return t.end-t.start-(e.end-e.start)})),_))for(var g of o)if(!t.proxyCachedFBO[g.key]){var x=t.renderCachePool.pop();void 0===x&&t.renderCache.length<50&&(x=t.renderCache.length,t.renderCache.push(this._createFBO())),void 0!==x&&(t.proxyCachedFBO[g.key]={},t.proxyCachedFBO[g.key][y.start]=x,t.renderCache[x].dirty=!0)}this._tilesDirty={}}}},{key:"_setupStencil",value:function(e,t,r,i){if(i&&this._sourceTilesOverlap[i.id]){var n=this.painter.context,a=n.gl;if(t.length<=1)this._overlapStencilType=!1;else{var o;if(r.isTileClipped())o=t.length,this._overlapStencilMode.test={func:a.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(t[0].overscaledZ>t[t.length-1].overscaledZ))return void(this._overlapStencilType=!1);o=1,this._overlapStencilMode.test={func:a.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+o>255&&(n.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=o,this._overlapStencilMode.ref=this._stencilRef,r.isTileClipped()&&this._renderTileClippingMasks(t,this._overlapStencilMode.ref)}}else this._overlapStencilType&&(this._overlapStencilType=!1)}},{key:"clipOrMaskOverlapStencilType",value:function(){return"Clip"===this._overlapStencilType||"Mask"===this._overlapStencilType}},{key:"stencilModeForRTTOverlap",value:function(e){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[e.key]),this._overlapStencilMode):ii.disabled}},{key:"_renderTileClippingMasks",value:function(e,t){var r=this.painter,i=this.painter.context,n=i.gl;r._tileClippingMaskIDs={},i.setColorMode(ei.disabled),i.setDepthMode(ti.disabled);var a=r.getOrCreateProgram("clippingMask");for(var o of e){var s=r._tileClippingMaskIDs[o.key]=--t;a.draw(r,n.TRIANGLES,ti.disabled,new ii({func:n.ALWAYS,mask:0},s,255,n.KEEP,n.KEEP,n.REPLACE),ei.disabled,oi.disabled,ta(o.projMatrix),"$clipping",r.tileExtentBuffer,r.quadTriangleIndexBuffer,r.tileExtentSegments)}}},{key:"pointCoordinate",value:function(t){var r=this.painter.transform;if(t.x<0||t.x>r.width||t.y<0||t.y>r.height)return null;var i=[t.x,t.y,1,1];e.a6.vec4.transformMat4(i,i,r.pixelMatrixInverse),e.a6.vec4.scale(i,i,1/i[3]),i[0]/=r.worldSize,i[1]/=r.worldSize;var n=r._camera.position,a=e.bD(1,r.center.lat),o=[n[0],n[1],n[2]/a,0],s=e.a6.vec3.subtract([],i.slice(0,3),o);e.a6.vec3.normalize(s,s);var l=this.raycast(o,s,this._exaggeration);return null!==l&&l?(e.a6.vec3.scaleAndAdd(o,o,s,l),o[3]=o[2],o[2]*=a,o):null}},{key:"_setupProxiedCoordsForOrtho",value:function(t,r,i){if(t.getSource()instanceof e.aD)return this._setupProxiedCoordsForImageSource(t,r,i);this._findCoveringTileCache[t.id]=this._findCoveringTileCache[t.id]||{};for(var n=this.proxiedCoords[t.id]=[],a=this.proxyCoords,o=0;oo+u.max.x||n+as+u.max.y},h=0;h0?(s=(o=e.ab>>u)*((r.tileID.canonical.x<=c){var h=t.canonical.z-c;r.getSource().reparseOverscaled?(s=Math.max(t.canonical.z+2,r.transform.tileZoom),o=new e.aA(s,t.wrap,c,t.canonical.x>>h,t.canonical.y>>h)):0!==h&&(s=c,o=new e.aA(s,t.wrap,c,t.canonical.x>>h,t.canonical.y>>h))}o.key!==t.key&&(u.push(o.key),i=r.getTile(o))}var f=function(e){u.forEach((function(t){n[t]=e})),u.length=0};for(s-=1;s>=l&&(!i||!i.hasData());s--){i&&f(i.tileID.key);var d=o.calculateScaledKey(s);if((i=r.getTileByID(d))&&i.hasData())break;var p=n[d];if(null===p)break;void 0===p?u.push(d):i=r.getTileByID(p)}return f(i?i.tileID.key:null),i&&i.hasData()?i:null}},{key:"findDEMTileFor",value:function(e){return this.enabled?this._findTileCoveringTileID(e,this.sourceCache):null}},{key:"prepareDrawTile",value:function(){this.renderedToTile=!0}},{key:"_clearRenderCacheForTile",value:function(e,t){var r=this._tilesDirty[e];r||(r=this._tilesDirty[e]={}),r[t.key]=!0}}])})(e.cE);function sa(t,r,i){var n=(function(t,r,i){var n=e.a6.vec3.dot(r,t),a=e.a6.vec3.dot(i,[.2126,.7152,.0722]),o=function(e,t,r){return(1-r)*e+r*t},s=o(1-.3*Math.min(a,1),1,Math.min(n+1,1));return o(.92,1,Math.asin(e.ap(r[2],-1,1))/Math.PI+.5)*s})(t,[0,0,1],r),a=[0,0,0];e.a6.vec3.scale(a,i.slice(0,3),n);var o=[0,0,0];e.a6.vec3.scale(o,r.slice(0,3),t[2]);var s=[0,0,0];return e.a6.vec3.add(s,a,o),e.cb(s)}var la=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],ua=["stars","fillExtrusion","fillExtrusionGroundEffect","model","symbol"],ca=(function(){return m((function t(r,i,n,a,o,s){p(this,t);var l=r.gl;this.program=l.createProgram(),this.configuration=a,this.name=i,this.fixedDefines=d(s);var u=a?a.getBinderAttributes():[],c=(n.staticAttributes||[]).concat(u),h=a?a.defines():[];h=h.concat(s.map((function(e){return`#define ${e}`})));var f="#version 300 es\n",m=f+h.concat("precision mediump float;",tn,en.fragmentSource).join("\n");for(var v of n.fragmentIncludes)m+=`\n${Ki[v]}`;m+=`\n${n.fragmentSource}`;var _=f+h.concat("precision highp float;",tn,en.vertexSource).join("\n");for(var y of n.vertexIncludes)_+=`\n${Ki[y]}`;_+=`\n${n.vertexSource}`;var g=l.createShader(l.FRAGMENT_SHADER);if(l.isContextLost())this.failedToCreate=!0;else{l.shaderSource(g,m),l.compileShader(g),l.attachShader(this.program,g);var x=l.createShader(l.VERTEX_SHADER);if(l.isContextLost())this.failedToCreate=!0;else{l.shaderSource(x,_),l.compileShader(x),l.attachShader(this.program,x),this.attributes={},this.numAttributes=c.length;for(var b=0;b1?m.drawElementsInstanced(m.LINES,x,m.UNSIGNED_SHORT,b,c):m.drawElements(m.LINES,x,m.UNSIGNED_SHORT,b),a.bind(),p.program.set(this.program),p.setDepthMode(r),p.setStencilMode(i),p.setColorMode(n)}}}}},{key:"draw",value:function(e,t,r,i,n,a,o,l,u,c,h,f,d,p,m,v){var _=e.context,y=_.gl;if(!this.failedToCreate){for(var g of(_.program.set(this.program),_.setDepthMode(r),_.setStencilMode(i),_.setColorMode(n),_.setCullFace(a),Object.keys(this.fixedUniforms)))this.fixedUniforms[g].set(this.program,g,o[g]);p&&p.setUniforms(this.program,_,this.binderUniforms,f,{zoom:d});var x=s(s(s(s({},y.POINTS,1),y.LINES,2),y.TRIANGLES,3),y.LINE_STRIP,1)[t],b=v&&v>0?1:void 0;for(var w of h.get()){var k=w.vaos||(w.vaos={});(k[l]||(k[l]=new on)).bind(_,this,u,p?p.getPaintVertexBuffers():[],c,w.vertexOffset,m||[],b),v&&v>1?y.drawElementsInstanced(t,w.primitiveLength*x,y.UNSIGNED_SHORT,w.primitiveOffset*x*2,v):c?y.drawElements(t,w.primitiveLength*x,y.UNSIGNED_SHORT,w.primitiveOffset*x*2):y.drawArrays(t,w.vertexOffset,w.vertexLength),t===y.TRIANGLES&&c&&this._drawDebugWireframe(e,r,i,n,c,w,f,d,p,v)}}}}],[{key:"cacheKey",value:function(e,t,r,i){var n=`${t}${i?i.cacheKey:""}`;for(var a of r)e.usedDefines.includes(a)&&(n+=`/${a}`);return n}}])})();function ha(t,r){var i=Math.pow(2,r.tileID.overscaledZ),n=r.tileSize*Math.pow(2,t.transform.tileZoom)/i,a=n*(r.tileID.canonical.x+r.tileID.wrap*i),o=n*r.tileID.canonical.y;return{u_image:0,u_texsize:r.imageAtlasTexture?r.imageAtlasTexture.size:[0,0],u_tile_units_to_pixels:1/e.ak(r,1,t.transform.tileZoom),u_pixel_coord_upper:[a>>16,o>>16],u_pixel_coord_lower:[65535&a,65535&o]}}var fa=e.a6.mat4.create(),da=function(t,r,i,n,a,o,s,l,u,c,h,f,d,p,m,v){var _=r.style.light,y=_.properties.get("position"),g=[y.x,y.y,y.z],x=e.a6.mat3.create();"viewport"===_.properties.get("anchor")&&(e.a6.mat3.fromRotation(x,-r.transform.angle),e.a6.vec3.transformMat3(g,g,x));var b=_.properties.get("color"),w=r.transform,k={u_matrix:t,u_lightpos:g,u_lightintensity:_.properties.get("intensity"),u_lightcolor:[b.r,b.g,b.b],u_vertical_gradient:+i,u_opacity:n,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:fa,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_ao:a,u_edge_radius:o,u_width_scale:s,u_flood_light_color:d,u_vertical_scale:p,u_flood_light_intensity:m,u_ground_shadow_factor:v};return"globe"===w.projection.name&&(k.u_tile_id=[l.canonical.x,l.canonical.y,1<2&&void 0!==arguments[2]?arguments[2]:1;return{u_matrix:e,u_color:t.toRenderColor(null),u_overlay:0,u_overlay_scale:r}},wa=e.a6.mat4.create(),ka=function(t,r,i,n,a,o,s){var l=t.transform,u="globe"===l.projection.name,c=u?e.cI(l.zoom,r.canonical)*l._pixelsPerMercatorPixel:e.ak(i,1,o),h={u_matrix:r.projMatrix,u_extrude_scale:c,u_intensity:s,u_inv_rot_matrix:wa,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(u){h.u_inv_rot_matrix=n,h.u_merc_center=a,h.u_tile_id=[r.canonical.x,r.canonical.y,1<>16,d>>16],u_pixel_coord_lower:[65535&f,65535&d]}})(0,o,s,n,l,u),{u_matrix:t,u_emissive_strength:r,u_opacity:i})},Oa=new Float32Array(e.a6.mat4.identity([])),Ba=function(t,r,i,n,a,o,s,l,u,c,h,f,d){var p=arguments.length>13&&void 0!==arguments[13]?arguments[13]:[0,0,0],m=arguments.length>14?arguments[14]:void 0,v=a.style.light,_=v.properties.get("position"),y=[-_.x,-_.y,_.z],g=e.a6.mat3.create();"viewport"===v.properties.get("anchor")&&(e.a6.mat3.fromRotation(g,-a.transform.angle),e.a6.vec3.transformMat3(y,y,g));var x="MASK"===h.alphaMode,b=v.properties.get("color").toRenderColor(null),w=d.paint.get("model-ambient-occlusion-intensity"),k=d.paint.get("model-color").constantOr(e.bz.white).toRenderColor(null),T=d.paint.get("model-color-mix-intensity").constantOr(0);return{u_matrix:t,u_lighting_matrix:r,u_normal_matrix:i,u_node_matrix:n||Oa,u_lightpos:y,u_lightintensity:v.properties.get("intensity"),u_lightcolor:[b.r,b.g,b.b],u_camera_pos:p,u_opacity:o,u_baseTextureIsAlpha:0,u_alphaMask:+x,u_alphaCutoff:h.alphaCutoff,u_baseColorFactor:[s.r,s.g,s.b,s.a],u_emissiveFactor:[l[0],l[1],l[2],1],u_metallicFactor:u,u_roughnessFactor:c,u_baseColorTexture:fi,u_metallicRoughnessTexture:di,u_normalTexture:pi,u_occlusionTexture:mi,u_emissionTexture:vi,u_lutTexture:_i,u_color_mix:[k.r,k.g,k.b,T],u_aoIntensity:w,u_emissive_strength:f,u_occlusionTextureTransform:m||[0,0,0,0]}},Fa=function(e){return{u_matrix:e,u_instance:arguments.length>1&&void 0!==arguments[1]?arguments[1]:Oa,u_node_matrix:arguments.length>2&&void 0!==arguments[2]?arguments[2]:Oa}},Na={fillExtrusion:function(t){return{u_matrix:new e.bF(t),u_lightpos:new e.bH(t),u_lightintensity:new e.bI(t),u_lightcolor:new e.bH(t),u_vertical_gradient:new e.bI(t),u_opacity:new e.bI(t),u_edge_radius:new e.bI(t),u_width_scale:new e.bI(t),u_ao:new e.bG(t),u_tile_id:new e.bH(t),u_zoom_transition:new e.bI(t),u_inv_rot_matrix:new e.bF(t),u_merc_center:new e.bG(t),u_up_dir:new e.bH(t),u_height_lift:new e.bI(t),u_flood_light_color:new e.bH(t),u_vertical_scale:new e.bI(t),u_flood_light_intensity:new e.bI(t),u_ground_shadow_factor:new e.bH(t)}},fillExtrusionDepth:function(t){return{u_matrix:new e.bF(t),u_edge_radius:new e.bI(t),u_width_scale:new e.bI(t),u_vertical_scale:new e.bI(t)}},fillExtrusionPattern:function(t){return{u_matrix:new e.bF(t),u_lightpos:new e.bH(t),u_lightintensity:new e.bI(t),u_lightcolor:new e.bH(t),u_vertical_gradient:new e.bI(t),u_height_factor:new e.bI(t),u_edge_radius:new e.bI(t),u_width_scale:new e.bI(t),u_ao:new e.bG(t),u_tile_id:new e.bH(t),u_zoom_transition:new e.bI(t),u_inv_rot_matrix:new e.bF(t),u_merc_center:new e.bG(t),u_up_dir:new e.bH(t),u_height_lift:new e.bI(t),u_image:new e.bJ(t),u_texsize:new e.bG(t),u_pixel_coord_upper:new e.bG(t),u_pixel_coord_lower:new e.bG(t),u_tile_units_to_pixels:new e.bI(t),u_opacity:new e.bI(t)}},fillExtrusionGroundEffect:function(t){return{u_matrix:new e.bF(t),u_opacity:new e.bI(t),u_ao_pass:new e.bI(t),u_meter_to_tile:new e.bI(t),u_ao:new e.bG(t),u_flood_light_intensity:new e.bI(t),u_flood_light_color:new e.bH(t),u_attenuation:new e.bI(t),u_edge_radius:new e.bI(t),u_fb:new e.bJ(t),u_fb_size:new e.bI(t),u_dynamic_offset:new e.bI(t)}},fill:function(t){return{u_matrix:new e.bF(t),u_emissive_strength:new e.bI(t)}},fillPattern:function(t){return{u_matrix:new e.bF(t),u_emissive_strength:new e.bI(t),u_image:new e.bJ(t),u_texsize:new e.bG(t),u_pixel_coord_upper:new e.bG(t),u_pixel_coord_lower:new e.bG(t),u_tile_units_to_pixels:new e.bI(t)}},fillOutline:function(t){return{u_matrix:new e.bF(t),u_emissive_strength:new e.bI(t),u_world:new e.bG(t)}},fillOutlinePattern:function(t){return{u_matrix:new e.bF(t),u_emissive_strength:new e.bI(t),u_world:new e.bG(t),u_image:new e.bJ(t),u_texsize:new e.bG(t),u_pixel_coord_upper:new e.bG(t),u_pixel_coord_lower:new e.bG(t),u_tile_units_to_pixels:new e.bI(t)}},circle:e.cN,collisionBox:function(t){return{u_matrix:new e.bF(t),u_camera_to_center_distance:new e.bI(t),u_extrude_scale:new e.bG(t)}},collisionCircle:function(t){return{u_matrix:new e.bF(t),u_inv_matrix:new e.bF(t),u_camera_to_center_distance:new e.bI(t),u_viewport_size:new e.bG(t)}},debug:function(t){return{u_color:new e.cu(t),u_matrix:new e.bF(t),u_overlay:new e.bJ(t),u_overlay_scale:new e.bI(t)}},clippingMask:function(t){return{u_matrix:new e.bF(t)}},heatmap:function(t){return{u_extrude_scale:new e.bI(t),u_intensity:new e.bI(t),u_matrix:new e.bF(t),u_inv_rot_matrix:new e.bF(t),u_merc_center:new e.bG(t),u_tile_id:new e.bH(t),u_zoom_transition:new e.bI(t),u_up_dir:new e.bH(t)}},heatmapTexture:function(t){return{u_image:new e.bJ(t),u_color_ramp:new e.bJ(t),u_opacity:new e.bI(t)}},hillshade:function(t){return{u_matrix:new e.bF(t),u_image:new e.bJ(t),u_latrange:new e.bG(t),u_light:new e.bG(t),u_shadow:new e.cu(t),u_highlight:new e.cu(t),u_emissive_strength:new e.bI(t),u_accent:new e.cu(t)}},hillshadePrepare:function(t){return{u_matrix:new e.bF(t),u_image:new e.bJ(t),u_dimension:new e.bG(t),u_zoom:new e.bI(t)}},line:e.cO,linePattern:e.cP,raster:function(t){return{u_matrix:new e.bF(t),u_normalize_matrix:new e.bF(t),u_globe_matrix:new e.bF(t),u_merc_matrix:new e.bF(t),u_grid_matrix:new e.cv(t),u_tl_parent:new e.bG(t),u_scale_parent:new e.bI(t),u_fade_t:new e.bI(t),u_opacity:new e.bI(t),u_image0:new e.bJ(t),u_image1:new e.bJ(t),u_brightness_low:new e.bI(t),u_brightness_high:new e.bI(t),u_saturation_factor:new e.bI(t),u_contrast_factor:new e.bI(t),u_spin_weights:new e.bH(t),u_perspective_transform:new e.bG(t),u_raster_elevation:new e.bI(t),u_zoom_transition:new e.bI(t),u_merc_center:new e.bG(t),u_cutoff_params:new e.c6(t),u_colorization_mix:new e.c6(t),u_colorization_offset:new e.bI(t),u_color_ramp:new e.bJ(t),u_texture_offset:new e.bG(t),u_texture_res:new e.bG(t),u_emissive_strength:new e.bI(t)}},rasterParticle:function(t){return{u_matrix:new e.bF(t),u_normalize_matrix:new e.bF(t),u_globe_matrix:new e.bF(t),u_merc_matrix:new e.bF(t),u_grid_matrix:new e.cv(t),u_tl_parent:new e.bG(t),u_scale_parent:new e.bI(t),u_fade_t:new e.bI(t),u_opacity:new e.bI(t),u_image0:new e.bJ(t),u_image1:new e.bJ(t),u_raster_elevation:new e.bI(t),u_zoom_transition:new e.bI(t),u_merc_center:new e.bG(t),u_cutoff_params:new e.c6(t)}},rasterParticleTexture:function(t){return{u_texture:new e.bJ(t),u_opacity:new e.bI(t)}},rasterParticleDraw:function(t){return{u_particle_texture:new e.bJ(t),u_particle_texture_side_len:new e.bI(t),u_tile_offset:new e.bG(t),u_velocity:new e.bJ(t),u_color_ramp:new e.bJ(t),u_velocity_res:new e.bG(t),u_max_speed:new e.bI(t),u_uv_offset:new e.bG(t),u_data_scale:new e.bG(t),u_data_offset:new e.bI(t),u_particle_pos_scale:new e.bI(t),u_particle_pos_offset:new e.bG(t)}},rasterParticleUpdate:function(t){return{u_particle_texture:new e.bJ(t),u_particle_texture_side_len:new e.bI(t),u_velocity:new e.bJ(t),u_velocity_res:new e.bG(t),u_max_speed:new e.bI(t),u_speed_factor:new e.bI(t),u_reset_rate:new e.bI(t),u_rand_seed:new e.bI(t),u_uv_offset:new e.bG(t),u_data_scale:new e.bG(t),u_data_offset:new e.bI(t),u_particle_pos_scale:new e.bI(t),u_particle_pos_offset:new e.bG(t)}},symbol:function(t){return{u_is_size_zoom_constant:new e.bJ(t),u_is_size_feature_constant:new e.bJ(t),u_size_t:new e.bI(t),u_size:new e.bI(t),u_camera_to_center_distance:new e.bI(t),u_rotate_symbol:new e.bJ(t),u_aspect_ratio:new e.bI(t),u_fade_change:new e.bI(t),u_matrix:new e.bF(t),u_label_plane_matrix:new e.bF(t),u_coord_matrix:new e.bF(t),u_is_text:new e.bJ(t),u_elevation_from_sea:new e.bJ(t),u_pitch_with_map:new e.bJ(t),u_texsize:new e.bG(t),u_texsize_icon:new e.bG(t),u_texture:new e.bJ(t),u_texture_icon:new e.bJ(t),u_gamma_scale:new e.bI(t),u_device_pixel_ratio:new e.bI(t),u_tile_id:new e.bH(t),u_zoom_transition:new e.bI(t),u_inv_rot_matrix:new e.bF(t),u_merc_center:new e.bG(t),u_camera_forward:new e.bH(t),u_tile_matrix:new e.bF(t),u_up_vector:new e.bH(t),u_ecef_origin:new e.bH(t),u_is_halo:new e.bJ(t),u_icon_transition:new e.bI(t),u_color_adj_mat:new e.bF(t)}},background:function(t){return{u_matrix:new e.bF(t),u_emissive_strength:new e.bI(t),u_opacity:new e.bI(t),u_color:new e.cu(t)}},backgroundPattern:function(t){return{u_matrix:new e.bF(t),u_emissive_strength:new e.bI(t),u_opacity:new e.bI(t),u_image:new e.bJ(t),u_pattern_tl:new e.bG(t),u_pattern_br:new e.bG(t),u_texsize:new e.bG(t),u_pattern_size:new e.bG(t),u_pixel_coord_upper:new e.bG(t),u_pixel_coord_lower:new e.bG(t),u_pattern_units_to_pixels:new e.bG(t)}},terrainRaster:function(t){return{u_matrix:new e.bF(t),u_image0:new e.bJ(t),u_skirt_height:new e.bI(t),u_ground_shadow_factor:new e.bH(t)}},skybox:function(t){return{u_matrix:new e.bF(t),u_sun_direction:new e.bH(t),u_cubemap:new e.bJ(t),u_opacity:new e.bI(t),u_temporal_offset:new e.bI(t)}},skyboxGradient:function(t){return{u_matrix:new e.bF(t),u_color_ramp:new e.bJ(t),u_center_direction:new e.bH(t),u_radius:new e.bI(t),u_opacity:new e.bI(t),u_temporal_offset:new e.bI(t)}},skyboxCapture:function(t){return{u_matrix_3f:new e.cv(t),u_sun_direction:new e.bH(t),u_sun_intensity:new e.bI(t),u_color_tint_r:new e.c6(t),u_color_tint_m:new e.c6(t),u_luminance:new e.bI(t)}},globeRaster:function(t){return{u_proj_matrix:new e.bF(t),u_globe_matrix:new e.bF(t),u_normalize_matrix:new e.bF(t),u_merc_matrix:new e.bF(t),u_zoom_transition:new e.bI(t),u_merc_center:new e.bG(t),u_image0:new e.bJ(t),u_grid_matrix:new e.cv(t),u_skirt_height:new e.bI(t),u_far_z_cutoff:new e.bI(t),u_frustum_tl:new e.bH(t),u_frustum_tr:new e.bH(t),u_frustum_br:new e.bH(t),u_frustum_bl:new e.bH(t),u_globe_pos:new e.bH(t),u_globe_radius:new e.bI(t),u_viewport:new e.bG(t)}},globeAtmosphere:function(t){return{u_frustum_tl:new e.bH(t),u_frustum_tr:new e.bH(t),u_frustum_br:new e.bH(t),u_frustum_bl:new e.bH(t),u_horizon:new e.bI(t),u_transition:new e.bI(t),u_fadeout_range:new e.bI(t),u_color:new e.c6(t),u_high_color:new e.c6(t),u_space_color:new e.c6(t),u_temporal_offset:new e.bI(t),u_horizon_angle:new e.bI(t)}},model:function(t){return{u_matrix:new e.bF(t),u_lighting_matrix:new e.bF(t),u_normal_matrix:new e.bF(t),u_node_matrix:new e.bF(t),u_lightpos:new e.bH(t),u_lightintensity:new e.bI(t),u_lightcolor:new e.bH(t),u_camera_pos:new e.bH(t),u_opacity:new e.bI(t),u_baseColorFactor:new e.c6(t),u_emissiveFactor:new e.c6(t),u_metallicFactor:new e.bI(t),u_roughnessFactor:new e.bI(t),u_baseTextureIsAlpha:new e.bJ(t),u_alphaMask:new e.bJ(t),u_alphaCutoff:new e.bI(t),u_baseColorTexture:new e.bJ(t),u_metallicRoughnessTexture:new e.bJ(t),u_normalTexture:new e.bJ(t),u_occlusionTexture:new e.bJ(t),u_emissionTexture:new e.bJ(t),u_lutTexture:new e.bJ(t),u_color_mix:new e.c6(t),u_aoIntensity:new e.bI(t),u_emissive_strength:new e.bI(t),u_occlusionTextureTransform:new e.c6(t)}},modelDepth:function(t){return{u_matrix:new e.bF(t),u_instance:new e.bF(t),u_node_matrix:new e.bF(t)}},groundShadow:function(t){return{u_matrix:new e.bF(t),u_ground_shadow_factor:new e.bH(t)}},stars:function(t){return{u_matrix:new e.bF(t),u_up:new e.bH(t),u_right:new e.bH(t),u_intensity_multiplier:new e.bI(t)}},occlusion:function(t){return{u_matrix:new e.bF(t),u_anchorPos:new e.bH(t),u_screenSizePx:new e.bG(t),u_occluderSizePx:new e.bG(t),u_color:new e.c6(t)}}},Va=(function(){function e(t,r,i,n){p(this,e),this.id=e.uniqueIdxCounter,e.uniqueIdxCounter++,this.context=t;var a=t.gl;this.buffer=a.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),a.bufferData(a.ELEMENT_ARRAY_BUFFER,r.arrayBuffer,this.dynamicDraw?a.DYNAMIC_DRAW:a.STATIC_DRAW),this.dynamicDraw||n||r.destroy()}return m(e,[{key:"bind",value:function(){this.context.bindElementBuffer.set(this.buffer)}},{key:"updateData",value:function(t){this.id=e.uniqueIdxCounter,e.uniqueIdxCounter++;var r=this.context.gl;this.context.unbindVAO(),this.bind(),r.bufferSubData(r.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)}},{key:"destroy",value:function(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}])})();Va.uniqueIdxCounter=0;var Ua,ja={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"},Ga=(function(){return m((function e(t,r,i,n,a,o){p(this,e),this.length=r.length,this.attributes=i,this.itemSize=r.bytesPerElement,this.dynamicDraw=n,this.instanceCount=o,this.context=t;var s=t.gl;this.buffer=s.createBuffer(),t.bindVertexBuffer.set(this.buffer),s.bufferData(s.ARRAY_BUFFER,r.arrayBuffer,this.dynamicDraw?s.DYNAMIC_DRAW:s.STATIC_DRAW),this.dynamicDraw||a||r.destroy()}),[{key:"bind",value:function(){this.context.bindVertexBuffer.set(this.buffer)}},{key:"updateData",value:function(e){var t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer)}},{key:"enableAttributes",value:function(e,t){for(var r=0;r0&&e.vertexAttribDivisor(n,r)}}},{key:"destroy",value:function(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}])})(),qa=(function(){return m((function e(t,r,i,n,a){p(this,e),this.context=t,this.width=r,this.height=i;var o=this.framebuffer=t.gl.createFramebuffer();n&&(this.colorAttachment=new qn(t,o)),a&&(this.depthAttachmentType=a,this.depthAttachment="renderbuffer"===a?new Zn(t,o):new $n(t,o))}),[{key:"destroy",value:function(){var e=this.context.gl;if(this.colorAttachment){var t=this.colorAttachment.get();t&&e.deleteTexture(t)}if(this.depthAttachment&&this.depthAttachmentType)if("renderbuffer"===this.depthAttachmentType){var r=this.depthAttachment.get();r&&e.deleteRenderbuffer(r)}else{var i=this.depthAttachment.get();i&&e.deleteTexture(i)}e.deleteFramebuffer(this.framebuffer)}}])})(),Za=(function(){return m((function e(t,r){p(this,e),this.gl=t,this.clearColor=new fn(this),this.clearDepth=new dn(this),this.clearStencil=new pn(this),this.colorMask=new mn(this),this.depthMask=new vn(this),this.stencilMask=new _n(this),this.stencilFunc=new yn(this),this.stencilOp=new gn(this),this.stencilTest=new xn(this),this.depthRange=new bn(this),this.depthTest=new wn(this),this.depthFunc=new kn(this),this.blend=new Tn(this),this.blendFunc=new Mn(this),this.blendColor=new Sn(this),this.blendEquation=new En(this),this.cullFace=new In(this),this.cullFaceSide=new An(this),this.frontFace=new Cn(this),this.program=new Pn(this),this.activeTexture=new zn(this),this.viewport=new Dn(this),this.bindFramebuffer=new Rn(this),this.bindRenderbuffer=new Ln(this),this.bindTexture=new On(this),this.bindVertexBuffer=new Bn(this),this.bindElementBuffer=new Fn(this),this.bindVertexArrayOES=new Nn(this),this.pixelStoreUnpack=new Vn(this),this.pixelStoreUnpackPremultiplyAlpha=new Un(this),this.pixelStoreUnpackFlipY=new jn(this),this.options=r?Object.assign({},r):{},this.options.extTextureFilterAnisotropicForceOff||(this.extTextureFilterAnisotropic=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=t.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT))),this.extDebugRendererInfo=t.getExtension("WEBGL_debug_renderer_info"),this.extDebugRendererInfo&&(this.renderer=t.getParameter(this.extDebugRendererInfo.UNMASKED_RENDERER_WEBGL),this.vendor=t.getParameter(this.extDebugRendererInfo.UNMASKED_VENDOR_WEBGL)),this.options.extTextureFloatLinearForceOff||(this.extTextureFloatLinear=t.getExtension("OES_texture_float_linear")),this.extRenderToTextureHalfFloat=t.getExtension("EXT_color_buffer_half_float"),this.extTimerQuery=t.getExtension("EXT_disjoint_timer_query_webgl2"),this.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE),this.maxPointSize=t.getParameter(t.ALIASED_POINT_SIZE_RANGE)[1]}),[{key:"setDefault",value:function(){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()}},{key:"setDirty",value:function(){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}},{key:"createIndexBuffer",value:function(e,t,r){return new Va(this,e,t,r)}},{key:"createVertexBuffer",value:function(e,t,r,i,n){return new Ga(this,e,t,r,i,n)}},{key:"createRenderbuffer",value:function(e,t,r){var i=this.gl,n=i.createRenderbuffer();return this.bindRenderbuffer.set(n),i.renderbufferStorage(i.RENDERBUFFER,e,t,r),this.bindRenderbuffer.set(null),n}},{key:"createFramebuffer",value:function(e,t,r,i){return new qa(this,e,t,r,i)}},{key:"clear",value:function(e){var t=e.color,r=e.depth,i=e.stencil,n=e.colorMask,a=this.gl,o=0;t&&(o|=a.COLOR_BUFFER_BIT,this.clearColor.set(t),this.colorMask.set(n||[!0,!0,!0,!0])),void 0!==r&&(o|=a.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(r),this.depthMask.set(!0)),void 0!==i&&(o|=a.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),a.clear(o)}},{key:"setCullFace",value:function(e){!1===e.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(e.mode),this.frontFace.set(e.frontFace))}},{key:"setDepthMode",value:function(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)}},{key:"setStencilMode",value:function(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)}},{key:"setColorMode",value:function(t){e.bh(t.blendFunction,ei.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)}},{key:"unbindVAO",value:function(){this.bindVertexArrayOES.set(null)}}])})();function $a(t,r,i,n,a,o,s){for(var l=t.context,u=l.gl,c=t.transform,h=t.getOrCreateProgram("collisionBox"),f=[],d=0,p=0,m=0;m0){var k=e.a6.mat4.create(),T=x;e.a6.mat4.mul(k,y.placementInvProjMatrix,c.glCoordMatrix),e.a6.mat4.mul(k,k,y.placementViewportMatrix),f.push({circleArray:w,circleOffset:p,transform:T,invTransform:k,projection:y.getProjection()}),p=d+=w.length/4}b&&(t.terrain&&t.terrain.setupElevationDraw(_,h),h.draw(t,u.LINES,ti.disabled,ii.disabled,t.colorModeForRenderPass(),oi.disabled,xa(x,c,_,y.getProjection()),i.id,b.layoutVertexBuffer,b.indexBuffer,b.segments,null,c.zoom,null,[b.collisionVertexBuffer,b.collisionVertexBufferExt]))}}if(s&&f.length){var M=t.getOrCreateProgram("collisionCircle"),S=new e.cQ;S.resize(4*d),S._trim();var E=0;for(var I of f)for(var A=0;A=0&&(m[w.associatedIconIndex]={x:F,y:N,z:V,angle:Z})}else xr(M,d)}if(h){p.clear();for(var H=t.icon.placedSymbolArray,W=0;W6&&void 0!==arguments[6]?arguments[6]:{},l=i.paint.get("icon-translate"),u=i.paint.get("text-translate"),c=i.paint.get("icon-translate-anchor"),h=i.paint.get("text-translate-anchor"),f=i.layout.get("icon-rotation-alignment"),d=i.layout.get("text-rotation-alignment"),p=i.layout.get("icon-pitch-alignment"),m=i.layout.get("text-pitch-alignment"),v=i.layout.get("icon-keep-upright"),_=i.layout.get("text-keep-upright"),y=i.paint.get("icon-color-saturation"),g=i.paint.get("icon-color-contrast"),x=i.paint.get("icon-color-brightness-min"),b=i.paint.get("icon-color-brightness-max"),w="sea"===i.paint.get("symbol-elevation-reference"),k=i.paint.get("text-occlusion-opacity").constantOr(0),T=t.context,M=T.gl,S=t.transform,E="map"===f,I="map"===d,A="map"===p,C="map"===m,P=void 0!==i.layout.get("symbol-sort-key").constantOr(1),z=!1,D=t.depthModeForSublayer(0,ti.ReadOnly),R=[e.am(S.center.lng),e.at(S.center.lat)],L=i.layout.get("text-variable-anchor"),O="globe"===S.projection.name,B=[],F=[0,-1,0],N=function(n){var a=r.getTile(n),o=a.getBucket(i);if(!o)return 0;if("mercator"===o.projection.name&&O)return 0;if(o.fullyClipped)return 0;var f="globe"===o.projection.name,d=f?e.a9(S.zoom):0,p=Sr(n,o.getProjection(),S),m=S.calculatePixelsToTileUnitsMatrix(a),T=L&&o.hasTextData(),D=o.hasIconTextFit()&&T&&o.hasIconData(),N=o.getProjection().createInversionMatrix(S,n.canonical),V=function(e){S.depthOcclusionForSymbolsAndCircles&&(i.hasInitialOcclusionOpacityProperties||t.terrain)&&(e.push("DEPTH_D24"),e.push("DEPTH_OCCLUSION"))},U=o.icon.segments.get().length,j=o.text.segments.get().length,G=U&&!s.onlyText?(function(){var r=E&&"point"!==i.layout.get("symbol-placement"),s=[];V(s);var u=r||D,h=i.paint.get("icon-image-cross-fade").constantOr(0);t.terrainRenderModeElevated()&&A&&s.push("PITCH_WITH_MAP_TERRAIN"),f&&(s.push("PROJECTION_GLOBE_VIEW"),u&&s.push("PROJECTED_POS_ON_VIEWPORT")),h>0&&s.push("ICON_TRANSITION"),o.icon.zOffsetVertexBuffer&&s.push("Z_OFFSET"),0===y&&0===g&&0===x&&1===b||s.push("COLOR_ADJUSTMENT"),o.sdfIcons&&s.push("RENDER_SDF");var _=o.icon.programConfigurations.get(i.id),k=t.getOrCreateProgram("symbol",{config:_,defines:s}),T=a.imageAtlasTexture?a.imageAtlasTexture.size:[0,0],I=o.iconSizeData,C=e.bj(I,S.zoom),P=A||0!==S.pitch,z=sr(p,a.tileID.canonical,A,E,S,o.getProjection(),m),L=ur(p,a.tileID.canonical,A,E,S,o.getProjection(),m),B=t.translatePosMatrix(L,a,l,c,!0),U=t.translatePosMatrix(p,a,l,c),j=u?Ha:z,G=E&&!A&&!r,q=F;!O&&!S.mercatorFromTransition||E||(q=Wa(S));var Z=f?q:F,$=i.getColorAdjustmentMatrix(y,g,x,b),H=Da(I.kind,C,G,A,t,U,j,B,w,!1,T,[0,0],!0,n,d,R,N,Z,o.getProjection(),$,h),W=a.imageAtlasTexture?a.imageAtlasTexture:null,X=1!==i.layout.get("icon-size").constantOr(0)||o.iconsNeedLinear,Y=o.sdfIcons||t.options.rotating||t.options.zooming||X||P?M.LINEAR:M.NEAREST,J=o.sdfIcons&&0!==i.paint.get("icon-halo-width").constantOr(1),K=t.terrain&&A&&r?e.a6.mat4.invert(e.a6.mat4.create(),z):Ha;if(r&&o.icon){var Q=S.elevation,ee=Q?Q.getAtTileOffsetFunc(n,S.center.lat,S.worldSize,o.getProjection()):null,te=lr(p,a.tileID.canonical,A,E,S,o.getProjection(),m);dr(o,p,t,!1,te,L,A,v,ee,n)}return{program:k,buffers:o.icon,uniformValues:H,atlasTexture:W,atlasTextureIcon:null,atlasInterpolation:Y,atlasInterpolationIcon:null,isSDF:o.sdfIcons,hasHalo:J,tile:a,labelPlaneMatrixInv:K}})():null,q=j&&!s.onlyIcons?(function(){var r=I&&"point"!==i.layout.get("symbol-placement"),s=[],l=r||L||D;t.terrainRenderModeElevated()&&C&&s.push("PITCH_WITH_MAP_TERRAIN"),f&&(s.push("PROJECTION_GLOBE_VIEW"),l&&s.push("PROJECTED_POS_ON_VIEWPORT")),o.text.zOffsetVertexBuffer&&s.push("Z_OFFSET"),o.iconsInText&&s.push("RENDER_TEXT_AND_SYMBOL"),s.push("RENDER_SDF"),V(s);var c,v=o.text.programConfigurations.get(i.id),y=t.getOrCreateProgram("symbol",{config:v,defines:s}),g=[0,0],x=null,b=o.textSizeData;o.iconsInText&&(g=a.imageAtlasTexture?a.imageAtlasTexture.size:[0,0],x=a.imageAtlasTexture?a.imageAtlasTexture:null,c=C||0!==S.pitch||t.options.rotating||t.options.zooming||"composite"===b.kind||"camera"===b.kind?M.LINEAR:M.NEAREST);var T=a.glyphAtlasTexture?a.glyphAtlasTexture.size:[0,0],E=e.bj(b,S.zoom),A=sr(p,a.tileID.canonical,C,I,S,o.getProjection(),m),P=ur(p,a.tileID.canonical,C,I,S,o.getProjection(),m),z=t.translatePosMatrix(P,a,u,h,!0),B=t.translatePosMatrix(p,a,u,h),U=l?Ha:A,j=I&&!C&&!r,G=F;!O&&!S.mercatorFromTransition||I||(G=Wa(S));var q=Da(b.kind,E,j,C,t,B,U,z,w,!0,T,g,!0,n,d,R,N,f?G:F,o.getProjection(),k),Z=a.glyphAtlasTexture?a.glyphAtlasTexture:null,$=M.LINEAR,H=0!==i.paint.get("text-halo-width").constantOr(1),W=t.terrain&&C&&r?e.a6.mat4.invert(e.a6.mat4.create(),A):Ha;if(r&&o.text){var X=S.elevation,Y=X?X.getAtTileOffsetFunc(n,S.center.lat,S.worldSize,o.getProjection()):null,J=lr(p,a.tileID.canonical,C,I,S,o.getProjection(),m);dr(o,p,t,!0,J,P,C,_,Y,n)}return{program:y,buffers:o.text,uniformValues:q,atlasTexture:Z,atlasTextureIcon:x,atlasInterpolation:$,atlasInterpolationIcon:c,isSDF:!0,hasHalo:H,tile:a,labelPlaneMatrixInv:W}})():null,Z=i.paint.get("icon-opacity").constantOr(1),$=i.paint.get("text-opacity").constantOr(1);if(P&&o.canOverlap){z=!0;var H=Z&&!s.onlyText?o.icon.segments.get():[],W=$&&!s.onlyIcons?o.text.segments.get():[];for(var X of H)B.push({segments:new e.b1([X]),sortKey:X.sortKey,state:G});for(var Y of W)B.push({segments:new e.b1([Y]),sortKey:Y.sortKey,state:q})}else s.onlyText||B.push({segments:Z?o.icon.segments:new e.b1([]),sortKey:0,state:G}),s.onlyIcons||B.push({segments:$?o.text.segments:new e.b1([]),sortKey:0,state:q})};for(var V of n)N(V);for(var U of(z&&B.sort((function(e,t){return e.sortKey-t.sortKey})),B)){var j=U.state;if(j)if(t.terrain?t.terrain.setupElevationDraw(j.tile,j.program,{useDepthForOcclusion:S.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:j.labelPlaneMatrixInv}):t.setupDepthForOcclusion(S.depthOcclusionForSymbolsAndCircles,j.program),T.activeTexture.set(M.TEXTURE0),j.atlasTexture&&j.atlasTexture.bind(j.atlasInterpolation,M.CLAMP_TO_EDGE,!0),j.atlasTextureIcon&&(T.activeTexture.set(M.TEXTURE1),j.atlasTextureIcon&&j.atlasTextureIcon.bind(j.atlasInterpolationIcon,M.CLAMP_TO_EDGE,!0)),t.uploadCommonLightUniforms(t.context,j.program),j.hasHalo){var G=j.uniformValues;G.u_is_halo=1,Ka(j.buffers,U.segments,i,t,j.program,D,a,o,G,2),G.u_is_halo=0}else{if(j.isSDF){var q=j.uniformValues;j.hasHalo&&(q.u_is_halo=1,Ka(j.buffers,U.segments,i,t,j.program,D,a,o,q,1)),q.u_is_halo=0}Ka(j.buffers,U.segments,i,t,j.program,D,a,o,j.uniformValues,1)}}}function Ka(e,t,r,i,n,a,o,s,l,u){var c=[e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer,e.iconTransitioningVertexBuffer,e.globeExtVertexBuffer,e.zOffsetVertexBuffer];n.draw(i,i.context.gl.TRIANGLES,a,o,s,oi.disabled,l,r.id,e.layoutVertexBuffer,e.indexBuffer,t,r.paint,i.transform.zoom,e.programConfigurations.get(r.id),c,u)}function Qa(e,t,r,i,n,a,o){var s,l,u,c,h,f=e.context.gl,d=r.paint.get("fill-pattern"),p=r.is3D(),m=p?e.stencilModeFor3D():ii.disabled,v=d&&d.constantOr(1);for(var _ of(o?(l=v&&!r.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",s=f.LINES):(l=v?"fillPattern":"fill",s=f.TRIANGLES),i)){var y=t.getTile(_);if(!v||y.patternsLoaded()){var g=y.getBucket(r);if(g){e.prepareDrawTile();var x=g.programConfigurations.get(r.id),b=e.isTileAffectedByFog(_),w=e.getOrCreateProgram(l,{config:x,overrideFog:b});v&&(e.context.activeTexture.set(f.TEXTURE0),y.imageAtlasTexture&&y.imageAtlasTexture.bind(f.LINEAR,f.CLAMP_TO_EDGE),x.updatePaintBuffers());var k=d.constantOr(null);if(k&&y.imageAtlas){var T=y.imageAtlas.patternPositions[k.toString()];T&&x.setConstantPatternPositions(T)}var M=e.translatePosMatrix(_.projMatrix,y,r.paint.get("fill-translate"),r.paint.get("fill-translate-anchor")),S=r.paint.get("fill-emissive-strength");if(o){c=g.indexBuffer2,h=g.segments2;var E=e.terrain&&e.terrain.renderingToTexture?e.terrain.drapeBufferSize:[f.drawingBufferWidth,f.drawingBufferHeight];u="fillOutlinePattern"===l&&v?ga(M,S,e,y,E):ya(M,S,E)}else c=g.indexBuffer,h=g.segments,u=v?_a(M,S,e,y):va(M,S);e.uploadCommonUniforms(e.context,w,_.toUnwrapped()),w.draw(e,s,n,p?m:e.stencilModeForClipping(_),a,oi.disabled,u,r.id,g.layoutVertexBuffer,c,h,r.paint,e.transform.zoom,x,void 0)}}}}function eo(t,r,i,n,a,o,s,l){i.resetLayerRenderingStats(t);var u,c=t.context,h=c.gl,f=t.transform,d=i.paint.get("fill-extrusion-pattern"),p=d.constantOr(1),m=i.paint.get("fill-extrusion-opacity"),v=t.style.enable3dLights(),_=i.paint.get(v&&!p?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),y=[i.paint.get("fill-extrusion-ambient-occlusion-intensity"),_],g=i.layout.get("fill-extrusion-edge-radius"),x=g>0&&!i.paint.get("fill-extrusion-rounded-roof"),b=x?0:g,w="globe"===f.projection.name?e.c_():0,k="globe"===f.projection.name,T=k?e.a9(f.zoom):0,M=[e.am(f.center.lng),e.at(f.center.lat)],S=i.paint.get("fill-extrusion-flood-light-color").toRenderColor(i.lut).toArray01().slice(0,3),E=i.paint.get("fill-extrusion-flood-light-intensity"),I=i.paint.get("fill-extrusion-vertical-scale"),A=0!==i.paint.get("fill-extrusion-line-width").constantOr(1),C=ki(t,i.paint.get("fill-extrusion-cutoff-fade-range")),P=[];k&&P.push("PROJECTION_GLOBE_VIEW"),y[0]>0&&P.push("FAUX_AO"),x&&P.push("ZERO_ROOF_RADIUS"),l&&P.push("HAS_CENTROID"),E>0&&P.push("FLOOD_LIGHT"),C.shouldRenderCutoff&&P.push("RENDER_CUTOFF"),A&&P.push("RENDER_WALL_MODE");var z="shadow"===t.renderPass,D=t.shadowRenderer,R=z&&!!D;t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!0);var L=[0,0,0];if(D){var O=t.style.directionalLight,B=t.style.ambientLight;O&&B&&(L=Ci(t.style,O,B)),u=P.concat(["SHADOWS_SINGLE_CASCADE"])}var F=R?"fillExtrusionDepth":p?"fillExtrusionPattern":"fillExtrusion",N=i.getLayerRenderingStats();for(var V of n){var U=r.getTile(V),j=U.getBucket(i);if(j&&j.projection.name===f.projection.name){var G=!1;D&&(G=0===D.getMaxCascadeForTile(V.toUnwrapped()));var q=t.isTileAffectedByFog(V),Z=j.programConfigurations.get(i.id),$=t.getOrCreateProgram(F,{config:Z,defines:G?u:P,overrideFog:q});if(t.terrain&&t.terrain.setupElevationDraw(U,$,{useMeterToDem:!0}),!j.centroidVertexBuffer){var H=$.attributes.a_centroid_pos;void 0!==H&&h.vertexAttrib2f(H,0,0)}!z&&D&&D.setupShadows(U.tileID.toUnwrapped(),$,"vector-tile",U.tileID.overscaledZ),p&&(t.context.activeTexture.set(h.TEXTURE0),U.imageAtlasTexture&&U.imageAtlasTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),Z.updatePaintBuffers());var W=d.constantOr(null);if(W&&U.imageAtlas){var X=U.imageAtlas.patternPositions[W.toString()];X&&Z.setConstantPatternPositions(X)}var Y=i.paint.get("fill-extrusion-vertical-gradient"),J=1/j.tileToMeter,K=void 0;if(z&&D){if(oo(U.tileID,j,t))continue;var Q=D.calculateShadowPassMatrixFromTile(U.tileID.toUnwrapped());K=pa(Q,b,J,I)}else{var ee=t.translatePosMatrix(V.expandedProjMatrix,U,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),te=f.projection.createInversionMatrix(f,V.canonical);K=p?ma(ee,t,Y,m,y,b,J,V,U,w,T,M,te,S,I):da(ee,t,Y,m,y,b,J,V,w,T,M,te,S,I,E,L)}t.uploadCommonUniforms(c,$,V.toUnwrapped(),null,C);var re=j.segments;if("mercator"!==f.projection.name||z||(re=j.getVisibleSegments(U.tileID,t.terrain,t.transform.getFrustum(0))).get().length){if(N)if(z)for(var ie of re.get())N.numRenderedVerticesInShadowPass+=ie.primitiveLength;else for(var ne of re.get())N.numRenderedVerticesInTransparentPass+=ne.primitiveLength;var ae=[];(t.terrain||l)&&ae.push(j.centroidVertexBuffer),k&&ae.push(j.layoutVertexExtBuffer),A&&ae.push(j.wallVertexBuffer),$.draw(t,c.gl.TRIANGLES,a,o,s,oi.backCCW,K,i.id,j.layoutVertexBuffer,j.indexBuffer,re,i.paint,t.transform.zoom,Z,ae)}}}t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!1)}function to(t,r,i,n,a,o,s,l,u,c,h,f,d,p,m,v,_,y,g){var x=t.context,b=x.gl,w=t.transform,k=t.transform.zoom,T=[],M=ki(t,i.paint.get("fill-extrusion-cutoff-fade-range"));"clear"===c?(T.push("CLEAR_SUBPASS"),g&&(T.push("CLEAR_FROM_TEXTURE"),x.activeTexture.set(b.TEXTURE0),g.bind(b.LINEAR,b.CLAMP_TO_EDGE))):"sdf"===c&&T.push("SDF_SUBPASS"),_&&T.push("HAS_CENTROID"),M.shouldRenderCutoff&&T.push("RENDER_CUTOFF");var S=i.layout.get("fill-extrusion-edge-radius"),E=function(e,r,n,c,y){var b=r.programConfigurations.get(i.id),w=t.isTileAffectedByFog(e),E=t.getOrCreateProgram("fillExtrusionGroundEffect",{config:b,defines:T,overrideFog:w}),I=(function(e,t,r,i,n,a,o,s,l,u,c){return{u_matrix:t,u_opacity:r,u_ao_pass:i?1:0,u_meter_to_tile:n,u_ao:a,u_flood_light_intensity:o,u_flood_light_color:s,u_attenuation:l,u_edge_radius:u,u_fb:0,u_fb_size:c,u_dynamic_offset:1}})(0,c,h,u,y,[f,d*y],p,m,v,k>=17?0:S*y,g?g.size[0]:0),A=[];_&&A.push(r.hiddenByLandmarkVertexBuffer),t.uploadCommonUniforms(x,E,e.toUnwrapped(),null,M),E.draw(t,x.gl.TRIANGLES,a,o,s,l,I,i.id,r.vertexBuffer,r.indexBuffer,n,i.paint,k,b,A)};for(var I of n){var A=r.getTile(I),C=A.getBucket(i);if(C&&C.projection.name===w.projection.name&&C.groundEffect&&(!C.groundEffect||C.groundEffect.hasData())){var P=C.groundEffect,z=1/C.tileToMeter,D=t.translatePosMatrix(I.projMatrix,A,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),R=P.getDefaultSegment();if(E(I,P,R,D,z),y)for(var L=0;L<4;L++){var O=e.c$[L](I),B=r.getTile(O);if(B){var F=B.getBucket(i);if(F&&F.projection.name===w.projection.name&&F.groundEffect&&(!F.groundEffect||F.groundEffect.hasData())){var N=F.groundEffect,V=void 0,U=void 0;0===L?(V=[-e.ab,0,0],U=1):1===L?(V=[e.ab,0,0],U=0):2===L?(V=[0,-e.ab,0],U=3):(V=[0,e.ab,0],U=2);var j=N.regionSegments[U];if(j){var G=new Float32Array(16);e.a6.mat4.translate(G,I.projMatrix,V),E(I,N,j,t.translatePosMatrix(G,A,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),z)}}}}}}}function ro(t,r,i,n,a,o,s){0===n.centroidVertexArray.length&&n.createCentroidsBuffer();var l=o?o.findDEMTileFor(i):null;if(l&&l.dem||s){for(var u,c,h=function(t){return new e.P(Math.ceil((t+e.d2)*e.d3),0)},f=function(e){var t=r.getSource().minzoom,i=function(e){var t=r.getTileByID(e);if(t&&t.hasData())return t.getBucket(a)};for(var n of[0,-1,1])if(!(e.overscaledZ+nt.max.x?r.min.x-e.ab:t.max.x,d},m=function(t,r){return d[0]=Math.min(t.min.x,r.min.x),d[1]=Math.max(t.max.x,r.max.x),d[2]=e.ab-r.min.y>t.max.y?r.min.y-e.ab:t.max.y,d},v=[function(e,t){return p(e,t)},function(e,t){return p(t,e)},function(e,t){return m(e,t)},function(e,t){return m(t,e)}],_=function(t,r,n,a,s,u,c){if(!o)return 0;var h=[[u?n:t,u?t:n,0],[u?n:r,u?r:n,0]],f=c<0?e.ab+c:c,d=[u?f:(t+r)/2,u?(t+r)/2:f,0];return 0===n&&c<0||0!==n&&c>0?o.getForTilePoints(s,[d],!0,a):h.push(d),o.getForTilePoints(i,h,!0,l),Math.max(h[0][2],h[1][2],d[2])/o.exaggeration()},y=0;y<4;y++){var g=n.borderFeatureIndices[y];if(0!==g.length){var x=e.c$[y](i),b=f(x);if(b&&b instanceof e.d0&&n.borderDoneWithNeighborZ[y]!==b.canonical.z){0===b.centroidVertexArray.length&&b.createCentroidsBuffer();var w=o?o.findDEMTileFor(x):null;if(w&&w.dem||s){var k=(y<2?1:5)-y,T=b.borderDoneWithNeighborZ[k]!==n.canonical.z,M=b.borderFeatureIndices[k],S=0;if(n.canonical.z!==b.canonical.z){for(var E of g)n.showCentroid(n.featuresOnBorder[E]);if(T)for(var I of M)b.showCentroid(b.featuresOnBorder[I]);n.borderDoneWithNeighborZ[y]=b.canonical.z,b.borderDoneWithNeighborZ[k]=n.canonical.z}for(var A of g){for(var C=n.featuresOnBorder[A],P=n.centroidData[C.centroidDataIndex],z=C.borders[y],D=void 0;Sz[0]+3||R[0]>z[0]-3)break;b.showCentroid(D),S++}if(D&&Sz[1]-3)&&(O++,++S!==M.length);)D=b.featuresOnBorder[M[S]];D=b.featuresOnBorder[M[L]];var B=!1;if(O>=1){var F=D.borders[k];Math.abs(z[0]-F[0])<3&&Math.abs(z[1]-F[1])<3&&(O=1,B=!0,S=L+1)}else if(0===O){n.showCentroid(C);continue}var N=b.centroidData[D.centroidDataIndex];s&&B&&(((u=P).flags|(c=N).flags)&e.d1?(u.flags|=e.d1,c.flags|=e.d1):(u.flags&=~e.d1,c.flags&=~e.d1));var V=C.intersectsCount()>1||D.intersectsCount()>1;if(O>1)S=L,P.centroidXY=N.centroidXY=new e.P(0,0);else if(w&&w.dem&&!V){var U=v[y](P,N),j=y%2?e.ab-1:0,G=_(U[0],Math.min(e.ab-1,U[1]),j,w,x,y<2,U[2]);P.centroidXY=N.centroidXY=h(G)}else V?P.centroidXY=N.centroidXY=new e.P(0,0):(P.centroidXY=n.encodeBorderCentroid(C),N.centroidXY=b.encodeBorderCentroid(D));n.writeCentroidToBuffer(P),b.writeCentroidToBuffer(N)}else n.showCentroid(C)}n.borderDoneWithNeighborZ[y]=b.canonical.z,b.borderDoneWithNeighborZ[k]=n.canonical.z}}}}(n.needsCentroidUpdate||!n.centroidVertexBuffer&&0!==n.centroidVertexArray.length)&&n.uploadCentroid(t)}}var io=[1,0,0],no=[0,1,0],ao=[0,0,1];function oo(t,r,i){var n=i.transform,a=i.shadowRenderer;if(!a)return!0;var o=t.toUnwrapped(),s=n.tileSize*a._cascades[i.currentShadowCascade].scale,l=r.maxHeight;if(n.elevation){var u=n.elevation.getMinMaxForTile(t);u&&(l+=u.max)}var c=d(a.shadowDirection);c[2]=-c[2];var h=a.computeSimplifiedTileShadowVolume(o,l,s,c);if(!h)return!1;var f=[io,no,ao,c,[c[0],0,c[2]],[0,c[1],c[2]]],p="globe"===n.projection.name,m=n.scaleZoom(s),v=e.bN.fromInvProjectionMatrix(n.invProjMatrix,n.worldSize,m,!p),_=a.getCurrentCascadeFrustum();return 0===v.intersectsPrecise(h.vertices,h.planes,f)||0===_.intersectsPrecise(h.vertices,h.planes,f)}function so(t){return[t[0]*e.d4,t[1]*e.d4,t[2]*e.d4,0]}function lo(t,r,i,n,a,o,s,l,u){var c,h,f,d=n.getSource(),p=i.globeSharedBuffers;if(p&&(r&&(c=n.getTile(r)),d instanceof e.aD?(h=d.texture,f=e.cD(0,0,i.transform)):c&&r&&(h=c.texture,f=e.cD(r.canonical.z,r.canonical.x,i.transform)),h&&f)){t||(f=e.a6.mat4.scale(e.a6.mat4.create(),f,[1,-1,1]));var m=i.context,v=m.gl,_="nearest"===a.paint.get("raster-resampling")?v.NEAREST:v.LINEAR,y=i.colorModeForDrapableLayerRenderPass(o),g=s.defines;g.push("GLOBE_POLES");var b=new ti(v.LEQUAL,ti.ReadWrite,i.depthRangeFor3D),w=Float32Array.from(i.transform.expandedFarZProjMatrix),k=Float32Array.from(e.b5(e.cC(new e.bP(0,0,0))));i.terrain&&i.terrain.prepareDrawTile(),m.activeTexture.set(v.TEXTURE0),h.bind(_,v.CLAMP_TO_EDGE),m.activeTexture.set(v.TEXTURE1),h.bind(_,v.CLAMP_TO_EDGE),h.useMipmap&&m.extTextureFilterAnisotropic&&i.transform.pitch>20&&v.texParameterf(v.TEXTURE_2D,m.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,m.extTextureFilterAnisotropicMax);var T,M=r?p.getPoleBuffers(r.canonical.z,!1):p.getPoleBuffers(0,!0),S=x(M,4),E=S[0],I=S[1],A=S[2],C=S[3],P=a.paint.get("raster-elevation");t?(T=E,i.renderDefaultNorthPole=0!==P):(T=I,i.renderDefaultSouthPole=0!==P);var z=so(s.mix),D=(function(e,t,r,i,n,a,o,s,l,u,c,h,f){return Sa(e,t,r,new Float32Array(16),new Float32Array(9),[0,0],i,[0,0],[0,0,0,0],1,{opacity:1,mix:0},a,[0,0],s,2,u,c,h,1,0,f)})(w,k,f,e.a9(i.transform.zoom),0,a,0,P,0,z,s.offset,s.range,o),R=i.getOrCreateProgram("raster",{defines:g});i.uploadCommonUniforms(m,R,null),R.draw(i,v.TRIANGLES,b,u,y,l,D,a.id,T,A,C)}}function uo(e){var t=e._nearZ,r=e.projection.farthestPixelDistance(e),i=r-t,n=.2*e.height,a=t+n;return[t,r,(a-n-t)/i,(a-t)/i]}function co(e,t,r,i){if(e)return t instanceof ct&&e instanceof Bt?t.getTextureDescriptor(e,r,!0):{texture:e.texture,mix:so(i.mix),offset:i.offset,buffer:0,tileSize:1}}var ho=e.d5([{name:"a_index",type:"Int16",components:1}]),fo=(function(){return m((function t(r,i,n,a){p(this,t);var o={width:n[0],height:n[1],data:null},s=r.gl;this.targetColorTexture=new e.T(r,o,s.RGBA8,{useMipmap:!1}),this.backgroundColorTexture=new e.T(r,o,s.RGBA8,{useMipmap:!1}),this.context=r,this.updateParticleTexture(i,a),this.lastInvalidatedAt=0}),[{key:"updateParticleTexture",value:function(t,r){if(this.particleTextureDimension!==r.width){(this.particleTexture0||this.particleTexture1||this.particleIndexBuffer||this.particleSegment)&&(this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleIndexBuffer.destroy(),this.particleSegment.destroy());var i=this.context.gl,n=r.width*r.height;this.particleTexture0=new e.T(this.context,r,i.RGBA8,{premultiply:!1,useMipmap:!1}),this.particleTexture1=new e.T(this.context,r,i.RGBA8,{premultiply:!1,useMipmap:!1});var a=new e.d6;a.reserve(n);for(var o=0;o0){var p=e.b4(i.canonical,u),m=e.d8(p);d=e.a6.mat4.multiply(new Float32Array(16),u.globeMatrix,m),e.a6.mat4.multiply(d,u.projMatrix,d)}var v=e.a6.mat4.create();v[12]+=2*a/(e.q.devicePixelRatio*u.width),v[13]+=2*o/(e.q.devicePixelRatio*u.height),e.a6.mat4.multiply(d,v,d);var _=t.getOrCreateProgram("debug",{defines:f}),y=r.getTileByID(i.key);t.terrain&&t.terrain.setupElevationDraw(y,_);var g=ti.disabled,x=ii.disabled,b=t.colorModeForRenderPass(),w="$debug";l.activeTexture.set(c.TEXTURE0),t.emptyTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE),h?y._makeGlobeTileDebugBuffers(t.context,u):y._makeDebugTileBoundsBuffers(t.context,u.projection);var k=y._tileDebugBuffer||t.debugBuffer,T=y._tileDebugIndexBuffer||t.debugIndexBuffer,M=y._tileDebugSegments||t.debugSegments;if(_.draw(t,c.LINE_STRIP,g,x,b,oi.disabled,ba(d,n),w,k,T,M,null,null,null,[y._globeTileDebugBorderBuffer]),s){var S=y.latestRawTileData,E=Math.floor((S&&S.byteLength||0)/1024),I=i.canonical.toString();i.overscaledZ!==i.canonical.z&&(I+=` => ${i.overscaledZ}`),I+=` ${y.state}`,(function(e,t){e.initDebugOverlayCanvas();var r=e.debugOverlayCanvas,i=e.context.gl,n=e.debugOverlayCanvas.getContext("2d");n.clearRect(0,0,r.width,r.height),n.shadowColor="white",n.shadowBlur=2,n.lineWidth=1.5,n.strokeStyle="white",n.textBaseline="top",n.font="bold 36px Open Sans, sans-serif",n.fillText(t,5,5),n.strokeText(t,5,5),e.debugOverlayTexture.update(r),e.debugOverlayTexture.bind(i.LINEAR,i.CLAMP_TO_EDGE)})(t,I+=` ${E}kb`)}var A=r.getTile(i).tileSize,C=512/Math.min(A,512)*(i.overscaledZ/u.zoom)*.5,P=y._tileDebugTextBuffer||t.debugBuffer,z=y._tileDebugTextIndexBuffer||t.quadTriangleIndexBuffer,D=y._tileDebugTextSegments||t.debugSegments;_.draw(t,c.TRIANGLES,g,x,ei.alphaBlended,oi.disabled,ba(d,e.bz.transparent,C),w,P,z,D,null,null,null,[y._globeTileDebugTextBuffer])}function wo(e,t,r,i){To(e,0,t+r/2,e.transform.width,r,i)}function ko(e,t,r,i){To(e,t-r/2,0,r,e.transform.height,i)}function To(t,r,i,n,a,o){var s=t.context,l=s.gl;l.enable(l.SCISSOR_TEST),l.scissor(r*e.q.devicePixelRatio,i*e.q.devicePixelRatio,n*e.q.devicePixelRatio,a*e.q.devicePixelRatio),s.clear({color:o}),l.disable(l.SCISSOR_TEST)}var Mo=e.d5([{name:"a_pos_3f",components:3,type:"Float32"}]).members;function So(e,t,r,i){e.emplaceBack(t,r,i)}var Eo=m((function t(r){p(this,t),this.vertexArray=new e.d9,this.indices=new e.aO,So(this.vertexArray,-1,-1,1),So(this.vertexArray,1,-1,1),So(this.vertexArray,-1,1,1),So(this.vertexArray,1,1,1),So(this.vertexArray,-1,-1,-1),So(this.vertexArray,1,-1,-1),So(this.vertexArray,-1,1,-1),So(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=r.createVertexBuffer(this.vertexArray,Mo),this.indexBuffer=r.createIndexBuffer(this.indices),this.segment=e.b1.simpleSegment(0,0,36,12)}));function Io(t,r,i,n,a,o){var s=t.context.gl,l=r.paint.get("sky-atmosphere-color"),u=r.paint.get("sky-atmosphere-halo-color"),c=r.paint.get("sky-atmosphere-sun-intensity"),h=(function(e,t,r,i,n){return{u_matrix_3f:e,u_sun_direction:t,u_sun_intensity:r,u_color_tint_r:[i.r,i.g,i.b,i.a],u_color_tint_m:[n.r,n.g,n.b,n.a],u_luminance:5e-5}})(e.a6.mat3.fromMat4(e.a6.mat3.create(),n),a,c,l,u);s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+o,r.skyboxTexture,0),i.draw(t,s.TRIANGLES,ti.disabled,ii.disabled,ei.unblended,oi.frontCW,h,"skyboxCapture",r.skyboxGeometry.vertexBuffer,r.skyboxGeometry.indexBuffer,r.skyboxGeometry.segment)}var Ao=e.d5([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]),Co=(function(){return m((function t(r){p(this,t);var 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);var n=new e.aO;n.emplaceBack(0,1,2),n.emplaceBack(2,3,0),this.vertexBuffer=r.createVertexBuffer(i,Ao.members),this.indexBuffer=r.createIndexBuffer(n),this.segments=e.b1.simpleSegment(0,0,4,2)}),[{key:"destroy",value:function(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}])})(),Po=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}]),zo=m((function e(){p(this,e),this.starsCount=16e3,this.sizeMultiplier=.15,this.sizeRange=100,this.intensityRange=200})),Do=(function(){return m((function t(r){var i=this;p(this,t),this.colorModeAlphaBlendedWriteRGB=new ei([1,Qr,1,Qr],e.bz.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new ei([1,0,1,0],e.bz.transparent,[!1,!1,!1,!0]),this.params=new zo,this.updateNeeded=!0,r.tp.registerParameter(this.params,["Stars"],"starsCount",{min:100,max:16e3,step:1},(function(){i.updateNeeded=!0})),r.tp.registerParameter(this.params,["Stars"],"sizeMultiplier",{min:.01,max:2,step:.01}),r.tp.registerParameter(this.params,["Stars"],"sizeRange",{min:0,max:200,step:1},(function(){i.updateNeeded=!0})),r.tp.registerParameter(this.params,["Stars"],"intensityRange",{min:0,max:200,step:1},(function(){i.updateNeeded=!0}))}),[{key:"update",value:function(t){var r=t.context;if(!this.atmosphereBuffer||this.updateNeeded){this.updateNeeded=!1,this.atmosphereBuffer=new Co(r);for(var i=this.params.sizeRange,n=this.params.intensityRange,a=(function(t){for(var r=e.dd(30),i=[],n=0;n=$e||P>=$e}}var z=ki(r,i.paint.get("model-cutoff-fade-range"));z.shouldRenderCutoff&&b.defines.push("RENDER_CUTOFF");var D=r.getOrCreateProgram("model",b);r.uploadCommonUniforms(u,D,null,T,z),"shadow"!==r.renderPass&&k&&k.setupShadowsFromMatrix(t.nodeModelMatrix,D),D.draw(r,u.gl.TRIANGLES,c,a,o,f.material.doubleSided?oi.disabled:oi.backCCW,g,i.id,f.vertexBuffer,f.indexBuffer,f.segments,i.paint,r.transform.zoom,void 0,w)}function Bo(t,r,i,n,a,o,s){var l;l="globe"===t.projection.name?e.dg(i,t):d(i),e.a6.mat4.multiply(l,l,r.matrix);var u=e.a6.mat4.multiply([],n,l);if(r.meshes)for(var c of r.meshes)if("BLEND"===c.material.alphaMode){var h=e.a6.vec3.transformMat4([],c.centroid,u);h[2]>0&&o.push({mesh:c,depth:h[2],modelIndex:a,worldViewProjection:u,nodeModelMatrix:l})}else s.push({mesh:c,depth:0,modelIndex:a,worldViewProjection:u,nodeModelMatrix:l});if(r.children)for(var f of r.children)Bo(t,f,i,n,a,o,s)}function Fo(e,t,r,i){var n=r.shadowRenderer;if(n){var a=n.getShadowPassDepthMode(),o=n.getShadowPassColorMode(),s=n.calculateShadowPassMatrixFromMatrix(t),l=Fa(s);r.getOrCreateProgram("modelDepth",{defines:r._shadowMapDebug?[]:["DEPTH_TEXTURE"]}).draw(r,r.context.gl.TRIANGLES,a,ii.disabled,o,oi.backCCW,l,i.id,e.vertexBuffer,e.indexBuffer,e.segments,i.paint,r.transform.zoom,void 0,void 0)}}function No(t,r,i){var n=r.updateZoomBasedPaintProperties(),a=(function(t,r,i){var n,a,o,s=t.terrain?t.terrain.exaggeration():0;if(t.terrain&&s>0){var l=t.terrain,u=l.findDEMTileFor(i);u&&u.dem?n=e.di.create(l,i,u):s=0}if(0===s&&(r.terrainElevationMin=0,r.terrainElevationMax=0),s===r.validForExaggeration&&(0===s||n&&n._demTile&&n._demTile.tileID===r.validForDEMTile.id&&n._dem._timestamp===r.validForDEMTile.timestamp))return!1;for(var c in r.instancesPerModel)for(var h=r.instancesPerModel[c],f=0;fc&&(c=h.max)}var f=e.ap(n.x,o,s)-n.x,d=e.ap(n.y,l,u)-n.y,p=e.bD(c,r.center.lat)-n.z;return r._zoomFromMercatorZ(Math.sqrt(f*f+d*d+p*p))}function jo(e,t,r,i,n,a,o){var s=e.context,l="shadow"===e.renderPass,u=e.shadowRenderer,c=l&&u?u.getShadowPassDepthMode():new ti(s.gl.LEQUAL,ti.ReadWrite,e.depthRangeFor3D),h=e.isTileAffectedByFog(a);if(r.meshes)for(var f of r.meshes){var d=["MODEL_POSITION_ON_GPU"],p=[],m=void 0,v=void 0,_=void 0;i.instancedDataArray.length>20&&d.push("INSTANCED_ARRAYS");var y=ki(e,t.paint.get("model-cutoff-fade-range"));if(y.shouldRenderCutoff&&d.push("RENDER_CUTOFF"),l&&u)m=e.getOrCreateProgram("modelDepth",{defines:d}),v=Fa(o.shadowTileMatrix,o.shadowTileMatrix,Float32Array.from(r.matrix)),_=u.getShadowPassColorMode();else{Lo(d,p,f,e,t.lut),m=e.getOrCreateProgram("model",{defines:d,overrideFog:h});var g=f.material,x=g.pbrMetallicRoughness,b=t.paint.get("model-opacity"),w=t.paint.get("model-emissive-strength").constantOr(0);v=Ba(a.expandedProjMatrix,Float32Array.from(r.matrix),new Float32Array(16),null,e,b,x.baseColorFactor.toRenderColor(null),g.emissiveFactor,x.metallicFactor,x.roughnessFactor,g,w,t,n),u&&(o.shadowUniformsInitialized?m.setShadowUniformValues(s,u.getShadowUniformValues()):(u.setupShadows(a.toUnwrapped(),m,"model-tile",a.overscaledZ),o.shadowUniformsInitialized=!0)),_=y.shouldRenderCutoff||b<1||"OPAQUE"!==g.alphaMode?ei.alphaBlended:ei.unblended}e.uploadCommonUniforms(s,m,a.toUnwrapped(),null,y);var k=f.material.doubleSided?oi.disabled:oi.backCCW;if(i.instancedDataArray.length>20)p.push(i.instancedDataBuffer),m.draw(e,s.gl.TRIANGLES,c,ii.disabled,_,k,v,t.id,f.vertexBuffer,f.indexBuffer,f.segments,t.paint,e.transform.zoom,void 0,p,i.instancedDataArray.length);else for(var T=l?"u_instance":"u_normal_matrix",M=0;Mu[1]?s:u,o[0]=i.max[0],l=(s=e.a6.vec4.transformMat4(e.a6.vec4.create(),o,a))[1]u[1]?s:u,o[1]=i.min[1],l=(s=e.a6.vec4.transformMat4(e.a6.vec4.create(),o,a))[1]u[1]?s:u;var c=e.ap(n[0],0,1),h=100*r.pixelsPerMeter*e.ap(n[1],0,1),f=e.ap(n[2],0,1),d=e.a6.vec4.lerp(e.a6.vec4.create(),l,u,c),p=Math.tan(.5*r.fovX),m=-d[2]*p;if(0===h)return d[1]<-Math.abs(m)?f:1;var v=(-Math.abs(m)-d[1])/h,_=function(e,t,r){return(1-r)*e+r*t},y=e.ap(_(1,f,v),f,1);return _(1,y,e.ap((r.pitch-20)/20,0,1))}var Ho=m((function e(){p(this,e)})),Wo=(function(){return m((function e(){p(this,e),this._storage=new Map}),[{key:"getLinesFromTrianglesBuffer",value:function(t,r,i){var n=this._storage.get(r.id);if(n)return n.lastUsedFrameIdx=t,n.buf;var a=i.gl,o=a.getBufferParameter(a.ELEMENT_ARRAY_BUFFER,a.BUFFER_SIZE),s=new ArrayBuffer(o),l=new Int16Array(s);a.getBufferSubData(a.ELEMENT_ARRAY_BUFFER,0,new Int16Array(s));for(var u=new e.dk,c=0;c30&&(n.buf.destroy(),this._storage.delete(i))}}},{key:"destroy",value:function(){for(var e of this._storage){var t=x(e,2),r=t[0];t[1].buf.destroy(),this._storage.delete(r)}}}])})(),Xo=m((function e(t){p(this,e),this.occluderSize=30,this.depthOffset=-1e-4,t.registerParameter(this,["Occlusion"],"occluderSize",{min:1,max:100,step:1}),t.registerParameter(this,["Occlusion"],"depthOffset",{min:-.05,max:0,step:1e-5})})),Yo={symbol:function(t,r,i,n,a){if("translucent"===t.renderPass){var o=ii.disabled,s=t.colorModeForRenderPass();i.layout.get("text-variable-anchor")&&(function(t,r,i,n,a,o,s){var l=r.transform,u="map"===a,c="map"===o;for(var h of t){var f=n.getTile(h),d=f.getBucket(i);if(d&&d.text&&d.text.segments.get().length){var p=e.bj(d.textSizeData,l.zoom),m=Sr(h,d.getProjection(),l),v=l.calculatePixelsToTileUnitsMatrix(f),_=sr(m,f.tileID.canonical,c,u,l,d.getProjection(),v),y=d.hasIconTextFit()&&d.hasIconData();if(p){var g=Math.pow(2,l.zoom-f.tileID.overscaledZ);Ya(d,u,c,s,e.cS,l,_,h,g,p,y)}}}})(n,t,i,r,i.layout.get("text-rotation-alignment"),i.layout.get("text-pitch-alignment"),a);var l=0!==i.paint.get("icon-opacity").constantOr(1),u=0!==i.paint.get("text-opacity").constantOr(1);void 0!==i.layout.get("symbol-sort-key").constantOr(1)&&(l||u)?Ja(t,r,i,n,o,s):(l&&Ja(t,r,i,n,o,s,{onlyIcons:!0}),u&&Ja(t,r,i,n,o,s,{onlyText:!0})),r.map.showCollisionBoxes&&($a(t,r,i,n,i.paint.get("text-translate"),i.paint.get("text-translate-anchor"),!0),$a(t,r,i,n,i.paint.get("icon-translate"),i.paint.get("icon-translate-anchor"),!1))}},circle:function(t,r,i,n){if("translucent"===t.renderPass){var a=i.paint.get("circle-opacity"),o=i.paint.get("circle-stroke-width"),s=i.paint.get("circle-stroke-opacity"),l=void 0!==i.layout.get("circle-sort-key").constantOr(1),u=i.paint.get("circle-emissive-strength");if(0!==a.constantOr(1)||0!==o.constantOr(1)&&0!==s.constantOr(1)){for(var c=t.context,h=c.gl,f=t.transform,d=t.depthModeForSublayer(0,ti.ReadOnly),p=ii.disabled,m=t.colorModeForDrapableLayerRenderPass(u),v="globe"===f.projection.name,_=[e.am(f.center.lng),e.at(f.center.lat)],y=[],g=0;g0&&u<1,C=i.paint.get("line-gradient"),P=S?"linePattern":"line",z=e.cV(i);if(_&&t.terrain&&t.terrain.clipOrMaskOverlapStencilType()&&(A=!1),0!==u&&t.depthOcclusion){var D=i.paint._values["line-opacity"];D&&D.value&&"constant"===D.value.kind?s=D.value:e.w(`Occlusion opacity for layer ${i.id} is supported only when line-opacity isn't data-driven.`)}if(p&&(t.forceTerrainMode=!0),p||0===u||!t.terrain||_){var R=A&&p?t.stencilModeFor3D():ii.disabled,L=function(){var n=r.getTile(O);if(S&&!n.patternsLoaded())return 0;var a=n.getBucket(i);if(!a)return 0;t.prepareDrawTile();var o=a.programConfigurations.get(i.id),l=t.isTileAffectedByFog(O),f=t.getOrCreateProgram(P,{config:o,defines:p?[].concat(d(z),["ELEVATED"]):z,overrideFog:l});if(E&&n.imageAtlas){var g=n.imageAtlas.patternPositions[E.toString()];g&&o.setConstantPatternPositions(g)}if(!S&&k&&T&&n.lineAtlas){var w=n.lineAtlas.getDash(k,T);w&&o.setConstantPatternPositions(w)}var M=i.paint.get("line-trim-offset"),D=x(M,2),L=D[0],B=D[1];if("round"===T||"square"===T){L!==B&&(0===L&&(L-=1),1===B&&(B+=1))}var F=_?O.projMatrix:null,N=S?e.cW(t,n,i,F,y,[L,B]):e.cX(t,n,i,F,a.lineClipsArray.length,y,[L,B]);if(C){var V=a.gradients[i.id],U=V.texture;if(i.gradientVersion!==V.version){var j=256;if(i.stepInterpolant){var G=r.getSource().maxzoom,q=O.canonical.z===G?Math.ceil(1<0&&w>0,S=k>0,E=function(e,t,r){return(1-r)*e+r*t},I=function(a){var o=t.depthModeForSublayer(1,ti.ReadOnly,s.LEQUAL,!0),l=i.paint.get(a?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),u=E(.1,3,l),h=t._showOverdrawInspector;if(!h){var f=new ii({func:s.ALWAYS,mask:255},255,255,s.KEEP,s.KEEP,s.REPLACE),d=new ei([s.ONE,s.ONE,s.ONE,s.ONE],e.bz.transparent,[!1,!1,!1,!0],s.MIN);to(t,r,i,n,o,f,d,oi.disabled,a,"sdf",x,b,w,k,T,u,c,!1)}var p=h?ii.disabled:new ii({func:s.EQUAL,mask:255},255,255,s.KEEP,s.DECR,s.DECR),m=h?t.colorModeForRenderPass():new ei([s.ONE_MINUS_DST_ALPHA,s.DST_ALPHA,s.ONE,s.ONE],e.bz.transparent,[!0,!0,!0,!0]);to(t,r,i,n,o,p,m,oi.disabled,a,"color",x,b,w,k,T,u,c,!1)};if(u){var A=function(a,o,l){var u=t.depthModeForSublayer(1,ti.ReadOnly,s.LEQUAL,!1),h=i.paint.get(a?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),f=E(.1,3,h),d=new ei([s.ONE,s.ONE,s.ONE,s.ONE],e.bz.transparent,[!1,!1,!1,!0]);to(t,r,i,n,u,ii.disabled,d,oi.disabled,a,"clear",x,b,w,k,T,f,c,o);var p=new ii({func:s.ALWAYS,mask:255},255,255,s.KEEP,s.KEEP,s.REPLACE),m=new ei([s.ONE,s.ONE,s.ONE,s.ONE],e.bz.transparent,[!1,!1,!1,!0],s.MIN);to(t,r,i,n,u,p,m,oi.disabled,a,"sdf",x,b,w,k,T,f,c,o);var v=a?s.ZERO:s.ONE_MINUS_DST_ALPHA,_=new ii({func:s.EQUAL,mask:255},255,255,s.KEEP,s.DECR,s.DECR),y=new ei([v,s.DST_ALPHA,s.ONE_MINUS_DST_ALPHA,s.ZERO],e.bz.transparent,[!0,!0,!0,!0]);to(t,r,i,n,u,_,y,oi.disabled,a,"color",x,b,w,k,T,f,c,o);var g=new ei([s.ONE,s.ONE,s.ONE,a?s.ZERO:s.ONE],e.bz.transparent,[!1,!1,!1,!0],a?s.FUNC_ADD:s.MAX);to(t,r,i,n,u,ii.disabled,g,oi.disabled,a,"clear",x,b,w,k,T,f,c,o,l)};if(M||S){var C;if(t.prepareDrawTile(),l){var P=l.drapeBufferSize[0],z=l.drapeBufferSize[1];(C=l.framebufferCopyTexture)&&(!C||C.size[0]===P&&C.size[1]===z)||(C&&C.destroy(),C=l.framebufferCopyTexture=new e.T(o,new e.r({width:P,height:z}),s.RGBA8)),C.bind(s.LINEAR,s.CLAMP_TO_EDGE),s.copyTexImage2D(s.TEXTURE_2D,0,s.RGBA,0,0,P,z,0)}M&&A(!0,!1,C),S&&A(!1,!0,C)}}else M&&I(!0),S&&I(!1),(M||S)&&t.resetStencilClippingMasks()}}}},hillshade:function(e,t,r,i){if(("offscreen"===e.renderPass||"translucent"===e.renderPass)&&!e.style.disableElevatedTerrain){var n=e.context,a=e.terrain&&e.terrain.renderingToTexture,o="translucent"!==e.renderPass||a?[{},i]:e.stencilConfigForOverlap(i),s=x(o,2),l=s[0],u=s[1];for(var c of u){var h=t.getTile(c);if(h.needsHillshadePrepare&&"offscreen"===e.renderPass)cn(e,h,r);else if("translucent"===e.renderPass){var f=e.depthModeForSublayer(0,ti.ReadOnly),d=r.paint.get("hillshade-emissive-strength"),p=e.colorModeForDrapableLayerRenderPass(d),m=a&&e.terrain?e.terrain.stencilModeForRTTOverlap(c):l[c.overscaledZ];ln(e,c,h,r,f,m,p)}}n.viewport.set([0,0,e.width,e.height]),e.resetStencilClippingMasks()}},raster:function(t,r,i,n,a,o){if("translucent"===t.renderPass&&0!==i.paint.get("raster-opacity")){var s="globe"===t.transform.projection.name,l=0!==i.paint.get("raster-elevation"),u=l&&s;if(!t.renderElevatedRasterBackface||u){var c=t.context,h=c.gl,f=r.getSource(),d=(function(t,r,i,n){var a=r.paint.get("raster-color"),o="raster-array"===t.type,s=[],l=r.paint.get("raster-resampling"),u=r.paint.get("raster-color-mix"),c=r.paint.get("raster-color-range"),h=[u[0],u[1],u[2],0],f=u[3],d="nearest"===l?n.NEAREST:n.LINEAR;if(o&&(s.push("RASTER_ARRAY"),a||s.push("RASTER_COLOR"),"linear"===l&&s.push("RASTER_ARRAY_LINEAR"),d=n.NEAREST,!c&&t.rasterLayers)){var p=t.rasterLayers.find((function(e){return e.id===r.sourceLayer}));p&&p.fields&&p.fields.range&&(c=p.fields.range)}if(c=c||[0,1],a){s.push("RASTER_COLOR"),i.activeTexture.set(n.TEXTURE2),r.updateColorRamp(c);var m=r.colorRampTexture;m||(m=r.colorRampTexture=new e.T(i,r.colorRamp,n.RGBA8)),m.bind(n.LINEAR,n.CLAMP_TO_EDGE)}return{mix:h,range:c,offset:f,defines:s,resampling:d}})(f,i,c,h);if(!(f instanceof e.aD)||n.length||s){var p=i.paint.get("raster-emissive-strength"),m=t.colorModeForDrapableLayerRenderPass(p),v=t.terrain&&t.terrain.renderingToTexture,_=!t.options.moving,y="nearest"===i.paint.get("raster-resampling")?h.NEAREST:h.LINEAR;if(f instanceof e.aD&&!n.length&&(f.onNorthPole||f.onSouthPole)){var g=l?t.stencilModeFor3D():ii.disabled;lo(!!f.onNorthPole,null,t,r,i,p,d,oi.disabled,g)}else if(n.length){var b=f instanceof e.aD||v?[{},n]:t.stencilConfigForOverlap(n),w=x(b,2),k=w[0],T=w[1],M=T[T.length-1].overscaledZ;u&&d.defines.push("PROJECTION_GLOBE_VIEW"),l&&d.defines.push("RENDER_CUTOFF");var S=function(n,a,g){for(var b of n){var w=b.toUnwrapped(),T=r.getTile(b);if(!v||T&&T.hasData()){c.activeTexture.set(h.TEXTURE0);var S=co(T,f,i,d);if(S&&S.texture){var E=S.texture,I=S.mix,A=S.offset,C=S.tileSize,P=S.buffer,z=void 0,D=void 0;v?(z=ti.disabled,D=b.projMatrix):l?(z=new ti(h.LEQUAL,ti.ReadWrite,t.depthRangeFor3D),D=s?Float32Array.from(t.transform.expandedFarZProjMatrix):t.transform.calculateProjMatrix(w,_)):(z=t.depthModeForSublayer(b.overscaledZ-M,1===i.paint.get("raster-opacity")?ti.ReadWrite:ti.ReadOnly,h.LESS),D=t.transform.calculateProjMatrix(w,_));var R=t.terrain&&v?t.terrain.stencilModeForRTTOverlap(b):k[b.overscaledZ],L=o?0:i.paint.get("raster-fade-duration");T.registerFadeDuration(L);var O=r.findLoadedParent(b,0),B=ra(T,O,r,t.transform,L),F=void 0,N=void 0;t.terrain&&t.terrain.prepareDrawTile(),c.activeTexture.set(h.TEXTURE0),E.bind(y,h.CLAMP_TO_EDGE),c.activeTexture.set(h.TEXTURE1),O?(O.texture&&O.texture.bind(y,h.CLAMP_TO_EDGE),F=Math.pow(2,O.tileID.overscaledZ-T.tileID.overscaledZ),N=[T.tileID.canonical.x*F%1,T.tileID.canonical.y*F%1]):E.bind(y,h.CLAMP_TO_EDGE),E.useMipmap&&c.extTextureFilterAnisotropic&&t.transform.pitch>20&&h.texParameterf(h.TEXTURE_2D,c.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,c.extTextureFilterAnisotropicMax);var V=t.transform,U=void 0,j=l?uo(V):[0,0,0,0],G=void 0,q=void 0,Z=void 0,$=void 0,H=void 0,W=0;if(u&&f instanceof e.aD&&f.coordinates.length>3)G=Float32Array.from(e.b5(e.cC(new e.bP(0,0,0)))),q=Float32Array.from(V.globeMatrix),Z=Float32Array.from(e.cy(V)),$=[e.am(V.center.lng),e.at(V.center.lat)],U=f.elevatedGlobePerspectiveTransform,H=f.elevatedGlobeGridMatrix||new Float32Array(9);else if(u){var X=e.cz(b.canonical);W=e.cA(X.getCenter().lat),G=Float32Array.from(e.b5(e.cC(b.canonical))),q=Float32Array.from(V.globeMatrix),Z=Float32Array.from(e.cy(V)),$=[e.am(V.center.lng),e.at(V.center.lat)],U=[0,0],H=Float32Array.from(e.cB(b.canonical,X,W,V.worldSize/V._pixelsPerMercatorPixel))}else U=f instanceof e.aD?f.perspectiveTransform:[0,0],G=new Float32Array(16),q=new Float32Array(9),Z=new Float32Array(16),$=[0,0],H=new Float32Array(9);var Y=Sa(D,G,q,Z,H,N||[0,0],e.a9(t.transform.zoom),$,j,F||1,B,i,U,l?i.paint.get("raster-elevation"):0,2,I,A,d.range,C,P,p),J=t.isTileAffectedByFog(b),K=t.getOrCreateProgram("raster",{defines:d.defines,overrideFog:J});if(t.uploadCommonUniforms(c,K,w),f instanceof e.aD){var Q=f.elevatedGlobeVertexBuffer,ee=f.elevatedGlobeIndexBuffer;if(v||!s)f.boundsBuffer&&f.boundsSegments&&K.draw(t,h.TRIANGLES,z,ii.disabled,m,oi.disabled,Y,i.id,f.boundsBuffer,t.quadTriangleIndexBuffer,f.boundsSegments);else if(Q&&ee){var te=V.zoom<=e.c2?f.elevatedGlobeSegments:f.getSegmentsForLongitude(V.center.lng);te&&K.draw(t,h.TRIANGLES,z,ii.disabled,m,a,Y,i.id,Q,ee,te)}}else if(u){z=new ti(h.LEQUAL,ti.ReadOnly,t.depthRangeFor3D);var re=t.globeSharedBuffers;if(re){var ie=re.getGridBuffers(W,!1),ne=x(ie,3),ae=ne[0],oe=ne[1],se=ne[2];K.draw(t,h.TRIANGLES,z,g||R,t.colorModeForRenderPass(),a,Y,i.id,ae,oe,se)}}else{var le=t.getTileBoundsBuffers(T),ue=le.tileBoundsBuffer,ce=le.tileBoundsIndexBuffer,he=le.tileBoundsSegments;K.draw(t,h.TRIANGLES,z,R,m,oi.disabled,Y,i.id,ue,ce,he)}}}}if(!(f instanceof e.aD)&&u)for(var fe of n){var de=fe.canonical.y===(1<>>16,2654435769),((e=Math.imul(e^e>>>16,2654435769))>>>0)/4294967296},n=.9090909090909091,a=0;a0&&t.style.isLayerClipped(i,r.getSource())&&p.updateReplacement(d,t.replacementSource,f,a)&&(p.uploaded=!1,p.upload(t.context)),p.instancesPerModel){var w=p.instancesPerModel[b];w.features.length>0&&(b=_.evaluate(w.features[0].feature,{}));var k=l.getModel(b,a);if(k&&k.uploaded)for(var T of k.nodes)jo(t,i,T,w,x,d,Vo)}}}}}}else e.w(`Drawing 3D models for ${o.projection.name} projection is not yet implemented`)})(t,r,i,n,"vector"===c.type?i.scope:""),void u();if(c.loaded()){if("batched-model"===c.type)return(function(t,r,i,n){i.resetLayerRenderingStats(t);var a=t.context,o=t.transform,s=t.style.fog,l=t.shadowRenderer;if("mercator"===o.projection.name){var u=t.transform.getFreeCameraOptions().position,c=e.a6.vec3.scale([],[u.x,u.y,u.z],t.transform.worldSize),h=e.a6.vec3.negate([],c),f=e.a6.mat4.identity([]),p=e.de(o.center.lat,o.zoom),m=e.a6.mat4.fromScaling([],[1,1,1/p]);e.a6.mat4.translate(f,f,h);var v=i.paint.get("model-opacity"),_=new ti(a.gl.LEQUAL,ti.ReadWrite,t.depthRangeFor3D),y=new ti(a.gl.LEQUAL,ti.ReadOnly,t.depthRangeFor3D),g=new e.c9([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),b="shadow"===t.renderPass,w=b&&l?l.getCurrentCascadeFrustum():o.getFrustum(o.scaleZoom(o.worldSize)),k=i.paint.get("model-front-cutoff"),T=k[2]<1,M=ki(t,i.paint.get("model-cutoff-fade-range")),S=i.getLayerRenderingStats();(function(e,t,r,i){var n=e.terrain?e.terrain.exaggeration():0,a=e.transform.zoom;for(var o of i){var s=t.getTile(o).getBucket(r);s&&(e.conflationActive&&s.updateReplacement(o,e.replacementSource),s.evaluateScale(e,r),e.terrain&&n>0&&s.elevationUpdate(e.terrain,n,o,r.source),s.needsReEvaluation(e,a,r)&&s.evaluate(r))}})(t,r,i,n),(function(){var u,h,E;T?(u=n.length-1,h=-1,E=-1):(u=0,h=n.length,E=1);for(var I=new Float64Array(16),A=e.a6.vec3.create(),C=new e.P(0,0),P=function(){var u=n[z],h=r.getTile(u).getBucket(i);if(!h||!h.uploaded)return 1;var E=!1;l&&(E=0===l.getMaxCascadeForTile(u.toUnwrapped()));var P=o.calculatePosMatrix(u.toUnwrapped(),o.worldSize),D=h.modelTraits;!b&&T&&(e.a6.mat4.invert(I,P),e.a6.vec3.transformMat4(A,c,I),C.x=A[0],C.y=A[1]);var R=[],L=function(r){if(r.hiddenByReplacement)return 0;if(!r.node.meshes)return 0;var i=r.node,n=0;t.terrain&&i.elevation&&(n=i.elevation*t.terrain.exaggeration());var a=(function(){var t=r.aabb;return g.min=d(t.min),g.max=d(t.max),g.min[2]+=n,g.max[2]+=n,e.a6.vec3.transformMat4(g.min,g.min,P),e.a6.vec3.transformMat4(g.max,g.max,P),g})(),s=r.evaluatedScale;if(s[0]<=1&&s[1]<=1&&s[2]<=1&&0===a.intersects(w))return 0;if(!b&&T){var l=.16666666666666666;r.cameraCollisionOpacity=c[0]>a.min[0]&&c[0]a.min[1]&&c[1]t.depth?-1:1})),R)){var F=B.nodeInfo,N=F.node,V=e.a6.mat4.multiply([],m,B.tileModelMatrix);e.a6.mat4.multiply(V,f,V);var U=e.a6.mat4.invert([],V);e.a6.mat4.transpose(U,U),e.a6.mat4.scale(U,U,Go),V=e.a6.mat4.multiply(V,V,N.matrix);for(var j="light-beam"===t.renderPass,G=D&e.dj.HasMapboxMeshFeatures,q=G?0:F.evaluatedRMEA[0][2],Z=0;Z=$e||ne>=$e}}var ae=$.material,oe=void 0;ae.occlusionTexture&&ae.occlusionTexture.offsetScale&&(oe=ae.occlusionTexture.offsetScale,X.defines.push("OCCLUSION_TEXTURE_TRANSFORM")),!b&&l&&(l.useNormalOffset=!!$.normalBuffer);var se=t.getOrCreateProgram("model",X);!b&&l&&l.setupShadowsFromMatrix(B.tileModelMatrix,se,l.useNormalOffset),t.uploadCommonUniforms(a,se,null,J);var le=ae.pbrMetallicRoughness;le.metallicFactor=.9,le.roughnessFactor=.5;var ue=Ba(new Float32Array(W),new Float32Array(V),new Float32Array(U),new Float32Array(N.matrix),t,B.opacity,le.baseColorFactor.toRenderColor(null),ae.emissiveFactor,le.metallicFactor,le.roughnessFactor,ae,q,i,[0,0,0],oe);!H&&(F.hasTranslucentParts||B.opacity<1)&&se.draw(t,a.gl.TRIANGLES,_,ii.disabled,ei.disabled,oi.backCCW,ue,i.id,$.vertexBuffer,$.indexBuffer,$.segments,i.paint,t.transform.zoom,void 0,Y),se.draw(t,a.gl.TRIANGLES,H?y:_,ii.disabled,H||B.opacity<1||F.hasTranslucentParts?ei.alphaBlended:ei.unblended,oi.backCCW,ue,i.id,$.vertexBuffer,$.indexBuffer,$.segments,i.paint,t.transform.zoom,void 0,Y)}}}},z=u;z!==h;z+=E)P()})()}else e.w(`Drawing 3D landmark models for ${o.projection.name} projection is not yet implemented`)})(t,r,i,n),void u();if("model"===c.type){var h=c.getModels(),f=[],p=t.transform.getFreeCameraOptions().position,m=e.a6.vec3.scale([],[p.x,p.y,p.z],t.transform.worldSize);e.a6.vec3.negate(m,m);var v=[],_=[],y=0;for(var g of h){var b=i.paint.get("model-rotation").constantOr(null),w=i.paint.get("model-scale").constantOr(null),k=i.paint.get("model-translation").constantOr(null);g.computeModelMatrix(t,b,w,k,!0,!0,!1);var T=e.a6.mat4.identity([]),M=e.de(g.position.lat,t.transform.zoom),S=e.a6.mat4.fromScaling([],[1,1,1/M]);for(var E of(e.a6.mat4.translate(T,T,m),f.push({zScaleMatrix:S,negCameraPosMatrix:T}),g.nodes))Bo(t.transform,E,g.matrix,t.transform.expandedFarZProjMatrix,y,v,_);y++}if(v.sort((function(e,t){return t.depth-e.depth})),"shadow"!==t.renderPass){if(1===a)for(var I of _)Oo(I,t,i,f[I.modelIndex],ii.disabled,t.colorModeForRenderPass());else{for(var A of _)Oo(A,t,i,f[A.modelIndex],ii.disabled,ei.disabled);for(var C of _)Oo(C,t,i,f[C.modelIndex],t.stencilModeFor3D(),t.colorModeForRenderPass());t.resetStencilClippingMasks()}for(var P of v)Oo(P,t,i,f[P.modelIndex],ii.disabled,t.colorModeForRenderPass());u()}else{for(var z of _)Fo(z.mesh,z.nodeModelMatrix,t,i);for(var D of v)Fo(D.mesh,D.nodeModelMatrix,t,i);u()}}}}}}}},Jo={model:function(e,t,r){var i=t.getSource();if(i.loaded())if("vector"!==i.type&&"geojson"!==i.type){if("batched-model"!==i.type&&"model"===i.type){var n=i.getModels();for(var a of n)a.upload(r.context)}}else r.modelManager&&r.modelManager.upload(r,"vector"===i.type?e.scope:"")},raster:function(e,t,r){var i=t.getSource();if(i instanceof ct&&i.loaded()){var n=e.sourceLayer||i.rasterLayerIds&&i.rasterLayerIds[0];if(n){var a=e.paint.get("raster-array-band")||i.getInitialBand(n);if(null!=a){var o=t.getIds().map((function(e){return t.getTileByID(e)}));for(var s of o)s.updateNeeded(n,a)&&i.prepareTile(s,n,a)}}}},"raster-particle":function(e,t,r){var i=t.getSource();if(i instanceof ct&&i.loaded()){var n=e.sourceLayer||i.rasterLayerIds&&i.rasterLayerIds[0];if(n){var a=e.paint.get("raster-particle-array-band")||i.getInitialBand(n);if(null!=a){var o=t.getIds().map((function(e){return t.getTileByID(e)}));for(var s of o)s.updateNeeded(n,a)&&i.prepareTile(s,n,a)}}}}},Ko=(function(){return m((function t(r,i,n,a){var o=this;p(this,t),this.context=new Za(r,i),this.transform=n,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.tp=a,this._timeStamp=e.q.now(),this._averageFPS=0,this._fpsHistory=[],this._dt=0,this._debugParams={showTerrainProxyTiles:!1,fpsWindow:30,continousRedraw:!1,enabledLayers:{}};var s=["fill","line","symbol","circle","heatmap","fill-extrusion","raster","raster-particle","hillshade","model","background","sky"];for(var l of s)this._debugParams.enabledLayers[l]=!0;for(var u of(a.registerParameter(this._debugParams,["Terrain"],"showTerrainProxyTiles",{},(function(){o.style.map.triggerRepaint()})),a.registerParameter(this._debugParams,["FPS"],"fpsWindow",{min:1,max:100,step:1}),a.registerBinding(this._debugParams,["FPS"],"continousRedraw",{readonly:!0,label:"continuous redraw"}),a.registerBinding(this,["FPS"],"_averageFPS",{readonly:!0,label:"value"}),a.registerBinding(this,["FPS"],"_averageFPS",{readonly:!0,label:"graph",view:"graph",min:0,max:200}),s))a.registerParameter(this._debugParams.enabledLayers,["Debug","Layers"],u);this.occlusionParams=new Xo(a),this.setup(),this.numSublayers=Vt.maxUnderzooming+Vt.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 Ei(this),this._wireframeDebugCache=new Wo,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0,this.layersWithOcclusionOpacity=[];var c=new e.r({width:1,height:1},Uint8Array.of(0,0,0,0));this.emptyDepthTexture=new e.T(this.context,c,r.RGBA8),this._clippingActiveLastFrame=!1}),[{key:"updateTerrain",value:function(e,t){var r=!!e&&!!e.terrain&&this.transform.projection.supportsTerrain;if(r||this._terrain&&this._terrain.enabled){this._terrain||(this._terrain=new oa(this,e));var i=this._terrain;this.transform.elevation=r?i:null,i.update(e,this.transform,t),this.transform.elevation&&!i.enabled&&(this.transform.elevation=null)}}},{key:"_updateFog",value:function(e){var t=e.fog;if(!t||"globe"===this.transform.projection.name||t.getOpacity(this.transform.pitch)<1||t.properties.get("horizon-blend")<.03)this.transform.fogCullDistSq=null;else{var r=t.getFovAdjustedRange(this.transform._fov),i=x(r,2),n=i[0],a=i[1];if(n>a)this.transform.fogCullDistSq=null;else{var o=n+.78*(a-n);this.transform.fogCullDistSq=o*o}}}},{key:"terrain",get:function(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled||this._forceTerrainMode?this._terrain:null}},{key:"forceTerrainMode",get:function(){return this._forceTerrainMode},set:function(e){e&&!this._terrain&&(this._terrain=new oa(this,this.style)),this._forceTerrainMode=e}},{key:"shadowRenderer",get:function(){return this._shadowRenderer&&this._shadowRenderer.enabled?this._shadowRenderer:null}},{key:"wireframeDebugCache",get:function(){return this._wireframeDebugCache}},{key:"resize",value:function(t,r){if(this.width=t*e.q.devicePixelRatio,this.height=r*e.q.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(var i of this.style.order)this.style._mergedLayers[i].resize()}},{key:"setup",value:function(){var t=this.context,r=new e.a_;r.emplaceBack(0,0),r.emplaceBack(e.ab,0),r.emplaceBack(0,e.ab),r.emplaceBack(e.ab,e.ab),this.tileExtentBuffer=t.createVertexBuffer(r,e.b0.members),this.tileExtentSegments=e.b1.simpleSegment(0,0,4,2);var 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.debugBuffer=t.createVertexBuffer(i,e.b0.members),this.debugSegments=e.b1.simpleSegment(0,0,4,5);var n=new e.a_;n.emplaceBack(-1,-1),n.emplaceBack(1,-1),n.emplaceBack(-1,1),n.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(n,e.b0.members),this.viewportSegments=e.b1.simpleSegment(0,0,4,2);var a=new e.aN;a.emplaceBack(0,0,0,0),a.emplaceBack(e.ab,0,e.ab,0),a.emplaceBack(0,e.ab,0,e.ab),a.emplaceBack(e.ab,e.ab,e.ab,e.ab),this.mercatorBoundsBuffer=t.createVertexBuffer(a,e.b3.members),this.mercatorBoundsSegments=e.b1.simpleSegment(0,0,4,2);var o=new e.aO;o.emplaceBack(0,1,2),o.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(o);var s=new e.a$;for(var l of[0,1,3,2,0])s.emplaceBack(l);this.debugIndexBuffer=t.createIndexBuffer(s),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();var u=this.context.gl;this.stencilClearMode=new ii({func:u.ALWAYS,mask:0},0,255,u.ZERO,u.ZERO,u.ZERO),this.loadTimeStamps.push(performance.now())}},{key:"getMercatorTileBoundsBuffers",value:function(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}},{key:"getTileBoundsBuffers",value:function(e){return e._makeTileBoundsBuffers(this.context,this.transform.projection),e._tileBoundsBuffer?{tileBoundsBuffer:e._tileBoundsBuffer,tileBoundsIndexBuffer:e._tileBoundsIndexBuffer,tileBoundsSegments:e._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}},{key:"clearStencil",value:function(){var e=this.context.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.getOrCreateProgram("clippingMask").draw(this,e.TRIANGLES,ti.disabled,this.stencilClearMode,ei.disabled,oi.disabled,ta(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}},{key:"resetStencilClippingMasks",value:function(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}},{key:"_renderTileClippingMasks",value:function(e,t,r){if(t&&this.currentStencilSource!==t.id&&e.isTileClipped()&&r&&0!==r.length){if(this._tileClippingMaskIDs&&!this.terrain){var i=!1;for(var n of r)if(void 0===this._tileClippingMaskIDs[n.key]){i=!0;break}if(!i)return}this.currentStencilSource=t.id;var a=this.context,o=a.gl;this.nextStencilID+r.length>256&&this.clearStencil(),a.setColorMode(ei.disabled),a.setDepthMode(ti.disabled);var s=this.getOrCreateProgram("clippingMask");for(var l of(this._tileClippingMaskIDs={},r)){var u=t.getTile(l),c=this._tileClippingMaskIDs[l.key]=this.nextStencilID++,h=this.getTileBoundsBuffers(u),f=h.tileBoundsBuffer,d=h.tileBoundsIndexBuffer,p=h.tileBoundsSegments;s.draw(this,o.TRIANGLES,ti.disabled,new ii({func:o.ALWAYS,mask:0},c,255,o.KEEP,o.KEEP,o.REPLACE),ei.disabled,oi.disabled,ta(l.projMatrix),"$clipping",f,d,p)}}}},{key:"stencilModeFor3D",value:function(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();var e=this.nextStencilID++,t=this.context.gl;return new ii({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}},{key:"stencilModeForClipping",value:function(e){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(e);var t=this.context.gl;return new ii({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}},{key:"stencilConfigForOverlap",value:function(e){var t=this.context.gl,r=e.sort((function(e,t){return t.overscaledZ-e.overscaledZ})),i=r[r.length-1].overscaledZ,n=r[0].overscaledZ-i+1;if(n>1){this.currentStencilSource=void 0,this.nextStencilID+n>256&&this.clearStencil();for(var a={},o=0;o3&&void 0!==arguments[3]&&arguments[3];if(this.depthOcclusion)return new ti(this.context.gl.GREATER,ti.ReadOnly,this.depthRangeFor3D);if(!this.opaquePassEnabledForLayer()&&!i)return ti.disabled;var n=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new ti(r||this.context.gl.LEQUAL,t,[n,n])}},{key:"opaquePassEnabledForLayer",value:function(){return this.currentLayerthis._debugParams.fpsWindow&&this._fpsHistory.splice(0,this._fpsHistory.length-this._debugParams.fpsWindow),this._averageFPS=Math.round(this._fpsHistory.reduce((function(t,r){return t+r/e._fpsHistory.length}),0))}},{key:"render",value:function(t,r){var i=this,n=e.q.now();this._dt=n-this._timeStamp,this._timeStamp=n,this._wireframeDebugCache.update(this.frameCounter),this._debugParams.continousRedraw=t.map.repaint,this.style=t,this.options=r;var a=this.style._mergedLayers,o=this.style.order.filter((function(e){var t=a[e];return!(t.type in i._debugParams.enabledLayers)||i._debugParams.enabledLayers[t.type]})),s=!1,l=!1;for(var u of o){var h=a[u];"circle"===h.type&&(s=!0),"symbol"===h.type&&(h.hasInitialOcclusionOpacityProperties?l=!0:s=!0)}var f=o.map((function(e){return a[e]})),p=this.style._mergedSourceCaches;this.imageManager=t.imageManager,this.modelManager=t.modelManager,this.symbolFadeChange=t.placement.symbolFadeChange(e.q.now()),this.imageManager.beginFrame();var m=0,v=!1;for(var _ in p){var y=p[_];y.used&&(y.prepare(this.context),y.getSource().usedInConflation&&++m)}var g=!1;for(var x of f)x.isHidden(this.transform.zoom)||("clip"===x.type&&(g=!0),this.prepareLayer(x));var b={},w={},k={},T={},M={};for(var S in p){var E=p[S];b[S]=E.getVisibleCoordinates(),w[S]=b[S].slice().reverse(),k[S]=E.getVisibleCoordinates(!0).reverse(),T[S]=E.getShadowCasterCoordinates(),M[S]=E.sortCoordinatesByDistance(b[S])}var I=function(e){var t=i.style.getLayerSourceCache(e);return t&&t.used?t.getSource():null};if(m||g||this._clippingActiveLastFrame){var A=[],C=[],P=0;for(var z of f)this.isSourceForClippingOrConflation(z,I(z))&&(A.push(z),C.push(P)),P++;if(g||A.length>1||this._clippingActiveLastFrame){g=!1;for(var D=[],R=0;R0){var H=I(Z);H&&(this.minCutoffZoom=Math.max(H.minzoom,this.minCutoffZoom)),Z.minzoom&&(this.minCutoffZoom=Math.max(Z.minzoom,this.minCutoffZoom))}Z.is3D()&&(this.opaquePassCutoff===1/0&&(this.opaquePassCutoff=q),this._lastOcclusionLayer=q)}var W=this.style&&this.style.fog;W?(this._fogVisible=0!==W.getOpacity(this.transform.pitch),this._fogVisible&&"globe"!==this.transform.projection.name&&(this._fogVisible=W.isVisibleOnFrustum(this.transform.cameraFrustum))):this._fogVisible=!1,this._cachedTileFogOpacities={},this.terrain&&(this.terrain.updateTileBinding(k),this.opaquePassCutoff=0);var X=this._shadowRenderer;if(X)for(var Y in X.updateShadowParameters(this.transform,this.style.directionalLight),p)for(var J of b[Y]){var K={min:0,max:0};this.terrain&&(K=this.terrain.getMinMaxForTile(J)||K),X.addShadowReceiver(J.toUnwrapped(),K.min,K.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 Do(this)),this._atmosphere.update(this)):this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0),Q.has(this.context.gl)){for(var ee of(this.renderPass="offscreen",f)){var te=t.getLayerSourceCache(ee);if(ee.hasOffscreenPass()&&!ee.isHidden(this.transform.zoom)){var re=te?w[te.id]:void 0;("custom"===ee.type||"raster"===ee.type||"raster-particle"===ee.type||ee.isSky()||re&&re.length)&&this.renderLayer(this,te,ee,re)}}this.depthRangeFor3D=[0,1-(f.length+2)*this.numSublayers*this.depthEpsilon],this._shadowRenderer&&(this.renderPass="shadow",this._shadowRenderer.drawShadowPass(this.style,T)),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]);var ie="globe"===this.transform.projection.name||this.transform.isHorizonVisible(),ne=(function(){if(r.showOverdrawInspector)return e.bz.black;var t=i.style.fog;if(t&&i.transform.projection.supportsFog){var n=i.style.getLut(t.scope);if(!ie){var a=t.properties.get("color").toRenderColor(n).toArray01();return c(e.bz,d(a))}if(ie){var o=t.properties.get("space-color").toRenderColor(n).toArray01();return c(e.bz,d(o))}}return e.bz.transparent})();if(this.context.clear({color:ne,depth:1}),this.clearStencil(),this._showOverdrawInspector=r.showOverdrawInspector,this.renderPass="opaque",this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&ie&&this._atmosphere.drawStars(this,this.style.fog),!this.terrain)for(this.currentLayer=o.length-1;this.currentLayer>=0;this.currentLayer--){var ae=f[this.currentLayer],oe=t.getLayerSourceCache(ae);if(!ae.isSky()){var se=oe?(ae.is3D()?M:w)[oe.id]:void 0;this._renderTileClippingMasks(ae,oe,se),this.renderLayer(this,oe,ae,se)}}if(this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&ie&&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.currentLayer0&&_e.hasShadowPass()&&0==--fe&&(X.drawGroundShadows(),this.firstLightBeamLayer<=this.currentLayer)){var ge=this.currentLayer;for(this.renderPass="light-beam",this.currentLayer=this.firstLightBeamLayer;this.currentLayer<=ge;this.currentLayer++){var xe=f[this.currentLayer];if(xe.hasLightBeamPass()){var be=t.getLayerSourceCache(xe);this.renderLayer(this,be,xe,be?w[be.id]:void 0)}}this.currentLayer=ge,this.renderPass="translucent"}if(this.currentLayer>=this._lastOcclusionLayer&&this.layersWithOcclusionOpacity.length>0){var we=this.currentLayer;for(var ke of(this.depthOcclusion=!0,this.layersWithOcclusionOpacity)){this.currentLayer=ke;var Te=f[this.currentLayer],Me=t.getLayerSourceCache(Te),Se=Me?w[Me.id]:void 0;Te.is3D()||this.terrain||this._renderTileClippingMasks(Te,Me,Me?b[Me.id]:void 0),this.renderLayer(this,Me,Te,Se)}this.depthOcclusion=!1,this.currentLayer=we,this.renderPass="translucent",this.layersWithOcclusionOpacity=[]}++this.currentLayer}}if(this.terrain&&this.terrain.postRender(),this.options.showTileBoundaries||this.options.showQueryGeometry||this.options.showTileAABBs){var Ee=null;f.forEach((function(e){var r=t.getLayerSourceCache(e);r&&!e.isHidden(i.transform.zoom)&&r.getVisibleCoordinates().length&&(!Ee||Ee.getSource().maxzoom0?t.pop():null}},{key:"terrainRenderModeElevated",value:function(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture||this.forceTerrainMode}},{key:"linearFloatFilteringSupported",value:function(){return null!=this.context.extTextureFloatLinear}},{key:"currentGlobalDefines",value:function(e,t,r){var i=void 0===r?this.terrain&&this.terrain.renderingToTexture:r,n=[];return this.style&&this.style.enable3dLights()&&("globeRaster"===e||"terrainRaster"===e?(n.push("LIGHTING_3D_MODE"),n.push("LIGHTING_3D_ALPHA_EMISSIVENESS")):i||n.push("LIGHTING_3D_MODE")),"shadow"===this.renderPass?this._shadowMapDebug||n.push("DEPTH_TEXTURE"):this.shadowRenderer&&(this.shadowRenderer.useNormalOffset?n.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"):n.push("RENDER_SHADOWS","DEPTH_TEXTURE")),this.terrainRenderModeElevated()&&(n.push("TERRAIN"),this.linearFloatFilteringSupported()&&n.push("TERRAIN_DEM_FLOAT_FORMAT")),"globe"===this.transform.projection.name&&n.push("GLOBE"),!this._fogVisible||i||void 0!==t&&!t||n.push("FOG","FOG_DITHERING"),i&&n.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&n.push("OVERDRAW_INSPECTOR"),n}},{key:"getOrCreateProgram",value:function(e,t){this.cache=this.cache||{};var r=t&&t.defines||[],i=t&&t.config,n=this.currentGlobalDefines(e,t&&t.overrideFog,t&&t.overrideRtt).concat(r),a=ca.cacheKey(rn[e],e,n,i);return this.cache[a]||(this.cache[a]=new ca(this.context,e,rn[e],i,Na[e],n)),this.cache[a]}},{key:"setCustomLayerDefaults",value:function(){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()}},{key:"setBaseState",value:function(){var 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)}},{key:"initDebugOverlayCanvas",value:function(){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))}},{key:"destroy",value:function(){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()}},{key:"prepareDrawTile",value:function(){this.terrain&&this.terrain.prepareDrawTile()}},{key:"uploadCommonLightUniforms",value:function(t,r){if(this.style.enable3dLights()){var i=this.style.directionalLight,n=this.style.ambientLight;if(i&&n){var a=(function(t,r,i){var n=t.properties.get("direction"),a=t.properties.get("color").toRenderColor(i.getLut(t.scope)).toArray01(),o=t.properties.get("intensity"),s=r.properties.get("color").toRenderColor(i.getLut(r.scope)).toArray01(),l=r.properties.get("intensity"),u=[n.x,n.y,n.z],c=e.cH(s,l),h=e.cH(a,o);return{u_lighting_ambient_color:c,u_lighting_directional_dir:u,u_lighting_directional_color:h,u_ground_radiance:sa(u,h,c)}})(i,n,this.style);r.setLightsUniformValues(t,a)}}}},{key:"uploadCommonUniforms",value:function(t,r,i,n,a){if(this.uploadCommonLightUniforms(t,r),!this.terrain||!this.terrain.renderingToTexture){var o=this.style.fog;if(o){var s=o.getOpacity(this.transform.pitch),l=(function(t,r,i,n,a,o,s,l,u,c,h,f){var d=t.transform,p=r.properties.get("color").toRenderColor(t.style.getLut(r.scope)).toArray01();p[3]=n;var m=t.frameCounter/1e3%1,v=r.properties.get("vertical-range"),_=x(v,2),y=_[0],g=_[1];return{u_fog_matrix:i?d.calculateFogTileMatrix(i):f||t.identityMat,u_fog_range:r.getFovAdjustedRange(d._fov),u_fog_color:p,u_fog_horizon_blend:r.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(y,g),g],u_fog_temporal_offset:m,u_frustum_tl:a,u_frustum_tr:o,u_frustum_br:s,u_frustum_bl:l,u_globe_pos:u,u_globe_radius:c,u_viewport:h,u_globe_transition:e.a9(d.zoom),u_is_globe:+("globe"===d.projection.name)}})(this,o,i,s,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],n);r.setFogUniformValues(t,l)}a&&r.setCutoffUniformValues(t,a.uniformValues)}}},{key:"setTileLoadedFlag",value:function(e){this.tileLoaded=e}},{key:"saveCanvasCopy",value:function(){var e=this.canvasCopy();e&&(this.frameCopies.push(e),this.tileLoaded=!1)}},{key:"canvasCopy",value:function(){var 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}},{key:"getCanvasCopiesAndTimestamps",value:function(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}},{key:"averageElevationNeedsEasing",value:function(){if(!this.transform._elevation)return!1;var e=this.style&&this.style.fog;return!!e&&0!==e.getOpacity(this.transform.pitch)}},{key:"getBackgroundTiles",value:function(){var e=this._backgroundTiles,t=this._backgroundTiles={},r=this.transform.coveringTiles({tileSize:512});for(var i of r)t[i.key]=e[i.key]||new Ot(i,512,this.transform.tileZoom,this);return t}},{key:"clearBackgroundTiles",value:function(){this._backgroundTiles={}}},{key:"isSourceForClippingOrConflation",value:function(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)))}},{key:"isTileAffectedByFog",value:function(e){if(!this.style||!this.style.fog)return!1;if("globe"===this.transform.projection.name)return!0;var t=this._cachedTileFogOpacities[e.key];return t||(this._cachedTileFogOpacities[e.key]=t=this.style.fog.getOpacityForTile(e)),t[0]>=$e||t[1]>=$e}},{key:"setupDepthForOcclusion",value:function(e,t,r){var i,n=this.context,a=n.gl,o=!!r;r||(r={u_dem:2,u_dem_prev:4,u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_depth_range_unpack:[0,1],u_occluder_half_size:16,u_occlusion_depth_offset:-1e-4,u_exaggeration:0}),n.activeTexture.set(a.TEXTURE3),e&&this.depthFBO&&this.depthTexture?(this.depthTexture.bind(a.NEAREST,a.CLAMP_TO_EDGE),r.u_depth_size_inv=[1/this.depthFBO.width,1/this.depthFBO.height],r.u_depth_range_unpack=[2/((i=this.depthRangeFor3D)[1]-i[0]),-1-2*i[0]/(i[1]-i[0])],r.u_occluder_half_size=.5*this.occlusionParams.occluderSize,r.u_occlusion_depth_offset=this.occlusionParams.depthOffset):this.emptyDepthTexture.bind(a.NEAREST,a.CLAMP_TO_EDGE),n.activeTexture.set(a.TEXTURE0),o||t.setTerrainUniformValues(n,r)}}])})();function Qo(e,t){var r=!1,i=null,n=function(){i=null,r&&(e(),i=setTimeout(n,t),r=!1)};return function(){return r=!0,i||n(),i}}var es=(function(){return m((function t(r){p(this,t),this._hashName=r&&encodeURIComponent(r),e.aJ(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=Qo(this._updateHashUnthrottled.bind(this),300)}),[{key:"addTo",value:function(e){return this._map=e,window.addEventListener("hashchange",this._onHashChange,!1),e.on("moveend",this._updateHash),this}},{key:"remove",value:function(){return this._map?(this._map.off("moveend",this._updateHash),window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}},{key:"getHashString",value:function(){var e=this._map;if(!e)return"";var t=ts(e);if(this._hashName){var r=this._hashName,i=!1,n=location.hash.slice(1).split("&").map((function(e){var n=e.split("=")[0];return n===r?(i=!0,`${n}=${t}`):e})).filter((function(e){return e}));return i||n.push(`${r}=${t}`),`#${n.join("&")}`}return`#${t}`}},{key:"_getCurrentHash",value:function(){var e,t=this,r=location.hash.replace("#","");return this._hashName?(r.split("&").map((function(e){return e.split("=")})).forEach((function(r){r[0]===t._hashName&&(e=r)})),(e&&e[1]||"").split("/")):r.split("/")}},{key:"_onHashChange",value:function(){var e=this._map;if(!e)return!1;var t=this._getCurrentHash();if(t.length>=3&&!t.some((function(e){return isNaN(e)}))){var r=e.dragRotate.isEnabled()&&e.touchZoomRotate.isEnabled()?+(t[3]||0):e.getBearing();return e.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:r,pitch:+(t[4]||0)}),!0}return!1}},{key:"_updateHashUnthrottled",value:function(){history.replaceState(history.state,"",location.href.replace(/(#.+)?$/,this.getHashString()))}}])})();function ts(e,t){var r=e.getCenter(),i=Math.round(100*e.getZoom())/100,n=Math.ceil((i*Math.LN2+Math.log(2.8444444444444446))/Math.LN10),a=Math.pow(10,n),o=Math.round(r.lng*a)/a,s=Math.round(r.lat*a)/a,l=e.getBearing(),u=e.getPitch(),c=t?`/${o}/${s}/${i}`:`${i}/${s}/${o}`;return(l||u)&&(c+="/"+Math.round(10*l)/10),u&&(c+=`/${Math.round(u)}`),c}var rs={linearity:.3,easing:e.dp(0,0,.3,1)},is=e.l({deceleration:2500,maxSpeed:1400},rs),ns=e.l({deceleration:20,maxSpeed:1400},rs),as=e.l({deceleration:1e3,maxSpeed:360},rs),os=e.l({deceleration:1e3,maxSpeed:90},rs),ss=(function(){return m((function e(t){p(this,e),this._map=t,this.clear()}),[{key:"clear",value:function(){this._inertiaBuffer=[]}},{key:"record",value:function(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:e.q.now(),settings:t})}},{key:"_drainInertiaBuffer",value:function(){for(var t=this._inertiaBuffer,r=e.q.now();t.length>0&&r-t[0].time>160;)t.shift()}},{key:"_onMoveEnd",value:function(t){if(!(this._map._prefersReducedMotion()||(this._drainInertiaBuffer(),this._inertiaBuffer.length<2))){var r={zoom:0,bearing:0,pitch:0,pan:new e.P(0,0),pinchAround:void 0,around:void 0};for(var i of this._inertiaBuffer){var n=i.settings;r.zoom+=n.zoomDelta||0,r.bearing+=n.bearingDelta||0,r.pitch+=n.pitchDelta||0,n.panDelta&&r.pan._add(n.panDelta),n.around&&(r.around=n.around),n.pinchAround&&(r.pinchAround=n.pinchAround)}var a=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,o={};if(r.pan.mag()){var s=us(r.pan.mag(),a,e.l({},is,t||{}));o.offset=r.pan.mult(s.amount/r.pan.mag()),o.center=this._map.transform.center,ls(o,s)}if(r.zoom){var l=us(r.zoom,a,ns);o.zoom=this._map.transform.zoom+l.amount,ls(o,l)}if(r.bearing){var u=us(r.bearing,a,as);o.bearing=this._map.transform.bearing+e.ap(u.amount,-179,179),ls(o,u)}if(r.pitch){var c=us(r.pitch,a,os);o.pitch=this._map.transform.pitch+c.amount,ls(o,c)}if(o.zoom||o.bearing){var h=void 0===r.pinchAround?r.around:r.pinchAround;o.around=h?this._map.unproject(h):this._map.getCenter()}return this.clear(),o.noMoveStart=!0,o}}}])})();function ls(e,t){(!e.duration||e.duration3&&void 0!==arguments[3]?arguments[3]:{};p(this,r);var s=C(i.getCanvasContainer(),n),l=i.unproject(s);return(a=T(this,r,[t,e.l({point:s,lngLat:l,originalEvent:n},o)]))._defaultPrevented=!1,a.target=i,a}return y(r,t),m(r,[{key:"preventDefault",value:function(){this._defaultPrevented=!0}},{key:"defaultPrevented",get:function(){return this._defaultPrevented}}])})(e.x),hs=(function(t){function r(t,i,n){var a;p(this,r);var o="touchend"===t?n.changedTouches:n.touches,s=P(i.getCanvasContainer(),o),l=s.map((function(e){return i.unproject(e)})),u=s.reduce((function(e,t,r,i){return e.add(t.div(i.length))}),new e.P(0,0));return(a=T(this,r,[t,{points:s,point:u,lngLats:l,lngLat:i.unproject(u),originalEvent:n}]))._defaultPrevented=!1,a}return y(r,t),m(r,[{key:"preventDefault",value:function(){this._defaultPrevented=!0}},{key:"defaultPrevented",get:function(){return this._defaultPrevented}}])})(e.x),fs=(function(e){function t(e,r){var i;return p(this,t),(i=T(this,t,["wheel",{originalEvent:r}]))._defaultPrevented=!1,i}return y(t,e),m(t,[{key:"preventDefault",value:function(){this._defaultPrevented=!0}},{key:"defaultPrevented",get:function(){return this._defaultPrevented}}])})(e.x),ds=(function(){return m((function e(t,r){p(this,e),this._map=t,this._clickTolerance=r.clickTolerance}),[{key:"reset",value:function(){this._mousedownPos=void 0}},{key:"wheel",value:function(e){return this._firePreventable(new fs(this._map,e))}},{key:"mousedown",value:function(e,t){return this._mousedownPos=t,this._firePreventable(new cs(e.type,this._map,e))}},{key:"mouseup",value:function(e){this._map.fire(new cs(e.type,this._map,e))}},{key:"preclick",value:function(t){var r=e.l({},t);r.type="preclick",this._map.fire(new cs(r.type,this._map,r))}},{key:"click",value:function(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||(this.preclick(e),this._map.fire(new cs(e.type,this._map,e)))}},{key:"dblclick",value:function(e){return this._firePreventable(new cs(e.type,this._map,e))}},{key:"mouseover",value:function(e){this._map.fire(new cs(e.type,this._map,e))}},{key:"mouseout",value:function(e){this._map.fire(new cs(e.type,this._map,e))}},{key:"touchstart",value:function(e){return this._firePreventable(new hs(e.type,this._map,e))}},{key:"touchmove",value:function(e){this._map.fire(new hs(e.type,this._map,e))}},{key:"touchend",value:function(e){this._map.fire(new hs(e.type,this._map,e))}},{key:"touchcancel",value:function(e){this._map.fire(new hs(e.type,this._map,e))}},{key:"_firePreventable",value:function(e){if(this._map.fire(e),e.defaultPrevented)return{}}},{key:"isEnabled",value:function(){return!0}},{key:"isActive",value:function(){return!1}},{key:"enable",value:function(){}},{key:"disable",value:function(){}}])})(),ps=(function(){return m((function e(t){p(this,e),this._map=t}),[{key:"reset",value:function(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}},{key:"mousemove",value:function(e){this._map.fire(new cs(e.type,this._map,e))}},{key:"mousedown",value:function(){this._delayContextMenu=!0}},{key:"mouseup",value:function(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new cs("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}},{key:"contextmenu",value:function(e){this._delayContextMenu?this._contextMenuEvent=e:this._map.fire(new cs(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}},{key:"isEnabled",value:function(){return!0}},{key:"isActive",value:function(){return!1}},{key:"enable",value:function(){}},{key:"disable",value:function(){}}])})(),ms=(function(){return m((function e(t,r){p(this,e),this._map=t,this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=r.clickTolerance||1}),[{key:"isEnabled",value:function(){return!!this._enabled}},{key:"isActive",value:function(){return!!this._active}},{key:"enable",value:function(){this.isEnabled()||(this._enabled=!0)}},{key:"disable",value:function(){this.isEnabled()&&(this._enabled=!1)}},{key:"mousedown",value:function(e,t){this.isEnabled()&&e.shiftKey&&0===e.button&&(S(),this._startPos=this._lastPos=t,this._active=!0)}},{key:"mousemoveWindow",value:function(e,t){var r=this;if(this._active){var i=t,n=this._startPos,a=this._lastPos;if(!(!n||!a||a.equals(i)||!this._box&&i.dist(n)this.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=t.timeStamp),i.length===this.numTouches&&(this.centroid=(function(t){var r=new e.P(0,0);for(var i of t)r._add(i);return r.div(t.length)})(r),this.touches=vs(i,r)))}},{key:"touchmove",value:function(e,t,r){if(!this.aborted&&this.centroid){var i=vs(r,t);for(var n in this.touches){var a=i[n];(!a||a.dist(this.touches[n])>30)&&(this.aborted=!0)}}}},{key:"touchend",value:function(e,t,r){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===r.length){var i=!this.aborted&&this.centroid;if(this.reset(),i)return i}}}])})(),ys=(function(){return m((function e(t){p(this,e),this.singleTap=new _s(t),this.numTaps=t.numTaps,this.reset()}),[{key:"reset",value:function(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}},{key:"touchstart",value:function(e,t,r){this.singleTap.touchstart(e,t,r)}},{key:"touchmove",value:function(e,t,r){this.singleTap.touchmove(e,t,r)}},{key:"touchend",value:function(e,t,r){var i=this.singleTap.touchend(e,t,r);if(i){var n=e.timeStamp-this.lastTime<500,a=!this.lastTap||this.lastTap.dist(i)<30;if(n&&a||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=i,this.count===this.numTaps)return this.reset(),i}}}])})(),gs=(function(){return m((function e(){p(this,e),this._zoomIn=new ys({numTouches:1,numTaps:2}),this._zoomOut=new ys({numTouches:2,numTaps:1}),this.reset()}),[{key:"reset",value:function(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}},{key:"touchstart",value:function(e,t,r){this._zoomIn.touchstart(e,t,r),this._zoomOut.touchstart(e,t,r)}},{key:"touchmove",value:function(e,t,r){this._zoomIn.touchmove(e,t,r),this._zoomOut.touchmove(e,t,r)}},{key:"touchend",value:function(e,t,r){var i=this,n=this._zoomIn.touchend(e,t,r),a=this._zoomOut.touchend(e,t,r);return n?(this._active=!0,e.preventDefault(),setTimeout((function(){return i.reset()}),0),{cameraAnimation:function(t){return t.easeTo({duration:300,zoom:t.getZoom()+1,around:t.unproject(n)},{originalEvent:e})}}):a?(this._active=!0,e.preventDefault(),setTimeout((function(){return i.reset()}),0),{cameraAnimation:function(t){return t.easeTo({duration:300,zoom:t.getZoom()-1,around:t.unproject(a)},{originalEvent:e})}}):void 0}},{key:"touchcancel",value:function(){this.reset()}},{key:"enable",value:function(){this._enabled=!0}},{key:"disable",value:function(){this._enabled=!1,this.reset()}},{key:"isEnabled",value:function(){return this._enabled}},{key:"isActive",value:function(){return this._active}}])})(),xs={0:1,2:2},bs=(function(){return m((function e(t){p(this,e),this.reset(),this._clickTolerance=t.clickTolerance||1}),[{key:"blur",value:function(){this.reset()}},{key:"reset",value:function(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}},{key:"_correctButton",value:function(e,t){return!1}},{key:"_move",value:function(e,t){return{}}},{key:"mousedown",value:function(e,t){if(!this._lastPoint){var r=z(e);this._correctButton(e,r)&&(this._lastPoint=t,this._eventButton=r)}}},{key:"mousemoveWindow",value:function(e,t){var r=this._lastPoint;if(r)if(e.preventDefault(),null!=this._eventButton&&(function(e,t){var r=xs[t];return void 0===e.buttons||(e.buttons&r)!==r})(e,this._eventButton))this.reset();else if(this._moved||!(t.dist(r)0&&(this._active=!0);var n=vs(i,r),a=new e.P(0,0),o=new e.P(0,0),s=0;for(var l in n){var u=n[l],c=this._touches[l];c&&(a._add(u),o._add(u.sub(c)),s++,n[l]=u)}if(this._touches=n,!(sMath.abs(e.x)}var Ds=(function(t){function r(e){var t;return p(this,r),(t=T(this,r))._map=e,t}return y(r,t),m(r,[{key:"reset",value:function(){k(r,"reset",this,3)([]),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}},{key:"_start",value:function(e){this._lastPoints=e,zs(e[0].sub(e[1]))&&(this._valid=!1)}},{key:"_move",value:function(t,r,i){var n=this._lastPoints;if(n){var a=t[0].sub(n[0]),o=t[1].sub(n[1]);return this._map._cooperativeGestures&&!e.dq()&&i.touches.length<3||(this._valid=this.gestureBeginsVertically(a,o,i.timeStamp),!this._valid)?void 0:(this._lastPoints=t,this._active=!0,{pitchDelta:(a.y+o.y)/2*-.5})}}},{key:"gestureBeginsVertically",value:function(e,t,r){if(void 0!==this._valid)return this._valid;var i=e.mag()>=2,n=t.mag()>=2;if(i||n){if(!i||!n)return null==this._firstMove&&(this._firstMove=r),r-this._firstMove<100&&void 0;var a=e.y>0==t.y>0;return zs(e)&&zs(t)&&a}}}])})(Ss),Rs={panStep:100,bearingStep:15,pitchStep:10},Ls=(function(){return m((function e(){p(this,e);var t=Rs;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.pitchStep,this._rotationDisabled=!1}),[{key:"blur",value:function(){this.reset()}},{key:"reset",value:function(){this._active=!1}},{key:"keydown",value:function(e){var t=this;if(!(e.altKey||e.ctrlKey||e.metaKey)){var r=0,i=0,n=0,a=0,o=0;switch(e.keyCode){case 61:case 107:case 171:case 187:r=1;break;case 189:case 109:case 173:r=-1;break;case 37:e.shiftKey?i=-1:(e.preventDefault(),a=-1);break;case 39:e.shiftKey?i=1:(e.preventDefault(),a=1);break;case 38:e.shiftKey?n=1:(e.preventDefault(),o=-1);break;case 40:e.shiftKey?n=-1:(e.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(i=0,n=0),{cameraAnimation:function(s){var l=s.getZoom();s.easeTo({duration:300,easeId:"keyboardHandler",easing:Os,zoom:r?Math.round(l)+r*(e.shiftKey?2:1):l,bearing:s.getBearing()+i*t._bearingStep,pitch:s.getPitch()+n*t._pitchStep,offset:[-a*t._panStep,-o*t._panStep],center:s.getCenter()},{originalEvent:e})}}}}},{key:"enable",value:function(){this._enabled=!0}},{key:"disable",value:function(){this._enabled=!1,this.reset()}},{key:"isEnabled",value:function(){return this._enabled}},{key:"isActive",value:function(){return this._active}},{key:"disableRotation",value:function(){this._rotationDisabled=!0}},{key:"enableRotation",value:function(){this._rotationDisabled=!1}}])})();function Os(e){return e*(2-e)}var Bs=4.000244140625,Fs=(function(){return m((function t(r,i){p(this,t),this._map=r,this._el=r.getCanvasContainer(),this._handler=i,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,e.aJ(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this)}),[{key:"setZoomRate",value:function(e){this._defaultZoomRate=e}},{key:"setWheelZoomRate",value:function(e){this._wheelZoomRate=e}},{key:"isEnabled",value:function(){return!!this._enabled}},{key:"isActive",value:function(){return this._active||void 0!==this._finishTimeout}},{key:"isZooming",value:function(){return!!this._zooming}},{key:"enable",value:function(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around,this._map._cooperativeGestures&&this._addScrollZoomBlocker())}},{key:"disable",value:function(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}},{key:"wheel",value:function(t){if(this.isEnabled()){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))}var r=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY,i=e.q.now(),n=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,0!==r&&r%Bs==0?this._type="wheel":0!==r&&Math.abs(r)<4?this._type="trackpad":n>400?(this._type=null,this._lastValue=r,this._timeout=window.setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(n*r)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,r+=this._lastValue)),t.shiftKey&&r&&(r/=4),this._type&&(this._lastWheelEvent=t,this._delta-=r,this._active||this._start(t)),t.preventDefault()}}},{key:"_onTimeout",value:function(e){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e)}},{key:"_start",value:function(e){if(this._delta){this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);var t=C(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())}}},{key:"renderFrame",value:function(){var t=this;if(this._frameId&&(this._frameId=null,this.isActive())){var r=this._map.transform;"wheel"===this._type&&r.projection.wrap&&(r._center.lng>=180||r._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);var i=function(){return r._terrainEnabled()&&t._aroundCoord?r.computeZoomRelativeTo(t._aroundCoord):r.zoom};if(0!==this._delta){var n="wheel"===this._type&&Math.abs(this._delta)>Bs?this._wheelZoomRate:this._defaultZoomRate,a=2/(1+Math.exp(-Math.abs(this._delta*n)));this._delta<0&&0!==a&&(a=1/a);var o=i(),s=Math.pow(2,o),l="number"==typeof this._targetZoom?r.zoomScale(this._targetZoom):s;this._targetZoom=Math.min(r.maxZoom,Math.max(r.minZoom,r.scaleZoom(l*a))),"wheel"===this._type&&(this._startZoom=o,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0}var u,c="number"==typeof this._targetZoom?this._targetZoom:i(),h=this._startZoom,f=this._easing,d=!1;if("wheel"===this._type&&h&&f){var p=Math.min((e.q.now()-this._lastWheelEventTime)/200,1),m=f(p);u=e.aa(h,c,m),p<1?this._frameId||(this._frameId=!0):d=!0}else u=c,d=!0;this._active=!0,d&&(this._active=!1,this._finishTimeout=window.setTimeout((function(){t._zooming=!1,t._handler._triggerRenderFrame(),delete t._targetZoom,delete t._finishTimeout}),200));var v=u-i();return v*this._lastDelta<0&&(v=0),{noInertia:!0,needsRenderFrame:!d,zoomDelta:v,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}}},{key:"_smoothOutEasing",value:function(t){var r=e.dr;if(this._prevEase){var i=this._prevEase,n=(e.q.now()-i.start)/i.duration,a=i.easing(n+.01)-i.easing(n),o=.27/Math.sqrt(a*a+1e-4)*.01,s=Math.sqrt(.0729-o*o);r=e.dp(o,s,.25,1)}return this._prevEase={start:e.q.now(),duration:t,easing:r},r}},{key:"blur",value:function(){this.reset()}},{key:"reset",value:function(){this._active=!1}},{key:"_addScrollZoomBlocker",value:function(){this._map&&!this._alertContainer&&(this._alertContainer=f("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`)}},{key:"_showBlockerAlert",value:function(){var e=this;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((function(){e._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),e._alertContainer.removeAttribute("role")}),200)}}])})(),Ns=(function(){return m((function e(t,r){p(this,e),this._clickZoom=t,this._tapZoom=r}),[{key:"enable",value:function(){this._clickZoom.enable(),this._tapZoom.enable()}},{key:"disable",value:function(){this._clickZoom.disable(),this._tapZoom.disable()}},{key:"isEnabled",value:function(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}},{key:"isActive",value:function(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}])})(),Vs=(function(){return m((function e(){p(this,e),this.reset()}),[{key:"reset",value:function(){this._active=!1}},{key:"blur",value:function(){this.reset()}},{key:"dblclick",value:function(e,t){return e.preventDefault(),{cameraAnimation:function(r){r.easeTo({duration:300,zoom:r.getZoom()+(e.shiftKey?-1:1),around:r.unproject(t)},{originalEvent:e})}}}},{key:"enable",value:function(){this._enabled=!0}},{key:"disable",value:function(){this._enabled=!1,this.reset()}},{key:"isEnabled",value:function(){return this._enabled}},{key:"isActive",value:function(){return this._active}}])})(),Us=(function(){return m((function e(){p(this,e),this._tap=new ys({numTouches:1,numTaps:1}),this.reset()}),[{key:"reset",value:function(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}},{key:"touchstart",value:function(e,t,r){this._swipePoint||(this._tapTime&&e.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?r.length>0&&(this._swipePoint=t[0],this._swipeTouch=r[0].identifier):this._tap.touchstart(e,t,r))}},{key:"touchmove",value:function(e,t,r){if(this._tapTime){if(this._swipePoint){if(r[0].identifier!==this._swipeTouch)return;var i=t[0],n=i.y-this._swipePoint.y;return this._swipePoint=i,e.preventDefault(),this._active=!0,{zoomDelta:n/128}}}else this._tap.touchmove(e,t,r)}},{key:"touchend",value:function(e,t,r){this._tapTime?this._swipePoint&&0===r.length&&this.reset():this._tap.touchend(e,t,r)&&(this._tapTime=e.timeStamp)}},{key:"touchcancel",value:function(){this.reset()}},{key:"enable",value:function(){this._enabled=!0}},{key:"disable",value:function(){this._enabled=!1,this.reset()}},{key:"isEnabled",value:function(){return this._enabled}},{key:"isActive",value:function(){return this._active}}])})(),js=(function(){return m((function e(t,r,i){p(this,e),this._el=t,this._mousePan=r,this._touchPan=i}),[{key:"enable",value:function(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("mapboxgl-touch-drag-pan")}},{key:"disable",value:function(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("mapboxgl-touch-drag-pan")}},{key:"isEnabled",value:function(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}},{key:"isActive",value:function(){return this._mousePan.isActive()||this._touchPan.isActive()}}])})(),Gs=(function(){return m((function e(t,r,i){p(this,e),this._pitchWithRotate=t.pitchWithRotate,this._mouseRotate=r,this._mousePitch=i}),[{key:"enable",value:function(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}},{key:"disable",value:function(){this._mouseRotate.disable(),this._mousePitch.disable()}},{key:"isEnabled",value:function(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}},{key:"isActive",value:function(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}])})(),qs=(function(){return m((function e(t,r,i,n){p(this,e),this._el=t,this._touchZoom=r,this._touchRotate=i,this._tapDragZoom=n,this._rotationDisabled=!1,this._enabled=!0}),[{key:"enable",value:function(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("mapboxgl-touch-zoom-rotate")}},{key:"disable",value:function(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("mapboxgl-touch-zoom-rotate")}},{key:"isEnabled",value:function(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}},{key:"isActive",value:function(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}},{key:"disableRotation",value:function(){this._rotationDisabled=!0,this._touchRotate.disable()}},{key:"enableRotation",value:function(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}])})(),Zs=function(e){return e.zoom||e.drag||e.pitch||e.rotate},$s=(function(e){function t(){return p(this,t),T(this,t,arguments)}return y(t,e),m(t)})(e.x),Hs=(function(){return m((function e(){p(this,e),this.constants=[1,1,.01],this.radius=0}),[{key:"setup",value:function(t,r){var i=e.a6.vec3.sub([],r,t);this.radius=e.a6.vec3.length(i[2]<0?e.a6.vec3.div([],i,this.constants):[i[0],i[1],0])}},{key:"projectRay",value:function(t){e.a6.vec3.div(t,t,this.constants),e.a6.vec3.normalize(t,t),e.a6.vec3.mul(t,t,this.constants);var r=e.a6.vec3.scale([],t,this.radius);if(r[2]>0){var i=e.a6.vec3.scale([],[0,0,1],e.a6.vec3.dot(r,[0,0,1])),n=e.a6.vec3.scale([],e.a6.vec3.normalize([],[r[0],r[1],0]),this.radius),a=e.a6.vec3.add([],r,e.a6.vec3.scale([],e.a6.vec3.sub([],e.a6.vec3.add([],n,i),r),2));r[0]=a[0],r[1]=a[1]}return r}}])})();function Ws(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta}var Xs=(function(){return m((function t(r,i){p(this,t),this._map=r,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new ss(r),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new Hs,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(i),e.aJ(["handleEvent","handleWindowEvent"],this);var n=this._el;for(var a of(this._listeners=[[n,"touchstart",{passive:!0}],[n,"touchmove",{passive:!1}],[n,"touchend",void 0],[n,"touchcancel",void 0],[n,"mousedown",void 0],[n,"mousemove",void 0],[n,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[n,"mouseover",void 0],[n,"mouseout",void 0],[n,"dblclick",void 0],[n,"click",void 0],[n,"keydown",{capture:!1}],[n,"keyup",void 0],[n,"wheel",{passive:!1}],[n,"contextmenu",void 0],[window,"blur",void 0]],this._listeners)){var o=x(a,3),s=o[0],l=o[1],u=o[2],c=s===document?this.handleWindowEvent:this.handleEvent;s.addEventListener(l,c,u)}}),[{key:"destroy",value:function(){for(var e of this._listeners){var t=x(e,3),r=t[0],i=t[1],n=t[2],a=r===document?this.handleWindowEvent:this.handleEvent;r.removeEventListener(i,a,n)}}},{key:"_addDefaultHandlers",value:function(e){var t=this._map,r=t.getCanvasContainer();this._add("mapEvent",new ds(t,e));var i=t.boxZoom=new ms(t,e);this._add("boxZoom",i);var n=new gs,a=new Vs;t.doubleClickZoom=new Ns(a,n),this._add("tapZoom",n),this._add("clickZoom",a);var o=new Us;this._add("tapDragZoom",o);var s=t.touchPitch=new Ds(t);this._add("touchPitch",s);var l=new ks(e),u=new Ts(e);t.dragRotate=new Gs(e,l,u),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",u,["mouseRotate"]);var c=new ws(e),h=new Ms(t,e);t.dragPan=new js(r,c,h),this._add("mousePan",c),this._add("touchPan",h,["touchZoom","touchRotate"]);var f=new Ps,d=new As;t.touchZoomRotate=new qs(r,d,f,o),this._add("touchRotate",f,["touchPan","touchZoom"]),this._add("touchZoom",d,["touchPan","touchRotate"]),this._add("blockableMapEvent",new ps(t));var p=t.scrollZoom=new Fs(t,this);this._add("scrollZoom",p,["mousePan"]);var m=t.keyboard=new Ls;for(var v of(this._add("keyboard",m),["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"]))e.interactive&&e[v]&&t[v].enable(e[v])}},{key:"_add",value:function(e,t,r){this._handlers.push({handlerName:e,handler:t,allowed:r}),this._handlersById[e]=t}},{key:"stop",value:function(e){if(!this._updatingCamera){for(var t of this._handlers){t.handler.reset()}this._inertia.clear(),this._fireEvents({},{},e),this._changes=[],this._originalZoom=void 0}}},{key:"isActive",value:function(){for(var e of this._handlers){if(e.handler.isActive())return!0}return!1}},{key:"isZooming",value:function(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}},{key:"isRotating",value:function(){return!!this._eventsInProgress.rotate}},{key:"isMoving",value:function(){return!!Zs(this._eventsInProgress)||this.isZooming()}},{key:"_isDragging",value:function(){return!!this._eventsInProgress.drag}},{key:"_blockedByActive",value:function(e,t,r){for(var i in e)if(i!==r&&(!t||t.indexOf(i)<0))return!0;return!1}},{key:"handleWindowEvent",value:function(e){this.handleEvent(e,`${e.type}Window`)}},{key:"_getMapTouches",value:function(e){var t=[];for(var r of e)this._el.contains(r.target)&&t.push(r);return t}},{key:"handleEvent",value:function(e,t){this._updatingCamera=!0;var r="renderFrame"===e.type,i=r?void 0:e,n={needsRenderFrame:!1},a={},o={},s=e.touches?this._getMapTouches(e.touches):void 0,l=s?P(this._el,s):r?void 0:C(this._el,e);for(var u of this._handlers){var c=u.handlerName,h=u.handler,f=u.allowed;if(h.isEnabled()){var d=void 0;this._blockedByActive(o,f,c)?h.reset():h[t||e.type]&&(d=h[t||e.type](e,l,s),this.mergeHandlerResult(n,a,d,c,i),d&&d.needsRenderFrame&&this._triggerRenderFrame()),(d||h.isActive())&&(o[c]=h)}}var p={};for(var m in this._previousActiveHandlers)o[m]||(p[m]=i);this._previousActiveHandlers=o,(Object.keys(p).length||Ws(n))&&(this._changes.push([n,a,p]),this._triggerRenderFrame()),(Object.keys(o).length||Ws(n))&&this._map._stop(!0),this._updatingCamera=!1;var v=n.cameraAnimation;v&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],v(this._map))}},{key:"mergeHandlerResult",value:function(t,r,i,n,a){if(i){e.l(t,i);var o={handlerName:n,originalEvent:i.originalEvent||a};void 0!==i.zoomDelta&&(r.zoom=o),void 0!==i.panDelta&&(r.drag=o),void 0!==i.pitchDelta&&(r.pitch=o),void 0!==i.bearingDelta&&(r.rotate=o)}}},{key:"_applyChanges",value:function(){var t={},r={},i={};for(var n of this._changes){var a=x(n,3),o=a[0],s=a[1],l=a[2];o.panDelta&&(t.panDelta=(t.panDelta||new e.P(0,0))._add(o.panDelta)),o.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+o.zoomDelta),o.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+o.bearingDelta),o.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+o.pitchDelta),void 0!==o.around&&(t.around=o.around),void 0!==o.aroundCoord&&(t.aroundCoord=o.aroundCoord),void 0!==o.pinchAround&&(t.pinchAround=o.pinchAround),o.noInertia&&(t.noInertia=o.noInertia),e.l(r,s),e.l(i,l)}this._updateMapTransform(t,r,i),this._changes=[]}},{key:"_updateMapTransform",value:function(t,r,i){var n=this,a=this._map,o=a.transform,s=function(e){return[e.x,e.y,e.z]};if((function(){var e=n._eventsInProgress.drag;return e&&!n._handlersById[e.handlerName].isActive()})()&&!Ws(t)){var l=o.zoom;o.cameraElevationReference="sea",null!=this._originalZoom&&o._orthographicProjectionAtLowPitch&&"globe"!==o.projection.name&&0===o.pitch?(o.cameraElevationReference="ground",o.zoom=this._originalZoom):(o.recenterOnTerrain(),o.cameraElevationReference="ground"),l!==o.zoom&&this._map._update(!0)}if(o._isCameraConstrained&&a._stop(!0),Ws(t)){var u=t.panDelta,c=t.zoomDelta,h=t.bearingDelta,f=t.pitchDelta,d=t.around,p=t.aroundCoord,m=t.pinchAround;o._isCameraConstrained&&(c>0&&(c=0),o._isCameraConstrained=!1),void 0!==m&&(d=m),(c||(function(e){return r[e]&&!n._eventsInProgress[e]})("drag"))&&d&&(this._dragOrigin=s(o.pointCoordinate3D(d)),this._originalZoom=o.zoom,this._trackingEllipsoid.setup(o._camera.position,this._dragOrigin)),o.cameraElevationReference="sea",a._stop(!0),d=d||a.transform.centerPoint,h&&(o.bearing+=h),f&&(o.pitch+=f),o._updateCameraState();var v=[0,0,0];if(u)if("mercator"===o.projection.name){var _=this._trackingEllipsoid.projectRay(o.screenPointToMercatorRay(d).dir),y=this._trackingEllipsoid.projectRay(o.screenPointToMercatorRay(d.sub(u)).dir);v[0]=y[0]-_[0],v[1]=y[1]-_[1]}else{var g=o.pointCoordinate(d);if("globe"===o.projection.name){u=u.rotate(-o.angle);var x=o._pixelsPerMercatorPixel/o.worldSize;v[0]=-u.x*e.ds(e.aM(g.y))*x,v[1]=-u.y*e.ds(o.center.lat)*x}else{var b=o.pointCoordinate(d.sub(u));g&&b&&(v[0]=b.x-g.x,v[1]=b.y-g.y)}}var w=o.zoom,k=[0,0,0];if(c){var T=s(p||o.pointCoordinate3D(d)),M={dir:e.a6.vec3.normalize([],e.a6.vec3.sub([],T,o._camera.position))};if(M.dir[2]<0){var S=o.zoomDeltaToMovement(T,c);e.a6.vec3.scale(k,M.dir,S)}}var E=e.a6.vec3.add(v,v,k);o._translateCameraConstrained(E),c&&Math.abs(o.zoom-w)>1e-4&&o.recenterOnTerrain(),o.cameraElevationReference="ground",this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(r,i,!0)}else this._fireEvents(r,i,!0)}},{key:"_fireEvents",value:function(t,r,i){var n=this,a=Zs(this._eventsInProgress),o=Zs(t),s={};for(var l in t){var u=t[l].originalEvent;this._eventsInProgress[l]||(s[`${l}start`]=u),this._eventsInProgress[l]=t[l]}for(var c in!a&&o&&this._fireEvent("movestart",o.originalEvent),s)this._fireEvent(c,s[c]);for(var h in o&&this._fireEvent("move",o.originalEvent),t){var f=t[h].originalEvent;this._fireEvent(h,f)}var d,p={};for(var m in this._eventsInProgress){var v=this._eventsInProgress[m],_=v.handlerName,y=v.originalEvent;this._handlersById[_].isActive()||(delete this._eventsInProgress[m],d=r[_]||y,p[`${m}end`]=d)}for(var g in p)this._fireEvent(g,p[g]);var x=Zs(this._eventsInProgress);if(i&&(a||o)&&!x){this._updatingCamera=!0;var b=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),w=function(e){return 0!==e&&-n._bearingSnape.aspect?r/(2*Math.tan(.5*e.fovX)*e.aspect):i/(2*Math.tan(.5*e.fovY)*e.aspect)}},{key:"_cameraForBoundsOnGlobe",value:function(t,r,i,n,a,o){var s=t.clone(),l=this._extendCameraOptions(o);s.bearing=n,s.pitch=a;var u=e.bK.convert(r),c=e.bK.convert(i),h=.5*(u.lat+c.lat),f=.5*(u.lng+c.lng),d=e.dt(h,f),p=e.a6.vec3.normalize([],d),m=e.a6.vec3.normalize([],e.a6.vec3.cross([],p,[0,1,0])),v=e.a6.vec3.cross([],m,p),_=[m[0],m[1],m[2],0,v[0],v[1],v[2],0,p[0],p[1],p[2],0,0,0,0,1],y=[d,e.dt(u.lat,u.lng),e.dt(c.lat,u.lng),e.dt(c.lat,c.lng),e.dt(u.lat,c.lng),e.dt(h,u.lng),e.dt(h,c.lng),e.dt(u.lat,f),e.dt(c.lat,f)],g=e.c9.fromPoints(y.map((function(t){return[e.a6.vec3.dot(m,t),e.a6.vec3.dot(v,t),e.a6.vec3.dot(p,t)]}))),x=e.a6.vec3.transformMat4([],g.center,_);0===e.a6.vec3.squaredLength(x)&&e.a6.vec3.set(x,0,0,1),e.a6.vec3.normalize(x,x),e.a6.vec3.scale(x,x,e.aq),s.center=e.du(x);var b=s.getWorldToCameraMatrix(),w=e.a6.mat4.invert(new Float64Array(16),b);g=e.c9.applyTransform(g,e.a6.mat4.multiply([],b,_));var k=this._extendAABB(g,s,l,n);if(k){g=k,e.a6.vec3.transformMat4(x,x,b);var T=.5*(g.max[2]-g.min[2]),M=this._minimumAABBFrustumDistance(s,g),S=e.a6.vec3.scale([],[0,0,1],T),E=e.a6.vec3.add(S,x,S),I=M+(0===s.pitch?0:e.a6.vec3.distance(x,E)),A=s.globeCenterInViewSpace,C=e.a6.vec3.sub([],x,[A[0],A[1],A[2]]);e.a6.vec3.normalize(C,C),e.a6.vec3.scale(C,C,I);var P=e.a6.vec3.add([],x,C);e.a6.vec3.transformMat4(P,P,w);var z=e.dw/e.aq,D=e.a6.vec3.length(P),R=e.bD(Math.max(D*z-e.dw,Number.EPSILON),0),L=Math.min(s.zoomFromMercatorZAdjusted(R),l.maxZoom);return L>.5*(e.c2+e.bU)?(s.setProjection({name:"mercator"}),s.zoom=L,this._cameraForBounds(s,r,i,n,a,o)):{center:s.center,zoom:L,bearing:n,pitch:a}}e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}},{key:"_extendAABB",value:function(t,r,i,n){var a=.5*((i.padding.left||0)+(i.padding.right||0)),o=.5*((i.padding.top||0)+(i.padding.bottom||0)),s=o,l=a,u=a,c=o,h=r.width-(l+u),f=r.height-(s+c),d=e.a6.vec3.sub([],t.max,t.min),p=Math.min(h/d[0],f/d[1]),m=Math.min(r.scaleZoom(r.scale*p),i.maxZoom);if(isNaN(m))return null;var v=r.scale/r.zoomScale(m),_=new e.c9([t.min[0]-l*v,t.min[1]-c*v,t.min[2]],[t.max[0]+u*v,t.max[1]+s*v,t.max[2]]),y=("number"==typeof i.offset.x&&"number"==typeof i.offset.y?new e.P(i.offset.x,i.offset.y):e.P.convert(i.offset)).rotate(-e.bB(n));return _.center[0]-=y.x*v,_.center[1]+=y.y*v,_}},{key:"queryTerrainElevation",value:function(t,r){var i=this.transform.elevation;return i?(r=e.l({},{exaggerated:!0},r),i.getAtPoint(e.a5.fromLngLat(t),null,r.exaggerated)):null}},{key:"_cameraForBounds",value:function(t,r,i,n,a,o){if("globe"===t.projection.name)return this._cameraForBoundsOnGlobe(t,r,i,n,a,o);var s=t.clone(),l=this._extendCameraOptions(o);s.bearing=n,s.pitch=a;var u=e.bK.convert(r),c=e.bK.convert(i),h=new e.bK(u.lng,c.lat),f=new e.bK(c.lng,u.lat),d=s.project(u),p=s.project(c),m=this.queryTerrainElevation(u),v=this.queryTerrainElevation(c),_=this.queryTerrainElevation(h),y=this.queryTerrainElevation(f),g=[[d.x,d.y,Math.min(m||0,v||0,_||0,y||0)],[p.x,p.y,Math.max(m||0,v||0,_||0,y||0)]],x=e.c9.fromPoints(g),b=s.getWorldToCameraMatrix(),w=e.a6.mat4.invert(new Float64Array(16),b);x=e.c9.applyTransform(x,b);var k=this._extendAABB(x,s,l,n);if(k){x=k;var T=.5*e.a6.vec3.sub([],x.max,x.min)[2],M=this._minimumAABBFrustumDistance(s,x),S=[0,0,1,0];e.a6.vec4.transformMat4(S,S,b),e.a6.vec4.normalize(S,S);var E=e.a6.vec3.scale([],S,M+T),I=e.a6.vec3.add([],x.center,E);e.a6.vec3.transformMat4(x.center,x.center,w),e.a6.vec3.transformMat4(I,I,w);var A=s.unproject(new e.P(x.center[0],x.center[1])),C=e.dv(s.projection,A),P=Math.pow(2,C),z=Math.min(s._zoomFromMercatorZ(I[2]*s.pixelsPerMeter*P/s.worldSize),l.maxZoom);return s.mercatorFromTransition&&z<.5*(e.c2+e.bU)?(s.setProjection({name:"globe"}),s.zoom=z,this._cameraForBounds(s,r,i,n,a,o)):{center:A,zoom:z,bearing:n,pitch:a}}e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}},{key:"fitBounds",value:function(e,t,r){var i=this.cameraForBounds(e,t);return this._fitInternal(i,t,r)}},{key:"fitScreenCoordinates",value:function(t,r,i,n,a){var o=e.P.convert(t),s=e.P.convert(r),l=new e.P(Math.min(o.x,s.x),Math.min(o.y,s.y)),u=new e.P(Math.max(o.x,s.x),Math.max(o.y,s.y));if("mercator"===this.transform.projection.name&&this.transform.anyCornerOffEdge(o,s))return this;var c=this.transform.pointLocation3D(l),h=this.transform.pointLocation3D(u),f=this.transform.pointLocation3D(new e.P(l.x,u.y)),d=this.transform.pointLocation3D(new e.P(u.x,l.y)),p=[Math.min(c.lng,h.lng,f.lng,d.lng),Math.min(c.lat,h.lat,f.lat,d.lat)],m=[Math.max(c.lng,h.lng,f.lng,d.lng),Math.max(c.lat,h.lat,f.lat,d.lat)],v=n&&n.pitch?n.pitch:this.getPitch(),_=this._cameraForBounds(this.transform,p,m,i,v,n);return this._fitInternal(_,n,a)}},{key:"_fitInternal",value:function(t,r,i){return t?(r=e.l(t,r)).linear?this.easeTo(r,i):this.flyTo(r,i):this}},{key:"jumpTo",value:function(t,r){this.stop();var i=t.preloadOnly?this.transform.clone():this.transform,n=!1,a=!1,o=!1;"zoom"in t&&i.zoom!==+t.zoom&&(n=!0,i.zoom=+t.zoom),void 0!==t.center&&(i.center=e.bK.convert(t.center)),"bearing"in t&&i.bearing!==+t.bearing&&(a=!0,i.bearing=+t.bearing),"pitch"in t&&i.pitch!==+t.pitch&&(o=!0,i.pitch=+t.pitch);var s="number"==typeof t.padding?this._extendPadding(t.padding):t.padding;if(null!=t.padding&&!i.isPaddingEqual(s))if(!1===t.retainPadding){var l=i.clone();l.padding=s,i.setLocationAtPoint(i.center,l.centerPoint)}else i.padding=s;return t.preloadOnly?(this._preloadTiles(i),this):(this.fire(new e.x("movestart",r)).fire(new e.x("move",r)),n&&this.fire(new e.x("zoomstart",r)).fire(new e.x("zoom",r)).fire(new e.x("zoomend",r)),a&&this.fire(new e.x("rotatestart",r)).fire(new e.x("rotate",r)).fire(new e.x("rotateend",r)),o&&this.fire(new e.x("pitchstart",r)).fire(new e.x("pitch",r)).fire(new e.x("pitchend",r)),this.fire(new e.x("moveend",r)))}},{key:"getFreeCameraOptions",value:function(){return this.transform.projection.supportsFreeCamera||e.w(Ys),this.transform.getFreeCameraOptions()}},{key:"setFreeCameraOptions",value:function(t,r){var i=this.transform;if(!i.projection.supportsFreeCamera)return e.w(Ys),this;this.stop();var n=i.zoom,a=i.pitch,o=i.bearing;i.setFreeCameraOptions(t);var s=n!==i.zoom,l=a!==i.pitch,u=o!==i.bearing;return this.fire(new e.x("movestart",r)).fire(new e.x("move",r)),s&&this.fire(new e.x("zoomstart",r)).fire(new e.x("zoom",r)).fire(new e.x("zoomend",r)),u&&this.fire(new e.x("rotatestart",r)).fire(new e.x("rotate",r)).fire(new e.x("rotateend",r)),l&&this.fire(new e.x("pitchstart",r)).fire(new e.x("pitch",r)).fire(new e.x("pitchend",r)),this.fire(new e.x("moveend",r)),this}},{key:"easeTo",value:function(t,r){var i=this;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);var n,a,o,s=this.transform,l=this.getZoom(),u=this.getBearing(),c=this.getPitch(),h=this.getPadding(),f="zoom"in t?+t.zoom:l,d="bearing"in t?this._normalizeBearing(t.bearing,u):u,p="pitch"in t?+t.pitch:c,m=this._extendPadding(t.padding),v=e.P.convert(t.offset);if("globe"===s.projection.name){var _=e.a5.fromLngLat(s.center),y=v.rotate(-s.angle);_.x+=y.x/s.worldSize,_.y+=y.y/s.worldSize;var g=_.toLngLat(),x=e.bK.convert(t.center||g);this._normalizeCenter(x),n=s.centerPoint.add(y),a=new e.P(_.x,_.y).mult(s.worldSize),o=new e.P(e.am(x.lng),e.at(x.lat)).mult(s.worldSize).sub(a)}else{n=s.centerPoint.add(v);var b=s.pointLocation(n),w=e.bK.convert(t.center||b);this._normalizeCenter(w),a=s.project(b),o=s.project(w).sub(a)}var k,T,M=s.zoomScale(f-l);t.around&&(k=e.bK.convert(t.around),T=s.locationPoint(k));var S=this._zooming||f!==l,E=this._rotating||u!==d,I=this._pitching||p!==c,A=!s.isPaddingEqual(m),C=!1===t.retainPadding?s.clone():s,P=function(s){return function(_){if(S&&(s.zoom=e.aa(l,f,_)),E&&(s.bearing=e.aa(u,d,_)),I&&(s.pitch=e.aa(c,p,_)),A&&(C.interpolatePadding(h,m,_),n=C.centerPoint.add(v)),k)s.setLocationAtPoint(k,T);else{var y=s.zoomScale(s.zoom-l),g=f>l?Math.min(2,M):Math.max(.5,M),x=Math.pow(g,1-_),b=s.unproject(a.add(o.mult(_*x)).mult(y));s.setLocationAtPoint(s.renderWorldCopies?b.wrap():b,n)}return t.preloadOnly||i._fireMoveEvents(r),s}};if(t.preloadOnly){var z=this._emulate(P,t.duration,s);return this._preloadTiles(z),this}var D={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=S,this._rotating=E,this._pitching=I,this._padding=A,this._easeId=t.easeId,this._prepareEase(r,t.noMoveStart,D),this._ease(P(s),(function(e){"sea"===s.cameraElevationReference&&s.recenterOnTerrain(),i._afterEase(r,e)}),t),this}},{key:"_prepareEase",value:function(t,r){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&0===this.transform.pitch&&"globe"!==this.transform.projection.name&&(this.transform.cameraElevationReference="ground"),r||i.moving||this.fire(new e.x("movestart",t)),this._zooming&&!i.zooming&&this.fire(new e.x("zoomstart",t)),this._rotating&&!i.rotating&&this.fire(new e.x("rotatestart",t)),this._pitching&&!i.pitching&&this.fire(new e.x("pitchstart",t))}},{key:"_fireMoveEvents",value:function(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))}},{key:"_afterEase",value:function(t,r){if(!this._easeId||!r||this._easeId!==r){this._easeId=void 0,this.transform.cameraElevationReference="ground";var i=this._zooming,n=this._rotating,a=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,i&&this.fire(new e.x("zoomend",t)),n&&this.fire(new e.x("rotateend",t)),a&&this.fire(new e.x("pitchend",t)),this.fire(new e.x("moveend",t))}}},{key:"flyTo",value:function(t,r){var i=this;if(this._prefersReducedMotion(t)){var n=e.ar(t,["center","zoom","bearing","pitch","around","padding","retainPadding"]);return this.jumpTo(n,r)}this.stop(),t=e.l({offset:[0,0],speed:1.2,curve:1.42,easing:e.dr},t);var a=this.transform,o=this.getZoom(),s=this.getBearing(),l=this.getPitch(),u=this.getPadding(),c="zoom"in t?e.ap(+t.zoom,a.minZoom,a.maxZoom):o,h="bearing"in t?this._normalizeBearing(t.bearing,s):s,f="pitch"in t?+t.pitch:l,d=this._extendPadding(t.padding),p=a.zoomScale(c-o),m=e.P.convert(t.offset),v=a.centerPoint.add(m),_=a.pointLocation(v),y=e.bK.convert(t.center||_);this._normalizeCenter(y);var g=a.project(_),x=a.project(y).sub(g),b=t.curve,w=Math.max(a.width,a.height),k=w/p,T=x.mag();if("minZoom"in t){var M=e.ap(Math.min(t.minZoom,o,c),a.minZoom,a.maxZoom),S=w/a.zoomScale(M-o);b=Math.sqrt(S/T*2)}var E=b*b;function I(e){var t=(k*k-w*w+(e?-1:1)*E*E*T*T)/(2*(e?k:w)*E*T);return Math.log(Math.sqrt(t*t+1)-t)}function A(e){return(Math.exp(e)-Math.exp(-e))/2}function C(e){return(Math.exp(e)+Math.exp(-e))/2}var P=I(0),z=function(e){return C(P)/C(P+b*e)},D=function(e){return w*((C(P)*(A(t=P+b*e)/C(t))-A(P))/E)/T;var t},R=(I(1)-P)/b;if(Math.abs(T)<1e-6||!isFinite(R)){if(Math.abs(w-k)<1e-6)return this.easeTo(t,r);var L=kt.maxDuration&&(t.duration=0);var O=s!==h,B=f!==l,F=!a.isPaddingEqual(d),N=!1===t.retainPadding?a.clone():a,V=function(n){return function(a){var p=a*R,_=1/z(p);n.zoom=1===a?c:o+n.scaleZoom(_),O&&(n.bearing=e.aa(s,h,a)),B&&(n.pitch=e.aa(l,f,a)),F&&(N.interpolatePadding(u,d,a),v=N.centerPoint.add(m));var b=1===a?y:n.unproject(g.add(x.mult(D(p))).mult(_));return n.setLocationAtPoint(n.renderWorldCopies?b.wrap():b,v),n._updateCameraOnTerrain(),t.preloadOnly||i._fireMoveEvents(r),n}};if(t.preloadOnly){var U=this._emulate(V,t.duration,a);return this._preloadTiles(U),this}return this._zooming=!0,this._rotating=O,this._pitching=B,this._padding=F,this._prepareEase(r,!1),this._ease(V(a),(function(){return i._afterEase(r)}),t),this}},{key:"isEasing",value:function(){return!!this._easeFrameId}},{key:"stop",value:function(){return this._stop()}},{key:"_requestRenderFrame",value:function(e){}},{key:"_cancelRenderFrame",value:function(e){}},{key:"_stop",value:function(e,t){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){var r=this._onEaseEnd;this._onEaseEnd=void 0,r.call(this,t)}if(!e){var i=this.handlers;i&&i.stop(!1)}return this}},{key:"_ease",value:function(t,r,i){!1===i.animate||0===i.duration?(t(1),r()):(this._easeStart=e.q.now(),this._easeOptions=i,this._onEaseFrame=t,this._onEaseEnd=r,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}},{key:"_renderFrameCallback",value:function(){var t=Math.min((e.q.now()-this._easeStart)/this._easeOptions.duration,1),r=this._onEaseFrame;r&&r(this._easeOptions.easing(t)),t<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}},{key:"_normalizeBearing",value:function(t,r){t=e.bA(t,-180,180);var i=Math.abs(t-r);return Math.abs(t-360-r)180?-360:r<-180?360:0}}},{key:"_prefersReducedMotion",value:function(t){return this._respectPrefersReducedMotion&&e.q.prefersReducedMotion&&!(t&&t.essential)}},{key:"_emulate",value:function(e,t,r){for(var i=Math.ceil(15*t/1e3),n=[],a=e(r.clone()),o=0;o<=i;o++){var s=a(o/i);n.push(s.clone())}return n}},{key:"_preloadTiles",value:function(e,t){}}])})(e.E),Ks=(function(){return m((function t(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};p(this,t),this.options=r,e.aJ(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}),[{key:"getDefaultPosition",value:function(){return"bottom-right"}},{key:"onAdd",value:function(e){var t=this.options&&this.options.compact,r=e._getUIString("AttributionControl.ToggleAttribution");this._map=e,this._container=f("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=f("button","mapboxgl-ctrl-attrib-button",this._container),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._compactButton.setAttribute("aria-label",r);var i=f("span","mapboxgl-ctrl-icon",this._compactButton);return i.setAttribute("aria-hidden","true"),i.setAttribute("title",r),this._innerContainer=f("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}},{key:"onRemove",value:function(){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}},{key:"_toggleAttribution",value:function(){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"))}},{key:"_updateEditLink",value:function(){var t=this._editLink;t||(t=this._editLink=this._container.querySelector(".mapbox-improve-map"));var r=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||e.e.ACCESS_TOKEN}];if(t){var i=r.reduce((function(e,t,i){return t.value&&(e+=`${t.key}=${t.value}${i=0)return!1;return!0})),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=[].concat(d(this.options.customAttribution),d(e)):e.unshift(this.options.customAttribution));var o=e.join(" | ");o!==this._attribHTML&&(this._attribHTML=o,e.length?(this._innerContainer.innerHTML=o,this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null)}}},{key:"_updateCompact",value:function(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact","mapboxgl-compact-show")}}])})(),Qs=(function(){return m((function t(){p(this,t),e.aJ(["_updateLogo","_updateCompact"],this)}),[{key:"onAdd",value:function(e){this._map=e,this._container=f("div","mapboxgl-ctrl");var t=f("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}},{key:"onRemove",value:function(){this._container.remove(),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact)}},{key:"getDefaultPosition",value:function(){return"bottom-left"}},{key:"_updateLogo",value:function(e){e&&"metadata"!==e.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none")}},{key:"_logoRequired",value:function(){if(!this._map.style)return!0;var e=this._map.style._sourceCaches;if(0===Object.entries(e).length)return!0;for(var t in e){var r=e[t].getSource();if(r.hasOwnProperty("mapbox_logo")&&!r.mapbox_logo)return!1}return!0}},{key:"_updateCompact",value:function(){var e=this._container.children;if(e.length){var t=e[0];this._map.getCanvasContainer().offsetWidth<250?t.classList.add("mapboxgl-compact"):t.classList.remove("mapboxgl-compact")}}}])})(),el=(function(){return m((function e(){p(this,e),this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}),[{key:"add",value:function(e){var t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}},{key:"remove",value:function(e){var t=this._currentlyRunning,r=t?this._queue.concat(t):this._queue;for(var i of r)if(i.id===e)return void(i.cancelled=!0)}},{key:"run",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=this._currentlyRunning=this._queue;for(var r of(this._queue=[],t))if(!r.cancelled&&(r.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}},{key:"clear",value:function(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}])})(),tl=(function(){return m((function e(t){p(this,e),this.jumpTo(t)}),[{key:"getValue",value:function(t){if(t<=this._startTime)return this._start;if(t>=this._endTime)return this._end;var r=e.cw((t-this._startTime)/(this._endTime-this._startTime));return this._start*(1-r)+this._end*r}},{key:"isEasing",value:function(e){return e>=this._startTime&&e<=this._endTime}},{key:"jumpTo",value:function(e){this._startTime=-1/0,this._endTime=-1/0,this._start=e,this._end=e}},{key:"easeTo",value:function(e,t,r){this._start=this.getValue(t),this._end=e,this._startTime=t,this._endTime=t+r}}])})(),rl={"AttributionControl.ToggleAttribution":"Toggle attribution","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox homepage","Map.Title":"Map","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use \u2318 + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"},il=(function(){return m((function e(){p(this,e)}),[{key:"registerParameter",value:function(){}},{key:"registerButton",value:function(){}},{key:"registerBinding",value:function(){}},{key:"refreshUI",value:function(){}}])})(),nl=(function(){return m((function e(t){p(this,e),this.map=t,this.interactionsByType=new Map,this.typeById=new Map,this.filters=new Map,this.handleType=this.handleType.bind(this)}),[{key:"add",value:function(t,r){if(this.typeById.has(t))throw new Error(`Interaction id "${t}" already exists.`);var i=r.type,n=r.filter;if(n){var a=e.M(n,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===a.result)throw new Error(a.value.map((function(e){return`${e.key}: ${e.message}`})).join(", "));this.filters.set(t,a.value)}var o=this.interactionsByType.get(i)||new Map;0===o.size&&(this.map.on(i,this.handleType),this.interactionsByType.set(i,o)),o.set(t,r),this.typeById.set(t,i)}},{key:"remove",value:function(e){var t=this.typeById.get(e);if(t){this.typeById.delete(e),this.filters.delete(e);var r=this.interactionsByType.get(t);r&&(r.delete(e),0===r.size&&this.map.off(t,this.handleType))}}},{key:"handleType",value:function(e){var t=e.features||this.map.queryRenderedFeatures(e.point);if(t){var r=this.interactionsByType.get(e.type),i={zoom:0};for(var n of r){var a=x(n,2),o=a[0],s=a[1],l=this.filters.get(o),u=s.handler,c=s.layers;for(var h of t)if((!c||c.includes(h.layer.id))&&(!l||l.evaluate(i,h))&&!1!==u({id:o,feature:h,interaction:s}))break}}}}])})(),al={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},ol={showCompass:!0,showZoom:!0,visualizePitch:!1},sl=(function(){return m((function t(r,i){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];p(this,t),this._clickTolerance=10,this.element=i,this.mouseRotate=new ks({clickTolerance:r.dragRotate._mouseRotate._clickTolerance}),this.map=r,n&&(this.mousePitch=new Ts({clickTolerance:r.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)}),[{key:"down",value:function(e,t){this.mouseRotate.mousedown(e,t),this.mousePitch&&this.mousePitch.mousedown(e,t),S()}},{key:"move",value:function(e,t){var r=this.map,i=this.mouseRotate.mousemoveWindow(e,t),n=i&&i.bearingDelta;if(n&&r.setBearing(r.getBearing()+n),this.mousePitch){var a=this.mousePitch.mousemoveWindow(e,t),o=a&&a.pitchDelta;o&&r.setPitch(r.getPitch()+o)}}},{key:"off",value:function(){var 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()}},{key:"offTemp",value:function(){E(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup)}},{key:"mousedown",value:function(t){this.down(e.l({},t,{ctrlKey:!0,preventDefault:function(){return t.preventDefault()}}),C(this.element,t)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)}},{key:"mousemove",value:function(e){this.move(e,C(this.element,e))}},{key:"mouseup",value:function(e){this.mouseRotate.mouseupWindow(e),this.mousePitch&&this.mousePitch.mouseupWindow(e),this.offTemp()}},{key:"touchstart",value:function(e){1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=P(this.element,e.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:function(){return e.preventDefault()}},this._startPos))}},{key:"touchmove",value:function(e){1!==e.targetTouches.length?this.reset():(this._lastPos=P(this.element,e.targetTouches)[0],this.move({preventDefault:function(){return e.preventDefault()}},this._lastPos))}},{key:"touchend",value:function(e){0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)i.width||r.y>i.height;i.locationPoint(n).distSqr(r)180;){var u=i.locationPoint(t);if(u.x>=0&&u.y>=0&&u.x<=i.width&&u.y<=i.height)break;t.lng>i.center.lng?t.lng-=360:t.lng+=360}return t}var ul={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%)"},cl=(function(t){function r(t,i){var n;if(p(this,r),n=T(this,r),(t instanceof HTMLElement||i)&&(t=e.l({element:t},i)),e.aJ(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],l(n)),n._anchor=t&&t.anchor||"center",n._color=t&&t.color||"#3FB1CE",n._scale=t&&t.scale||1,n._draggable=t&&t.draggable||!1,n._clickTolerance=t&&t.clickTolerance||0,n._isDragging=!1,n._state="inactive",n._rotation=t&&t.rotation||0,n._rotationAlignment=t&&t.rotationAlignment||"auto",n._pitchAlignment=t&&t.pitchAlignment&&t.pitchAlignment||"auto",n._updateMoving=function(){return n._update(!0)},n._occludedOpacity=t&&t.occludedOpacity||.2,t&&t.element)n._element=t.element,n._offset=e.P.convert(t&&t.offset||[0,0]);else{n._defaultMarker=!0,n._element=f("div");var a=v("svg",{display:"block",height:41*n._scale+"px",width:27*n._scale+"px",viewBox:"0 0 27 41"},n._element),o=v("radialGradient",{id:"shadowGradient"},v("defs",{},a));v("stop",{offset:"10%","stop-opacity":.4},o),v("stop",{offset:"100%","stop-opacity":.05},o),v("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},a),v("path",{fill:n._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"},a),v("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"},a),v("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},a),n._offset=e.P.convert(t&&t.offset||[0,-14])}n._element.hasAttribute("aria-label")||n._element.setAttribute("aria-label","Map marker"),n._element.hasAttribute("role")||n._element.setAttribute("role","img"),n._element.classList.add("mapboxgl-marker"),n._element.addEventListener("dragstart",(function(e){e.preventDefault()})),n._element.addEventListener("mousedown",(function(e){e.preventDefault()}));var s=n._element.classList;for(var u in ul)s.remove(`mapboxgl-marker-anchor-${u}`);s.add(`mapboxgl-marker-anchor-${n._anchor}`);var c=t&&t.className?t.className.trim().split(/\s+/):[];return s.add.apply(s,d(c)),n._popup=null,n}return y(r,t),m(r,[{key:"addTo",value:function(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}},{key:"remove",value:function(){var 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}},{key:"getLngLat",value:function(){return this._lngLat}},{key:"setLngLat",value:function(t){return this._lngLat=e.bK.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}},{key:"getElement",value:function(){return this._element}},{key:"setPopup",value:function(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)){var t=Math.sqrt(Math.pow(13.5,2)/2);e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[t,-34.14594154601839],"bottom-right":[-9.545941546018392,-34.14594154601839],left:[13.5,-24.6],right:[-13.5,-24.6]}: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}},{key:"_onKeyPress",value:function(e){var t=e.code,r=e.charCode||e.keyCode;"Space"!==t&&"Enter"!==t&&32!==r&&13!==r||this.togglePopup()}},{key:"_onMapClick",value:function(e){var t=e.originalEvent.target,r=this._element;this._popup&&(t===r||r.contains(t))&&this.togglePopup()}},{key:"getPopup",value:function(){return this._popup}},{key:"togglePopup",value:function(){var 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}},{key:"_behindTerrain",value:function(){var e=this._map,t=this._pos;if(!e||!t)return!1;var r=e.unproject(t),i=e.getFreeCameraOptions();if(!i.position)return!1;var n=i.position.toLngLat();return n.distanceTo(r)<.9*n.distanceTo(this._lngLat)}},{key:"_evaluateOpacity",value:function(){var t=this._map;if(t){var r=this._pos;if(!r||r.x<0||r.x>t.transform.width||r.y<0||r.y>t.transform.height)this._clearFadeTimer();else{var i,n=t.unproject(r);t._showingGlobe()&&e.dz(t.transform,this._lngLat)?i=0:(i=1-t._queryFogOpacity(n),t.transform._terrainEnabled()&&t.getTerrain()&&this._behindTerrain()&&(i*=this._occludedOpacity)),this._element.style.opacity=`${i}`,this._element.style.pointerEvents=i>0?"auto":"none",this._popup&&this._popup._setOpacity(i),this._fadeTimer=null}}}},{key:"_clearFadeTimer",value:function(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}},{key:"_updateDOM",value:function(){var e=this._pos;if(e&&this._map){var t=this._offset.mult(this._scale);this._element.style.transform=`\n translate(${e.x}px,${e.y}px)\n ${ul[this._anchor]}\n ${this._calculateXYTransform()} ${this._calculateZTransform()}\n translate(${t.x}px,${t.y}px)\n `}}},{key:"_calculateXYTransform",value:function(){var t=this._pos,r=this._map,i=this.getPitchAlignment();if(!r||!t||"map"!==i)return"";if(!r._showingGlobe()){var n=r.getPitch();return n?`rotateX(${n}deg)`:""}var a=e.c0(e.dA(r.transform,this._lngLat)),o=t.sub(e.dB(r.transform)),s=Math.abs(o.x)+Math.abs(o.y);if(0===s)return"";var l=a/s;return`rotateX(${-o.y*l}deg) rotateY(${o.x*l}deg)`}},{key:"_calculateZTransform",value:function(){var t=this._pos,r=this._map;if(!r||!t)return"";var i=0,n=this.getRotationAlignment();if("map"===n)if(r._showingGlobe()){var a=r.project(new e.bK(this._lngLat.lng,this._lngLat.lat+.001)),o=r.project(new e.bK(this._lngLat.lng,this._lngLat.lat-.001)).sub(a);i=e.c0(Math.atan2(o.y,o.x))-90}else i=-r.getBearing();else if("horizon"===n){var s=e.a7(4,6,r.getZoom()),l=e.dB(r.transform);l.y+=s*r.transform.height;var u=t.sub(l),c=e.c0(Math.atan2(u.y,u.x));i=(c>90?c-270:c+90)*(1-s)}return(i+=this._rotation)?`rotateZ(${i}deg)`:""}},{key:"_update",value:function(e){var t=this;cancelAnimationFrame(this._updateFrameId);var r=this._map;r&&(r.transform.renderWorldCopies&&(this._lngLat=ll(this._lngLat,this._pos,r.transform)),this._pos=r.project(this._lngLat),!0===e?this._updateFrameId=requestAnimationFrame((function(){t._element&&t._pos&&t._anchor&&(t._pos=t._pos.round(),t._updateDOM())})):this._pos=this._pos.round(),r._requestDomTask((function(){t._map&&(t._element&&t._pos&&t._anchor&&t._updateDOM(),(r._showingGlobe()||r.getTerrain()||r.getFog())&&!t._fadeTimer&&(t._fadeTimer=window.setTimeout(t._evaluateOpacity.bind(t),60)))})))}},{key:"getOffset",value:function(){return this._offset}},{key:"setOffset",value:function(t){return this._offset=e.P.convert(t),this._update(),this}},{key:"addClassName",value:function(e){return this._element.classList.add(e),this}},{key:"removeClassName",value:function(e){return this._element.classList.remove(e),this}},{key:"toggleClassName",value:function(e){return this._element.classList.toggle(e)}},{key:"_onMove",value:function(t){var r=this._map;if(r){var i=this._pointerdownPos,n=this._positionDelta;if(i&&n){if(!this._isDragging){var a=this._clickTolerance||r._clickTolerance;if(t.point.dist(i)0&&void 0!==arguments[0]?arguments[0]:new e.P(0,0),r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"bottom";if("number"==typeof t){var i=Math.round(Math.sqrt(.5*Math.pow(t,2)));switch(r){case"top":return new e.P(0,t);case"top-left":return new e.P(i,i);case"top-right":return new e.P(-i,i);case"bottom":return new e.P(0,-t);case"bottom-left":return new e.P(i,-i);case"bottom-right":return new e.P(-i,-i);case"left":return new e.P(t,0);case"right":return new e.P(-t,0)}return new e.P(0,0)}return t instanceof e.P||Array.isArray(t)?e.P.convert(t):e.P.convert(t[r]||[0,0])}return{version:t,supported:h.supported,setRTLTextPlugin:e.dC,getRTLTextPluginStatus:e.dD,Map:(function(n){function a(t){var n;p(this,a),i(r.create);var o=t;if(null!=(t=e.l({},al,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")),(n=T(this,a,[new wi(t.minZoom,t.maxZoom,t.minPitch,t.maxPitch,t.renderWorldCopies),t]))._repaint=!!t.repaint,n._interactive=t.interactive,n._minTileCacheSize=t.minTileCacheSize,n._maxTileCacheSize=t.maxTileCacheSize,n._failIfMajorPerformanceCaveat=t.failIfMajorPerformanceCaveat,n._preserveDrawingBuffer=t.preserveDrawingBuffer,n._antialias=t.antialias,n._trackResize=t.trackResize,n._bearingSnap=t.bearingSnap,n._refreshExpiredTiles=t.refreshExpiredTiles,n._fadeDuration=t.fadeDuration,n._isInitialLoad=!0,n._crossSourceCollisions=t.crossSourceCollisions,n._collectResourceTiming=t.collectResourceTiming,n._language=n._parseLanguage(t.language),n._worldview=t.worldview,n._renderTaskQueue=new el,n._domRenderTaskQueue=new el,n._controls=[],n._markers=[],n._popups=[],n._mapId=e.aP(),n._locale=e.l({},rl,t.locale),n._clickTolerance=t.clickTolerance,n._cooperativeGestures=t.cooperativeGestures,n._performanceMetricsCollection=t.performanceMetricsCollection,n._tessellationStep=t.tessellationStep,n._containerWidth=0,n._containerHeight=0,n._showParseStatus=!0,n._precompilePrograms=t.precompilePrograms,n._averageElevationLastSampledAt=-1/0,n._averageElevationExaggeration=0,n._averageElevation=new tl(0),n._interactionRange=[1/0,-1/0],n._visibilityHidden=0,n._useExplicitProjection=!1,n._frameId=0,n._requestManager=new O(t.transformRequest,t.accessToken,t.testMode),n._silenceAuthErrors=!!t.testMode,n._contextCreateOptions=t.contextCreateOptions?Object.assign({},t.contextCreateOptions):{},"string"==typeof t.container){var s=document.getElementById(t.container);if(!s)throw new Error(`Container '${t.container.toString()}' not found.`);n._container=s}else{if(!(t.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");n._container=t.container}if(n._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&&n.setMaxBounds(t.maxBounds),e.aJ(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],n),n._setupContainer(),n._tp||(n._tp=new il),n._tp.registerParameter(n,["Debug"],"showOverdrawInspector"),n._tp.registerParameter(n,["Debug"],"showTileBoundaries"),n._tp.registerParameter(n,["Debug"],"showParseStatus"),n._tp.registerParameter(n,["Debug"],"repaint"),n._tp.registerParameter(n,["Debug"],"showTileAABBs"),n._tp.registerParameter(n,["Debug"],"showPadding"),n._tp.registerParameter(n,["Debug"],"showCollisionBoxes",{noSave:!0}),n._tp.registerParameter(n.transform,["Debug"],"freezeTileCoverage",{noSave:!0},(function(){n._update()})),n._tp.registerParameter(n,["Debug","Wireframe"],"showTerrainWireframe"),n._tp.registerParameter(n,["Debug","Wireframe"],"showLayers2DWireframe"),n._tp.registerParameter(n,["Debug","Wireframe"],"showLayers3DWireframe"),n._setupPainter(),void 0===n.painter)throw new Error("Failed to initialize WebGL.");if(n.on("move",(function(){return n._update(!1)})),n.on("moveend",(function(){return n._update(!1)})),n.on("zoom",(function(){return n._update(!0)})),n._fullscreenchangeEvent="onfullscreenchange"in document?"fullscreenchange":"webkitfullscreenchange",window.addEventListener("online",n._onWindowOnline,!1),window.addEventListener("resize",n._onWindowResize,!1),window.addEventListener("orientationchange",n._onWindowResize,!1),window.addEventListener(n._fullscreenchangeEvent,n._onWindowResize,!1),window.addEventListener("visibilitychange",n._onVisibilityChange,!1),n.handlers=new Xs(n,t),n._localFontFamily=t.localFontFamily,n._localIdeographFontFamily=t.localIdeographFontFamily,(t.style||!t.testMode)&&n.setStyle(t.style||e.e.DEFAULT_STYLE,{config:t.config,localFontFamily:n._localFontFamily,localIdeographFontFamily:n._localIdeographFontFamily}),t.projection&&n.setProjection(t.projection),t.hash&&(n._hash=new es("string"==typeof t.hash&&t.hash||void 0).addTo(n)),!n._hash||!n._hash._onHashChange()){null==o.center&&null==o.zoom||(n.transform._unmodified=!1),n.jumpTo({center:t.center,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch});var l=t.bounds;l&&(n.resize(),n.fitBounds(l,e.l({},t.fitBoundsOptions,{duration:0})))}return n.resize(),t.attributionControl&&n.addControl(new Ks({customAttribution:t.customAttribution})),n._logoControl=new Qs,n.addControl(n._logoControl,t.logoPosition),n.on("style.load",(function(){n.transform.unmodified&&n.jumpTo(n.style.stylesheet),n._postStyleLoadEvent()})),n.on("data",(function(t){n._update("style"===t.dataType),n.fire(new e.x(`${t.dataType}data`,t))})),n.on("dataloading",(function(t){n.fire(new e.x(`${t.dataType}dataloading`,t))})),n._interactions=new nl(n),n}return y(a,n),m(a,[{key:"_getMapId",value:function(){return this._mapId}},{key:"addControl",value:function(t,r){if(void 0===r&&(r=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.")));var i=t.onAdd(this);this._controls.push(t);var n=this._controlPositions[r];return-1!==r.indexOf("bottom")?n.insertBefore(i,n.firstChild):n.appendChild(i),this}},{key:"removeControl",value:function(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.")));var r=this._controls.indexOf(t);return r>-1&&this._controls.splice(r,1),t.onRemove(this),this}},{key:"hasControl",value:function(e){return this._controls.indexOf(e)>-1}},{key:"getContainer",value:function(){return this._container}},{key:"getCanvasContainer",value:function(){return this._canvasContainer}},{key:"getCanvas",value:function(){return this._canvas}},{key:"resize",value:function(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));var r=!this._moving;return r&&this.fire(new e.x("movestart",t)).fire(new e.x("move",t)),this.fire(new e.x("resize",t)),r&&this.fire(new e.x("moveend",t)),this}},{key:"getBounds",value:function(){return this.transform.getBounds()}},{key:"getMaxBounds",value:function(){return this.transform.getMaxBounds()||null}},{key:"setMaxBounds",value:function(t){return this.transform.setMaxBounds(e.as.convert(t)),this._update()}},{key:"setMinZoom",value:function(t){var r;if((t=null!=(r=t)?r:-2)>=-2&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t?this.setZoom(t):this.fire(new e.x("zoomstart")).fire(new e.x("zoom")).fire(new e.x("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}},{key:"getMaxZoom",value:function(){return this.transform.maxZoom}},{key:"setMinPitch",value:function(t){var r;if((t=null!=(r=t)?r:0)<0)throw new Error("minPitch must be greater than or equal to 0");if(t>=0&&t<=this.transform.maxPitch)return this.transform.minPitch=t,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(t>=this.transform.minPitch)return this.transform.maxPitch=t,this._update(),this.getPitch()>t?this.setPitch(t):this.fire(new e.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")}},{key:"getMaxPitch",value:function(){return this.transform.maxPitch}},{key:"getRenderWorldCopies",value:function(){return this.transform.renderWorldCopies}},{key:"setRenderWorldCopies",value:function(e){return this.transform.renderWorldCopies=e,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}},{key:"getLanguage",value:function(){return this._language}},{key:"_parseLanguage",value:function(e){return"auto"===e?navigator.language:Array.isArray(e)?0===e.length?void 0:e.map((function(e){return"auto"===e?navigator.language:e})):e}},{key:"setLanguage",value:function(e){var t=this._parseLanguage(e);if(!this.style||t===this._language)return this;for(var r of(this._language=t,this.style.reloadSources(),this._controls))r._setLanguage&&r._setLanguage(this._language);return this}},{key:"getWorldview",value:function(){return this._worldview}},{key:"setWorldview",value:function(e){return this.style&&e!==this._worldview?(this._worldview=e,this.style.reloadSources(),this):this}},{key:"getProjection",value:function(){return this.transform.mercatorFromTransition?{name:"globe",center:[0,0]}:this.transform.getProjection()}},{key:"_showingGlobe",value:function(){return"globe"===this.transform.projection.name}},{key:"setProjection",value:function(e){return this._lazyInitEmptyStyle(),e?"string"==typeof e&&(e={name:e}):e=null,this._useExplicitProjection=!!e,this._prioritizeAndUpdateProjection(e,this.style.projection)}},{key:"_updateProjectionTransition",value:function(){if("globe"===this.getProjection().name){var t,r=this.transform,i=r.projection.name;"globe"===i&&r.zoom>=e.bU?(r.setMercatorFromTransition(),t=!0):"mercator"===i&&r.zoom=e.bU?this.transform.setMercatorFromTransition():this.transform.setProjection(t),this.style.applyProjectionUpdate(),r&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}},{key:"project",value:function(t){return this.transform.locationPoint3D(e.bK.convert(t))}},{key:"unproject",value:function(t){return this.transform.pointLocation3D(e.P.convert(t))}},{key:"isMoving",value:function(){return this._moving||this.handlers&&this.handlers.isMoving()||!1}},{key:"isZooming",value:function(){return this._zooming||this.handlers&&this.handlers.isZooming()||!1}},{key:"isRotating",value:function(){return this._rotating||this.handlers&&this.handlers.isRotating()||!1}},{key:"_isDragging",value:function(){return this.handlers&&this.handlers._isDragging()||!1}},{key:"_createDelegatedListener",value:function(e,t,r){var i=this;if("mouseenter"===e||"mouseover"===e){var n=!1;return{layers:new Set(t),listener:r,delegates:{mousemove:function(a){var o=t.filter((function(e){return i.getLayer(e)})),s=o.length?i.queryRenderedFeatures(a.point,{layers:o}):[];s.length?n||(n=!0,r.call(i,new cs(e,i,a.originalEvent,{features:s}))):n=!1},mouseout:function(){n=!1}}}}if("mouseleave"===e||"mouseout"===e){var a=!1;return{layers:new Set(t),listener:r,delegates:{mousemove:function(n){var o=t.filter((function(e){return i.getLayer(e)}));(o.length?i.queryRenderedFeatures(n.point,{layers:o}):[]).length?a=!0:a&&(a=!1,r.call(i,new cs(e,i,n.originalEvent)))},mouseout:function(t){a&&(a=!1,r.call(i,new cs(e,i,t.originalEvent)))}}}}return{layers:new Set(t),listener:r,delegates:s({},e,(function(e){var n=t.filter((function(e){return i.getLayer(e)})),a=n.length?i.queryRenderedFeatures(e.point,{layers:n}):[];a.length&&(e.features=a,r.call(i,e),delete e.features)}))}}},{key:"on",value:function(e,t,r){if("function"==typeof t||void 0===r)return k(a,"on",this,3)([e,t]);if(Array.isArray(t)||(t=[t]),t)for(var i of t)if(!this._isValidId(i))return this;var n=this._createDelegatedListener(e,t,r);for(var o in this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(n),n.delegates)this.on(o,n.delegates[o]);return this}},{key:"once",value:function(e,t,r){if("function"==typeof t||void 0===r)return k(a,"once",this,3)([e,t]);if(Array.isArray(t)||(t=[t]),t)for(var i of t)if(!this._isValidId(i))return this;var n=this._createDelegatedListener(e,t,r);for(var o in n.delegates)this.once(o,n.delegates[o]);return this}},{key:"off",value:function(e,t,r){var i=this;if("function"==typeof t||void 0===r)return k(a,"off",this,3)([e,t]);var n=new Set(Array.isArray(t)?t:[t]);for(var o of n)if(!this._isValidId(o))return this;var s=function(e,t){if(e.size!==t.size)return!1;for(var r of e)if(!t.has(r))return!1;return!0},l=this._delegatedListeners?this._delegatedListeners[e]:void 0;return l&&(function(e){for(var t=0;t2&&void 0!==arguments[2]?arguments[2]:{},n=i.pixelRatio,a=void 0===n?1:n,o=i.sdf,s=void 0!==o&&o,l=i.stretchX,u=i.stretchY,c=i.content;if(this._lazyInitEmptyStyle(),r instanceof HTMLImageElement||ImageBitmap&&r instanceof ImageBitmap){var h=e.q.getImageData(r),f=h.width,d=h.height,p=h.data;this.style.addImage(t,{data:new e.r({width:f,height:d},p),pixelRatio:a,stretchX:l,stretchY:u,content:c,sdf:s,version:0})}else if(void 0===r.width||void 0===r.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{var m=r.width,v=r.height,_=r;this.style.addImage(t,{data:new e.r({width:m,height:v},new Uint8Array(_.data)),pixelRatio:a,stretchX:l,stretchY:u,content:c,sdf:s,version:0,userImage:_}),_.onAdd&&_.onAdd(this,t)}}},{key:"updateImage",value:function(t,r){this._lazyInitEmptyStyle();var i=this.style.getImage(t);if(i){var n=r instanceof HTMLImageElement||ImageBitmap&&r instanceof ImageBitmap?e.q.getImageData(r):r,a=n.width,o=n.height,s=n.data;if(void 0!==a&&void 0!==o)if(a===i.data.width&&o===i.data.height){var l=!(r instanceof HTMLImageElement||ImageBitmap&&r instanceof ImageBitmap);i.data.replace(s,l),this.style.updateImage(t,i)}else this.fire(new e.t(new Error(`The width and height of the updated image (${a}, ${o})\n must be that same as the previous version of the image\n (${i.data.width}, ${i.data.height})`)));else 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`")))}else 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.")))}},{key:"hasImage",value:function(t){return t?!!this.style&&!!this.style.getImage(t):(this.fire(new e.t(new Error("Missing required image id"))),!1)}},{key:"removeImage",value:function(e){this.style.removeImage(e)}},{key:"loadImage",value:function(t,r){e.o(this._requestManager.transformRequest(t,e.R.Image),(function(t,i){r(t,i instanceof HTMLImageElement?e.q.getImageData(i):i)}))}},{key:"listImages",value:function(){return this.style.listImages()}},{key:"addModel",value:function(e,t){this._lazyInitEmptyStyle(),this.style.addModel(e,t)}},{key:"hasModel",value:function(t){return t?this.style.hasModel(t):(this.fire(new e.t(new Error("Missing required model id"))),!1)}},{key:"removeModel",value:function(e){this.style.removeModel(e)}},{key:"listModels",value:function(){return this.style.listModels()}},{key:"addLayer",value:function(e,t){return this._isValidId(e.id)?(this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)):this}},{key:"getSlot",value:function(e){var t=this.getLayer(e);return t&&t.slot||null}},{key:"setSlot",value:function(e,t){return this.style.setSlot(e,t),this.style.mergeLayers(),this._update(!0)}},{key:"addImport",value:function(e,t){return this.style.addImport(e,t),this}},{key:"updateImport",value:function(e,t){return"string"!=typeof t&&t.id!==e?(this.removeImport(e),this.addImport(t)):(this.style.updateImport(e,t),this._update(!0))}},{key:"removeImport",value:function(e){return this.style.removeImport(e),this}},{key:"moveImport",value:function(e,t){return this.style.moveImport(e,t),this._update(!0)}},{key:"moveLayer",value:function(e,t){return this._isValidId(e)?(this.style.moveLayer(e,t),this._update(!0)):this}},{key:"removeLayer",value:function(e){return this._isValidId(e)?(this.style.removeLayer(e),this._update(!0)):this}},{key:"getLayer",value:function(e){if(!this._isValidId(e))return null;var t=this.style.getOwnLayer(e);return t?"custom"===t.type?t.implementation:t.serialize():void 0}},{key:"getSlots",value:function(){return this.style.getSlots()}},{key:"setLayerZoomRange",value:function(e,t,r){return this._isValidId(e)?(this.style.setLayerZoomRange(e,t,r),this._update(!0)):this}},{key:"setFilter",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this._isValidId(e)?(this.style.setFilter(e,t,r),this._update(!0)):this}},{key:"getFilter",value:function(e){return this._isValidId(e)?this.style.getFilter(e):null}},{key:"setPaintProperty",value:function(e,t,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this._isValidId(e)?(this.style.setPaintProperty(e,t,r,i),this._update(!0)):this}},{key:"getPaintProperty",value:function(e,t){return this._isValidId(e)?this.style.getPaintProperty(e,t):null}},{key:"setLayoutProperty",value:function(e,t,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this._isValidId(e)?(this.style.setLayoutProperty(e,t,r,i),this._update(!0)):this}},{key:"getLayoutProperty",value:function(e,t){return this._isValidId(e)?this.style.getLayoutProperty(e,t):null}},{key:"getSchema",value:function(e){return this.style.getSchema(e)}},{key:"setSchema",value:function(e,t){return this.style.setSchema(e,t),this._update(!0)}},{key:"getConfig",value:function(e){return this.style.getConfig(e)}},{key:"setConfig",value:function(e,t){return this.style.setConfig(e,t),this._update(!0)}},{key:"getConfigProperty",value:function(e,t){return this.style.getConfigProperty(e,t)}},{key:"setConfigProperty",value:function(e,t,r){return this.style.setConfigProperty(e,t,r),this._update(!0)}},{key:"setLights",value:function(e){if(this._lazyInitEmptyStyle(),e&&1===e.length&&"flat"===e[0].type){var 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)}},{key:"getLights",value:function(){var e=this.style.getLights()||[];return 0===e.length&&e.push({id:this.style.light.id,type:"flat",properties:this.style.getFlatLight()}),e}},{key:"setLight",value:function(e){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}])}},{key:"getLight",value:function(){return console.log("The `map.getLight` function is deprecated, prefer using `map.getLights` instead."),this.style.getFlatLight()}},{key:"setTerrain",value:function(e){return this._lazyInitEmptyStyle(),!e&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(e),this._averageElevationLastSampledAt=-1/0,this._update(!0)}},{key:"getTerrain",value:function(){return this.style?this.style.getTerrain():null}},{key:"setFog",value:function(e){return this._lazyInitEmptyStyle(),this.style.setFog(e),this._update(!0)}},{key:"getFog",value:function(){return this.style?this.style.getFog():null}},{key:"setColorTheme",value:function(e){return this._lazyInitEmptyStyle(),this.style.setColorTheme(e),this._update(!0)}},{key:"setCamera",value:function(e){return this.style.setCamera(e),this._triggerCameraUpdate(e)}},{key:"_triggerCameraUpdate",value:function(e){return this._update(this.transform.setOrthographicProjectionAtLowPitch("orthographic"===e["camera-projection"]))}},{key:"getCamera",value:function(){return this.style.camera}},{key:"_queryFogOpacity",value:function(t){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(e.bK.convert(t),this.transform):0}},{key:"setFeatureState",value:function(e,t){return this._isValidId(e.source)?(this.style.setFeatureState(e,t),this._update()):this}},{key:"removeFeatureState",value:function(e,t){return this._isValidId(e.source)?(this.style.removeFeatureState(e,t),this._update()):this}},{key:"getFeatureState",value:function(e){return this._isValidId(e.source)?this.style.getFeatureState(e):null}},{key:"_updateContainerDimensions",value:function(){if(this._container){for(var e,t,r,i=this._container.getBoundingClientRect().width||400,n=this._container.getBoundingClientRect().height||300,a=this._container;a&&(!t||!r);){var o=window.getComputedStyle(a).transform;o&&"none"!==o&&((e=o.match(/matrix.*\((.+)\)/)[1].split(", "))[0]&&"0"!==e[0]&&"1"!==e[0]&&(t=e[0]),e[3]&&"0"!==e[3]&&"1"!==e[3]&&(r=e[3])),a=a.parentElement}this._containerWidth=t?Math.abs(i/t):i,this._containerHeight=r?Math.abs(n/r):n}}},{key:"_detectMissingCSS",value:function(){"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/.")}},{key:"_setupContainer",value:function(){var e=this._container;e.classList.add("mapboxgl-map"),(this._missingCSSCanary=f("div","mapboxgl-canary",e)).style.visibility="hidden",this._detectMissingCSS();var t=this._canvasContainer=f("div","mapboxgl-canvas-container",e);this._canvas=f("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);var r=this._controlContainer=f("div","mapboxgl-control-container",e),i=this._controlPositions={};["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"].forEach((function(e){i[e]=f("div",`mapboxgl-ctrl-${e}`,r)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}},{key:"_resizeCanvas",value:function(t,r){var i=e.q.devicePixelRatio||1;this._canvas.width=i*Math.ceil(t),this._canvas.height=i*Math.ceil(r),this._canvas.style.width=`${t}px`,this._canvas.style.height=`${r}px`}},{key:"_addMarker",value:function(e){this._markers.push(e)}},{key:"_removeMarker",value:function(e){var t=this._markers.indexOf(e);-1!==t&&this._markers.splice(t,1)}},{key:"_addPopup",value:function(e){this._popups.push(e)}},{key:"_removePopup",value:function(e){var t=this._popups.indexOf(e);-1!==t&&this._popups.splice(t,1)}},{key:"_setupPainter",value:function(){var t=this,r=e.l({},h.supported.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),i=this._canvas.getContext("webgl2",r);i?(ee(i,!0),this.painter=new Ko(i,this._contextCreateOptions,this.transform,this._tp),this.on("data",(function(e){"source"===e.dataType&&t.painter.setTileLoadedFlag(!0)})),e.m.testSupport(i)):this.fire(new e.t(new Error("Failed to initialize WebGL")))}},{key:"_contextLost",value:function(t){t.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new e.x("webglcontextlost",{originalEvent:t}))}},{key:"_contextRestored",value:function(t){this._setupPainter(),this.resize(),this._update(),this.fire(new e.x("webglcontextrestored",{originalEvent:t}))}},{key:"_onMapScroll",value:function(e){if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}},{key:"idle",value:function(){return!this.isMoving()&&this.loaded()}},{key:"loaded",value:function(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}},{key:"frameReady",value:function(){return this.loaded()&&!this._placementDirty}},{key:"_update",value:function(e){return this.style?(this._styleDirty=this._styleDirty||e,this._sourcesDirty=!0,this.triggerRepaint(),this):this}},{key:"_requestRenderFrame",value:function(e){return this._update(),this._renderTaskQueue.add(e)}},{key:"_cancelRenderFrame",value:function(e){this._renderTaskQueue.remove(e)}},{key:"_requestDomTask",value:function(e){!this.loaded()||this.loaded()&&!this.isMoving()?e():this._domRenderTaskQueue.add(e)}},{key:"_render",value:function(t){var n,a=this;this.fire(new e.x("renderstart")),++this._frameId;var o=this.painter.context.extTimerQuery,s=e.q.now(),l=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(n=l.createQuery(),l.beginQuery(o.TIME_ELAPSED_EXT,n)),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){this._updateProjectionTransition();var u=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;var c=this.transform.zoom,h=this.transform.pitch,f=e.q.now(),d=new e.a3(c,{now:f,fadeDuration:u,pitch:h,transition:this.style.transition});this.style.update(d)}this.style&&this.style.hasFogTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);var p=!1;this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),p=this._updateAverageElevation(s),this.style.updateSources(this.transform),this._forceMarkerAndPopupUpdate()):p=this._updateAverageElevation(s);var m=this.style&&this.style._updatePlacement(this.painter,this.painter.transform,this.showCollisionBoxes,u,this._crossSourceCollisions,this.painter.replacementSource);if(m&&(this._placementDirty=m.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:u,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,i(r.load),this.fire(new e.x("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),n){var v=e.q.now()-s;l.endQuery(o.TIME_ELAPSED_EXT),setTimeout((function(){var t=l.getQueryParameter(n,l.QUERY_RESULT)/1e6;l.deleteQuery(n),a.fire(new e.x("gpu-timing-frame",{cpuTime:v,gpuTime:t}))}),50)}if(this.listens("gpu-timing-layer")){var _=this.painter.collectGpuTimers();setTimeout((function(){var t=a.painter.queryGpuTimers(_);a.fire(new e.x("gpu-timing-layer",{layerTimes:t}))}),50)}if(this.listens("gpu-timing-deferred-render")){var y=this.painter.collectDeferredRenderGpuQueries();setTimeout((function(){var t=a.painter.queryGpuTimeDeferredRender(y);a.fire(new e.x("gpu-timing-deferred-render",{gpuTime:t}))}),50)}var g=this._sourcesDirty||this._styleDirty||this._placementDirty||p;if(g||this._repaint)this.triggerRepaint();else{var x=this.idle();if(x&&(p=this._updateAverageElevation(s,!0)),p)this.triggerRepaint();else if(this._triggerFrame(!1),x&&(this.fire(new e.x("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){var b=this._calculateSpeedIndex();this.fire(new e.x("speedindexcompleted",{speedIndex:b})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||g||(this._fullyLoaded=!0,i(r.fullLoad),this._performanceMetricsCollection&&Y(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())}}},{key:"_forceMarkerAndPopupUpdate",value:function(e){for(var t of this._markers)e&&!this.getRenderWorldCopies()&&(t._lngLat=t._lngLat.wrap()),t._update();for(var r of this._popups)!e||this.getRenderWorldCopies()||r._trackPointer||(r._lngLat=r._lngLat.wrap()),r._update()}},{key:"_updateAverageElevation",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=function(e){return t.transform.averageElevation=e,t._update(!1),!0};if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&i(0);var n=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(n||(r||e-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(e)){var a=this.transform.averageElevation,o=this.transform.sampleAverageElevation();null!=this.transform.elevation&&(this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(o)?o=0:this._averageElevationLastSampledAt=e;var s=Math.abs(a-o);if(s>1){if(this._isInitialLoad||n)return this._averageElevation.jumpTo(o),i(o);this._averageElevation.easeTo(o,e,300)}else if(s>1e-4)return this._averageElevation.jumpTo(o),i(o)}return!!this._averageElevation.isEasing(e)&&i(this._averageElevation.getValue(e))}},{key:"_authenticate",value:function(){var t=this;K(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(function(r){if(r&&(r.message===L||401===r.status)){var i=t.painter.context.gl;ee(i,!1),t._logoControl instanceof Qs&&t._logoControl._updateLogo(),i&&i.clear(i.DEPTH_BUFFER_BIT|i.COLOR_BUFFER_BIT|i.STENCIL_BUFFER_BIT),t._silenceAuthErrors||t.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/")))}})),$(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(function(){}))}},{key:"_postStyleLoadEvent",value:function(){this.style.globalId&&W(this._requestManager._customAccessToken,{map:this,skuToken:this._requestManager._skuToken,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()})}},{key:"_updateTerrain",value:function(){var e=this._isDragging();this.painter.updateTerrain(this.style,e)}},{key:"_calculateSpeedIndex",value:function(){var e=this.painter.canvasCopy(),t=this.painter.getCanvasCopiesAndTimestamps();t.timeStamps.push(performance.now());var r=this.painter.context.gl,i=r.createFramebuffer();function n(e){r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,e,0);var t=new Uint8Array(r.drawingBufferWidth*r.drawingBufferHeight*4);return r.readPixels(0,0,r.drawingBufferWidth,r.drawingBufferHeight,r.RGBA,r.UNSIGNED_BYTE,t),t}return r.bindFramebuffer(r.FRAMEBUFFER,i),this._canvasPixelComparison(n(e),t.canvasCopies.map(n),t.timeStamps)}},{key:"_canvasPixelComparison",value:function(e,t,r){for(var i=r[1]-r[0],n=e.length/4,a=0;a0&&void 0!==arguments[0]?arguments[0]:{};p(this,t),this.options=e.l({},ol,i),this._container=f("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",(function(e){return e.preventDefault()})),this.options.showZoom&&(e.aJ(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",(function(e){r._map&&r._map.zoomIn({},{originalEvent:e})})),f("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",(function(e){r._map&&r._map.zoomOut({},{originalEvent:e})})),f("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(e.aJ(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",(function(e){var t=r._map;t&&(r.options.visualizePitch?t.resetNorthPitch({},{originalEvent:e}):t.resetNorth({},{originalEvent:e}))})),this._compassIcon=f("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}),[{key:"_updateZoomButtons",value:function(){var e=this._map;if(e){var t=e.getZoom(),r=t===e.getMaxZoom(),i=t===e.getMinZoom();this._zoomInButton.disabled=r,this._zoomOutButton.disabled=i,this._zoomInButton.setAttribute("aria-disabled",r.toString()),this._zoomOutButton.setAttribute("aria-disabled",i.toString())}}},{key:"_rotateCompassArrow",value:function(){var e=this,t=this._map;if(t){var r=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(t.transform.pitch*(Math.PI/180)),.5)}) rotateX(${t.transform.pitch}deg) rotateZ(${t.transform.angle*(180/Math.PI)}deg)`:`rotate(${t.transform.angle*(180/Math.PI)}deg)`;t._requestDomTask((function(){e._compassIcon&&(e._compassIcon.style.transform=r)}))}}},{key:"onAdd",value:function(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 sl(e,this._compass,this.options.visualizePitch)),this._container}},{key:"onRemove",value:function(){var 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)}},{key:"_createButton",value:function(e,t){var r=f("button",e,this._container);return r.type="button",r.addEventListener("click",t),r}},{key:"_setButtonTitle",value:function(e,t){if(this._map){var r=this._map._getUIString(`NavigationControl.${t}`);e.setAttribute("aria-label",r),e.firstElementChild&&e.firstElementChild.setAttribute("title",r)}}}])})(),GeolocateControl:(function(t){function r(){var t,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};p(this,r),t=T(this,r);var n=navigator.geolocation;return t.options=e.l({geolocation:n},hl,i),e.aJ(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],t),t._updateMarkerRotationThrottled=Qo(t._updateMarkerRotation,20),t._numberOfWatches=0,t}return y(r,t),m(r,[{key:"onAdd",value:function(e){return this._map=e,this._container=f("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}},{key:"onRemove",value:function(){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}},{key:"_checkGeolocationSupport",value:function(e){var t=this,r=function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:!!t.options.geolocation;t._supportsGeolocation=r,e(r)};void 0!==this._supportsGeolocation?e(this._supportsGeolocation):void 0!==navigator.permissions?navigator.permissions.query({name:"geolocation"}).then((function(e){return r("denied"!==e.state)})).catch((function(){return r()})):r()}},{key:"_isOutOfMapMaxBounds",value:function(e){var t=this._map.getMaxBounds(),r=e.coords;return!!t&&(r.longitudet.getEast()||r.latitudet.getNorth())}},{key:"_setErrorState",value:function(){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")}}},{key:"_onSuccess",value:function(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()}}},{key:"_updateCamera",value:function(t){var r=new e.bK(t.coords.longitude,t.coords.latitude),i=t.coords.accuracy,n=this._map.getBearing(),a=e.l({bearing:n},this.options.fitBoundsOptions);this._map.fitBounds(r.toBounds(i),a,{geolocateSource:!0})}},{key:"_updateMarker",value:function(t){if(t){var r=new e.bK(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(r).addTo(this._map),this._userLocationDotMarker.setLngLat(r).addTo(this._map),this._accuracy=t.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}},{key:"_updateCircleRadius",value:function(){var t=this._map.transform,r=e.bD(1,t._center.lat)*t.worldSize,i=Math.ceil(2*this._accuracy*r);this._circleElement.style.width=`${i}px`,this._circleElement.style.height=`${i}px`}},{key:"_onZoom",value:function(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}},{key:"_updateMarkerRotation",value:function(){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))}},{key:"_onError",value:function(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;var r=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",r),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",r),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()}}},{key:"_finish",value:function(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}},{key:"_setupUI",value:function(t){var r=this;if(void 0!==this._map){if(this._container.addEventListener("contextmenu",(function(e){return e.preventDefault()})),this._geolocateButton=f("button","mapboxgl-ctrl-geolocate",this._container),f("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.");var i=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",i),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",i)}else{var n=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",n),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",n)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=f("div","mapboxgl-user-location"),this._dotElement.appendChild(f("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(f("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new cl({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=f("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new cl({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",(function(t){t.geolocateSource||"ACTIVE_LOCK"!==r._watchState||t.originalEvent&&"resize"===t.originalEvent.type||(r._watchState="BACKGROUND",r._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),r._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),r.fire(new e.x("trackuserlocationend")))}))}}},{key:"_onDeviceOrientation",value:function(e){this._userLocationDotMarker&&(e.webkitCompassHeading?this._heading=e.webkitCompassHeading:!0===e.absolute&&(this._heading=-1*e.alpha),this._updateMarkerRotationThrottled())}},{key:"trigger",value:function(){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){var t;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(t={maximumAge:6e5,timeout:0},this._noTimeout=!0):(t=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,t),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}},{key:"_addDeviceOrientationListener",value:function(){var e=this,t=function(){"ondeviceorientationabsolute"in window?window.addEventListener("deviceorientationabsolute",e._onDeviceOrientation):window.addEventListener("deviceorientation",e._onDeviceOrientation)};"undefined"!=typeof DeviceMotionEvent&&"function"==typeof DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((function(e){"granted"===e&&t()})).catch(console.error):t()}},{key:"_clearWatch",value:function(){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)}}])})(e.E),AttributionControl:Ks,ScaleControl:(function(){return m((function t(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};p(this,t),this.options=e.l({},fl,r),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)}),[{key:"getDefaultPosition",value:function(){return"bottom-left"}},{key:"_update",value:function(){var e=this.options.maxWidth||100,t=this._map,r=t._containerHeight/2,i=t._containerWidth/2-e/2,n=t.unproject([i,r]),a=t.unproject([i+e,r]),o=n.distanceTo(a);if("imperial"===this.options.unit){var s=3.2808*o;s>5280?this._setScale(e,s/5280,"mile"):this._setScale(e,s,"foot")}else"nautical"===this.options.unit?this._setScale(e,o/1852,"nautical-mile"):o>=1e3?this._setScale(e,o/1e3,"kilometer"):this._setScale(e,o,"meter")}},{key:"_setScale",value:function(e,t,r){var i=this;this._map._requestDomTask((function(){var n=(function(e){var t=Math.pow(10,`${Math.floor(e)}`.length-1),r=e/t;return r=r>=10?10:r>=5?5:r>=3?3:r>=2?2:r>=1?1:(function(e){var t=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*t)/t})(r),t*r})(t),a=n/t;i._container.innerHTML=i._isNumberFormatSupported&&"nautical-mile"!==r?new Intl.NumberFormat(i._language,{style:"unit",unitDisplay:"short",unit:r}).format(n):`${n} ${dl[r]}`,i._container.style.width=e*a+"px"}))}},{key:"onAdd",value:function(e){return this._map=e,this._language=e.getLanguage(),this._container=f("div","mapboxgl-ctrl mapboxgl-ctrl-scale",e.getContainer()),this._container.dir="auto",this._map.on("move",this._update),this._update(),this._container}},{key:"onRemove",value:function(){this._container.remove(),this._map.off("move",this._update),this._map=void 0}},{key:"_setLanguage",value:function(e){this._language=e,this._update()}},{key:"setUnit",value:function(e){this.options.unit=e,this._update()}}])})(),FullscreenControl:(function(){return m((function t(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};p(this,t),this._fullscreen=!1,r&&r.container&&(r.container instanceof HTMLElement?this._container=r.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")}),[{key:"onAdd",value:function(t){return this._map=t,this._container||(this._container=this._map.getContainer()),this._controlContainer=f("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}},{key:"onRemove",value:function(){this._controlContainer.remove(),this._map=null,document.removeEventListener(this._fullscreenchange,this._changeIcon)}},{key:"_checkFullscreenSupport",value:function(){return!(!document.fullscreenEnabled&&!document.webkitFullscreenEnabled)}},{key:"_setupUI",value:function(){var e=this._fullscreenButton=f("button","mapboxgl-ctrl-fullscreen",this._controlContainer);f("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)}},{key:"_updateTitle",value:function(){var e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",e)}},{key:"_getTitle",value:function(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}},{key:"_isFullscreen",value:function(){return this._fullscreen}},{key:"_changeIcon",value:function(){(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())}},{key:"_onClickFullscreen",value:function(){this._isFullscreen()?document.exitFullscreen?document.exitFullscreen():document.webkitCancelFullScreen&&document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}}])})(),Popup:(function(t){function r(t){var i;return p(this,r),(i=T(this,r)).options=e.l(Object.create(pl),t),e.aJ(["_update","_onClose","remove","_onMouseEvent"],l(i)),i._classList=new Set(t&&t.className?t.className.trim().split(/\s+/):[]),i}return y(r,t),m(r,[{key:"addTo",value:function(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}},{key:"isOpen",value:function(){return!!this._map}},{key:"remove",value:function(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);var 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}},{key:"getLngLat",value:function(){return this._lngLat}},{key:"setLngLat",value:function(t){this._lngLat=e.bK.convert(t),this._pos=null,this._trackPointer=!1,this._update();var r=this._map;return r&&(r.on("move",this._update),r.off("mousemove",this._onMouseEvent),r._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}},{key:"trackPointer",value:function(){this._trackPointer=!0,this._pos=null,this._update();var 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}},{key:"getElement",value:function(){return this._container}},{key:"setText",value:function(e){return this.setDOMContent(document.createTextNode(e))}},{key:"setHTML",value:function(e){var t,r=document.createDocumentFragment(),i=document.createElement("body");for(i.innerHTML=e;t=i.firstChild;)r.appendChild(t);return this.setDOMContent(r)}},{key:"getMaxWidth",value:function(){return this._container&&this._container.style.maxWidth}},{key:"setMaxWidth",value:function(e){return this.options.maxWidth=e,this._update(),this}},{key:"setDOMContent",value:function(e){var t=this._content;if(t)for(;t.hasChildNodes();)t.firstChild&&t.removeChild(t.firstChild);else t=this._content=f("div","mapboxgl-popup-content",this._container||void 0);if(t.appendChild(e),this.options.closeButton){var r=this._closeButton=f("button","mapboxgl-popup-close-button",t);r.type="button",r.setAttribute("aria-label","Close popup"),r.setAttribute("aria-hidden","true"),r.innerHTML="×",r.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}},{key:"addClassName",value:function(e){return this._classList.add(e),this._updateClassList(),this}},{key:"removeClassName",value:function(e){return this._classList.delete(e),this._updateClassList(),this}},{key:"setOffset",value:function(e){return this.options.offset=e,this._update(),this}},{key:"toggleClassName",value:function(e){var t;return this._classList.delete(e)?t=!1:(this._classList.add(e),t=!0),this._updateClassList(),t}},{key:"_onMouseEvent",value:function(e){this._update(e.point)}},{key:"_getAnchor",value:function(e){if(this.options.anchor)return this.options.anchor;var t=this._map,r=this._container,i=this._pos;if(!t||!r||!i)return"bottom";var n=r.offsetWidth,a=r.offsetHeight,o=i.xt.transform.width-n/2;if(i.y+et.transform.height-a){if(o)return"bottom-left";if(s)return"bottom-right"}return o?"left":s?"right":"bottom"}},{key:"_updateClassList",value:function(){var e=this._container;if(e){var t=d(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(" ")}}},{key:"_update",value:function(t){var r=this,i=this._map,n=this._content;if(i&&(this._lngLat||this._trackPointer)&&n){var a=this._container;if(a||(a=this._container=f("div","mapboxgl-popup",i.getContainer()),this._tip=f("div","mapboxgl-popup-tip",a),a.appendChild(n)),this.options.maxWidth&&a.style.maxWidth!==this.options.maxWidth&&(a.style.maxWidth=this.options.maxWidth),i.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=ll(this._lngLat,this._pos,i.transform)),!this._trackPointer||t){var o=this._pos=this._trackPointer&&t instanceof e.P?t:i.project(this._lngLat),s=vl(this.options.offset),l=this._anchor=this._getAnchor(s.y),u=vl(this.options.offset,l),c=o.add(u).round();i._requestDomTask((function(){r._container&&l&&(r._container.style.transform=`${ul[l]} translate(${c.x}px,${c.y}px)`)}))}if(!this._marker&&i._showingGlobe()){var h=e.dz(i.transform,this._lngLat)?0:1;this._setOpacity(h)}this._updateClassList()}}},{key:"_focusFirstElement",value:function(){if(this.options.focusAfterOpen&&this._container){var e=this._container.querySelector(ml);e&&e.focus()}}},{key:"_onClose",value:function(){this.remove()}},{key:"_setOpacity",value:function(e){this._container&&(this._container.style.opacity=`${e}`),this._content&&(this._content.style.pointerEvents=e?"auto":"none")}}])})(e.E),Marker:cl,Style:Ni,LngLat:e.bK,LngLatBounds:e.as,Point:e.P,MercatorCoordinate:e.a5,FreeCameraOptions:ci,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:function(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}})),r}))}),298,[12,115,299,300,158,302,34,105,106,114,116,117,303,280]); +__d((function(e,t,r,i,n,a,o){var s=t(o[0]),l=t(o[1]),u=t(o[2]),c=t(o[3]),h=t(o[4]),f=t(o[5]),d=t(o[6]),p=t(o[7]),m=t(o[8]),v=t(o[9]),_=t(o[10]),g=t(o[11]),y=t(o[12]),x=t(o[13]),b=["data"],w=["data"];function k(e,t,r,i){var n=h(_(1&i?e.prototype:e),t,r);return 2&i&&"function"==typeof n?function(e){return n.apply(r,e)}:n}function T(e,t,r){return t=_(t),v(e,S()?Reflect.construct(t,r||[],_(e).constructor):t.apply(e,r))}function S(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(S=function(){return!!e})()}!(function(e,t){'object'==typeof a&&void 0!==n?n.exports=t():'function'==typeof define&&define.amd?define(t):(e='undefined'!=typeof globalThis?globalThis:e||self).mapboxgl=t()})(this,(function(){'use strict';var e,t,r;function i(i,n){if(e)if(t){var a="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 = {}; ("+e+")(sharedChunk); ("+t+")(sharedChunk); self.onerror = null;",o={};e(o),r=n(o),'undefined'!=typeof window&&window&&window.URL&&window.URL.createObjectURL&&(r.workerUrl=window.URL.createObjectURL(new Blob([a],{type:'text/javascript'})))}else t=n;else e=n}return i(0,(function(e){function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var r,i={},n={};function a(){if(r)return n;r=1,Object.defineProperty(n,"__esModule",{value:!0}),n.setMatrixArrayType=function(e){n.ARRAY_TYPE=t=e},n.toRadian=function(e){return e*a},n.equals=function(t,r){return Math.abs(t-r)<=e*Math.max(1,Math.abs(t),Math.abs(r))},n.RANDOM=n.ARRAY_TYPE=n.EPSILON=void 0;var e=1e-6;n.EPSILON=e;var t="undefined"!=typeof Float32Array?Float32Array:Array;n.ARRAY_TYPE=t;var i=Math.random;n.RANDOM=i;var a=Math.PI/180;return Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)}),n}var o,s={};function l(){if(o)return s;function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}o=1,Object.defineProperty(s,"__esModule",{value:!0}),s.create=function(){var e=new t.ARRAY_TYPE(4);return t.ARRAY_TYPE!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e},s.clone=function(e){var r=new t.ARRAY_TYPE(4);return r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=e[3],r},s.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},s.identity=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e},s.fromValues=function(e,r,i,n){var a=new t.ARRAY_TYPE(4);return a[0]=e,a[1]=r,a[2]=i,a[3]=n,a},s.set=function(e,t,r,i,n){return e[0]=t,e[1]=r,e[2]=i,e[3]=n,e},s.transpose=function(e,t){if(e===t){var r=t[1];e[1]=t[2],e[2]=r}else e[0]=t[0],e[1]=t[2],e[2]=t[1],e[3]=t[3];return e},s.invert=function(e,t){var r=t[0],i=t[1],n=t[2],a=t[3],o=r*a-n*i;return o?(e[0]=a*(o=1/o),e[1]=-i*o,e[2]=-n*o,e[3]=r*o,e):null},s.adjoint=function(e,t){var r=t[0];return e[0]=t[3],e[1]=-t[1],e[2]=-t[2],e[3]=r,e},s.determinant=function(e){return e[0]*e[3]-e[2]*e[1]},s.multiply=i,s.rotate=function(e,t,r){var i=t[0],n=t[1],a=t[2],o=t[3],s=Math.sin(r),l=Math.cos(r);return e[0]=i*l+a*s,e[1]=n*l+o*s,e[2]=i*-s+a*l,e[3]=n*-s+o*l,e},s.scale=function(e,t,r){var i=t[1],n=t[2],a=t[3],o=r[0],s=r[1];return e[0]=t[0]*o,e[1]=i*o,e[2]=n*s,e[3]=a*s,e},s.fromRotation=function(e,t){var r=Math.sin(t),i=Math.cos(t);return e[0]=i,e[1]=r,e[2]=-r,e[3]=i,e},s.fromScaling=function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=t[1],e},s.str=function(e){return"mat2("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},s.frob=function(e){return Math.hypot(e[0],e[1],e[2],e[3])},s.LDU=function(e,t,r,i){return e[2]=i[2]/i[0],r[0]=i[0],r[1]=i[1],r[3]=i[3]-e[2]*r[1],[e,t,r]},s.add=function(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e},s.subtract=n,s.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]},s.equals=function(e,r){var i=e[0],n=e[1],a=e[2],o=e[3],s=r[0],l=r[1],u=r[2],c=r[3];return Math.abs(i-s)<=t.EPSILON*Math.max(1,Math.abs(i),Math.abs(s))&&Math.abs(n-l)<=t.EPSILON*Math.max(1,Math.abs(n),Math.abs(l))&&Math.abs(a-u)<=t.EPSILON*Math.max(1,Math.abs(a),Math.abs(u))&&Math.abs(o-c)<=t.EPSILON*Math.max(1,Math.abs(o),Math.abs(c))},s.multiplyScalar=function(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e},s.multiplyScalarAndAdd=function(e,t,r,i){return e[0]=t[0]+r[0]*i,e[1]=t[1]+r[1]*i,e[2]=t[2]+r[2]*i,e[3]=t[3]+r[3]*i,e},s.sub=s.mul=void 0;var t=(function(t){if(t&&t.__esModule)return t;if(null===t||"object"!==e(t)&&"function"!=typeof t)return{default:t};var i=r(void 0);if(i&&i.has(t))return i.get(t);var n={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in t)if("default"!==o&&Object.prototype.hasOwnProperty.call(t,o)){var s=a?Object.getOwnPropertyDescriptor(t,o):null;s&&(s.get||s.set)?Object.defineProperty(n,o,s):n[o]=t[o]}return n.default=t,i&&i.set(t,n),n})(a());function r(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return(r=function(e){return e?i:t})(e)}function i(e,t,r){var i=t[0],n=t[1],a=t[2],o=t[3],s=r[0],l=r[1],u=r[2],c=r[3];return e[0]=i*s+a*l,e[1]=n*s+o*l,e[2]=i*u+a*c,e[3]=n*u+o*c,e}function n(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e}return s.mul=i,s.sub=n,s}var u,h={};function v(){if(u)return h;function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}u=1,Object.defineProperty(h,"__esModule",{value:!0}),h.create=function(){var e=new t.ARRAY_TYPE(6);return t.ARRAY_TYPE!=Float32Array&&(e[1]=0,e[2]=0,e[4]=0,e[5]=0),e[0]=1,e[3]=1,e},h.clone=function(e){var r=new t.ARRAY_TYPE(6);return r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=e[3],r[4]=e[4],r[5]=e[5],r},h.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e},h.identity=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e},h.fromValues=function(e,r,i,n,a,o){var s=new t.ARRAY_TYPE(6);return s[0]=e,s[1]=r,s[2]=i,s[3]=n,s[4]=a,s[5]=o,s},h.set=function(e,t,r,i,n,a,o){return e[0]=t,e[1]=r,e[2]=i,e[3]=n,e[4]=a,e[5]=o,e},h.invert=function(e,t){var r=t[0],i=t[1],n=t[2],a=t[3],o=t[4],s=t[5],l=r*a-i*n;return l?(e[0]=a*(l=1/l),e[1]=-i*l,e[2]=-n*l,e[3]=r*l,e[4]=(n*s-a*o)*l,e[5]=(i*o-r*s)*l,e):null},h.determinant=function(e){return e[0]*e[3]-e[1]*e[2]},h.multiply=i,h.rotate=function(e,t,r){var i=t[0],n=t[1],a=t[2],o=t[3],s=t[4],l=t[5],u=Math.sin(r),c=Math.cos(r);return e[0]=i*c+a*u,e[1]=n*c+o*u,e[2]=i*-u+a*c,e[3]=n*-u+o*c,e[4]=s,e[5]=l,e},h.scale=function(e,t,r){var i=t[1],n=t[2],a=t[3],o=t[4],s=t[5],l=r[0],u=r[1];return e[0]=t[0]*l,e[1]=i*l,e[2]=n*u,e[3]=a*u,e[4]=o,e[5]=s,e},h.translate=function(e,t,r){var i=t[0],n=t[1],a=t[2],o=t[3],s=t[4],l=t[5],u=r[0],c=r[1];return e[0]=i,e[1]=n,e[2]=a,e[3]=o,e[4]=i*u+a*c+s,e[5]=n*u+o*c+l,e},h.fromRotation=function(e,t){var r=Math.sin(t),i=Math.cos(t);return e[0]=i,e[1]=r,e[2]=-r,e[3]=i,e[4]=0,e[5]=0,e},h.fromScaling=function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=t[1],e[4]=0,e[5]=0,e},h.fromTranslation=function(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=t[0],e[5]=t[1],e},h.str=function(e){return"mat2d("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+")"},h.frob=function(e){return Math.hypot(e[0],e[1],e[2],e[3],e[4],e[5],1)},h.add=function(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e[4]=t[4]+r[4],e[5]=t[5]+r[5],e},h.subtract=n,h.multiplyScalar=function(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*r,e[5]=t[5]*r,e},h.multiplyScalarAndAdd=function(e,t,r,i){return e[0]=t[0]+r[0]*i,e[1]=t[1]+r[1]*i,e[2]=t[2]+r[2]*i,e[3]=t[3]+r[3]*i,e[4]=t[4]+r[4]*i,e[5]=t[5]+r[5]*i,e},h.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]},h.equals=function(e,r){var i=e[0],n=e[1],a=e[2],o=e[3],s=e[4],l=e[5],u=r[0],c=r[1],h=r[2],f=r[3],d=r[4],p=r[5];return Math.abs(i-u)<=t.EPSILON*Math.max(1,Math.abs(i),Math.abs(u))&&Math.abs(n-c)<=t.EPSILON*Math.max(1,Math.abs(n),Math.abs(c))&&Math.abs(a-h)<=t.EPSILON*Math.max(1,Math.abs(a),Math.abs(h))&&Math.abs(o-f)<=t.EPSILON*Math.max(1,Math.abs(o),Math.abs(f))&&Math.abs(s-d)<=t.EPSILON*Math.max(1,Math.abs(s),Math.abs(d))&&Math.abs(l-p)<=t.EPSILON*Math.max(1,Math.abs(l),Math.abs(p))},h.sub=h.mul=void 0;var t=(function(t){if(t&&t.__esModule)return t;if(null===t||"object"!==e(t)&&"function"!=typeof t)return{default:t};var i=r(void 0);if(i&&i.has(t))return i.get(t);var n={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in t)if("default"!==o&&Object.prototype.hasOwnProperty.call(t,o)){var s=a?Object.getOwnPropertyDescriptor(t,o):null;s&&(s.get||s.set)?Object.defineProperty(n,o,s):n[o]=t[o]}return n.default=t,i&&i.set(t,n),n})(a());function r(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return(r=function(e){return e?i:t})(e)}function i(e,t,r){var i=t[0],n=t[1],a=t[2],o=t[3],s=t[4],l=t[5],u=r[0],c=r[1],h=r[2],f=r[3],d=r[4],p=r[5];return e[0]=i*u+a*c,e[1]=n*u+o*c,e[2]=i*h+a*f,e[3]=n*h+o*f,e[4]=i*d+a*p+s,e[5]=n*d+o*p+l,e}function n(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e[4]=t[4]-r[4],e[5]=t[5]-r[5],e}return h.mul=i,h.sub=n,h}var _,b={};function w(){if(_)return b;function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}_=1,Object.defineProperty(b,"__esModule",{value:!0}),b.create=function(){var e=new t.ARRAY_TYPE(9);return t.ARRAY_TYPE!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e},b.fromMat4=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[4],e[4]=t[5],e[5]=t[6],e[6]=t[8],e[7]=t[9],e[8]=t[10],e},b.clone=function(e){var r=new t.ARRAY_TYPE(9);return r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=e[3],r[4]=e[4],r[5]=e[5],r[6]=e[6],r[7]=e[7],r[8]=e[8],r},b.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e},b.fromValues=function(e,r,i,n,a,o,s,l,u){var c=new t.ARRAY_TYPE(9);return c[0]=e,c[1]=r,c[2]=i,c[3]=n,c[4]=a,c[5]=o,c[6]=s,c[7]=l,c[8]=u,c},b.set=function(e,t,r,i,n,a,o,s,l,u){return e[0]=t,e[1]=r,e[2]=i,e[3]=n,e[4]=a,e[5]=o,e[6]=s,e[7]=l,e[8]=u,e},b.identity=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},b.transpose=function(e,t){if(e===t){var r=t[1],i=t[2],n=t[5];e[1]=t[3],e[2]=t[6],e[3]=r,e[5]=t[7],e[6]=i,e[7]=n}else e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8];return e},b.invert=function(e,t){var r=t[0],i=t[1],n=t[2],a=t[3],o=t[4],s=t[5],l=t[6],u=t[7],c=t[8],h=c*o-s*u,f=-c*a+s*l,d=u*a-o*l,p=r*h+i*f+n*d;return p?(e[0]=h*(p=1/p),e[1]=(-c*i+n*u)*p,e[2]=(s*i-n*o)*p,e[3]=f*p,e[4]=(c*r-n*l)*p,e[5]=(-s*r+n*a)*p,e[6]=d*p,e[7]=(-u*r+i*l)*p,e[8]=(o*r-i*a)*p,e):null},b.adjoint=function(e,t){var r=t[0],i=t[1],n=t[2],a=t[3],o=t[4],s=t[5],l=t[6],u=t[7],c=t[8];return e[0]=o*c-s*u,e[1]=n*u-i*c,e[2]=i*s-n*o,e[3]=s*l-a*c,e[4]=r*c-n*l,e[5]=n*a-r*s,e[6]=a*u-o*l,e[7]=i*l-r*u,e[8]=r*o-i*a,e},b.determinant=function(e){var t=e[3],r=e[4],i=e[5],n=e[6],a=e[7],o=e[8];return e[0]*(o*r-i*a)+e[1]*(-o*t+i*n)+e[2]*(a*t-r*n)},b.multiply=i,b.translate=function(e,t,r){var i=t[0],n=t[1],a=t[2],o=t[3],s=t[4],l=t[5],u=t[6],c=t[7],h=t[8],f=r[0],d=r[1];return e[0]=i,e[1]=n,e[2]=a,e[3]=o,e[4]=s,e[5]=l,e[6]=f*i+d*o+u,e[7]=f*n+d*s+c,e[8]=f*a+d*l+h,e},b.rotate=function(e,t,r){var i=t[0],n=t[1],a=t[2],o=t[3],s=t[4],l=t[5],u=t[6],c=t[7],h=t[8],f=Math.sin(r),d=Math.cos(r);return e[0]=d*i+f*o,e[1]=d*n+f*s,e[2]=d*a+f*l,e[3]=d*o-f*i,e[4]=d*s-f*n,e[5]=d*l-f*a,e[6]=u,e[7]=c,e[8]=h,e},b.scale=function(e,t,r){var i=r[0],n=r[1];return e[0]=i*t[0],e[1]=i*t[1],e[2]=i*t[2],e[3]=n*t[3],e[4]=n*t[4],e[5]=n*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e},b.fromTranslation=function(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=t[0],e[7]=t[1],e[8]=1,e},b.fromRotation=function(e,t){var r=Math.sin(t),i=Math.cos(t);return e[0]=i,e[1]=r,e[2]=0,e[3]=-r,e[4]=i,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},b.fromScaling=function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=t[1],e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},b.fromMat2d=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=0,e[3]=t[2],e[4]=t[3],e[5]=0,e[6]=t[4],e[7]=t[5],e[8]=1,e},b.fromQuat=function(e,t){var r=t[0],i=t[1],n=t[2],a=t[3],o=r+r,s=i+i,l=n+n,u=r*o,c=i*o,h=i*s,f=n*o,d=n*s,p=n*l,m=a*o,v=a*s,_=a*l;return e[0]=1-h-p,e[3]=c-_,e[6]=f+v,e[1]=c+_,e[4]=1-u-p,e[7]=d-m,e[2]=f-v,e[5]=d+m,e[8]=1-u-h,e},b.normalFromMat4=function(e,t){var r=t[0],i=t[1],n=t[2],a=t[3],o=t[4],s=t[5],l=t[6],u=t[7],c=t[8],h=t[9],f=t[10],d=t[11],p=t[12],m=t[13],v=t[14],_=t[15],g=r*s-i*o,y=r*l-n*o,x=r*u-a*o,b=i*l-n*s,w=i*u-a*s,k=n*u-a*l,T=c*m-h*p,S=c*v-f*p,E=c*_-d*p,M=h*v-f*m,A=h*_-d*m,I=f*_-d*v,C=g*I-y*A+x*M+b*E-w*S+k*T;return C?(e[0]=(s*I-l*A+u*M)*(C=1/C),e[1]=(l*E-o*I-u*S)*C,e[2]=(o*A-s*E+u*T)*C,e[3]=(n*A-i*I-a*M)*C,e[4]=(r*I-n*E+a*S)*C,e[5]=(i*E-r*A-a*T)*C,e[6]=(m*k-v*w+_*b)*C,e[7]=(v*x-p*k-_*y)*C,e[8]=(p*w-m*x+_*g)*C,e):null},b.projection=function(e,t,r){return e[0]=2/t,e[1]=0,e[2]=0,e[3]=0,e[4]=-2/r,e[5]=0,e[6]=-1,e[7]=1,e[8]=1,e},b.str=function(e){return"mat3("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+", "+e[8]+")"},b.frob=function(e){return Math.hypot(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8])},b.add=function(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e[4]=t[4]+r[4],e[5]=t[5]+r[5],e[6]=t[6]+r[6],e[7]=t[7]+r[7],e[8]=t[8]+r[8],e},b.subtract=n,b.multiplyScalar=function(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,e[8]=t[8]*r,e},b.multiplyScalarAndAdd=function(e,t,r,i){return e[0]=t[0]+r[0]*i,e[1]=t[1]+r[1]*i,e[2]=t[2]+r[2]*i,e[3]=t[3]+r[3]*i,e[4]=t[4]+r[4]*i,e[5]=t[5]+r[5]*i,e[6]=t[6]+r[6]*i,e[7]=t[7]+r[7]*i,e[8]=t[8]+r[8]*i,e},b.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]},b.equals=function(e,r){var i=e[0],n=e[1],a=e[2],o=e[3],s=e[4],l=e[5],u=e[6],c=e[7],h=e[8],f=r[0],d=r[1],p=r[2],m=r[3],v=r[4],_=r[5],g=r[6],y=r[7],x=r[8];return Math.abs(i-f)<=t.EPSILON*Math.max(1,Math.abs(i),Math.abs(f))&&Math.abs(n-d)<=t.EPSILON*Math.max(1,Math.abs(n),Math.abs(d))&&Math.abs(a-p)<=t.EPSILON*Math.max(1,Math.abs(a),Math.abs(p))&&Math.abs(o-m)<=t.EPSILON*Math.max(1,Math.abs(o),Math.abs(m))&&Math.abs(s-v)<=t.EPSILON*Math.max(1,Math.abs(s),Math.abs(v))&&Math.abs(l-_)<=t.EPSILON*Math.max(1,Math.abs(l),Math.abs(_))&&Math.abs(u-g)<=t.EPSILON*Math.max(1,Math.abs(u),Math.abs(g))&&Math.abs(c-y)<=t.EPSILON*Math.max(1,Math.abs(c),Math.abs(y))&&Math.abs(h-x)<=t.EPSILON*Math.max(1,Math.abs(h),Math.abs(x))},b.sub=b.mul=void 0;var t=(function(t){if(t&&t.__esModule)return t;if(null===t||"object"!==e(t)&&"function"!=typeof t)return{default:t};var i=r(void 0);if(i&&i.has(t))return i.get(t);var n={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in t)if("default"!==o&&Object.prototype.hasOwnProperty.call(t,o)){var s=a?Object.getOwnPropertyDescriptor(t,o):null;s&&(s.get||s.set)?Object.defineProperty(n,o,s):n[o]=t[o]}return n.default=t,i&&i.set(t,n),n})(a());function r(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return(r=function(e){return e?i:t})(e)}function i(e,t,r){var i=t[0],n=t[1],a=t[2],o=t[3],s=t[4],l=t[5],u=t[6],c=t[7],h=t[8],f=r[0],d=r[1],p=r[2],m=r[3],v=r[4],_=r[5],g=r[6],y=r[7],x=r[8];return e[0]=f*i+d*o+p*u,e[1]=f*n+d*s+p*c,e[2]=f*a+d*l+p*h,e[3]=m*i+v*o+_*u,e[4]=m*n+v*s+_*c,e[5]=m*a+v*l+_*h,e[6]=g*i+y*o+x*u,e[7]=g*n+y*s+x*c,e[8]=g*a+y*l+x*h,e}function n(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e[4]=t[4]-r[4],e[5]=t[5]-r[5],e[6]=t[6]-r[6],e[7]=t[7]-r[7],e[8]=t[8]-r[8],e}return b.mul=i,b.sub=n,b}var S,E={};function M(){if(S)return E;function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}S=1,Object.defineProperty(E,"__esModule",{value:!0}),E.create=function(){var e=new t.ARRAY_TYPE(16);return t.ARRAY_TYPE!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e},E.clone=function(e){var r=new t.ARRAY_TYPE(16);return r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=e[3],r[4]=e[4],r[5]=e[5],r[6]=e[6],r[7]=e[7],r[8]=e[8],r[9]=e[9],r[10]=e[10],r[11]=e[11],r[12]=e[12],r[13]=e[13],r[14]=e[14],r[15]=e[15],r},E.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},E.fromValues=function(e,r,i,n,a,o,s,l,u,c,h,f,d,p,m,v){var _=new t.ARRAY_TYPE(16);return _[0]=e,_[1]=r,_[2]=i,_[3]=n,_[4]=a,_[5]=o,_[6]=s,_[7]=l,_[8]=u,_[9]=c,_[10]=h,_[11]=f,_[12]=d,_[13]=p,_[14]=m,_[15]=v,_},E.set=function(e,t,r,i,n,a,o,s,l,u,c,h,f,d,p,m,v){return e[0]=t,e[1]=r,e[2]=i,e[3]=n,e[4]=a,e[5]=o,e[6]=s,e[7]=l,e[8]=u,e[9]=c,e[10]=h,e[11]=f,e[12]=d,e[13]=p,e[14]=m,e[15]=v,e},E.identity=i,E.transpose=function(e,t){if(e===t){var r=t[1],i=t[2],n=t[3],a=t[6],o=t[7],s=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=r,e[6]=t[9],e[7]=t[13],e[8]=i,e[9]=a,e[11]=t[14],e[12]=n,e[13]=o,e[14]=s}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e},E.invert=function(e,t){var r=t[0],i=t[1],n=t[2],a=t[3],o=t[4],s=t[5],l=t[6],u=t[7],c=t[8],h=t[9],f=t[10],d=t[11],p=t[12],m=t[13],v=t[14],_=t[15],g=r*s-i*o,y=r*l-n*o,x=r*u-a*o,b=i*l-n*s,w=i*u-a*s,k=n*u-a*l,T=c*m-h*p,S=c*v-f*p,E=c*_-d*p,M=h*v-f*m,A=h*_-d*m,I=f*_-d*v,C=g*I-y*A+x*M+b*E-w*S+k*T;return C?(e[0]=(s*I-l*A+u*M)*(C=1/C),e[1]=(n*A-i*I-a*M)*C,e[2]=(m*k-v*w+_*b)*C,e[3]=(f*w-h*k-d*b)*C,e[4]=(l*E-o*I-u*S)*C,e[5]=(r*I-n*E+a*S)*C,e[6]=(v*x-p*k-_*y)*C,e[7]=(c*k-f*x+d*y)*C,e[8]=(o*A-s*E+u*T)*C,e[9]=(i*E-r*A-a*T)*C,e[10]=(p*w-m*x+_*g)*C,e[11]=(h*x-c*w-d*g)*C,e[12]=(s*S-o*M-l*T)*C,e[13]=(r*M-i*S+n*T)*C,e[14]=(m*y-p*b-v*g)*C,e[15]=(c*b-h*y+f*g)*C,e):null},E.adjoint=function(e,t){var r=t[0],i=t[1],n=t[2],a=t[3],o=t[4],s=t[5],l=t[6],u=t[7],c=t[8],h=t[9],f=t[10],d=t[11],p=t[12],m=t[13],v=t[14],_=t[15];return e[0]=s*(f*_-d*v)-h*(l*_-u*v)+m*(l*d-u*f),e[1]=-(i*(f*_-d*v)-h*(n*_-a*v)+m*(n*d-a*f)),e[2]=i*(l*_-u*v)-s*(n*_-a*v)+m*(n*u-a*l),e[3]=-(i*(l*d-u*f)-s*(n*d-a*f)+h*(n*u-a*l)),e[4]=-(o*(f*_-d*v)-c*(l*_-u*v)+p*(l*d-u*f)),e[5]=r*(f*_-d*v)-c*(n*_-a*v)+p*(n*d-a*f),e[6]=-(r*(l*_-u*v)-o*(n*_-a*v)+p*(n*u-a*l)),e[7]=r*(l*d-u*f)-o*(n*d-a*f)+c*(n*u-a*l),e[8]=o*(h*_-d*m)-c*(s*_-u*m)+p*(s*d-u*h),e[9]=-(r*(h*_-d*m)-c*(i*_-a*m)+p*(i*d-a*h)),e[10]=r*(s*_-u*m)-o*(i*_-a*m)+p*(i*u-a*s),e[11]=-(r*(s*d-u*h)-o*(i*d-a*h)+c*(i*u-a*s)),e[12]=-(o*(h*v-f*m)-c*(s*v-l*m)+p*(s*f-l*h)),e[13]=r*(h*v-f*m)-c*(i*v-n*m)+p*(i*f-n*h),e[14]=-(r*(s*v-l*m)-o*(i*v-n*m)+p*(i*l-n*s)),e[15]=r*(s*f-l*h)-o*(i*f-n*h)+c*(i*l-n*s),e},E.determinant=function(e){var t=e[0],r=e[1],i=e[2],n=e[3],a=e[4],o=e[5],s=e[6],l=e[7],u=e[8],c=e[9],h=e[10],f=e[11],d=e[12],p=e[13],m=e[14],v=e[15];return(t*o-r*a)*(h*v-f*m)-(t*s-i*a)*(c*v-f*p)+(t*l-n*a)*(c*m-h*p)+(r*s-i*o)*(u*v-f*d)-(r*l-n*o)*(u*m-h*d)+(i*l-n*s)*(u*p-c*d)},E.multiply=n,E.translate=function(e,t,r){var i,n,a,o,s,l,u,c,h,f,d,p,m=r[0],v=r[1],_=r[2];return t===e?(e[12]=t[0]*m+t[4]*v+t[8]*_+t[12],e[13]=t[1]*m+t[5]*v+t[9]*_+t[13],e[14]=t[2]*m+t[6]*v+t[10]*_+t[14],e[15]=t[3]*m+t[7]*v+t[11]*_+t[15]):(n=t[1],a=t[2],o=t[3],s=t[4],l=t[5],u=t[6],c=t[7],h=t[8],f=t[9],d=t[10],p=t[11],e[0]=i=t[0],e[1]=n,e[2]=a,e[3]=o,e[4]=s,e[5]=l,e[6]=u,e[7]=c,e[8]=h,e[9]=f,e[10]=d,e[11]=p,e[12]=i*m+s*v+h*_+t[12],e[13]=n*m+l*v+f*_+t[13],e[14]=a*m+u*v+d*_+t[14],e[15]=o*m+c*v+p*_+t[15]),e},E.scale=function(e,t,r){var i=r[0],n=r[1],a=r[2];return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e[4]=t[4]*n,e[5]=t[5]*n,e[6]=t[6]*n,e[7]=t[7]*n,e[8]=t[8]*a,e[9]=t[9]*a,e[10]=t[10]*a,e[11]=t[11]*a,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},E.rotate=function(e,r,i,n){var a,o,s,l,u,c,h,f,d,p,m,v,_,g,y,x,b,w,k,T,S,E,M,A,I=n[0],C=n[1],P=n[2],z=Math.hypot(I,C,P);return z0?(i[0]=2*(u*l+f*n+c*s-h*a)/d,i[1]=2*(c*l+f*a+h*n-u*s)/d,i[2]=2*(h*l+f*s+u*a-c*n)/d):(i[0]=2*(u*l+f*n+c*s-h*a),i[1]=2*(c*l+f*a+h*n-u*s),i[2]=2*(h*l+f*s+u*a-c*n)),o(e,r,i),e},E.getTranslation=function(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e},E.getScaling=s,E.getRotation=function(e,r){var i=new t.ARRAY_TYPE(3);s(i,r);var n=1/i[0],a=1/i[1],o=1/i[2],l=r[0]*n,u=r[1]*a,c=r[2]*o,h=r[4]*n,f=r[5]*a,d=r[6]*o,p=r[8]*n,m=r[9]*a,v=r[10]*o,_=l+f+v,g=0;return _>0?(g=2*Math.sqrt(_+1),e[3]=.25*g,e[0]=(d-m)/g,e[1]=(p-c)/g,e[2]=(u-h)/g):l>f&&l>v?(g=2*Math.sqrt(1+l-f-v),e[3]=(d-m)/g,e[0]=.25*g,e[1]=(u+h)/g,e[2]=(p+c)/g):f>v?(g=2*Math.sqrt(1+f-l-v),e[3]=(p-c)/g,e[0]=(u+h)/g,e[1]=.25*g,e[2]=(d+m)/g):(g=2*Math.sqrt(1+v-l-f),e[3]=(u-h)/g,e[0]=(p+c)/g,e[1]=(d+m)/g,e[2]=.25*g),e},E.fromRotationTranslationScale=function(e,t,r,i){var n=t[0],a=t[1],o=t[2],s=t[3],l=n+n,u=a+a,c=o+o,h=n*l,f=n*u,d=n*c,p=a*u,m=a*c,v=o*c,_=s*l,g=s*u,y=s*c,x=i[0],b=i[1],w=i[2];return e[0]=(1-(p+v))*x,e[1]=(f+y)*x,e[2]=(d-g)*x,e[3]=0,e[4]=(f-y)*b,e[5]=(1-(h+v))*b,e[6]=(m+_)*b,e[7]=0,e[8]=(d+g)*w,e[9]=(m-_)*w,e[10]=(1-(h+p))*w,e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e},E.fromRotationTranslationScaleOrigin=function(e,t,r,i,n){var a=t[0],o=t[1],s=t[2],l=t[3],u=a+a,c=o+o,h=s+s,f=a*u,d=a*c,p=a*h,m=o*c,v=o*h,_=s*h,g=l*u,y=l*c,x=l*h,b=i[0],w=i[1],k=i[2],T=n[0],S=n[1],E=n[2],M=(1-(m+_))*b,A=(d+x)*b,I=(p-y)*b,C=(d-x)*w,P=(1-(f+_))*w,z=(v+g)*w,D=(p+y)*k,R=(v-g)*k,L=(1-(f+m))*k;return e[0]=M,e[1]=A,e[2]=I,e[3]=0,e[4]=C,e[5]=P,e[6]=z,e[7]=0,e[8]=D,e[9]=R,e[10]=L,e[11]=0,e[12]=r[0]+T-(M*T+C*S+D*E),e[13]=r[1]+S-(A*T+P*S+R*E),e[14]=r[2]+E-(I*T+z*S+L*E),e[15]=1,e},E.fromQuat=function(e,t){var r=t[0],i=t[1],n=t[2],a=t[3],o=r+r,s=i+i,l=n+n,u=r*o,c=i*o,h=i*s,f=n*o,d=n*s,p=n*l,m=a*o,v=a*s,_=a*l;return e[0]=1-h-p,e[1]=c+_,e[2]=f-v,e[3]=0,e[4]=c-_,e[5]=1-u-p,e[6]=d+m,e[7]=0,e[8]=f+v,e[9]=d-m,e[10]=1-u-h,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},E.frustum=function(e,t,r,i,n,a,o){var s=1/(r-t),l=1/(n-i),u=1/(a-o);return e[0]=2*a*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=2*a*l,e[6]=0,e[7]=0,e[8]=(r+t)*s,e[9]=(n+i)*l,e[10]=(o+a)*u,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*a*2*u,e[15]=0,e},E.perspectiveNO=l,E.perspectiveZO=function(e,t,r,i,n){var a,o=1/Math.tan(t/2);return e[0]=o/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=n&&n!==1/0?(e[10]=n*(a=1/(i-n)),e[14]=n*i*a):(e[10]=-1,e[14]=-i),e},E.perspectiveFromFieldOfView=function(e,t,r,i){var n=Math.tan(t.upDegrees*Math.PI/180),a=Math.tan(t.downDegrees*Math.PI/180),o=Math.tan(t.leftDegrees*Math.PI/180),s=Math.tan(t.rightDegrees*Math.PI/180),l=2/(o+s),u=2/(n+a);return e[0]=l,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=u,e[6]=0,e[7]=0,e[8]=-(o-s)*l*.5,e[9]=(n-a)*u*.5,e[10]=i/(r-i),e[11]=-1,e[12]=0,e[13]=0,e[14]=i*r/(r-i),e[15]=0,e},E.orthoNO=u,E.orthoZO=function(e,t,r,i,n,a,o){var s=1/(t-r),l=1/(i-n),u=1/(a-o);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=u,e[11]=0,e[12]=(t+r)*s,e[13]=(n+i)*l,e[14]=a*u,e[15]=1,e},E.lookAt=function(e,r,n,a){var o,s,l,u,c,h,f,d,p,m,v=r[0],_=r[1],g=r[2],y=a[0],x=a[1],b=a[2],w=n[0],k=n[1],T=n[2];return Math.abs(v-w)0&&(c*=d=1/Math.sqrt(d),h*=d,f*=d);var p=l*f-u*h,m=u*c-s*f,v=s*h-l*c;return(d=p*p+m*m+v*v)>0&&(p*=d=1/Math.sqrt(d),m*=d,v*=d),e[0]=p,e[1]=m,e[2]=v,e[3]=0,e[4]=h*v-f*m,e[5]=f*p-c*v,e[6]=c*m-h*p,e[7]=0,e[8]=c,e[9]=h,e[10]=f,e[11]=0,e[12]=n,e[13]=a,e[14]=o,e[15]=1,e},E.str=function(e){return"mat4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+", "+e[8]+", "+e[9]+", "+e[10]+", "+e[11]+", "+e[12]+", "+e[13]+", "+e[14]+", "+e[15]+")"},E.frob=function(e){return Math.hypot(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15])},E.add=function(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e[4]=t[4]+r[4],e[5]=t[5]+r[5],e[6]=t[6]+r[6],e[7]=t[7]+r[7],e[8]=t[8]+r[8],e[9]=t[9]+r[9],e[10]=t[10]+r[10],e[11]=t[11]+r[11],e[12]=t[12]+r[12],e[13]=t[13]+r[13],e[14]=t[14]+r[14],e[15]=t[15]+r[15],e},E.subtract=c,E.multiplyScalar=function(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,e[8]=t[8]*r,e[9]=t[9]*r,e[10]=t[10]*r,e[11]=t[11]*r,e[12]=t[12]*r,e[13]=t[13]*r,e[14]=t[14]*r,e[15]=t[15]*r,e},E.multiplyScalarAndAdd=function(e,t,r,i){return e[0]=t[0]+r[0]*i,e[1]=t[1]+r[1]*i,e[2]=t[2]+r[2]*i,e[3]=t[3]+r[3]*i,e[4]=t[4]+r[4]*i,e[5]=t[5]+r[5]*i,e[6]=t[6]+r[6]*i,e[7]=t[7]+r[7]*i,e[8]=t[8]+r[8]*i,e[9]=t[9]+r[9]*i,e[10]=t[10]+r[10]*i,e[11]=t[11]+r[11]*i,e[12]=t[12]+r[12]*i,e[13]=t[13]+r[13]*i,e[14]=t[14]+r[14]*i,e[15]=t[15]+r[15]*i,e},E.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]},E.equals=function(e,r){var i=e[0],n=e[1],a=e[2],o=e[3],s=e[4],l=e[5],u=e[6],c=e[7],h=e[8],f=e[9],d=e[10],p=e[11],m=e[12],v=e[13],_=e[14],g=e[15],y=r[0],x=r[1],b=r[2],w=r[3],k=r[4],T=r[5],S=r[6],E=r[7],M=r[8],A=r[9],I=r[10],C=r[11],P=r[12],z=r[13],D=r[14],R=r[15];return Math.abs(i-y)<=t.EPSILON*Math.max(1,Math.abs(i),Math.abs(y))&&Math.abs(n-x)<=t.EPSILON*Math.max(1,Math.abs(n),Math.abs(x))&&Math.abs(a-b)<=t.EPSILON*Math.max(1,Math.abs(a),Math.abs(b))&&Math.abs(o-w)<=t.EPSILON*Math.max(1,Math.abs(o),Math.abs(w))&&Math.abs(s-k)<=t.EPSILON*Math.max(1,Math.abs(s),Math.abs(k))&&Math.abs(l-T)<=t.EPSILON*Math.max(1,Math.abs(l),Math.abs(T))&&Math.abs(u-S)<=t.EPSILON*Math.max(1,Math.abs(u),Math.abs(S))&&Math.abs(c-E)<=t.EPSILON*Math.max(1,Math.abs(c),Math.abs(E))&&Math.abs(h-M)<=t.EPSILON*Math.max(1,Math.abs(h),Math.abs(M))&&Math.abs(f-A)<=t.EPSILON*Math.max(1,Math.abs(f),Math.abs(A))&&Math.abs(d-I)<=t.EPSILON*Math.max(1,Math.abs(d),Math.abs(I))&&Math.abs(p-C)<=t.EPSILON*Math.max(1,Math.abs(p),Math.abs(C))&&Math.abs(m-P)<=t.EPSILON*Math.max(1,Math.abs(m),Math.abs(P))&&Math.abs(v-z)<=t.EPSILON*Math.max(1,Math.abs(v),Math.abs(z))&&Math.abs(_-D)<=t.EPSILON*Math.max(1,Math.abs(_),Math.abs(D))&&Math.abs(g-R)<=t.EPSILON*Math.max(1,Math.abs(g),Math.abs(R))},E.sub=E.mul=E.ortho=E.perspective=void 0;var t=(function(t){if(t&&t.__esModule)return t;if(null===t||"object"!==e(t)&&"function"!=typeof t)return{default:t};var i=r(void 0);if(i&&i.has(t))return i.get(t);var n={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in t)if("default"!==o&&Object.prototype.hasOwnProperty.call(t,o)){var s=a?Object.getOwnPropertyDescriptor(t,o):null;s&&(s.get||s.set)?Object.defineProperty(n,o,s):n[o]=t[o]}return n.default=t,i&&i.set(t,n),n})(a());function r(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return(r=function(e){return e?i:t})(e)}function i(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function n(e,t,r){var i=t[0],n=t[1],a=t[2],o=t[3],s=t[4],l=t[5],u=t[6],c=t[7],h=t[8],f=t[9],d=t[10],p=t[11],m=t[12],v=t[13],_=t[14],g=t[15],y=r[0],x=r[1],b=r[2],w=r[3];return e[0]=y*i+x*s+b*h+w*m,e[1]=y*n+x*l+b*f+w*v,e[2]=y*a+x*u+b*d+w*_,e[3]=y*o+x*c+b*p+w*g,e[4]=(y=r[4])*i+(x=r[5])*s+(b=r[6])*h+(w=r[7])*m,e[5]=y*n+x*l+b*f+w*v,e[6]=y*a+x*u+b*d+w*_,e[7]=y*o+x*c+b*p+w*g,e[8]=(y=r[8])*i+(x=r[9])*s+(b=r[10])*h+(w=r[11])*m,e[9]=y*n+x*l+b*f+w*v,e[10]=y*a+x*u+b*d+w*_,e[11]=y*o+x*c+b*p+w*g,e[12]=(y=r[12])*i+(x=r[13])*s+(b=r[14])*h+(w=r[15])*m,e[13]=y*n+x*l+b*f+w*v,e[14]=y*a+x*u+b*d+w*_,e[15]=y*o+x*c+b*p+w*g,e}function o(e,t,r){var i=t[0],n=t[1],a=t[2],o=t[3],s=i+i,l=n+n,u=a+a,c=i*s,h=i*l,f=i*u,d=n*l,p=n*u,m=a*u,v=o*s,_=o*l,g=o*u;return e[0]=1-(d+m),e[1]=h+g,e[2]=f-_,e[3]=0,e[4]=h-g,e[5]=1-(c+m),e[6]=p+v,e[7]=0,e[8]=f+_,e[9]=p-v,e[10]=1-(c+d),e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e}function s(e,t){var r=t[4],i=t[5],n=t[6],a=t[8],o=t[9],s=t[10];return e[0]=Math.hypot(t[0],t[1],t[2]),e[1]=Math.hypot(r,i,n),e[2]=Math.hypot(a,o,s),e}function l(e,t,r,i,n){var a,o=1/Math.tan(t/2);return e[0]=o/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=n&&n!==1/0?(e[10]=(n+i)*(a=1/(i-n)),e[14]=2*n*i*a):(e[10]=-1,e[14]=-2*i),e}function u(e,t,r,i,n,a,o){var s=1/(t-r),l=1/(i-n),u=1/(a-o);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*u,e[11]=0,e[12]=(t+r)*s,e[13]=(n+i)*l,e[14]=(o+a)*u,e[15]=1,e}function c(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e[4]=t[4]-r[4],e[5]=t[5]-r[5],e[6]=t[6]-r[6],e[7]=t[7]-r[7],e[8]=t[8]-r[8],e[9]=t[9]-r[9],e[10]=t[10]-r[10],e[11]=t[11]-r[11],e[12]=t[12]-r[12],e[13]=t[13]-r[13],e[14]=t[14]-r[14],e[15]=t[15]-r[15],e}return E.perspective=l,E.ortho=u,E.mul=n,E.sub=c,E}var A,I={},C={};function P(){if(A)return C;function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}A=1,Object.defineProperty(C,"__esModule",{value:!0}),C.create=i,C.clone=function(e){var r=new t.ARRAY_TYPE(3);return r[0]=e[0],r[1]=e[1],r[2]=e[2],r},C.length=n,C.fromValues=function(e,r,i){var n=new t.ARRAY_TYPE(3);return n[0]=e,n[1]=r,n[2]=i,n},C.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},C.set=function(e,t,r,i){return e[0]=t,e[1]=r,e[2]=i,e},C.add=function(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e},C.subtract=o,C.multiply=s,C.divide=l,C.ceil=function(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e},C.floor=function(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e},C.min=function(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e[2]=Math.min(t[2],r[2]),e},C.max=function(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e[2]=Math.max(t[2],r[2]),e},C.round=function(e,t){return e[0]=Math.round(t[0]),e[1]=Math.round(t[1]),e[2]=Math.round(t[2]),e},C.scale=function(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e},C.scaleAndAdd=function(e,t,r,i){return e[0]=t[0]+r[0]*i,e[1]=t[1]+r[1]*i,e[2]=t[2]+r[2]*i,e},C.distance=u,C.squaredDistance=c,C.squaredLength=h,C.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e},C.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e},C.normalize=function(e,t){var r=t[0],i=t[1],n=t[2],a=r*r+i*i+n*n;return a>0&&(a=1/Math.sqrt(a)),e[0]=t[0]*a,e[1]=t[1]*a,e[2]=t[2]*a,e},C.dot=f,C.cross=function(e,t,r){var i=t[0],n=t[1],a=t[2],o=r[0],s=r[1],l=r[2];return e[0]=n*l-a*s,e[1]=a*o-i*l,e[2]=i*s-n*o,e},C.lerp=function(e,t,r,i){var n=t[0],a=t[1],o=t[2];return e[0]=n+i*(r[0]-n),e[1]=a+i*(r[1]-a),e[2]=o+i*(r[2]-o),e},C.hermite=function(e,t,r,i,n,a){var o=a*a,s=o*(2*a-3)+1,l=o*(a-2)+a,u=o*(a-1),c=o*(3-2*a);return e[0]=t[0]*s+r[0]*l+i[0]*u+n[0]*c,e[1]=t[1]*s+r[1]*l+i[1]*u+n[1]*c,e[2]=t[2]*s+r[2]*l+i[2]*u+n[2]*c,e},C.bezier=function(e,t,r,i,n,a){var o=1-a,s=o*o,l=a*a,u=s*o,c=3*a*s,h=3*l*o,f=l*a;return e[0]=t[0]*u+r[0]*c+i[0]*h+n[0]*f,e[1]=t[1]*u+r[1]*c+i[1]*h+n[1]*f,e[2]=t[2]*u+r[2]*c+i[2]*h+n[2]*f,e},C.random=function(e,r){r=r||1;var i=2*t.RANDOM()*Math.PI,n=2*t.RANDOM()-1,a=Math.sqrt(1-n*n)*r;return e[0]=Math.cos(i)*a,e[1]=Math.sin(i)*a,e[2]=n*r,e},C.transformMat4=function(e,t,r){var i=t[0],n=t[1],a=t[2],o=r[3]*i+r[7]*n+r[11]*a+r[15];return e[0]=(r[0]*i+r[4]*n+r[8]*a+r[12])/(o=o||1),e[1]=(r[1]*i+r[5]*n+r[9]*a+r[13])/o,e[2]=(r[2]*i+r[6]*n+r[10]*a+r[14])/o,e},C.transformMat3=function(e,t,r){var i=t[0],n=t[1],a=t[2];return e[0]=i*r[0]+n*r[3]+a*r[6],e[1]=i*r[1]+n*r[4]+a*r[7],e[2]=i*r[2]+n*r[5]+a*r[8],e},C.transformQuat=function(e,t,r){var i=r[0],n=r[1],a=r[2],o=t[0],s=t[1],l=t[2],u=n*l-a*s,c=a*o-i*l,h=i*s-n*o,f=n*h-a*c,d=a*u-i*h,p=i*c-n*u,m=2*r[3];return c*=m,h*=m,d*=2,p*=2,e[0]=o+(u*=m)+(f*=2),e[1]=s+c+d,e[2]=l+h+p,e},C.rotateX=function(e,t,r,i){var n=[],a=[];return n[0]=t[0]-r[0],n[1]=t[1]-r[1],n[2]=t[2]-r[2],a[0]=n[0],a[1]=n[1]*Math.cos(i)-n[2]*Math.sin(i),a[2]=n[1]*Math.sin(i)+n[2]*Math.cos(i),e[0]=a[0]+r[0],e[1]=a[1]+r[1],e[2]=a[2]+r[2],e},C.rotateY=function(e,t,r,i){var n=[],a=[];return n[0]=t[0]-r[0],n[1]=t[1]-r[1],n[2]=t[2]-r[2],a[0]=n[2]*Math.sin(i)+n[0]*Math.cos(i),a[1]=n[1],a[2]=n[2]*Math.cos(i)-n[0]*Math.sin(i),e[0]=a[0]+r[0],e[1]=a[1]+r[1],e[2]=a[2]+r[2],e},C.rotateZ=function(e,t,r,i){var n=[],a=[];return n[0]=t[0]-r[0],n[1]=t[1]-r[1],n[2]=t[2]-r[2],a[0]=n[0]*Math.cos(i)-n[1]*Math.sin(i),a[1]=n[0]*Math.sin(i)+n[1]*Math.cos(i),a[2]=n[2],e[0]=a[0]+r[0],e[1]=a[1]+r[1],e[2]=a[2]+r[2],e},C.angle=function(e,t){var r=e[0],i=e[1],n=e[2],a=t[0],o=t[1],s=t[2],l=Math.sqrt(r*r+i*i+n*n)*Math.sqrt(a*a+o*o+s*s),u=l&&f(e,t)/l;return Math.acos(Math.min(Math.max(u,-1),1))},C.zero=function(e){return e[0]=0,e[1]=0,e[2]=0,e},C.str=function(e){return"vec3("+e[0]+", "+e[1]+", "+e[2]+")"},C.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]},C.equals=function(e,r){var i=e[0],n=e[1],a=e[2],o=r[0],s=r[1],l=r[2];return Math.abs(i-o)<=t.EPSILON*Math.max(1,Math.abs(i),Math.abs(o))&&Math.abs(n-s)<=t.EPSILON*Math.max(1,Math.abs(n),Math.abs(s))&&Math.abs(a-l)<=t.EPSILON*Math.max(1,Math.abs(a),Math.abs(l))},C.forEach=C.sqrLen=C.len=C.sqrDist=C.dist=C.div=C.mul=C.sub=void 0;var t=(function(t){if(t&&t.__esModule)return t;if(null===t||"object"!==e(t)&&"function"!=typeof t)return{default:t};var i=r(void 0);if(i&&i.has(t))return i.get(t);var n={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in t)if("default"!==o&&Object.prototype.hasOwnProperty.call(t,o)){var s=a?Object.getOwnPropertyDescriptor(t,o):null;s&&(s.get||s.set)?Object.defineProperty(n,o,s):n[o]=t[o]}return n.default=t,i&&i.set(t,n),n})(a());function r(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return(r=function(e){return e?i:t})(e)}function i(){var e=new t.ARRAY_TYPE(3);return t.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function n(e){return Math.hypot(e[0],e[1],e[2])}function o(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e}function s(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e}function l(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e[2]=t[2]/r[2],e}function u(e,t){return Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2])}function c(e,t){var r=t[0]-e[0],i=t[1]-e[1],n=t[2]-e[2];return r*r+i*i+n*n}function h(e){var t=e[0],r=e[1],i=e[2];return t*t+r*r+i*i}function f(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}C.sub=o,C.mul=s,C.div=l,C.dist=u,C.sqrDist=c,C.len=n,C.sqrLen=h;var d,p=(d=i(),function(e,t,r,i,n,a){var o,s;for(t||(t=3),r||(r=0),s=i?Math.min(i*t+r,e.length):e.length,o=r;o0&&(o=1/Math.sqrt(o)),e[0]=r*o,e[1]=i*o,e[2]=n*o,e[3]=a*o,e},R.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},R.cross=function(e,t,r,i){var n=r[0]*i[1]-r[1]*i[0],a=r[0]*i[2]-r[2]*i[0],o=r[0]*i[3]-r[3]*i[0],s=r[1]*i[2]-r[2]*i[1],l=r[1]*i[3]-r[3]*i[1],u=r[2]*i[3]-r[3]*i[2],c=t[0],h=t[1],f=t[2],d=t[3];return e[0]=h*u-f*l+d*s,e[1]=-c*u+f*o-d*a,e[2]=c*l-h*o+d*n,e[3]=-c*s+h*a-f*n,e},R.lerp=function(e,t,r,i){var n=t[0],a=t[1],o=t[2],s=t[3];return e[0]=n+i*(r[0]-n),e[1]=a+i*(r[1]-a),e[2]=o+i*(r[2]-o),e[3]=s+i*(r[3]-s),e},R.random=function(e,r){var i,n,a,o,s,l;r=r||1;do{s=(i=2*t.RANDOM()-1)*i+(n=2*t.RANDOM()-1)*n}while(s>=1);do{l=(a=2*t.RANDOM()-1)*a+(o=2*t.RANDOM()-1)*o}while(l>=1);var u=Math.sqrt((1-s)/l);return e[0]=r*i,e[1]=r*n,e[2]=r*a*u,e[3]=r*o*u,e},R.transformMat4=function(e,t,r){var i=t[0],n=t[1],a=t[2],o=t[3];return e[0]=r[0]*i+r[4]*n+r[8]*a+r[12]*o,e[1]=r[1]*i+r[5]*n+r[9]*a+r[13]*o,e[2]=r[2]*i+r[6]*n+r[10]*a+r[14]*o,e[3]=r[3]*i+r[7]*n+r[11]*a+r[15]*o,e},R.transformQuat=function(e,t,r){var i=t[0],n=t[1],a=t[2],o=r[0],s=r[1],l=r[2],u=r[3],c=u*i+s*a-l*n,h=u*n+l*i-o*a,f=u*a+o*n-s*i,d=-o*i-s*n-l*a;return e[0]=c*u+d*-o+h*-l-f*-s,e[1]=h*u+d*-s+f*-o-c*-l,e[2]=f*u+d*-l+c*-s-h*-o,e[3]=t[3],e},R.zero=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e},R.str=function(e){return"vec4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},R.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]},R.equals=function(e,r){var i=e[0],n=e[1],a=e[2],o=e[3],s=r[0],l=r[1],u=r[2],c=r[3];return Math.abs(i-s)<=t.EPSILON*Math.max(1,Math.abs(i),Math.abs(s))&&Math.abs(n-l)<=t.EPSILON*Math.max(1,Math.abs(n),Math.abs(l))&&Math.abs(a-u)<=t.EPSILON*Math.max(1,Math.abs(a),Math.abs(u))&&Math.abs(o-c)<=t.EPSILON*Math.max(1,Math.abs(o),Math.abs(c))},R.forEach=R.sqrLen=R.len=R.sqrDist=R.dist=R.div=R.mul=R.sub=void 0;var t=(function(t){if(t&&t.__esModule)return t;if(null===t||"object"!==e(t)&&"function"!=typeof t)return{default:t};var i=r(void 0);if(i&&i.has(t))return i.get(t);var n={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in t)if("default"!==o&&Object.prototype.hasOwnProperty.call(t,o)){var s=a?Object.getOwnPropertyDescriptor(t,o):null;s&&(s.get||s.set)?Object.defineProperty(n,o,s):n[o]=t[o]}return n.default=t,i&&i.set(t,n),n})(a());function r(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return(r=function(e){return e?i:t})(e)}function i(){var e=new t.ARRAY_TYPE(4);return t.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function n(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e}function o(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e[3]=t[3]*r[3],e}function s(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e[2]=t[2]/r[2],e[3]=t[3]/r[3],e}function l(e,t){return Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2],t[3]-e[3])}function u(e,t){var r=t[0]-e[0],i=t[1]-e[1],n=t[2]-e[2],a=t[3]-e[3];return r*r+i*i+n*n+a*a}function c(e){return Math.hypot(e[0],e[1],e[2],e[3])}function h(e){var t=e[0],r=e[1],i=e[2],n=e[3];return t*t+r*r+i*i+n*n}R.sub=n,R.mul=o,R.div=s,R.dist=l,R.sqrDist=u,R.len=c,R.sqrLen=h;var f,d=(f=i(),function(e,t,r,i,n,a){var o,s;for(t||(t=4),r||(r=0),s=i?Math.min(i*t+r,e.length):e.length,o=r;ot.EPSILON?(e[0]=r[0]/n,e[1]=r[1]/n,e[2]=r[2]/n):(e[0]=1,e[1]=0,e[2]=0),i},I.getAngle=function(e,t){var r=v(e,t);return Math.acos(2*r*r-1)},I.multiply=c,I.rotateX=function(e,t,r){r*=.5;var i=t[0],n=t[1],a=t[2],o=t[3],s=Math.sin(r),l=Math.cos(r);return e[0]=i*l+o*s,e[1]=n*l+a*s,e[2]=a*l-n*s,e[3]=o*l-i*s,e},I.rotateY=function(e,t,r){r*=.5;var i=t[0],n=t[1],a=t[2],o=t[3],s=Math.sin(r),l=Math.cos(r);return e[0]=i*l-a*s,e[1]=n*l+o*s,e[2]=a*l+i*s,e[3]=o*l-n*s,e},I.rotateZ=function(e,t,r){r*=.5;var i=t[0],n=t[1],a=t[2],o=t[3],s=Math.sin(r),l=Math.cos(r);return e[0]=i*l+n*s,e[1]=n*l-i*s,e[2]=a*l+o*s,e[3]=o*l-a*s,e},I.calculateW=function(e,t){var r=t[0],i=t[1],n=t[2];return e[0]=r,e[1]=i,e[2]=n,e[3]=Math.sqrt(Math.abs(1-r*r-i*i-n*n)),e},I.exp=h,I.ln=f,I.pow=function(e,t,r){return f(e,t),m(e,e,r),h(e,e),e},I.slerp=d,I.random=function(e){var r=t.RANDOM(),i=t.RANDOM(),n=t.RANDOM(),a=Math.sqrt(1-r),o=Math.sqrt(r);return e[0]=a*Math.sin(2*Math.PI*i),e[1]=a*Math.cos(2*Math.PI*i),e[2]=o*Math.sin(2*Math.PI*n),e[3]=o*Math.cos(2*Math.PI*n),e},I.invert=function(e,t){var r=t[0],i=t[1],n=t[2],a=t[3],o=r*r+i*i+n*n+a*a,s=o?1/o:0;return e[0]=-r*s,e[1]=-i*s,e[2]=-n*s,e[3]=a*s,e},I.conjugate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},I.fromMat3=p,I.fromEuler=function(e,t,r,i){var n=.5*Math.PI/180;t*=n,r*=n,i*=n;var a=Math.sin(t),o=Math.cos(t),s=Math.sin(r),l=Math.cos(r),u=Math.sin(i),c=Math.cos(i);return e[0]=a*l*c-o*s*u,e[1]=o*s*c+a*l*u,e[2]=o*l*u-a*s*c,e[3]=o*l*c+a*s*u,e},I.str=function(e){return"quat("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},I.setAxes=I.sqlerp=I.rotationTo=I.equals=I.exactEquals=I.normalize=I.sqrLen=I.squaredLength=I.len=I.length=I.lerp=I.dot=I.scale=I.mul=I.add=I.set=I.copy=I.fromValues=I.clone=void 0;var t=s(a()),r=s(w()),i=s(P()),n=s(L());function o(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(o=function(e){return e?r:t})(e)}function s(t,r){if(t&&t.__esModule)return t;if(null===t||"object"!==e(t)&&"function"!=typeof t)return{default:t};var i=o(r);if(i&&i.has(t))return i.get(t);var n={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if("default"!==s&&Object.prototype.hasOwnProperty.call(t,s)){var l=a?Object.getOwnPropertyDescriptor(t,s):null;l&&(l.get||l.set)?Object.defineProperty(n,s,l):n[s]=t[s]}return n.default=t,i&&i.set(t,n),n}function l(){var e=new t.ARRAY_TYPE(4);return t.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function u(e,t,r){r*=.5;var i=Math.sin(r);return e[0]=i*t[0],e[1]=i*t[1],e[2]=i*t[2],e[3]=Math.cos(r),e}function c(e,t,r){var i=t[0],n=t[1],a=t[2],o=t[3],s=r[0],l=r[1],u=r[2],c=r[3];return e[0]=i*c+o*s+n*u-a*l,e[1]=n*c+o*l+a*s-i*u,e[2]=a*c+o*u+i*l-n*s,e[3]=o*c-i*s-n*l-a*u,e}function h(e,t){var r=t[0],i=t[1],n=t[2],a=t[3],o=Math.sqrt(r*r+i*i+n*n),s=Math.exp(a),l=o>0?s*Math.sin(o)/o:0;return e[0]=r*l,e[1]=i*l,e[2]=n*l,e[3]=s*Math.cos(o),e}function f(e,t){var r=t[0],i=t[1],n=t[2],a=t[3],o=Math.sqrt(r*r+i*i+n*n),s=o>0?Math.atan2(o,a)/o:0;return e[0]=r*s,e[1]=i*s,e[2]=n*s,e[3]=.5*Math.log(r*r+i*i+n*n+a*a),e}function d(e,r,i,n){var a,o,s,l,u,c=r[0],h=r[1],f=r[2],d=r[3],p=i[0],m=i[1],v=i[2],_=i[3];return(o=c*p+h*m+f*v+d*_)<0&&(o=-o,p=-p,m=-m,v=-v,_=-_),1-o>t.EPSILON?(a=Math.acos(o),s=Math.sin(a),l=Math.sin((1-n)*a)/s,u=Math.sin(n*a)/s):(l=1-n,u=n),e[0]=l*c+u*p,e[1]=l*h+u*m,e[2]=l*f+u*v,e[3]=l*d+u*_,e}function p(e,t){var r,i=t[0]+t[4]+t[8];if(i>0)r=Math.sqrt(i+1),e[3]=.5*r,e[0]=(t[5]-t[7])*(r=.5/r),e[1]=(t[6]-t[2])*r,e[2]=(t[1]-t[3])*r;else{var n=0;t[4]>t[0]&&(n=1),t[8]>t[3*n+n]&&(n=2);var a=(n+1)%3,o=(n+2)%3;r=Math.sqrt(t[3*n+n]-t[3*a+a]-t[3*o+o]+1),e[n]=.5*r,e[3]=(t[3*a+o]-t[3*o+a])*(r=.5/r),e[a]=(t[3*a+n]+t[3*n+a])*r,e[o]=(t[3*o+n]+t[3*n+o])*r}return e}I.clone=n.clone,I.fromValues=n.fromValues,I.copy=n.copy,I.set=n.set,I.add=n.add,I.mul=c;var m=n.scale;I.scale=m;var v=n.dot;I.dot=v,I.lerp=n.lerp;var _=n.length;I.length=_,I.len=_;var g=n.squaredLength;I.squaredLength=g,I.sqrLen=g;var y=n.normalize;I.normalize=y,I.exactEquals=n.exactEquals,I.equals=n.equals;var x,b,k,T=(x=i.create(),b=i.fromValues(1,0,0),k=i.fromValues(0,1,0),function(e,t,r){var n=i.dot(t,r);return n<-.999999?(i.cross(x,b,t),i.len(x)<1e-6&&i.cross(x,k,t),i.normalize(x,x),u(e,x,Math.PI),e):n>.999999?(e[0]=0,e[1]=0,e[2]=0,e[3]=1,e):(i.cross(x,t,r),e[0]=x[0],e[1]=x[1],e[2]=x[2],e[3]=1+n,y(e,e))});I.rotationTo=T;var S,E,M=(S=l(),E=l(),function(e,t,r,i,n,a){return d(S,t,n,a),d(E,r,i,a),d(e,S,E,2*a*(1-a)),e});I.sqlerp=M;var A,C=(A=r.create(),function(e,t,r,i){return A[0]=r[0],A[3]=r[1],A[6]=r[2],A[1]=i[0],A[4]=i[1],A[7]=i[2],A[2]=-t[0],A[5]=-t[1],A[8]=-t[2],y(e,p(e,A))});return I.setAxes=C,I}var F,B={};function N(){if(F)return B;function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}F=1,Object.defineProperty(B,"__esModule",{value:!0}),B.create=function(){var e=new t.ARRAY_TYPE(8);return t.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[4]=0,e[5]=0,e[6]=0,e[7]=0),e[3]=1,e},B.clone=function(e){var r=new t.ARRAY_TYPE(8);return r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=e[3],r[4]=e[4],r[5]=e[5],r[6]=e[6],r[7]=e[7],r},B.fromValues=function(e,r,i,n,a,o,s,l){var u=new t.ARRAY_TYPE(8);return u[0]=e,u[1]=r,u[2]=i,u[3]=n,u[4]=a,u[5]=o,u[6]=s,u[7]=l,u},B.fromRotationTranslationValues=function(e,r,i,n,a,o,s){var l=new t.ARRAY_TYPE(8);l[0]=e,l[1]=r,l[2]=i,l[3]=n;var u=.5*a,c=.5*o,h=.5*s;return l[4]=u*n+c*i-h*r,l[5]=c*n+h*e-u*i,l[6]=h*n+u*r-c*e,l[7]=-u*e-c*r-h*i,l},B.fromRotationTranslation=s,B.fromTranslation=function(e,t){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e[4]=.5*t[0],e[5]=.5*t[1],e[6]=.5*t[2],e[7]=0,e},B.fromRotation=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=0,e[5]=0,e[6]=0,e[7]=0,e},B.fromMat4=function(e,n){var a=r.create();i.getRotation(a,n);var o=new t.ARRAY_TYPE(3);return i.getTranslation(o,n),s(e,a,o),e},B.copy=l,B.identity=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e[6]=0,e[7]=0,e},B.set=function(e,t,r,i,n,a,o,s,l){return e[0]=t,e[1]=r,e[2]=i,e[3]=n,e[4]=a,e[5]=o,e[6]=s,e[7]=l,e},B.getDual=function(e,t){return e[0]=t[4],e[1]=t[5],e[2]=t[6],e[3]=t[7],e},B.setDual=function(e,t){return e[4]=t[0],e[5]=t[1],e[6]=t[2],e[7]=t[3],e},B.getTranslation=function(e,t){var r=t[4],i=t[5],n=t[6],a=t[7],o=-t[0],s=-t[1],l=-t[2],u=t[3];return e[0]=2*(r*u+a*o+i*l-n*s),e[1]=2*(i*u+a*s+n*o-r*l),e[2]=2*(n*u+a*l+r*s-i*o),e},B.translate=function(e,t,r){var i=t[0],n=t[1],a=t[2],o=t[3],s=.5*r[0],l=.5*r[1],u=.5*r[2],c=t[4],h=t[5],f=t[6],d=t[7];return e[0]=i,e[1]=n,e[2]=a,e[3]=o,e[4]=o*s+n*u-a*l+c,e[5]=o*l+a*s-i*u+h,e[6]=o*u+i*l-n*s+f,e[7]=-i*s-n*l-a*u+d,e},B.rotateX=function(e,t,i){var n=-t[0],a=-t[1],o=-t[2],s=t[3],l=t[4],u=t[5],c=t[6],h=t[7],f=l*s+h*n+u*o-c*a,d=u*s+h*a+c*n-l*o,p=c*s+h*o+l*a-u*n,m=h*s-l*n-u*a-c*o;return r.rotateX(e,t,i),e[4]=f*(s=e[3])+m*(n=e[0])+d*(o=e[2])-p*(a=e[1]),e[5]=d*s+m*a+p*n-f*o,e[6]=p*s+m*o+f*a-d*n,e[7]=m*s-f*n-d*a-p*o,e},B.rotateY=function(e,t,i){var n=-t[0],a=-t[1],o=-t[2],s=t[3],l=t[4],u=t[5],c=t[6],h=t[7],f=l*s+h*n+u*o-c*a,d=u*s+h*a+c*n-l*o,p=c*s+h*o+l*a-u*n,m=h*s-l*n-u*a-c*o;return r.rotateY(e,t,i),e[4]=f*(s=e[3])+m*(n=e[0])+d*(o=e[2])-p*(a=e[1]),e[5]=d*s+m*a+p*n-f*o,e[6]=p*s+m*o+f*a-d*n,e[7]=m*s-f*n-d*a-p*o,e},B.rotateZ=function(e,t,i){var n=-t[0],a=-t[1],o=-t[2],s=t[3],l=t[4],u=t[5],c=t[6],h=t[7],f=l*s+h*n+u*o-c*a,d=u*s+h*a+c*n-l*o,p=c*s+h*o+l*a-u*n,m=h*s-l*n-u*a-c*o;return r.rotateZ(e,t,i),e[4]=f*(s=e[3])+m*(n=e[0])+d*(o=e[2])-p*(a=e[1]),e[5]=d*s+m*a+p*n-f*o,e[6]=p*s+m*o+f*a-d*n,e[7]=m*s-f*n-d*a-p*o,e},B.rotateByQuatAppend=function(e,t,r){var i=r[0],n=r[1],a=r[2],o=r[3],s=t[0],l=t[1],u=t[2],c=t[3];return e[0]=s*o+c*i+l*a-u*n,e[1]=l*o+c*n+u*i-s*a,e[2]=u*o+c*a+s*n-l*i,e[3]=c*o-s*i-l*n-u*a,e[4]=(s=t[4])*o+(c=t[7])*i+(l=t[5])*a-(u=t[6])*n,e[5]=l*o+c*n+u*i-s*a,e[6]=u*o+c*a+s*n-l*i,e[7]=c*o-s*i-l*n-u*a,e},B.rotateByQuatPrepend=function(e,t,r){var i=t[0],n=t[1],a=t[2],o=t[3],s=r[0],l=r[1],u=r[2],c=r[3];return e[0]=i*c+o*s+n*u-a*l,e[1]=n*c+o*l+a*s-i*u,e[2]=a*c+o*u+i*l-n*s,e[3]=o*c-i*s-n*l-a*u,e[4]=i*(c=r[7])+o*(s=r[4])+n*(u=r[6])-a*(l=r[5]),e[5]=n*c+o*l+a*s-i*u,e[6]=a*c+o*u+i*l-n*s,e[7]=o*c-i*s-n*l-a*u,e},B.rotateAroundAxis=function(e,r,i,n){if(Math.abs(n)0){r=Math.sqrt(r);var i=t[0]/r,n=t[1]/r,a=t[2]/r,o=t[3]/r,s=t[4],l=t[5],u=t[6],c=t[7],h=i*s+n*l+a*u+o*c;e[0]=i,e[1]=n,e[2]=a,e[3]=o,e[4]=(s-i*h)/r,e[5]=(l-n*h)/r,e[6]=(u-a*h)/r,e[7]=(c-o*h)/r}return e},B.str=function(e){return"quat2("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+")"},B.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]},B.equals=function(e,r){var i=e[0],n=e[1],a=e[2],o=e[3],s=e[4],l=e[5],u=e[6],c=e[7],h=r[0],f=r[1],d=r[2],p=r[3],m=r[4],v=r[5],_=r[6],g=r[7];return Math.abs(i-h)<=t.EPSILON*Math.max(1,Math.abs(i),Math.abs(h))&&Math.abs(n-f)<=t.EPSILON*Math.max(1,Math.abs(n),Math.abs(f))&&Math.abs(a-d)<=t.EPSILON*Math.max(1,Math.abs(a),Math.abs(d))&&Math.abs(o-p)<=t.EPSILON*Math.max(1,Math.abs(o),Math.abs(p))&&Math.abs(s-m)<=t.EPSILON*Math.max(1,Math.abs(s),Math.abs(m))&&Math.abs(l-v)<=t.EPSILON*Math.max(1,Math.abs(l),Math.abs(v))&&Math.abs(u-_)<=t.EPSILON*Math.max(1,Math.abs(u),Math.abs(_))&&Math.abs(c-g)<=t.EPSILON*Math.max(1,Math.abs(c),Math.abs(g))},B.sqrLen=B.squaredLength=B.len=B.length=B.dot=B.mul=B.setReal=B.getReal=void 0;var t=o(a()),r=o(O()),i=o(M());function n(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(n=function(e){return e?r:t})(e)}function o(t,r){if(t&&t.__esModule)return t;if(null===t||"object"!==e(t)&&"function"!=typeof t)return{default:t};var i=n(r);if(i&&i.has(t))return i.get(t);var a={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if("default"!==s&&Object.prototype.hasOwnProperty.call(t,s)){var l=o?Object.getOwnPropertyDescriptor(t,s):null;l&&(l.get||l.set)?Object.defineProperty(a,s,l):a[s]=t[s]}return a.default=t,i&&i.set(t,a),a}function s(e,t,r){var i=.5*r[0],n=.5*r[1],a=.5*r[2],o=t[0],s=t[1],l=t[2],u=t[3];return e[0]=o,e[1]=s,e[2]=l,e[3]=u,e[4]=i*u+n*l-a*s,e[5]=n*u+a*o-i*l,e[6]=a*u+i*s-n*o,e[7]=-i*o-n*s-a*l,e}function l(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e}function u(e,t,r){var i=t[0],n=t[1],a=t[2],o=t[3],s=r[4],l=r[5],u=r[6],c=r[7],h=t[4],f=t[5],d=t[6],p=t[7],m=r[0],v=r[1],_=r[2],g=r[3];return e[0]=i*g+o*m+n*_-a*v,e[1]=n*g+o*v+a*m-i*_,e[2]=a*g+o*_+i*v-n*m,e[3]=o*g-i*m-n*v-a*_,e[4]=i*c+o*s+n*u-a*l+h*g+p*m+f*_-d*v,e[5]=n*c+o*l+a*s-i*u+f*g+p*v+d*m-h*_,e[6]=a*c+o*u+i*l-n*s+d*g+p*_+h*v-f*m,e[7]=o*c-i*s-n*l-a*u+p*g-h*m-f*v-d*_,e}B.getReal=r.copy,B.setReal=r.copy,B.mul=u;var c=r.dot;B.dot=c;var h=r.length;B.length=h,B.len=h;var f=r.squaredLength;return B.squaredLength=f,B.sqrLen=f,B}var V,U,j={};function G(){if(V)return j;function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}V=1,Object.defineProperty(j,"__esModule",{value:!0}),j.create=i,j.clone=function(e){var r=new t.ARRAY_TYPE(2);return r[0]=e[0],r[1]=e[1],r},j.fromValues=function(e,r){var i=new t.ARRAY_TYPE(2);return i[0]=e,i[1]=r,i},j.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e},j.set=function(e,t,r){return e[0]=t,e[1]=r,e},j.add=function(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e},j.subtract=n,j.multiply=o,j.divide=s,j.ceil=function(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e},j.floor=function(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e},j.min=function(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e},j.max=function(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e},j.round=function(e,t){return e[0]=Math.round(t[0]),e[1]=Math.round(t[1]),e},j.scale=function(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e},j.scaleAndAdd=function(e,t,r,i){return e[0]=t[0]+r[0]*i,e[1]=t[1]+r[1]*i,e},j.distance=l,j.squaredDistance=u,j.length=c,j.squaredLength=h,j.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e},j.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e},j.normalize=function(e,t){var r=t[0],i=t[1],n=r*r+i*i;return n>0&&(n=1/Math.sqrt(n)),e[0]=t[0]*n,e[1]=t[1]*n,e},j.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]},j.cross=function(e,t,r){var i=t[0]*r[1]-t[1]*r[0];return e[0]=e[1]=0,e[2]=i,e},j.lerp=function(e,t,r,i){var n=t[0],a=t[1];return e[0]=n+i*(r[0]-n),e[1]=a+i*(r[1]-a),e},j.random=function(e,r){r=r||1;var i=2*t.RANDOM()*Math.PI;return e[0]=Math.cos(i)*r,e[1]=Math.sin(i)*r,e},j.transformMat2=function(e,t,r){var i=t[0],n=t[1];return e[0]=r[0]*i+r[2]*n,e[1]=r[1]*i+r[3]*n,e},j.transformMat2d=function(e,t,r){var i=t[0],n=t[1];return e[0]=r[0]*i+r[2]*n+r[4],e[1]=r[1]*i+r[3]*n+r[5],e},j.transformMat3=function(e,t,r){var i=t[0],n=t[1];return e[0]=r[0]*i+r[3]*n+r[6],e[1]=r[1]*i+r[4]*n+r[7],e},j.transformMat4=function(e,t,r){var i=t[0],n=t[1];return e[0]=r[0]*i+r[4]*n+r[12],e[1]=r[1]*i+r[5]*n+r[13],e},j.rotate=function(e,t,r,i){var n=t[0]-r[0],a=t[1]-r[1],o=Math.sin(i),s=Math.cos(i);return e[0]=n*s-a*o+r[0],e[1]=n*o+a*s+r[1],e},j.angle=function(e,t){var r=e[0],i=e[1],n=t[0],a=t[1],o=Math.sqrt(r*r+i*i)*Math.sqrt(n*n+a*a);return Math.acos(Math.min(Math.max(o&&(r*n+i*a)/o,-1),1))},j.zero=function(e){return e[0]=0,e[1]=0,e},j.str=function(e){return"vec2("+e[0]+", "+e[1]+")"},j.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]},j.equals=function(e,r){var i=e[0],n=e[1],a=r[0],o=r[1];return Math.abs(i-a)<=t.EPSILON*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(n-o)<=t.EPSILON*Math.max(1,Math.abs(n),Math.abs(o))},j.forEach=j.sqrLen=j.sqrDist=j.dist=j.div=j.mul=j.sub=j.len=void 0;var t=(function(t){if(t&&t.__esModule)return t;if(null===t||"object"!==e(t)&&"function"!=typeof t)return{default:t};var i=r(void 0);if(i&&i.has(t))return i.get(t);var n={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in t)if("default"!==o&&Object.prototype.hasOwnProperty.call(t,o)){var s=a?Object.getOwnPropertyDescriptor(t,o):null;s&&(s.get||s.set)?Object.defineProperty(n,o,s):n[o]=t[o]}return n.default=t,i&&i.set(t,n),n})(a());function r(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return(r=function(e){return e?i:t})(e)}function i(){var e=new t.ARRAY_TYPE(2);return t.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0),e}function n(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e}function o(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e}function s(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e}function l(e,t){return Math.hypot(t[0]-e[0],t[1]-e[1])}function u(e,t){var r=t[0]-e[0],i=t[1]-e[1];return r*r+i*i}function c(e){return Math.hypot(e[0],e[1])}function h(e){var t=e[0],r=e[1];return t*t+r*r}j.len=c,j.sub=n,j.mul=o,j.div=s,j.dist=l,j.sqrDist=u,j.sqrLen=h;var f,d=(f=i(),function(e,t,r,i,n,a){var o,s;for(t||(t=2),r||(r=0),s=i?Math.min(i*t+r,e.length):e.length,o=r;o1)return 1;for(var r=e,i=0;i<8;i++){var n=this.sampleCurveX(r)-e;if(Math.abs(n)n?o=r:s=r,r=.5*(s-o)+o;return r},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}},q})(),Y=t(X);function J(){if(H)return $;function e(e,t){this.x=e,this.y=t}return H=1,$=e,e.prototype={clone:function(){return new e(this.x,this.y)},add:function(e){return this.clone()._add(e)},sub:function(e){return this.clone()._sub(e)},multByPoint:function(e){return this.clone()._multByPoint(e)},divByPoint:function(e){return this.clone()._divByPoint(e)},mult:function(e){return this.clone()._mult(e)},div:function(e){return this.clone()._div(e)},rotate:function(e){return this.clone()._rotate(e)},rotateAround:function(e,t){return this.clone()._rotateAround(e,t)},matMult:function(e){return this.clone()._matMult(e)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(e){return this.x===e.x&&this.y===e.y},dist:function(e){return Math.sqrt(this.distSqr(e))},distSqr:function(e){var t=e.x-this.x,r=e.y-this.y;return t*t+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith:function(e){return this.angleWithSep(e.x,e.y)},angleWithSep:function(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult:function(e){var t=e[2]*this.x+e[3]*this.y;return this.x=e[0]*this.x+e[1]*this.y,this.y=t,this},_add:function(e){return this.x+=e.x,this.y+=e.y,this},_sub:function(e){return this.x-=e.x,this.y-=e.y,this},_mult:function(e){return this.x*=e,this.y*=e,this},_div:function(e){return this.x/=e,this.y/=e,this},_multByPoint:function(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint:function(e){return this.x/=e.x,this.y/=e.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var e=this.y;return this.y=this.x,this.x=-e,this},_rotate:function(e){var t=Math.cos(e),r=Math.sin(e),i=r*this.x+t*this.y;return this.x=t*this.x-r*this.y,this.y=i,this},_rotateAround:function(e,t){var r=Math.cos(e),i=Math.sin(e),n=t.y+i*(this.x-t.x)+r*(this.y-t.y);return this.x=t.x+r*(this.x-t.x)-i*(this.y-t.y),this.y=n,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},e.convert=function(t){return t instanceof e?t:Array.isArray(t)?new e(t[0],t[1]):t},$}var K=t(J());function Q(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(var r=0;r=1)return 1;var t=e*e,r=t*e;return 4*(e<.5?r:3*(e-t)+r-.75)}function oe(e,t,r,i){var n=new Y(e,t,r,i);return function(e){return n.solve(e)}}var se=oe(.25,.1,.25,1);function le(e,t,r){return Math.min(r,Math.max(t,e))}function ue(e,t,r){return(r=le((r-e)/(t-e),0,1))*r*(3-2*r)}function ce(e,t,r){var i=r-t,n=((e-t)%i+i)%i+t;return n===t?r:n}function he(e,t,r){if(!e.length)return r(null,[]);var i=e.length,n=new Array(e.length),a=null;e.forEach((function(e,o){t(e,(function(e,t){e&&(a=e),n[o]=t,0==--i&&r(a,n)}))}))}function fe(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i(t.y-e.y)*(r.x-e.x)}function Te(e){for(var t,r,i=0,n=0,a=e.length,o=a-1;n@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(function(e,r,i,n){var a=i||n;return t[r]=!a||a.toLowerCase(),""})),t["max-age"]){var r=parseInt(t["max-age"],10);isNaN(r)?delete t["max-age"]:t["max-age"]=r}return t}var Ae=null;function Ie(e,t){return[e[4*t],e[4*t+1],e[4*t+2],e[4*t+3]]}function Ce(e,t,r,i){for(;t>1;e[n]>1;e[n]<=i?t=n+1:r=n}return t}function ze(e){return e>0?1/(1.001-e):1+e}function De(e){return e>0?1-1/(1.001-e):-e}var Re,Le,Oe,Fe,Be,Ne,Ve={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(!Ve.API_URL)return null;try{var e=new URL(Ve.API_URL);return"api.mapbox.cn"===e.hostname?"https://events.mapbox.cn/events/v2":"api.mapbox.com"===e.hostname?"https://events.mapbox.com/events/v2":null}catch(e){return null}},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",RASTERARRAYS_URL_PREFIX:"rasterarrays/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,DEFAULT_STYLE:"mapbox://styles/mapbox/standard",MAX_PARALLEL_IMAGE_REQUESTS:16,DRACO_URL:"https://api.mapbox.com/mapbox-gl-js/draco_decoder_gltf_v1.5.6.wasm",MESHOPT_URL:"https://api.mapbox.com/mapbox-gl-js/meshopt_base_v0.20.wasm",MESHOPT_SIMD_URL:"https://api.mapbox.com/mapbox-gl-js/meshopt_simd_v0.20.wasm",GLYPHS_URL:"mapbox://fonts/mapbox/{fontstack}/{range}.pbf",TILES3D_URL_PREFIX:"3dtiles/v1"};function Ue(e){return Ve.API_URL_REGEX.test(e)}function je(e){return Ve.API_SPRITE_REGEX.test(e)}function Ge(){return null==Re&&(Re=self.OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof self.createImageBitmap),Re}var qe={now:function(){return void 0!==Fe?Fe:performance.now()},setNow:function(e){Fe=e},restoreNow:function(){Fe=void 0},frame:function(e){var t=requestAnimationFrame(e);return{cancel:function(){return cancelAnimationFrame(t)}}},getImageData:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=e.width,i=e.height;Be||(Be=document.createElement("canvas"));var n=Be.getContext("2d",{willReadFrequently:!0});if(!n)throw new Error("failed to create canvas 2d context");return(r>Be.width||i>Be.height)&&(Be.width=r,Be.height=i),n.clearRect(-t,-t,r+2*t,i+2*t),n.drawImage(e,0,0,r,i),n.getImageData(-t,-t,r+2*t,i+2*t)},resolveURL:function(e){return Le||(Le=document.createElement("a")),Le.href=e,Le.href},get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return!!window.matchMedia&&(null==Oe&&(Oe=window.matchMedia("(prefers-reduced-motion: reduce)")),Oe.matches)},hasCanvasFingerprintNoise:function(){if(void 0!==Ne)return Ne;if(!Ge())return Ne=!1,!1;for(var e=new OffscreenCanvas(85,1),t=e.getContext("2d",{willReadFrequently:!0}),r=0,i=0;i1&&void 0!==arguments[1]?arguments[1]:{persistentParams:[]},r=e.indexOf("?");if(r<0)return e;var i=new URLSearchParams,n=new URLSearchParams(e.slice(r));for(var a of t.persistentParams){var o=n.get(a);o&&i.set(a,o)}var s=i.toString();return`${e.slice(0,r)}${s.length>0?`?${s}`:""}`}var He,We,Xe="mapbox-tiles",Ye=500,Je=50,Ke=["language","worldview","jobid"];function Qe(){try{return caches}catch(e){}}function et(){var e=Qe();e&&null==He&&(He=e.open(Xe))}var tt,rt,it=1/0,nt={supported:!1,testSupport:function(e){!at&&rt&&(ot?lt(e):tt=e)}},at=!1,ot=!1,st="undefined"!=typeof self?self:{};function lt(e){var t=e.createTexture();e.bindTexture(e.TEXTURE_2D,t);try{if(e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,rt),e.isContextLost())return;nt.supported=!0}catch(e){}e.deleteTexture(t),at=!0}st.document&&((rt=st.document.createElement("img")).onload=function(){tt&<(tt),tt=null,ot=!0},rt.onerror=function(){at=!0,tt=null},rt.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");var ut={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image",Model:"Model"};"function"==typeof Object.freeze&&Object.freeze(ut);var ct=(function(e){function t(e,r,i){var n;return p(this,t),401===r&&Ue(i)&&(e+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),(n=T(this,t,[e])).status=r,n.url=i,n}return g(t,e),m(t,[{key:"toString",value:function(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}])})(y(Error)),ht=Ee()?function(){return self.worker&&self.worker.referrer}:function(){return("blob:"===location.protocol?parent:self).location.href},ft=function(e,t){if(!(/^file:/.test(r=e.url)||/^file:/.test(ht())&&!/^\w+:/.test(r))){if(self.fetch&&self.Request&&self.AbortController&&Request.prototype.hasOwnProperty("signal"))return(function(e,t){var r,i=new AbortController,n=new Request(e.url,{method:e.method||"GET",body:e.body,credentials:e.credentials,headers:e.headers,referrer:ht(),referrerPolicy:e.referrerPolicy,signal:i.signal}),a=!1,o=!1,s=(r=n.url).indexOf("sku=")>0&&Ue(r);"json"===e.type&&n.headers.set("Accept","application/json");var l=function(r,i,a){if(!o){if(r&&"SecurityError"!==r.message&&we(r.toString()),i&&a)return u(i);var l=Date.now();fetch(n).then((function(r){if(r.ok){var i=s?r.clone():null;return u(r,i,l)}return t(new ct(r.statusText,r.status,e.url))})).catch((function(r){"AbortError"!==r.name&&t(new Error(`${r.message} ${e.url}`))}))}},u=function(r,i,s){("arrayBuffer"===e.type?r.arrayBuffer():"json"===e.type?r.json():r.text()).then((function(e){o||(i&&s&&(function(e,t,r){if(et(),null!=He){var i=Me(t.headers.get("Cache-Control")||"");if(!i["no-store"]){var n={status:t.status,statusText:t.statusText,headers:new Headers};t.headers.forEach((function(e,t){return n.headers.set(t,e)})),i["max-age"]&&n.headers.set("Expires",new Date(r+1e3*i["max-age"]).toUTCString());var a=n.headers.get("Expires");if(a&&!(new Date(a).getTime()-r<42e4)){var o=$e(e.url,{persistentParams:Ke});if(206===t.status){var s=e.headers.get("Range");if(!s)return;n.status=200,o=Ze(o,{range:s})}!(function(e,t){if(void 0===We)try{new Response(new ReadableStream),We=!0}catch(e){We=!1}We?t(e.body):e.blob().then(t)})(t,(function(e){var r,i=new Response(200!==(r=t.status)&&404!==r&&[101,103,204,205,304].includes(r)?null:e,n);et(),null!=He&&He.then((function(e){return e.put(o,i)})).catch((function(e){return we(e.message)}))}))}}}})(n,i,s),a=!0,t(null,e,r.headers.get("Cache-Control"),r.headers.get("Expires")))})).catch((function(e){o||t(new Error(e.message))}))};return s?(function(e,t){if(et(),null==He)return t(null);He.then((function(r){var i=$e(e.url,{persistentParams:Ke}),n=e.headers.get("Range");n&&(i=Ze(i,{range:n})),r.match(i).then((function(e){var n=(function(e){if(!e)return!1;var t=new Date(e.headers.get("Expires")||0),r=Me(e.headers.get("Cache-Control")||"");return t>Date.now()&&!r["no-cache"]})(e);r.delete(i),n&&r.put(i,e.clone()),t(null,e,n)})).catch(t)})).catch(t)})(n,l):l(null,null),{cancel:function(){o=!0,a||i.abort()}}})(e,t);if(Ee()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",e,t,void 0,!0)}var r;return(function(e,t){var r=new XMLHttpRequest;for(var i in r.open(e.method||"GET",e.url,!0),"arrayBuffer"===e.type&&(r.responseType="arraybuffer"),e.headers)r.setRequestHeader(i,e.headers[i]);return"json"===e.type&&(r.responseType="text",r.setRequestHeader("Accept","application/json")),r.withCredentials="include"===e.credentials,r.onerror=function(){t(new Error(r.statusText))},r.onload=function(){if((r.status>=200&&r.status<300||0===r.status)&&null!==r.response){var i=r.response;if("json"===e.type)try{i=JSON.parse(r.response)}catch(e){return t(e)}t(null,i,r.getResponseHeader("Cache-Control"),r.getResponseHeader("Expires"))}else t(new ct(r.statusText,r.status,e.url))},r.send(e.body),{cancel:function(){return r.abort()}}})(e,t)},dt=function(e,t){return ft(fe(e,{type:"arrayBuffer"}),t)};function pt(e){var t=document.createElement("a");return t.href=e,t.protocol===location.protocol&&t.host===location.host}var mt,vt,_t="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";mt=[],vt=0;var gt,yt,xt,bt=function(e,t){if(nt.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),vt>=Ve.MAX_PARALLEL_IMAGE_REQUESTS){var r={requestParameters:e,callback:t,cancelled:!1,cancel:function(){this.cancelled=!0}};return mt.push(r),r}vt++;var i=!1,n=function(){if(!i)for(i=!0,vt--;mt.length&&vt>>16)*o&65535)<<16)&4294967295)<<15|l>>>17))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<13|n>>>19))+((5*(n>>>16)&65535)<<16)&4294967295))+((58964+(a>>>16)&65535)<<16);switch(l=0,r){case 3:l^=(255&e.charCodeAt(u+2))<<16;case 2:l^=(255&e.charCodeAt(u+1))<<8;case 1:n^=l=(65535&(l=(l=(65535&(l^=255&e.charCodeAt(u)))*o+(((l>>>16)*o&65535)<<16)&4294967295)<<15|l>>>17))*s+(((l>>>16)*s&65535)<<16)&4294967295}return n^=e.length,n=2246822507*(65535&(n^=n>>>16))+((2246822507*(n>>>16)&65535)<<16)&4294967295,n=3266489909*(65535&(n^=n>>>13))+((3266489909*(n>>>16)&65535)<<16)&4294967295,(n^=n>>>16)>>>0}),kt.exports),t=(yt||(yt=1,Tt.exports=function(e,t){for(var r,i=e.length,n=t^i,a=0;i>=4;)r=1540483477*(65535&(r=255&e.charCodeAt(a)|(255&e.charCodeAt(++a))<<8|(255&e.charCodeAt(++a))<<16|(255&e.charCodeAt(++a))<<24))+((1540483477*(r>>>16)&65535)<<16),n=1540483477*(65535&n)+((1540483477*(n>>>16)&65535)<<16)^(r=1540483477*(65535&(r^=r>>>24))+((1540483477*(r>>>16)&65535)<<16)),i-=4,++a;switch(i){case 3:n^=(255&e.charCodeAt(a+2))<<16;case 2:n^=(255&e.charCodeAt(a+1))<<8;case 1:n=1540483477*(65535&(n^=255&e.charCodeAt(a)))+((1540483477*(n>>>16)&65535)<<16)}return n=1540483477*(65535&(n^=n>>>13))+((1540483477*(n>>>16)&65535)<<16),(n^=n>>>15)>>>0}),Tt.exports);return wt.exports=e,wt.exports.murmur3=e,wt.exports.murmur2=t,wt.exports})(),Et=t(St),Mt=m((function e(t){p(this,e),fe(this,(arguments.length<=1?void 0:arguments[1])||{}),this.type=t})),At=(function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return p(this,t),T(this,t,["error",fe({error:e},r)])}return g(t,e),m(t)})(Mt);function It(e,t,r){r[e]&&-1!==r[e].indexOf(t)||(r[e]=r[e]||[],r[e].push(t))}function Ct(e,t,r){if(r&&r[e]){var i=r[e].indexOf(t);-1!==i&&r[e].splice(i,1)}}var Pt,zt=(function(){return m((function e(){p(this,e)}),[{key:"on",value:function(e,t){return this._listeners=this._listeners||{},It(e,t,this._listeners),this}},{key:"off",value:function(e,t){return Ct(e,t,this._listeners),Ct(e,t,this._oneTimeListeners),this}},{key:"once",value:function(e,t){var r=this;return t?(this._oneTimeListeners=this._oneTimeListeners||{},It(e,t,this._oneTimeListeners),this):new Promise((function(t){return r.once(e,t)}))}},{key:"fire",value:function(e,t){var r="string"==typeof e?new Mt(e,t):e,i=r.type;if(this.listens(i)){r.target=this;var n=this._listeners&&this._listeners[i]?this._listeners[i].slice():[];for(var a of n)a.call(this,r);var o=this._oneTimeListeners&&this._oneTimeListeners[i]?this._oneTimeListeners[i].slice():[];for(var s of o)Ct(i,s,this._oneTimeListeners),s.call(this,r);var l=this._eventedParent;l&&(fe(r,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),l.fire(r))}else r instanceof At&&console.error(r.error);return this}},{key:"listens",value:function(e){return!!(this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e))}},{key:"setEventedParent",value:function(e,t){return this._eventedParent=e,this._eventedParentData=t,this}}])})(),Dt={},Rt=(function(){if(Pt)return Dt;Pt=1;var e={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function t(e){return(e=Math.round(e))<0?0:e>255?255:e}function r(e){return t("%"===e[e.length-1]?parseFloat(e)/100*255:parseInt(e))}function i(e){return(t="%"===e[e.length-1]?parseFloat(e)/100:parseFloat(e))<0?0:t>1?1:t;var t}function n(e,t,r){return r<0?r+=1:r>1&&(r-=1),6*r<1?e+(t-e)*r*6:2*r<1?t:3*r<2?e+(t-e)*(.6666666666666666-r)*6:e}try{Dt.parseCSSColor=function(a){var o,s=a.replace(/ /g,"").toLowerCase();if(s in e)return e[s].slice();if("#"===s[0])return 4===s.length?(o=parseInt(s.substr(1),16))>=0&&o<=4095?[(3840&o)>>4|(3840&o)>>8,240&o|(240&o)>>4,15&o|(15&o)<<4,1]:null:7===s.length&&(o=parseInt(s.substr(1),16))>=0&&o<=16777215?[(16711680&o)>>16,(65280&o)>>8,255&o,1]:null;var l=s.indexOf("("),u=s.indexOf(")");if(-1!==l&&u+1===s.length){var c=s.substr(0,l),h=s.substr(l+1,u-(l+1)).split(","),f=1;switch(c){case"rgba":if(4!==h.length)return null;f=i(h.pop());case"rgb":return 3!==h.length?null:[r(h[0]),r(h[1]),r(h[2]),f];case"hsla":if(4!==h.length)return null;f=i(h.pop());case"hsl":if(3!==h.length)return null;var d=(parseFloat(h[0])%360+360)%360/360,p=i(h[1]),m=i(h[2]),v=m<=.5?m*(p+1):m+p-m*p,_=2*m-v;return[t(255*n(_,v,d+.3333333333333333)),t(255*n(_,v,d)),t(255*n(_,v,d-.3333333333333333)),f];default:return null}}return null}}catch(e){}return Dt})(),Lt=(function(){function e(t,r,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;p(this,e),this.r=t,this.g=r,this.b=i,this.a=n}return m(e,[{key:"toString",value:function(){var e=0===this.a?[0,0,0,0]:[255*this.r/this.a,255*this.g/this.a,255*this.b/this.a,this.a],t=x(e,4),r=t[0],i=t[1],n=t[2],a=t[3];return`rgba(${Math.round(r)},${Math.round(i)},${Math.round(n)},${a})`}},{key:"toRenderColor",value:function(e){var t=this.r,r=this.g,i=this.b,n=this.a;return new Ot(e,t,r,i,n)}}],[{key:"parse",value:function(t){if(t){if(t instanceof e)return t;if("string"==typeof t){var r=Rt.parseCSSColor(t);return r?new e(r[0]/255*r[3],r[1]/255*r[3],r[2]/255*r[3],r[3]):void 0}}}}])})(),Ot=(function(){return m((function e(t,r,i,n,a){if(p(this,e),t){var o=t.image.height,s=o*o;r=0===a?0:r/a*(o-1),i=0===a?0:i/a*(o-1),n=0===a?0:n/a*(o-1);var l=Math.floor(r),u=Math.floor(i),c=Math.floor(n),h=Math.ceil(r),f=Math.ceil(i),d=Math.ceil(n),m=r-l,v=i-u,_=n-c,g=t.image.data,y=4*(l+u*s+c*o),x=4*(l+u*s+d*o),b=4*(l+f*s+c*o),w=4*(l+f*s+d*o),k=4*(h+u*s+c*o),T=4*(h+u*s+d*o),S=4*(h+f*s+c*o),E=4*(h+f*s+d*o);if(y<0||E>=g.length)throw new Error("out of range");this.r=Ft(Ft(Ft(g[y],g[x],_),Ft(g[b],g[w],_),v),Ft(Ft(g[k],g[T],_),Ft(g[S],g[E],_),v),m)/255*a,this.g=Ft(Ft(Ft(g[y+1],g[x+1],_),Ft(g[b+1],g[w+1],_),v),Ft(Ft(g[k+1],g[T+1],_),Ft(g[S+1],g[E+1],_),v),m)/255*a,this.b=Ft(Ft(Ft(g[y+2],g[x+2],_),Ft(g[b+2],g[w+2],_),v),Ft(Ft(g[k+2],g[T+2],_),Ft(g[S+2],g[E+2],_),v),m)/255*a,this.a=a}else this.r=r,this.g=i,this.b=n,this.a=a}),[{key:"toArray",value:function(){var e=this.r,t=this.g,r=this.b,i=this.a;return 0===i?[0,0,0,0]:[255*e/i,255*t/i,255*r/i,i]}},{key:"toArray01",value:function(){var e=this.r,t=this.g,r=this.b,i=this.a;return 0===i?[0,0,0,0]:[e/i,t/i,r/i,i]}},{key:"toArray01Scaled",value:function(e){var t=this.r,r=this.g,i=this.b,n=this.a;return 0===n?[0,0,0]:[t/n*e,r/n*e,i/n*e]}},{key:"toArray01PremultipliedAlpha",value:function(){return[this.r,this.g,this.b,this.a]}},{key:"toArray01Linear",value:function(){var e=this.r,t=this.g,r=this.b,i=this.a;return 0===i?[0,0,0,0]:[Math.pow(e/i,2.2),Math.pow(t/i,2.2),Math.pow(r/i,2.2),i]}}])})();function Ft(e,t,r){return e*(1-r)+t*r}function Bt(e,t,r){return e.map((function(e,i){return Ft(e,t[i],r)}))}Lt.black=new Lt(0,0,0,1),Lt.white=new Lt(1,1,1,1),Lt.transparent=new Lt(0,0,0,0),Lt.red=new Lt(1,0,0,1),Lt.blue=new Lt(0,0,1,1);var Nt=Object.freeze({__proto__:null,array:Bt,color:function(e,t,r){return new Lt(Ft(e.r,t.r,r),Ft(e.g,t.g,r),Ft(e.b,t.b,r),Ft(e.a,t.a,r))},number:Ft});function Vt(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i1&&void 0!==arguments[1]?arguments[1]:[];for(var i of(p(this,e),this.parent=t,this.bindings={},r)){var n=x(i,2),a=n[0],o=n[1];this.bindings[a]=o}}return m(e,[{key:"concat",value:function(t){return new e(this,t)}},{key:"get",value:function(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw new Error(`${e} not found in scope.`)}},{key:"has",value:function(e){return!!this.bindings[e]||!!this.parent&&this.parent.has(e)}}])})(),Gt={kind:"null"},qt={kind:"number"},Zt={kind:"string"},$t={kind:"boolean"},Ht={kind:"color"},Wt={kind:"object"},Xt={kind:"value"},Yt={kind:"collator"},Jt={kind:"formatted"},Kt={kind:"resolvedImage"};function Qt(e,t){return{kind:"array",itemType:e,N:t}}function er(e){if("array"===e.kind){var t=er(e.itemType);return"number"==typeof e.N?`array<${t}, ${e.N}>`:"value"===e.itemType.kind?"array":`array<${t}>`}return e.kind}var tr=[Gt,qt,Zt,$t,Ht,Jt,Wt,Qt(Xt),Kt];function rr(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!rr(e.itemType,t.itemType))&&("number"!=typeof e.N||e.N===t.N))return null}else{if(e.kind===t.kind)return null;if("value"===e.kind)for(var r of tr)if(!rr(r,t))return null}return`Expected ${er(e)} but found ${er(t)} instead.`}function ir(e,t){return t.some((function(t){return t.kind===e.kind}))}function nr(e,t){return t.some((function(t){return"null"===t?null===e:"array"===t?Array.isArray(e):"object"===t?e&&!Array.isArray(e)&&"object"==typeof e:t===typeof e}))}var ar=(function(){return m((function e(t,r,i){p(this,e),this.sensitivity=t?r?"variant":"case":r?"accent":"base",this.locale=i,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}),[{key:"compare",value:function(e,t){return this.collator.compare(e,t)}},{key:"resolvedLocale",value:function(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}])})(),or=m((function e(t,r,i,n,a){p(this,e),this.text=t.normalize?t.normalize():t,this.image=r,this.scale=i,this.fontStack=n,this.textColor=a})),sr=(function(){function e(t){p(this,e),this.sections=t}return m(e,[{key:"isEmpty",value:function(){return 0===this.sections.length||!this.sections.some((function(e){return 0!==e.text.length||e.image&&0!==e.image.namePrimary.length}))}},{key:"toString",value:function(){return 0===this.sections.length?"":this.sections.map((function(e){return e.text})).join("")}},{key:"serialize",value:function(){var e=["format"];for(var t of this.sections)if(t.image)e.push(["image",t.image.namePrimary]);else{e.push(t.text);var r={};t.fontStack&&(r["text-font"]=["literal",t.fontStack.split(",")]),t.scale&&(r["font-scale"]=t.scale),t.textColor&&(r["text-color"]=["rgba"].concat(t.textColor.toRenderColor(null).toArray())),e.push(r)}return e}}],[{key:"fromString",value:function(t){return new e([new or(t,null,null,null,null)])}},{key:"factory",value:function(t){return t instanceof e?t:e.fromString(t)}}])})(),lr=(function(){function e(t){p(this,e),this.namePrimary=t.namePrimary,t.nameSecondary&&(this.nameSecondary=t.nameSecondary),this.available=t.available}return m(e,[{key:"toString",value:function(){return this.nameSecondary?`[${this.namePrimary},${this.nameSecondary}]`:this.namePrimary}},{key:"serialize",value:function(){return this.nameSecondary?["image",this.namePrimary,this.nameSecondary]:["image",this.namePrimary]}}],[{key:"fromString",value:function(t,r){return t?new e({namePrimary:t,nameSecondary:r,available:!1}):null}}])})();function ur(e,t,r,i){return"number"==typeof e&&e>=0&&e<=255&&"number"==typeof t&&t>=0&&t<=255&&"number"==typeof r&&r>=0&&r<=255?void 0===i||"number"==typeof i&&i>=0&&i<=1?null:`Invalid rgba value [${[e,t,r,i].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof i?[e,t,r,i]:[e,t,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function cr(e){if(null===e)return!0;if("string"==typeof e)return!0;if("boolean"==typeof e)return!0;if("number"==typeof e)return!0;if(e instanceof Lt)return!0;if(e instanceof ar)return!0;if(e instanceof sr)return!0;if(e instanceof lr)return!0;if(Array.isArray(e)){for(var t of e)if(!cr(t))return!1;return!0}if("object"==typeof e){for(var r in e)if(!cr(e[r]))return!1;return!0}return!1}function hr(e){if(null===e)return Gt;if("string"==typeof e)return Zt;if("boolean"==typeof e)return $t;if("number"==typeof e)return qt;if(e instanceof Lt)return Ht;if(e instanceof ar)return Yt;if(e instanceof sr)return Jt;if(e instanceof lr)return Kt;if(Array.isArray(e)){var t,r=e.length;for(var i of e){var n=hr(i);if(t){if(t===n)continue;t=Xt;break}t=n}return Qt(t||Xt,r)}return Wt}function fr(e){var t=typeof e;return null===e?"":"string"===t||"number"===t||"boolean"===t?String(e):e instanceof Lt||e instanceof sr||e instanceof lr?e.toString():JSON.stringify(e)}var dr=(function(){function e(t,r){p(this,e),this.type=t,this.value=r}return m(e,[{key:"evaluate",value:function(){return this.value}},{key:"eachChild",value:function(){}},{key:"outputDefined",value:function(){return!0}},{key:"serialize",value:function(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof Lt?["rgba"].concat(this.value.toRenderColor(null).toArray()):this.value instanceof sr?this.value.serialize():this.value}}],[{key:"parse",value:function(t,r){if(2!==t.length)return r.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!cr(t[1]))return r.error("invalid value");var i=t[1],n=hr(i),a=r.expectedType;return"array"!==n.kind||0!==n.N||!a||"array"!==a.kind||"number"==typeof a.N&&0!==a.N||(n=a),new e(n,i)}}])})(),pr=(function(){return m((function e(t){p(this,e),this.name="ExpressionEvaluationError",this.message=t}),[{key:"toJSON",value:function(){return this.message}}])})(),mr={string:Zt,number:qt,boolean:$t,object:Wt},vr=(function(){function e(t,r){p(this,e),this.type=t,this.args=r}return m(e,[{key:"evaluate",value:function(e){for(var t=0;t1)&&t.push(i)}}return t.concat(this.args.map((function(e){return e.serialize()})))}}],[{key:"parse",value:function(t,r){if(t.length<2)return r.error("Expected at least one argument.");var i,n=1,a=t[0];if("array"===a){var o,s;if(t.length>2){var l=t[1];if("string"!=typeof l||!(l in mr)||"object"===l)return r.error('The item type argument of "array" must be one of string, number, boolean',1);o=mr[l],n++}else o=Xt;if(t.length>3){if(null!==t[2]&&("number"!=typeof t[2]||t[2]<0||t[2]!==Math.floor(t[2])))return r.error('The length argument to "array" must be a positive integer literal',2);s=t[2],n++}i=Qt(o,s)}else i=mr[a];for(var u=[];n-1,t.nameSecondary&&t.available&&e.availableImages&&(t.available=e.availableImages.indexOf(t.nameSecondary)>-1)),t}},{key:"eachChild",value:function(e){e(this.inputPrimary),this.inputSecondary&&e(this.inputSecondary)}},{key:"outputDefined",value:function(){return!1}},{key:"serialize",value:function(){return this.inputSecondary?["image",this.inputPrimary.serialize(),this.inputSecondary.serialize()]:["image",this.inputPrimary.serialize()]}}],[{key:"parse",value:function(t,r){if(t.length<2)return r.error("Expected two or more arguments.");var i=r.parse(t[1],1,Zt);if(!i)return r.error("No image name provided.");if(2===t.length)return new e(i);var n=r.parse(t[2],1,Zt);return n?new e(i,n):r.error("Secondary image variant is not a string.")}}])})();function yr(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":null===e?"null":typeof e}var xr={"to-boolean":$t,"to-color":Ht,"to-number":qt,"to-string":Zt},br=(function(){function e(t,r){p(this,e),this.type=t,this.args=r}return m(e,[{key:"evaluate",value:function(e){if("boolean"===this.type.kind)return Boolean(this.args[0].evaluate(e));if("color"===this.type.kind){var t,r;for(var i of this.args){if(r=null,(t=i.evaluate(e))instanceof Lt)return t;if("string"==typeof t){var n=e.parseColor(t);if(n)return n}else if(Array.isArray(t)&&!(r=t.length<3||t.length>4?`Invalid rbga value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:ur(t[0],t[1],t[2],t[3])))return new Lt(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new pr(r||`Could not parse color from value '${"string"==typeof t?t:String(JSON.stringify(t))}'`)}if("number"===this.type.kind){var a=null;for(var o of this.args){if(null===(a=o.evaluate(e)))return 0;var s=Number(a);if(!isNaN(s))return s}throw new pr(`Could not convert ${JSON.stringify(a)} to number.`)}return"formatted"===this.type.kind?sr.fromString(fr(this.args[0].evaluate(e))):"resolvedImage"===this.type.kind?lr.fromString(fr(this.args[0].evaluate(e))):"array"===this.type.kind?this.args.map((function(t){return t.evaluate(e)})):fr(this.args[0].evaluate(e))}},{key:"eachChild",value:function(e){this.args.forEach(e)}},{key:"outputDefined",value:function(){return this.args.every((function(e){return e.outputDefined()}))}},{key:"serialize",value:function(){if("formatted"===this.type.kind)return new _r([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new gr(this.args[0]).serialize();var e="array"===this.type.kind?[]:[`to-${this.type.kind}`];return this.eachChild((function(t){e.push(t.serialize())})),e}}],[{key:"parse",value:function(t,r){if(t.length<2)return r.error("Expected at least one argument.");var i=t[0],n=[],a=Gt;if("to-array"===i){if(!Array.isArray(t[1]))return null;var o=t[1].length;if(r.expectedType){if("array"!==r.expectedType.kind)return r.error(`Expected ${r.expectedType.kind} but found array.`);a=Qt(r.expectedType.itemType,o)}else{if(!(o>0&&cr(t[1][0])))return null;a=Qt(hr(t[1][0]),o)}for(var s=0;s2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:e.length-1,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:Ir;i>r;){if(i-r>600){var a=i-r+1,o=t-r+1,s=Math.log(a),l=.5*Math.exp(2*s/3),u=.5*Math.sqrt(s*l*(a-l)/a)*(o-a/2<0?-1:1);Mr(e,t,Math.max(r,Math.floor(t-o*l/a+u)),Math.min(i,Math.floor(t+(a-o)*l/a+u)),n)}var c=e[t],h=r,f=i;for(Ar(e,r,t),n(e[i],c)>0&&Ar(e,r,i);h0;)f--}0===n(e[r],c)?Ar(e,r,f):Ar(e,++f,i),f<=t&&(r=f+1),t<=f&&(i=f-1)}}function Ar(e,t,r){var i=e[t];e[t]=e[r],e[r]=i}function Ir(e,t){return et?1:0}function Cr(e){for(var t,r,i=0,n=0,a=e.length,o=a-1;n=t[2]||e[1]<=t[1]||e[3]>=t[3])}function Dr(e,t,r){var i=e[0]-t[0],n=e[1]-t[1],a=e[0]-r[0],o=e[1]-r[1];return i*o-a*n==0&&i*a<=0&&n*o<=0}function Rr(e,t){for(var r,i,n,a=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=!1,s=0,l=t.length;s(r=e)[1]!=(n=p)[1]>r[1]&&r[0]<(n[0]-i[0])*(r[1]-i[1])/(n[1]-i[1])+i[0]&&(o=!o)}return o}function Lr(e,t,r,i){var n=i[0]-r[0],a=i[1]-r[1],o=(e[0]-r[0])*a-n*(e[1]-r[1]),s=(t[0]-r[0])*a-n*(t[1]-r[1]);return o>0&&s<0||o<0&&s>0}function Or(e,t,r,i){return 0!=(n=[i[0]-r[0],i[1]-r[1]])[0]*(a=[t[0]-e[0],t[1]-e[1]])[1]-n[1]*a[0]&&!(!Lr(e,t,r,i)||!Lr(r,i,e,t));var n,a}var Fr=8192;function Br(e,t){var r=(180+e[0])/360,i=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e[1]*Math.PI/360)))/360,n=Math.pow(2,t.z);return[Math.round(r*n*Fr),Math.round(i*n*Fr)]}function Nr(e,t){for(var r=0;rr[2]){var n=.5*i,a=e[0]-r[0]>n?-i:r[0]-e[0]>n?i:0;0===a&&(a=e[0]-r[2]>n?-i:r[2]-e[0]>n?i:0),e[0]+=a}Pr(t,e)}function $r(e,t,r,i){var n=Math.pow(2,i.z)*Fr,a=[i.x*Fr,i.y*Fr],o=[];if(!e)return o;for(var s of e)for(var l of s){var u=[l.x+a[0],l.y+a[1]];Zr(u,t,r,n),o.push(u)}return o}function Hr(e,t,r,i){var n,a=Math.pow(2,i.z)*Fr,o=[i.x*Fr,i.y*Fr],s=[];if(!e)return s;for(var l of e){var u=[];for(var c of l){var h=[c.x+o[0],c.y+o[1]];Pr(t,h),u.push(h)}s.push(u)}if(t[2]-t[0]<=a/2)for(var f of((n=t)[0]=n[1]=1/0,n[2]=n[3]=-1/0,s))for(var d of f)Zr(d,t,r,a);return s}var Wr=(function(){function e(t,r){p(this,e),this.type=$t,this.geojson=t,this.geometries=r}return m(e,[{key:"evaluate",value:function(e){if(null!=e.geometry()&&null!=e.canonicalID()){if("Point"===e.geometryType())return(function(e,t){var r=[1/0,1/0,-1/0,-1/0],i=[1/0,1/0,-1/0,-1/0],n=e.canonicalID();if(!n)return!1;if("Polygon"===t.type){var a=Gr(t.coordinates,i,n),o=$r(e.geometry(),r,i,n);if(!zr(r,i))return!1;for(var s of o)if(!Rr(s,a))return!1}if("MultiPolygon"===t.type){var l=qr(t.coordinates,i,n),u=$r(e.geometry(),r,i,n);if(!zr(r,i))return!1;for(var c of u)if(!Nr(c,l))return!1}return!0})(e,this.geometries);if("LineString"===e.geometryType())return(function(e,t){var r=[1/0,1/0,-1/0,-1/0],i=[1/0,1/0,-1/0,-1/0],n=e.canonicalID();if(!n)return!1;if("Polygon"===t.type){var a=Gr(t.coordinates,i,n),o=Hr(e.geometry(),r,i,n);if(!zr(r,i))return!1;for(var s of o)if(!Ur(s,a))return!1}if("MultiPolygon"===t.type){var l=qr(t.coordinates,i,n),u=Hr(e.geometry(),r,i,n);if(!zr(r,i))return!1;for(var c of u)if(!jr(c,l))return!1}return!0})(e,this.geometries)}return!1}},{key:"eachChild",value:function(){}},{key:"outputDefined",value:function(){return!0}},{key:"serialize",value:function(){return["within",this.geojson]}}],[{key:"parse",value:function(t,r){if(2!==t.length)return r.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(cr(t[1])){var i=t[1];if("FeatureCollection"===i.type)for(var n=0;nt)return Qr(n,a,(t-(r-o))/o)}return e[e.length-1]}},{key:"pointToSegmentDistance",value:function(e,t,r){var i=x(t,2),n=i[0],a=i[1],o=ei(r[0]-n)*this.kx,s=(r[1]-a)*this.ky;if(0!==o||0!==s){var l=(ei(e[0]-n)*this.kx*o+(e[1]-a)*this.ky*s)/(o*o+s*s);l>1?(n=r[0],a=r[1]):l>0&&(n+=o/this.kx*l,a+=s/this.ky*l)}return o=ei(e[0]-n)*this.kx,s=(e[1]-a)*this.ky,Math.sqrt(o*o+s*s)}},{key:"pointOnLine",value:function(e,t){for(var r=1/0,i=e[0][0],n=e[0][1],a=0,o=0,s=0;s1?(l=e[s+1][0],u=e[s+1][1]):f>0&&(l+=c/this.kx*f,u+=h/this.ky*f));var d=(c=ei(t[0]-l)*this.kx)*c+(h=(t[1]-u)*this.ky)*h;dn.index||i.index===n.index&&i.t>n.t){var a=i;i=n,n=a}var o=[i.point],s=i.index+1,l=n.index;!Kr(r[s],o[0])&&s<=l&&o.push(r[s]);for(var u=s+1;u<=l;u++)o.push(r[u]);return Kr(r[l],n.point)||o.push(n.point),o}},{key:"lineSliceAlong",value:function(e,t,r){for(var i=0,n=[],a=0;ae&&0===n.length&&n.push(Qr(o,s,(e-(i-l))/l)),i>=t)return n.push(Qr(o,s,(t-(i-l))/l)),n;i>e&&n.push(s)}return n}},{key:"bufferPoint",value:function(e,t){var r=t/this.ky,i=t/this.kx;return[e[0]-i,e[1]-r,e[0]+i,e[1]+r]}},{key:"bufferBBox",value:function(e,t){var r=t/this.ky,i=t/this.kx;return[e[0]-i,e[1]-r,e[2]+i,e[3]+r]}},{key:"insideBBox",value:function(e,t){return ei(e[0]-t[0])>=0&&ei(e[0]-t[2])<=0&&e[1]>=t[1]&&e[1]<=t[3]}}],[{key:"fromTile",value:function(t,r,i){var n=Math.PI*(1-2*(t+.5)/Math.pow(2,r));return new e(Math.atan(.5*(Math.exp(n)-Math.exp(-n)))/Yr,i)}},{key:"units",get:function(){return Xr}}])})();function Kr(e,t){return e[0]===t[0]&&e[1]===t[1]}function Qr(e,t,r){var i=ei(t[0]-e[0]);return[e[0]+i*r,e[1]+(t[1]-e[1])*r]}function ei(e){for(;e<-180;)e+=360;for(;e>180;)e-=360;return e}var ti=(function(){return m((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(e,t){return et?1:0};if(p(this,e),this.data=t,this.length=this.data.length,this.compare=r,this.length>0)for(var i=(this.length>>1)-1;i>=0;i--)this._down(i)}),[{key:"push",value:function(e){this.data.push(e),this._up(this.length++)}},{key:"pop",value:function(){if(0!==this.length){var e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}}},{key:"peek",value:function(){return this.data[0]}},{key:"_up",value:function(e){for(var t=this.data,r=this.compare,i=t[e];e>0;){var n=e-1>>1,a=t[n];if(r(i,a)>=0)break;t[e]=a,e=n}t[e]=i}},{key:"_down",value:function(e){for(var t=this.data,r=this.compare,i=this.length>>1,n=t[e];e=0)break;t[e]=t[a],e=a}t[e]=n}}])})(),ri=8192;function ii(e,t){return t.dist-e.dist}function ni(e){var t=[1/0,1/0,-1/0,-1/0];if(t.length!==e.length)return!1;for(var r=0;r=e[0]&&e[1]e[1])return[null,null];var r=ai(e);if(t){if(2===r)return[e,null];var i=Math.floor(r/2);return[[e[0],e[0]+i],[e[0]+i,e[1]]]}if(1===r)return[e,null];var n=Math.floor(r/2)-1;return[[e[0],e[0]+n],[e[0]+n+1,e[1]]]}function li(e,t){var r=[1/0,1/0,-1/0,-1/0];if(!oi(t,e.length))return r;for(var i=t[0];i<=t[1];++i)Pr(r,e[i]);return r}function ui(e){for(var t=[1/0,1/0,-1/0,-1/0],r=0;rt[2]&&(i=e[0]-t[2]),e[1]>t[3]&&(n=e[1]-t[3]),e[3]3&&void 0!==arguments[3]?arguments[3]:1/0,n=ui(e),a=ui(t);if(i!==1/0&&ci(n,a,r)>=i)return i;if(zr(n,a)){if(wi(e,t))return 0}else if(wi(t,e))return 0;var o=i;for(var s of e)for(var l=0,u=s.length,c=u-1;l4&&void 0!==arguments[4]?arguments[4]:1/0,a=Math.min(i.distance(e[0],r[0][0]),n);if(0===a)return a;for(var o=new ti([{dist:0,range1:[0,e.length-1],range2:[0,0]}],ii),s=t?50:100,l=ui(r);o.length;){var u=o.pop();if(!(u.dist>=a)){var c=u.range1;if(ai(c)<=s){if(!oi(c,e.length))return NaN;if(t){var h=bi(e,c,r,i);if(0===(a=Math.min(a,h)))return a}else for(var f=c[0];f<=c[1];++f){var d=xi(e[f],r,i);if(0===(a=Math.min(a,d)))return a}}else{var p=si(c,t);if(null!==p[0]){var m=ci(li(e,p[0]),l,i);m5&&void 0!==arguments[5]?arguments[5]:1/0,o=Math.min(a,n.distance(e[0],r[0]));if(0===o)return o;for(var s=new ti([{dist:0,range1:[0,e.length-1],range2:[0,r.length-1]}],ii),l=t?50:100,u=i?50:100;s.length;){var c=s.pop();if(!(c.dist>=o)){var h=c.range1,f=c.range2;if(ai(h)<=l&&ai(f)<=u){if(!oi(h,e.length)||!oi(f,r.length))return NaN;if(t&&i?o=Math.min(o,gi(e,h,r,f,n)):t||i?t&&!i?o=Math.min(o,vi(r,f,e,h,n)):!t&&i&&(o=Math.min(o,vi(e,h,r,f,n))):o=Math.min(o,yi(e,h,r,f,n)),0===o)return o}else{var d=si(h,t),p=si(f,i);Ti(s,o,n,e,r,d[0],p[0]),Ti(s,o,n,e,r,d[0],p[1]),Ti(s,o,n,e,r,d[1],p[0]),Ti(s,o,n,e,r,d[1],p[1])}}}return o}function Mi(e,t,r,i){var n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1/0,a=li(e,[0,e.length-1]);for(var o of r)if(!(n!==1/0&&ci(a,li(o,[0,o.length-1]),i)>=n)&&0===(n=Math.min(n,Ei(e,t,o,!0,i,n))))return n;return n}function Ai(e,t,r,i){var n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1/0,a=li(e,[0,e.length-1]);for(var o of r)if(!(n!==1/0&&ci(a,ui(o),i)>=n)){var s=Si(e,t,o,i,n);if(isNaN(s))return s;if(0===(n=Math.min(n,s)))return n}return n}function Ii(e){return"Point"===e||"MultiPoint"===e||"LineString"===e||"MultiLineString"===e||"Polygon"===e||"MultiPolygon"===e}var Ci=(function(){function e(t,r){p(this,e),this.type=qt,this.geojson=t,this.geometries=r}return m(e,[{key:"evaluate",value:function(e){var t=e.geometry(),r=e.canonicalID();if(null!=t&&null!=r){if("Point"===e.geometryType())return(function(e,t,r){var i=[];for(var n of e)for(var a of n)i.push(di(a,t));var o=new Jr(i[0][1],"meters");return"Point"===r.type||"MultiPoint"===r.type||"LineString"===r.type?Ei(i,!1,"Point"===r.type?[r.coordinates]:r.coordinates,"LineString"===r.type,o):"MultiLineString"===r.type?Mi(i,!1,r.coordinates,o):"Polygon"===r.type||"MultiPolygon"===r.type?Ai(i,!1,"Polygon"===r.type?[r.coordinates]:r.coordinates,o):null})(t,r,this.geometries);if("LineString"===e.geometryType())return(function(e,t,r){var i=[];for(var n of e){var a=[];for(var o of n)a.push(di(o,t));i.push(a)}var s=new Jr(i[0][0][1],"meters");if("Point"===r.type||"MultiPoint"===r.type||"LineString"===r.type)return Mi("Point"===r.type?[r.coordinates]:r.coordinates,"LineString"===r.type,i,s);if("MultiLineString"===r.type){for(var l=1/0,u=0;ur&&(e=r),e}var Di=(function(){function e(t,r,i){p(this,e),this.type=t,this.key=r,this.scope=i}return m(e,[{key:"evaluate",value:function(e){var t=[this.key,this.scope,e.scope].filter(Boolean).join("\x1f"),r=e.getConfig(t);if(!r)return null;var i=r.type,n=r.value,a=r.values,o=r.minValue,s=r.maxValue,l=r.stepValue,u=r.default.evaluate(e),c=u;if(n){var h=e.scope;e.scope=(h||"").split("\x1f").slice(1).join("\x1f"),c=n.evaluate(e),e.scope=h}return i&&(c=Pi(i,c)),void 0===c||void 0===o&&void 0===s&&void 0===l||("number"==typeof c?c=zi(c,o,s,l):Array.isArray(c)&&(c=c.map((function(e){return"number"==typeof e?zi(e,o,s,l):e})))),void 0!==n&&void 0!==c&&a&&!a.includes(c)&&(c=u,i&&(c=Pi(i,c))),(i&&i!==this.type||void 0!==c&&hr(c)!==this.type)&&(c=Pi(this.type.kind,c)),c}},{key:"eachChild",value:function(){}},{key:"outputDefined",value:function(){return!1}},{key:"serialize",value:function(){var e=["config",this.key];return this.scope&&e.concat(this.key),e}}],[{key:"parse",value:function(t,r){var i=r.expectedType;if(null==i&&(i=Xt),t.length<2||t.length>3)return r.error("Invalid number of arguments for 'config' expression.");var n=r.parse(t[1],1);if(!(n instanceof dr))return r.error("Key name of 'config' expression must be a string literal.");if(t.length>=3){var a=r.parse(t[2],2);return a instanceof dr?new e(i,fr(n.value),fr(a.value)):r.error("Scope of 'config' expression must be a string literal.")}return new e(i,fr(n.value))}}])})();function Ri(e){if(e instanceof Tr){if("get"===e.name&&1===e.args.length)return!1;if("feature-state"===e.name)return!1;if("has"===e.name&&1===e.args.length)return!1;if("properties"===e.name||"geometry-type"===e.name||"id"===e.name)return!1;if(/^filter-/.test(e.name))return!1}if(e instanceof Wr)return!1;if(e instanceof Ci)return!1;var t=!0;return e.eachChild((function(e){t&&!Ri(e)&&(t=!1)})),t}function Li(e){if(e instanceof Tr&&"feature-state"===e.name)return!1;var t=!0;return e.eachChild((function(e){t&&!Li(e)&&(t=!1)})),t}function Oi(e){if(e instanceof Di)return new Set([e.key]);var t=new Set;return e.eachChild((function(e){t=new Set([].concat(d(t),d(Oi(e))))})),t}function Fi(e,t){if(e instanceof Tr&&t.indexOf(e.name)>=0)return!1;var r=!0;return e.eachChild((function(e){r&&!Fi(e,t)&&(r=!1)})),r}var Bi=(function(){function e(t,r){p(this,e),this.type=r.type,this.name=t,this.boundExpression=r}return m(e,[{key:"evaluate",value:function(e){return this.boundExpression.evaluate(e)}},{key:"eachChild",value:function(){}},{key:"outputDefined",value:function(){return!1}},{key:"serialize",value:function(){return["var",this.name]}}],[{key:"parse",value:function(t,r){if(2!==t.length||"string"!=typeof t[1])return r.error("'var' expression requires exactly one string literal argument.");var i=t[1];return r.scope.has(i)?new e(i,r.scope.get(i)):r.error(`Unknown variable "${i}". Make sure "${i}" has been bound in an enclosing "let" expression before using it.`,1)}}])})(),Ni=(function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=arguments.length>2?arguments[2]:void 0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:new jt,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[],o=arguments.length>5?arguments[5]:void 0,s=arguments.length>6?arguments[6]:void 0;p(this,e),this.registry=t,this.path=r,this.key=r.map((function(e){return"string"==typeof e?`['${e}']`:`[${e}]`})).join(""),this.scope=n,this.errors=a,this.expectedType=i,this._scope=o,this.options=s}return m(e,[{key:"parse",value:function(e,t,r,i){var n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};return t||r?this.concat(t,null,r,i)._parse(e,n):this._parse(e,n)}},{key:"parseObjectValue",value:function(e,t,r,i,n){var a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};return this.concat(t,r,i,n)._parse(e,a)}},{key:"_parse",value:function(e,t){function r(e,t,r){return"assert"===r?new vr(t,[e]):"coerce"===r?new br(t,[e]):e}if(null!==e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e||(e=["literal",e]),Array.isArray(e)){if(0===e.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');var i="string"==typeof e[0]?this.registry[e[0]]:void 0;if(i){var n=i.parse(e,this);if(!n)return null;if(this.expectedType){var a=this.expectedType,o=n.type;if("string"!==a.kind&&"number"!==a.kind&&"boolean"!==a.kind&&"object"!==a.kind&&"array"!==a.kind||"value"!==o.kind)if("color"!==a.kind&&"formatted"!==a.kind&&"resolvedImage"!==a.kind||"value"!==o.kind&&"string"!==o.kind){if(this.checkSubtype(a,o))return null}else n=r(n,a,t.typeAnnotation||"coerce");else n=r(n,a,t.typeAnnotation||"assert")}if(!(n instanceof dr)&&"resolvedImage"!==n.type.kind&&Ui(n)){var s=new kr(this._scope,this.options);try{n=new dr(n.type,n.evaluate(s))}catch(e){return this.error(e.message),null}}return n}return br.parse(["to-array",e],this)}return this.error(void 0===e?"'undefined' value invalid. Use null instead.":"object"==typeof e?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}},{key:"concat",value:function(t,r,i,n){var a="number"==typeof t?this.path.concat(t):this.path;a="string"==typeof r?a.concat(r):a;var o=n?this.scope.concat(n):this.scope;return new e(this.registry,a,i||null,o,this.errors,this._scope,this.options)}},{key:"error",value:function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;it))throw new pr("Input is not a number.");o=s-1}return 0}var Gi=(function(){function e(t,r,i){for(var n of(p(this,e),this.type=t,this.input=r,this.labels=[],this.outputs=[],i)){var a=x(n,2),o=a[0],s=a[1];this.labels.push(o),this.outputs.push(s)}}return m(e,[{key:"evaluate",value:function(e){var t=this.labels,r=this.outputs;if(1===t.length)return r[0].evaluate(e);var i=this.input.evaluate(e);if(i<=t[0])return r[0].evaluate(e);var n=t.length;return i>=t[n-1]?r[n-1].evaluate(e):r[ji(t,i)].evaluate(e)}},{key:"eachChild",value:function(e){for(var t of(e(this.input),this.outputs))e(t)}},{key:"outputDefined",value:function(){return this.outputs.every((function(e){return e.outputDefined()}))}},{key:"serialize",value:function(){for(var e=["step",this.input.serialize()],t=0;t0&&e.push(this.labels[t]),e.push(this.outputs[t].serialize());return e}}],[{key:"parse",value:function(t,r){if(t.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return r.error("Expected an even number of arguments.");var i=r.parse(t[1],1,qt);if(!i)return null;var n=[],a=null;r.expectedType&&"value"!==r.expectedType.kind&&(a=r.expectedType);for(var o=1;o=s)return r.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',u);var h=r.parse(l,c,a);if(!h)return null;a=a||h.type,n.push([s,h])}return new e(a,i,n)}}])})(),qi=.95047,Zi=1.08883,$i=.13793103448275862,Hi=.12841854934601665,Wi=Math.PI/180,Xi=180/Math.PI;function Yi(e){return e>.008856451679035631?Math.pow(e,.3333333333333333):e/Hi+$i}function Ji(e){return e>.20689655172413793?e*e*e:Hi*(e-$i)}function Ki(e){return 255*(e<=.0031308?12.92*e:1.055*Math.pow(e,.4166666666666667)-.055)}function Qi(e){return(e/=255)<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function en(e){var t=Qi(e.r),r=Qi(e.g),i=Qi(e.b),n=Yi((.4124564*t+.3575761*r+.1804375*i)/qi),a=Yi((.2126729*t+.7151522*r+.072175*i)/1);return{l:116*a-16,a:500*(n-a),b:200*(a-Yi((.0193339*t+.119192*r+.9503041*i)/Zi)),alpha:e.a}}function tn(e){var t=(e.l+16)/116,r=isNaN(e.a)?t:t+e.a/500,i=isNaN(e.b)?t:t-e.b/200;return t=1*Ji(t),r=qi*Ji(r),i=Zi*Ji(i),new Lt(Ki(3.2404542*r-1.5371385*t-.4985314*i),Ki(-.969266*r+1.8760108*t+.041556*i),Ki(.0556434*r-.2040259*t+1.0572252*i),e.alpha)}function rn(e,t,r){var i=t-e;return e+r*(i>180||i<-180?i-360*Math.round(i/360):i)}var nn={forward:en,reverse:tn,interpolate:function(e,t,r){return{l:Ft(e.l,t.l,r),a:Ft(e.a,t.a,r),b:Ft(e.b,t.b,r),alpha:Ft(e.alpha,t.alpha,r)}}},an={forward:function(e){var t=en(e),r=t.l,i=t.a,n=t.b,a=Math.atan2(n,i)*Xi;return{h:a<0?a+360:a,c:Math.sqrt(i*i+n*n),l:r,alpha:e.a}},reverse:function(e){var t=e.h*Wi,r=e.c;return tn({l:e.l,a:Math.cos(t)*r,b:Math.sin(t)*r,alpha:e.alpha})},interpolate:function(e,t,r){return{h:rn(e.h,t.h,r),c:Ft(e.c,t.c,r),l:Ft(e.l,t.l,r),alpha:Ft(e.alpha,t.alpha,r)}}},on=Object.freeze({__proto__:null,hcl:an,lab:nn}),sn=(function(){function e(t,r,i,n,a){for(var o of(p(this,e),this.type=t,this.operator=r,this.interpolation=i,this.input=n,this.labels=[],this.outputs=[],a)){var s=x(o,2),l=s[0],u=s[1];this.labels.push(l),this.outputs.push(u)}}return m(e,[{key:"evaluate",value:function(t){var r=this.labels,i=this.outputs;if(1===r.length)return i[0].evaluate(t);var n=this.input.evaluate(t);if(n<=r[0])return i[0].evaluate(t);var a=r.length;if(n>=r[a-1])return i[a-1].evaluate(t);var o=ji(r,n),s=e.interpolationFactor(this.interpolation,n,r[o],r[o+1]),l=i[o].evaluate(t),u=i[o+1].evaluate(t);return"interpolate"===this.operator?Nt[this.type.kind.toLowerCase()](l,u,s):"interpolate-hcl"===this.operator?an.reverse(an.interpolate(an.forward(l),an.forward(u),s)):nn.reverse(nn.interpolate(nn.forward(l),nn.forward(u),s))}},{key:"eachChild",value:function(e){for(var t of(e(this.input),this.outputs))e(t)}},{key:"outputDefined",value:function(){return this.outputs.every((function(e){return e.outputDefined()}))}},{key:"serialize",value:function(){var e;e="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);for(var t=[this.operator,e,this.input.serialize()],r=0;r1})))return r.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);a={name:"cubic-bezier",controlPoints:u}}if(t.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return r.error("Expected an even number of arguments.");if(!(o=r.parse(o,2,qt)))return null;var c=[],h=null;"interpolate-hcl"===n||"interpolate-lab"===n?h=Ht:r.expectedType&&"value"!==r.expectedType.kind&&(h=r.expectedType);for(var d=0;d=p)return r.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',v);var g=r.parse(m,_,h);if(!g)return null;h=h||g.type,c.push([p,g])}return"number"===h.kind||"color"===h.kind||"array"===h.kind&&"number"===h.itemType.kind&&"number"==typeof h.N?new e(h,n,a,o,c):r.error(`Type ${er(h)} is not interpolatable.`)}}])})();function ln(e,t,r,i){var n=i-r,a=e-r;return 0===n?0:1===t?a/n:(Math.pow(t,a)-1)/(Math.pow(t,n)-1)}var un=(function(){function e(t,r){p(this,e),this.type=t,this.args=r}return m(e,[{key:"evaluate",value:function(e){var t,r=null,i=0;for(var n of this.args){if(i++,(r=n.evaluate(e))&&r instanceof lr&&!r.available&&(t||(t=r),r=null,i===this.args.length))return t;if(null!==r)break}return r}},{key:"eachChild",value:function(e){this.args.forEach(e)}},{key:"outputDefined",value:function(){return this.args.every((function(e){return e.outputDefined()}))}},{key:"serialize",value:function(){var e=["coalesce"];return this.eachChild((function(t){e.push(t.serialize())})),e}}],[{key:"parse",value:function(t,r){if(t.length<2)return r.error("Expectected at least one argument.");var i=null,n=r.expectedType;n&&"value"!==n.kind&&(i=n);var a=[];for(var o of t.slice(1)){var s=r.parse(o,1+a.length,i,void 0,{typeAnnotation:"omit"});if(!s)return null;i=i||s.type,a.push(s)}var l=n&&a.some((function(e){return rr(n,e.type)}));return new e(l?Xt:i,a)}}])})(),cn=(function(){function e(t,r){p(this,e),this.type=r.type,this.bindings=[].concat(t),this.result=r}return m(e,[{key:"evaluate",value:function(e){return this.result.evaluate(e)}},{key:"eachChild",value:function(e){for(var t of this.bindings)e(t[1]);e(this.result)}},{key:"outputDefined",value:function(){return this.result.outputDefined()}},{key:"serialize",value:function(){var e=["let"];for(var t of this.bindings){var r=x(t,2),i=r[0],n=r[1];e.push(i,n.serialize())}return e.push(this.result.serialize()),e}}],[{key:"parse",value:function(t,r){if(t.length<4)return r.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);for(var i=[],n=1;nr.length-1)throw new pr(`Array index out of bounds: ${t} > ${r.length-1}.`);if(t===Math.floor(t))return r[t];var i=Math.floor(t),n=Math.ceil(t),a=r[i],o=r[n];if("number"!=typeof a||"number"!=typeof o)throw new pr(`Cannot interpolate between non-number values at index ${t}.`);var s=t-i;return a*(1-s)+o*s}},{key:"eachChild",value:function(e){e(this.index),e(this.input)}},{key:"outputDefined",value:function(){return!1}},{key:"serialize",value:function(){return["at",this.index.serialize(),this.input.serialize()]}}],[{key:"parse",value:function(t,r){if(3!==t.length)return r.error(`Expected 2 arguments, but found ${t.length-1} instead.`);var i=r.parse(t[1],1,qt),n=r.parse(t[2],2,Qt(r.expectedType||Xt));return i&&n?new e(n.type.itemType,i,n):null}}])})(),fn=(function(){function e(t,r){p(this,e),this.type=$t,this.needle=t,this.haystack=r}return m(e,[{key:"evaluate",value:function(e){var t=this.needle.evaluate(e),r=this.haystack.evaluate(e);if(null==r)return!1;if(!nr(t,["boolean","string","number","null"]))throw new pr(`Expected first argument to be of type boolean, string, number or null, but found ${er(hr(t))} instead.`);if(!nr(r,["string","array"]))throw new pr(`Expected second argument to be of type array or string, but found ${er(hr(r))} instead.`);return r.indexOf(t)>=0}},{key:"eachChild",value:function(e){e(this.needle),e(this.haystack)}},{key:"outputDefined",value:function(){return!0}},{key:"serialize",value:function(){return["in",this.needle.serialize(),this.haystack.serialize()]}}],[{key:"parse",value:function(t,r){if(3!==t.length)return r.error(`Expected 2 arguments, but found ${t.length-1} instead.`);var i=r.parse(t[1],1,Xt),n=r.parse(t[2],2,Xt);return i&&n?ir(i.type,[$t,Zt,qt,Gt,Xt])?new e(i,n):r.error(`Expected first argument to be of type boolean, string, number or null, but found ${er(i.type)} instead`):null}}])})(),dn=(function(){function e(t,r,i){p(this,e),this.type=qt,this.needle=t,this.haystack=r,this.fromIndex=i}return m(e,[{key:"evaluate",value:function(e){var t=this.needle.evaluate(e),r=this.haystack.evaluate(e);if(!nr(t,["boolean","string","number","null"]))throw new pr(`Expected first argument to be of type boolean, string, number or null, but found ${er(hr(t))} instead.`);if(!nr(r,["string","array"]))throw new pr(`Expected second argument to be of type array or string, but found ${er(hr(r))} instead.`);if(this.fromIndex){var i=this.fromIndex.evaluate(e);return r.indexOf(t,i)}return r.indexOf(t)}},{key:"eachChild",value:function(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}},{key:"outputDefined",value:function(){return!1}},{key:"serialize",value:function(){if(null!=this.fromIndex&&void 0!==this.fromIndex){var e=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),e]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}],[{key:"parse",value:function(t,r){if(t.length<=2||t.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);var i=r.parse(t[1],1,Xt),n=r.parse(t[2],2,Xt);if(!i||!n)return null;if(!ir(i.type,[$t,Zt,qt,Gt,Xt]))return r.error(`Expected first argument to be of type boolean, string, number or null, but found ${er(i.type)} instead`);if(4===t.length){var a=r.parse(t[3],3,qt);return a?new e(i,n,a):null}return new e(i,n)}}])})(),pn=(function(){function e(t,r,i,n,a,o){p(this,e),this.inputType=t,this.type=r,this.input=i,this.cases=n,this.outputs=a,this.otherwise=o}return m(e,[{key:"evaluate",value:function(e){var t=this.input.evaluate(e);return(hr(t)===this.inputType&&this.outputs[this.cases[t]]||this.otherwise).evaluate(e)}},{key:"eachChild",value:function(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}},{key:"outputDefined",value:function(){return this.outputs.every((function(e){return e.outputDefined()}))&&this.otherwise.outputDefined()}},{key:"serialize",value:function(){var e=this,t=["match",this.input.serialize()],r=Object.keys(this.cases).sort(),i=[],n={};for(var a of r){var o=n[this.cases[a]];void 0===o?(n[this.cases[a]]=i.length,i.push([this.cases[a],[a]])):i[o][1].push(a)}var s=function(t){return"number"===e.inputType.kind?Number(t):t};for(var l of i){var u=x(l,2),c=u[0],h=u[1];t.push(1===h.length?s(h[0]):h.map(s)),t.push(this.outputs[c].serialize())}return t.push(this.otherwise.serialize()),t}}],[{key:"parse",value:function(t,r){if(t.length<5)return r.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return r.error("Expected an even number of arguments.");var i,n;r.expectedType&&"value"!==r.expectedType.kind&&(n=r.expectedType);for(var a={},o=[],s=2;sNumber.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof h&&Math.floor(h)!==h)return c.error("Numeric branch labels must be integer values.");if(i){if(c.checkSubtype(i,hr(h)))return null}else i=hr(h);if(void 0!==a[String(h)])return c.error("Branch labels must be unique.");a[String(h)]=o.length}var f=r.parse(u,s,n);if(!f)return null;n=n||f.type,o.push(f)}var d=r.parse(t[1],1,Xt);if(!d)return null;var p=r.parse(t[t.length-1],t.length-1,n);return p?"value"!==d.type.kind&&r.concat(1).checkSubtype(i,d.type)?null:new e(i,n,d,a,o,p):null}}])})(),mn=(function(){function e(t,r,i){p(this,e),this.type=t,this.branches=r,this.otherwise=i}return m(e,[{key:"evaluate",value:function(e){for(var t of this.branches){var r=x(t,2),i=r[0],n=r[1];if(i.evaluate(e))return n.evaluate(e)}return this.otherwise.evaluate(e)}},{key:"eachChild",value:function(e){for(var t of this.branches){var r=x(t,2),i=r[0],n=r[1];e(i),e(n)}e(this.otherwise)}},{key:"outputDefined",value:function(){return this.branches.every((function(e){var t=x(e,2);t[0];return t[1].outputDefined()}))&&this.otherwise.outputDefined()}},{key:"serialize",value:function(){var e=["case"];return this.eachChild((function(t){e.push(t.serialize())})),e}}],[{key:"parse",value:function(t,r){if(t.length<4)return r.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return r.error("Expected an odd number of arguments.");var i;r.expectedType&&"value"!==r.expectedType.kind&&(i=r.expectedType);for(var n=[],a=1;a=5)return r.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);var i=r.parse(t[1],1,Xt),n=r.parse(t[2],2,qt);if(!i||!n)return null;if(!ir(i.type,[Qt(Xt),Zt,Xt]))return r.error(`Expected first argument to be of type array or string, but found ${er(i.type)} instead`);if(4===t.length){var a=r.parse(t[3],3,qt);return a?new e(i.type,i,n,a):null}return new e(i.type,i,n)}}])})();function _n(e,t){return"=="===e||"!="===e?"boolean"===t.kind||"string"===t.kind||"number"===t.kind||"null"===t.kind||"value"===t.kind:"string"===t.kind||"number"===t.kind||"value"===t.kind}function gn(e,t,r,i){return 0===i.compare(t,r)}function yn(e,t,r){var i="=="!==e&&"!="!==e;return(function(){function n(e,t,r){p(this,n),this.type=$t,this.lhs=e,this.rhs=t,this.collator=r,this.hasUntypedArgument="value"===e.type.kind||"value"===t.type.kind}return m(n,[{key:"evaluate",value:function(n){var a=this.lhs.evaluate(n),o=this.rhs.evaluate(n);if(i&&this.hasUntypedArgument){var s=hr(a),l=hr(o);if(s.kind!==l.kind||"string"!==s.kind&&"number"!==s.kind)throw new pr(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${s.kind}, ${l.kind}) instead.`)}if(this.collator&&!i&&this.hasUntypedArgument){var u=hr(a),c=hr(o);if("string"!==u.kind||"string"!==c.kind)return t(n,a,o)}return this.collator?r(n,a,o,this.collator.evaluate(n)):t(n,a,o)}},{key:"eachChild",value:function(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}},{key:"outputDefined",value:function(){return!0}},{key:"serialize",value:function(){var t=[e];return this.eachChild((function(e){t.push(e.serialize())})),t}}],[{key:"parse",value:function(e,t){if(3!==e.length&&4!==e.length)return t.error("Expected two or three arguments.");var r=e[0],a=t.parse(e[1],1,Xt);if(!a)return null;if(!_n(r,a.type))return t.concat(1).error(`"${r}" comparisons are not supported for type '${er(a.type)}'.`);var o=t.parse(e[2],2,Xt);if(!o)return null;if(!_n(r,o.type))return t.concat(2).error(`"${r}" comparisons are not supported for type '${er(o.type)}'.`);if(a.type.kind!==o.type.kind&&"value"!==a.type.kind&&"value"!==o.type.kind)return t.error(`Cannot compare types '${er(a.type)}' and '${er(o.type)}'.`);i&&("value"===a.type.kind&&"value"!==o.type.kind?a=new vr(o.type,[a]):"value"!==a.type.kind&&"value"===o.type.kind&&(o=new vr(a.type,[o])));var s=null;if(4===e.length){if("string"!==a.type.kind&&"string"!==o.type.kind&&"value"!==a.type.kind&&"value"!==o.type.kind)return t.error("Cannot use collator to compare non-string types.");if(!(s=t.parse(e[3],3,Yt)))return null}return new n(a,o,s)}}])})()}var xn=yn("==",(function(e,t,r){return t===r}),gn),bn=yn("!=",(function(e,t,r){return t!==r}),(function(e,t,r,i){return!gn(0,t,r,i)})),wn=yn("<",(function(e,t,r){return t",(function(e,t,r){return t>r}),(function(e,t,r,i){return i.compare(t,r)>0})),Tn=yn("<=",(function(e,t,r){return t<=r}),(function(e,t,r,i){return i.compare(t,r)<=0})),Sn=yn(">=",(function(e,t,r){return t>=r}),(function(e,t,r,i){return i.compare(t,r)>=0})),En=(function(){function e(t,r,i,n,a,o){p(this,e),this.type=Zt,this.number=t,this.locale=r,this.currency=i,this.unit=n,this.minFractionDigits=a,this.maxFractionDigits=o}return m(e,[{key:"evaluate",value:function(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(e):void 0,unit:this.unit?this.unit.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}},{key:"eachChild",value:function(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.unit&&e(this.unit),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}},{key:"outputDefined",value:function(){return!1}},{key:"serialize",value:function(){var e={};return this.locale&&(e.locale=this.locale.serialize()),this.currency&&(e.currency=this.currency.serialize()),this.unit&&(e.unit=this.unit.serialize()),this.minFractionDigits&&(e["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(e["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),e]}}],[{key:"parse",value:function(t,r){if(3!==t.length)return r.error("Expected two arguments.");var i=r.parse(t[1],1,qt);if(!i)return null;var n=t[2];if("object"!=typeof n||Array.isArray(n))return r.error("NumberFormat options argument must be an object.");var a=null;if(n.locale&&!(a=r.parseObjectValue(n.locale,2,"locale",Zt)))return null;var o=null;if(n.currency&&!(o=r.parseObjectValue(n.currency,2,"currency",Zt)))return null;var s=null;if(n.unit&&!(s=r.parseObjectValue(n.unit,2,"unit",Zt)))return null;var l=null;if(n["min-fraction-digits"]&&!(l=r.parseObjectValue(n["min-fraction-digits"],2,"min-fraction-digits",qt)))return null;var u=null;return n["max-fraction-digits"]&&!(u=r.parseObjectValue(n["max-fraction-digits"],2,"max-fraction-digits",qt))?null:new e(i,a,o,s,l,u)}}])})(),Mn=(function(){function e(t){p(this,e),this.type=qt,this.input=t}return m(e,[{key:"evaluate",value:function(e){var t=this.input.evaluate(e);if("string"==typeof t)return t.length;if(Array.isArray(t))return t.length;throw new pr(`Expected value to be of type string or array, but found ${er(hr(t))} instead.`)}},{key:"eachChild",value:function(e){e(this.input)}},{key:"outputDefined",value:function(){return!1}},{key:"serialize",value:function(){var e=["length"];return this.eachChild((function(t){e.push(t.serialize())})),e}}],[{key:"parse",value:function(t,r){if(2!==t.length)return r.error(`Expected 1 argument, but found ${t.length-1} instead.`);var i=r.parse(t[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?r.error(`Expected argument of type string or array, but found ${er(i.type)} instead.`):new e(i):null}}])})();function An(e){return function(){e=1831565813+(e|=0)|0;var t=Math.imul(e^e>>>15,1|e);return(((t=t+Math.imul(t^t>>>7,61|t)^t)^t>>>14)>>>0)/4294967296}}var In={"==":xn,"!=":bn,">":kn,"<":wn,">=":Sn,"<=":Tn,array:vr,at:hn,boolean:vr,case:mn,coalesce:un,collator:Er,format:_r,image:gr,in:fn,"index-of":dn,interpolate:sn,"interpolate-hcl":sn,"interpolate-lab":sn,length:Mn,let:cn,literal:dr,match:pn,number:vr,"number-format":En,object:vr,slice:vn,step:Gi,string:vr,"to-boolean":br,"to-color":br,"to-number":br,"to-string":br,var:Bi,within:Wr,distance:Ci,config:Di};function Cn(e,t){var r=x(t,4),i=r[0],n=r[1],a=r[2],o=r[3];i=i.evaluate(e),n=n.evaluate(e),a=a.evaluate(e);var s=o?o.evaluate(e):1,l=ur(i,n,a,s);if(l)throw new pr(l);return new Lt(i/255*s,n/255*s,a/255*s,s)}function Pn(e,t){var r=x(t,4),i=r[0],n=r[1],a=r[2],o=r[3];i=i.evaluate(e),n=n.evaluate(e),a=a.evaluate(e);var s=o?o.evaluate(e):1,l=(function(e,t,r,i){return"number"==typeof e&&e>=0&&e<=360?"number"==typeof t&&t>=0&&t<=100&&"number"==typeof r&&r>=0&&r<=100?void 0===i||"number"==typeof i&&i>=0&&i<=1?null:`Invalid hsla value [${[e,t,r,i].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${("number"==typeof i?[e,t,r,i]:[e,t,r]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${("number"==typeof i?[e,t,r,i]:[e,t,r]).join(", ")}]: 'h' must be between 0 and 360.`})(i,n,a,s);if(l)throw new pr(l);var u=`hsla(${i}, ${n}%, ${a}%, ${s})`,c=Lt.parse(u);if(!c)throw new pr(`Failed to parse HSLA color: ${u}`);return c}function zn(e,t){return e in t}function Dn(e,t){var r=t[e];return void 0===r?null:r}function Rn(e){return{type:e}}function Ln(e){return{result:"success",value:e}}function On(e){return{result:"error",value:e}}function Fn(e,t){return!!e&&!!e.parameters&&e.parameters.indexOf(t)>-1}function Bn(e){return"data-driven"===e["property-type"]}function Nn(e){return Fn(e.expression,"measure-light")}function Vn(e){return Fn(e.expression,"zoom")}function Un(e){return!!e.expression&&e.expression.interpolated}function jn(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Gn(e){return e}function qn(e,t){var r,i,n,a="color"===t.type,o=e.stops&&"object"==typeof e.stops[0][0],s=o||!(o||void 0!==e.property),l=e.type||(Un(t)?"exponential":"interval");if(a&&((e=Vt({},e)).stops&&(e.stops=e.stops.map((function(e){return[e[0],Lt.parse(e[1])]}))),e.default=Lt.parse(e.default?e.default:t.default)),e.colorSpace&&"rgb"!==e.colorSpace&&!on[e.colorSpace])throw new Error(`Unknown color space: ${e.colorSpace}`);if("exponential"===l)r=Wn;else if("interval"===l)r=Hn;else if("categorical"===l){for(var u of(r=$n,i=Object.create(null),e.stops))i[u[0]]=u[1];n=typeof e.stops[0][0]}else{if("identity"!==l)throw new Error(`Unknown function type "${l}"`);r=Xn}if(o){for(var c={},h=[],f=0;f=e.stops[i-1][0])return e.stops[i-1][1];var n=ji(e.stops.map((function(e){return e[0]})),r);return e.stops[n][1]}function Wn(e,t,r){var i=void 0!==e.base?e.base:1;if("number"!==yr(r))return Zn(e.default,t.default);var n=e.stops.length;if(1===n)return e.stops[0][1];if(r<=e.stops[0][0])return e.stops[0][1];if(r>=e.stops[n-1][0])return e.stops[n-1][1];var a=ji(e.stops.map((function(e){return e[0]})),r),o=(function(e,t,r,i){var n=i-r,a=e-r;return 0===n?0:1===t?a/n:(Math.pow(t,a)-1)/(Math.pow(t,n)-1)})(r,i,e.stops[a][0],e.stops[a+1][0]),s=e.stops[a][1],l=e.stops[a+1][1],u=Nt[t.type]||Gn;if(e.colorSpace&&"rgb"!==e.colorSpace){var c=on[e.colorSpace];u=function(e,t){return c.reverse(c.interpolate(c.forward(e),c.forward(t),o))}}return"function"==typeof s.evaluate?{evaluate:function(){for(var e=arguments.length,t=new Array(e),r=0;r":[$t,[Zt,Xt],function(e,t){var r=x(t,2),i=r[0],n=r[1],a=e.properties()[i.value],o=n.value;return typeof a==typeof o&&a>o}],"filter-id->":[$t,[Xt],function(e,t){var r=x(t,1)[0],i=e.id(),n=r.value;return typeof i==typeof n&&i>n}],"filter-<=":[$t,[Zt,Xt],function(e,t){var r=x(t,2),i=r[0],n=r[1],a=e.properties()[i.value],o=n.value;return typeof a==typeof o&&a<=o}],"filter-id-<=":[$t,[Xt],function(e,t){var r=x(t,1)[0],i=e.id(),n=r.value;return typeof i==typeof n&&i<=n}],"filter->=":[$t,[Zt,Xt],function(e,t){var r=x(t,2),i=r[0],n=r[1],a=e.properties()[i.value],o=n.value;return typeof a==typeof o&&a>=o}],"filter-id->=":[$t,[Xt],function(e,t){var r=x(t,1)[0],i=e.id(),n=r.value;return typeof i==typeof n&&i>=n}],"filter-has":[$t,[Xt],function(e,t){return x(t,1)[0].value in e.properties()}],"filter-has-id":[$t,[],function(e){return null!==e.id()&&void 0!==e.id()}],"filter-type-in":[$t,[Qt(Zt)],function(e,t){return x(t,1)[0].value.indexOf(e.geometryType())>=0}],"filter-id-in":[$t,[Qt(Xt)],function(e,t){return x(t,1)[0].value.indexOf(e.id())>=0}],"filter-in-small":[$t,[Zt,Qt(Xt)],function(e,t){var r=x(t,2),i=r[0];return r[1].value.indexOf(e.properties()[i.value])>=0}],"filter-in-large":[$t,[Zt,Qt(Xt)],function(e,t){var r=x(t,2),i=r[0],n=r[1];return(function(e,t,r,i){for(;r<=i;){var n=r+i>>1;if(t[n]===e)return!0;t[n]>e?i=n-1:r=n+1}return!1})(e.properties()[i.value],n.value,0,n.value.length-1)}],all:{type:$t,overloads:[[[$t,$t],function(e,t){var r=x(t,2),i=r[0],n=r[1];return i.evaluate(e)&&n.evaluate(e)}],[Rn($t),function(e,t){for(var r of t)if(!r.evaluate(e))return!1;return!0}]]},any:{type:$t,overloads:[[[$t,$t],function(e,t){var r=x(t,2),i=r[0],n=r[1];return i.evaluate(e)||n.evaluate(e)}],[Rn($t),function(e,t){for(var r of t)if(r.evaluate(e))return!0;return!1}]]},"!":[$t,[$t],function(e,t){return!x(t,1)[0].evaluate(e)}],"is-supported-script":[$t,[Zt],function(e,t){var r=x(t,1)[0],i=e.globals&&e.globals.isSupportedScript;return!i||i(r.evaluate(e))}],upcase:[Zt,[Zt],function(e,t){return x(t,1)[0].evaluate(e).toUpperCase()}],downcase:[Zt,[Zt],function(e,t){return x(t,1)[0].evaluate(e).toLowerCase()}],concat:[Zt,Rn(Xt),function(e,t){return t.map((function(t){return fr(t.evaluate(e))})).join("")}],"resolved-locale":[Zt,[Yt],function(e,t){return x(t,1)[0].evaluate(e).resolvedLocale()}],random:[qt,[qt,qt,Xt],function(e,t){var r,i=t.map((function(t){return t.evaluate(e)})),n=x(i,3),a=n[0],o=n[1],s=n[2];if(a>o)return a;if(a===o)return a;if("string"==typeof s)r=(function(e){var t=0;if(0===e.length)return t;for(var r=0;r0&&"string"==typeof e[0]&&e[0]in In}function Kn(e,t,r,i){var n=new Vi(In,[],t?(function(e){var t={color:Ht,string:Zt,number:qt,enum:Zt,boolean:$t,formatted:Jt,resolvedImage:Kt};return"array"===e.type?Qt(t[e.value]||Xt,e.length):t[e.type]})(t):void 0,void 0,void 0,r,i),a=n.parse(e,void 0,void 0,void 0,t&&"string"===t.type?{typeAnnotation:"coerce"}:void 0);return a?Ln(new Yn(a,t,r,i)):On(n.errors)}var Qn=(function(){return m((function e(t,r,i){p(this,e),this.kind=t,this._styleExpression=r,this.isLightConstant=i,this.isStateDependent="constant"!==t&&!Li(r.expression),this.configDependencies=Oi(r.expression)}),[{key:"evaluateWithoutErrorHandling",value:function(e,t,r,i,n,a){return this._styleExpression.evaluateWithoutErrorHandling(e,t,r,i,n,a)}},{key:"evaluate",value:function(e,t,r,i,n,a){return this._styleExpression.evaluate(e,t,r,i,n,a)}}])})(),ea=(function(){return m((function e(t,r,i,n,a){p(this,e),this.kind=t,this.zoomStops=i,this._styleExpression=r,this.isStateDependent="camera"!==t&&!Li(r.expression),this.isLightConstant=a,this.configDependencies=Oi(r.expression),this.interpolationType=n}),[{key:"evaluateWithoutErrorHandling",value:function(e,t,r,i,n,a){return this._styleExpression.evaluateWithoutErrorHandling(e,t,r,i,n,a)}},{key:"evaluate",value:function(e,t,r,i,n,a){return this._styleExpression.evaluate(e,t,r,i,n,a)}},{key:"interpolationFactor",value:function(e,t,r){return this.interpolationType?sn.interpolationFactor(this.interpolationType,e,t,r):0}}])})();function ta(e,t,r,i){if("error"===(e=Kn(e,t,r,i)).result)return e;var n=e.value.expression,a=Ri(n);if(!a&&!Bn(t))return On([new Ut("","data expressions not supported")]);var o=Fi(n,["zoom","pitch","distance-from-center"]);if(!o&&!Vn(t))return On([new Ut("","zoom expressions not supported")]);var s=Fi(n,["measure-light"]);if(!s&&!Nn(t))return On([new Ut("","measure-light expression not supported")]);var l=Fi(n,["line-progress"]);if(!l&&!(function(e){return Fn(e.expression,"line-progress")})(t))return On([new Ut("","line-progress expression not supported")]);var u=t.expression&&t.expression.relaxZoomRestriction,c=ia(n);return c||o||u?c instanceof Ut?On([c]):c instanceof sn&&!Un(t)?On([new Ut("",'"interpolate" expressions cannot be used with this property')]):Ln(c?new ea(a&&l?"camera":"composite",e.value,c.labels,c instanceof sn?c.interpolation:void 0,s):new Qn(a&&l?"constant":"source",e.value,s)):On([new Ut("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}var ra=(function(){function e(t,r){p(this,e),this._parameters=t,this._specification=r,Vt(this,qn(this._parameters,this._specification))}return m(e,null,[{key:"deserialize",value:function(t){return new e(t._parameters,t._specification)}},{key:"serialize",value:function(e){return{_parameters:e._parameters,_specification:e._specification}}}])})();function ia(e){var t=null;if(e instanceof cn)t=ia(e.result);else if(e instanceof un){for(var r of e.args)if(t=ia(r))break}else(e instanceof Gi||e instanceof sn)&&e.input instanceof Tr&&"zoom"===e.input.name&&(t=e);return t instanceof Ut||e.eachChild((function(e){var r=ia(e);r instanceof Ut?t=r:t&&r&&t!==r&&(t=new Ut("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),t}var na,aa,oa=(function(){if(aa)return na;aa=1,na=t;var e=3;function t(t,r,i){var n=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;var a=new Int32Array(this.arrayBuffer);t=a[0],this.d=(r=a[1])+2*(i=a[2]);for(var o=0;o=c[d+0]&&i>=c[d+1])?(o[f]=!0,a.push(u[f])):o[f]=!1}}},t.prototype._forEachCell=function(e,t,r,i,n,a,o,s){for(var l=this._convertToCellCoord(e),u=this._convertToCellCoord(t),c=this._convertToCellCoord(r),h=this._convertToCellCoord(i),f=l;f<=c;f++)for(var d=u;d<=h;d++){var p=this.d*d+f;if((!s||s(this._convertFromCellCoord(f),this._convertFromCellCoord(d),this._convertFromCellCoord(f+1),this._convertFromCellCoord(d+1)))&&n.call(this,e,t,r,i,p,a,o,s))return}},t.prototype._convertFromCellCoord=function(e){return(e-this.padding)/this.scale},t.prototype._convertToCellCoord=function(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))},t.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var t=this.cells,r=e+this.cells.length+1+1,i=0,n=0;n2&&void 0!==arguments[2]?arguments[2]:{};Object.defineProperty(e,"_classRegistryKey",{value:t,writable:!1}),la[t]={klass:e,omit:r.omit||[]}}for(var ca in ua(Object,"Object"),sa.serialize=function(e,t){var r=e.toArrayBuffer();return t&&t.add(r),{buffer:r}},sa.deserialize=function(e){return new sa(e.buffer)},Object.defineProperty(sa,"name",{value:"Grid"}),ua(sa,"Grid"),ua(Lt,"Color"),ua(Error,"Error"),ua(sr,"Formatted"),ua(or,"FormattedSection"),ua(ct,"AJAXError"),ua(lr,"ResolvedImage"),ua(ra,"StylePropertyFunction"),ua(Yn,"StyleExpression",{omit:["_evaluator"]}),ua(ea,"ZoomDependentExpression"),ua(Qn,"ZoomConstantExpression"),ua(Tr,"CompoundExpression",{omit:["_evaluate"]}),In)la[In[ca]._classRegistryKey]||ua(In[ca],`Expression${ca}`);function ha(e){return e&&"undefined"!=typeof ArrayBuffer&&(e instanceof ArrayBuffer||e.constructor&&"ArrayBuffer"===e.constructor.name)}function fa(e){return self.ImageBitmap&&e instanceof ImageBitmap}function da(e,t){if(null==e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||e instanceof Boolean||e instanceof Number||e instanceof String||e instanceof Date||e instanceof RegExp)return e;if(ha(e)||fa(e))return t&&t.add(e),e;if(ArrayBuffer.isView(e)){var r=e;return t&&t.add(r.buffer),r}if(e instanceof ImageData)return t&&t.add(e.data.buffer),e;if(Array.isArray(e)){var i=[];for(var n of e)i.push(da(n,t));return i}if(e instanceof Map){var a={$name:"Map"};for(var o of e.entries()){var s=x(o,2),l=s[0],u=s[1];a[l]=da(u)}return a}if(e instanceof Set){var c={$name:"Set"},h=0;for(var f of e.values())c[++h]=da(f);return c}if("object"==typeof e){var d=e.constructor,p=d._classRegistryKey;if(!p)throw new Error(`can't serialize object of unregistered class ${p}`);var m=d.serialize?d.serialize(e,t):{};if(!d.serialize){for(var v in e)e.hasOwnProperty(v)&&(la[p].omit.indexOf(v)>=0||(m[v]=da(e[v],t)));e instanceof Error&&(m.message=e.message)}if(m.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==p&&(m.$name=p),m}throw new Error("can't serialize object of type "+typeof e)}function pa(e){if(null==e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||e instanceof Boolean||e instanceof Number||e instanceof String||e instanceof Date||e instanceof RegExp||ha(e)||fa(e)||ArrayBuffer.isView(e)||e instanceof ImageData)return e;if(Array.isArray(e))return e.map(pa);if("object"==typeof e){var t=e.$name||"Object";if("Map"===t){var r=new Map;for(var i of Object.keys(e))"$name"!==i&&r.set(i,pa(e[i]));return r}if("Set"===t){var n=new Set;for(var a of Object.keys(e))"$name"!==a&&n.add(pa(e[a]));return n}var o=la[t].klass;if(!o)throw new Error(`can't deserialize unregistered class ${t}`);if(o.deserialize)return o.deserialize(e);var s=Object.create(o.prototype);for(var l of Object.keys(e))"$name"!==l&&(s[l]=pa(e[l]));return s}throw new Error("can't deserialize object of type "+typeof e)}var ma=function(e){return e>=128&&e<=255},va=function(e){return e>=1536&&e<=1791},_a=function(e){return e>=1872&&e<=1919},ga=function(e){return e>=2208&&e<=2303},ya=function(e){return e>=4352&&e<=4607},xa=function(e){return e>=5120&&e<=5759},ba=function(e){return e>=6016&&e<=6143},wa=function(e){return e>=6320&&e<=6399},ka=function(e){return e>=8192&&e<=8303},Ta=function(e){return e>=8448&&e<=8527},Sa=function(e){return e>=8528&&e<=8591},Ea=function(e){return e>=8960&&e<=9215},Ma=function(e){return e>=9216&&e<=9279},Aa=function(e){return e>=9280&&e<=9311},Ia=function(e){return e>=9312&&e<=9471},Ca=function(e){return e>=9632&&e<=9727},Pa=function(e){return e>=9728&&e<=9983},za=function(e){return e>=11008&&e<=11263},Da=function(e){return e>=11904&&e<=12031},Ra=function(e){return e>=12032&&e<=12255},La=function(e){return e>=12272&&e<=12287},Oa=function(e){return e>=12288&&e<=12351},Fa=function(e){return e>=12352&&e<=12447},Ba=function(e){return e>=12448&&e<=12543},Na=function(e){return e>=12544&&e<=12591},Va=function(e){return e>=12592&&e<=12687},Ua=function(e){return e>=12688&&e<=12703},ja=function(e){return e>=12704&&e<=12735},Ga=function(e){return e>=12736&&e<=12783},qa=function(e){return e>=12784&&e<=12799},Za=function(e){return e>=12800&&e<=13055},$a=function(e){return e>=13056&&e<=13311},Ha=function(e){return e>=13312&&e<=19903},Wa=function(e){return e>=19904&&e<=19967},Xa=function(e){return e>=19968&&e<=40959},Ya=function(e){return e>=40960&&e<=42127},Ja=function(e){return e>=42128&&e<=42191},Ka=function(e){return e>=43360&&e<=43391},Qa=function(e){return e>=44032&&e<=55215},eo=function(e){return e>=55216&&e<=55295},to=function(e){return e>=57344&&e<=63743},ro=function(e){return e>=63744&&e<=64255},io=function(e){return e>=64336&&e<=65023},no=function(e){return e>=65040&&e<=65055},ao=function(e){return e>=65072&&e<=65103},oo=function(e){return e>=65104&&e<=65135},so=function(e){return e>=65136&&e<=65279},lo=function(e){return e>=65280&&e<=65519},uo=function(e){return e>=66736&&e<=66815},co=function(e){return e>=131072&&e<=173791};function ho(e){for(var t of e)if(mo(t.charCodeAt(0)))return!0;return!1}function fo(e){for(var t of e)if(!po(t.charCodeAt(0)))return!1;return!0}function po(e){return!(va(e)||_a(e)||ga(e)||io(e)||so(e))}function mo(e){return!(746!==e&&747!==e&&(e<4352||!(ja(e)||Na(e)||ao(e)&&!(e>=65097&&e<=65103)||ro(e)||$a(e)||Da(e)||Ga(e)||!(!Oa(e)||e>=12296&&e<=12305||e>=12308&&e<=12319||12336===e)||Ha(e)||Xa(e)||Za(e)||Va(e)||Ka(e)||eo(e)||ya(e)||Qa(e)||Fa(e)||La(e)||Ua(e)||Ra(e)||qa(e)||Ba(e)&&12540!==e||!(!lo(e)||65288===e||65289===e||65293===e||e>=65306&&e<=65310||65339===e||65341===e||65343===e||e>=65371&&e<=65503||65507===e||e>=65512&&e<=65519)||!(!oo(e)||e>=65112&&e<=65118||e>=65123&&e<=65126)||xa(e)||wa(e)||no(e)||Wa(e)||Ya(e)||Ja(e))))}function vo(e){return!(mo(e)||(function(e){return!!(ma(e)&&(167===e||169===e||174===e||177===e||188===e||189===e||190===e||215===e||247===e)||ka(e)&&(8214===e||8224===e||8225===e||8240===e||8241===e||8251===e||8252===e||8258===e||8263===e||8264===e||8265===e||8273===e)||Ta(e)||Sa(e)||Ea(e)&&(e>=8960&&e<=8967||e>=8972&&e<=8991||e>=8996&&e<=9e3||9003===e||e>=9085&&e<=9114||e>=9150&&e<=9165||9167===e||e>=9169&&e<=9179||e>=9186&&e<=9215)||Ma(e)&&9251!==e||Aa(e)||Ia(e)||Ca(e)||Pa(e)&&!(e>=9754&&e<=9759)||za(e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||Oa(e)||Ba(e)||to(e)||ao(e)||oo(e)||lo(e)||8734===e||8756===e||8757===e||e>=9984&&e<=10087||e>=10102&&e<=10131||65532===e||65533===e)})(e))}function _o(e){return e>=1424&&e<=2303||io(e)||so(e)}function go(e,t){return!(!t&&_o(e)||e>=2304&&e<=3583||e>=3840&&e<=4255||ba(e))}function yo(e){for(var t of e)if(_o(t.charCodeAt(0)))return!0;return!1}var xo="deferred",bo="loading",wo="loaded",ko=null,To="unavailable",So=null,Eo=function(e){e&&"string"==typeof e&&e.indexOf("NetworkError")>-1&&(To="error"),ko&&ko(e)};function Mo(){Ao.fire(new Mt("pluginStateChange",{pluginStatus:To,pluginURL:So}))}var Ao=new zt,Io=function(){return To},Co=function(){if(To!==xo||!So)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");To=bo,Mo(),So&&dt({url:So},(function(e){e?Eo(e):(To=wo,Mo())}))},Po={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:function(){return To===wo||null!=Po.applyArabicShaping},isLoading:function(){return To===bo},setState:function(e){To=e.pluginStatus,So=e.pluginURL},isParsed:function(){return null!=Po.applyArabicShaping&&null!=Po.processBidirectionalText&&null!=Po.processStyledBidirectionalText},getPluginURL:function(){return So}},zo=(function(){return m((function e(t,r){p(this,e),this.zoom=t,r?(this.now=r.now,this.fadeDuration=r.fadeDuration,this.transition=r.transition,this.pitch=r.pitch,this.brightness=r.brightness):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0)}),[{key:"isSupportedScript",value:function(e){return(function(e,t){for(var r of e)if(!go(r.charCodeAt(0),t))return!1;return!0})(e,Po.isLoaded())}}])})(),Do=(function(){return m((function e(t,r,i,n){p(this,e),this.property=t,this.value=r,this.expression=(function(e,t,r,i){if(jn(e))return new ra(e,t);if(Jn(e)||Array.isArray(e)&&e.length>0){var n=ta(e,t,r,i);if("error"===n.result)throw new Error(n.value.map((function(e){return`${e.key}: ${e.message}`})).join(", "));return n.value}var a=e;return"string"==typeof e&&"color"===t.type&&(a=Lt.parse(e)),{kind:"constant",configDependencies:new Set,evaluate:function(){return a}}})(void 0===r?t.specification.default:r,t.specification,i,n)}),[{key:"isDataDriven",value:function(){return"source"===this.expression.kind||"composite"===this.expression.kind}},{key:"possiblyEvaluate",value:function(e,t,r){return this.property.possiblyEvaluate(this,e,t,r)}}])})(),Ro=(function(){return m((function e(t,r,i){p(this,e),this.property=t,this.value=new Do(t,void 0,r,i)}),[{key:"transitioned",value:function(e,t){return new Oo(this.property,this.value,t,fe({},e.transition,this.transition),e.now)}},{key:"untransitioned",value:function(){return new Oo(this.property,this.value,null,{},0)}}])})(),Lo=(function(){return m((function e(t,r,i){p(this,e),this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues),this._scope=r,this._options=i,this.configDependencies=new Set}),[{key:"getValue",value:function(e){return xe(this._values[e].value.value)}},{key:"setValue",value:function(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new Ro(this._values[e].property,this._scope,this._options)),this._values[e].value=new Do(this._values[e].property,null===t?void 0:xe(t),this._scope,this._options),this._values[e].value.expression.configDependencies&&(this.configDependencies=new Set([].concat(d(this.configDependencies),d(this._values[e].value.expression.configDependencies))))}},{key:"setTransitionOrValue",value:function(e,t){t&&(this._options=t);var r=this._properties.properties;if(e)for(var i in e){var n=e[i];if(_e(i,"-transition")){var a=i.slice(0,-11);r[a]&&this.setTransition(a,n)}else r.hasOwnProperty(i)&&this.setValue(i,n)}}},{key:"getTransition",value:function(e){return xe(this._values[e].transition)}},{key:"setTransition",value:function(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new Ro(this._values[e].property)),this._values[e].transition=xe(t)||void 0}},{key:"serialize",value:function(){var e={};for(var t of Object.keys(this._values)){var r=this.getValue(t);void 0!==r&&(e[t]=r);var i=this.getTransition(t);void 0!==i&&(e[`${t}-transition`]=i)}return e}},{key:"transitioned",value:function(e,t){var r=new Fo(this._properties);for(var i of Object.keys(this._values))r._values[i]=this._values[i].transitioned(e,t._values[i]);return r}},{key:"untransitioned",value:function(){var e=new Fo(this._properties);for(var t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}}])})(),Oo=(function(){return m((function e(t,r,i,n,a){p(this,e);var o=n.delay||0,s=n.duration||0;a=a||0,this.property=t,this.value=r,this.begin=a+o,this.end=this.begin+s,t.specification.transition&&(n.delay||n.duration)&&(this.prior=i)}),[{key:"possiblyEvaluate",value:function(e,t,r){var i=e.now||0,n=this.value.possiblyEvaluate(e,t,r),a=this.prior;if(a){if(i>this.end)return this.prior=null,n;if(this.value.isDataDriven())return this.prior=null,n;if(i":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 $o(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function Ho(e){if(Array.isArray(e))return e.map(Ho);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){var t={};for(var r in e)t[r]=Ho(e[r]);return t}return $o(e)}function Wo(e){if(!0===e||!1===e)return!0;if(!Array.isArray(e)||0===e.length)return!1;switch(e[0]){case"has":return e.length>=2&&"$id"!==e[1]&&"$type"!==e[1];case"in":return e.length>=3&&("string"!=typeof e[1]||Array.isArray(e[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==e.length||Array.isArray(e[1])||Array.isArray(e[2]);case"any":case"all":for(var t of e.slice(1))if(!Wo(t)&&"boolean"!=typeof t)return!1;return!0;default:return!0}}function Xo(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"fill";if(null==e)return{filter:function(){return!0},needGeometry:!1,needFeature:!1};Wo(e)||(e=rs(e));var n=e,a=!0;try{a=(function(e){if(!Ko(e))return e;var t=Ho(e);return Jo(t),t=Yo(t)})(n)}catch(e){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.\nThis is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md\nand paste the contents of this message in the report.\nThank you!\nFilter Expression:\n${JSON.stringify(n,null,2)}\n `)}var o=null,s=null;if("background"!==i&&"sky"!==i&&"slot"!==i){var l=Kn(a,s=Zo[`filter_${i}`],t,r);if("error"===l.result)throw new Error(l.value.map((function(e){return`${e.key}: ${e.message}`})).join(", "));o=function(e,t,r){return l.value.evaluate(e,t,{},r)}}var u=null,c=null;if(a!==n){var h=Kn(n,s,t,r);if("error"===h.result)throw new Error(h.value.map((function(e){return`${e.key}: ${e.message}`})).join(", "));u=function(e,t,r,i,n){return h.value.evaluate(e,t,{},r,void 0,void 0,i,n)},c=!Ri(h.value.expression)}return{filter:o,dynamicFilter:u||void 0,needGeometry:ts(a),needFeature:!!c}}function Yo(e){if(!Array.isArray(e))return e;var t=(function(e){if(Qo.has(e[0]))for(var t=1;t",">=","<","<=","to-boolean"]);function es(e,t){return et?1:0}function ts(e){if(!Array.isArray(e))return!1;if("within"===e[0]||"distance"===e[0])return!0;for(var t=1;t"===r||"<="===r||">="===r?is(e[1],e[2],r):"any"===r?(t=e.slice(1),["any"].concat(t.map(rs))):"all"===r?["all"].concat(e.slice(1).map(rs)):"none"===r?["all"].concat(e.slice(1).map(rs).map(os)):"in"===r?ns(e[1],e.slice(2)):"!in"===r?os(ns(e[1],e.slice(2))):"has"===r?as(e[1]):"!has"!==r||os(as(e[1]))}function is(e,t,r){switch(e){case"$type":return[`filter-type-${r}`,t];case"$id":return[`filter-id-${r}`,t];default:return[`filter-${r}`,e,t]}}function ns(e,t){if(0===t.length)return!1;switch(e){case"$type":return["filter-type-in",["literal",t]];case"$id":return["filter-id-in",["literal",t]];default:return t.length>200&&!t.some((function(e){return typeof e!=typeof t[0]}))?["filter-in-large",e,["literal",t.sort(es)]]:["filter-in-small",e,["literal",t]]}}function as(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function os(e){return["!",e]}var ss="\x1f";function ls(e,t){return t?`${e}${ss}${t}`:e}var us="-transition",cs=new Set(["fill","line","background","hillshade","raster"]),hs=(function(e){function t(e,r,i,n,a){var o;if(p(this,t),(o=T(this,t)).id=e.id,o.fqid=ls(o.id,i),o.type=e.type,o.scope=i,o.lut=n,o.options=a,o._featureFilter={filter:function(){return!0},needGeometry:!1,needFeature:!1},o._filterCompiled=!1,o.configDependencies=new Set,"custom"!==e.type){if(o.metadata=e.metadata,o.minzoom=e.minzoom,o.maxzoom=e.maxzoom,e.type&&"background"!==e.type&&"sky"!==e.type&&"slot"!==e.type){o.source=e.source,o.sourceLayer=e["source-layer"],o.filter=e.filter;var s=Kn(o.filter,Zo[`filter_${e.type}`]);"error"!==s.result&&(o.configDependencies=new Set([].concat(d(o.configDependencies),d(s.value.configDependencies))))}if(e.slot&&(o.slot=e.slot),r.layout&&(o._unevaluatedLayout=new Bo(r.layout,o.scope,a),o.configDependencies=new Set([].concat(d(o.configDependencies),d(o._unevaluatedLayout.configDependencies)))),r.paint){for(var l in o._transitionablePaint=new Lo(r.paint,o.scope,a),e.paint)o.setPaintProperty(l,e.paint[l]);for(var u in e.layout)o.setLayoutProperty(u,e.layout[u]);o.configDependencies=new Set([].concat(d(o.configDependencies),d(o._transitionablePaint.configDependencies))),o._transitioningPaint=o._transitionablePaint.untransitioned(),o.paint=new Vo(r.paint)}}return o}return g(t,e),m(t,[{key:"onAdd",value:function(e){}},{key:"onRemove",value:function(e){}},{key:"isDraped",value:function(e){return!this.is3D()&&cs.has(this.type)}},{key:"getLayoutProperty",value:function(e){return"visibility"===e?this.visibility:this._unevaluatedLayout.getValue(e)}},{key:"setLayoutProperty",value:function(e,t){if("custom"!==this.type||"visibility"!==e){var r=this._unevaluatedLayout;r._properties.properties[e]&&(r.setValue(e,t),this.configDependencies=new Set([].concat(d(this.configDependencies),d(r.configDependencies))),"visibility"===e&&this.possiblyEvaluateVisibility())}else this.visibility=t}},{key:"possiblyEvaluateVisibility",value:function(){this._unevaluatedLayout._values.visibility&&(this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0}))}},{key:"getPaintProperty",value:function(e){return _e(e,us)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}},{key:"setPaintProperty",value:function(e,t){var r=this._transitionablePaint,i=r._properties.properties;if(_e(e,us)){var n=e.slice(0,-11);return i[n]&&r.setTransition(n,t||void 0),!1}if(!i[e])return!1;var a=r._values[e],o=a.value.isDataDriven(),s=a.value;r.setValue(e,t),this.configDependencies=new Set([].concat(d(this.configDependencies),d(r.configDependencies))),this._handleSpecialPaintPropertyUpdate(e);var l=r._values[e].value,u=l.isDataDriven(),c=_e(e,"pattern")||"line-dasharray"===e;return u||o||c||this._handleOverridablePaintPropertyUpdate(e,s,l)}},{key:"_handleSpecialPaintPropertyUpdate",value:function(e){}},{key:"getProgramIds",value:function(){return null}},{key:"getDefaultProgramParams",value:function(e,t,r){return null}},{key:"_handleOverridablePaintPropertyUpdate",value:function(e,t,r){return!1}},{key:"isHidden",value:function(e){return!!(this.minzoom&&e=this.maxzoom)||"none"===this.visibility}},{key:"updateTransitions",value:function(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}},{key:"hasTransition",value:function(){return this._transitioningPaint.hasTransition()}},{key:"recalculate",value:function(e,t){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,t)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,t)}},{key:"serialize",value:function(){return ye({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()},(function(e,t){return!(void 0===e||"layout"===t&&!Object.keys(e).length||"paint"===t&&!Object.keys(e).length)}))}},{key:"is3D",value:function(){return!1}},{key:"isSky",value:function(){return!1}},{key:"isTileClipped",value:function(){return!1}},{key:"hasOffscreenPass",value:function(){return!1}},{key:"hasShadowPass",value:function(){return!1}},{key:"canCastShadows",value:function(){return!1}},{key:"hasLightBeamPass",value:function(){return!1}},{key:"cutoffRange",value:function(){return 0}},{key:"tileCoverLift",value:function(){return 0}},{key:"resize",value:function(){}},{key:"isStateDependent",value:function(){for(var e in this.paint._values){var t=this.paint.get(e);if(t instanceof No&&Bn(t.property.specification)&&("source"===t.value.kind||"composite"===t.value.kind)&&t.value.isStateDependent)return!0}return!1}},{key:"compileFilter",value:function(e){this._filterCompiled||(this._featureFilter=Xo(this.filter,this.scope,e),this._filterCompiled=!0)}},{key:"invalidateCompiledFilter",value:function(){this._filterCompiled=!1}},{key:"dynamicFilter",value:function(){return this._featureFilter.dynamicFilter}},{key:"dynamicFilterNeedsFeature",value:function(){return this._featureFilter.needFeature}},{key:"getLayerRenderingStats",value:function(){return this._stats}},{key:"resetLayerRenderingStats",value:function(e){this._stats&&("shadow"===e.renderPass?this._stats.numRenderedVerticesInShadowPass=0:this._stats.numRenderedVerticesInTransparentPass=0)}},{key:"queryRadius",value:function(e){}},{key:"queryIntersectsFeature",value:function(e,t,r,i,n,a,o,s,l){}},{key:"queryIntersectsMatchingFeature",value:function(e,t,r,i){}}])})(zt),fs={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array},ds=m((function e(t,r){p(this,e),this._structArray=t,this._pos1=r*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8})),ps=(function(){return m((function e(){p(this,e),this.isTransferred=!1,this.capacity=-1,this.resize(0)}),[{key:"_trim",value:function(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}},{key:"clear",value:function(){this.length=0}},{key:"resize",value:function(e){this.reserve(e),this.length=e}},{key:"reserve",value:function(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);var t=this.uint8;this._refreshViews(),t&&this.uint8.set(t)}}},{key:"_refreshViews",value:function(){throw new Error("StructArray#_refreshViews() must be implemented by each concrete StructArray layout")}},{key:"emplace",value:function(){throw new Error("StructArray#emplace() must be implemented by each concrete StructArray layout")}},{key:"emplaceBack",value:function(){throw new Error("StructArray#emplaceBack() must be implemented by each concrete StructArray layout")}},{key:"destroy",value:function(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null}}],[{key:"serialize",value:function(e,t){return e._trim(),t&&(e.isTransferred=!0,t.add(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}},{key:"deserialize",value:function(e){var t=Object.create(this.prototype);return t.arrayBuffer=e.arrayBuffer,t.length=e.length,t.capacity=e.arrayBuffer.byteLength/t.bytesPerElement,t._refreshViews(),t}}])})();function ms(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=0,i=0;return{members:e.map((function(e){var n=fs[e.type].BYTES_PER_ELEMENT,a=r=vs(r,Math.max(t,n)),o=e.components||1;return i=Math.max(i,n),r+=n*o,{name:e.name,type:e.type,components:o,offset:a}})),size:vs(r,Math.max(i,t)),alignment:t}}function vs(e,t){return Math.ceil(e/t)*t}var _s=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t){var r=this.length;return this.resize(r+1),this.emplace(r,e,t)}},{key:"emplace",value:function(e,t,r){var i=2*e;return this.int16[i+0]=t,this.int16[i+1]=r,e}}])})(ps);_s.prototype.bytesPerElement=4,ua(_s,"StructArrayLayout2i4");var gs=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t,r){var i=this.length;return this.resize(i+1),this.emplace(i,e,t,r)}},{key:"emplace",value:function(e,t,r,i){var n=3*e;return this.int16[n+0]=t,this.int16[n+1]=r,this.int16[n+2]=i,e}}])})(ps);gs.prototype.bytesPerElement=6,ua(gs,"StructArrayLayout3i6");var ys=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t,r,i){var n=this.length;return this.resize(n+1),this.emplace(n,e,t,r,i)}},{key:"emplace",value:function(e,t,r,i,n){var a=4*e;return this.int16[a+0]=t,this.int16[a+1]=r,this.int16[a+2]=i,this.int16[a+3]=n,e}}])})(ps);ys.prototype.bytesPerElement=8,ua(ys,"StructArrayLayout4i8");var xs=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t,r,i,n){var a=this.length;return this.resize(a+1),this.emplace(a,e,t,r,i,n)}},{key:"emplace",value:function(e,t,r,i,n,a){var o=5*e;return this.int16[o+0]=t,this.int16[o+1]=r,this.int16[o+2]=i,this.int16[o+3]=n,this.int16[o+4]=a,e}}])})(ps);xs.prototype.bytesPerElement=10,ua(xs,"StructArrayLayout5i10");var bs=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t,r,i,n,a,o){var s=this.length;return this.resize(s+1),this.emplace(s,e,t,r,i,n,a,o)}},{key:"emplace",value:function(e,t,r,i,n,a,o,s){var l=6*e,u=12*e,c=3*e;return this.int16[l+0]=t,this.int16[l+1]=r,this.uint8[u+4]=i,this.uint8[u+5]=n,this.uint8[u+6]=a,this.uint8[u+7]=o,this.float32[c+2]=s,e}}])})(ps);bs.prototype.bytesPerElement=12,ua(bs,"StructArrayLayout2i4ub1f12");var ws=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t,r,i){var n=this.length;return this.resize(n+1),this.emplace(n,e,t,r,i)}},{key:"emplace",value:function(e,t,r,i,n){var a=4*e;return this.float32[a+0]=t,this.float32[a+1]=r,this.float32[a+2]=i,this.float32[a+3]=n,e}}])})(ps);ws.prototype.bytesPerElement=16,ua(ws,"StructArrayLayout4f16");var ks=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t,r){var i=this.length;return this.resize(i+1),this.emplace(i,e,t,r)}},{key:"emplace",value:function(e,t,r,i){var n=3*e;return this.float32[n+0]=t,this.float32[n+1]=r,this.float32[n+2]=i,e}}])})(ps);ks.prototype.bytesPerElement=12,ua(ks,"StructArrayLayout3f12");var Ts=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t,r,i,n){var a=this.length;return this.resize(a+1),this.emplace(a,e,t,r,i,n)}},{key:"emplace",value:function(e,t,r,i,n,a){var o=6*e,s=3*e;return this.uint16[o+0]=t,this.uint16[o+1]=r,this.uint16[o+2]=i,this.uint16[o+3]=n,this.float32[s+2]=a,e}}])})(ps);Ts.prototype.bytesPerElement=12,ua(Ts,"StructArrayLayout4ui1f12");var Ss=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t,r,i){var n=this.length;return this.resize(n+1),this.emplace(n,e,t,r,i)}},{key:"emplace",value:function(e,t,r,i,n){var a=4*e;return this.uint16[a+0]=t,this.uint16[a+1]=r,this.uint16[a+2]=i,this.uint16[a+3]=n,e}}])})(ps);Ss.prototype.bytesPerElement=8,ua(Ss,"StructArrayLayout4ui8");var Es=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t,r,i,n,a){var o=this.length;return this.resize(o+1),this.emplace(o,e,t,r,i,n,a)}},{key:"emplace",value:function(e,t,r,i,n,a,o){var s=6*e;return this.int16[s+0]=t,this.int16[s+1]=r,this.int16[s+2]=i,this.int16[s+3]=n,this.int16[s+4]=a,this.int16[s+5]=o,e}}])})(ps);Es.prototype.bytesPerElement=12,ua(Es,"StructArrayLayout6i12");var Ms=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t,r,i,n,a,o,s,l,u,c,h){var f=this.length;return this.resize(f+1),this.emplace(f,e,t,r,i,n,a,o,s,l,u,c,h)}},{key:"emplace",value:function(e,t,r,i,n,a,o,s,l,u,c,h,f){var d=12*e;return this.int16[d+0]=t,this.int16[d+1]=r,this.int16[d+2]=i,this.int16[d+3]=n,this.uint16[d+4]=a,this.uint16[d+5]=o,this.uint16[d+6]=s,this.uint16[d+7]=l,this.int16[d+8]=u,this.int16[d+9]=c,this.int16[d+10]=h,this.int16[d+11]=f,e}}])})(ps);Ms.prototype.bytesPerElement=24,ua(Ms,"StructArrayLayout4i4ui4i24");var As=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t,r,i,n,a){var o=this.length;return this.resize(o+1),this.emplace(o,e,t,r,i,n,a)}},{key:"emplace",value:function(e,t,r,i,n,a,o){var s=10*e,l=5*e;return this.int16[s+0]=t,this.int16[s+1]=r,this.int16[s+2]=i,this.float32[l+2]=n,this.float32[l+3]=a,this.float32[l+4]=o,e}}])})(ps);As.prototype.bytesPerElement=20,ua(As,"StructArrayLayout3i3f20");var Is=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e){var t=this.length;return this.resize(t+1),this.emplace(t,e)}},{key:"emplace",value:function(e,t){return this.uint32[1*e+0]=t,e}}])})(ps);Is.prototype.bytesPerElement=4,ua(Is,"StructArrayLayout1ul4");var Cs=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t){var r=this.length;return this.resize(r+1),this.emplace(r,e,t)}},{key:"emplace",value:function(e,t,r){var i=2*e;return this.uint16[i+0]=t,this.uint16[i+1]=r,e}}])})(ps);Cs.prototype.bytesPerElement=4,ua(Cs,"StructArrayLayout2ui4");var Ps=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"_refreshViews",value:function(){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)}},{key:"emplaceBack",value:function(e,t,r,i,n,a,o,s,l,u,c,h,f){var d=this.length;return this.resize(d+1),this.emplace(d,e,t,r,i,n,a,o,s,l,u,c,h,f)}},{key:"emplace",value:function(e,t,r,i,n,a,o,s,l,u,c,h,f,d){var p=20*e,m=10*e;return this.int16[p+0]=t,this.int16[p+1]=r,this.int16[p+2]=i,this.int16[p+3]=n,this.int16[p+4]=a,this.float32[m+3]=o,this.float32[m+4]=s,this.float32[m+5]=l,this.float32[m+6]=u,this.int16[p+14]=c,this.uint32[m+8]=h,this.uint16[p+18]=f,this.uint16[p+19]=d,e}}])})(ps);Ps.prototype.bytesPerElement=40,ua(Ps,"StructArrayLayout5i4f1i1ul2ui40");var zs=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t,r,i,n,a,o){var s=this.length;return this.resize(s+1),this.emplace(s,e,t,r,i,n,a,o)}},{key:"emplace",value:function(e,t,r,i,n,a,o,s){var l=8*e;return this.int16[l+0]=t,this.int16[l+1]=r,this.int16[l+2]=i,this.int16[l+4]=n,this.int16[l+5]=a,this.int16[l+6]=o,this.int16[l+7]=s,e}}])})(ps);zs.prototype.bytesPerElement=16,ua(zs,"StructArrayLayout3i2i2i16");var Ds=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t,r,i,n){var a=this.length;return this.resize(a+1),this.emplace(a,e,t,r,i,n)}},{key:"emplace",value:function(e,t,r,i,n,a){var o=4*e,s=8*e;return this.float32[o+0]=t,this.float32[o+1]=r,this.float32[o+2]=i,this.int16[s+6]=n,this.int16[s+7]=a,e}}])})(ps);Ds.prototype.bytesPerElement=16,ua(Ds,"StructArrayLayout2f1f2i16");var Rs=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t,r,i,n,a){var o=this.length;return this.resize(o+1),this.emplace(o,e,t,r,i,n,a)}},{key:"emplace",value:function(e,t,r,i,n,a,o){var s=20*e,l=5*e;return this.uint8[s+0]=t,this.uint8[s+1]=r,this.float32[l+1]=i,this.float32[l+2]=n,this.float32[l+3]=a,this.float32[l+4]=o,e}}])})(ps);Rs.prototype.bytesPerElement=20,ua(Rs,"StructArrayLayout2ub4f20");var Ls=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t,r){var i=this.length;return this.resize(i+1),this.emplace(i,e,t,r)}},{key:"emplace",value:function(e,t,r,i){var n=3*e;return this.uint16[n+0]=t,this.uint16[n+1]=r,this.uint16[n+2]=i,e}}])})(ps);Ls.prototype.bytesPerElement=6,ua(Ls,"StructArrayLayout3ui6");var Os=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"_refreshViews",value:function(){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)}},{key:"emplaceBack",value:function(e,t,r,i,n,a,o,s,l,u,c,h,f,d,p,m,v,_,g,y,x){var b=this.length;return this.resize(b+1),this.emplace(b,e,t,r,i,n,a,o,s,l,u,c,h,f,d,p,m,v,_,g,y,x)}},{key:"emplace",value:function(e,t,r,i,n,a,o,s,l,u,c,h,f,d,p,m,v,_,g,y,x,b){var w=30*e,k=15*e,T=60*e;return this.int16[w+0]=t,this.int16[w+1]=r,this.int16[w+2]=i,this.float32[k+2]=n,this.float32[k+3]=a,this.uint16[w+8]=o,this.uint16[w+9]=s,this.uint32[k+5]=l,this.uint32[k+6]=u,this.uint32[k+7]=c,this.uint16[w+16]=h,this.uint16[w+17]=f,this.uint16[w+18]=d,this.float32[k+10]=p,this.float32[k+11]=m,this.uint8[T+48]=v,this.uint8[T+49]=_,this.uint8[T+50]=g,this.uint32[k+13]=y,this.int16[w+28]=x,this.uint8[T+58]=b,e}}])})(ps);Os.prototype.bytesPerElement=60,ua(Os,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");var Fs=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"_refreshViews",value:function(){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)}},{key:"emplaceBack",value:function(e,t,r,i,n,a,o,s,l,u,c,h,f,d,p,m,v,_,g,y,x,b,w,k,T,S,E,M,A,I,C,P){var z=this.length;return this.resize(z+1),this.emplace(z,e,t,r,i,n,a,o,s,l,u,c,h,f,d,p,m,v,_,g,y,x,b,w,k,T,S,E,M,A,I,C,P)}},{key:"emplace",value:function(e,t,r,i,n,a,o,s,l,u,c,h,f,d,p,m,v,_,g,y,x,b,w,k,T,S,E,M,A,I,C,P,z){var D=20*e,R=40*e,L=80*e;return this.float32[D+0]=t,this.float32[D+1]=r,this.int16[R+4]=i,this.int16[R+5]=n,this.int16[R+6]=a,this.int16[R+7]=o,this.int16[R+8]=s,this.int16[R+9]=l,this.int16[R+10]=u,this.int16[R+11]=c,this.int16[R+12]=h,this.uint16[R+13]=f,this.uint16[R+14]=d,this.uint16[R+15]=p,this.uint16[R+16]=m,this.uint16[R+17]=v,this.uint16[R+18]=_,this.uint16[R+19]=g,this.uint16[R+20]=y,this.uint16[R+21]=x,this.uint16[R+22]=b,this.uint16[R+23]=w,this.uint16[R+24]=k,this.uint16[R+25]=T,this.uint16[R+26]=S,this.uint16[R+27]=E,this.uint32[D+14]=M,this.float32[D+15]=A,this.float32[D+16]=I,this.float32[D+17]=C,this.float32[D+18]=P,this.uint8[L+76]=z,e}}])})(ps);Fs.prototype.bytesPerElement=80,ua(Fs,"StructArrayLayout2f9i15ui1ul4f1ub80");var Bs=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e){var t=this.length;return this.resize(t+1),this.emplace(t,e)}},{key:"emplace",value:function(e,t){return this.float32[1*e+0]=t,e}}])})(ps);Bs.prototype.bytesPerElement=4,ua(Bs,"StructArrayLayout1f4");var Ns=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t,r,i,n){var a=this.length;return this.resize(a+1),this.emplace(a,e,t,r,i,n)}},{key:"emplace",value:function(e,t,r,i,n,a){var o=5*e;return this.float32[o+0]=t,this.float32[o+1]=r,this.float32[o+2]=i,this.float32[o+3]=n,this.float32[o+4]=a,e}}])})(ps);Ns.prototype.bytesPerElement=20,ua(Ns,"StructArrayLayout5f20");var Vs=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t,r,i,n,a,o){var s=this.length;return this.resize(s+1),this.emplace(s,e,t,r,i,n,a,o)}},{key:"emplace",value:function(e,t,r,i,n,a,o,s){var l=7*e;return this.float32[l+0]=t,this.float32[l+1]=r,this.float32[l+2]=i,this.float32[l+3]=n,this.float32[l+4]=a,this.float32[l+5]=o,this.float32[l+6]=s,e}}])})(ps);Vs.prototype.bytesPerElement=28,ua(Vs,"StructArrayLayout7f28");var Us=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t,r,i,n,a,o,s,l,u,c){var h=this.length;return this.resize(h+1),this.emplace(h,e,t,r,i,n,a,o,s,l,u,c)}},{key:"emplace",value:function(e,t,r,i,n,a,o,s,l,u,c,h){var f=11*e;return this.float32[f+0]=t,this.float32[f+1]=r,this.float32[f+2]=i,this.float32[f+3]=n,this.float32[f+4]=a,this.float32[f+5]=o,this.float32[f+6]=s,this.float32[f+7]=l,this.float32[f+8]=u,this.float32[f+9]=c,this.float32[f+10]=h,e}}])})(ps);Us.prototype.bytesPerElement=44,ua(Us,"StructArrayLayout11f44");var js=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t,r,i,n,a,o,s,l){var u=this.length;return this.resize(u+1),this.emplace(u,e,t,r,i,n,a,o,s,l)}},{key:"emplace",value:function(e,t,r,i,n,a,o,s,l,u){var c=9*e;return this.float32[c+0]=t,this.float32[c+1]=r,this.float32[c+2]=i,this.float32[c+3]=n,this.float32[c+4]=a,this.float32[c+5]=o,this.float32[c+6]=s,this.float32[c+7]=l,this.float32[c+8]=u,e}}])})(ps);js.prototype.bytesPerElement=36,ua(js,"StructArrayLayout9f36");var Gs=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t,r,i){var n=this.length;return this.resize(n+1),this.emplace(n,e,t,r,i)}},{key:"emplace",value:function(e,t,r,i,n){var a=6*e;return this.uint32[3*e+0]=t,this.uint16[a+2]=r,this.uint16[a+3]=i,this.uint16[a+4]=n,e}}])})(ps);Gs.prototype.bytesPerElement=12,ua(Gs,"StructArrayLayout1ul3ui12");var qs=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e){var t=this.length;return this.resize(t+1),this.emplace(t,e)}},{key:"emplace",value:function(e,t){return this.uint16[1*e+0]=t,e}}])})(ps);qs.prototype.bytesPerElement=2,ua(qs,"StructArrayLayout1ui2");var Zs=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t){var r=this.length;return this.resize(r+1),this.emplace(r,e,t)}},{key:"emplace",value:function(e,t,r){var i=2*e;return this.float32[i+0]=t,this.float32[i+1]=r,e}}])})(ps);Zs.prototype.bytesPerElement=8,ua(Zs,"StructArrayLayout2f8");var $s=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t,r,i,n,a,o,s,l,u,c,h,f,d,p,m){var v=this.length;return this.resize(v+1),this.emplace(v,e,t,r,i,n,a,o,s,l,u,c,h,f,d,p,m)}},{key:"emplace",value:function(e,t,r,i,n,a,o,s,l,u,c,h,f,d,p,m,v){var _=16*e;return this.float32[_+0]=t,this.float32[_+1]=r,this.float32[_+2]=i,this.float32[_+3]=n,this.float32[_+4]=a,this.float32[_+5]=o,this.float32[_+6]=s,this.float32[_+7]=l,this.float32[_+8]=u,this.float32[_+9]=c,this.float32[_+10]=h,this.float32[_+11]=f,this.float32[_+12]=d,this.float32[_+13]=p,this.float32[_+14]=m,this.float32[_+15]=v,e}}])})(ps);$s.prototype.bytesPerElement=64,ua($s,"StructArrayLayout16f64");var Hs=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e,t,r,i,n,a,o){var s=this.length;return this.resize(s+1),this.emplace(s,e,t,r,i,n,a,o)}},{key:"emplace",value:function(e,t,r,i,n,a,o,s){var l=10*e,u=5*e;return this.uint16[l+0]=t,this.uint16[l+1]=r,this.uint16[l+2]=i,this.uint16[l+3]=n,this.float32[u+2]=a,this.float32[u+3]=o,this.float32[u+4]=s,e}}])})(ps);Hs.prototype.bytesPerElement=20,ua(Hs,"StructArrayLayout4ui3f20");var Ws=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e){var t=this.length;return this.resize(t+1),this.emplace(t,e)}},{key:"emplace",value:function(e,t){return this.int16[1*e+0]=t,e}}])})(ps);Ws.prototype.bytesPerElement=2,ua(Ws,"StructArrayLayout1i2");var Xs=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"_refreshViews",value:function(){this.uint8=new Uint8Array(this.arrayBuffer)}},{key:"emplaceBack",value:function(e){var t=this.length;return this.resize(t+1),this.emplace(t,e)}},{key:"emplace",value:function(e,t){return this.uint8[1*e+0]=t,e}}])})(ps);Xs.prototype.bytesPerElement=1,ua(Xs,"StructArrayLayout1ub1");var Ys=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"projectedAnchorX",get:function(){return this._structArray.int16[this._pos2+0]}},{key:"projectedAnchorY",get:function(){return this._structArray.int16[this._pos2+1]}},{key:"projectedAnchorZ",get:function(){return this._structArray.int16[this._pos2+2]}},{key:"tileAnchorX",get:function(){return this._structArray.int16[this._pos2+3]}},{key:"tileAnchorY",get:function(){return this._structArray.int16[this._pos2+4]}},{key:"x1",get:function(){return this._structArray.float32[this._pos4+3]}},{key:"y1",get:function(){return this._structArray.float32[this._pos4+4]}},{key:"x2",get:function(){return this._structArray.float32[this._pos4+5]}},{key:"y2",get:function(){return this._structArray.float32[this._pos4+6]}},{key:"padding",get:function(){return this._structArray.int16[this._pos2+14]}},{key:"featureIndex",get:function(){return this._structArray.uint32[this._pos4+8]}},{key:"sourceLayerIndex",get:function(){return this._structArray.uint16[this._pos2+18]}},{key:"bucketIndex",get:function(){return this._structArray.uint16[this._pos2+19]}}])})(ds);Ys.prototype.size=40;var Js=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"get",value:function(e){return new Ys(this,e)}}])})(Ps);ua(Js,"CollisionBoxArray");var Ks=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"projectedAnchorX",get:function(){return this._structArray.int16[this._pos2+0]}},{key:"projectedAnchorY",get:function(){return this._structArray.int16[this._pos2+1]}},{key:"projectedAnchorZ",get:function(){return this._structArray.int16[this._pos2+2]}},{key:"tileAnchorX",get:function(){return this._structArray.float32[this._pos4+2]}},{key:"tileAnchorY",get:function(){return this._structArray.float32[this._pos4+3]}},{key:"glyphStartIndex",get:function(){return this._structArray.uint16[this._pos2+8]}},{key:"numGlyphs",get:function(){return this._structArray.uint16[this._pos2+9]}},{key:"vertexStartIndex",get:function(){return this._structArray.uint32[this._pos4+5]}},{key:"lineStartIndex",get:function(){return this._structArray.uint32[this._pos4+6]}},{key:"lineLength",get:function(){return this._structArray.uint32[this._pos4+7]}},{key:"segment",get:function(){return this._structArray.uint16[this._pos2+16]}},{key:"lowerSize",get:function(){return this._structArray.uint16[this._pos2+17]}},{key:"upperSize",get:function(){return this._structArray.uint16[this._pos2+18]}},{key:"lineOffsetX",get:function(){return this._structArray.float32[this._pos4+10]}},{key:"lineOffsetY",get:function(){return this._structArray.float32[this._pos4+11]}},{key:"writingMode",get:function(){return this._structArray.uint8[this._pos1+48]}},{key:"placedOrientation",get:function(){return this._structArray.uint8[this._pos1+49]},set:function(e){this._structArray.uint8[this._pos1+49]=e}},{key:"hidden",get:function(){return this._structArray.uint8[this._pos1+50]},set:function(e){this._structArray.uint8[this._pos1+50]=e}},{key:"crossTileID",get:function(){return this._structArray.uint32[this._pos4+13]},set:function(e){this._structArray.uint32[this._pos4+13]=e}},{key:"associatedIconIndex",get:function(){return this._structArray.int16[this._pos2+28]}},{key:"flipState",get:function(){return this._structArray.uint8[this._pos1+58]},set:function(e){this._structArray.uint8[this._pos1+58]=e}}])})(ds);Ks.prototype.size=60;var Qs=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"get",value:function(e){return new Ks(this,e)}}])})(Os);ua(Qs,"PlacedSymbolArray");var el=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"tileAnchorX",get:function(){return this._structArray.float32[this._pos4+0]}},{key:"tileAnchorY",get:function(){return this._structArray.float32[this._pos4+1]}},{key:"projectedAnchorX",get:function(){return this._structArray.int16[this._pos2+4]}},{key:"projectedAnchorY",get:function(){return this._structArray.int16[this._pos2+5]}},{key:"projectedAnchorZ",get:function(){return this._structArray.int16[this._pos2+6]}},{key:"rightJustifiedTextSymbolIndex",get:function(){return this._structArray.int16[this._pos2+7]}},{key:"centerJustifiedTextSymbolIndex",get:function(){return this._structArray.int16[this._pos2+8]}},{key:"leftJustifiedTextSymbolIndex",get:function(){return this._structArray.int16[this._pos2+9]}},{key:"verticalPlacedTextSymbolIndex",get:function(){return this._structArray.int16[this._pos2+10]}},{key:"placedIconSymbolIndex",get:function(){return this._structArray.int16[this._pos2+11]}},{key:"verticalPlacedIconSymbolIndex",get:function(){return this._structArray.int16[this._pos2+12]}},{key:"key",get:function(){return this._structArray.uint16[this._pos2+13]}},{key:"textBoxStartIndex",get:function(){return this._structArray.uint16[this._pos2+14]}},{key:"textBoxEndIndex",get:function(){return this._structArray.uint16[this._pos2+15]}},{key:"verticalTextBoxStartIndex",get:function(){return this._structArray.uint16[this._pos2+16]}},{key:"verticalTextBoxEndIndex",get:function(){return this._structArray.uint16[this._pos2+17]}},{key:"iconBoxStartIndex",get:function(){return this._structArray.uint16[this._pos2+18]}},{key:"iconBoxEndIndex",get:function(){return this._structArray.uint16[this._pos2+19]}},{key:"verticalIconBoxStartIndex",get:function(){return this._structArray.uint16[this._pos2+20]}},{key:"verticalIconBoxEndIndex",get:function(){return this._structArray.uint16[this._pos2+21]}},{key:"featureIndex",get:function(){return this._structArray.uint16[this._pos2+22]}},{key:"numHorizontalGlyphVertices",get:function(){return this._structArray.uint16[this._pos2+23]}},{key:"numVerticalGlyphVertices",get:function(){return this._structArray.uint16[this._pos2+24]}},{key:"numIconVertices",get:function(){return this._structArray.uint16[this._pos2+25]}},{key:"numVerticalIconVertices",get:function(){return this._structArray.uint16[this._pos2+26]}},{key:"useRuntimeCollisionCircles",get:function(){return this._structArray.uint16[this._pos2+27]}},{key:"crossTileID",get:function(){return this._structArray.uint32[this._pos4+14]},set:function(e){this._structArray.uint32[this._pos4+14]=e}},{key:"textOffset0",get:function(){return this._structArray.float32[this._pos4+15]}},{key:"textOffset1",get:function(){return this._structArray.float32[this._pos4+16]}},{key:"collisionCircleDiameter",get:function(){return this._structArray.float32[this._pos4+17]}},{key:"zOffset",get:function(){return this._structArray.float32[this._pos4+18]},set:function(e){this._structArray.float32[this._pos4+18]=e}},{key:"hasIconTextFit",get:function(){return this._structArray.uint8[this._pos1+76]}}])})(ds);el.prototype.size=80;var tl=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"get",value:function(e){return new el(this,e)}}])})(Fs);ua(tl,"SymbolInstanceArray");var rl=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"getoffsetX",value:function(e){return this.float32[1*e+0]}}])})(Bs);ua(rl,"GlyphOffsetArray");var il=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"getx",value:function(e){return this.int16[2*e+0]}},{key:"gety",value:function(e){return this.int16[2*e+1]}}])})(_s);ua(il,"SymbolLineVertexArray");var nl=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"featureIndex",get:function(){return this._structArray.uint32[this._pos4+0]}},{key:"sourceLayerIndex",get:function(){return this._structArray.uint16[this._pos2+2]}},{key:"bucketIndex",get:function(){return this._structArray.uint16[this._pos2+3]}},{key:"layoutVertexArrayOffset",get:function(){return this._structArray.uint16[this._pos2+4]}}])})(ds);nl.prototype.size=12;var al=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"get",value:function(e){return new nl(this,e)}}])})(Gs);ua(al,"FeatureIndexArray");var ol=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"geta_centroid_pos0",value:function(e){return this.uint16[2*e+0]}},{key:"geta_centroid_pos1",value:function(e){return this.uint16[2*e+1]}}])})(Cs);ua(ol,"FillExtrusionCentroidArray");var sl=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"a_join_normal_inside0",get:function(){return this._structArray.int16[this._pos2+0]}},{key:"a_join_normal_inside1",get:function(){return this._structArray.int16[this._pos2+1]}},{key:"a_join_normal_inside2",get:function(){return this._structArray.int16[this._pos2+2]}}])})(ds);sl.prototype.size=6;var ll=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"get",value:function(e){return new sl(this,e)}}])})(gs);ua(ll,"FillExtrusionWallArray");var ul=ms([{name:"a_pos",components:2,type:"Int16"}],4),cl=ms([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]),hl=(function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];p(this,e),this.segments=t}return m(e,[{key:"_prepareSegment",value:function(t,r,i,n){var a=this.segments[this.segments.length-1];return t>e.MAX_VERTEX_ARRAY_LENGTH&&we(`Max vertices per segment is ${e.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}`),(!a||a.vertexLength+t>e.MAX_VERTEX_ARRAY_LENGTH||a.sortKey!==n)&&(a={vertexOffset:r,primitiveOffset:i,vertexLength:0,primitiveLength:0},void 0!==n&&(a.sortKey=n),this.segments.push(a)),a}},{key:"prepareSegment",value:function(e,t,r,i){return this._prepareSegment(e,t.length,r.length,i)}},{key:"get",value:function(){return this.segments}},{key:"destroy",value:function(){for(var e of this.segments)for(var t in e.vaos)e.vaos[t].destroy()}}],[{key:"simpleSegment",value:function(t,r,i,n){return new e([{vertexOffset:t,primitiveOffset:r,vertexLength:i,primitiveLength:n,vaos:{},sortKey:0}])}}])})();function fl(e,t){return 256*(e=le(Math.floor(e),0,255))+le(Math.floor(t),0,255)}hl.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,ua(hl,"SegmentVector");var dl=ms([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),pl=ms([{name:"a_dash",components:4,type:"Uint16"}]),ml=(function(){function e(){p(this,e),this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}return m(e,[{key:"add",value:function(e,t,r,i){this.ids.push(vl(e)),this.positions.push(t,r,i)}},{key:"eachPosition",value:function(e,t){for(var r=vl(e),i=0,n=this.ids.length-1;i>1;this.ids[a]>=r?n=a:i=a+1}for(;this.ids[i]===r;)t(this.positions[3*i],this.positions[3*i+1],this.positions[3*i+2]),i++}}],[{key:"serialize",value:function(e,t){var r=new Float64Array(e.ids),i=new Uint32Array(e.positions);return _l(r,i,0,r.length-1),t&&(t.add(r.buffer),t.add(i.buffer)),{ids:r,positions:i}}},{key:"deserialize",value:function(t){var r,i=new e;for(var n of(i.ids=t.ids,i.positions=t.positions,i.ids))n!==r&&i.uniqueIds.push(n),r=n;return i.indexed=!0,i}}])})();function vl(e){var t=+e;return!isNaN(t)&&Number.MIN_SAFE_INTEGER<=t&&t<=Number.MAX_SAFE_INTEGER?t:Et(String(e))}function _l(e,t,r,i){for(;r>1],a=r-1,o=i+1;;){do{a++}while(e[a]n);if(a>=o)break;gl(e,a,o),gl(t,3*a,3*o),gl(t,3*a+1,3*o+1),gl(t,3*a+2,3*o+2)}o-r2&&void 0!==arguments[2]?arguments[2]:function(){return!0};p(this,e),this.binders={},this._buffers=[],this.context=r;var n=[];for(var a in t.paint._values){var o=t.paint.get(a);if(i(a)&&(o instanceof No&&Bn(o.property.specification))){var s=Vl(a,t.type),l=o.value,u=o.property.specification.type,c=!!o.property.useIntegerZoom,h="line-dasharray"===a||a.endsWith("pattern"),f="line-dasharray"===a&&"constant"!==t.layout.get("line-cap").value.kind;if("constant"!==l.kind||f)if("source"===l.kind||f||h){var d=Gl(a,u,"source");this.binders[a]=h?new Ol(l,s,u,d,t.id):new Rl(l,s,u,d),n.push(`/a_${a}`)}else{var m=Gl(a,u,"composite");this.binders[a]=new Ll(l,s,u,c,r,m),n.push(`/z_${a}`)}else this.binders[a]=h?new Dl(l.value,s):new zl(l.value,s,u,r),n.push(`/u_${a}`)}}this.cacheKey=n.sort().join("")}),[{key:"getMaxValue",value:function(e){var t=this.binders[e];return t instanceof Rl||t instanceof Ll?t.maxValue:0}},{key:"populatePaintArrays",value:function(e,t,r,i,n,a,o){for(var s in this.binders){var l=this.binders[s];l.context=this.context,(l instanceof Rl||l instanceof Ll||l instanceof Ol)&&l.populatePaintArray(e,t,r,i,n,a,o)}}},{key:"setConstantPatternPositions",value:function(e){for(var t in this.binders){var r=this.binders[t];r instanceof Dl&&r.setConstantPatternPositions(e)}}},{key:"updatePaintArrays",value:function(e,t,r,i,n,a,o,s){var l=this,u=!1,c=Object.keys(e),h=0!==c.length,f=h?c:t.uniqueIds;this.context.lut=n.lut;var d=function(){var c=l.binders[p];if(c.context=l.context,(c instanceof Rl||c instanceof Ll||c instanceof Ol)&&(!0===c.expression.isStateDependent||!1===c.expression.isLightConstant)){var d=n.paint.get(p);c.expression=d.value;var m=function(){var r=e[v.toString()];t.eachPosition(v,(function(e,t,n){var l=i.feature(e);c.updatePaintArray(t,n,l,r,a,o,s)}))};for(var v of f)m();if(!h){var _=function(){var t=e[g.toString()];r.eachPosition(g,(function(e,r,n){var l=i.feature(e);c.updatePaintArray(r,n,l,t,a,o,s)}))};for(var g of r.uniqueIds)_()}u=!0}};for(var p in this.binders)d();return u}},{key:"defines",value:function(){var e=[];for(var t in this.binders){var r=this.binders[t];(r instanceof zl||r instanceof Dl)&&e.push.apply(e,d(r.uniformNames.map((function(e){return`#define HAS_UNIFORM_${e}`}))))}return e}},{key:"getBinderAttributes",value:function(){var e=[];for(var t in this.binders){var r=this.binders[t];if(r instanceof Rl||r instanceof Ll||r instanceof Ol)for(var i=0;i2&&void 0!==arguments[2]?arguments[2]:function(){return!0};for(var n of(p(this,e),this.programConfigurations={},t))this.programConfigurations[n.id]=new Fl(n,r,i);this.needsUpload=!1,this._featureMap=new ml,this._featureMapWithoutIds=new ml,this._bufferOffset=0,this._idlessCounter=0}),[{key:"populatePaintArrays",value:function(e,t,r,i,n,a,o,s){for(var l in this.programConfigurations)this.programConfigurations[l].populatePaintArrays(e,t,i,n,a,o,s);void 0!==t.id?this._featureMap.add(t.id,r,this._bufferOffset,e):(this._featureMapWithoutIds.add(this._idlessCounter,r,this._bufferOffset,e),this._idlessCounter+=1),this._bufferOffset=e,this.needsUpload=!0}},{key:"updatePaintArrays",value:function(e,t,r,i,n,a){for(var o of r)this.needsUpload=this.programConfigurations[o.id].updatePaintArrays(e,this._featureMap,this._featureMapWithoutIds,t,o,i,n,a||0)||this.needsUpload}},{key:"get",value:function(e){return this.programConfigurations[e]}},{key:"upload",value:function(e){if(this.needsUpload){for(var t in this.programConfigurations)this.programConfigurations[t].upload(e);this.needsUpload=!1}}},{key:"destroy",value:function(){for(var e in this.programConfigurations)this.programConfigurations[e].destroy()}}])})(),Nl={"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 Vl(e,t){return Nl[e]||[e.replace(`${t}-`,"").replace(/-/g,"_")]}var Ul={"line-pattern":{source:Ts,composite:Ts},"fill-pattern":{source:Ts,composite:Ts},"fill-extrusion-pattern":{source:Ts,composite:Ts},"line-dasharray":{source:Ss,composite:Ss}},jl={color:{source:Zs,composite:ws},number:{source:Bs,composite:Zs}};function Gl(e,t,r){var i=Ul[e];return i&&i[r]||jl[t][r]}ua(zl,"ConstantBinder"),ua(Dl,"PatternConstantBinder"),ua(Rl,"SourceExpressionBinder"),ua(Ol,"PatternCompositeBinder"),ua(Ll,"CompositeExpressionBinder"),ua(Fl,"ProgramConfiguration",{omit:["_buffers"]}),ua(Bl,"ProgramConfigurationSet");var ql=ri/Math.PI/2,Zl=64,$l=[Zl,32,16],Hl=-ql,Wl=ql;function Xl(e,t,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:ql;return r=re(r),[e*Math.sin(r)*i,-t*i,e*Math.cos(r)*i]}function Yl(e,t,r){return Xl(Math.cos(re(e)),Math.sin(re(e)),t,r)}var Jl=6371008.8,Kl=2*Math.PI*Jl,Ql=(function(){function e(t,r){if(p(this,e),isNaN(t)||isNaN(r))throw new Error(`Invalid LngLat object: (${t}, ${r})`);if(this.lng=+t,this.lat=+r,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}return m(e,[{key:"wrap",value:function(){return new e(ce(this.lng,-180,180),this.lat)}},{key:"toArray",value:function(){return[this.lng,this.lat]}},{key:"toString",value:function(){return`LngLat(${this.lng}, ${this.lat})`}},{key:"distanceTo",value:function(e){var t=Math.PI/180,r=this.lat*t,i=e.lat*t,n=Math.sin(r)*Math.sin(i)+Math.cos(r)*Math.cos(i)*Math.cos((e.lng-this.lng)*t);return Jl*Math.acos(Math.min(n,1))}},{key:"toBounds",value:function(){var e=360*(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)/40075017,t=e/Math.cos(Math.PI/180*this.lat);return new eu({lng:this.lng-t,lat:this.lat-e},{lng:this.lng+t,lat:this.lat+e})}},{key:"toEcef",value:function(e){return Yl(this.lat,this.lng,ql+e*ql/Jl)}}],[{key:"convert",value:function(t){if(t instanceof e)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new e(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new e(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: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}])})(),eu=(function(){function e(t,r){if(p(this,e),t)if(r)this.setSouthWest(t).setNorthEast(r);else if(4===t.length){var i=t;this.setSouthWest([i[0],i[1]]).setNorthEast([i[2],i[3]])}else{var n=t;this.setSouthWest(n[0]).setNorthEast(n[1])}}return m(e,[{key:"setNorthEast",value:function(e){return this._ne=e instanceof Ql?new Ql(e.lng,e.lat):Ql.convert(e),this}},{key:"setSouthWest",value:function(e){return this._sw=e instanceof Ql?new Ql(e.lng,e.lat):Ql.convert(e),this}},{key:"extend",value:function(t){var r,i,n=this._sw,a=this._ne;if(t instanceof Ql)r=t,i=t;else{if(!(t instanceof e))return Array.isArray(t)?4===t.length||t.every(Array.isArray)?this.extend(e.convert(t)):this.extend(Ql.convert(t)):"object"==typeof t&&null!==t&&t.hasOwnProperty("lat")&&(t.hasOwnProperty("lon")||t.hasOwnProperty("lng"))?this.extend(Ql.convert(t)):this;if(r=t._sw,i=t._ne,!r||!i)return this}return n||a?(n.lng=Math.min(r.lng,n.lng),n.lat=Math.min(r.lat,n.lat),a.lng=Math.max(i.lng,a.lng),a.lat=Math.max(i.lat,a.lat)):(this._sw=new Ql(r.lng,r.lat),this._ne=new Ql(i.lng,i.lat)),this}},{key:"getCenter",value:function(){return new Ql((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}},{key:"getSouthWest",value:function(){return this._sw}},{key:"getNorthEast",value:function(){return this._ne}},{key:"getNorthWest",value:function(){return new Ql(this.getWest(),this.getNorth())}},{key:"getSouthEast",value:function(){return new Ql(this.getEast(),this.getSouth())}},{key:"getWest",value:function(){return this._sw.lng}},{key:"getSouth",value:function(){return this._sw.lat}},{key:"getEast",value:function(){return this._ne.lng}},{key:"getNorth",value:function(){return this._ne.lat}},{key:"toArray",value:function(){return[this._sw.toArray(),this._ne.toArray()]}},{key:"toString",value:function(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}},{key:"isEmpty",value:function(){return!(this._sw&&this._ne)}},{key:"contains",value:function(e){var t=Ql.convert(e),r=t.lng,i=t.lat,n=this._sw.lng<=r&&r<=this._ne.lng;return this._sw.lng>this._ne.lng&&(n=this._sw.lng>=r&&r>=this._ne.lng),this._sw.lat<=i&&i<=this._ne.lat&&n}}],[{key:"convert",value:function(t){if(t)return t instanceof e?t:new e(t)}}])})();function tu(e){return Kl*Math.cos(e*Math.PI/180)}function ru(e){return(180+e)/360}function iu(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function nu(e,t){return e/tu(t)}function au(e){return 360*e-180}function ou(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function su(e,t){return e*tu(ou(t))}var lu=85.051129;function uu(e){return Math.cos(re(le(e,-85.051129,lu)))}function cu(e,t){var r=le(t,0,25.5),i=Math.pow(2,r);return uu(e)*Kl/(512*i)}function hu(e){return 1/Math.cos(e*Math.PI/180)}function fu(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=Math.exp(Math.PI*(1-(e.y+t/ri)/(1<2&&void 0!==arguments[2]?arguments[2]:0;p(this,e),this.x=+t,this.y=+r,this.z=+i}return m(e,[{key:"toLngLat",value:function(){return new Ql(au(this.x),ou(this.y))}},{key:"toAltitude",value:function(){return su(this.z,this.y)}},{key:"meterInMercatorCoordinateUnits",value:function(){return 1/Kl*hu(ou(this.y))}}],[{key:"fromLngLat",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=Ql.convert(t);return new e(ru(i.lng),iu(i.lat),nu(r,i.lat))}}])})();function pu(e,t,r,i,n,a,o,s,l){var u=(t+i)/2,c=(r+n)/2,h=new K(u,c);s(h),(function(e,t,r,i,n,a){var o=r-n,s=i-a;return Math.abs((i-t)*o-(r-e)*s)/Math.hypot(o,s)})(h.x,h.y,a.x,a.y,o.x,o.y)>=l?(pu(e,t,r,u,c,a,h,s,l),pu(e,u,c,i,n,h,o,s,l)):e.push(o)}function mu(e,t,r){var i=e[0],n=i.x,a=i.y;t(i);for(var o=[i],s=1;se.x+1||ie.y+1)&&we("Geometry exceeds allowed extent, reduce your vector tile buffer size"),e}function bu(e,t,r){var i=e.loadGeometry(),n=e.extent,a=ri/n;if(t&&r&&r.projection.isReprojectedInTileSpace)for(var o=1<=n||p.y<0||p.y>=n||(h(p),d.push(p));i[f]=d}for(var m of i)for(var v of m)xu(v,a);return i}function wu(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?bu(e):[]}}function ku(e,t,r,i,n){e.emplaceBack(2*t+(i+1)/2,2*r+(n+1)/2)}function Tu(e,t,r){var i=16384;e.emplaceBack(t.x,t.y,t.z,r[0]*i,r[1]*i,r[2]*i)}var Su,Eu,Mu=(function(){return m((function e(t){p(this,e),this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((function(e){return e.fqid})),this.index=t.index,this.hasPattern=!1,this.projection=t.projection,this.layoutVertexArray=new _s,this.indexArray=new Ls,this.segments=new hl,this.programConfigurations=new Bl(t.layers,{zoom:t.zoom,lut:t.lut}),this.stateDependentLayerIds=this.layers.filter((function(e){return e.isStateDependent()})).map((function(e){return e.id}))}),[{key:"updateFootprints",value:function(e,t){}},{key:"populate",value:function(e,t,r,i){var n=this.layers[0],a=[],o=null;for(var s of("circle"===n.type&&(o=n.layout.get("circle-sort-key")),e)){var l=s.feature,u=s.id,c=s.index,h=s.sourceLayerIndex,f=this.layers[0]._featureFilter.needGeometry,d=wu(l,f);if(this.layers[0]._featureFilter.filter(new zo(this.zoom),d,r)){var p=o?o.evaluate(d,{},r):void 0,m={id:u,properties:l.properties,type:l.type,sourceLayerIndex:h,index:c,geometry:f?d.geometry:bu(l,r,i),patterns:{},sortKey:p};a.push(m)}}o&&a.sort((function(e,t){return e.sortKey-t.sortKey}));var v=null;for(var _ of("globe"===i.projection.name&&(this.globeExtVertexArray=new Es,v=i.projection),a)){var g=_.geometry,y=_.index,x=_.sourceLayerIndex,b=e[y].feature;this.addFeature(_,g,y,t.availableImages,r,v,t.brightness),t.featureIndex.insert(b,g,y,x,this.index)}}},{key:"update",value:function(e,t,r,i,n){var a=0!==Object.keys(e).length;a&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(e,t,a?this.stateDependentLayers:this.layers,r,i,n)}},{key:"isEmpty",value:function(){return 0===this.layoutVertexArray.length}},{key:"uploadPending",value:function(){return!this.uploaded||this.programConfigurations.needsUpload}},{key:"upload",value:function(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,ul.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,cl.members))),this.programConfigurations.upload(e),this.uploaded=!0}},{key:"destroy",value:function(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}},{key:"addFeature",value:function(e,t,r,i,n,a,o){for(var s of t)for(var l of s){var u=l.x,c=l.y;if(!(u<0||u>=ri||c<0||c>=ri)){if(a){var h=a.projectTilePoint(u,c,n),f=a.upVector(n,u,c),d=this.globeExtVertexArray;Tu(d,h,f),Tu(d,h,f),Tu(d,h,f),Tu(d,h,f)}var p=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),m=p.vertexLength;ku(this.layoutVertexArray,u,c,-1,-1),ku(this.layoutVertexArray,u,c,1,-1),ku(this.layoutVertexArray,u,c,1,1),ku(this.layoutVertexArray,u,c,-1,1),this.indexArray.emplaceBack(m,m+1,m+2),this.indexArray.emplaceBack(m,m+2,m+3),p.vertexLength+=4,p.primitiveLength+=2}}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,r,{},i,n,o)}}])})();function Au(e,t){for(var r=0;r1){if(zu(e,t))return!0;for(var i=0;i1?r:r.sub(t)._mult(n)._add(t))}function Ou(e,t){for(var r,i,n,a=!1,o=0;ot.y!=n.y>t.y&&t.x<(n.x-i.x)*(t.y-i.y)/(n.y-i.y)+i.x&&(a=!a);return a}function Fu(e,t){for(var r=!1,i=0,n=e.length-1;it.y!=o.y>t.y&&t.x<(o.x-a.x)*(t.y-a.y)/(o.y-a.y)+a.x&&(r=!r)}return r}function Bu(e,t,r,i,n){for(var a of e)if(t<=a.x&&r<=a.y&&i>=a.x&&n>=a.y)return!0;var o=[new K(t,r),new K(t,n),new K(i,n),new K(i,r)];if(e.length>2)for(var s of o)if(Fu(e,s))return!0;for(var l=0;ln.x&&t.x>n.x||e.yn.y&&t.y>n.y)return!1;var a=ke(e,t,r[0]);return a!==ke(e,t,r[1])||a!==ke(e,t,r[2])||a!==ke(e,t,r[3])}function Vu(e,t,r,i,n,a){var o=t.y-e.y,s=e.x-t.x;if(a=a||0){var l=o*o+s*s;if(0===l)return!0;var u=Math.sqrt(l);o/=u,s/=u}return!((r.x-e.x)*o+(r.y-e.y)*s-a<0||(i.x-e.x)*o+(i.y-e.y)*s-a<0||(n.x-e.x)*o+(n.y-e.y)*s-a<0)}function Uu(e,t,r,i,n,a,o){return!(Vu(e,t,i,n,a,o)||Vu(t,r,i,n,a,o)||Vu(r,e,i,n,a,o)||Vu(i,n,e,t,r,o)||Vu(n,a,e,t,r,o)||Vu(a,i,e,t,r,o))}function ju(e,t,r){var i=t.paint.get(e).value;return"constant"===i.kind?i.value:r.programConfigurations.get(t.id).getMaxValue(e)}function Gu(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function qu(e,t,r,i,n){if(!t[0]&&!t[1])return e;var a=K.convert(t)._mult(n);"viewport"===r&&a._rotate(-i);for(var o=[],s=0;s0;a--)n+=(t&(i=1<this.canonical.z?new e(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new e(t,this.wrap,t,this.canonical.x>>r,this.canonical.y>>r)}},{key:"calculateScaledKey",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(this.overscaledZ===e&&t)return this.key;if(e>this.canonical.z)return Ku(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y);var r=this.canonical.z-e;return Ku(this.wrap*+t,e,e,this.canonical.x>>r,this.canonical.y>>r)}},{key:"isChildOf",value:function(e){if(e.wrap!==this.wrap)return!1;var t=this.canonical.z-e.canonical.z;return 0===e.overscaledZ||e.overscaledZ>t&&e.canonical.y===this.canonical.y>>t}},{key:"children",value:function(t){if(this.overscaledZ>=t)return[new e(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];var r=this.canonical.z+1,i=2*this.canonical.x,n=2*this.canonical.y;return[new e(r,this.wrap,r,i,n),new e(r,this.wrap,r,i+1,n),new e(r,this.wrap,r,i,n+1),new e(r,this.wrap,r,i+1,n+1)]}},{key:"isLessThan",value:function(e){return this.wrape.wrap)&&(this.overscaledZe.overscaledZ)&&(this.canonical.xe.canonical.x)&&this.canonical.y=0;if(0===a)return 0;a!==t.length&&(r=!1)}return r?2:1}function sc(e,t){for(var r of e.projections){var i=ac(t,e.points[0],r.axis);if(r.projection[1]i[1])return 0}return 1}function lc(e,t){for(var r=0,i=[0,0,0,0],n=0;n=0&&r++;return r}var uc=(function(){function e(t,r){for(var i of(p(this,e),this.points=t||new Array(8).fill([0,0,0]),this.planes=r||new Array(6).fill([0,0,0,0]),this.bounds=cc.fromPoints(this.points),this.projections=[],this.frustumEdges=[W.vec3.sub([],this.points[2],this.points[3]),W.vec3.sub([],this.points[0],this.points[3]),W.vec3.sub([],this.points[4],this.points[0]),W.vec3.sub([],this.points[5],this.points[1]),W.vec3.sub([],this.points[6],this.points[2]),W.vec3.sub([],this.points[7],this.points[3])],this.frustumEdges)){var n=[0,-i[2],i[1]],a=[i[2],0,-i[0]];this.projections.push({axis:n,projection:ac(this.points,this.points[0],n)}),this.projections.push({axis:a,projection:ac(this.points,this.points[0],a)})}}return m(e,[{key:"intersectsPrecise",value:function(e,t,r){for(var i=0;ic[1]||c[0]>u[1])return 0}}return 1}},{key:"containsPoint",value:function(e){for(var t of this.planes){var r=t[3];if(W.vec3.dot([t[0],t[1],t[2]],e)+r<0)return!1}return!0}}],[{key:"fromInvProjectionMatrix",value:function(t,r,i,n){for(var a=Math.pow(2,i),o=[[-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((function(e){var i=W.vec4.transformMat4([],e,t),o=1/i[3]/r*a;return W.vec4.mul(i,i,[o,o,n?1/i[3]:o,o])})),s=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((function(e){var t=W.vec3.sub([],o[e[0]],o[e[1]]),r=W.vec3.sub([],o[e[2]],o[e[1]]),i=W.vec3.normalize([],W.vec3.cross([],t,r)),n=-W.vec3.dot(i,o[e[1]]);return i.concat(n)})),l=[],u=0;ue.max[t]||e.min[t]>this.max[t])return!1;return!0}},{key:"intersectsAabbXY",value:function(e){return!(this.min[0]>e.max[0]||e.min[0]>this.max[0]||this.min[1]>e.max[1]||e.min[1]>this.max[1])}},{key:"encapsulate",value:function(e){for(var t=0;t<3;t++)this.min[t]=Math.min(this.min[t],e.min[t]),this.max[t]=Math.max(this.max[t],e.max[t])}},{key:"encapsulatePoint",value:function(e){for(var t=0;t<3;t++)this.min[t]=Math.min(this.min[t],e[t]),this.max[t]=Math.max(this.max[t],e[t])}},{key:"closestPoint",value:function(e){return[Math.max(Math.min(this.max[0],e[0]),this.min[0]),Math.max(Math.min(this.max[1],e[1]),this.min[1]),Math.max(Math.min(this.max[2],e[2]),this.min[2])]}}],[{key:"fromPoints",value:function(t){var r=[1/0,1/0,1/0],i=[-1/0,-1/0,-1/0];for(var n of t)W.vec3.min(r,r,n),W.vec3.max(i,i,n);return new e(r,i)}},{key:"fromTileIdAndHeight",value:function(t,r,i){var n=1<3&&void 0!==arguments[3])||arguments[3],n=W.vec3.scale([],e._camera.position,e.worldSize),a=[t,r,1,1];W.vec4.transformMat4(a,a,e.pixelMatrixInverse),W.vec4.scale(a,a,1/a[3]);var o=W.vec3.sub([],a,n),s=W.vec3.normalize([],o),l=e.globeMatrix,u=[l[12],l[13],l[14]],c=W.vec3.sub([],u,n),h=W.vec3.length(c),f=W.vec3.normalize([],c),d=e.worldSize/(2*Math.PI),p=W.vec3.dot(f,s),m=Math.asin(d/h);if(m1?null:(function(e,t,r,i){var n=Math.sin(r);return e*(Math.sin((1-i)*r)/n)+t*(Math.sin(i*r)/n)})(e.a[t],e.b[t],e.angle,le(r,0,1))+e.center[t];var r}function vc(e){if(e.z<=1)return fc[e.z+2*e.y+e.x];var t=bc(xc(e));return cc.fromPoints(t)}function _c(e,t,r){return W.vec3.scale(e,e,1-r),W.vec3.scaleAndAdd(e,e,t,r)}function gc(e,t,r){for(var i of e)W.vec3.transformMat4(i,i,t),W.vec3.scale(i,i,r)}function yc(e,t,r,i){var n=t/e.worldSize,a=e.globeMatrix;if(r.z<=1){var o=vc(r).getCorners();return gc(o,a,n),cc.fromPoints(o)}var s=xc(r,i),l=bc(s,ql+hc(e._tileCoverLift));gc(l,a,n);var u=Number.MAX_VALUE,c=[-u,-u,-u],h=[u,u,u];if(s.contains(e.center)){for(var f of l)W.vec3.min(h,h,f),W.vec3.max(c,c,f);c[2]=0;var d=e.point,p=[d.x*n,d.y*n,0];return W.vec3.min(h,h,p),W.vec3.max(c,c,p),new cc(h,c)}if(e._tileCoverLift>0){for(var m of l)W.vec3.min(h,h,m),W.vec3.max(c,c,m);return new cc(h,c)}var v=[a[12]*n,a[13]*n,a[14]*n],_=s.getCenter(),g=le(e.center.lat,-85.051129,lu),y=le(_.lat,-85.051129,lu),x=ru(e.center.lng),b=iu(g),w=x-ru(_.lng),k=b-iu(y);w>.5?w-=1:w<-.5&&(w+=1);var T=0;if(Math.abs(w)>Math.abs(k))T=w>=0?1:3;else{T=k>=0?0:2;var S=[a[4]*n,a[5]*n,a[6]*n],E=-Math.sin(re(k>=0?s.getSouth():s.getNorth()))*ql;W.vec3.scaleAndAdd(v,v,S,E)}var M=l[T],A=l[(T+1)%4],I=new pc(M,A,v),C=[mc(I,0)||M[0],mc(I,1)||M[1],mc(I,2)||M[2]],P=Cc(e.zoom);if(P>0){for(var z=(function(e,t,r,i,n){var a=e.x,o=e.y,s=1/(1<.5?f=-1:d<-.5&&(f=1),c=(c*t-(n*=t))*r+n,[[l=((l+f)*t-(i*=t))*r+i,h=(h*t-n)*r+n,0],[u=((u+f)*t-i)*r+i,h,0],[u,c,0],[l,c,0]]})(r,t,e._pixelsPerMercatorPixel,x,b),D=0;D1&&void 0!==arguments[1]&&arguments[1],a=1/(1<1&&void 0!==arguments[1]?arguments[1]:ql,r=re(e.getNorth()),i=re(e.getSouth()),n=Math.cos(r),a=Math.cos(i),o=Math.sin(r),s=Math.sin(i),l=e.getWest(),u=e.getEast();return[Xl(a,s,l,t),Xl(a,s,u,t),Xl(n,o,u,t),Xl(n,o,l,t)]}function wc(e,t,r,i){var n=1<Math.PI/2*1.01}var Dc=re(85),Rc=Math.cos(Dc),Lc=Math.sin(Dc),Oc=W.mat4.create(),Fc=function(e){var t=[];return"map"===e.paint.get("circle-pitch-alignment")&&t.push("PITCH_WITH_MAP"),"map"===e.paint.get("circle-pitch-scale")&&t.push("SCALE_WITH_MAP"),t};function Bc(e,t,r,i,n,a,o,s,l){if(a&&e.queryGeometry.isAboveHorizon)return!1;a&&(l*=e.pixelToTileUnitsFactor);var u=e.tileID.canonical,c=r.projection.upVectorScale(u,r.center.lat,r.worldSize).metersToTile;for(var h of t){var f,d=function(){var t=p.add(s),h=n&&r.elevation?r.elevation.exaggeration()*n.getElevationAt(t.x,t.y,!0):0,f=r.projection.projectTilePoint(t.x,t.y,u);if(h>0){var d=r.projection.upVector(u,t.x,t.y);f.x+=d[0]*c*h,f.y+=d[1]*c*h,f.z+=d[2]*c*h}var m=a?t:Nc(f.x,f.y,f.z,i),v=a?e.tilespaceRays.map((function(e){return jc(e,h)})):e.queryGeometry.screenGeometry,_=W.vec4.transformMat4([],[f.x,f.y,f.z,1],i);if(!o&&a?l*=_[3]/r.cameraToCenterDistance:o&&!a&&(l*=r.cameraToCenterDistance/_[3]),a){var g=ou((p.y/ri+u.y)/(1<e.width||n.height>e.height||r.x>e.width-n.width||r.y>e.height-n.height)throw new RangeError("out of range source coordinates for image copy");if(n.width>t.width||n.height>t.height||i.x>t.width-n.width||i.y>t.height-n.height)throw new RangeError("out of range destination coordinates for image copy");for(var l=e.data,u=t.data,c=4===a&&s,h=0;h2&&void 0!==arguments[2]?arguments[2]:2,o=t&&t.length,s=o?t[0]*a:e.length,l=ih(e,0,s,a,!0),u=[];if(!l||l.next===l.prev)return u;if(o&&(l=(function(e,t,r,i){for(var n=[],a=0,o=t.length;a80*a){r=1/0,i=1/0;for(var c=-1/0,h=-1/0,f=a;fc&&(c=d),p>h&&(h=p)}n=0!==(n=Math.max(c-r,h-i))?32767/n:0}return ah(l,u,a,r,i,n,0),u}function ih(e,t,r,i,n){var a;if(n===(function(e,t,r,i){for(var n=0,a=t,o=r-i;a0)for(var o=t;o=t;s-=i)a=Th(s/i|0,e[s],e[s+1],a);return a&&gh(a,a.next)&&(Sh(a),a=a.next),a}function nh(e,t){if(!e)return e;t||(t=e);var r,i=e;do{if(r=!1,i.steiner||!gh(i,i.next)&&0!==_h(i.prev,i,i.next))i=i.next;else{if(Sh(i),(i=t=i.prev)===i.next)break;r=!0}}while(r||i!==t);return t}function ah(e,t,r,i,n,a,o){if(e){!o&&a&&(function(e,t,r,i){var n=e;do{0===n.z&&(n.z=dh(n.x,n.y,t,r,i)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==e);n.prevZ.nextZ=null,n.prevZ=null,(function(e){var t,r=1;do{var i=void 0,n=e;e=null;var a=null;for(t=0;n;){t++;for(var o=n,s=0,l=0;l0||u>0&&o;)0!==s&&(0===u||!o||n.z<=o.z)?(i=n,n=n.nextZ,s--):(i=o,o=o.nextZ,u--),a?a.nextZ=i:e=i,i.prevZ=a,a=i;n=o}a.nextZ=null,r*=2}while(t>1)})(n)})(e,i,n,a);for(var s=e;e.prev!==e.next;){var l=e.prev,u=e.next;if(a?sh(e,i,n,a):oh(e))t.push(l.i,e.i,u.i),Sh(e),e=u.next,s=u.next;else if((e=u)===s){o?1===o?ah(e=lh(nh(e),t),t,r,i,n,a,2):2===o&&uh(e,t,r,i,n,a):ah(nh(e),t,r,i,n,a,1);break}}}}function oh(e){var t=e.prev,r=e,i=e.next;if(_h(t,r,i)>=0)return!1;for(var n=t.x,a=r.x,o=i.x,s=t.y,l=r.y,u=i.y,c=na?n>o?n:o:a>o?a:o,d=s>l?s>u?s:u:l>u?l:u,p=i.next;p!==t;){if(p.x>=c&&p.x<=f&&p.y>=h&&p.y<=d&&mh(n,s,a,l,o,u,p.x,p.y)&&_h(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function sh(e,t,r,i){var n=e.prev,a=e,o=e.next;if(_h(n,a,o)>=0)return!1;for(var s=n.x,l=a.x,u=o.x,c=n.y,h=a.y,f=o.y,d=sl?s>u?s:u:l>u?l:u,v=c>h?c>f?c:f:h>f?h:f,_=dh(d,p,t,r,i),g=dh(m,v,t,r,i),y=e.prevZ,x=e.nextZ;y&&y.z>=_&&x&&x.z<=g;){if(y.x>=d&&y.x<=m&&y.y>=p&&y.y<=v&&y!==n&&y!==o&&mh(s,c,l,h,u,f,y.x,y.y)&&_h(y.prev,y,y.next)>=0)return!1;if(y=y.prevZ,x.x>=d&&x.x<=m&&x.y>=p&&x.y<=v&&x!==n&&x!==o&&mh(s,c,l,h,u,f,x.x,x.y)&&_h(x.prev,x,x.next)>=0)return!1;x=x.nextZ}for(;y&&y.z>=_;){if(y.x>=d&&y.x<=m&&y.y>=p&&y.y<=v&&y!==n&&y!==o&&mh(s,c,l,h,u,f,y.x,y.y)&&_h(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;x&&x.z<=g;){if(x.x>=d&&x.x<=m&&x.y>=p&&x.y<=v&&x!==n&&x!==o&&mh(s,c,l,h,u,f,x.x,x.y)&&_h(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function lh(e,t){var r=e;do{var i=r.prev,n=r.next.next;!gh(i,n)&&yh(i,r,r.next,n)&&wh(i,n)&&wh(n,i)&&(t.push(i.i,r.i,n.i),Sh(r),Sh(r.next),r=e=n),r=r.next}while(r!==e);return nh(r)}function uh(e,t,r,i,n,a){var o=e;do{for(var s=o.next.next;s!==o.prev;){if(o.i!==s.i&&vh(o,s)){var l=kh(o,s);return o=nh(o,o.next),l=nh(l,l.next),ah(o,t,r,i,n,a,0),void ah(l,t,r,i,n,a,0)}s=s.next}o=o.next}while(o!==e)}function ch(e,t){return e.x-t.x}function hh(e,t){var r=(function(e,t){var r,i=t,n=e.x,a=e.y,o=-1/0;do{if(a<=i.y&&a>=i.next.y&&i.next.y!==i.y){var s=i.x+(a-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(s<=n&&s>o&&(o=s,r=i.x=i.x&&i.x>=u&&n!==i.x&&mh(ar.x||i.x===r.x&&fh(r,i)))&&(r=i,h=f)}i=i.next}while(i!==l);return r})(e,t);if(!r)return t;var i=kh(r,e);return nh(i,i.next),nh(r,r.next)}function fh(e,t){return _h(e.prev,e,t.prev)<0&&_h(t.next,e,e.next)<0}function dh(e,t,r,i,n){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*n|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*n|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function ph(e){var t=e,r=e;do{(t.x=(e-o)*(a-s)&&(e-o)*(i-s)>=(r-o)*(t-s)&&(r-o)*(a-s)>=(n-o)*(i-s)}function vh(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!(function(e,t){var r=e;do{if(r.i!==e.i&&r.next.i!==e.i&&r.i!==t.i&&r.next.i!==t.i&&yh(r,r.next,e,t))return!0;r=r.next}while(r!==e);return!1})(e,t)&&(wh(e,t)&&wh(t,e)&&(function(e,t){var r=e,i=!1,n=(e.x+t.x)/2,a=(e.y+t.y)/2;do{r.y>a!=r.next.y>a&&r.next.y!==r.y&&n<(r.next.x-r.x)*(a-r.y)/(r.next.y-r.y)+r.x&&(i=!i),r=r.next}while(r!==e);return i})(e,t)&&(_h(e.prev,e,t.prev)||_h(e,t.prev,t))||gh(e,t)&&_h(e.prev,e,e.next)>0&&_h(t.prev,t,t.next)>0)}function _h(e,t,r){return(t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function gh(e,t){return e.x===t.x&&e.y===t.y}function yh(e,t,r,i){var n=bh(_h(e,t,r)),a=bh(_h(e,t,i)),o=bh(_h(r,i,e)),s=bh(_h(r,i,t));return n!==a&&o!==s||!(0!==n||!xh(e,r,t))||!(0!==a||!xh(e,i,t))||!(0!==o||!xh(r,e,i))||!(0!==s||!xh(r,t,i))}function xh(e,t,r){return t.x<=Math.max(e.x,r.x)&&t.x>=Math.min(e.x,r.x)&&t.y<=Math.max(e.y,r.y)&&t.y>=Math.min(e.y,r.y)}function bh(e){return e>0?1:e<0?-1:0}function wh(e,t){return _h(e.prev,e,e.next)<0?_h(e,t,e.next)>=0&&_h(e,e.prev,t)>=0:_h(e,t,e.prev)<0||_h(e,e.next,t)<0}function kh(e,t){var r=Eh(e.i,e.x,e.y),i=Eh(t.i,t.x,t.y),n=e.next,a=t.prev;return e.next=t,t.prev=e,r.next=n,n.prev=r,i.next=r,r.prev=i,a.next=i,i.prev=a,i}function Th(e,t,r,i){var n=Eh(e,t,r);return i?(n.next=i.next,n.prev=i,i.next.prev=n,i.next=n):(n.prev=n,n.next=n),n}function Sh(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Eh(e,t,r){return{i:e,x:t,y:r,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Mh(e,t){var r=e.length;if(r<=1)return[e];for(var i,n,a=[],o=0;o1)for(var l=0;l5&&void 0!==arguments[5]?arguments[5]:[],o=arguments.length>6?arguments[6]:void 0;for(var s of Mh(t,500)){var l=0;for(var u of s)l+=u.length;var c=this.segments.prepareSegment(l,this.layoutVertexArray,this.indexArray),h=c.vertexLength,f=[],d=[];for(var p of s)if(0!==p.length){p!==s[0]&&d.push(f.length/2);var m=this.segments2.prepareSegment(p.length,this.layoutVertexArray,this.indexArray2),v=m.vertexLength;this.layoutVertexArray.emplaceBack(p[0].x,p[0].y),this.indexArray2.emplaceBack(v+p.length-1,v),f.push(p[0].x),f.push(p[0].y);for(var _=1;_this.max.x||this.min.x>e.x||e.y>this.max.y||this.min.y>e.y)){var r=Fh(e.x-this.min.x,this.xScale,this.cellsX),i=Fh(e.y-this.min.y,this.yScale,this.cellsY),n=this.cells[i*this.cellsX+r];if(n){this._lazyInitLookup();for(var a=0;athis.max.x||this.min.x>t.x||e.y>this.max.y||this.min.y>t.y)){this._lazyInitLookup();for(var i=Fh(e.x-this.min.x,this.xScale,this.cellsX),n=Fh(t.x-this.min.x,this.xScale,this.cellsX),a=Fh(e.y-this.min.y,this.yScale,this.cellsY),o=Fh(t.y-this.min.y,this.yScale,this.cellsY),s=a;s<=o;s++)for(var l=i;l<=n;l++){var u=this.cells[s*this.cellsX+l];if(u)for(var c=0;c>3}if(a--,1===n||2===n)o+=t.readSVarint(),s+=t.readSVarint(),1===n&&(r&&l.push(r),r=[]),r.push(new e(o,s));else{if(7!==n)throw new Error("unknown command "+n);r&&r.push(r[0].clone())}}return r&&l.push(r),l},t.prototype.bbox=function(){var e=this._pbf;e.pos=this._geometry;for(var t=e.readVarint()+e.pos,r=1,i=0,n=0,a=0,o=1/0,s=-1/0,l=1/0,u=-1/0;e.pos>3}if(i--,1===r||2===r)(n+=e.readSVarint())s&&(s=n),(a+=e.readSVarint())u&&(u=a);else if(7!==r)throw new Error("unknown command "+r)}return[o,l,s,u]},t.prototype.toGeoJSON=function(e,r,n){var a,o,s=this.extent*Math.pow(2,n),l=this.extent*e,u=this.extent*r,c=this.loadGeometry(),h=t.types[this.type];function f(e){for(var t=0;t>3;t=1===i?e.readString():2===i?e.readFloat():3===i?e.readDouble():4===i?e.readVarint64():5===i?e.readVarint():6===i?e.readSVarint():7===i?e.readBoolean():null}return t})(r))}return Uh=t,t.prototype.feature=function(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];var r=this._pbf.readVarint()+this._pbf.pos;return new e(this._pbf,r,this.extent,this._keys,this._values)},Uh}function rf(){return Zh||(Zh=1,Qh.VectorTile=(function(){if(qh)return Gh;qh=1;var e=tf();function t(t,r,i){if(3===t){var n=new e(i,i.readVarint()+i.pos);n.length&&(r[n.name]=n)}}return Gh=function(e,r){this.layers=e.readFields(t,{},r)},Gh})(),Qh.VectorTileFeature=ef(),Qh.VectorTileLayer=tf()),Qh}var nf=rf(),af=(function(e){function t(e,r,i){var n;return p(this,t),(n=T(this,t,[e,r])).z=i,n}return g(t,e),m(t)})(K),of=(function(e){function t(e,r,i,n){var a;return p(this,t),(a=T(this,t,[e,r,i])).w=n,a}return g(t,e),m(t)})(af);function sf(e,t,r,i){var n=[],a=0===i?function(e,t,r,i,n,a){e.push(new K(a,r+(a-t)/(i-t)*(n-r)))}:function(e,t,r,i,n,a){e.push(new K(t+(a-r)/(n-r)*(i-t),a))};for(var o of e){var s=[];for(var l of o)if(!(l.length<=2)){for(var u=[],c=0;ct&&a(u,h,f,d,p,t):m>r?v=t&&a(u,h,f,d,p,t),v>r&&m<=r&&a(u,h,f,d,p,r)}var _=l[l.length-1],g=0===i?_.x:_.y;g>=t&&g<=r&&u.push(_),u.length&&(_=u[u.length-1],u[0].x===_.x&&u[0].y===_.y||u.push(u[0]),s.push(u))}s.length&&n.push(s)}return n}function lf(e,t,r,i){var n="x"===r?"y":"x",a=(i-e[r])/(t[r]-e[r]);e[n]=e[n]+(t[n]-e[n])*a,e[r]=i,e.hasOwnProperty("z")&&(e.z=Ft(e.z,t.z,a)),e.hasOwnProperty("w")&&(e.w=Ft(e.w,t.w,a))}function uf(e,t,r,i){var n=r,a=i;for(var o of["x","y"]){var s=e,l=t;s[o]>=l[o]&&(s=t,l=e),s[o]n&&lf(s,l,o,n),s[o]a&&lf(l,s,o,a)}}var cf=Number.MAX_SAFE_INTEGER;function hf(e,t,r,i){return e.ordert.max.x||e.max.xt.max.y||e.max.y0&&(i.length>1&&r.push(i),i=[])}return i.length>1&&r.push(i),r}var Tf=nf.VectorTileFeature.types,Sf=["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"],Ef=["fill-extrusion-flood-light-ground-radius"],Mf=Math.pow(2,13),Af=Math.pow(2,15)-1,If=new K(0,1),Cf=2147483648;function Pf(e,t,r,i,n,a,o,s){e.emplaceBack((t<<1)+o,(r<<1)+a,(Math.floor(i*Mf)<<1)+n,Math.round(s))}function zf(e,t,r){e.emplaceBack(t.x*ri,t.y*ri,r?1:0)}function Df(e,t,r,i,n,a){e.emplaceBack(t.x,t.y,(r.x<<1)+i,(r.y<<1)+n,a)}function Rf(e,t,r){var i=16384;e.emplaceBack(t.x,t.y,t.z,r[0]*i,r[1]*i,r[2]*i)}var Lf=m((function e(){p(this,e),this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0})),Of=(function(){return m((function e(){p(this,e),this.centroidXY=new K(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 K(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new K(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0}),[{key:"span",value:function(){return new K(this.max.x-this.min.x,this.max.y-this.min.y)}}])})(),Ff=(function(){return m((function e(){p(this,e),this.acc=new K(0,0),this.accCount=0,this.centroidDataIndex=0}),[{key:"startRing",value:function(e,t){e.min.x===Number.MAX_VALUE&&(e.min.x=e.max.x=t.x,e.min.y=e.max.y=t.y)}},{key:"appendEdge",value:function(e,t,r){this.accCount++,this.acc._add(t);var i=!!this.borders;t.xe.max.x&&(e.max.x=t.x,i=!0),t.ye.max.y&&(e.max.y=t.y,i=!0),((0===t.x||t.x===ri)&&t.x===r.x)!=((0===t.y||t.y===ri)&&t.y===r.y)&&this.processBorderOverlap(t,r),i&&this.checkBorderIntersection(t,r)}},{key:"checkBorderIntersection",value:function(e,t){t.x<0!=e.x<0&&this.addBorderIntersection(0,Ft(t.y,e.y,(0-t.x)/(e.x-t.x))),t.x>ri!=e.x>ri&&this.addBorderIntersection(1,Ft(t.y,e.y,(ri-t.x)/(e.x-t.x))),t.y<0!=e.y<0&&this.addBorderIntersection(2,Ft(t.x,e.x,(0-t.y)/(e.y-t.y))),t.y>ri!=e.y>ri&&this.addBorderIntersection(3,Ft(t.x,e.x,(ri-t.y)/(e.y-t.y)))}},{key:"addBorderIntersection",value:function(e,t){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);var r=this.borders[e];tr[1]&&(r[1]=t)}},{key:"processBorderOverlap",value:function(e,t){if(e.x===t.x){if(e.y===t.y)return;var r=0===e.x?0:1;this.addBorderIntersection(r,t.y),this.addBorderIntersection(r,e.y)}else{var i=0===e.y?2:3;this.addBorderIntersection(i,t.x),this.addBorderIntersection(i,e.x)}}},{key:"centroid",value:function(){return 0===this.accCount?new K(0,0):new K(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}},{key:"intersectsCount",value:function(){return this.borders?this.borders.reduce((function(e,t){return e+ +(t[0]!==Number.MAX_VALUE)}),0):0}}])})();function Bf(e,t){var r,i,n,a=e.add(t)._unit(),o=le(e.x*a.x+e.y*a.y,-1,1);return n=Math.acos(o),Math.min(4,Math.max(-4,Math.tan(n)))/4*Af*((r=e).x*(i=t).y-r.y*i.x<0?-1:1)}var Nf=[function(e){return e.x<0},function(e){return e.x>ri},function(e){return e.y<0},function(e){return e.y>ri}];function Vf(e,t,r,i){var n=[4];if(0===i)return n;r._mult(i);for(var a=e.sub(r),o=t.sub(r),s=[e,t,a,o],l=0;l<4;l++)for(var u of s)if(Nf[l](u)){n.push(l);break}return n}var Uf,jf,Gf=(function(){return m((function e(t){p(this,e),this.vertexArray=new xs,this.indexArray=new Ls,this.programConfigurations=new Bl(t.layers,{zoom:t.zoom,lut:t.lut},(function(e){return Ef.includes(e)})),this._segments=new hl,this.hiddenByLandmarkVertexArray=new Xs,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new hl}),[{key:"getDefaultSegment",value:function(){return this.regionSegments[4]}},{key:"hasData",value:function(){return 0!==this.vertexArray.length}},{key:"addData",value:function(e,t,r){var i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],n=e.length;if(n>2){var a,o=Math.max(0,this._segments.get().length-1),s=this._segments._prepareSegment(4*n,this.vertexArray.length,2*this._segmentToGroundQuads[o].length);o!==this._segments.get().length-1&&(o++,this._segmentToGroundQuads[o]=[],this._segmentToRegionTriCounts[o]=[0,0,0,0,0]);var l=e[0],u=e[1];a=Bf(l.sub(e[n-1])._perp()._unit(),u.sub(l)._perp()._unit());for(var c=0;c0?this.hiddenByLandmarkVertexBuffer=e.createVertexBuffer(this.hiddenByLandmarkVertexArray,Yh.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1)}},{key:"destroy",value:function(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(var e=0;e<=4;e++){var t=this.regionSegments[e];t&&t.destroy()}}}}])})(),qf=(function(){return m((function e(t){p(this,e),this.zoom=t.zoom,this.canonical=t.canonical,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((function(e){return e.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 Ls,this.footprintVertices=new _s,this.footprintSegments=[],this.layoutVertexArray=new ys,this.centroidVertexArray=new ol,this.wallVertexArray=new ll,this.indexArray=new Ls,this.programConfigurations=new Bl(t.layers,{zoom:t.zoom,lut:t.lut},(function(e){return Sf.includes(e)})),this.segments=new hl,this.stateDependentLayerIds=this.layers.filter((function(e){return e.isStateDependent()})).map((function(e){return e.id})),this.groundEffect=new Gf(t),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[]}),[{key:"updateFootprints",value:function(e,t){}},{key:"populate",value:function(e,t,r,i){for(var n of(this.features=[],this.hasPattern=Ih("fill-extrusion",this.layers,t),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=fu(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),e)){var a=n.feature,o=n.id,s=n.index,l=n.sourceLayerIndex,u=this.layers[0]._featureFilter.needGeometry,c=wu(a,u);if(this.layers[0]._featureFilter.filter(new zo(this.zoom),c,r)){var h={id:o,sourceLayerIndex:l,index:s,geometry:u?c.geometry:bu(a,r,i),properties:a.properties,type:a.type,patterns:{}},f=this.layoutVertexArray.length,d="Polygon"===Tf[h.type];if(this.hasPattern)this.features.push(Ch("fill-extrusion",this.layers,h,this.zoom,t));else if(this.wallMode)for(var p of h.geometry)for(var m of kf(p,d))this.addFeature(h,[m],s,r,{},t.availableImages,i,t.brightness);else this.addFeature(h,h.geometry,s,r,{},t.availableImages,i,t.brightness);t.featureIndex.insert(a,h.geometry,s,l,this.index,f)}}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}},{key:"addFeatures",value:function(e,t,r,i,n,a){for(var o of this.features){var s="Polygon"===Tf[o.type],l=o.geometry;if(this.wallMode)for(var u of l)for(var c of kf(u,s))this.addFeature(o,[c],o.index,t,r,i,n,a);else this.addFeature(o,l,o.index,t,r,i,n,a)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles()}},{key:"update",value:function(e,t,r,i,n){var a=0!==Object.keys(e).length;if(!a||this.stateDependentLayers.length){var o=a?this.stateDependentLayers:this.layers;this.programConfigurations.updatePaintArrays(e,t,o,r,i,n),this.groundEffect.update(e,t,o,r,i,n)}}},{key:"isEmpty",value:function(){return 0===this.layoutVertexArray.length}},{key:"uploadPending",value:function(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}},{key:"upload",value:function(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Kh),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.wallVertexBuffer=e.createVertexBuffer(this.wallVertexArray,Xh.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=e.createVertexBuffer(this.layoutVertexExtArray,Jh.members,!0)),this.groundEffect.upload(e)),this.groundEffect.uploadPaintProperties(e),this.programConfigurations.upload(e),this.uploaded=!0}},{key:"uploadCentroid",value:function(e){this.groundEffect.uploadHiddenByLandmark(e),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,Wh.members,!0):this.centroidVertexBuffer&&this.centroidVertexBuffer.updateData(this.centroidVertexArray),this.needsCentroidUpdate=!1)}},{key:"destroy",value:function(){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())}},{key:"addFeature",value:function(e,t,r,i,n,a,o,s){var l=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(e,{})/this.tileToMeter,u=[new K(0,0),new K(ri,ri)],c=o.projection,h="globe"===c.name,f=this.wallMode||"Polygon"===Tf[e.type],p=new Ff;p.centroidDataIndex=this.centroidData.length;var m,v=new Of,_=this.layers[0].paint.get("fill-extrusion-base").evaluate(e,{},i)<=0,g=this.layers[0].paint.get("fill-extrusion-height").evaluate(e,{},i);if(v.height=g,v.vertexArrayOffset=this.layoutVertexArray.length,v.groundVertexArrayOffset=this.groundEffect.vertexArray.length,h&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new Es),this.wallMode){if(h)return void we("Non zero fill-extrusion-line-width is not yet supported on globe.");if(1!==t.length)return;m=(function(e){var t=e[0].x===e[e.length-1].x&&e[0].y===e[e.length-1].y,r=(function(e){for(var t=0,r=e.length,i=0;i=0})(e);r||(e=e.reverse());var i={geometry:[],joinNormals:[],indices:[]},n=[],a=[],o=[],s=e.length;if(s<(t?3:2))return i;for(;s>=2&&e[s-1].equals(e[s-2]);)s--;for(var l,u,c,h,f,p=0;p0,x="miter";"miter"===x&&g>2&&(x="bevel"),"bevel"===x&&(g>100&&(x="flipbevel"),g<2&&(x="miter"));var b=function(e,t,r,i){var s=new K(e.x,e.y),l=new K(e.x,e.y);s.x+=t.x*i,s.y+=t.y*i,l.x-=t.x*Math.max(r,1),l.y-=t.y*Math.max(r,1),o.push(t),n.push(s),a.push(l)};if("miter"===x)v._mult(g),b(l,v,0,0);else if("flipbevel"===x)b(l,v=f.mult(-1),0,0),b(l,v.mult(-1),0,0);else{var w=-Math.sqrt(g*g-1),k=y?w:0,T=y?0:w;u&&b(l,h,k,T),c&&b(l,f,k,T)}}i.geometry=[].concat(n,d(a.reverse()),[n[0]]),i.joinNormals=[].concat(o,d(o.reverse()),[o[o.length-1]]);for(var S=i.geometry.length-1,E=0;E=0;k--){var T=w[k];(0===T.length||(y=T[0]).every((function(e){return e.x<=0}))||y.every((function(e){return e.x>=ri}))||y.every((function(e){return e.y<=0}))||y.every((function(e){return e.y>=ri})))&&w.splice(k,1)}if(h)x=Qf(w,u,i);else for(var S of(x=[],w))x.push({polygon:S,bounds:u});var E=f?this.edgeRadius:0,M=E>0&&this.zoom<17,A=function(e,t){if(0===e.length)return!1;var r=e[e.length-1];return t.x===r.x&&t.y===r.y};for(var I of x){var C=I.polygon,P=I.bounds,z=0,D=0;for(var R of C)f&&!R[0].equals(R[R.length-1])&&R.push(R[0]),D+=f?R.length-1:R.length;var L=this.segments.prepareSegment((f?5:4)*D,this.layoutVertexArray,this.indexArray);v.footprintSegIdx<0&&(v.footprintSegIdx=this.footprintSegments.length),v.polygonSegIdx<0&&(v.polygonSegIdx=this.polygonSegments.length);var O={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},F=new Lf;if(F.vertexOffset=this.footprintVertices.length,F.indexOffset=3*this.footprintIndices.length,F.ringIndices=[],f){var B=[],N=[];z=L.vertexLength;for(var V=0;V4&&Yf(re[re.length-2],re[0],re[1]),ne=E?$f(re[re.length-2],re[0],re[1],E):0,ae=[],oe=void 0,se=void 0,le=void 0;se=re[1].sub(re[0])._perp()._unit();for(var ue=!0,ce=1,he=0;ce0?1:0,ge=fe.dist(de);if(he+ge>32768&&(he=0),E){le=pe.sub(de)._perp()._unit();var ye=Hf(fe,de,pe,Zf(se,le),E);isNaN(ye)&&(ye=0);var xe=de.sub(fe)._unit();fe=fe.add(xe.mult(ne))._round(),de=de.add(xe.mult(-ye))._round(),ne=ye,se=le,_&&this.zoom>=17&&(A(ae,fe)||ae.push(fe),A(ae,de)||ae.push(de))}var be=L.vertexLength,ke=re.length>4&&Yf(fe,de,pe),Te=Jf(he,ie,ue);if(Pf(this.layoutVertexArray,fe.x,fe.y,ve,_e,0,0,Te),Pf(this.layoutVertexArray,fe.x,fe.y,ve,_e,0,1,Te),this.wallMode){var Se=b(ce-1,re),Ee=m.joinNormals[ce-1];zf(this.wallVertexArray,Ee,Se),zf(this.wallVertexArray,Ee,Se)}if(Te=Jf(he+=ge,ke,!ue),ie=ke,Pf(this.layoutVertexArray,de.x,de.y,ve,_e,0,0,Te),Pf(this.layoutVertexArray,de.x,de.y,ve,_e,0,1,Te),this.wallMode){var Me=b(ce,re),Ae=m.joinNormals[ce];zf(this.wallVertexArray,Ae,Me),zf(this.wallVertexArray,Ae,Me)}if(L.vertexLength+=4,this.indexArray.emplaceBack(be+0,be+1,be+2),this.indexArray.emplaceBack(be+1,be+3,be+2),L.primitiveLength+=2,E){var Ie=z+(1===ce?re.length-2:ce-2),Ce=1===ce?z:Ie+1;if(this.indexArray.emplaceBack(be+1,Ie,be+3),this.indexArray.emplaceBack(Ie,Ce,be+3),L.primitiveLength+=2,void 0===oe&&(oe=be),!Wf(pe,re[ce],P)){var Pe=ce===re.length-1?oe:L.vertexLength;this.indexArray.emplaceBack(be+2,be+3,Pe),this.indexArray.emplaceBack(be+3,Pe+1,Pe),this.indexArray.emplaceBack(be+3,Ce,Pe+1),L.primitiveLength+=3}ue=!ue}if(h){var ze=this.layoutVertexExtArray,De=c.projectTilePoint(fe.x,fe.y,i),Re=c.projectTilePoint(de.x,de.y,i),Le=c.upVector(i,fe.x,fe.y),Oe=c.upVector(i,de.x,de.y);Rf(ze,De,Le),Rf(ze,De,Le),Rf(ze,Re,Oe),Rf(ze,Re,Oe)}}}f&&(z+=re.length-1),_&&E&&this.zoom>=17&&(0!==ae.length&&A(ae,ae[0])&&ae.pop(),this.groundEffect.addData(ae,P,l,E>0))}this.footprintSegments.push(F),O.triangleCount=this.indexArray.length-O.triangleArrayOffset,this.polygonSegments.push(O),++v.footprintSegLen,++v.polygonSegLen}if(v.vertexCount=this.layoutVertexArray.length-v.vertexArrayOffset,v.groundVertexCount=this.groundEffect.vertexArray.length-v.groundVertexArrayOffset,0!==v.vertexCount){if(v.centroidXY=p.borders?If:this.encodeCentroid(p,v),this.centroidData.push(v),p.borders){this.featuresOnBorder.push(p);for(var Fe=this.featuresOnBorder.length-1,Be=0;Beri),n=2*i+(+(r.min.x+r.max.x>ri)^i),a=0;a0&&this.triangleSubSegments.push({segment:x,min:g,max:y});for(var A=p=m;Al.max.x||l.min.x>o.max.x||o.min.y>l.max.y||l.min.y>o.max.y))for(var u=0;ut!=f>t&&e<(this.footprintVertices.int16[2*(u+a.vertexOffset)+0]-c)*(t-h)/(f-h)+c&&(i=!i)}o=s}}return i}},{key:"getHeightAtTileCoord",value:function(e,t){var r=Number.NEGATIVE_INFINITY,i=!0,n=4*(e+ri)*ri+(t+ri);if(this.partLookup.hasOwnProperty(n)){var a=this.partLookup[n];return a?{height:a.height,hidden:!!(a.flags&Cf)}:void 0}for(var o of this.centroidData)e>o.max.x||o.min.x>e||t>o.max.y||o.min.y>t||this.footprintContainsPoint(e,t,o)&&o&&o.height>r&&(r=o.height,this.partLookup[n]=o,i=!!(o.flags&Cf));if(r!==Number.NEGATIVE_INFINITY)return{height:r,hidden:i};this.partLookup[n]=void 0}}])})();function Zf(e,t){var r=e.add(t)._unit();return e.x*r.x+e.y*r.y}function $f(e,t,r,i){var n=t.sub(e)._perp()._unit(),a=r.sub(t)._perp()._unit();return Hf(e,t,r,Zf(n,a),i)}function Hf(e,t,r,i,n){var a=Math.sqrt(1-i*i);return Math.min(e.dist(t)/3,t.dist(r)/3,n*a/i)}function Wf(e,t,r){return e.xr[1].x&&t.x>r[1].x||e.yr[1].y&&t.y>r[1].y}function Xf(e,t){return e.xt[1].x||e.yt[1].y}function Yf(e,t,r){if(e.x<0||e.x>=ri||t.x<0||t.x>=ri||r.x<0||r.x>=ri)return!1;var i=r.sub(t),n=i.perp(),a=e.sub(t);return(i.x*a.x+i.y*a.y)/Math.sqrt((i.x*i.x+i.y*i.y)*(a.x*a.x+a.y*a.y))>-.866&&n.x*a.x+n.y*a.y<0}function Jf(e,t,r){var i=t?2|e:-3&e;return r?1|i:-2&i}function Kf(){var e=Math.PI/32,t=Math.tan(e),r=Jl;return r*Math.sqrt(1+2*t*t)-r}function Qf(e,t,r){var i=1<4&&void 0!==arguments[4]?arguments[4]:0,a=arguments.length>5?arguments[5]:void 0,o=[];if(!e.length||!r||!i)return o;for(var s=function(e,t){for(var r of e)o.push({polygon:r,bounds:t})},l=Math.ceil(Math.log2(r)),u=Math.ceil(Math.log2(i)),c=l-u,h=[],f=0;f0?0:1);for(var d=0;d_+1?m.push({polygons:T,bounds:E,depth:_+1}):s(T,E)}if(S.length){var M=[new K(0===g?k:y.x,1===g?k:y.y),x];h.length>_+1?m.push({polygons:S,bounds:M,depth:_+1}):s(S,M)}}return o})(e,t,Math.ceil((a-n)/11.25),Math.ceil((o-s)/11.25),1,(function(e,t,n){if(0===e)return.5*(t+n);var a=ou((r.y+t/ri)/i);return(iu(.5*(ou((r.y+n/ri)/i)+a))*i-r.y)*ri}))}function ed(e,t,r,i,n,a){for(var o=Math.pow(2,i.z-n.z),s=0;s1&&(s=e[++o]);var u=Math.abs(l-s.left),c=Math.abs(l-s.right),h=Math.min(u,c),f=void 0,d=n/r*(i+1);if(s.isDash){var p=i-Math.abs(d);f=Math.sqrt(h*h+p*p)}else f=i-Math.sqrt(h*h+d*d);this.image.data[a+l]=Math.max(0,Math.min(255,f+128))}}},{key:"addRegularDash",value:function(e,t){for(var r=e.length-1;r>=0;--r){var i=e[r],n=e[r+1];i.zeroLength?e.splice(r,1):n&&n.isDash===i.isDash&&(n.left=i.left,e.splice(r,1))}var a=e[0],o=e[e.length-1];a.isDash===o.isDash&&(a.left=o.left-this.width,o.right=a.right+this.width);for(var s=this.width*this.nextRow,l=0,u=e[l],c=0;c1&&(u=e[++l]);var h=Math.abs(c-u.left),f=Math.abs(c-u.right),d=Math.min(h,f);this.image.data[s+c]=Math.max(0,Math.min(255,(u.isDash?d:-d)+t+128))}}},{key:"addDash",value:function(e,t){var r=this.getKey(e,t);if(this.positions[r])return this.positions[r];var i="round"===t,n=i?7:0,a=2*n+1;if(this.nextRow+a>this.height)return we("LineAtlas out of space"),null;0===e.length&&e.push(1);for(var o=0,s=0;s0&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,ad.members,!0)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,od),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}},{key:"destroy",value:function(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}},{key:"lineFeatureClips",value:function(e){if(e.properties&&e.properties.hasOwnProperty("mapbox_clip_start")&&e.properties.hasOwnProperty("mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}},{key:"addFeature",value:function(e,t,r,i,n,a,o){var s=this.layers[0].layout,l=s.get("line-join").evaluate(e,{}),u=s.get("line-cap").evaluate(e,{}),c=s.get("line-miter-limit"),h=s.get("line-round-limit");for(var f of(this.lineClips=this.lineFeatureClips(e),this.lineFeature=e,this.zOffsetValue=s.get("line-z-offset").value,t))this.addLine(f,e,i,l,u,c,h);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,r,n,a,i,o)}},{key:"addLine",value:function(e,t,r,i,n,a,o){this.distance=0,this.prevDistance=0,this.scaledDistance=0,this.totalDistance=0,this.totalFeatureLength=0,this.lineSoFar=0,this.currentVertex=void 0;var s="none"===i;if(this.patternJoinNone=this.hasPattern&&s,this.segmentStart=0,this.segmentStartf32=0,this.segmentPoints=[],this.lineClips){this.lineClipsArray.push(this.lineClips);for(var l=0;l=2&&e[c-1].equals(e[c-2]);)c--;for(var h=0;h0,C=this.overscaling<=16?122880/(512*this.overscaling):0;if(x&&"round"===b)if(Ea&&(b="bevel"),"bevel"===b&&(E>2&&(b="flipbevel"),E2*C){var D=f.sub(f.sub(d)._mult(C/z)._round());this.updateDistance(d,D),this.addCurrentVertex(D,m,0,0,g,_),d=D}this.updateDistance(d,f),T._mult(E),this.addCurrentVertex(f,T,0,0,g,_);var R=f.dist(p);if(R>2*C){var L=f.add(p.sub(f)._mult(C/R)._round());this.updateDistance(f,L),this.addCurrentVertex(L,v,0,0,g,_),f=L}}else T._mult(E),this.addCurrentVertex(f,T,0,0,g,_);else if("flipbevel"===b){if(E>100)T=v.mult(-1);else{var O=E*m.add(v).mag()/m.sub(v).mag();T._perp()._mult(O*(I?-1:1))}this.addCurrentVertex(f,T,0,0,g,_),this.addCurrentVertex(f,T.mult(-1),0,0,g,_)}else if("bevel"===b||"fakeround"===b){null!=_&&d&&this.addCurrentVertex(f,m,-1,-1,g,_);var F=f.dist(d)<=2*C&&"bevel"!==b,B=T.mult(I?1:-1);B._mult(E);var N=v.mult(I?-1:1),V=m.mult(I?-1:1),U=this.evaluateElevationValue(this.distance);if(null==_&&(this.addHalfVertex(f,B.x,B.y,!1,!I,0,g,U),F||this.addHalfVertex(f,B.x+2*V.x,B.y+2*V.y,!1,I,0,g,U)),"fakeround"===b){var j=Math.round(180*M/Math.PI/20);this.addHalfVertex(f,V.x,V.y,!1,I,0,g,U);for(var G=0;G1){this.lineSoFar=e.w;for(var d=(t.x-e.x)/c,p=(t.y-e.y)/c,m=(t.z-e.z)/c,v=(t.w-e.w)/c,_=1;_6&&void 0!==arguments[6]&&arguments[6],s=t.x+t.y*r,l=t.y-t.x*r,u=t.y*i-t.x,c=-t.y-t.x*i;if(null!=a){var h=-10,f=8202,d=a,p=new of(e.x,e.y,d,this.lineSoFar),m=vd(e,h,f),v=this.lineSoFar,_=this.distance;if(this.currentVertex)if(m){var g=this.currentVertexIsOutside,y=this.currentVertex,x=new of(e.x,e.y,d,this.lineSoFar);if(uf(y,x,h,f),!vd(x,h,f)){if(g){this.e1=this.e2=-1,this.distance-=y.dist(p),this.lineSoFar=y.w;var b=this.evaluateElevationValue(y.w-this.totalFeatureLength*(this.lineClips?this.lineClips.start:0));this.addHalfVertex(y,s,l,o,!1,r,n,b),this.addHalfVertex(y,u,c,o,!0,-i,n,b),this.prevDistance=this.distance}this.distance=this.prevDistance+y.dist(x),this.scaledDistance=this.distance/this.totalDistance,this.addVerticesTo(y,x,s,l,u,c,r,i,n,o),this.distance=_,this.scaledDistance=this.distance/this.totalDistance}}else{var w=this.currentVertex;if(this.currentVertexIsOutside){uf(w,p,h,f),this.e1=this.e2=-1,this.distance-=w.dist(p),this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=w.w;var k=this.evaluateElevationValue(w.w-this.totalFeatureLength*(this.lineClips?this.lineClips.start:0));this.addHalfVertex(w,s,l,o,!1,r,n,k),this.addHalfVertex(w,u,c,o,!0,-i,n,k),this.prevDistance=this.distance,this.distance=_,this.scaledDistance=this.distance/this.totalDistance}this.addVerticesTo(w,p,s,l,u,c,r,i,n,o)}else m||(this.addHalfVertex(e,s,l,o,!1,r,n,a),this.addHalfVertex(e,u,c,o,!0,-i,n,a));this.currentVertex=p,this.currentVertexIsOutside=m,this.lineSoFar=v}else this.addHalfVertex(e,s,l,o,!1,r,n,a),this.addHalfVertex(e,u,c,o,!0,-i,n,a)}},{key:"addHalfVertex",value:function(e,t,r,i,n,a,o,s){var l=e.x,u=e.y;this.patternJoinNone&&(0===this.segmentPoints.length&&(this.segmentStart=this.lineSoFar,this.segmentStartf32=Math.fround(this.lineSoFar)),n||this.segmentPoints.push(this.lineSoFar-this.segmentStart,a)),this.layoutVertexArray.emplaceBack((l<<1)+(i?1:0),(u<<1)+(n?1:0),Math.round(63*t)+128,Math.round(63*r)+128,1+(0===a?0:a<0?-1:1),0,this.lineSoFar-this.segmentStartf32),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineClips.start,this.lineClips.end);var c=o.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,c),o.primitiveLength++),n?this.e2=c:this.e1=c,null!=s&&this.zOffsetVertexArray.emplaceBack(s)}},{key:"updateScaledDistance",value:function(){this.lineClips?(this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=this.totalFeatureLength*this.lineClips.start+this.distance):this.lineSoFar=this.distance}},{key:"updateDistance",value:function(e,t){this.prevDistance=this.distance,this.distance+=e.dist(t),this.updateScaledDistance()}}])})();function vd(e,t,r){return e.xr||e.yr}function _d(e,t,r){return t*(ri/(e.tileSize*Math.pow(2,r-e.tileID.overscaledZ)))}ua(md,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});var gd=function(e,t,r){return(1-r)*e+r*t};function yd(e,t){return 1/_d(e,1,t.tileZoom)}function xd(e,t,r,i){return e.translatePosMatrix(i||t.tileID.projMatrix,t,r.paint.get("line-translate"),r.paint.get("line-translate-anchor"))}var bd,wd=function(e){var t=[];kd(e)&&t.push("RENDER_LINE_DASH"),e.paint.get("line-gradient")&&t.push("RENDER_LINE_GRADIENT");var r=e.paint.get("line-trim-offset");0===r[0]&&0===r[1]||t.push("RENDER_LINE_TRIM_OFFSET"),0!==e.paint.get("line-border-width").constantOr(1)&&t.push("RENDER_LINE_BORDER");var i="none"===e.layout.get("line-join").constantOr("miter"),n=!!e.paint.get("line-pattern").constantOr(1);return i&&n&&t.push("LINE_JOIN_NONE"),t};function kd(e){var t=e.paint.get("line-dasharray").value;return t.value||"constant"!==t.kind}var Td,Sd=function(){return bd||(bd={layout:cd||(cd=new qo({"line-cap":new jo(Zo.layout_line["line-cap"]),"line-join":new jo(Zo.layout_line["line-join"]),"line-miter-limit":new Uo(Zo.layout_line["line-miter-limit"]),"line-round-limit":new Uo(Zo.layout_line["line-round-limit"]),"line-sort-key":new jo(Zo.layout_line["line-sort-key"]),"line-z-offset":new jo(Zo.layout_line["line-z-offset"]),"line-elevation-reference":new Uo(Zo.layout_line["line-elevation-reference"]),"line-cross-slope":new Uo(Zo.layout_line["line-cross-slope"]),visibility:new Uo(Zo.layout_line.visibility)})),paint:hd||(hd=new qo({"line-opacity":new jo(Zo.paint_line["line-opacity"]),"line-color":new jo(Zo.paint_line["line-color"]),"line-translate":new Uo(Zo.paint_line["line-translate"]),"line-translate-anchor":new Uo(Zo.paint_line["line-translate-anchor"]),"line-width":new jo(Zo.paint_line["line-width"]),"line-gap-width":new jo(Zo.paint_line["line-gap-width"]),"line-offset":new jo(Zo.paint_line["line-offset"]),"line-blur":new jo(Zo.paint_line["line-blur"]),"line-dasharray":new jo(Zo.paint_line["line-dasharray"]),"line-pattern":new jo(Zo.paint_line["line-pattern"]),"line-gradient":new Go(Zo.paint_line["line-gradient"]),"line-trim-offset":new Uo(Zo.paint_line["line-trim-offset"]),"line-trim-fade-range":new Uo(Zo.paint_line["line-trim-fade-range"]),"line-trim-color":new Uo(Zo.paint_line["line-trim-color"]),"line-emissive-strength":new Uo(Zo.paint_line["line-emissive-strength"]),"line-border-width":new jo(Zo.paint_line["line-border-width"]),"line-border-color":new jo(Zo.paint_line["line-border-color"]),"line-occlusion-opacity":new Uo(Zo.paint_line["line-occlusion-opacity"])}))})},Ed=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"possiblyEvaluate",value:function(e,r){return r=new zo(Math.floor(r.zoom),{now:r.now,fadeDuration:r.fadeDuration,transition:r.transition}),k(t,"possiblyEvaluate",this,3)([e,r])}},{key:"evaluate",value:function(e,r,i,n){return r=fe({},r,{zoom:Math.floor(r.zoom)}),k(t,"evaluate",this,3)([e,r,i,n])}}])})(jo);function Md(e,t){return t>0?t+2*e:e}var Ad=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),Id=ms([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),Cd=ms([{name:"a_projected_pos",components:4,type:"Float32"}],4);ms([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);var Pd=ms([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),zd=ms([{name:"a_texb",components:2,type:"Uint16"}]),Dd=ms([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),Rd=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"}]);var Ld=ms([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Od=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 Fd=24,Bd=128;function Nd(e,t){var r=t.expression;if("constant"===r.kind)return{kind:"constant",layoutSize:r.evaluate(new zo(e+1))};if("source"===r.kind)return{kind:"source"};for(var i=r.zoomStops,n=r.interpolationType,a=0;a2&&void 0!==arguments[2]?arguments[2]:1,i=0,n=0;if("constant"===e.kind)n=e.layoutSize*r;else if("source"!==e.kind){var a=e.interpolationType,o=e.minZoom,s=e.maxZoom,l=a?le(sn.interpolationFactor(a,t,o,s),0,1):0;"camera"===e.kind?n=Ft(e.minSize,e.maxSize,l)*r:i=l*r}return{uSizeT:i,uSize:n}}var jd=Object.freeze({__proto__:null,SIZE_PACK_FACTOR:Bd,evaluateSizeForFeature:Vd,evaluateSizeForZoom:Ud,getSizeData:Nd});function Gd(e,t,r){return e.sections.forEach((function(e){e.text=(function(e,t,r){var i=t.layout.get("text-transform").evaluate(r,{});return"uppercase"===i?e=e.toLocaleUpperCase():"lowercase"===i&&(e=e.toLocaleLowerCase()),Po.applyArabicShaping&&(e=Po.applyArabicShaping(e)),e})(e.text,t,r)})),e}var qd={"!":"\ufe15","#":"\uff03",$:"\uff04","%":"\uff05","&":"\uff06","(":"\ufe35",")":"\ufe36","*":"\uff0a","+":"\uff0b",",":"\ufe10","-":"\ufe32",".":"\u30fb","/":"\uff0f",":":"\ufe13",";":"\ufe14","<":"\ufe3f","=":"\uff1d",">":"\ufe40","?":"\ufe16","@":"\uff20","[":"\ufe47","\\":"\uff3c","]":"\ufe48","^":"\uff3e",_:"\ufe33","`":"\uff40","{":"\ufe37","|":"\u2015","}":"\ufe38","~":"\uff5e","\xa2":"\uffe0","\xa3":"\uffe1","\xa5":"\uffe5","\xa6":"\uffe4","\xac":"\uffe2","\xaf":"\uffe3","\u2013":"\ufe32","\u2014":"\ufe31","\u2018":"\ufe43","\u2019":"\ufe44","\u201c":"\ufe41","\u201d":"\ufe42","\u2026":"\ufe19","\u2027":"\u30fb","\u20a9":"\uffe6","\u3001":"\ufe11","\u3002":"\ufe12","\u3008":"\ufe3f","\u3009":"\ufe40","\u300a":"\ufe3d","\u300b":"\ufe3e","\u300c":"\ufe41","\u300d":"\ufe42","\u300e":"\ufe43","\u300f":"\ufe44","\u3010":"\ufe3b","\u3011":"\ufe3c","\u3014":"\ufe39","\u3015":"\ufe3a","\u3016":"\ufe17","\u3017":"\ufe18","\uff01":"\ufe15","\uff08":"\ufe35","\uff09":"\ufe36","\uff0c":"\ufe10","\uff0d":"\ufe32","\uff0e":"\u30fb","\uff1a":"\ufe13","\uff1b":"\ufe14","\uff1c":"\ufe3f","\uff1e":"\ufe40","\uff1f":"\ufe16","\uff3b":"\ufe47","\uff3d":"\ufe48","\uff3f":"\ufe33","\uff5b":"\ufe37","\uff5c":"\u2015","\uff5d":"\ufe38","\uff5f":"\ufe35","\uff60":"\ufe36","\uff61":"\ufe12","\uff62":"\ufe41","\uff63":"\ufe42","\u2190":"\u2191","\u2192":"\u2193"};function Zd(e){return"\ufe36"===e||"\ufe48"===e||"\ufe38"===e||"\ufe44"===e||"\ufe42"===e||"\ufe3e"===e||"\ufe3c"===e||"\ufe3a"===e||"\ufe18"===e||"\ufe40"===e||"\ufe10"===e||"\ufe13"===e||"\ufe14"===e||"\uff40"===e||"\uffe3"===e||"\ufe11"===e||"\ufe12"===e}function $d(e){return"\ufe35"===e||"\ufe47"===e||"\ufe37"===e||"\ufe43"===e||"\ufe41"===e||"\ufe3d"===e||"\ufe3b"===e||"\ufe39"===e||"\ufe17"===e||"\ufe3f"===e}var Hd,Wd,Xd,Yd={};function Jd(){if(Xd)return Wd;Xd=1,Wd=t;var e=(Hd||(Hd=1,Yd.read=function(e,t,r,i,n){var a,o,s=8*n-i-1,l=(1<>1,c=-7,h=r?n-1:0,f=r?-1:1,d=e[t+h];for(h+=f,a=d&(1<<-c)-1,d>>=-c,c+=s;c>0;a=256*a+e[t+h],h+=f,c-=8);for(o=a&(1<<-c)-1,a>>=-c,c+=i;c>0;o=256*o+e[t+h],h+=f,c-=8);if(0===a)a=1-u;else{if(a===l)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,i),a-=u}return(d?-1:1)*o*Math.pow(2,a-i)},Yd.write=function(e,t,r,i,n,a){var o,s,l,u=8*a-n-1,c=(1<>1,f=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,d=i?0:a-1,p=i?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,o=c):(o=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-o))<1&&(o--,l*=2),(t+=o+h>=1?f/l:f*Math.pow(2,1-h))*l>=2&&(o++,l/=2),o+h>=c?(s=0,o=c):o+h>=1?(s=(t*l-1)*Math.pow(2,n),o+=h):(s=t*Math.pow(2,h-1)*Math.pow(2,n),o=0));n>=8;e[r+d]=255&s,d+=p,s/=256,n-=8);for(o=o<0;e[r+d]=255&o,d+=p,o/=256,u-=8);e[r+d-p]|=128*m}),Yd);function t(e){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(e)?e:new Uint8Array(e||0),this.pos=0,this.type=0,this.length=this.buf.length}t.Varint=0,t.Fixed64=1,t.Bytes=2,t.Fixed32=5;var r=4294967296,i=2.3283064365386963e-10,n="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function a(e){return e.type===t.Bytes?e.readVarint()+e.pos:e.pos+1}function o(e,t,r){return r?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function s(e,t,r){var i=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));r.realloc(i);for(var n=r.pos-1;n>=e;n--)r.buf[n+i]=r.buf[n]}function l(e,t){for(var r=0;r>>8,e[r+2]=t>>>16,e[r+3]=t>>>24}function y(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}return t.prototype={destroy:function(){this.buf=null},readFields:function(e,t,r){for(r=r||this.length;this.pos>3,a=this.pos;this.type=7&i,e(n,t,this),this.pos===a&&this.skip(i)}return t},readMessage:function(e,t){return this.readFields(e,t,this.readVarint()+this.pos)},readFixed32:function(){var e=_(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=y(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=_(this.buf,this.pos)+_(this.buf,this.pos+4)*r;return this.pos+=8,e},readSFixed64:function(){var e=_(this.buf,this.pos)+y(this.buf,this.pos+4)*r;return this.pos+=8,e},readFloat:function(){var t=e.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=e.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(e){var t,r,i=this.buf;return t=127&(r=i[this.pos++]),r<128?t:(t|=(127&(r=i[this.pos++]))<<7,r<128?t:(t|=(127&(r=i[this.pos++]))<<14,r<128?t:(t|=(127&(r=i[this.pos++]))<<21,r<128?t:(function(e,t,r){var i,n,a=r.buf;if(i=(112&(n=a[r.pos++]))>>4,n<128)return o(e,i,t);if(i|=(127&(n=a[r.pos++]))<<3,n<128)return o(e,i,t);if(i|=(127&(n=a[r.pos++]))<<10,n<128)return o(e,i,t);if(i|=(127&(n=a[r.pos++]))<<17,n<128)return o(e,i,t);if(i|=(127&(n=a[r.pos++]))<<24,n<128)return o(e,i,t);if(i|=(1&(n=a[r.pos++]))<<31,n<128)return o(e,i,t);throw new Error("Expected varint not more than 10 bytes")})(t|=(15&(r=i[this.pos]))<<28,e,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var e=this.readVarint();return e%2==1?(e+1)/-2:e/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&n?(function(e,t,r){return n.decode(e.subarray(t,r))})(this.buf,t,e):(function(e,t,r){for(var i="",n=t;n239?4:l>223?3:l>191?2:1;if(n+c>r)break;1===c?l<128&&(u=l):2===c?128==(192&(a=e[n+1]))&&(u=(31&l)<<6|63&a)<=127&&(u=null):3===c?(o=e[n+2],128==(192&(a=e[n+1]))&&128==(192&o)&&((u=(15&l)<<12|(63&a)<<6|63&o)<=2047||u>=55296&&u<=57343)&&(u=null)):4===c&&(o=e[n+2],s=e[n+3],128==(192&(a=e[n+1]))&&128==(192&o)&&128==(192&s)&&((u=(15&l)<<18|(63&a)<<12|(63&o)<<6|63&s)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,c=1):u>65535&&(u-=65536,i+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),i+=String.fromCharCode(u),n+=c}return i})(this.buf,t,e)},readBytes:function(){var e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t},readPackedVarint:function(e,r){if(this.type!==t.Bytes)return e.push(this.readVarint(r));var i=a(this);for(e=e||[];this.pos127;);else if(r===t.Bytes)this.pos=this.readVarint()+this.pos;else if(r===t.Fixed32)this.pos+=4;else{if(r!==t.Fixed64)throw new Error("Unimplemented type: "+r);this.pos+=8}},writeTag:function(e,t){this.writeVarint(e<<3|t)},realloc:function(e){for(var t=this.length||16;t268435455||e<0?(function(e,t){var r,i;if(e>=0?(r=e%4294967296|0,i=e/4294967296|0):(i=~(-e/4294967296),4294967295^(r=~(-e%4294967296))?r=r+1|0:(r=0,i=i+1|0)),e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),(function(e,t,r){r.buf[r.pos++]=127&e|128,e>>>=7,r.buf[r.pos++]=127&e|128,e>>>=7,r.buf[r.pos++]=127&e|128,e>>>=7,r.buf[r.pos++]=127&e|128,r.buf[r.pos]=127&(e>>>=7)})(r,0,t),(function(e,t){var r=(7&e)<<4;t.buf[t.pos++]|=r|((e>>>=3)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e)))))})(i,t)})(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))))},writeSVarint:function(e){this.writeVarint(e<0?2*-e-1:2*e)},writeBoolean:function(e){this.writeVarint(Boolean(e))},writeString:function(e){e=String(e),this.realloc(4*e.length),this.pos++;var t=this.pos;this.pos=(function(e,t,r){for(var i,n,a=0;a55295&&i<57344){if(!n){i>56319||a+1===t.length?(e[r++]=239,e[r++]=191,e[r++]=189):n=i;continue}if(i<56320){e[r++]=239,e[r++]=191,e[r++]=189,n=i;continue}i=n-55296<<10|i-56320|65536,n=null}else n&&(e[r++]=239,e[r++]=191,e[r++]=189,n=null);i<128?e[r++]=i:(i<2048?e[r++]=i>>6|192:(i<65536?e[r++]=i>>12|224:(e[r++]=i>>18|240,e[r++]=i>>12&63|128),e[r++]=i>>6&63|128),e[r++]=63&i|128)}return r})(this.buf,e,this.pos);var r=this.pos-t;r>=128&&s(t,r,this),this.pos=t-1,this.writeVarint(r),this.pos+=r},writeFloat:function(t){this.realloc(4),e.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),e.write(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(e){var t=e.length;this.writeVarint(t),this.realloc(t);for(var r=0;r=128&&s(r,i,this),this.pos=r-1,this.writeVarint(i),this.pos+=i},writeMessage:function(e,r,i){this.writeTag(e,t.Bytes),this.writeRawMessage(r,i)},writePackedVarint:function(e,t){t.length&&this.writeMessage(e,l,t)},writePackedSVarint:function(e,t){t.length&&this.writeMessage(e,u,t)},writePackedBoolean:function(e,t){t.length&&this.writeMessage(e,f,t)},writePackedFloat:function(e,t){t.length&&this.writeMessage(e,c,t)},writePackedDouble:function(e,t){t.length&&this.writeMessage(e,h,t)},writePackedFixed32:function(e,t){t.length&&this.writeMessage(e,d,t)},writePackedSFixed32:function(e,t){t.length&&this.writeMessage(e,p,t)},writePackedFixed64:function(e,t){t.length&&this.writeMessage(e,m,t)},writePackedSFixed64:function(e,t){t.length&&this.writeMessage(e,v,t)},writeBytesField:function(e,r){this.writeTag(e,t.Bytes),this.writeBytes(r)},writeFixed32Field:function(e,r){this.writeTag(e,t.Fixed32),this.writeFixed32(r)},writeSFixed32Field:function(e,r){this.writeTag(e,t.Fixed32),this.writeSFixed32(r)},writeFixed64Field:function(e,r){this.writeTag(e,t.Fixed64),this.writeFixed64(r)},writeSFixed64Field:function(e,r){this.writeTag(e,t.Fixed64),this.writeSFixed64(r)},writeVarintField:function(e,r){this.writeTag(e,t.Varint),this.writeVarint(r)},writeSVarintField:function(e,r){this.writeTag(e,t.Varint),this.writeSVarint(r)},writeStringField:function(e,r){this.writeTag(e,t.Bytes),this.writeString(r)},writeFloatField:function(e,r){this.writeTag(e,t.Fixed32),this.writeFloat(r)},writeDoubleField:function(e,r){this.writeTag(e,t.Fixed64),this.writeDouble(r)},writeBooleanField:function(e,t){this.writeVarintField(e,Boolean(t))}},Wd}var Kd=t(Jd());function Qd(e,t,r){t.glyphs=[],1===e&&r.readMessage(ep,t)}function ep(e,t,r){if(3===e){var i=r.readMessage(tp,{}),n=i.id,a=i.bitmap,o=i.width,s=i.height,l=i.left,u=i.top,c=i.advance;t.glyphs.push({id:n,bitmap:new Jc({width:o+6,height:s+6},a),metrics:{width:o,height:s,left:l,top:u,advance:c}})}else 4===e?t.ascender=r.readSVarint():5===e&&(t.descender=r.readSVarint())}function tp(e,t,r){1===e?t.id=r.readVarint():2===e?t.bitmap=r.readBytes():3===e?t.width=r.readVarint():4===e?t.height=r.readVarint():5===e?t.left=r.readSVarint():6===e?t.top=r.readSVarint():7===e&&(t.advance=r.readVarint())}var rp={horizontal:1,vertical:2,horizontalOnly:3},ip=(function(){function e(){p(this,e),this.scale=1,this.fontStack="",this.imageName=null}return m(e,null,[{key:"forText",value:function(t,r){var i=new e;return i.scale=t||1,i.fontStack=r,i}},{key:"forImage",value:function(t){var r=new e;return r.imageName=t,r}}])})(),np=(function(){function e(){p(this,e),this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}return m(e,[{key:"length",value:function(){return this.text.length}},{key:"getSection",value:function(e){return this.sections[this.sectionIndex[e]]}},{key:"getSections",value:function(){return this.sections}},{key:"getSectionIndex",value:function(e){return this.sectionIndex[e]}},{key:"getCodePoint",value:function(e){return this.text.codePointAt(e)}},{key:"verticalizePunctuation",value:function(e){this.text=(function(e,t){for(var r="",i=0;i=0&&i>=e&&op[this.text.charCodeAt(i)];i--)r--;this.text=this.text.substring(e,r),this.sectionIndex=this.sectionIndex.slice(e,r)}},{key:"substring",value:function(t,r){var i=new e;return i.text=this.text.substring(t,r),i.sectionIndex=this.sectionIndex.slice(t,r),i.sections=this.sections,i}},{key:"toString",value:function(){return this.text}},{key:"getMaxScale",value:function(){var e=this;return this.sectionIndex.reduce((function(t,r){return Math.max(t,e.sections[r].scale)}),0)}},{key:"addTextSection",value:function(e,t){this.text+=e.text,this.sections.push(ip.forText(e.scale,e.fontStack||t));for(var r=this.sections.length-1,i=0;i=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}],[{key:"fromFeature",value:function(t,r){for(var i=new e,n=0;n=0,c=0,h=0;h0&&q>A&&(A=q)}else{var Z=r[z.fontStack];if(!Z)continue;Z[R]&&(F=Z[R]);var $=t[z.fontStack];if(!$)continue;var H=$.glyphs[R];if(!H)continue;if(O=H.metrics,N=8203!==R?Fd:0,v){var W=void 0!==$.ascender?Math.abs($.ascender):0,X=void 0!==$.descender?Math.abs($.descender):0,Y=(W+X)*L;I-r/2;){if(--o<0)return!1;s-=e[o].dist(a),a=e[o]}s+=e[o].dist(e[o+1]),o++;for(var l=[],u=0;si;)u-=l.shift().angleDelta;if(u>n)return!1;o++,s+=c.dist(h)}return!0}function yp(e){for(var t=0,r=0;ru){var p=(u-l)/d,m=Ft(h.x,f.x,p),v=Ft(h.y,f.y,p),_=new _p(m,v,0,f.angleTo(h),c);return!o||gp(e,_,s,o,t)?_:void 0}l+=d}}function kp(e,t,r,i,n,a,o,s,l){var u=xp(i,a,o),c=bp(i,n),h=c*o,f=0===e[0].x||e[0].x===l||0===e[0].y||e[0].y===l;return t-h=0&&x=0&&b=0&&f+u<=c){var w=new _p(x,b,0,g,p);i&&!gp(e,w,a,i,n)||d.push(w)}}h+=_}return s||d.length||o||(d=Tp(e,h/2,r,i,n,a,o,!0,l)),d}function Sp(e,t,r,i,n){for(var a=[],o=0;o=i&&h.x>=i||(c.x>=i?c=new K(i,c.y+(i-c.x)/(h.x-c.x)*(h.y-c.y))._round():h.x>=i&&(h=new K(i,c.y+(i-c.x)/(h.x-c.x)*(h.y-c.y))._round()),c.y>=n&&h.y>=n||(c.y>=n?c=new K(c.x+(n-c.y)/(h.y-c.y)*(h.x-c.x),n)._round():h.y>=n&&(h=new K(c.x+(n-c.y)/(h.y-c.y)*(h.x-c.x),n)._round()),l&&c.equals(l[l.length-1])||(l=[c],a.push(l)),l.push(h)))))}return a}function Ep(e){var t=0,r=0;for(var i of e)t+=i.w*i.h,r=Math.max(r,i.w);e.sort((function(e,t){return t.h-e.h}));var n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),r),h:1/0}],a=0,o=0;for(var s of e)for(var l=n.length-1;l>=0;l--){var u=n[l];if(!(s.w>u.w||s.h>u.h)){if(s.x=u.x,s.y=u.y,o=Math.max(o,s.y+s.h),a=Math.max(a,s.x+s.w),s.w===u.w&&s.h===u.h){var c=n.pop();l1?g-1:g,Kc.copy(v.data,c,{x:0,y:0},{x:y,y:x},v.data,i),Kc.copy(v.data,c,{x:0,y:w-g},{x:y,y:x-g},{width:b,height:g},i),Kc.copy(v.data,c,{x:0,y:0},{x:y,y:x+w},{width:b,height:g},i),Kc.copy(v.data,c,{x:b-g,y:0},{x:y-g,y:x},{width:g,height:w},i),Kc.copy(v.data,c,{x:0,y:0},{x:y+b,y:x},{width:g,height:w},i),Kc.copy(v.data,c,{x:b-g,y:w-g},{x:y-g,y:x-g},{width:g,height:g},i),Kc.copy(v.data,c,{x:0,y:w-g},{x:y+b,y:x-g},{width:g,height:g},i),Kc.copy(v.data,c,{x:0,y:0},{x:y+b,y:x+w},{width:g,height:g},i),Kc.copy(v.data,c,{x:b-g,y:0},{x:y-g,y:x+w},{width:g,height:g},i)}this.image=c,this.iconPositions=n,this.patternPositions=a}),[{key:"addImages",value:function(e,t,r,i){for(var n in e){var a=e[n],o={x:0,y:0,w:a.data.width+2*r,h:a.data.height+2*r};i.push(o),t[n]=new Mp(o,a,r),a.hasRenderCallback&&this.haveRenderCallbacks.push(n)}}},{key:"patchUpdatedImages",value:function(e,t,r){for(var i in this.haveRenderCallbacks=this.haveRenderCallbacks.filter((function(t){return e.hasImage(t,r)})),e.dispatchRenderCallbacks(this.haveRenderCallbacks,r),e.getUpdatedImages(r))this.patchUpdatedImage(this.iconPositions[i],e.getImage(i,r),t),this.patchUpdatedImage(this.patternPositions[i],e.getImage(i,r),t)}},{key:"patchUpdatedImage",value:function(e,t,r){if(e&&t&&e.version!==t.version){e.version=t.version;var i=x(e.tl,2),n=i[0],a=i[1];r.update(t.data,{position:{x:n,y:a}})}}}])})();ua(Mp,"ImagePosition"),ua(Ap,"ImageAtlas");var Ip=1e20;function Cp(e,t,r,i,n,a,o,s,l){for(var u=t;u-1);a[++l]=s,o[l]=u,o[l+1]=Ip}for(var f=0,d=0;f65535)return we("glyphs > 65535 not supported"),void r(null,{stack:i,id:a,glyph:l});if(s.ranges[u])r(null,{stack:i,id:a,glyph:l});else{var c=s.requests[u];c||(c=s.requests[u]=[],e.loadGlyphRange(i,u,o,n.requestManager,(function(e,t){if(t){for(var r in s.ascender=t.ascender,s.descender=t.descender,t.glyphs)n._doesCharSupportLocalGlyph(+r)||(s.glyphs[+r]=t.glyphs[+r]);s.ranges[u]=!0}for(var i of c)i(e,t);delete s.requests[u]}))),c.push((function(e,t){e?r(e):t&&r(null,{stack:i,id:a,glyph:t.glyphs[a]||null})}))}}else r(null,{stack:i,id:a,glyph:l})}),(function(e,t){if(e)i(e);else if(t){var r={};for(var a of t){var o=a.stack,s=a.id,l=a.glyph;void 0===r[o]&&(r[o]={}),void 0===r[o].glyphs&&(r[o].glyphs={}),r[o].glyphs[s]=l&&{id:l.id,bitmap:l.bitmap.clone(),metrics:l.metrics},r[o].ascender=n.entries[o].ascender,r[o].descender=n.entries[o].descender}i(null,r)}}))}},{key:"_doesCharSupportLocalGlyph",value:function(e){return this.localGlyphMode!==zp.none&&(this.localGlyphMode===zp.all?!!this.localFontFamily:!!this.localFontFamily&&(Xa(e)||Qa(e)||Fa(e)||Ba(e)||Oa(e)||Ha(e)||co(e)||uo(e)))}},{key:"_tinySDF",value:function(t,r,i){var n=this.localFontFamily;if(n&&this._doesCharSupportLocalGlyph(i)){var a=t.tinySDF;if(!a){var o="400";/bold/i.test(r)?o="900":/medium/i.test(r)?o="500":/light/i.test(r)&&(o="200"),(a=t.tinySDF=new e.TinySDF({fontFamily:n,fontWeight:o,fontSize:48,buffer:6,radius:16})).fontWeight=o}if(this.localGlyphs[a.fontWeight][i])return this.localGlyphs[a.fontWeight][i];var s=String.fromCodePoint(i),l=a.draw(s),u=l.data,c=l.width,h=l.height,f=l.glyphWidth,d=l.glyphHeight,p=l.glyphLeft,m=l.glyphTop,v=l.glyphAdvance;return this.localGlyphs[a.fontWeight][i]={id:i,bitmap:new Jc({width:c,height:h},u),metrics:{width:f/2,height:d/2,left:p/2,top:m/2-27,advance:v/2,localGlyph:!0}}}}}])})();Dp.loadGlyphRange=function(e,t,r,i,n){var a=256*t,o=a+255,s=i.transformRequest(i.normalizeGlyphsURL(r).replace("{fontstack}",e).replace("{range}",`${a}-${o}`),ut.Glyphs);dt(s,(function(e,t){if(e)n(e);else if(t){var r={},i=(function(e){return new Kd(e).readFields(Qd,{})})(t);for(var a of i.glyphs)r[a.id]=a;n(null,{glyphs:r,ascender:i.ascender,descender:i.descender})}}))},Dp.TinySDF=(function(){return m((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=t.fontSize,i=void 0===r?24:r,n=t.buffer,a=void 0===n?3:n,o=t.radius,s=void 0===o?8:o,l=t.cutoff,u=void 0===l?.25:l,c=t.fontFamily,h=void 0===c?"sans-serif":c,f=t.fontWeight,d=void 0===f?"normal":f,m=t.fontStyle,v=void 0===m?"normal":m;p(this,e),this.buffer=a,this.cutoff=u,this.radius=s;var _=this.size=i+4*a,g=this._createCanvas(_),y=this.ctx=g.getContext("2d",{willReadFrequently:!0});y.font=`${v} ${d} ${i}px ${h}`,y.textBaseline="alphabetic",y.textAlign="left",y.fillStyle="black",this.gridOuter=new Float64Array(_*_),this.gridInner=new Float64Array(_*_),this.f=new Float64Array(_),this.z=new Float64Array(_+1),this.v=new Uint16Array(_)}),[{key:"_createCanvas",value:function(e){var t=document.createElement("canvas");return t.width=t.height=e,t}},{key:"draw",value:function(e){var t=this.ctx.measureText(e),r=t.width,i=t.actualBoundingBoxAscent,n=t.actualBoundingBoxDescent,a=t.actualBoundingBoxLeft,o=t.actualBoundingBoxRight,s=Math.ceil(i),l=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-a))),u=Math.min(this.size-this.buffer,s+Math.ceil(n)),c=l+2*this.buffer,h=u+2*this.buffer,f=Math.max(c*h,0),d=new Uint8ClampedArray(f),p={data:d,width:c,height:h,glyphWidth:l,glyphHeight:u,glyphTop:s,glyphLeft:0,glyphAdvance:r};if(0===l||0===u)return p;var m=this.ctx,v=this.buffer,_=this.gridInner,g=this.gridOuter;m.clearRect(v,v,l,u),m.fillText(e,v,v+s);var y=m.getImageData(v,v,l,u);g.fill(Ip,0,f),_.fill(0,0,f);for(var x=0;x0?T*T:0,_[k]=T<0?T*T:0}}}Cp(g,0,0,c,h,c,this.f,this.v,this.z),Cp(_,v,v,l,u,c,this.f,this.v,this.z);for(var S=0;S4&&void 0!==arguments[4]?arguments[4]:1,a=[],o=e.imagePrimary,s=o.pixelRatio,l=o.paddedRect.w-2,u=o.paddedRect.h-2,c=(e.right-e.left)*n,h=(e.bottom-e.top)*n,f=o.stretchX||[[0,l]],d=o.stretchY||[[0,u]],p=function(e,t){return e+t[1]-t[0]},m=f.reduce(p,0),v=d.reduce(p,0),_=l-m,g=u-v,y=0,x=m,b=0,w=v,k=0,T=_,S=0,E=g;if(o.content&&i){var M=o.content;y=Lp(f,0,M[0]),b=Lp(d,0,M[1]),x=Lp(f,M[0],M[2]),w=Lp(d,M[1],M[3]),k=M[0]-y,S=M[1]-b,T=M[2]-M[0]-x,E=M[3]-M[1]-w}var A=function(i,a,l,u){var f=Fp(i.stretch-y,x,c,e.left*n),d=Bp(i.fixed-k,T,i.stretch,m),p=Fp(a.stretch-b,w,h,e.top*n),_=Bp(a.fixed-S,E,a.stretch,v),g=Fp(l.stretch-y,x,c,e.left*n),M=Bp(l.fixed-k,T,l.stretch,m),A=Fp(u.stretch-b,w,h,e.top*n),I=Bp(u.fixed-S,E,u.stretch,v),C=new K(f,p),P=new K(g,p),z=new K(g,A),D=new K(f,A),R=new K(d/s,_/s),L=new K(M/s,I/s),O=t*Math.PI/180;if(O){var F=Math.sin(O),B=Math.cos(O),N=[B,-F,F,B];C._matMult(N),P._matMult(N),D._matMult(N),z._matMult(N)}var V=i.stretch+i.fixed,U=l.stretch+l.fixed,j=a.stretch+a.fixed,G=u.stretch+u.fixed,q=e.imageSecondary;return{tl:C,tr:P,bl:D,br:z,texPrimary:{x:o.paddedRect.x+1+V,y:o.paddedRect.y+1+j,w:U-V,h:G-j},texSecondary:q?{x:q.paddedRect.x+1+V,y:q.paddedRect.y+1+j,w:U-V,h:G-j}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:R,pixelOffsetBR:L,minFontScaleX:T/s/c,minFontScaleY:E/s/h,isSDF:r}};if(i&&(o.stretchX||o.stretchY))for(var I=Op(f,_,m),C=Op(d,g,v),P=0;P1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=1/0,n=1/0,a=-1/0,o=-1/0,s=e[0],l=0;la)&&(a=u.x),(!l||u.y>o)&&(o=u.y)}var c=Math.min(a-i,o-n),h=c/2,f=new ti([],Up);if(0===c)return new K(i,n);for(var d=i;dm.d||!m.d)&&(m=_,r&&console.log("found best %d after %d probes",Math.round(1e4*_.d)/1e4,v)),_.max-m.d<=t||(h=_.h/2,f.push(new jp(_.p.x-h,_.p.y-h,h,e)),f.push(new jp(_.p.x+h,_.p.y-h,h,e)),f.push(new jp(_.p.x-h,_.p.y+h,h,e)),f.push(new jp(_.p.x+h,_.p.y+h,h,e)),v+=4)}return r&&(console.log(`num probes: ${v}`),console.log(`best distance: ${m.d}`)),m.p}function Up(e,t){return t.max-e.max}var jp=m((function e(t,r,i,n){p(this,e),this.p=new K(t,r),this.h=i,this.d=(function(e,t){for(var r=!1,i=1/0,n=0;ne.y!=c.y>e.y&&e.x<(c.x-u.x)*(e.y-u.y)/(c.y-u.y)+u.x&&(r=!r),i=Math.min(i,Lu(e,u,c))}return(r?1:-1)*Math.sqrt(i)})(this.p,n),this.max=this.d+this.h*Math.SQRT2})),Gp=Number.POSITIVE_INFINITY,qp=Math.sqrt(2);function Zp(e,t){var r=x(t,2),i=r[0],n=r[1],a=0,o=0;if(n===Gp){i<0&&(i=0);var s=i/qp;switch(e){case"top-right":case"top-left":o=s-7;break;case"bottom-right":case"bottom-left":o=7-s;break;case"bottom":o=7-i;break;case"top":o=i-7}switch(e){case"top-right":case"bottom-right":a=-s;break;case"top-left":case"bottom-left":a=s;break;case"left":a=i;break;case"right":a=-i}}else{switch(i=Math.abs(i),n=Math.abs(n),e){case"top-right":case"top-left":case"top":o=n-7;break;case"bottom-right":case"bottom-left":case"bottom":o=7-n}switch(e){case"top-right":case"bottom-right":case"right":a=-i;break;case"top-left":case"bottom-left":case"left":a=i}}return[a,o]}function $p(e){switch(e){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function Hp(e,t,r,i,n,a,o,s,l,u,c,h,f,d,p){var m=a.textMaxSize.evaluate(t,{},h);void 0===m?m=o*a.textScaleFactor:m*=a.textScaleFactor;var v,_,g=e.layers[0].layout,y=g.get("icon-offset").evaluate(t,{},h),b=Jp(r.horizontal)||r.vertical,w="globe"===f.name,k=o*a.textScaleFactor/24,T=e.tilePixelRatio*m/24,S=(v=e.overscaling,e.zoom>18&&v>2&&(v>>=1),Math.max(ri/(512*v),1)*g.get("symbol-spacing")),E=g.get("text-padding")*e.tilePixelRatio,M=g.get("icon-padding")*e.tilePixelRatio,A=re(g.get("text-max-angle")),I="map"===g.get("text-rotation-alignment")&&"point"!==g.get("symbol-placement"),C="map"===g.get("icon-rotation-alignment")&&"point"!==g.get("symbol-placement"),P=g.get("symbol-placement"),z=S/2,D=g.get("icon-text-fit").evaluate(t,{},h),R=g.get("icon-text-fit-padding").evaluate(t,{},h),L="none"!==D;!1===e.hasAnyIconTextFit&&L&&(e.hasAnyIconTextFit=!0),i&&L&&(e.allowVerticalPlacement&&r.vertical&&(_=vp(i,r.vertical,D,R,y,k)),b&&(i=vp(i,b,D,R,y,k)));var O=function(o,s,m){if(!(s.x<0||s.x>=ri||s.y<0||s.y>=ri)){var v=null;if(w){var g=f.projectTilePoint(s.x,s.y,m),b=g.x,k=g.y,T=g.z;v={anchor:new _p(b,k,T,0,void 0),up:f.upVector(m,s.x,s.y)}}!(function(e,t,r,i,n,a,o,s,l,u,c,h,f,d,p,m,v,_,g,y,b,w,k,T,S,E,M,A,I){var C,P,z,D,R,L,O,F=e.addToLineVertexArray(t,i),B=0,N=0,V=0,U=0,j=-1,G=-1,q={},Z=Et(""),$=r?r.anchor:t,H="none"!==l.layout.get("icon-text-fit").evaluate(b,{},S),W=0,X=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?(A=l.layout.get("text-offset").evaluate(b,{},S).map((function(e){return e*Fd})),W=(I=x(A,2))[0],X=I[1]):(W=l.layout.get("text-radial-offset").evaluate(b,{},S)*Fd,X=Gp),e.allowVerticalPlacement&&n.vertical){var Y=n.vertical;if(p)L=Qp(Y),s&&(O=Qp(s));else{var J=l.layout.get("text-rotate").evaluate(b,{},S)+90;z=Kp(u,$,t,c,h,f,Y,d,J,m),s&&(D=Kp(u,$,t,c,h,f,s,_,J))}}if(a){var K=l.layout.get("icon-rotate").evaluate(b,{},S),Q=Rp(a,K,k,H,w.iconScaleFactor),ee=s?Rp(s,K,k,H,w.iconScaleFactor):void 0;P=Kp(u,$,t,c,h,f,a,_,K),B=4*Q.length;var te=e.iconSizeData,re=null;"source"===te.kind?(re=[Bd*l.layout.get("icon-size").evaluate(b,{},S)*w.iconScaleFactor])[0]>Xp&&we(`${e.layerIds[0]}: Value for "icon-size" is >= ${Wp}. Reduce your "icon-size".`):"composite"===te.kind&&(((re=[Bd*w.compositeIconSizes[0].evaluate(b,{},S)*w.iconScaleFactor,Bd*w.compositeIconSizes[1].evaluate(b,{},S)*w.iconScaleFactor])[0]>Xp||re[1]>Xp)&&we(`${e.layerIds[0]}: Value for "icon-size" is >= ${Wp}. Reduce your "icon-size".`)),e.addSymbols(e.icon,Q,re,y,g,b,!1,r,t,F.lineStartIndex,F.lineLength,-1,T,S,E,M),j=e.icon.placedSymbolArray.length-1,ee&&(N=4*ee.length,e.addSymbols(e.icon,ee,re,y,g,b,rp.vertical,r,t,F.lineStartIndex,F.lineLength,-1,T,S,E,M),G=e.icon.placedSymbolArray.length-1)}for(var ie in n.horizontal){var ne=n.horizontal[ie];C||(Z=Et(ne.text),p?R=Qp(ne):C=Kp(u,$,t,c,h,f,ne,d,l.layout.get("text-rotate").evaluate(b,{},S),m));var ae=1===ne.positionedLines.length;if(V+=Yp(e,r,t,ne,o,l,p,b,m,F,n.vertical?rp.horizontal:rp.horizontalOnly,ae?Object.keys(n.horizontal):[ie],q,j,w,T,S,E),ae)break}n.vertical&&(U+=Yp(e,r,t,n.vertical,o,l,p,b,m,F,rp.vertical,["vertical"],q,G,w,T,S,E));var oe=-1,se=function(e,t){return e?Math.max(e,t):t};oe=se(R,oe),oe=se(L,oe);var le=(oe=se(O,oe))>-1?1:0;e.glyphOffsetArray.length>=65535&&we("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==b.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,b.sortKey),e.symbolInstances.emplaceBack(t.x,t.y,$.x,$.y,$.z,q.right>=0?q.right:-1,q.center>=0?q.center:-1,q.left>=0?q.left:-1,q.vertical>=0?q.vertical:-1,j,G,Z,void 0!==C?C:e.collisionBoxArray.length,void 0!==C?C+1:e.collisionBoxArray.length,void 0!==z?z:e.collisionBoxArray.length,void 0!==z?z+1:e.collisionBoxArray.length,void 0!==P?P:e.collisionBoxArray.length,void 0!==P?P+1:e.collisionBoxArray.length,D||e.collisionBoxArray.length,D?D+1:e.collisionBoxArray.length,c,V,U,B,N,le,0,W,X,oe,0,H?1:0)})(e,s,v,o,r,i,n,_,e.layers[0],e.collisionBoxArray,t.index,t.sourceLayerIndex,e.index,E,I,l,0,M,C,y,t,a,u,c,h,d,p)}};if("line"===P)for(var F of Sp(t.geometry,0,0,ri,ri)){var B=kp(F,S,A,r.vertical||b,i,24,T,e.overscaling,ri);for(var N of B)b&&em(e,b.text,z,N)||O(F,N,h)}else if("line-center"===P){for(var V of t.geometry)if(V.length>1){var U=wp(V,A,r.vertical||b,i,24,T);U&&O(V,U,h)}}else if("Polygon"===t.type)for(var j of Mh(t.geometry,0)){var G=Vp(j,16);O(j[0],new _p(G.x,G.y,0,0,void 0),h)}else if("LineString"===t.type)for(var q of t.geometry)O(q,new _p(q[0].x,q[0].y,0,0,void 0),h);else if("Point"===t.type)for(var Z of t.geometry)for(var $ of Z)O([$],new _p($.x,$.y,0,0,void 0),h)}var Wp=255,Xp=32640;function Yp(e,t,r,i,n,a,o,s,l,u,h,f,p,m,v,_,g,y){var x=(function(e,t,r,i,n,a,o,s){var l=[];if(0===t.positionedLines.length)return l;var u=i.layout.get("text-rotate").evaluate(a,{})*Math.PI/180,h=(function(e){var t=e[0],r=e[1],i=t*r;return i>0?[t,-r]:i<0?[-t,r]:0===t?[r,t]:[r,-t]})(r),f=Math.abs(t.top-t.bottom);for(var p of t.positionedLines)f-=p.lineOffset;for(var m=t.positionedLines.length,v=f/m,_=t.top-r[1],g=0;gXp&&we(`${e.layerIds[0]}: Value for "text-size" is >= ${Wp}. Reduce your "text-size".`):"composite"===b.kind&&(((w=[Bd*v.compositeTextSizes[0].evaluate(s,{},g)*v.textScaleFactor,Bd*v.compositeTextSizes[1].evaluate(s,{},g)*v.textScaleFactor])[0]>Xp||w[1]>Xp)&&we(`${e.layerIds[0]}: Value for "text-size" is >= ${Wp}. Reduce your "text-size".`)),e.addSymbols(e.text,x,w,l,o,s,h,t,r,u.lineStartIndex,u.lineLength,m,_,g,y,!1),f))p[k]=e.text.placedSymbolArray.length-1;return 4*x.length}function Jp(e){for(var t in e)return e[t];return null}function Kp(e,t,r,i,n,a,o,s,l,u){var c=o.top,h=o.bottom,f=o.left,d=o.right,p=o.collisionPadding;if(p&&(f-=p[0],c-=p[1],d+=p[2],h+=p[3]),l){var m=new K(f,c),v=new K(d,c),_=new K(f,h),g=new K(d,h),y=re(l),x=new K(0,0);u&&(x=new K(u[0],u[1])),m._rotateAround(y,x),v._rotateAround(y,x),_._rotateAround(y,x),g._rotateAround(y,x),f=Math.min(m.x,v.x,_.x,g.x),d=Math.max(m.x,v.x,_.x,g.x),c=Math.min(m.y,v.y,_.y,g.y),h=Math.max(m.y,v.y,_.y,g.y)}return e.emplaceBack(t.x,t.y,t.z,r.x,r.y,f,c,d,h,s,i,n,a),e.length-1}function Qp(e){e.collisionPadding&&(e.top-=e.collisionPadding[1],e.bottom+=e.collisionPadding[3]);var t=e.bottom-e.top;return t>0?Math.max(10,t):null}function em(e,t,r,i){var n=e.compareText;if(t in n){for(var a=n[t],o=a.length-1;o>=0;o--)if(i.dist(a[o])y&&(x(e,u,i,n,s,l),x(u,r,s,l,a,o))}x(h,f,i,a,n,a),x(f,d,n,a,n,o),x(d,p,n,o,i,o),x(p,h,i,o,i,a),m-=y,v-=y,_+=y,g+=y;var b=1/Math.max(_-m,g-v);return{scale:b,x:m*b,y:v*b,x2:_*b,y2:g*b,projection:t}}function im(e,t){var r=t.x,i=t.y;return new K(((r-(arguments.length>2&&void 0!==arguments[2]?arguments[2]:0))*e.scale-e.x)*ri,(i*e.scale-e.y)*ri)}var nm=W.mat4.identity(new Float32Array(16)),am=(function(){return m((function e(t){p(this,e),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]}),[{key:"project",value:function(e,t){return{x:0,y:0,z:0}}},{key:"unproject",value:function(e,t){return new Ql(0,0)}},{key:"projectTilePoint",value:function(e,t,r){return{x:e,y:t,z:0}}},{key:"locationPoint",value:function(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return e._coordinatePoint(e.locationCoordinate(t),r)}},{key:"pixelsPerMeter",value:function(e,t){return nu(1,e)*t}},{key:"pixelSpaceConversion",value:function(e,t,r){return 1}},{key:"farthestPixelDistance",value:function(e){return tm(e,e.pixelsPerMeter)}},{key:"pointCoordinate",value:function(e,t,r,i){var n=e.horizonLineFromTop(!1),a=new K(t,Math.max(n,r));return e.rayIntersectionCoordinate(e.pointRayIntersection(a,i))}},{key:"pointCoordinate3D",value:function(e,t,r){var i=new K(t,r);if(e.elevation)return e.elevation.pointCoordinate(i);var n=this.pointCoordinate(e,i.x,i.y,0);return[n.x,n.y,n.z]}},{key:"isPointAboveHorizon",value:function(e,t){if(e.elevation&&e.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(e,t.x,t.y);var r=e.horizonLineFromTop();return t.y0?t<-pm+r&&(t=-pm+r):t>pm-r&&(t=pm-r);var a=n/Math.pow(mm(t),i),o=a*Math.sin(i*e),s=n-a*Math.cos(i*e);return o=.5*(o/Math.PI+.5),s=.5*(s/Math.PI+.5),{x:o,y:this.southernCenter?s:1-s,z:0}}},{key:"unproject",value:function(e,t){e=(2*e-.5)*Math.PI,this.southernCenter&&(t=1-t),t=(2*(1-t)-.5)*Math.PI;var r=this.n,i=this.f,n=i-t,a=Math.sign(n),o=Math.sign(r)*Math.sqrt(e*e+n*n),s=Math.atan2(e,Math.abs(n))*a;n*r<0&&(s-=Math.PI*Math.sign(e)*a);var l=le(ie(s/r)+this.center[0],-180,180),u=le(ie(2*Math.atan(Math.pow(i/o,1/r))-pm),-85.051129,lu);return new Ql(l,this.southernCenter?-u:u)}}])})(am),_m=(function(e){function t(e){var r;return p(this,t),(r=T(this,t,[e])).wrap=!0,r.supportsWorldCopies=!0,r.supportsTerrain=!0,r.supportsFog=!0,r.supportsFreeCamera=!0,r.isReprojectedInTileSpace=!1,r.unsupportedLayers=[],r.range=null,r}return g(t,e),m(t,[{key:"project",value:function(e,t){return{x:ru(e),y:iu(t),z:0}}},{key:"unproject",value:function(e,t){var r=au(e),i=ou(t);return new Ql(r,i)}}])})(am),gm=re(lu),ym=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"project",value:function(e,t){var r=(t=re(t))*t,i=r*r;return{x:.5*((e=re(e))*(.8707-.131979*r+i*(i*(.003971*r-.001529*i)-.013791))/Math.PI+.5),y:1-.5*(t*(1.007226+r*(.015085+i*(.028874*r-.044475-.005916*i)))/Math.PI+1),z:0}}},{key:"unproject",value:function(e,t){e=(2*e-.5)*Math.PI;var r=t=(2*(1-t)-1)*Math.PI,i=25,n=0,a=r*r;do{var o=(a=r*r)*a;r=le(r-(n=(r*(1.007226+a*(.015085+o*(.028874*a-.044475-.005916*o)))-t)/(1.007226+a*(.045255+o*(.259866*a-.311325-.06507600000000001*o)))),-gm,gm)}while(Math.abs(n)>1e-6&&--i>0);var s=le(ie(e/(.8707+(a=r*r)*(a*(a*a*a*(.003971-.001529*a)-.013791)-.131979))),-180,180),l=ie(r);return new Ql(s,l)}}])})(am),xm=re(lu),bm=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t,[{key:"project",value:function(e,t){t=re(t),e=re(e);var r=Math.cos(t),i=2/Math.PI,n=Math.acos(r*Math.cos(e/2)),a=Math.sin(n)/n,o=.5*(e*i+2*r*Math.sin(e/2)/a)||0,s=.5*(t+Math.sin(t)/a)||0;return{x:.5*(o/Math.PI+.5),y:1-.5*(s/Math.PI+1),z:0}}},{key:"unproject",value:function(e,t){var r=e=(2*e-.5)*Math.PI,i=t=(2*(1-t)-1)*Math.PI,n=25,a=1e-6,o=0,s=0;do{var l=Math.cos(i),u=Math.sin(i),c=2*u*l,h=u*u,f=l*l,d=Math.cos(r/2),p=Math.sin(r/2),m=2*d*p,v=p*p,_=1-f*d*d,g=_?1/_:0,y=_?Math.acos(l*d)*Math.sqrt(1/_):0,x=.5*(2*y*l*p+2*r/Math.PI)-e,b=.5*(y*u+i)-t,w=.5*g*(f*v+y*l*d*h)+1/Math.PI,k=g*(m*c/4-y*u*p),T=.125*g*(c*p-y*u*f*m),S=.5*g*(h*d+y*v*l)+.5,E=k*T-S*w;s=(x*T-b*w)/E,r=le(r-(o=(b*k-x*S)/E),-Math.PI,Math.PI),i=le(i-s,-xm,xm)}while((Math.abs(o)>a||Math.abs(s)>a)&&--n>0);return new Ql(ie(r),ie(i))}}])})(am),wm=(function(e){function t(e){var r;return p(this,t),(r=T(this,t,[e])).center=e.center||[0,0],r.parallels=e.parallels||[0,0],r.cosPhi=Math.max(.01,Math.cos(re(r.parallels[0]))),r.scale=1/(2*Math.max(Math.PI*r.cosPhi,1/r.cosPhi)),r.wrap=!0,r.supportsWorldCopies=!0,r}return g(t,e),m(t,[{key:"project",value:function(e,t){var r=this.scale,i=this.cosPhi;return{x:re(e)*i*r+.5,y:-Math.sin(re(t))/i*r+.5,z:0}}},{key:"unproject",value:function(e,t){var r=this.scale,i=this.cosPhi,n=-(t-.5)/r,a=le(ie((e-.5)/r)/i,-180,180),o=Math.asin(le(n*i,-1,1)),s=le(ie(o),-85.051129,lu);return new Ql(a,s)}}])})(am),km=(function(e){function t(e){var r;return p(this,t),(r=T(this,t,[e])).requiresDraping=!0,r.supportsWorldCopies=!1,r.supportsFog=!0,r.zAxisUnit="pixels",r.unsupportedLayers=["debug"],r.range=[3,5],r}return g(t,e),m(t,[{key:"projectTilePoint",value:function(e,t,r){var i=wc(e,t,r),n=Sc(vc(r));return W.vec3.transformMat4(i,i,n),{x:i[0],y:i[1],z:i[2]}}},{key:"locationPoint",value:function(e,t){var r=Yl(t.lat,t.lng),i=W.vec3.normalize([],r),n=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(t),e._centerAltitude):e._centerAltitude,a=nu(1,0)*ri*n;W.vec3.scaleAndAdd(r,r,i,a);var o=W.mat4.identity(new Float64Array(16));return W.mat4.multiply(o,e.pixelMatrix,e.globeMatrix),W.vec3.transformMat4(r,r,o),new K(r[0],r[1])}},{key:"pixelsPerMeter",value:function(e,t){return nu(1,0)*t}},{key:"pixelSpaceConversion",value:function(e,t,r){var i=nu(1,e)*t,n=Ft(nu(1,45)*t,i,r);return this.pixelsPerMeter(e,t)/n}},{key:"createTileMatrix",value:function(e,t,r){var i=Ec(vc(r.canonical));return W.mat4.multiply(new Float64Array(16),e.globeMatrix,i)}},{key:"createInversionMatrix",value:function(e,t){var r=e.center,i=Sc(vc(t));return W.mat4.rotateY(i,i,re(r.lng)),W.mat4.rotateX(i,i,re(r.lat)),W.mat4.scale(i,i,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(i)}},{key:"pointCoordinate",value:function(e,t,r,i){return dc(e,t,r,!0)||new du(0,0)}},{key:"pointCoordinate3D",value:function(e,t,r){var i=this.pointCoordinate(e,t,r,0);return[i.x,i.y,i.z]}},{key:"isPointAboveHorizon",value:function(e,t){return!dc(e,t.x,t.y,!1)}},{key:"farthestPixelDistance",value:function(e){var t=(function(e,t){var r,i=e.cameraToCenterDistance,n=e._centerAltitude*t,a=e._camera,o=e._camera.forward(),s=W.vec3.add([],W.vec3.scale([],o,-i),[0,0,n]),l=e.worldSize/(2*Math.PI),u=[0,0,-l],c=e.width/e.height,h=Math.tan(e.fovAboveCenter),f=W.vec3.scale([],a.up(),h),d=W.vec3.scale([],a.right(),h*c),p=W.vec3.normalize([],W.vec3.add([],W.vec3.add([],o,f),d)),m=[];if(new ic(s,p).closestPointOnSphere(u,l,m)){var v=W.vec3.add([],m,u),_=W.vec3.sub([],v,s);r=Math.cos(e.fovAboveCenter)*W.vec3.length(_)}else{var g=W.vec3.sub([],s,u),y=W.vec3.sub([],u,s);W.vec3.normalize(y,y);var x=W.vec3.length(g)-l;r=Math.sqrt(x*(x+2*l));var b=Math.acos(r/(l+x))-Math.acos(W.vec3.dot(o,y));r*=Math.cos(b)}return 1.01*r})(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),r=Cc(e.zoom);if(r>0){var i=tm(e,nu(1,e.center.lat)*e.worldSize),n=e.worldSize/(2*Math.PI),a=Math.max(e.width,e.height)/e.worldSize*Math.PI;return Ft(t,i+n*(1-Math.cos(a)),Math.pow(r,10))}return t}},{key:"upVector",value:function(e,t,r){return wc(t,r,e,1)}},{key:"upVectorScale",value:function(e){return{metersToTile:hc(kc(vc(e)))}}}])})(_m);function Tm(e){var t=e.parallels,r=!!t&&Math.abs(t[0]+t[1])<.01;switch(e.name){case"mercator":return new _m(e);case"equirectangular":return new dm(e);case"naturalEarth":return new ym(e);case"equalEarth":return new fm(e);case"winkelTripel":return new bm(e);case"albers":return r?new wm(e):new om(e);case"lambertConformalConic":return r?new wm(e):new vm(e);case"globe":return new km(e)}throw new Error(`Invalid projection name: ${e.name}`)}var Sm=nf.VectorTileFeature.types,Em=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function Mm(e,t,r,i,n,a,o,s,l,u,c,h,f){var d=s?Math.min(Xp,Math.round(s[0])):0,p=s?Math.min(Xp,Math.round(s[1])):0;e.emplaceBack(t,r,Math.round(32*i),Math.round(32*n),a,o,(d<<1)+(l?1:0),p,16*u,16*c,256*h,256*f)}function Am(e,t,r){e.emplaceBack(t,r)}function Im(e,t,r,i,n,a,o){e.emplaceBack(t,r,i,n,a,o)}function Cm(e,t,r,i,n){e.emplaceBack(t,r,i,n),e.emplaceBack(t,r,i,n),e.emplaceBack(t,r,i,n),e.emplaceBack(t,r,i,n)}function Pm(e){for(var t of e.sections)if(yo(t.text))return!0;return!1}var zm=(function(){return m((function e(t){p(this,e),this.layoutVertexArray=new Ms,this.indexArray=new Ls,this.programConfigurations=t,this.segments=new hl,this.dynamicLayoutVertexArray=new ws,this.opacityVertexArray=new Is,this.placedSymbolArray=new Qs,this.iconTransitioningVertexArray=new Cs,this.globeExtVertexArray=new As,this.zOffsetVertexArray=new Bs}),[{key:"isEmpty",value:function(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length&&0===this.iconTransitioningVertexArray.length}},{key:"upload",value:function(e,t,r,i,n){this.isEmpty()||(r&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Ad.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,t),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,Cd.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,Em,!0),this.iconTransitioningVertexArray.length>0&&(this.iconTransitioningVertexBuffer=e.createVertexBuffer(this.iconTransitioningVertexArray,zd.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,Id.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||n)&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,Pd.members,!0)),this.opacityVertexBuffer.itemSize=1),(r||i)&&this.programConfigurations.upload(e))}},{key:"destroy",value:function(){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())}}])})();ua(zm,"SymbolBuffers");var Dm=(function(){return m((function e(t,r,i){p(this,e),this.layoutVertexArray=new t,this.layoutAttributes=r,this.indexArray=new i,this.segments=new hl,this.collisionVertexArray=new Rs,this.collisionVertexArrayExt=new ws}),[{key:"upload",value:function(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,Dd.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,Rd.members,!0)}},{key:"destroy",value:function(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}])})();ua(Dm,"CollisionBuffers");var Rm,Lm,Om,Fm=(function(){return m((function e(t){p(this,e),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((function(e){return e.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=W.mat4.identity([]),this.placementViewportMatrix=W.mat4.identity([]);var r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Nd(this.zoom,r["text-size"]),this.iconSizeData=Nd(this.zoom,r["icon-size"]);var i=this.layers[0].layout,n=i.get("symbol-sort-key"),a=i.get("symbol-z-order");this.canOverlap=i.get("text-allow-overlap")||i.get("icon-allow-overlap")||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==a&&void 0!==n.constantOr(1),this.sortFeaturesByY=("viewport-y"===a||"auto"===a&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=i.get("text-writing-mode").map((function(e){return rp[e]})),this.stateDependentLayerIds=this.layers.filter((function(e){return e.isStateDependent()})).map((function(e){return e.id})),this.sourceID=t.sourceID,this.projection=t.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=i.get("symbol-z-elevate"),this.activeReplacements=[],this.replacementUpdateTime=0}),[{key:"createArrays",value:function(){this.text=new zm(new Bl(this.layers,{zoom:this.zoom,lut:this.lut},(function(e){return e.startsWith("text")||e.startsWith("symbol")}))),this.icon=new zm(new Bl(this.layers,{zoom:this.zoom,lut:this.lut},(function(e){return e.startsWith("icon")||e.startsWith("symbol")}))),this.glyphOffsetArray=new rl,this.lineVertexArray=new il,this.symbolInstances=new tl}},{key:"calculateGlyphDependencies",value:function(e,t,r,i,n){for(var a of e){var o=a.codePointAt(0);if(void 0===o)break;if(t[o]=!0,i&&n&&o<=65535){var s=qd[a];s&&(t[s.charCodeAt(0)]=!0)}}}},{key:"updateFootprints",value:function(e,t){}},{key:"updateReplacement",value:function(e,t){if(t.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=t.updateTime;var r=t.getReplacementRegionsForTile(e.toUnwrapped(),!0);return!mf(this.activeReplacements,r)&&(this.activeReplacements=r,!0)}},{key:"populate",value:function(e,t,r,i){var n=this,a=this.layers[0],o=a.layout,s="globe"===this.projection.name,l=o.get("text-font"),u=o.get("text-field"),c=o.get("icon-image"),h=("constant"!==u.value.kind||u.value.value instanceof sr&&!u.value.value.isEmpty()||u.value.value.toString().length>0)&&("constant"!==l.value.kind||l.value.value.length>0),f="constant"!==c.value.kind||!!c.value.value||Object.keys(c.parameters).length>0,d=o.get("symbol-sort-key");if(this.features=[],h||f){var p=t.iconDependencies,m=t.glyphDependencies,v=t.availableImages,_=new zo(this.zoom),g=function(){var e,t,u=a._featureFilter.needGeometry,c=wu(x,u);if(!a._featureFilter.filter(_,c,r))return 0;if(u||(c.geometry=bu(x,r,i)),s&&1!==x.type&&r.z<=5)for(var g=c.geometry,y=function(e,t){var i=wc(e.x,e.y,r,1),n=wc(t.x,t.y,r,1);return W.vec3.dot(i,n)<.98078528056},T=0;T=0,e.sections))if(P.image)p[P.image.namePrimary]=!0;else{var z=ho(e.toString()),D=P.fontStack||I,R=m[D]=m[D]||{};n.calculateGlyphDependencies(P.text,R,C,n.allowVerticalPlacement,z)}}};for(var y of e){var x=y.feature,b=y.id,w=y.index,k=y.sourceLayerIndex;g()}"line"===o.get("symbol-placement")&&(this.features=(function(e){var t={},r={},i=[],n=0;function a(t){i.push(e[t]),n++}function o(e,t,n){var a=r[e];return delete r[e],r[t]=a,i[a].geometry[0].pop(),i[a].geometry[0]=i[a].geometry[0].concat(n[0]),a}function s(e,r,n){var a=t[r];return delete t[r],t[e]=a,i[a].geometry[0].shift(),i[a].geometry[0]=n[0].concat(i[a].geometry[0]),a}function l(e,t,r){var i=r?t[0][t[0].length-1]:t[0][0];return`${e}:${i.x}:${i.y}`}for(var u=0;ue.length&&e.resize(r);for(var n=-t;n<0;n++)e.emplace(n+r,i)},t=function(e,t,r){(i+=t)>e.length&&e.resize(i);for(var n=-t;n<0;n++)e.emplace(n+i,r)};if(this.zOffsetBuffersNeedUpload){this.zOffsetBuffersNeedUpload=!1;for(var r=0,i=0,n=0;n0;if((o>0||s>0)&&(e(this.text.zOffsetVertexArray,o,u),e(this.text.zOffsetVertexArray,s,u)),c){var h=a.placedIconSymbolIndex,f=a.verticalPlacedIconSymbolIndex;h>=0&&t(this.icon.zOffsetVertexArray,l,u),f>=0&&t(this.icon.zOffsetVertexArray,a.numVerticalIconVertices,u)}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray)}}},{key:"isEmpty",value:function(){return 0===this.symbolInstances.length&&!this.hasRTLText}},{key:"uploadPending",value:function(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}},{key:"upload",value:function(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.uploaded=!0}},{key:"destroyDebugData",value:function(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}},{key:"getProjection",value:function(){return this.projectionInstance||(this.projectionInstance=Tm(this.projection)),this.projectionInstance}},{key:"destroy",value:function(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}},{key:"addToLineVertexArray",value:function(e,t){var r=this.lineVertexArray.length;if(void 0!==e.segment)for(var i of t){var n=i.x,a=i.y;this.lineVertexArray.emplaceBack(n,a)}return{lineStartIndex:r,lineLength:this.lineVertexArray.length-r}}},{key:"addSymbols",value:function(e,t,r,i,n,a,o,s,l,u,c,h,f,d,p,m){for(var v=e.indexArray,_=e.layoutVertexArray,g=e.globeExtVertexArray,y=e.segments.prepareSegment(4*t.length,_,v,this.canOverlap?a.sortKey:void 0),b=this.glyphOffsetArray.length,w=y.vertexLength,k=this.allowVerticalPlacement&&o===rp.vertical?Math.PI/2:0,T=a.text&&a.text.sections,S=0;S=0?t.rightJustifiedTextSymbolIndex:t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.leftJustifiedTextSymbolIndex>=0?t.leftJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex>=0?t.verticalPlacedTextSymbolIndex:i),a=Vd(this.textSizeData,e,n)/Fd;return this.tilePixelRatio*a}},{key:"getSymbolInstanceIconSize",value:function(e,t,r){var i=this.icon.placedSymbolArray.get(r),n=Vd(this.iconSizeData,e,i);return this.tilePixelRatio*n}},{key:"_commitDebugCollisionVertexUpdate",value:function(e,t,r,i){e.emplaceBack(t,-r,-r,i),e.emplaceBack(t,r,-r,i),e.emplaceBack(t,r,r,i),e.emplaceBack(t,-r,r,i)}},{key:"_updateTextDebugCollisionBoxes",value:function(e,t,r,i,n,a,o){for(var s=i;s0}},{key:"hasIconData",value:function(){return this.icon.segments.get().length>0}},{key:"hasDebugData",value:function(){return this.textCollisionBox&&this.iconCollisionBox}},{key:"hasTextCollisionBoxData",value:function(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}},{key:"hasIconCollisionBoxData",value:function(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}},{key:"hasIconTextFit",value:function(){return this.hasAnyIconTextFit}},{key:"addIndicesForPlacedSymbol",value:function(e,t){for(var r=e.placedSymbolArray.get(t),i=r.vertexStartIndex+4*r.numGlyphs,n=r.vertexStartIndex;n1||this.icon.segments.get().length>1)){for(var t of(this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[],this.symbolInstanceIndexes)){var r=this.symbolInstances.get(t);this.featureSortOrder.push(r.featureIndex);var i=r.rightJustifiedTextSymbolIndex,n=r.centerJustifiedTextSymbolIndex,a=r.leftJustifiedTextSymbolIndex,o=r.verticalPlacedTextSymbolIndex,s=r.placedIconSymbolIndex,l=r.verticalPlacedIconSymbolIndex;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),n>=0&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),a>=0&&a!==n&&a!==i&&this.addIndicesForPlacedSymbol(this.text,a),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),l>=0&&this.addIndicesForPlacedSymbol(this.icon,l)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}])})();ua(Fm,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Fm.addDynamicAttributes=Cm;var Bm=(function(){return m((function e(t){p(this,e),this.type=t.property.overrides?t.property.overrides.runtimeType:Gt,this.defaultValue=t}),[{key:"evaluate",value:function(e){if(e.formattedSection){var t=this.defaultValue.property.overrides;if(t&&t.hasOverride(e.formattedSection))return t.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}},{key:"eachChild",value:function(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression)}},{key:"outputDefined",value:function(){return!1}},{key:"serialize",value:function(){return null}}])})();ua(Bm,"FormatSectionOverride",{omit:["defaultValue"]});var Nm,Vm,Um,jm,Gm=function(){return Om||(Om={layout:Rm||(Rm=new qo({"symbol-placement":new Uo(Zo.layout_symbol["symbol-placement"]),"symbol-spacing":new Uo(Zo.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Uo(Zo.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new jo(Zo.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Uo(Zo.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new Uo(Zo.layout_symbol["symbol-z-elevate"]),"symbol-elevation-reference":new Uo(Zo.layout_symbol["symbol-elevation-reference"]),"icon-allow-overlap":new Uo(Zo.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Uo(Zo.layout_symbol["icon-ignore-placement"]),"icon-optional":new Uo(Zo.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Uo(Zo.layout_symbol["icon-rotation-alignment"]),"icon-size":new jo(Zo.layout_symbol["icon-size"]),"icon-size-scale-range":new Uo(Zo.layout_symbol["icon-size-scale-range"]),"icon-text-fit":new jo(Zo.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new jo(Zo.layout_symbol["icon-text-fit-padding"]),"icon-image":new jo(Zo.layout_symbol["icon-image"]),"icon-rotate":new jo(Zo.layout_symbol["icon-rotate"]),"icon-padding":new Uo(Zo.layout_symbol["icon-padding"]),"icon-keep-upright":new Uo(Zo.layout_symbol["icon-keep-upright"]),"icon-offset":new jo(Zo.layout_symbol["icon-offset"]),"icon-anchor":new jo(Zo.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Uo(Zo.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Uo(Zo.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Uo(Zo.layout_symbol["text-rotation-alignment"]),"text-field":new jo(Zo.layout_symbol["text-field"]),"text-font":new jo(Zo.layout_symbol["text-font"]),"text-size":new jo(Zo.layout_symbol["text-size"]),"text-size-scale-range":new Uo(Zo.layout_symbol["text-size-scale-range"]),"text-max-width":new jo(Zo.layout_symbol["text-max-width"]),"text-line-height":new jo(Zo.layout_symbol["text-line-height"]),"text-letter-spacing":new jo(Zo.layout_symbol["text-letter-spacing"]),"text-justify":new jo(Zo.layout_symbol["text-justify"]),"text-radial-offset":new jo(Zo.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Uo(Zo.layout_symbol["text-variable-anchor"]),"text-anchor":new jo(Zo.layout_symbol["text-anchor"]),"text-max-angle":new Uo(Zo.layout_symbol["text-max-angle"]),"text-writing-mode":new Uo(Zo.layout_symbol["text-writing-mode"]),"text-rotate":new jo(Zo.layout_symbol["text-rotate"]),"text-padding":new Uo(Zo.layout_symbol["text-padding"]),"text-keep-upright":new Uo(Zo.layout_symbol["text-keep-upright"]),"text-transform":new jo(Zo.layout_symbol["text-transform"]),"text-offset":new jo(Zo.layout_symbol["text-offset"]),"text-allow-overlap":new Uo(Zo.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Uo(Zo.layout_symbol["text-ignore-placement"]),"text-optional":new Uo(Zo.layout_symbol["text-optional"]),visibility:new Uo(Zo.layout_symbol.visibility)})),paint:Lm||(Lm=new qo({"icon-opacity":new jo(Zo.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new jo(Zo.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new jo(Zo.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new jo(Zo.paint_symbol["text-emissive-strength"]),"icon-color":new jo(Zo.paint_symbol["icon-color"]),"icon-halo-color":new jo(Zo.paint_symbol["icon-halo-color"]),"icon-halo-width":new jo(Zo.paint_symbol["icon-halo-width"]),"icon-halo-blur":new jo(Zo.paint_symbol["icon-halo-blur"]),"icon-translate":new Uo(Zo.paint_symbol["icon-translate"]),"icon-translate-anchor":new Uo(Zo.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new jo(Zo.paint_symbol["icon-image-cross-fade"]),"text-opacity":new jo(Zo.paint_symbol["text-opacity"]),"text-occlusion-opacity":new jo(Zo.paint_symbol["text-occlusion-opacity"]),"text-color":new jo(Zo.paint_symbol["text-color"],{runtimeType:Ht,getOverride:function(e){return e.textColor},hasOverride:function(e){return!!e.textColor}}),"text-halo-color":new jo(Zo.paint_symbol["text-halo-color"]),"text-halo-width":new jo(Zo.paint_symbol["text-halo-width"]),"text-halo-blur":new jo(Zo.paint_symbol["text-halo-blur"]),"text-translate":new Uo(Zo.paint_symbol["text-translate"]),"text-translate-anchor":new Uo(Zo.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new Uo(Zo.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new Uo(Zo.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new Uo(Zo.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new Uo(Zo.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new jo(Zo.paint_symbol["symbol-z-offset"])}))},Om)},qm=(function(e){function t(e,r,i,n){var a;return p(this,t),(a=T(this,t,[e,Gm(),r,i,n]))._colorAdjustmentMatrix=W.mat4.identity([]),a.hasInitialOcclusionOpacityProperties=void 0!==e.paint&&("icon-occlusion-opacity"in e.paint||"text-occlusion-opacity"in e.paint),a}return g(t,e),m(t,[{key:"recalculate",value:function(e,r){k(t,"recalculate",this,3)([e,r]),"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"));var i=this.layout.get("text-writing-mode");if(i){var n=[];for(var a of i)n.indexOf(a)<0&&n.push(a);this.layout._values["text-writing-mode"]=n}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}},{key:"getColorAdjustmentMatrix",value:function(e,t,r,i){return this._saturation===e&&this._contrast===t&&this._brightnessMin===r&&this._brightnessMax===i||(this._colorAdjustmentMatrix=(function(e,t,r,i){e=De(e),t=ze(t);var n=W.mat4.create(),a=e/3,o=1-2*a,s=[o,a,a,0,a,o,a,0,a,a,o,0,0,0,0,1],l=.5-.5*t,u=i-r;return W.mat4.multiply(n,[u,0,0,0,0,u,0,0,0,0,u,0,r,r,r,1],[t,0,0,0,0,t,0,0,0,0,t,0,l,l,l,1]),W.mat4.multiply(n,n,s),n})(e,t,r,i),this._saturation=e,this._contrast=t,this._brightnessMin=r,this._brightnessMax=i),this._colorAdjustmentMatrix}},{key:"getValueAndResolveTokens",value:function(e,t,r,i){var n=this.layout.get(e).evaluate(t,{},r,i),a=this._unevaluatedLayout._values[e];return a.isDataDriven()||Jn(a.value)||!n?n:(function(e,t){return t.replace(/{([^{}]+)}/g,(function(t,r){return r in e?String(e[r]):""}))})(t.properties,n)}},{key:"createBucket",value:function(e){return new Fm(e)}},{key:"queryRadius",value:function(){return 0}},{key:"queryIntersectsFeature",value:function(){return!1}},{key:"_setPaintOverrides",value:function(){for(var e of Gm().paint.overridableProperties)if(t.hasPaintOverride(this.layout,e)){var r,i=this.paint.get(e),n=new Bm(i),a=new Yn(n,i.property.specification,this.scope,this.options);r="constant"===i.value.kind||"source"===i.value.kind?new Qn("source",a):new ea("composite",a,i.value.zoomStops,i.value._interpolationType),this.paint._values[e]=new No(i.property,r,i.parameters)}}},{key:"_handleOverridablePaintPropertyUpdate",value:function(e,r,i){return!(!this.layout||r.isDataDriven()||i.isDataDriven())&&t.hasPaintOverride(this.layout,e)}},{key:"getProgramIds",value:function(){return["symbol"]}},{key:"getDefaultProgramParams",value:function(e,t,r){return{config:new Fl(this,{zoom:t,lut:r}),overrideFog:!1}}}],[{key:"hasPaintOverride",value:function(e,t){var r=e.get("text-field"),i=Gm().paint.properties[t],n=!1,a=function(e){for(var t of e)if(i.overrides&&i.overrides.hasOverride(t))return void(n=!0)};if("constant"===r.value.kind&&r.value.value instanceof sr)a(r.value.value.sections);else if("source"===r.value.kind){var o=function(e){n||(e instanceof dr&&hr(e.value)===Jt?a(e.value.sections):e instanceof _r?a(e.sections):e.eachChild(o))},s=r.value;s._styleExpression&&o(s._styleExpression.expression)}return n}}])})(hs),Zm=ms([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);function $m(e){switch(e){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.RGBA;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.DEPTH_COMPONENT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.DEPTH_STENCIL;case WebGL2RenderingContext.R8:case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.RED}}function Hm(e){switch(e){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.UNSIGNED_SHORT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.UNSIGNED_INT_24_8;case WebGL2RenderingContext.R8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.FLOAT}}var Wm=(function(){return m((function e(t,r,i,n){p(this,e),this.context=t,this.format=i,this.useMipmap=n&&n.useMipmap,this.texture=t.gl.createTexture(),this.update(r,{premultiply:n&&n.premultiply})}),[{key:"update",value:function(e,t){var r=e&&e instanceof HTMLVideoElement&&0===e.width?e.videoWidth:e.width,i=e&&e instanceof HTMLVideoElement&&0===e.height?e.videoHeight:e.height,n=this.context,a=n.gl,o=t&&t.position?t.position:{x:0,y:0},s=o.x,l=o.y,u=Math.max(s+r,this.size?this.size[0]:0),c=Math.max(l+i,this.size?this.size[1]:0);!this.size||this.size[0]===u&&this.size[1]===c||(a.bindTexture(a.TEXTURE_2D,null),a.deleteTexture(this.texture),this.texture=a.createTexture(),this.size=null),a.bindTexture(a.TEXTURE_2D,this.texture),n.pixelStoreUnpackFlipY.set(!1),n.pixelStoreUnpack.set(1),n.pixelStoreUnpackPremultiplyAlpha.set(this.format===a.RGBA8&&(!t||!1!==t.premultiply));var h=e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||ImageBitmap&&e instanceof ImageBitmap;if(!this.size&&u>0&&c>0){var f=this.useMipmap?Math.floor(Math.log2(Math.max(u,c)))+1:1;a.texStorage2D(a.TEXTURE_2D,f,this.format,u,c),this.size=[u,c]}if(this.size)if(h)a.texSubImage2D(a.TEXTURE_2D,0,s,l,$m(this.format),Hm(this.format),e);else{var d=e.data;d&&a.texSubImage2D(a.TEXTURE_2D,0,s,l,r,i,$m(this.format),Hm(this.format),d)}this.useMipmap&&a.generateMipmap(a.TEXTURE_2D)}},{key:"bind",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=this.context.gl;i.bindTexture(i.TEXTURE_2D,this.texture),e!==this.minFilter&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,e),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,this.useMipmap&&!r?e===i.NEAREST?i.NEAREST_MIPMAP_NEAREST:i.LINEAR_MIPMAP_LINEAR:e),this.minFilter=e),t!==this.wrapS&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,t),this.wrapS=t)}},{key:"bindExtraParam",value:function(e,t,r,i){var n=this.context.gl;n.bindTexture(n.TEXTURE_2D,this.texture),t!==this.magFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,t),this.magFilter=t),e!==this.minFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,this.useMipmap?e===n.NEAREST?n.NEAREST_MIPMAP_NEAREST:n.LINEAR_MIPMAP_LINEAR:e),this.minFilter=e),r!==this.wrapS&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,r),this.wrapS=r),i!==this.wrapT&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,i),this.wrapT=i)}},{key:"destroy",value:function(){this.context.gl.deleteTexture(this.texture),this.texture=null}}])})(),Xm=(function(){return m((function e(t,r){p(this,e),this.context=t,this.texture=r}),[{key:"bind",value:function(e,t){var r=this.context.gl;r.bindTexture(r.TEXTURE_2D,this.texture),e!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,e),this.minFilter=e),t!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,t),this.wrapS=t)}}])})();function Ym(e,t,r,i,n,a,o,s){var l=[e,t,1,r,i,1,n,a,1],u=[o,s,1],c=W.mat3.adjoint([],l),h=W.vec3.transformMat3(u,u,c),f=x(h,3),d=f[0],p=f[1],m=f[2];return W.mat3.multiply(l,l,[d,0,0,0,p,0,0,0,m])}function Jm(e,t,r,i,n,a,o,s){var l=(function(e,t,r,i,n,a,o,s){var l=Ym(0,0,1,0,1,1,0,1),u=Ym(e,t,r,i,n,a,o,s),c=W.mat3.adjoint([],l);return W.mat3.multiply(u,u,c)})(e,t,r,i,n,a,o,s);return[l[2]/l[8]/ri,l[5]/l[8]/ri]}function Km(e){return[e[0],Math.min(Math.max(e[1],-85.051129),lu)]}var Qm,ev,tv,rv,iv,nv=(function(e){function t(e,r,i,n){var a;return p(this,t),(a=T(this,t)).id=e,a.dispatcher=i,a.coordinates=r.coordinates,a.type="image",a.minzoom=0,a.maxzoom=22,a.tileSize=512,a.tiles={},a._loaded=!1,a.onNorthPole=!1,a.onSouthPole=!1,a.setEventedParent(n),a.options=r,a._dirty=!1,a}return g(t,e),m(t,[{key:"load",value:function(e,t){var r=this;if(this._loaded=t||!1,this.fire(new Mt("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return e&&(this.coordinates=e),this._loaded=!0,void this._finishLoading();this._imageRequest=bt(this.map._requestManager.transformRequest(this.url,ut.Image),(function(t,i){r._imageRequest=null,r._loaded=!0,t?r.fire(new At(t)):i&&(r.image=i instanceof HTMLImageElement?qe.getImageData(i):i,r._dirty=!0,r.width=r.image.width,r.height=r.image.height,e&&(r.coordinates=e),r._finishLoading())}))}},{key:"loaded",value:function(){return this._loaded}},{key:"updateImage",value:function(e){return e.url?(this._imageRequest&&e.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=e.url,this.load(e.coordinates,this._loaded),this):this}},{key:"setTexture",value:function(e){if(!(e.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new Xm(this.map.painter.context,e.handle),this.width=e.dimensions[0],this.height=e.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}},{key:"_finishLoading",value:function(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new Mt("data",{dataType:"source",sourceDataType:"metadata"})))}},{key:"onAdd",value:function(e){this.map=e,this.load()}},{key:"onRemove",value:function(e){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Xm||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy())}},{key:"setCoordinates",value:function(e){if(this.coordinates=e,this._boundsArray=void 0,this._unsupportedCoords=!1,!e.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;var t=e[0][1],r=e[0][1];for(var i of e)i[1]>r&&(r=i[1]),i[1]lu?this.onNorthPole=!0:n<-85.051129&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){var a=e.map(du.fromLngLat);this.tileID=(function(e){var t=1/0,r=1/0,i=-1/0,n=-1/0;for(var a of e)t=Math.min(t,a.x),r=Math.min(r,a.y),i=Math.max(i,a.x),n=Math.max(n,a.y);var o=Math.max(i-t,n-r),s=Math.max(0,Math.floor(-Math.log(o)/Math.LN2)),l=Math.pow(2,s),u=Math.floor((t+i)/2*l);return u>1&&(u-=1),new Xu(s,u,Math.floor((r+n)/2*l))})(a),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new Mt("data",{dataType:"source",sourceDataType:"content"})),this}},{key:"_clear",value:function(){this._boundsArray=void 0,this._unsupportedCoords=!1}},{key:"_prepareData",value:function(e){var t=this;for(var r in this.tiles){var i=this.tiles[r];"loaded"!==i.state&&(i.state="loaded",i.texture=this.texture)}if(!(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)){var n=rm(new Xu(0,0,0),this.map.transform.projection),a=[n.projection.project(this.coordinates[0][0],this.coordinates[0][1]),n.projection.project(this.coordinates[1][0],this.coordinates[1][1]),n.projection.project(this.coordinates[2][0],this.coordinates[2][1]),n.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!(function(e){var t=e[1].x-e[0].x,r=e[1].y-e[0].y,i=e[2].x-e[1].x,n=e[2].y-e[1].y,a=e[3].x-e[2].x,o=e[3].y-e[2].y,s=e[0].x-e[3].x,l=e[0].y-e[3].y,u=t*n-i*r,c=i*o-a*n,h=a*l-s*o,f=s*r-t*l;return u>0&&c>0&&h>0&&f>0||u<0&&c<0&&h<0&&f<0})(a))return console.warn("Image source coordinates are defining non-convex area in the Mercator projection"),void(this._unsupportedCoords=!0);var o=rm(this.tileID,this.map.transform.projection),s=this.coordinates.map((function(e){var t=o.projection.project(e[0],e[1]);return im(o,t)._round()})),l=x(s,4),u=l[0],c=l[1],h=l[2],f=l[3];this.perspectiveTransform=Jm(u.x,u.y,c.x,c.y,h.x,h.y,f.x,f.y);var d=this._boundsArray=new ys;d.emplaceBack(u.x,u.y,0,0),d.emplaceBack(c.x,c.y,ri,0),d.emplaceBack(f.x,f.y,0,ri),d.emplaceBack(h.x,h.y,ri,ri),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=e.createVertexBuffer(d,Zm.members),this.boundsSegments=hl.simpleSegment(0,0,4,2);var p,m,v,_=[],g=(function(e){for(var t=e[0][0],r=t,i=e[0][1],n=i,a=1;ar&&(r=e[a][0]),e[a][1]n&&(n=e[a][1]);return[t,i,r-t,n-i]})([Km((p=this.coordinates)[0]),Km(p[1]),Km(p[2]),Km(p[3])]),y=x(g,4),b=y[0],w=y[1],k=y[2],T=y[3],S=new ys,E=(function(e){for(var t=e[0].x,r=t,i=e[0].y,n=i,a=1;ar&&(r=e[a].x),e[a].yn&&(n=e[a].y);return[t,i,r-t,n-i]})(a),M=x(E,4),A=M[0],I=M[1],C=M[2],P=M[3],z=function(e){return[(e.x-A)/C,(e.y-I)/P]},D=a.map(z),R=x(D,4),L=R[0],O=R[1],F=R[2],B=R[3],N=(function(e,t,r,i,n,a,o,s){var l=Ym(0,0,1,0,1,1,0,1),u=Ym(e,t,r,i,n,a,o,s),c=W.mat3.adjoint([],u);return W.mat3.multiply(l,l,c)})(L[0],L[1],O[0],O[1],F[0],F[1],B[0],B[1]);this.elevatedGlobePerspectiveTransform=Jm(L[0],L[1],O[0],O[1],F[0],F[1],B[0],B[1]);for(var V=function(e,t){_.push(e.lng);var r=Math.round((e.lng-b)/k*ri),i=Math.round((e.lat-w)/T*ri),n=z(t),a=W.vec3.transformMat3([],[n[0],n[1],1],N),o=Math.round(a[0]/a[2]*ri),s=Math.round(a[1]/a[2]*ri);S.emplaceBack(r,i,o,s)},U=a[3].x-a[0].x,j=a[3].y-a[0].y,G=a[2].x-a[1].x,q=a[2].y-a[1].y,Z=0;Z<65;Z++)for(var $=Z/64,H=[a[0].x+$*U,a[0].y+$*j],X=[a[1].x+$*G,a[1].y+$*q],Y=X[0]-H[0],J=X[1]-H[1],K=0;K<65;K++){var Q=K/64,ee={x:H[0]+Y*Q,y:H[1]+J*Q,z:0};V(n.projection.unproject(ee.x,ee.y),ee)}this.elevatedGlobeVertexBuffer=e.createVertexBuffer(S,Zm.members),this.maxLongitudeTriangleSize=0;for(var te=[],re=new Ls,ie=function(e,r,i){re.emplaceBack(e,r,i);var n=_[e],a=_[r],o=_[i],s=Math.min(Math.min(n,a),o),l=Math.max(Math.max(n,a),o)-s;l>t.maxLongitudeTriangleSize&&(t.maxLongitudeTriangleSize=l),te.push(s+l/2)},ne=0;ne<64;ne++)for(var ae=0;ae<64;ae++){var oe=65*ne+ae,se=oe+1,le=oe+65,ue=le+1;ie(oe,le,se),ie(se,le,ue)}m=(function(e,t){var r=Array.from({length:e.length},(function(e,t){return t}));r.sort((function(t,r){return e[t]-e[r]}));for(var i=[],n=new Ls,a=0;a4&&void 0!==arguments[4]?arguments[4]:1/0,a=e.range;if(!a)return 0;var o=Math.min(n,Math.max(r,i)),s=Math.log(o/1024)/Math.LN2;return ue(a[0]+s,a[1]+s,t)}var dv=25e-6;function pv(e,t){var r=le(t.lat,-85.051129,lu),i=new Ql(t.lng-.0045000000000000005,r),n=new Ql(t.lng+.0045000000000000005,r),a=e.project(i.lng,r),o=e.project(n.lng,r),s=du.fromLngLat(i),l=du.fromLngLat(n),u=o.x-a.x,c=o.y-a.y,h=l.x-s.x,f=l.y-s.y,d=Math.sqrt((h*h+f*f)/(u*u+c*c));return Math.log(d)/Math.LN2}function mv(e,t,r){var i=Math.cos(r),n=Math.sin(r);return{x:e*i-t*n,y:e*n+t*i}}function vv(e,t,r){W.mat4.identity(e),W.mat4.rotateZ(e,e,re(t[2])),W.mat4.rotateX(e,e,re(t[0])),W.mat4.rotateY(e,e,re(t[1])),W.mat4.scale(e,e,r),W.mat4.multiply(e,e,[1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1])}function _v(e,t,r,i,n,a,o,s){var l=[r[0]-t[0],r[1]-t[1],0],u=[i[0]-t[0],i[1]-t[1],0];if(W.vec3.length(l)<1e-12||W.vec3.length(u)<1e-12)return W.quat.identity(e);var c=W.vec3.cross([],l,u);W.vec3.normalize(c,c),W.vec3.subtract(u,i,t),l[2]=(a-n)*s,u[2]=(o-n)*s;var h=l;return W.vec3.cross(h,l,u),W.vec3.normalize(h,h),W.quat.rotationTo(e,c,h)}function gv(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=Cc(t.zoom),n=(function(e,t,r){var i=t.worldSize,n=[e[12],e[13],e[14]],a=ou(n[1]/i),o=au(n[0]/i),s=W.mat4.identity([]),l=nu(1,a)*i,u=nu(1,0)*i*cu(a,t.zoom),c=1/Mc(i),h=u*c;if(r){var f=fv(t.projection,t.zoom,t.width,t.height,1024);h=c*t.projection.pixelSpaceConversion(t.center.lat,i,f)}var d=Yl(a,o);W.vec3.add(d,d,W.vec3.scale([],W.vec3.normalize([],d),l*h*n[2]));var p=(function(e){var t=[e[0],e[1],e[2]],r=[0,1,0],i=W.vec3.cross([],r,t);return W.vec3.cross(r,t,i),0===W.vec3.squaredLength(r)&&(r=[0,1,0],W.vec3.cross(i,t,r)),W.vec3.normalize(i,i),W.vec3.normalize(r,r),W.vec3.normalize(t,t),[i[0],i[1],i[2],0,r[0],r[1],r[2],0,t[0],t[1],t[2],0,e[0],e[1],e[2],1]})(d);W.mat4.scale(s,s,[h,h,h*l]),W.mat4.translate(s,s,[-n[0],-n[1],-n[2]]);var m=W.mat4.multiply([],t.globeMatrix,p);return W.mat4.multiply(m,m,s),W.mat4.multiply(m,m,e),m})(e,t,r);if(i>0){var a=(function(e,t){var r=t.worldSize,i=nu(1,0)*r*cu(t.center.lat,t.zoom)/Mc(r),n=nu(1,t.center.lat)*r,a=W.mat4.identity([]);return W.mat4.rotateY(a,a,re(t.center.lng)),W.mat4.rotateX(a,a,re(t.center.lat)),W.mat4.translate(a,a,[0,0,ql]),W.mat4.scale(a,a,[i,i,i*n]),W.mat4.translate(a,a,[t.point.x-.5*r,t.point.y-.5*r,0]),W.mat4.multiply(a,a,e),W.mat4.multiply(a,t.globeMatrix,a)})(e,t);return(function(e,t,r){var i=function(e,t,r){var i=W.vec3.length(e),n=W.vec3.length(t),a=_c(e,t,r);return W.vec3.scale(a,a,1/W.vec3.length(a)*Ft(i,n,r))},n=i([e[0],e[1],e[2]],[t[0],t[1],t[2]],r),a=i([e[4],e[5],e[6]],[t[4],t[5],t[6]],r),o=i([e[8],e[9],e[10]],[t[8],t[9],t[10]],r),s=_c([e[12],e[13],e[14]],[t[12],t[13],t[14]],r);return[n[0],n[1],n[2],0,a[0],a[1],a[2],0,o[0],o[1],o[2],0,s[0],s[1],s[2],1]})(n,a,i)}return n}function yv(e,t,r,i){for(var n=cc.projectAabbCorners(i,r),a=Number.MAX_VALUE,o=-1,s=0;sthis.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}),[{key:"updateFootprints",value:function(e,t){}},{key:"populate",value:function(e,t,r,i){this.tileToMeter=fu(r);var n=this.layers[0]._featureFilter.needGeometry;for(var a of(this.lookup=new Uint8Array(this.lookupDim*this.lookupDim),e)){var o=a.feature,s=a.id,l=a.index,u=a.sourceLayerIndex,c=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,h=wu(o,n);if(this.layers[0]._featureFilter.filter(new zo(this.zoom),h,r)){var f={id:c,sourceLayerIndex:u,index:l,geometry:n?h.geometry:bu(o,r,i),properties:o.properties,type:o.type,patterns:{}},d=this.addFeature(f,f.geometry,h);d&&t.featureIndex.insert(o,f.geometry,l,u,this.index,this.instancesPerModel[d].instancedDataArray.length,256)}}this.lookup=null}},{key:"update",value:function(e,t,r,i){for(var n in this.instancesPerModel){var a=this.instancesPerModel[n];for(var o in e)a.idToFeaturesIndex.hasOwnProperty(o)&&(this.evaluate(a.features[a.idToFeaturesIndex[o]],e[o],a,!0),this.uploaded=!1)}this.maxHeight=0}},{key:"updateZoomBasedPaintProperties",value:function(){if(!this.hasZoomDependentProperties)return!1;var e=!1;for(var t in this.instancesPerModel){var r=this.instancesPerModel[t];for(var i of r.features){var n=this.layers[0],a=i.feature,o=this.canonical,s=n.paint.get("model-rotation").evaluate(a,{},o),l=n.paint.get("model-scale").evaluate(a,{},o),u=n.paint.get("model-translation").evaluate(a,{},o);W.vec3.exactEquals(i.rotation,s)&&W.vec3.exactEquals(i.scale,l)&&W.vec3.exactEquals(i.translation,u)||(this.evaluate(i,i.featureStates,r,!0),e=!0)}}return e}},{key:"updateReplacement",value:function(e,t,r,i){if(t.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=t.updateTime;var n=t.getReplacementRegionsForTile(e.toUnwrapped(),!0);if(mf(this.activeReplacements,n))return!1;this.activeReplacements=n;var a=!1;for(var o in this.instancesPerModel){var s=this.instancesPerModel[o],l=s.instancedDataArray;for(var u of s.features)for(var c=u.instancedDataOffset,h=u.instancedDataCount,f=0;fri;p=m?p-ri:p;var v=Math.floor(p),_=l.float32[d+1],g=!1;for(var y of this.activeReplacements)if(!hf(y,r,Mv.Model,i)&&!(y.min.x>v||v>y.max.x||y.min.y>_||_>y.max.y)&&(g=bf(xf(v,_,e.canonical,y.footprintTileId.canonical),y.footprint)))break;l.float32[d]=g?p+ri:p,a=a||g!==m}}return a}},{key:"isEmpty",value:function(){for(var e in this.instancesPerModel)if(0!==this.instancesPerModel[e].instancedDataArray.length)return!1;return!0}},{key:"uploadPending",value:function(){return!this.uploaded}},{key:"upload",value:function(e){if(!this.uploaded)for(var t in this.instancesPerModel){var r=this.instancesPerModel[t];r.instancedDataArray.length<0||0===r.instancedDataArray.length||(r.instancedDataBuffer?r.instancedDataBuffer.updateData(r.instancedDataArray):r.instancedDataBuffer=e.createVertexBuffer(r.instancedDataArray,Sv.members,!0,void 0,this.instanceCount))}this.uploaded=!0}},{key:"destroy",value:function(){for(var e in this.instancesPerModel){var t=this.instancesPerModel[e];0!==t.instancedDataArray.length&&t.instancedDataBuffer&&t.instancedDataBuffer.destroy()}var r=this.layers[0].modelManager;if(r&&this.modelUris)for(var i of this.modelUris)r.removeModel(i,"")}},{key:"addFeature",value:function(e,t,r){var i=this.layers[0],n=i.layout.get("model-id").evaluate(r,{},this.canonical);if(!n)return we(`modelId is not evaluated for layer ${i.id} and it is not going to get rendered.`),n;Iv(n,!1)&&(this.modelUris.includes(n)||this.modelUris.push(n)),this.instancesPerModel[n]||(this.instancesPerModel[n]=new Dv);var a=this.instancesPerModel[n],o=a.instancedDataArray,s=new zv(r,o.length);for(var l of t)for(var u of l)if(!(u.x<0||u.x>=ri||u.y<0||u.y>=ri)){var c=(this.lookupDim-1)/ri,h=this.lookupDim*(u.y*c|0)+u.x*c|0;if(this.lookup){if(0!==this.lookup[h])continue;this.lookup[h]=1}this.instanceCount++;var f=o.length;o.resize(f+1),a.instancesEvaluatedElevation.push(0),o.float32[16*f]=u.x,o.float32[16*f+1]=u.y}return s.instancedDataCount=a.instancedDataArray.length-s.instancedDataOffset,s.instancedDataCount>0&&(e.id&&(a.idToFeaturesIndex[e.id]=a.features.length),a.features.push(s),this.evaluate(s,{},a,!1)),n}},{key:"getModelUris",value:function(){return this.modelUris}},{key:"evaluate",value:function(e,t,r,i){var n=this.layers[0],a=e.feature,o=this.canonical,s=e.rotation=n.paint.get("model-rotation").evaluate(a,t,o),l=e.scale=n.paint.get("model-scale").evaluate(a,t,o),u=e.translation=n.paint.get("model-translation").evaluate(a,t,o),c=n.paint.get("model-color").evaluate(a,t,o);c.a=n.paint.get("model-color-mix-intensity").evaluate(a,t,o);var h=[];this.maxVerticalOffset10?this.tileToMeter:fu(o,g)),v[m+4]=u[0],v[m+5]=u[1],v[m+6]=u[2]+_,v[m+7]=h[0],v[m+8]=h[1],v[m+9]=h[2],v[m+10]=h[4],v[m+11]=h[5],v[m+12]=h[6],v[m+13]=h[8],v[m+14]=h[9],v[m+15]=h[10],r.instancesEvaluatedElevation[p]=u[2]}}}])})();ua(Rv,"ModelBucket",{omit:["layers"]}),ua(Dv,"PerModelAttributes"),ua(zv,"ModelFeature");var Lv=64,Ov={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function Fv(e,t,r,i,n,a,o,s,l){var u=arguments.length>9&&void 0!==arguments[9]&&arguments[9],c=r.zoom,h=r.project(i),f=cu(i.lat,c),p=1/f;W.mat4.identity(e),W.mat4.translate(e,e,[h.x+o[0]*p,h.y+o[1]*p,o[2]]);var m=1,v=1,_=r.worldSize;if(u){if("mercator"===r.projection.name){var g=0;r.elevation&&(g=r.elevation.getAtPointOrZero(new du(h.x/_,h.y/_),0));var y=W.vec4.transformMat4([],[h.x,h.y,g,1],r.projMatrix)[3]/r.cameraToCenterDistance;m=y,v=y*cu(r.center.lat,c)}else if("globe"===r.projection.name){var x=gv(e,r),b=W.mat4.multiply([],r.projMatrix,x),w=[0,0,0,1];W.vec4.transformMat4(w,w,b);var k=w[3]/r.cameraToCenterDistance,T=Cc(c),S=r.projection.pixelsPerMeter(i.lat,_)*cu(i.lat,c),E=r.projection.pixelsPerMeter(r.center.lat,_)*cu(r.center.lat,c);m=k/Ft(S,uu(r.center.lat),T),v=k*f/S,m*=E,v*=E}}else m=p;W.mat4.scale(e,e,[m,m,v]);var M=d(e),A=t.orientation,I=[];if(vv(I,[A[0]+n[0],A[1]+n[1],A[2]+n[2]],a),W.mat4.multiply(e,M,I),s&&r.elevation){var C=0,P=[];if(l&&r.elevation){C=(function(e,t,r,i,n){var a=t.elevation;if(!a)return 0;var o=cc.projectAabbCorners(r,i),s=nu(1,n.lat)*t.worldSize,l=(function(e,t){var r=[0,0,1],i=[{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(var n of i){var a=e[n.corners[0]],o=e[n.corners[1]],s=e[n.corners[2]],l=[o[0]-a[0],o[1]-a[1],t*(o[2]-a[2])],u=W.vec3.cross(l,l,[s[0]-a[0],s[1]-a[1],t*(s[2]-a[2])]);W.vec3.normalize(u,u),n.dotProductWithUp=W.vec3.dot(u,r)}return i.sort((function(e,t){return e.dotProductWithUp-t.dotProductWithUp})),i[0].corners})(o,s),u=o[l[0]],c=o[l[1]],h=o[l[2]],f=o[l[3]],d=a.getAtPointOrZero(new du(u[0]/t.worldSize,u[1]/t.worldSize),0),p=a.getAtPointOrZero(new du(c[0]/t.worldSize,c[1]/t.worldSize),0),m=a.getAtPointOrZero(new du(h[0]/t.worldSize,h[1]/t.worldSize),0),v=a.getAtPointOrZero(new du(f[0]/t.worldSize,f[1]/t.worldSize),0),_=(d+v)/2,g=(p+m)/2;return _>g?p2&&void 0!==arguments[2]&&arguments[2];e.uploaded||(e.gfxTexture=new Wm(t,e.image,r?t.gl.R8:t.gl.RGBA8,{useMipmap:e.sampler.minFilter>=t.gl.NEAREST_MIPMAP_NEAREST}),e.uploaded=!0,e.image=null)}function Nv(e,t,r){e.indexBuffer=t.createIndexBuffer(e.indexArray,!1,!0),e.vertexBuffer=t.createVertexBuffer(e.vertexArray,xv.members,!1,!0),e.normalArray&&(e.normalBuffer=t.createVertexBuffer(e.normalArray,Tv.members,!1,!0)),e.texcoordArray&&(e.texcoordBuffer=t.createVertexBuffer(e.texcoordArray,kv.members,!1,!0)),e.colorArray&&(e.colorBuffer=t.createVertexBuffer(e.colorArray,(12===e.colorArray.bytesPerElement?bv:wv).members,!1,!0)),e.featureArray&&(e.pbrBuffer=t.createVertexBuffer(e.featureArray,Ev.members,!0)),e.segments=hl.simpleSegment(0,0,e.vertexArray.length,e.indexArray.length);var i=e.material;i.pbrMetallicRoughness.baseColorTexture&&Bv(i.pbrMetallicRoughness.baseColorTexture,t),i.pbrMetallicRoughness.metallicRoughnessTexture&&Bv(i.pbrMetallicRoughness.metallicRoughnessTexture,t),i.normalTexture&&Bv(i.normalTexture,t),i.occlusionTexture&&Bv(i.occlusionTexture,t,r),i.emissionTexture&&Bv(i.emissionTexture,t)}function Vv(e,t,r){if(e.meshes)for(var i of e.meshes)Nv(i,t,r);if(e.children)for(var n of e.children)Vv(n,t,r)}function Uv(e){if(e.meshes)for(var t of e.meshes)t.indexArray.destroy(),t.vertexArray.destroy(),t.colorArray&&t.colorArray.destroy(),t.normalArray&&t.normalArray.destroy(),t.texcoordArray&&t.texcoordArray.destroy(),t.featureArray&&t.featureArray.destroy();if(e.children)for(var r of e.children)Uv(r)}function jv(e){if(e.meshes)for(var t of e.meshes)t.vertexBuffer&&(t.vertexBuffer.destroy(),t.indexBuffer.destroy(),t.normalBuffer&&t.normalBuffer.destroy(),t.texcoordBuffer&&t.texcoordBuffer.destroy(),t.colorBuffer&&t.colorBuffer.destroy(),t.pbrBuffer&&t.pbrBuffer.destroy(),t.segments.destroy(),t.material&&((r=t.material).pbrMetallicRoughness.baseColorTexture&&r.pbrMetallicRoughness.baseColorTexture.gfxTexture&&r.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),r.pbrMetallicRoughness.metallicRoughnessTexture&&r.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&r.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),r.normalTexture&&r.normalTexture.gfxTexture&&r.normalTexture.gfxTexture.destroy(),r.emissionTexture&&r.emissionTexture.gfxTexture&&r.emissionTexture.gfxTexture.destroy(),r.occlusionTexture&&r.occlusionTexture.gfxTexture&&r.occlusionTexture.gfxTexture.destroy()));var r;if(e.children)for(var i of e.children)jv(i)}var Gv=(function(){function e(t,r,i){p(this,e),this._demTile=t,this._dem=this._demTile.dem,this._scale=r,this._offset=i}return m(e,[{key:"tileCoordToPixel",value:function(e,t){var r=t*this._scale+this._offset[1],i=Math.floor(e*this._scale+this._offset[0]),n=Math.floor(r);return new K(i,n)}},{key:"getElevationAt",value:function(e,t,r,i){var n=e*this._scale+this._offset[0],a=t*this._scale+this._offset[1],o=Math.floor(n),s=Math.floor(a),l=this._dem;return i=!!i,r?Ft(Ft(l.get(o,s,i),l.get(o,s+1,i),a-s),Ft(l.get(o+1,s,i),l.get(o+1,s+1,i),a-s),n-o):l.get(o,s,i)}},{key:"getElevationAtPixel",value:function(e,t,r){return this._dem.get(e,t,!!r)}},{key:"getMeterToDEM",value:function(e){return(1<=P)){var j=qv[U],G=Math.abs(j);G>O&&(L=j,O=G,F=V,B=N)}}if(O>.1){var q=1-(P+.5*Math.abs(F*B))/d,Z=t._dem.get(D,z)+L*q,$=t._dem.get(D+F,z+B),H=t._dem.get(D-F,z-B,!0);(Z-$)*(Z-H)>0&&(Z=($+H)/2),qv[R]=t._dem.set(D,z,Z),Zv[R]=P}}}}}}}o&&(t._demTile.needsDEMTextureUpload=!0,t._dem._timestamp=qe.now())}}},{key:"getNodesInfo",value:function(){return this.nodesInfo}},{key:"destroy",value:function(){var e=this.getNodesInfo();for(var t of e)Uv(t.node),jv(t.node)}},{key:"isEmpty",value:function(){return!this.nodesInfo.length}},{key:"updateReplacement",value:function(e,t){if(t.updateTime!==this.replacementUpdateTime){this.replacementUpdateTime=t.updateTime;for(var r=t.getReplacementRegionsForTile(e.toUnwrapped()),i=this.getNodesInfo(),n=function(){var e=i[a].node;i[a].hiddenByReplacement=!!e.footprint&&!r.find((function(t){return t.footprint===e.footprint}))},a=0;au.max[0]||t>u.max[1])){if(!0===s.node.hidden)return{height:1/0,maxHeight:s.feature.properties.height,hidden:!1,verticalScale:s.evaluatedScale[2]};W.mat4.invert(a,s.node.matrix),n[0]=e,n[1]=t,W.vec3.transformMat4(n,n,a);var c=(n[0]-l.aabb.min[0])/(l.aabb.max[0]-l.aabb.min[0])*Lv|0,h=Math.min(63,(n[1]-l.aabb.min[1])/(l.aabb.max[1]-l.aabb.min[1])*Lv|0)*Lv+Math.min(63,c),f=l.heightmap[h];if(!(f<0&&s.node.footprint)){if(s.hiddenByReplacement)return;return{height:f,maxHeight:s.feature.properties.height,hidden:!1,verticalScale:s.evaluatedScale[2]}}if(s.node.footprint.grid.query(new K(e,t),new K(e,t),i),i.length>0)return{height:void 0,maxHeight:s.feature.properties.height,hidden:s.hiddenByReplacement,verticalScale:s.evaluatedScale[2]}}}}}])})();function Jv(e,t){return!e.isLightConstant&&t}function Kv(e,t,r,i,n,a,o,s){var l=(61440&t|(61440&t)>>4)>>8,u=(3840&t|(3840&t)>>4)>>4,c=240&t|(240&t)>>4;r[3]>0&&(l=Ft(l,255*r[0],r[3]),u=Ft(u,255*r[1],r[3]),c=Ft(c,255*r[2],r[3]));var h,f,d,p,m=l<<8|u,v=c<<8|Math.floor(255*i[3]),_=(function(e){var t=le(e,0,2);return Math.min(Math.round(.5*t*255),255)})(i[2])<<8|15*i[0]<<4|15*i[1],g=le(n[0],0,1),y=le(n[1],0,1),x=le(n[2],0,1),b=le(n[3],0,1);if(g!==y&&o!==a&&y!==g){var w=o-a;f=1/(w*(y-g)),d=-(a+w*g)/(w*(y-g));var k=le(n[4],-1,1);p=Math.pow(10,k),h=255*x<<8|255*b}else h=65535,f=0,d=1,p=1;if(e.emplaceBack(m,v,_,h,f,d,p),s){var T=s.length;s.clear();for(var S=0;S>16&65535,c=a?l>>16&65535:65535&l,h=(15&c)<8?15&c:0,f=e.evaluatedRMEA[h],d=e.evaluatedColor[h],p=e.emissionHeightBasedParams[h],m=void 0;if(s&&2===h&&i.lights&&(m=new Hs).resize(10*i.lights.length),Kv(o.featureArray,u,d,f,p,o.aabb.min[2],o.aabb.max[2],m),m&&s){s=!1;var v=i.meshes[i.lightMeshIndex];v.featureArray=m,v.featureArray._trim()}}o.featureArray._trim(),n++}}ua(Yv,"Tiled3dModelBucket",{omit:["layers"]}),ua(Xv,"Tiled3dModelFeature");var e_=["id","tile","layer","source","sourceLayer","state"],t_=(function(){function e(t,r,i,n,a){p(this,e),this.type="Feature",this._vectorTileFeature=t,this._z=r,this._x=i,this._y=n,this.properties=t.properties,this.id=a}return m(e,[{key:"clone",value:function(){var t=new e(this._vectorTileFeature,this._z,this._x,this._y,this.id);return this.state&&(t.state=Object.assign({},this.state)),this.layer&&(t.layer=Object.assign({},this.layer)),this.namespace&&(t.namespace=this.namespace),t}},{key:"geometry",get:function(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry},set:function(e){this._geometry=e}},{key:"toJSON",value:function(){var e={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};for(var t of e_)void 0!==this[t]&&(e[t]=this[t]);return e}}])})();function r_(e,t,r,i){var n=1<0&&(r+=_),i+=_,t)){var y=[],x=[];for(var b of g){var w=b.x+n.x,k=b.y+n.y,T=e.projection.projectTilePoint(w,k,c),S=e.projection.upVector(c,b.x,b.y),E=r,M=i;if(o){var A=id(w,k,r,i,o,s,l,u);E+=A.base,M+=A.top}0!==r?v(p,T.x+S[0]*d*E,T.y+S[1]*d*E,T.z+S[2]*d*E):v(p,T.x,T.y,T.z),v(m,T.x+S[0]*d*M,T.y+S[1]*d*M,T.z+S[2]*d*M),W.vec3.transformMat4(p,p,a),W.vec3.transformMat4(m,m,a),y.push(new af(p[0],p[1],p[2])),x.push(new af(m[0],m[1],m[2]))}h.push(y),f.push(x)}return[h,f]})(e,t,r,i,n,a,o,s,l,u,c):o?(function(e,t,r,i,n,a,o,s,l){var u=[],c=[],h=[0,0,0,1];for(var f of e){var d=[],p=[];for(var m of f){var v=m.x+i.x,_=m.y+i.y,g=id(v,_,t,r,a,o,s,l);h[0]=v,h[1]=_,h[2]=g.base,h[3]=1,W.vec4.transformMat4(h,h,n),h[3]=Math.max(h[3],1e-5);var y=new af(h[0]/h[3],h[1]/h[3],h[2]/h[3]);h[0]=v,h[1]=_,h[2]=g.top,h[3]=1,W.vec4.transformMat4(h,h,n),h[3]=Math.max(h[3],1e-5);var x=new af(h[0]/h[3],h[1]/h[3],h[2]/h[3]);d.push(y),p.push(x)}u.push(d),c.push(p)}return[u,c]})(t,r,i,n,a,o,s,l,u):(function(e,t,r,i,n){var a=[],o=[],s=n[8]*t,l=n[9]*t,u=n[10]*t,c=n[11]*t,h=n[8]*r,f=n[9]*r,d=n[10]*r,p=n[11]*r;for(var m of e){var v=[],_=[];for(var g of m){var y=g.x+i.x,x=g.y+i.y,b=n[0]*y+n[4]*x+n[12],w=n[1]*y+n[5]*x+n[13],k=n[2]*y+n[6]*x+n[14],T=n[3]*y+n[7]*x+n[15],S=b+s,E=w+l,M=k+u,A=Math.max(T+c,1e-5),I=b+h,C=w+f,P=k+d,z=Math.max(T+p,1e-5);v.push(new af(S/A,E/A,M/A)),_.push(new af(I/z,C/z,P/z))}a.push(v),o.push(_)}return[a,o]})(t,r,i,n,a)})(a,i,h,c,u,o,d?s:null,f,p,a.center.lat,e.tileID.canonical),y=x(g,2),b=y[0],w=y[1],k=e.queryGeometry;return(function(e,t,r){var i=1/0;Cu(r,t)&&(i=rd(r,t[0]));for(var n=0;n=3)for(var a=0;a4&&void 0!==arguments[4]&&arguments[4],o=arguments.length>5?arguments[5]:void 0,s=Math.round(1e18*Math.random()).toString(36).substring(0,10);r&&(r.metadata=o,this.callbacks[s]=r);var l=new Set;return this.target.postMessage({id:s,type:e,hasCallback:!!r,targetMapId:i,mustQueue:a,sourceMapId:this.mapId,data:da(t,l)},l),{cancel:function(){r&&delete n.callbacks[s],n.target.postMessage({id:s,type:"",targetMapId:i,sourceMapId:n.mapId})}}}},{key:"receive",value:function(e){var t=this,r=e.data,i=r.id;if(i&&(!r.targetMapId||this.mapId===r.targetMapId))if(""===r.type){var n=this.cancelCallbacks[i];delete this.cancelCallbacks[i],n&&n.cancel()}else if(r.mustQueue||Ee()){var a=this.callbacks[i],o=this.scheduler.add((function(){return t.processTask(i,r)}),a&&a.metadata||{type:"message"});o&&(this.cancelCallbacks[i]=o)}else this.processTask(i,r)}},{key:"processTask",value:function(e,t){var r=this;if(delete this.cancelCallbacks[e],""===t.type){var i=this.callbacks[e];delete this.callbacks[e],i&&(t.error?i(pa(t.error)):i(null,pa(t.data)))}else{var n=new Set,a=t.hasCallback?function(t,i){r.target.postMessage({id:e,type:"",sourceMapId:r.mapId,error:t?da(t):null,data:da(i,n)},n)}:function(){},o=pa(t.data);if(this.parent[t.type])this.parent[t.type](t.sourceMapId,o,a);else if(this.parent.getWorkerSource){var s=t.type.split(".");this.parent.getWorkerSource(t.sourceMapId,s[0],o.source,o.scope)[s[1]](o,a)}else a(new Error(`Could not find function ${t.type}`))}}},{key:"remove",value:function(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}])})(),s_=(function(){return m((function e(t,r){var i=this;p(this,e),this.workerPool=t,this.actors=[],this.currentActor=0,this.id=pe();for(var n=this.workerPool.acquire(this.id),a=0;at[o])return null}else{var s=1/i[o],l=(e[o]-r[o])*s,u=(t[o]-r[o])*s;if(l>u){var c=l;l=u,u=c}if(l>n&&(n=l),ua)return null}return n}function c_(e,t,r,i,n,a,o,s,l,u,c){var h=i-e,f=n-t,d=a-r,p=o-e,m=s-t,v=l-r,_=c[1]*v-c[2]*m,g=c[2]*p-c[0]*v,y=c[0]*m-c[1]*p,x=h*_+f*g+d*y;if(Math.abs(x)<1e-15)return null;var b=1/x,w=u[0]-e,k=u[1]-t,T=u[2]-r,S=(w*_+k*g+T*y)*b;if(S<0||S>1)return null;var E=k*d-T*f,M=T*h-w*d,A=w*f-k*h,I=(c[0]*E+c[1]*M+c[2]*A)*b;return I<0||S+I>1?null:(p*E+m*M+v*A)*b}function h_(e,t,r){return(e-t)/(r-t)}function f_(e,t,r,i,n,a,o,s,l){var u=1<=1;i/=2){var d=r[r.length-1];o=new l_(i);for(var p=0;p6&&void 0!==arguments[6]?arguments[6]:1;return u_([e,t,-100],[r,i,this.maximums[0]*o],n,a)}},{key:"raycast",value:function(e,t,r,i,n,a){var o=arguments.length>6&&void 0!==arguments[6]?arguments[6]:1;if(!this.nodeCount)return null;var s=this.raycastRoot(e,t,r,i,n,a,o);if(null==s)return null;for(var l=[],u=[],c=[],h=[],f=[{idx:0,t:s,nodex:0,nodey:0,depth:0}];f.length>0;){var d=f.pop(),p=d.idx,m=d.t,v=d.nodex,_=d.nodey,g=d.depth;if(this.leaves[p]){f_(v,_,g,e,t,r,i,c,h);var y=1<=P[2])return m}else{for(var z=0,D=0;D=l[u[F]]&&(u.splice(F,0,D),O=!0);O||(u[z]=D),z++}}for(var B=0;B3&&void 0!==arguments[3]&&arguments[3];if(p(this,e),this.uid=t,r.height!==r.width)throw new RangeError("DEM tiles must be square");if(i&&"mapbox"!==i&&"terrarium"!==i)we(`"${i}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);else{this.stride=r.height;var a=this.dim=r.height-2,o=new Uint32Array(r.data.buffer);if(this.pixels=new Uint8Array(r.data.buffer),this.floatView=new Float32Array(r.data.buffer),this.borderReady=n,this._modifiedForSources={},!n){for(var s=0;s2&&void 0!==arguments[2]&&arguments[2]&&(e=le(e,-1,this.dim),t=le(t,-1,this.dim));var r=this._idx(e,t);return this.floatView[r]}},{key:"set",value:function(e,t,r){var i=this._idx(e,t),n=this.floatView[i];return this.floatView[i]=r,r-n}},{key:"_idx",value:function(e,t){if(e<-1||e>=this.dim+1||t<-1||t>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(t+1)*this.stride+(e+1)}},{key:"getPixels",value:function(){return new Qc({width:this.stride,height:this.stride},this.pixels)}},{key:"backfillBorder",value:function(e,t,r){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");var i=t*this.dim,n=t*this.dim+this.dim,a=r*this.dim,o=r*this.dim+this.dim;switch(t){case-1:i=n-1;break;case 1:n=i+1}switch(r){case-1:a=o-1;break;case 1:o=a+1}for(var s=-t*this.dim,l=-r*this.dim,u=a;u=1;i--){for(var n=1===i?1:0,a=2===i?1:0,o=0;o>>1^-(1&e[t]);return e}function P_(e,t){switch(t){case"uint32":return e;case"uint16":for(var r=0;r>4|(61440&i)>>8|(240&n)<<4|61440&n,e[r+1]=15&i|(3840&i)>>4|(15&n)<<8|(3840&n)<<4}return e;case"uint8":for(var a=0;a>6|(192&s)>>4|(192&l)>>2|192&u,e[a+1]=(48&o)>>4|(48&s)>>2|48&l|(48&u)<<2,e[a+2]=(12&o)>>2|12&s|(12&l)<<2|(12&u)<<4,e[a+3]=3&o|(3&s)<<2|(3&l)<<4|(3&u)<<6}return e;default:throw new Error(`Invalid pixel format, "${t}"`)}}var z_=Uint8Array,D_=Uint16Array,R_=Int32Array,L_=new z_([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]),O_=new z_([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]),F_=new z_([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),B_=function(e,t){for(var r=new D_(31),i=0;i<31;++i)r[i]=t+=1<>1|(21845&q_)<<1;G_[q_]=((65280&(Z_=(61680&(Z_=(52428&Z_)>>2|(13107&Z_)<<2))>>4|(3855&Z_)<<4))>>8|(255&Z_)<<8)>>1}var $_=function(e,t,r){for(var i=e.length,n=0,a=new D_(t);n>l]=u;return o},H_=new z_(288);for(q_=0;q_<144;++q_)H_[q_]=8;for(q_=144;q_<256;++q_)H_[q_]=9;for(q_=256;q_<280;++q_)H_[q_]=7;for(q_=280;q_<288;++q_)H_[q_]=8;var W_=new z_(32);for(q_=0;q_<32;++q_)W_[q_]=5;var X_=$_(H_,9),Y_=$_(W_,5),J_=function(e){for(var t=e[0],r=1;rt&&(t=e[r]);return t},K_=function(e,t,r){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(7&t)&r},Q_=function(e,t){var r=t/8|0;return(e[r]|e[r+1]<<8|e[r+2]<<16)>>(7&t)},eg=["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"],tg=function(e,t,r){var i=new Error(t||eg[e]);if(i.code=e,Error.captureStackTrace&&Error.captureStackTrace(i,tg),!r)throw i;return i},rg=new z_(0),ig="undefined"!=typeof TextDecoder&&new TextDecoder;try{ig.decode(rg,{stream:!0})}catch(e){}var ng,ag={gzip_data:"gzip"},og=(function(e){function t(e){var r;return p(this,t),(r=T(this,t,[e])).name="MRTError",r}return g(t,e),m(t)})(y(Error)),sg={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},lg={uint32:1,uint16:2,uint8:4},ug={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array},cg=(function(){return m((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5;p(this,e),this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=t}),[{key:"getLayer",value:function(e){var t=this.layers[e];if(!t)throw new og(`Layer '${e}' not found`);return t}},{key:"getHeaderLength",value:function(e){var t=new Uint8Array(e),r=new DataView(e);if(13!==t[0])throw new og("File is not a valid MRT.");return r.getUint32(1,!0)}},{key:"parseHeader",value:function(e){var t=new Uint8Array(e),r=this.getHeaderLength(e);if(t.length= ${r} but got buffer of length ${t.length}`);var i=(function(e){return e.readFields(x_,{headerLength:0,x:0,y:0,z:0,layers:[]},void 0)})(new ng(t.subarray(0,r)));if(!isNaN(this.x)&&(this.x!==i.x||this.y!==i.y||this.z!==i.z))throw new og(`Invalid attempt to parse header ${i.z}/${i.x}/${i.y} for tile ${this.z}/${this.x}/${this.y}`);for(var n of(this.x=i.x,this.y=i.y,this.z=i.z,i.layers))this.layers[n.name]=new hg(n,{cacheSize:this._cacheSize});return this}},{key:"createDecodingTask",value:function(e){var t=this,r=[],i=this.getLayer(e.layerName);for(var n of e.blockIndices){var a=i.dataIndex[n],o=a.firstByte-e.firstByte,s=a.lastByte-e.firstByte;if(!i._blocksInProgress.has(n)){var l={layerName:i.name,firstByte:o,lastByte:s,pixelFormat:i.pixelFormat,blockIndex:n,blockShape:[a.bands.length].concat(i.bandShape),buffer:i.buffer,codec:a.codec.codec,filters:a.filters.map((function(e){return e.filter}))};i._blocksInProgress.add(n),r.push(l)}}return new fg(r,(function(){r.forEach((function(e){return i._blocksInProgress.delete(e.blockIndex)}))}),(function(e,n){if(r.forEach((function(e){return i._blocksInProgress.delete(e.blockIndex)})),e)throw e;n.forEach((function(e){t.getLayer(e.layerName).processDecodedData(e)}))}))}}])})(),hg=(function(){return m((function e(t,r){var i=t.version,n=t.name,a=t.units,o=t.tileSize,s=t.pixelFormat,l=t.buffer,u=t.dataIndex;if(p(this,e),this.version=i,1!==this.version)throw new og(`Cannot parse raster layer encoded with MRT version ${i}`);this.name=n,this.units=a,this.tileSize=o,this.buffer=l,this.pixelFormat=sg[s],this.dataIndex=u,this.bandShape=[o+2*l,o+2*l,lg[this.pixelFormat]],this._decodedBlocks=new A_(r?r.cacheSize:5),this._blocksInProgress=new Set}),[{key:"dimension",get:function(){return lg[this.pixelFormat]}},{key:"cacheSize",get:function(){return this._decodedBlocks.capacity}},{key:"getBandList",value:function(){return this.dataIndex.map((function(e){return e.bands})).flat()}},{key:"processDecodedData",value:function(e){var t=e.blockIndex.toString();this._decodedBlocks.get(t)||this._decodedBlocks.put(t,e.data)}},{key:"getBlockForBand",value:function(e){var t=0;switch(typeof e){case"string":for(var r of this.dataIndex.entries()){var i=x(r,2),n=i[0],a=i[1];for(var o of a.bands.entries()){var s=x(o,2),l=s[0];if(s[1]===e)return{bandIndex:t+l,blockIndex:n,blockBandIndex:l}}t+=a.bands.length}break;case"number":for(var u of this.dataIndex.entries()){var c=x(u,2),h=c[0],f=c[1];if(e>=t&&ethis.cacheSize)throw new og(`Number of blocks to decode (${n.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:t,lastByte:r,blockIndices:i}}},{key:"hasBand",value:function(e){return this.getBlockForBand(e).blockIndex>=0}},{key:"hasDataForBand",value:function(e){var t=this.getBlockForBand(e).blockIndex;return t>=0&&!!this._decodedBlocks.get(t.toString())}},{key:"getBandView",value:function(e){var t=this.getBlockForBand(e),r=t.blockIndex,i=t.blockBandIndex,n=this._decodedBlocks.get(r.toString());if(!n)throw new og(`Data for band ${JSON.stringify(e)} of layer "${this.name}" not decoded.`);var a=this.dataIndex[r],o=this.bandShape.reduce((function(e,t){return e*t}),1),s=i*o,l=n.subarray(s,s+o);return{data:l,bytes:new Uint8Array(l.buffer).subarray(l.byteOffset,l.byteOffset+l.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:a.offset,scale:a.scale}}}])})();cg.setPbf=function(e){ng=e};var fg=(function(){return m((function e(t,r,i){p(this,e),this.tasks=t,this._onCancel=r,this._onComplete=i,this._finalized=!1}),[{key:"cancel",value:function(){this._finalized||(this._onCancel(),this._finalized=!0)}},{key:"complete",value:function(e,t){this._finalized||(this._onComplete(e,t),this._finalized=!0)}}])})();cg.performDecoding=function(e,t){var r=new Uint8Array(e);return Promise.all(t.tasks.map((function(e){var t,i=e.layerName,n=e.firstByte,a=e.lastByte,o=e.pixelFormat,s=e.blockShape,l=e.blockIndex,u=e.filters,c=e.codec,h=r.subarray(n,a+1),f=new Uint32Array(s[0]*s[1]*s[2]);if("gzip_data"!==c)throw new og(`Unhandled codec: ${c}`);return t=(function(e,t){if(!globalThis.DecompressionStream&&"gzip_data"===t)return Promise.resolve(((a=(function(e){31==e[0]&&139==e[1]&&8==e[2]||tg(6,"invalid gzip data");var t=e[3],r=10;4&t&&(r+=2+(e[10]|e[11]<<8));for(var i=(t>>3&1)+(t>>4&1);i>0;i-=!e[r++]);return r+(2&t)})(n=e))+8>n.length&&tg(6,"invalid gzip data"),(function(e,t,r){var i=e.length;if(!i||t.f&&!t.l)return r||new z_(0);var n=!r,a=n||2!=t.i,o=t.i;n&&(r=new z_(3*i));var s,l,u=function(e){var t=r.length;if(e>t){var i=new z_(Math.max(2*t,e));i.set(r),r=i}},c=t.f||0,h=t.p||0,f=t.b||0,d=t.l,p=t.d,m=t.m,v=t.n,_=8*i;do{if(!d){c=K_(e,h,1);var g=K_(e,h+1,3);if(h+=3,!g){var y=e[(C=4+((h+7)/8|0))-4]|e[C-3]<<8,x=C+y;if(x>i){o&&tg(0);break}a&&u(f+y),r.set(e.subarray(C,x),f),t.b=f+=y,t.p=h=8*x,t.f=c;continue}if(1==g)d=X_,p=Y_,m=9,v=5;else if(2==g){var b=K_(e,h,31)+257,w=K_(e,h+10,15)+4,k=b+K_(e,h+5,31)+1;h+=14;for(var T=new z_(k),S=new z_(19),E=0;E>4)<16)T[E++]=C;else{var z=0,D=0;for(16==C?(D=3+K_(e,h,3),h+=2,z=T[E-1]):17==C?(D=3+K_(e,h,7),h+=3):18==C&&(D=11+K_(e,h,127),h+=7);D--;)T[E++]=z}}var R=T.subarray(0,b),L=T.subarray(b);m=J_(R),v=J_(L),d=$_(R,m),p=$_(L,v)}else tg(1);if(h>_){o&&tg(0);break}}a&&u(f+131072);for(var O=(1<>4;if((h+=15&z)>_){o&&tg(0);break}if(z||tg(2),N<256)r[f++]=N;else{if(256==N){B=h,d=null;break}var V=N-254;N>264&&(V=K_(e,h,(1<<(G=L_[E=N-257]))-1)+V_[E],h+=G);var U=p[Q_(e,h)&F],j=U>>4;if(U||tg(3),h+=15&U,L=j_[j],j>3){var G=O_[j];L+=Q_(e,h)&(1<_){o&&tg(0);break}a&&u(f+131072);var q=f+V;if(fs.length)&&(l=s.length),new z_(s.subarray(0,l))):r.subarray(0,f)})(n.subarray(a,-8),{i:2},new z_(((r=n)[(i=r.length)-4]|r[i-3]<<8|r[i-2]<<16|r[i-1]<<24)>>>0))));var r,i,n,a,o=ag[t];if(!o)throw new Error(`Unhandled codec: ${t}`);var s=new globalThis.DecompressionStream(o);return new Response(new Blob([e]).stream().pipeThrough(s)).arrayBuffer().then((function(e){return new Uint8Array(e)}))})(h,c).then((function(e){return(function(e,t){e.readFields(E_,t)})(new ng(e),f),new(0,ug[o])(f.buffer)})),t.then((function(e){for(var t=u.length-1;t>=0;t--)switch(u[t]){case"delta_filter":I_(e,s);break;case"zigzag_filter":C_(e);break;case"bitshuffle_filter":P_(e,o);break;default:throw new og(`Unhandled filter "${u[t]}"`)}return{layerName:i,blockIndex:l,data:e}})).catch((function(e){throw e}))})))},ua(fg,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]});var dg,pg={workerUrl:"",workerClass:null,workerParams:void 0},mg="mapboxgl_preloaded_worker_pool",vg=(function(){function e(){p(this,e),this.active={}}return m(e,[{key:"acquire",value:function(t){if(!this.workers)for(this.workers=[];this.workers.length1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2?arguments[2]:void 0,i={json:null,images:[],buffers:[]};if(new Uint32Array(e,t,1)[0]===Rg){var n=new Uint32Array(e,t),a=2,o=(n[a++]>>2)-3,s=n[a++]>>2;if(a++,i.json=JSON.parse(Lg.decode(n.subarray(a,a+s))),(a+=s)>>0,Math.ceil(1.2*n)),o=Math.ceil((a-n)/65536);try{return r.grow(o),i(),!0}catch(e){return!1}},b:n}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(e,a):e.then((function(e){return e.arrayBuffer()})).then((function(e){return WebAssembly.instantiate(e,a)}))).then((function(e){var n=e.instance.exports,a=n.Rb,o=n.Qb,s=n.P,l=n.T,u=n.X,c=n.Ja,h=n.La,f=n.Qa,d=n.Va,v=n.Wa,_=n.eb,g=n.jb,y=n.f,x=n.e,b=n.yb,w=n.zb,k=n.Ab,T=n.Bb,S=n.Db,E=n.Gb;r=x;var M=(function(){var e=0,r=0,i=0,n=0;return function(s){i&&(a(n),a(e),r+=i,i=e=0),e||(e=o(r+=128));var l=s.length+7&-8,u=e;l>=r&&(i=l,u=n=o(l));for(var c=0;c0){for(var n=0;n0){a.texcoordArray=new Zs;var x=t.json.accessors[n.TEXCOORD_0];a.texcoordArray.resize(x.count);var b=Ug(t,x);jg(t,x,a.texcoordArray,b)}if(void 0!==n._FEATURE_ID_RGBA4444){var w=t.json.accessors[n._FEATURE_ID_RGBA4444];t.json.extensionsUsed&&t.json.extensionsUsed.includes("EXT_meshopt_compression")&&(a.featureData=Ug(t,w))}void 0!==n._FEATURE_RGBA4444&&(a.featureData=new Uint32Array(Ug(t,t.json.accessors[n._FEATURE_RGBA4444]).buffer));var k=e.material;return a.material=(function(e,t){var r=e.emissiveFactor,i=void 0===r?[0,0,0]:r,n=e.alphaMode,a=void 0===n?"OPAQUE":n,o=e.alphaCutoff,s=void 0===o?.5:o,l=e.normalTexture,u=e.occlusionTexture,h=e.emissiveTexture,f=e.doubleSided,p=e.pbrMetallicRoughness||{},m=p.baseColorFactor,v=void 0===m?[1,1,1,1]:m,_=p.metallicFactor,g=void 0===_?1:_,y=p.roughnessFactor,x=void 0===y?1:y,b=p.baseColorTexture,w=p.metallicRoughnessTexture,k=u?t[u.index]:void 0;if(u&&u.extensions&&u.extensions.KHR_texture_transform&&k){var T=u.extensions.KHR_texture_transform;k.offsetScale=[T.offset[0],T.offset[1],T.scale[0],T.scale[1]]}return{pbrMetallicRoughness:{baseColorFactor:c(Lt,d(v)),metallicFactor:g,roughnessFactor:x,baseColorTexture:b?t[b.index]:void 0,metallicRoughnessTexture:w?t[w.index]:void 0},doubleSided:f,emissiveFactor:i,alphaMode:a,alphaCutoff:s,normalTexture:l?t[l.index]:void 0,occlusionTexture:k,emissionTexture:h?t[h.index]:void 0,defined:void 0===e.defined}})(void 0!==k?t.json.materials[k]:{defined:!1},r),a}function qg(e,t,r){var i=e.matrix,n=e.rotation,a=e.translation,o=e.scale,s=e.mesh,l=e.extras,u=e.children,c={};if(c.matrix=i||W.mat4.fromRotationTranslationScale([],n||[0,0,0,1],a||[0,0,0],o||[1,1,1]),void 0!==s){c.meshes=r[s];var h=c.anchor=[0,0];for(var f of c.meshes){var d=f.aabb,p=d.min,m=d.max;h[0]+=p[0]+m[0],h[1]+=p[1]+m[1]}h[0]=Math.floor(h[0]/c.meshes.length/2),h[1]=Math.floor(h[1]/c.meshes.length/2)}if(l&&(l.id&&(c.id=l.id),l.lights&&(c.lights=(function(e){if(!e.length)return[];for(var t=(function(e){for(var t=atob(e),r=new Uint8Array(t.length),i=0;i1&&i[i.length-1].equals(i[0])&&i.pop();for(var s=0,l=0;l0&&i.reverse();var f=rh(i.flatMap((function(e){return[e.x,e.y]})),[]);return 0===f.length?null:{vertices:i,indices:f}}function Hg(e,t){var r=[],i=[],n=0,a=[];for(var o of e){n=r.length;for(var s=o.vertexArray.float32,l=o.indexArray.uint16,u=0;u0&&(f=[i[h+2],i[h+1]],i[h+1]=f[0],i[h+2]=f[1])}return{vertices:r,indices:i}}function Wg(e){var t=(function(e,t){var r=[],i=WebGL2RenderingContext;if(e.json.textures)for(var n of e.json.textures){var a={magFilter:i.LINEAR,minFilter:i.NEAREST,wrapS:i.REPEAT,wrapT:i.REPEAT};void 0!==n.sampler&&Object.assign(a,e.json.samplers[n.sampler]),r.push({image:t[n.source],sampler:a,uploaded:!1})}return r})(e,e.images),r=(function(e,t){var r=[];for(var i of e.json.meshes){var n=[];for(var a of i.primitives)n.push(Gg(a,e,t));r.push(n)}return r})(e,t),i=e.json,n=i.scenes,a=i.scene,o=i.nodes,s=n?n[a||0].nodes:o,l=[];for(var u of s)l.push(qg(o[u],e,r));return(function(e,t,r){for(var i={},n=new Set,a=0;a0)for(var d=Array.from(n.values()).sort((function(e,t){return e-t})),p=d.length-1;p>=0;p--)e.splice(d[p],1)})(l,s,e.json.nodes),l}function Xg(e){e.heightmap=new Float32Array(4096),e.heightmap.fill(-1);for(var t=e.vertexArray.float32,r=e.aabb.min[0]-1,i=e.aabb.min[1]-1,n=Lv/(e.aabb.max[0]-r+2),a=Lv/(e.aabb.max[1]-i+2),o=0;oe.heightmap[u*Lv+l]&&(e.heightmap[u*Lv+l]=s)}}function Yg(e,t){var r={};r.indexArray=new Ls,r.indexArray.reserve(4*e.length),r.vertexArray=new ks,r.vertexArray.reserve(10*e.length),r.colorArray=new ws,r.vertexArray.reserve(10*e.length);var i=0;for(var n of e){var a=Math.min(10,Math.max(4,1.3*n.height))*t,o=[-n.normal[1],n.normal[0],0],s=Math.min(.29,.1*n.width/n.depth),l=n.width-2*n.depth*t*(s+.01),u=W.vec3.scaleAndAdd([],n.pos,o,l/2),c=W.vec3.scaleAndAdd([],n.pos,o,-l/2),h=[u[0],u[1],u[2]+n.height],f=[c[0],c[1],c[2]+n.height],d=W.vec3.scaleAndAdd([],n.normal,o,s);W.vec3.scale(d,d,a);var p=W.vec3.scaleAndAdd([],n.normal,o,-s);W.vec3.scale(p,p,a),W.vec3.add(d,u,d),W.vec3.add(p,c,p),u[2]+=.1,c[2]+=.1,r.vertexArray.emplaceBack(d[0],d[1],d[2]),r.vertexArray.emplaceBack(p[0],p[1],p[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(f[0],f[1],f[2]),r.vertexArray.emplaceBack(u[0],u[1],u[2]),r.vertexArray.emplaceBack(c[0],c[1],c[2]),r.vertexArray.emplaceBack(d[0],d[1],d[2]),r.vertexArray.emplaceBack(p[0],p[1],p[2]);var m=l/a/2;r.colorArray.emplaceBack(-m-s,-1,m,.8),r.colorArray.emplaceBack(m+s,-1,m,.8),r.colorArray.emplaceBack(-m,0,m,1.3),r.colorArray.emplaceBack(m,0,m,1.3),r.colorArray.emplaceBack(m+s,-.8,m,.7),r.colorArray.emplaceBack(m+s,-.8,m,.7),r.colorArray.emplaceBack(0,0,m,1.3),r.colorArray.emplaceBack(0,0,m,1.3),r.colorArray.emplaceBack(m+s,-1.2,m,.8),r.colorArray.emplaceBack(m+s,-1.2,m,.8),r.indexArray.emplaceBack(6+i,4+i,8+i),r.indexArray.emplaceBack(7+i,9+i,5+i),r.indexArray.emplaceBack(0+i,1+i,2+i),r.indexArray.emplaceBack(1+i,3+i,2+i),i+=10}var v={defined:!0,emissiveFactor:[0,0,0]},_={};return _.baseColorFactor=Lt.white,v.pbrMetallicRoughness=_,r.material=v,r.aabb=new cc([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),r}var Jg=(function(){return m((function e(t){p(this,e),this._stringToNumber={},this._numberToString=[];for(var r=0;r5&&void 0!==arguments[5]?arguments[5]:0,o=arguments.length>6&&void 0!==arguments[6]?arguments[6]:0,s=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(r,i,n,a);for(var l=this.grid,u=0;u=0&&h[3]>=0&&l.insert(s,h[0],h[1],h[2],h[3])}}},{key:"loadVTLayers",value:function(){if(!this.vtLayers)for(var e in this.vtLayers=new nf.VectorTile(new Kd(this.rawTileData)).layers,this.sourceLayerCoder=new Jg(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={},this.vtLayers)this.vtFeatures[e]=[];return this.vtLayers}},{key:"query",value:function(e,t,r){var i=this;this.loadVTLayers(),this.serializedLayersCache.clear();var n=Xo(e.filter),a=e.tileResult,o=e.transform,s=a.bufferedTilespaceBounds,l=this.grid.query(s.min.x,s.min.y,s.max.x,s.max.y,(function(e,t,r,i){return Bu(a.bufferedTilespaceGeometry,e,t,r,i)}));l.sort(ey);var u=null;o.elevation&&l.length>0&&(u=Gv.create(o.elevation,this.tileID));for(var c,h={},f=function(){var s=l[d];if(s===c)return 0;c=s;var f=i.featureIndexArray.get(s),p=null;if(i.is3DTile){var m=i.bucketLayerIDs[0][0],v=t[m];if("model"!==v.type)return 0;var _=v.queryIntersectsMatchingFeature(a,f.featureIndex,n,o),g=_.queryFeature,y=_.intersectionZ;g&&i.appendToResult(h,m,f.featureIndex,g,y)}else i.loadMatchingFeature(h,f,n,e.layers,e.availableImages,t,r,(function(t,r,n){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;return p||(p=bu(t,i.tileID.canonical,e.tileTransform)),r.queryIntersectsFeature(a,t,n,p,i.z,e.transform,e.pixelPosMatrix,u,o)}))},d=0;d=0)return!0;return!1})(i,f)){var d=this.sourceLayerCoder.decode(c),p=this.vtLayers[d].feature(l);if(r.needGeometry){var m=wu(p,!0);if(!r.filter(new zo(this.tileID.overscaledZ),m,this.tileID.canonical))return}else if(!r.filter(new zo(this.tileID.overscaledZ),p))return;for(var v=this.getId(p,d),_=0;_1&&void 0!==arguments[1]?arguments[1]:64,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Float64Array,n=arguments.length>3?arguments[3]:void 0;if(p(this,e),isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+r,2),65535),this.ArrayType=i,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;var a=ty.indexOf(this.ArrayType),o=2*t*this.ArrayType.BYTES_PER_ELEMENT,s=t*this.IndexArrayType.BYTES_PER_ELEMENT,l=(8-s%8)%8;if(a<0)throw new Error(`Unexpected typed array class: ${i}.`);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+l,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+o+s+l),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+s+l,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+a]),new Uint16Array(this.data,2,1)[0]=r,new Uint32Array(this.data,4,1)[0]=t)}return m(e,[{key:"add",value:function(e,t){var r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=e,this.coords[this._pos++]=t,r}},{key:"finish",value:function(){var e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return iy(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}},{key:"range",value:function(e,t,r,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");for(var n=this.ids,a=this.coords,o=this.nodeSize,s=[0,n.length-1,0],l=[];s.length;){var u=s.pop()||0,c=s.pop()||0,h=s.pop()||0;if(c-h<=o)for(var f=h;f<=c;f++){var d=a[2*f],p=a[2*f+1];d>=e&&d<=r&&p>=t&&p<=i&&l.push(n[f])}else{var m=h+c>>1,v=a[2*m],_=a[2*m+1];v>=e&&v<=r&&_>=t&&_<=i&&l.push(n[m]),(0===u?e<=v:t<=_)&&(s.push(h),s.push(m-1),s.push(1-u)),(0===u?r>=v:i>=_)&&(s.push(m+1),s.push(c),s.push(1-u))}}return l}},{key:"within",value:function(e,t,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");for(var i=this.ids,n=this.coords,a=this.nodeSize,o=[0,i.length-1,0],s=[],l=r*r;o.length;){var u=o.pop()||0,c=o.pop()||0,h=o.pop()||0;if(c-h<=a)for(var f=h;f<=c;f++)sy(n[2*f],n[2*f+1],e,t)<=l&&s.push(i[f]);else{var d=h+c>>1,p=n[2*d],m=n[2*d+1];sy(p,m,e,t)<=l&&s.push(i[d]),(0===u?e-r<=p:t-r<=m)&&(o.push(h),o.push(d-1),o.push(1-u)),(0===u?e+r>=p:t+r>=m)&&(o.push(d+1),o.push(c),o.push(1-u))}}return s}}],[{key:"from",value:function(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");var r=new Uint8Array(t,0,2),i=x(r,2),n=i[0],a=i[1];if(219!==n)throw new Error("Data does not appear to be in a KDBush format.");var o=a>>4;if(1!==o)throw new Error(`Got v${o} data when expected v1.`);var s=ty[15&a];if(!s)throw new Error("Unrecognized array type.");var l=new Uint16Array(t,2,1),u=x(l,1)[0],c=new Uint32Array(t,4,1);return new e(x(c,1)[0],u,s,t)}}])})();function iy(e,t,r,i,n,a){if(!(n-i<=r)){var o=i+n>>1;ny(e,t,o,i,n,a),iy(e,t,r,i,o-1,1-a),iy(e,t,r,o+1,n,1-a)}}function ny(e,t,r,i,n,a){for(;n>i;){if(n-i>600){var o=n-i+1,s=r-i+1,l=Math.log(o),u=.5*Math.exp(2*l/3),c=.5*Math.sqrt(l*u*(o-u)/o)*(s-o/2<0?-1:1);ny(e,t,r,Math.max(i,Math.floor(r-s*u/o+c)),Math.min(n,Math.floor(r+(o-s)*u/o+c)),a)}var h=t[2*r+a],f=i,d=n;for(ay(e,t,i,r),t[2*n+a]>h&&ay(e,t,i,n);fh;)d--}t[2*i+a]===h?ay(e,t,i,d):ay(e,t,++d,n),d<=r&&(i=d+1),r<=d&&(n=d-1)}}function ay(e,t,r,i){oy(e,r,i),oy(t,2*r,2*i),oy(t,2*r+1,2*i+1)}function oy(e,t,r){var i=e[t];e[t]=e[r],e[r]=i}function sy(e,t,r,i){var n=e-r,a=t-i;return n*n+a*a}e.$=Lo,e.A=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t)})(Av),e.B=yr,e.C=Vt,e.D=$o,e.E=zt,e.F=Un,e.G=Bn,e.H=Vn,e.I=Mp,e.J=Jn,e.K=Ho,e.L=ta,e.M=Kn,e.N=Li,e.O=Fi,e.P=K,e.Q=Ri,e.R=ut,e.S=Tr,e.T=Wm,e.U=Rt,e.V=Av,e.W=Wo,e.X=jn,e.Y=Nn,e.Z=function(e){var t=e.value,r=[];if(!t)return r;var i=yr(t);return"string"!==i?r=r.concat([new Av(e.key,t,`string expected, "${i}" found`)]):(Iv(t,!0)||(r=r.concat([new Av(e.key,t,`invalid url "${t}"`)])),r)},e._=Zo,e.a=function(e){return Ve.API_CDN_URL_REGEX.test(e)},e.a$=_s,e.a0=qo,e.a1=Uo,e.a2=(function(){return m((function e(t){p(this,e),this.specification=t}),[{key:"possiblyEvaluate",value:function(e,t){return Se(e.expression.evaluate(t))}},{key:"interpolate",value:function(e,t,r){return{x:Ft(e.x,t.x,r),y:Ft(e.y,t.y,r),z:Ft(e.z,t.z,r),azimuthal:Ft(e.azimuthal,t.azimuthal,r),polar:Ft(e.polar,t.polar,r)}}}])})(),e.a3=zo,e.a4=ea,e.a5=du,e.a6=W,e.a7=ue,e.a8=Vo,e.a9=Cc,e.aA=Ju,e.aB=ov,e.aC=sv,e.aD=nv,e.aE=function(e,t){var r=document.createElement("video");r.muted=!0,r.onloadstart=function(){t(null,r)};for(var i=0;i6&&void 0!==arguments[6]&&arguments[6];Fv(this.matrix,this,e.transform,this.position,t,r,i,n,a,o)}},{key:"upload",value:function(e){if(!this.uploaded){for(var t of this.nodes)Vv(t,e);for(var r of this.nodes)Uv(r);this.uploaded=!0}}},{key:"destroy",value:function(){for(var e of this.nodes)jv(e)}}])})(),e.aJ=ve,e.aK=function(e){return e.indexOf(ss)>=0},e.aL=rm,e.aM=au,e.aN=ou,e.aO=ys,e.aP=Ls,e.aQ=pe,e.aR=Js,e.aS=Fm,e.aT=function(){Po.isLoading()||Po.isLoaded()||"deferred"!==Io()||Co()},e.aU=Xo,e.aV=wu,e.aW=t_,e.aX=Me,e.aY=md,e.aZ=Lh,e.a_=bu,e.aa=Ft,e.ab=ri,e.ac=Bt,e.ad=(function(){return m((function e(t){p(this,e),this.specification=t}),[{key:"possiblyEvaluate",value:function(e,t){return(function(e){var t=x(e,2),r=Se([1,t[0],t[1]]);return{x:r.x,y:r.y,z:r.z}})(e.expression.evaluate(t))}},{key:"interpolate",value:function(e,t,r){return{x:Ft(e.x,t.x,r),y:Ft(e.y,t.y,r),z:Ft(e.z,t.z,r)}}}])})(),e.ae=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],n=new K(r,r),a=e.sub(n),o=t.add(n),s=[a,new K(o.x,a.y),o,new K(a.x,o.y)];return i&&s.push(a.clone()),s},e.af=function(e,t){for(var r=[],i=0;i2&&void 0!==arguments[2]?arguments[2]:0;return W.vec3.fromValues(((t.x-r)*e.scale-e.x)*ri,(t.y*e.scale-e.y)*ri,su(t.z,t.y))},e.aj=ic,e.ak=_d,e.al=function(e){var t=1/0,r=1/0,i=-1/0,n=-1/0;for(var a of e)t=Math.min(t,a.x),r=Math.min(r,a.y),i=Math.max(i,a.x),n=Math.max(n,a.y);return{min:new K(t,r),max:new K(i,n)}},e.am=ru,e.an=Fu,e.ao=mu,e.ap=le,e.aq=ql,e.ar=function(e,t){for(var r={},i=0;iJe&&(e.getActor().send("enforceCacheSizeLimit",Ye),it=0)},e.ay=Ge,e.az=function(e){return e<=1?1:Math.pow(2,Math.floor(Math.log(e)/Math.LN2))},e.b=function(e){return Ve.API_FONTS_REGEX.test(e)},e.b$=nc,e.b0=qs,e.b1=rc,e.b2=hl,e.b3=rh,e.b4=Zm,e.b5=function(e,t){var r=Cc(t.zoom);if(0===r)return vc(e);var i=xc(e),n=bc(i),a=ru(i.getWest())*t.worldSize,o=ru(i.getEast())*t.worldSize,s=iu(i.getNorth())*t.worldSize,l=iu(i.getSouth())*t.worldSize,u=[a,s,0],c=[o,s,0],h=[a,l,0],f=[o,l,0],d=W.mat4.invert([],t.globeMatrix);return W.vec3.transformMat4(u,u,d),W.vec3.transformMat4(c,c,d),W.vec3.transformMat4(h,h,d),W.vec3.transformMat4(f,f,d),n[0]=_c(n[0],h,r),n[1]=_c(n[1],f,r),n[2]=_c(n[2],c,r),n[3]=_c(n[3],u,r),cc.fromPoints(n)},e.b6=Sc,e.b7=wc,e.b8=_c,e.b9=gs,e.bA=Lt,e.bB=ce,e.bC=re,e.bD=Ie,e.bE=nu,e.bF=function(e,t,r){e[4*t+0]=r[0],e[4*t+1]=r[1],e[4*t+2]=r[2],e[4*t+3]=r[3]},e.bG=Ml,e.bH=wl,e.bI=kl,e.bJ=bl,e.bK=xl,e.bL=Ql,e.bM=Tm,e.bN=Yu,e.bO=uc,e.bP=hv,e.bQ=Xu,e.bR=yc,e.bS=function(e,t,r,i,n,a,o,s,l){if("globe"===l.name)return yc(e,t,new Xu(r,i,n),!1);var u=rm({z:r,x:i,y:n},l);return new cc([(a+u.x/u.scale)*t,t*(u.y/u.scale),o],[(a+u.x2/u.scale)*t,t*(u.y2/u.scale),s])},e.bT=function(e,t,r){for(var i=0,n=0;n<2;++n){e[n]>0&&(i+=(e[n]-0)*(e[n]-0)),t[n]<0&&(i+=(0-t[n])*(0-t[n]))}return i},e.bU=lu,e.bV=6,e.bW=function(e){var t=W.mat4.identity(new Float64Array(16));W.mat4.multiply(t,e.pixelMatrix,e.globeMatrix);var r=[0,Hl,0],i=[0,Wl,0];return W.vec3.transformMat4(r,r,t),W.vec3.transformMat4(i,i,t),[r[0]>0&&r[0]<=e.width&&r[1]>0&&r[1]<=e.height&&!zc(e,new Ql(e.center.lat,90)),i[0]>0&&i[0]<=e.width&&i[1]>0&&i[1]<=e.height&&!zc(e,new Ql(e.center.lat,-90))]},e.bX=function(e,t){var r=e.tileTransform.scale*ri/(e.tileSize*Math.pow(2,t.zoom-e.tileID.overscaledZ+e.tileID.canonical.z));return W.mat2.scale(new Float32Array(4),t.inverseAdjustmentMatrix,[r,r])},e.bY=fv,e.bZ=cv,e.b_=function(e){var t=cv(e,!0);return W.mat2.invert([],[t[0],t[1],t[4],t[5]])},e.ba=tc,e.bb=cg,e.bc=Kd,e.bd=dt,e.be=function(e){var t=[];for(var r in e)t.push(e[r]);return t},e.bf=function(e,t){var r=[];for(var i in e)i in t||r.push(i);return r},e.bg=he,e.bh=["type","source","source-layer","minzoom","maxzoom","filter","layout"],e.bi=Q,e.bj=function(e,t){var r=e.point,i=Ic(r.x,r.y,e.worldSize/e._pixelsPerMercatorPixel,0,0);return W.mat4.multiply(i,i,Ec(vc(t)))},e.bk=Ud,e.bl=rp,e.bm=Vd,e.bn=function(e,t,r,i,n){var a=5*t+2;e.float32[a+0]=r,e.float32[a+1]=i,e.float32[a+2]=n},e.bo=Cm,e.bp=Sp,e.bq=Au,e.br=Fd,e.bs=hf,e.bt=Mv,e.bu=xf,e.bv=bf,e.bw=$p,e.bx=Zp,e.by=dp,e.bz=ry,e.c=je,e.c$=Qu,e.c0=function(e){var t=e.point,r=t.x,i=t.y,n=e._center,a=n.lng,o=n.lat;return Ic(r,i,e.worldSize,a,o)},e.c1=ie,e.c2=Ku,e.c3=5,e.c4=function(e){var t=Math.round((e+45+360)%360/90)%4;return ne[t]},e.c5=45,e.c6=tu,e.c7=Tl,e.c8=function(e,t,r){var i=Math.sqrt(e*e+t*t+r*r),n=i>0?Math.acos(r/i)*te:0,a=0!==e||0!==t?Math.atan2(-t,-e)*te+90:0;return a<0&&(a+=360),[i,a,n]},e.c9=fu,e.cA=function(e){var t=80.051129;e=le(e,-80.051129,t)/t*90;var r=Math.pow(Math.abs(Math.sin(re(e))),3);return Math.round(r*($l.length-1))},e.cB=function(e,t,r,i){var n=t.getNorth(),a=t.getSouth(),o=t.getWest(),s=t.getEast(),l=1<0){var p=180/i;W.mat3.multiply(d,d,[p/u+1,0,0,0,p/c+1,0,-.5*p/h,.5*p/f,1])}return d[2]=l,d[5]=e.x,d[8]=e.y,d},e.cC=vc,e.cD=function(e,t,r){var i=W.mat4.identity(new Float64Array(16)),n=(t/(1<1)return!1;var r=t.getSource().maxzoom,i=1<1&&void 0!==arguments[1]?arguments[1]:0;return this.getAtPoint(e,t)||0}},{key:"getAtPoint",value:function(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(this.isUsingMockSource())return null;null==t&&(t=null);var i=this._source();if(!i)return t;if(e.y<0||e.y>1)return t;var n=i.getSource().maxzoom,a=1<=0?e.slice(0,t):e},e.co=function(e){var t=e.indexOf(ss);return t>=0?e.slice(t+1):""},e.cp=function(e){var t=[],r=e.id;return void 0===r&&t.push({message:`layers.${r}: missing required property "id"`}),void 0===e.render&&t.push({message:`layers.${r}: missing required method "render"`}),e.renderingMode&&"2d"!==e.renderingMode&&"3d"!==e.renderingMode&&t.push({message:`layers.${r}: property "renderingMode" must be either "2d" or "3d"`}),t},e.cq=function(e,t,r,i){return"custom"===e.type?new lv(e,t):new i_[e.type](e,t,r,i)},e.cr=ye,e.cs=Ao,e.ct=ft,e.cu=Sl,e.cv=(function(e){function t(e){var r;return p(this,t),(r=T(this,t,[e])).current=Al,r}return g(t,e),m(t,[{key:"set",value:function(e,t,r){if(this.fetchUniformLocation(e,t))for(var i=0;i<9;i++)if(r[i]!==this.current[i]){this.current=r,this.gl.uniformMatrix3fv(this.location,!1,r);break}}}])})(yl),e.cw=ae,e.cx=function(e,t,r){var i=Cc(r.zoom),n=e.style.map._antialias,a=t.options.extStandardDerivativesForceOff||e.terrain&&e.terrain.exaggeration()>0;return 0===i&&!n&&!a},e.cy=function(e){var t=e.pixelsPerMeter,r=t/nu(1,e.center.lat),i=W.mat4.identity(new Float64Array(16));return W.mat4.translate(i,i,[e.point.x,e.point.y,0]),W.mat4.scale(i,i,[r,r,t]),Float32Array.from(i)},e.cz=xc,e.d=function(e){return Ve.API_TILEJSON_REGEX.test(e)},e.d$=t,e.d0=qf,e.d1=Cf,e.d2=450,e.d3=7,e.d4=av,e.d5=ms,e.d6=Ws,e.d7=256,e.d8=Ec,e.d9=ks,e.dA=Pc,e.dB=function(e){var t=[0,0,0],r=W.mat4.identity(new Float64Array(16));return W.mat4.multiply(r,e.pixelMatrix,e.globeMatrix),W.vec3.transformMat4(t,t,r),new K(t[0],t[1])},e.dC=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(To===xo||To===bo||To===wo)throw new Error("setRTLTextPlugin cannot be called multiple times.");So=qe.resolveURL(e),To=xo,ko=t,Mo(),r||Co()},e.dD=Io,e.dE=function(){_g().acquire(mg)},e.dF=function(){var e=dg;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(mg),dg=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},e.dG=vg,e.dH=function(e){var t=Qe();if(t){var r=t.delete(Xe);e&&r.catch(e).then((function(){return e()}))}},e.dI=pg,e.dJ=Tg,e.dK=function(e){yg=qe.resolveURL(e),kg||(kg=new s_(_g(),new zt)),kg.broadcast("setDracoUrl",yg)},e.dL=Sg,e.dM=function(e){bg=qe.resolveURL(e),kg||(kg=new s_(_g(),new zt)),kg.broadcast("setMeshoptUrl",bg)},e.dN=ua,e.dO=Jc,e.dP=2,e.dQ=Jg,e.dR=Kg,e.dS=ud,e.dT=ge,e.dU=Ap,e.dV=function(e,t,r,i,n,a,o,s,l,u){var c=arguments.length>10&&void 0!==arguments[10]?arguments[10]:1,h=arguments.length>11?arguments[11]:void 0;e.createArrays(),e.tilePixelRatio=ri/(512*e.overscaling),e.compareText={},e.iconsNeedLinear=!1;var f=e.layers[0].layout,d=e.layers[0]._unevaluatedLayout._values,p={};if(p.scaleFactor=c,p.textSizeScaleRange=f.get("text-size-scale-range"),p.iconSizeScaleRange=f.get("icon-size-scale-range"),p.textScaleFactor=le(p.scaleFactor,p.textSizeScaleRange[0],p.textSizeScaleRange[1]),p.iconScaleFactor=le(p.scaleFactor,p.iconSizeScaleRange[0],p.iconSizeScaleRange[1]),"composite"===e.textSizeData.kind){var m=e.textSizeData,v=m.minZoom,_=m.maxZoom;p.compositeTextSizes=[d["text-size"].possiblyEvaluate(new zo(v),s),d["text-size"].possiblyEvaluate(new zo(_),s)]}if("composite"===e.iconSizeData.kind){var g=e.iconSizeData,y=g.minZoom,x=g.maxZoom;p.compositeIconSizes=[d["icon-size"].possiblyEvaluate(new zo(y),s),d["icon-size"].possiblyEvaluate(new zo(x),s)]}p.layoutTextSize=d["text-size"].possiblyEvaluate(new zo(l+1),s),p.layoutIconSize=d["icon-size"].possiblyEvaluate(new zo(l+1),s),p.textMaxSize=d["text-size"].possiblyEvaluate(new zo(18),s);var b="map"===f.get("text-rotation-alignment")&&"point"!==f.get("symbol-placement"),w=f.get("text-size"),k=!1;for(var T of e.features)if(T.icon&&T.icon.nameSecondary){k=!0;break}var S=function(){var a,l=f.get("text-font").evaluate(E,{},s).join(","),c=w.evaluate(E,{},s)*p.textScaleFactor,d=p.layoutTextSize.evaluate(E,{},s)*p.textScaleFactor,m=(p.layoutIconSize.evaluate(E,{},s),{horizontal:{},vertical:void 0}),v=E.text,_=[0,0];if(v){var g=v.toString(),y=f.get("text-letter-spacing").evaluate(E,{},s)*Fd,x=f.get("text-line-height").evaluate(E,{},s)*Fd,T=fo(g)?y:0,S=f.get("text-anchor").evaluate(E,{},s),M=f.get("text-variable-anchor");if(!M){var A=f.get("text-radial-offset").evaluate(E,{},s);_=A?Zp(S,[A*Fd,Gp]):f.get("text-offset").evaluate(E,{},s).map((function(e){return e*Fd}))}var I=b?"center":f.get("text-justify").evaluate(E,{},s),C="point"===f.get("symbol-placement"),P=C?f.get("text-max-width").evaluate(E,{},s)*Fd:1/0,z=function(i){e.allowVerticalPlacement&&ho(g)&&(m.vertical=ap(v,t,r,n,l,P,x,S,i,T,_,rp.vertical,!0,d,c))};if(!b&&M){for(var D="auto"===I?M.map((function(e){return $p(e)})):[I],R=!1,L=0;L=0||!ho(g)){var B=ap(v,t,r,n,l,P,x,S,I,T,_,rp.horizontal,!1,d,c);B&&(m.horizontal[I]=B)}z(C?"left":I)}}var N=!1;if(E.icon&&E.icon.namePrimary){var V=i[E.icon.namePrimary];V&&(a=mp(n[E.icon.namePrimary],E.icon.nameSecondary?n[E.icon.nameSecondary]:void 0,f.get("icon-offset").evaluate(E,{},s),f.get("icon-anchor").evaluate(E,{},s)),N=V.sdf,void 0===e.sdfIcons?e.sdfIcons=V.sdf:e.sdfIcons!==V.sdf&&we("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(V.pixelRatio!==e.pixelRatio||0!==f.get("icon-rotate").constantOr(1))&&(e.iconsNeedLinear=!0))}var U=Jp(m.horizontal)||m.vertical;e.iconsInText||(e.iconsInText=!!U&&U.iconsInText),(U||a)&&Hp(e,E,m,a,i,p,d,0,_,N,o,s,u,h,k)};for(var E of e.features)S();a&&e.generateCollisionDebugBuffers(l,e.collisionBoxArray,p.textScaleFactor)},e.dW=nf,e.dX=y_,e.dY=J,e.dZ=rf,e.d_=Jd,e.da=Ns,e.db=Vs,e.dc=function(e,t,r,i,n){return le((e-t)/(r-t)*(n-i)+i,i,n)},e.dd=An,e.de=cu,e.df=(function(){return m((function e(t,r,i,n){p(this,e),this.context=t,this.format=n,this.size=i,this.texture=t.gl.createTexture();var a=x(this.size,3),o=a[0],s=a[1],l=a[2],u=t.gl;u.bindTexture(u.TEXTURE_3D,this.texture),t.pixelStoreUnpackFlipY.set(!1),t.pixelStoreUnpack.set(1),t.pixelStoreUnpackPremultiplyAlpha.set(!1),u.texImage3D(u.TEXTURE_3D,0,this.format,o,s,l,0,$m(this.format),Hm(this.format),r.data)}),[{key:"bind",value:function(e,t){var r=this.context.gl;r.bindTexture(r.TEXTURE_3D,this.texture),e!==this.minFilter&&(r.texParameteri(r.TEXTURE_3D,r.TEXTURE_MAG_FILTER,e),r.texParameteri(r.TEXTURE_3D,r.TEXTURE_MIN_FILTER,e),this.minFilter=e),t!==this.wrapS&&(r.texParameteri(r.TEXTURE_3D,r.TEXTURE_WRAP_S,t),r.texParameteri(r.TEXTURE_3D,r.TEXTURE_WRAP_T,t),this.wrapS=t)}},{key:"destroy",value:function(){this.context.gl.deleteTexture(this.texture),this.texture=null}}])})(),e.dg=gv,e.dh=[1,1,1],e.di=Gv,e.dj=Ov,e.dk=Cs,e.dl=(function(){return m((function e(){p(this,e),this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new K(1/0,1/0),max:new K(-1/0,-1/0)}}),[{key:"clear",value:function(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}},{key:"updateTime",get:function(){return this._updateTime}},{key:"getReplacementRegionsForTile",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=vf(new K(0,0),new K(ri,ri),e),i=[];if(t&&!pf(r,this._globalClipBounds))return i;for(var n of this._activeRegions)if(!n.hiddenByOverlap&&pf(r,n)){var a=_f(n.min,n.max,e);i.push({min:a.min,max:a.max,sourceId:this._sourceIds[n.priority],footprint:n.footprint,footprintTileId:n.tileId,order:n.order,clipMask:n.clipMask,clipScope:n.clipScope})}return i}},{key:"setSources",value:function(e){this._setSources(e.map((function(e){return{getSourceId:function(){return e.cache.id},getFootprints:function(){var t=[];for(var r of e.cache.getVisibleCoordinates()){var i=e.cache.getTile(r).buckets[e.layer];i&&i.updateFootprints(r.toUnwrapped(),t)}return t},getOrder:function(){return e.order},getClipMask:function(){return e.clipMask},getClipScope:function(){return e.clipScope}}})))}},{key:"_addSource",value:function(e){var t=e.getFootprints();if(0!==t.length){var r=e.getOrder(),i=e.getClipMask(),n=e.getClipScope();for(var a of t)if(a.footprint){var o=vf(a.footprint.min,a.footprint.max,a.id);this._activeRegions.push({min:o.min,max:o.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:a.id,footprint:a.footprint,order:r,clipMask:i,clipScope:n})}this._sourceIds.push(e.getSourceId())}}},{key:"_computeReplacement",value:function(){var e=this;this._activeRegions.sort((function(e,t){return e.priority-t.priority||ff(e.min,t.min)||ff(e.max,t.max)||e.order-t.order||e.clipMask-t.clipMask||(function(e,t){var r=function(e,t){return e+t};return e.length-t.length||e.reduce(r,"").localeCompare(t.reduce(r,""))})(e.clipScope,t.clipScope)}));var t=this._activeRegions.length!==this._prevRegions.length;if(!t)for(var r=0;!t&&r!==this._activeRegions.length;){var i=this._activeRegions[r],n=this._prevRegions[r];t=i.priority!==n.priority||!df(i,n)||i.order!==n.order||i.clipMask!==n.clipMask||!Q(i.clipScope,n.clipScope),++r}if(t){for(var a of(++this._updateTime,this._activeRegions))a.order!==cf&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,a.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,a.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,a.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,a.max.y));var o=function(t){var r=e._activeRegions;if(t>=r.length)return t;for(var i=r[t].priority;t1)for(var s=0,l=o(s);s!==l;){for(var u=s,c=s;u!==l;){var h=this._activeRegions[u];h.hiddenByOverlap=!1;for(var f=0;f=0;r--)this._addSource(e[r]);this._computeReplacement()}}])})(),e.dm=(function(){return m((function e(t){p(this,e),this._createGrid(t),this._createPoles(t)}),[{key:"destroy",value:function(){for(var e of(this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy(),this._poleSegments))e.destroy();for(var t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy()}},{key:"_fillGridMeshWithLods",value:function(e,t){for(var r=new _s,i=new Ls,n=[],a=e+1+2,o=t[0]+1,s=t[0]+1+(1+t.length),l=function(e,t,r){var i=e===a-1?e-2:0===e?e:e-1;return[i+=r?24575:0,t]},u=0;u=e.byteLength)&&we("Invalid b3dm header information.")}return Vg(e,t)},e.e1=function(e,t){var r=Wg(e);for(var i of r){for(var n of i.meshes)Xg(n);i.lights&&(i.lightMeshIndex=i.meshes.length,i.meshes.push(Yg(i.lights,t)))}return r},e.e2=Yv,e.e3=o_,e.e4=Po,e.e5=function(e){et(),null!=He&&He.then((function(t){t.keys().then((function(r){for(var i=0;i>t/4)).toString(16):"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e)})()},e.v=function(e){return!!e&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)},e.w=we,e.x=Mt,e.y=2,e.z=Ep})),i(0,(function(e){function t(e){var t=e?e.url.toString():void 0;return t?performance.getEntriesByName(t):[]}function r(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e||null==e)return JSON.stringify(e);if(Array.isArray(e)){var t="[";for(var i of e)t+=`${r(i)},`;return`${t}]`}var n="{";for(var a of Object.keys(e).sort())n+=`${a}:${r(e[a])},`;return`${n}}`}function i(t){var i="";for(var n of e.bh)i+=`/${r(t[n])}`;return i}var n=(function(){return m((function e(t){p(this,e),this.keyCache={},this._layers={},this._layerConfigs={},t&&this.replace(t)}),[{key:"replace",value:function(e,t){this._layerConfigs={},this._layers={},this.update(e,[],t)}},{key:"update",value:function(t,r,n){var a=this;for(var o of(this._options=n,t))this._layerConfigs[o.id]=o,(this._layers[o.id]=e.cq(o,this.scope,null,this._options)).compileFilter(n),this.keyCache[o.id]&&delete this.keyCache[o.id];for(var s of r)delete this.keyCache[s],delete this._layerConfigs[s],delete this._layers[s];this.familiesBySource={};var l=(function(e,t){for(var r={},n=0;n=D.maxzoom||"none"!==D.visibility&&(l(z,this.zoom,_.brightness,i),(m[D.id]=D.createBucket({index:c.bucketLayerIDs.length,layers:z,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:S,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep})).populate(E,_,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(z.map((function(t){return e.av(t.id,t.scope)})))))}}}}v.trim();var R={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},L=function(){if(h)return s.status="done",a(h);if(s.extraShadowCaster)s.status="done",a(null,{buckets:e.be(m).filter((function(e){return!e.isEmpty()})),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:_.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(f&&d&&p){var t=new o(f),r=new e.dU(d,p,s.lut);for(var n in m){var u=m[n];u instanceof e.aS?(l(u.layers,s.zoom,_.brightness,i),e.dV(u,f,t.positions,d,r.iconPositions,s.showCollisionBoxes,i,s.tileID.canonical,s.tileZoom,s.projection,s.scaleFactor,s.brightness)):u.hasPattern&&(u instanceof e.aY||u instanceof e.aZ||u instanceof e.d0)&&(l(u.layers,s.zoom,_.brightness,i),u.addFeatures(_,s.tileID.canonical,r.patternPositions,i,s.tileTransform,s.brightness))}s.status="done",a(null,{buckets:e.be(m).filter((function(e){return!e.isEmpty()})),featureIndex:c,collisionBoxArray:s.collisionBoxArray,glyphAtlasImage:t.image,lineAtlas:v,imageAtlas:r,brightness:_.brightness})}};if(!this.extraShadowCaster){var O=e.dT(_.glyphDependencies,(function(e){return Object.keys(e).map(Number)}));Object.keys(O).length?n.send("getGlyphs",{uid:this.uid,stacks:O,scope:this.scope},(function(e,t){h||(h=e,f=t,L())}),void 0,!1,R):f={};var F=Object.keys(_.iconDependencies);F.length?n.send("getImages",{icons:F,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},(function(e,t){h||(h=e,d=t,L())}),void 0,!1,R):d={};var B=Object.keys(_.patternDependencies);B.length?n.send("getImages",{icons:B,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},(function(e,t){h||(h=e,p=t,L())}),void 0,!1,R):p={}}L()}}])})();function l(t,r,i,n){var a=new e.a3(r,{brightness:i});for(var o of t)o.recalculate(a,n)}var u=(function(r){function i(t,r,n,a,o,s){var l;return p(this,i),(l=T(this,i)).actor=t,l.layerIndex=r,l.availableImages=n,l.loadVectorData=o||e.aw,l.loading={},l.loaded={},l.deduped=new e.au(t.scheduler),l.isSpriteLoaded=a,l.scheduler=t.scheduler,l.brightness=s,l}return g(i,r),m(i,[{key:"loadTile",value:function(r,i){var n=this,a=r.uid,o=r&&r.request,l=o&&o.collectResourceTiming,u=this.loading[a]=new s(r);u.abort=this.loadVectorData(r,(function(s,c){var h=!n.loading[a];if(delete n.loading[a],h||s||!c)return u.status="done",h||(n.loaded[a]=u),i(s);var f=c.rawData,d={};c.expires&&(d.expires=c.expires),c.cacheControl&&(d.cacheControl=c.cacheControl),u.vectorTile=c.vectorTile||new e.dW.VectorTile(new e.bc(f));var p=function(){u.parse(u.vectorTile,n.layerIndex,n.availableImages,n.actor,(function(r,n){if(r||!n)return i(r);var a={};if(l){var s=t(o);s.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(s)))}i(null,e.l({rawTileData:f.slice(0)},n,d,a))}))};n.isSpriteLoaded?p():n.once("isSpriteLoaded",(function(){n.scheduler?n.scheduler.add(p,{type:"parseTile",isSymbolTile:r.isSymbolTile,zoom:r.tileZoom}):p()})),n.loaded=n.loaded||{},n.loaded[a]=u}))}},{key:"reloadTile",value:function(t,r){var i=this,n=this.loaded,a=t.uid;if(n&&n[a]){var o=n[a];o.scaleFactor=t.scaleFactor,o.showCollisionBoxes=t.showCollisionBoxes,o.projection=t.projection,o.brightness=t.brightness,o.tileTransform=e.aL(t.tileID.canonical,t.projection),o.extraShadowCaster=t.extraShadowCaster,o.lut=t.lut;var s=function(e,t){var n=o.reloadCallback;n&&(delete o.reloadCallback,o.parse(o.vectorTile,i.layerIndex,i.availableImages,i.actor,n)),r(e,t)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}else r(null,void 0)}},{key:"abortTile",value:function(e,t){var r=e.uid,i=this.loading[r];i&&(i.abort&&i.abort(),delete this.loading[r]),t()}},{key:"removeTile",value:function(e,t){var r=this.loaded,i=e.uid;r&&r[i]&&delete r[i],t()}}])})(e.E),c=(function(){return m((function e(){p(this,e)}),[{key:"loadTile",value:function(t,r){var i=t.uid,n=t.encoding,a=t.rawImageData,o=t.padding,s=ImageBitmap&&a instanceof ImageBitmap?this.getImageData(a,o):a;r(null,new e.dX(i,s,n,o<1))}},{key:"getImageData",value:function(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);var r=this.offscreenCanvasContext.getImageData(-t,-t,e.width+2*t,e.height+2*t);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),r}}])})();e.bb.setPbf(e.bc);var h=(function(){return m((function e(){p(this,e)}),[{key:"decodeRasterArray",value:function(t,r){var i=t.task,n=t.buffer;e.bb.performDecoding(n,i).then((function(e){r(null,e)}),(function(e){r(e)}))}}])})(),f=e.dW.VectorTileFeature.prototype.toGeoJSON,v=(function(){return m((function t(r){p(this,t),this._feature=r,this.extent=e.ab,this.type=r.type,this.properties=r.tags,"id"in r&&!isNaN(r.id)&&(this.id=parseInt(r.id,10))}),[{key:"loadGeometry",value:function(){if(1===this._feature.type){var t=[];for(var r of this._feature.geometry)t.push([new e.P(r[0],r[1])]);return t}var i=[];for(var n of this._feature.geometry){var a=[];for(var o of n)a.push(new e.P(o[0],o[1]));i.push(a)}return i}},{key:"toGeoJSON",value:function(e,t,r){return f.call(this,e,t,r)}}])})(),_=(function(){return m((function t(r){p(this,t),this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=e.ab,this.length=r.length,this._features=r}),[{key:"feature",value:function(e){return new v(this._features[e])}}])})(),y=.015625,b=(function(){return m((function e(){p(this,e),this.features=new Map}),[{key:"clear",value:function(){this.features.clear()}},{key:"load",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0;for(var r of e){var i=r.id;if(null!=i){var n=this.features.get(i);n&&this.updateCache(n,t),r.geometry?(n=S(r),this.updateCache(n,t),this.features.set(i,n)):this.features.delete(i),this.updateCache(n,t)}}}},{key:"updateCache",value:function(e,t){for(var r of Object.values(t)){var i=r.canonical,n=r.uid,a=i.z,o=i.x,s=i.y;w(e,Math.pow(2,a),o,s)&&delete t[n]}}},{key:"getTile",value:function(e,t,r){var i=Math.pow(2,e),n=[];for(var a of this.features.values())w(a,i,t,r)&&n.push(I(a,i,t,r));return{features:n}}},{key:"getFeatures",value:function(){return d(this.features.values())}}])})();function w(e,t,r,i){var n=e.minX,a=e.minY,o=e.maxX,s=e.maxY;return n<(r+1+y)/t&&a<(i+1+y)/t&&o>(r-y)/t&&s>(i-y)/t}function S(e){var t=e.id,r=e.geometry,i=e.properties;if(r){if("GeometryCollection"===r.type)throw new Error("GeometryCollection not supported in dynamic mode.");var n=r.type,a=r.coordinates,o={id:t,type:1,geometry:[],tags:i,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},s=o.geometry;if("Point"===n)E(a,s,o);else if("MultiPoint"===n)for(var l of a)E(l,s,o);else if("LineString"===n)o.type=2,M(a,s,o);else if("MultiLineString"===n)o.type=2,A(a,s,o);else if("Polygon"===n)o.type=3,A(a,s,o,!0);else{if("MultiPolygon"!==n)throw new Error("Input data is not a valid GeoJSON object.");for(var u of(o.type=3,a))A(u,s,o,!0)}return o}}function E(t,r,i){var n=x(t,2),a=n[0],o=n[1],s=e.am(a),l=e.at(o);l=l<0?0:l>1?1:l,r.push(s,l),i.minX=Math.min(i.minX,s),i.minY=Math.min(i.minY,l),i.maxX=Math.max(i.maxX,s),i.maxY=Math.max(i.maxY,l)}function M(e,t,r){var i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],n=arguments.length>4&&void 0!==arguments[4]&&arguments[4],a=[];for(var o of e)E(o,a,r);t.push(a),i&&(function(e,t){for(var r=0,i=0,n=e.length,a=n-2;i0===t)for(var o=0,s=e.length;o3&&void 0!==arguments[3]&&arguments[3],n=0;n=l&&f>=l||(c>=l?(h+=Math.round(m*((l-c)/p)),c=l):f>=l&&(d=h+Math.round(m*((l-c)/p)),f=l),h>=l&&d>=l||(h>=l?(c+=Math.round(p*((l-h)/m)),h=l):d>=l&&(f=c+Math.round(p*((l-h)/m)),d=l),o&&c===o[o.length-1][0]&&h===o[o.length-1][1]||(o=[[c,h]],a.push(o)),o.push([f,d])))))}}var P,z,D,R,L={exports:{}},O=(function(){if(D)return L.exports;D=1;var t=e.d_(),r=(function(){if(z)return P;z=1;var t=e.dY(),r=e.dZ().VectorTileFeature;function i(e,t){this.options=t||{},this.features=e,this.length=e.length}function n(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 P=i,i.prototype.feature=function(e){return new n(this.features[e],this.options.extent)},n.prototype.loadGeometry=function(){var e=this.rawGeometry;this.geometry=[];for(var r=0;r>31}function u(e,t){for(var r=e.loadGeometry(),i=e.type,n=0,a=0,o=r.length,u=0;u=i;m--){var v=+Date.now();p=this.trees[m]=this._createTree(this._cluster(p,m)),r&&console.log("z%d: %d clusters in %dms",m,p.numItems,+Date.now()-v)}return r&&console.timeEnd("total time"),this}},{key:"getClusters",value:function(e,t){var r=((e[0]+180)%360+360)%360-180,i=Math.max(-90,Math.min(90,e[1])),n=180===e[2]?180:((e[2]+180)%360+360)%360-180,a=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)r=-180,n=180;else if(r>n){var o=this.getClusters([r,i,180,a],t),s=this.getClusters([-180,i,n,a],t);return o.concat(s)}var l=this.trees[this._limitZoom(t)],u=l.range(G(r),q(a),G(n),q(i)),c=l.data,h=[];for(var f of u){var d=this.stride*f;h.push(c[d+5]>1?U(c,d,this.clusterProps):this.points[c[d+3]])}return h}},{key:"getChildren",value:function(e){var t=this._getOriginId(e),r=this._getOriginZoom(e),i="No cluster with the specified id.",n=this.trees[r];if(!n)throw new Error(i);var a=n.data;if(t*this.stride>=a.length)throw new Error(i);var o=this.options.radius/(this.options.extent*Math.pow(2,r-1)),s=n.within(a[t*this.stride],a[t*this.stride+1],o),l=[];for(var u of s){var c=u*this.stride;a[c+4]===e&&l.push(a[c+5]>1?U(a,c,this.clusterProps):this.points[a[c+3]])}if(0===l.length)throw new Error(i);return l}},{key:"getLeaves",value:function(e,t,r){var i=[];return this._appendLeaves(i,e,t=t||10,r=r||0,0),i}},{key:"getTile",value:function(e,t,r){var i=this.trees[this._limitZoom(e)],n=Math.pow(2,e),a=this.options,o=a.extent,s=a.radius/o,l=(r-s)/n,u=(r+1+s)/n,c={features:[]};return this._addTileFeatures(i.range((t-s)/n,l,(t+1+s)/n,u),i.data,t,r,n,c),0===t&&this._addTileFeatures(i.range(1-s/n,l,1,u),i.data,n,r,n,c),t===n-1&&this._addTileFeatures(i.range(0,l,s/n,u),i.data,-1,r,n,c),c.features.length?c:null}},{key:"getClusterExpansionZoom",value:function(e){for(var t=this._getOriginZoom(e)-1;t<=this.options.maxZoom;){var r=this.getChildren(e);if(t++,1!==r.length)break;e=r[0].properties.cluster_id}return t}},{key:"_appendLeaves",value:function(e,t,r,i,n){var a=this.getChildren(t);for(var o of a){var s=o.properties;if(s&&s.cluster?n+s.point_count<=i?n+=s.point_count:n=this._appendLeaves(e,s.cluster_id,r,i,n):n1,u=void 0,c=void 0,h=void 0;if(l)u=j(t,s,this.clusterProps),c=t[s],h=t[s+1];else{var f=this.points[t[s+3]];u=f.properties;var d=x(f.geometry.coordinates,2),p=d[0],m=d[1];c=G(p),h=q(m)}var v,_={type:1,geometry:[[Math.round(this.options.extent*(c*n-r)),Math.round(this.options.extent*(h*n-i))]],tags:u};void 0!==(v=l||this.options.generateId?t[s+3]:this.points[t[s+3]].id)&&(_.id=v),a.features.push(_)}}},{key:"_limitZoom",value:function(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}},{key:"_cluster",value:function(e,t){for(var r=this.options,i=r.radius,n=r.extent,a=r.reduce,o=r.minPoints,s=i/(n*Math.pow(2,t)),l=e.data,u=[],c=this.stride,h=0;ht&&(v+=l[g+5])}if(v>m&&v>=o){var y=void 0,x=f*m,b=d*m,w=-1,k=(h/c<<5)+(t+1)+this.points.length;for(var T of p){var S=T*c;if(!(l[S+2]<=t)){l[S+2]=t;var E=l[S+5];x+=l[S]*E,b+=l[S+1]*E,l[S+4]=k,a&&(y||(y=this._map(l,h,!0),w=this.clusterProps.length,this.clusterProps.push(y)),a(y,this._map(l,S)))}}l[h+4]=k,u.push(x/v,b/v,1/0,k,-1,v),a&&u.push(w)}else{for(var M=0;M1)for(var A of p){var I=A*c;if(!(l[I+2]<=t)){l[I+2]=t;for(var C=0;C>5}},{key:"_getOriginZoom",value:function(e){return(e-this.points.length)%32}},{key:"_map",value:function(e,t,r){if(e[t+5]>1){var i=this.clusterProps[e[t+6]];return r?Object.assign({},i):i}var n=this.points[e[t+3]].properties,a=this.options.map(n);return r&&a===n?Object.assign({},a):a}}])})();function U(e,t,r){return{type:"Feature",id:e[t+3],properties:j(e,t,r),geometry:{type:"Point",coordinates:[(i=e[t],360*(i-.5)),Z(e[t+1])]}};var i}function j(e,t,r){var i=e[t+5],n=i>=1e4?`${Math.round(i/1e3)}k`:i>=1e3?Math.round(i/100)/10+"k":i,a=e[t+6],o=-1===a?{}:Object.assign({},r[a]);return Object.assign(o,{cluster:!0,cluster_id:e[t+3],point_count:i,point_count_abbreviated:n})}function G(e){return e/360+.5}function q(e){var t=Math.sin(e*Math.PI/180),r=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return r<0?0:r>1?1:r}function Z(e){var t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function $(e,t,r,i){for(var n,a=i,o=t+(r-t>>1),s=r-t,l=e[t],u=e[t+1],c=e[r],h=e[r+1],f=t+3;fa)n=f,a=d;else if(d===a){var p=Math.abs(f-o);pi&&(n-t>3&&$(e,t,n,i),e[n+2]=a,r-n>3&&$(e,n,r,i))}function H(e,t,r,i,n,a){var o=n-r,s=a-i;if(0!==o||0!==s){var l=((e-r)*o+(t-i)*s)/(o*o+s*s);l>1?(r=n,i=a):l>0&&(r+=o*l,i+=s*l)}return(o=e-r)*o+(s=t-i)*s}function W(e,t,r,i){var n={id:null!=e?e:null,type:t,geometry:r,tags:i,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===t||"MultiPoint"===t||"LineString"===t)X(n,r);else if("Polygon"===t)X(n,r[0]);else if("MultiLineString"===t)for(var a of r)X(n,a);else if("MultiPolygon"===t)for(var o of r)X(n,o[0]);return n}function X(e,t){for(var r=0;r0&&(o+=i?(n*u-l*a)/2:Math.sqrt(Math.pow(l-n,2)+Math.pow(u-a,2))),n=l,a=u}var c=t.length-3;t[2]=1,$(t,0,c,r),t[c+2]=1,t.size=Math.abs(o),t.start=0,t.end=t.size}function Q(e,t,r,i){for(var n=0;n1?1:r}function re(e,t,r,i,n,a,o,s){if(i/=t,a>=(r/=t)&&o=i)return null;var l=[];for(var u of e){var c=u.geometry,h=u.type,f=0===n?u.minX:u.minY,d=0===n?u.maxX:u.maxY;if(f>=r&&d=i)){var p=[];if("Point"===h||"MultiPoint"===h)ie(c,p,r,i,n);else if("LineString"===h)ne(c,p,r,i,n,!1,s.lineMetrics);else if("MultiLineString"===h)oe(c,p,r,i,n,!1);else if("Polygon"===h)oe(c,p,r,i,n,!0);else if("MultiPolygon"===h)for(var m of c){var v=[];oe(m,v,r,i,n,!0),v.length&&p.push(v)}if(p.length){if(s.lineMetrics&&"LineString"===h){for(var _ of p)l.push(W(u.id,h,_,u.tags));continue}"LineString"!==h&&"MultiLineString"!==h||(1===p.length?(h="LineString",p=p[0]):h="MultiLineString"),"Point"!==h&&"MultiPoint"!==h||(h=3===p.length?"Point":"MultiPoint"),l.push(W(u.id,h,p,u.tags))}}}return l.length?l:null}function ie(e,t,r,i,n){for(var a=0;a=r&&o<=i&&se(t,e[a],e[a+1],e[a+2])}}function ne(e,t,r,i,n,a,o){for(var s,l,u=ae(e),c=0===n?le:ue,h=e.start,f=0;fr&&(l=c(u,d,p,v,_,r),o&&(u.start=h+s*l)):g>i?y=r&&(l=c(u,d,p,v,_,r),x=!0),y>i&&g<=i&&(l=c(u,d,p,v,_,i),x=!0),!a&&x&&(o&&(u.end=h+s*l),t.push(u),u=ae(e)),o&&(h+=s)}var b=e.length-3,w=e[b],k=e[b+1],T=0===n?w:k;T>=r&&T<=i&&se(u,w,k,e[b+2]),b=u.length-3,a&&b>=3&&(u[b]!==u[0]||u[b+1]!==u[1])&&se(u,u[0],u[1],u[2]),u.length&&t.push(u)}function ae(e){var t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function oe(e,t,r,i,n,a){for(var o of e)ne(o,t,r,i,n,a,!1)}function se(e,t,r,i){e.push(t,r,i)}function le(e,t,r,i,n,a){var o=(a-t)/(i-t);return se(e,a,r+(n-r)*o,1),o}function ue(e,t,r,i,n,a){var o=(a-r)/(n-r);return se(e,t+(i-t)*o,a,1),o}function ce(e,t){for(var r=[],i=0;i0&&t.size<(n?o:i))r.numPoints+=t.length/3;else{for(var s=[],l=0;lo)&&(r.numSimplified++,s.push(t[l],t[l+1])),r.numPoints++;n&&(function(e,t){for(var r=0,i=0,n=e.length,a=n-2;i0===t)for(var o=0,s=e.length;o24)throw new Error("maxZoom should be in the 0-24 range");if(r.promoteId&&r.generateId)throw new Error("promoteId and generateId cannot be used together.");var n=(function(e,t){var r=[];if("FeatureCollection"===e.type)for(var i=0;i1&&console.time("creation"),f=this.tiles[h]=pe(e,t,r,i,l),this.tileCoords.push({z:t,x:r,y:i}),u)){u>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,r,i,f.numFeatures,f.numPoints,f.numSimplified),console.timeEnd("creation"));var d=`z${t}`;this.stats[d]=(this.stats[d]||0)+1,this.total++}if(f.source=e,null==n){if(t===l.indexMaxZoom||f.numPoints<=l.indexMaxPoints)continue}else{if(t===l.maxZoom||t===n)continue;if(null!=n){var p=n-t;if(r!==a>>p||i!==o>>p)continue}}if(f.source=null,0!==e.length){u>1&&console.time("clipping");var m=.5*l.buffer/l.extent,v=.5-m,_=.5+m,g=1+m,y=null,x=null,b=null,w=null,k=re(e,c,r-m,r+_,0,f.minX,f.maxX,l),T=re(e,c,r+v,r+g,0,f.minX,f.maxX,l);e=null,k&&(y=re(k,c,i-m,i+_,1,f.minY,f.maxY,l),x=re(k,c,i+v,i+g,1,f.minY,f.maxY,l),k=null),T&&(b=re(T,c,i-m,i+_,1,f.minY,f.maxY,l),w=re(T,c,i+v,i+g,1,f.minY,f.maxY,l),T=null),u>1&&console.timeEnd("clipping"),s.push(y||[],t+1,2*r,2*i),s.push(x||[],t+1,2*r,2*i+1),s.push(b||[],t+1,2*r+1,2*i),s.push(w||[],t+1,2*r+1,2*i+1)}}}},{key:"getTile",value:function(e,t,r){e=+e,t=+t,r=+r;var i=this.options,n=i.extent,a=i.debug;if(e<0||e>24)return null;var o=1<1&&console.log("drilling down to z%d-%d-%d",e,t,r);for(var l,u=e,c=t,h=r;!l&&u>0;)u--,c>>=1,h>>=1,l=this.tiles[ye(u,c,h)];return l&&l.source?(a>1&&(console.log("found parent tile z%d-%d-%d",u,c,h),console.time("drilling down")),this.splitTile(l.source,u,c,h,e,t,r),a>1&&console.timeEnd("drilling down"),this.tiles[s]?fe(this.tiles[s],n):null):null}}])})();function ye(e,t,r){return 32*((1<=0?0:e.button}function D(t,r,i){var n=t.offsetWidth===r.width?1:t.offsetWidth/r.width;return new e.P((i.clientX-r.left)*n,(i.clientY-r.top)*n)}var R="01",L="NO_ACCESS_TOKEN",O=(function(){return m((function e(t,r,i){p(this,e),this._transformRequestFn=t,this._customAccessToken=r,this._silenceAuthErrors=!!i,this._createSkuToken()}),[{key:"_createSkuToken",value:function(){var e=(function(){for(var e="",t=0;t<10;t++)e+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1",R,e].join(""),tokenExpiresAt:Date.now()+432e5}})();this._skuToken=e.token,this._skuTokenExpiresAt=e.tokenExpiresAt}},{key:"_isSkuTokenExpired",value:function(){return Date.now()>this._skuTokenExpiresAt}},{key:"transformRequest",value:function(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}},{key:"normalizeStyleURL",value:function(r,i){if(!e.f(r))return r;var n=B(r);return n.params.push(`sdk=js-${t}`),n.path=`/styles/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||i)}},{key:"normalizeGlyphsURL",value:function(t,r){if(!e.f(t))return t;var i=B(t);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||r)}},{key:"normalizeModelURL",value:function(t,r){if(!e.f(t))return t;var i=B(t);return i.path=`/models/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||r)}},{key:"normalizeSourceURL",value:function(t,r,i,n){if(!e.f(t))return t;var a=B(t);return a.path=`/v4/${a.authority}.json`,a.params.push("secure"),i&&a.params.push(`language=${i}`),n&&a.params.push(`worldview=${n}`),this._makeAPIURL(a,this._customAccessToken||r)}},{key:"normalizeSpriteURL",value:function(t,r,i,n){var a=B(t);return e.f(t)?(a.path=`/styles/v1${a.path}/sprite${r}${i}`,this._makeAPIURL(a,this._customAccessToken||n)):(a.path+=`${r}${i}`,N(a))}},{key:"normalizeTileURL",value:function(t,r,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!e.f(t))return t;var n=B(t);n.path=n.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${r||i&&"raster"!==n.authority&&512===i?"@2x":""}${e.m.supported?".webp":"$1"}`),"raster"===n.authority?n.path=`/${e.e.RASTER_URL_PREFIX}${n.path}`:"rasterarrays"===n.authority?n.path=`/${e.e.RASTERARRAYS_URL_PREFIX}${n.path}`:"3dtiles"===n.authority?n.path=`/${e.e.TILES3D_URL_PREFIX}${n.path}`:(n.path=n.path.replace(/^.+\/v4\//,"/"),n.path=`/${e.e.TILE_URL_VERSION}${n.path}`);var a=this._customAccessToken||(function(e){for(var t of e){var r=t.match(/^access_token=(.*)$/);if(r)return r[1]}return null})(n.params)||e.e.ACCESS_TOKEN;return e.e.REQUIRE_ACCESS_TOKEN&&a&&this._skuToken&&n.params.push(`sku=${this._skuToken}`),this._makeAPIURL(n,a)}},{key:"canonicalizeTileURL",value:function(t,r){var i=B(t);if(!i.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!i.path.match(/\.[\w]+$/))return t;var n="mapbox://";i.path.match(/^\/raster\/v1\//)?n+=`raster/${i.path.replace(`/${e.e.RASTER_URL_PREFIX}/`,"")}`:i.path.match(/^\/rasterarrays\/v1\//)?n+=`rasterarrays/${i.path.replace(`/${e.e.RASTERARRAYS_URL_PREFIX}/`,"")}`:n+=`tiles/${i.path.replace(`/${e.e.TILE_URL_VERSION}/`,"")}`;var a=i.params;return r&&(a=a.filter((function(e){return!e.match(/^access_token=/)}))),a.length&&(n+=`?${a.join("&")}`),n}},{key:"canonicalizeTileset",value:function(t,r){var i=!!r&&e.f(r),n=[];for(var a of t.tiles||[])e.h(a)?n.push(this.canonicalizeTileURL(a,i)):n.push(a);return n}},{key:"_makeAPIURL",value:function(t,r){var i="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",n=B(e.e.API_URL);if(t.protocol=n.protocol,t.authority=n.authority,"http"===t.protocol){var a=t.params.indexOf("secure");a>=0&&t.params.splice(a,1)}if("/"!==n.path&&(t.path=`${n.path}${t.path}`),!e.e.REQUIRE_ACCESS_TOKEN)return N(t);if(r=r||e.e.ACCESS_TOKEN,!this._silenceAuthErrors){if(!r)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if("s"===r[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return t.params=t.params.filter((function(e){return-1===e.indexOf("access_token")})),t.params.push(`access_token=${r||""}`),N(t)}}])})(),F=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function B(e){var t=e.match(F);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 N(e){var t=e.params.length?`?${e.params.join("&")}`:"";return`${e.protocol}://${e.authority}${e.path}${t}`}var V="mapbox.eventData";function U(t){if(!t)return null;var r=t.split(".");if(!r||3!==r.length)return null;try{return JSON.parse(e.j(r[1]))}catch(e){return null}}var j=(function(){return m((function e(t){p(this,e),this.type=t,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}),[{key:"getStorageKey",value:function(t){var r,i=U(e.e.ACCESS_TOKEN);return r=i&&i.u?e.k(i.u):e.e.ACCESS_TOKEN||"",t?`${V}.${t}:${r}`:`${V}:${r}`}},{key:"fetchEventData",value:function(){var t=e.s("localStorage"),r=this.getStorageKey(),i=this.getStorageKey("uuid");if(t)try{var n=localStorage.getItem(r);n&&(this.eventData=JSON.parse(n));var a=localStorage.getItem(i);a&&(this.anonId=a)}catch(t){e.w("Unable to read from LocalStorage")}}},{key:"saveEventData",value:function(){var t=e.s("localStorage"),r=this.getStorageKey(),i=this.getStorageKey("uuid"),n=this.anonId;if(t&&n)try{localStorage.setItem(i,n),Object.keys(this.eventData).length>=1&&localStorage.setItem(r,JSON.stringify(this.eventData))}catch(t){e.w("Unable to write to LocalStorage")}}},{key:"processRequests",value:function(e){}},{key:"postEvent",value:function(t,r,i,n){var a=this;if(e.e.EVENTS_URL){var o=B(e.e.EVENTS_URL);o.params.push(`access_token=${n||e.e.ACCESS_TOKEN||""}`);var s={event:this.type,created:new Date(t).toISOString()},l=r?e.l(s,r):s,u={url:N(o),headers:{"Content-Type":"text/plain"},body:JSON.stringify([l])};this.pendingRequest=e.p(u,(function(e){a.pendingRequest=null,i(e),a.saveEventData(),a.processRequests(n)}))}}},{key:"queueRequest",value:function(e,t){this.queue.push(e),this.processRequests(t)}}])})(),G=new((function(r){function i(e){var t;return p(this,i),(t=T(this,i,["appUserTurnstile"]))._customAccessToken=e,t}return g(i,r),m(i,[{key:"postTurnstileEvent",value:function(t,r){e.e.EVENTS_URL&&e.e.ACCESS_TOKEN&&Array.isArray(t)&&t.some((function(t){return e.f(t)||e.h(t)}))&&this.queueRequest(Date.now(),r)}},{key:"processRequests",value:function(r){var i=this;if(!this.pendingRequest&&0!==this.queue.length){this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();var n=U(e.e.ACCESS_TOKEN),a=n?n.u:e.e.ACCESS_TOKEN,o=a!==this.eventData.tokenU;e.v(this.anonId)||(this.anonId=e.u(),o=!0);var s=this.queue.shift();if(this.eventData.lastSuccess){var l=new Date(this.eventData.lastSuccess),u=new Date(s),c=(s-this.eventData.lastSuccess)/864e5;o=o||c>=1||c<-1||l.getDate()!==u.getDate()}else o=!0;o?this.postEvent(s,{sdkIdentifier:"mapbox-gl-js",sdkVersion:t,skuId:R,"enabled.telemetry":!1,userId:this.anonId},(function(e){e||(i.eventData.lastSuccess=s,i.eventData.tokenU=a)}),r):this.processRequests()}}}])})(j)),q=G.postTurnstileEvent.bind(G),Z=new((function(r){function i(){var e;return p(this,i),(e=T(this,i,["map.load"])).success={},e.skuToken="",e}return g(i,r),m(i,[{key:"postMapLoadEvent",value:function(t,r,i,n){this.skuToken=r,this.errorCb=n,e.e.EVENTS_URL&&(i||e.e.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},i):this.errorCb(new Error(L)))}},{key:"processRequests",value:function(r){var i=this;if(!this.pendingRequest&&0!==this.queue.length){var n=this.queue.shift(),a=n.id,o=n.timestamp;a&&this.success[a]||(this.anonId||this.fetchEventData(),e.v(this.anonId)||(this.anonId=e.u()),this.postEvent(o,{sdkIdentifier:"mapbox-gl-js",sdkVersion:t,skuId:R,skuToken:this.skuToken,userId:this.anonId},(function(e){e?i.errorCb(e):a&&(i.success[a]=!0)}),r))}}},{key:"remove",value:function(){this.errorCb=null}}])})(j)),$=Z.postMapLoadEvent.bind(Z),H=new((function(t){function r(){var e;return p(this,r),(e=T(this,r,["style.load"])).eventIdPerMapInstanceMap=new Map,e.mapInstanceIdMap=new WeakMap,e}return g(r,t),m(r,[{key:"getMapInstanceId",value:function(t){var r=this.mapInstanceIdMap.get(t);return r||(r=e.u(),this.mapInstanceIdMap.set(t,r)),r}},{key:"getEventId",value:function(e){var t=this.eventIdPerMapInstanceMap.get(e)||0;return this.eventIdPerMapInstanceMap.set(e,t+1),t}},{key:"postStyleLoadEvent",value:function(t,r){var i=r.map,n=r.style,a=r.importedStyles;if(e.e.EVENTS_URL&&(t||e.e.ACCESS_TOKEN)){var o=this.getMapInstanceId(i),s={mapInstanceId:o,eventId:this.getEventId(o),style:n};a.length&&(s.importedStyles=a),this.queueRequest({timestamp:Date.now(),payload:s},t)}}},{key:"processRequests",value:function(e){if(!this.pendingRequest&&0!==this.queue.length){var t=this.queue.shift(),r=t.timestamp,i=t.payload;this.postEvent(r,i,(function(){}),e)}}}])})(j)),W=H.postStyleLoadEvent.bind(H),X=new((function(i){function a(){return p(this,a),T(this,a,["gljs.performance"])}return g(a,i),m(a,[{key:"postPerformanceEvent",value:function(t,r){e.e.EVENTS_URL&&(t||e.e.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:r},t)}},{key:"processRequests",value:function(i){if(!this.pendingRequest&&0!==this.queue.length){var a=this.queue.shift(),o=a.timestamp,s=(function(i){var a=performance.getEntriesByType("resource"),o=performance.getEntriesByType("mark"),s=(function(e){var t={};if(e)for(var r in e)if("other"!==r)for(var i of e[r]){var n=`${r}ResolveRangeMin`,a=`${r}ResolveRangeMax`,o=`${r}RequestCount`,s=`${r}RequestCachedCount`;t[n]=Math.min(t[n]||1/0,i.startTime),t[a]=Math.max(t[a]||-1/0,i.responseEnd);var l=function(e){void 0===t[e]&&(t[e]=0),++t[e]};void 0!==i.transferSize&&0===i.transferSize&&l(s),l(o)}return t})((function(e,t){var r={};if(e)for(var i of e){var n=t(i);void 0===r[n]&&(r[n]=[]),r[n].push(i)}return r})(a,n)),l=window.devicePixelRatio,u=navigator.connection||navigator.mozConnection||navigator.webkitConnection,c=u?u.effectiveType:void 0,h={counters:[],metadata:[],attributes:[]},f=function(e,t,r){null!=r&&e.push({name:t,value:r.toString()})};for(var d in s)f(h.counters,d,s[d]);if(i.interactionRange[0]!==1/0&&i.interactionRange[1]!==-1/0&&(f(h.counters,"interactionRangeMin",i.interactionRange[0]),f(h.counters,"interactionRangeMax",i.interactionRange[1])),o){var p=function(){var e=r[m],t=o.find((function(t){return t.name===e}));t&&f(h.counters,e,t.startTime)};for(var m of Object.keys(r))p()}return f(h.counters,"visibilityHidden",i.visibilityHidden),f(h.attributes,"style",(function(t){if(t)for(var r of t){var i=r.name.split("?")[0];if(e.i(i)){var n=i.split("/").slice(-2);if(2===n.length)return`mapbox://styles/${n[0]}/${n[1]}`}}})(a)),f(h.attributes,"terrainEnabled",i.terrainEnabled?"true":"false"),f(h.attributes,"fogEnabled",i.fogEnabled?"true":"false"),f(h.attributes,"projection",i.projection),f(h.attributes,"zoom",i.zoom),f(h.metadata,"devicePixelRatio",l),f(h.metadata,"connectionEffectiveType",c),f(h.metadata,"navigatorUserAgent",navigator.userAgent),f(h.metadata,"screenWidth",window.screen.width),f(h.metadata,"screenHeight",window.screen.height),f(h.metadata,"windowWidth",window.innerWidth),f(h.metadata,"windowHeight",window.innerHeight),f(h.metadata,"mapWidth",i.width/l),f(h.metadata,"mapHeight",i.height/l),f(h.metadata,"webglRenderer",i.renderer),f(h.metadata,"webglVendor",i.vendor),f(h.metadata,"sdkVersion",t),f(h.metadata,"sdkIdentifier","mapbox-gl-js"),h})(a.performanceData);for(var l of s.metadata);for(var u of s.counters);for(var c of s.attributes);this.postEvent(o,s,(function(){}),i)}}}])})(j)),Y=X.postPerformanceEvent.bind(X),J=new((function(t){function r(){var e;return p(this,r),(e=T(this,r,["map.auth"])).success={},e.skuToken="",e}return g(r,t),m(r,[{key:"getSession",value:function(t,r,i,n){var a=this;if(e.e.API_URL&&e.e.SESSION_PATH){var o=B(e.e.API_URL+e.e.SESSION_PATH);o.params.push(`sku=${r||""}`),o.params.push(`access_token=${n||e.e.ACCESS_TOKEN||""}`);var s={url:N(o),headers:{"Content-Type":"text/plain"}};this.pendingRequest=e.g(s,(function(e){a.pendingRequest=null,i(e),a.saveEventData(),a.processRequests(n)}))}}},{key:"getSessionAPI",value:function(t,r,i,n){this.skuToken=r,this.errorCb=n,e.e.SESSION_PATH&&e.e.API_URL&&(i||e.e.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},i):this.errorCb(new Error(L)))}},{key:"processRequests",value:function(e){var t=this;if(!this.pendingRequest&&0!==this.queue.length){var r=this.queue.shift(),i=r.id,n=r.timestamp;i&&this.success[i]||this.getSession(n,this.skuToken,(function(e){e?t.errorCb(e):i&&(t.success[i]=!0)}),e)}}},{key:"remove",value:function(){this.errorCb=null}}])})(j)),K=J.getSessionAPI.bind(J),Q=new Set;function ee(e,t){t?Q.add(e):Q.delete(e)}var te=(function(){return m((function e(){p(this,e),this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps=new Set,this._updatedImages=new Set}),[{key:"isDirty",value:function(){return this._changed}},{key:"setDirty",value:function(){this._changed=!0}},{key:"getUpdatedSourceCaches",value:function(){return this._updatedSourceCaches}},{key:"updateSourceCache",value:function(e,t){this._updatedSourceCaches[e]=t,this.setDirty()}},{key:"discardSourceCacheUpdate",value:function(e){delete this._updatedSourceCaches[e]}},{key:"updateLayer",value:function(e){var t=e.scope;this._updatedLayers[t]=this._updatedLayers[t]||new Set,this._updatedLayers[t].add(e.id),this.setDirty()}},{key:"removeLayer",value:function(e){var 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()}},{key:"getRemovedLayer",value:function(e){return this._removedLayers[e.scope]?this._removedLayers[e.scope][e.id]:null}},{key:"discardLayerRemoval",value:function(e){this._removedLayers[e.scope]&&delete this._removedLayers[e.scope][e.id]}},{key:"getLayerUpdatesByScope",value:function(){var e={};for(var t in this._updatedLayers)e[t]=e[t]||{},e[t].updatedIds=Array.from(this._updatedLayers[t].values());for(var r in this._removedLayers)e[r]=e[r]||{},e[r].removedIds=Object.keys(this._removedLayers[r]);return e}},{key:"getUpdatedPaintProperties",value:function(){return this._updatedPaintProps}},{key:"updatePaintProperties",value:function(e){this._updatedPaintProps.add(e.fqid),this.setDirty()}},{key:"getUpdatedImages",value:function(){return Array.from(this._updatedImages.values())}},{key:"updateImage",value:function(e){this._updatedImages.add(e),this.setDirty()}},{key:"resetUpdatedImages",value:function(){this._updatedImages.clear()}},{key:"reset",value:function(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps.clear(),this._updatedImages.clear()}}])})();function re(e){var t=e.userImage;return!!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}var ie=(function(t){function r(){var e;return p(this,r),(e=T(this,r)).images={},e.updatedImages={},e.callbackDispatchedThisFrame={},e.loaded={},e.requestors=[],e.patterns={},e.atlasImage={},e.atlasTexture={},e.dirty=!0,e}return g(r,t),m(r,[{key:"createScope",value:function(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})}},{key:"isLoaded",value:function(){for(var e in this.loaded)if(!this.loaded[e])return!1;return!0}},{key:"setLoaded",value:function(e,t){if(this.loaded[t]!==e&&(this.loaded[t]=e,e)){for(var r of this.requestors){var i=r.ids,n=r.callback;this._notify(i,t,n)}this.requestors=[]}}},{key:"hasImage",value:function(e,t){return!!this.getImage(e,t)}},{key:"getImage",value:function(e,t){return this.images[t][e]}},{key:"addImage",value:function(e,t,r){this._validate(e,r)&&(this.images[t][e]=r)}},{key:"_validate",value:function(t,r){var i=!0;return this._validateStretch(r.stretchX,r.data&&r.data.width)||(this.fire(new e.t(new Error(`Image "${t}" has invalid "stretchX" value`))),i=!1),this._validateStretch(r.stretchY,r.data&&r.data.height)||(this.fire(new e.t(new Error(`Image "${t}" has invalid "stretchY" value`))),i=!1),this._validateContent(r.content,r)||(this.fire(new e.t(new Error(`Image "${t}" has invalid "content" value`))),i=!1),i}},{key:"_validateStretch",value:function(e,t){if(!e)return!0;var r=0;for(var i of e){if(i[0]1?f-1:f,e.r.copy(m,l,{x:0,y:0},{x:d,y:p},{width:v,height:_},r),e.r.copy(m,l,{x:0,y:_-f},{x:d,y:p-f},{width:v,height:f},r),e.r.copy(m,l,{x:0,y:0},{x:d,y:p+_},{width:v,height:f},r),e.r.copy(m,l,{x:v-f,y:0},{x:d-f,y:p},{width:f,height:_},r),e.r.copy(m,l,{x:0,y:0},{x:d+v,y:p},{width:f,height:_},r),e.r.copy(m,l,{x:v-f,y:_-f},{x:d-f,y:p-f},{width:f,height:f},r),e.r.copy(m,l,{x:0,y:_-f},{x:d+v,y:p-f},{width:f,height:f},r),e.r.copy(m,l,{x:0,y:0},{x:d+v,y:p+_},{width:f,height:f},r),e.r.copy(m,l,{x:v-f,y:0},{x:d-f,y:p+_},{width:f,height:f},r)}this.dirty=!0}},{key:"beginFrame",value:function(){for(var e in this.images)this.callbackDispatchedThisFrame[e]={}}},{key:"dispatchRenderCallbacks",value:function(e,t){for(var r of e)if(!this.callbackDispatchedThisFrame[t][r]){this.callbackDispatchedThisFrame[t][r]=!0;var i=this.images[t][r];re(i)&&this.updateImage(r,t,i)}}}])})(e.E);function ne(t){var r=t.key,i=t.value,n=t.valueSpec||{},a=t.objectElementValidators||{},o=t.style,s=t.styleSpec,l=[],u=e.B(i);if("object"!==u)return[new e.V(r,i,`object expected, ${u} found`)];for(var c in i){var h=c.split(".")[0],f=void 0;a[h]?f=a[h]:n[h]?f=Ee:a["*"]?f=a["*"]:n["*"]&&(f=Ee),f?l=l.concat(f({key:(r?`${r}.`:r)+c,value:i[c],valueSpec:n[h]||n["*"],style:o,styleSpec:s,object:i,objectKey:c},i)):l.push(new e.A(r,i[c],`unknown property "${c}"`))}for(var d in n)a[d]||n[d].required&&void 0===n[d].default&&void 0===i[d]&&l.push(new e.V(r,i,`missing required property "${d}"`));return l}function ae(t){var r=t.value,i=t.valueSpec,n=t.style,a=t.styleSpec,o=t.key,s=t.arrayElementValidator||Ee;if("array"!==e.B(r))return[new e.V(o,r,`array expected, ${e.B(r)} found`)];if(i.length&&r.length!==i.length)return[new e.V(o,r,`array length ${i.length} expected, length ${r.length} found`)];if(i["min-length"]&&r.lengths)return[new e.V(r,i,`${i} is greater than the maximum value ${s}`)]}return[]}function se(t){var r,i,n,a=t.valueSpec,o=e.D(t.value.type),s={},l="categorical"!==o&&void 0===t.value.property,u=!l,c="array"===e.B(t.value.stops)&&"array"===e.B(t.value.stops[0])&&"object"===e.B(t.value.stops[0][0]),h=ne({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')];var r=[],i=t.value;return r=r.concat(ae({key:t.key,value:i,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:f})),"array"===e.B(i)&&0===i.length&&r.push(new e.V(t.key,i,"array must have at least one stop")),r},default:function(e){return Ee({key:e.key,value:e.value,valueSpec:a,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===o&&l&&h.push(new e.V(t.key,t.value,'missing required property "property"')),"identity"===o||t.value.stops||h.push(new e.V(t.key,t.value,'missing required property "stops"')),"exponential"===o&&t.valueSpec.expression&&!e.F(t.valueSpec)&&h.push(new e.V(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(u&&!e.G(t.valueSpec)?h.push(new e.V(t.key,t.value,"property functions not supported")):l&&!e.H(t.valueSpec)&&h.push(new e.V(t.key,t.value,"zoom functions not supported"))),"categorical"!==o&&!c||void 0!==t.value.property||h.push(new e.V(t.key,t.value,'"property" property is required')),h;function f(t){var r=[],o=t.value,l=t.key;if("array"!==e.B(o))return[new e.V(l,o,`array expected, ${e.B(o)} found`)];if(2!==o.length)return[new e.V(l,o,`array length 2 expected, length ${o.length} found`)];if(c){if("object"!==e.B(o[0]))return[new e.V(l,o,`object expected, ${e.B(o[0])} found`)];if(void 0===o[0].zoom)return[new e.V(l,o,"object stop key must have zoom")];if(void 0===o[0].value)return[new e.V(l,o,"object stop key must have value")];var u=e.D(o[0].zoom);if("number"!=typeof u)return[new e.V(l,o[0].zoom,"stop zoom values must be numbers")];if(n&&n>u)return[new e.V(l,o[0].zoom,"stop zoom values must appear in ascending order")];u!==n&&(n=u,i=void 0,s={}),r=r.concat(ne({key:`${l}[0]`,value:o[0],valueSpec:{zoom:{}},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:oe,value:d}}))}else r=r.concat(d({key:`${l}[0]`,value:o[0],valueSpec:{},style:t.style,styleSpec:t.styleSpec},o));return e.J(e.K(o[1]))?r.concat([new e.V(`${l}[1]`,o[1],"expressions are not allowed in function stops.")]):r.concat(Ee({key:`${l}[1]`,value:o[1],valueSpec:a,style:t.style,styleSpec:t.styleSpec}))}function d(t,n){var l=e.B(t.value),u=e.D(t.value),c=null!==t.value?t.value:n;if(r){if(l!==r)return[new e.V(t.key,c,`${l} stop domain type must match previous stop domain type ${r}`)]}else r=l;if("number"!==l&&"string"!==l&&"boolean"!==l&&"number"!=typeof u&&"string"!=typeof u&&"boolean"!=typeof u)return[new e.V(t.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==l&&"categorical"!==o){var h=`number expected, ${l} found`;return e.G(a)&&void 0===o&&(h+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new e.V(t.key,c,h)]}return"categorical"!==o||"number"!==l||"number"==typeof u&&isFinite(u)&&Math.floor(u)===u?"categorical"!==o&&"number"===l&&"number"==typeof u&&"number"==typeof i&&void 0!==i&&u":case">=":r.length>=2&&"$type"===e.D(r[1])&&o.push(new e.V(i,r,`"$type" cannot be use with operator "${r[0]}"`));case"==":case"!=":3!==r.length&&o.push(new e.V(i,r,`filter array for operator "${r[0]}" must have 3 elements`));case"in":case"!in":r.length>=2&&("string"!==(n=e.B(r[1]))&&o.push(new e.V(`${i}[1]`,r[1],`string expected, ${n} found`)));for(var s=2;s1&&void 0!==arguments[1]&&arguments[1],i=t.value,n=t.valueSpec,a=t.styleSpec;if(n.expression&&e.X(e.D(i)))return se(t);if(n.expression&&e.J(e.K(i)))return le(t);if(n.type&&Se[n.type]){var o=Se[n.type](t);return!0===r&&o.length>0&&"array"===e.B(t.value)?le(t):o}return ne(e.C({},t,{valueSpec:n.type?a[n.type]:n}))}function Me(t){var r=t.value,i=t.key,n=_e(t);return n.length||(-1===r.indexOf("{fontstack}")&&n.push(new e.V(i,r,'"glyphs" url must include a "{fontstack}" token')),-1===r.indexOf("{range}")&&n.push(new e.V(i,r,'"glyphs" url must include a "{range}" token'))),n}function Ae(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e._;return Ee({key:(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).key||"",value:t,valueSpec:r.$root,styleSpec:r,style:t,objectElementValidators:{glyphs:Me,"*":function(){return[]}}})}function Ie(t){return Ue(Ae(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:e._))}var Ce,Pe=function(e){return Ue(ye(e))},ze=function(e){return Ue(be(e))},De=function(e){return Ue(we(e))},Re=function(e){return Ue(ke(e))},Le=function(e){return Ue(Te(e))},Oe=function(e){return Ue(ve(e))},Fe=function(e){return Ue(he(e))},Be=function(e){return Ue(pe(e))},Ne=function(e){return Ue(me(e))},Ve=function(t){return Ue(e.Z(t))};function Ue(e){return e.slice().sort((function(e,t){return e.line&&t.line?e.line-t.line:0}))}function je(t,r){var i=!1;if(r&&r.length)for(var n of r)n instanceof e.A?e.w(n.message):(t.fire(new e.t(new Error(n.message))),i=!0);return i}var Ge=(function(t){function r(t){var i,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"flat";return p(this,r),(i=T(this,r))._transitionable=new e.$(Ce||(Ce=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)}))),i.setLight(t,n),i._transitioning=i._transitionable.untransitioned(),i}return g(r,t),m(r,[{key:"getLight",value:function(){return this._transitionable.serialize()}},{key:"setLight",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this._validate(ze,e,r)||(this._transitionable.setTransitionOrValue(e),this.id=t)}},{key:"updateTransitions",value:function(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}},{key:"hasTransition",value:function(){return this._transitioning.hasTransition()}},{key:"recalculate",value:function(e){this.properties=this._transitioning.possiblyEvaluate(e)}},{key:"_validate",value:function(t,r,i){return(!i||!1!==i.validate)&&je(this,t.call(Ie,e.l({value:r,style:{glyphs:!0,sprite:!0},styleSpec:e._})))}}])})(e.E),qe=(function(t){function r(t,i,n,a){var o;return p(this,r),(o=T(this,r)).scope=n,o._transitionable=new e.$(new e.a0({source:new e.a1(e._.terrain.source),exaggeration:new e.a1(e._.terrain.exaggeration)}),n,a),o._transitionable.setTransitionOrValue(t,a),o._transitioning=o._transitionable.untransitioned(),o.drapeRenderMode=i,o}return g(r,t),m(r,[{key:"get",value:function(){return this._transitionable.serialize()}},{key:"set",value:function(e,t){this._transitionable.setTransitionOrValue(e,t)}},{key:"updateTransitions",value:function(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}},{key:"hasTransition",value:function(){return this._transitioning.hasTransition()}},{key:"recalculate",value:function(e){this.properties=this._transitioning.possiblyEvaluate(e)}},{key:"getExaggeration",value:function(t){return this._transitioning.possiblyEvaluate(new e.a3(t)).get("exaggeration")}},{key:"getAttenuationRange",value:function(){if(!this.isZoomDependent())return null;var t=this._transitionable._values.exaggeration;if(!t)return null;var r=t.value.expression;if(!r)return null;var i=-1,n=-1,a=1;for(var o of r.zoomStops)(a=r.evaluate(new e.a3(o)))>.01?(i=o,n=-1):n=o;return a<.01&&i>0&&n>i?[i,n]:null}},{key:"isZoomDependent",value:function(){var t=this._transitionable._values.exaggeration;return null!=t&&null!=t.value&&null!=t.value.expression&&t.value.expression instanceof e.a4}}])})(e.E),Ze=.05;function $e(t,r,i,n){var a=e.a7(45,65,i),o=He(t,n),s=x(o,2),l=s[0],u=s[1],c=1-Math.min(1,Math.exp((r-l)/(u-l)*-6));return c*=c*c,(c=Math.min(1,1.00747*c))*a*t.alpha}function He(e,t){var r=.5/Math.tan(.5*t);return[e.range[0]+r,e.range[1]+r]}function We(t,r,i,n,a){var o=e.a6.vec3.transformMat4([],[r,i,n],a.mercatorFogMatrix);return $e(t,e.a6.vec3.length(o),a.pitch,a._fov)}function Xe(t,r,i,n,a,o,s){var l=[[i,n,0],[a,n,0],[a,o,0],[i,o,0]],u=Number.MAX_VALUE,c=-Number.MAX_VALUE;for(var h of l){var f=e.a6.vec3.transformMat4([],h,r),d=e.a6.vec3.length(f);u=Math.min(u,d),c=Math.max(c,d)}return[$e(t,u,s.pitch,s._fov),$e(t,c,s.pitch,s._fov)]}var Ye,Je,Ke=(function(t){function r(t,i,n,a){var o;p(this,r),o=T(this,r);var s=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"])});return o._transitionable=new e.$(s,n,new Map(a)),o.set(t,a),o._transitioning=o._transitionable.untransitioned(),o._transform=i,o.properties=new e.a8(s),o.scope=n,o}return g(r,t),m(r,[{key:"state",get:function(){var t=this._transform,r="globe"===t.projection.name,i=e.a9(t.zoom),n=this.properties.get("range"),a=[.5,3];return{range:r?[e.aa(a[0],n[0],i),e.aa(a[1],n[1],i)]:n,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}},{key:"get",value:function(){return this._transitionable.serialize()}},{key:"set",value:function(t,r){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!this._validate(Le,t,i)){var n=e.l({},t);for(var a of Object.keys(e._.fog))void 0===n[a]&&(n[a]=e._.fog[a].default);this._options=n,this._transitionable.setTransitionOrValue(this._options,r)}}},{key:"getOpacity",value:function(t){if(!this._transform.projection.supportsFog)return 0;var r=this.properties&&this.properties.get("color")||1;return("globe"===this._transform.projection.name?1:e.a7(45,65,t))*r.a}},{key:"getOpacityAtLatLng",value:function(t,r){return this._transform.projection.supportsFog?(function(t,r,i){var n=e.a5.fromLngLat(r),a=i.elevation?i.elevation.getAtPointOrZero(n):0;return We(t,n.x,n.y,a,i)})(this.state,t,r):0}},{key:"getOpacityForTile",value:function(t){if(!this._transform.projection.supportsFog)return[1,1];var r=this._transform.calculateFogTileMatrix(t.toUnwrapped());return Xe(this.state,r,0,0,e.ab,e.ab,this._transform)}},{key:"getOpacityForBounds",value:function(e,t,r,i,n){return this._transform.projection.supportsFog?Xe(this.state,e,t,r,i,n,this._transform):[1,1]}},{key:"getFovAdjustedRange",value:function(e){return this._transform.projection.supportsFog?He(this.state,e):[0,1]}},{key:"isVisibleOnFrustum",value:function(t){if(!this._transform.projection.supportsFog)return!1;for(var r of[4,5,6,7]){var i=t.points[r],n=void 0;if(i[2]>=0)n=i;else{var a=t.points[r-4];n=e.ac(a,i,a[2]/(a[2]-i[2]))}if(We(this.state,n[0],n[1],0,this._transform)>=Ze)return!0}return!1}},{key:"updateConfig",value:function(e){this._transitionable.setTransitionOrValue(this._options,new Map(e))}},{key:"updateTransitions",value:function(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}},{key:"hasTransition",value:function(){return this._transitioning.hasTransition()}},{key:"recalculate",value:function(e){this.properties=this._transitioning.possiblyEvaluate(e)}},{key:"_validate",value:function(t,r,i){return(!i||!1!==i.validate)&&je(this,t.call(Ie,e.l({value:r,style:{glyphs:!0,sprite:!0},styleSpec:e._})))}}])})(e.E),Qe=(function(t){function r(t,i,n,a){var o;return p(this,r),(o=T(this,r)).scope=n,o._options=t,o.properties=new e.a8(i),o._transitionable=new e.$(i,n,new Map(a)),o._transitionable.setTransitionOrValue(t.properties),o._transitioning=o._transitionable.untransitioned(),o}return g(r,t),m(r,[{key:"updateConfig",value:function(e){this._transitionable.setTransitionOrValue(this._options.properties,new Map(e))}},{key:"updateTransitions",value:function(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}},{key:"hasTransition",value:function(){return this._transitioning.hasTransition()}},{key:"recalculate",value:function(e){this.properties=this._transitioning.possiblyEvaluate(e)}},{key:"get",value:function(){return this._options.properties=this._transitionable.serialize(),this._options}},{key:"set",value:function(e,t){this._options=e,this._transitionable.setTransitionOrValue(e.properties,t)}},{key:"shadowsEnabled",value:function(){return!!this.properties&&!0===this.properties.get("cast-shadows")}}])})(e.E),et=(function(){function t(e,r,i,n){p(this,t),this.screenBounds=e,this.cameraPoint=r,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=i,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,n)}return m(t,[{key:"isPointQuery",value:function(){return 1===this.screenBounds.length}},{key:"bufferedScreenGeometry",value:function(t){return e.ae(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],t)}},{key:"bufferedCameraGeometry",value:function(t){var r=this.screenBounds[0],i=1===this.screenBounds.length?this.screenBounds[0].add(new e.P(1,1)):this.screenBounds[1],n=e.ae(r,i,0,!1);return this.cameraPoint.y>i.y&&(this.cameraPoint.x>r.x&&this.cameraPoint.x=i.x?n[2]=this.cameraPoint:this.cameraPoint.x<=r.x&&(n[3]=this.cameraPoint)),e.af(n,t)}},{key:"bufferedCameraGeometryGlobe",value:function(t){var r=this.screenBounds[0],i=1===this.screenBounds.length?this.screenBounds[0].add(new e.P(1,1)):this.screenBounds[1],n=e.ae(r,i,t),a=this.cameraPoint.clone();switch(3*((a.y>r.y)+(a.y>i.y))+((a.x>r.x)+(a.x>i.x))){case 0:n[0]=a,n[4]=a.clone();break;case 1:n.splice(1,0,a);break;case 2:n[1]=a;break;case 3:n.splice(4,0,a);break;case 5:n.splice(2,0,a);break;case 6:n[3]=a;break;case 7:n.splice(3,0,a);break;case 8:n[2]=a}return n}},{key:"containsTile",value:function(t,r,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=t.queryPadding/r._pixelsPerMercatorPixel+1,o=i?this._bufferedCameraMercator(a,r):this._bufferedScreenMercator(a,r),s=t.tileID.wrap+(o.unwrapped?n:0),l=o.polygon.map((function(r){return e.ag(t.tileTransform,r,s)}));if(e.ah(l,0,0,e.ab,e.ab)){s=t.tileID.wrap+(this.screenGeometryMercator.unwrapped?n:0);var u,c=this.screenGeometryMercator.polygon.map((function(r){return e.ai(t.tileTransform,r,s)})),h=c.map((function(t){return new e.P(t[0],t[1])})),f=r.getFreeCameraOptions().position||new e.a5(0,0,0),d=e.ai(t.tileTransform,f,s),p=c.map((function(t){var r=e.a6.vec3.sub(t,t,d);return e.a6.vec3.normalize(r,r),new e.aj(d,r)})),m=e.ak(t,1,r.zoom)*r._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:h,tilespaceRays:p,bufferedTilespaceGeometry:l,bufferedTilespaceBounds:(u=e.al(l),u.min.x=e.ap(u.min.x,0,e.ab),u.min.y=e.ap(u.min.y,0,e.ab),u.max.x=e.ap(u.max.x,0,e.ab),u.max.y=e.ap(u.max.y,0,e.ab),u),tile:t,tileID:t.tileID,pixelToTileUnitsFactor:m}}}},{key:"_bufferedScreenMercator",value:function(e,t){var r,i=it(e);return this._screenRaycastCache[i]?this._screenRaycastCache[i]:(r="globe"===t.projection.name?this._projectAndResample(this.bufferedScreenGeometry(e),t):{polygon:this.bufferedScreenGeometry(e).map((function(e){return t.pointCoordinate3D(e)})),unwrapped:!0},this._screenRaycastCache[i]=r,r)}},{key:"_bufferedCameraMercator",value:function(e,t){var r,i=it(e);return this._cameraRaycastCache[i]?this._cameraRaycastCache[i]:(r="globe"===t.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(e),t):{polygon:this.bufferedCameraGeometry(e).map((function(e){return t.pointCoordinate3D(e)})),unwrapped:!0},this._cameraRaycastCache[i]=r,r)}},{key:"_projectAndResample",value:function(t,r){var i=(function(t,r){var i=e.a6.mat4.multiply([],r.pixelMatrix,r.globeMatrix),n=[0,-e.aq,0,1],a=[0,e.aq,0,1],o=[0,0,0,1];e.a6.vec4.transformMat4(n,n,i),e.a6.vec4.transformMat4(a,a,i),e.a6.vec4.transformMat4(o,o,i);var s=new e.P(n[0]/n[3],n[1]/n[3]),l=new e.P(a[0]/a[3],a[1]/a[3]),u=e.an(t,s)&&n[3]1?tt(t.slice(0,f),r):[],v=fn&&(n=t[o].x,a=o);for(var s=0;s.5&&(u.x=i&&t.x=n&&t.y=2,a=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),n,this.tileSize);t.request=e.o(this.map._requestManager.transformRequest(a,e.R.Tile),(function(n,a,o,s){return delete t.request,t.aborted?(t.state="unloaded",r(null)):n?(t.state="errored",r(n)):a?(i.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:o,expires:s}),t.setTexture(a,i.map.painter),t.state="loaded",e.ax(i.dispatcher),void r(null)):r(null)}))}},{key:"abortTile",value:function(e,t){e.request&&(e.request.cancel(),delete e.request),t&&t()}},{key:"unloadTile",value:function(t,r){t.texture&&t.texture instanceof e.T?(t.destroy(!0),t.texture&&t.texture instanceof e.T&&this.map.painter.saveTileTexture(t.texture)):t.destroy(),r&&r()}},{key:"hasTransition",value:function(){return!1}},{key:"cancelTileJSONRequest",value:function(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}])})(e.E),lt=(function(t){function r(t,i,n,a){var o;return p(this,r),(o=T(this,r,[t,i,n,a])).type="raster-array",o.maxzoom=22,o._options=e.l({type:"raster-array"},i),o}return g(r,t),m(r,[{key:"triggerRepaint",value:function(e){var t=this.map.painter._terrain,r=this.map.style.getSourceCache(this.id);t&&t.enabled&&r&&t._clearRenderCacheForTile(r.id,e.tileID),this.map.triggerRepaint()}},{key:"loadTile",value:function(t,r){var i=this,n=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),a=this.map._requestManager.transformRequest(n,e.R.Tile);t.requestParams=a,t.actor||(t.actor=this.dispatcher.getActor()),t.request=t.fetchHeader(void 0,(function(e,n,a,o){if(delete t.request,t.aborted)return t.state="unloaded",r(null);if(e){if(20===e.code)return;return t.state="errored",r(e)}i.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:a,expires:o}),t.state="empty",r(null)}))}},{key:"unloadTile",value:function(t,r){var i=t.texture;i&&i instanceof e.T?(t.destroy(!0),this.map.painter.saveTileTexture(i)):(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"}},{key:"prepareTile",value:function(t,r,i){var n=this;t._isHeaderLoaded&&("empty"!==t.state&&(t.state="reloading"),t.fetchBand(r,i,(function(r,i){if(r)return t.state="errored",n.fire(new e.t(r)),void n.triggerRepaint(t);i&&(t.setTexture(i,n.map.painter),t.state="loaded",n.triggerRepaint(t))})))}},{key:"getInitialBand",value:function(e){if(!this.rasterLayers)return 0;var t=this.rasterLayers.find((function(t){return t.id===e})),r=t&&t.fields,i=r&&r.bands&&r.bands;return i?i[0]:0}},{key:"getTextureDescriptor",value:function(t,r,i){if(t){var n=r.sourceLayer||this.rasterLayerIds&&this.rasterLayerIds[0];if(n){var a=null;r instanceof e.aB?a=r.paint.get("raster-array-band"):r instanceof e.aC&&(a=r.paint.get("raster-particle-array-band"));var o=a||this.getInitialBand(n);if(null!=o)if(t.textureDescriptor){if(!t.updateNeeded(n,o)||i)return Object.assign({},t.textureDescriptor,{texture:t.texture})}else this.prepareTile(t,n,o)}}}}])})(st),ut={vector:ot,raster:st,"raster-dem":(function(t){function r(t,i,n,a){var o;return p(this,r),(o=T(this,r,[t,i,n,a])).type="raster-dem",o.maxzoom=22,o._options=e.l({type:"raster-dem"},i),o.encoding=i.encoding||"mapbox",o}return g(r,t),m(r,[{key:"loadTile",value:function(t,r){var i=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function n(e,i){e&&(t.state="errored",r(e)),i&&(t.dem=i,t.dem.onDeserialize(),t.needsHillshadePrepare=!0,t.needsDEMTextureUpload=!0,t.state="loaded",r(null))}t.request=e.o(this.map._requestManager.transformRequest(i,e.R.Tile),function(i,a,o,s){if(delete t.request,t.aborted)t.state="unloaded",r(null);else if(i)t.state="errored",r(i);else if(a){this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:o,expires:s});var l=ImageBitmap&&a instanceof ImageBitmap&&e.ay(),u=1-(a.width-e.az(a.width))/2;u<1||t.neighboringTiles||(t.neighboringTiles=this._getNeighboringTiles(t.tileID));var c=l?a:e.q.getImageData(a,u),h={uid:t.uid,coord:t.tileID,source:this.id,scope:this.scope,rawImageData:c,encoding:this.encoding,padding:u};t.actor&&"expired"!==t.state||(t.actor=this.dispatcher.getActor(),t.actor.send("loadDEMTile",h,n.bind(this),void 0,!0))}}.bind(this))}},{key:"_getNeighboringTiles",value:function(t){var r=t.canonical,i=Math.pow(2,r.z),n=(r.x-1+i)%i,a=0===r.x?t.wrap-1:t.wrap,o=(r.x+1+i)%i,s=r.x+1===i?t.wrap+1:t.wrap,l={};return l[new e.aA(t.overscaledZ,a,r.z,n,r.y).key]={backfilled:!1},l[new e.aA(t.overscaledZ,s,r.z,o,r.y).key]={backfilled:!1},r.y>0&&(l[new e.aA(t.overscaledZ,a,r.z,n,r.y-1).key]={backfilled:!1},l[new e.aA(t.overscaledZ,t.wrap,r.z,r.x,r.y-1).key]={backfilled:!1},l[new e.aA(t.overscaledZ,s,r.z,o,r.y-1).key]={backfilled:!1}),r.y+10&&void 0!==arguments[0]&&arguments[0];if(this._pendingLoad)this._coalesce=!0;else{this.fire(new e.x("dataloading",{dataType:"source"})),this._loaded=!1;var i=e.l({append:r},this.workerOptions);i.scope=this.scope;var n=this._data;"string"==typeof n?(i.request=this.map._requestManager.transformRequest(e.q.resolveURL(n),e.R.Source),i.request.collectResourceTiming=this._collectResourceTiming):i.data=JSON.stringify(n),this._pendingLoad=this.actor.send(`${this.type}.loadData`,i,(function(i,n){if(t._loaded=!0,t._pendingLoad=null,i)t.fire(new e.t(i));else{var a={dataType:"source",sourceDataType:t._metadataFired?"content":"metadata"};t._collectResourceTiming&&n&&n.resourceTiming&&n.resourceTiming[t.id]&&(a.resourceTiming=n.resourceTiming[t.id]),r&&(t._partialReload=!0),t.fire(new e.x("data",a)),t._partialReload=!1,t._metadataFired=!0}t._coalesce&&(t._updateWorkerData(r),t._coalesce=!1)}))}}},{key:"loaded",value:function(){return this._loaded}},{key:"loadTile",value:function(t,r){var i=this,n=t.actor?"reloadTile":"loadTile";t.actor=this.actor;var a=this.map.style?this.map.style.getLut(this.scope):null,o=a?{image:a.image.clone()}:null,s=this._partialReload,l={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:o,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:s};t.request=this.actor.send(n,l,(function(e,a){return s&&!a?(t.state="loaded",r(null)):(delete t.request,t.destroy(),t.aborted?r(null):e?r(e):(t.loadVectorData(a,i.map.painter,"reloadTile"===n),r(null)))}),void 0,"loadTile"===n)}},{key:"abortTile",value:function(e){e.request&&(e.request.cancel(),delete e.request),e.aborted=!0}},{key:"unloadTile",value:function(e,t){this.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope}),e.destroy()}},{key:"onRemove",value:function(e){this._pendingLoad&&this._pendingLoad.cancel()}},{key:"serialize",value:function(){return e.l({},this._options,{type:this.type,data:this._data})}},{key:"hasTransition",value:function(){return!1}}])})(e.E),video:(function(t){function r(e,t,i,n){var a;return p(this,r),(a=T(this,r,[e,t,i,n])).roundZoom=!0,a.type="video",a.options=t,a}return g(r,t),m(r,[{key:"load",value:function(){var t=this;this._loaded=!1;var r=this.options;for(var i of(this.urls=[],r.urls))this.urls.push(this.map._requestManager.transformRequest(i,e.R.Source).url);e.aE(this.urls,(function(r,i){t._loaded=!0,r?t.fire(new e.t(r)):i&&(t.video=i,t.video.loop=!0,t.video.setAttribute("playsinline",""),t.video.addEventListener("playing",(function(){t.map.triggerRepaint()})),t.map&&t.video.play(),t._finishLoading())}))}},{key:"pause",value:function(){this.video&&this.video.pause()}},{key:"play",value:function(){this.video&&this.video.play()}},{key:"seek",value:function(t){if(this.video){var r=this.video.seekable;tr.end(0)?this.fire(new e.t(new e.V(`sources.${this.id}`,null,`Playback for this video can be set only between the ${r.start(0)} and ${r.end(0)}-second mark.`))):this.video.currentTime=t}}},{key:"getVideo",value:function(){return this.video}},{key:"onAdd",value:function(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}},{key:"prepare",value:function(){if(!(0===Object.keys(this.tiles).length||this.video.readyState<2)){var t=this.map.painter.context,r=t.gl;this.texture?this.video.paused||(this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE),r.texSubImage2D(r.TEXTURE_2D,0,0,0,r.RGBA,r.UNSIGNED_BYTE,this.video)):(this.texture=new e.T(t,this.video,r.RGBA8),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(t)}}},{key:"serialize",value:function(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}},{key:"hasTransition",value:function(){return this.video&&!this.video.paused}}])})(e.aD),image:e.aD,model:(function(t){function r(e,t,i,n){var a;return p(this,r),(a=T(this,r)).id=e,a.type="model",a.models=[],a._loaded=!1,a._options=t,a}return g(r,t),m(r,[{key:"load",value:function(){var t=this,r=[],i=function(i){var n=t._options.models[i],a=e.aG(t.map._requestManager.transformRequest(n.uri,e.R.Model).url).then((function(r){if(r){var a=e.aH(r),o=new e.aI(i,n.position,n.orientation,a);o.computeBoundsAndApplyParent(),t.models.push(o)}})).catch((function(r){t.fire(new e.t(new Error(`Could not load model ${i} from ${n.uri}: ${r.message}`)))}));r.push(a)};for(var n in this._options.models)i(n);return Promise.allSettled(r).then((function(){t._loaded=!0,t.fire(new e.x("data",{dataType:"source",sourceDataType:"metadata"}))})).catch((function(r){t.fire(new e.t(new Error(`Could not load models: ${r.message}`)))}))}},{key:"onAdd",value:function(e){this.map=e,this.load()}},{key:"hasTransition",value:function(){return!1}},{key:"loaded",value:function(){return this._loaded}},{key:"getModels",value:function(){return this.models}},{key:"loadTile",value:function(e,t){}},{key:"serialize",value:function(){return{type:"model"}}}])})(e.E),"batched-model":(function(t){function r(e,t,i,n){var a;return p(this,r),(a=T(this,r)).type="batched-model",a.id=e,a.tileSize=512,a._options=t,a.tiles=a._options.tiles,a.maxzoom=t.maxzoom||19,a.minzoom=t.minzoom||0,a.roundZoom=!0,a.usedInConflation=!0,a.dispatcher=i,a.reparseOverscaled=!1,a.scheme="xyz",a._loaded=!1,a.setEventedParent(n),a}return g(r,t),m(r,[{key:"onAdd",value:function(e){this.map=e,this.load()}},{key:"load",value:function(t){var r=this;this._loaded=!1,this.fire(new e.x("dataloading",{dataType:"source"}));var i=Array.isArray(this.map._language)?this.map._language.join():this.map._language,n=this.map.getWorldview();this._tileJSONRequest=nt(this._options,this.map._requestManager,i,n,(function(a,o){r._tileJSONRequest=null,r._loaded=!0,a?(i&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${i}`),n&&2!==n.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${n}`),r.fire(new e.t(a))):o&&(e.l(r,o),o.bounds&&(r.tileBounds=new at(o.bounds,r.minzoom,r.maxzoom)),q(o.tiles,r.map._requestManager._customAccessToken),r.fire(new e.x("data",{dataType:"source",sourceDataType:"metadata"})),r.fire(new e.x("data",{dataType:"source",sourceDataType:"content"}))),t&&t(a)}))}},{key:"hasTransition",value:function(){return!1}},{key:"hasTile",value:function(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}},{key:"loaded",value:function(){return this._loaded}},{key:"loadTile",value:function(t,r){var i=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme)),n={request:this.map._requestManager.transformRequest(i,e.R.Tile),data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,showCollisionBoxes:this.map.showCollisionBoxes,isSymbolTile:t.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0,lut:null,maxZoom:null,promoteId:null,pixelRatio:null,scaleFactor:null};if(t.actor&&"expired"!==t.state)if("loading"===t.state)t.reloadCallback=r;else{if(t.buckets){var a=Object.values(t.buckets);for(var o of a)o.dirty=!0;return void(t.state="loaded")}t.request=t.actor.send("reloadTile",n,s.bind(this))}else t.actor=this.dispatcher.getActor(),t.request=t.actor.send("loadTile",n,s.bind(this),void 0,!0);function s(e,i){return t.aborted?r(null):e&&404!==e.status?r(e):(this.map._refreshExpiredTiles&&i&&t.setExpiryData(i),t.loadModelData(i,this.map.painter),t.state="loaded",void r(null))}}},{key:"serialize",value:function(){return e.l({},this._options)}}])})(e.E),canvas:(function(t){function r(t,i,n,a){var o;return p(this,r),o=T(this,r,[t,i,n,a]),i.coordinates?Array.isArray(i.coordinates)&&4===i.coordinates.length&&!i.coordinates.some((function(e){return!Array.isArray(e)||2!==e.length||e.some((function(e){return"number"!=typeof e}))}))||o.fire(new e.t(new e.V(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):o.fire(new e.t(new e.V(`sources.${t}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&o.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||o.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'))):o.fire(new e.t(new e.V(`sources.${t}`,null,'missing required property "canvas"'))),o.options=i,o.animate=void 0===i.animate||i.animate,o}return g(r,t),m(r,[{key:"load",value:function(){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())}},{key:"getCanvas",value:function(){return this.canvas}},{key:"onAdd",value:function(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play()}},{key:"onRemove",value:function(e){this.pause()}},{key:"prepare",value:function(){var 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()&&0!==Object.keys(this.tiles).length){var r=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(r,this.canvas,r.gl.RGBA8,{premultiply:!0}),this._prepareData(r)}}},{key:"serialize",value:function(){return{type:"canvas",coordinates:this.coordinates}}},{key:"hasTransition",value:function(){return this._playing}},{key:"_hasInvalidDimensions",value:function(){for(var e of[this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return!0;return!1}}])})(e.aD),custom:(function(t){function r(t,i,n,a){var o;return p(this,r),(o=T(this,r)).id=t,o.type="custom",o._dataType="raster",o._dispatcher=n,o._implementation=i,o.setEventedParent(a),o.scheme="xyz",o.minzoom=0,o.maxzoom=22,o.tileSize=512,o._loaded=!1,o.roundZoom=!0,o._implementation||o.fire(new e.t(new Error(`Missing implementation for ${o.id} custom source`))),o._implementation.loadTile||o.fire(new e.t(new Error(`Missing loadTile implementation for ${o.id} custom source`))),o._implementation.bounds&&(o.tileBounds=new at(o._implementation.bounds,o.minzoom,o.maxzoom)),i.update=o._update.bind(l(o)),i.clearTiles=o._clearTiles.bind(l(o)),i.coveringTiles=o._coveringTiles.bind(l(o)),e.l(l(o),e.ar(i,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"])),o}return g(r,t),m(r,[{key:"serialize",value:function(){return e.ar(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}},{key:"load",value:function(){this._loaded=!0,this.fire(new e.x("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.x("data",{dataType:"source",sourceDataType:"content"}))}},{key:"loaded",value:function(){return this._loaded}},{key:"onAdd",value:function(t){this.map=t,this._loaded=!1,this.fire(new e.x("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(t),this.load()}},{key:"onRemove",value:function(e){this._implementation.onRemove&&this._implementation.onRemove(e)}},{key:"hasTile",value:function(e){if(this._implementation.hasTile){var t=e.canonical,r=t.x,i=t.y,n=t.z;return this._implementation.hasTile({x:r,y:i,z:n})}return!this.tileBounds||this.tileBounds.contains(e.canonical)}},{key:"loadTile",value:function(e,t){var r=e.tileID.canonical,i=r.x,n=r.y,a=r.z,o=new AbortController;e.request=Promise.resolve(this._implementation.loadTile({x:i,y:n,z:a},{signal:o.signal})).then(function(r){return delete e.request,e.aborted?(e.state="unloaded",t(null)):void 0===r?(e.state="errored",t(null)):null===r?(this.loadTileData(e,{width:this.tileSize,height:this.tileSize,data:null}),e.state="loaded",t(null)):(function(e){return e instanceof ImageData||e instanceof HTMLCanvasElement||e instanceof ImageBitmap||e instanceof HTMLImageElement})(r)?(this.loadTileData(e,r),e.state="loaded",void t(null)):(e.state="errored",t(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}.bind(this)).catch((function(r){20!==r.code&&(e.state="errored",t(r))})),e.request.cancel=function(){return o.abort()}}},{key:"loadTileData",value:function(e,t){e.setTexture(t,this.map.painter)}},{key:"unloadTile",value:function(t,r){if(t.texture&&t.texture instanceof e.T?(t.destroy(!0),t.texture&&t.texture instanceof e.T&&this.map.painter.saveTileTexture(t.texture)):t.destroy(),this._implementation.unloadTile){var i=t.tileID.canonical,n=i.x,a=i.y,o=i.z;this._implementation.unloadTile({x:n,y:a,z:o})}r&&r()}},{key:"abortTile",value:function(e,t){e.request&&e.request.cancel&&(e.request.cancel(),delete e.request),t&&t()}},{key:"hasTransition",value:function(){return!1}},{key:"_coveringTiles",value:function(){return this.map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map((function(e){return{x:e.canonical.x,y:e.canonical.y,z:e.canonical.z}}))}},{key:"_clearTiles",value:function(){var t=e.av(this.id,this.scope);this.map.style.clearSource(t)}},{key:"_update",value:function(){this.fire(new e.x("data",{dataType:"source",sourceDataType:"content"}))}}])})(e.E)},ct=function(t,r,i,n){var a=new ut[r.type](t,r,i,n);if(a.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${a.id}`);return e.aJ(["load","abort","unload","serialize","prepare"],a),a};function ht(t,r){var i=e.a6.mat4.identity([]);return e.a6.mat4.scale(i,i,[.5*t.width,.5*-t.height,1]),e.a6.mat4.translate(i,i,[1,-1,0]),e.a6.mat4.multiply(i,i,t.calculateProjMatrix(r.toUnwrapped())),Float32Array.from(i)}function ft(t,r,i,n,a,o,s,l){var u=arguments.length>8&&void 0!==arguments[8]&&arguments[8],c=t.tilesIn(i,l,u);c.sort(pt);var h=[];for(var f of c)h.push({wrappedTileID:f.tile.tileID.wrapped().key,queryResults:f.tile.queryRenderedFeatures(r,t._state,f,n,a,o,s,ht(t.transform,f.tile.tileID),u)});var d=(function(e){var t={},r={};for(var i of e){var n=i.queryResults,a=i.wrappedTileID,o=r[a]=r[a]||{};for(var s in n){var l=n[s],u=o[s]=o[s]||{},c=t[s]=t[s]||[];for(var h of l)u[h.featureIndex]||(u[h.featureIndex]=!0,c.push(h))}}return t})(h),p=function(r){d[r].forEach((function(i){var n=i.feature,a=n.layer;a&&"background"!==a.type&&"sky"!==a.type&&"slot"!==a.type&&(e.aK(r)||(n.source=a.source,a["source-layer"]&&(n.sourceLayer=a["source-layer"])),n.state=void 0!==n.id?t.getFeatureState(a["source-layer"],n.id):{})}))};for(var m in d)p(m);return d}function dt(e,t){for(var r=e.getRenderableIds().map((function(t){return e.getTileByID(t)})),i=[],n={},a=0;a>=1)>1;){var Mt=bt+kt>>1,At=wt+Tt>>1;1&xt?(kt=bt,Tt=wt,bt=St,wt=Et):(bt=kt,wt=Tt,kt=St,Tt=Et),St=Mt,Et=At}var It=4*yt;gt[It+0]=bt,gt[It+1]=wt,gt[It+2]=kt,gt[It+3]=Tt}var Ct=new Uint16Array(2178),Pt=new Uint8Array(1089),zt=new Uint16Array(1089);function Dt(e){return 0===e?-.03125:32===e?.03125:0}var Rt={type:2,extent:e.ab,loadGeometry:function(){return[[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)]]}},Lt=(function(){return m((function t(r,i,n,a,o){p(this,t),this.tileID=r,this.uid=e.aQ(),this.uses=0,this.tileSize=i,this.tileZoom=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=o,a&&a.style&&(this._lastUpdatedBrightness=a.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",a&&a.transform&&(this.projection=a.transform.projection)}),[{key:"registerFadeDuration",value:function(t){var r=t+this.timeAdded;rn)a=!1;else if(r)if(this.expirationTime=0;h--){var f=4*h,d=gt[f+0],p=gt[f+1],m=gt[f+2],v=gt[f+3],_=d+m>>1,g=p+v>>1,y=_+g-p,x=g+d-_,b=p*_t+d,w=v*_t+m,k=g*_t+_,T=Math.hypot((Ct[2*b+0]+Ct[2*w+0])/2-Ct[2*k+0],(Ct[2*b+1]+Ct[2*w+1])/2-Ct[2*k+1])>=16;Pt[k]=Pt[k]||(T?1:0),h<1022&&(Pt[k]=Pt[k]||Pt[(p+x>>1)*_t+(d+y>>1)]||Pt[(v+x>>1)*_t+(m+y>>1)])}var S=new e.aO,E=new e.aP,M=0;function A(t,r){var i=r*_t+t;return 0===zt[i]&&(S.emplaceBack(Ct[2*i+0],Ct[2*i+1],t*e.ab/vt,r*e.ab/vt),zt[i]=++M),zt[i]-1}function I(e,t,r,i,n,a){var o=e+r>>1,s=t+i>>1;if(Math.abs(e-n)+Math.abs(t-a)>1&&Pt[s*_t+o])I(n,a,e,t,o,s),I(r,i,n,a,o,s);else{var l=A(e,t),u=A(r,i),c=A(n,a);E.emplaceBack(l,u,c)}}return I(0,0,vt,vt,vt,0),I(vt,vt,0,0,0,vt),{vertices:S,indices:E}})(this.tileID.canonical,r);i=o.vertices,n=o.indices}else{for(var s of(i=new e.aO,n=new e.aP,a)){var l=s.x,u=s.y;i.emplaceBack(l,u,0,0)}for(var c=e.b3(i.int16,void 0,4),h=0;h0&&(n=e.a6.mat4.invert(new Float64Array(16),r.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(t,a,r,s,n,l),this._makeGlobeTileDebugTextBuffer(t,a,r,s,n,l)}}},{key:"_globePoint",value:function(t,r,i,n,a,o,s){var l=e.b7(t,r,i);if(o){var u=1<.5?d=-1:f<-.5&&(d=1);var p=(t/e.ab+i.x)/u+d,m=(r/e.ab+i.y)/u;p=(p-c)*n._pixelsPerMercatorPixel+c,m=(m-h)*n._pixelsPerMercatorPixel+h;var v=[p*n.worldSize,m*n.worldSize,0];e.a6.vec3.transformMat4(v,v,o),l=e.b8(l,v,s)}return e.a6.vec3.transformMat4(l,l,a)}},{key:"_makeGlobeTileDebugBorderBuffer",value:function(t,r,i,n,a,o){var s=this,l=new e.a$,u=new e.b0,c=new e.b9,h=function(e,t,h,f,d){for(var p=(h-e)/(d-1),m=(f-t)/(d-1),v=l.length,_=0;_0&&void 0!==arguments[0]&&arguments[0];for(var r in this.buckets)this.buckets[r].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);var Ot=(function(t){function r(e,t,i,n,a){var o;return p(this,r),(o=T(this,r,[e,t,i,n,a]))._workQueue=[],o._fetchQueue=[],o._isHeaderLoaded=!1,o}return g(r,t),m(r,[{key:"setTexture",value:function(t,r){var i=r.context,n=i.gl;this.texture=this.texture||r.getTileTexture(t.width),this.texture&&this.texture instanceof e.T?this.texture.update(t,{premultiply:!1}):this.texture=new e.T(i,t,n.RGBA8,{premultiply:!1})}},{key:"flushQueues",value:function(){for(;this._workQueue.length;)this._workQueue.pop()();for(;this._fetchQueue.length;)this._fetchQueue.pop()()}},{key:"fetchHeader",value:function(){var t=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:16384,i=arguments.length>1?arguments[1]:void 0,n=this._mrt=new e.bb(30),a=Object.assign({},this.requestParams,{headers:{Range:"bytes=0-"+(r-1)}});return this.entireBuffer=null,this.request=e.bd(a,(function(e,a,o,s){if(e)i(e);else try{var l=n.getHeaderLength(a);if(l>r)return void(t.request=t.fetchHeader(l,i));n.parseHeader(a),t._isHeaderLoaded=!0;var u=0;for(var c of Object.values(n.layers))u=Math.max(u,c.dataIndex[c.dataIndex.length-1].last_byte);a.byteLength>=u&&(t.entireBuffer=a),i(null,t.entireBuffer||a,o,s)}catch(e){i(e)}})),this.request}},{key:"fetchBand",value:function(t,r,i){var n=this,a=this._mrt;if(this._isHeaderLoaded&&a){var o=this.actor;if(o){var s,l=function(e,a){s.complete(e,a),e?i(e):(n.updateTextureDescriptor(t,r),i(null,n.textureDescriptor&&n.textureDescriptor.img))},u=function(e,t){if(e)return i(e);var r=o.send("decodeRasterArray",{buffer:t,task:s},l,void 0,!0);n._workQueue.push((function(){r&&r.cancel(),s.cancel()}))},c=a.getLayer(t);if(c){if(c.hasDataForBand(r))return this.updateTextureDescriptor(t,r),void i(null,this.textureDescriptor?this.textureDescriptor.img:null);var h=c.getDataRange([r]);if(!(s=a.createDecodingTask(h))||s.tasks.length)if(this.flushQueues(),this.entireBuffer)u(null,this.entireBuffer.slice(h.firstByte,h.lastByte+1));else{var f=Object.assign({},this.requestParams,{headers:{Range:`bytes=${h.firstByte}-${h.lastByte}`}}),d=e.bd(f,u);this._fetchQueue.push((function(){d.cancel(),s.cancel()}))}else i(null)}else i(new Error(`Unknown sourceLayer "${t}"`))}else i(new Error("Can't fetch tile band without an actor"))}else i(new Error("Tile header is not ready"))}},{key:"updateNeeded",value:function(e,t){return(!this.textureDescriptor||this.textureDescriptor.band!==t||this.textureDescriptor.layer!==e)&&"errored"!==this.state}},{key:"updateTextureDescriptor",value:function(t,r){if(this._mrt){var i=this._mrt.getLayer(t);if(i&&i.hasBand(r)&&i.hasDataForBand(r)){var n=i.getBandView(r),a=n.bytes,o=n.tileSize,s=n.buffer,l=n.offset,u=n.scale,c=o+2*s,h={data:a,width:c,height:c},f=this.texture;f&&f instanceof e.T&&f.update(h,{premultiply:!1}),this.textureDescriptor={layer:t,band:r,img:h,buffer:s,offset:l,tileSize:o,format:i.pixelFormat,mix:[u,256*u,65536*u,16777216*u]}}}}}])})(Lt),Ft=(function(){return m((function e(t,r){p(this,e),this.max=t,this.onRemove=r,this.reset()}),[{key:"reset",value:function(){for(var e in this.data)for(var t of this.data[e])t.timeout&&clearTimeout(t.timeout),this.onRemove(t.value);return this.data={},this.order=[],this}},{key:"add",value:function(e,t,r){var i=this,n=e.wrapped().key;void 0===this.data[n]&&(this.data[n]=[]);var a={value:t,timeout:void 0};if(void 0!==r&&(a.timeout=setTimeout((function(){i.remove(e,a)}),r)),this.data[n].push(a),this.order.push(n),this.order.length>this.max){var o=this._getAndRemoveByKey(this.order[0]);o&&this.onRemove(o)}return this}},{key:"has",value:function(e){return e.wrapped().key in this.data}},{key:"getAndRemove",value:function(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}},{key:"_getAndRemoveByKey",value:function(e){var 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}},{key:"getByKey",value:function(e){var t=this.data[e];return t?t[0].value:null}},{key:"get",value:function(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}},{key:"remove",value:function(e,t){if(!this.has(e))return this;var r=e.wrapped().key,i=void 0===t?0:this.data[r].indexOf(t),n=this.data[r][i];return this.data[r].splice(i,1),n.timeout&&clearTimeout(n.timeout),0===this.data[r].length&&delete this.data[r],this.onRemove(n.value),this.order.splice(this.order.indexOf(r),1),this}},{key:"setMaxSize",value:function(e){for(this.max=e;this.order.length>this.max;){var t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}},{key:"filter",value:function(e){var t=[];for(var r in this.data)for(var i of this.data[r])e(i.value)||t.push(i);for(var n of t)this.remove(n.value.tileID,n)}}])})(),Bt=(function(){return m((function e(){p(this,e),this.state={},this.stateChanges={},this.deletedStates={}}),[{key:"updateState",value:function(t,r,i){var n=String(r);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][n]=this.stateChanges[t][n]||{},e.l(this.stateChanges[t][n],i),null===this.deletedStates[t])for(var a in this.deletedStates[t]={},this.state[t])a!==n&&(this.deletedStates[t][a]=null);else if(this.deletedStates[t]&&null===this.deletedStates[t][n])for(var o in this.deletedStates[t][n]={},this.state[t][n])i[o]||(this.deletedStates[t][n][o]=null);else for(var s in i)this.deletedStates[t]&&this.deletedStates[t][n]&&null===this.deletedStates[t][n][s]&&delete this.deletedStates[t][n][s]}},{key:"removeFeatureState",value:function(e,t,r){if(null!==this.deletedStates[e]){var i=String(t);if(this.deletedStates[e]=this.deletedStates[e]||{},r&&void 0!==t)null!==this.deletedStates[e][i]&&(this.deletedStates[e][i]=this.deletedStates[e][i]||{},this.deletedStates[e][i][r]=null);else if(void 0!==t)if(this.stateChanges[e]&&this.stateChanges[e][i])for(r in this.deletedStates[e][i]={},this.stateChanges[e][i])this.deletedStates[e][i][r]=null;else this.deletedStates[e][i]=null;else this.deletedStates[e]=null}}},{key:"getState",value:function(t,r){var i=this.state[t]||{},n=this.stateChanges[t]||{},a=this.deletedStates[t];if(null===a)return{};if(void 0!==r){var o=String(r),s=e.l({},i[o],n[o]);if(a){var l=a[r];if(null===l)return{};for(var u in l)delete s[u]}return s}var c=e.l({},i,n);if(a)for(var h in a)delete c[h];return c}},{key:"initializeTileState",value:function(e,t){e.refreshFeatureState(t)}},{key:"coalesceChanges",value:function(t,r){var i={};for(var n in this.stateChanges){this.state[n]=this.state[n]||{};var a={};for(var o in this.stateChanges[n])this.state[n][o]||(this.state[n][o]={}),e.l(this.state[n][o],this.stateChanges[n][o]),a[o]=this.state[n][o];i[n]=a}for(var s in this.deletedStates){this.state[s]=this.state[s]||{};var l={};if(null===this.deletedStates[s])for(var u in this.state[s])l[u]={},this.state[s][u]={};else for(var c in this.deletedStates[s]){if(null===this.deletedStates[s][c])this.state[s][c]={};else if(this.state[s][c])for(var h of Object.keys(this.deletedStates[s][c]))delete this.state[s][c][h];l[c]=this.state[s][c]}i[s]=i[s]||{},e.l(i[s],l)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(i).length)for(var f in t)t[f].refreshFeatureState(r)}}])})(),Nt=(function(t){function r(e,t,i){var n;return p(this,r),(n=T(this,r)).id=e,n._onlySymbols=i,t.on("data",(function(e){"source"===e.dataType&&"metadata"===e.sourceDataType&&(n._sourceLoaded=!0),n._sourceLoaded&&!n._paused&&"source"===e.dataType&&"content"===e.sourceDataType&&(n.reload(),n.transform&&n.update(n.transform))})),t.on("error",(function(){n._sourceErrored=!0})),n._source=t,n._tiles={},n._cache=new Ft(0,n._unloadTile.bind(l(n))),n._timers={},n._cacheTimers={},n._minTileCacheSize=t.minTileCacheSize,n._maxTileCacheSize=t.maxTileCacheSize,n._loadedParentTiles={},n.castsShadows=!1,n.tileCoverLift=0,n._coveredTiles={},n._shadowCasterTiles={},n._state=new Bt,n._isRaster="raster"===n._source.type||"raster-dem"===n._source.type||"raster-array"===n._source.type||"custom"===n._source.type&&"raster"===n._source._dataType,n}return g(r,t),m(r,[{key:"onAdd",value:function(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}},{key:"loaded",value:function(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(var e in this._tiles){var t=this._tiles[e];if("loaded"!==t.state&&"errored"!==t.state)return!1}return!0}},{key:"getSource",value:function(){return this._source}},{key:"pause",value:function(){this._paused=!0}},{key:"resume",value:function(){if(this._paused){var e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform)}}},{key:"_loadTile",value:function(e,t){return e.isSymbolTile=this._onlySymbols,e.isExtraShadowCaster=this._shadowCasterTiles[e.tileID.key],this._source.loadTile(e,t)}},{key:"_unloadTile",value:function(e){if(this._source.unloadTile)return this._source.unloadTile(e)}},{key:"_abortTile",value:function(e){if(this._source.abortTile)return this._source.abortTile(e)}},{key:"serialize",value:function(){return this._source.serialize()}},{key:"prepare",value:function(e){for(var t in this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null),this._tiles){var r=this._tiles[t];r.upload(e),r.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}},{key:"getIds",value:function(){return e.be(this._tiles).map((function(e){return e.tileID})).sort(Vt).map((function(e){return e.key}))}},{key:"getRenderableIds",value:function(t,r){var i=this,n=[];for(var a in this._tiles)this._isIdRenderable(+a,t,r)&&n.push(this._tiles[a]);return t?n.sort((function(t,r){var n=t.tileID,a=r.tileID,o=new e.P(n.canonical.x,n.canonical.y)._rotate(i.transform.angle),s=new e.P(a.canonical.x,a.canonical.y)._rotate(i.transform.angle);return n.overscaledZ-a.overscaledZ||s.y-o.y||s.x-o.x})).map((function(e){return e.tileID.key})):n.map((function(e){return e.tileID})).sort(Vt).map((function(e){return e.key}))}},{key:"hasRenderableParent",value:function(e){var t=this.findLoadedParent(e,0);return!!t&&this._isIdRenderable(t.tileID.key)}},{key:"_isIdRenderable",value:function(e,t,r){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(t||!this._tiles[e].holdingForFade())&&(r||!this._shadowCasterTiles[e])}},{key:"reload",value:function(){if(this._paused)this._shouldReloadOnResume=!0;else for(var e in this._cache.reset(),this._tiles)"errored"!==this._tiles[e].state&&this._reloadTile(+e,"reloading")}},{key:"_reloadTile",value:function(e,t){var r=this._tiles[e];r&&("loading"!==r.state&&(r.state=t),this._loadTile(r,this._tileLoaded.bind(this,r,e,t)))}},{key:"_tileLoaded",value:function(t,r,i,n){if(n)if(t.state="errored",404!==n.status)this._source.fire(new e.t(n,{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){var a=this.map.painter.terrain;this.update(this.transform,a.getScaledDemTileSize(),!0),a.resetTileLookupCache(this.id)}else this.update(this.transform)}else t.timeAdded=e.q.now(),"expired"===i&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(r,t),"raster-dem"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),this._source.fire(new e.x("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id}))}},{key:"_backfillDEM",value:function(e){for(var t=this.getRenderableIds(),r=0;r1||(Math.abs(r)>1&&(1===Math.abs(r+n)?r+=n:1===Math.abs(r-n)&&(r-=n)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,r,i),e.neighboringTiles&&e.neighboringTiles[a]&&(e.neighboringTiles[a].backfilled=!0)))}}}},{key:"getTile",value:function(e){return this.getTileByID(e.key)}},{key:"getTileByID",value:function(e){return this._tiles[e]}},{key:"_retainLoadedChildren",value:function(e,t,r,i){for(var n in this._tiles){var a=this._tiles[n];if(!(i[n]||!a.hasData()||a.tileID.overscaledZ<=t||a.tileID.overscaledZ>r)){for(var o=a.tileID;a&&a.tileID.overscaledZ>t+1;){var s=a.tileID.scaledTo(a.tileID.overscaledZ-1);(a=this._tiles[s.key])&&a.hasData()&&(o=s)}for(var l=o;l.overscaledZ>t;)if(e[(l=l.scaledTo(l.overscaledZ-1)).key]){i[o.key]=o;break}}}}},{key:"findLoadedParent",value:function(e,t){if(e.key in this._loadedParentTiles){var r=this._loadedParentTiles[e.key];return r&&r.tileID.overscaledZ>=t?r:null}for(var i=e.overscaledZ-1;i>=t;i--){var n=e.scaledTo(i),a=this._getLoadedTile(n);if(a)return a}}},{key:"_getLoadedTile",value:function(e){var t=this._tiles[e.key];return t&&t.hasData()?t:this._cache.getByKey(this._source.reparseOverscaled?e.wrapped().key:e.canonical.key)}},{key:"updateCacheSize",value:function(e,t){t=t||this._source.tileSize;var r=Math.ceil(e.width/t)+1,i=Math.ceil(e.height/t)+1,n=Math.floor(r*i*5),a="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,n):n,o="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,a):a;this._cache.setMaxSize(o)}},{key:"handleWrapJump",value:function(e){var t=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);if(this._prevLng=e,t){var r={};for(var i in this._tiles){var n=this._tiles[i];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+t),r[n.tileID.key]=n}for(var a in this._tiles=r,this._timers)clearTimeout(this._timers[a]),delete this._timers[a];for(var o in this._tiles)this._setTileReloadTimer(+o,this._tiles[o])}}},{key:"update",value:function(t,i,n,a){if(this.transform=t,this._sourceLoaded&&!this._paused&&!this.transform.freezeTileCoverage&&(!this.usedForTerrain||n)){this.updateCacheSize(t,i),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={};var o,s="batched-model"===this._source.type,l=this._source.maxzoom,u=this.map&&this.map.painter?this.map.painter._terrain:null;if(u&&u.sourceCache===this&&u.attenuationRange()){var c=u.attenuationRange()[0],h=Math.floor(c)-Math.log2(u.getDemUpscale());l>h&&(l=h)}if(this.used||this.usedForTerrain){if(this._source.tileID)o=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((function(t){return new e.aA(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y)}));else if(0!==this.tileCoverLift){var f=t.clone();f.tileCoverLift=this.tileCoverLift,o=f.coveringTiles({tileSize:i||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:l,roundZoom:this._source.roundZoom&&!n,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:s}),this._source.minzoom<=1&&"globe"===t.projection.name&&(o.push(new e.aA(1,0,1,0,0)),o.push(new e.aA(1,0,1,1,0)),o.push(new e.aA(1,0,1,0,1)),o.push(new e.aA(1,0,1,1,1)))}else if(o=t.coveringTiles({tileSize:i||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:l,roundZoom:this._source.roundZoom&&!n,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:s}),this._source.hasTile){var d=this._source.hasTile.bind(this._source);o=o.filter((function(e){return d(e)}))}}else o=[];if(o.length>0&&this.castsShadows&&a&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!Ut(this._source.type)){var p=t.coveringZoomLevel({tileSize:i||this._source.tileSize,roundZoom:this._source.roundZoom&&!n}),m=Math.min(p,this._source.maxzoom);if(s){var v=t.extendTileCover(o,m);for(var _ of v)o.push(_)}else{var g=t.extendTileCover(o,m,a);for(var y of g)this._shadowCasterTiles[y.key]=!0,o.push(y)}}var x=this._updateRetainedTiles(o);if(Ut(this._source.type)&&0!==o.length){var b={},w={},k=Object.keys(x);for(var T of k){var S=x[T],E=this._tiles[T];if(E&&!(E.fadeEndTime&&E.fadeEndTime<=e.q.now())){var M=this.findLoadedParent(S,Math.max(S.overscaledZ-r.maxOverzooming,this._source.minzoom));M&&(this._addTile(M.tileID),b[M.tileID.key]=M.tileID),w[T]=S}}var A=o[o.length-1].overscaledZ;for(var I in this._tiles){var C=this._tiles[I];if(!x[I]&&C.hasData())for(var P=C.tileID;P.overscaledZ>A;){P=P.scaledTo(P.overscaledZ-1);var z=this._tiles[P.key];if(z&&z.hasData()&&w[P.key]){x[I]=C.tileID;break}}}for(var D in b)x[D]||(this._coveredTiles[D]=!0,x[D]=b[D])}for(var R in x)this._tiles[R].clearFadeHold();var L=e.bf(this._tiles,x);for(var O of L){var F=this._tiles[O];F.hasSymbolBuckets&&!F.holdingForFade()?F.setHoldDuration(this.map._fadeDuration):F.hasSymbolBuckets&&!F.symbolFadeFinished()||this._removeTile(+O)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}}},{key:"releaseSymbolFadeTiles",value:function(){for(var e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(+e)}},{key:"_updateRetainedTiles",value:function(e){var t={};if(0===e.length)return t;var i={},n=e.reduce((function(e,t){return Math.min(e,t.overscaledZ)}),1/0),a=e[0].overscaledZ,o=Math.max(a-r.maxOverzooming,this._source.minzoom),s=Math.max(a+r.maxUnderzooming,this._source.minzoom),l={};for(var u of e){var c=this._addTile(u);t[u.key]=u,c.hasData()||n=this._source.maxzoom){var d=h.children(this._source.maxzoom)[0],p=this.getTile(d);if(p&&p.hasData()){t[d.key]=d;continue}}else{var m=h.children(this._source.maxzoom);if(t[m[0].key]&&t[m[1].key]&&t[m[2].key]&&t[m[3].key])continue}for(var v=f.wasRequested(),_=h.overscaledZ-1;_>=o;--_){var g=h.scaledTo(_);if(i[g.key])break;if(i[g.key]=!0,!(f=this.getTile(g))&&v&&(f=this._addTile(g)),f&&(t[g.key]=g,v=f.wasRequested(),f.hasData()))break}}}return t}},{key:"_updateLoadedParentTileCache",value:function(){for(var e in this._loadedParentTiles={},this._tiles){for(var t=[],r=void 0,i=this._tiles[e].tileID;i.overscaledZ>0;){if(i.key in this._loadedParentTiles){r=this._loadedParentTiles[i.key];break}t.push(i.key);var n=i.scaledTo(i.overscaledZ-1);if(r=this._getLoadedTile(n))break;i=n}for(var a of t)this._loadedParentTiles[a]=r}}},{key:"_addTile",value:function(t){var r=this._tiles[t.key];if(r)return!0!==r.isExtraShadowCaster||!!this._shadowCasterTiles[t.key]||this._reloadTile(t.key,"reloading"),r;(r=this._cache.getAndRemove(t))&&(this._setTileReloadTimer(t.key,r),r.tileID=t,this._state.initializeTileState(r,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,r)));var i=Boolean(r);if(!i){var n=this.map?this.map.painter:null,a=this._source.tileSize*t.overscaleFactor();r="raster-array"===this._source.type?new Ot(t,a,this.transform.tileZoom,n,this._isRaster):new Lt(t,a,this.transform.tileZoom,n,this._isRaster),this._loadTile(r,this._tileLoaded.bind(this,r,t.key,r.state))}return r?(r.uses++,this._tiles[t.key]=r,i||this._source.fire(new e.x("dataloading",{tile:r,coord:r.tileID,dataType:"source"})),r):null}},{key:"_setTileReloadTimer",value:function(e,t){var r=this;e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);var i=t.getExpiryTimeout();i&&(this._timers[e]=setTimeout((function(){r._reloadTile(e,"expired"),delete r._timers[e]}),i))}},{key:"_removeTile",value:function(e){var 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))))}},{key:"clearTiles",value:function(){for(var e in this._shouldReloadOnResume=!1,this._paused=!1,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)}},{key:"tilesIn",value:function(t,r,i){var n=[],a=this.transform;if(!a)return n;var o="globe"===a.projection.name,s=e.am(a.center.lng);for(var l in this._tiles){var u=this._tiles[l];if(i&&u.clearQueryDebugViz(),!u.holdingForFade()){var c=void 0;if(o){var h=u.tileID.canonical;if(0===h.z){var f=[Math.abs(e.ap.apply(e,[s].concat(d(jt(h,-1))))-s),Math.abs(e.ap.apply(e,[s].concat(d(jt(h,1))))-s)];c=[0,2*f.indexOf(Math.min.apply(Math,f))-1]}else{var p=[Math.abs(e.ap.apply(e,[s].concat(d(jt(h,-1))))-s),Math.abs(e.ap.apply(e,[s].concat(d(jt(h,0))))-s),Math.abs(e.ap.apply(e,[s].concat(d(jt(h,1))))-s)];c=[p.indexOf(Math.min.apply(Math,p))-1]}}else c=[0];for(var m of c){var v=t.containsTile(u,a,r,m);v&&n.push(v)}}}return n}},{key:"getShadowCasterCoordinates",value:function(){return this._getRenderableCoordinates(!1,!0)}},{key:"getVisibleCoordinates",value:function(e){return this._getRenderableCoordinates(e)}},{key:"_getRenderableCoordinates",value:function(e,t){var r=this,i=this.getRenderableIds(e,t).map((function(e){return r._tiles[e].tileID})),n="globe"===this.transform.projection.name;for(var a of i)a.projMatrix=this.transform.calculateProjMatrix(a.toUnwrapped()),a.expandedProjMatrix=n?this.transform.calculateProjMatrix(a.toUnwrapped(),!1,!0):a.projMatrix;return i}},{key:"sortCoordinatesByDistance",value:function(e){var t=e.slice(),r=this.transform._camera.position,i=this.transform._camera.forward(),n={};for(var a of t){var o=1/(1<=e.q.now())return!0}return!1}},{key:"setFeatureState",value:function(e,t,r){this._state.updateState(e=e||"_geojsonTileLayer",t,r)}},{key:"removeFeatureState",value:function(e,t,r){this._state.removeFeatureState(e=e||"_geojsonTileLayer",t,r)}},{key:"getFeatureState",value:function(e,t){return this._state.getState(e=e||"_geojsonTileLayer",t)}},{key:"setDependencies",value:function(e,t,r){var i=this._tiles[e];i&&i.setDependencies(t,r)}},{key:"reloadTilesForDependencies",value:function(e,t){for(var r in this._tiles)this._tiles[r].hasDependency(e,t)&&this._reloadTile(+r,"reloading");this._cache.filter((function(r){return!r.hasDependency(e,t)}))}},{key:"_preloadTiles",value:function(t,r){var i=this;if(this._sourceLoaded){var n=new Map,a=Array.isArray(t)?t:[t],o=this.map.painter.terrain,s=this.usedForTerrain&&o?o.getScaledDemTileSize():this._source.tileSize;for(var l of a){var u=l.coveringTiles({tileSize:s,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(var c of u)n.set(c.key,c);this.usedForTerrain&&l.updateElevation(!1)}var h=Array.from(n.values());e.bg(h,(function(e,t){var r=new Lt(e,i._source.tileSize*e.overscaleFactor(),i.transform.tileZoom,i.map.painter,i._isRaster);i._loadTile(r,(function(e){"raster-dem"===i._source.type&&r.dem&&i._backfillDEM(r),t(e,r)}))}),r)}else{var f=function(){i._sourceLoaded&&(i._source.off("data",f),i._preloadTiles(t,r))};this._source.on("data",f)}}}])})(e.E);function Vt(e,t){var r=Math.abs(2*e.wrap)-+(e.wrap<0),i=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||i-r||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function Ut(e){return"raster"===e||"image"===e||"video"===e||"custom"===e}function jt(e,t){var r=1<0:"model"===r.type&&(i=!r.isHidden(e)&&r.paint.get("model-opacity")>0),this.layersGotHidden=this.layersGotHidden||!i&&t.visible,t.visible=i}}},{key:"updateZOffset",value:function(e,t){for(var r of(this.currentBuildingBuckets=[],this.layers)){var i=r.layer,n=this.style.getLayerSourceCache(i),a=1;"fill-extrusion"===i.type&&(a=r.visible?i.paint.get("fill-extrusion-vertical-scale"):0);var o=n?n.getTile(t):null;if(!o&&n&&t.canonical.z>n.getSource().minzoom)for(var s=t.scaledTo(Math.min(n.getSource().maxzoom,t.overscaledZ-1));s.overscaledZ>=n.getSource().minzoom&&(!(o=n.getTile(s))&&0!==s.overscaledZ);)s=s.scaledTo(s.overscaledZ-1);this.currentBuildingBuckets.push({bucket:o?o.getBucket(i):null,tileID:o?o.tileID:t,verticalScale:a})}e.hasAnyZOffset=!1;for(var l=!1,u=0;u0?(n-o)/s:0;return this.points[a].mult(1-l).add(this.points[r].mult(l))}}])})(),tr=(function(){return m((function e(t,r,i){p(this,e);var n=this.boxCells=[],a=this.circleCells=[];this.xCellCount=Math.ceil(t/i),this.yCellCount=Math.ceil(r/i);for(var o=0;othis.width||i<0||t>this.height)return!n&&[];var o=[];if(e<=0&&t<=0&&this.width<=r&&this.height<=i){if(n)return!0;for(var s=0;s0:o}},{key:"_queryCircle",value:function(e,t,r,i,n){var a=e-r,o=e+r,s=t-r,l=t+r;if(o<0||a>this.width||l<0||s>this.height)return!i&&[];var u=[];return this._forEachCell(a,s,o,l,this._queryCellCircle,u,{hitTest:i,circle:{x:e,y:t,radius:r},seenUids:{box:{},circle:{}}},n),i?u.length>0:u}},{key:"query",value:function(e,t,r,i,n){return this._query(e,t,r,i,!1,n)}},{key:"hitTest",value:function(e,t,r,i,n){return this._query(e,t,r,i,!0,n)}},{key:"hitTestCircle",value:function(e,t,r,i){return this._queryCircle(e,t,r,!0,i)}},{key:"_queryCell",value:function(e,t,r,i,n,a,o,s){var l=o.seenUids,u=this.boxCells[n];if(null!==u){var c=this.bboxes;for(var h of u)if(!l.box[h]){l.box[h]=!0;var f=4*h;if(e<=c[f+2]&&t<=c[f+3]&&r>=c[f+0]&&i>=c[f+1]&&(!s||s(this.boxKeys[h]))){if(o.hitTest)return a.push(!0),!0;a.push({key:this.boxKeys[h],x1:c[f],y1:c[f+1],x2:c[f+2],y2:c[f+3]})}}}var d=this.circleCells[n];if(null!==d){var p=this.circles;for(var m of d)if(!l.circle[m]){l.circle[m]=!0;var v=3*m;if(this._circleAndRectCollide(p[v],p[v+1],p[v+2],e,t,r,i)&&(!s||s(this.circleKeys[m]))){if(o.hitTest)return a.push(!0),!0;var _=p[v],g=p[v+1],y=p[v+2];a.push({key:this.circleKeys[m],x1:_-y,y1:g-y,x2:_+y,y2:g+y})}}}}},{key:"_queryCellCircle",value:function(e,t,r,i,n,a,o,s){var l=o.circle,u=o.seenUids,c=this.boxCells[n];if(null!==c){var h=this.bboxes;for(var f of c)if(!u.box[f]){u.box[f]=!0;var d=4*f;if(this._circleAndRectCollide(l.x,l.y,l.radius,h[d+0],h[d+1],h[d+2],h[d+3])&&(!s||s(this.boxKeys[f])))return a.push(!0),!0}}var p=this.circleCells[n];if(null!==p){var m=this.circles;for(var v of p)if(!u.circle[v]){u.circle[v]=!0;var _=3*v;if(this._circlesCollide(m[_],m[_+1],m[_+2],l.x,l.y,l.radius)&&(!s||s(this.circleKeys[v])))return a.push(!0),!0}}}},{key:"_forEachCell",value:function(e,t,r,i,n,a,o,s){for(var l=this._convertToXCellCoord(e),u=this._convertToYCellCoord(t),c=this._convertToXCellCoord(r),h=this._convertToYCellCoord(i),f=l;f<=c;f++)for(var d=u;d<=h;d++)if(n.call(this,e,t,r,i,this.xCellCount*d+f,a,o,s))return}},{key:"_convertToXCellCoord",value:function(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}},{key:"_convertToYCellCoord",value:function(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}},{key:"_circlesCollide",value:function(e,t,r,i,n,a){var o=i-e,s=n-t,l=r+a;return l*l>o*o+s*s}},{key:"_circleAndRectCollide",value:function(e,t,r,i,n,a,o){var s=(a-i)/2,l=Math.abs(e-(i+s));if(l>s+r)return!1;var u=(o-n)/2,c=Math.abs(t-(n+u));if(c>u+r)return!1;if(l<=s||c<=u)return!0;var h=l-s,f=c-u;return h*h+f*f<=r*r}}])})(),rr=0,ir=1,nr=2,ar=Math.tan(85*Math.PI/180);function or(t,r,i,n,a,o,s){var l=e.a6.mat4.create();if(i)if("globe"===o.name){var u=e.bj(a,r);e.a6.mat4.multiply(l,l,u)}else{var c=e.a6.mat2.invert([],s);l[0]=c[0],l[1]=c[1],l[4]=c[2],l[5]=c[3],n||e.a6.mat4.rotateZ(l,l,a.angle)}else e.a6.mat4.multiply(l,a.labelPlaneMatrix,t);return l}function sr(e,t,r,i,n,a,o){var s=or(e,t,r,i,n,a,o);return"globe"===a.name&&r||(s[2]=s[6]=s[10]=s[14]=0),s}function lr(t,r,i,n,a,o,s){if(i){if("globe"===o.name){var l=or(t,r,i,n,a,o,s);return e.a6.mat4.invert(l,l),e.a6.mat4.multiply(l,t,l),l}var u=e.a6.mat4.clone(t),c=e.a6.mat4.identity([]);return c[0]=s[0],c[1]=s[1],c[4]=s[2],c[5]=s[3],e.a6.mat4.multiply(u,u,c),n||e.a6.mat4.rotateZ(u,u,-a.angle),u}return a.glCoordMatrix}function ur(t,r,i,n){var a=[t,r,i,1];i?e.a6.vec4.transformMat4(a,a,n):xr(a,a,n);var o=a[3];return a[0]/=o,a[1]/=o,a[2]/=o,a}function cr(e,t){return Math.min(.5+e/t*.5,1.5)}function hr(e,t){var r=e[0]/e[3],i=e[1]/e[3];return r>=-t[0]&&r<=t[0]&&i>=-t[1]&&i<=t[1]}function fr(t,r,i,n,a,o,s,l,u,c){var h=i.transform,f=n?t.textSizeData:t.iconSizeData,d=e.bk(f,i.transform.zoom),p="globe"===h.projection.name,m=[256/i.width*2+1,256/i.height*2+1],v=n?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;v.clear();var _=null;p&&(_=n?t.text.globeExtVertexArray:t.icon.globeExtVertexArray);for(var g,y=t.lineVertexArray,b=n?t.text.placedSymbolArray:t.icon.placedSymbolArray,w=i.transform.width/i.transform.height,k=!1,T=0;TMath.abs(i)?{useVertical:!0}:t===e.bl.vertical?n>0?{needsFlipping:!0}:null:r!==rr&&(function(e,t){return 0===e||Math.abs(t/e)>ar})(i,n)?r===ir?{needsFlipping:!0}:null:i<0?{needsFlipping:!0}:null}function mr(t,r,i,n,a,o,s,l,u,c,h,f,d,p,m,v,_,g,y){var b=r/24,w=t.lineOffsetX*b,k=t.lineOffsetY*b,T=t.lineStartIndex,S=t.glyphStartIndex,E=t.numGlyphs,M=t.segment,A=t.writingMode,I=t.flipState,C=T+t.lineLength,P=function(t){if(h){var r=x(t.up,3),i=r[0],n=r[1],a=r[2],o=c.length;e.bn(h,o+0,i,n,a),e.bn(h,o+1,i,n,a),e.bn(h,o+2,i,n,a),e.bn(h,o+3,i,n,a)}var s=x(t.point,3),l=s[0],u=s[1],f=s[2];e.bo(c,l,u,f,t.angle)};if(E>1){var z=dr(b,l,w,k,i,f,d,t,u,o,p,v,!1,_,g,y);if(!z)return{notEnoughRoom:!0};if(n&&!i){var D,R,L,O,F=x(z.first.point,3),B=F[0],N=F[1],V=F[2],U=x(z.last.point,3),j=U[0],G=U[1],q=U[2];D=ur(B,N,V,s),B=(R=x(D,2))[0],N=R[1],L=ur(j,G,q,s);var Z=pr(A,I,((j=(O=x(L,2))[0])-B)*m,(G=O[1])-N);if(t.flipState=Z&&Z.needsFlipping?ir:nr,Z)return Z}P(z.first);for(var $=S+1;$0?J:_r(d,Y,W,1,a,void 0,_,g.canonical),Q=pr(A,I,(K[0]-W[0])*m,K[1]-W[1]);if(t.flipState=Q&&Q.needsFlipping?ir:nr,Q)return Q}var ee=gr(b*l.getoffsetX(S),w,k,i,f,d,M,T,C,u,o,p,v,!1,!1,_,g,y);if(!ee)return{notEnoughRoom:!0};P(ee)}return{}}function vr(e,t,r,i,n){var a=i.projectTilePoint(e.x,e.y,t),o=a.x,s=a.y,l=a.z;if(!n)return ur(o,s,l,r);var u=n(e),c=x(u,3);return ur(o+c[0],s+c[1],l+c[2],r)}function _r(t,r,i,n,a,o,s,l){var u=vr(t.sub(r)._unit()._add(t),l,a,s,o);return e.a6.vec3.sub(u,i,u),e.a6.vec3.normalize(u,u),e.a6.vec3.scaleAndAdd(u,i,u,n)}function gr(t,r,i,n,a,o,s,l,u,c,h,f,d,p,m,v,_,g){var y=n?t-r:t+r,x=y>0?1:-1,b=0;n&&(x*=-1,b=Math.PI),x<0&&(b+=Math.PI);for(var w=l+s+(x>0?0:1)|0,k=a,T=a,S=0,E=0,M=Math.abs(y),A=[],I=[],C=o,P=C,z=function(){return _r(P,C,T,M-S+1,h,d,v,_.canonical)};S+E<=M;){if((w+=x)=u)return null;if(T=k,P=C,A.push(T),p&&I.push(P),C=new e.P(c.getx(w),c.gety(w)),!(k=f[w])){var D=vr(C,_.canonical,h,v,d);k=D[3]>0?f[w]=D:z()}S+=E,E=e.a6.vec3.distance(T,k)}m&&d&&(f[w]&&(k=z(),E=e.a6.vec3.distance(T,k)),f[w]=k);var R=(M-S)/E,L=C.sub(P)._mult(R)._add(P),O=e.a6.vec3.sub([],k,T),F=e.a6.vec3.scaleAndAdd([],T,O,R),B=[0,0,1],N=O[0],V=O[1];if(g&&(0!==(B=v.upVector(_.canonical,L.x,L.y))[0]||0!==B[1]||1!==B[2])){var U=[B[2],0,-B[0]],j=e.a6.vec3.cross([],B,U);e.a6.vec3.normalize(U,U),e.a6.vec3.normalize(j,j),N=e.a6.vec3.dot(O,U),V=e.a6.vec3.dot(O,j)}if(i){var G=e.a6.vec3.cross([],B,O);e.a6.vec3.normalize(G,G),e.a6.vec3.scaleAndAdd(F,F,G,i*x)}var q=b+Math.atan2(V,N);return A.push(F),p&&I.push(L),{point:F,angle:q,path:A,tilePath:I,up:B}}function yr(e,t){var r=t.length,i=r+4*e;t.resize(i),t.float32.fill(-1/0,4*r,4*i)}function xr(e,t,r){var i=t[0],n=t[1];return e[0]=r[0]*i+r[4]*n+r[12],e[1]=r[1]*i+r[5]*n+r[13],e[3]=r[3]*i+r[7]*n+r[15],e}var br=100,wr=(function(){return m((function e(t,r){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new tr(t.width+200,t.height+200,25),n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:new tr(t.width+200,t.height+200,25);p(this,e),this.transform=t,this.grid=i,this.ignoredGrid=n,this.pitchfactor=Math.cos(t._pitch)*t.cameraToCenterDistance,this.screenRightBoundary=t.width+br,this.screenBottomBoundary=t.height+br,this.gridRightBoundary=t.width+200,this.gridBottomBoundary=t.height+200,this.fogState=r}),[{key:"placeCollisionBox",value:function(e,t,r,i,n,a,o,s){var l=r.projectedAnchorX,u=r.projectedAnchorY,c=r.projectedAnchorZ,h=r.elevation,f=r.tileID,d=e.getProjection();if(h&&f){var p=d.upVector(f.canonical,r.tileAnchorX,r.tileAnchorY),m=x(p,3),v=m[0],_=m[1],g=m[2],y=d.upVectorScale(f.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;l+=v*h*y,u+=_*h*y,c+=g*h*y}var b=this.projectAndGetPerspectiveRatio(o,l,u,c,r.tileID,"globe"===d.name||!!h||this.transform.pitch>0,d),w=a*b.perspectiveRatio,k=(r.x1*t+i.x-r.padding)*w+b.point.x,T=(r.y1*t+i.y-r.padding)*w+b.point.y,S=(r.x2*t+i.x+r.padding)*w+b.point.x,E=(r.y2*t+i.y+r.padding)*w+b.point.y,M=b.perspectiveRatio<=.55||b.occluded;return!this.isInsideGrid(k,T,S,E)||!n&&this.grid.hitTest(k,T,S,E,s)||M?{box:[],offscreen:!1,occluded:b.occluded}:{box:[k,T,S,E],offscreen:this.isOffscreen(k,T,S,E),occluded:!1}}},{key:"placeCollisionCircles",value:function(t,r,i,n,a,o,s,l,u,c,h,f,d,p,m){var v=[],_=this.transform.elevation,g=t.getProjection(),y=_?_.getAtTileOffsetFunc(m,this.transform.center.lat,this.transform.worldSize,g):null,b=new e.P(i.tileAnchorX,i.tileAnchorY),w=g.projectTilePoint(b.x,b.y,m.canonical),k=w.x,T=w.y,S=w.z;if(y){var E=y(b),M=x(E,3);k+=M[0],T+=M[1],S+=M[2]}var A="globe"===g.name,I=this.projectAndGetPerspectiveRatio(s,k,T,S,m,A||!!_||this.transform.pitch>0,g),C=I.perspectiveRatio,P=(h?o/C:o*C)/e.br,z=ur(k,T,S,l),D=I.signedDistanceFromCamera>0?dr(P,a,i.lineOffsetX*P,i.lineOffsetY*P,!1,z,b,i,n,l,{},_&&!h?y:null,h&&!!_,g,m,h):null,R=!1,L=!1,O=!0;if(D&&!I.occluded){for(var F=.5*d*C+p,B=new e.P(-100,-100),N=new e.P(this.screenRightBoundary,this.screenBottomBoundary),V=new er,U=D.first,j=D.last,G=U.path.length,q=[],Z=G-1;Z>=1;Z--)q.push(U.path[Z]);for(var $=1;$0){var X=1/0,Y=-1/0,J=1/0,K=-1/0;for(var Q of q)X=Math.min(X,Q[0]),J=Math.min(J,Q[1]),Y=Math.max(Y,Q[0]),K=Math.max(K,Q[1]);Y>=B.x&&X<=N.x&&K>=B.y&&J<=N.y&&(W=[q.map((function(t){return new e.P(t[0],t[1])}))],(XN.x||JN.y)&&(W=e.bp(W,B.x,B.y,N.x,N.y)))}for(var ee of W){V.reset(ee,.25*F);var te;te=V.length<=.5*F?1:Math.ceil(V.paddedLength/H)+1;for(var re=0;re0){if(e.a6.vec4.transformMat4(l,l,t),this.fogState&&a&&"globe"!==s.name){var c=(function(t,r,i,n,a,o){var s=o.calculateFogTileMatrix(a),l=[r,i,n];return e.a6.vec3.transformMat4(l,l,s),$e(t,e.a6.vec3.length(l),o.pitch,o._fov)})(this.fogState,r,i,n,a.toUnwrapped(),this.transform);u=c>.9}}else xr(l,l,t);var h=l[3];return{point:new e.P((l[0]/h+1)/2*this.transform.width+br,(-l[1]/h+1)/2*this.transform.height+br),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(s)/h*.5,1.5),signedDistanceFromCamera:h,occluded:o&&l[2]>h||u}}},{key:"isOffscreen",value:function(e,t,r,i){return r=this.screenRightBoundary||ithis.screenBottomBoundary}},{key:"isInsideGrid",value:function(e,t,r,i){return r>=0&&e=0&&t5&&void 0!==arguments[5]&&arguments[5];p(this,e),this.text=new Er(t?t.text:null,r,i,a),this.icon=new Er(t?t.icon:null,r,n,a),this.clipped=o}),[{key:"isHidden",value:function(){return this.text.isHidden()&&this.icon.isHidden()}}])})(),Ar=m((function e(t,r,i){var n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];p(this,e),this.text=t,this.icon=r,this.skipFade=i,this.clipped=n})),Ir=m((function t(){p(this,t),this.invProjMatrix=e.a6.mat4.create(),this.viewportMatrix=e.a6.mat4.create(),this.circles=[]})),Cr=m((function e(t,r,i,n,a){p(this,e),this.bucketInstanceId=t,this.featureIndex=r,this.sourceLayerIndex=i,this.bucketIndex=n,this.tileID=a})),Pr=(function(){return m((function e(t){p(this,e),this.crossSourceCollisions=t,this.maxGroupID=0,this.collisionGroups={}}),[{key:"get",value:function(e){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[e]){var t=++this.maxGroupID;this.collisionGroups[e]={ID:t,predicate:function(e){return e.collisionGroupID===t}}}return this.collisionGroups[e]}}])})();function zr(t,r,i,n,a){var o=e.by(t),s=-(o.horizontalAlign-.5)*r,l=-(o.verticalAlign-.5)*i,u=e.bx(t,n);return new e.P(s+u[0]*a,l+u[1]*a)}function Dr(t,r,i,n,a){var o=new e.P(t,r);return i&&o._rotate(n?a:-a),o}var Rr=(function(){return m((function e(t,r,i,n,a,o){p(this,e),this.transform=t.clone(),this.projection=t.projection.name,this.collisionIndex=new wr(this.transform,a),this.buildingIndex=o,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=r,this.retainedQueryData={},this.collisionGroups=new Pr(i),this.collisionCircleArrays={},this.prevPlacement=n,n&&(n.prevPlacement=void 0),this.placedOrientations={}}),[{key:"getBucketParts",value:function(t,r,i,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1,o=i.getBucket(r),s=i.latestFeatureIndex;if(o&&s&&r.fqid===o.layerIds[0]){var l=o.layers[0].layout,u=o.layers[0].paint,c=i.collisionBoxArray,h=Math.pow(2,this.transform.zoom-i.tileID.overscaledZ),f=i.tileSize/e.ab,d=i.tileID.toUnwrapped();this.transform.setProjection(o.projection);var p,m,v,_=(p=i.tileID,m=o.getProjection(),v=this.transform,m.name===this.projection?v.calculateProjMatrix(p.toUnwrapped()):kr(v,m,p)),g="map"===l.get("text-pitch-alignment"),y="map"===l.get("text-rotation-alignment");r.compileFilter(r.options);var x=r.dynamicFilter(),b=r.dynamicFilterNeedsFeature(),w=this.transform.calculatePixelsToTileUnitsMatrix(i),k=sr(_,i.tileID.canonical,g,y,this.transform,o.getProjection(),w),T=null;if(g){var S=lr(_,i.tileID.canonical,g,y,this.transform,o.getProjection(),w);T=e.a6.mat4.multiply([],this.transform.labelPlaneMatrix,S)}var E=null;x&&i.latestFeatureIndex&&(E={unwrappedTileID:d,dynamicFilter:x,dynamicFilterNeedsFeature:b}),this.retainedQueryData[o.bucketInstanceId]=new Cr(o.bucketInstanceId,s,o.sourceLayerIndex,o.index,i.tileID);var M=o.layers[0].layout.get("text-size-scale-range"),A=e.ap(a,M[0],M[1]),I=o.layers[0].layout.get("icon-size-scale-range"),C=e.ap(a,I[0],I[1]),P={bucket:o,layout:l,paint:u,posMatrix:_,textLabelPlaneMatrix:k,labelToScreenMatrix:T,clippingData:E,scale:h,textPixelRatio:f,holdingForFade:i.holdingForFade(),collisionBoxArray:c,partiallyEvaluatedTextSize:e.bk(o.textSizeData,this.transform.zoom,A),partiallyEvaluatedIconSize:e.bk(o.iconSizeData,this.transform.zoom,C),collisionGroup:this.collisionGroups.get(o.sourceID),latestFeatureIndex:i.latestFeatureIndex};if(n)for(var z of o.sortKeyRanges){var D=z.sortKey,R=z.symbolInstanceStart,L=z.symbolInstanceEnd;t.push({sortKey:D,symbolInstanceStart:R,symbolInstanceEnd:L,parameters:P})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:o.symbolInstances.length,parameters:P})}}},{key:"attemptAnchorPlacement",value:function(e,t,r,i,n,a,o,s,l,u,c,h,f,d,p,m,v,_){var g,y=h.textOffset0,x=h.textOffset1,b=h.crossTileID,w=[y,x],k=zr(e,r,i,w,n),T=this.collisionIndex.placeCollisionBox(d,n,t,Dr(k.x,k.y,a,o,this.transform.angle),c,s,l,u.predicate);if(m){var S=d.getSymbolInstanceIconSize(_,this.transform.zoom,h.placedIconSymbolIndex);if(0===this.collisionIndex.placeCollisionBox(d,S,m,Dr(k.x,k.y,a,o,this.transform.angle),c,s,l,u.predicate).box.length)return}if(T.box.length>0)return this.prevPlacement&&this.prevPlacement.variableOffsets[b]&&this.prevPlacement.placements[b]&&this.prevPlacement.placements[b].text&&(g=this.prevPlacement.variableOffsets[b].anchor),this.variableOffsets[b]={textOffset:w,width:r,height:i,anchor:e,textScale:n,prevAnchor:g},this.markUsedJustification(d,e,h,p),d.allowVerticalPlacement&&(this.markUsedOrientation(d,p,h),this.placedOrientations[b]=p),{shift:k,placedGlyphBoxes:T}}},{key:"placeLayerBucketPart",value:function(t,r,i,n){var a=this,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1,s=t.parameters,l=s.bucket,u=s.layout,c=s.paint,h=s.posMatrix,f=s.textLabelPlaneMatrix,d=s.labelToScreenMatrix,p=s.clippingData,m=s.textPixelRatio,v=s.holdingForFade,_=s.collisionBoxArray,g=s.partiallyEvaluatedTextSize,y=s.partiallyEvaluatedIconSize,x=s.collisionGroup,b=s.latestFeatureIndex,w=u.get("text-optional"),k=u.get("icon-optional"),T=u.get("text-allow-overlap"),S=u.get("icon-allow-overlap"),E="map"===u.get("text-rotation-alignment"),M="map"===u.get("text-pitch-alignment"),A=u.get("symbol-z-elevate"),I=c.get("symbol-z-offset"),C="sea"===u.get("symbol-elevation-reference"),P=u.get("text-size-scale-range"),z=u.get("icon-size-scale-range"),D=e.ap(o,P[0],P[1]),R=e.ap(o,z[0],z[1]);this.transform.setProjection(l.projection);var L=T&&(S||!l.hasIconData()||k),O=S&&(T||!l.hasTextData()||w),F=!I.isConstant();!l.collisionArrays&&_&&l.deserializeCollisionBoxes(_),i&&n&&l.updateCollisionDebugBuffers(this.transform.zoom,_,D,R);var B=function(t,n,s){var c=t.crossTileID,_=t.numVerticalGlyphVertices,A=null;if(p&&p.dynamicFilterNeedsFeature||F){var P=a.retainedQueryData[l.bucketInstanceId];A=b.loadFeature({featureIndex:t.featureIndex,bucketIndex:P.bucketIndex,sourceLayerIndex:P.sourceLayerIndex,layoutVertexArrayOffset:0})}if(p&&!(0,p.dynamicFilter)({zoom:a.transform.zoom,pitch:a.transform.pitch},A,a.retainedQueryData[l.bucketInstanceId].tileID.canonical,new e.P(t.tileAnchorX,t.tileAnchorY),a.transform.calculateDistanceTileData(p.unwrappedTileID)))return a.placements[c]=new Ar(!1,!1,!1,!0),void r.add(c);var z=I.evaluate(A,{});if(!r.has(c))if(v)a.placements[c]=new Ar(!1,!1,!1);else{var D,R=!1,B=!1,N=!0,V=!1,U=!1,j=null,G={box:null,offscreen:null,occluded:null},q={box:null,offscreen:null,occluded:null},Z=null,$=null,H=0,W=0,X=0;s.textFeatureIndex?H=s.textFeatureIndex:t.useRuntimeCollisionCircles&&(H=t.featureIndex),s.verticalTextFeatureIndex&&(W=s.verticalTextFeatureIndex);var Y=function(e){e.tileID=a.retainedQueryData[l.bucketInstanceId].tileID;var r=a.transform.elevation;e.elevation=C?z:z+(r?r.getAtTileOffset(e.tileID,e.tileAnchorX,e.tileAnchorY):0),e.elevation+=t.zOffset},J=s.textBox;if(J){Y(J);var K=function(r){var i=e.bl.horizontal;if(l.allowVerticalPlacement&&!r&&a.prevPlacement){var n=a.prevPlacement.placedOrientations[c];n&&(a.placedOrientations[c]=n,i=n,a.markUsedOrientation(l,i,t))}return i},Q=function(t,r){if(l.allowVerticalPlacement&&_>0&&s.verticalTextBox){for(var i of l.writingModes)if(i===e.bl.vertical?(G=r(),q=G):G=t(),G&&G.box&&G.box.length)break}else G=t()};if(u.get("text-variable-anchor")){var ee=u.get("text-variable-anchor");if(a.prevPlacement&&a.prevPlacement.variableOffsets[c]){var te=a.prevPlacement.variableOffsets[c];ee.indexOf(te.anchor)>0&&(ee=ee.filter((function(e){return e!==te.anchor})),ee.unshift(te.anchor))}var re=function(e,r,i){var o=l.getSymbolInstanceTextSize(g,t,a.transform.zoom,n),s=(e.x2-e.x1)*o+2*e.padding,u=(e.y2-e.y1)*o+2*e.padding,c=t.hasIconTextFit&&!S?r:null;c&&Y(c);for(var f={box:[],offscreen:!1,occluded:!1},d=T?2*ee.length:ee.length,p=0;p=ee.length,t,n,l,i,c,g,y);if(v&&((f=v.placedGlyphBoxes)&&f.box&&f.box.length)){R=!0,j=v.shift;break}}return f};Q((function(){return re(J,s.iconBox,e.bl.horizontal)}),(function(){var t=s.verticalTextBox;return t&&Y(t),l.allowVerticalPlacement&&!(G&&G.box&&G.box.length)&&_>0&&t?re(t,s.verticalIconBox,e.bl.vertical):{box:null,offscreen:null,occluded:null}})),G&&(R=G.box,N=G.offscreen,V=G.occluded);var ie=K(!(!G||!G.box));if(!R&&a.prevPlacement){var ne=a.prevPlacement.variableOffsets[c];ne&&(a.variableOffsets[c]=ne,a.markUsedJustification(l,ne.anchor,t,ie))}}else{var ae=function(r,i){var s=l.getSymbolInstanceTextSize(g,t,a.transform.zoom,n,o),u=a.collisionIndex.placeCollisionBox(l,s,r,new e.P(0,0),T,m,h,x.predicate);return u&&u.box&&u.box.length&&(a.markUsedOrientation(l,i,t),a.placedOrientations[c]=i),u};Q((function(){return ae(J,e.bl.horizontal)}),(function(){var t=s.verticalTextBox;return l.allowVerticalPlacement&&_>0&&t?(Y(t),ae(t,e.bl.vertical)):{box:null,offscreen:null,occluded:null}})),K(!!(G&&G.box&&G.box.length))}}if(R=(D=G)&&D.box&&D.box.length>0,N=D&&D.offscreen,V=D&&D.occluded,t.useRuntimeCollisionCircles){var oe=l.text.placedSymbolArray.get(t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex),se=e.bm(l.textSizeData,g,oe),le=u.get("text-padding");Z=a.collisionIndex.placeCollisionCircles(l,T,oe,l.lineVertexArray,l.glyphOffsetArray,se,h,f,d,i,M,x.predicate,t.collisionCircleDiameter*se/e.br,le,a.retainedQueryData[l.bucketInstanceId].tileID),R=T||Z.circles.length>0&&!Z.collisionDetected,N=N&&Z.offscreen,V=Z.occluded}if(s.iconFeatureIndex&&(X=s.iconFeatureIndex),s.iconBox){var ue=function(r){Y(r);var i=t.hasIconTextFit&&j?Dr(j.x,j.y,E,M,a.transform.angle):new e.P(0,0),n=l.getSymbolInstanceIconSize(y,a.transform.zoom,t.placedIconSymbolIndex);return a.collisionIndex.placeCollisionBox(l,n,r,i,S,m,h,x.predicate)};q&&q.box&&q.box.length&&s.verticalIconBox?B=($=ue(s.verticalIconBox)).box.length>0:B=($=ue(s.iconBox)).box.length>0,N=N&&$.offscreen,U=$.occluded}var ce=w||0===t.numHorizontalGlyphVertices&&0===_,he=k||0===t.numIconVertices;if(ce||he?he?ce||(B=B&&R):R=B&&R:B=R=B&&R,R&&D&&D.box&&a.collisionIndex.insertCollisionBox(D.box,u.get("text-ignore-placement"),l.bucketInstanceId,q&&q.box&&W?W:H,x.ID),B&&$&&a.collisionIndex.insertCollisionBox($.box,u.get("icon-ignore-placement"),l.bucketInstanceId,X,x.ID),Z&&(R&&a.collisionIndex.insertCollisionCircles(Z.circles,u.get("text-ignore-placement"),l.bucketInstanceId,H,x.ID),i)){var fe=l.bucketInstanceId,de=a.collisionCircleArrays[fe];void 0===de&&(de=a.collisionCircleArrays[fe]=new Ir);for(var pe=0;pe=0;--V){var U=N[V];B(l.symbolInstances.get(U),U,l.collisionArrays[U])}l.hasAnyZOffset&&e.w(`${l.layerIds[0]} layer symbol-z-elevate: symbols are not sorted by elevation if symbol-z-order is evaluated to viewport-y`)}else if(l.hasAnyZOffset)for(var j=l.getSortedIndexesByZOffset(),G=0;G=0&&(t.text.placedSymbolArray.get(a).crossTileID=h>=0&&a!==h?0:u),o>=0&&(t.text.placedSymbolArray.get(o).crossTileID=h>=0&&o!==h?0:u),s>=0&&(t.text.placedSymbolArray.get(s).crossTileID=h>=0&&s!==h?0:u),l>=0&&(t.text.placedSymbolArray.get(l).crossTileID=h>=0&&l!==h?0:u)}},{key:"markUsedOrientation",value:function(t,r,i){var n=r===e.bl.horizontal||r===e.bl.horizontalOnly?r:0,a=r===e.bl.vertical?r:0,o=i.leftJustifiedTextSymbolIndex,s=i.centerJustifiedTextSymbolIndex,l=i.rightJustifiedTextSymbolIndex,u=i.verticalPlacedTextSymbolIndex,c=t.text.placedSymbolArray;o>=0&&(c.get(o).placedOrientation=n),s>=0&&(c.get(s).placedOrientation=n),l>=0&&(c.get(l).placedOrientation=n),u>=0&&(c.get(u).placedOrientation=a)}},{key:"commit",value:function(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;var t=this.prevPlacement,r=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;var i=t?t.symbolFadeChange(e):1,n=t?t.opacities:{},a=t?t.variableOffsets:{},o=t?t.placedOrientations:{};for(var s in this.placements){var l=this.placements[s],u=n[s];u?(this.opacities[s]=new Mr(u,i,l.text,l.icon,null,l.clipped),r=r||l.text!==u.text.placed||l.icon!==u.icon.placed):(this.opacities[s]=new Mr(null,i,l.text,l.icon,l.skipFade,l.clipped),r=r||l.text||l.icon)}for(var c in n){var h=n[c];if(!this.opacities[c]){var f=new Mr(h,i,!1,!1);f.isHidden()||(this.opacities[c]=f,r=r||h.text.placed||h.icon.placed)}}for(var d in a)this.variableOffsets[d]||!this.opacities[d]||this.opacities[d].isHidden()||(this.variableOffsets[d]=a[d]);for(var p in o)this.placedOrientations[p]||!this.opacities[p]||this.opacities[p].isHidden()||(this.placedOrientations[p]=o[p]);r?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)}},{key:"updateLayerOpacities",value:function(e,t,r,i){var n=new Set;for(var a of t){var o=a.getBucket(e);o&&a.latestFeatureIndex&&e.fqid===o.layerIds[0]&&(this.updateBucketOpacities(o,n,a,a.collisionBoxArray,r,i,a.tileID,e.scope),o.layers[0].layout.get("symbol-z-elevate")&&this.buildingIndex&&(this.buildingIndex.updateZOffset(o,a.tileID),o.updateZOffset()))}}},{key:"updateBucketOpacities",value:function(t,r,i,n,a,o,s,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();var u=t.layers[0].layout,c=t.layers[0].paint,h=!!t.layers[0].dynamicFilter(),f=new Mr(null,0,!1,!1,!0),d=u.get("text-allow-overlap"),p=u.get("icon-allow-overlap"),m=u.get("text-variable-anchor"),v="map"===u.get("text-rotation-alignment"),_="map"===u.get("text-pitch-alignment"),g=c.get("symbol-z-offset"),y="sea"===u.get("symbol-elevation-reference"),x=!g.isConstant(),b=new Mr(null,0,d&&(p||!t.hasIconData()||u.get("icon-optional")),p&&(d||!t.hasTextData()||u.get("text-optional")),!0);!t.collisionArrays&&n&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(n);var w=function(e,t,r){for(var i=0;i0||M>0,B=I>0,N=this.placedOrientations[A],V=N===e.bl.vertical,U=N===e.bl.horizontal||N===e.bl.horizontalOnly;!F&&!B||O.isHidden()||k++;var j=!1;if((F||B)&&o)for(var G of t.activeReplacements)if(!e.bs(G,a,e.bt.Symbol,l)&&!(G.min.x>C||C>G.max.x||G.min.y>P||P>G.max.y)){var q=e.bu(C,P,s.canonical,G.footprintTileId.canonical);if(j=e.bv(q,G.footprint))break}if(F){var Z=j?qr:Gr(O.text);w(t.text,E,V?qr:Z),w(t.text,M,U?qr:Z);var $=O.text.isHidden(),H=S.leftJustifiedTextSymbolIndex,W=S.centerJustifiedTextSymbolIndex,X=S.rightJustifiedTextSymbolIndex,Y=S.verticalPlacedTextSymbolIndex,J=t.text.placedSymbolArray,K=$||V?1:0;H>=0&&(J.get(H).hidden=K),W>=0&&(J.get(W).hidden=K),X>=0&&(J.get(X).hidden=K),Y>=0&&(J.get(Y).hidden=$||U?1:0);var Q=this.variableOffsets[A];Q&&this.markUsedJustification(t,Q.anchor,S,N);var ee=this.placedOrientations[A];ee&&(this.markUsedJustification(t,"left",S,ee),this.markUsedOrientation(t,ee,S))}if(B){var te=j?qr:Gr(O.icon),re=S.placedIconSymbolIndex,ie=S.verticalPlacedIconSymbolIndex,ne=t.icon.placedSymbolArray,ae=O.icon.isHidden()?1:0;re>=0&&(w(t.icon,I,V?qr:te),ne.get(re).hidden=ae),ie>=0&&(w(t.icon,S.numVerticalIconVertices,U?qr:te),ne.get(ie).hidden=ae)}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){var oe=t.collisionArrays[T];if(oe){var se=new e.P(0,0),le=!0;if(oe.textBox||oe.verticalTextBox){if(m){var ue=this.variableOffsets[A];ue?(se=zr(ue.anchor,ue.width,ue.height,ue.textOffset,ue.textScale),v&&se._rotate(_?this.transform.angle:-this.transform.angle)):le=!1}h&&(le=!O.clipped),oe.textBox&&Lr(t.textCollisionBox.collisionVertexArray,O.text.placed,!le||V,R,y,se.x,se.y),oe.verticalTextBox&&Lr(t.textCollisionBox.collisionVertexArray,O.text.placed,!le||U,R,y,se.x,se.y)}var ce=le&&Boolean(!U&&oe.verticalIconBox);oe.iconBox&&Lr(t.iconCollisionBox.collisionVertexArray,O.icon.placed,ce,R,y,S.hasIconTextFit?se.x:0,S.hasIconTextFit?se.y:0),oe.verticalIconBox&&Lr(t.iconCollisionBox.collisionVertexArray,O.icon.placed,!ce,R,y,S.hasIconTextFit?se.x:0,S.hasIconTextFit?se.y:0)}}}if(t.fullyClipped=0===k,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){var he=this.collisionCircleArrays[t.bucketInstanceId];t.placementInvProjMatrix=he.invProjMatrix,t.placementViewportMatrix=he.viewportMatrix,t.collisionCircleArray=he.circles,delete this.collisionCircleArrays[t.bucketInstanceId]}}},{key:"symbolFadeChange",value:function(e){return 0===this.fadeDuration?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}},{key:"zoomAdjustment",value:function(e){return Math.max(0,(this.transform.zoom-e)/1.5)}},{key:"hasTransitions",value:function(e){return this.stale||e-this.lastPlacementChangeTimee}},{key:"setStale",value:function(){this.stale=!0}}])})();function Lr(e,t,r,i,n,a,o){e.emplaceBack(t?1:0,r?1:0,a||0,o||0,i,n?1:0),e.emplaceBack(t?1:0,r?1:0,a||0,o||0,i,n?1:0),e.emplaceBack(t?1:0,r?1:0,a||0,o||0,i,n?1:0),e.emplaceBack(t?1:0,r?1:0,a||0,o||0,i,n?1:0)}var Or=Math.pow(2,25),Fr=Math.pow(2,24),Br=Math.pow(2,17),Nr=Math.pow(2,16),Vr=Math.pow(2,9),Ur=Math.pow(2,8),jr=Math.pow(2,1);function Gr(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;var t=e.placed?1:0,r=Math.floor(127*e.opacity);return r*Or+t*Fr+r*Br+t*Nr+r*Vr+t*Ur+r*jr+t}var qr=0,Zr=(function(){return m((function e(t){p(this,e),this._sortAcrossTiles="viewport-y"!==t.layout.get("symbol-z-order")&&void 0!==t.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs=new Set,this._bucketParts=[]}),[{key:"continuePlacement",value:function(e,t,r,i,n,a){for(var o=this._bucketParts;this._currentTileIndex2};this._currentPlacementIndex>=0;){var u=r[t[this._currentPlacementIndex]],c=this.placement.collisionIndex.transform.zoom;if("symbol"===u.type&&(!u.minzoom||u.minzoom<=c)&&(!u.maxzoom||u.maxzoom>c)){var h=u,f=h.layout.get("symbol-z-elevate"),d=void 0!==h.layout.get("symbol-sort-key").constantOr(1),p=h.layout.get("symbol-z-order"),m="viewport-y"===p||"auto"===p&&!("viewport-y"!==p&&d),v=h.layout.get("text-allow-overlap")||h.layout.get("icon-allow-overlap")||h.layout.get("text-ignore-placement")||h.layout.get("icon-ignore-placement"),_=m&&v,g=this._inProgressLayer=this._inProgressLayer||new Zr(h),y=e.av(u.source,u.scope);if(g.continuePlacement(f||_?n[y]:i[y],this.placement,this._showCollisionBoxes,u,l,a))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}},{key:"commit",value:function(e){return this.placement.commit(e),this.placement}}])})(),Hr=512/e.ab/2,Wr=(function(){return m((function t(r,i,n){p(this,t),this.tileID=r,this.bucketInstanceId=n,this.index=new e.bz(i.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];for(var a=r.canonical.x*e.ab,o=r.canonical.y*e.ab,s=0;se.overscaledZ)for(var s in o){var l=o[s];l.tileID.isChildOf(e)&&l.findMatches(t.symbolInstances,e,n)}else{var u=o[e.scaledTo(Number(a)).key];u&&u.findMatches(t.symbolInstances,e,n)}}for(var c=0;c=1e-15){var a=e.a6.vec3.normalize([],i);e.a6.vec3.scale(n,a,e.a6.vec3.dot(n,a)),r[0]=n[0],r[1]=n[1]}var o=e.a6.vec3.cross([],r,t);if(e.a6.vec3.len(o)<1e-15)return null;var s=Math.atan2(-o[1],o[0]);return si(Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2]),s)}ai.disabled=new ai(!1,ii,ni),ai.backCCW=new ai(!0,ii,ni),ai.backCW=new ai(!0,ii,2304),ai.frontCW=new ai(!0,1028,2304),ai.frontCCW=new ai(!0,1028,ni);var ui=(function(){return m((function e(t,r){p(this,e),this.position=t,this.orientation=r}),[{key:"position",get:function(){return this._position},set:function(t){if(t){var r=t instanceof e.a5?t:new e.a5(t[0],t[1],t[2]);this._renderWorldCopies&&(r.x=e.bB(r.x,0,1)),this._position=r}else this._position=null}},{key:"lookAtPoint",value:function(t,r){if(this.orientation=null,this.position){var i=this.position,n=this._elevation?this._elevation.getAtPointOrZero(e.a5.fromLngLat(t)):0,a=e.a5.fromLngLat(t,n),o=[a.x-i.x,a.y-i.y,a.z-i.z];r||(r=[0,0,1]),r[2]=Math.abs(r[2]),this.orientation=li(o,r)}}},{key:"setPitchBearing",value:function(t,r){this.orientation=si(e.bC(t),e.bC(-r))}}])})(),ci=(function(){function t(r,i){p(this,t),this._transform=e.a6.mat4.identity([]),this.orientation=i,this.position=r}return m(t,[{key:"mercatorPosition",get:function(){var t=this.position;return new e.a5(t[0],t[1],t[2])}},{key:"position",get:function(){var t=e.bD(this._transform,3);return[t[0],t[1],t[2]]},set:function(t){var r;t&&e.bF(this._transform,3,[(r=t)[0],r[1],r[2],1])}},{key:"orientation",get:function(){return this._orientation},set:function(t){this._orientation=t||e.a6.quat.identity([]),t&&oi(this._transform,this._orientation)}},{key:"getPitchBearing",value:function(){var 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])}}},{key:"setPitchBearing",value:function(e,t){this._orientation=si(e,t),oi(this._transform,this._orientation)}},{key:"forward",value:function(){var t=e.bD(this._transform,2);return[-t[0],-t[1],-t[2]]}},{key:"up",value:function(){var t=e.bD(this._transform,1);return[-t[0],-t[1],-t[2]]}},{key:"right",value:function(){var t=e.bD(this._transform,0);return[t[0],t[1],t[2]]}},{key:"getCameraToWorld",value:function(t,r){var i=new Float64Array(16);return e.a6.mat4.invert(i,this.getWorldToCamera(t,r)),i}},{key:"getCameraToWorldMercator",value:function(){return this._transform}},{key:"getWorldToCameraPosition",value:function(t,r,i){var n=this.position;e.a6.vec3.scale(n,n,-t);var a=new Float64Array(16);return e.a6.mat4.fromScaling(a,[i,i,i]),e.a6.mat4.translate(a,a,n),a[10]*=r,a}},{key:"getWorldToCamera",value:function(t,r){var i=new Float64Array(16),n=new Float64Array(4),a=this.position;return e.a6.quat.conjugate(n,this._orientation),e.a6.vec3.scale(a,a,-t),e.a6.mat4.fromQuat(i,n),e.a6.mat4.translate(i,i,a),i[1]*=-1,i[5]*=-1,i[9]*=-1,i[13]*=-1,i[8]*=r,i[9]*=r,i[10]*=r,i[11]*=r,i}},{key:"getCameraToClipPerspective",value:function(t,r,i,n){var a=new Float64Array(16);return e.a6.mat4.perspective(a,t,r,i,n),a}},{key:"getCameraToClipOrthographic",value:function(t,r,i,n,a,o){var s=new Float64Array(16);return e.a6.mat4.ortho(s,t,r,i,n,a,o),s}},{key:"getDistanceToElevation",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=0===t?0:e.bE(t,r?e.aN(this.position[1]):this.position[1]),n=this.forward();return(i-this.position[2])/n[2]}},{key:"clone",value:function(){return new t(d(this.position),d(this.orientation))}}])})(),hi=5,fi=6,di=7,pi=8,mi=9,vi=10,_i=11,gi=(function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(p(this,t),isNaN(e)||e<0||isNaN(r)||r<0||isNaN(i)||i<0||isNaN(n)||n<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=r,this.left=i,this.right=n}return m(t,[{key:"interpolate",value:function(t,r,i){return null!=r.top&&null!=t.top&&(this.top=e.aa(t.top,r.top,i)),null!=r.bottom&&null!=t.bottom&&(this.bottom=e.aa(t.bottom,r.bottom,i)),null!=r.left&&null!=t.left&&(this.left=e.aa(t.left,r.left,i)),null!=r.right&&null!=t.right&&(this.right=e.aa(t.right,r.right,i)),this}},{key:"getCenter",value:function(t,r){var i=e.ap((this.left+t-this.right)/2,0,t),n=e.ap((this.top+r-this.bottom)/2,0,r);return new e.P(i,n)}},{key:"equals",value:function(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}},{key:"clone",value:function(){return new t(this.top,this.bottom,this.left,this.right)}},{key:"toJSON",value:function(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}])})(),yi=function(e,t,r){return(1-r)*e+r*t},xi=function(e){return e*e*e*e*e},bi=(function(){function t(r,i,n,a,o,s,l){p(this,t),this.tileSize=512,this._renderWorldCopies=void 0===o||o,this._minZoom=r||0,this._maxZoom=i||22,this._minPitch=null!=n?n:0,this._maxPitch=null!=a?a:60,this.setProjection(s),this.setMaxBounds(l),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 gi,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new ci,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._pixelsPerMercatorPixel=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._tileCoverLift=0,this.freezeTileCoverage=!1,this._horizonShift=.1,this._orthographicProjectionAtLowPitch=!1}return m(t,[{key:"clone",value:function(){var e=new t(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}},{key:"isOrthographic",get:function(){return"globe"!==this.projection.name&&this._orthographicProjectionAtLowPitch&&this.pitch<15}},{key:"elevation",get:function(){return this._elevation},set:function(e){this._elevation!==e&&(this._elevation=e,this._updateCameraOnTerrain(),this._calcMatrices())}},{key:"depthOcclusionForSymbolsAndCircles",get:function(){return"globe"!==this.projection.name&&!this.isOrthographic}},{key:"updateElevation",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(null==this._seaLevelZoom||r)&&this._updateCameraOnTerrain(),(e||r)&&this._constrainCamera(t),this._calcMatrices()}},{key:"getProjection",value:function(){return e.ar(this.projection,["name","center","parallels"])}},{key:"setProjection",value:function(t){this.projectionOptions=t||{name:"mercator"};var r=this.projection?this.getProjection():void 0;this.projection=e.bM(this.projectionOptions);var i=this.getProjection(),n=!e.bi(r,i);return n&&this._calcMatrices(),this.mercatorFromTransition=!1,n}},{key:"setOrthographicProjectionAtLowPitch",value:function(e){return this._orthographicProjectionAtLowPitch!==e&&(this._orthographicProjectionAtLowPitch=e,this._calcMatrices(),!0)}},{key:"setMercatorFromTransition",value:function(){var t=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=e.bM({name:"mercator"});var r=t!==this.projection.name;return r&&this._calcMatrices(),r}},{key:"minZoom",get:function(){return this._minZoom},set:function(e){this._minZoom!==e&&(this._minZoom=e,this.zoom=Math.max(this.zoom,e))}},{key:"maxZoom",get:function(){return this._maxZoom},set:function(e){this._maxZoom!==e&&(this._maxZoom=e,this.zoom=Math.min(this.zoom,e))}},{key:"minPitch",get:function(){return this._minPitch},set:function(e){this._minPitch!==e&&(this._minPitch=e,this.pitch=Math.max(this.pitch,e))}},{key:"maxPitch",get:function(){return this._maxPitch},set:function(e){this._maxPitch!==e&&(this._maxPitch=e,this.pitch=Math.min(this.pitch,e))}},{key:"renderWorldCopies",get:function(){return this._renderWorldCopies&&!0===this.projection.supportsWorldCopies},set:function(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e}},{key:"worldSize",get:function(){return this.tileSize*this.scale}},{key:"cameraWorldSizeForFog",get:function(){var e=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}},{key:"cameraWorldSize",get:function(){var e=Math.max(this._camera.getDistanceToElevation(this._averageElevation,!0),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}},{key:"pixelsPerMeter",get:function(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}},{key:"cameraPixelsPerMeter",get:function(){return e.bE(1,this.center.lat)*this.cameraWorldSizeForFog}},{key:"centerOffset",get:function(){return this.centerPoint._sub(this.size._div(2))}},{key:"size",get:function(){return new e.P(this.width,this.height)}},{key:"bearing",get:function(){return e.bB(this.rotation,-180,180)},set:function(e){this.rotation=e}},{key:"rotation",get:function(){return-this.angle/Math.PI*180},set:function(t){var r=-t*Math.PI/180;this.angle!==r&&(this._unmodified=!1,this.angle=r,this._calcMatrices(),this.rotationMatrix=e.a6.mat2.create(),e.a6.mat2.rotate(this.rotationMatrix,this.rotationMatrix,this.angle))}},{key:"pitch",get:function(){return this._pitch/Math.PI*180},set:function(t){var r=e.ap(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==r&&(this._unmodified=!1,this._pitch=r,this._calcMatrices())}},{key:"aspect",get:function(){return this.width/this.height}},{key:"fov",get:function(){return this._fov/Math.PI*180},set:function(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=e.bC(t),this._calcMatrices())}},{key:"fovX",get:function(){return this._fov}},{key:"fovY",get:function(){var e=1/Math.tan(.5*this.fovX);return 2*Math.atan(1/this.aspect/e)}},{key:"averageElevation",get:function(){return this._averageElevation},set:function(e){this._averageElevation=e,this._calcFogMatrices(),this._distanceTileDataCache={}}},{key:"zoom",get:function(){return this._zoom},set:function(e){var 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())}},{key:"_setZoom",value:function(e){this._zoom=e,this.scale=this.zoomScale(e),this.tileZoom=Math.floor(e),this.zoomFraction=e-this.tileZoom}},{key:"tileCoverLift",get:function(){return this._tileCoverLift},set:function(e){this._tileCoverLift!==e&&(this._tileCoverLift=e)}},{key:"_updateCameraOnTerrain",value:function(){var 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);var r=this._elevation;t||this._centerAltitude&&this._centerAltitudeValidForExaggeration&&r.exaggeration()&&this._centerAltitudeValidForExaggeration!==r.exaggeration()?(this._centerAltitude=this._centerAltitude/this._centerAltitudeValidForExaggeration*r.exaggeration(),this._centerAltitudeValidForExaggeration=r.exaggeration()):(this._centerAltitude=e||0,this._centerAltitudeValidForExaggeration=r.exaggeration()),this._updateSeaLevelZoom()}},{key:"_updateSeaLevelZoom",value:function(){void 0!==this._centerAltitudeValidForExaggeration&&(this._seaLevelZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize))}},{key:"sampleAverageElevation",value:function(){if(!this._elevation)return 0;for(var t=this._elevation,r=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],i=this.horizonLineFromTop(),n=0,a=0,o=0;o0,_=h.y+10,y=c.wrap-(v?0:1),x=c.wrap+(m?0:1),b=v?h.x-1:p-1,w=m?h.x+1:0;if(a)i[0]<0?(l(f,x,h.z,w,h.y),i[1]<0&&_&&(l(f,d,h.z,h.x,h.y+1),l(f,x,h.z,w,h.y+1)),i[1]>0&&g&&(l(f,d,h.z,h.x,h.y-1),l(f,x,h.z,w,h.y-1))):i[0]>0?(l(f,y,h.z,b,h.y),i[1]<0&&_&&(l(f,d,h.z,h.x,h.y+1),l(f,y,h.z,b,h.y+1)),i[1]>0&&g&&(l(f,d,h.z,h.x,h.y-1),l(f,y,h.z,b,h.y-1))):i[1]<0&&_?l(f,d,h.z,h.x,h.y+1):g&&l(f,d,h.z,h.x,h.y-1);else{var k=c.visibleQuadrants;1&k&&(l(f,y,h.z,b,h.y),g&&(l(f,d,h.z,h.x,h.y-1),l(f,y,h.z,b,h.y-1))),2&k&&(l(f,x,h.z,w,h.y),g&&(l(f,d,h.z,h.x,h.y-1),l(f,x,h.z,w,h.y-1))),4&k&&(l(f,y,h.z,b,h.y),_&&(l(f,d,h.z,h.x,h.y+1),l(f,y,h.z,b,h.y+1))),8&k&&(l(f,x,h.z,w,h.y),_&&(l(f,d,h.z,h.x,h.y+1),l(f,x,h.z,w,h.y+1)))}}}var T=[],S=function(e){n.some((function(t){return e.isChildOf(t)}))||T.push(e)};for(var E of n)S(E);if(n=T.filter((function(e){return!t.some((function(t){return!!(e.overscaledZt.maxzoom&&(i=t.maxzoom);var l,u=this.locationCoordinate(this.center),c=this.center.lat,h=1<=.9)return!0}else if(o&&(l=t.aabb.distanceZ(y)*_),r.projection.isReprojectedInTileSpace&&n<=5){var x=Math.pow(2,t.zoom),k=E(new e.a5((t.x+.5)/x,(t.y+.5)/x));u=k>.85?1:k}if(!s){var T=Math.sqrt(i*i+a*a+l*l),S=(1<>1),b={aabb:s?n.aabb.quadrant(_):e.bS(r,h,n.zoom+1,g,y,n.wrap,n.minZ,n.maxZ,r.projection),zoom:n.zoom+1,x:g,y:y,wrap:n.wrap,fullyVisible:u,tileID:void 0,shouldSplit:void 0,minZ:n.minZ,maxZ:n.maxZ};o&&!d&&(b.tileID=new e.aA(n.zoom+1===C?P:n.zoom+1,n.wrap,n.zoom+1,g,y),D(b)),A.push(b)}else{var w=n.zoom===C?P:n.zoom;if(t.minzoom&&t.minzoom>w)return 0;var k=0;if(!u){var T=x?n.aabb.intersectsPrecise(m):n.aabb.intersectsPreciseFlat(m);if(0===T&&c()){var S=new e.bQ(n.zoom,a,l);T=e.bR(r,h,S,!0).intersectsPrecise(m)}if(0===T)return 0;if(t.calculateQuadrantVisibility)if(m.containsPoint(n.aabb.center))k=15;else for(var E=0;E<4;E++)0!==n.aabb.quadrant(E).intersects(m)&&(k|=1<0;)F();if(this.fogCullDistSq){var B=this.fogCullDistSq,N=this.horizonLineFromTop();I=I.filter((function(i){var n=[0,0,0,1],a=[e.ab,e.ab,0,1],o=r.calculateFogTileMatrix(i.tileID.toUnwrapped());e.a6.vec4.transformMat4(n,n,o),e.a6.vec4.transformMat4(a,a,o);var s=e.a6.vec4.min([],n,a),u=e.a6.vec4.max([],n,a),c=e.bT(s,u);if(0===c)return!0;var h=!1,f=r._elevation;if(f&&c>B&&0!==N){var d,p=r.calculateProjMatrix(i.tileID.toUnwrapped());t.isTerrainDEM||(d=f.getMinMaxForTile(i.tileID)),d||(d={min:T,max:l});var m=e.c4(r.rotation),v=[m[0]*e.ab,m[1]*e.ab,d.max];e.a6.vec3.transformMat4(v,v,p),h=(1-v[1])*r.height*.51&&void 0!==arguments[1]?arguments[1]:this._centerAltitude;return this.projection.pointCoordinate(this,e.x,e.y,t)}},{key:"pointCoordinate3D",value:function(t){if(!this.elevation)return this.pointCoordinate(t);var r=this.projection.pointCoordinate3D(this,t.x,t.y);if(r)return new e.a5(r[0],r[1],r[2]);var i=0,n=this.horizonLineFromTop();if(t.y>n)return this.pointCoordinate(t);for(var a=.02*n,o=t.clone(),s=0;s<10&&n-i>a;s++){o.y=e.aa(i,n,.66);var l=this.projection.pointCoordinate3D(this,o.x,o.y);l?(n=o.y,r=l):i=o.y}return r?new e.a5(r[0],r[1],r[2]):this.pointCoordinate(t)}},{key:"isPointAboveHorizon",value:function(e){return this.projection.isPointAboveHorizon(this,e)}},{key:"isPointOnSurface",value:function(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);var r=this.pointCoordinate(t);return r.y>=0&&r.y<=1}},{key:"_coordinatePoint",value:function(t,r){var i=r&&this.elevation?this.elevation.getAtPointOrZero(t,this._centerAltitude):this._centerAltitude,n=[t.x*this.worldSize,t.y*this.worldSize,i+t.toAltitude(),1];return e.a6.vec4.transformMat4(n,n,this.pixelMatrix),n[3]>0?new e.P(n[0]/n[3],n[1]/n[3]):new e.P(Number.MAX_VALUE,Number.MAX_VALUE)}},{key:"_getBoundsNonRectangular",value:function(){var t=this,r=this._edgeInsets,i=r.top,n=r.left,a=this.height-this._edgeInsets.bottom,o=this.width-this._edgeInsets.right,s=this.pointLocation3D(new e.P(n,i)),l=this.pointLocation3D(new e.P(o,i)),u=this.pointLocation3D(new e.P(o,a)),c=this.pointLocation3D(new e.P(n,a)),h=Math.min(s.lng,l.lng,u.lng,c.lng),f=Math.max(s.lng,l.lng,u.lng,c.lng),d=Math.min(s.lat,l.lat,u.lat,c.lat),p=Math.max(s.lat,l.lat,u.lat,c.lat),m=Math.pow(2,-this.zoom)/16*270,v="globe"===this.projection.name?1:4,_=function(r,i,n,a,o){var s=(r+n)/2,l=(i+a)/2,u=new e.P(s,l),c=t.pointLocation3D(u),g=c.lng,y=c.lat,x=Math.max(0,h-g,d-y,g-f,y-p);h=Math.min(h,g),f=Math.max(f,g),d=Math.min(d,y),p=Math.max(p,y),(om)&&(_(r,i,s,l,o+1),_(s,l,n,a,o+1))};if(_(n,i,o,i,1),_(o,i,o,a,1),_(o,a,n,a,1),_(n,a,n,i,1),"globe"===this.projection.name){var g=e.bW(this),y=x(g,2),b=y[0],w=y[1];b?(p=90,f=180,h=-180):w&&(d=-90,f=180,h=-180)}return new e.as(new e.bL(h,d),new e.bL(f,p))}},{key:"_getBoundsRectangular",value:function(t,r){var i=this._edgeInsets,n=i.top,a=i.left,o=this.height-this._edgeInsets.bottom,s=this.width-this._edgeInsets.right,l=new e.P(a,n),u=new e.P(s,n),c=new e.P(s,o),h=new e.P(a,o),f=this.pointCoordinate(l,t),d=this.pointCoordinate(u,t),p=this.pointCoordinate(c,r),m=this.pointCoordinate(h,r),v=function(e,t){return(t.y-e.y)/(t.x-e.x)};return f.y>1&&d.y>=0?f=new e.a5((1-m.y)/v(m,f)+m.x,1):f.y<0&&d.y<=1&&(f=new e.a5(-m.y/v(m,f)+m.x,0)),d.y>1&&f.y>=0?d=new e.a5((1-p.y)/v(p,d)+p.x,1):d.y<0&&f.y<=1&&(d=new e.a5(-p.y/v(p,d)+p.x,0)),(new e.as).extend(this.coordinateLocation(f)).extend(this.coordinateLocation(d)).extend(this.coordinateLocation(m)).extend(this.coordinateLocation(p))}},{key:"_getBoundsRectangularTerrain",value:function(){var e=this.elevation;if(!e.visibleDemTiles.length||e.isUsingMockSource())return this._getBoundsRectangular(0,0);var t=e.visibleDemTiles.reduce((function(e,t){if(t.dem){var r=t.dem.tree;e.min=Math.min(e.min,r.minimums[0]),e.max=Math.max(e.max,r.maximums[0])}return e}),{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(t.min*e.exaggeration(),t.max*e.exaggeration())}},{key:"getBounds",value:function(){return"mercator"===this.projection.name||"equirectangular"===this.projection.name?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}},{key:"horizonLineFromTop",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))-this.centerOffset.y,r=this.height/2-t*(1-this._horizonShift);return e?Math.max(0,r):r}},{key:"getMaxBounds",value:function(){return this.maxBounds}},{key:"setMaxBounds",value:function(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.maxLng1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=t.key;if((r=n?this._expandedProjMatrixCache:i?this._alignedProjMatrixCache:this._projMatrixCache)[a])return r[a];var o,s=this.calculatePosMatrix(t,this.worldSize);return o=this.projection.isReprojectedInTileSpace?this.mercatorMatrix:n?this.expandedFarZProjMatrix:i?this.alignedProjMatrix:this.projMatrix,e.a6.mat4.multiply(s,o,s),r[a]=new Float32Array(s),r[a]}},{key:"calculatePixelsToTileUnitsMatrix",value:function(t){var r=t.tileID.key,i=this._pixelsToTileUnitsCache;if(i[r])return i[r];var n=e.bX(t,this);return i[r]=n,i[r]}},{key:"customLayerMatrix",value:function(){return this.mercatorMatrix.slice()}},{key:"globeToMercatorMatrix",value:function(){if("globe"===this.projection.name){var t=1/this.worldSize,r=e.a6.mat4.fromScaling([],[t,t,t]);return e.a6.mat4.multiply(r,r,this.globeMatrix),r}}},{key:"recenterOnTerrain",value:function(){if(this._elevation&&"globe"!==this.projection.name){var t=this._elevation;this._updateCameraState();var r=e.bE(1,this._center.lat)*this.worldSize,i=this._computeCameraPosition(r),n=this._camera.forward(),a=e.bE(1,this._center.lat);i[2]/=a,n[2]/=a,e.a6.vec3.normalize(n,n);var o=t.raycast(i,n,t.exaggeration());if(o){var s=e.a6.vec3.scaleAndAdd([],i,n,o),l=new e.a5(s[0],s[1],e.bE(s[2],e.aN(s[1]))),u=(l.z+e.a6.vec3.length([l.x-i[0],l.y-i[1],l.z-i[2]*a]))*this._pixelsPerMercatorPixel;this._seaLevelZoom=this._zoomFromMercatorZ(u),this._centerAltitude=l.toAltitude(),this._center=this.coordinateLocation(l),this._updateZoomFromElevation(),this._constrain(),this._calcMatrices()}}}},{key:"_constrainCamera",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this._elevation){var r=this._elevation,i=e.bE(1,this._center.lat)*this.worldSize,n=this._computeCameraPosition(i),a=r.getAtPointOrZero(c(e.a5,d(n))),o=this.pixelsPerMeter/this.worldSize*a,s=this._minimumHeightOverTerrain(),l=n[2]-o;if(l<=s)if(l<0||t){var u=this.locationCoordinate(this._center,this._centerAltitude),h=[n[0],n[1],u.z-n[2]],f=e.a6.vec3.length(h);h[2]-=(s-l)/this._pixelsPerMercatorPixel;var p=e.a6.vec3.length(h);if(0===p)return;e.a6.vec3.scale(h,h,f/p*this._pixelsPerMercatorPixel),this._camera.position=[n[0],n[1],u.z*this._pixelsPerMercatorPixel-h[2]],this._updateStateFromCamera()}else this._isCameraConstrained=!0}}},{key:"_constrain",value:function(){if(this.center&&this.width&&this.height&&!this._constraining){this._constraining=!0;var t="globe"===this.projection.name||this.mercatorFromTransition;if(this.projection.isReprojectedInTileSpace||t){var r=this.center;return r.lat=e.ap(r.lat,this.minLat,this.maxLat),(this.maxBounds||!this.renderWorldCopies&&!t)&&(r.lng=e.ap(r.lng,this.minLng,this.maxLng)),this.center=r,void(this._constraining=!1)}var i=this._unmodified,n=this.point,a=n.x,o=n.y,s=0,l=a,u=o,c=this.width/2,h=this.height/2,f=this.worldMinY*this.scale,d=this.worldMaxY*this.scale;if(o-hd&&(u=d-h),d-fm&&(l=m-c),m-p=15?1:this.pitch/15))}else a=l;var d=e.a6.mat4.mul([],l,s),p=e.a6.mat4.mul([],a,s);if(this.projection.isReprojectedInTileSpace){var m=this.locationCoordinate(this.center),v=e.a6.mat4.identity([]);e.a6.mat4.translate(v,v,[m.x*this.worldSize,m.y*this.worldSize,0]),e.a6.mat4.multiply(v,v,e.bZ(this)),e.a6.mat4.translate(v,v,[-m.x*this.worldSize,-m.y*this.worldSize,0]),e.a6.mat4.multiply(p,p,v),e.a6.mat4.multiply(d,d,v),this.inverseAdjustmentMatrix=e.b_(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];if(this.mercatorMatrix=e.a6.mat4.scale([],p,[this.worldSize,this.worldSize,this.worldSize/o,1]),this.projMatrix=p,this.invProjMatrix=e.a6.mat4.invert(new Float64Array(16),this.projMatrix),r){var _=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);_[8]=2*-t.x/this.width,_[9]=2*t.y/this.height,this.expandedFarZProjMatrix=e.a6.mat4.mul([],_,s)}else this.expandedFarZProjMatrix=this.projMatrix;var g=e.a6.mat4.invert([],a);this.frustumCorners=e.b$.fromInvProjectionMatrix(g,this.horizonLineFromTop(),this.height),this.cameraFrustum=e.bO.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!r);var y=new Float32Array(16);e.a6.mat4.identity(y),e.a6.mat4.scale(y,y,[1,-1,1]),e.a6.mat4.rotateX(y,y,this._pitch),e.a6.mat4.rotateZ(y,y,this.angle);var x=e.a6.mat4.perspective(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ);this.starsProjMatrix=e.a6.mat4.clone(x);var b=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;x[8]=2*-t.x/this.width,x[9]=2*(t.y+b)/this.height,this.skyboxMatrix=e.a6.mat4.multiply(y,x,y);var w=this.point,k=w.x,T=w.y,S=this.width%2/2,E=this.height%2/2,M=Math.cos(this.angle),A=Math.sin(this.angle),I=k-Math.round(k)+M*S+A*E,C=T-Math.round(T)+M*E+A*S,P=new Float64Array(p);if(e.a6.mat4.translate(P,P,[I>.5?I-1:I,C>.5?C-1:C,0]),this.alignedProjMatrix=P,p=e.a6.mat4.create(),e.a6.mat4.scale(p,p,[this.width/2,-this.height/2,1]),e.a6.mat4.translate(p,p,[1,-1,0]),this.labelPlaneMatrix=p,p=e.a6.mat4.create(),e.a6.mat4.scale(p,p,[1,-1,1]),e.a6.mat4.translate(p,p,[-1,-1,0]),e.a6.mat4.scale(p,p,[2/this.width,2/this.height,1]),this.glCoordMatrix=p,this.pixelMatrix=e.a6.mat4.multiply(new Float64Array(16),this.labelPlaneMatrix,d),this._calcFogMatrices(),this._distanceTileDataCache={},!(p=e.a6.mat4.invert(new Float64Array(16),this.pixelMatrix)))throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=p,"globe"===this.projection.name||this.mercatorFromTransition){this.globeMatrix=e.c0(this);var z=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=e.a6.vec3.transformMat4(z,z,s),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=p;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={}}}},{key:"_calcFogMatrices",value:function(){this._fogTileMatrixCache={};var t=this.cameraWorldSizeForFog,r=this.cameraPixelsPerMeter,i=this._camera.position,n=1/this.height/this._pixelsPerMercatorPixel,a=[t,t,r];e.a6.vec3.scale(a,a,n),e.a6.vec3.scale(i,i,-1),e.a6.vec3.multiply(i,i,a);var o=e.a6.mat4.create();e.a6.mat4.translate(o,o,i),e.a6.mat4.scale(o,o,a),this.mercatorFogMatrix=o,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(t,r,n)}},{key:"_computeCameraPosition",value:function(e){var t=(e=e||this.pixelsPerMeter)/this.pixelsPerMeter,r=this._camera.forward(),i=this.point,n=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*t-e/this.worldSize*this._centerAltitude;return[i.x/this.worldSize-r[0]*n,i.y/this.worldSize-r[1]*n,e/this.worldSize*this._centerAltitude-r[2]*n]}},{key:"_updateCameraState",value:function(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}},{key:"_translateCameraConstrained",value:function(t){var r=this._maxCameraBoundsDistance()*Math.cos(this._pitch),i=this._camera.position[2],n=t[2],a=1;this.projection.wrap&&(this.center=this.center.wrap()),n>0&&(a=Math.min((r-i)/n,1)),this._camera.position=e.a6.vec3.scaleAndAdd([],this._camera.position,t,a),this._updateStateFromCamera()}},{key:"_updateStateFromCamera",value:function(){var t=this._camera.position,r=this._camera.forward(),i=this._camera.getPitchBearing(),n=i.pitch,a=i.bearing,o=e.bE(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,s=this._mercatorZfromZoom(this._maxZoom)*Math.cos(e.bC(this._maxPitch)),l=Math.max((t[2]-o)/Math.cos(n),s),u=this._zoomFromMercatorZ(l);e.a6.vec3.scaleAndAdd(t,t,r,l),this._pitch=e.ap(n,e.bC(this.minPitch),e.bC(this.maxPitch)),this.angle=e.bB(a,-Math.PI,Math.PI),this._setZoom(e.ap(u,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()}},{key:"_worldSizeFromZoom",value:function(e){return Math.pow(2,e)*this.tileSize}},{key:"_mercatorZfromZoom",value:function(e){return this.cameraToCenterDistance/this._worldSizeFromZoom(e)}},{key:"_minimumHeightOverTerrain",value:function(){var e=Math.min(null!=this._seaLevelZoom?this._seaLevelZoom:this._zoom,this._maxZoom)+4;return this._mercatorZfromZoom(e)}},{key:"_zoomFromMercatorZ",value:function(e){return this.scaleZoom(this.cameraToCenterDistance/(e*this.tileSize))}},{key:"zoomFromMercatorZAdjusted",value:function(t){for(var r=0,i=e.bV,n=0,a=1/0;i-r>1e-6&&i>r;){var o=r+.5*(i-r),s=this.tileSize*Math.pow(2,o),l=this.getCameraToCenterDistance(this.projection,o,s),u=this.scaleZoom(l/(t*this.tileSize)),c=Math.abs(o-u);cu||f.y>1)return!0}return!1}},{key:"isHorizonVisible",value:function(){return this.pitch+e.c1(this.fovAboveCenter)>88||this.anyCornerOffEdge(new e.P(0,0),new e.P(this.width,this.height))}},{key:"zoomDeltaToMovement",value:function(t,r){var i=e.a6.vec3.length(e.a6.vec3.sub([],this._camera.position,t)),n=this._zoomFromMercatorZ(i)+r;return i-this._mercatorZfromZoom(n)}},{key:"getCameraPoint",value:function(){if("globe"===this.projection.name){var t=(function(t,r){var i=x(t,3),n=[i[0],i[1],i[2],1];e.a6.vec4.transformMat4(n,n,r);var a=n[3]=Math.max(n[3],1e-6);return n[0]/=a,n[1]/=a,n[2]/=a,n})([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new e.P(t[0],t[1])}var r=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new e.P(0,r))}},{key:"getCameraToCenterDistance",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.zoom,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.worldSize,n=e.bY(t,r,this.width,this.height,1024),a=t.pixelSpaceConversion(this.center.lat,i,n),o=.5/Math.tan(.5*this._fov)*this.height*a;return this.isOrthographic&&(o=yi(1,o,xi(this.pitch>=15?1:this.pitch/15))),o}},{key:"getWorldToCameraMatrix",value:function(){var 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}},{key:"getFrustum",value:function(t){return e.bO.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,t,"meters"===this.projection.zAxisUnit)}}])})(),wi=function(t,r){if(r>0&&t.terrain&&e.w("Cutoff is currently disabled on terrain"),r<=0||t.terrain)return{shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};var i,n=t.transform,a=Math.max(Math.abs(n._zoom-(t.minCutoffZoom-1)),1),o=n.isLODDisabled(!1)?e.a7(60,45,n.pitch):e.a7(30,15,n.pitch),s=n._farZ-n._nearZ,l=r*n.height,u=((1-(i=o))*n.cameraToCenterDistance+i*(n._farZ+l))*a;return{shouldRenderCutoff:o<1,uniformValues:{u_cutoff_params:[n._nearZ,n._farZ,(u-n._nearZ)/s,(u-l-n._nearZ)/s]}}},ki={cascadeCount:2,normalOffset:3,shadowMapResolution:2048},Ti=m((function e(t,r){p(this,e),this.aabb=t,this.lastCascade=r})),Si=(function(){return m((function e(){p(this,e)}),[{key:"add",value:function(e,t){var r=this.receivers[e.key];void 0!==r?(r.aabb.min[0]=Math.min(r.aabb.min[0],t.min[0]),r.aabb.min[1]=Math.min(r.aabb.min[1],t.min[1]),r.aabb.min[2]=Math.min(r.aabb.min[2],t.min[2]),r.aabb.max[0]=Math.max(r.aabb.max[0],t.max[0]),r.aabb.max[1]=Math.max(r.aabb.max[1],t.max[1]),r.aabb.max[2]=Math.max(r.aabb.max[2],t.max[2])):this.receivers[e.key]=new Ti(t,null)}},{key:"clear",value:function(){this.receivers={}}},{key:"get",value:function(e){return this.receivers[e.key]}},{key:"computeRequiredCascades",value:function(t,r,i){var n=e.ca.fromPoints(t.points),a=0;for(var o in this.receivers){var s=this.receivers[o];if(s&&n.intersectsAabb(s.aabb)){s.aabb.min=n.closestPoint(s.aabb.min),s.aabb.max=n.closestPoint(s.aabb.max);for(var l=s.aabb.getCorners(),u=0;u1||f[1]<-1||f[1]>1){c=!1;break}}if(s.lastCascade=u,a=Math.max(a,u),c)break}}}return a+1}}])})(),Ei=(function(){return m((function e(t){var r=this;p(this,e),this.painter=t,this._enabled=!1,this._shadowLayerCount=0,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new Si,this._depthMode=new ei(t.context.gl.LEQUAL,ei.ReadWrite,[0,1]),this._uniformValues={u_light_matrix_0:new Float32Array(16),u_light_matrix_1:new Float32Array(16),u_shadow_intensity:0,u_fade_range:[0,0],u_shadow_normal_offset:[1,1,1],u_shadow_texel_size:1,u_shadow_map_resolution:1,u_shadow_direction:[0,0,1],u_shadow_bias:[36e-5,.0012,.012],u_shadowmap_0:0,u_shadowmap_1:0},this._forceDisable=!1,this.useNormalOffset=!1,t.tp.registerParameter(this,["Shadows"],"_forceDisable",{label:"forceDisable"},(function(){r.painter.style.map.triggerRepaint()})),t.tp.registerParameter(ki,["Shadows"],"cascadeCount",{min:1,max:2,step:1}),t.tp.registerParameter(ki,["Shadows"],"normalOffset",{min:0,max:10,step:.05}),t.tp.registerParameter(ki,["Shadows"],"shadowMapResolution",{min:32,max:2048,step:32}),t.tp.registerBinding(this,["Shadows"],"_numCascadesToRender",{readonly:!0,label:"numCascadesToRender"})}),[{key:"destroy",value:function(){for(var e of this._cascades)e.texture.destroy(),e.framebuffer.destroy();this._cascades=[]}},{key:"updateShadowParameters",value:function(t,r){var i=this.painter;if(this._enabled=!1,this._shadowLayerCount=0,this._receivers.clear(),r&&r.properties){var n=r.properties.get("shadow-intensity");if(r.shadowsEnabled()&&!(n<=0)&&(this._shadowLayerCount=i.style.order.reduce((function(e,r){var n=i.style._mergedLayers[r];return e+(n.hasShadowPass()&&!n.isHidden(t.zoom)?1:0)}),0),this._enabled=this._shadowLayerCount>0,this.enabled)){var a=i.context,o=ki.shadowMapResolution,s=ki.shadowMapResolution;if(0===this._cascades.length||ki.shadowMapResolution!==this._cascades[0].texture.size[0]){this._cascades=[];for(var l=0;l3&&void 0!==arguments[3]?arguments[3]:0;if(this.enabled){for(var a=this.painter.transform,o=this.painter.context,s=o.gl,l=this._uniformValues,u=new Float64Array(16),c=a.calculatePosMatrix(t,a.worldSize),h=0;h2&&void 0!==arguments[2]&&arguments[2];if(this.enabled){for(var n=this.painter.context,a=n.gl,o=this._uniformValues,s=new Float64Array(16),l=0;l=0)return{};var a=(function(t,r,i){var n=i/(1<0&&(e.a6.vec3.add(a[1],a[1],[n[0]*o,0,0]),e.a6.vec3.add(a[2],a[2],[n[0]*o,0,0])),n[1]<0?(e.a6.vec3.add(a[0],a[0],[0,n[1]*o,0]),e.a6.vec3.add(a[1],a[1],[0,n[1]*o,0])):n[1]>0&&(e.a6.vec3.add(a[2],a[2],[0,n[1]*o,0]),e.a6.vec3.add(a[3],a[3],[0,n[1]*o,0]));var s={};return s.vertices=a,s.planes=[Mi(a[1],a[0],a[4]),Mi(a[2],a[1],a[5]),Mi(a[3],a[2],a[6]),Mi(a[0],a[3],a[7])],s}},{key:"addShadowReceiver",value:function(t,r,i){this._receivers.add(t,e.ca.fromTileIdAndHeight(t,r,i))}},{key:"getMaxCascadeForTile",value:function(e){var t=this._receivers.get(e);return t&&t.lastCascade?t.lastCascade:0}}])})();function Mi(t,r,i){var n=e.a6.vec3.sub([],i,r),a=e.a6.vec3.sub([],t,r),o=e.a6.vec3.cross([],n,a),s=e.a6.vec3.length(o);return 0===s?[0,0,1,0]:(e.a6.vec3.scale(o,o,1/s),[o[0],o[1],o[2],-e.a6.vec3.dot(o,r)])}function Ai(t){var r=t.properties.get("direction"),i=e.c8(r.x,r.y,r.z);i[2]=e.ap(i[2],0,75);var n=e.cb([i[0],i[1],i[2]]);return e.a6.vec3.fromValues(n.x,n.y,n.z)}function Ii(t,r,i){var n=r.properties.get("color"),a=r.properties.get("intensity"),o=r.properties.get("direction"),s=[o.x,o.y,o.z],l=i.properties.get("color"),u=i.properties.get("intensity"),c=Math.max(e.a6.vec3.dot([0,0,1],s),0),h=[0,0,0];e.a6.vec3.scale(h,l.toRenderColor(t.getLut(r.scope)).toArray01Linear().slice(0,3),u);var f=[0,0,0];return e.a6.vec3.scale(f,n.toRenderColor(t.getLut(i.scope)).toArray01Linear().slice(0,3),c*a),e.cc([h[0]>0?h[0]/(h[0]+f[0]):0,h[1]>0?h[1]/(h[1]+f[1]):0,h[2]>0?h[2]/(h[2]+f[2]):0])}function Ci(t,r,i,n,a,o){var s,l,u=t.zoom,c=t.scale,h=t.worldSize,f=1/h,d=t.aspect,p=Math.sqrt(1+d*d)*Math.tan(.5*t.fovX),m=p*p,v=n-i,_=n+i;m>v/_?(s=n,l=n*p):(s=.5*_*(1+m),l=.5*Math.sqrt(v*v+2*(n*n+i*i)*m+_*_*m*m));var g=t.projection.pixelsPerMeter(t.center.lat,h),y=t._camera.getCameraToWorldMercator(),x=[0,0,-s*f];e.a6.vec3.transformMat4(x,x,y);var b,w=l*f,k=t._edgeInsets;if(!(0===k.left&&0===k.top&&0===k.right&&0===k.bottom||k.left===k.right&&k.top===k.bottom)){var T=t._camera.getWorldToCamera(t.worldSize,"meters"===t.projection.zAxisUnit?g:1),S=t._camera.getCameraToClipPerspective(t._fov,t.width/t.height,i,n);S[8]=2*-t.centerOffset.x/t.width,S[9]=2*t.centerOffset.y/t.height;var E=new Float64Array(16);e.a6.mat4.mul(E,S,T);var M=new Float64Array(16);e.a6.mat4.invert(M,E);var A=e.bO.fromInvProjectionMatrix(M,h,u,!0);for(var I of A.points){var C=((b=I)[0]/=c,b[1]/=c,b[2]=e.bE(b[2],t._center.lat),b);w=Math.max(w,e.a6.vec3.len(e.a6.vec3.subtract([],x,C)))}}w*=a/(a-1);var P=Math.acos(r[2]),z=Math.atan2(-r[0],-r[1]),D=new ci;D.position=x,D.setPitchBearing(P,z);var R=D.getWorldToCamera(h,g),L=w*h,O=Math.min(t._mercatorZfromZoom(17)*h*-2,-2*L),F=D.getCameraToClipOrthographic(-L,L,-L,L,O,(L+o*g)/r[2]),B=new Float64Array(16);e.a6.mat4.multiply(B,F,R);var N=e.a6.vec3.fromValues(Math.floor(1e6*x[0])/1e6*h,Math.floor(1e6*x[1])/1e6*h,0),V=.5*a,U=[0,0,0];e.a6.vec3.transformMat4(U,N,B),e.a6.vec3.scale(U,U,V);var j=[Math.floor(U[0]),Math.floor(U[1]),Math.floor(U[2])],G=[0,0,0];e.a6.vec3.sub(G,U,j),e.a6.vec3.scale(G,G,-1/V);var q=new Float64Array(16);return e.a6.mat4.identity(q),e.a6.mat4.translate(q,q,G),e.a6.mat4.multiply(B,q,B),[B,L]}var Pi=(function(t){function r(e){var t;return p(this,r),(t=T(this,r)).requestManager=e,t.models={"":{}},t.numModelsLoading={},t}return g(r,t),m(r,[{key:"loadModel",value:function(t,r){var i=this;return e.aG(this.requestManager.transformRequest(r,e.R.Model).url).then((function(r){if(r){var i=e.aH(r),n=new e.aI(t,void 0,void 0,i);return n.computeBoundsAndApplyParent(),n}})).catch((function(n){if(n&&404===n.status)return null;i.fire(new e.t(new Error(`Could not load model ${t} from ${r}: ${n.message}`)))}))}},{key:"load",value:function(t,r){var i=this;this.models[r]||(this.models[r]={});var n=Object.keys(t);this.numModelsLoading[r]=(this.numModelsLoading[r]||0)+n.length;var a=[];for(var o of n)a.push(this.loadModel(o,t[o]));Promise.allSettled(a).then((function(t){for(var a=0;a0)return!1;return!0}},{key:"hasModel",value:function(e,t){return!!this.getModel(e,t)}},{key:"getModel",value:function(e,t){return this.models[t]||(this.models[t]={}),this.models[t][e]?this.models[t][e].model:void 0}},{key:"addModel",value:function(e,t,r){this.models[r]||(this.models[r]={}),this.hasModel(e,r)&&this.models[r][e].numReferences++,this.load(s({},e,this.requestManager.normalizeModelURL(t)),r)}},{key:"addModels",value:function(e,t){this.models[t]||(this.models[t]={});var r={};for(var i in e)this.models[t][i]={},r[i]=this.requestManager.normalizeModelURL(e[i]);this.load(r,t)}},{key:"addModelsFromBucket",value:function(e,t){this.models[t]||(this.models[t]={});var r={};for(var i of e)this.hasModel(i,t)?this.models[t][i].numReferences++:r[i]=this.requestManager.normalizeModelURL(i);this.load(r,t)}},{key:"removeModel",value:function(e,t){if(this.models[t]&&this.models[t][e]&&(this.models[t][e].numReferences--,0===this.models[t][e].numReferences)){var r=this.models[t][e].model;delete this.models[t][e],r.destroy()}}},{key:"listModels",value:function(e){return this.models[e]||(this.models[e]={}),Object.keys(this.models[e])}},{key:"upload",value:function(e,t){for(var r in this.models[t]||(this.models[t]={}),this.models[t])this.models[t][r].model&&this.models[t][r].model.upload(e.context)}}])})(e.E),zi=new e.a0({data:new e.a1(e._.colorTheme.data)}),Di=function(e,t){return je(e,t&&t.filter((function(e){return"source.canvas"!==e.identifier})))},Ri=e.ar($t,["addLayer","removeLayer","setLights","setPaintProperty","setLayoutProperty","setSlot","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection","setCamera","addImport","removeImport","updateImport"]),Li=e.ar($t,["setCenter","setZoom","setBearing","setPitch"]),Oi={version:8,layers:[],sources:{}},Fi={duration:300,delay:0},Bi=(function(t){function r(t){var i,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};p(this,r),(i=T(this,r)).map=t,i.scope=n.scope||"",i.globalId=null,i.fragments=[],i.importDepth=n.importDepth||0,i.importsCache=n.importsCache||new Map,i.resolvedImports=n.resolvedImports||new Set,i.transition=e.l({},Fi),i._buildingIndex=new Gt(l(i)),i.crossTileSymbolIndex=new Jr,i._mergedOrder=[],i._drapedFirstOrder=[],i._mergedLayers={},i._mergedSourceCaches={},i._mergedOtherSourceCaches={},i._mergedSymbolSourceCaches={},i._mergedLayerSelectors=new Map,i._clipLayerPresent=!1,i._has3DLayers=!1,i._hasCircleLayers=!1,i._hasSymbolLayers=!1,i._changes=n.styleChanges||new te,i.dispatcher=n.dispatcher?n.dispatcher:new e.ce(e.cf(),l(i)),n.imageManager?i.imageManager=n.imageManager:(i.imageManager=new ie,i.imageManager.setEventedParent(l(i))),i.imageManager.createScope(i.scope),i.glyphManager=n.glyphManager?n.glyphManager:new e.cg(t._requestManager,n.localFontFamily?e.ch.all:n.localIdeographFontFamily?e.ch.ideographs:e.ch.none,n.localFontFamily||n.localIdeographFontFamily),n.modelManager?i.modelManager=n.modelManager:(i.modelManager=new Pi(t._requestManager),i.modelManager.setEventedParent(l(i))),i._layers={},i._sourceCaches={},i._otherSourceCaches={},i._symbolSourceCaches={},i._loaded=!1,i._precompileDone=!1,i._shouldPrecompile=!1,i._availableImages=[],i._order=[],i._markersNeedUpdate=!1,i._styleColorTheme={lut:null,lutLoading:!1,lutLoadingCorrelationID:0,colorTheme:null},i._styleColorThemeForScope={},i.options=n.configOptions?n.configOptions:new Map,i._configDependentLayers=n.configDependentLayers?n.configDependentLayers:new Set,i._config=n.config,i._initialConfig=n.initialConfig,i.dispatcher.broadcast("setReferrer",e.ci());var a=i;return i._rtlTextPluginCallback=r.registerForPluginStateChange((function(t){a.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:t.pluginStatus,pluginURL:t.pluginURL},(function(t,r){if(e.cj(t),r&&r.every((function(e){return e})))for(var i in a._sourceCaches){var n=a._sourceCaches[i],o=n.getSource().type;"vector"!==o&&"geojson"!==o||n.reload()}}))})),i.on("data",(function(e){if("source"===e.dataType&&"metadata"===e.sourceDataType){var t=i.getOwnSource(e.sourceId);if(t&&t.vectorLayerIds)for(var r in i._layers){var n=i._layers[r];n.source===t.id&&i._validateLayer(n)}}})),i}return g(r,t),m(r,[{key:"load",value:function(e){return e?("string"==typeof e?this.loadURL(e):this.loadJSON(e),this):this}},{key:"_getGlobalId",value:function(t){if(!t)return null;if("string"==typeof t){if(e.f(t))return t;var r=e.ck(t);if(!r.startsWith("http"))try{return new URL(r,location.href).toString()}catch(e){return r}return r}return`json://${e.cl(JSON.stringify(t))}`}},{key:"_diffStyle",value:function(t,r,i){var n=this;this.globalId=this._getGlobalId(t);var a=function(e,t){try{t(null,n.setState(e,i))}catch(e){t(e,!1)}};if("string"==typeof t){var o=this.map._requestManager.normalizeStyleURL(t),s=this.map._requestManager.transformRequest(o,e.R.Style);e.n(s,(function(t,i){t?n.fire(new e.t(t)):i&&a(i,r)}))}else"object"==typeof t&&a(t,r)}},{key:"loadURL",value:function(t){var r=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.fire(new e.x("dataloading",{dataType:"style"}));var n="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);var a=this.importsCache.get(t);if(a)return this._load(a,n);var o=this.map._requestManager.transformRequest(t,e.R.Style);this._request=e.n(o,(function(i,a){if(r._request=null,i)r.fire(new e.t(i));else if(a)return r.importsCache.set(t,a),r._load(a,n)}))}},{key:"loadJSON",value:function(t){var r=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.fire(new e.x("dataloading",{dataType:"style"})),this.globalId=this._getGlobalId(t),this._request=e.q.frame((function(){r._request=null,r._load(t,!1!==i.validate)}))}},{key:"loadEmpty",value:function(){this.fire(new e.x("dataloading",{dataType:"style"})),this._load(Oi,!1)}},{key:"_loadImports",value:function(t,r,i){var n=this;if(this.importDepth>=4)return e.w("Style doesn't support nesting deeper than 5"),Promise.resolve();var a=[],o=function(){var e=n._createFragmentStyle(s),t=new Promise((function(t){e.once("style.import.load",t),e.once("error",t)})).then((function(){return n.mergeAll()}));if(a.push(t),n.resolvedImports.has(s.url))return e.loadEmpty(),1;var o=s.data||n.importsCache.get(s.url);o?(e.loadJSON(o,{validate:r}),n._isInternalStyle(o)&&(e.globalId=null)):s.url?e.loadURL(s.url,{validate:r}):e.loadEmpty();var l={style:e,id:s.id,config:s.config};if(i){var u=n.fragments.findIndex((function(e){return e.id===i}));n.fragments=n.fragments.slice(0,u).concat(l).concat(n.fragments.slice(u))}else n.fragments.push(l)};for(var s of t)o();return Promise.allSettled(a)}},{key:"getImportGlobalIds",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Set;for(var r of e.fragments)r.style.globalId&&t.add(r.style.globalId),this.getImportGlobalIds(r.style,t);return d(t.values())}},{key:"_createFragmentStyle",value:function(t){var i,n=this.scope?e.av(t.id,this.scope):t.id,a=this._initialConfig&&this._initialConfig[n];(t.config||a)&&(i=e.l({},t.config,a));var o=new r(this.map,{scope:n,styleChanges:this._changes,importDepth:this.importDepth+1,importsCache:this.importsCache,resolvedImports:new Set(this.resolvedImports),dispatcher:this.dispatcher,imageManager:this.imageManager,glyphManager:this.glyphManager,modelManager:this.modelManager,config:i,configOptions:this.options,configDependentLayers:this._configDependentLayers});return o.setEventedParent(this.map,{style:o}),o}},{key:"_reloadImports",value:function(){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()}},{key:"_isInternalStyle",value:function(e){return this.isRootStyle()&&(e.fragment||!!e.schema&&!1!==e.fragment)}},{key:"_load",value:function(t,r){var i=this,n=t.schema;if(this._isInternalStyle(t)){var a=e.l({},Oi,{imports:[{id:"basemap",data:t,url:""}]});this._load(a,r)}else if(this.updateConfig(this._config,n),!r||!Di(this,Ie(t))){this._loaded=!0,this.stylesheet=e.cm(t);var o=function(){for(var n in t.sources)i.addSource(n,t.sources[n],{validate:!1,isInitialLoad:!0});t.sprite?i._loadSprite(t.sprite):(i.imageManager.setLoaded(!0,i.scope),i.dispatcher.broadcast("spriteLoaded",{scope:i.scope,isLoaded:!0})),i.glyphManager.setURL(t.glyphs,i.scope);var a=Zt(i.stylesheet.layers);if(i._order=a.map((function(e){return e.id})),i.stylesheet.light&&e.w("The `light` root property is deprecated, prefer using `lights` with `flat` light type instead."),i.stylesheet.lights)if(1===i.stylesheet.lights.length&&"flat"===i.stylesheet.lights[0].type){var o=i.stylesheet.lights[0];i.light=new Ge(o.properties,o.id)}else i.setLights(i.stylesheet.lights);for(var s of(i.light||(i.light=new Ge(i.stylesheet.light)),i._layers={},a)){var l=e.cq(s,i.scope,i._styleColorTheme.lut,i.options);0!==l.configDependencies.size&&i._configDependentLayers.add(l.fqid),l.setEventedParent(i,{layer:{id:l.id}}),i._layers[l.id]=l;var u=i.getOwnLayerSourceCache(l),c=!!i.directionalLight&&i.directionalLight.shadowsEnabled();u&&l.canCastShadows()&&c&&(u.castsShadows=!0)}i.stylesheet.models&&i.modelManager.addModels(i.stylesheet.models,i.scope);var h=i.stylesheet.terrain;h&&(i.checkCanvasFingerprintNoise(),i.disableElevatedTerrain||i.terrainSetForDrapingOnly()||i._createTerrain(h,1)),i.stylesheet.fog&&i._createFog(i.stylesheet.fog),i.stylesheet.transition&&i.setTransition(i.stylesheet.transition),i.fire(new e.x("data",{dataType:"style"}));var f=i.isRootStyle();t.imports?i._loadImports(t.imports,r).then((function(){i._reloadImports(),i.fire(new e.x(f?"style.load":"style.import.load"))})):(i._reloadImports(),i.fire(new e.x(f?"style.load":"style.import.load")))},s=this.stylesheet["color-theme"];if(this._styleColorTheme.colorTheme=s,s){var l=this._evaluateColorThemeData(s);this._loadColorTheme(l).then((function(){o()})).catch((function(t){e.w(`Couldn't load color theme from the stylesheet: ${t}`),o()}))}else this._styleColorTheme.lut=null,o()}}},{key:"isRootStyle",value:function(){return 0===this.importDepth}},{key:"mergeAll",value:function(){var t,r,i,n,a,o,s,l,u=this,c={};this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle((function(e){if(e.stylesheet){if(null!=e.light&&(t=e.light),e.stylesheet.lights)for(var h of e.stylesheet.lights)"ambient"===h.type&&null!=e.ambientLight&&(r=e.ambientLight),"directional"===h.type&&null!=e.directionalLight&&(i=e.directionalLight);n=u._prioritizeTerrain(n,e.terrain,e.stylesheet.terrain),e.stylesheet.fog&&null!=e.fog&&(a=e.fog),null!=e.stylesheet.camera&&(l=e.stylesheet.camera),null!=e.stylesheet.projection&&(o=e.stylesheet.projection),null!=e.stylesheet.transition&&(s=e.stylesheet.transition),c[e.scope]=e._styleColorTheme}})),this.light=t,this.ambientLight=r,this.directionalLight=i,this.fog=a,this._styleColorThemeForScope=c,null===n?delete this.terrain:this.terrain=n,this.camera=l||{"camera-projection":"perspective"},this.projection=o||{name:"mercator"},this.transition=e.l({},Fi,s),this.mergeSources(),this.mergeLayers()}},{key:"forEachFragmentStyle",value:function(e){var t=function(r){for(var i of r.fragments)t(i.style);e(r)};t(this)}},{key:"_prioritizeTerrain",value:function(e,t,r){var i=e&&0===e.drapeRenderMode;return null===r?t&&0===t.drapeRenderMode?t:i?e:null:null!=t&&(!e||i||t&&1===t.drapeRenderMode)?t:e}},{key:"mergeTerrain",value:function(){var e,t=this;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle((function(r){e=t._prioritizeTerrain(e,r.terrain,r.stylesheet.terrain)})),null===e?delete this.terrain:this.terrain=e}},{key:"mergeProjection",value:function(){var e;this.forEachFragmentStyle((function(t){null!=t.stylesheet.projection&&(e=t.stylesheet.projection)})),this.projection=e||{name:"mercator"}}},{key:"mergeSources",value:function(){var t={},r={},i={};this.forEachFragmentStyle((function(n){for(var a in n._sourceCaches){var o=e.av(a,n.scope);t[o]=n._sourceCaches[a]}for(var s in n._otherSourceCaches){var l=e.av(s,n.scope);r[l]=n._otherSourceCaches[s]}for(var u in n._symbolSourceCaches){var c=e.av(u,n.scope);i[c]=n._symbolSourceCaches[u]}})),this._mergedSourceCaches=t,this._mergedOtherSourceCaches=r,this._mergedSymbolSourceCaches=i}},{key:"mergeLayers",value:function(){var t=this,r={},i=[],n={};this._mergedSlots=[],this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this._mergedLayerSelectors.clear(),this.forEachFragmentStyle((function(n){for(var a of n._order){var o=n._layers[a];if("slot"===o.type){var s=e.cn(a);if(r[s])continue;r[s]=[]}o.slot&&r[o.slot]?r[o.slot].push(o):i.push(o)}var l=(n.stylesheet||{}).featuresets;if(l)for(var u in l){var c=l[u].selectors;for(var h of c){var f=n._layers[h.layer],d=t._mergedLayerSelectors.get(f.fqid)||[],p=void 0;if(h.properties)for(var m in h.properties){var v=e.M(h.properties[m]);"success"===v.result&&((p=p||{})[m]=v.value)}d.push({featuresetId:u,featureNamespace:h.featureNamespace,properties:p}),t._mergedLayerSelectors.set(f.fqid,d)}}})),this._mergedOrder=[];var a=function(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];for(var o of i)if("slot"===o.type){var s=e.cn(o.id);r[s]&&a(r[s]),t._mergedSlots.push(s)}else{var l=e.av(o.id,o.scope);t._mergedOrder.push(l),n[l]=o,o.is3D()&&(t._has3DLayers=!0),"circle"===o.type&&(t._hasCircleLayers=!0),"symbol"===o.type&&(t._hasSymbolLayers=!0),"clip"===o.type&&(t._clipLayerPresent=!0)}};a(i),this._mergedOrder.sort((function(e,t){var r=n[e],i=n[t];return r.hasInitialOcclusionOpacityProperties?i.is3D()?1:0:r.is3D()&&i.hasInitialOcclusionOpacityProperties?-1:0})),this._mergedLayers=n,this.updateDrapeFirstLayers(),this._buildingIndex.processLayersChanged()}},{key:"terrainSetForDrapingOnly",value:function(){return!!this.terrain&&0===this.terrain.drapeRenderMode}},{key:"getCamera",value:function(){return this.stylesheet.camera}},{key:"setCamera",value:function(t){return this.stylesheet.camera=e.l({},this.stylesheet.camera,t),this.camera=this.stylesheet.camera,this}},{key:"_evaluateColorThemeData",value:function(t){return t.data?(function(t,r,i){var n=e.l({},r);for(var a of Object.keys(e._.colorTheme))void 0===n[a]&&(n[a]=e._.colorTheme[a].default);var o=new e.$(zi,t,new Map(i));return o.setTransitionOrValue(n,i),o.untransitioned().possiblyEvaluate(new e.a3(0))})(this.scope,t,this.options).get("data"):null}},{key:"_loadColorTheme",value:function(t){var r=this;this._styleColorTheme.lutLoading=!0,this._styleColorTheme.lutLoadingCorrelationID+=1;var i=this._styleColorTheme.lutLoadingCorrelationID;return new Promise((function(n,a){var o="data:image/png;base64,";if(!t||0===t.length)return r._styleColorTheme.lut=null,r._styleColorTheme.lutLoading=!1,void n();var s=t;s.startsWith(o)||(s=o+s);var l="mapbox-reserved-lut",u=new Image;u.src=s,u.onerror=function(){r._styleColorTheme.lutLoading=!1,a(new Error("Failed to load image data"))},u.onload=function(){if(r._styleColorTheme.lutLoadingCorrelationID===i){r._styleColorTheme.lutLoading=!1;var o=e.q.getImageData(u),s=o.width,c=o.height,h=o.data;if(c>32)a(new Error("The height of the image must be less than or equal to 32 pixels."));else if(s===c*c){r.getImage(l)&&r.removeImage(l),r.addImage(l,{data:new e.r({width:s,height:c},h),pixelRatio:1,sdf:!1,version:0});var f=r.imageManager.getImage(l,r.scope);f?(r._styleColorTheme.lut={image:f.data,data:t},n()):a(new Error("Missing LUT image."))}else a(new Error("The width of the image must be equal to the height squared."))}else n()}}))}},{key:"getLut",value:function(e){var t=this._styleColorThemeForScope[e];return t?t.lut:null}},{key:"setProjection",value:function(e){e?this.stylesheet.projection=e:delete this.stylesheet.projection,this.mergeProjection(),this._updateMapProjection()}},{key:"applyProjectionUpdate",value:function(){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))}},{key:"_updateMapProjection",value:function(){this.isRootStyle()&&(this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.projection))}},{key:"_loadSprite",value:function(t){var r=this;this._spriteRequest=(function(t,r,i){var n,a,o,s=e.q.devicePixelRatio>1?"@2x":"",l=e.n(r.transformRequest(r.normalizeSpriteURL(t,s,".json"),e.R.SpriteJSON),(function(e,t){l=null,o||(o=e,n=t,c())})),u=e.o(r.transformRequest(r.normalizeSpriteURL(t,s,".png"),e.R.SpriteImage),(function(e,t){u=null,o||(o=e,a=t,c())}));function c(){if(o)i(o);else if(n&&a){var t=e.q.getImageData(a),r={};for(var s in n){var l=n[s],u=l.width,c=l.height,h=l.x,f=l.y,d=l.sdf,p=l.pixelRatio,m=l.stretchX,v=l.stretchY,_=l.content,g=new e.r({width:u,height:c});e.r.copy(t,g,{x:h,y:f},{x:0,y:0},{width:u,height:c},null),r[s]={data:g,pixelRatio:p,sdf:d,stretchX:m,stretchY:v,content:_}}i(null,r)}}return{cancel:function(){l&&(l.cancel(),l=null),u&&(u.cancel(),u=null)}}})(t,this.map._requestManager,(function(t,i){if(r._spriteRequest=null,t)r.fire(new e.t(t));else if(i)for(var n in i)r.imageManager.addImage(n,r.scope,i[n]);r.imageManager.setLoaded(!0,r.scope),r._availableImages=r.imageManager.listImages(r.scope),r.dispatcher.broadcast("setImages",{scope:r.scope,images:r._availableImages}),r.dispatcher.broadcast("spriteLoaded",{scope:r.scope,isLoaded:!0}),r.fire(new e.x("data",{dataType:"style"}))}))}},{key:"_validateLayer",value:function(t){var r=this.getOwnSource(t.source);if(r){var i=t.sourceLayer;i&&("geojson"===r.type||r.vectorLayerIds&&-1===r.vectorLayerIds.indexOf(i))&&this.fire(new e.t(new Error(`Source layer "${i}" does not exist on source "${r.id}" as specified by style layer "${t.id}"`)))}}},{key:"loaded",value:function(){if(!this._loaded)return!1;if(Object.keys(this._changes.getUpdatedSourceCaches()).length)return!1;for(var 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(var t of this.fragments){if(!t.style.loaded())return!1}return!0}},{key:"_serializeImports",value:function(){var e=this;if(this.stylesheet.imports)return this.stylesheet.imports.map((function(t,r){var i=e.fragments[r];return i&&i.style&&(t.data=i.style.serialize()),t}))}},{key:"_serializeSources",value:function(){var e={};for(var t in this._sourceCaches){var r=this._sourceCaches[t].getSource();e[r.id]||(e[r.id]=r.serialize())}return e}},{key:"_serializeLayers",value:function(e){var t=[];for(var r of e){var i=this._layers[r];i&&"custom"!==i.type&&t.push(i.serialize())}return t}},{key:"hasLightTransitions",value:function(){return!(!this.light||!this.light.hasTransition())||!(!this.ambientLight||!this.ambientLight.hasTransition())||!(!this.directionalLight||!this.directionalLight.hasTransition())}},{key:"hasFogTransition",value:function(){return!!this.fog&&this.fog.hasTransition()}},{key:"hasTransitions",value:function(){if(this.hasLightTransitions())return!0;if(this.hasFogTransition())return!0;for(var e in this._sourceCaches)if(this._sourceCaches[e].hasTransition())return!0;for(var t in this._layers)if(this._layers[t].hasTransition())return!0;return!1}},{key:"order",get:function(){return this.terrain?this._drapedFirstOrder:this._mergedOrder}},{key:"_getOrder",value:function(e){return e?this.order:this._mergedOrder}},{key:"isLayerDraped",value:function(e){return!!this.terrain&&e.isDraped(this.getLayerSourceCache(e))}},{key:"_checkLoaded",value:function(){if(!this._loaded)throw new Error("Style is not done loading")}},{key:"_checkLayer",value:function(t){var r=this.getOwnLayer(t);if(r)return r;this.fire(new e.t(new Error(`The layer '${t}' does not exist in the map's style.`)))}},{key:"_checkSource",value:function(t){var r=this.getOwnSource(t);if(r)return r;this.fire(new e.t(new Error(`The source '${t}' does not exist in the map's style.`)))}},{key:"precompilePrograms",value:function(e,t){var r=this.map.painter;if(r)for(var i=e.minzoom||0;i<(e.maxzoom||25.5);i++){var n=e.getProgramIds();if(n)for(var a of n){var o=e.getDefaultProgramParams(a,t.zoom,this._styleColorTheme.lut);o&&(r.style=this,this.fog&&(r._fogVisible=!0,o.overrideFog=!0,r.getOrCreateProgram(a,o)),r._fogVisible=!1,o.overrideFog=!1,r.getOrCreateProgram(a,o),(this.stylesheet.terrain||this.stylesheet.projection&&"globe"===this.stylesheet.projection.name)&&(o.overrideRtt=!0,r.getOrCreateProgram(a,o)))}}}},{key:"update",value:function(t){var r=this;if(this._loaded){this.ambientLight&&this.ambientLight.recalculate(t),this.directionalLight&&this.directionalLight.recalculate(t);var i=this.calculateLightsBrightness();t.brightness=i||0,i!==this._brightness&&(this._brightness=i,this.dispatcher.broadcast("setBrightness",i));var n=this._changes.isDirty(),a=!1;if(this._changes.isDirty()){var o=this._changes.getLayerUpdatesByScope();for(var s in o){var l=o[s],u=l.updatedIds,c=l.removedIds;(u||c)&&(this._updateWorkerLayers(s,u,c),a=!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()}var h={};for(var f in this._mergedSourceCaches){var d=this._mergedSourceCaches[f];h[f]=d.used,d.used=!1,d.tileCoverLift=0}var p=function(){var e=r._mergedLayers[m];if(e.recalculate(t,r._availableImages),!e.isHidden(t.zoom)){var i=r.getLayerSourceCache(e);i&&(i.used=!0,i.tileCoverLift=Math.max(i.tileCoverLift,e.tileCoverLift()))}!r._precompileDone&&r._shouldPrecompile&&("requestIdleCallback"in window?requestIdleCallback((function(){r.precompilePrograms(e,t)})):r.precompilePrograms(e,t))};for(var m of this._mergedOrder)p();for(var v in this._shouldPrecompile&&(this._precompileDone=!0),this.terrain&&a&&this.mergeLayers(),h){var _=this._mergedSourceCaches[v];h[v]!==_.used&&_.getSource().fire(new e.x("data",{sourceDataType:"visibility",dataType:"source",sourceId:_.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),n&&this.fire(new e.x("data",{dataType:"style"}))}}},{key:"_updateTilesForChangedImages",value:function(){var e=this._changes.getUpdatedImages();if(e.length){for(var t in this._sourceCaches)this._sourceCaches[t].reloadTilesForDependencies(["icons","patterns"],e);this._changes.resetUpdatedImages()}}},{key:"_updateWorkerLayers",value:function(e,t,r){var i=this.getFragmentStyle(e);i&&this.dispatcher.broadcast("updateLayers",{layers:t?i._serializeLayers(t):[],scope:e,removedIds:r||[],options:i.options})}},{key:"setState",value:function(t,r){var i=this;if(this._checkLoaded(),Di(this,Ie(t)))return!1;(t=e.cm(t)).layers=Zt(t.layers);var n=(function(t,r){if(!t)return[{command:$t.setStyle,args:[r]}];var i=[];try{if(!e.bi(t.version,r.version))return[{command:$t.setStyle,args:[r]}];if(e.bi(t.center,r.center)||i.push({command:$t.setCenter,args:[r.center]}),e.bi(t.zoom,r.zoom)||i.push({command:$t.setZoom,args:[r.zoom]}),e.bi(t.bearing,r.bearing)||i.push({command:$t.setBearing,args:[r.bearing]}),e.bi(t.pitch,r.pitch)||i.push({command:$t.setPitch,args:[r.pitch]}),e.bi(t.sprite,r.sprite)||i.push({command:$t.setSprite,args:[r.sprite]}),e.bi(t.glyphs,r.glyphs)||i.push({command:$t.setGlyphs,args:[r.glyphs]}),e.bi(t.imports,r.imports)||(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=arguments.length>2?arguments[2]:void 0;r=r||[];var n,a,o,s,l=(t=t||[]).map(Kt),u=r.map(Kt),c=t.reduce(Qt,{}),h=r.reduce(Qt,{}),f=l.slice();for(n=0,a=0;n0)throw new Error(`Unimplemented: ${a.map((function(e){return e.command})).join(", ")}.`);var o=[];return n.forEach((function(e){o.push(i[e.command].apply(i,e.args))})),r&&Promise.all(o).then(r),this.stylesheet=t,this.mergeAll(),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),!0}},{key:"addImage",value:function(t,r){return this.getImage(t)?this.fire(new e.t(new Error("An image with this name already exists."))):(this.imageManager.addImage(t,this.scope,r),this._afterImageUpdated(t),this)}},{key:"updateImage",value:function(e,t){this.imageManager.updateImage(e,this.scope,t)}},{key:"getImage",value:function(e){return this.imageManager.getImage(e,this.scope)}},{key:"removeImage",value:function(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.")))}},{key:"_afterImageUpdated",value:function(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"}))}},{key:"listImages",value:function(){return this._checkLoaded(),this._availableImages.slice()}},{key:"addModel",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this._checkLoaded(),this._validate(Ve,`models.${e}`,t,null,r)||(this.modelManager.addModel(e,t,this.scope),this._changes.setDirty()),this}},{key:"hasModel",value:function(e){return this.modelManager.hasModel(e,this.scope)}},{key:"removeModel",value:function(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.")))}},{key:"listModels",value:function(){return this._checkLoaded(),this.modelManager.listModels(this.scope)}},{key:"addSource",value:function(t,r){var i=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(this._checkLoaded(),void 0!==this.getOwnSource(t))throw new Error(`There is already a source with ID "${t}".`);if(!r.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(r).join(", ")}.`);if(!(["vector","raster","geojson","video","image"].indexOf(r.type)>=0&&this._validate(Pe,`sources.${t}`,r,null,n))){this.map&&this.map._collectResourceTiming&&(r.collectResourceTiming=!0);var a=ct(t,r,this.dispatcher,this);a.scope=this.scope,a.setEventedParent(this,(function(){return{isSourceLoaded:i._isSourceCacheLoaded(a.id),source:a.serialize(),sourceId:a.id}}));var o=function(t){var r=(t?"symbol:":"other:")+a.id,n=e.av(r,i.scope),o=i._sourceCaches[r]=new Nt(n,a,t);(t?i._symbolSourceCaches:i._otherSourceCaches)[a.id]=o,o.onAdd(i.map)};o(!1),"vector"!==r.type&&"geojson"!==r.type||o(!0),a.onAdd&&a.onAdd(this.map),n.isInitialLoad||(this.mergeSources(),this._changes.setDirty())}}},{key:"removeSource",value:function(t){this._checkLoaded();var r=this.getOwnSource(t);if(!r)throw new Error("There is no source with this ID");for(var 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.`)));var n=this.getOwnSourceCaches(t);for(var a of n){var o=e.cn(a.id);delete this._sourceCaches[o],this._changes.discardSourceCacheUpdate(a.id),a.fire(new e.x("data",{sourceDataType:"metadata",dataType:"source",sourceId:a.getSource().id})),a.setEventedParent(null),a.clearTiles()}return delete this._otherSourceCaches[t],delete this._symbolSourceCaches[t],this.mergeSources(),r.setEventedParent(null),r.onRemove&&r.onRemove(this.map),this._changes.setDirty(),this}},{key:"setGeoJSONSourceData",value:function(e,t){this._checkLoaded(),this.getOwnSource(e).setData(t),this._changes.setDirty()}},{key:"getOwnSource",value:function(e){var t=this.getOwnSourceCache(e);return t&&t.getSource()}},{key:"getOwnSources",value:function(){var e=[];for(var t in this._otherSourceCaches){var r=this.getOwnSourceCache(t);r&&e.push(r.getSource())}return e}},{key:"areTilesLoaded",value:function(){var e=this._mergedSourceCaches;for(var t in e){var r=e[t]._tiles;for(var i in r){var n=r[i];if("loaded"!==n.state&&"errored"!==n.state)return!1}}return!0}},{key:"setLights",value:function(t){if(this._checkLoaded(),t){var r=this._getTransitionParameters();for(var i of t){if(this._validate(De,"lights",i))return;switch(i.type){case"ambient":if(this.ambientLight){var n=this.ambientLight;n.set(i),n.updateTransitions(r)}else this.ambientLight=new Qe(i,Ye||(Ye=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){var a=this.directionalLight;a.set(i),a.updateTransitions(r)}else this.directionalLight=new Qe(i,Je||(Je=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)}}var o=new e.a3(this.z||0,r);this.ambientLight&&this.ambientLight.recalculate(o),this.directionalLight&&this.directionalLight.recalculate(o),this._brightness=this.calculateLightsBrightness(),this.dispatcher.broadcast("setBrightness",this._brightness)}else delete this.ambientLight}},{key:"calculateLightsBrightness",value:function(){var t=this.directionalLight,r=this.ambientLight;if(t&&r){var i=function(e){return.2126*(e[0]<=.03928?e[0]/12.92:Math.pow((e[0]+.055)/1.055,2.4))+.7152*(e[1]<=.03928?e[1]/12.92:Math.pow((e[1]+.055)/1.055,2.4))+.0722*(e[2]<=.03928?e[2]/12.92:Math.pow((e[2]+.055)/1.055,2.4))},n=t.properties.get("color").toRenderColor(null).toArray01(),a=t.properties.get("intensity"),o=t.properties.get("direction"),s=1-e.c8(o.x,o.y,o.z)[2]/90,l=i(n)*a*s,u=r.properties.get("color").toRenderColor(null).toArray01(),c=r.properties.get("intensity"),h=i(u)*c;return Number(((l+h)/2).toFixed(6))}}},{key:"getBrightness",value:function(){return this._brightness}},{key:"getLights",value:function(){if(!this.enable3dLights())return null;var e=[];return this.directionalLight&&e.push(this.directionalLight.get()),this.ambientLight&&e.push(this.ambientLight.get()),e}},{key:"enable3dLights",value:function(){return!!this.ambientLight&&!!this.directionalLight}},{key:"getFragmentStyle",value:function(t){if(!t)return this;if(e.aK(t)){var r=e.co(t),i=this.fragments.find((function(e){return e.id===r}));if(!i)throw new Error(`Style import '${t}' not found`);var n=e.cn(t);return i.style.getFragmentStyle(n)}var a=this.fragments.find((function(e){return e.id===t}));if(!a)throw new Error(`Style import '${t}' not found`);return a.style}},{key:"getFeaturesetDescriptors",value:function(e){var t=this.getFragmentStyle(e);if(!t||!t.stylesheet.featuresets)return[];var r=[];for(var i in t.stylesheet.featuresets)r.push({featuresetId:i,importId:t.scope?t.scope:void 0});return r}},{key:"getFeaturesetLayers",value:function(t,r){var i=this.getFragmentStyle(r),n=i.stylesheet.featuresets;if(!n||!n[t])return this.fire(new e.t(new Error(`The featureset '${t}' does not exist in the map's style and cannot be queried.`))),[];var a=[];for(var o of n[t].selectors){var s=i.getOwnLayer(o.layer);s&&a.push(s)}return a}},{key:"getConfigProperty",value:function(t,r){var i=this.getFragmentStyle(t);if(!i)return null;var n=e.av(r,i.scope),a=i.options.get(n),o=a?a.value||a.default:null;return o?o.serialize():null}},{key:"setConfigProperty",value:function(t,r,i){var n=this.getFragmentStyle(t);if(n){var a=n.stylesheet.schema;if(a&&a[r]){var o=e.M(i);if("success"===o.result){var s=o.value.expression,l=e.av(r,n.scope),u=n.options.get(l);if(u){var c,h=a[r],f=h.minValue,d=h.maxValue,p=h.stepValue,m=h.type,v=h.values,_=e.M(a[r].default);"success"===_.result&&(c=_.value.expression),c?(this.options.set(l,Object.assign({},u,{value:s,default:c,minValue:f,maxValue:d,stepValue:p,type:m,values:v})),this.updateConfigDependencies(r)):this.fire(new e.t(new Error(`No schema defined for the config option "${r}" in the "${t}" fragment.`)))}}else Di(this,o.value)}}}},{key:"getConfig",value:function(t){var r=this.getFragmentStyle(t);if(!r)return null;var i=r.stylesheet.schema;if(!i)return null;var n={};for(var a in i){var o=e.av(a,r.scope),s=r.options.get(o),l=s?s.value||s.default:null;n[a]=l?l.serialize():null}return n}},{key:"setConfig",value:function(e,t){var r=this.getFragmentStyle(e);r&&(r.updateConfig(t,r.stylesheet.schema),this.updateConfigDependencies())}},{key:"getSchema",value:function(e){var t=this.getFragmentStyle(e);return t?t.stylesheet.schema:null}},{key:"setSchema",value:function(e,t){var r=this.getFragmentStyle(e);r&&(r.stylesheet.schema=t,r.updateConfig(r._config,t),this.updateConfigDependencies())}},{key:"updateConfig",value:function(t,r){if(this._config=t,t||r)if(r)for(var i in r){var n=void 0,a=void 0,o=e.M(r[i].default);if("success"===o.result&&(n=o.value.expression),t&&void 0!==t[i]){var s=e.M(t[i]);"success"===s.result&&(a=s.value.expression)}var l=r[i],u=l.minValue,c=l.maxValue,h=l.stepValue,f=l.type,d=l.values;if(n){var p=e.av(i,this.scope);this.options.set(p,{default:n,value:a,minValue:u,maxValue:c,stepValue:h,type:f,values:d})}else this.fire(new e.t(new Error(`No schema defined for config option "${i}".`)))}else this.fire(new e.t(new Error("Attempting to set config for a style without schema.")))}},{key:"updateConfigDependencies",value:function(e){for(var t of this._configDependentLayers){var r=this.getLayer(t);if(r){if(e&&!r.configDependencies.has(e))continue;r.possiblyEvaluateVisibility(),this._updateLayer(r)}}this.ambientLight&&this.ambientLight.updateConfig(this.options),this.directionalLight&&this.directionalLight.updateConfig(this.options),this.fog&&this.fog.updateConfig(this.options),this.forEachFragmentStyle((function(e){if(e._styleColorTheme.colorTheme){var 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()}},{key:"addLayer",value:function(t,r){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this._checkLoaded();var n=t.id;if(this._layers[n])this.fire(new e.t(new Error(`Layer with id "${n}" already exists on this map`)));else{var a;if("custom"===t.type){if(Di(this,e.cp(t)))return;a=e.cq(t,this.scope,this._styleColorTheme.lut,this.options)}else{if("object"==typeof t.source&&(this.addSource(n,t.source),t=e.cm(t),t=e.l(t,{source:n})),this._validate(Oe,`layers.${n}`,t,{arrayIndex:-1},i))return;a=e.cq(t,this.scope,this._styleColorTheme.lut,this.options),this._validateLayer(a),a.setEventedParent(this,{layer:{id:n}})}0!==a.configDependencies.size&&this._configDependentLayers.add(a.fqid);var o=this._order.length;if(r){var s=this._order.indexOf(r);if(-1===s)return void this.fire(new e.t(new Error(`Layer with id "${r}" does not exist on this map.`)));a.slot===this._layers[r].slot?o=s:e.w(`Layer with id "${r}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(o,0,n),this._layerOrderChanged=!0,this._layers[n]=a;var l=this.getOwnLayerSourceCache(a),u=!!this.directionalLight&&this.directionalLight.shadowsEnabled();l&&a.canCastShadows()&&u&&(l.castsShadows=!0);var c=this._changes.getRemovedLayer(a);if(c&&a.source&&l&&"custom"!==a.type){this._changes.discardLayerRemoval(a);var h=e.av(a.source,a.scope);c.type!==a.type?this._changes.updateSourceCache(h,"clear"):(this._changes.updateSourceCache(h,"reload"),l.pause())}this._updateLayer(a),a.onAdd&&a.onAdd(this.map),a.scope=this.scope,this.mergeLayers()}}},{key:"moveLayer",value:function(t,r){this._checkLoaded();var i=this._checkLayer(t);if(i&&t!==r){var n=this._order.indexOf(t);this._order.splice(n,1);var a=this._order.length;if(r){var o=this._order.indexOf(r);if(-1===o)return void this.fire(new e.t(new Error(`Layer with id "${r}" does not exist on this map.`)));i.slot===this._layers[r].slot?a=o:e.w(`Layer with id "${r}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(a,0,t),this._changes.setDirty(),this._layerOrderChanged=!0,this.mergeLayers()}}},{key:"removeLayer",value:function(e){this._checkLoaded();var t=this._checkLayer(e);if(t){t.setEventedParent(null);var r=this._order.indexOf(e);this._order.splice(r,1),delete this._layers[e],this._changes.setDirty(),this._layerOrderChanged=!0,this._configDependentLayers.delete(t.fqid),this._changes.removeLayer(t);var i=this.getOwnLayerSourceCache(t);if(i&&i.castsShadows){var n=!1;for(var a in this._layers)if(this._layers[a].source===t.source&&this._layers[a].canCastShadows()){n=!0;break}i.castsShadows=n}t.onRemove&&t.onRemove(this.map),this.mergeLayers()}}},{key:"getOwnLayer",value:function(e){return this._layers[e]}},{key:"hasLayer",value:function(e){return e in this._mergedLayers}},{key:"hasLayerType",value:function(e){for(var t in this._layers)if(this._layers[t].type===e)return!0;return!1}},{key:"setLayerZoomRange",value:function(e,t,r){this._checkLoaded();var i=this._checkLayer(e);i&&(i.minzoom===t&&i.maxzoom===r||(null!=t&&(i.minzoom=t),null!=r&&(i.maxzoom=r),this._updateLayer(i)))}},{key:"getSlots",value:function(){return this._checkLoaded(),this._mergedSlots}},{key:"setSlot",value:function(e,t){this._checkLoaded();var r=this._checkLayer(e);r&&r.slot!==t&&(r.slot=t,this._updateLayer(r))}},{key:"setFilter",value:function(t,r){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this._checkLoaded();var n=this._checkLayer(t);if(n&&!e.bi(n.filter,r))return null==r?(n.filter=void 0,void this._updateLayer(n)):void(this._validate(Fe,`layers.${n.id}.filter`,r,{layerType:n.type},i)||(n.filter=e.cm(r),this._updateLayer(n)))}},{key:"getFilter",value:function(t){var r=this._checkLayer(t);if(r)return e.cm(r.filter)}},{key:"setLayoutProperty",value:function(t,r,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};this._checkLoaded();var a=this._checkLayer(t);if(a&&!e.bi(a.getLayoutProperty(r),i)){if(null!=i&&(!n||!1!==n.validate)&&Di(a,Ne.call(Ie,{key:`layers.${t}.layout.${r}`,layerType:a.type,objectKey:r,value:i,styleSpec:e._,style:{glyphs:!0,sprite:!0}})))return;a.setLayoutProperty(r,i),0!==a.configDependencies.size&&this._configDependentLayers.add(a.fqid),this._updateLayer(a)}}},{key:"getLayoutProperty",value:function(e,t){var r=this._checkLayer(e);if(r)return r.getLayoutProperty(t)}},{key:"setPaintProperty",value:function(t,r,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};this._checkLoaded();var a=this._checkLayer(t);if(a&&!e.bi(a.getPaintProperty(r),i)&&(null==i||n&&!1===n.validate||!Di(a,Be.call(Ie,{key:`layers.${t}.paint.${r}`,layerType:a.type,objectKey:r,value:i,styleSpec:e._})))){var o=a.setPaintProperty(r,i);0!==a.configDependencies.size&&this._configDependentLayers.add(a.fqid),o&&this._updateLayer(a),this._changes.updatePaintProperties(a)}}},{key:"getPaintProperty",value:function(e,t){var r=this._checkLayer(e);if(r)return r.getPaintProperty(t)}},{key:"setFeatureState",value:function(t,r){this._checkLoaded();var i=t.featureset;if(i){if("featuresetId"in i){var n=this.getFragmentStyle(i.importId),a=n.getFeaturesetLayers(i.featuresetId);for(var o of a){var s=o.source,l=o.sourceLayer;n.setFeatureState({id:t.id,source:s,sourceLayer:l},r)}}else if("layerId"in i){var u=this.getLayer(i.layerId);this.setFeatureState({id:t.id,source:u.source,sourceLayer:u.sourceLayer},r)}}else{var c=t.source,h=t.sourceLayer,f=this._checkSource(c);if(f){var d=f.type;if("geojson"===d&&h)this.fire(new e.t(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));else if("vector"!==d||h){void 0===t.id&&this.fire(new e.t(new Error("The feature id parameter must be provided.")));var p=this.getOwnSourceCaches(c);for(var m of p)m.setFeatureState(h,t.id,r)}else this.fire(new e.t(new Error("The sourceLayer parameter must be provided for vector source types.")))}}}},{key:"removeFeatureState",value:function(t,r){this._checkLoaded();var i=t.featureset;if(i){if("featuresetId"in i){var n=this.getFragmentStyle(i.importId),a=n.getFeaturesetLayers(i.featuresetId);for(var o of a){var s=o.source,l=o.sourceLayer;n.removeFeatureState({id:t.id,source:s,sourceLayer:l},r)}}else if("layerId"in i){var u=this.getLayer(i.layerId);this.removeFeatureState({id:t.id,source:u.source,sourceLayer:u.sourceLayer},r)}}else{var c=t.source,h=this._checkSource(c);if(h){var f=h.type,d="vector"===f?t.sourceLayer:void 0;if("vector"!==f||d)if(r&&"string"!=typeof t.id&&"number"!=typeof t.id)this.fire(new e.t(new Error("A feature id is required to remove its specific state property.")));else{var p=this.getOwnSourceCaches(c);for(var m of p)m.removeFeatureState(d,t.id,r)}else this.fire(new e.t(new Error("The sourceLayer parameter must be provided for vector source types.")))}}}},{key:"getFeatureState",value:function(t){this._checkLoaded();var r=t.featureset;if(r){var i;if("featuresetId"in r){var n=this.getFragmentStyle(r.importId),a=n.getFeaturesetLayers(r.featuresetId);for(var o of a){var s=o.source,l=o.sourceLayer,u=n.getFeatureState({id:t.id,source:s,sourceLayer:l});if(u&&!i)i=u;else if(!e.bi(i,u))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){var c=this.getLayer(r.layerId);i=this.getFeatureState({id:t.id,source:c.source,sourceLayer:c.sourceLayer})}return i}var h=t.source,f=t.sourceLayer,d=this._checkSource(h);if(d){if("vector"!==d.type||f)return void 0===t.id&&this.fire(new e.t(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(h)[0].getFeatureState(f,t.id);this.fire(new e.t(new Error("The sourceLayer parameter must be provided for vector source types.")))}}},{key:"setTransition",value:function(t){return this.stylesheet.transition=e.l({},this.stylesheet.transition,t),this.transition=this.stylesheet.transition,this}},{key:"getTransition",value:function(){return e.l({},this.stylesheet.transition)}},{key:"serialize",value:function(){this._checkLoaded();var t=this.getTerrain(),r=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:r,fog:this.stylesheet.fog,center:this.stylesheet.center,"color-theme":this.stylesheet["color-theme"],zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,projection:this.stylesheet.projection,sources:this._serializeSources(),layers:this._serializeLayers(this._order)},(function(e){return void 0!==e}))}},{key:"_updateFilteredLayers",value:function(e){for(var t of Object.values(this._mergedLayers))e(t)&&this._updateLayer(t)}},{key:"_updateLayer",value:function(t){this._changes.updateLayer(t);var r=this.getLayerSourceCache(t),i=e.av(t.source,t.scope),n=this._changes.getUpdatedSourceCaches();t.source&&!n[i]&&r&&"raster"!==r.getSource().type&&(this._changes.updateSourceCache(i,"reload"),r.pause()),t.invalidateCompiledFilter()}},{key:"_flattenAndSortRenderedFeatures",value:function(e){for(var t=this,r=function(e){return t._mergedLayers[e].is3D()},i=this.order,n={},a=[],o=i.length-1;o>=0;o--){var s=i[o];if(r(s))for(var l of(n[s]=o,e)){var u=l[s];if(u)for(var c of u)a.push(c)}}a.sort((function(e,t){return t.intersectionZ-e.intersectionZ}));for(var h=[],f=i.length-1;f>=0;f--){var d=i[f];if(r(d))for(var p=a.length-1;p>=0;p--){var m=a[p].feature;if(m.layer&&n[m.layer.id]2&&void 0!==arguments[2]?arguments[2]:{};this._checkLoaded();var n=this.light.getLight(),a=!1;for(var o in t)if(!e.bi(t[o],n[o])){a=!0;break}if(a){var s=this._getTransitionParameters();this.light.setLight(t,r,i),this.light.updateTransitions(s)}}},{key:"getTerrain",value:function(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}},{key:"setTerrainForDraping",value:function(){this.setTerrain({source:"",exaggeration:0},0)}},{key:"checkCanvasFingerprintNoise",value:function(){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)."))}},{key:"setTerrain",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(this._checkLoaded(),!t)return this.terrainSetForDrapingOnly()||(delete this.terrain,this.map.transform.projection.requiresDraping&&this.setTerrainForDraping()),0===r&&delete this.terrain,null===t?this.stylesheet.terrain=null:delete this.stylesheet.terrain,this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);this.checkCanvasFingerprintNoise();var i=t,n=null==t.source;if(1===r){if(this.disableElevatedTerrain)return;if("object"==typeof i.source){var a="terrain-dem-src";this.addSource(a,i.source),i=e.cm(i),i=e.l(i,{source:a})}var o=e.l({},i),s={};if(this.terrain&&n){o.source=this.terrain.get().source;var l=this.terrain?this.getFragmentStyle(this.terrain.scope):null;l&&(s.style=l.serialize())}if(this._validate(Re,"terrain",o,s))return}if(!this.terrain||this.terrain.scope!==this.scope&&!n||this.terrain&&r!==this.terrain.drapeRenderMode){if(!i)return;this._createTerrain(i,r),this.fire(new e.x("data",{dataType:"style"}))}else{var u=this.terrain,c=u.get();for(var h of Object.keys(e._.terrain))!i.hasOwnProperty(h)&&e._.terrain[h].default&&(i[h]=e._.terrain[h].default);for(var f in t)if(!e.bi(t[f],c[f])){u.set(t,this.options),this.stylesheet.terrain=t;var d=this._getTransitionParameters({duration:0});u.updateTransitions(d),this.fire(new e.x("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0}},{key:"_createFog",value:function(e){var t=this.fog=new Ke(e,this.map.transform,this.scope,this.options);this.stylesheet.fog=t.get();var r=this._getTransitionParameters({duration:0});t.updateTransitions(r)}},{key:"_updateMarkersOpacity",value:function(){var e=this;0!==this.map._markers.length&&this.map._requestDomTask((function(){for(var t of e.map._markers)t._evaluateOpacity()}))}},{key:"getFog",value:function(){return this.fog?this.fog.get():null}},{key:"setFog",value:function(t){if(this._checkLoaded(),!t)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){var r=this.fog;if(!e.bi(r.get(),t)){r.set(t,this.options),this.stylesheet.fog=r.get();var i=this._getTransitionParameters({duration:0});r.updateTransitions(i)}}else this._createFog(t);this._markersNeedUpdate=!0}},{key:"setColorTheme",value:function(t){var r=this;this._checkLoaded();var i=function(){for(var e in r._layers)r._layers[e].lut=r._styleColorTheme.lut;for(var t in r._sourceCaches)r._sourceCaches[t].clearTiles()};if(this._styleColorTheme.colorTheme=t,!t)return this._styleColorTheme.lut=null,void i();var n=this._evaluateColorThemeData(t);this._loadColorTheme(n).then((function(){r.fire(new e.x("colorthemeset")),i()})).catch((function(t){e.w(`Couldn't set color theme: ${t}`)}))}},{key:"_getTransitionParameters",value:function(t){return{now:e.q.now(),transition:e.l(this.transition,t)}}},{key:"updateDrapeFirstLayers",value:function(){var e,t;if(this.terrain){var r=[],i=[];for(var n of this._mergedOrder)this.isLayerDraped(this._mergedLayers[n])?r.push(n):i.push(n);this._drapedFirstOrder=[],(e=this._drapedFirstOrder).push.apply(e,r),(t=this._drapedFirstOrder).push.apply(t,i)}}},{key:"_createTerrain",value:function(e,t){var r=this.terrain=new qe(e,t,this.scope,this.options);1===t&&(this.stylesheet.terrain=e),this.mergeTerrain(),this.updateDrapeFirstLayers(),this._force3DLayerUpdate();var i=this._getTransitionParameters({duration:0});r.updateTransitions(i)}},{key:"_force3DLayerUpdate",value:function(){for(var e in this._layers){var t=this._layers[e];"fill-extrusion"===t.type&&this._updateLayer(t)}}},{key:"_forceSymbolLayerUpdate",value:function(){for(var e in this._layers){var t=this._layers[e];"symbol"===t.type&&this._updateLayer(t)}}},{key:"_validate",value:function(t,r,i,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};if(a&&!1===a.validate)return!1;var o=e.l({},this.serialize());return Di(this,t.call(Ie,e.l({key:r,style:o,value:i,styleSpec:e._},n)))}},{key:"_remove",value:function(){for(var t in this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),e.cs.off("pluginStateChange",this._rtlTextPluginCallback),this._mergedLayers)this._mergedLayers[t].setEventedParent(null);for(var r in this._mergedSourceCaches)this._mergedSourceCaches[r].clearTiles(),this._mergedSourceCaches[r].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())}},{key:"clearSource",value:function(e){var t=this.getSourceCaches(e);for(var r of t)r.clearTiles()}},{key:"clearSources",value:function(){for(var e in this._mergedSourceCaches)this._mergedSourceCaches[e].clearTiles()}},{key:"reloadSource",value:function(e){var t=this.getSourceCaches(e);for(var r of t)r.resume(),r.reload()}},{key:"reloadSources",value:function(){for(var e of this.getSources())e.reload&&e.reload()}},{key:"updateSources",value:function(e){var t;for(var r in this.directionalLight&&(t=Ai(this.directionalLight)),this._mergedSourceCaches)this._mergedSourceCaches[r].update(e,void 0,void 0,t)}},{key:"_generateCollisionBoxes",value:function(){for(var e in this._sourceCaches){var t=this._sourceCaches[e];t.resume(),t.reload()}}},{key:"_updatePlacement",value:function(t,r,i,n,a,o){var s=this,l=arguments.length>6&&void 0!==arguments[6]&&arguments[6],u=!1,c=!1,h={},f={},d=function(){var t=s._mergedLayers[p];if("symbol"!==t.type)return 0;var i=e.av(t.source,t.scope),n=h[i];if(!n){var a=s.getLayerSourceCache(t);if(!a)return 0;var o=a.getRenderableIds(!0).map((function(e){return a.getTileByID(e)}));f[i]=o.slice(),n=h[i]=o.sort((function(e,t){return t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1)}))}var l=s.crossTileSymbolIndex.addLayer(t,n,r.center.lng,r.projection);u=u||l};for(var p of this._mergedOrder)d();if(this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder),l=l||this._layerOrderChanged||0===n,this._layerOrderChanged&&this.fire(new e.x("neworder")),(l||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(e.q.now(),r.zoom))&&(this.pauseablePlacement=new $r(r,this._mergedOrder,l,i,n,a,this.placement,this.fog&&r.projection.supportsFog?this.fog.state:null,this._buildingIndex),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._mergedOrder,this._mergedLayers,h,f,this.map.painter.scaleFactor),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(e.q.now()),c=!0),u&&this.pauseablePlacement.placement.setStale()),c||u){this._buildingIndex.onNewFrame(r.zoom);for(var m=0;m=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:nn("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:nn('#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:nn('#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:nn('#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:nn('#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:nn('#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:nn("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:nn('#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:nn('#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:nn("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:nn("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:nn('#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:nn('#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:nn('#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:nn('#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:nn('#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:nn("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:nn("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:nn('#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:nn('#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:nn('#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:nn("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:nn('#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}',ji),skyboxGradient:nn('#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}',ji),skyboxCapture:nn("\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:nn('#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:nn('#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:nn('#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:nn("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:nn("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:nn("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:nn("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:nn("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 rn(e,t){var r=e.replace(/\s*\/\/[^\n]*\n/g,"\n").split("\n");for(var i of r)if("#"===(i=i.trim())[0]&&i.includes("if")&&!i.includes("endif")){var n=(i=i.replace("#","").replace(/ifdef|ifndef|elif|if/g,"").replace(/!|defined|\(|\)|\|\||&&/g,"").replace(/\s+/g," ").trim()).split(" ");for(var a of n)t.includes(a)||t.push(a)}}function nn(e,t){var r=/#include\s+"([^"]+)"/g,i=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g,n=t.match(/(attribute(\S*)|(^\s*|;)in) (highp |mediump |lowp )?([\w]+) ([\w]+)/gm);n&&(n=n.map((function(e){var t=e.split(" ");return t[t.length-1]})),n=d(new Set(n)));var a={},o=[],s=[];if(e=e.replace(r,(function(e,t){return s.push(t),""})),!(t=t.replace(r,(function(e,t){return o.push(t),""}))).includes("flat out")){var l=[].concat(Yi);for(var u of(rn(e,l),rn(t,l),[].concat(o,s)))Ji[u]||console.error(`Undefined include: ${u}`),Ki[u]||(Ki[u]=[],rn(Ji[u],Ki[u])),l=[].concat(d(l),d(Ki[u]));return{fragmentSource:e=e.replace(i,(function(e,t,r,i,n){return a[n]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nin ${r} ${i} ${n};\n#else\nuniform ${r} ${i} u_${n};\n#endif\n`:"initialize"===t?`\n#ifdef HAS_UNIFORM_u_${n}\n ${r} ${i} ${n} = u_${n};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n in ${r} ${i} ${n};\n#endif\n`:"initialize-attribute"===t?"":void 0})),vertexSource:t=t.replace(i,(function(e,t,r,i,n){var o="float"===i?"vec2":i,s=n.match(/color/)?"color":o;return"define-attribute-vertex-shader-only"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\nin ${r} ${i} a_${n};\n#endif\n`:a[n]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nin ${r} ${o} a_${n};\nout ${r} ${i} ${n};\n#else\nuniform ${r} ${i} u_${n};\n#endif\n`:"initialize"===t?"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = a_${n};\n#else\n ${r} ${i} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = unpack_mix_${s}(a_${n}, u_${n}_t);\n#else\n ${r} ${i} ${n} = u_${n};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n in ${r} ${i} a_${n};\n out ${r} ${i} ${n};\n#endif\n`:"initialize-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n ${n} = a_${n};\n#endif\n`:void 0:"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nin ${r} ${o} a_${n};\n#else\nuniform ${r} ${i} u_${n};\n#endif\n`:"define-instanced"===t?"mat4"===s?`\n#ifdef INSTANCED_ARRAYS\nin vec4 a_${n}0;\nin vec4 a_${n}1;\nin vec4 a_${n}2;\nin vec4 a_${n}3;\n#else\nuniform ${r} ${i} u_${n};\n#endif\n`:`\n#ifdef INSTANCED_ARRAYS\nin ${r} ${o} a_${n};\n#else\nuniform ${r} ${i} u_${n};\n#endif\n`:"initialize-attribute-custom"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n ${r} ${i} ${n} = a_${n};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${n}\n ${r} ${i} ${n} = a_${n};\n#else\n ${r} ${i} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${r} ${i} ${n} = unpack_mix_${s}(a_${n}, u_${n}_t);\n#else\n ${r} ${i} ${n} = u_${n};\n#endif\n`})),staticAttributes:n,usedDefines:l,vertexIncludes:o,fragmentIncludes:s}}console.error('The usage of "flat" qualifier is disallowed, see: https://bugs.webkit.org/show_bug.cgi?id=268071')}var an=(function(){return m((function e(){p(this,e),this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}),[{key:"bind",value:function(e,t,r,i,n,a,o,s){this.context=e;for(var l=this.boundPaintVertexBuffers.length!==i.length,u=0;!l&&u=1||!this._validOp(r);)if(!this._nextOp(r,e)){delete this.operations[t];break}}}},{key:"_nextOp",value:function(e,t){return!!e.queued&&(e.from=e.to,e.to=e.queued,e.queued=null,e.phase=0,e.startTime=t,!0)}},{key:"_validOp",value:function(e){return e.from.hasData()&&e.to.hasData()}}])})()),Jn={0:null,1:"TERRAIN_VERTEX_MORPHING"};function Kn(e,t,r){if(0===t)return 0;var i=t<1&&514===r?.25/t:1;return 6*Math.pow(1.5,22-e)*Math.max(t,1)*i}function Qn(e,t){var r=1<0){var o=e.q.now(),s=(o-t.timeAdded)/a,l=r?(o-r.timeAdded)/a:-1,u=i.getSource(),c=n.coveringZoomLevel({tileSize:u.tileSize,roundZoom:u.roundZoom}),h=!r||Math.abs(r.tileID.overscaledZ-c)>Math.abs(t.tileID.overscaledZ-c),f=h&&t.refreshedUponExpiration?1:e.ap(h?s:1-l,0,1);return t.refreshedUponExpiration&&s>=1&&(t.refreshedUponExpiration=!1),r?{opacity:1,mix:1-f}:{opacity:f,mix:0}}return{opacity:1,mix:0}}var ra=(function(t){function r(t){var i;p(this,r);var n={type:"raster-dem",maxzoom:t.transform.maxZoom},a=new e.ce(e.cf(),null),o=ct("mock-dem",n,a,t.style);return i=T(this,r,["mock-dem",o,!1]),o.setEventedParent(l(i)),i._sourceLoaded=!0,i}return g(r,t),m(r,[{key:"_loadTile",value:function(e,t){e.state="loaded",t(null)}}])})(Nt),ia=(function(t){function r(t){var i;p(this,r);var n=ct("proxy",{type:"geojson",maxzoom:t.transform.maxZoom},new e.ce(e.cf(),null),t.style);return i=T(this,r,["proxy",n,!1]),n.setEventedParent(l(i)),i.map=i.getSource().map=t,i.used=i._sourceLoaded=!0,i.renderCache=[],i.renderCachePool=[],i.proxyCachedFBO={},i}return g(r,t),m(r,[{key:"update",value:function(e,t,r){var i=this;if(!e.freezeTileCoverage){this.transform=e;var n=e.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((function(t,r){if(t[r.key]="",!i._tiles[r.key]){var n=new Lt(r,i._source.tileSize*r.overscaleFactor(),e.tileZoom);n.state="loaded",i._tiles[r.key]=n}return t}),{});for(var a in this._tiles)a in n||(this.freeFBO(a),this._tiles[a].unloadVectorData(),delete this._tiles[a])}}},{key:"freeFBO",value:function(e){var t=this.proxyCachedFBO[e];if(void 0!==t){var r,i=Object.values(t);(r=this.renderCachePool).push.apply(r,i),delete this.proxyCachedFBO[e]}}},{key:"deallocRenderCache",value:function(){this.renderCache.forEach((function(e){return e.fb.destroy()})),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}])})(Nt),na=(function(e){function t(e,r,i){var n;return p(this,t),(n=T(this,t,[e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y])).proxyTileKey=r,n.projMatrix=i,n}return g(t,e),m(t)})(e.aA),aa=(function(t){function r(t,i){var n;p(this,r),(n=T(this,r))._debugParams={sortTilesHiZFirst:!0,disableRenderCache:!1},t.tp.registerParameter(n._debugParams,["Terrain"],"sortTilesHiZFirst",{},(function(){n._style.map.triggerRepaint()})),t.tp.registerParameter(n._debugParams,["Terrain"],"disableRenderCache",{},(function(){n._style.map.triggerRepaint()})),t.tp.registerButton(["Terrain"],"Invalidate Render Cache",(function(){n.invalidateRenderCache=!0,n._style.map.triggerRepaint()})),n.painter=t,n.terrainTileForTile={},n.prevTerrainTileForTile={};var a=(function(){var t=new e.a$,r=new e.aP,i=131;t.reserve(17161),r.reserve(33800);for(var n=e.ab/128,a=e.ab+n/2,o=a+n,s=-n;sa||s<0||s>a?24575:0,c=e.ap(Math.round(l),0,e.ab),h=e.ap(Math.round(s),0,e.ab);t.emplaceBack(c+u,h)}for(var f=function(e,t){var n=t*i+e;r.emplaceBack(n+1,n,n+i),r.emplaceBack(n+i,n+i+1,n+1)},d=1;d<129;d++)for(var p=1;p<129;p++)f(p,d);return[0,129].forEach((function(e){for(var t=0;t<130;t++)f(t,e),f(e,t)})),[t,r,32768]})(),o=x(a,3),s=o[0],l=o[1],u=o[2],c=t.context;n.gridBuffer=c.createVertexBuffer(s,e.b1.members),n.gridIndexBuffer=c.createIndexBuffer(l),n.gridSegments=e.b2.simpleSegment(0,0,s.length,l.length),n.gridNoSkirtSegments=e.b2.simpleSegment(0,0,s.length,u),n.proxyCoords=[],n.proxiedCoords={},n._visibleDemTiles=[],n._drapedRenderBatches=[],n._sourceTilesOverlap={},n.proxySourceCache=new ia(i.map),n.orthoMatrix=e.a6.mat4.create(),e.a6.mat4.ortho(n.orthoMatrix,"globe"===n.painter.transform.projection.name?.015:0,e.ab,0,e.ab,0,1);var h=c.gl;return n._overlapStencilMode=new ri({func:h.GEQUAL,mask:255},0,255,h.KEEP,h.KEEP,h.REPLACE),n._previousZoom=t.transform.zoom,n.pool=[],n._findCoveringTileCache={},n._tilesDirty={},n.style=i,n._useVertexMorphing=!0,n._exaggeration=1,n._mockSourceCache=new ra(i.map),n._pendingGroundEffectLayers=[],n}return g(r,t),m(r,[{key:"style",set:function(e){var t=this;e.on("data",this._onStyleDataEvent.bind(this)),this._style=e,this._style.map.on("moveend",(function(){t._clearLineLayersFromRenderCache()}))}},{key:"update",value:function(t,r,i){var n=this;if(t&&t.terrain){this._style!==t&&(this.style=t,this._evaluationZoom=void 0);var a=t.terrain.properties,o=0===t.terrain.drapeRenderMode,s=t.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=e.q.now();var l=t.terrain&&t.terrain.scope,u=a.get("source"),c=o?this._mockSourceCache:t.getSourceCache(u,l);if(!c)return void e.w(`Couldn't find terrain source "${u}".`);if(this.sourceCache=c,this._attenuationRange=t.terrain.getAttenuationRange(),this._exaggeration=s?this.calculateExaggeration(r):a.get("exaggeration"),!r.projection.requiresDraping&&s&&0===this._exaggeration)return void this._disable();this.enabled=!0;var h=function(){n.sourceCache.used&&e.w(`Raster DEM source '${n.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.`);var t=n.getScaledDemTileSize();n.sourceCache.update(r,t,!0),n.resetTileLookupCache(n.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,h(),this._initializing=!0),h(),r.updateElevation(!0,i),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(r),this._emptyDEMTextureDirty=!0,this._previousZoom=r.zoom}else this._disable()}},{key:"calculateExaggeration",value:function(t){if(this._attenuationRange&&t.zoom>=Math.ceil(this._attenuationRange[1]))return this._style.terrain.getExaggeration(t.zoom);var r=this._previousCameraAltitude,i=t.getFreeCameraOptions().position.z/t.pixelsPerMeter*t.worldSize;this._previousCameraAltitude=i;var n=null!=r?i-r:Number.MAX_VALUE;if(Math.abs(n)<2)return this._exaggeration;var a=t.zoom,o=this._style.terrain;if(!this._previousUpdateTimestamp)return o.getExaggeration(a);var s=a-this._previousZoom,l=this._previousUpdateTimestamp,u=a;null!=this._evaluationZoom&&(u=this._evaluationZoom,Math.abs(a-u)>.5&&(s=.5*(a-u+s)),s*n<0&&(u+=s)),this._evaluationZoom=u;var c=o.getExaggeration(u),h=c===o.getExaggeration(Math.max(0,u-.1));if(h&&Math.abs(c-this._exaggeration)<.01)return c;var f=Math.min(.1,.00375*(this._updateTimestamp-l));return(h||c<.1||Math.abs(s)<1e-4)&&(f=Math.min(.2,4*f)),e.aa(this._exaggeration,c,f)}},{key:"resetTileLookupCache",value:function(e){this._findCoveringTileCache[e]={}}},{key:"attenuationRange",value:function(){return this._attenuationRange}},{key:"getDemUpscale",value:function(){return this.proxySourceCache.getSource().tileSize/128}},{key:"getScaledDemTileSize",value:function(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}},{key:"_onStyleDataEvent",value:function(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)}},{key:"_disable",value:function(){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(var e in this._style._mergedSourceCaches)this._style._mergedSourceCaches[e].usedForTerrain=!1}},{key:"destroy",value:function(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this.pool.forEach((function(e){return e.fb.destroy()})),this.pool=[],this.framebufferCopyTexture&&this.framebufferCopyTexture.destroy()}},{key:"_source",value:function(){return this.enabled?this.sourceCache:null}},{key:"isUsingMockSource",value:function(){return this.sourceCache===this._mockSourceCache}},{key:"exaggeration",value:function(){return this.enabled?this._exaggeration:0}},{key:"visibleDemTiles",get:function(){return this._visibleDemTiles}},{key:"drapeBufferSize",get:function(){var e=2*this.proxySourceCache.getSource().tileSize;return[e,e]}},{key:"useVertexMorphing",set:function(e){this._useVertexMorphing=e}},{key:"updateTileBinding",value:function(t){var r=this;if(this.enabled){this.prevTerrainTileForTile=this.terrainTileForTile;var i=this.proxySourceCache,n=this.painter.transform;this._initializing&&(this._initializing=0===n._centerAltitude&&-1===this.getAtPointOrZero(e.a5.fromLngLat(n.center),-1),this._emptyDEMTextureDirty=!this._initializing);var a=this.proxyCoords=i.getIds().map((function(e){var t=i.getTileByID(e).tileID;return t.projMatrix=n.calculateProjMatrix(t.toUnwrapped()),t}));!(function(t,r){var i=r.transform.pointCoordinate(r.transform.getCameraPoint()),n=new e.P(i.x,i.y);t.sort((function(t,r){if(r.overscaledZ-t.overscaledZ)return r.overscaledZ-t.overscaledZ;var i=new e.P(t.canonical.x+(1<0&&e++,t+i}),0);return e?t/e:0}},{key:"_updateEmptyDEMTexture",value:function(){var t=this.painter.context,r=t.gl;t.activeTexture.set(r.TEXTURE2);var i=this._getLoadedAreaMinimum(),n=new e.cF({width:1,height:1},new Float32Array([i]));this._emptyDEMTextureDirty=!1;var a=this._emptyDEMTexture;return a?a.update(n,{premultiply:!1}):a=this._emptyDEMTexture=new e.T(t,n,r.R32F,{premultiply:!1}),a}},{key:"setupElevationDraw",value:function(t,r,i){var n=this,a=this.painter.context,o=a.gl,s={u_dem:2,u_dem_prev:4,u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_depth_range_unpack:[0,1],u_occluder_half_size:16,u_occlusion_depth_offset:-1e-4,u_exaggeration:0};s.u_exaggeration=this.exaggeration();var l=null,u=null,c=1;if(i&&i.morphing&&this._useVertexMorphing){var h=i.morphing.srcDemTile,f=i.morphing.dstDemTile;c=i.morphing.phase,h&&f&&(this._prepareDemTileUniforms(t,h,s,"_prev")&&(u=h),this._prepareDemTileUniforms(t,f,s)&&(l=f))}var d,p=function(e){return e&&e.demTexture&&n.painter.linearFloatFilteringSupported()?o.LINEAR:o.NEAREST},m=null;if(this.enabled?u&&l?(m=l.demTexture,a.activeTexture.set(o.TEXTURE4),u.demTexture.bind(p(u),o.CLAMP_TO_EDGE),s.u_dem_lerp=c):(l=this.terrainTileForTile[t.tileID.key],m=this._prepareDemTileUniforms(t,l,s)?l.demTexture:this.emptyDEMTexture):m=this.emptyDEMTexture,a.activeTexture.set(o.TEXTURE2),m&&(s.u_dem_size=1===(d=m).size[0]?1:d.size[0]-2,m.bind(p(l),o.CLAMP_TO_EDGE)),this.painter.setupDepthForOcclusion(i&&i.useDepthForOcclusion,r,s),i&&i.useMeterToDem&&l){var v=(1<r}},{key:"getMinElevationBelowMSL",value:function(){var e=0;return this._visibleDemTiles.filter((function(e){return e.dem})).forEach((function(t){e=Math.min(e,t.dem.tree.minimums[0])})),0===e?e:(e-30)*this._exaggeration}},{key:"raycast",value:function(e,t,r){if(!this._visibleDemTiles)return null;var i=this._visibleDemTiles.filter((function(e){return e.dem})).map((function(i){var n=i.tileID,a=1<l.end}))||e.w("fill-extrusion with flood lighting and/or ground ambient occlusion should be moved to be on top of all draped layers.")}this._drapedRenderBatches=i}}},{key:"_setupRenderCache",value:function(e){var t=this.proxySourceCache;if(this._shouldDisableRenderCache()||this.invalidateRenderCache){if(this.invalidateRenderCache=!1,t.renderCache.length>t.renderCachePool.length){var r=Object.values(t.proxyCachedFBO);t.proxyCachedFBO={};for(var i=0;i=0;l--){var u=o[l];if(t.getTileByID(u.key),void 0!==t.proxyCachedFBO[u.key]){var c=e[u.key],h=this.proxyToSource[u.key],f=0,p=function(e){var t=h[e],r=c[e];if(!r||r.length!==t.length||t.some((function(t,i){return t!==r[i]||s[e]&&s[e].hasOwnProperty(t.key)})))return f=-1,1;++f};for(var m in h)if(p(m))break;for(var v in t.proxyCachedFBO[u.key])t.renderCache[t.proxyCachedFBO[u.key][v]].dirty=f<0||f!==Object.values(c).length}}var _=d(this._drapedRenderBatches);for(var g of(_.sort((function(e,t){return t.end-t.start-(e.end-e.start)})),_))for(var y of o)if(!t.proxyCachedFBO[y.key]){var x=t.renderCachePool.pop();void 0===x&&t.renderCache.length<50&&(x=t.renderCache.length,t.renderCache.push(this._createFBO())),void 0!==x&&(t.proxyCachedFBO[y.key]={},t.proxyCachedFBO[y.key][g.start]=x,t.renderCache[x].dirty=!0)}this._tilesDirty={}}}},{key:"_setupStencil",value:function(e,t,r,i){if(i&&this._sourceTilesOverlap[i.id]){var n=this.painter.context,a=n.gl;if(t.length<=1)this._overlapStencilType=!1;else{var o;if(r.isTileClipped())o=t.length,this._overlapStencilMode.test={func:a.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(t[0].overscaledZ>t[t.length-1].overscaledZ))return void(this._overlapStencilType=!1);o=1,this._overlapStencilMode.test={func:a.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+o>255&&(n.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=o,this._overlapStencilMode.ref=this._stencilRef,r.isTileClipped()&&this._renderTileClippingMasks(t,this._overlapStencilMode.ref)}}else this._overlapStencilType&&(this._overlapStencilType=!1)}},{key:"clipOrMaskOverlapStencilType",value:function(){return"Clip"===this._overlapStencilType||"Mask"===this._overlapStencilType}},{key:"stencilModeForRTTOverlap",value:function(e){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[e.key]),this._overlapStencilMode):ri.disabled}},{key:"_renderTileClippingMasks",value:function(e,t){var r=this.painter,i=this.painter.context,n=i.gl;r._tileClippingMaskIDs={},i.setColorMode(Qr.disabled),i.setDepthMode(ei.disabled);var a=r.getOrCreateProgram("clippingMask");for(var o of e){var s=r._tileClippingMaskIDs[o.key]=--t;a.draw(r,n.TRIANGLES,ei.disabled,new ri({func:n.ALWAYS,mask:0},s,255,n.KEEP,n.KEEP,n.REPLACE),Qr.disabled,ai.disabled,ea(o.projMatrix),"$clipping",r.tileExtentBuffer,r.quadTriangleIndexBuffer,r.tileExtentSegments)}}},{key:"pointCoordinate",value:function(t){var r=this.painter.transform;if(t.x<0||t.x>r.width||t.y<0||t.y>r.height)return null;var i=[t.x,t.y,1,1];e.a6.vec4.transformMat4(i,i,r.pixelMatrixInverse),e.a6.vec4.scale(i,i,1/i[3]),i[0]/=r.worldSize,i[1]/=r.worldSize;var n=r._camera.position,a=e.bE(1,r.center.lat),o=[n[0],n[1],n[2]/a,0],s=e.a6.vec3.subtract([],i.slice(0,3),o);e.a6.vec3.normalize(s,s);var l=this.raycast(o,s,this._exaggeration);return null!==l&&l?(e.a6.vec3.scaleAndAdd(o,o,s,l),o[3]=o[2],o[2]*=a,o):null}},{key:"_setupProxiedCoordsForOrtho",value:function(t,r,i){if(t.getSource()instanceof e.aD)return this._setupProxiedCoordsForImageSource(t,r,i);this._findCoveringTileCache[t.id]=this._findCoveringTileCache[t.id]||{};for(var n=this.proxiedCoords[t.id]=[],a=this.proxyCoords,o=0;oo+u.max.x||n+as+u.max.y},h=0;h0?(s=(o=e.ab>>u)*((r.tileID.canonical.x<=c){var h=t.canonical.z-c;r.getSource().reparseOverscaled?(s=Math.max(t.canonical.z+2,r.transform.tileZoom),o=new e.aA(s,t.wrap,c,t.canonical.x>>h,t.canonical.y>>h)):0!==h&&(s=c,o=new e.aA(s,t.wrap,c,t.canonical.x>>h,t.canonical.y>>h))}o.key!==t.key&&(u.push(o.key),i=r.getTile(o))}var f=function(e){u.forEach((function(t){n[t]=e})),u.length=0};for(s-=1;s>=l&&(!i||!i.hasData());s--){i&&f(i.tileID.key);var d=o.calculateScaledKey(s);if((i=r.getTileByID(d))&&i.hasData())break;var p=n[d];if(null===p)break;void 0===p?u.push(d):i=r.getTileByID(p)}return f(i?i.tileID.key:null),i&&i.hasData()?i:null}},{key:"findDEMTileFor",value:function(e){return this.enabled?this._findTileCoveringTileID(e,this.sourceCache):null}},{key:"prepareDrawTile",value:function(){this.renderedToTile=!0}},{key:"_clearRenderCacheForTile",value:function(e,t){var r=this._tilesDirty[e];r||(r=this._tilesDirty[e]={}),r[t.key]=!0}}])})(e.cE);function oa(t,r,i){var n=(function(t,r,i){var n=e.a6.vec3.dot(r,t),a=e.a6.vec3.dot(i,[.2126,.7152,.0722]),o=function(e,t,r){return(1-r)*e+r*t},s=o(1-.3*Math.min(a,1),1,Math.min(n+1,1));return o(.92,1,Math.asin(e.ap(r[2],-1,1))/Math.PI+.5)*s})(t,[0,0,1],r),a=[0,0,0];e.a6.vec3.scale(a,i.slice(0,3),n);var o=[0,0,0];e.a6.vec3.scale(o,r.slice(0,3),t[2]);var s=[0,0,0];return e.a6.vec3.add(s,a,o),e.cc(s)}var sa=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],la=["stars","rain_particle","snow_particle","fillExtrusion","fillExtrusionGroundEffect","model","symbol"],ua=(function(){return m((function t(r,i,n,a,o,s){p(this,t);var l=r.gl;this.program=l.createProgram(),this.configuration=a,this.name=i,this.fixedDefines=d(s);var u=a?a.getBinderAttributes():[],c=(n.staticAttributes||[]).concat(u),h=a?a.defines():[];h=h.concat(s.map((function(e){return`#define ${e}`})));var f="#version 300 es\n",m=f+h.concat("precision mediump float;",en,Qi.fragmentSource).join("\n");for(var v of n.fragmentIncludes)m+=`\n${Ji[v]}`;m+=`\n${n.fragmentSource}`;var _=f+h.concat("precision highp float;",en,Qi.vertexSource).join("\n");for(var g of n.vertexIncludes)_+=`\n${Ji[g]}`;_+=`\n${n.vertexSource}`;var y=l.createShader(l.FRAGMENT_SHADER);if(l.isContextLost())this.failedToCreate=!0;else{l.shaderSource(y,m),l.compileShader(y),l.attachShader(this.program,y);var x=l.createShader(l.VERTEX_SHADER);if(l.isContextLost())this.failedToCreate=!0;else{l.shaderSource(x,_),l.compileShader(x),l.attachShader(this.program,x),this.attributes={},this.numAttributes=c.length;for(var b=0;b1?m.drawElementsInstanced(m.LINES,x,m.UNSIGNED_SHORT,b,c):m.drawElements(m.LINES,x,m.UNSIGNED_SHORT,b),a.bind(),p.program.set(this.program),p.setDepthMode(r),p.setStencilMode(i),p.setColorMode(n)}}}}},{key:"checkUniforms",value:function(e,t,r){if(this.fixedDefines.includes(t))for(var i of Object.keys(r))if(!r[i].initialized)throw new Error(`Program '${this.name}', from draw '${e}': uniform ${i} not set but required by ${t} being defined`)}},{key:"draw",value:function(e,t,r,i,n,a,o,l,u,c,h,f,d,p,m,v){var _=e.context,g=_.gl;if(!this.failedToCreate){for(var y of(_.program.set(this.program),_.setDepthMode(r),_.setStencilMode(i),_.setColorMode(n),_.setCullFace(a),Object.keys(this.fixedUniforms)))this.fixedUniforms[y].set(this.program,y,o[y]);p&&p.setUniforms(this.program,_,this.binderUniforms,f,{zoom:d});var x=s(s(s(s({},g.POINTS,1),g.LINES,2),g.TRIANGLES,3),g.LINE_STRIP,1)[t];this.checkUniforms(l,"RENDER_SHADOWS",this.shadowUniforms);var b=v&&v>0?1:void 0;for(var w of h.get()){var k=w.vaos||(w.vaos={});(k[l]||(k[l]=new an)).bind(_,this,u,p?p.getPaintVertexBuffers():[],c,w.vertexOffset,m||[],b),v&&v>1?g.drawElementsInstanced(t,w.primitiveLength*x,g.UNSIGNED_SHORT,w.primitiveOffset*x*2,v):c?g.drawElements(t,w.primitiveLength*x,g.UNSIGNED_SHORT,w.primitiveOffset*x*2):g.drawArrays(t,w.vertexOffset,w.vertexLength),t===g.TRIANGLES&&c&&this._drawDebugWireframe(e,r,i,n,c,w,f,d,p,v)}}}}],[{key:"cacheKey",value:function(e,t,r,i){var n=`${t}${i?i.cacheKey:""}`;for(var a of r)e.usedDefines.includes(a)&&(n+=`/${a}`);return n}}])})();function ca(t,r){var i=Math.pow(2,r.tileID.overscaledZ),n=r.tileSize*Math.pow(2,t.transform.tileZoom)/i,a=n*(r.tileID.canonical.x+r.tileID.wrap*i),o=n*r.tileID.canonical.y;return{u_image:0,u_texsize:r.imageAtlasTexture?r.imageAtlasTexture.size:[0,0],u_tile_units_to_pixels:1/e.ak(r,1,t.transform.tileZoom),u_pixel_coord_upper:[a>>16,o>>16],u_pixel_coord_lower:[65535&a,65535&o]}}var ha={terrain:0,flat:1},fa=e.a6.mat4.create(),da=function(t,r,i,n,a,o,s,l,u,c,h,f,d,p,m,v,_,g){var y=r.style.light,x=y.properties.get("position"),b=[x.x,x.y,x.z],w=e.a6.mat3.create();"viewport"===y.properties.get("anchor")&&(e.a6.mat3.fromRotation(w,-r.transform.angle),e.a6.vec3.transformMat3(b,b,w));var k=y.properties.get("color"),T=r.transform,S={u_matrix:t,u_lightpos:b,u_lightintensity:y.properties.get("intensity"),u_lightcolor:[k.r,k.g,k.b],u_vertical_gradient:+i,u_opacity:n,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:fa,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_height_type:ha[c],u_base_type:ha[h],u_ao:a,u_edge_radius:o,u_width_scale:s,u_flood_light_color:m,u_vertical_scale:v,u_flood_light_intensity:_,u_ground_shadow_factor:g};return"globe"===T.projection.name&&(S.u_tile_id=[l.canonical.x,l.canonical.y,1<2&&void 0!==arguments[2]?arguments[2]:1;return{u_matrix:e,u_color:t.toRenderColor(null),u_overlay:0,u_overlay_scale:r}},wa=e.a6.mat4.create(),ka=function(t,r,i,n,a,o,s){var l=t.transform,u="globe"===l.projection.name,c=u?e.cI(l.zoom,r.canonical)*l._pixelsPerMercatorPixel:e.ak(i,1,o),h={u_matrix:r.projMatrix,u_extrude_scale:c,u_intensity:s,u_inv_rot_matrix:wa,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(u){h.u_inv_rot_matrix=n,h.u_merc_center=a,h.u_tile_id=[r.canonical.x,r.canonical.y,1<>16,d>>16],u_pixel_coord_lower:[65535&f,65535&d]}})(0,o,s,n,l,u),{u_matrix:t,u_emissive_strength:r,u_opacity:i})},Oa=new Float32Array(e.a6.mat4.identity([])),Fa=function(t,r,i,n,a,o,s,l,u,c,h,f,d){var p=arguments.length>13&&void 0!==arguments[13]?arguments[13]:[0,0,0],m=arguments.length>14?arguments[14]:void 0,v=a.style.light,_=v.properties.get("position"),g=[-_.x,-_.y,_.z],y=e.a6.mat3.create();"viewport"===v.properties.get("anchor")&&(e.a6.mat3.fromRotation(y,-a.transform.angle),e.a6.vec3.transformMat3(g,g,y));var x="MASK"===h.alphaMode,b=v.properties.get("color").toRenderColor(null),w=d.paint.get("model-ambient-occlusion-intensity"),k=d.paint.get("model-color").constantOr(e.bA.white).toRenderColor(null),T=d.paint.get("model-color-mix-intensity").constantOr(0);return{u_matrix:t,u_lighting_matrix:r,u_normal_matrix:i,u_node_matrix:n||Oa,u_lightpos:g,u_lightintensity:v.properties.get("intensity"),u_lightcolor:[b.r,b.g,b.b],u_camera_pos:p,u_opacity:o,u_baseTextureIsAlpha:0,u_alphaMask:+x,u_alphaCutoff:h.alphaCutoff,u_baseColorFactor:[s.r,s.g,s.b,s.a],u_emissiveFactor:[l[0],l[1],l[2],1],u_metallicFactor:u,u_roughnessFactor:c,u_baseColorTexture:hi,u_metallicRoughnessTexture:fi,u_normalTexture:di,u_occlusionTexture:pi,u_emissionTexture:mi,u_lutTexture:vi,u_color_mix:[k.r,k.g,k.b,T],u_aoIntensity:w,u_emissive_strength:f,u_occlusionTextureTransform:m||[0,0,0,0]}},Ba=function(e){return{u_matrix:e,u_instance:arguments.length>1&&void 0!==arguments[1]?arguments[1]:Oa,u_node_matrix:arguments.length>2&&void 0!==arguments[2]?arguments[2]:Oa}},Na={fillExtrusion:function(t){return{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:function(t){return{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:function(t){return{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:function(t){return{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:function(t){return{u_matrix:new e.bG(t),u_emissive_strength:new e.bJ(t)}},fillPattern:function(t){return{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:function(t){return{u_matrix:new e.bG(t),u_emissive_strength:new e.bJ(t),u_world:new e.bH(t)}},fillOutlinePattern:function(t){return{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:function(t){return{u_matrix:new e.bG(t),u_camera_to_center_distance:new e.bJ(t),u_extrude_scale:new e.bH(t)}},collisionCircle:function(t){return{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:function(t){return{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:function(t){return{u_matrix:new e.bG(t)}},heatmap:function(t){return{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:function(t){return{u_image:new e.bK(t),u_color_ramp:new e.bK(t),u_opacity:new e.bJ(t)}},hillshade:function(t){return{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:function(t){return{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:function(t){return{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:function(t){return{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:function(t){return{u_texture:new e.bK(t),u_opacity:new e.bJ(t)}},rasterParticleDraw:function(t){return{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:function(t){return{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:function(t){return{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:function(t){return{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:function(t){return{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:function(t){return{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:function(t){return{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:function(t){return{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:function(t){return{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:function(t){return{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:function(t){return{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:function(t){return{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:function(t){return{u_matrix:new e.bG(t),u_instance:new e.bG(t),u_node_matrix:new e.bG(t)}},groundShadow:function(t){return{u_matrix:new e.bG(t),u_ground_shadow_factor:new e.bI(t)}},stars:function(t){return{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:function(t){return{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:function(t){return{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:function(t){return{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)}}},Va=(function(){function e(t,r,i,n){p(this,e),this.id=e.uniqueIdxCounter,e.uniqueIdxCounter++,this.context=t;var a=t.gl;this.buffer=a.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),a.bufferData(a.ELEMENT_ARRAY_BUFFER,r.arrayBuffer,this.dynamicDraw?a.DYNAMIC_DRAW:a.STATIC_DRAW),this.dynamicDraw||n||r.destroy()}return m(e,[{key:"bind",value:function(){this.context.bindElementBuffer.set(this.buffer)}},{key:"updateData",value:function(t){this.id=e.uniqueIdxCounter,e.uniqueIdxCounter++;var r=this.context.gl;this.context.unbindVAO(),this.bind(),r.bufferSubData(r.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)}},{key:"destroy",value:function(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}])})();Va.uniqueIdxCounter=0;var Ua,ja={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"},Ga=(function(){return m((function e(t,r,i,n,a,o){p(this,e),this.length=r.length,this.attributes=i,this.itemSize=r.bytesPerElement,this.dynamicDraw=n,this.instanceCount=o,this.context=t;var s=t.gl;this.buffer=s.createBuffer(),t.bindVertexBuffer.set(this.buffer),s.bufferData(s.ARRAY_BUFFER,r.arrayBuffer,this.dynamicDraw?s.DYNAMIC_DRAW:s.STATIC_DRAW),this.dynamicDraw||a||r.destroy()}),[{key:"bind",value:function(){this.context.bindVertexBuffer.set(this.buffer)}},{key:"updateData",value:function(e){var t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer)}},{key:"enableAttributes",value:function(e,t){for(var r=0;r0&&e.vertexAttribDivisor(n,r)}}},{key:"destroy",value:function(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}])})(),qa=(function(){return m((function e(t,r,i,n,a){p(this,e),this.context=t,this.width=r,this.height=i;var o=this.framebuffer=t.gl.createFramebuffer();n&&(this.colorAttachment=new Gn(t,o)),a&&(this.depthAttachmentType=a,this.depthAttachment="renderbuffer"===a?new qn(t,o):new Zn(t,o))}),[{key:"destroy",value:function(){var e=this.context.gl;if(this.colorAttachment){var t=this.colorAttachment.get();t&&e.deleteTexture(t)}if(this.depthAttachment&&this.depthAttachmentType)if("renderbuffer"===this.depthAttachmentType){var r=this.depthAttachment.get();r&&e.deleteRenderbuffer(r)}else{var i=this.depthAttachment.get();i&&e.deleteTexture(i)}e.deleteFramebuffer(this.framebuffer)}}])})(),Za=(function(){return m((function e(t,r){p(this,e),this.gl=t,this.clearColor=new hn(this),this.clearDepth=new fn(this),this.clearStencil=new dn(this),this.colorMask=new pn(this),this.depthMask=new mn(this),this.stencilMask=new vn(this),this.stencilFunc=new _n(this),this.stencilOp=new gn(this),this.stencilTest=new yn(this),this.depthRange=new xn(this),this.depthTest=new bn(this),this.depthFunc=new wn(this),this.blend=new kn(this),this.blendFunc=new Tn(this),this.blendColor=new Sn(this),this.blendEquation=new En(this),this.cullFace=new Mn(this),this.cullFaceSide=new An(this),this.frontFace=new In(this),this.program=new Cn(this),this.activeTexture=new Pn(this),this.viewport=new zn(this),this.bindFramebuffer=new Dn(this),this.bindRenderbuffer=new Rn(this),this.bindTexture=new Ln(this),this.bindVertexBuffer=new On(this),this.bindElementBuffer=new Fn(this),this.bindVertexArrayOES=new Bn(this),this.pixelStoreUnpack=new Nn(this),this.pixelStoreUnpackPremultiplyAlpha=new Vn(this),this.pixelStoreUnpackFlipY=new Un(this),this.options=r?Object.assign({},r):{},this.options.extTextureFilterAnisotropicForceOff||(this.extTextureFilterAnisotropic=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=t.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT))),this.extDebugRendererInfo=t.getExtension("WEBGL_debug_renderer_info"),this.extDebugRendererInfo&&(this.renderer=t.getParameter(this.extDebugRendererInfo.UNMASKED_RENDERER_WEBGL),this.vendor=t.getParameter(this.extDebugRendererInfo.UNMASKED_VENDOR_WEBGL)),this.options.extTextureFloatLinearForceOff||(this.extTextureFloatLinear=t.getExtension("OES_texture_float_linear")),this.extRenderToTextureHalfFloat=t.getExtension("EXT_color_buffer_half_float"),this.extTimerQuery=t.getExtension("EXT_disjoint_timer_query_webgl2"),this.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE),this.maxPointSize=t.getParameter(t.ALIASED_POINT_SIZE_RANGE)[1]}),[{key:"setDefault",value:function(){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()}},{key:"setDirty",value:function(){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}},{key:"createIndexBuffer",value:function(e,t,r){return new Va(this,e,t,r)}},{key:"createVertexBuffer",value:function(e,t,r,i,n){return new Ga(this,e,t,r,i,n)}},{key:"createRenderbuffer",value:function(e,t,r){var i=this.gl,n=i.createRenderbuffer();return this.bindRenderbuffer.set(n),i.renderbufferStorage(i.RENDERBUFFER,e,t,r),this.bindRenderbuffer.set(null),n}},{key:"createFramebuffer",value:function(e,t,r,i){return new qa(this,e,t,r,i)}},{key:"clear",value:function(e){var t=e.color,r=e.depth,i=e.stencil,n=e.colorMask,a=this.gl,o=0;t&&(o|=a.COLOR_BUFFER_BIT,this.clearColor.set(t),this.colorMask.set(n||[!0,!0,!0,!0])),void 0!==r&&(o|=a.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(r),this.depthMask.set(!0)),void 0!==i&&(o|=a.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),a.clear(o)}},{key:"setCullFace",value:function(e){!1===e.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(e.mode),this.frontFace.set(e.frontFace))}},{key:"setDepthMode",value:function(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)}},{key:"setStencilMode",value:function(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)}},{key:"setColorMode",value:function(t){e.bi(t.blendFunction,Qr.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)}},{key:"unbindVAO",value:function(){this.bindVertexArrayOES.set(null)}}])})();function $a(t,r,i,n,a,o,s){for(var l=t.context,u=l.gl,c=t.transform,h=t.getOrCreateProgram("collisionBox"),f=[],d=0,p=0,m=0;m0){var k=e.a6.mat4.create(),T=x;e.a6.mat4.mul(k,g.placementInvProjMatrix,c.glCoordMatrix),e.a6.mat4.mul(k,k,g.placementViewportMatrix),f.push({circleArray:w,circleOffset:p,transform:T,invTransform:k,projection:g.getProjection()}),p=d+=w.length/4}b&&(t.terrain&&t.terrain.setupElevationDraw(_,h),h.draw(t,u.LINES,ei.disabled,ri.disabled,t.colorModeForRenderPass(),ai.disabled,xa(x,c,_,g.getProjection()),i.id,b.layoutVertexBuffer,b.indexBuffer,b.segments,null,c.zoom,null,[b.collisionVertexBuffer,b.collisionVertexBufferExt]))}}if(s&&f.length){var S=t.getOrCreateProgram("collisionCircle"),E=new e.cQ;E.resize(4*d),E._trim();var M=0;for(var A of f)for(var I=0;I=0&&(m[w.associatedIconIndex]={x:B,y:N,z:V,angle:Z})}else yr(S,d)}if(h){p.clear();for(var H=t.icon.placedSymbolArray,W=0;W6&&void 0!==arguments[6]?arguments[6]:{},l=i.paint.get("icon-translate"),u=i.paint.get("text-translate"),c=i.paint.get("icon-translate-anchor"),h=i.paint.get("text-translate-anchor"),f=i.layout.get("icon-rotation-alignment"),d=i.layout.get("text-rotation-alignment"),p=i.layout.get("icon-pitch-alignment"),m=i.layout.get("text-pitch-alignment"),v=i.layout.get("icon-keep-upright"),_=i.layout.get("text-keep-upright"),g=i.paint.get("icon-color-saturation"),y=i.paint.get("icon-color-contrast"),x=i.paint.get("icon-color-brightness-min"),b=i.paint.get("icon-color-brightness-max"),w="sea"===i.layout.get("symbol-elevation-reference"),k=t.context,T=k.gl,S=t.transform,E="map"===f,M="map"===d,A="map"===p,I="map"===m,C=void 0!==i.layout.get("symbol-sort-key").constantOr(1),P=!1,z=t.depthModeForSublayer(0,ei.ReadOnly),D=[e.am(S.center.lng),e.at(S.center.lat)],R=i.layout.get("text-variable-anchor"),L="globe"===S.projection.name,O=[],F=[0,-1,0],B=function(n){var a=r.getTile(n),o=a.getBucket(i);if(!o)return 0;if("mercator"===o.projection.name&&L)return 0;if(o.fullyClipped)return 0;var f="globe"===o.projection.name,d=f?e.a9(S.zoom):0,p=Sr(n,o.getProjection(),S),m=S.calculatePixelsToTileUnitsMatrix(a),k=R&&o.hasTextData(),z=o.hasIconTextFit()&&k&&o.hasIconData(),B=o.getProjection().createInversionMatrix(S,n.canonical),N=function(e){S.depthOcclusionForSymbolsAndCircles&&(i.hasInitialOcclusionOpacityProperties||t.terrain)&&(e.push("DEPTH_D24"),e.push("DEPTH_OCCLUSION"))},V=o.icon.segments.get().length,U=o.text.segments.get().length,j=V&&!s.onlyText?(function(){var r=E&&"point"!==i.layout.get("symbol-placement"),s=[];N(s);var u=r||z,h=i.paint.get("icon-image-cross-fade").constantOr(0);t.terrainRenderModeElevated()&&A&&s.push("PITCH_WITH_MAP_TERRAIN"),f&&(s.push("PROJECTION_GLOBE_VIEW"),u&&s.push("PROJECTED_POS_ON_VIEWPORT")),h>0&&s.push("ICON_TRANSITION"),o.icon.zOffsetVertexBuffer&&s.push("Z_OFFSET"),0===g&&0===y&&0===x&&1===b||s.push("COLOR_ADJUSTMENT"),o.sdfIcons&&s.push("RENDER_SDF");var _=o.icon.programConfigurations.get(i.id),k=t.getOrCreateProgram("symbol",{config:_,defines:s}),M=a.imageAtlasTexture?a.imageAtlasTexture.size:[0,0],I=o.iconSizeData,C=e.bk(I,S.zoom),P=A||0!==S.pitch,R=or(p,a.tileID.canonical,A,E,S,o.getProjection(),m),O=lr(p,a.tileID.canonical,A,E,S,o.getProjection(),m),V=t.translatePosMatrix(O,a,l,c,!0),U=t.translatePosMatrix(p,a,l,c),j=u?Ha:R,G=E&&!A&&!r,q=F;!L&&!S.mercatorFromTransition||E||(q=Wa(S));var Z=f?q:F,$=i.getColorAdjustmentMatrix(g,y,x,b),H=Da(I.kind,C,G,A,t,U,j,V,w,!1,M,[0,0],!0,n,d,D,B,Z,o.getProjection(),$,h),W=a.imageAtlasTexture?a.imageAtlasTexture:null,X=1!==i.layout.get("icon-size").constantOr(0)||o.iconsNeedLinear,Y=o.sdfIcons||t.options.rotating||t.options.zooming||X||P?T.LINEAR:T.NEAREST,J=o.sdfIcons&&0!==i.paint.get("icon-halo-width").constantOr(1),K=t.terrain&&A&&r?e.a6.mat4.invert(e.a6.mat4.create(),R):Ha;if(r&&o.icon){var Q=S.elevation,ee=Q?Q.getAtTileOffsetFunc(n,S.center.lat,S.worldSize,o.getProjection()):null,te=sr(p,a.tileID.canonical,A,E,S,o.getProjection(),m);fr(o,p,t,!1,te,O,A,v,ee,n)}return{program:k,buffers:o.icon,uniformValues:H,atlasTexture:W,atlasTextureIcon:null,atlasInterpolation:Y,atlasInterpolationIcon:null,isSDF:o.sdfIcons,hasHalo:J,tile:a,labelPlaneMatrixInv:K}})():null,G=U&&!s.onlyIcons?(function(){var r=M&&"point"!==i.layout.get("symbol-placement"),s=[],l=r||R||z;t.terrainRenderModeElevated()&&I&&s.push("PITCH_WITH_MAP_TERRAIN"),f&&(s.push("PROJECTION_GLOBE_VIEW"),l&&s.push("PROJECTED_POS_ON_VIEWPORT")),o.text.zOffsetVertexBuffer&&s.push("Z_OFFSET"),o.iconsInText&&s.push("RENDER_TEXT_AND_SYMBOL"),s.push("RENDER_SDF"),N(s);var c,v=o.text.programConfigurations.get(i.id),g=t.getOrCreateProgram("symbol",{config:v,defines:s}),y=[0,0],x=null,b=o.textSizeData;o.iconsInText&&(y=a.imageAtlasTexture?a.imageAtlasTexture.size:[0,0],x=a.imageAtlasTexture?a.imageAtlasTexture:null,c=I||0!==S.pitch||t.options.rotating||t.options.zooming||"composite"===b.kind||"camera"===b.kind?T.LINEAR:T.NEAREST);var k=a.glyphAtlasTexture?a.glyphAtlasTexture.size:[0,0],E=i.layout.get("text-size-scale-range"),A=e.ap(t.scaleFactor,E[0],E[1]),C=e.bk(b,S.zoom,A),P=or(p,a.tileID.canonical,I,M,S,o.getProjection(),m),O=lr(p,a.tileID.canonical,I,M,S,o.getProjection(),m),V=t.translatePosMatrix(O,a,u,h,!0),U=t.translatePosMatrix(p,a,u,h),j=l?Ha:P,G=M&&!I&&!r,q=F;!L&&!S.mercatorFromTransition||M||(q=Wa(S));var Z=Da(b.kind,C,G,I,t,U,j,V,w,!0,k,y,!0,n,d,D,B,f?q:F,o.getProjection(),null,null,A),$=a.glyphAtlasTexture?a.glyphAtlasTexture:null,H=T.LINEAR,W=0!==i.paint.get("text-halo-width").constantOr(1),X=t.terrain&&I&&r?e.a6.mat4.invert(e.a6.mat4.create(),P):Ha;if(r&&o.text){var Y=S.elevation,J=Y?Y.getAtTileOffsetFunc(n,S.center.lat,S.worldSize,o.getProjection()):null,K=sr(p,a.tileID.canonical,I,M,S,o.getProjection(),m);fr(o,p,t,!0,K,O,I,_,J,n)}return{program:g,buffers:o.text,uniformValues:Z,atlasTexture:$,atlasTextureIcon:x,atlasInterpolation:H,atlasInterpolationIcon:c,isSDF:!0,hasHalo:W,tile:a,labelPlaneMatrixInv:X}})():null,q=i.paint.get("icon-opacity").constantOr(1),Z=i.paint.get("text-opacity").constantOr(1);if(C&&o.canOverlap){P=!0;var $=q&&!s.onlyText?o.icon.segments.get():[],H=Z&&!s.onlyIcons?o.text.segments.get():[];for(var W of $)O.push({segments:new e.b2([W]),sortKey:W.sortKey,state:j});for(var X of H)O.push({segments:new e.b2([X]),sortKey:X.sortKey,state:G})}else s.onlyText||O.push({segments:q?o.icon.segments:new e.b2([]),sortKey:0,state:j}),s.onlyIcons||O.push({segments:Z?o.text.segments:new e.b2([]),sortKey:0,state:G})};for(var N of n)B(N);for(var V of(P&&O.sort((function(e,t){return e.sortKey-t.sortKey})),O)){var U=V.state;if(U)if(t.terrain?t.terrain.setupElevationDraw(U.tile,U.program,{useDepthForOcclusion:S.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:U.labelPlaneMatrixInv}):t.setupDepthForOcclusion(S.depthOcclusionForSymbolsAndCircles,U.program),k.activeTexture.set(T.TEXTURE0),U.atlasTexture&&U.atlasTexture.bind(U.atlasInterpolation,T.CLAMP_TO_EDGE,!0),U.atlasTextureIcon&&(k.activeTexture.set(T.TEXTURE1),U.atlasTextureIcon&&U.atlasTextureIcon.bind(U.atlasInterpolationIcon,T.CLAMP_TO_EDGE,!0)),t.uploadCommonLightUniforms(t.context,U.program),U.hasHalo){var j=U.uniformValues;j.u_is_halo=1,Ka(U.buffers,V.segments,i,t,U.program,z,a,o,j,2),j.u_is_halo=0}else{if(U.isSDF){var G=U.uniformValues;U.hasHalo&&(G.u_is_halo=1,Ka(U.buffers,V.segments,i,t,U.program,z,a,o,G,1)),G.u_is_halo=0}Ka(U.buffers,V.segments,i,t,U.program,z,a,o,U.uniformValues,1)}}}function Ka(e,t,r,i,n,a,o,s,l,u){var c=[e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer,e.iconTransitioningVertexBuffer,e.globeExtVertexBuffer,e.zOffsetVertexBuffer];n.draw(i,i.context.gl.TRIANGLES,a,o,s,ai.disabled,l,r.id,e.layoutVertexBuffer,e.indexBuffer,t,r.paint,i.transform.zoom,e.programConfigurations.get(r.id),c,u)}function Qa(e,t,r,i,n,a,o){var s,l,u,c,h,f=e.context.gl,d=r.paint.get("fill-pattern"),p=r.is3D(),m=p?e.stencilModeFor3D():ri.disabled,v=d&&d.constantOr(1);for(var _ of(o?(l=v&&!r.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",s=f.LINES):(l=v?"fillPattern":"fill",s=f.TRIANGLES),i)){var g=t.getTile(_);if(!v||g.patternsLoaded()){var y=g.getBucket(r);if(y){e.prepareDrawTile();var x=y.programConfigurations.get(r.id),b=e.isTileAffectedByFog(_),w=e.getOrCreateProgram(l,{config:x,overrideFog:b});v&&(e.context.activeTexture.set(f.TEXTURE0),g.imageAtlasTexture&&g.imageAtlasTexture.bind(f.LINEAR,f.CLAMP_TO_EDGE),x.updatePaintBuffers());var k=d.constantOr(null);if(k&&g.imageAtlas){var T=g.imageAtlas.patternPositions[k.toString()];T&&x.setConstantPatternPositions(T)}var S=e.translatePosMatrix(_.projMatrix,g,r.paint.get("fill-translate"),r.paint.get("fill-translate-anchor")),E=r.paint.get("fill-emissive-strength");if(o){c=y.indexBuffer2,h=y.segments2;var M=e.terrain&&e.terrain.renderingToTexture?e.terrain.drapeBufferSize:[f.drawingBufferWidth,f.drawingBufferHeight];u="fillOutlinePattern"===l&&v?ya(S,E,e,g,M):ga(S,E,M)}else c=y.indexBuffer,h=y.segments,u=v?_a(S,E,e,g):va(S,E);e.uploadCommonUniforms(e.context,w,_.toUnwrapped()),w.draw(e,s,n,p?m:e.stencilModeForClipping(_),a,ai.disabled,u,r.id,y.layoutVertexBuffer,c,h,r.paint,e.transform.zoom,x,void 0)}}}}function eo(t,r,i,n,a,o,s,l){i.resetLayerRenderingStats(t);var u,c=t.context,h=c.gl,f=t.transform,d=i.paint.get("fill-extrusion-pattern"),p=d.constantOr(1),m=i.paint.get("fill-extrusion-opacity"),v=t.style.enable3dLights(),_=i.paint.get(v&&!p?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),g=[i.paint.get("fill-extrusion-ambient-occlusion-intensity"),_],y=i.layout.get("fill-extrusion-edge-radius"),x=y>0&&!i.paint.get("fill-extrusion-rounded-roof"),b=x?0:y,w="globe"===f.projection.name?e.c_():0,k="globe"===f.projection.name,T=k?e.a9(f.zoom):0,S=[e.am(f.center.lng),e.at(f.center.lat)],E=i.paint.get("fill-extrusion-flood-light-color").toRenderColor(i.lut).toArray01().slice(0,3),M=i.paint.get("fill-extrusion-flood-light-intensity"),A=i.paint.get("fill-extrusion-vertical-scale"),I=0!==i.paint.get("fill-extrusion-line-width").constantOr(1),C=i.paint.get("fill-extrusion-height-alignment"),P=i.paint.get("fill-extrusion-base-alignment"),z=wi(t,i.paint.get("fill-extrusion-cutoff-fade-range")),D=[];k&&D.push("PROJECTION_GLOBE_VIEW"),g[0]>0&&D.push("FAUX_AO"),x&&D.push("ZERO_ROOF_RADIUS"),l&&D.push("HAS_CENTROID"),M>0&&D.push("FLOOD_LIGHT"),z.shouldRenderCutoff&&D.push("RENDER_CUTOFF"),I&&D.push("RENDER_WALL_MODE");var R="shadow"===t.renderPass,L=t.shadowRenderer,O=R&&!!L;t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!0);var F=[0,0,0];if(L){var B=t.style.directionalLight,N=t.style.ambientLight;B&&N&&(F=Ii(t.style,B,N)),R||(D.push("RENDER_SHADOWS","DEPTH_TEXTURE"),L.useNormalOffset&&D.push("NORMAL_OFFSET")),u=D.concat(["SHADOWS_SINGLE_CASCADE"])}var V=O?"fillExtrusionDepth":p?"fillExtrusionPattern":"fillExtrusion",U=i.getLayerRenderingStats();for(var j of n){var G=r.getTile(j),q=G.getBucket(i);if(q&&q.projection.name===f.projection.name){var Z=!1;L&&(Z=0===L.getMaxCascadeForTile(j.toUnwrapped()));var $=t.isTileAffectedByFog(j),H=q.programConfigurations.get(i.id),W=t.getOrCreateProgram(V,{config:H,defines:Z?u:D,overrideFog:$});if(t.terrain&&t.terrain.setupElevationDraw(G,W,{useMeterToDem:!0}),!q.centroidVertexBuffer){var X=W.attributes.a_centroid_pos;void 0!==X&&h.vertexAttrib2f(X,0,0)}!R&&L&&L.setupShadows(G.tileID.toUnwrapped(),W,"vector-tile",G.tileID.overscaledZ),p&&(t.context.activeTexture.set(h.TEXTURE0),G.imageAtlasTexture&&G.imageAtlasTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),H.updatePaintBuffers());var Y=d.constantOr(null);if(Y&&G.imageAtlas){var J=G.imageAtlas.patternPositions[Y.toString()];J&&H.setConstantPatternPositions(J)}var K=i.paint.get("fill-extrusion-vertical-gradient"),Q=1/q.tileToMeter,ee=void 0;if(R&&L){if(oo(G.tileID,q,t))continue;var te=L.calculateShadowPassMatrixFromTile(G.tileID.toUnwrapped());ee=pa(te,b,Q,A,C,P)}else{var re=t.translatePosMatrix(j.expandedProjMatrix,G,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),ie=f.projection.createInversionMatrix(f,j.canonical);ee=p?ma(re,t,K,m,g,b,Q,j,G,w,C,P,T,S,ie,E,A):da(re,t,K,m,g,b,Q,j,w,C,P,T,S,ie,E,A,M,F)}t.uploadCommonUniforms(c,W,j.toUnwrapped(),null,z);var ne=q.segments;if("mercator"!==f.projection.name||R||(ne=q.getVisibleSegments(G.tileID,t.terrain,t.transform.getFrustum(0))).get().length){if(U)if(R)for(var ae of ne.get())U.numRenderedVerticesInShadowPass+=ae.primitiveLength;else for(var oe of ne.get())U.numRenderedVerticesInTransparentPass+=oe.primitiveLength;var se=[];(t.terrain||l)&&se.push(q.centroidVertexBuffer),k&&se.push(q.layoutVertexExtBuffer),I&&se.push(q.wallVertexBuffer),W.draw(t,c.gl.TRIANGLES,a,o,s,ai.backCCW,ee,i.id,q.layoutVertexBuffer,q.indexBuffer,ne,i.paint,t.transform.zoom,H,se)}}}t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!1)}function to(t,r,i,n,a,o,s,l,u,c,h,f,d,p,m,v,_,g,y){var x=t.context,b=x.gl,w=t.transform,k=t.transform.zoom,T=[],S=wi(t,i.paint.get("fill-extrusion-cutoff-fade-range"));"clear"===c?(T.push("CLEAR_SUBPASS"),y&&(T.push("CLEAR_FROM_TEXTURE"),x.activeTexture.set(b.TEXTURE0),y.bind(b.LINEAR,b.CLAMP_TO_EDGE))):"sdf"===c&&T.push("SDF_SUBPASS"),_&&T.push("HAS_CENTROID"),S.shouldRenderCutoff&&T.push("RENDER_CUTOFF");var E=i.layout.get("fill-extrusion-edge-radius"),M=function(e,r,n,c,g){var b=r.programConfigurations.get(i.id),w=t.isTileAffectedByFog(e),M=t.getOrCreateProgram("fillExtrusionGroundEffect",{config:b,defines:T,overrideFog:w}),A=(function(e,t,r,i,n,a,o,s,l,u,c){return{u_matrix:t,u_opacity:r,u_ao_pass:i?1:0,u_meter_to_tile:n,u_ao:a,u_flood_light_intensity:o,u_flood_light_color:s,u_attenuation:l,u_edge_radius:u,u_fb:0,u_fb_size:c,u_dynamic_offset:1}})(0,c,h,u,g,[f,d*g],p,m,v,k>=17?0:E*g,y?y.size[0]:0),I=[];_&&I.push(r.hiddenByLandmarkVertexBuffer),t.uploadCommonUniforms(x,M,e.toUnwrapped(),null,S),M.draw(t,x.gl.TRIANGLES,a,o,s,l,A,i.id,r.vertexBuffer,r.indexBuffer,n,i.paint,k,b,I)};for(var A of n){var I=r.getTile(A),C=I.getBucket(i);if(C&&C.projection.name===w.projection.name&&C.groundEffect&&(!C.groundEffect||C.groundEffect.hasData())){var P=C.groundEffect,z=1/C.tileToMeter,D=t.translatePosMatrix(A.projMatrix,I,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),R=P.getDefaultSegment();if(M(A,P,R,D,z),g)for(var L=0;L<4;L++){var O=e.c$[L](A),F=r.getTile(O);if(F){var B=F.getBucket(i);if(B&&B.projection.name===w.projection.name&&B.groundEffect&&(!B.groundEffect||B.groundEffect.hasData())){var N=B.groundEffect,V=void 0,U=void 0;0===L?(V=[-e.ab,0,0],U=1):1===L?(V=[e.ab,0,0],U=0):2===L?(V=[0,-e.ab,0],U=3):(V=[0,e.ab,0],U=2);var j=N.regionSegments[U];if(j){var G=new Float32Array(16);e.a6.mat4.translate(G,A.projMatrix,V),M(A,N,j,t.translatePosMatrix(G,I,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),z)}}}}}}}function ro(t,r,i,n,a,o,s){0===n.centroidVertexArray.length&&n.createCentroidsBuffer();var l=o?o.findDEMTileFor(i):null;if(l&&l.dem||s){for(var u,c,h=function(t){return new e.P(Math.ceil((t+e.d2)*e.d3),0)},f=function(e){var t=r.getSource().minzoom,i=function(e){var t=r.getTileByID(e);if(t&&t.hasData())return t.getBucket(a)};for(var n of[0,-1,1])if(!(e.overscaledZ+nt.max.x?r.min.x-e.ab:t.max.x,d},m=function(t,r){return d[0]=Math.min(t.min.x,r.min.x),d[1]=Math.max(t.max.x,r.max.x),d[2]=e.ab-r.min.y>t.max.y?r.min.y-e.ab:t.max.y,d},v=[function(e,t){return p(e,t)},function(e,t){return p(t,e)},function(e,t){return m(e,t)},function(e,t){return m(t,e)}],_=function(t,r,n,a,s,u,c){if(!o)return 0;var h=[[u?n:t,u?t:n,0],[u?n:r,u?r:n,0]],f=c<0?e.ab+c:c,d=[u?f:(t+r)/2,u?(t+r)/2:f,0];return 0===n&&c<0||0!==n&&c>0?o.getForTilePoints(s,[d],!0,a):h.push(d),o.getForTilePoints(i,h,!0,l),Math.max(h[0][2],h[1][2],d[2])/o.exaggeration()},g=0;g<4;g++){var y=n.borderFeatureIndices[g];if(0!==y.length){var x=e.c$[g](i),b=f(x);if(b&&b instanceof e.d0&&n.borderDoneWithNeighborZ[g]!==b.canonical.z){0===b.centroidVertexArray.length&&b.createCentroidsBuffer();var w=o?o.findDEMTileFor(x):null;if(w&&w.dem||s){var k=(g<2?1:5)-g,T=b.borderDoneWithNeighborZ[k]!==n.canonical.z,S=b.borderFeatureIndices[k],E=0;if(n.canonical.z!==b.canonical.z){for(var M of y)n.showCentroid(n.featuresOnBorder[M]);if(T)for(var A of S)b.showCentroid(b.featuresOnBorder[A]);n.borderDoneWithNeighborZ[g]=b.canonical.z,b.borderDoneWithNeighborZ[k]=n.canonical.z}for(var I of y){for(var C=n.featuresOnBorder[I],P=n.centroidData[C.centroidDataIndex],z=C.borders[g],D=void 0;Ez[0]+3||R[0]>z[0]-3)break;b.showCentroid(D),E++}if(D&&Ez[1]-3)&&(O++,++E!==S.length);)D=b.featuresOnBorder[S[E]];D=b.featuresOnBorder[S[L]];var F=!1;if(O>=1){var B=D.borders[k];Math.abs(z[0]-B[0])<3&&Math.abs(z[1]-B[1])<3&&(O=1,F=!0,E=L+1)}else if(0===O){n.showCentroid(C);continue}var N=b.centroidData[D.centroidDataIndex];s&&F&&(((u=P).flags|(c=N).flags)&e.d1?(u.flags|=e.d1,c.flags|=e.d1):(u.flags&=~e.d1,c.flags&=~e.d1));var V=C.intersectsCount()>1||D.intersectsCount()>1;if(O>1)E=L,P.centroidXY=N.centroidXY=new e.P(0,0);else if(w&&w.dem&&!V){var U=v[g](P,N),j=g%2?e.ab-1:0,G=_(U[0],Math.min(e.ab-1,U[1]),j,w,x,g<2,U[2]);P.centroidXY=N.centroidXY=h(G)}else V?P.centroidXY=N.centroidXY=new e.P(0,0):(P.centroidXY=n.encodeBorderCentroid(C),N.centroidXY=b.encodeBorderCentroid(D));n.writeCentroidToBuffer(P),b.writeCentroidToBuffer(N)}else n.showCentroid(C)}n.borderDoneWithNeighborZ[g]=b.canonical.z,b.borderDoneWithNeighborZ[k]=n.canonical.z}}}}(n.needsCentroidUpdate||!n.centroidVertexBuffer&&0!==n.centroidVertexArray.length)&&n.uploadCentroid(t)}}var io=[1,0,0],no=[0,1,0],ao=[0,0,1];function oo(t,r,i){var n=i.transform,a=i.shadowRenderer;if(!a)return!0;var o=t.toUnwrapped(),s=n.tileSize*a._cascades[i.currentShadowCascade].scale,l=r.maxHeight;if(n.elevation){var u=n.elevation.getMinMaxForTile(t);u&&(l+=u.max)}var c=d(a.shadowDirection);c[2]=-c[2];var h=a.computeSimplifiedTileShadowVolume(o,l,s,c);if(!h)return!1;var f=[io,no,ao,c,[c[0],0,c[2]],[0,c[1],c[2]]],p="globe"===n.projection.name,m=n.scaleZoom(s),v=e.bO.fromInvProjectionMatrix(n.invProjMatrix,n.worldSize,m,!p),_=a.getCurrentCascadeFrustum();return 0===v.intersectsPrecise(h.vertices,h.planes,f)||0===_.intersectsPrecise(h.vertices,h.planes,f)}function so(t){return[t[0]*e.d4,t[1]*e.d4,t[2]*e.d4,0]}function lo(t,r,i,n,a,o,s,l,u){var c,h,f,d=n.getSource(),p=i.globeSharedBuffers;if(p&&(r&&(c=n.getTile(r)),d instanceof e.aD?(h=d.texture,f=e.cD(0,0,i.transform)):c&&r&&(h=c.texture,f=e.cD(r.canonical.z,r.canonical.x,i.transform)),h&&f)){t||(f=e.a6.mat4.scale(e.a6.mat4.create(),f,[1,-1,1]));var m=i.context,v=m.gl,_="nearest"===a.paint.get("raster-resampling")?v.NEAREST:v.LINEAR,g=i.colorModeForDrapableLayerRenderPass(o),y=s.defines;y.push("GLOBE_POLES");var b=new ei(v.LEQUAL,ei.ReadWrite,i.depthRangeFor3D),w=Float32Array.from(i.transform.expandedFarZProjMatrix),k=Float32Array.from(e.b6(e.cC(new e.bQ(0,0,0))));i.terrain&&i.terrain.prepareDrawTile(),m.activeTexture.set(v.TEXTURE0),h.bind(_,v.CLAMP_TO_EDGE),m.activeTexture.set(v.TEXTURE1),h.bind(_,v.CLAMP_TO_EDGE),h.useMipmap&&m.extTextureFilterAnisotropic&&i.transform.pitch>20&&v.texParameterf(v.TEXTURE_2D,m.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,m.extTextureFilterAnisotropicMax);var T,S=r?p.getPoleBuffers(r.canonical.z,!1):p.getPoleBuffers(0,!0),E=x(S,4),M=E[0],A=E[1],I=E[2],C=E[3],P=a.paint.get("raster-elevation");t?(T=M,i.renderDefaultNorthPole=0!==P):(T=A,i.renderDefaultSouthPole=0!==P);var z=so(s.mix),D=(function(e,t,r,i,n,a,o,s,l,u,c,h,f){return Ea(e,t,r,new Float32Array(16),new Float32Array(9),[0,0],i,[0,0],[0,0,0,0],1,{opacity:1,mix:0},a,[0,0],s,2,u,c,h,1,0,f)})(w,k,f,e.a9(i.transform.zoom),0,a,0,P,0,z,s.offset,s.range,o),R=i.getOrCreateProgram("raster",{defines:y});i.uploadCommonUniforms(m,R,null),R.draw(i,v.TRIANGLES,b,u,g,l,D,a.id,T,I,C)}}function uo(e){var t=e._nearZ,r=e.projection.farthestPixelDistance(e),i=r-t,n=.2*e.height,a=t+n;return[t,r,(a-n-t)/i,(a-t)/i]}function co(e,t,r,i){if(e)return t instanceof lt&&e instanceof Ot?t.getTextureDescriptor(e,r,!0):{texture:e.texture,mix:so(i.mix),offset:i.offset,buffer:0,tileSize:1}}var ho=e.d5([{name:"a_index",type:"Int16",components:1}]),fo=(function(){return m((function t(r,i,n,a){p(this,t);var o={width:n[0],height:n[1],data:null},s=r.gl;this.targetColorTexture=new e.T(r,o,s.RGBA8,{useMipmap:!1}),this.backgroundColorTexture=new e.T(r,o,s.RGBA8,{useMipmap:!1}),this.context=r,this.updateParticleTexture(i,a),this.lastInvalidatedAt=0}),[{key:"updateParticleTexture",value:function(t,r){if(this.particleTextureDimension!==r.width){(this.particleTexture0||this.particleTexture1||this.particleIndexBuffer||this.particleSegment)&&(this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleIndexBuffer.destroy(),this.particleSegment.destroy());var i=this.context.gl,n=r.width*r.height;this.particleTexture0=new e.T(this.context,r,i.RGBA8,{premultiply:!1,useMipmap:!1}),this.particleTexture1=new e.T(this.context,r,i.RGBA8,{premultiply:!1,useMipmap:!1});var a=new e.d6;a.reserve(n);for(var o=0;o0){var p=e.b5(i.canonical,u),m=e.d8(p);d=e.a6.mat4.multiply(new Float32Array(16),u.globeMatrix,m),e.a6.mat4.multiply(d,u.projMatrix,d)}var v=e.a6.mat4.create();v[12]+=2*a/(e.q.devicePixelRatio*u.width),v[13]+=2*o/(e.q.devicePixelRatio*u.height),e.a6.mat4.multiply(d,v,d);var _=t.getOrCreateProgram("debug",{defines:f}),g=r.getTileByID(i.key);t.terrain&&t.terrain.setupElevationDraw(g,_);var y=ei.disabled,x=ri.disabled,b=t.colorModeForRenderPass(),w="$debug";l.activeTexture.set(c.TEXTURE0),t.emptyTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE),h?g._makeGlobeTileDebugBuffers(t.context,u):g._makeDebugTileBoundsBuffers(t.context,u.projection);var k=g._tileDebugBuffer||t.debugBuffer,T=g._tileDebugIndexBuffer||t.debugIndexBuffer,S=g._tileDebugSegments||t.debugSegments;if(_.draw(t,c.LINE_STRIP,y,x,b,ai.disabled,ba(d,n),w,k,T,S,null,null,null,[g._globeTileDebugBorderBuffer]),s){var E=g.latestRawTileData,M=Math.floor((E&&E.byteLength||0)/1024),A=i.canonical.toString();i.overscaledZ!==i.canonical.z&&(A+=` => ${i.overscaledZ}`),A+=` ${g.state}`,(function(e,t){e.initDebugOverlayCanvas();var r=e.debugOverlayCanvas,i=e.context.gl,n=e.debugOverlayCanvas.getContext("2d");n.clearRect(0,0,r.width,r.height),n.shadowColor="white",n.shadowBlur=2,n.lineWidth=1.5,n.strokeStyle="white",n.textBaseline="top",n.font="bold 36px Open Sans, sans-serif",n.fillText(t,5,5),n.strokeText(t,5,5),e.debugOverlayTexture.update(r),e.debugOverlayTexture.bind(i.LINEAR,i.CLAMP_TO_EDGE)})(t,A+=` ${M}kb`)}var I=r.getTile(i).tileSize,C=512/Math.min(I,512)*(i.overscaledZ/u.zoom)*.5,P=g._tileDebugTextBuffer||t.debugBuffer,z=g._tileDebugTextIndexBuffer||t.quadTriangleIndexBuffer,D=g._tileDebugTextSegments||t.debugSegments;_.draw(t,c.TRIANGLES,y,x,Qr.alphaBlended,ai.disabled,ba(d,e.bA.transparent,C),w,P,z,D,null,null,null,[g._globeTileDebugTextBuffer])}function wo(e,t,r,i){To(e,0,t+r/2,e.transform.width,r,i)}function ko(e,t,r,i){To(e,t-r/2,0,r,e.transform.height,i)}function To(t,r,i,n,a,o){var s=t.context,l=s.gl;l.enable(l.SCISSOR_TEST),l.scissor(r*e.q.devicePixelRatio,i*e.q.devicePixelRatio,n*e.q.devicePixelRatio,a*e.q.devicePixelRatio),s.clear({color:o}),l.disable(l.SCISSOR_TEST)}var So=e.d5([{name:"a_pos_3f",components:3,type:"Float32"}]).members;function Eo(e,t,r,i){e.emplaceBack(t,r,i)}var Mo=m((function t(r){p(this,t),this.vertexArray=new e.d9,this.indices=new e.aP,Eo(this.vertexArray,-1,-1,1),Eo(this.vertexArray,1,-1,1),Eo(this.vertexArray,-1,1,1),Eo(this.vertexArray,1,1,1),Eo(this.vertexArray,-1,-1,-1),Eo(this.vertexArray,1,-1,-1),Eo(this.vertexArray,-1,1,-1),Eo(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=r.createVertexBuffer(this.vertexArray,So),this.indexBuffer=r.createIndexBuffer(this.indices),this.segment=e.b2.simpleSegment(0,0,36,12)}));function Ao(t,r,i,n,a,o){var s=t.context.gl,l=r.paint.get("sky-atmosphere-color"),u=r.paint.get("sky-atmosphere-halo-color"),c=r.paint.get("sky-atmosphere-sun-intensity"),h=(function(e,t,r,i,n){return{u_matrix_3f:e,u_sun_direction:t,u_sun_intensity:r,u_color_tint_r:[i.r,i.g,i.b,i.a],u_color_tint_m:[n.r,n.g,n.b,n.a],u_luminance:5e-5}})(e.a6.mat3.fromMat4(e.a6.mat3.create(),n),a,c,l,u);s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+o,r.skyboxTexture,0),i.draw(t,s.TRIANGLES,ei.disabled,ri.disabled,Qr.unblended,ai.frontCW,h,"skyboxCapture",r.skyboxGeometry.vertexBuffer,r.skyboxGeometry.indexBuffer,r.skyboxGeometry.segment)}var Io=e.d5([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]),Co=(function(){return m((function t(r){p(this,t);var 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);var n=new e.aP;n.emplaceBack(0,1,2),n.emplaceBack(2,3,0),this.vertexBuffer=r.createVertexBuffer(i,Io.members),this.indexBuffer=r.createIndexBuffer(n),this.segments=e.b2.simpleSegment(0,0,4,2)}),[{key:"destroy",value:function(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}])})(),Po=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}]),zo=m((function e(){p(this,e),this.starsCount=16e3,this.sizeMultiplier=.15,this.sizeRange=100,this.intensityRange=200})),Do=(function(){return m((function t(r){var i=this;p(this,t),this.colorModeAlphaBlendedWriteRGB=new Qr([1,Kr,1,Kr],e.bA.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new Qr([1,0,1,0],e.bA.transparent,[!1,!1,!1,!0]),this.params=new zo,this.updateNeeded=!0,r.tp.registerParameter(this.params,["Stars"],"starsCount",{min:100,max:16e3,step:1},(function(){i.updateNeeded=!0})),r.tp.registerParameter(this.params,["Stars"],"sizeMultiplier",{min:.01,max:2,step:.01}),r.tp.registerParameter(this.params,["Stars"],"sizeRange",{min:0,max:200,step:1},(function(){i.updateNeeded=!0})),r.tp.registerParameter(this.params,["Stars"],"intensityRange",{min:0,max:200,step:1},(function(){i.updateNeeded=!0}))}),[{key:"update",value:function(t){var r=t.context;if(!this.atmosphereBuffer||this.updateNeeded){this.updateNeeded=!1,this.atmosphereBuffer=new Co(r);for(var i=this.params.sizeRange,n=this.params.intensityRange,a=(function(t){for(var r=e.dd(30),i=[],n=0;n=Ze||P>=Ze}}var z=wi(r,i.paint.get("model-cutoff-fade-range"));z.shouldRenderCutoff&&b.defines.push("RENDER_CUTOFF");var D=r.getOrCreateProgram("model",b);r.uploadCommonUniforms(u,D,null,T,z),"shadow"!==r.renderPass&&k&&k.setupShadowsFromMatrix(t.nodeModelMatrix,D),D.draw(r,u.gl.TRIANGLES,c,a,o,f.material.doubleSided?ai.disabled:ai.backCCW,y,i.id,f.vertexBuffer,f.indexBuffer,f.segments,i.paint,r.transform.zoom,void 0,w)}function Fo(t,r,i,n,a,o,s){var l;l="globe"===t.projection.name?e.dg(i,t):d(i),e.a6.mat4.multiply(l,l,r.matrix);var u=e.a6.mat4.multiply([],n,l);if(r.meshes)for(var c of r.meshes)if("BLEND"===c.material.alphaMode){var h=e.a6.vec3.transformMat4([],c.centroid,u);h[2]>0&&o.push({mesh:c,depth:h[2],modelIndex:a,worldViewProjection:u,nodeModelMatrix:l})}else s.push({mesh:c,depth:0,modelIndex:a,worldViewProjection:u,nodeModelMatrix:l});if(r.children)for(var f of r.children)Fo(t,f,i,n,a,o,s)}function Bo(e,t,r,i){var n=r.shadowRenderer;if(n){var a=n.getShadowPassDepthMode(),o=n.getShadowPassColorMode(),s=n.calculateShadowPassMatrixFromMatrix(t),l=Ba(s);r.getOrCreateProgram("modelDepth",{defines:r._shadowMapDebug?[]:["DEPTH_TEXTURE"]}).draw(r,r.context.gl.TRIANGLES,a,ri.disabled,o,ai.backCCW,l,i.id,e.vertexBuffer,e.indexBuffer,e.segments,i.paint,r.transform.zoom,void 0,void 0)}}function No(t,r,i){var n=r.updateZoomBasedPaintProperties(),a=(function(t,r,i){var n,a,o,s=t.terrain?t.terrain.exaggeration():0;if(t.terrain&&s>0){var l=t.terrain,u=l.findDEMTileFor(i);u&&u.dem?n=e.di.create(l,i,u):s=0}if(0===s&&(r.terrainElevationMin=0,r.terrainElevationMax=0),s===r.validForExaggeration&&(0===s||n&&n._demTile&&n._demTile.tileID===r.validForDEMTile.id&&n._dem._timestamp===r.validForDEMTile.timestamp))return!1;for(var c in r.instancesPerModel)for(var h=r.instancesPerModel[c],f=0;fc&&(c=h.max)}var f=e.ap(n.x,o,s)-n.x,d=e.ap(n.y,l,u)-n.y,p=e.bE(c,r.center.lat)-n.z;return r._zoomFromMercatorZ(Math.sqrt(f*f+d*d+p*p))}function jo(e,t,r,i,n,a,o){var s=e.context,l="shadow"===e.renderPass,u=e.shadowRenderer,c=l&&u?u.getShadowPassDepthMode():new ei(s.gl.LEQUAL,ei.ReadWrite,e.depthRangeFor3D),h=e.isTileAffectedByFog(a);if(r.meshes)for(var f of r.meshes){var d=["MODEL_POSITION_ON_GPU"],p=[],m=void 0,v=void 0,_=void 0;i.instancedDataArray.length>20&&d.push("INSTANCED_ARRAYS");var g=wi(e,t.paint.get("model-cutoff-fade-range"));if(g.shouldRenderCutoff&&d.push("RENDER_CUTOFF"),l&&u)m=e.getOrCreateProgram("modelDepth",{defines:d}),v=Ba(o.shadowTileMatrix,o.shadowTileMatrix,Float32Array.from(r.matrix)),_=u.getShadowPassColorMode();else{Lo(d,p,f,e,t.lut),m=e.getOrCreateProgram("model",{defines:d,overrideFog:h});var y=f.material,x=y.pbrMetallicRoughness,b=t.paint.get("model-opacity"),w=t.paint.get("model-emissive-strength").constantOr(0);v=Fa(a.expandedProjMatrix,Float32Array.from(r.matrix),new Float32Array(16),null,e,b,x.baseColorFactor.toRenderColor(null),y.emissiveFactor,x.metallicFactor,x.roughnessFactor,y,w,t,n),u&&(o.shadowUniformsInitialized?m.setShadowUniformValues(s,u.getShadowUniformValues()):(u.setupShadows(a.toUnwrapped(),m,"model-tile",a.overscaledZ),o.shadowUniformsInitialized=!0)),_=g.shouldRenderCutoff||b<1||"OPAQUE"!==y.alphaMode?Qr.alphaBlended:Qr.unblended}e.uploadCommonUniforms(s,m,a.toUnwrapped(),null,g);var k=f.material.doubleSided?ai.disabled:ai.backCCW;if(i.instancedDataArray.length>20)p.push(i.instancedDataBuffer),m.draw(e,s.gl.TRIANGLES,c,ri.disabled,_,k,v,t.id,f.vertexBuffer,f.indexBuffer,f.segments,t.paint,e.transform.zoom,void 0,p,i.instancedDataArray.length);else for(var T=l?"u_instance":"u_normal_matrix",S=0;Su[1]?s:u,o[0]=i.max[0],l=(s=e.a6.vec4.transformMat4(e.a6.vec4.create(),o,a))[1]u[1]?s:u,o[1]=i.min[1],l=(s=e.a6.vec4.transformMat4(e.a6.vec4.create(),o,a))[1]u[1]?s:u;var c=e.ap(n[0],0,1),h=100*r.pixelsPerMeter*e.ap(n[1],0,1),f=e.ap(n[2],0,1),d=e.a6.vec4.lerp(e.a6.vec4.create(),l,u,c),p=Math.tan(.5*r.fovX),m=-d[2]*p;if(0===h)return d[1]<-Math.abs(m)?f:1;var v=(-Math.abs(m)-d[1])/h,_=function(e,t,r){return(1-r)*e+r*t},g=e.ap(_(1,f,v),f,1);return _(1,g,e.ap((r.pitch-20)/20,0,1))}var Ho=m((function e(){p(this,e)})),Wo=(function(){return m((function e(){p(this,e),this._storage=new Map}),[{key:"getLinesFromTrianglesBuffer",value:function(t,r,i){var n=this._storage.get(r.id);if(n)return n.lastUsedFrameIdx=t,n.buf;var a=i.gl,o=a.getBufferParameter(a.ELEMENT_ARRAY_BUFFER,a.BUFFER_SIZE),s=new ArrayBuffer(o),l=new Int16Array(s);a.getBufferSubData(a.ELEMENT_ARRAY_BUFFER,0,new Int16Array(s));for(var u=new e.dk,c=0;c30&&(n.buf.destroy(),this._storage.delete(i))}}},{key:"destroy",value:function(){for(var e of this._storage){var t=x(e,2),r=t[0];t[1].buf.destroy(),this._storage.delete(r)}}}])})(),Xo=m((function e(t){p(this,e),this.occluderSize=30,this.depthOffset=-1e-4,t.registerParameter(this,["Occlusion"],"occluderSize",{min:1,max:100,step:1}),t.registerParameter(this,["Occlusion"],"depthOffset",{min:-.05,max:0,step:1e-5})})),Yo=(function(){return m((function e(){p(this,e)}),[{key:"registerParameter",value:function(){}},{key:"registerButton",value:function(){}},{key:"registerBinding",value:function(){}},{key:"refreshUI",value:function(){}}])})(),Jo={symbol:function(t,r,i,n,a){if("translucent"===t.renderPass){var o=ri.disabled,s=t.colorModeForRenderPass(),l=i.layout.get("text-variable-anchor"),u=i.layout.get("text-size-scale-range"),c=e.ap(t.scaleFactor,u[0],u[1]);l&&(function(t,r,i,n,a,o,s,l){var u=r.transform,c="map"===a,h="map"===o;for(var f of t){var d=n.getTile(f),p=d.getBucket(i);if(p&&p.text&&p.text.segments.get().length){var m=e.bk(p.textSizeData,u.zoom,l),v=Sr(f,p.getProjection(),u),_=u.calculatePixelsToTileUnitsMatrix(d),g=or(v,d.tileID.canonical,h,c,u,p.getProjection(),_),y=p.hasIconTextFit()&&p.hasIconData();if(m){var x=Math.pow(2,u.zoom-d.tileID.overscaledZ);Ya(p,c,h,s,e.cS,u,g,f,x,m,y)}}}})(n,t,i,r,i.layout.get("text-rotation-alignment"),i.layout.get("text-pitch-alignment"),a,c);var h=0!==i.paint.get("icon-opacity").constantOr(1),f=0!==i.paint.get("text-opacity").constantOr(1);void 0!==i.layout.get("symbol-sort-key").constantOr(1)&&(h||f)?Ja(t,r,i,n,o,s):(h&&Ja(t,r,i,n,o,s,{onlyIcons:!0}),f&&Ja(t,r,i,n,o,s,{onlyText:!0})),r.map.showCollisionBoxes&&($a(t,r,i,n,i.paint.get("text-translate"),i.paint.get("text-translate-anchor"),!0),$a(t,r,i,n,i.paint.get("icon-translate"),i.paint.get("icon-translate-anchor"),!1))}},circle:function(t,r,i,n){if("translucent"===t.renderPass){var a=i.paint.get("circle-opacity"),o=i.paint.get("circle-stroke-width"),s=i.paint.get("circle-stroke-opacity"),l=void 0!==i.layout.get("circle-sort-key").constantOr(1),u=i.paint.get("circle-emissive-strength");if(0!==a.constantOr(1)||0!==o.constantOr(1)&&0!==s.constantOr(1)){for(var c=t.context,h=c.gl,f=t.transform,d=t.depthModeForSublayer(0,ei.ReadOnly),p=ri.disabled,m=t.colorModeForDrapableLayerRenderPass(u),v="globe"===f.projection.name,_=[e.am(f.center.lng),e.at(f.center.lat)],g=[],y=0;y0&&l<1,z=i.paint.get("line-gradient"),D=A?"linePattern":"line",R=e.cV(i);if(y&&t.terrain&&t.terrain.clipOrMaskOverlapStencilType()&&(P=!1),0!==l&&t.depthOcclusion){var L=i.paint._values["line-opacity"];L&&L.value&&"constant"===L.value.kind?d=L.value:e.w(`Occlusion opacity for layer ${i.id} is supported only when line-opacity isn't data-driven.`)}if(f&&(t.forceTerrainMode=!0),f||0===l||!t.terrain||y){var O=P&&f?t.stencilModeFor3D():ri.disabled;f&&(R.push("ELEVATED"),m&&R.push(v?"CROSS_SLOPE_HORIZONTAL":"CROSS_SLOPE_VERTICAL"),u&&R.push("ELEVATION_REFERENCE_SEA"));var F=function(){var n=r.getTile(B);if(A&&!n.patternsLoaded())return 0;var a=n.getBucket(i);if(!a)return 0;t.prepareDrawTile();var o=a.programConfigurations.get(i.id),s=t.isTileAffectedByFog(B),p=t.getOrCreateProgram(D,{config:o,defines:R,overrideFog:s,overrideRtt:!f&&void 0});if(I&&n.imageAtlas){var m=n.imageAtlas.patternPositions[I.toString()];m&&o.setConstantPatternPositions(m)}if(!A&&S&&E&&n.lineAtlas){var v=n.lineAtlas.getDash(S,E);v&&o.setConstantPatternPositions(v)}var w=i.paint.get("line-trim-offset"),T=x(w,2),M=T[0],L=T[1];if("round"===E||"square"===E){M!==L&&(0===M&&(M-=1),1===L&&(L+=1))}var F=y?B.projMatrix:null,N=A?e.cW(t,n,i,F,b,[M,L]):e.cX(t,n,i,F,a.lineClipsArray.length,b,[M,L]);if(z){var V=a.gradients[i.id],U=V.texture;if(i.gradientVersion!==V.version){var j=256;if(i.stepInterpolant){var G=r.getSource().maxzoom,q=B.canonical.z===G?Math.ceil(1<0&&w>0,E=k>0,M=function(e,t,r){return(1-r)*e+r*t},A=function(a){var o=t.depthModeForSublayer(1,ei.ReadOnly,s.LEQUAL,!0),l=i.paint.get(a?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),u=M(.1,3,l),h=t._showOverdrawInspector;if(!h){var f=new ri({func:s.ALWAYS,mask:255},255,255,s.KEEP,s.KEEP,s.REPLACE),d=new Qr([s.ONE,s.ONE,s.ONE,s.ONE],e.bA.transparent,[!1,!1,!1,!0],s.MIN);to(t,r,i,n,o,f,d,ai.disabled,a,"sdf",x,b,w,k,T,u,c,!1)}var p=h?ri.disabled:new ri({func:s.EQUAL,mask:255},255,255,s.KEEP,s.DECR,s.DECR),m=h?t.colorModeForRenderPass():new Qr([s.ONE_MINUS_DST_ALPHA,s.DST_ALPHA,s.ONE,s.ONE],e.bA.transparent,[!0,!0,!0,!0]);to(t,r,i,n,o,p,m,ai.disabled,a,"color",x,b,w,k,T,u,c,!1)};if(u){var I=function(a,o,l){var u=t.depthModeForSublayer(1,ei.ReadOnly,s.LEQUAL,!1),h=i.paint.get(a?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),f=M(.1,3,h),d=new Qr([s.ONE,s.ONE,s.ONE,s.ONE],e.bA.transparent,[!1,!1,!1,!0]);to(t,r,i,n,u,ri.disabled,d,ai.disabled,a,"clear",x,b,w,k,T,f,c,o);var p=new ri({func:s.ALWAYS,mask:255},255,255,s.KEEP,s.KEEP,s.REPLACE),m=new Qr([s.ONE,s.ONE,s.ONE,s.ONE],e.bA.transparent,[!1,!1,!1,!0],s.MIN);to(t,r,i,n,u,p,m,ai.disabled,a,"sdf",x,b,w,k,T,f,c,o);var v=a?s.ZERO:s.ONE_MINUS_DST_ALPHA,_=new ri({func:s.EQUAL,mask:255},255,255,s.KEEP,s.DECR,s.DECR),g=new Qr([v,s.DST_ALPHA,s.ONE_MINUS_DST_ALPHA,s.ZERO],e.bA.transparent,[!0,!0,!0,!0]);to(t,r,i,n,u,_,g,ai.disabled,a,"color",x,b,w,k,T,f,c,o);var y=new Qr([s.ONE,s.ONE,s.ONE,a?s.ZERO:s.ONE],e.bA.transparent,[!1,!1,!1,!0],a?s.FUNC_ADD:s.MAX);to(t,r,i,n,u,ri.disabled,y,ai.disabled,a,"clear",x,b,w,k,T,f,c,o,l)};if(S||E){var C;if(t.prepareDrawTile(),l){var P=l.drapeBufferSize[0],z=l.drapeBufferSize[1];(C=l.framebufferCopyTexture)&&(!C||C.size[0]===P&&C.size[1]===z)||(C&&C.destroy(),C=l.framebufferCopyTexture=new e.T(o,new e.r({width:P,height:z}),s.RGBA8)),C.bind(s.LINEAR,s.CLAMP_TO_EDGE),s.copyTexSubImage2D(s.TEXTURE_2D,0,0,0,0,0,P,z)}S&&I(!0,!1,C),E&&I(!1,!0,C)}}else S&&A(!0),E&&A(!1),(S||E)&&t.resetStencilClippingMasks()}}}},hillshade:function(e,t,r,i){if(("offscreen"===e.renderPass||"translucent"===e.renderPass)&&!e.style.disableElevatedTerrain){var n=e.context,a=e.terrain&&e.terrain.renderingToTexture,o="translucent"!==e.renderPass||a?[{},i]:e.stencilConfigForOverlap(i),s=x(o,2),l=s[0],u=s[1];for(var c of u){var h=t.getTile(c);if(h.needsHillshadePrepare&&"offscreen"===e.renderPass)un(e,h,r);else if("translucent"===e.renderPass){var f=e.depthModeForSublayer(0,ei.ReadOnly),d=r.paint.get("hillshade-emissive-strength"),p=e.colorModeForDrapableLayerRenderPass(d),m=a&&e.terrain?e.terrain.stencilModeForRTTOverlap(c):l[c.overscaledZ];sn(e,c,h,r,f,m,p)}}n.viewport.set([0,0,e.width,e.height]),e.resetStencilClippingMasks()}},raster:function(t,r,i,n,a,o){if("translucent"===t.renderPass&&0!==i.paint.get("raster-opacity")){var s="globe"===t.transform.projection.name,l=0!==i.paint.get("raster-elevation"),u=l&&s;if(!t.renderElevatedRasterBackface||u){var c=t.context,h=c.gl,f=r.getSource(),d=(function(t,r,i,n){var a=r.paint.get("raster-color"),o="raster-array"===t.type,s=[],l=r.paint.get("raster-resampling"),u=r.paint.get("raster-color-mix"),c=r.paint.get("raster-color-range"),h=[u[0],u[1],u[2],0],f=u[3],d="nearest"===l?n.NEAREST:n.LINEAR;if(o&&(s.push("RASTER_ARRAY"),a||s.push("RASTER_COLOR"),"linear"===l&&s.push("RASTER_ARRAY_LINEAR"),d=n.NEAREST,!c&&t.rasterLayers)){var p=t.rasterLayers.find((function(e){return e.id===r.sourceLayer}));p&&p.fields&&p.fields.range&&(c=p.fields.range)}if(c=c||[0,1],a){s.push("RASTER_COLOR"),i.activeTexture.set(n.TEXTURE2),r.updateColorRamp(c);var m=r.colorRampTexture;m||(m=r.colorRampTexture=new e.T(i,r.colorRamp,n.RGBA8)),m.bind(n.LINEAR,n.CLAMP_TO_EDGE)}return{mix:h,range:c,offset:f,defines:s,resampling:d}})(f,i,c,h);if(!(f instanceof e.aD)||n.length||s){var p=i.paint.get("raster-emissive-strength"),m=t.colorModeForDrapableLayerRenderPass(p),v=t.terrain&&t.terrain.renderingToTexture,_=!t.options.moving,g="nearest"===i.paint.get("raster-resampling")?h.NEAREST:h.LINEAR;if(f instanceof e.aD&&!n.length&&(f.onNorthPole||f.onSouthPole)){var y=l?t.stencilModeFor3D():ri.disabled;lo(!!f.onNorthPole,null,t,r,i,p,d,ai.disabled,y)}else if(n.length){var b=f instanceof e.aD||v?[{},n]:t.stencilConfigForOverlap(n),w=x(b,2),k=w[0],T=w[1],S=T[T.length-1].overscaledZ;u&&d.defines.push("PROJECTION_GLOBE_VIEW"),l&&d.defines.push("RENDER_CUTOFF");var E=function(n,a,y){for(var b of n){var w=b.toUnwrapped(),T=r.getTile(b);if(!v||T&&T.hasData()){c.activeTexture.set(h.TEXTURE0);var E=co(T,f,i,d);if(E&&E.texture){var M=E.texture,A=E.mix,I=E.offset,C=E.tileSize,P=E.buffer,z=void 0,D=void 0;v?(z=ei.disabled,D=b.projMatrix):l?(z=new ei(h.LEQUAL,ei.ReadWrite,t.depthRangeFor3D),D=s?Float32Array.from(t.transform.expandedFarZProjMatrix):t.transform.calculateProjMatrix(w,_)):(z=t.depthModeForSublayer(b.overscaledZ-S,1===i.paint.get("raster-opacity")?ei.ReadWrite:ei.ReadOnly,h.LESS),D=t.transform.calculateProjMatrix(w,_));var R=t.terrain&&v?t.terrain.stencilModeForRTTOverlap(b):k[b.overscaledZ],L=o?0:i.paint.get("raster-fade-duration");T.registerFadeDuration(L);var O=r.findLoadedParent(b,0),F=ta(T,O,r,t.transform,L),B=void 0,N=void 0;t.terrain&&t.terrain.prepareDrawTile(),c.activeTexture.set(h.TEXTURE0),M.bind(g,h.CLAMP_TO_EDGE),c.activeTexture.set(h.TEXTURE1),O?(O.texture&&O.texture.bind(g,h.CLAMP_TO_EDGE),B=Math.pow(2,O.tileID.overscaledZ-T.tileID.overscaledZ),N=[T.tileID.canonical.x*B%1,T.tileID.canonical.y*B%1]):M.bind(g,h.CLAMP_TO_EDGE),M.useMipmap&&c.extTextureFilterAnisotropic&&t.transform.pitch>20&&h.texParameterf(h.TEXTURE_2D,c.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,c.extTextureFilterAnisotropicMax);var V=t.transform,U=void 0,j=l?uo(V):[0,0,0,0],G=void 0,q=void 0,Z=void 0,$=void 0,H=void 0,W=0;if(u&&f instanceof e.aD&&f.coordinates.length>3)G=Float32Array.from(e.b6(e.cC(new e.bQ(0,0,0)))),q=Float32Array.from(V.globeMatrix),Z=Float32Array.from(e.cy(V)),$=[e.am(V.center.lng),e.at(V.center.lat)],U=f.elevatedGlobePerspectiveTransform,H=f.elevatedGlobeGridMatrix||new Float32Array(9);else if(u){var X=e.cz(b.canonical);W=e.cA(X.getCenter().lat),G=Float32Array.from(e.b6(e.cC(b.canonical))),q=Float32Array.from(V.globeMatrix),Z=Float32Array.from(e.cy(V)),$=[e.am(V.center.lng),e.at(V.center.lat)],U=[0,0],H=Float32Array.from(e.cB(b.canonical,X,W,V.worldSize/V._pixelsPerMercatorPixel))}else U=f instanceof e.aD?f.perspectiveTransform:[0,0],G=new Float32Array(16),q=new Float32Array(9),Z=new Float32Array(16),$=[0,0],H=new Float32Array(9);var Y=Ea(D,G,q,Z,H,N||[0,0],e.a9(t.transform.zoom),$,j,B||1,F,i,U,l?i.paint.get("raster-elevation"):0,2,A,I,d.range,C,P,p),J=t.isTileAffectedByFog(b),K=t.getOrCreateProgram("raster",{defines:d.defines,overrideFog:J});if(t.uploadCommonUniforms(c,K,w),f instanceof e.aD){var Q=f.elevatedGlobeVertexBuffer,ee=f.elevatedGlobeIndexBuffer;if(v||!s)f.boundsBuffer&&f.boundsSegments&&K.draw(t,h.TRIANGLES,z,ri.disabled,m,ai.disabled,Y,i.id,f.boundsBuffer,t.quadTriangleIndexBuffer,f.boundsSegments);else if(Q&&ee){var te=V.zoom<=e.c3?f.elevatedGlobeSegments:f.getSegmentsForLongitude(V.center.lng);te&&K.draw(t,h.TRIANGLES,z,ri.disabled,m,a,Y,i.id,Q,ee,te)}}else if(u){z=new ei(h.LEQUAL,ei.ReadOnly,t.depthRangeFor3D);var re=t.globeSharedBuffers;if(re){var ie=re.getGridBuffers(W,!1),ne=x(ie,3),ae=ne[0],oe=ne[1],se=ne[2];K.draw(t,h.TRIANGLES,z,y||R,t.colorModeForRenderPass(),a,Y,i.id,ae,oe,se)}}else{var le=t.getTileBoundsBuffers(T),ue=le.tileBoundsBuffer,ce=le.tileBoundsIndexBuffer,he=le.tileBoundsSegments;K.draw(t,h.TRIANGLES,z,R,m,ai.disabled,Y,i.id,ue,ce,he)}}}}if(!(f instanceof e.aD)&&u)for(var fe of n){var de=fe.canonical.y===(1<>>16,2654435769),((e=Math.imul(e^e>>>16,2654435769))>>>0)/4294967296},n=.9090909090909091,a=0;a0&&t.style.isLayerClipped(i,r.getSource())&&p.updateReplacement(d,t.replacementSource,f,a)&&(p.uploaded=!1,p.upload(t.context)),p.instancesPerModel){var w=p.instancesPerModel[b];w.features.length>0&&(b=_.evaluate(w.features[0].feature,{}));var k=l.getModel(b,a);if(k&&k.uploaded)for(var T of k.nodes)jo(t,i,T,w,x,d,Vo)}}}}}}else e.w(`Drawing 3D models for ${o.projection.name} projection is not yet implemented`)})(t,r,i,n,"vector"===c.type?i.scope:""),void u();if(c.loaded()){if("batched-model"===c.type)return(function(t,r,i,n){i.resetLayerRenderingStats(t);var a=t.context,o=t.transform,s=t.style.fog,l=t.shadowRenderer;if("mercator"===o.projection.name){var u=t.transform.getFreeCameraOptions().position,c=e.a6.vec3.scale([],[u.x,u.y,u.z],t.transform.worldSize),h=e.a6.vec3.negate([],c),f=e.a6.mat4.identity([]),p=e.de(o.center.lat,o.zoom),m=e.a6.mat4.fromScaling([],[1,1,1/p]);e.a6.mat4.translate(f,f,h);var v=i.paint.get("model-opacity"),_=new ei(a.gl.LEQUAL,ei.ReadWrite,t.depthRangeFor3D),g=new ei(a.gl.LEQUAL,ei.ReadOnly,t.depthRangeFor3D),y=new e.ca([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),b="shadow"===t.renderPass,w=b&&l?l.getCurrentCascadeFrustum():o.getFrustum(o.scaleZoom(o.worldSize)),k=i.paint.get("model-front-cutoff"),T=k[2]<1,S=wi(t,i.paint.get("model-cutoff-fade-range")),E=i.getLayerRenderingStats();(function(e,t,r,i){var n=e.terrain?e.terrain.exaggeration():0,a=e.transform.zoom;for(var o of i){var s=t.getTile(o).getBucket(r);s&&(e.conflationActive&&s.updateReplacement(o,e.replacementSource),s.evaluateScale(e,r),e.terrain&&n>0&&s.elevationUpdate(e.terrain,n,o,r.source),s.needsReEvaluation(e,a,r)&&s.evaluate(r))}})(t,r,i,n),(function(){var u,h,M;T?(u=n.length-1,h=-1,M=-1):(u=0,h=n.length,M=1);for(var A=new Float64Array(16),I=e.a6.vec3.create(),C=new e.P(0,0),P=function(){var u=n[z],h=r.getTile(u).getBucket(i);if(!h||!h.uploaded)return 1;var M=!1;l&&(M=0===l.getMaxCascadeForTile(u.toUnwrapped()));var P=o.calculatePosMatrix(u.toUnwrapped(),o.worldSize),D=h.modelTraits;!b&&T&&(e.a6.mat4.invert(A,P),e.a6.vec3.transformMat4(I,c,A),C.x=I[0],C.y=I[1]);var R=[],L=function(r){if(r.hiddenByReplacement)return 0;if(!r.node.meshes)return 0;var i=r.node,n=0;t.terrain&&i.elevation&&(n=i.elevation*t.terrain.exaggeration());var a=(function(){var t=r.aabb;return y.min=d(t.min),y.max=d(t.max),y.min[2]+=n,y.max[2]+=n,e.a6.vec3.transformMat4(y.min,y.min,P),e.a6.vec3.transformMat4(y.max,y.max,P),y})(),s=r.evaluatedScale;if(s[0]<=1&&s[1]<=1&&s[2]<=1&&0===a.intersects(w))return 0;if(!b&&T){var l=.16666666666666666;r.cameraCollisionOpacity=c[0]>a.min[0]&&c[0]a.min[1]&&c[1]t.depth?-1:1})),R)){var B=F.nodeInfo,N=B.node,V=e.a6.mat4.multiply([],m,F.tileModelMatrix);e.a6.mat4.multiply(V,f,V);var U=e.a6.mat4.invert([],V);e.a6.mat4.transpose(U,U),e.a6.mat4.scale(U,U,Go),V=e.a6.mat4.multiply(V,V,N.matrix);for(var j="light-beam"===t.renderPass,G=D&e.dj.HasMapboxMeshFeatures,q=G?0:B.evaluatedRMEA[0][2],Z=0;Z=Ze||ne>=Ze}}var ae=$.material,oe=void 0;ae.occlusionTexture&&ae.occlusionTexture.offsetScale&&(oe=ae.occlusionTexture.offsetScale,X.defines.push("OCCLUSION_TEXTURE_TRANSFORM"));var se=t.getOrCreateProgram("model",X);!b&&l&&l.setupShadowsFromMatrix(F.tileModelMatrix,se,l.useNormalOffset),t.uploadCommonUniforms(a,se,null,J);var le=ae.pbrMetallicRoughness;le.metallicFactor=.9,le.roughnessFactor=.5;var ue=Fa(new Float32Array(W),new Float32Array(V),new Float32Array(U),new Float32Array(N.matrix),t,F.opacity,le.baseColorFactor.toRenderColor(null),ae.emissiveFactor,le.metallicFactor,le.roughnessFactor,ae,q,i,[0,0,0],oe);!H&&(B.hasTranslucentParts||F.opacity<1)&&se.draw(t,a.gl.TRIANGLES,_,ri.disabled,Qr.disabled,ai.backCCW,ue,i.id,$.vertexBuffer,$.indexBuffer,$.segments,i.paint,t.transform.zoom,void 0,Y),se.draw(t,a.gl.TRIANGLES,H?g:_,ri.disabled,H||F.opacity<1||B.hasTranslucentParts?Qr.alphaBlended:Qr.unblended,ai.backCCW,ue,i.id,$.vertexBuffer,$.indexBuffer,$.segments,i.paint,t.transform.zoom,void 0,Y)}}}},z=u;z!==h;z+=M)P()})()}else e.w(`Drawing 3D landmark models for ${o.projection.name} projection is not yet implemented`)})(t,r,i,n),void u();if("model"===c.type){var h=c.getModels(),f=[],p=t.transform.getFreeCameraOptions().position,m=e.a6.vec3.scale([],[p.x,p.y,p.z],t.transform.worldSize);e.a6.vec3.negate(m,m);var v=[],_=[],g=0;for(var y of h){var b=i.paint.get("model-rotation").constantOr(null),w=i.paint.get("model-scale").constantOr(null),k=i.paint.get("model-translation").constantOr(null);y.computeModelMatrix(t,b,w,k,!0,!0,!1);var T=e.a6.mat4.identity([]),S=e.de(y.position.lat,t.transform.zoom),E=e.a6.mat4.fromScaling([],[1,1,1/S]);for(var M of(e.a6.mat4.translate(T,T,m),f.push({zScaleMatrix:E,negCameraPosMatrix:T}),y.nodes))Fo(t.transform,M,y.matrix,t.transform.expandedFarZProjMatrix,g,v,_);g++}if(v.sort((function(e,t){return t.depth-e.depth})),"shadow"!==t.renderPass){if(1===a)for(var A of _)Oo(A,t,i,f[A.modelIndex],ri.disabled,t.colorModeForRenderPass());else{for(var I of _)Oo(I,t,i,f[I.modelIndex],ri.disabled,Qr.disabled);for(var C of _)Oo(C,t,i,f[C.modelIndex],t.stencilModeFor3D(),t.colorModeForRenderPass());t.resetStencilClippingMasks()}for(var P of v)Oo(P,t,i,f[P.modelIndex],ri.disabled,t.colorModeForRenderPass());u()}else{for(var z of _)Bo(z.mesh,z.nodeModelMatrix,t,i);for(var D of v)Bo(D.mesh,D.nodeModelMatrix,t,i);u()}}}}}}}},Ko={model:function(e,t,r){var i=t.getSource();if(i.loaded())if("vector"!==i.type&&"geojson"!==i.type){if("batched-model"!==i.type&&"model"===i.type){var n=i.getModels();for(var a of n)a.upload(r.context)}}else r.modelManager&&r.modelManager.upload(r,"vector"===i.type?e.scope:"")},raster:function(e,t,r){var i=t.getSource();if(i instanceof lt&&i.loaded()){var n=e.sourceLayer||i.rasterLayerIds&&i.rasterLayerIds[0];if(n){var a=e.paint.get("raster-array-band")||i.getInitialBand(n);if(null!=a){var o=t.getIds().map((function(e){return t.getTileByID(e)}));for(var s of o)s.updateNeeded(n,a)&&i.prepareTile(s,n,a)}}}},"raster-particle":function(e,t,r){var i=t.getSource();if(i instanceof lt&&i.loaded()){var n=e.sourceLayer||i.rasterLayerIds&&i.rasterLayerIds[0];if(n){var a=e.paint.get("raster-particle-array-band")||i.getInitialBand(n);if(null!=a){var o=t.getIds().map((function(e){return t.getTileByID(e)}));for(var s of o)s.updateNeeded(n,a)&&i.prepareTile(s,n,a)}}}}},Qo=(function(){return m((function t(r,i,n,a,o){var s=this;p(this,t),this.context=new Za(r,i),this.transform=n,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.tp=o,this._timeStamp=e.q.now(),this._averageFPS=0,this._fpsHistory=[],this._dt=0,this._debugParams={forceEnablePrecipitation:!1,showTerrainProxyTiles:!1,fpsWindow:30,continousRedraw:!1,enabledLayers:{}};var l=["fill","line","symbol","circle","heatmap","fill-extrusion","raster","raster-particle","hillshade","model","background","sky"];for(var u of l)this._debugParams.enabledLayers[u]=!0;for(var c of(o.registerParameter(this._debugParams,["Terrain"],"showTerrainProxyTiles",{},(function(){s.style.map.triggerRepaint()})),o.registerParameter(this._debugParams,["Precipitation"],"forceEnablePrecipitation"),o.registerParameter(this._debugParams,["FPS"],"fpsWindow",{min:1,max:100,step:1}),o.registerBinding(this._debugParams,["FPS"],"continousRedraw",{readonly:!0,label:"continuous redraw"}),o.registerBinding(this,["FPS"],"_averageFPS",{readonly:!0,label:"value"}),o.registerBinding(this,["FPS"],"_averageFPS",{readonly:!0,label:"graph",view:"graph",min:0,max:200}),l))o.registerParameter(this._debugParams.enabledLayers,["Debug","Layers"],c);this.occlusionParams=new Xo(o),this.setup(),this.numSublayers=Nt.maxUnderzooming+Nt.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 Ei(this),this._wireframeDebugCache=new Wo,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0,this.layersWithOcclusionOpacity=[];var h=new e.r({width:1,height:1},Uint8Array.of(0,0,0,0));this.emptyDepthTexture=new e.T(this.context,h,r.RGBA8),this._clippingActiveLastFrame=!1,this.scaleFactor=a}),[{key:"updateTerrain",value:function(e,t){var r=!!e&&!!e.terrain&&this.transform.projection.supportsTerrain;if(r||this._terrain&&this._terrain.enabled){this._terrain||(this._terrain=new aa(this,e));var i=this._terrain;this.transform.elevation=r?i:null,i.update(e,this.transform,t),this.transform.elevation&&!i.enabled&&(this.transform.elevation=null)}}},{key:"_updateFog",value:function(e){var t=e.fog;if(!t||"globe"===this.transform.projection.name||t.getOpacity(this.transform.pitch)<1||t.properties.get("horizon-blend")<.03)this.transform.fogCullDistSq=null;else{var r=t.getFovAdjustedRange(this.transform._fov),i=x(r,2),n=i[0],a=i[1];if(n>a)this.transform.fogCullDistSq=null;else{var o=n+.78*(a-n);this.transform.fogCullDistSq=o*o}}}},{key:"terrain",get:function(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled||this._forceTerrainMode?this._terrain:null}},{key:"forceTerrainMode",get:function(){return this._forceTerrainMode},set:function(e){e&&!this._terrain&&(this._terrain=new aa(this,this.style)),this._forceTerrainMode=e}},{key:"shadowRenderer",get:function(){return this._shadowRenderer&&this._shadowRenderer.enabled?this._shadowRenderer:null}},{key:"wireframeDebugCache",get:function(){return this._wireframeDebugCache}},{key:"resize",value:function(t,r){if(this.width=t*e.q.devicePixelRatio,this.height=r*e.q.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(var i of this.style.order)this.style._mergedLayers[i].resize()}},{key:"setup",value:function(){var t=this.context,r=new e.a$;r.emplaceBack(0,0),r.emplaceBack(e.ab,0),r.emplaceBack(0,e.ab),r.emplaceBack(e.ab,e.ab),this.tileExtentBuffer=t.createVertexBuffer(r,e.b1.members),this.tileExtentSegments=e.b2.simpleSegment(0,0,4,2);var 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.debugBuffer=t.createVertexBuffer(i,e.b1.members),this.debugSegments=e.b2.simpleSegment(0,0,4,5);var n=new e.a$;n.emplaceBack(-1,-1),n.emplaceBack(1,-1),n.emplaceBack(-1,1),n.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(n,e.b1.members),this.viewportSegments=e.b2.simpleSegment(0,0,4,2);var a=new e.aO;a.emplaceBack(0,0,0,0),a.emplaceBack(e.ab,0,e.ab,0),a.emplaceBack(0,e.ab,0,e.ab),a.emplaceBack(e.ab,e.ab,e.ab,e.ab),this.mercatorBoundsBuffer=t.createVertexBuffer(a,e.b4.members),this.mercatorBoundsSegments=e.b2.simpleSegment(0,0,4,2);var o=new e.aP;o.emplaceBack(0,1,2),o.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(o);var s=new e.b0;for(var l of[0,1,3,2,0])s.emplaceBack(l);this.debugIndexBuffer=t.createIndexBuffer(s),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();var u=this.context.gl;this.stencilClearMode=new ri({func:u.ALWAYS,mask:0},0,255,u.ZERO,u.ZERO,u.ZERO),this.loadTimeStamps.push(performance.now())}},{key:"getMercatorTileBoundsBuffers",value:function(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}},{key:"getTileBoundsBuffers",value:function(e){return e._makeTileBoundsBuffers(this.context,this.transform.projection),e._tileBoundsBuffer?{tileBoundsBuffer:e._tileBoundsBuffer,tileBoundsIndexBuffer:e._tileBoundsIndexBuffer,tileBoundsSegments:e._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}},{key:"clearStencil",value:function(){var e=this.context.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.getOrCreateProgram("clippingMask").draw(this,e.TRIANGLES,ei.disabled,this.stencilClearMode,Qr.disabled,ai.disabled,ea(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}},{key:"resetStencilClippingMasks",value:function(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}},{key:"_renderTileClippingMasks",value:function(e,t,r){if(t&&this.currentStencilSource!==t.id&&e.isTileClipped()&&r&&0!==r.length){if(this._tileClippingMaskIDs&&!this.terrain){var i=!1;for(var n of r)if(void 0===this._tileClippingMaskIDs[n.key]){i=!0;break}if(!i)return}this.currentStencilSource=t.id;var a=this.context,o=a.gl;this.nextStencilID+r.length>256&&this.clearStencil(),a.setColorMode(Qr.disabled),a.setDepthMode(ei.disabled);var s=this.getOrCreateProgram("clippingMask");for(var l of(this._tileClippingMaskIDs={},r)){var u=t.getTile(l),c=this._tileClippingMaskIDs[l.key]=this.nextStencilID++,h=this.getTileBoundsBuffers(u),f=h.tileBoundsBuffer,d=h.tileBoundsIndexBuffer,p=h.tileBoundsSegments;s.draw(this,o.TRIANGLES,ei.disabled,new ri({func:o.ALWAYS,mask:0},c,255,o.KEEP,o.KEEP,o.REPLACE),Qr.disabled,ai.disabled,ea(l.projMatrix),"$clipping",f,d,p)}}}},{key:"stencilModeFor3D",value:function(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();var e=this.nextStencilID++,t=this.context.gl;return new ri({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}},{key:"stencilModeForClipping",value:function(e){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(e);var t=this.context.gl;return new ri({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}},{key:"stencilConfigForOverlap",value:function(e){var t=this.context.gl,r=e.sort((function(e,t){return t.overscaledZ-e.overscaledZ})),i=r[r.length-1].overscaledZ,n=r[0].overscaledZ-i+1;if(n>1){this.currentStencilSource=void 0,this.nextStencilID+n>256&&this.clearStencil();for(var a={},o=0;o3&&void 0!==arguments[3]&&arguments[3];if(this.depthOcclusion)return new ei(this.context.gl.GREATER,ei.ReadOnly,this.depthRangeFor3D);if(!this.opaquePassEnabledForLayer()&&!i)return ei.disabled;var n=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new ei(r||this.context.gl.LEQUAL,t,[n,n])}},{key:"opaquePassEnabledForLayer",value:function(){return this.currentLayerthis._debugParams.fpsWindow&&this._fpsHistory.splice(0,this._fpsHistory.length-this._debugParams.fpsWindow),this._averageFPS=Math.round(this._fpsHistory.reduce((function(t,r){return t+r/e._fpsHistory.length}),0))}},{key:"render",value:function(t,r){var i=this,n=e.q.now();this._dt=n-this._timeStamp,this._timeStamp=n,this._wireframeDebugCache.update(this.frameCounter),this._debugParams.continousRedraw=t.map.repaint,this.style=t,this.options=r;var a=this.style._mergedLayers,o=this.style._getOrder(!(!this.terrain||!this.terrain.enabled)).filter((function(e){var t=a[e];return!(t.type in i._debugParams.enabledLayers)||i._debugParams.enabledLayers[t.type]})),s=!1,l=!1;for(var u of o){var h=a[u];"circle"===h.type&&(s=!0),"symbol"===h.type&&(h.hasInitialOcclusionOpacityProperties?l=!0:s=!0)}var f=o.map((function(e){return a[e]})),p=this.style._mergedSourceCaches;this.imageManager=t.imageManager,this.modelManager=t.modelManager,this.symbolFadeChange=t.placement.symbolFadeChange(e.q.now()),this.imageManager.beginFrame();var m=0,v=!1;for(var _ in p){var g=p[_];g.used&&(g.prepare(this.context),g.getSource().usedInConflation&&++m)}var y=!1;for(var x of f)x.isHidden(this.transform.zoom)||("clip"===x.type&&(y=!0),this.prepareLayer(x));var b={},w={},k={},T={},S={};for(var E in p){var M=p[E];b[E]=M.getVisibleCoordinates(),w[E]=b[E].slice().reverse(),k[E]=M.getVisibleCoordinates(!0).reverse(),T[E]=M.getShadowCasterCoordinates(),S[E]=M.sortCoordinatesByDistance(b[E])}var A=function(e){var t=i.style.getLayerSourceCache(e);return t&&t.used?t.getSource():null};if(m||y||this._clippingActiveLastFrame){var I=[],C=[],P=0;for(var z of f)this.isSourceForClippingOrConflation(z,A(z))&&(I.push(z),C.push(P)),P++;if(y||I.length>1||this._clippingActiveLastFrame){y=!1;for(var D=[],R=0;R0){var H=A(Z);H&&(this.minCutoffZoom=Math.max(H.minzoom,this.minCutoffZoom)),Z.minzoom&&(this.minCutoffZoom=Math.max(Z.minzoom,this.minCutoffZoom))}Z.is3D()&&(this.opaquePassCutoff===1/0&&(this.opaquePassCutoff=q),this._lastOcclusionLayer=q)}var W=this.style&&this.style.fog;W?(this._fogVisible=0!==W.getOpacity(this.transform.pitch),this._fogVisible&&"globe"!==this.transform.projection.name&&(this._fogVisible=W.isVisibleOnFrustum(this.transform.cameraFrustum))):this._fogVisible=!1,this._cachedTileFogOpacities={},this.terrain&&(this.terrain.updateTileBinding(k),this.opaquePassCutoff=0);var X=this._shadowRenderer;if(X)for(var Y in X.updateShadowParameters(this.transform,this.style.directionalLight),p)for(var J of b[Y]){var K={min:0,max:0};this.terrain&&(K=this.terrain.getMinMaxForTile(J)||K),X.addShadowReceiver(J.toUnwrapped(),K.min,K.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 Do(this)),this._atmosphere.update(this)):this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0),Q.has(this.context.gl)){for(var ee of(this.renderPass="offscreen",f)){var te=t.getLayerSourceCache(ee);if(ee.hasOffscreenPass()&&!ee.isHidden(this.transform.zoom)){var re=te?w[te.id]:void 0;("custom"===ee.type||"raster"===ee.type||"raster-particle"===ee.type||ee.isSky()||re&&re.length)&&this.renderLayer(this,te,ee,re)}}this.depthRangeFor3D=[0,1-(f.length+2)*this.numSublayers*this.depthEpsilon],this._shadowRenderer&&(this.renderPass="shadow",this._shadowRenderer.drawShadowPass(this.style,T)),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]);var ie="globe"===this.transform.projection.name||this.transform.isHorizonVisible(),ne=(function(){if(r.showOverdrawInspector)return e.bA.black;var t=i.style.fog;if(t&&i.transform.projection.supportsFog){var n=i.style.getLut(t.scope);if(!ie){var a=t.properties.get("color").toRenderColor(n).toArray01();return c(e.bA,d(a))}if(ie){var o=t.properties.get("space-color").toRenderColor(n).toArray01();return c(e.bA,d(o))}}return e.bA.transparent})();if(this.context.clear({color:ne,depth:1}),this.clearStencil(),this._showOverdrawInspector=r.showOverdrawInspector,this.renderPass="opaque",this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&ie&&this._atmosphere.drawStars(this,this.style.fog),!this.terrain)for(this.currentLayer=o.length-1;this.currentLayer>=0;this.currentLayer--){var ae=f[this.currentLayer],oe=t.getLayerSourceCache(ae);if(!ae.isSky()){var se=oe?(ae.is3D()?S:w)[oe.id]:void 0;this._renderTileClippingMasks(ae,oe,se),this.renderLayer(this,oe,ae,se)}}if(this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&ie&&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.currentLayer0&&_e.hasShadowPass()&&0==--fe&&(X.drawGroundShadows(),this.firstLightBeamLayer<=this.currentLayer)){var ye=this.currentLayer;for(this.renderPass="light-beam",this.currentLayer=this.firstLightBeamLayer;this.currentLayer<=ye;this.currentLayer++){var xe=f[this.currentLayer];if(xe.hasLightBeamPass()){var be=t.getLayerSourceCache(xe);this.renderLayer(this,be,xe,be?w[be.id]:void 0)}}this.currentLayer=ye,this.renderPass="translucent"}if(this.currentLayer>=this._lastOcclusionLayer&&this.layersWithOcclusionOpacity.length>0){var we=this.currentLayer;for(var ke of(this.depthOcclusion=!0,this.layersWithOcclusionOpacity)){this.currentLayer=ke;var Te=f[this.currentLayer],Se=t.getLayerSourceCache(Te),Ee=Se?w[Se.id]:void 0;Te.is3D()||this.terrain||this._renderTileClippingMasks(Te,Se,Se?b[Se.id]:void 0),this.renderLayer(this,Se,Te,Ee)}this.depthOcclusion=!1,this.currentLayer=we,this.renderPass="translucent",this.layersWithOcclusionOpacity=[]}++this.currentLayer}}if(this.terrain&&this.terrain.postRender(),this.options.showTileBoundaries||this.options.showQueryGeometry||this.options.showTileAABBs){var Me=null;f.forEach((function(e){var r=t.getLayerSourceCache(e);r&&!e.isHidden(i.transform.zoom)&&r.getVisibleCoordinates().length&&(!Me||Me.getSource().maxzoom0?t.pop():null}},{key:"terrainRenderModeElevated",value:function(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture||this.forceTerrainMode}},{key:"linearFloatFilteringSupported",value:function(){return null!=this.context.extTextureFloatLinear}},{key:"currentGlobalDefines",value:function(e,t,r){var i=void 0===r?this.terrain&&this.terrain.renderingToTexture:r,n=[];return this.style&&this.style.enable3dLights()&&("globeRaster"===e||"terrainRaster"===e?(n.push("LIGHTING_3D_MODE"),n.push("LIGHTING_3D_ALPHA_EMISSIVENESS")):i||n.push("LIGHTING_3D_MODE")),"shadow"===this.renderPass&&(this._shadowMapDebug||n.push("DEPTH_TEXTURE")),this.terrainRenderModeElevated()&&(n.push("TERRAIN"),this.linearFloatFilteringSupported()&&n.push("TERRAIN_DEM_FLOAT_FORMAT")),"globe"===this.transform.projection.name&&n.push("GLOBE"),!this._fogVisible||i||void 0!==t&&!t||n.push("FOG","FOG_DITHERING"),i&&n.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&n.push("OVERDRAW_INSPECTOR"),n}},{key:"getOrCreateProgram",value:function(e,t){this.cache=this.cache||{};var r=t&&t.defines||[],i=t&&t.config,n=this.currentGlobalDefines(e,t&&t.overrideFog,t&&t.overrideRtt).concat(r),a=ua.cacheKey(tn[e],e,n,i);return this.cache[a]||(this.cache[a]=new ua(this.context,e,tn[e],i,Na[e],n)),this.cache[a]}},{key:"setCustomLayerDefaults",value:function(){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()}},{key:"setBaseState",value:function(){var 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)}},{key:"initDebugOverlayCanvas",value:function(){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))}},{key:"destroy",value:function(){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()}},{key:"prepareDrawTile",value:function(){this.terrain&&this.terrain.prepareDrawTile()}},{key:"uploadCommonLightUniforms",value:function(t,r){if(this.style.enable3dLights()){var i=this.style.directionalLight,n=this.style.ambientLight;if(i&&n){var a=(function(t,r,i){var n=t.properties.get("direction"),a=t.properties.get("color").toRenderColor(i.getLut(t.scope)).toArray01(),o=t.properties.get("intensity"),s=r.properties.get("color").toRenderColor(i.getLut(r.scope)).toArray01(),l=r.properties.get("intensity"),u=[n.x,n.y,n.z],c=e.cH(s,l),h=e.cH(a,o);return{u_lighting_ambient_color:c,u_lighting_directional_dir:u,u_lighting_directional_color:h,u_ground_radiance:oa(u,h,c)}})(i,n,this.style);r.setLightsUniformValues(t,a)}}}},{key:"uploadCommonUniforms",value:function(t,r,i,n,a){if(this.uploadCommonLightUniforms(t,r),!this.terrain||!this.terrain.renderingToTexture){var o=this.style.fog;if(o){var s=o.getOpacity(this.transform.pitch),l=(function(t,r,i,n,a,o,s,l,u,c,h,f){var d=t.transform,p=r.properties.get("color").toRenderColor(t.style.getLut(r.scope)).toArray01();p[3]=n;var m=t.frameCounter/1e3%1,v=r.properties.get("vertical-range"),_=x(v,2),g=_[0],y=_[1];return{u_fog_matrix:i?d.calculateFogTileMatrix(i):f||t.identityMat,u_fog_range:r.getFovAdjustedRange(d._fov),u_fog_color:p,u_fog_horizon_blend:r.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(g,y),y],u_fog_temporal_offset:m,u_frustum_tl:a,u_frustum_tr:o,u_frustum_br:s,u_frustum_bl:l,u_globe_pos:u,u_globe_radius:c,u_viewport:h,u_globe_transition:e.a9(d.zoom),u_is_globe:+("globe"===d.projection.name)}})(this,o,i,s,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],n);r.setFogUniformValues(t,l)}a&&r.setCutoffUniformValues(t,a.uniformValues)}}},{key:"setTileLoadedFlag",value:function(e){this.tileLoaded=e}},{key:"saveCanvasCopy",value:function(){var e=this.canvasCopy();e&&(this.frameCopies.push(e),this.tileLoaded=!1)}},{key:"canvasCopy",value:function(){var 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}},{key:"getCanvasCopiesAndTimestamps",value:function(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}},{key:"averageElevationNeedsEasing",value:function(){if(!this.transform._elevation)return!1;var e=this.style&&this.style.fog;return!!e&&0!==e.getOpacity(this.transform.pitch)}},{key:"getBackgroundTiles",value:function(){var e=this._backgroundTiles,t=this._backgroundTiles={},r=this.transform.coveringTiles({tileSize:512});for(var i of r)t[i.key]=e[i.key]||new Lt(i,512,this.transform.tileZoom,this);return t}},{key:"clearBackgroundTiles",value:function(){this._backgroundTiles={}}},{key:"isSourceForClippingOrConflation",value:function(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)))}},{key:"isTileAffectedByFog",value:function(e){if(!this.style||!this.style.fog)return!1;if("globe"===this.transform.projection.name)return!0;var t=this._cachedTileFogOpacities[e.key];return t||(this._cachedTileFogOpacities[e.key]=t=this.style.fog.getOpacityForTile(e)),t[0]>=Ze||t[1]>=Ze}},{key:"setupDepthForOcclusion",value:function(e,t,r){var i,n=this.context,a=n.gl,o=!!r;r||(r={u_dem:2,u_dem_prev:4,u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_depth_range_unpack:[0,1],u_occluder_half_size:16,u_occlusion_depth_offset:-1e-4,u_exaggeration:0}),n.activeTexture.set(a.TEXTURE3),e&&this.depthFBO&&this.depthTexture?(this.depthTexture.bind(a.NEAREST,a.CLAMP_TO_EDGE),r.u_depth_size_inv=[1/this.depthFBO.width,1/this.depthFBO.height],r.u_depth_range_unpack=[2/((i=this.depthRangeFor3D)[1]-i[0]),-1-2*i[0]/(i[1]-i[0])],r.u_occluder_half_size=.5*this.occlusionParams.occluderSize,r.u_occlusion_depth_offset=this.occlusionParams.depthOffset):this.emptyDepthTexture.bind(a.NEAREST,a.CLAMP_TO_EDGE),n.activeTexture.set(a.TEXTURE0),o||t.setTerrainUniformValues(n,r)}}])})();function es(e,t){var r=!1,i=null,n=function(){i=null,r&&(e(),i=setTimeout(n,t),r=!1)};return function(){return r=!0,i||n(),i}}var ts=(function(){return m((function t(r){p(this,t),this._hashName=r&&encodeURIComponent(r),e.aJ(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=es(this._updateHashUnthrottled.bind(this),300)}),[{key:"addTo",value:function(e){return this._map=e,window.addEventListener("hashchange",this._onHashChange,!1),e.on("moveend",this._updateHash),this}},{key:"remove",value:function(){return this._map?(this._map.off("moveend",this._updateHash),window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}},{key:"getHashString",value:function(){var e=this._map;if(!e)return"";var t=rs(e);if(this._hashName){var r=this._hashName,i=!1,n=location.hash.slice(1).split("&").map((function(e){var n=e.split("=")[0];return n===r?(i=!0,`${n}=${t}`):e})).filter((function(e){return e}));return i||n.push(`${r}=${t}`),`#${n.join("&")}`}return`#${t}`}},{key:"_getCurrentHash",value:function(){var e,t=this,r=location.hash.replace("#","");return this._hashName?(r.split("&").map((function(e){return e.split("=")})).forEach((function(r){r[0]===t._hashName&&(e=r)})),(e&&e[1]||"").split("/")):r.split("/")}},{key:"_onHashChange",value:function(){var e=this._map;if(!e)return!1;var t=this._getCurrentHash();if(t.length>=3&&!t.some((function(e){return isNaN(e)}))){var r=e.dragRotate.isEnabled()&&e.touchZoomRotate.isEnabled()?+(t[3]||0):e.getBearing();return e.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:r,pitch:+(t[4]||0)}),!0}return!1}},{key:"_updateHashUnthrottled",value:function(){history.replaceState(history.state,"",location.href.replace(/(#.+)?$/,this.getHashString()))}}])})();function rs(e,t){var r=e.getCenter(),i=Math.round(100*e.getZoom())/100,n=Math.ceil((i*Math.LN2+Math.log(2.8444444444444446))/Math.LN10),a=Math.pow(10,n),o=Math.round(r.lng*a)/a,s=Math.round(r.lat*a)/a,l=e.getBearing(),u=e.getPitch(),c=t?`/${o}/${s}/${i}`:`${i}/${s}/${o}`;return(l||u)&&(c+="/"+Math.round(10*l)/10),u&&(c+=`/${Math.round(u)}`),c}var is={linearity:.3,easing:e.dp(0,0,.3,1)},ns=e.l({deceleration:2500,maxSpeed:1400},is),as=e.l({deceleration:20,maxSpeed:1400},is),os=e.l({deceleration:1e3,maxSpeed:360},is),ss=e.l({deceleration:1e3,maxSpeed:90},is),ls=(function(){return m((function e(t){p(this,e),this._map=t,this.clear()}),[{key:"clear",value:function(){this._inertiaBuffer=[]}},{key:"record",value:function(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:e.q.now(),settings:t})}},{key:"_drainInertiaBuffer",value:function(){for(var t=this._inertiaBuffer,r=e.q.now();t.length>0&&r-t[0].time>160;)t.shift()}},{key:"_onMoveEnd",value:function(t){if(!(this._map._prefersReducedMotion()||(this._drainInertiaBuffer(),this._inertiaBuffer.length<2))){var r={zoom:0,bearing:0,pitch:0,pan:new e.P(0,0),pinchAround:void 0,around:void 0};for(var i of this._inertiaBuffer){var n=i.settings;r.zoom+=n.zoomDelta||0,r.bearing+=n.bearingDelta||0,r.pitch+=n.pitchDelta||0,n.panDelta&&r.pan._add(n.panDelta),n.around&&(r.around=n.around),n.pinchAround&&(r.pinchAround=n.pinchAround)}var a=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,o={};if(r.pan.mag()){var s=cs(r.pan.mag(),a,e.l({},ns,t||{}));o.offset=r.pan.mult(s.amount/r.pan.mag()),o.center=this._map.transform.center,us(o,s)}if(r.zoom){var l=cs(r.zoom,a,as);o.zoom=this._map.transform.zoom+l.amount,us(o,l)}if(r.bearing){var u=cs(r.bearing,a,os);o.bearing=this._map.transform.bearing+e.ap(u.amount,-179,179),us(o,u)}if(r.pitch){var c=cs(r.pitch,a,ss);o.pitch=this._map.transform.pitch+c.amount,us(o,c)}if(o.zoom||o.bearing){var h=void 0===r.pinchAround?r.around:r.pinchAround;o.around=h?this._map.unproject(h):this._map.getCenter()}return this.clear(),o.noMoveStart=!0,o}}}])})();function us(e,t){(!e.duration||e.duration3&&void 0!==arguments[3]?arguments[3]:{};p(this,r);var s=C(i.getCanvasContainer(),n),l=i.unproject(s);return(a=T(this,r,[t,e.l({point:s,lngLat:l,originalEvent:n},o)]))._defaultPrevented=!1,a.target=i,a}return g(r,t),m(r,[{key:"preventDefault",value:function(){this._defaultPrevented=!0}},{key:"defaultPrevented",get:function(){return this._defaultPrevented}}])})(e.x),fs=(function(t){function r(t,i,n){var a;p(this,r);var o="touchend"===t?n.changedTouches:n.touches,s=P(i.getCanvasContainer(),o),l=s.map((function(e){return i.unproject(e)})),u=s.reduce((function(e,t,r,i){return e.add(t.div(i.length))}),new e.P(0,0));return(a=T(this,r,[t,{points:s,point:u,lngLats:l,lngLat:i.unproject(u),originalEvent:n}]))._defaultPrevented=!1,a}return g(r,t),m(r,[{key:"preventDefault",value:function(){this._defaultPrevented=!0}},{key:"defaultPrevented",get:function(){return this._defaultPrevented}}])})(e.x),ds=(function(e){function t(e,r){var i;return p(this,t),(i=T(this,t,["wheel",{originalEvent:r}]))._defaultPrevented=!1,i}return g(t,e),m(t,[{key:"preventDefault",value:function(){this._defaultPrevented=!0}},{key:"defaultPrevented",get:function(){return this._defaultPrevented}}])})(e.x),ps=(function(){return m((function e(t,r){p(this,e),this._map=t,this._clickTolerance=r.clickTolerance}),[{key:"reset",value:function(){this._mousedownPos=void 0}},{key:"wheel",value:function(e){return this._firePreventable(new ds(this._map,e))}},{key:"mousedown",value:function(e,t){return this._mousedownPos=t,this._firePreventable(new hs(e.type,this._map,e))}},{key:"mouseup",value:function(e){this._map.fire(new hs(e.type,this._map,e))}},{key:"preclick",value:function(t){var r=e.l({},t);r.type="preclick",this._map.fire(new hs(r.type,this._map,r))}},{key:"click",value:function(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||(this.preclick(e),this._map.fire(new hs(e.type,this._map,e)))}},{key:"dblclick",value:function(e){return this._firePreventable(new hs(e.type,this._map,e))}},{key:"mouseover",value:function(e){this._map.fire(new hs(e.type,this._map,e))}},{key:"mouseout",value:function(e){this._map.fire(new hs(e.type,this._map,e))}},{key:"touchstart",value:function(e){return this._firePreventable(new fs(e.type,this._map,e))}},{key:"touchmove",value:function(e){this._map.fire(new fs(e.type,this._map,e))}},{key:"touchend",value:function(e){this._map.fire(new fs(e.type,this._map,e))}},{key:"touchcancel",value:function(e){this._map.fire(new fs(e.type,this._map,e))}},{key:"_firePreventable",value:function(e){if(this._map.fire(e),e.defaultPrevented)return{}}},{key:"isEnabled",value:function(){return!0}},{key:"isActive",value:function(){return!1}},{key:"enable",value:function(){}},{key:"disable",value:function(){}}])})(),ms=(function(){return m((function e(t){p(this,e),this._map=t}),[{key:"reset",value:function(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}},{key:"mousemove",value:function(e){this._map.fire(new hs(e.type,this._map,e))}},{key:"mousedown",value:function(){this._delayContextMenu=!0}},{key:"mouseup",value:function(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new hs("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}},{key:"contextmenu",value:function(e){this._delayContextMenu?this._contextMenuEvent=e:this._map.fire(new hs(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}},{key:"isEnabled",value:function(){return!0}},{key:"isActive",value:function(){return!1}},{key:"enable",value:function(){}},{key:"disable",value:function(){}}])})(),vs=(function(){return m((function e(t,r){p(this,e),this._map=t,this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=r.clickTolerance||1}),[{key:"isEnabled",value:function(){return!!this._enabled}},{key:"isActive",value:function(){return!!this._active}},{key:"enable",value:function(){this.isEnabled()||(this._enabled=!0)}},{key:"disable",value:function(){this.isEnabled()&&(this._enabled=!1)}},{key:"mousedown",value:function(e,t){this.isEnabled()&&e.shiftKey&&0===e.button&&(E(),this._startPos=this._lastPos=t,this._active=!0)}},{key:"mousemoveWindow",value:function(e,t){var r=this;if(this._active){var i=t,n=this._startPos,a=this._lastPos;if(!(!n||!a||a.equals(i)||!this._box&&i.dist(n)this.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=t.timeStamp),i.length===this.numTouches&&(this.centroid=(function(t){var r=new e.P(0,0);for(var i of t)r._add(i);return r.div(t.length)})(r),this.touches=_s(i,r)))}},{key:"touchmove",value:function(e,t,r){if(!this.aborted&&this.centroid){var i=_s(r,t);for(var n in this.touches){var a=i[n];(!a||a.dist(this.touches[n])>30)&&(this.aborted=!0)}}}},{key:"touchend",value:function(e,t,r){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===r.length){var i=!this.aborted&&this.centroid;if(this.reset(),i)return i}}}])})(),ys=(function(){return m((function e(t){p(this,e),this.singleTap=new gs(t),this.numTaps=t.numTaps,this.reset()}),[{key:"reset",value:function(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}},{key:"touchstart",value:function(e,t,r){this.singleTap.touchstart(e,t,r)}},{key:"touchmove",value:function(e,t,r){this.singleTap.touchmove(e,t,r)}},{key:"touchend",value:function(e,t,r){var i=this.singleTap.touchend(e,t,r);if(i){var n=e.timeStamp-this.lastTime<500,a=!this.lastTap||this.lastTap.dist(i)<30;if(n&&a||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=i,this.count===this.numTaps)return this.reset(),i}}}])})(),xs=(function(){return m((function e(){p(this,e),this._zoomIn=new ys({numTouches:1,numTaps:2}),this._zoomOut=new ys({numTouches:2,numTaps:1}),this.reset()}),[{key:"reset",value:function(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}},{key:"touchstart",value:function(e,t,r){this._zoomIn.touchstart(e,t,r),this._zoomOut.touchstart(e,t,r)}},{key:"touchmove",value:function(e,t,r){this._zoomIn.touchmove(e,t,r),this._zoomOut.touchmove(e,t,r)}},{key:"touchend",value:function(e,t,r){var i=this,n=this._zoomIn.touchend(e,t,r),a=this._zoomOut.touchend(e,t,r);return n?(this._active=!0,e.preventDefault(),setTimeout((function(){return i.reset()}),0),{cameraAnimation:function(t){return t.easeTo({duration:300,zoom:t.getZoom()+1,around:t.unproject(n)},{originalEvent:e})}}):a?(this._active=!0,e.preventDefault(),setTimeout((function(){return i.reset()}),0),{cameraAnimation:function(t){return t.easeTo({duration:300,zoom:t.getZoom()-1,around:t.unproject(a)},{originalEvent:e})}}):void 0}},{key:"touchcancel",value:function(){this.reset()}},{key:"enable",value:function(){this._enabled=!0}},{key:"disable",value:function(){this._enabled=!1,this.reset()}},{key:"isEnabled",value:function(){return this._enabled}},{key:"isActive",value:function(){return this._active}}])})(),bs={0:1,2:2},ws=(function(){return m((function e(t){p(this,e),this.reset(),this._clickTolerance=t.clickTolerance||1}),[{key:"blur",value:function(){this.reset()}},{key:"reset",value:function(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}},{key:"_correctButton",value:function(e,t){return!1}},{key:"_move",value:function(e,t){return{}}},{key:"mousedown",value:function(e,t){if(!this._lastPoint){var r=z(e);this._correctButton(e,r)&&(this._lastPoint=t,this._eventButton=r)}}},{key:"mousemoveWindow",value:function(e,t){var r=this._lastPoint;if(r)if(e.preventDefault(),null!=this._eventButton&&(function(e,t){var r=bs[t];return void 0===e.buttons||(e.buttons&r)!==r})(e,this._eventButton))this.reset();else if(this._moved||!(t.dist(r)0&&(this._active=!0);var n=_s(i,r),a=new e.P(0,0),o=new e.P(0,0),s=0;for(var l in n){var u=n[l],c=this._touches[l];c&&(a._add(u),o._add(u.sub(c)),s++,n[l]=u)}if(this._touches=n,!(sMath.abs(e.x)}var Rs=(function(t){function r(e){var t;return p(this,r),(t=T(this,r))._map=e,t}return g(r,t),m(r,[{key:"reset",value:function(){k(r,"reset",this,3)([]),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}},{key:"_start",value:function(e){this._lastPoints=e,Ds(e[0].sub(e[1]))&&(this._valid=!1)}},{key:"_move",value:function(t,r,i){var n=this._lastPoints;if(n){var a=t[0].sub(n[0]),o=t[1].sub(n[1]);return this._map._cooperativeGestures&&!e.dq()&&i.touches.length<3||(this._valid=this.gestureBeginsVertically(a,o,i.timeStamp),!this._valid)?void 0:(this._lastPoints=t,this._active=!0,{pitchDelta:(a.y+o.y)/2*-.5})}}},{key:"gestureBeginsVertically",value:function(e,t,r){if(void 0!==this._valid)return this._valid;var i=e.mag()>=2,n=t.mag()>=2;if(i||n){if(!i||!n)return null==this._firstMove&&(this._firstMove=r),r-this._firstMove<100&&void 0;var a=e.y>0==t.y>0;return Ds(e)&&Ds(t)&&a}}}])})(Ms),Ls={panStep:100,bearingStep:15,pitchStep:10},Os=(function(){return m((function e(){p(this,e);var t=Ls;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.pitchStep,this._rotationDisabled=!1}),[{key:"blur",value:function(){this.reset()}},{key:"reset",value:function(){this._active=!1}},{key:"keydown",value:function(e){var t=this;if(!(e.altKey||e.ctrlKey||e.metaKey)){var r=0,i=0,n=0,a=0,o=0;switch(e.keyCode){case 61:case 107:case 171:case 187:r=1;break;case 189:case 109:case 173:r=-1;break;case 37:e.shiftKey?i=-1:(e.preventDefault(),a=-1);break;case 39:e.shiftKey?i=1:(e.preventDefault(),a=1);break;case 38:e.shiftKey?n=1:(e.preventDefault(),o=-1);break;case 40:e.shiftKey?n=-1:(e.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(i=0,n=0),{cameraAnimation:function(s){var l=s.getZoom();s.easeTo({duration:300,easeId:"keyboardHandler",easing:Fs,zoom:r?Math.round(l)+r*(e.shiftKey?2:1):l,bearing:s.getBearing()+i*t._bearingStep,pitch:s.getPitch()+n*t._pitchStep,offset:[-a*t._panStep,-o*t._panStep],center:s.getCenter()},{originalEvent:e})}}}}},{key:"enable",value:function(){this._enabled=!0}},{key:"disable",value:function(){this._enabled=!1,this.reset()}},{key:"isEnabled",value:function(){return this._enabled}},{key:"isActive",value:function(){return this._active}},{key:"disableRotation",value:function(){this._rotationDisabled=!0}},{key:"enableRotation",value:function(){this._rotationDisabled=!1}}])})();function Fs(e){return e*(2-e)}var Bs=4.000244140625,Ns=(function(){return m((function t(r,i){p(this,t),this._map=r,this._el=r.getCanvasContainer(),this._handler=i,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,e.aJ(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this)}),[{key:"setZoomRate",value:function(e){this._defaultZoomRate=e}},{key:"setWheelZoomRate",value:function(e){this._wheelZoomRate=e}},{key:"isEnabled",value:function(){return!!this._enabled}},{key:"isActive",value:function(){return this._active||void 0!==this._finishTimeout}},{key:"isZooming",value:function(){return!!this._zooming}},{key:"enable",value:function(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around,this._map._cooperativeGestures&&this._addScrollZoomBlocker())}},{key:"disable",value:function(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}},{key:"wheel",value:function(t){if(this.isEnabled()){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))}var r=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY,i=e.q.now(),n=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,0!==r&&r%Bs==0?this._type="wheel":0!==r&&Math.abs(r)<4?this._type="trackpad":n>400?(this._type=null,this._lastValue=r,this._timeout=window.setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(n*r)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,r+=this._lastValue)),t.shiftKey&&r&&(r/=4),this._type&&(this._lastWheelEvent=t,this._delta-=r,this._active||this._start(t)),t.preventDefault()}}},{key:"_onTimeout",value:function(e){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e)}},{key:"_start",value:function(e){if(this._delta){this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);var t=C(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())}}},{key:"renderFrame",value:function(){var t=this;if(this._frameId&&(this._frameId=null,this.isActive())){var r=this._map.transform;"wheel"===this._type&&r.projection.wrap&&(r._center.lng>=180||r._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);var i=function(){return r._terrainEnabled()&&t._aroundCoord?r.computeZoomRelativeTo(t._aroundCoord):r.zoom};if(0!==this._delta){var n="wheel"===this._type&&Math.abs(this._delta)>Bs?this._wheelZoomRate:this._defaultZoomRate,a=2/(1+Math.exp(-Math.abs(this._delta*n)));this._delta<0&&0!==a&&(a=1/a);var o=i(),s=Math.pow(2,o),l="number"==typeof this._targetZoom?r.zoomScale(this._targetZoom):s;this._targetZoom=Math.min(r.maxZoom,Math.max(r.minZoom,r.scaleZoom(l*a))),"wheel"===this._type&&(this._startZoom=o,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0}var u,c="number"==typeof this._targetZoom?this._targetZoom:i(),h=this._startZoom,f=this._easing,d=!1;if("wheel"===this._type&&h&&f){var p=Math.min((e.q.now()-this._lastWheelEventTime)/200,1),m=f(p);u=e.aa(h,c,m),p<1?this._frameId||(this._frameId=!0):d=!0}else u=c,d=!0;this._active=!0,d&&(this._active=!1,this._finishTimeout=window.setTimeout((function(){t._zooming=!1,t._handler._triggerRenderFrame(),delete t._targetZoom,delete t._finishTimeout}),200));var v=u-i();return v*this._lastDelta<0&&(v=0),{noInertia:!0,needsRenderFrame:!d,zoomDelta:v,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}}},{key:"_smoothOutEasing",value:function(t){var r=e.dr;if(this._prevEase){var i=this._prevEase,n=(e.q.now()-i.start)/i.duration,a=i.easing(n+.01)-i.easing(n),o=.27/Math.sqrt(a*a+1e-4)*.01,s=Math.sqrt(.0729-o*o);r=e.dp(o,s,.25,1)}return this._prevEase={start:e.q.now(),duration:t,easing:r},r}},{key:"blur",value:function(){this.reset()}},{key:"reset",value:function(){this._active=!1}},{key:"_addScrollZoomBlocker",value:function(){this._map&&!this._alertContainer&&(this._alertContainer=f("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`)}},{key:"_showBlockerAlert",value:function(){var e=this;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((function(){e._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),e._alertContainer.removeAttribute("role")}),200)}}])})(),Vs=(function(){return m((function e(t,r){p(this,e),this._clickZoom=t,this._tapZoom=r}),[{key:"enable",value:function(){this._clickZoom.enable(),this._tapZoom.enable()}},{key:"disable",value:function(){this._clickZoom.disable(),this._tapZoom.disable()}},{key:"isEnabled",value:function(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}},{key:"isActive",value:function(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}])})(),Us=(function(){return m((function e(){p(this,e),this.reset()}),[{key:"reset",value:function(){this._active=!1}},{key:"blur",value:function(){this.reset()}},{key:"dblclick",value:function(e,t){return e.preventDefault(),{cameraAnimation:function(r){r.easeTo({duration:300,zoom:r.getZoom()+(e.shiftKey?-1:1),around:r.unproject(t)},{originalEvent:e})}}}},{key:"enable",value:function(){this._enabled=!0}},{key:"disable",value:function(){this._enabled=!1,this.reset()}},{key:"isEnabled",value:function(){return this._enabled}},{key:"isActive",value:function(){return this._active}}])})(),js=(function(){return m((function e(){p(this,e),this._tap=new ys({numTouches:1,numTaps:1}),this.reset()}),[{key:"reset",value:function(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}},{key:"touchstart",value:function(e,t,r){this._swipePoint||(this._tapTime&&e.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?r.length>0&&(this._swipePoint=t[0],this._swipeTouch=r[0].identifier):this._tap.touchstart(e,t,r))}},{key:"touchmove",value:function(e,t,r){if(this._tapTime){if(this._swipePoint){if(r[0].identifier!==this._swipeTouch)return;var i=t[0],n=i.y-this._swipePoint.y;return this._swipePoint=i,e.preventDefault(),this._active=!0,{zoomDelta:n/128}}}else this._tap.touchmove(e,t,r)}},{key:"touchend",value:function(e,t,r){this._tapTime?this._swipePoint&&0===r.length&&this.reset():this._tap.touchend(e,t,r)&&(this._tapTime=e.timeStamp)}},{key:"touchcancel",value:function(){this.reset()}},{key:"enable",value:function(){this._enabled=!0}},{key:"disable",value:function(){this._enabled=!1,this.reset()}},{key:"isEnabled",value:function(){return this._enabled}},{key:"isActive",value:function(){return this._active}}])})(),Gs=(function(){return m((function e(t,r,i){p(this,e),this._el=t,this._mousePan=r,this._touchPan=i}),[{key:"enable",value:function(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("mapboxgl-touch-drag-pan")}},{key:"disable",value:function(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("mapboxgl-touch-drag-pan")}},{key:"isEnabled",value:function(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}},{key:"isActive",value:function(){return this._mousePan.isActive()||this._touchPan.isActive()}}])})(),qs=(function(){return m((function e(t,r,i){p(this,e),this._pitchWithRotate=t.pitchWithRotate,this._mouseRotate=r,this._mousePitch=i}),[{key:"enable",value:function(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}},{key:"disable",value:function(){this._mouseRotate.disable(),this._mousePitch.disable()}},{key:"isEnabled",value:function(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}},{key:"isActive",value:function(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}])})(),Zs=(function(){return m((function e(t,r,i,n){p(this,e),this._el=t,this._touchZoom=r,this._touchRotate=i,this._tapDragZoom=n,this._rotationDisabled=!1,this._enabled=!0}),[{key:"enable",value:function(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("mapboxgl-touch-zoom-rotate")}},{key:"disable",value:function(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("mapboxgl-touch-zoom-rotate")}},{key:"isEnabled",value:function(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}},{key:"isActive",value:function(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}},{key:"disableRotation",value:function(){this._rotationDisabled=!0,this._touchRotate.disable()}},{key:"enableRotation",value:function(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}])})(),$s=function(e){return e.zoom||e.drag||e.pitch||e.rotate},Hs=(function(e){function t(){return p(this,t),T(this,t,arguments)}return g(t,e),m(t)})(e.x),Ws=(function(){return m((function e(){p(this,e),this.constants=[1,1,.01],this.radius=0}),[{key:"setup",value:function(t,r){var i=e.a6.vec3.sub([],r,t);this.radius=e.a6.vec3.length(i[2]<0?e.a6.vec3.div([],i,this.constants):[i[0],i[1],0])}},{key:"projectRay",value:function(t){e.a6.vec3.div(t,t,this.constants),e.a6.vec3.normalize(t,t),e.a6.vec3.mul(t,t,this.constants);var r=e.a6.vec3.scale([],t,this.radius);if(r[2]>0){var i=e.a6.vec3.scale([],[0,0,1],e.a6.vec3.dot(r,[0,0,1])),n=e.a6.vec3.scale([],e.a6.vec3.normalize([],[r[0],r[1],0]),this.radius),a=e.a6.vec3.add([],r,e.a6.vec3.scale([],e.a6.vec3.sub([],e.a6.vec3.add([],n,i),r),2));r[0]=a[0],r[1]=a[1]}return r}}])})();function Xs(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta}var Ys=(function(){return m((function t(r,i){p(this,t),this._map=r,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new ls(r),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new Ws,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(i),e.aJ(["handleEvent","handleWindowEvent"],this);var n=this._el;for(var a of(this._listeners=[[n,"touchstart",{passive:!0}],[n,"touchmove",{passive:!1}],[n,"touchend",void 0],[n,"touchcancel",void 0],[n,"mousedown",void 0],[n,"mousemove",void 0],[n,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[n,"mouseover",void 0],[n,"mouseout",void 0],[n,"dblclick",void 0],[n,"click",void 0],[n,"keydown",{capture:!1}],[n,"keyup",void 0],[n,"wheel",{passive:!1}],[n,"contextmenu",void 0],[window,"blur",void 0]],this._listeners)){var o=x(a,3),s=o[0],l=o[1],u=o[2],c=s===document?this.handleWindowEvent:this.handleEvent;s.addEventListener(l,c,u)}}),[{key:"destroy",value:function(){for(var e of this._listeners){var t=x(e,3),r=t[0],i=t[1],n=t[2],a=r===document?this.handleWindowEvent:this.handleEvent;r.removeEventListener(i,a,n)}}},{key:"_addDefaultHandlers",value:function(e){var t=this._map,r=t.getCanvasContainer();this._add("mapEvent",new ps(t,e));var i=t.boxZoom=new vs(t,e);this._add("boxZoom",i);var n=new xs,a=new Us;t.doubleClickZoom=new Vs(a,n),this._add("tapZoom",n),this._add("clickZoom",a);var o=new js;this._add("tapDragZoom",o);var s=t.touchPitch=new Rs(t);this._add("touchPitch",s);var l=new Ts(e),u=new Ss(e);t.dragRotate=new qs(e,l,u),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",u,["mouseRotate"]);var c=new ks(e),h=new Es(t,e);t.dragPan=new Gs(r,c,h),this._add("mousePan",c),this._add("touchPan",h,["touchZoom","touchRotate"]);var f=new zs,d=new Cs;t.touchZoomRotate=new Zs(r,d,f,o),this._add("touchRotate",f,["touchPan","touchZoom"]),this._add("touchZoom",d,["touchPan","touchRotate"]),this._add("blockableMapEvent",new ms(t));var p=t.scrollZoom=new Ns(t,this);this._add("scrollZoom",p,["mousePan"]);var m=t.keyboard=new Os;for(var v of(this._add("keyboard",m),["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"]))e.interactive&&e[v]&&t[v].enable(e[v])}},{key:"_add",value:function(e,t,r){this._handlers.push({handlerName:e,handler:t,allowed:r}),this._handlersById[e]=t}},{key:"stop",value:function(e){if(!this._updatingCamera){for(var t of this._handlers){t.handler.reset()}this._inertia.clear(),this._fireEvents({},{},e),this._changes=[],this._originalZoom=void 0}}},{key:"isActive",value:function(){for(var e of this._handlers){if(e.handler.isActive())return!0}return!1}},{key:"isZooming",value:function(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}},{key:"isRotating",value:function(){return!!this._eventsInProgress.rotate}},{key:"isMoving",value:function(){return!!$s(this._eventsInProgress)||this.isZooming()}},{key:"_isDragging",value:function(){return!!this._eventsInProgress.drag}},{key:"_blockedByActive",value:function(e,t,r){for(var i in e)if(i!==r&&(!t||t.indexOf(i)<0))return!0;return!1}},{key:"handleWindowEvent",value:function(e){this.handleEvent(e,`${e.type}Window`)}},{key:"_getMapTouches",value:function(e){var t=[];for(var r of e)this._el.contains(r.target)&&t.push(r);return t}},{key:"handleEvent",value:function(e,t){this._updatingCamera=!0;var r="renderFrame"===e.type,i=r?void 0:e,n={needsRenderFrame:!1},a={},o={},s=e.touches?this._getMapTouches(e.touches):void 0,l=s?P(this._el,s):r?void 0:C(this._el,e);for(var u of this._handlers){var c=u.handlerName,h=u.handler,f=u.allowed;if(h.isEnabled()){var d=void 0;this._blockedByActive(o,f,c)?h.reset():h[t||e.type]&&(d=h[t||e.type](e,l,s),this.mergeHandlerResult(n,a,d,c,i),d&&d.needsRenderFrame&&this._triggerRenderFrame()),(d||h.isActive())&&(o[c]=h)}}var p={};for(var m in this._previousActiveHandlers)o[m]||(p[m]=i);this._previousActiveHandlers=o,(Object.keys(p).length||Xs(n))&&(this._changes.push([n,a,p]),this._triggerRenderFrame()),(Object.keys(o).length||Xs(n))&&this._map._stop(!0),this._updatingCamera=!1;var v=n.cameraAnimation;v&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],v(this._map))}},{key:"mergeHandlerResult",value:function(t,r,i,n,a){if(i){e.l(t,i);var o={handlerName:n,originalEvent:i.originalEvent||a};void 0!==i.zoomDelta&&(r.zoom=o),void 0!==i.panDelta&&(r.drag=o),void 0!==i.pitchDelta&&(r.pitch=o),void 0!==i.bearingDelta&&(r.rotate=o)}}},{key:"_applyChanges",value:function(){var t={},r={},i={};for(var n of this._changes){var a=x(n,3),o=a[0],s=a[1],l=a[2];o.panDelta&&(t.panDelta=(t.panDelta||new e.P(0,0))._add(o.panDelta)),o.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+o.zoomDelta),o.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+o.bearingDelta),o.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+o.pitchDelta),void 0!==o.around&&(t.around=o.around),void 0!==o.aroundCoord&&(t.aroundCoord=o.aroundCoord),void 0!==o.pinchAround&&(t.pinchAround=o.pinchAround),o.noInertia&&(t.noInertia=o.noInertia),e.l(r,s),e.l(i,l)}this._updateMapTransform(t,r,i),this._changes=[]}},{key:"_updateMapTransform",value:function(t,r,i){var n=this,a=this._map,o=a.transform,s=function(e){return[e.x,e.y,e.z]};if((function(){var e=n._eventsInProgress.drag;return e&&!n._handlersById[e.handlerName].isActive()})()&&!Xs(t)){var l=o.zoom;o.cameraElevationReference="sea",null!=this._originalZoom&&o._orthographicProjectionAtLowPitch&&"globe"!==o.projection.name&&0===o.pitch?(o.cameraElevationReference="ground",o.zoom=this._originalZoom):(o.recenterOnTerrain(),o.cameraElevationReference="ground"),l!==o.zoom&&this._map._update(!0)}if(o._isCameraConstrained&&a._stop(!0),Xs(t)){var u=t.panDelta,c=t.zoomDelta,h=t.bearingDelta,f=t.pitchDelta,d=t.around,p=t.aroundCoord,m=t.pinchAround;o._isCameraConstrained&&(c>0&&(c=0),o._isCameraConstrained=!1),void 0!==m&&(d=m),(c||(function(e){return r[e]&&!n._eventsInProgress[e]})("drag"))&&d&&(this._dragOrigin=s(o.pointCoordinate3D(d)),this._originalZoom=o.zoom,this._trackingEllipsoid.setup(o._camera.position,this._dragOrigin)),o.cameraElevationReference="sea",a._stop(!0),d=d||a.transform.centerPoint,h&&(o.bearing+=h),f&&(o.pitch+=f),o._updateCameraState();var v=[0,0,0];if(u)if("mercator"===o.projection.name){var _=this._trackingEllipsoid.projectRay(o.screenPointToMercatorRay(d).dir),g=this._trackingEllipsoid.projectRay(o.screenPointToMercatorRay(d.sub(u)).dir);v[0]=g[0]-_[0],v[1]=g[1]-_[1]}else{var y=o.pointCoordinate(d);if("globe"===o.projection.name){u=u.rotate(-o.angle);var x=o._pixelsPerMercatorPixel/o.worldSize;v[0]=-u.x*e.ds(e.aN(y.y))*x,v[1]=-u.y*e.ds(o.center.lat)*x}else{var b=o.pointCoordinate(d.sub(u));y&&b&&(v[0]=b.x-y.x,v[1]=b.y-y.y)}}var w=o.zoom,k=[0,0,0];if(c){var T=s(p||o.pointCoordinate3D(d)),S={dir:e.a6.vec3.normalize([],e.a6.vec3.sub([],T,o._camera.position))};if(S.dir[2]<0){var E=o.zoomDeltaToMovement(T,c);e.a6.vec3.scale(k,S.dir,E)}}var M=e.a6.vec3.add(v,v,k);o._translateCameraConstrained(M),c&&Math.abs(o.zoom-w)>1e-4&&o.recenterOnTerrain(),o.cameraElevationReference="ground",this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(r,i,!0)}else this._fireEvents(r,i,!0)}},{key:"_fireEvents",value:function(t,r,i){var n=this,a=$s(this._eventsInProgress),o=$s(t),s={};for(var l in t){var u=t[l].originalEvent;this._eventsInProgress[l]||(s[`${l}start`]=u),this._eventsInProgress[l]=t[l]}for(var c in!a&&o&&this._fireEvent("movestart",o.originalEvent),s)this._fireEvent(c,s[c]);for(var h in o&&this._fireEvent("move",o.originalEvent),t){var f=t[h].originalEvent;this._fireEvent(h,f)}var d,p={};for(var m in this._eventsInProgress){var v=this._eventsInProgress[m],_=v.handlerName,g=v.originalEvent;this._handlersById[_].isActive()||(delete this._eventsInProgress[m],d=r[_]||g,p[`${m}end`]=d)}for(var y in p)this._fireEvent(y,p[y]);var x=$s(this._eventsInProgress);if(i&&(a||o)&&!x){this._updatingCamera=!0;var b=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),w=function(e){return 0!==e&&-n._bearingSnape.aspect?r/(2*Math.tan(.5*e.fovX)*e.aspect):i/(2*Math.tan(.5*e.fovY)*e.aspect)}},{key:"_cameraForBoundsOnGlobe",value:function(t,r,i,n,a,o){var s=t.clone(),l=this._extendCameraOptions(o);s.bearing=n,s.pitch=a;var u=e.bL.convert(r),c=e.bL.convert(i),h=.5*(u.lat+c.lat),f=.5*(u.lng+c.lng),d=e.dt(h,f),p=e.a6.vec3.normalize([],d),m=e.a6.vec3.normalize([],e.a6.vec3.cross([],p,[0,1,0])),v=e.a6.vec3.cross([],m,p),_=[m[0],m[1],m[2],0,v[0],v[1],v[2],0,p[0],p[1],p[2],0,0,0,0,1],g=[d,e.dt(u.lat,u.lng),e.dt(c.lat,u.lng),e.dt(c.lat,c.lng),e.dt(u.lat,c.lng),e.dt(h,u.lng),e.dt(h,c.lng),e.dt(u.lat,f),e.dt(c.lat,f)],y=e.ca.fromPoints(g.map((function(t){return[e.a6.vec3.dot(m,t),e.a6.vec3.dot(v,t),e.a6.vec3.dot(p,t)]}))),x=e.a6.vec3.transformMat4([],y.center,_);0===e.a6.vec3.squaredLength(x)&&e.a6.vec3.set(x,0,0,1),e.a6.vec3.normalize(x,x),e.a6.vec3.scale(x,x,e.aq),s.center=e.du(x);var b=s.getWorldToCameraMatrix(),w=e.a6.mat4.invert(new Float64Array(16),b);y=e.ca.applyTransform(y,e.a6.mat4.multiply([],b,_));var k=this._extendAABB(y,s,l,n);if(k){y=k,e.a6.vec3.transformMat4(x,x,b);var T=.5*(y.max[2]-y.min[2]),S=this._minimumAABBFrustumDistance(s,y),E=e.a6.vec3.scale([],[0,0,1],T),M=e.a6.vec3.add(E,x,E),A=S+(0===s.pitch?0:e.a6.vec3.distance(x,M)),I=s.globeCenterInViewSpace,C=e.a6.vec3.sub([],x,[I[0],I[1],I[2]]);e.a6.vec3.normalize(C,C),e.a6.vec3.scale(C,C,A);var P=e.a6.vec3.add([],x,C);e.a6.vec3.transformMat4(P,P,w);var z=e.dw/e.aq,D=e.a6.vec3.length(P),R=e.bE(Math.max(D*z-e.dw,Number.EPSILON),0),L=Math.min(s.zoomFromMercatorZAdjusted(R),l.maxZoom);return L>.5*(e.c3+e.bV)?(s.setProjection({name:"mercator"}),s.zoom=L,this._cameraForBounds(s,r,i,n,a,o)):{center:s.center,zoom:L,bearing:n,pitch:a}}e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}},{key:"_extendAABB",value:function(t,r,i,n){var a=.5*((i.padding.left||0)+(i.padding.right||0)),o=.5*((i.padding.top||0)+(i.padding.bottom||0)),s=o,l=a,u=a,c=o,h=r.width-(l+u),f=r.height-(s+c),d=e.a6.vec3.sub([],t.max,t.min),p=Math.min(h/d[0],f/d[1]),m=Math.min(r.scaleZoom(r.scale*p),i.maxZoom);if(isNaN(m))return null;var v=r.scale/r.zoomScale(m),_=new e.ca([t.min[0]-l*v,t.min[1]-c*v,t.min[2]],[t.max[0]+u*v,t.max[1]+s*v,t.max[2]]),g=("number"==typeof i.offset.x&&"number"==typeof i.offset.y?new e.P(i.offset.x,i.offset.y):e.P.convert(i.offset)).rotate(-e.bC(n));return _.center[0]-=g.x*v,_.center[1]+=g.y*v,_}},{key:"queryTerrainElevation",value:function(t,r){var i=this.transform.elevation;return i?(r=e.l({},{exaggerated:!0},r),i.getAtPoint(e.a5.fromLngLat(t),null,r.exaggerated)):null}},{key:"_cameraForBounds",value:function(t,r,i,n,a,o){if("globe"===t.projection.name)return this._cameraForBoundsOnGlobe(t,r,i,n,a,o);var s=t.clone(),l=this._extendCameraOptions(o);s.bearing=n,s.pitch=a;var u=e.bL.convert(r),c=e.bL.convert(i),h=new e.bL(u.lng,c.lat),f=new e.bL(c.lng,u.lat),d=s.project(u),p=s.project(c),m=this.queryTerrainElevation(u),v=this.queryTerrainElevation(c),_=this.queryTerrainElevation(h),g=this.queryTerrainElevation(f),y=[[d.x,d.y,Math.min(m||0,v||0,_||0,g||0)],[p.x,p.y,Math.max(m||0,v||0,_||0,g||0)]],x=e.ca.fromPoints(y),b=s.getWorldToCameraMatrix(),w=e.a6.mat4.invert(new Float64Array(16),b);x=e.ca.applyTransform(x,b);var k=this._extendAABB(x,s,l,n);if(k){x=k;var T=.5*e.a6.vec3.sub([],x.max,x.min)[2],S=this._minimumAABBFrustumDistance(s,x),E=[0,0,1,0];e.a6.vec4.transformMat4(E,E,b),e.a6.vec4.normalize(E,E);var M=e.a6.vec3.scale([],E,S+T),A=e.a6.vec3.add([],x.center,M);e.a6.vec3.transformMat4(x.center,x.center,w),e.a6.vec3.transformMat4(A,A,w);var I=s.unproject(new e.P(x.center[0],x.center[1])),C=e.dv(s.projection,I),P=Math.pow(2,C),z=Math.min(s._zoomFromMercatorZ(A[2]*s.pixelsPerMeter*P/s.worldSize),l.maxZoom);return s.mercatorFromTransition&&z<.5*(e.c3+e.bV)?(s.setProjection({name:"globe"}),s.zoom=z,this._cameraForBounds(s,r,i,n,a,o)):{center:I,zoom:z,bearing:n,pitch:a}}e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}},{key:"fitBounds",value:function(e,t,r){var i=this.cameraForBounds(e,t);return this._fitInternal(i,t,r)}},{key:"fitScreenCoordinates",value:function(t,r,i,n,a){var o=e.P.convert(t),s=e.P.convert(r),l=new e.P(Math.min(o.x,s.x),Math.min(o.y,s.y)),u=new e.P(Math.max(o.x,s.x),Math.max(o.y,s.y));if("mercator"===this.transform.projection.name&&this.transform.anyCornerOffEdge(o,s))return this;var c=this.transform.pointLocation3D(l),h=this.transform.pointLocation3D(u),f=this.transform.pointLocation3D(new e.P(l.x,u.y)),d=this.transform.pointLocation3D(new e.P(u.x,l.y)),p=[Math.min(c.lng,h.lng,f.lng,d.lng),Math.min(c.lat,h.lat,f.lat,d.lat)],m=[Math.max(c.lng,h.lng,f.lng,d.lng),Math.max(c.lat,h.lat,f.lat,d.lat)],v=n&&n.pitch?n.pitch:this.getPitch(),_=this._cameraForBounds(this.transform,p,m,i,v,n);return this._fitInternal(_,n,a)}},{key:"_fitInternal",value:function(t,r,i){return t?(r=e.l(t,r)).linear?this.easeTo(r,i):this.flyTo(r,i):this}},{key:"jumpTo",value:function(t,r){this.stop();var i=t.preloadOnly?this.transform.clone():this.transform,n=!1,a=!1,o=!1;"zoom"in t&&i.zoom!==+t.zoom&&(n=!0,i.zoom=+t.zoom),void 0!==t.center&&(i.center=e.bL.convert(t.center)),"bearing"in t&&i.bearing!==+t.bearing&&(a=!0,i.bearing=+t.bearing),"pitch"in t&&i.pitch!==+t.pitch&&(o=!0,i.pitch=+t.pitch);var s="number"==typeof t.padding?this._extendPadding(t.padding):t.padding;if(null!=t.padding&&!i.isPaddingEqual(s))if(!1===t.retainPadding){var l=i.clone();l.padding=s,i.setLocationAtPoint(i.center,l.centerPoint)}else i.padding=s;return t.preloadOnly?(this._preloadTiles(i),this):(this.fire(new e.x("movestart",r)).fire(new e.x("move",r)),n&&this.fire(new e.x("zoomstart",r)).fire(new e.x("zoom",r)).fire(new e.x("zoomend",r)),a&&this.fire(new e.x("rotatestart",r)).fire(new e.x("rotate",r)).fire(new e.x("rotateend",r)),o&&this.fire(new e.x("pitchstart",r)).fire(new e.x("pitch",r)).fire(new e.x("pitchend",r)),this.fire(new e.x("moveend",r)))}},{key:"getFreeCameraOptions",value:function(){return this.transform.projection.supportsFreeCamera||e.w(Js),this.transform.getFreeCameraOptions()}},{key:"setFreeCameraOptions",value:function(t,r){var i=this.transform;if(!i.projection.supportsFreeCamera)return e.w(Js),this;this.stop();var n=i.zoom,a=i.pitch,o=i.bearing;i.setFreeCameraOptions(t);var s=n!==i.zoom,l=a!==i.pitch,u=o!==i.bearing;return this.fire(new e.x("movestart",r)).fire(new e.x("move",r)),s&&this.fire(new e.x("zoomstart",r)).fire(new e.x("zoom",r)).fire(new e.x("zoomend",r)),u&&this.fire(new e.x("rotatestart",r)).fire(new e.x("rotate",r)).fire(new e.x("rotateend",r)),l&&this.fire(new e.x("pitchstart",r)).fire(new e.x("pitch",r)).fire(new e.x("pitchend",r)),this.fire(new e.x("moveend",r)),this}},{key:"easeTo",value:function(t,r){var i=this;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);var n,a,o,s=this.transform,l=this.getZoom(),u=this.getBearing(),c=this.getPitch(),h=this.getPadding(),f="zoom"in t?+t.zoom:l,d="bearing"in t?this._normalizeBearing(t.bearing,u):u,p="pitch"in t?+t.pitch:c,m=this._extendPadding(t.padding),v=e.P.convert(t.offset);if("globe"===s.projection.name){var _=e.a5.fromLngLat(s.center),g=v.rotate(-s.angle);_.x+=g.x/s.worldSize,_.y+=g.y/s.worldSize;var y=_.toLngLat(),x=e.bL.convert(t.center||y);this._normalizeCenter(x),n=s.centerPoint.add(g),a=new e.P(_.x,_.y).mult(s.worldSize),o=new e.P(e.am(x.lng),e.at(x.lat)).mult(s.worldSize).sub(a)}else{n=s.centerPoint.add(v);var b=s.pointLocation(n),w=e.bL.convert(t.center||b);this._normalizeCenter(w),a=s.project(b),o=s.project(w).sub(a)}var k,T,S=s.zoomScale(f-l);t.around&&(k=e.bL.convert(t.around),T=s.locationPoint(k));var E=this._zooming||f!==l,M=this._rotating||u!==d,A=this._pitching||p!==c,I=!s.isPaddingEqual(m),C=!1===t.retainPadding?s.clone():s,P=function(s){return function(_){if(E&&(s.zoom=e.aa(l,f,_)),M&&(s.bearing=e.aa(u,d,_)),A&&(s.pitch=e.aa(c,p,_)),I&&(C.interpolatePadding(h,m,_),n=C.centerPoint.add(v)),k)s.setLocationAtPoint(k,T);else{var g=s.zoomScale(s.zoom-l),y=f>l?Math.min(2,S):Math.max(.5,S),x=Math.pow(y,1-_),b=s.unproject(a.add(o.mult(_*x)).mult(g));s.setLocationAtPoint(s.renderWorldCopies?b.wrap():b,n)}return t.preloadOnly||i._fireMoveEvents(r),s}};if(t.preloadOnly){var z=this._emulate(P,t.duration,s);return this._preloadTiles(z),this}var D={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=E,this._rotating=M,this._pitching=A,this._padding=I,this._easeId=t.easeId,this._prepareEase(r,t.noMoveStart,D),this._ease(P(s),(function(e){"sea"===s.cameraElevationReference&&s.recenterOnTerrain(),i._afterEase(r,e)}),t),this}},{key:"_prepareEase",value:function(t,r){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&0===this.transform.pitch&&"globe"!==this.transform.projection.name&&(this.transform.cameraElevationReference="ground"),r||i.moving||this.fire(new e.x("movestart",t)),this._zooming&&!i.zooming&&this.fire(new e.x("zoomstart",t)),this._rotating&&!i.rotating&&this.fire(new e.x("rotatestart",t)),this._pitching&&!i.pitching&&this.fire(new e.x("pitchstart",t))}},{key:"_fireMoveEvents",value:function(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))}},{key:"_afterEase",value:function(t,r){if(!this._easeId||!r||this._easeId!==r){this._easeId=void 0,this.transform.cameraElevationReference="ground";var i=this._zooming,n=this._rotating,a=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,i&&this.fire(new e.x("zoomend",t)),n&&this.fire(new e.x("rotateend",t)),a&&this.fire(new e.x("pitchend",t)),this.fire(new e.x("moveend",t))}}},{key:"flyTo",value:function(t,r){var i=this;if(this._prefersReducedMotion(t)){var n=e.ar(t,["center","zoom","bearing","pitch","around","padding","retainPadding"]);return this.jumpTo(n,r)}this.stop(),t=e.l({offset:[0,0],speed:1.2,curve:1.42,easing:e.dr},t);var a=this.transform,o=this.getZoom(),s=this.getBearing(),l=this.getPitch(),u=this.getPadding(),c="zoom"in t?e.ap(+t.zoom,a.minZoom,a.maxZoom):o,h="bearing"in t?this._normalizeBearing(t.bearing,s):s,f="pitch"in t?+t.pitch:l,d=this._extendPadding(t.padding),p=a.zoomScale(c-o),m=e.P.convert(t.offset),v=a.centerPoint.add(m),_=a.pointLocation(v),g=e.bL.convert(t.center||_);this._normalizeCenter(g);var y=a.project(_),x=a.project(g).sub(y),b=t.curve,w=Math.max(a.width,a.height),k=w/p,T=x.mag();if("minZoom"in t){var S=e.ap(Math.min(t.minZoom,o,c),a.minZoom,a.maxZoom),E=w/a.zoomScale(S-o);b=Math.sqrt(E/T*2)}var M=b*b;function A(e){var t=(k*k-w*w+(e?-1:1)*M*M*T*T)/(2*(e?k:w)*M*T);return Math.log(Math.sqrt(t*t+1)-t)}function I(e){return(Math.exp(e)-Math.exp(-e))/2}function C(e){return(Math.exp(e)+Math.exp(-e))/2}var P=A(0),z=function(e){return C(P)/C(P+b*e)},D=function(e){return w*((C(P)*(I(t=P+b*e)/C(t))-I(P))/M)/T;var t},R=(A(1)-P)/b;if(Math.abs(T)<1e-6||!isFinite(R)){if(Math.abs(w-k)<1e-6)return this.easeTo(t,r);var L=kt.maxDuration&&(t.duration=0);var O=s!==h,F=f!==l,B=!a.isPaddingEqual(d),N=!1===t.retainPadding?a.clone():a,V=function(n){return function(a){var p=a*R,_=1/z(p);n.zoom=1===a?c:o+n.scaleZoom(_),O&&(n.bearing=e.aa(s,h,a)),F&&(n.pitch=e.aa(l,f,a)),B&&(N.interpolatePadding(u,d,a),v=N.centerPoint.add(m));var b=1===a?g:n.unproject(y.add(x.mult(D(p))).mult(_));return n.setLocationAtPoint(n.renderWorldCopies?b.wrap():b,v),n._updateCameraOnTerrain(),t.preloadOnly||i._fireMoveEvents(r),n}};if(t.preloadOnly){var U=this._emulate(V,t.duration,a);return this._preloadTiles(U),this}return this._zooming=!0,this._rotating=O,this._pitching=F,this._padding=B,this._prepareEase(r,!1),this._ease(V(a),(function(){return i._afterEase(r)}),t),this}},{key:"isEasing",value:function(){return!!this._easeFrameId}},{key:"stop",value:function(){return this._stop()}},{key:"_requestRenderFrame",value:function(e){}},{key:"_cancelRenderFrame",value:function(e){}},{key:"_stop",value:function(e,t){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){var r=this._onEaseEnd;this._onEaseEnd=void 0,r.call(this,t)}if(!e){var i=this.handlers;i&&i.stop(!1)}return this}},{key:"_ease",value:function(t,r,i){!1===i.animate||0===i.duration?(t(1),r()):(this._easeStart=e.q.now(),this._easeOptions=i,this._onEaseFrame=t,this._onEaseEnd=r,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}},{key:"_renderFrameCallback",value:function(){var t=Math.min((e.q.now()-this._easeStart)/this._easeOptions.duration,1),r=this._onEaseFrame;r&&r(this._easeOptions.easing(t)),t<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}},{key:"_normalizeBearing",value:function(t,r){t=e.bB(t,-180,180);var i=Math.abs(t-r);return Math.abs(t-360-r)180?-360:r<-180?360:0}}},{key:"_prefersReducedMotion",value:function(t){return this._respectPrefersReducedMotion&&e.q.prefersReducedMotion&&!(t&&t.essential)}},{key:"_emulate",value:function(e,t,r){for(var i=Math.ceil(15*t/1e3),n=[],a=e(r.clone()),o=0;o<=i;o++){var s=a(o/i);n.push(s.clone())}return n}},{key:"_preloadTiles",value:function(e,t){}}])})(e.E),Qs=(function(){return m((function t(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};p(this,t),this.options=r,e.aJ(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}),[{key:"getDefaultPosition",value:function(){return"bottom-right"}},{key:"onAdd",value:function(e){var t=this.options&&this.options.compact,r=e._getUIString("AttributionControl.ToggleAttribution");this._map=e,this._container=f("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=f("button","mapboxgl-ctrl-attrib-button",this._container),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._compactButton.setAttribute("aria-label",r);var i=f("span","mapboxgl-ctrl-icon",this._compactButton);return i.setAttribute("aria-hidden","true"),i.setAttribute("title",r),this._innerContainer=f("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}},{key:"onRemove",value:function(){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}},{key:"_toggleAttribution",value:function(){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"))}},{key:"_updateEditLink",value:function(){var t=this._editLink;t||(t=this._editLink=this._container.querySelector(".mapbox-improve-map"));var r=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||e.e.ACCESS_TOKEN}];if(t){var i=r.reduce((function(e,t,i){return t.value&&(e+=`${t.key}=${t.value}${i=0)return!1;return!0})),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=[].concat(d(this.options.customAttribution),d(e)):e.unshift(this.options.customAttribution));var o=e.join(" | ");o!==this._attribHTML&&(this._attribHTML=o,e.length?(this._innerContainer.innerHTML=o,this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null)}}},{key:"_updateCompact",value:function(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact","mapboxgl-compact-show")}}])})(),el=(function(){return m((function t(){p(this,t),e.aJ(["_updateLogo","_updateCompact"],this)}),[{key:"onAdd",value:function(e){this._map=e,this._container=f("div","mapboxgl-ctrl");var t=f("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}},{key:"onRemove",value:function(){this._container.remove(),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact)}},{key:"getDefaultPosition",value:function(){return"bottom-left"}},{key:"_updateLogo",value:function(e){e&&"metadata"!==e.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none")}},{key:"_logoRequired",value:function(){if(!this._map.style)return!0;var e=this._map.style._sourceCaches;if(0===Object.entries(e).length)return!0;for(var t in e){var r=e[t].getSource();if(r.hasOwnProperty("mapbox_logo")&&!r.mapbox_logo)return!1}return!0}},{key:"_updateCompact",value:function(){var e=this._container.children;if(e.length){var t=e[0];this._map.getCanvasContainer().offsetWidth<250?t.classList.add("mapboxgl-compact"):t.classList.remove("mapboxgl-compact")}}}])})(),tl=(function(){return m((function e(){p(this,e),this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}),[{key:"add",value:function(e){var t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}},{key:"remove",value:function(e){var t=this._currentlyRunning,r=t?this._queue.concat(t):this._queue;for(var i of r)if(i.id===e)return void(i.cancelled=!0)}},{key:"run",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=this._currentlyRunning=this._queue;for(var r of(this._queue=[],t))if(!r.cancelled&&(r.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}},{key:"clear",value:function(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}])})(),rl=(function(){return m((function e(t){p(this,e),this.jumpTo(t)}),[{key:"getValue",value:function(t){if(t<=this._startTime)return this._start;if(t>=this._endTime)return this._end;var r=e.cw((t-this._startTime)/(this._endTime-this._startTime));return this._start*(1-r)+this._end*r}},{key:"isEasing",value:function(e){return e>=this._startTime&&e<=this._endTime}},{key:"jumpTo",value:function(e){this._startTime=-1/0,this._endTime=-1/0,this._start=e,this._end=e}},{key:"easeTo",value:function(e,t,r){this._start=this.getValue(t),this._end=e,this._startTime=t,this._endTime=t+r}}])})(),il={"AttributionControl.ToggleAttribution":"Toggle attribution","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox homepage","Map.Title":"Map","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use \u2318 + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"},nl=["mouseenter","mouseover","mouseleave","mouseout"],al=(function(e){function t(e,r,i,n){var a;p(this,t);var o=e.point,s=e.lngLat,l=e.originalEvent,u=e.target;return(a=T(this,t,[e.type,{point:o,lngLat:s,originalEvent:l,target:u}])).preventDefault=function(){e.preventDefault()},a.id=r,a.interaction=i,a.feature=n,a}return g(t,e),m(t)})(e.x),ol=(function(){return m((function e(t){p(this,e),this.map=t,this.interactionsByType=new Map,this.typeById=new Map,this.filters=new Map,this.handleType=this.handleType.bind(this)}),[{key:"add",value:function(t,r){if(this.typeById.has(t))throw new Error(`Interaction id "${t}" already exists.`);var i=r.type,n=r.filter;if(n){var a=e.M(n,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===a.result)throw new Error(a.value.map((function(e){return`${e.key}: ${e.message}`})).join(", "));this.filters.set(t,a.value)}var o=this.interactionsByType.get(i)||new Map;0===o.size&&(nl.includes(i)?this.map.on(i,r.featureset,this.handleType):this.map.on(i,this.handleType),this.interactionsByType.set(i,o)),o.set(t,r),this.typeById.set(t,i)}},{key:"remove",value:function(e){var t=this.typeById.get(e);if(t){this.typeById.delete(e),this.filters.delete(e);var r=this.interactionsByType.get(t);r&&(r.delete(e),0===r.size&&this.map.off(t,this.handleType))}}},{key:"handleType",value:function(t){var r=this.interactionsByType.get(t.type),i=Array.from(r).reverse(),n=[];for(var a of i){var o=x(a,2)[1];o.featureset&&n.push({featureset:o.featureset,filter:o.filter,radius:o.radius})}var s=this.map.style.queryRenderedFeaturesForInteractions(t.point,n,this.map.transform);!s.length&&nl.includes(t.type)&&(s=[null]);var l=!1;for(var u of s){for(var c of i){var h=x(c,2),f=h[0],d=h[1],p=d.handler,m=d.featureset;if(m&&(null==u||e.bi(u.featureset,m))&&!1!==p(new al(t,f,d,u))){l=!0;break}}if(l)break}if(!l)for(var v of i){var _=x(v,2),g=_[0],y=_[1],b=y.handler;if(!y.featureset&&!1!==b(new al(t,g,y,null)))break}}}])})();function sl(t,r){if(Array.isArray(t)&&Array.isArray(r)){var i=new Set(t),n=new Set(r);return i.size===n.size&&t.every((function(e){return n.has(e)}))}return e.bi(t,r)}var ll={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},ul={showCompass:!0,showZoom:!0,visualizePitch:!1},cl=(function(){return m((function t(r,i){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];p(this,t),this._clickTolerance=10,this.element=i,this.mouseRotate=new Ts({clickTolerance:r.dragRotate._mouseRotate._clickTolerance}),this.map=r,n&&(this.mousePitch=new Ss({clickTolerance:r.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)}),[{key:"down",value:function(e,t){this.mouseRotate.mousedown(e,t),this.mousePitch&&this.mousePitch.mousedown(e,t),E()}},{key:"move",value:function(e,t){var r=this.map,i=this.mouseRotate.mousemoveWindow(e,t),n=i&&i.bearingDelta;if(n&&r.setBearing(r.getBearing()+n),this.mousePitch){var a=this.mousePitch.mousemoveWindow(e,t),o=a&&a.pitchDelta;o&&r.setPitch(r.getPitch()+o)}}},{key:"off",value:function(){var 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()}},{key:"offTemp",value:function(){M(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup)}},{key:"mousedown",value:function(t){this.down(e.l({},t,{ctrlKey:!0,preventDefault:function(){return t.preventDefault()}}),C(this.element,t)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)}},{key:"mousemove",value:function(e){this.move(e,C(this.element,e))}},{key:"mouseup",value:function(e){this.mouseRotate.mouseupWindow(e),this.mousePitch&&this.mousePitch.mouseupWindow(e),this.offTemp()}},{key:"touchstart",value:function(e){1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=P(this.element,e.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:function(){return e.preventDefault()}},this._startPos))}},{key:"touchmove",value:function(e){1!==e.targetTouches.length?this.reset():(this._lastPos=P(this.element,e.targetTouches)[0],this.move({preventDefault:function(){return e.preventDefault()}},this._lastPos))}},{key:"touchend",value:function(e){0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)i.width||r.y>i.height;i.locationPoint(n).distSqr(r)180;){var u=i.locationPoint(t);if(u.x>=0&&u.y>=0&&u.x<=i.width&&u.y<=i.height)break;t.lng>i.center.lng?t.lng-=360:t.lng+=360}return t}var fl={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%)"},dl=(function(t){function r(t,i){var n;if(p(this,r),n=T(this,r),(t instanceof HTMLElement||i)&&(t=e.l({element:t},i)),e.aJ(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],l(n)),n._anchor=t&&t.anchor||"center",n._color=t&&t.color||"#3FB1CE",n._scale=t&&t.scale||1,n._draggable=t&&t.draggable||!1,n._clickTolerance=t&&t.clickTolerance||0,n._isDragging=!1,n._state="inactive",n._rotation=t&&t.rotation||0,n._rotationAlignment=t&&t.rotationAlignment||"auto",n._pitchAlignment=t&&t.pitchAlignment&&t.pitchAlignment||"auto",n._updateMoving=function(){return n._update(!0)},n._occludedOpacity=t&&t.occludedOpacity||.2,t&&t.element)n._element=t.element,n._offset=e.P.convert(t&&t.offset||[0,0]);else{n._defaultMarker=!0,n._element=f("div");var a=v("svg",{display:"block",height:41*n._scale+"px",width:27*n._scale+"px",viewBox:"0 0 27 41"},n._element),o=v("radialGradient",{id:"shadowGradient"},v("defs",{},a));v("stop",{offset:"10%","stop-opacity":.4},o),v("stop",{offset:"100%","stop-opacity":.05},o),v("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},a),v("path",{fill:n._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"},a),v("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"},a),v("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},a),n._offset=e.P.convert(t&&t.offset||[0,-14])}n._element.hasAttribute("aria-label")||n._element.setAttribute("aria-label","Map marker"),n._element.hasAttribute("role")||n._element.setAttribute("role","img"),n._element.classList.add("mapboxgl-marker"),n._element.addEventListener("dragstart",(function(e){e.preventDefault()})),n._element.addEventListener("mousedown",(function(e){e.preventDefault()}));var s=n._element.classList;for(var u in fl)s.remove(`mapboxgl-marker-anchor-${u}`);s.add(`mapboxgl-marker-anchor-${n._anchor}`);var c=t&&t.className?t.className.trim().split(/\s+/):[];return s.add.apply(s,d(c)),n._popup=null,n}return g(r,t),m(r,[{key:"addTo",value:function(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}},{key:"remove",value:function(){var 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}},{key:"getLngLat",value:function(){return this._lngLat}},{key:"setLngLat",value:function(t){return this._lngLat=e.bL.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}},{key:"getElement",value:function(){return this._element}},{key:"setPopup",value:function(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)){var t=Math.sqrt(Math.pow(13.5,2)/2);e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[t,-34.14594154601839],"bottom-right":[-9.545941546018392,-34.14594154601839],left:[13.5,-24.6],right:[-13.5,-24.6]}: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}},{key:"_onKeyPress",value:function(e){var t=e.code,r=e.charCode||e.keyCode;"Space"!==t&&"Enter"!==t&&32!==r&&13!==r||this.togglePopup()}},{key:"_onMapClick",value:function(e){var t=e.originalEvent.target,r=this._element;this._popup&&(t===r||r.contains(t))&&this.togglePopup()}},{key:"getPopup",value:function(){return this._popup}},{key:"togglePopup",value:function(){var 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}},{key:"_behindTerrain",value:function(){var e=this._map,t=this._pos;if(!e||!t)return!1;var r=e.unproject(t),i=e.getFreeCameraOptions();if(!i.position)return!1;var n=i.position.toLngLat();return n.distanceTo(r)<.9*n.distanceTo(this._lngLat)}},{key:"_evaluateOpacity",value:function(){var t=this._map;if(t){var r=this._pos;if(!r||r.x<0||r.x>t.transform.width||r.y<0||r.y>t.transform.height)this._clearFadeTimer();else{var i,n=t.unproject(r);t._showingGlobe()&&e.dz(t.transform,this._lngLat)?i=0:(i=1-t._queryFogOpacity(n),t.transform._terrainEnabled()&&t.getTerrain()&&this._behindTerrain()&&(i*=this._occludedOpacity)),this._element.style.opacity=`${i}`,this._element.style.pointerEvents=i>0?"auto":"none",this._popup&&this._popup._setOpacity(i),this._fadeTimer=null}}}},{key:"_clearFadeTimer",value:function(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}},{key:"_updateDOM",value:function(){var e=this._pos;if(e&&this._map){var t=this._offset.mult(this._scale);this._element.style.transform=`\n translate(${e.x}px,${e.y}px)\n ${fl[this._anchor]}\n ${this._calculateXYTransform()} ${this._calculateZTransform()}\n translate(${t.x}px,${t.y}px)\n `}}},{key:"_calculateXYTransform",value:function(){var t=this._pos,r=this._map,i=this.getPitchAlignment();if(!r||!t||"map"!==i)return"";if(!r._showingGlobe()){var n=r.getPitch();return n?`rotateX(${n}deg)`:""}var a=e.c1(e.dA(r.transform,this._lngLat)),o=t.sub(e.dB(r.transform)),s=Math.abs(o.x)+Math.abs(o.y);if(0===s)return"";var l=a/s;return`rotateX(${-o.y*l}deg) rotateY(${o.x*l}deg)`}},{key:"_calculateZTransform",value:function(){var t=this._pos,r=this._map;if(!r||!t)return"";var i=0,n=this.getRotationAlignment();if("map"===n)if(r._showingGlobe()){var a=r.project(new e.bL(this._lngLat.lng,this._lngLat.lat+.001)),o=r.project(new e.bL(this._lngLat.lng,this._lngLat.lat-.001)).sub(a);i=e.c1(Math.atan2(o.y,o.x))-90}else i=-r.getBearing();else if("horizon"===n){var s=e.a7(4,6,r.getZoom()),l=e.dB(r.transform);l.y+=s*r.transform.height;var u=t.sub(l),c=e.c1(Math.atan2(u.y,u.x));i=(c>90?c-270:c+90)*(1-s)}return(i+=this._rotation)?`rotateZ(${i}deg)`:""}},{key:"_update",value:function(e){var t=this;cancelAnimationFrame(this._updateFrameId);var r=this._map;r&&(r.transform.renderWorldCopies&&(this._lngLat=hl(this._lngLat,this._pos,r.transform)),this._pos=r.project(this._lngLat),!0===e?this._updateFrameId=requestAnimationFrame((function(){t._element&&t._pos&&t._anchor&&(t._pos=t._pos.round(),t._updateDOM())})):this._pos=this._pos.round(),r._requestDomTask((function(){t._map&&(t._element&&t._pos&&t._anchor&&t._updateDOM(),(r._showingGlobe()||r.getTerrain()||r.getFog())&&!t._fadeTimer&&(t._fadeTimer=window.setTimeout(t._evaluateOpacity.bind(t),60)))})))}},{key:"getOffset",value:function(){return this._offset}},{key:"setOffset",value:function(t){return this._offset=e.P.convert(t),this._update(),this}},{key:"addClassName",value:function(e){return this._element.classList.add(e),this}},{key:"removeClassName",value:function(e){return this._element.classList.remove(e),this}},{key:"toggleClassName",value:function(e){return this._element.classList.toggle(e)}},{key:"_onMove",value:function(t){var r=this._map;if(r){var i=this._pointerdownPos,n=this._positionDelta;if(i&&n){if(!this._isDragging){var a=this._clickTolerance||r._clickTolerance;if(t.point.dist(i)0&&void 0!==arguments[0]?arguments[0]:new e.P(0,0),r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"bottom";if("number"==typeof t){var i=Math.round(Math.sqrt(.5*Math.pow(t,2)));switch(r){case"top":return new e.P(0,t);case"top-left":return new e.P(i,i);case"top-right":return new e.P(-i,i);case"bottom":return new e.P(0,-t);case"bottom-left":return new e.P(i,-i);case"bottom-right":return new e.P(-i,-i);case"left":return new e.P(t,0);case"right":return new e.P(-t,0)}return new e.P(0,0)}return t instanceof e.P||Array.isArray(t)?e.P.convert(t):e.P.convert(t[r]||[0,0])}var xl={version:t,supported:h.supported,setRTLTextPlugin:e.dC,getRTLTextPluginStatus:e.dD,Map:(function(n){function a(t){var n;p(this,a),i(r.create);var o=t;if(null!=(t=e.l({},ll,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")),(n=T(this,a,[new bi(t.minZoom,t.maxZoom,t.minPitch,t.maxPitch,t.renderWorldCopies),t]))._repaint=!!t.repaint,n._interactive=t.interactive,n._minTileCacheSize=t.minTileCacheSize,n._maxTileCacheSize=t.maxTileCacheSize,n._failIfMajorPerformanceCaveat=t.failIfMajorPerformanceCaveat,n._preserveDrawingBuffer=t.preserveDrawingBuffer,n._antialias=t.antialias,n._trackResize=t.trackResize,n._bearingSnap=t.bearingSnap,n._refreshExpiredTiles=t.refreshExpiredTiles,n._fadeDuration=t.fadeDuration,n._isInitialLoad=!0,n._crossSourceCollisions=t.crossSourceCollisions,n._collectResourceTiming=t.collectResourceTiming,n._language=n._parseLanguage(t.language),n._worldview=t.worldview,n._renderTaskQueue=new tl,n._domRenderTaskQueue=new tl,n._controls=[],n._markers=[],n._popups=[],n._mapId=e.aQ(),n._locale=e.l({},il,t.locale),n._clickTolerance=t.clickTolerance,n._cooperativeGestures=t.cooperativeGestures,n._performanceMetricsCollection=t.performanceMetricsCollection,n._tessellationStep=t.tessellationStep,n._containerWidth=0,n._containerHeight=0,n._showParseStatus=!0,n._precompilePrograms=t.precompilePrograms,n._scaleFactorChanged=!1,n._averageElevationLastSampledAt=-1/0,n._averageElevationExaggeration=0,n._averageElevation=new rl(0),n._interactionRange=[1/0,-1/0],n._visibilityHidden=0,n._useExplicitProjection=!1,n._frameId=0,n._scaleFactor=t.scaleFactor,n._requestManager=new O(t.transformRequest,t.accessToken,t.testMode),n._silenceAuthErrors=!!t.testMode,n._contextCreateOptions=t.contextCreateOptions?Object.assign({},t.contextCreateOptions):{},"string"==typeof t.container){var s=document.getElementById(t.container);if(!s)throw new Error(`Container '${t.container.toString()}' not found.`);n._container=s}else{if(!(t.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");n._container=t.container}if(n._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&&n.setMaxBounds(t.maxBounds),e.aJ(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],n),n._setupContainer(),n._tp||(n._tp=new Yo),n._tp.registerParameter(n,["Debug"],"showOverdrawInspector"),n._tp.registerParameter(n,["Debug"],"showTileBoundaries"),n._tp.registerParameter(n,["Debug"],"showParseStatus"),n._tp.registerParameter(n,["Debug"],"repaint"),n._tp.registerParameter(n,["Debug"],"showTileAABBs"),n._tp.registerParameter(n,["Debug"],"showPadding"),n._tp.registerParameter(n,["Debug"],"showCollisionBoxes",{noSave:!0}),n._tp.registerParameter(n.transform,["Debug"],"freezeTileCoverage",{noSave:!0},(function(){n._update()})),n._tp.registerParameter(n,["Debug","Wireframe"],"showTerrainWireframe"),n._tp.registerParameter(n,["Debug","Wireframe"],"showLayers2DWireframe"),n._tp.registerParameter(n,["Debug","Wireframe"],"showLayers3DWireframe"),n._tp.registerParameter(n,["Scaling"],"_scaleFactor",{min:.1,max:10,step:.1},(function(){n.setScaleFactor(n._scaleFactor)})),n._setupPainter(),void 0===n.painter)throw new Error("Failed to initialize WebGL.");if(n.on("move",(function(){return n._update(!1)})),n.on("moveend",(function(){return n._update(!1)})),n.on("zoom",(function(){return n._update(!0)})),n._fullscreenchangeEvent="onfullscreenchange"in document?"fullscreenchange":"webkitfullscreenchange",window.addEventListener("online",n._onWindowOnline,!1),window.addEventListener("resize",n._onWindowResize,!1),window.addEventListener("orientationchange",n._onWindowResize,!1),window.addEventListener(n._fullscreenchangeEvent,n._onWindowResize,!1),window.addEventListener("visibilitychange",n._onVisibilityChange,!1),n.handlers=new Ys(n,t),n._localFontFamily=t.localFontFamily,n._localIdeographFontFamily=t.localIdeographFontFamily,(t.style||!t.testMode)&&n.setStyle(t.style||e.e.DEFAULT_STYLE,{config:t.config,localFontFamily:n._localFontFamily,localIdeographFontFamily:n._localIdeographFontFamily}),t.projection&&n.setProjection(t.projection),t.hash&&(n._hash=new ts("string"==typeof t.hash&&t.hash||void 0).addTo(n)),!n._hash||!n._hash._onHashChange()){null==o.center&&null==o.zoom||(n.transform._unmodified=!1),n.jumpTo({center:t.center,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch});var l=t.bounds;l&&(n.resize(),n.fitBounds(l,e.l({},t.fitBoundsOptions,{duration:0})))}return n.resize(),t.attributionControl&&n.addControl(new Qs({customAttribution:t.customAttribution})),n._logoControl=new el,n.addControl(n._logoControl,t.logoPosition),n.on("style.load",(function(){n.transform.unmodified&&n.jumpTo(n.style.stylesheet),n._postStyleLoadEvent()})),n.on("data",(function(t){n._update("style"===t.dataType),n.fire(new e.x(`${t.dataType}data`,t))})),n.on("dataloading",(function(t){n.fire(new e.x(`${t.dataType}dataloading`,t))})),n._interactions=new ol(n),n}return g(a,n),m(a,[{key:"_getMapId",value:function(){return this._mapId}},{key:"addControl",value:function(t,r){if(void 0===r&&(r=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.")));var i=t.onAdd(this);this._controls.push(t);var n=this._controlPositions[r];return-1!==r.indexOf("bottom")?n.insertBefore(i,n.firstChild):n.appendChild(i),this}},{key:"removeControl",value:function(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.")));var r=this._controls.indexOf(t);return r>-1&&this._controls.splice(r,1),t.onRemove(this),this}},{key:"hasControl",value:function(e){return this._controls.indexOf(e)>-1}},{key:"getContainer",value:function(){return this._container}},{key:"getCanvasContainer",value:function(){return this._canvasContainer}},{key:"getCanvas",value:function(){return this._canvas}},{key:"resize",value:function(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));var r=!this._moving;return r&&this.fire(new e.x("movestart",t)).fire(new e.x("move",t)),this.fire(new e.x("resize",t)),r&&this.fire(new e.x("moveend",t)),this}},{key:"getBounds",value:function(){return this.transform.getBounds()}},{key:"getMaxBounds",value:function(){return this.transform.getMaxBounds()||null}},{key:"setMaxBounds",value:function(t){return this.transform.setMaxBounds(e.as.convert(t)),this._update()}},{key:"setMinZoom",value:function(t){var r;if((t=null!=(r=t)?r:-2)>=-2&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t?this.setZoom(t):this.fire(new e.x("zoomstart")).fire(new e.x("zoom")).fire(new e.x("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}},{key:"getMaxZoom",value:function(){return this.transform.maxZoom}},{key:"setMinPitch",value:function(t){var r;if((t=null!=(r=t)?r:0)<0)throw new Error("minPitch must be greater than or equal to 0");if(t>=0&&t<=this.transform.maxPitch)return this.transform.minPitch=t,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(t>=this.transform.minPitch)return this.transform.maxPitch=t,this._update(),this.getPitch()>t?this.setPitch(t):this.fire(new e.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")}},{key:"getMaxPitch",value:function(){return this.transform.maxPitch}},{key:"getScaleFactor",value:function(){return this._scaleFactor}},{key:"setScaleFactor",value:function(e){return this._scaleFactor=e,this.painter.scaleFactor=e,this._tp.refreshUI(),this._scaleFactorChanged=!0,this.style._updateFilteredLayers((function(e){return"symbol"===e.type})),this._update(!0),this}},{key:"getRenderWorldCopies",value:function(){return this.transform.renderWorldCopies}},{key:"setRenderWorldCopies",value:function(e){return this.transform.renderWorldCopies=e,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}},{key:"getLanguage",value:function(){return this._language}},{key:"_parseLanguage",value:function(e){return"auto"===e?navigator.language:Array.isArray(e)?0===e.length?void 0:e.map((function(e){return"auto"===e?navigator.language:e})):e}},{key:"setLanguage",value:function(e){var t=this._parseLanguage(e);if(!this.style||t===this._language)return this;for(var r of(this._language=t,this.style.reloadSources(),this._controls))r._setLanguage&&r._setLanguage(this._language);return this}},{key:"getWorldview",value:function(){return this._worldview}},{key:"setWorldview",value:function(e){return this.style&&e!==this._worldview?(this._worldview=e,this.style.reloadSources(),this):this}},{key:"getProjection",value:function(){return this.transform.mercatorFromTransition?{name:"globe",center:[0,0]}:this.transform.getProjection()}},{key:"_showingGlobe",value:function(){return"globe"===this.transform.projection.name}},{key:"setProjection",value:function(e){return this._lazyInitEmptyStyle(),e?"string"==typeof e&&(e={name:e}):e=null,this._useExplicitProjection=!!e,this._prioritizeAndUpdateProjection(e,this.style.projection)}},{key:"_updateProjectionTransition",value:function(){if("globe"===this.getProjection().name){var t,r=this.transform,i=r.projection.name;"globe"===i&&r.zoom>=e.bV?(r.setMercatorFromTransition(),t=!0):"mercator"===i&&r.zoom=e.bV?this.transform.setMercatorFromTransition():this.transform.setProjection(t),this.style.applyProjectionUpdate(),r&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}},{key:"project",value:function(t){return this.transform.locationPoint3D(e.bL.convert(t))}},{key:"unproject",value:function(t){return this.transform.pointLocation3D(e.P.convert(t))}},{key:"isMoving",value:function(){return this._moving||this.handlers&&this.handlers.isMoving()||!1}},{key:"isZooming",value:function(){return this._zooming||this.handlers&&this.handlers.isZooming()||!1}},{key:"isRotating",value:function(){return this._rotating||this.handlers&&this.handlers.isRotating()||!1}},{key:"_isDragging",value:function(){return this.handlers&&this.handlers._isDragging()||!1}},{key:"_createDelegatedListener",value:function(e,t,r){var i=this,n=function(e){var r=[];if(Array.isArray(t)){var n=t.filter((function(e){return i.getLayer(e)}));r=n.length?i.queryRenderedFeatures(e,{layers:n}):[]}else r=i.queryRenderedFeatures(e,{featureset:t});return r};if("mouseenter"===e||"mouseover"===e){var a=!1;return{listener:r,targets:t,delegates:{mousemove:function(t){var o=n(t.point);o.length?a||(a=!0,r.call(i,new hs(e,i,t.originalEvent,{features:o}))):a=!1},mouseout:function(){a=!1}}}}if("mouseleave"===e||"mouseout"===e){var o=!1;return{listener:r,targets:t,delegates:{mousemove:function(t){n(t.point).length?o=!0:o&&(o=!1,r.call(i,new hs(e,i,t.originalEvent)))},mouseout:function(t){o&&(o=!1,r.call(i,new hs(e,i,t.originalEvent)))}}}}return{listener:r,targets:t,delegates:s({},e,(function(e){var t=n(e.point);t.length&&(e.features=t,r.call(i,e),delete e.features)}))}}},{key:"on",value:function(e,t,r){if("function"==typeof t||void 0===r)return k(a,"on",this,3)([e,t]);if("string"==typeof t&&(t=[t]),!this._areTargetsValid(t))return this;var i=this._createDelegatedListener(e,t,r);for(var n in this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(i),i.delegates)this.on(n,i.delegates[n]);return this}},{key:"once",value:function(e,t,r){if("function"==typeof t||void 0===r)return k(a,"once",this,3)([e,t]);if("string"==typeof t&&(t=[t]),!this._areTargetsValid(t))return this;var i=this._createDelegatedListener(e,t,r);for(var n in i.delegates)this.once(n,i.delegates[n]);return this}},{key:"off",value:function(e,t,r){var i=this;if("function"==typeof t||void 0===r)return k(a,"off",this,3)([e,t]);if("string"==typeof t&&(t=[t]),!this._areTargetsValid(t))return this;var n=this._delegatedListeners?this._delegatedListeners[e]:void 0;return n&&(function(e){for(var n=0;n2&&void 0!==arguments[2]?arguments[2]:{},n=i.pixelRatio,a=void 0===n?1:n,o=i.sdf,s=void 0!==o&&o,l=i.stretchX,u=i.stretchY,c=i.content;if(this._lazyInitEmptyStyle(),r instanceof HTMLImageElement||ImageBitmap&&r instanceof ImageBitmap){var h=e.q.getImageData(r),f=h.width,d=h.height,p=h.data;this.style.addImage(t,{data:new e.r({width:f,height:d},p),pixelRatio:a,stretchX:l,stretchY:u,content:c,sdf:s,version:0})}else if(void 0===r.width||void 0===r.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{var m=r.width,v=r.height,_=r;this.style.addImage(t,{data:new e.r({width:m,height:v},new Uint8Array(_.data)),pixelRatio:a,stretchX:l,stretchY:u,content:c,sdf:s,version:0,userImage:_}),_.onAdd&&_.onAdd(this,t)}}},{key:"updateImage",value:function(t,r){this._lazyInitEmptyStyle();var i=this.style.getImage(t);if(i){var n=r instanceof HTMLImageElement||ImageBitmap&&r instanceof ImageBitmap?e.q.getImageData(r):r,a=n.width,o=n.height,s=n.data;if(void 0!==a&&void 0!==o)if(a===i.data.width&&o===i.data.height){var l=!(r instanceof HTMLImageElement||ImageBitmap&&r instanceof ImageBitmap);i.data.replace(s,l),this.style.updateImage(t,i)}else this.fire(new e.t(new Error(`The width and height of the updated image (${a}, ${o})\n must be that same as the previous version of the image\n (${i.data.width}, ${i.data.height})`)));else 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`")))}else 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.")))}},{key:"hasImage",value:function(t){return t?!!this.style&&!!this.style.getImage(t):(this.fire(new e.t(new Error("Missing required image id"))),!1)}},{key:"removeImage",value:function(e){this.style.removeImage(e)}},{key:"loadImage",value:function(t,r){e.o(this._requestManager.transformRequest(t,e.R.Image),(function(t,i){r(t,i instanceof HTMLImageElement?e.q.getImageData(i):i)}))}},{key:"listImages",value:function(){return this.style.listImages()}},{key:"addModel",value:function(e,t){this._lazyInitEmptyStyle(),this.style.addModel(e,t)}},{key:"hasModel",value:function(t){return t?this.style.hasModel(t):(this.fire(new e.t(new Error("Missing required model id"))),!1)}},{key:"removeModel",value:function(e){this.style.removeModel(e)}},{key:"listModels",value:function(){return this.style.listModels()}},{key:"addLayer",value:function(e,t){return this._isValidId(e.id)?(this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)):this}},{key:"getSlot",value:function(e){var t=this.getLayer(e);return t&&t.slot||null}},{key:"setSlot",value:function(e,t){return this.style.setSlot(e,t),this.style.mergeLayers(),this._update(!0)}},{key:"addImport",value:function(e,t){return this.style.addImport(e,t),this}},{key:"updateImport",value:function(e,t){return"string"!=typeof t&&t.id!==e?(this.removeImport(e),this.addImport(t)):(this.style.updateImport(e,t),this._update(!0))}},{key:"removeImport",value:function(e){return this.style.removeImport(e),this}},{key:"moveImport",value:function(e,t){return this.style.moveImport(e,t),this._update(!0)}},{key:"moveLayer",value:function(e,t){return this._isValidId(e)?(this.style.moveLayer(e,t),this._update(!0)):this}},{key:"removeLayer",value:function(e){return this._isValidId(e)?(this.style.removeLayer(e),this._update(!0)):this}},{key:"getLayer",value:function(e){if(!this._isValidId(e))return null;var t=this.style.getOwnLayer(e);return t?"custom"===t.type?t.implementation:t.serialize():void 0}},{key:"getSlots",value:function(){return this.style.getSlots()}},{key:"setLayerZoomRange",value:function(e,t,r){return this._isValidId(e)?(this.style.setLayerZoomRange(e,t,r),this._update(!0)):this}},{key:"setFilter",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this._isValidId(e)?(this.style.setFilter(e,t,r),this._update(!0)):this}},{key:"getFilter",value:function(e){return this._isValidId(e)?this.style.getFilter(e):null}},{key:"setPaintProperty",value:function(e,t,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this._isValidId(e)?(this.style.setPaintProperty(e,t,r,i),this._update(!0)):this}},{key:"getPaintProperty",value:function(e,t){return this._isValidId(e)?this.style.getPaintProperty(e,t):null}},{key:"setLayoutProperty",value:function(e,t,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this._isValidId(e)?(this.style.setLayoutProperty(e,t,r,i),this._update(!0)):this}},{key:"getLayoutProperty",value:function(e,t){return this._isValidId(e)?this.style.getLayoutProperty(e,t):null}},{key:"getSchema",value:function(e){return this.style.getSchema(e)}},{key:"setSchema",value:function(e,t){return this.style.setSchema(e,t),this._update(!0)}},{key:"getConfig",value:function(e){return this.style.getConfig(e)}},{key:"setConfig",value:function(e,t){return this.style.setConfig(e,t),this._update(!0)}},{key:"getConfigProperty",value:function(e,t){return this.style.getConfigProperty(e,t)}},{key:"setConfigProperty",value:function(e,t,r){return this.style.setConfigProperty(e,t,r),this._update(!0)}},{key:"getFeaturesetDescriptors",value:function(e){return this.style.getFeaturesetDescriptors(e)}},{key:"setLights",value:function(e){if(this._lazyInitEmptyStyle(),e&&1===e.length&&"flat"===e[0].type){var 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)}},{key:"getLights",value:function(){var e=this.style.getLights()||[];return 0===e.length&&e.push({id:this.style.light.id,type:"flat",properties:this.style.getFlatLight()}),e}},{key:"setLight",value:function(e){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}])}},{key:"getLight",value:function(){return console.log("The `map.getLight` function is deprecated, prefer using `map.getLights` instead."),this.style.getFlatLight()}},{key:"setTerrain",value:function(e){return this._lazyInitEmptyStyle(),!e&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(e),this._averageElevationLastSampledAt=-1/0,this._update(!0)}},{key:"getTerrain",value:function(){return this.style?this.style.getTerrain():null}},{key:"setFog",value:function(e){return this._lazyInitEmptyStyle(),this.style.setFog(e),this._update(!0)}},{key:"getFog",value:function(){return this.style?this.style.getFog():null}},{key:"setColorTheme",value:function(e){return this._lazyInitEmptyStyle(),this.style.setColorTheme(e),this._update(!0)}},{key:"setCamera",value:function(e){return this.style.setCamera(e),this._triggerCameraUpdate(e)}},{key:"_triggerCameraUpdate",value:function(e){return this._update(this.transform.setOrthographicProjectionAtLowPitch("orthographic"===e["camera-projection"]))}},{key:"getCamera",value:function(){return this.style.camera}},{key:"_queryFogOpacity",value:function(t){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(e.bL.convert(t),this.transform):0}},{key:"setFeatureState",value:function(e,t){return e.source&&!this._isValidId(e.source)?this:(this.style.setFeatureState(e,t),this._update())}},{key:"removeFeatureState",value:function(e,t){return e.source&&!this._isValidId(e.source)?this:(this.style.removeFeatureState(e,t),this._update())}},{key:"getFeatureState",value:function(e){return e.source&&!this._isValidId(e.source)?null:this.style.getFeatureState(e)}},{key:"_updateContainerDimensions",value:function(){if(this._container){for(var e,t,r,i=this._container.getBoundingClientRect().width||400,n=this._container.getBoundingClientRect().height||300,a=this._container;a&&(!t||!r);){var o=window.getComputedStyle(a).transform;o&&"none"!==o&&((e=o.match(/matrix.*\((.+)\)/)[1].split(", "))[0]&&"0"!==e[0]&&"1"!==e[0]&&(t=e[0]),e[3]&&"0"!==e[3]&&"1"!==e[3]&&(r=e[3])),a=a.parentElement}this._containerWidth=t?Math.abs(i/t):i,this._containerHeight=r?Math.abs(n/r):n}}},{key:"_detectMissingCSS",value:function(){"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/.")}},{key:"_setupContainer",value:function(){var e=this._container;e.classList.add("mapboxgl-map"),(this._missingCSSCanary=f("div","mapboxgl-canary",e)).style.visibility="hidden",this._detectMissingCSS();var t=this._canvasContainer=f("div","mapboxgl-canvas-container",e);this._canvas=f("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);var r=this._controlContainer=f("div","mapboxgl-control-container",e),i=this._controlPositions={};["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"].forEach((function(e){i[e]=f("div",`mapboxgl-ctrl-${e}`,r)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}},{key:"_resizeCanvas",value:function(t,r){var i=e.q.devicePixelRatio||1;this._canvas.width=i*Math.ceil(t),this._canvas.height=i*Math.ceil(r),this._canvas.style.width=`${t}px`,this._canvas.style.height=`${r}px`}},{key:"_addMarker",value:function(e){this._markers.push(e)}},{key:"_removeMarker",value:function(e){var t=this._markers.indexOf(e);-1!==t&&this._markers.splice(t,1)}},{key:"_addPopup",value:function(e){this._popups.push(e)}},{key:"_removePopup",value:function(e){var t=this._popups.indexOf(e);-1!==t&&this._popups.splice(t,1)}},{key:"_setupPainter",value:function(){var t=this,r=e.l({},h.supported.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),i=this._canvas.getContext("webgl2",r);i?(ee(i,!0),this.painter=new Qo(i,this._contextCreateOptions,this.transform,this._scaleFactor,this._tp),this.on("data",(function(e){"source"===e.dataType&&t.painter.setTileLoadedFlag(!0)})),e.m.testSupport(i)):this.fire(new e.t(new Error("Failed to initialize WebGL")))}},{key:"_contextLost",value:function(t){t.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new e.x("webglcontextlost",{originalEvent:t}))}},{key:"_contextRestored",value:function(t){this._setupPainter(),this.resize(),this._update(),this.fire(new e.x("webglcontextrestored",{originalEvent:t}))}},{key:"_onMapScroll",value:function(e){if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}},{key:"idle",value:function(){return!this.isMoving()&&this.loaded()}},{key:"loaded",value:function(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}},{key:"frameReady",value:function(){return this.loaded()&&!this._placementDirty}},{key:"_update",value:function(e){return this.style?(this._styleDirty=this._styleDirty||e,this._sourcesDirty=!0,this.triggerRepaint(),this):this}},{key:"_requestRenderFrame",value:function(e){return this._update(),this._renderTaskQueue.add(e)}},{key:"_cancelRenderFrame",value:function(e){this._renderTaskQueue.remove(e)}},{key:"_requestDomTask",value:function(e){!this.loaded()||this.loaded()&&!this.isMoving()?e():this._domRenderTaskQueue.add(e)}},{key:"_render",value:function(t){var n,a=this;this.fire(new e.x("renderstart")),++this._frameId;var o=this.painter.context.extTimerQuery,s=e.q.now(),l=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(n=l.createQuery(),l.beginQuery(o.TIME_ELAPSED_EXT,n)),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){this._updateProjectionTransition();var u=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;var c=this.transform.zoom,h=this.transform.pitch,f=e.q.now(),d=new e.a3(c,{now:f,fadeDuration:u,pitch:h,transition:this.style.transition});this.style.update(d)}this.style&&this.style.hasFogTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);var p=!1;this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),p=this._updateAverageElevation(s),this.style.updateSources(this.transform),this._forceMarkerAndPopupUpdate()):p=this._updateAverageElevation(s);var m=this.style&&this.style._updatePlacement(this.painter,this.painter.transform,this.showCollisionBoxes,u,this._crossSourceCollisions,this.painter.replacementSource,this._scaleFactorChanged);if(this._scaleFactorChanged&&(this._scaleFactorChanged=!1),m&&(this._placementDirty=m.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:u,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,i(r.load),this.fire(new e.x("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),n){var v=e.q.now()-s;l.endQuery(o.TIME_ELAPSED_EXT),setTimeout((function(){var t=l.getQueryParameter(n,l.QUERY_RESULT)/1e6;l.deleteQuery(n),a.fire(new e.x("gpu-timing-frame",{cpuTime:v,gpuTime:t}))}),50)}if(this.listens("gpu-timing-layer")){var _=this.painter.collectGpuTimers();setTimeout((function(){var t=a.painter.queryGpuTimers(_);a.fire(new e.x("gpu-timing-layer",{layerTimes:t}))}),50)}if(this.listens("gpu-timing-deferred-render")){var g=this.painter.collectDeferredRenderGpuQueries();setTimeout((function(){var t=a.painter.queryGpuTimeDeferredRender(g);a.fire(new e.x("gpu-timing-deferred-render",{gpuTime:t}))}),50)}var y=this._sourcesDirty||this._styleDirty||this._placementDirty||p;if(y||this._repaint)this.triggerRepaint();else{var x=this.idle();if(x&&(p=this._updateAverageElevation(s,!0)),p)this.triggerRepaint();else if(this._triggerFrame(!1),x&&(this.fire(new e.x("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){var b=this._calculateSpeedIndex();this.fire(new e.x("speedindexcompleted",{speedIndex:b})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||y||(this._fullyLoaded=!0,i(r.fullLoad),this._performanceMetricsCollection&&Y(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())}}},{key:"_forceMarkerAndPopupUpdate",value:function(e){for(var t of this._markers)e&&!this.getRenderWorldCopies()&&(t._lngLat=t._lngLat.wrap()),t._update();for(var r of this._popups)!e||this.getRenderWorldCopies()||r._trackPointer||(r._lngLat=r._lngLat.wrap()),r._update()}},{key:"_updateAverageElevation",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=function(e){return t.transform.averageElevation=e,t._update(!1),!0};if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&i(0);var n=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(n||(r||e-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(e)){var a=this.transform.averageElevation,o=this.transform.sampleAverageElevation();null!=this.transform.elevation&&(this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(o)?o=0:this._averageElevationLastSampledAt=e;var s=Math.abs(a-o);if(s>1){if(this._isInitialLoad||n)return this._averageElevation.jumpTo(o),i(o);this._averageElevation.easeTo(o,e,300)}else if(s>1e-4)return this._averageElevation.jumpTo(o),i(o)}return!!this._averageElevation.isEasing(e)&&i(this._averageElevation.getValue(e))}},{key:"_authenticate",value:function(){var t=this;K(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(function(r){if(r&&(r.message===L||401===r.status)){var i=t.painter.context.gl;ee(i,!1),t._logoControl instanceof el&&t._logoControl._updateLogo(),i&&i.clear(i.DEPTH_BUFFER_BIT|i.COLOR_BUFFER_BIT|i.STENCIL_BUFFER_BIT),t._silenceAuthErrors||t.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/")))}})),$(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(function(){}))}},{key:"_postStyleLoadEvent",value:function(){this.style.globalId&&W(this._requestManager._customAccessToken,{map:this,skuToken:this._requestManager._skuToken,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()})}},{key:"_updateTerrain",value:function(){var e=this._isDragging();this.painter.updateTerrain(this.style,e)}},{key:"_calculateSpeedIndex",value:function(){var e=this.painter.canvasCopy(),t=this.painter.getCanvasCopiesAndTimestamps();t.timeStamps.push(performance.now());var r=this.painter.context.gl,i=r.createFramebuffer();function n(e){r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,e,0);var t=new Uint8Array(r.drawingBufferWidth*r.drawingBufferHeight*4);return r.readPixels(0,0,r.drawingBufferWidth,r.drawingBufferHeight,r.RGBA,r.UNSIGNED_BYTE,t),t}return r.bindFramebuffer(r.FRAMEBUFFER,i),this._canvasPixelComparison(n(e),t.canvasCopies.map(n),t.timeStamps)}},{key:"_canvasPixelComparison",value:function(e,t,r){for(var i=r[1]-r[0],n=e.length/4,a=0;a0&&void 0!==arguments[0]?arguments[0]:{};p(this,t),this.options=e.l({},ul,i),this._container=f("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",(function(e){return e.preventDefault()})),this.options.showZoom&&(e.aJ(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",(function(e){r._map&&r._map.zoomIn({},{originalEvent:e})})),f("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",(function(e){r._map&&r._map.zoomOut({},{originalEvent:e})})),f("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(e.aJ(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",(function(e){var t=r._map;t&&(r.options.visualizePitch?t.resetNorthPitch({},{originalEvent:e}):t.resetNorth({},{originalEvent:e}))})),this._compassIcon=f("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}),[{key:"_updateZoomButtons",value:function(){var e=this._map;if(e){var t=e.getZoom(),r=t===e.getMaxZoom(),i=t===e.getMinZoom();this._zoomInButton.disabled=r,this._zoomOutButton.disabled=i,this._zoomInButton.setAttribute("aria-disabled",r.toString()),this._zoomOutButton.setAttribute("aria-disabled",i.toString())}}},{key:"_rotateCompassArrow",value:function(){var e=this,t=this._map;if(t){var r=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(t.transform.pitch*(Math.PI/180)),.5)}) rotateX(${t.transform.pitch}deg) rotateZ(${t.transform.angle*(180/Math.PI)}deg)`:`rotate(${t.transform.angle*(180/Math.PI)}deg)`;t._requestDomTask((function(){e._compassIcon&&(e._compassIcon.style.transform=r)}))}}},{key:"onAdd",value:function(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 cl(e,this._compass,this.options.visualizePitch)),this._container}},{key:"onRemove",value:function(){var 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)}},{key:"_createButton",value:function(e,t){var r=f("button",e,this._container);return r.type="button",r.addEventListener("click",t),r}},{key:"_setButtonTitle",value:function(e,t){if(this._map){var r=this._map._getUIString(`NavigationControl.${t}`);e.setAttribute("aria-label",r),e.firstElementChild&&e.firstElementChild.setAttribute("title",r)}}}])})(),GeolocateControl:(function(t){function r(){var t,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};p(this,r),t=T(this,r);var n=navigator.geolocation;return t.options=e.l({geolocation:n},pl,i),e.aJ(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],t),t._updateMarkerRotationThrottled=es(t._updateMarkerRotation,20),t._numberOfWatches=0,t}return g(r,t),m(r,[{key:"onAdd",value:function(e){return this._map=e,this._container=f("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}},{key:"onRemove",value:function(){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}},{key:"_checkGeolocationSupport",value:function(e){var t=this,r=function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:!!t.options.geolocation;t._supportsGeolocation=r,e(r)};void 0!==this._supportsGeolocation?e(this._supportsGeolocation):void 0!==navigator.permissions?navigator.permissions.query({name:"geolocation"}).then((function(e){return r("denied"!==e.state)})).catch((function(){return r()})):r()}},{key:"_isOutOfMapMaxBounds",value:function(e){var t=this._map.getMaxBounds(),r=e.coords;return!!t&&(r.longitudet.getEast()||r.latitudet.getNorth())}},{key:"_setErrorState",value:function(){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")}}},{key:"_onSuccess",value:function(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()}}},{key:"_updateCamera",value:function(t){var r=new e.bL(t.coords.longitude,t.coords.latitude),i=t.coords.accuracy,n=this._map.getBearing(),a=e.l({bearing:n},this.options.fitBoundsOptions);this._map.fitBounds(r.toBounds(i),a,{geolocateSource:!0})}},{key:"_updateMarker",value:function(t){if(t){var r=new e.bL(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(r).addTo(this._map),this._userLocationDotMarker.setLngLat(r).addTo(this._map),this._accuracy=t.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}},{key:"_updateCircleRadius",value:function(){var t=this._map.transform,r=e.bE(1,t._center.lat)*t.worldSize,i=Math.ceil(2*this._accuracy*r);this._circleElement.style.width=`${i}px`,this._circleElement.style.height=`${i}px`}},{key:"_onZoom",value:function(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}},{key:"_updateMarkerRotation",value:function(){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))}},{key:"_onError",value:function(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;var r=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",r),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",r),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()}}},{key:"_finish",value:function(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}},{key:"_setupUI",value:function(t){var r=this;if(void 0!==this._map){if(this._container.addEventListener("contextmenu",(function(e){return e.preventDefault()})),this._geolocateButton=f("button","mapboxgl-ctrl-geolocate",this._container),f("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.");var i=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",i),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",i)}else{var n=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",n),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",n)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=f("div","mapboxgl-user-location"),this._dotElement.appendChild(f("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(f("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new dl({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=f("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new dl({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",(function(t){t.geolocateSource||"ACTIVE_LOCK"!==r._watchState||t.originalEvent&&"resize"===t.originalEvent.type||(r._watchState="BACKGROUND",r._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),r._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),r.fire(new e.x("trackuserlocationend")))}))}}},{key:"_onDeviceOrientation",value:function(e){this._userLocationDotMarker&&(e.webkitCompassHeading?this._heading=e.webkitCompassHeading:!0===e.absolute&&(this._heading=-1*e.alpha),this._updateMarkerRotationThrottled())}},{key:"trigger",value:function(){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){var t;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(t={maximumAge:6e5,timeout:0},this._noTimeout=!0):(t=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,t),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}},{key:"_addDeviceOrientationListener",value:function(){var e=this,t=function(){"ondeviceorientationabsolute"in window?window.addEventListener("deviceorientationabsolute",e._onDeviceOrientation):window.addEventListener("deviceorientation",e._onDeviceOrientation)};"undefined"!=typeof DeviceMotionEvent&&"function"==typeof DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((function(e){"granted"===e&&t()})).catch(console.error):t()}},{key:"_clearWatch",value:function(){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)}}])})(e.E),AttributionControl:Qs,ScaleControl:(function(){return m((function t(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};p(this,t),this.options=e.l({},ml,r),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)}),[{key:"getDefaultPosition",value:function(){return"bottom-left"}},{key:"_update",value:function(){var e=this.options.maxWidth||100,t=this._map,r=t._containerHeight/2,i=t._containerWidth/2-e/2,n=t.unproject([i,r]),a=t.unproject([i+e,r]),o=n.distanceTo(a);if("imperial"===this.options.unit){var s=3.2808*o;s>5280?this._setScale(e,s/5280,"mile"):this._setScale(e,s,"foot")}else"nautical"===this.options.unit?this._setScale(e,o/1852,"nautical-mile"):o>=1e3?this._setScale(e,o/1e3,"kilometer"):this._setScale(e,o,"meter")}},{key:"_setScale",value:function(e,t,r){var i=this;this._map._requestDomTask((function(){var n=(function(e){var t=Math.pow(10,`${Math.floor(e)}`.length-1),r=e/t;return r=r>=10?10:r>=5?5:r>=3?3:r>=2?2:r>=1?1:(function(e){var t=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*t)/t})(r),t*r})(t),a=n/t;i._container.innerHTML=i._isNumberFormatSupported&&"nautical-mile"!==r?new Intl.NumberFormat(i._language,{style:"unit",unitDisplay:"short",unit:r}).format(n):`${n} ${vl[r]}`,i._container.style.width=e*a+"px"}))}},{key:"onAdd",value:function(e){return this._map=e,this._language=e.getLanguage(),this._container=f("div","mapboxgl-ctrl mapboxgl-ctrl-scale",e.getContainer()),this._container.dir="auto",this._map.on("move",this._update),this._update(),this._container}},{key:"onRemove",value:function(){this._container.remove(),this._map.off("move",this._update),this._map=void 0}},{key:"_setLanguage",value:function(e){this._language=e,this._update()}},{key:"setUnit",value:function(e){this.options.unit=e,this._update()}}])})(),FullscreenControl:(function(){return m((function t(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};p(this,t),this._fullscreen=!1,r&&r.container&&(r.container instanceof HTMLElement?this._container=r.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")}),[{key:"onAdd",value:function(t){return this._map=t,this._container||(this._container=this._map.getContainer()),this._controlContainer=f("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}},{key:"onRemove",value:function(){this._controlContainer.remove(),this._map=null,document.removeEventListener(this._fullscreenchange,this._changeIcon)}},{key:"_checkFullscreenSupport",value:function(){return!(!document.fullscreenEnabled&&!document.webkitFullscreenEnabled)}},{key:"_setupUI",value:function(){var e=this._fullscreenButton=f("button","mapboxgl-ctrl-fullscreen",this._controlContainer);f("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)}},{key:"_updateTitle",value:function(){var e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",e)}},{key:"_getTitle",value:function(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}},{key:"_isFullscreen",value:function(){return this._fullscreen}},{key:"_changeIcon",value:function(){(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())}},{key:"_onClickFullscreen",value:function(){this._isFullscreen()?document.exitFullscreen?document.exitFullscreen():document.webkitCancelFullScreen&&document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}}])})(),Popup:(function(t){function r(t){var i;return p(this,r),(i=T(this,r)).options=e.l(Object.create(_l),t),e.aJ(["_update","_onClose","remove","_onMouseEvent"],l(i)),i._classList=new Set(t&&t.className?t.className.trim().split(/\s+/):[]),i}return g(r,t),m(r,[{key:"addTo",value:function(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}},{key:"isOpen",value:function(){return!!this._map}},{key:"remove",value:function(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);var 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}},{key:"getLngLat",value:function(){return this._lngLat}},{key:"setLngLat",value:function(t){this._lngLat=e.bL.convert(t),this._pos=null,this._trackPointer=!1,this._update();var r=this._map;return r&&(r.on("move",this._update),r.off("mousemove",this._onMouseEvent),r._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}},{key:"trackPointer",value:function(){this._trackPointer=!0,this._pos=null,this._update();var 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}},{key:"getElement",value:function(){return this._container}},{key:"setText",value:function(e){return this.setDOMContent(document.createTextNode(e))}},{key:"setHTML",value:function(e){var t,r=document.createDocumentFragment(),i=document.createElement("body");for(i.innerHTML=e;t=i.firstChild;)r.appendChild(t);return this.setDOMContent(r)}},{key:"getMaxWidth",value:function(){return this._container&&this._container.style.maxWidth}},{key:"setMaxWidth",value:function(e){return this.options.maxWidth=e,this._update(),this}},{key:"setDOMContent",value:function(e){var t=this._content;if(t)for(;t.hasChildNodes();)t.firstChild&&t.removeChild(t.firstChild);else t=this._content=f("div","mapboxgl-popup-content",this._container||void 0);if(t.appendChild(e),this.options.closeButton){var r=this._closeButton=f("button","mapboxgl-popup-close-button",t);r.type="button",r.setAttribute("aria-label","Close popup"),r.setAttribute("aria-hidden","true"),r.innerHTML="×",r.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}},{key:"addClassName",value:function(e){return this._classList.add(e),this._updateClassList(),this}},{key:"removeClassName",value:function(e){return this._classList.delete(e),this._updateClassList(),this}},{key:"setOffset",value:function(e){return this.options.offset=e,this._update(),this}},{key:"toggleClassName",value:function(e){var t;return this._classList.delete(e)?t=!1:(this._classList.add(e),t=!0),this._updateClassList(),t}},{key:"_onMouseEvent",value:function(e){this._update(e.point)}},{key:"_getAnchor",value:function(e){if(this.options.anchor)return this.options.anchor;var t=this._map,r=this._container,i=this._pos;if(!t||!r||!i)return"bottom";var n=r.offsetWidth,a=r.offsetHeight,o=i.xt.transform.width-n/2;if(i.y+et.transform.height-a){if(o)return"bottom-left";if(s)return"bottom-right"}return o?"left":s?"right":"bottom"}},{key:"_updateClassList",value:function(){var e=this._container;if(e){var t=d(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(" ")}}},{key:"_update",value:function(t){var r=this,i=this._map,n=this._content;if(i&&(this._lngLat||this._trackPointer)&&n){var a=this._container;if(a||(a=this._container=f("div","mapboxgl-popup",i.getContainer()),this._tip=f("div","mapboxgl-popup-tip",a),a.appendChild(n)),this.options.maxWidth&&a.style.maxWidth!==this.options.maxWidth&&(a.style.maxWidth=this.options.maxWidth),i.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=hl(this._lngLat,this._pos,i.transform)),!this._trackPointer||t){var o=this._pos=this._trackPointer&&t instanceof e.P?t:i.project(this._lngLat),s=yl(this.options.offset),l=this._anchor=this._getAnchor(s.y),u=yl(this.options.offset,l),c=o.add(u).round();i._requestDomTask((function(){r._container&&l&&(r._container.style.transform=`${fl[l]} translate(${c.x}px,${c.y}px)`)}))}if(!this._marker&&i._showingGlobe()){var h=e.dz(i.transform,this._lngLat)?0:1;this._setOpacity(h)}this._updateClassList()}}},{key:"_focusFirstElement",value:function(){if(this.options.focusAfterOpen&&this._container){var e=this._container.querySelector(gl);e&&e.focus()}}},{key:"_onClose",value:function(){this.remove()}},{key:"_setOpacity",value:function(e){this._container&&(this._container.style.opacity=`${e}`),this._content&&(this._content.style.pointerEvents=e?"auto":"none")}}])})(e.E),Marker:dl,Style:Bi,LngLat:e.bL,LngLatBounds:e.as,Point:e.P,MercatorCoordinate:e.a5,FreeCameraOptions:ui,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:function(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 xl})),r}))}),298,[12,115,299,300,158,302,34,105,106,114,116,117,303,280]); __d((function(g,_r,_i,a,m,_e,d){m.exports=function(e,r){if(null==e)return{};var t,o,n=_r(d[0])(e,r);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(o=0;o1&&void 0!==arguments[1]?arguments[1]:21;return function(){for(var o='',i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:t;i--;)o+=n[Math.random()*n.length|0];return o}},e.nanoid=function(){for(var n='',t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:21;t--;)n+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[64*Math.random()|0];return n}}),345,[]); +__d((function(g,r,_i,a,m,e,d){Object.defineProperty(e,"__esModule",{value:!0}),e.nanoid=e.customAlphabet=void 0;e.customAlphabet=function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:21;return function(){for(var o='',i=0|(arguments.length>0&&void 0!==arguments[0]?arguments[0]:t);i--;)o+=n[Math.random()*n.length|0];return o}},e.nanoid=function(){for(var n='',t=0|(arguments.length>0&&void 0!==arguments[0]?arguments[0]:21);t--;)n+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[64*Math.random()|0];return n}}),345,[]); __d((function(g,_r,_i,_a,m,_e,d){var t=_r(d[0]);Object.defineProperty(_e,"__esModule",{value:!0}),_e.DrawerActions=void 0,_e.default=function(t){var o=t.defaultStatus,i=void 0===o?'closed':o,s=(0,r.default)(t,a),c=(0,n.default)(s),f=function(t){var e;return Boolean(null===(e=t.history)||void 0===e?void 0:e.some((function(t){return'drawer'===t.type})))},l=function(t){return f(t)?t:Object.assign({},t,{history:[].concat((0,e.default)(t.history),[{type:'drawer',status:'open'===i?'closed':'open'}])})},p=function(t){return f(t)?Object.assign({},t,{history:t.history.filter((function(t){return'drawer'!==t.type}))}):t},y=function(t){return'open'===i?p(t):l(t)},O=function(t){return'open'===i?l(t):p(t)};return Object.assign({},c,{type:'drawer',getInitialState:function(t){var e=t.routeNames,r=t.routeParamList,n=t.routeGetIdList,a=c.getInitialState({routeNames:e,routeParamList:r,routeGetIdList:n});return Object.assign({},a,{default:i,stale:!1,type:'drawer',key:`drawer-${(0,_r(d[4]).nanoid)()}`})},getRehydratedState:function(t,e){var r=e.routeNames,n=e.routeParamList,a=e.routeGetIdList;if(!1===t.stale)return t;var o=c.getRehydratedState(t,{routeNames:r,routeParamList:n,routeGetIdList:a});return f(t)&&(o=p(o),o=l(o)),Object.assign({},o,{default:i,type:'drawer',key:`drawer-${(0,_r(d[4]).nanoid)()}`})},getStateForRouteFocus:function(t,e){var r=c.getStateForRouteFocus(t,e);return O(r)},getStateForAction:function(t,e,r){switch(e.type){case'OPEN_DRAWER':return y(t);case'CLOSE_DRAWER':return O(t);case'TOGGLE_DRAWER':return f(t)?p(t):l(t);case'JUMP_TO':case'NAVIGATE':var n=c.getStateForAction(t,e,r);return null!=n&&n.index!==t.index?O(n):n;case'GO_BACK':return f(t)?p(t):c.getStateForAction(t,e,r);default:return c.getStateForAction(t,e,r)}},actionCreators:u})};var e=t(_r(d[1])),r=t(_r(d[2])),n=(function(t,e){if(!e&&t&&t.__esModule)return t;if(null===t||"object"!=typeof t&&"function"!=typeof t)return{default:t};var r=o(e);if(r&&r.has(t))return r.get(t);var n={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var u in t)if("default"!==u&&{}.hasOwnProperty.call(t,u)){var i=a?Object.getOwnPropertyDescriptor(t,u):null;i&&(i.get||i.set)?Object.defineProperty(n,u,i):n[u]=t[u]}return n.default=t,r&&r.set(t,n),n})(_r(d[3])),a=["defaultStatus"];function o(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,r=new WeakMap;return(o=function(t){return t?r:e})(t)}var u=_e.DrawerActions=Object.assign({},n.TabActions,{openDrawer:function(){return{type:'OPEN_DRAWER'}},closeDrawer:function(){return{type:'CLOSE_DRAWER'}},toggleDrawer:function(){return{type:'TOGGLE_DRAWER'}}})}),346,[1,34,299,347,345]); __d((function(g,_r,_i,a,m,e,d){var t=_r(d[0]);Object.defineProperty(e,"__esModule",{value:!0}),e.TabActions=void 0,e.default=function(t){var r=t.initialRouteName,s=t.backBehavior,y=void 0===s?'firstRoute':s;return Object.assign({},n.default,{type:'tab',getInitialState:function(t){var n=t.routeNames,i=t.routeParamList,u=void 0!==r&&n.includes(r)?n.indexOf(r):0,s=n.map((function(t){return{name:t,key:`${t}-${(0,_r(d[2]).nanoid)()}`,params:i[t]}})),c=o(s,u,y,r);return{stale:!1,type:'tab',key:`tab-${(0,_r(d[2]).nanoid)()}`,index:u,routeNames:n,history:c,routes:s}},getRehydratedState:function(t,n){var i,o,s,c,l=n.routeNames,f=n.routeParamList,p=t;if(!1===p.stale)return p;var h=l.map((function(t){var n=p.routes.find((function(n){return n.name===t}));return Object.assign({},n,{name:t,key:n&&n.name===t&&n.key?n.key:`${t}-${(0,_r(d[2]).nanoid)()}`,params:void 0!==f[t]?Object.assign({},f[t],n?n.params:void 0):n?n.params:void 0})})),v=Math.min(Math.max(l.indexOf(null===(s=p.routes[null!=(i=null==p?void 0:p.index)?i:0])||void 0===s?void 0:s.name),0),h.length-1),k=null!=(o=null===(c=p.history)||void 0===c?void 0:c.filter((function(t){return h.find((function(n){return n.key===t.key}))})))?o:[];return u({stale:!1,type:'tab',key:`tab-${(0,_r(d[2]).nanoid)()}`,index:v,routeNames:l,history:k,routes:h},v,y,r)},getStateForRouteNamesChange:function(t,n){var i=n.routeNames,u=n.routeParamList,s=n.routeKeyChanges,c=i.map((function(n){return t.routes.find((function(t){return t.name===n&&!s.includes(t.name)}))||{name:n,key:`${n}-${(0,_r(d[2]).nanoid)()}`,params:u[n]}})),l=Math.max(0,i.indexOf(t.routes[t.index].name)),f=t.history.filter((function(t){return'route'!==t.type||c.find((function(n){return n.key===t.key}))}));return f.length||(f=o(c,l,y,r)),Object.assign({},t,{history:f,routeNames:i,routes:c,index:l})},getStateForRouteFocus:function(t,n){var i=t.routes.findIndex((function(t){return t.key===n}));return-1===i||i===t.index?t:u(t,i,y,r)},getStateForAction:function(t,i,o){var s=o.routeParamList,c=o.routeGetIdList;switch(i.type){case'JUMP_TO':case'NAVIGATE':var l=-1;return-1===(l='NAVIGATE'===i.type&&i.payload.key?t.routes.findIndex((function(t){return t.key===i.payload.key})):t.routes.findIndex((function(t){return t.name===i.payload.name})))?null:u(Object.assign({},t,{routes:t.routes.map((function(t,n){if(n!==l)return t;var r,o=c[t.name],u=null==o?void 0:o({params:t.params}),y=null==o?void 0:o({params:i.payload.params}),f=u===y?t.key:`${t.name}-${(0,_r(d[2]).nanoid)()}`;r='NAVIGATE'===i.type&&i.payload.merge&&u===y?void 0!==i.payload.params||void 0!==s[t.name]?Object.assign({},s[t.name],t.params,i.payload.params):t.params:void 0!==s[t.name]?Object.assign({},s[t.name],i.payload.params):i.payload.params;var p='NAVIGATE'===i.type&&null!=i.payload.path?i.payload.path:t.path;return r!==t.params||p!==t.path?Object.assign({},t,{key:f,path:p,params:r}):t}))}),l,y,r);case'GO_BACK':if(1===t.history.length)return null;var f=t.history[t.history.length-2].key,p=t.routes.findIndex((function(t){return t.key===f}));return-1===p?null:Object.assign({},t,{history:t.history.slice(0,-1),index:p});default:return n.default.getStateForAction(t,i)}},shouldActionChangeFocus:function(t){return'NAVIGATE'===t.type},actionCreators:i})};var n=t(_r(d[1])),r='route',i=e.TabActions={jumpTo:function(t,n){return{type:'JUMP_TO',payload:{name:t,params:n}}}},o=function(t,n,i,o){var u,s=[{type:r,key:t[n].key}];switch(i){case'order':for(var y=n;y>0;y--)s.unshift({type:r,key:t[y-1].key});break;case'firstRoute':0!==n&&s.unshift({type:r,key:t[0].key});break;case'initialRoute':n!==(u=-1===(u=t.findIndex((function(t){return t.name===o})))?0:u)&&s.unshift({type:r,key:t[u].key})}return s},u=function(t,n,i,u){var s;if('history'===i){var y=t.routes[n].key;s=t.history.filter((function(t){return'route'===t.type&&t.key!==y})).concat({type:r,key:y})}else s=o(t.routes,n,i,u);return Object.assign({},t,{index:n,history:s})}}),347,[1,344,345]); __d((function(g,_r,_i,a,m,e,d){var t=_r(d[0]);Object.defineProperty(e,"__esModule",{value:!0}),e.StackActions=void 0,e.default=function(t){var i=Object.assign({},o.default,{type:'stack',getInitialState:function(n){var o=n.routeNames,r=n.routeParamList,i=void 0!==t.initialRouteName&&o.includes(t.initialRouteName)?t.initialRouteName:o[0];return{stale:!1,type:'stack',key:`stack-${(0,_r(d[3]).nanoid)()}`,index:0,routeNames:o,routes:[{key:`${i}-${(0,_r(d[3]).nanoid)()}`,name:i,params:r[i]}]}},getRehydratedState:function(n,o){var r=o.routeNames,i=o.routeParamList,s=n;if(!1===s.stale)return s;var u=s.routes.filter((function(t){return r.includes(t.name)})).map((function(t){return Object.assign({},t,{key:t.key||`${t.name}-${(0,_r(d[3]).nanoid)()}`,params:void 0!==i[t.name]?Object.assign({},i[t.name],t.params):t.params})}));if(0===u.length){var l=void 0!==t.initialRouteName?t.initialRouteName:r[0];u.push({key:`${l}-${(0,_r(d[3]).nanoid)()}`,name:l,params:i[l]})}return{stale:!1,type:'stack',key:`stack-${(0,_r(d[3]).nanoid)()}`,index:u.length-1,routeNames:r,routes:u}},getStateForRouteNamesChange:function(n,o){var r=o.routeNames,i=o.routeParamList,s=o.routeKeyChanges,u=n.routes.filter((function(t){return r.includes(t.name)&&!s.includes(t.name)}));if(0===u.length){var l=void 0!==t.initialRouteName&&r.includes(t.initialRouteName)?t.initialRouteName:r[0];u.push({key:`${l}-${(0,_r(d[3]).nanoid)()}`,name:l,params:i[l]})}return Object.assign({},n,{routeNames:r,routes:u,index:Math.min(n.index,u.length-1)})},getStateForRouteFocus:function(t,n){var o=t.routes.findIndex((function(t){return t.key===n}));return-1===o||o===t.index?t:Object.assign({},t,{index:o,routes:t.routes.slice(0,o+1)})},getStateForAction:function(t,r,s){var u=s.routeParamList;switch(r.type){case'REPLACE':var l=r.target===t.key&&r.source?t.routes.findIndex((function(t){return t.key===r.source})):t.index;if(-1===l)return null;var p=r.payload,y=p.name,c=p.key,f=p.params;return t.routeNames.includes(y)?Object.assign({},t,{routes:t.routes.map((function(t,n){return n===l?{key:void 0!==c?c:`${y}-${(0,_r(d[3]).nanoid)()}`,name:y,params:void 0!==u[y]?Object.assign({},u[y],f):f}:t}))}):null;case'PUSH':if(t.routeNames.includes(r.payload.name)){var v,k=s.routeGetIdList[r.payload.name],O=null==k?void 0:k({params:r.payload.params}),h=O?t.routes.find((function(t){return t.name===r.payload.name&&O===(null==k?void 0:k({params:t.params}))})):void 0;return h?(v=t.routes.filter((function(t){return t.key!==h.key}))).push(Object.assign({},h,{params:void 0!==u[r.payload.name]?Object.assign({},u[r.payload.name],r.payload.params):r.payload.params})):v=[].concat((0,n.default)(t.routes),[{key:`${r.payload.name}-${(0,_r(d[3]).nanoid)()}`,name:r.payload.name,params:void 0!==u[r.payload.name]?Object.assign({},u[r.payload.name],r.payload.params):r.payload.params}]),Object.assign({},t,{index:v.length-1,routes:v})}return null;case'POP':var P=r.target===t.key&&r.source?t.routes.findIndex((function(t){return t.key===r.source})):t.index;if(P>0){var x=Math.max(P-r.payload.count+1,1),b=t.routes.slice(0,x).concat(t.routes.slice(P+1));return Object.assign({},t,{index:b.length-1,routes:b})}return null;case'POP_TO_TOP':return i.getStateForAction(t,{type:'POP',payload:{count:t.routes.length-1}},s);case'NAVIGATE':if(void 0!==r.payload.name&&!t.routeNames.includes(r.payload.name))return null;if(r.payload.key||r.payload.name){var j,N=-1,$=void 0===r.payload.key&&void 0!==r.payload.name?s.routeGetIdList[r.payload.name]:void 0,R=null==$?void 0:$({params:r.payload.params});if(R)N=t.routes.findIndex((function(t){return t.name===r.payload.name&&R===(null==$?void 0:$({params:t.params}))}));else if(t.routes[t.index].name===r.payload.name&&void 0===r.payload.key||t.routes[t.index].key===r.payload.key)N=t.index;else for(var S=t.routes.length-1;S>=0;S--)if(t.routes[S].name===r.payload.name&&void 0===r.payload.key||t.routes[S].key===r.payload.key){N=S;break}if(-1===N&&r.payload.key&&void 0===r.payload.name)return null;if(-1===N&&void 0!==r.payload.name){var A,_=[].concat((0,n.default)(t.routes),[{key:null!=(A=r.payload.key)?A:`${r.payload.name}-${(0,_r(d[3]).nanoid)()}`,name:r.payload.name,path:r.payload.path,params:void 0!==u[r.payload.name]?Object.assign({},u[r.payload.name],r.payload.params):r.payload.params}]);return Object.assign({},t,{routes:_,index:_.length-1})}var I,L=t.routes[N];return I=r.payload.merge?void 0!==r.payload.params||void 0!==u[L.name]?Object.assign({},u[L.name],L.params,r.payload.params):L.params:void 0!==u[L.name]?Object.assign({},u[L.name],r.payload.params):r.payload.params,Object.assign({},t,{index:N,routes:[].concat((0,n.default)(t.routes.slice(0,N)),[I!==L.params||r.payload.path&&r.payload.path!==L.path?Object.assign({},L,{path:null!=(j=r.payload.path)?j:L.path,params:I}):t.routes[N]])})}return null;case'GO_BACK':return t.index>0?i.getStateForAction(t,{type:'POP',payload:{count:1},target:r.target,source:r.source},s):null;default:return o.default.getStateForAction(t,r)}},actionCreators:r});return i};var n=t(_r(d[1])),o=t(_r(d[2])),r=e.StackActions={replace:function(t,n){return{type:'REPLACE',payload:{name:t,params:n}}},push:function(t,n){return{type:'PUSH',payload:{name:t,params:n}}},pop:function(){return{type:'POP',payload:{count:arguments.length>0&&void 0!==arguments[0]?arguments[0]:1}}},popToTop:function(){return{type:'POP_TO_TOP'}}}}),348,[1,34,344,345]); diff --git a/static/example-app/index.html b/static/example-app/index.html index caacde6..986f0ac 100644 --- a/static/example-app/index.html +++ b/static/example-app/index.html @@ -32,6 +32,6 @@
- +